public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/28] drivers/base/platform.c: Drop return value from platform_driver remove functions
@ 2008-12-10 16:26 Julia Lawall
  2008-12-10 16:38 ` Alan Cox
  2008-12-10 17:28 ` Mike Frysinger
  0 siblings, 2 replies; 14+ messages in thread
From: Julia Lawall @ 2008-12-10 16:26 UTC (permalink / raw)
  To: dmitri.vorobiev, gregkh, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

The return value of the remove function of a driver structure, and thus of
a platform_driver structure, is ultimately ignored, and is thus
unnecessary.  The goal of this patch is to make it possible to convert the
platform_driver functions stored in the remove field such that they return
void.  This patch introduces a temporary field remove_new with return type
void into the platform_driver structure, and updates the only place that
the remove function is called to call the function in the remove_new field,
if one is available.  The subsequent patches update some drivers to use the
remove_new field.

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/base/platform.c         |   16 ++++++++++++++--
 include/linux/platform_device.h |    1 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 4b8cc6a..4800110 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -50,6 +50,7 @@ extern void platform_device_put(struct platform_device *pdev);
 struct platform_driver {
 	int (*probe)(struct platform_device *);
 	int (*remove)(struct platform_device *);
+	void (*remove_new)(struct platform_device *);
 	void (*shutdown)(struct platform_device *);
 	int (*suspend)(struct platform_device *, pm_message_t state);
 	int (*suspend_late)(struct platform_device *, pm_message_t state);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index dfcbfe5..2d7b26a 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -459,7 +459,12 @@ static int platform_drv_remove(struct device *_dev)
 	struct platform_driver *drv = to_platform_driver(_dev->driver);
 	struct platform_device *dev = to_platform_device(_dev);
 
-	return drv->remove(dev);
+	if (drv->remove)
+		drv->remove(dev);
+	else
+		drv->remove_new(dev);
+
+	return 0;
 }
 
 static void platform_drv_shutdown(struct device *_dev)
@@ -492,10 +497,17 @@ static int platform_drv_resume(struct device *_dev)
  */
 int platform_driver_register(struct platform_driver *drv)
 {
+	if (drv->remove && drv->remove_new) {
+		printk(KERN_ERR "only one of remove() and "
+				"remove_new() callbacks can be defined, "
+				"aborting...\n");
+		return -EINVAL;
+	}
+
 	drv->driver.bus = &platform_bus_type;
 	if (drv->probe)
 		drv->driver.probe = platform_drv_probe;
-	if (drv->remove)
+	if (drv->remove || drv->remove_new)
 		drv->driver.remove = platform_drv_remove;
 	if (drv->shutdown)
 		drv->driver.shutdown = platform_drv_shutdown;

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

end of thread, other threads:[~2008-12-17 21:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-10 16:26 [PATCH 1/28] drivers/base/platform.c: Drop return value from platform_driver remove functions Julia Lawall
2008-12-10 16:38 ` Alan Cox
2008-12-10 18:03   ` Vorobiev Dmitri
2008-12-10 21:26     ` Anton Vorontsov
2008-12-10 22:06       ` Vorobiev Dmitri
2008-12-10 22:48         ` Anton Vorontsov
2008-12-10 17:28 ` Mike Frysinger
2008-12-10 22:18   ` Vorobiev Dmitri
2008-12-10 22:37     ` Mike Frysinger
2008-12-12  5:17       ` Greg KH
2008-12-12 11:00         ` Dmitri Vorobiev
2008-12-17 21:38           ` Greg KH
2008-12-12 21:00         ` Mike Frysinger
2008-12-17 21:37           ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox