[SRU OEM-B][PATCH 04/10] serdev: Make .remove in struct serdev_device_driver optional

Shrirang Bagul shrirang.bagul at canonical.com
Mon May 7 10:56:33 UTC 2018


From: Andrey Smirnov <andrew.smirnov at gmail.com>

BugLink: http://bugs.launchpad.net/bugs/1769610

Using devres infrastructure it is possible to write a serdev driver
that doesn't have any code that needs to be called as a part of
.remove. Add code to make .remove optional.

Acked-by: Philippe Ombredanne <pombredanne at nexb.com>
Acked-by: Pavel Machek <pavel at ucw.cz>
Acked-by: Rob Herring <robh at kernel.org>
Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>
Reviewed-by: Guenter Roeck <linux at roeck-us.net>
Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
Signed-off-by: Lee Jones <lee.jones at linaro.org>
(cherry picked from commit c5ff7de262b6e92ec88a20ea0a0244c29ccdc764)
Signed-off-by: Shrirang Bagul <shrirang.bagul at canonical.com>
---
 drivers/tty/serdev/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 571ce1f69d8d..4504e195fdbe 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -273,8 +273,8 @@ static int serdev_drv_probe(struct device *dev)
 static int serdev_drv_remove(struct device *dev)
 {
 	const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
-
-	sdrv->remove(to_serdev_device(dev));
+	if (sdrv->remove)
+		sdrv->remove(to_serdev_device(dev));
 	return 0;
 }
 
-- 
2.14.1





More information about the kernel-team mailing list