diff options
author | Jan Beulich <JBeulich@suse.com> | 2011-12-22 04:08:13 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-01-04 17:01:17 -0500 |
commit | 73db144b58a32fc39733db6a7e1fe582072ad26a (patch) | |
tree | f03edee848be5aa085c30d493c02a5ee1b8fc3da /drivers | |
parent | 2e16341438c9eca15a2e0bb2ad8555bbdf24b86d (diff) |
Xen: consolidate and simplify struct xenbus_driver instantiation
The 'name', 'owner', and 'mod_name' members are redundant with the
identically named fields in the 'driver' sub-structure. Rather than
switching each instance to specify these fields explicitly, introduce
a macro to simplify this.
Eliminate further redundancy by allowing the drvname argument to
DEFINE_XENBUS_DRIVER() to be blank (in which case the first entry from
the ID table will be used for .driver.name).
Also eliminate the questionable xenbus_register_{back,front}end()
wrappers - their sole remaining purpose was the checking of the
'owner' field, proper setting of which shouldn't be an issue anymore
when the macro gets used.
v2: Restore DRV_NAME for the driver name in xen-pciback.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/xen-blkback/xenbus.c | 9 | ||||
-rw-r--r-- | drivers/block/xen-blkfront.c | 11 | ||||
-rw-r--r-- | drivers/input/misc/xen-kbdfront.c | 7 | ||||
-rw-r--r-- | drivers/net/xen-netback/xenbus.c | 9 | ||||
-rw-r--r-- | drivers/net/xen-netfront.c | 9 | ||||
-rw-r--r-- | drivers/pci/xen-pcifront.c | 11 | ||||
-rw-r--r-- | drivers/video/xen-fbfront.c | 9 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/xenbus.c | 13 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe.c | 7 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe.h | 4 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe_backend.c | 8 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe_frontend.c | 8 |
12 files changed, 35 insertions, 70 deletions
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index f759ad4584c3..edbb69ebdf20 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c | |||
@@ -787,17 +787,14 @@ static const struct xenbus_device_id xen_blkbk_ids[] = { | |||
787 | }; | 787 | }; |
788 | 788 | ||
789 | 789 | ||
790 | static struct xenbus_driver xen_blkbk = { | 790 | static DEFINE_XENBUS_DRIVER(xen_blkbk, , |
791 | .name = "vbd", | ||
792 | .owner = THIS_MODULE, | ||
793 | .ids = xen_blkbk_ids, | ||
794 | .probe = xen_blkbk_probe, | 791 | .probe = xen_blkbk_probe, |
795 | .remove = xen_blkbk_remove, | 792 | .remove = xen_blkbk_remove, |
796 | .otherend_changed = frontend_changed | 793 | .otherend_changed = frontend_changed |
797 | }; | 794 | ); |
798 | 795 | ||
799 | 796 | ||
800 | int xen_blkif_xenbus_init(void) | 797 | int xen_blkif_xenbus_init(void) |
801 | { | 798 | { |
802 | return xenbus_register_backend(&xen_blkbk); | 799 | return xenbus_register_backend(&xen_blkbk_driver); |
803 | } | 800 | } |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 7b2ec5908413..9fd3ee203b1e 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -1437,16 +1437,13 @@ static const struct xenbus_device_id blkfront_ids[] = { | |||
1437 | { "" } | 1437 | { "" } |
1438 | }; | 1438 | }; |
1439 | 1439 | ||
1440 | static struct xenbus_driver blkfront = { | 1440 | static DEFINE_XENBUS_DRIVER(blkfront, , |
1441 | .name = "vbd", | ||
1442 | .owner = THIS_MODULE, | ||
1443 | .ids = blkfront_ids, | ||
1444 | .probe = blkfront_probe, | 1441 | .probe = blkfront_probe, |
1445 | .remove = blkfront_remove, | 1442 | .remove = blkfront_remove, |
1446 | .resume = blkfront_resume, | 1443 | .resume = blkfront_resume, |
1447 | .otherend_changed = blkback_changed, | 1444 | .otherend_changed = blkback_changed, |
1448 | .is_ready = blkfront_is_ready, | 1445 | .is_ready = blkfront_is_ready, |
1449 | }; | 1446 | ); |
1450 | 1447 | ||
1451 | static int __init xlblk_init(void) | 1448 | static int __init xlblk_init(void) |
1452 | { | 1449 | { |
@@ -1461,7 +1458,7 @@ static int __init xlblk_init(void) | |||
1461 | return -ENODEV; | 1458 | return -ENODEV; |
1462 | } | 1459 | } |
1463 | 1460 | ||
1464 | ret = xenbus_register_frontend(&blkfront); | 1461 | ret = xenbus_register_frontend(&blkfront_driver); |
1465 | if (ret) { | 1462 | if (ret) { |
1466 | unregister_blkdev(XENVBD_MAJOR, DEV_NAME); | 1463 | unregister_blkdev(XENVBD_MAJOR, DEV_NAME); |
1467 | return ret; | 1464 | return ret; |
@@ -1474,7 +1471,7 @@ module_init(xlblk_init); | |||
1474 | 1471 | ||
1475 | static void __exit xlblk_exit(void) | 1472 | static void __exit xlblk_exit(void) |
1476 | { | 1473 | { |
1477 | return xenbus_unregister_driver(&blkfront); | 1474 | return xenbus_unregister_driver(&blkfront_driver); |
1478 | } | 1475 | } |
1479 | module_exit(xlblk_exit); | 1476 | module_exit(xlblk_exit); |
1480 | 1477 | ||
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c index ad2e51c04db8..02ca8680ea5b 100644 --- a/drivers/input/misc/xen-kbdfront.c +++ b/drivers/input/misc/xen-kbdfront.c | |||
@@ -361,15 +361,12 @@ static const struct xenbus_device_id xenkbd_ids[] = { | |||
361 | { "" } | 361 | { "" } |
362 | }; | 362 | }; |
363 | 363 | ||
364 | static struct xenbus_driver xenkbd_driver = { | 364 | static DEFINE_XENBUS_DRIVER(xenkbd, , |
365 | .name = "vkbd", | ||
366 | .owner = THIS_MODULE, | ||
367 | .ids = xenkbd_ids, | ||
368 | .probe = xenkbd_probe, | 365 | .probe = xenkbd_probe, |
369 | .remove = xenkbd_remove, | 366 | .remove = xenkbd_remove, |
370 | .resume = xenkbd_resume, | 367 | .resume = xenkbd_resume, |
371 | .otherend_changed = xenkbd_backend_changed, | 368 | .otherend_changed = xenkbd_backend_changed, |
372 | }; | 369 | ); |
373 | 370 | ||
374 | static int __init xenkbd_init(void) | 371 | static int __init xenkbd_init(void) |
375 | { | 372 | { |
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index 1ce729d6af75..410018c4c528 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c | |||
@@ -474,17 +474,14 @@ static const struct xenbus_device_id netback_ids[] = { | |||
474 | }; | 474 | }; |
475 | 475 | ||
476 | 476 | ||
477 | static struct xenbus_driver netback = { | 477 | static DEFINE_XENBUS_DRIVER(netback, , |
478 | .name = "vif", | ||
479 | .owner = THIS_MODULE, | ||
480 | .ids = netback_ids, | ||
481 | .probe = netback_probe, | 478 | .probe = netback_probe, |
482 | .remove = netback_remove, | 479 | .remove = netback_remove, |
483 | .uevent = netback_uevent, | 480 | .uevent = netback_uevent, |
484 | .otherend_changed = frontend_changed, | 481 | .otherend_changed = frontend_changed, |
485 | }; | 482 | ); |
486 | 483 | ||
487 | int xenvif_xenbus_init(void) | 484 | int xenvif_xenbus_init(void) |
488 | { | 485 | { |
489 | return xenbus_register_backend(&netback); | 486 | return xenbus_register_backend(&netback_driver); |
490 | } | 487 | } |
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 226faab23603..81ff5a749279 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
@@ -1910,7 +1910,7 @@ static void xennet_sysfs_delif(struct net_device *netdev) | |||
1910 | 1910 | ||
1911 | #endif /* CONFIG_SYSFS */ | 1911 | #endif /* CONFIG_SYSFS */ |
1912 | 1912 | ||
1913 | static struct xenbus_device_id netfront_ids[] = { | 1913 | static const struct xenbus_device_id netfront_ids[] = { |
1914 | { "vif" }, | 1914 | { "vif" }, |
1915 | { "" } | 1915 | { "" } |
1916 | }; | 1916 | }; |
@@ -1937,15 +1937,12 @@ static int __devexit xennet_remove(struct xenbus_device *dev) | |||
1937 | return 0; | 1937 | return 0; |
1938 | } | 1938 | } |
1939 | 1939 | ||
1940 | static struct xenbus_driver netfront_driver = { | 1940 | static DEFINE_XENBUS_DRIVER(netfront, , |
1941 | .name = "vif", | ||
1942 | .owner = THIS_MODULE, | ||
1943 | .ids = netfront_ids, | ||
1944 | .probe = netfront_probe, | 1941 | .probe = netfront_probe, |
1945 | .remove = __devexit_p(xennet_remove), | 1942 | .remove = __devexit_p(xennet_remove), |
1946 | .resume = netfront_resume, | 1943 | .resume = netfront_resume, |
1947 | .otherend_changed = netback_changed, | 1944 | .otherend_changed = netback_changed, |
1948 | }; | 1945 | ); |
1949 | 1946 | ||
1950 | static int __init netif_init(void) | 1947 | static int __init netif_init(void) |
1951 | { | 1948 | { |
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 90832a955991..7cf3d2fcf56a 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c | |||
@@ -1126,14 +1126,11 @@ static const struct xenbus_device_id xenpci_ids[] = { | |||
1126 | {""}, | 1126 | {""}, |
1127 | }; | 1127 | }; |
1128 | 1128 | ||
1129 | static struct xenbus_driver xenbus_pcifront_driver = { | 1129 | static DEFINE_XENBUS_DRIVER(xenpci, "pcifront", |
1130 | .name = "pcifront", | ||
1131 | .owner = THIS_MODULE, | ||
1132 | .ids = xenpci_ids, | ||
1133 | .probe = pcifront_xenbus_probe, | 1130 | .probe = pcifront_xenbus_probe, |
1134 | .remove = pcifront_xenbus_remove, | 1131 | .remove = pcifront_xenbus_remove, |
1135 | .otherend_changed = pcifront_backend_changed, | 1132 | .otherend_changed = pcifront_backend_changed, |
1136 | }; | 1133 | ); |
1137 | 1134 | ||
1138 | static int __init pcifront_init(void) | 1135 | static int __init pcifront_init(void) |
1139 | { | 1136 | { |
@@ -1142,12 +1139,12 @@ static int __init pcifront_init(void) | |||
1142 | 1139 | ||
1143 | pci_frontend_registrar(1 /* enable */); | 1140 | pci_frontend_registrar(1 /* enable */); |
1144 | 1141 | ||
1145 | return xenbus_register_frontend(&xenbus_pcifront_driver); | 1142 | return xenbus_register_frontend(&xenpci_driver); |
1146 | } | 1143 | } |
1147 | 1144 | ||
1148 | static void __exit pcifront_cleanup(void) | 1145 | static void __exit pcifront_cleanup(void) |
1149 | { | 1146 | { |
1150 | xenbus_unregister_driver(&xenbus_pcifront_driver); | 1147 | xenbus_unregister_driver(&xenpci_driver); |
1151 | pci_frontend_registrar(0 /* disable */); | 1148 | pci_frontend_registrar(0 /* disable */); |
1152 | } | 1149 | } |
1153 | module_init(pcifront_init); | 1150 | module_init(pcifront_init); |
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c index beac52fc1c0e..cb4529c40d74 100644 --- a/drivers/video/xen-fbfront.c +++ b/drivers/video/xen-fbfront.c | |||
@@ -671,20 +671,17 @@ InitWait: | |||
671 | } | 671 | } |
672 | } | 672 | } |
673 | 673 | ||
674 | static struct xenbus_device_id xenfb_ids[] = { | 674 | static const struct xenbus_device_id xenfb_ids[] = { |
675 | { "vfb" }, | 675 | { "vfb" }, |
676 | { "" } | 676 | { "" } |
677 | }; | 677 | }; |
678 | 678 | ||
679 | static struct xenbus_driver xenfb_driver = { | 679 | static DEFINE_XENBUS_DRIVER(xenfb, , |
680 | .name = "vfb", | ||
681 | .owner = THIS_MODULE, | ||
682 | .ids = xenfb_ids, | ||
683 | .probe = xenfb_probe, | 680 | .probe = xenfb_probe, |
684 | .remove = xenfb_remove, | 681 | .remove = xenfb_remove, |
685 | .resume = xenfb_resume, | 682 | .resume = xenfb_resume, |
686 | .otherend_changed = xenfb_backend_changed, | 683 | .otherend_changed = xenfb_backend_changed, |
687 | }; | 684 | ); |
688 | 685 | ||
689 | static int __init xenfb_init(void) | 686 | static int __init xenfb_init(void) |
690 | { | 687 | { |
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c index 075525945e36..c80f9c84d08e 100644 --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c | |||
@@ -707,19 +707,16 @@ static int xen_pcibk_xenbus_remove(struct xenbus_device *dev) | |||
707 | return 0; | 707 | return 0; |
708 | } | 708 | } |
709 | 709 | ||
710 | static const struct xenbus_device_id xenpci_ids[] = { | 710 | static const struct xenbus_device_id xen_pcibk_ids[] = { |
711 | {"pci"}, | 711 | {"pci"}, |
712 | {""}, | 712 | {""}, |
713 | }; | 713 | }; |
714 | 714 | ||
715 | static struct xenbus_driver xenbus_xen_pcibk_driver = { | 715 | static DEFINE_XENBUS_DRIVER(xen_pcibk, DRV_NAME, |
716 | .name = DRV_NAME, | ||
717 | .owner = THIS_MODULE, | ||
718 | .ids = xenpci_ids, | ||
719 | .probe = xen_pcibk_xenbus_probe, | 716 | .probe = xen_pcibk_xenbus_probe, |
720 | .remove = xen_pcibk_xenbus_remove, | 717 | .remove = xen_pcibk_xenbus_remove, |
721 | .otherend_changed = xen_pcibk_frontend_changed, | 718 | .otherend_changed = xen_pcibk_frontend_changed, |
722 | }; | 719 | ); |
723 | 720 | ||
724 | const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; | 721 | const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; |
725 | 722 | ||
@@ -735,11 +732,11 @@ int __init xen_pcibk_xenbus_register(void) | |||
735 | if (passthrough) | 732 | if (passthrough) |
736 | xen_pcibk_backend = &xen_pcibk_passthrough_backend; | 733 | xen_pcibk_backend = &xen_pcibk_passthrough_backend; |
737 | pr_info(DRV_NAME ": backend is %s\n", xen_pcibk_backend->name); | 734 | pr_info(DRV_NAME ": backend is %s\n", xen_pcibk_backend->name); |
738 | return xenbus_register_backend(&xenbus_xen_pcibk_driver); | 735 | return xenbus_register_backend(&xen_pcibk_driver); |
739 | } | 736 | } |
740 | 737 | ||
741 | void __exit xen_pcibk_xenbus_unregister(void) | 738 | void __exit xen_pcibk_xenbus_unregister(void) |
742 | { | 739 | { |
743 | destroy_workqueue(xen_pcibk_wq); | 740 | destroy_workqueue(xen_pcibk_wq); |
744 | xenbus_unregister_driver(&xenbus_xen_pcibk_driver); | 741 | xenbus_unregister_driver(&xen_pcibk_driver); |
745 | } | 742 | } |
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 1c05b2508ae8..3864967202b5 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c | |||
@@ -291,14 +291,9 @@ void xenbus_dev_shutdown(struct device *_dev) | |||
291 | EXPORT_SYMBOL_GPL(xenbus_dev_shutdown); | 291 | EXPORT_SYMBOL_GPL(xenbus_dev_shutdown); |
292 | 292 | ||
293 | int xenbus_register_driver_common(struct xenbus_driver *drv, | 293 | int xenbus_register_driver_common(struct xenbus_driver *drv, |
294 | struct xen_bus_type *bus, | 294 | struct xen_bus_type *bus) |
295 | struct module *owner, | ||
296 | const char *mod_name) | ||
297 | { | 295 | { |
298 | drv->driver.name = drv->name; | ||
299 | drv->driver.bus = &bus->bus; | 296 | drv->driver.bus = &bus->bus; |
300 | drv->driver.owner = owner; | ||
301 | drv->driver.mod_name = mod_name; | ||
302 | 297 | ||
303 | return driver_register(&drv->driver); | 298 | return driver_register(&drv->driver); |
304 | } | 299 | } |
diff --git a/drivers/xen/xenbus/xenbus_probe.h b/drivers/xen/xenbus/xenbus_probe.h index 460d784a769a..bb4f92ed8730 100644 --- a/drivers/xen/xenbus/xenbus_probe.h +++ b/drivers/xen/xenbus/xenbus_probe.h | |||
@@ -53,9 +53,7 @@ extern int xenbus_match(struct device *_dev, struct device_driver *_drv); | |||
53 | extern int xenbus_dev_probe(struct device *_dev); | 53 | extern int xenbus_dev_probe(struct device *_dev); |
54 | extern int xenbus_dev_remove(struct device *_dev); | 54 | extern int xenbus_dev_remove(struct device *_dev); |
55 | extern int xenbus_register_driver_common(struct xenbus_driver *drv, | 55 | extern int xenbus_register_driver_common(struct xenbus_driver *drv, |
56 | struct xen_bus_type *bus, | 56 | struct xen_bus_type *bus); |
57 | struct module *owner, | ||
58 | const char *mod_name); | ||
59 | extern int xenbus_probe_node(struct xen_bus_type *bus, | 57 | extern int xenbus_probe_node(struct xen_bus_type *bus, |
60 | const char *type, | 58 | const char *type, |
61 | const char *nodename); | 59 | const char *nodename); |
diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c index c3c7cd195c11..257be37d9091 100644 --- a/drivers/xen/xenbus/xenbus_probe_backend.c +++ b/drivers/xen/xenbus/xenbus_probe_backend.c | |||
@@ -232,15 +232,13 @@ int xenbus_dev_is_online(struct xenbus_device *dev) | |||
232 | } | 232 | } |
233 | EXPORT_SYMBOL_GPL(xenbus_dev_is_online); | 233 | EXPORT_SYMBOL_GPL(xenbus_dev_is_online); |
234 | 234 | ||
235 | int __xenbus_register_backend(struct xenbus_driver *drv, | 235 | int xenbus_register_backend(struct xenbus_driver *drv) |
236 | struct module *owner, const char *mod_name) | ||
237 | { | 236 | { |
238 | drv->read_otherend_details = read_frontend_details; | 237 | drv->read_otherend_details = read_frontend_details; |
239 | 238 | ||
240 | return xenbus_register_driver_common(drv, &xenbus_backend, | 239 | return xenbus_register_driver_common(drv, &xenbus_backend); |
241 | owner, mod_name); | ||
242 | } | 240 | } |
243 | EXPORT_SYMBOL_GPL(__xenbus_register_backend); | 241 | EXPORT_SYMBOL_GPL(xenbus_register_backend); |
244 | 242 | ||
245 | static int backend_probe_and_watch(struct notifier_block *notifier, | 243 | static int backend_probe_and_watch(struct notifier_block *notifier, |
246 | unsigned long event, | 244 | unsigned long event, |
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c index 2f73195512b4..9c57819df51a 100644 --- a/drivers/xen/xenbus/xenbus_probe_frontend.c +++ b/drivers/xen/xenbus/xenbus_probe_frontend.c | |||
@@ -230,15 +230,13 @@ static void wait_for_devices(struct xenbus_driver *xendrv) | |||
230 | print_device_status); | 230 | print_device_status); |
231 | } | 231 | } |
232 | 232 | ||
233 | int __xenbus_register_frontend(struct xenbus_driver *drv, | 233 | int xenbus_register_frontend(struct xenbus_driver *drv) |
234 | struct module *owner, const char *mod_name) | ||
235 | { | 234 | { |
236 | int ret; | 235 | int ret; |
237 | 236 | ||
238 | drv->read_otherend_details = read_backend_details; | 237 | drv->read_otherend_details = read_backend_details; |
239 | 238 | ||
240 | ret = xenbus_register_driver_common(drv, &xenbus_frontend, | 239 | ret = xenbus_register_driver_common(drv, &xenbus_frontend); |
241 | owner, mod_name); | ||
242 | if (ret) | 240 | if (ret) |
243 | return ret; | 241 | return ret; |
244 | 242 | ||
@@ -247,7 +245,7 @@ int __xenbus_register_frontend(struct xenbus_driver *drv, | |||
247 | 245 | ||
248 | return 0; | 246 | return 0; |
249 | } | 247 | } |
250 | EXPORT_SYMBOL_GPL(__xenbus_register_frontend); | 248 | EXPORT_SYMBOL_GPL(xenbus_register_frontend); |
251 | 249 | ||
252 | static DECLARE_WAIT_QUEUE_HEAD(backend_state_wq); | 250 | static DECLARE_WAIT_QUEUE_HEAD(backend_state_wq); |
253 | static int backend_state; | 251 | static int backend_state; |