public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC patch 0/3] remove pci_driver.owner and .name fields
@ 2005-10-26 20:48 Laurent riffard
  2005-10-26 20:48 ` [RFC patch 1/3] " Laurent riffard
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Laurent riffard @ 2005-10-26 20:48 UTC (permalink / raw)
  To: linux-kernel, Al Viro, Greg KH, Russell King

I'm willing to submit patches to remove pci_driver.owner and .name
fields. pci_driver.driver.owner and .name will be used instead.

Patch 1 prepares the core pci code for future removal of the 2
fields, but actually do not remove them. As suggested by Al Viro,
pci_driver.driver.owner will be set by pci_register_driver.

Patch 2 is an example of driver's update. There will be lots of
patches like this.

Patch 3 is the final touch, after all pci_driver.name and
pci_driver.owner are removed.

Any comments ? Feel free to correct my bad english.

thanks
--
laurent



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

* [RFC patch 1/3] remove pci_driver.owner and .name fields
  2005-10-26 20:48 [RFC patch 0/3] remove pci_driver.owner and .name fields Laurent riffard
@ 2005-10-26 20:48 ` Laurent riffard
  2005-10-26 21:20   ` Al Viro
  2005-10-26 20:48 ` [RFC patch 2/3] " Laurent riffard
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Laurent riffard @ 2005-10-26 20:48 UTC (permalink / raw)
  To: linux-kernel, Al Viro, Greg KH, Russell King

[-- Attachment #1: remove_pci_driver_owner_name-pci_core.patch --]
[-- Type: text/plain, Size: 5906 bytes --]

pci_driver.name and .owner are duplicates of pci_driver.driver.name
and .owner.

This patch prepares the core pci code for future removal of the 2
pci_driver's fields, but actually do not remove them. 

Driver developpers should set pci_driver.driver.name, while
pci_driver.driver.owner will be set by pci_register_driver.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
--

 drivers/ide/setup-pci.c  |   10 ++++++----
 drivers/pci/pci-driver.c |   13 +++++++++----
 include/linux/ide.h      |    2 ++
 include/linux/pci.h      |   11 +++++++++--
 4 files changed, 26 insertions(+), 10 deletions(-)

Index: linux-2.6-stable/include/linux/pci.h
===================================================================
--- linux-2.6-stable.orig/include/linux/pci.h
+++ linux-2.6-stable/include/linux/pci.h
@@ -664,6 +664,12 @@
 struct module;
 struct pci_driver {
 	struct list_head node;
+	/*
+	 * Please do not use the 2 following fields, they are planned for
+	 * deletion.
+	 * Use driver.name instead of .name.
+	 * The field driver.owner will be set by pci_register_driver.
+	 */
 	char *name;
 	struct module *owner;
 	const struct pci_device_id *id_table;	/* must be non-NULL for probe to be called */
@@ -857,7 +863,8 @@
 void pci_enable_bridges(struct pci_bus *bus);
 
 /* New-style probing supporting hot-pluggable devices */
-int pci_register_driver(struct pci_driver *);
+int __pci_register_driver(struct pci_driver *, struct module *);
+#define pci_register_driver(d) __pci_register_driver(d, THIS_MODULE)
 void pci_unregister_driver(struct pci_driver *);
 void pci_remove_behind_bridge(struct pci_dev *);
 struct pci_driver *pci_dev_driver(const struct pci_dev *);
@@ -957,7 +964,7 @@
 static inline void pci_disable_device(struct pci_dev *dev) { }
 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
 static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}
-static inline int pci_register_driver(struct pci_driver *drv) { return 0;}
+static inline int __pci_register_driver(struct pci_driver *drv, struct module *owner) { return 0;}
 static inline void pci_unregister_driver(struct pci_driver *drv) { }
 static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; }
 static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; }
Index: linux-2.6-stable/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6-stable.orig/drivers/pci/pci-driver.c
+++ linux-2.6-stable/drivers/pci/pci-driver.c
@@ -327,18 +327,23 @@
 /**
  * pci_register_driver - register a new pci driver
  * @drv: the driver structure to register
+ * @owner: owner module of drv
  * 
  * Adds the driver structure to the list of registered drivers.
  * Returns a negative value on error, otherwise 0. 
  * If no error occurred, the driver remains registered even if 
  * no device was claimed during registration.
  */
-int pci_register_driver(struct pci_driver *drv)
+int __pci_register_driver(struct pci_driver *drv, struct module *owner)
 {
 	int error;
 
 	/* initialize common driver fields */
-	drv->driver.name = drv->name;
+	if (drv->name) {
+		/* backward compatibility until all pci_driver are converted to
+		 * use pci_driver.driver.name instead of pci_driver.name */
+		drv->driver.name = drv->name;
+	}
 	drv->driver.bus = &pci_bus_type;
 	drv->driver.probe = pci_device_probe;
 	drv->driver.remove = pci_device_remove;
@@ -346,7 +351,7 @@
 	 * the pci shutdown function, this test can go away. */
 	if (!drv->driver.shutdown)
 		drv->driver.shutdown = pci_device_shutdown;
-	drv->driver.owner = drv->owner;
+	drv->driver.owner = owner;
 	drv->driver.kobj.ktype = &pci_driver_kobj_type;
 
 	spin_lock_init(&drv->dynids.lock);
@@ -483,7 +488,7 @@
 
 EXPORT_SYMBOL(pci_match_id);
 EXPORT_SYMBOL(pci_match_device);
-EXPORT_SYMBOL(pci_register_driver);
+EXPORT_SYMBOL(__pci_register_driver);
 EXPORT_SYMBOL(pci_unregister_driver);
 EXPORT_SYMBOL(pci_dev_driver);
 EXPORT_SYMBOL(pci_bus_type);
Index: linux-2.6-stable/drivers/ide/setup-pci.c
===================================================================
--- linux-2.6-stable.orig/drivers/ide/setup-pci.c
+++ linux-2.6-stable/drivers/ide/setup-pci.c
@@ -787,8 +787,9 @@
 static LIST_HEAD(ide_pci_drivers);
 
 /*
- *	ide_register_pci_driver		-	attach IDE driver
+ *	__ide_register_pci_driver	-	attach IDE driver
  *	@driver: pci driver
+ *	@module: owner module of the driver
  *
  *	Registers a driver with the IDE layer. The IDE layer arranges that
  *	boot time setup is done in the expected device order and then 
@@ -801,15 +802,16 @@
  *	Returns are the same as for pci_register_driver
  */
 
-int ide_pci_register_driver(struct pci_driver *driver)
+int __ide_pci_register_driver(struct pci_driver *driver, struct module *module)
 {
 	if(!pre_init)
-		return pci_module_init(driver);
+		return __pci_register_driver(driver, module);
+	driver->driver.owner = module;
 	list_add_tail(&driver->node, &ide_pci_drivers);
 	return 0;
 }
 
-EXPORT_SYMBOL_GPL(ide_pci_register_driver);
+EXPORT_SYMBOL_GPL(__ide_pci_register_driver);
 
 /**
  *	ide_unregister_pci_driver	-	unregister an IDE driver
Index: linux-2.6-stable/include/linux/ide.h
===================================================================
--- linux-2.6-stable.orig/include/linux/ide.h
+++ linux-2.6-stable/include/linux/ide.h
@@ -1324,6 +1324,8 @@
 extern int ideprobe_init(void);
 
 extern void ide_scan_pcibus(int scan_direction) __init;
+extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner);
+#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE)
 extern int ide_pci_register_driver(struct pci_driver *driver);
 extern void ide_pci_unregister_driver(struct pci_driver *driver);
 void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *);

--


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

* [RFC patch 2/3] remove pci_driver.owner and .name fields
  2005-10-26 20:48 [RFC patch 0/3] remove pci_driver.owner and .name fields Laurent riffard
  2005-10-26 20:48 ` [RFC patch 1/3] " Laurent riffard
@ 2005-10-26 20:48 ` Laurent riffard
  2005-10-26 21:05   ` Roland Dreier
  2005-10-26 20:48 ` [RFC patch 3/3] " Laurent riffard
  2005-10-26 21:17 ` [RFC patch 0/3] " Al Viro
  3 siblings, 1 reply; 15+ messages in thread
From: Laurent riffard @ 2005-10-26 20:48 UTC (permalink / raw)
  To: linux-kernel, Al Viro, Greg KH, Russell King

[-- Attachment #1: remove_pci_driver_owner_name-drivers_block.patch --]
[-- Type: text/plain, Size: 2761 bytes --]

Use pci_driver.driver.name instead of pci_driver.name (this field is
planned for deletion).

This patch updates the drivers found in directory drivers/block.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
--

 drivers/block/DAC960.c   |    4 +++-
 drivers/block/cciss.c    |    4 +++-
 drivers/block/cpqarray.c |    4 +++-
 drivers/block/sx8.c      |    4 +++-
 drivers/block/umem.c     |    4 +++-
 5 files changed, 15 insertions(+), 5 deletions(-)

Index: linux-2.6-stable/drivers/block/DAC960.c
===================================================================
--- linux-2.6-stable.orig/drivers/block/DAC960.c
+++ linux-2.6-stable/drivers/block/DAC960.c
@@ -7185,7 +7185,9 @@
 MODULE_DEVICE_TABLE(pci, DAC960_id_table);
 
 static struct pci_driver DAC960_pci_driver = {
-	.name		= "DAC960",
+	.driver = {
+		.name	= "DAC960",
+	},
 	.id_table	= DAC960_id_table,
 	.probe		= DAC960_Probe,
 	.remove		= DAC960_Remove,
Index: linux-2.6-stable/drivers/block/cciss.c
===================================================================
--- linux-2.6-stable.orig/drivers/block/cciss.c
+++ linux-2.6-stable/drivers/block/cciss.c
@@ -2929,7 +2929,9 @@
 }	
 
 static struct pci_driver cciss_pci_driver = {
-	.name =		"cciss",
+	.driver = {
+		.name =	"cciss",
+	},
 	.probe =	cciss_init_one,
 	.remove =	__devexit_p(cciss_remove_one),
 	.id_table =	cciss_pci_device_id, /* id_table */
Index: linux-2.6-stable/drivers/block/cpqarray.c
===================================================================
--- linux-2.6-stable.orig/drivers/block/cpqarray.c
+++ linux-2.6-stable/drivers/block/cpqarray.c
@@ -541,7 +541,9 @@
 }
 
 static struct pci_driver cpqarray_pci_driver = {
-	.name = "cpqarray",
+	.driver = {
+		.name = "cpqarray",
+	},
 	.probe = cpqarray_init_one,
 	.remove = __devexit_p(cpqarray_remove_one_pci),
 	.id_table = cpqarray_pci_device_id,
Index: linux-2.6-stable/drivers/block/sx8.c
===================================================================
--- linux-2.6-stable.orig/drivers/block/sx8.c
+++ linux-2.6-stable/drivers/block/sx8.c
@@ -395,7 +395,9 @@
 MODULE_DEVICE_TABLE(pci, carm_pci_tbl);
 
 static struct pci_driver carm_driver = {
-	.name		= DRV_NAME,
+	.driver = {
+		.name	= DRV_NAME,
+	},
 	.id_table	= carm_pci_tbl,
 	.probe		= carm_init_one,
 	.remove		= carm_remove_one,
Index: linux-2.6-stable/drivers/block/umem.c
===================================================================
--- linux-2.6-stable.orig/drivers/block/umem.c
+++ linux-2.6-stable/drivers/block/umem.c
@@ -1170,7 +1170,9 @@
 MODULE_DEVICE_TABLE(pci, mm_pci_ids);
 
 static struct pci_driver mm_pci_driver = {
-	.name =		"umem",
+	.driver = {
+		.name =	"umem",
+	},
 	.id_table =	mm_pci_ids,
 	.probe =	mm_pci_probe,
 	.remove =	mm_pci_remove,

--


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

* [RFC patch 3/3] remove pci_driver.owner and .name fields
  2005-10-26 20:48 [RFC patch 0/3] remove pci_driver.owner and .name fields Laurent riffard
  2005-10-26 20:48 ` [RFC patch 1/3] " Laurent riffard
  2005-10-26 20:48 ` [RFC patch 2/3] " Laurent riffard
@ 2005-10-26 20:48 ` Laurent riffard
  2005-10-26 21:11   ` Greg KH
  2005-10-26 21:17 ` [RFC patch 0/3] " Al Viro
  3 siblings, 1 reply; 15+ messages in thread
From: Laurent riffard @ 2005-10-26 20:48 UTC (permalink / raw)
  To: linux-kernel, Al Viro, Greg KH, Russell King

[-- Attachment #1: remove_pci_driver_owner_name-final_cleanup.patch --]
[-- Type: text/plain, Size: 1659 bytes --]

This is the final cleanup : deletion of pci_driver.name and .owner
happens now. 

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
--

 drivers/pci/pci-driver.c |    5 -----
 include/linux/pci.h      |    8 --------
 2 files changed, 13 deletions(-)

Index: linux-2.6-stable/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6-stable.orig/drivers/pci/pci-driver.c
+++ linux-2.6-stable/drivers/pci/pci-driver.c
@@ -339,11 +339,6 @@
 	int error;
 
 	/* initialize common driver fields */
-	if (drv->name) {
-		/* backward compatibility until all pci_driver are converted to
-		 * use pci_driver.driver.name instead of pci_driver.name */
-		drv->driver.name = drv->name;
-	}
 	drv->driver.bus = &pci_bus_type;
 	drv->driver.probe = pci_device_probe;
 	drv->driver.remove = pci_device_remove;
Index: linux-2.6-stable/include/linux/pci.h
===================================================================
--- linux-2.6-stable.orig/include/linux/pci.h
+++ linux-2.6-stable/include/linux/pci.h
@@ -664,14 +664,6 @@
 struct module;
 struct pci_driver {
 	struct list_head node;
-	/*
-	 * Please do not use the 2 following fields, they are planned for
-	 * deletion.
-	 * Use driver.name instead of .name.
-	 * The field driver.owner will be set by pci_register_driver.
-	 */
-	char *name;
-	struct module *owner;
 	const struct pci_device_id *id_table;	/* must be non-NULL for probe to be called */
 	int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);	/* New device inserted */
 	void (*remove) (struct pci_dev *dev);	/* Device removed (NULL if not a hot-plug capable driver) */

--


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

* Re: [RFC patch 2/3] remove pci_driver.owner and .name fields
  2005-10-26 20:48 ` [RFC patch 2/3] " Laurent riffard
@ 2005-10-26 21:05   ` Roland Dreier
  2005-10-26 21:21     ` Al Viro
  0 siblings, 1 reply; 15+ messages in thread
From: Roland Dreier @ 2005-10-26 21:05 UTC (permalink / raw)
  To: Laurent riffard; +Cc: linux-kernel, Al Viro, Greg KH, Russell King

        > -	.name		= "DAC960",
        > +	.driver = {
        > +		.name	= "DAC960",
        > +	},

This change looks like a (rather ugly) step backwards.  Maybe it would
be better to add the name as a parameter to pci_register_driver?

 - R.

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

* Re: [RFC patch 3/3] remove pci_driver.owner and .name fields
  2005-10-26 20:48 ` [RFC patch 3/3] " Laurent riffard
@ 2005-10-26 21:11   ` Greg KH
  2005-10-26 22:22     ` Laurent Riffard
  0 siblings, 1 reply; 15+ messages in thread
From: Greg KH @ 2005-10-26 21:11 UTC (permalink / raw)
  To: Laurent riffard; +Cc: linux-kernel, Al Viro, Russell King

On Wed, Oct 26, 2005 at 10:48:05PM +0200, Laurent riffard wrote:
> This is the final cleanup : deletion of pci_driver.name and .owner
> happens now. 

what?  Did you actually try to build a kernel with this patch applied?

Sorry, but I think we have to wait a long time before this can be
appliedr...

thanks,

greg k-h

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

* Re: [RFC patch 0/3] remove pci_driver.owner and .name fields
  2005-10-26 20:48 [RFC patch 0/3] remove pci_driver.owner and .name fields Laurent riffard
                   ` (2 preceding siblings ...)
  2005-10-26 20:48 ` [RFC patch 3/3] " Laurent riffard
@ 2005-10-26 21:17 ` Al Viro
  3 siblings, 0 replies; 15+ messages in thread
From: Al Viro @ 2005-10-26 21:17 UTC (permalink / raw)
  To: Laurent riffard; +Cc: linux-kernel, Greg KH, Russell King

On Wed, Oct 26, 2005 at 10:48:02PM +0200, Laurent riffard wrote:
> I'm willing to submit patches to remove pci_driver.owner and .name
> fields. pci_driver.driver.owner and .name will be used instead.
> 
> Patch 1 prepares the core pci code for future removal of the 2
> fields, but actually do not remove them. As suggested by Al Viro,
> pci_driver.driver.owner will be set by pci_register_driver.
> 
> Patch 2 is an example of driver's update. There will be lots of
> patches like this.
> 
> Patch 3 is the final touch, after all pci_driver.name and
> pci_driver.owner are removed.
> 
> Any comments ? Feel free to correct my bad english.

After 2.6.14 gets released, please...

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

* Re: [RFC patch 1/3] remove pci_driver.owner and .name fields
  2005-10-26 20:48 ` [RFC patch 1/3] " Laurent riffard
@ 2005-10-26 21:20   ` Al Viro
  2005-10-26 22:53     ` Laurent Riffard
  0 siblings, 1 reply; 15+ messages in thread
From: Al Viro @ 2005-10-26 21:20 UTC (permalink / raw)
  To: Laurent riffard; +Cc: linux-kernel, Greg KH, Russell King

On Wed, Oct 26, 2005 at 10:48:03PM +0200, Laurent riffard wrote:
> --- linux-2.6-stable.orig/drivers/ide/setup-pci.c
> +++ linux-2.6-stable/drivers/ide/setup-pci.c
> @@ -787,8 +787,9 @@
>  static LIST_HEAD(ide_pci_drivers);
>  
>  /*
> - *	ide_register_pci_driver		-	attach IDE driver
> + *	__ide_register_pci_driver	-	attach IDE driver
>   *	@driver: pci driver
> + *	@module: owner module of the driver
>   *
>   *	Registers a driver with the IDE layer. The IDE layer arranges that
>   *	boot time setup is done in the expected device order and then 
> @@ -801,15 +802,16 @@
>   *	Returns are the same as for pci_register_driver
>   */
>  
> -int ide_pci_register_driver(struct pci_driver *driver)
> +int __ide_pci_register_driver(struct pci_driver *driver, struct module *module)
>  {
>  	if(!pre_init)
> -		return pci_module_init(driver);
> +		return __pci_register_driver(driver, module);
> +	driver->driver.owner = module;
>  	list_add_tail(&driver->node, &ide_pci_drivers);
>  	return 0;
>  }
>  
> -EXPORT_SYMBOL_GPL(ide_pci_register_driver);
> +EXPORT_SYMBOL_GPL(__ide_pci_register_driver);

Not enough - you have to deal with pci_register_driver() call later in
the same file.  Replace with __pci_register_driver(d, d->driver.owner)...

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

* Re: [RFC patch 2/3] remove pci_driver.owner and .name fields
  2005-10-26 21:05   ` Roland Dreier
@ 2005-10-26 21:21     ` Al Viro
  2005-10-26 21:30       ` Roland Dreier
  2005-10-26 21:35       ` Andrew Morton
  0 siblings, 2 replies; 15+ messages in thread
From: Al Viro @ 2005-10-26 21:21 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Laurent riffard, linux-kernel, Greg KH, Russell King

On Wed, Oct 26, 2005 at 02:05:08PM -0700, Roland Dreier wrote:
>         > -	.name		= "DAC960",
>         > +	.driver = {
>         > +		.name	= "DAC960",
>         > +	},
> 
> This change looks like a (rather ugly) step backwards.  Maybe it would
> be better to add the name as a parameter to pci_register_driver?

It looks stupid in the first place - what's wrong with
		.driver.name = "DAC960",
instead of that mess?

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

* Re: [RFC patch 2/3] remove pci_driver.owner and .name fields
  2005-10-26 21:21     ` Al Viro
@ 2005-10-26 21:30       ` Roland Dreier
  2005-10-26 21:35       ` Andrew Morton
  1 sibling, 0 replies; 15+ messages in thread
From: Roland Dreier @ 2005-10-26 21:30 UTC (permalink / raw)
  To: Al Viro; +Cc: Laurent riffard, linux-kernel, Greg KH, Russell King

    > It looks stupid in the first place - what's wrong with
    > 		.driver.name = "DAC960",
    > instead of that mess?

Unfortunately I don't think gcc 2.95 accepts that syntax.  For
example the following:

	void foo(void)
	{
		struct {
			struct {
				int y;
			} x;
		} bar = {
			.x.y = 1
		};
	}

gives

	a.c: In function `foo':
	a.c:8: unknown field `y' specified in initializer

when compiled with gcc 2.95.

I guess we could do

	.driver = { .name = "DAC960" },

but that seems silly as well.

 - R.

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

* Re: [RFC patch 2/3] remove pci_driver.owner and .name fields
  2005-10-26 21:21     ` Al Viro
  2005-10-26 21:30       ` Roland Dreier
@ 2005-10-26 21:35       ` Andrew Morton
  1 sibling, 0 replies; 15+ messages in thread
From: Andrew Morton @ 2005-10-26 21:35 UTC (permalink / raw)
  To: Al Viro; +Cc: rolandd, laurent.riffard, linux-kernel, greg, rmk+lkml

Al Viro <viro@ftp.linux.org.uk> wrote:
>
> On Wed, Oct 26, 2005 at 02:05:08PM -0700, Roland Dreier wrote:
> >         > -	.name		= "DAC960",
> >         > +	.driver = {
> >         > +		.name	= "DAC960",
> >         > +	},
> > 
> > This change looks like a (rather ugly) step backwards.  Maybe it would
> > be better to add the name as a parameter to pci_register_driver?
> 
> It looks stupid in the first place - what's wrong with
> 		.driver.name = "DAC960",
> instead of that mess?

gcc-2.95.x doesn't support that.

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

* Re: [RFC patch 3/3] remove pci_driver.owner and .name fields
  2005-10-26 21:11   ` Greg KH
@ 2005-10-26 22:22     ` Laurent Riffard
  2005-10-26 22:26       ` Greg KH
  0 siblings, 1 reply; 15+ messages in thread
From: Laurent Riffard @ 2005-10-26 22:22 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Al Viro, Russell King


Le 26.10.2005 23:11, Greg KH a écrit :
> On Wed, Oct 26, 2005 at 10:48:05PM +0200, Laurent riffard wrote:
> 
>>This is the final cleanup : deletion of pci_driver.name and .owner
>>happens now. 
> 
> 
> what?  Did you actually try to build a kernel with this patch applied?

No, a bunch of patch #2-like have to be applied first.

This third patch is to be applied after *all* the drivers are
converted to use the pci_driver.driver.{name|owner} fields.

> Sorry, but I think we have to wait a long time before this can be
> appliedr...

Yes, I know. Is it worth to do it ?

> thanks,
> 
> greg k-h

thanks
--
laurent


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

* Re: [RFC patch 3/3] remove pci_driver.owner and .name fields
  2005-10-26 22:22     ` Laurent Riffard
@ 2005-10-26 22:26       ` Greg KH
  2005-10-26 22:57         ` Laurent Riffard
  0 siblings, 1 reply; 15+ messages in thread
From: Greg KH @ 2005-10-26 22:26 UTC (permalink / raw)
  To: Laurent Riffard; +Cc: linux-kernel, Al Viro, Russell King

On Thu, Oct 27, 2005 at 12:22:27AM +0200, Laurent Riffard wrote:
> 
> Le 26.10.2005 23:11, Greg KH a ?crit :
> > On Wed, Oct 26, 2005 at 10:48:05PM +0200, Laurent riffard wrote:
> > 
> >>This is the final cleanup : deletion of pci_driver.name and .owner
> >>happens now. 
> > 
> > 
> > what?  Did you actually try to build a kernel with this patch applied?
> 
> No, a bunch of patch #2-like have to be applied first.
> 
> This third patch is to be applied after *all* the drivers are
> converted to use the pci_driver.driver.{name|owner} fields.
> 
> > Sorry, but I think we have to wait a long time before this can be
> > appliedr...
> 
> Yes, I know. Is it worth to do it ?

The .owner stuff, yes.  Do that first and then we can revisit the .name
stuff and see if that is worth it or not.

thanks,

greg k-h

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

* Re: [RFC patch 1/3] remove pci_driver.owner and .name fields
  2005-10-26 21:20   ` Al Viro
@ 2005-10-26 22:53     ` Laurent Riffard
  0 siblings, 0 replies; 15+ messages in thread
From: Laurent Riffard @ 2005-10-26 22:53 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel, Greg KH, Russell King

[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]



Le 26.10.2005 23:20, Al Viro a écrit :
> On Wed, Oct 26, 2005 at 10:48:03PM +0200, Laurent riffard wrote:
> 
>>--- linux-2.6-stable.orig/drivers/ide/setup-pci.c
>>+++ linux-2.6-stable/drivers/ide/setup-pci.c
>>@@ -787,8 +787,9 @@
>> static LIST_HEAD(ide_pci_drivers);
>> 
>> /*
>>- *	ide_register_pci_driver		-	attach IDE driver
>>+ *	__ide_register_pci_driver	-	attach IDE driver
>>  *	@driver: pci driver
>>+ *	@module: owner module of the driver
>>  *
>>  *	Registers a driver with the IDE layer. The IDE layer arranges that
>>  *	boot time setup is done in the expected device order and then 
>>@@ -801,15 +802,16 @@
>>  *	Returns are the same as for pci_register_driver
>>  */
>> 
>>-int ide_pci_register_driver(struct pci_driver *driver)
>>+int __ide_pci_register_driver(struct pci_driver *driver, struct module *module)
>> {
>> 	if(!pre_init)
>>-		return pci_module_init(driver);
>>+		return __pci_register_driver(driver, module);
>>+	driver->driver.owner = module;
>> 	list_add_tail(&driver->node, &ide_pci_drivers);
>> 	return 0;
>> }
>> 
>>-EXPORT_SYMBOL_GPL(ide_pci_register_driver);
>>+EXPORT_SYMBOL_GPL(__ide_pci_register_driver);
> 
> 
> Not enough - you have to deal with pci_register_driver() call later in
> the same file.  Replace with __pci_register_driver(d, d->driver.owner)...

My bad, I should have have tried to check that...

Here is an updated patch, it includes your above remark and some
fixes related to .name deletion.

thanks
-- 
laurent

[-- Attachment #2: remove_pci_driver_owner_name-pci_core.patch --]
[-- Type: text/x-patch, Size: 6763 bytes --]

pci_driver.name and .owner are duplicates of pci_driver.driver.name
and .owner.

This patch prepares the core pci code for future removal of the 2
pci_driver's fields, but actually do not remove them. 

Driver developpers should set pci_driver.driver.name, while
pci_driver.driver.owner will be set by pci_register_driver.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
--

 drivers/ide/setup-pci.c  |   12 +++++++-----
 drivers/pci/pci-driver.c |   19 +++++++++++++------
 drivers/pci/proc.c       |    2 +-
 include/linux/ide.h      |    3 ++-
 include/linux/pci.h      |   11 +++++++++--
 5 files changed, 32 insertions(+), 15 deletions(-)

Index: linux-2.6-stable/include/linux/pci.h
===================================================================
--- linux-2.6-stable.orig/include/linux/pci.h
+++ linux-2.6-stable/include/linux/pci.h
@@ -664,6 +664,12 @@
 struct module;
 struct pci_driver {
 	struct list_head node;
+	/*
+	 * Please do not use the 2 following fields, they are planned for
+	 * deletion.
+	 * Use driver.name instead of .name.
+	 * The field driver.owner will be set by pci_register_driver.
+	 */
 	char *name;
 	struct module *owner;
 	const struct pci_device_id *id_table;	/* must be non-NULL for probe to be called */
@@ -857,7 +863,8 @@
 void pci_enable_bridges(struct pci_bus *bus);
 
 /* New-style probing supporting hot-pluggable devices */
-int pci_register_driver(struct pci_driver *);
+int __pci_register_driver(struct pci_driver *, struct module *);
+#define pci_register_driver(d) __pci_register_driver(d, THIS_MODULE)
 void pci_unregister_driver(struct pci_driver *);
 void pci_remove_behind_bridge(struct pci_dev *);
 struct pci_driver *pci_dev_driver(const struct pci_dev *);
@@ -957,7 +964,7 @@
 static inline void pci_disable_device(struct pci_dev *dev) { }
 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
 static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}
-static inline int pci_register_driver(struct pci_driver *drv) { return 0;}
+static inline int __pci_register_driver(struct pci_driver *drv, struct module *owner) { return 0;}
 static inline void pci_unregister_driver(struct pci_driver *drv) { }
 static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; }
 static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; }
Index: linux-2.6-stable/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6-stable.orig/drivers/pci/pci-driver.c
+++ linux-2.6-stable/drivers/pci/pci-driver.c
@@ -325,20 +325,25 @@
 };
 
 /**
- * pci_register_driver - register a new pci driver
+ * __pci_register_driver - register a new pci driver
  * @drv: the driver structure to register
+ * @owner: owner module of drv
  * 
  * Adds the driver structure to the list of registered drivers.
  * Returns a negative value on error, otherwise 0. 
  * If no error occurred, the driver remains registered even if 
  * no device was claimed during registration.
  */
-int pci_register_driver(struct pci_driver *drv)
+int __pci_register_driver(struct pci_driver *drv, struct module *owner)
 {
 	int error;
 
 	/* initialize common driver fields */
-	drv->driver.name = drv->name;
+	if (drv->name) {
+		/* backward compatibility until all pci_driver are converted to
+		 * use pci_driver.driver.name instead of pci_driver.name */
+		drv->driver.name = drv->name;
+	}
 	drv->driver.bus = &pci_bus_type;
 	drv->driver.probe = pci_device_probe;
 	drv->driver.remove = pci_device_remove;
@@ -346,7 +351,7 @@
 	 * the pci shutdown function, this test can go away. */
 	if (!drv->driver.shutdown)
 		drv->driver.shutdown = pci_device_shutdown;
-	drv->driver.owner = drv->owner;
+	drv->driver.owner = owner;
 	drv->driver.kobj.ktype = &pci_driver_kobj_type;
 
 	spin_lock_init(&drv->dynids.lock);
@@ -379,7 +384,9 @@
 }
 
 static struct pci_driver pci_compat_driver = {
-	.name = "compat"
+	.driver = {
+		.name = "compat"
+	}
 };
 
 /**
@@ -483,7 +490,7 @@
 
 EXPORT_SYMBOL(pci_match_id);
 EXPORT_SYMBOL(pci_match_device);
-EXPORT_SYMBOL(pci_register_driver);
+EXPORT_SYMBOL(__pci_register_driver);
 EXPORT_SYMBOL(pci_unregister_driver);
 EXPORT_SYMBOL(pci_dev_driver);
 EXPORT_SYMBOL(pci_bus_type);
Index: linux-2.6-stable/drivers/ide/setup-pci.c
===================================================================
--- linux-2.6-stable.orig/drivers/ide/setup-pci.c
+++ linux-2.6-stable/drivers/ide/setup-pci.c
@@ -787,8 +787,9 @@
 static LIST_HEAD(ide_pci_drivers);
 
 /*
- *	ide_register_pci_driver		-	attach IDE driver
+ *	__ide_register_pci_driver	-	attach IDE driver
  *	@driver: pci driver
+ *	@module: owner module of the driver
  *
  *	Registers a driver with the IDE layer. The IDE layer arranges that
  *	boot time setup is done in the expected device order and then 
@@ -801,15 +802,16 @@
  *	Returns are the same as for pci_register_driver
  */
 
-int ide_pci_register_driver(struct pci_driver *driver)
+int __ide_pci_register_driver(struct pci_driver *driver, struct module *module)
 {
 	if(!pre_init)
-		return pci_module_init(driver);
+		return __pci_register_driver(driver, module);
+	driver->driver.owner = module;
 	list_add_tail(&driver->node, &ide_pci_drivers);
 	return 0;
 }
 
-EXPORT_SYMBOL_GPL(ide_pci_register_driver);
+EXPORT_SYMBOL_GPL(__ide_pci_register_driver);
 
 /**
  *	ide_unregister_pci_driver	-	unregister an IDE driver
@@ -897,6 +899,6 @@
 	{
 		list_del(l);
 		d = list_entry(l, struct pci_driver, node);
-		pci_register_driver(d);
+		__pci_register_driver(d, d->driver.owner);
 	}
 }
Index: linux-2.6-stable/include/linux/ide.h
===================================================================
--- linux-2.6-stable.orig/include/linux/ide.h
+++ linux-2.6-stable/include/linux/ide.h
@@ -1324,7 +1324,8 @@
 extern int ideprobe_init(void);
 
 extern void ide_scan_pcibus(int scan_direction) __init;
-extern int ide_pci_register_driver(struct pci_driver *driver);
+extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner);
+#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE)
 extern void ide_pci_unregister_driver(struct pci_driver *driver);
 void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *);
 extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d);
Index: linux-2.6-stable/drivers/pci/proc.c
===================================================================
--- linux-2.6-stable.orig/drivers/pci/proc.c
+++ linux-2.6-stable/drivers/pci/proc.c
@@ -371,7 +371,7 @@
 	}
 	seq_putc(m, '\t');
 	if (drv)
-		seq_printf(m, "%s", drv->name);
+		seq_printf(m, "%s", drv->driver.name);
 	seq_putc(m, '\n');
 	return 0;
 }

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

* Re: [RFC patch 3/3] remove pci_driver.owner and .name fields
  2005-10-26 22:26       ` Greg KH
@ 2005-10-26 22:57         ` Laurent Riffard
  0 siblings, 0 replies; 15+ messages in thread
From: Laurent Riffard @ 2005-10-26 22:57 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Al Viro, Russell King


Le 27.10.2005 00:26, Greg KH a écrit :
> On Thu, Oct 27, 2005 at 12:22:27AM +0200, Laurent Riffard wrote:
> 
>>Le 26.10.2005 23:11, Greg KH a ?crit :
>>
>>>On Wed, Oct 26, 2005 at 10:48:05PM +0200, Laurent riffard wrote:
>>>
>>>
>>>>This is the final cleanup : deletion of pci_driver.name and .owner
>>>>happens now. 
>>>
>>>
>>>what?  Did you actually try to build a kernel with this patch applied?
>>
>>No, a bunch of patch #2-like have to be applied first.
>>
>>This third patch is to be applied after *all* the drivers are
>>converted to use the pci_driver.driver.{name|owner} fields.
>>
>>
>>>Sorry, but I think we have to wait a long time before this can be
>>>appliedr...
>>
>>Yes, I know. Is it worth to do it ?
> 
> 
> The .owner stuff, yes.  Do that first and then we can revisit the .name
> stuff and see if that is worth it or not.
> 
> thanks,
> 
> greg k-h

Ok, I'll try to submit tomorrow such a patch.

thanks
-- 
laurent

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

end of thread, other threads:[~2005-10-26 22:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-26 20:48 [RFC patch 0/3] remove pci_driver.owner and .name fields Laurent riffard
2005-10-26 20:48 ` [RFC patch 1/3] " Laurent riffard
2005-10-26 21:20   ` Al Viro
2005-10-26 22:53     ` Laurent Riffard
2005-10-26 20:48 ` [RFC patch 2/3] " Laurent riffard
2005-10-26 21:05   ` Roland Dreier
2005-10-26 21:21     ` Al Viro
2005-10-26 21:30       ` Roland Dreier
2005-10-26 21:35       ` Andrew Morton
2005-10-26 20:48 ` [RFC patch 3/3] " Laurent riffard
2005-10-26 21:11   ` Greg KH
2005-10-26 22:22     ` Laurent Riffard
2005-10-26 22:26       ` Greg KH
2005-10-26 22:57         ` Laurent Riffard
2005-10-26 21:17 ` [RFC patch 0/3] " Al Viro

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