Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mei: bus: simplify mei_cl_device_remove()

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>
Link: https://lore.kernel.org/r/20210208073705.428185-2-uwe@kleine-koenig.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Uwe Kleine-König and committed by
Greg Kroah-Hartman
f320ff03 369aea84

+1 -5
+1 -5
drivers/misc/mei/bus.c
··· 880 880 static int mei_cl_device_remove(struct device *dev) 881 881 { 882 882 struct mei_cl_device *cldev = to_mei_cl_device(dev); 883 - struct mei_cl_driver *cldrv; 883 + struct mei_cl_driver *cldrv = to_mei_cl_driver(dev->driver); 884 884 int ret = 0; 885 885 886 - if (!cldev || !dev->driver) 887 - return 0; 888 - 889 - cldrv = to_mei_cl_driver(dev->driver); 890 886 if (cldrv->remove) 891 887 ret = cldrv->remove(cldev); 892 888