diff options
author | Frank Rowand <frank.rowand@sony.com> | 2017-10-17 19:36:22 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2017-10-17 21:46:15 -0400 |
commit | bbed8794d53b7043d7989e22bc2e1e399da305eb (patch) | |
tree | 3a268571f05b0c7482986afd0d441578be92acb3 | |
parent | 646afc4ad7f01d582d00e43a4f35b1ebdb70cb4e (diff) |
of: overlay.c: Convert comparisons to zero or NULL to logical expressions
Use normal shorthand for comparing a variable to zero.
For variable "XXX":
convert (XXX == 0) to (!XXX)
convert (XXX != 0) to (XXX)
Signed-off-by: Frank Rowand <frank.rowand@sony.com>
Signed-off-by: Rob Herring <robh@kernel.org>
-rw-r--r-- | drivers/of/overlay.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index a42dd7b094c4..d3f4a5974a11 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c | |||
@@ -169,9 +169,9 @@ static int of_overlay_apply_single_property(struct of_overlay *ov, | |||
169 | 169 | ||
170 | tprop = of_find_property(target, prop->name, NULL); | 170 | tprop = of_find_property(target, prop->name, NULL); |
171 | 171 | ||
172 | if (of_prop_cmp(prop->name, "name") == 0 || | 172 | if (!of_prop_cmp(prop->name, "name") || |
173 | of_prop_cmp(prop->name, "phandle") == 0 || | 173 | !of_prop_cmp(prop->name, "phandle") || |
174 | of_prop_cmp(prop->name, "linux,phandle") == 0) | 174 | !of_prop_cmp(prop->name, "linux,phandle")) |
175 | return 0; | 175 | return 0; |
176 | 176 | ||
177 | if (is_symbols_node) { | 177 | if (is_symbols_node) { |
@@ -182,10 +182,10 @@ static int of_overlay_apply_single_property(struct of_overlay *ov, | |||
182 | propn = __of_prop_dup(prop, GFP_KERNEL); | 182 | propn = __of_prop_dup(prop, GFP_KERNEL); |
183 | } | 183 | } |
184 | 184 | ||
185 | if (propn == NULL) | 185 | if (!propn) |
186 | return -ENOMEM; | 186 | return -ENOMEM; |
187 | 187 | ||
188 | if (tprop == NULL) | 188 | if (!tprop) |
189 | ret = of_changeset_add_property(&ov->cset, target, propn); | 189 | ret = of_changeset_add_property(&ov->cset, target, propn); |
190 | else | 190 | else |
191 | ret = of_changeset_update_property(&ov->cset, target, propn); | 191 | ret = of_changeset_update_property(&ov->cset, target, propn); |
@@ -206,14 +206,14 @@ static int of_overlay_apply_single_device_node(struct of_overlay *ov, | |||
206 | int ret = 0; | 206 | int ret = 0; |
207 | 207 | ||
208 | cname = kbasename(child->full_name); | 208 | cname = kbasename(child->full_name); |
209 | if (cname == NULL) | 209 | if (!cname) |
210 | return -ENOMEM; | 210 | return -ENOMEM; |
211 | 211 | ||
212 | for_each_child_of_node(target, tchild) | 212 | for_each_child_of_node(target, tchild) |
213 | if (!of_node_cmp(cname, kbasename(tchild->full_name))) | 213 | if (!of_node_cmp(cname, kbasename(tchild->full_name))) |
214 | break; | 214 | break; |
215 | 215 | ||
216 | if (tchild != NULL) { | 216 | if (tchild) { |
217 | if (child->phandle) | 217 | if (child->phandle) |
218 | return -EINVAL; | 218 | return -EINVAL; |
219 | 219 | ||
@@ -271,7 +271,7 @@ static int of_overlay_apply_one(struct of_overlay *ov, | |||
271 | 271 | ||
272 | for_each_child_of_node(overlay, child) { | 272 | for_each_child_of_node(overlay, child) { |
273 | ret = of_overlay_apply_single_device_node(ov, target, child); | 273 | ret = of_overlay_apply_single_device_node(ov, target, child); |
274 | if (ret != 0) { | 274 | if (ret) { |
275 | pr_err("Failed to apply single node @%pOF/%s\n", | 275 | pr_err("Failed to apply single node @%pOF/%s\n", |
276 | target, child->name); | 276 | target, child->name); |
277 | of_node_put(child); | 277 | of_node_put(child); |
@@ -300,7 +300,7 @@ static int of_overlay_apply(struct of_overlay *ov) | |||
300 | 300 | ||
301 | err = of_overlay_apply_one(ov, ovinfo->target, ovinfo->overlay, | 301 | err = of_overlay_apply_one(ov, ovinfo->target, ovinfo->overlay, |
302 | ovinfo->is_symbols_node); | 302 | ovinfo->is_symbols_node); |
303 | if (err != 0) { | 303 | if (err) { |
304 | pr_err("apply failed '%pOF'\n", ovinfo->target); | 304 | pr_err("apply failed '%pOF'\n", ovinfo->target); |
305 | return err; | 305 | return err; |
306 | } | 306 | } |
@@ -323,11 +323,11 @@ static struct device_node *find_target_node(struct device_node *info_node) | |||
323 | int ret; | 323 | int ret; |
324 | 324 | ||
325 | ret = of_property_read_u32(info_node, "target", &val); | 325 | ret = of_property_read_u32(info_node, "target", &val); |
326 | if (ret == 0) | 326 | if (!ret) |
327 | return of_find_node_by_phandle(val); | 327 | return of_find_node_by_phandle(val); |
328 | 328 | ||
329 | ret = of_property_read_string(info_node, "target-path", &path); | 329 | ret = of_property_read_string(info_node, "target-path", &path); |
330 | if (ret == 0) | 330 | if (!ret) |
331 | return of_find_node_by_path(path); | 331 | return of_find_node_by_path(path); |
332 | 332 | ||
333 | pr_err("Failed to find target for node %p (%s)\n", | 333 | pr_err("Failed to find target for node %p (%s)\n", |
@@ -354,11 +354,11 @@ static int of_fill_overlay_info(struct of_overlay *ov, | |||
354 | struct device_node *info_node, struct of_overlay_info *ovinfo) | 354 | struct device_node *info_node, struct of_overlay_info *ovinfo) |
355 | { | 355 | { |
356 | ovinfo->overlay = of_get_child_by_name(info_node, "__overlay__"); | 356 | ovinfo->overlay = of_get_child_by_name(info_node, "__overlay__"); |
357 | if (ovinfo->overlay == NULL) | 357 | if (!ovinfo->overlay) |
358 | goto err_fail; | 358 | goto err_fail; |
359 | 359 | ||
360 | ovinfo->target = find_target_node(info_node); | 360 | ovinfo->target = find_target_node(info_node); |
361 | if (ovinfo->target == NULL) | 361 | if (!ovinfo->target) |
362 | goto err_fail; | 362 | goto err_fail; |
363 | 363 | ||
364 | return 0; | 364 | return 0; |
@@ -398,13 +398,13 @@ static int of_build_overlay_info(struct of_overlay *ov, | |||
398 | cnt++; | 398 | cnt++; |
399 | 399 | ||
400 | ovinfo = kcalloc(cnt, sizeof(*ovinfo), GFP_KERNEL); | 400 | ovinfo = kcalloc(cnt, sizeof(*ovinfo), GFP_KERNEL); |
401 | if (ovinfo == NULL) | 401 | if (!ovinfo) |
402 | return -ENOMEM; | 402 | return -ENOMEM; |
403 | 403 | ||
404 | cnt = 0; | 404 | cnt = 0; |
405 | for_each_child_of_node(tree, node) { | 405 | for_each_child_of_node(tree, node) { |
406 | err = of_fill_overlay_info(ov, node, &ovinfo[cnt]); | 406 | err = of_fill_overlay_info(ov, node, &ovinfo[cnt]); |
407 | if (err == 0) | 407 | if (!err) |
408 | cnt++; | 408 | cnt++; |
409 | } | 409 | } |
410 | 410 | ||
@@ -422,7 +422,7 @@ static int of_build_overlay_info(struct of_overlay *ov, | |||
422 | cnt++; | 422 | cnt++; |
423 | } | 423 | } |
424 | 424 | ||
425 | if (cnt == 0) { | 425 | if (!cnt) { |
426 | kfree(ovinfo); | 426 | kfree(ovinfo); |
427 | return -ENODEV; | 427 | return -ENODEV; |
428 | } | 428 | } |
@@ -478,7 +478,7 @@ int of_overlay_create(struct device_node *tree) | |||
478 | int err, id; | 478 | int err, id; |
479 | 479 | ||
480 | ov = kzalloc(sizeof(*ov), GFP_KERNEL); | 480 | ov = kzalloc(sizeof(*ov), GFP_KERNEL); |
481 | if (ov == NULL) | 481 | if (!ov) |
482 | return -ENOMEM; | 482 | return -ENOMEM; |
483 | ov->id = -1; | 483 | ov->id = -1; |
484 | 484 | ||
@@ -629,7 +629,7 @@ int of_overlay_destroy(int id) | |||
629 | mutex_lock(&of_mutex); | 629 | mutex_lock(&of_mutex); |
630 | 630 | ||
631 | ov = idr_find(&ov_idr, id); | 631 | ov = idr_find(&ov_idr, id); |
632 | if (ov == NULL) { | 632 | if (!ov) { |
633 | err = -ENODEV; | 633 | err = -ENODEV; |
634 | pr_err("destroy: Could not find overlay #%d\n", id); | 634 | pr_err("destroy: Could not find overlay #%d\n", id); |
635 | goto out; | 635 | goto out; |