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/xen | |
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/xen')
-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 |
5 files changed, 13 insertions, 27 deletions
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; |