From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Driver Core patches for 2.6.7
Date: Tue, 22 Jun 2004 10:41:49 -0700 [thread overview]
Message-ID: <10879261084005@kroah.com> (raw)
In-Reply-To: <1087926108744@kroah.com>
ChangeSet 1.1722.85.5, 2004/06/03 17:05:41-07:00, mochel@digitalimplant.org
[Driver Model] Add default attributes for struct bus_type.
- Similar to default attributes for struct class, this is an array
of attributes, terminated with an attribute with a NULL name, that
are added when the bus is registered, and removed when the bus is
unregistered.
drivers/base/bus.c | 37 +++++++++++++++++++++++++++++++++++++
include/linux/device.h | 2 ++
2 files changed, 39 insertions(+)
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c Tue Jun 22 09:48:40 2004
+++ b/drivers/base/bus.c Tue Jun 22 09:48:40 2004
@@ -549,6 +549,41 @@
return k ? to_bus(k) : NULL;
}
+
+/**
+ * bus_add_attrs - Add default attributes for this bus.
+ * @bus: Bus that has just been registered.
+ */
+
+static int bus_add_attrs(struct bus_type * bus)
+{
+ int error = 0;
+ int i;
+
+ if (bus->bus_attrs) {
+ for (i = 0; attr_name(bus->bus_attrs[i]); i++) {
+ if ((error = bus_create_file(bus,&bus->bus_attrs[i])))
+ goto Err;
+ }
+ }
+ Done:
+ return error;
+ Err:
+ while (i >= 0)
+ bus_remove_file(bus,&bus->bus_attrs[i]);
+ goto Done;
+}
+
+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]);
+ }
+}
+
/**
* bus_register - register a bus with the system.
* @bus: bus.
@@ -582,6 +617,7 @@
retval = kset_register(&bus->drivers);
if (retval)
goto bus_drivers_fail;
+ bus_add_attrs(bus);
pr_debug("bus type '%s' registered\n",bus->name);
return 0;
@@ -605,6 +641,7 @@
void bus_unregister(struct bus_type * bus)
{
pr_debug("bus %s: unregistering\n",bus->name);
+ bus_remove_attrs(bus);
kset_unregister(&bus->drivers);
kset_unregister(&bus->devices);
subsystem_unregister(&bus->subsys);
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Tue Jun 22 09:48:40 2004
+++ b/include/linux/device.h Tue Jun 22 09:48:40 2004
@@ -54,6 +54,8 @@
struct kset drivers;
struct kset devices;
+ struct bus_attribute * bus_attrs;
+
int (*match)(struct device * dev, struct device_driver * drv);
struct device * (*add) (struct device * parent, char * bus_id);
int (*hotplug) (struct device *dev, char **envp,
next prev parent reply other threads:[~2004-06-22 22:56 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-22 17:19 [BK PATCH] Driver Core patches for 2.6.7 Greg KH
2004-06-22 17:41 ` [PATCH] " Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH [this message]
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 17:41 ` Greg KH
2004-06-22 23:21 ` Dmitry Torokhov
2004-06-22 23:31 ` Greg KH
2004-06-22 23:44 ` Dmitry Torokhov
2004-06-22 23:51 ` Greg KH
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=10879261084005@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/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