Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1 1/2] mei: bus: simplify mei_cl_device_remove()
@ 2021-02-07 22:22 Uwe Kleine-König
  2021-02-07 22:22 ` [PATCH v1 2/2] mei: bus: change remove callback to return void Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2021-02-07 22:22 UTC (permalink / raw)
  To: Tomas Winkler, Arnd Bergmann, Greg Kroah-Hartman,
	Wim Van Sebroeck, Guenter Roeck
  Cc: linux-kernel, netdev, linux-watchdog

The driver core only calls a bus' remove function when there is actually
a driver and a device. So drop the needless check and assign cldrv earlier.

(Side note: The check for cldev being non-NULL is broken anyhow, because
to_mei_cl_device() is a wrapper around container_of() for a member that is
not the first one. So cldev only can become NULL if dev is (void *)0xc
(for archs with 32 bit pointers) or (void *)0x18 (for archs with 64 bit
pointers).)

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
 drivers/misc/mei/bus.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 2907db260fba..50d617e7467e 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -878,13 +878,9 @@ static int mei_cl_device_probe(struct device *dev)
 static int mei_cl_device_remove(struct device *dev)
 {
 	struct mei_cl_device *cldev = to_mei_cl_device(dev);
-	struct mei_cl_driver *cldrv;
+	struct mei_cl_driver *cldrv = to_mei_cl_driver(dev->driver);
 	int ret = 0;
 
-	if (!cldev || !dev->driver)
-		return 0;
-
-	cldrv = to_mei_cl_driver(dev->driver);
 	if (cldrv->remove)
 		ret = cldrv->remove(cldev);
 

base-commit: 5c8fe583cce542aa0b84adc939ce85293de36e5e
-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 22:22 [PATCH v1 1/2] mei: bus: simplify mei_cl_device_remove() Uwe Kleine-König
2021-02-07 22:22 ` [PATCH v1 2/2] mei: bus: change remove callback to return void Uwe Kleine-König
2021-02-07 23:48   ` Guenter Roeck
2021-02-08  0:16   ` kernel test robot
2021-02-08  0:16   ` kernel test robot
2021-02-08  0:17   ` kernel test robot

Linux-Watchdog Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-watchdog/0 linux-watchdog/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-watchdog linux-watchdog/ https://lore.kernel.org/linux-watchdog \
		linux-watchdog@vger.kernel.org
	public-inbox-index linux-watchdog

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-watchdog


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git