Message ID | 1305220265-9020-2-git-send-email-lamiaposta71@gmail.com (mailing list archive) |
---|---|
State | Rejected, archived |
Headers | show |
On Thu, May 12, 2011 at 09:28:53PM +0200, Rafael J. Wysocki wrote: hi, sorry, I missed this message this morning. > On Thursday, May 12, 2011, Raffaele Recalcati wrote: > > From: Davide Ciminaghi <ciminaghi@gnudd.com> > > Please explain why you need to export it, what the alternatives are and > why you think this approach is better than the alternatives. > what I needed to do was walking through the list of registered busses, and invoking the bus_added()/bus_removed() callback of a newly registered policy. I couldn't find any other simple way to do it. Regards Davide
On Fri, May 13, 2011 at 07:11:48PM +0200, Davide Ciminaghi wrote: > On Thu, May 12, 2011 at 09:28:53PM +0200, Rafael J. Wysocki wrote: > > hi, > > sorry, I missed this message this morning. > > > On Thursday, May 12, 2011, Raffaele Recalcati wrote: > > > From: Davide Ciminaghi <ciminaghi@gnudd.com> > > > > Please explain why you need to export it, what the alternatives are and > > why you think this approach is better than the alternatives. > > > > what I needed to do was walking through the list of registered busses, > and invoking the bus_added()/bus_removed() callback of a newly registered > policy. I couldn't find any other simple way to do it. > well, I there is another way to do that: adding a function like this (include/linux/device.h) : /** * run a callback for each registered bus type * * @data : arg passed to callback * @fn : pointer to callback */ int for_each_bus(void *data, int (*fn)(struct bus_type *bus, void *data)); which would be similar to the already existing bus_for_each_dev() and would allow to avoid exporting a global variable. Regards Davide
On Sunday, May 15, 2011, Davide Ciminaghi wrote: > On Fri, May 13, 2011 at 07:11:48PM +0200, Davide Ciminaghi wrote: > > On Thu, May 12, 2011 at 09:28:53PM +0200, Rafael J. Wysocki wrote: > > > > hi, > > > > sorry, I missed this message this morning. > > > > > On Thursday, May 12, 2011, Raffaele Recalcati wrote: > > > > From: Davide Ciminaghi <ciminaghi@gnudd.com> > > > > > > Please explain why you need to export it, what the alternatives are and > > > why you think this approach is better than the alternatives. > > > > > > > what I needed to do was walking through the list of registered busses, > > and invoking the bus_added()/bus_removed() callback of a newly registered > > policy. I couldn't find any other simple way to do it. > > > well, I there is another way to do that: adding a function like this > (include/linux/device.h) : > > /** > * run a callback for each registered bus type > * > * @data : arg passed to callback > * @fn : pointer to callback > */ > int for_each_bus(void *data, int (*fn)(struct bus_type *bus, void *data)); > > which would be similar to the already existing bus_for_each_dev() and > would allow to avoid exporting a global variable. I really think you'd simply need to browse all devices, like the core PM code in drivers/base/power/main.c. You can use dpm_list for that just fine. Thanks, Rafael
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 000e7b2..2134248 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -158,7 +158,8 @@ static const struct kset_uevent_ops bus_uevent_ops = { .filter = bus_uevent_filter, }; -static struct kset *bus_kset; +struct kset *bus_kset; +EXPORT_SYMBOL(bus_kset); #ifdef CONFIG_HOTPLUG diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 8f6d121..456b20d 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -205,6 +205,8 @@ extern struct kobject *power_kobj; /* The global /sys/firmware/ kobject for people to chain off of */ extern struct kobject *firmware_kobj; +extern struct kset *bus_kset ; + #if defined(CONFIG_HOTPLUG) int kobject_uevent(struct kobject *kobj, enum kobject_action action); int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,