public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 16/19] add bus' default driver attributes
Date: Mon, 28 Jun 2004 00:24:51 -0500	[thread overview]
Message-ID: <200406280024.53717.dtor_core@ameritech.net> (raw)
In-Reply-To: <200406280023.21998.dtor_core@ameritech.net>


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


ChangeSet@1.1790, 2004-06-27 19:22:44-05:00, dtor_core@ameritech.net
  Driver core: add default driver attributes to struct bus_type
  
  Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


 drivers/base/bus.c     |   37 +++++++++++++++++++++++++++++++++++--
 include/linux/device.h |    1 +
 2 files changed, 36 insertions(+), 2 deletions(-)


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



diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c	2004-06-27 19:24:04 -05:00
+++ b/drivers/base/bus.c	2004-06-27 19:24:04 -05:00
@@ -415,7 +415,7 @@
 static void device_remove_attrs(struct bus_type * bus, struct device * dev)
 {
 	int i;
-	
+
 	if (bus->dev_attrs) {
 		for (i = 0; attr_name(bus->dev_attrs[i]); i++)
 			device_remove_file(dev,&bus->dev_attrs[i]);
@@ -471,6 +471,37 @@
 	}
 }
 
+static int driver_add_attrs(struct bus_type * bus, struct device_driver * drv)
+{
+	int error = 0;
+	int i;
+
+	if (bus->drv_attrs) {
+		for (i = 0; attr_name(bus->drv_attrs[i]); i++) {
+			error = driver_create_file(drv, &bus->drv_attrs[i]);
+			if (error)
+				goto Err;
+		}
+	}
+ Done:
+	return error;
+ Err:
+	while (--i >= 0)
+		driver_remove_file(drv, &bus->drv_attrs[i]);
+	goto Done;
+}
+
+
+static void driver_remove_attrs(struct bus_type * bus, struct device_driver * drv)
+{
+	int i;
+
+	if (bus->drv_attrs) {
+		for (i = 0; attr_name(bus->drv_attrs[i]); i++)
+			driver_remove_file(drv, &bus->drv_attrs[i]);
+	}
+}
+
 
 /**
  *	bus_add_driver - Add a driver to the bus.
@@ -499,6 +530,7 @@
 		driver_attach(drv);
 		up_write(&bus->subsys.rwsem);
 
+		driver_add_attrs(bus, drv);
 	}
 	return error;
 }
@@ -516,6 +548,7 @@
 void bus_remove_driver(struct device_driver * drv)
 {
 	if (drv->bus) {
+		driver_remove_attrs(drv->bus, drv);
 		down_write(&drv->bus->subsys.rwsem);
 		pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
 		driver_detach(drv);
@@ -610,7 +643,7 @@
 static void bus_remove_attrs(struct bus_type * bus)
 {
 	int i;
-	
+
 	if (bus->bus_attrs) {
 		for (i = 0; attr_name(bus->bus_attrs[i]); i++)
 			bus_remove_file(bus,&bus->bus_attrs[i]);
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h	2004-06-27 19:24:04 -05:00
+++ b/include/linux/device.h	2004-06-27 19:24:04 -05:00
@@ -56,6 +56,7 @@
 
 	struct bus_attribute	* bus_attrs;
 	struct device_attribute	* dev_attrs;
+	struct driver_attribute	* drv_attrs;
 
 	int		(*match)(struct device * dev, struct device_driver * drv);
 	struct device * (*add)	(struct device * parent, char * bus_id);

  reply	other threads:[~2004-06-28  5:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-28  5:08 [PATCH 0/19] New set of input patches Dmitry Torokhov
2004-06-28  5:09 ` [PATCH 1/19] psmouse state locking Dmitry Torokhov
2004-06-28  5:10   ` [PATCH 2/19] serio connect/disconnect mandatory Dmitry Torokhov
2004-06-28  5:11     ` [PATCH 3/19] serio renames 1 Dmitry Torokhov
2004-06-28  5:12       ` [PATCH 4/19] serio renames 2 Dmitry Torokhov
2004-06-28  5:13         ` [PATCH 5/19] serio dynamic allocation Dmitry Torokhov
2004-06-28  5:14           ` [PATCH 6/19] serio avoid recursion Dmitry Torokhov
2004-06-28  5:15             ` [PATCH 7/19] serio sysfs intergration Dmitry Torokhov
2004-06-28  5:16               ` [PATCH 8/19] serio rebind Dmitry Torokhov
2004-06-28  5:17                 ` PATCH 9/19] serio manual bind Dmitry Torokhov
2004-06-28  5:17                   ` [PATCH 10/19] serio_raw driver Dmitry Torokhov
2004-06-28  5:19                     ` [PATCH 11/19] add platform_device_register_simple Dmitry Torokhov
2004-06-28  5:19                       ` [PATCH 12/19] convert i8042 into a platform device Dmitry Torokhov
2004-06-28  5:21                         ` [PATCH 13/19] more platform device conversions Dmitry Torokhov
2004-06-28  5:22                           ` [PATCH 14/19] bind serio ports and their parents Dmitry Torokhov
2004-06-28  5:23                             ` [PATCH 15/19] synaptics passthrough handling Dmitry Torokhov
2004-06-28  5:24                               ` Dmitry Torokhov [this message]
2004-06-28  5:25                                 ` [PATCH 17/19] serio use bus' default driver/device attributes Dmitry Torokhov
2004-06-28  5:26                                   ` [PATCH 18/19] add driver_find Dmitry Torokhov
2004-06-28  5:27                                     ` [PATCH 19/19] serio use driver_find Dmitry Torokhov
2004-06-28  6:52 ` [PATCH 0/19] New set of input patches Vojtech Pavlik
2004-06-28  7:13   ` Dmitry Torokhov
2004-06-28  7:51     ` Vojtech Pavlik
2004-06-28 10:32   ` Neil Brown
2004-06-28 12:13     ` Vojtech Pavlik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200406280024.53717.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox