public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BKPATCH] bus notifiers for the generic device model
@ 2002-12-04 17:09 James Bottomley
  2002-12-04 17:56 ` Greg KH
  0 siblings, 1 reply; 15+ messages in thread
From: James Bottomley @ 2002-12-04 17:09 UTC (permalink / raw)
  To: mochel; +Cc: linux-kernel, James.Bottomley

There are certain bus types (notably MCA and parisc internal ones) that like 
to do generic houskeeping operations (claim slots, claim uniform resources 
etc.) when drivers are attached to devices.

I've added a fairly generic notifier callback to the bus_type so that these 
busses can intercept and process the events they're interested in.

At the moment, the only events are attachment and detachment of drivers but in 
principle, more could be added.

James

You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


ChangeSet@1.928, 2002-12-04 10:21:28-06:00, jejb@raven.il.steeleye.com
  make bus notify events more general in generic device model

ChangeSet@1.927, 2002-12-03 14:16:53-06:00, jejb@raven.il.steeleye.com
  add device model bus notifier
  
  This adds a bus notifier (per bus type) which is called after a device
  driver successfully attaches to a device.  The idea behind this is
  that there are certain operations that need to be performed globally
  after driver attachment (bus resource claiming etc.).  This notifier
  is set by the bus so that it can do these.


 drivers/base/bus.c     |    4 ++++
 include/linux/device.h |    9 +++++++++
 2 files changed, 13 insertions(+)


diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c	Wed Dec  4 11:05:18 2002
+++ b/drivers/base/bus.c	Wed Dec  4 11:05:18 2002
@@ -145,6 +145,8 @@
 		 dev->bus_id,dev->driver->name);
 	list_add_tail(&dev->driver_list,&dev->driver->devices);
 	sysfs_create_link(&dev->driver->kobj,&dev->kobj,dev->kobj.name);
+	if(dev->bus && dev->bus->notify)
+		dev->bus->notify(dev, BUS_NOTIFIER_DRIVER_ATTACHED);
 }
 
 
@@ -260,6 +262,8 @@
 		if (drv->remove)
 			drv->remove(dev);
 		dev->driver = NULL;
+		if(dev->bus && dev->bus->notify)
+			dev->bus->notify(dev, BUS_NOTIFIER_DRIVER_DETACHED);
 	}
 }
 
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h	Wed Dec  4 11:05:18 2002
+++ b/include/linux/device.h	Wed Dec  4 11:05:18 2002
@@ -58,6 +58,13 @@
 	DEVICE_GONE		= 3,
 };
 
+/* bus notifier events: events that the bus type may choose to be notified
+ * about */
+enum bus_notifier {
+	BUS_NOTIFIER_DRIVER_ATTACHED,
+	BUS_NOTIFIER_DRIVER_DETACHED,
+};
+
 struct device;
 struct device_driver;
 struct device_class;
@@ -75,6 +82,8 @@
 	struct device * (*add)	(struct device * parent, char * bus_id);
 	int		(*hotplug) (struct device *dev, char **envp, 
 				    int num_envp, char *buffer, int buffer_size);
+	/* notify the bus that something happened */
+	void		(*notify)(struct device *dev, enum bus_notifier event);
 };
 
 

===================================================================


This BitKeeper patch contains the following changesets:
1.927..1.928
## Wrapped with gzip_uu ##


begin 664 bkpatch486
M'XL(`,\U[CT``]57:T_C.!3]7/^**XTT`I8\[#S;$8A'F9V*U0YB8#^MA)S$
M;3*3)E7L,E-M]K_O==*4!3I=0"#8-F_;U\?WG'MMOX-+*:I![ZOX&I%W\*F4
M:M"K^+4HS"PWI1(B%PMAQN442\_+$DNMM)P*2S>PCDXMN9!C:41S:12ERL:9
MJ*3!3,_T;((MSKB*4[C&CX,>-9W5%[68B4'O_.37R]\.SPG9VX/CE!<3\44H
MV-LCJJRN>9[(`Z[2O"Q,5?%"3H7B&DB]JEHSVV;X]VC@V)Y?4]]V@SJF":7<
MI2*QF1OZ[HTU#7RC+4I9P)CC>&%MA[;#R!"HV6<!V,RBS+(=H.Z`^@//,6Q_
M8-N@O7"PUEWP"P/#)D?PO&,Y)C'P)(%$7&>Q@&F9B!S0^]!Y'\OQN$@SJ>OA
MY58I;,WPHK]H!K;A>YHA&U@WYGDN$N!CA>5\:1X-)56&[(&<Q[&0<CS/\P5P
MI7B<"K11KJJ:@'T*R!*!'8HT*Q)0&D,FT8A*N<*+J`1P/&-1*9X54"(6KK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newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-04 17:09 [BKPATCH] bus notifiers for the generic device model James Bottomley
2002-12-04 17:56 ` Greg KH
2002-12-04 18:04   ` James Bottomley
2002-12-04 18:04     ` Patrick Mochel
2002-12-04 18:42       ` Jeff Garzik
2002-12-05  3:33         ` Patrick Mochel
2002-12-04 18:13     ` Greg KH
2002-12-04 19:35       ` James Bottomley
2002-12-04 22:29         ` Greg KH
2002-12-05  3:50           ` Patrick Mochel
2002-12-05 16:14             ` James Bottomley
2002-12-05 16:57               ` Jeff Garzik
2002-12-06 19:10               ` Patrick Mochel
2002-12-04 18:10   ` Mike Anderson
2002-12-04 18:52     ` Greg KH

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