public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* What is struct pci_driver.owner for?
@ 2005-10-18 20:47 Roland Dreier
  2005-10-18 20:53 ` Jeff Garzik
  0 siblings, 1 reply; 8+ messages in thread
From: Roland Dreier @ 2005-10-18 20:47 UTC (permalink / raw)
  To: linux-kernel

I just noticed that at some point, struct pci_driver grew a .owner
member.  However, only a handful of drivers set it:

    $ grep -r -A10 pci_driver drivers/ | grep owner
    drivers/block/sx8.c-    .owner          = THIS_MODULE,
    drivers/ieee1394/pcilynx.c-     .owner =           THIS_MODULE,
    drivers/net/spider_net.c-       .owner          = THIS_MODULE,
    drivers/video/imsttfb.c-        .owner          = THIS_MODULE,
    drivers/video/kyro/fbdev.c-     .owner          = THIS_MODULE,
    drivers/video/tridentfb.c-      .owner  = THIS_MODULE,

Should all drivers be setting .owner = THIS_MODULE?  Is this a good
kernel janitors task?

 - R.

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

* Re: What is struct pci_driver.owner for?
  2005-10-18 20:47 What is struct pci_driver.owner for? Roland Dreier
@ 2005-10-18 20:53 ` Jeff Garzik
  2005-10-18 20:59   ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Garzik @ 2005-10-18 20:53 UTC (permalink / raw)
  To: Roland Dreier; +Cc: linux-kernel, Greg KH

Roland Dreier wrote:
> I just noticed that at some point, struct pci_driver grew a .owner
> member.  However, only a handful of drivers set it:
> 
>     $ grep -r -A10 pci_driver drivers/ | grep owner
>     drivers/block/sx8.c-    .owner          = THIS_MODULE,
>     drivers/ieee1394/pcilynx.c-     .owner =           THIS_MODULE,
>     drivers/net/spider_net.c-       .owner          = THIS_MODULE,
>     drivers/video/imsttfb.c-        .owner          = THIS_MODULE,
>     drivers/video/kyro/fbdev.c-     .owner          = THIS_MODULE,
>     drivers/video/tridentfb.c-      .owner  = THIS_MODULE,
> 
> Should all drivers be setting .owner = THIS_MODULE?  Is this a good
> kernel janitors task?

In theory its for module refcounting.  With so many PCI drivers and so 
few pci_driver::owner users, it makes me wonder how needed it is.

If it is needed (I've done no analysis, even though I am sx8.c author), 
then it should be applied uniformly.

	Jeff



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

* Re: What is struct pci_driver.owner for?
  2005-10-18 20:53 ` Jeff Garzik
@ 2005-10-18 20:59   ` Greg KH
  2005-10-18 21:04     ` Russell King
  2005-10-18 21:06     ` Roland Dreier
  0 siblings, 2 replies; 8+ messages in thread
From: Greg KH @ 2005-10-18 20:59 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Roland Dreier, linux-kernel

On Tue, Oct 18, 2005 at 04:53:36PM -0400, Jeff Garzik wrote:
> Roland Dreier wrote:
> >I just noticed that at some point, struct pci_driver grew a .owner
> >member.  However, only a handful of drivers set it:
> >
> >    $ grep -r -A10 pci_driver drivers/ | grep owner
> >    drivers/block/sx8.c-    .owner          = THIS_MODULE,
> >    drivers/ieee1394/pcilynx.c-     .owner =           THIS_MODULE,
> >    drivers/net/spider_net.c-       .owner          = THIS_MODULE,
> >    drivers/video/imsttfb.c-        .owner          = THIS_MODULE,
> >    drivers/video/kyro/fbdev.c-     .owner          = THIS_MODULE,
> >    drivers/video/tridentfb.c-      .owner  = THIS_MODULE,
> >
> >Should all drivers be setting .owner = THIS_MODULE?  Is this a good
> >kernel janitors task?
> 
> In theory its for module refcounting.  With so many PCI drivers and so 
> few pci_driver::owner users, it makes me wonder how needed it is.

It might in the future be needed for refcounting, I originally added it
when I thought it was needed.

But what it really does today is create the symlink from the driver to
the module that is contained in it, in sysfs.  Which is very invaluable
for people who want to know these things (installer programs, etc.)

For example:
$ tree /sys/bus/pci/drivers/uhci_hcd/
/sys/bus/pci/drivers/uhci_hcd/
|-- 0000:00:1d.0 -> ../../../../devices/pci0000:00/0000:00:1d.0
|-- 0000:00:1d.1 -> ../../../../devices/pci0000:00/0000:00:1d.1
|-- 0000:00:1d.2 -> ../../../../devices/pci0000:00/0000:00:1d.2
|-- 0000:00:1d.3 -> ../../../../devices/pci0000:00/0000:00:1d.3
|-- bind
|-- module -> ../../../../module/uhci_hcd
|-- new_id
`-- unbind


That "module" symlink is created only if the .owner field is set.
That's why people are going through and adding it to all of the drivers
in the system.

Hope this helps,

greg k-h	

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

* Re: What is struct pci_driver.owner for?
  2005-10-18 20:59   ` Greg KH
@ 2005-10-18 21:04     ` Russell King
  2005-10-18 21:06     ` Roland Dreier
  1 sibling, 0 replies; 8+ messages in thread
From: Russell King @ 2005-10-18 21:04 UTC (permalink / raw)
  To: Greg KH; +Cc: Jeff Garzik, Roland Dreier, linux-kernel

On Tue, Oct 18, 2005 at 01:59:08PM -0700, Greg KH wrote:
> On Tue, Oct 18, 2005 at 04:53:36PM -0400, Jeff Garzik wrote:
> > Roland Dreier wrote:
> > >I just noticed that at some point, struct pci_driver grew a .owner
> > >member.  However, only a handful of drivers set it:
> > >
> > >    $ grep -r -A10 pci_driver drivers/ | grep owner
> > >    drivers/block/sx8.c-    .owner          = THIS_MODULE,
> > >    drivers/ieee1394/pcilynx.c-     .owner =           THIS_MODULE,
> > >    drivers/net/spider_net.c-       .owner          = THIS_MODULE,
> > >    drivers/video/imsttfb.c-        .owner          = THIS_MODULE,
> > >    drivers/video/kyro/fbdev.c-     .owner          = THIS_MODULE,
> > >    drivers/video/tridentfb.c-      .owner  = THIS_MODULE,
> > >
> > >Should all drivers be setting .owner = THIS_MODULE?  Is this a good
> > >kernel janitors task?
> > 
> > In theory its for module refcounting.  With so many PCI drivers and so 
> > few pci_driver::owner users, it makes me wonder how needed it is.
> 
> It might in the future be needed for refcounting, I originally added it
> when I thought it was needed.

Note that both pci_driver and pci_driver.driver both have an "owner"
field.  One should go - there's no point needlessly duplicating stuff
like this.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

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

* Re: What is struct pci_driver.owner for?
  2005-10-18 20:59   ` Greg KH
  2005-10-18 21:04     ` Russell King
@ 2005-10-18 21:06     ` Roland Dreier
  2005-10-19 15:42       ` Jiri Slaby
  1 sibling, 1 reply; 8+ messages in thread
From: Roland Dreier @ 2005-10-18 21:06 UTC (permalink / raw)
  To: Greg KH; +Cc: Jeff Garzik, linux-kernel

    Greg> But what it really does today is create the symlink from the
    Greg> driver to the module that is contained in it, in sysfs.
    Greg> Which is very invaluable for people who want to know these
    Greg> things (installer programs, etc.)

    Greg> That "module" symlink is created only if the .owner field is
    Greg> set.  That's why people are going through and adding it to
    Greg> all of the drivers in the system.

OK, I'll make my own small contribution and push this for 2.6.15:

diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -1196,6 +1196,7 @@ MODULE_DEVICE_TABLE(pci, mthca_pci_table
 
 static struct pci_driver mthca_driver = {
 	.name		= DRV_NAME,
+	.owner		= THIS_MODULE,
 	.id_table	= mthca_pci_table,
 	.probe		= mthca_init_one,
 	.remove		= __devexit_p(mthca_remove_one)

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

* Re: What is struct pci_driver.owner for?
  2005-10-18 21:06     ` Roland Dreier
@ 2005-10-19 15:42       ` Jiri Slaby
  2005-10-19 16:48         ` Roland Dreier
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Slaby @ 2005-10-19 15:42 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Greg KH, Jeff Garzik, linux-kernel

Roland Dreier napsal(a):

>    Greg> But what it really does today is create the symlink from the
>    Greg> driver to the module that is contained in it, in sysfs.
>    Greg> Which is very invaluable for people who want to know these
>    Greg> things (installer programs, etc.)
>
>    Greg> That "module" symlink is created only if the .owner field is
>    Greg> set.  That's why people are going through and adding it to
>    Greg> all of the drivers in the system.
>
>OK, I'll make my own small contribution and push this for 2.6.15:
>  
>
Ok, but read Documentation/SubmittingPatches. At least Signed-off-by is
missing.

>diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
>--- a/drivers/infiniband/hw/mthca/mthca_main.c
>+++ b/drivers/infiniband/hw/mthca/mthca_main.c
>@@ -1196,6 +1196,7 @@ MODULE_DEVICE_TABLE(pci, mthca_pci_table
> 
> static struct pci_driver mthca_driver = {
> 	.name		= DRV_NAME,
>+	.owner		= THIS_MODULE,
> 	.id_table	= mthca_pci_table,
> 	.probe		= mthca_init_one,
> 	.remove		= __devexit_p(mthca_remove_one)
>  
>
regards,
-- 
Jiri Slaby         www.fi.muni.cz/~xslaby
~\-/~      jirislaby@gmail.com      ~\-/~
B67499670407CE62ACC8 22A032CC55C339D47A7E


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

* Re: What is struct pci_driver.owner for?
  2005-10-19 15:42       ` Jiri Slaby
@ 2005-10-19 16:48         ` Roland Dreier
  2005-10-19 16:51           ` Jiri Slaby
  0 siblings, 1 reply; 8+ messages in thread
From: Roland Dreier @ 2005-10-19 16:48 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Greg KH, Jeff Garzik, linux-kernel

    Jiri> Ok, but read Documentation/SubmittingPatches. At least
    Jiri> Signed-off-by is missing.

Thanks, but that wasn't really a patch for anyone to accept.  It was
just a note about what I just put into my git tree, which I'll ask
Linus to pull from directly when 2.6.15 opens.  Of course in the real
commit message I put a nice description and Signed-off-by: line.

 - R.

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

* Re: What is struct pci_driver.owner for?
  2005-10-19 16:48         ` Roland Dreier
@ 2005-10-19 16:51           ` Jiri Slaby
  0 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2005-10-19 16:51 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Greg KH, Jeff Garzik, linux-kernel

Roland Dreier napsal(a):

>    Jiri> Ok, but read Documentation/SubmittingPatches. At least
>    Jiri> Signed-off-by is missing.
>
>Thanks, but that wasn't really a patch for anyone to accept.  It was
>just a note about what I just put into my git tree, which I'll ask
>Linus to pull from directly when 2.6.15 opens.  Of course in the real
>commit message I put a nice description and Signed-off-by: line.
>  
>
Oh, sorry.

-- 
Jiri Slaby         www.fi.muni.cz/~xslaby
~\-/~      jirislaby@gmail.com      ~\-/~
B67499670407CE62ACC8 22A032CC55C339D47A7E


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

end of thread, other threads:[~2005-10-19 16:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-18 20:47 What is struct pci_driver.owner for? Roland Dreier
2005-10-18 20:53 ` Jeff Garzik
2005-10-18 20:59   ` Greg KH
2005-10-18 21:04     ` Russell King
2005-10-18 21:06     ` Roland Dreier
2005-10-19 15:42       ` Jiri Slaby
2005-10-19 16:48         ` Roland Dreier
2005-10-19 16:51           ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox