remove pci_driver.owner and .name fields
Subsystems (2)
cover remove pci_driver.owner and .name fields
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
RFC PATCH 1/3 remove pci_driver.owner and .name fields
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.
--
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(-)
include/linux/pci.h +9 -2
@@ -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 ; }
drivers/pci/pci-driver.c +9 -4
@@ -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);
drivers/ide/setup-pci.c +6 -4
@@ -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
include/linux/ide.h +2 -0
@@ -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 *);
--
Quoted 20 lines · Laurent riffard
drivers/ide/setup-pci.c +3
-2@@ -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) {
drivers/ide/setup-pci.c line 814
Quoted 10 lines
drivers/ide/setup-pci.c +3
-2if (!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)...
Quoted 30 lines · Al Viro
Quoted 28 lines · Laurent riffard
drivers/ide/setup-pci.c +5
-3@@ -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 ; }
Quoted 6 lines
drivers/ide/setup-pci.c line 814
Quoted 2 lines
drivers/ide/setup-pci.c +1
-1-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
Signature · 1 line
laurent
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.
--
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(-)
include/linux/pci.h +9 -2
@@ -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 ; }
drivers/pci/pci-driver.c +13 -6
@@ -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);
drivers/ide/setup-pci.c +7 -5
@@ -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); } }
include/linux/ide.h +2 -1
@@ -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);
drivers/pci/proc.c +1 -1
@@ -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 ; }
RFC PATCH 2/3 remove pci_driver.owner and .name fields
In reply to Laurent riffardUse 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.
--
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(-)
drivers/block/DAC960.c +3 -1
@@ -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,
drivers/block/cciss.c +3 -1
@@ -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 */
drivers/block/cpqarray.c +3 -1
@@ -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,
drivers/block/sx8.c +3 -1
@@ -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,
drivers/block/umem.c +3 -1
@@ -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,
--
> - .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.
Quoted 7 lines · Roland Dreier
> - .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?
Quoted 3 lines
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.
Quoted 7 lines · Al Viro
Quoted 5 lines · Roland Dreier
> - .name = "DAC960", > + .driver = { > + .name = "DAC960", > + },
Quoted 6 lines
Quoted 2 lines
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.
RFC PATCH 3/3 remove pci_driver.owner and .name fields
In reply to Laurent riffardThis is the final cleanup : deletion of pci_driver.name and .owner happens now.
--
drivers/pci/pci-driver.c | 5 ----- include/linux/pci.h | 8 -------- 2 files changed, 13 deletions(-)
drivers/pci/pci-driver.c +0 -5
@@ -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;
include/linux/pci.h +0 -8
@@ -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) */
--
Quoted 2 lines · Laurent riffard
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
Quoted 7 lines · Greg KH
Quoted 2 lines · Laurent riffard
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.
Quoted 2 lines
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 ?
Quoted 3 lines
thanks,
greg k-h
thanks
--
laurent
Quoted 12 lines · Laurent Riffard
Le 26.10.2005 23:11, Greg KH a ?crit :
Quoted 7 lines · Laurent riffard
Quoted 3 lines
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.
Quoted 7 lines
This third patch is to be applied after *all* the drivers are converted to use the pci_driver.driver.{name|owner} fields.
Quoted 2 lines
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
Quoted 25 lines · Greg KH
Quoted 13 lines · Laurent Riffard
Le 26.10.2005 23:11, Greg KH a ?crit :
Quoted 8 lines · Laurent riffard
Quoted 4 lines
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.
Quoted 8 lines
This third patch is to be applied after *all* the drivers are converted to use the pci_driver.driver.{name|owner} fields.
Quoted 2 lines
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 ?
Quoted 6 lines
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
Signature · 1 line
laurent
Quoted 7 lines · Laurent riffard
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.
Quoted 7 lines
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...