linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [CFT 1/29] Add bus_type probe, remove, shutdown methods.
@ 2006-01-05 14:29 Russell King
  2006-01-05 14:30 ` [CFT 2/29] Add pci_bus_type probe and remove methods Russell King
                   ` (32 more replies)
  0 siblings, 33 replies; 47+ messages in thread
From: Russell King @ 2006-01-05 14:29 UTC (permalink / raw)
  To: LKML; +Cc: Greg K-H

Add bus_type probe, remove and shutdown methods to replace the
corresponding methods in struct device_driver.  This matches
the way we handle the suspend/resume methods.

Since the bus methods override the device_driver methods, warn
if a device driver is registered whose methods will not be
called.

The long-term idea is to remove the device_driver methods entirely.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

---
 drivers/base/driver.c         |    5 +++++
 drivers/base/dd.c             |   12 ++++++++++--
 drivers/base/power/shutdown.c |    5 ++++-
 include/linux/device.h        |    3 +++
 4 files changed, 22 insertions(+), 3 deletions(-)

diff -up -x BitKeeper -x ChangeSet -x SCCS -x _xlk -x '*.orig' -x '*.rej' -x .git -r linus/drivers/base/dd.c linux/drivers/base/dd.c
--- linus/drivers/base/dd.c	Fri Sep 23 07:03:13 2005
+++ linux/drivers/base/dd.c	Sun Nov 13 14:02:19 2005
@@ -77,7 +77,13 @@ int driver_probe_device(struct device_dr
 	pr_debug("%s: Matched Device %s with Driver %s\n",
 		 drv->bus->name, dev->bus_id, drv->name);
 	dev->driver = drv;
-	if (drv->probe) {
+	if (dev->bus->probe) {
+		ret = dev->bus->probe(dev);
+		if (ret) {
+			dev->driver = NULL;
+			goto ProbeFailed;
+		}
+	} else if (drv->probe) {
 		ret = drv->probe(dev);
 		if (ret) {
 			dev->driver = NULL;
@@ -194,7 +200,9 @@ static void __device_release_driver(stru
 		sysfs_remove_link(&dev->kobj, "driver");
 		klist_remove(&dev->knode_driver);
 
-		if (drv->remove)
+		if (dev->bus->remove)
+			dev->bus->remove(dev);
+		else if (drv->remove)
 			drv->remove(dev);
 		dev->driver = NULL;
 		put_driver(drv);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -171,6 +171,11 @@ static void klist_devices_put(struct kli
  */
 int driver_register(struct device_driver * drv)
 {
+	if ((drv->bus->probe && drv->probe) ||
+	    (drv->bus->remove && drv->remove) ||
+	    (drv->bus->shutdown && drv->shutdown)) {
+		printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name);
+	}
 	klist_init(&drv->klist_devices, klist_devices_get, klist_devices_put);
 	init_completion(&drv->unloaded);
 	return bus_add_driver(drv);
diff -up -x BitKeeper -x ChangeSet -x SCCS -x _xlk -x '*.orig' -x '*.rej' -x .git -r linus/drivers/base/power/shutdown.c linux/drivers/base/power/shutdown.c
--- linus/drivers/base/power/shutdown.c	Sun Nov  6 22:15:23 2005
+++ linux/drivers/base/power/shutdown.c	Sun Nov 13 14:03:05 2005
@@ -40,7 +40,10 @@ void device_shutdown(void)
 	down_write(&devices_subsys.rwsem);
 	list_for_each_entry_reverse(dev, &devices_subsys.kset.list,
 				kobj.entry) {
-		if (dev->driver && dev->driver->shutdown) {
+		if (dev->bus && dev->bus->shutdown) {
+			dev_dbg(dev, "shutdown\n");
+			dev->bus->shutdown(dev);
+		} else if (dev->driver && dev->driver->shutdown) {
 			dev_dbg(dev, "shutdown\n");
 			dev->driver->shutdown(dev);
 		}
diff -up -x BitKeeper -x ChangeSet -x SCCS -x _xlk -x *.orig -x *.rej -x .git -r linus/include/linux/device.h linux/include/linux/device.h
--- linus/include/linux/device.h	Sun Nov  6 22:20:07 2005
+++ linux/include/linux/device.h	Sun Nov 13 13:58:17 2005
@@ -49,6 +49,9 @@ struct bus_type {
 	int		(*match)(struct device * dev, struct device_driver * drv);
 	int		(*hotplug) (struct device *dev, char **envp, 
 				    int num_envp, char *buffer, int buffer_size);
+	int		(*probe)(struct device * dev);
+	int		(*remove)(struct device * dev);
+	void		(*shutdown)(struct device * dev);
 	int		(*suspend)(struct device * dev, pm_message_t state);
 	int		(*resume)(struct device * dev);
 };

^ permalink raw reply	[flat|nested] 47+ messages in thread
* [PATCH] Add bttv sub bus_type probe and remove methods
@ 2006-01-13 19:50 Greg KH
  2006-01-13 19:50 ` [PATCH] Add {css,ccw}_bus_type probe, remove, shutdown methods Greg KH
  0 siblings, 1 reply; 47+ messages in thread
From: Greg KH @ 2006-01-13 19:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: rmk

[PATCH] Add bttv sub bus_type probe and remove methods

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit 348290a4ae143a692124330942b464ccdb0d0365
tree 1fae9909d4d4519c9548b5940be2dca7e31935c2
parent d78967fb035aeb839a047ae69ce5f1ff39288a8d
author Russell King <rmk@arm.linux.org.uk> Fri, 06 Jan 2006 11:42:03 +0000
committer Greg Kroah-Hartman <gregkh@suse.de> Fri, 13 Jan 2006 11:26:11 -0800

 drivers/media/dvb/bt8xx/dvb-bt8xx.c |   23 +++++++++++------------
 drivers/media/video/bttv-gpio.c     |   24 ++++++++++++++++++++++--
 drivers/media/video/bttv.h          |    2 ++
 3 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index f65f64b..44fcbe7 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -779,9 +779,8 @@ static int __init dvb_bt8xx_load_card(st
 	return 0;
 }
 
-static int dvb_bt8xx_probe(struct device *dev)
+static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
 {
-	struct bttv_sub_device *sub = to_bttv_sub_dev(dev);
 	struct dvb_bt8xx_card *card;
 	struct pci_dev* bttv_pci_dev;
 	int ret;
@@ -890,13 +889,13 @@ static int dvb_bt8xx_probe(struct device
 		return ret;
 	}
 
-	dev_set_drvdata(dev, card);
+	dev_set_drvdata(&sub->dev, card);
 	return 0;
 }
 
-static int dvb_bt8xx_remove(struct device *dev)
+static int dvb_bt8xx_remove(struct bttv_sub_device *sub)
 {
-	struct dvb_bt8xx_card *card = dev_get_drvdata(dev);
+	struct dvb_bt8xx_card *card = dev_get_drvdata(&sub->dev);
 
 	dprintk("dvb_bt8xx: unloading card%d\n", card->bttv_nr);
 
@@ -919,14 +918,14 @@ static int dvb_bt8xx_remove(struct devic
 static struct bttv_sub_driver driver = {
 	.drv = {
 		.name		= "dvb-bt8xx",
-		.probe		= dvb_bt8xx_probe,
-		.remove		= dvb_bt8xx_remove,
-		/* FIXME:
-		 * .shutdown	= dvb_bt8xx_shutdown,
-		 * .suspend	= dvb_bt8xx_suspend,
-		 * .resume	= dvb_bt8xx_resume,
-		 */
 	},
+	.probe		= dvb_bt8xx_probe,
+	.remove		= dvb_bt8xx_remove,
+	/* FIXME:
+	 * .shutdown	= dvb_bt8xx_shutdown,
+	 * .suspend	= dvb_bt8xx_suspend,
+	 * .resume	= dvb_bt8xx_resume,
+	 */
 };
 
 static int __init dvb_bt8xx_init(void)
diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c
index d64accc..c4d5e2b 100644
--- a/drivers/media/video/bttv-gpio.c
+++ b/drivers/media/video/bttv-gpio.c
@@ -47,9 +47,29 @@ static int bttv_sub_bus_match(struct dev
 	return 0;
 }
 
+static int bttv_sub_probe(struct device *dev)
+{
+	struct bttv_sub_device *sdev = to_bttv_sub_dev(dev);
+	struct bttv_sub_driver *sub = to_bttv_sub_drv(dev->driver);
+
+	return sub->probe ? sub->probe(sdev) : -ENODEV;
+}
+
+static int bttv_sub_remove(struct device *dev)
+{
+	struct bttv_sub_device *sdev = to_bttv_sub_dev(dev);
+	struct bttv_sub_driver *sub = to_bttv_sub_drv(dev->driver);
+
+	if (sub->remove)
+		sub->remove(sdev);
+	return 0;
+}
+
 struct bus_type bttv_sub_bus_type = {
-	.name  = "bttv-sub",
-	.match = &bttv_sub_bus_match,
+	.name   = "bttv-sub",
+	.match  = &bttv_sub_bus_match,
+	.probe  = bttv_sub_probe,
+	.remove = bttv_sub_remove,
 };
 EXPORT_SYMBOL(bttv_sub_bus_type);
 
diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h
index e370d74..9908c8e 100644
--- a/drivers/media/video/bttv.h
+++ b/drivers/media/video/bttv.h
@@ -365,6 +365,8 @@ struct bttv_sub_device {
 struct bttv_sub_driver {
 	struct device_driver   drv;
 	char                   wanted[BUS_ID_SIZE];
+	int                    (*probe)(struct bttv_sub_device *sub);
+	void                   (*remove)(struct bttv_sub_device *sub);
 	void                   (*gpio_irq)(struct bttv_sub_device *sub);
 };
 #define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)


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

end of thread, other threads:[~2006-01-13 19:50 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-05 14:29 [CFT 1/29] Add bus_type probe, remove, shutdown methods Russell King
2006-01-05 14:30 ` [CFT 2/29] Add pci_bus_type probe and remove methods Russell King
2006-01-05 14:30 ` [CFT 3/29] Add ecard_bus_type probe/remove/shutdown methods Russell King
2006-01-05 14:31 ` [CFT 4/29] " Russell King
2006-01-05 14:32 ` [CFT 5/29] Add AMBA bus_type " Russell King
2006-01-05 14:32 ` [CFT 6/29] Add SA1111 bus_type probe/remove methods Russell King
2006-01-05 14:33 ` [CFT 7/29] Add locomo " Russell King
2006-01-05 15:35   ` Richard Purdie
2006-01-05 14:33 ` [CFT 8/29] Add logic module " Russell King
2006-01-05 14:34 ` [CFT 9/29] Add tiocx " Russell King
2006-01-12  9:45   ` Paul Jackson
2006-01-12 10:31     ` Paul Jackson
2006-01-05 14:34 ` [CFT 10/29] Add parisc_bus_type probe and remove methods Russell King
2006-01-05 18:46   ` [parisc-linux] " Matthew Wilcox
2006-01-05 14:35 ` [CFT 11/29] Add ocp_bus_type " Russell King
2006-01-05 14:35 ` [CFT 12/29] Add sh_bus_type " Russell King
2006-01-05 14:36 ` [CFT 13/29] Add of_platform_bus_type " Russell King
2006-01-05 14:36 ` [CFT 14/29] Add vio_bus_type " Russell King
2006-01-05 14:37 ` [CFT 15/29] Add dio_bus_type " Russell King
2006-01-05 14:37 ` [CFT 16/29] Add i2c_bus_type " Russell King
2006-01-05 14:38 ` [CFT 17/29] Add gameport bus_type " Russell King
2006-01-05 14:38 ` [CFT 18/29] Add serio " Russell King
2006-01-05 14:39 ` [CFT 19/29] Add macio_bus_type " Russell King
2006-01-05 14:39 ` [CFT 20/29] Add MCP bus_type " Russell King
2006-01-05 14:40 ` [CFT 21/29] Add mmc_bus_type " Russell King
2006-01-05 14:40 ` [CFT 22/29] Add pcmcia_bus_type " Russell King
2006-01-05 14:41 ` [CFT 23/29] Add pnp_bus_type " Russell King
2006-01-05 14:42 ` [CFT 24/29] Add ccwgroup_bus_type " Russell King
2006-01-05 14:42 ` [CFT 25/29] Add superhyway_bus_type " Russell King
2006-01-05 14:43 ` [CFT 26/29] Add usb_serial_bus_type " Russell King
2006-01-05 14:43 ` [CFT 27/29] Add zorro_bus_type " Russell King
2006-01-05 14:44 ` [CFT 28/29] Add rio_bus_type " Russell King
2006-01-05 14:44 ` [CFT 29/29] Add Pseudo LLD bus_type " Russell King
2006-01-05 23:07 ` [CFT 1/29] Add bus_type probe, remove, shutdown methods Greg KH
2006-01-05 23:24   ` Russell King
2006-01-06  0:44     ` Greg KH
2006-01-06 11:41 ` [CFT 1/3] Add ide_bus_type probe and remove methods Russell King
2006-01-11 15:01   ` Bartlomiej Zolnierkiewicz
2006-01-06 11:41 ` [CFT 2/3] Remove usb gadget generic driver methods Russell King
2006-01-06 11:42 ` [CFT 3/3] Add bttv sub bus_type probe and remove methods Russell King
2006-01-10 15:05   ` Michael Krufky
2006-01-06 11:48 ` [CFT 1/29] Add bus_type probe, remove, shutdown methods Russell King
2006-01-06 13:38   ` Cornelia Huck
2006-01-11  9:56     ` [PATCH] Add {css,ccw}_bus_type " Cornelia Huck
2006-01-06 16:34   ` [CFT 1/29] Add bus_type " James Bottomley
2006-01-06 16:57     ` Russell King
2006-01-13 19:50 [PATCH] Add bttv sub bus_type probe and remove methods Greg KH
2006-01-13 19:50 ` [PATCH] Add {css,ccw}_bus_type probe, remove, shutdown methods Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).