Skip to content

Commit 807508c

Browse files
enomsggregkh
authored andcommitted
base/platform: Simplifications for NULL platform data/resources handling
There's no need to explicitly check for data and resources being NULL, as platform_device_add_{data,resources}() do this internally nowadays. This makes the code more linear and less indented. Signed-off-by: Anton Vorontsov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5cfc64c commit 807508c

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

drivers/base/platform.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -380,17 +380,13 @@ struct platform_device *__init_or_module platform_device_register_resndata(
380380

381381
pdev->dev.parent = parent;
382382

383-
if (res) {
384-
ret = platform_device_add_resources(pdev, res, num);
385-
if (ret)
386-
goto err;
387-
}
383+
ret = platform_device_add_resources(pdev, res, num);
384+
if (ret)
385+
goto err;
388386

389-
if (data) {
390-
ret = platform_device_add_data(pdev, data, size);
391-
if (ret)
392-
goto err;
393-
}
387+
ret = platform_device_add_data(pdev, data, size);
388+
if (ret)
389+
goto err;
394390

395391
ret = platform_device_add(pdev);
396392
if (ret) {
@@ -537,17 +533,13 @@ struct platform_device * __init_or_module platform_create_bundle(
537533
goto err_out;
538534
}
539535

540-
if (res) {
541-
error = platform_device_add_resources(pdev, res, n_res);
542-
if (error)
543-
goto err_pdev_put;
544-
}
536+
error = platform_device_add_resources(pdev, res, n_res);
537+
if (error)
538+
goto err_pdev_put;
545539

546-
if (data) {
547-
error = platform_device_add_data(pdev, data, size);
548-
if (error)
549-
goto err_pdev_put;
550-
}
540+
error = platform_device_add_data(pdev, data, size);
541+
if (error)
542+
goto err_pdev_put;
551543

552544
error = platform_device_add(pdev);
553545
if (error)

0 commit comments

Comments
 (0)