ARM: cleanup: OMAP hwmod error checking
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 24 Feb 2013 10:56:59 +0000 (10:56 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 24 Feb 2013 10:56:59 +0000 (10:56 +0000)
omap_hwmod_lookup() only returns NULL on error, never an error pointer.
Checking the returned pointer using IS_ERR_OR_NULL() is needless
overhead.  Use a simple !ptr check instead.

OMAP devices (oh->od) always have a valid platform device attached (see
omap_device_alloc()) so there's no point validating the platform device
pointer (we will have already oopsed long before if this is not the
case here.)

Lastly, oh->od is only ever NULL or a valid omap device pointer - 'oh'
comes from the statically declared hwmod tables, and the pointer is
only filled in by omap_device_alloc() at a point where the omap device
pointer must be valid.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-omap2/omap_device.c

index e065daa537c07bd8c8946d394d9ab60c0b120c3b..fabb32d047d9c36b48187bdf15cc56c902c6e5f1 100644 (file)
@@ -1157,20 +1157,17 @@ struct device *omap_device_get_by_hwmod_name(const char *oh_name)
        }
 
        oh = omap_hwmod_lookup(oh_name);
-       if (IS_ERR_OR_NULL(oh)) {
+       if (!oh) {
                WARN(1, "%s: no hwmod for %s\n", __func__,
                        oh_name);
-               return ERR_PTR(oh ? PTR_ERR(oh) : -ENODEV);
+               return -ENODEV;
        }
-       if (IS_ERR_OR_NULL(oh->od)) {
+       if (!oh->od) {
                WARN(1, "%s: no omap_device for %s\n", __func__,
                        oh_name);
-               return ERR_PTR(oh->od ? PTR_ERR(oh->od) : -ENODEV);
+               return -ENODEV;
        }
 
-       if (IS_ERR_OR_NULL(oh->od->pdev))
-               return ERR_PTR(oh->od->pdev ? PTR_ERR(oh->od->pdev) : -ENODEV);
-
        return &oh->od->pdev->dev;
 }
 EXPORT_SYMBOL(omap_device_get_by_hwmod_name);