mei: gsc: remove unnecessary NULL pointer checks
authorBjorn Helgaas <bhelgaas@google.com>
Thu, 29 Feb 2024 18:12:58 +0000 (12:12 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Mar 2024 14:28:02 +0000 (14:28 +0000)
The .remove() and power management callbacks are never called unless
.probe() has already returned success, which means it has set drvdata to a
non-NULL pointer, so "dev" can never be NULL in the other callbacks.

Remove the unnecessary checks.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20240229181300.352077-2-helgaas@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/gsc-me.c

index 9e558ec2ea1d5cef1aee7fb386ef59703f2d1ca4..5a8c26c3df13da4c3fc5dfc93d1685e3220bae4c 100644 (file)
@@ -144,9 +144,6 @@ static void mei_gsc_remove(struct auxiliary_device *aux_dev)
        struct mei_me_hw *hw;
 
        dev = dev_get_drvdata(&aux_dev->dev);
-       if (!dev)
-               return;
-
        hw = to_me_hw(dev);
 
        mei_stop(dev);
@@ -168,9 +165,6 @@ static int __maybe_unused mei_gsc_pm_suspend(struct device *device)
 {
        struct mei_device *dev = dev_get_drvdata(device);
 
-       if (!dev)
-               return -ENODEV;
-
        mei_stop(dev);
 
        mei_disable_interrupts(dev);
@@ -186,9 +180,6 @@ static int __maybe_unused mei_gsc_pm_resume(struct device *device)
        int err;
        struct mei_me_hw *hw;
 
-       if (!dev)
-               return -ENODEV;
-
        hw = to_me_hw(dev);
        aux_dev = to_auxiliary_dev(device);
        adev = auxiliary_dev_to_mei_aux_dev(aux_dev);
@@ -211,8 +202,6 @@ static int __maybe_unused mei_gsc_pm_runtime_idle(struct device *device)
 {
        struct mei_device *dev = dev_get_drvdata(device);
 
-       if (!dev)
-               return -ENODEV;
        if (mei_write_is_idle(dev))
                pm_runtime_autosuspend(device);
 
@@ -225,9 +214,6 @@ static int  __maybe_unused mei_gsc_pm_runtime_suspend(struct device *device)
        struct mei_me_hw *hw;
        int ret;
 
-       if (!dev)
-               return -ENODEV;
-
        mutex_lock(&dev->device_lock);
 
        if (mei_write_is_idle(dev)) {
@@ -252,9 +238,6 @@ static int __maybe_unused mei_gsc_pm_runtime_resume(struct device *device)
        struct mei_me_hw *hw;
        irqreturn_t irq_ret;
 
-       if (!dev)
-               return -ENODEV;
-
        mutex_lock(&dev->device_lock);
 
        hw = to_me_hw(dev);