Skip to content

Commit

Permalink
ARM: cleanup: soc_device_register() error checking
Browse files Browse the repository at this point in the history
soc_device_register() never returns NULL, it only ever returns an
error pointer or a valid pointer.  Use the right function (IS_ERR())
to check this.

soc_device_to_device() only ever returns &soc_dev->dev, and so can
never return an error or NULL if the pointer passed into it was
valid, so there's no point checking its return.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King committed Feb 24, 2013
1 parent f6604ef commit b269b17
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions arch/arm/mach-integrator/integrator_ap.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,16 +540,14 @@ static void __init ap_init_of(void)
'A' + (ap_sc_id & 0x0f));

soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR_OR_NULL(soc_dev)) {
if (IS_ERR(soc_dev)) {
kfree(soc_dev_attr->revision);
kfree(soc_dev_attr);
return;
}

parent = soc_device_to_device(soc_dev);

if (!IS_ERR_OR_NULL(parent))
integrator_init_sysfs(parent, ap_sc_id);
integrator_init_sysfs(parent, ap_sc_id);

of_platform_populate(root, of_default_bus_match_table,
ap_auxdata_lookup, parent);
Expand Down
7 changes: 2 additions & 5 deletions arch/arm/mach-integrator/integrator_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,14 @@ static void __init intcp_init_of(void)
'A' + (intcp_sc_id & 0x0f));

soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR_OR_NULL(soc_dev)) {
if (IS_ERR(soc_dev)) {
kfree(soc_dev_attr->revision);
kfree(soc_dev_attr);
return;
}

parent = soc_device_to_device(soc_dev);

if (!IS_ERR_OR_NULL(parent))
integrator_init_sysfs(parent, intcp_sc_id);

integrator_init_sysfs(parent, intcp_sc_id);
of_platform_populate(root, of_default_bus_match_table,
intcp_auxdata_lookup, parent);
}
Expand Down
5 changes: 2 additions & 3 deletions arch/arm/mach-ux500/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,13 @@ struct device * __init ux500_soc_device_init(const char *soc_id)
soc_info_populate(soc_dev_attr, soc_id);

soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR_OR_NULL(soc_dev)) {
if (IS_ERR(soc_dev)) {
kfree(soc_dev_attr);
return NULL;
}

parent = soc_device_to_device(soc_dev);
if (!IS_ERR_OR_NULL(parent))
device_create_file(parent, &ux500_soc_attr);
device_create_file(parent, &ux500_soc_attr);

return parent;
}

0 comments on commit b269b17

Please sign in to comment.