linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sysfs - which driver for a device?
@ 2003-09-24  2:03 Jon Smirl
  2003-09-24  9:03 ` Daniel Stekloff
  2003-09-25 18:05 ` Patrick Mochel
  0 siblings, 2 replies; 3+ messages in thread
From: Jon Smirl @ 2003-09-24  2:03 UTC (permalink / raw)
  To: lkml

In sysfs it is easy to see which devices a driver is supporting.
For example /sys/bus/pci/drivers/e1000 links to 0000:02:0c.0 in my system.

But how do you go the other way; starting from 0000:02:0c.0 to determine the
driver? Is the best solution to loop though the drivers directories searching
for the device? Or would it be better to change sysfs to add an attribute to
each device containing the driver name?

In /proc/bus/pci/devices the driver name is the last field.


=====
Jon Smirl
jonsmirl@yahoo.com

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sysfs - which driver for a device?
  2003-09-24  2:03 sysfs - which driver for a device? Jon Smirl
@ 2003-09-24  9:03 ` Daniel Stekloff
  2003-09-25 18:05 ` Patrick Mochel
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Stekloff @ 2003-09-24  9:03 UTC (permalink / raw)
  To: Jon Smirl, lkml


Hi,

On Wednesday 24 September 2003 02:03 am, Jon Smirl wrote:
> In sysfs it is easy to see which devices a driver is supporting.
> For example /sys/bus/pci/drivers/e1000 links to 0000:02:0c.0 in my system.
>
> But how do you go the other way; starting from 0000:02:0c.0 to determine
> the driver? Is the best solution to loop though the drivers directories
> searching for the device? Or would it be better to change sysfs to add an
> attribute to each device containing the driver name?
>
> In /proc/bus/pci/devices the driver name is the last field.


Have you looked at libsysfs? You can query for a sysfs_device, which includes 
the name of the driver. Libsysfs' goal is to provide an easy interface for 
retrieving such information. The library should also reduce the need for 
adding extra references or attributes in the kernel. 

Libsysfs is included in the sysfsutils package that also contains systool, a 
command to view system information exposed through sysfs. 

Sysfsutils can be found at:

http://linux-diag.sourceforge.net/

Thanks,

Dan



> =====
> Jon Smirl
> jonsmirl@yahoo.com
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sysfs - which driver for a device?
  2003-09-24  2:03 sysfs - which driver for a device? Jon Smirl
  2003-09-24  9:03 ` Daniel Stekloff
@ 2003-09-25 18:05 ` Patrick Mochel
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick Mochel @ 2003-09-25 18:05 UTC (permalink / raw)
  To: Jon Smirl; +Cc: lkml


> In sysfs it is easy to see which devices a driver is supporting.
> For example /sys/bus/pci/drivers/e1000 links to 0000:02:0c.0 in my system.
> 
> But how do you go the other way; starting from 0000:02:0c.0 to determine the
> driver? Is the best solution to loop though the drivers directories searching
> for the device? Or would it be better to change sysfs to add an attribute to
> each device containing the driver name?

Well, one could use a script to ascertain the driver name for a given 
device. Or, you could use the patch below, which will insert a 'driver' 
symlink that points to the device driver's directory. 


	Pat

===== drivers/base/bus.c 1.51 vs edited =====
--- 1.51/drivers/base/bus.c	Fri Aug 29 14:18:26 2003
+++ edited/drivers/base/bus.c	Thu Sep 25 10:55:14 2003
@@ -243,6 +243,7 @@
 	list_add_tail(&dev->driver_list,&dev->driver->devices);
 	sysfs_create_link(&dev->driver->kobj,&dev->kobj,
 			  kobject_name(&dev->kobj));
+	sysfs_create_link(&dev->kobj,&dev->driver->kobj,"driver");
 }
 
 
@@ -365,6 +366,7 @@
 	struct device_driver * drv = dev->driver;
 	if (drv) {
 		sysfs_remove_link(&drv->kobj,kobject_name(&dev->kobj));
+		sysfs_remove_link(&dev->kobj,"driver");
 		list_del_init(&dev->driver_list);
 		device_detach_shutdown(dev);
 		if (drv->remove)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-25 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-24  2:03 sysfs - which driver for a device? Jon Smirl
2003-09-24  9:03 ` Daniel Stekloff
2003-09-25 18:05 ` Patrick Mochel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).