* [PARCH] driver core: add driver_find to find a driver by name
@ 2004-06-28 2:26 Dmitry Torokhov
2004-06-28 8:41 ` Christoph Hellwig
2004-07-14 23:02 ` Greg KH
0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2004-06-28 2:26 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
Hi,
Here is a patch that adds driver_find() that allows to search for a driver
on a bus by it's name. The function is similar to device_find already present
in the tree. I need it for my serio sysfs patches where user can re-bind
serio port to an alternate driver by echoing driver's name to serio port's
driver attribute.
--
Dmitry
===================================================================
ChangeSet@1.1792, 2004-06-27 20:49:01-05:00, dtor_core@ameritech.net
Driver core: add driver_find helper to find a driver by its name
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/base/driver.c | 16 ++++++++++++++++
include/linux/device.h | 1 +
2 files changed, 17 insertions(+)
===================================================================
diff -Nru a/drivers/base/driver.c b/drivers/base/driver.c
--- a/drivers/base/driver.c 2004-06-27 21:24:06 -05:00
+++ b/drivers/base/driver.c 2004-06-27 21:24:06 -05:00
@@ -111,10 +111,26 @@
up(&drv->unload_sem);
}
+/**
+ * driver_find - find driver on a given bus by its name.
+ * @name: name of the driver.
+ * @bus: bus to seatch for the driver
+ */
+
+struct device_driver *driver_find(const char *name, struct bus_type *bus)
+{
+ struct kobject *k = kset_find_obj(&bus->drivers, name);
+ if (k)
+ return to_drv(k);
+ return NULL;
+}
+
+
EXPORT_SYMBOL(driver_register);
EXPORT_SYMBOL(driver_unregister);
EXPORT_SYMBOL(get_driver);
EXPORT_SYMBOL(put_driver);
+EXPORT_SYMBOL(driver_find);
EXPORT_SYMBOL(driver_create_file);
EXPORT_SYMBOL(driver_remove_file);
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h 2004-06-27 21:24:06 -05:00
+++ b/include/linux/device.h 2004-06-27 21:24:06 -05:00
@@ -120,6 +120,7 @@
extern struct device_driver * get_driver(struct device_driver * drv);
extern void put_driver(struct device_driver * drv);
+extern struct device_driver *driver_find(const char *name, struct bus_type *bus);
/* driverfs interface for exporting driver attributes */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PARCH] driver core: add driver_find to find a driver by name
2004-06-28 2:26 [PARCH] driver core: add driver_find to find a driver by name Dmitry Torokhov
@ 2004-06-28 8:41 ` Christoph Hellwig
2004-07-14 23:02 ` Greg KH
1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2004-06-28 8:41 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Greg KH, linux-kernel
On Sun, Jun 27, 2004 at 09:26:03PM -0500, Dmitry Torokhov wrote:
> Hi,
>
> Here is a patch that adds driver_find() that allows to search for a driver
> on a bus by it's name. The function is similar to device_find already present
> in the tree. I need it for my serio sysfs patches where user can re-bind
> serio port to an alternate driver by echoing driver's name to serio port's
> driver attribute.
It looks like it's missing some refcounting, no?
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PARCH] driver core: add driver_find to find a driver by name
@ 2004-06-28 13:37 Dmitry Torokhov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2004-06-28 13:37 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Greg KH, LKML
Christoph Hellwig wrote:
> On Sun, Jun 27, 2004 at 09:26:03PM -0500, Dmitry Torokhov wrote:
> > Hi,
> >
> > Here is a patch that adds driver_find() that allows to search for a
> driver
> > on a bus by it's name. The function is similar to device_find already
> present
> > in the tree. I need it for my serio sysfs patches where user can re-bind
> > serio port to an alternate driver by echoing driver's name to serio
> port's
> > driver attribute.
>
> It looks like it's missing some refcounting, no?
Actually I think that kset_find_obj is the one that is missing
refcounting - device/driver can easily go away on return from
this function as well, no?
Anyway, usage in serio should be fine as the whole thing is
protected by serio_sem.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PARCH] driver core: add driver_find to find a driver by name
2004-06-28 2:26 [PARCH] driver core: add driver_find to find a driver by name Dmitry Torokhov
2004-06-28 8:41 ` Christoph Hellwig
@ 2004-07-14 23:02 ` Greg KH
2004-07-15 12:30 ` Marcelo Tosatti
1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2004-07-14 23:02 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-kernel
On Sun, Jun 27, 2004 at 09:26:03PM -0500, Dmitry Torokhov wrote:
> Hi,
>
> Here is a patch that adds driver_find() that allows to search for a driver
> on a bus by it's name. The function is similar to device_find already present
> in the tree. I need it for my serio sysfs patches where user can re-bind
> serio port to an alternate driver by echoing driver's name to serio port's
> driver attribute.
Applied, thanks.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PARCH] driver core: add driver_find to find a driver by name
2004-07-14 23:02 ` Greg KH
@ 2004-07-15 12:30 ` Marcelo Tosatti
2004-07-16 4:41 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Marcelo Tosatti @ 2004-07-15 12:30 UTC (permalink / raw)
To: Greg KH; +Cc: Dmitry Torokhov, linux-kernel
On Wed, Jul 14, 2004 at 04:02:46PM -0700, Greg KH wrote:
> On Sun, Jun 27, 2004 at 09:26:03PM -0500, Dmitry Torokhov wrote:
> > Hi,
> >
> > Here is a patch that adds driver_find() that allows to search for a driver
> > on a bus by it's name. The function is similar to device_find already present
> > in the tree. I need it for my serio sysfs patches where user can re-bind
> > serio port to an alternate driver by echoing driver's name to serio port's
> > driver attribute.
>
> Applied, thanks.
Dmitry,
I remember you fixed kset_find_obj() to get a reference count on the kobject.
driver_find()/device_find() use that, maybe it would be nice to add a comment
on top of those saying the caller is responsible for putting the refcount
on the kobject?
Last time I looked at your patches there was no such comment on driver_find/device_find,
only kset_find_obj().
Just nitpicking.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PARCH] driver core: add driver_find to find a driver by name
2004-07-15 12:30 ` Marcelo Tosatti
@ 2004-07-16 4:41 ` Dmitry Torokhov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2004-07-16 4:41 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Greg KH, linux-kernel
On Thursday 15 July 2004 07:30 am, Marcelo Tosatti wrote:
> On Wed, Jul 14, 2004 at 04:02:46PM -0700, Greg KH wrote:
> > On Sun, Jun 27, 2004 at 09:26:03PM -0500, Dmitry Torokhov wrote:
> > > Hi,
> > >
> > > Here is a patch that adds driver_find() that allows to search for a driver
> > > on a bus by it's name. The function is similar to device_find already present
> > > in the tree. I need it for my serio sysfs patches where user can re-bind
> > > serio port to an alternate driver by echoing driver's name to serio port's
> > > driver attribute.
> >
> > Applied, thanks.
>
> Dmitry,
>
> I remember you fixed kset_find_obj() to get a reference count on the kobject.
>
> driver_find()/device_find() use that, maybe it would be nice to add a comment
> on top of those saying the caller is responsible for putting the refcount
> on the kobject?
>
> Last time I looked at your patches there was no such comment on driver_find/device_find,
> only kset_find_obj().
>
> Just nitpicking.
>
Hi Marcelo,
I tried to document driver_find, device_find and find_bus, please check out
the version that Greg has committed. If comments still somewhat unclear I
will try redoing them.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-07-16 5:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-28 2:26 [PARCH] driver core: add driver_find to find a driver by name Dmitry Torokhov
2004-06-28 8:41 ` Christoph Hellwig
2004-07-14 23:02 ` Greg KH
2004-07-15 12:30 ` Marcelo Tosatti
2004-07-16 4:41 ` Dmitry Torokhov
-- strict thread matches above, loose matches on Subject: below --
2004-06-28 13:37 Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox