Skip to content

Commit

Permalink
base/platform: Simplifications for NULL platform data/resources handling
Browse files Browse the repository at this point in the history
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 <cbouatmailru@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Anton Vorontsov authored and Greg Kroah-Hartman committed Oct 22, 2010
1 parent 5cfc64c commit 807508c
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,13 @@ struct platform_device *__init_or_module platform_device_register_resndata(

pdev->dev.parent = parent;

if (res) {
ret = platform_device_add_resources(pdev, res, num);
if (ret)
goto err;
}
ret = platform_device_add_resources(pdev, res, num);
if (ret)
goto err;

if (data) {
ret = platform_device_add_data(pdev, data, size);
if (ret)
goto err;
}
ret = platform_device_add_data(pdev, data, size);
if (ret)
goto err;

ret = platform_device_add(pdev);
if (ret) {
Expand Down Expand Up @@ -537,17 +533,13 @@ struct platform_device * __init_or_module platform_create_bundle(
goto err_out;
}

if (res) {
error = platform_device_add_resources(pdev, res, n_res);
if (error)
goto err_pdev_put;
}
error = platform_device_add_resources(pdev, res, n_res);
if (error)
goto err_pdev_put;

if (data) {
error = platform_device_add_data(pdev, data, size);
if (error)
goto err_pdev_put;
}
error = platform_device_add_data(pdev, data, size);
if (error)
goto err_pdev_put;

error = platform_device_add(pdev);
if (error)
Expand Down

0 comments on commit 807508c

Please sign in to comment.