staging: unisys: visorbus: add checks for probe, remove, pause and resume in visorbus...
authorSameer Wadgaonkar <sameer.wadgaonkar@unisys.com>
Mon, 17 Jul 2017 20:16:59 +0000 (16:16 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Jul 2017 06:48:41 +0000 (08:48 +0200)
Added checks for functions probe, remove, pause and resume in
visorbus_register_visor_driver() and removed these checks from
the individual functions itself.

Signed-off-by: Sameer Wadgaonkar <sameer.wadgaonkar@unisys.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: David Binder <david.binder@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorbus_main.c

index 57f59cb487ae4da3c8e27f1b8286e21861fc93bc..48490545add93ba2e3c4577c0243f7f531f6a244 100644 (file)
@@ -490,8 +490,7 @@ static int visordriver_remove_device(struct device *xdev)
 
        mutex_lock(&dev->visordriver_callback_lock);
        dev->being_removed = true;
-       if (drv->remove)
-               drv->remove(dev);
+       drv->remove(dev);
        mutex_unlock(&dev->visordriver_callback_lock);
 
        dev_stop_periodic_work(dev);
@@ -868,8 +867,6 @@ static int visordriver_probe_device(struct device *xdev)
 
        dev = to_visor_device(xdev);
        drv = to_visor_driver(xdev->driver);
-       if (!drv->probe)
-               return -ENODEV;
 
        mutex_lock(&dev->visordriver_callback_lock);
        dev->being_removed = false;
@@ -940,6 +937,18 @@ int visorbus_register_visor_driver(struct visor_driver *drv)
        if (!initialized)
                return -ENODEV;
 
+       if (!drv->probe)
+               return -ENODEV;
+
+       if (!drv->remove)
+               return -ENODEV;
+
+       if (!drv->pause)
+               return -ENODEV;
+
+       if (!drv->resume)
+               return -ENODEV;
+
        drv->driver.name = drv->name;
        drv->driver.bus = &visorbus_type;
        drv->driver.probe = visordriver_probe_device;
@@ -1158,9 +1167,6 @@ static int visorchipset_initiate_device_pause_resume(struct visor_device *dev,
                return -EBUSY;
 
        if (is_pause) {
-               if (!drv->pause)
-                       return -EINVAL;
-
                dev->pausing = true;
                err = drv->pause(dev, pause_state_change_complete);
        } else {
@@ -1169,8 +1175,6 @@ static int visorchipset_initiate_device_pause_resume(struct visor_device *dev,
                 * make sure it is valid.
                 */
                fix_vbus_dev_info(dev);
-               if (!drv->resume)
-                       return -EINVAL;
 
                dev->resuming = true;
                err = drv->resume(dev, resume_state_change_complete);