Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Wed, 4 Dec 2002 12:02:01 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Wed, 4 Dec 2002 12:02:01 -0500 Received: from host194.steeleye.com ([66.206.164.34]:63237 "EHLO pogo.mtv1.steeleye.com") by vger.kernel.org with ESMTP id ; Wed, 4 Dec 2002 12:01:58 -0500 Message-Id: <200212041709.gB4H9LA02808@localhost.localdomain> X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 To: mochel@osdl.org cc: linux-kernel@vger.kernel.org, James.Bottomley@SteelEye.com Subject: [BKPATCH] bus notifiers for the generic device model Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 04 Dec 2002 11:09:21 -0600 From: James Bottomley X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4711 Lines: 127 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!"HV6Q@&F9B!S0^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