staging: unisys: Don't check for null before getting driver device.
authorDavid Kershner <david.kershner@unisys.com>
Wed, 30 Aug 2017 17:36:17 +0000 (13:36 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Aug 2017 16:17:39 +0000 (18:17 +0200)
The macro to convert to the driver object was giving a checkpatch warning
when it ateempted to check for a null driver. It would return NULL if it
found it, but only one location was checking to see if it was NULL.

Remove the check in the MACRO and do it prior to calling the macro if
required.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/include/visorbus.h
drivers/staging/unisys/visorbus/visorbus_main.c

index e97bb5ffb0dd7e7ffd49e6bdacdba1477f75df21..0af54774d7b5e4f472c4f83089cbcbc5e2a0e7a7 100644 (file)
@@ -104,8 +104,7 @@ struct visor_driver {
        struct device_driver driver;
 };
 
-#define to_visor_driver(x) ((x) ? \
-       (container_of(x, struct visor_driver, driver)) : (NULL))
+#define to_visor_driver(x) (container_of(x, struct visor_driver, driver))
 
 /**
  * struct visor_device - A device type for things "plugged" into the visorbus
index 05b632e972411230d3590677a401690724d849c0..0957eaa247c48939fb46f62a9c20723721997776 100644 (file)
@@ -1158,13 +1158,13 @@ static int visorchipset_initiate_device_pause_resume(struct visor_device *dev,
        int err;
        struct visor_driver *drv = NULL;
 
-       drv = to_visor_driver(dev->device.driver);
-       if (!drv)
-               return -ENODEV;
-
+       /* If no driver associated with the device nothing to pause/resume */
+       if (!dev->device.driver)
+               return 0;
        if (dev->pausing || dev->resuming)
                return -EBUSY;
 
+       drv = to_visor_driver(dev->device.driver);
        if (is_pause) {
                dev->pausing = true;
                err = drv->pause(dev, pause_state_change_complete);