mei: remove unnecessary NULL pointer checks
Subsystems (2)
cover mei: remove unnecessary NULL pointer checks
From: Bjorn Helgaas <[email protected]>
After .probe() has returned success, drvdata has been set to a non-NULL value, so there's no need to check for NULL in other callbacks.
Bjorn Helgaas (3):
mei: gsc: remove unnecessary NULL pointer checks
mei: txe: remove unnecessary NULL pointer checks
mei: me: remove unnecessary NULL pointer checks
drivers/misc/mei/gsc-me.c | 17 ---------------- drivers/misc/mei/pci-me.c | 38 ++++++------------------------------ drivers/misc/mei/pci-txe.c | 40 ++++++-------------------------------- 3 files changed, 12 insertions(+), 83 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 mei: gsc: remove unnecessary NULL pointer checks
From: Bjorn Helgaas <[email protected]>
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.
--- drivers/misc/mei/gsc-me.c | 17 ----------------- 1 file changed, 17 deletions(-)
drivers/misc/mei/gsc-me.c +0 -17
@@ -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);
Signature · 1 line
2.34.1
PATCH 2/3 mei: txe: remove unnecessary NULL pointer checks
In reply to Bjorn HelgaasFrom: Bjorn Helgaas <[email protected]>
The .shutdown(), .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.
--- drivers/misc/mei/pci-txe.c | 40 ++++++-------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-)
drivers/misc/mei/pci-txe.c +6 -34
@@ -166,11 +166,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)*/ static void mei_txe_shutdown (struct pci_dev *pdev) { -struct mei_device *dev; - - dev =pci_get_drvdata (pdev); -if (!dev) -return ; +struct mei_device *dev =pci_get_drvdata (pdev);dev_dbg (&pdev->dev,"shutdown\n" );mei_stop (dev);
@@ -191,13 +187,7 @@ static void mei_txe_shutdown(struct pci_dev *pdev)*/ static void mei_txe_remove (struct pci_dev *pdev) { -struct mei_device *dev; - - dev =pci_get_drvdata (pdev); -if (!dev) { -dev_err (&pdev->dev,"mei: dev == NULL\n" ); -return ; - } +struct mei_device *dev =pci_get_drvdata (pdev);pm_runtime_get_noresume (&pdev->dev);
@@ -218,9 +208,6 @@ static int mei_txe_pci_suspend(struct device *device)struct pci_dev *pdev =to_pci_dev (device);struct mei_device *dev =pci_get_drvdata (pdev); -if (!dev) -return -ENODEV ; -dev_dbg (&pdev->dev,"suspend\n" );mei_stop (dev);
@@ -236,13 +223,9 @@ static int mei_txe_pci_suspend(struct device *device)static int mei_txe_pci_resume (struct device *device) {struct pci_dev *pdev =to_pci_dev (device); -struct mei_device *dev; +struct mei_device *dev =pci_get_drvdata (pdev);int err; - dev =pci_get_drvdata (pdev); -if (!dev) -return -ENODEV ; -pci_enable_msi (pdev);mei_clear_interrupts (dev);
@@ -273,13 +256,10 @@ static int mei_txe_pci_resume(struct device *device)#ifdef CONFIG_PM static int mei_txe_pm_runtime_idle (struct device *device) { -struct mei_device *dev; +struct mei_device *dev =dev_get_drvdata (device);dev_dbg (device,"rpm: txe: runtime_idle\n" ); - dev =dev_get_drvdata (device); -if (!dev) -return -ENODEV ;if (mei_write_is_idle (dev))pm_runtime_autosuspend (device);
@@ -287,15 +267,11 @@ static int mei_txe_pm_runtime_idle(struct device *device) }static int mei_txe_pm_runtime_suspend (struct device *device) { -struct mei_device *dev; +struct mei_device *dev =dev_get_drvdata (device);int ret;dev_dbg (device,"rpm: txe: runtime suspend\n" ); - dev =dev_get_drvdata (device); -if (!dev) -return -ENODEV ; -mutex_lock (&dev->device_lock);if (mei_write_is_idle (dev))
@@ -317,15 +293,11 @@ static int mei_txe_pm_runtime_suspend(struct device *device)static int mei_txe_pm_runtime_resume (struct device *device) { -struct mei_device *dev; +struct mei_device *dev =dev_get_drvdata (device);int ret;dev_dbg (device,"rpm: txe: runtime resume\n" ); - dev =dev_get_drvdata (device); -if (!dev) -return -ENODEV ; -mutex_lock (&dev->device_lock);mei_enable_interrupts (dev);
Signature · 1 line
2.34.1
PATCH 3/3 mei: me: remove unnecessary NULL pointer checks
In reply to Bjorn HelgaasFrom: Bjorn Helgaas <[email protected]>
The .shutdown(), .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.
--- drivers/misc/mei/pci-me.c | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-)
drivers/misc/mei/pci-me.c +6 -32
@@ -295,11 +295,7 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)*/ static void mei_me_shutdown (struct pci_dev *pdev) { -struct mei_device *dev; - - dev =pci_get_drvdata (pdev); -if (!dev) -return ; +struct mei_device *dev =pci_get_drvdata (pdev);dev_dbg (&pdev->dev,"shutdown\n" );mei_stop (dev);
@@ -320,11 +316,7 @@ static void mei_me_shutdown(struct pci_dev *pdev)*/ static void mei_me_remove (struct pci_dev *pdev) { -struct mei_device *dev; - - dev =pci_get_drvdata (pdev); -if (!dev) -return ; +struct mei_device *dev =pci_get_drvdata (pdev);if (mei_pg_is_enabled (dev))pm_runtime_get_noresume (&pdev->dev);
@@ -353,9 +345,6 @@ static int mei_me_pci_suspend(struct device *device)struct pci_dev *pdev =to_pci_dev (device);struct mei_device *dev =pci_get_drvdata (pdev); -if (!dev) -return -ENODEV ; -dev_dbg (&pdev->dev,"suspend\n" );mei_stop (dev);
@@ -371,14 +360,10 @@ static int mei_me_pci_suspend(struct device *device)static int mei_me_pci_resume (struct device *device) {struct pci_dev *pdev =to_pci_dev (device); -struct mei_device *dev; +struct mei_device *dev =pci_get_drvdata (pdev);unsigned int irqflags;int err; - dev =pci_get_drvdata (pdev); -if (!dev) -return -ENODEV ; -pci_enable_msi (pdev); irqflags =pci_dev_msi_enabled (pdev) ?IRQF_ONESHOT :IRQF_SHARED ;
@@ -419,13 +404,10 @@ static void mei_me_pci_complete(struct device *device)#ifdef CONFIG_PM static int mei_me_pm_runtime_idle (struct device *device) { -struct mei_device *dev; +struct mei_device *dev =dev_get_drvdata (device);dev_dbg (device,"rpm: me: runtime_idle\n" ); - dev =dev_get_drvdata (device); -if (!dev) -return -ENODEV ;if (mei_write_is_idle (dev))pm_runtime_autosuspend (device);
@@ -434,15 +416,11 @@ static int mei_me_pm_runtime_idle(struct device *device)static int mei_me_pm_runtime_suspend (struct device *device) { -struct mei_device *dev; +struct mei_device *dev =dev_get_drvdata (device);int ret;dev_dbg (device,"rpm: me: runtime suspend\n" ); - dev =dev_get_drvdata (device); -if (!dev) -return -ENODEV ; -mutex_lock (&dev->device_lock);if (mei_write_is_idle (dev))
@@ -462,15 +440,11 @@ static int mei_me_pm_runtime_suspend(struct device *device)static int mei_me_pm_runtime_resume (struct device *device) { -struct mei_device *dev; +struct mei_device *dev =dev_get_drvdata (device);int ret;dev_dbg (device,"rpm: me: runtime resume\n" ); - dev =dev_get_drvdata (device); -if (!dev) -return -ENODEV ; -mutex_lock (&dev->device_lock); ret =mei_me_pg_exit_sync (dev);
Signature · 1 line
2.34.1