diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2012-03-26 15:06:30 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2012-03-27 20:33:24 -0400 |
commit | cb52d8970eee65bf2c47d9a91bd4f58b17f595f4 (patch) | |
tree | 43521ba99805f293e09a284901cb5435afeab789 /arch/sparc | |
parent | 1d9a47315042606b4217691bcea36cfa6ccbde66 (diff) |
powerpc+sparc/vio: Modernize driver registration
This makes vio_register_driver() get the module owner & name at compile
time like PCI drivers do, and adds a name pointer directly in struct
vio_driver to avoid having to explicitly initialize the embedded
struct device.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/include/asm/vio.h | 9 | ||||
-rw-r--r-- | arch/sparc/kernel/ds.c | 5 | ||||
-rw-r--r-- | arch/sparc/kernel/vio.c | 8 |
3 files changed, 15 insertions, 7 deletions
diff --git a/arch/sparc/include/asm/vio.h b/arch/sparc/include/asm/vio.h index 9d83d3bcb494..432afa838861 100644 --- a/arch/sparc/include/asm/vio.h +++ b/arch/sparc/include/asm/vio.h | |||
@@ -284,6 +284,7 @@ struct vio_dev { | |||
284 | }; | 284 | }; |
285 | 285 | ||
286 | struct vio_driver { | 286 | struct vio_driver { |
287 | const char *name; | ||
287 | struct list_head node; | 288 | struct list_head node; |
288 | const struct vio_device_id *id_table; | 289 | const struct vio_device_id *id_table; |
289 | int (*probe)(struct vio_dev *dev, const struct vio_device_id *id); | 290 | int (*probe)(struct vio_dev *dev, const struct vio_device_id *id); |
@@ -371,7 +372,13 @@ do { if (vio->debug & VIO_DEBUG_##TYPE) \ | |||
371 | vio->vdev->channel_id, ## a); \ | 372 | vio->vdev->channel_id, ## a); \ |
372 | } while (0) | 373 | } while (0) |
373 | 374 | ||
374 | extern int vio_register_driver(struct vio_driver *drv); | 375 | extern int __vio_register_driver(struct vio_driver *drv, struct module *owner, |
376 | const char *mod_name); | ||
377 | /* | ||
378 | * vio_register_driver must be a macro so that KBUILD_MODNAME can be expanded | ||
379 | */ | ||
380 | #define vio_register_driver(driver) \ | ||
381 | __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) | ||
375 | extern void vio_unregister_driver(struct vio_driver *drv); | 382 | extern void vio_unregister_driver(struct vio_driver *drv); |
376 | 383 | ||
377 | static inline struct vio_driver *to_vio_driver(struct device_driver *drv) | 384 | static inline struct vio_driver *to_vio_driver(struct device_driver *drv) |
diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c index 381edcd5bc29..fea13c7b1aee 100644 --- a/arch/sparc/kernel/ds.c +++ b/arch/sparc/kernel/ds.c | |||
@@ -1244,10 +1244,7 @@ static struct vio_driver ds_driver = { | |||
1244 | .id_table = ds_match, | 1244 | .id_table = ds_match, |
1245 | .probe = ds_probe, | 1245 | .probe = ds_probe, |
1246 | .remove = ds_remove, | 1246 | .remove = ds_remove, |
1247 | .driver = { | 1247 | .name = "ds", |
1248 | .name = "ds", | ||
1249 | .owner = THIS_MODULE, | ||
1250 | } | ||
1251 | }; | 1248 | }; |
1252 | 1249 | ||
1253 | static int __init ds_init(void) | 1250 | static int __init ds_init(void) |
diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c index f67e28ef598c..5cffdc55f075 100644 --- a/arch/sparc/kernel/vio.c +++ b/arch/sparc/kernel/vio.c | |||
@@ -119,13 +119,17 @@ static struct bus_type vio_bus_type = { | |||
119 | .remove = vio_device_remove, | 119 | .remove = vio_device_remove, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | int vio_register_driver(struct vio_driver *viodrv) | 122 | int __vio_register_driver(struct vio_driver *viodrv, struct module *owner, |
123 | const char *mod_name) | ||
123 | { | 124 | { |
124 | viodrv->driver.bus = &vio_bus_type; | 125 | viodrv->driver.bus = &vio_bus_type; |
126 | viodrv->driver.name = viodrv->name; | ||
127 | viodrv->driver.owner = owner; | ||
128 | viodrv->driver.mod_name = mod_name; | ||
125 | 129 | ||
126 | return driver_register(&viodrv->driver); | 130 | return driver_register(&viodrv->driver); |
127 | } | 131 | } |
128 | EXPORT_SYMBOL(vio_register_driver); | 132 | EXPORT_SYMBOL(__vio_register_driver); |
129 | 133 | ||
130 | void vio_unregister_driver(struct vio_driver *viodrv) | 134 | void vio_unregister_driver(struct vio_driver *viodrv) |
131 | { | 135 | { |