aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/xen-blkback/xenbus.c11
-rw-r--r--drivers/block/xen-blkfront.c5
-rw-r--r--drivers/char/tpm/xen-tpmfront.c13
-rw-r--r--drivers/input/misc/xen-kbdfront.c5
-rw-r--r--drivers/net/xen-netback/xenbus.c10
-rw-r--r--drivers/net/xen-netfront.c16
-rw-r--r--drivers/pci/xen-pcifront.c6
-rw-r--r--drivers/scsi/xen-scsifront.c5
-rw-r--r--drivers/tty/hvc/hvc_xen.c9
-rw-r--r--drivers/video/fbdev/xen-fbfront.c5
-rw-r--r--drivers/xen/xen-pciback/xenbus.c6
-rw-r--r--drivers/xen/xen-scsiback.c5
-rw-r--r--drivers/xen/xenbus/xenbus_probe.c6
-rw-r--r--drivers/xen/xenbus/xenbus_probe.h4
-rw-r--r--drivers/xen/xenbus/xenbus_probe_backend.c8
-rw-r--r--drivers/xen/xenbus/xenbus_probe_frontend.c8
-rw-r--r--include/xen/xenbus.h21
17 files changed, 78 insertions, 65 deletions
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 3a8b810b4980..0b13b1c9a01e 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -907,22 +907,17 @@ static int connect_ring(struct backend_info *be)
907 return 0; 907 return 0;
908} 908}
909 909
910
911/* ** Driver Registration ** */
912
913
914static const struct xenbus_device_id xen_blkbk_ids[] = { 910static const struct xenbus_device_id xen_blkbk_ids[] = {
915 { "vbd" }, 911 { "vbd" },
916 { "" } 912 { "" }
917}; 913};
918 914
919 915static struct xenbus_driver xen_blkbk_driver = {
920static DEFINE_XENBUS_DRIVER(xen_blkbk, , 916 .ids = xen_blkbk_ids,
921 .probe = xen_blkbk_probe, 917 .probe = xen_blkbk_probe,
922 .remove = xen_blkbk_remove, 918 .remove = xen_blkbk_remove,
923 .otherend_changed = frontend_changed 919 .otherend_changed = frontend_changed
924); 920};
925
926 921
927int xen_blkif_xenbus_init(void) 922int xen_blkif_xenbus_init(void)
928{ 923{
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 5deb235bd18f..37af03e9d859 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2055,13 +2055,14 @@ static const struct xenbus_device_id blkfront_ids[] = {
2055 { "" } 2055 { "" }
2056}; 2056};
2057 2057
2058static DEFINE_XENBUS_DRIVER(blkfront, , 2058static struct xenbus_driver blkfront_driver = {
2059 .ids = blkfront_ids,
2059 .probe = blkfront_probe, 2060 .probe = blkfront_probe,
2060 .remove = blkfront_remove, 2061 .remove = blkfront_remove,
2061 .resume = blkfront_resume, 2062 .resume = blkfront_resume,
2062 .otherend_changed = blkback_changed, 2063 .otherend_changed = blkback_changed,
2063 .is_ready = blkfront_is_ready, 2064 .is_ready = blkfront_is_ready,
2064); 2065};
2065 2066
2066static int __init xlblk_init(void) 2067static int __init xlblk_init(void)
2067{ 2068{
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index 2064b4527040..441b44e54226 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -367,12 +367,13 @@ static const struct xenbus_device_id tpmfront_ids[] = {
367}; 367};
368MODULE_ALIAS("xen:vtpm"); 368MODULE_ALIAS("xen:vtpm");
369 369
370static DEFINE_XENBUS_DRIVER(tpmfront, , 370static struct xenbus_driver tpmfront_driver = {
371 .probe = tpmfront_probe, 371 .ids = tpmfront_ids,
372 .remove = tpmfront_remove, 372 .probe = tpmfront_probe,
373 .resume = tpmfront_resume, 373 .remove = tpmfront_remove,
374 .otherend_changed = backend_changed, 374 .resume = tpmfront_resume,
375 ); 375 .otherend_changed = backend_changed,
376};
376 377
377static int __init xen_tpmfront_init(void) 378static int __init xen_tpmfront_init(void)
378{ 379{
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index fbfdc10573be..1af28b06c713 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -365,12 +365,13 @@ static const struct xenbus_device_id xenkbd_ids[] = {
365 { "" } 365 { "" }
366}; 366};
367 367
368static DEFINE_XENBUS_DRIVER(xenkbd, , 368static struct xenbus_driver xenkbd_driver = {
369 .ids = xenkbd_ids,
369 .probe = xenkbd_probe, 370 .probe = xenkbd_probe,
370 .remove = xenkbd_remove, 371 .remove = xenkbd_remove,
371 .resume = xenkbd_resume, 372 .resume = xenkbd_resume,
372 .otherend_changed = xenkbd_backend_changed, 373 .otherend_changed = xenkbd_backend_changed,
373); 374};
374 375
375static int __init xenkbd_init(void) 376static int __init xenkbd_init(void)
376{ 377{
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 9c47b897b6d2..8079c31ac5e6 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -937,22 +937,18 @@ static int read_xenbus_vif_flags(struct backend_info *be)
937 return 0; 937 return 0;
938} 938}
939 939
940
941/* ** Driver Registration ** */
942
943
944static const struct xenbus_device_id netback_ids[] = { 940static const struct xenbus_device_id netback_ids[] = {
945 { "vif" }, 941 { "vif" },
946 { "" } 942 { "" }
947}; 943};
948 944
949 945static struct xenbus_driver netback_driver = {
950static DEFINE_XENBUS_DRIVER(netback, , 946 .ids = netback_ids,
951 .probe = netback_probe, 947 .probe = netback_probe,
952 .remove = netback_remove, 948 .remove = netback_remove,
953 .uevent = netback_uevent, 949 .uevent = netback_uevent,
954 .otherend_changed = frontend_changed, 950 .otherend_changed = frontend_changed,
955); 951};
956 952
957int xenvif_xenbus_init(void) 953int xenvif_xenbus_init(void)
958{ 954{
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index ca82f545ec2c..fa671442f420 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -2300,12 +2300,6 @@ static void xennet_sysfs_delif(struct net_device *netdev)
2300 2300
2301#endif /* CONFIG_SYSFS */ 2301#endif /* CONFIG_SYSFS */
2302 2302
2303static const struct xenbus_device_id netfront_ids[] = {
2304 { "vif" },
2305 { "" }
2306};
2307
2308
2309static int xennet_remove(struct xenbus_device *dev) 2303static int xennet_remove(struct xenbus_device *dev)
2310{ 2304{
2311 struct netfront_info *info = dev_get_drvdata(&dev->dev); 2305 struct netfront_info *info = dev_get_drvdata(&dev->dev);
@@ -2338,12 +2332,18 @@ static int xennet_remove(struct xenbus_device *dev)
2338 return 0; 2332 return 0;
2339} 2333}
2340 2334
2341static DEFINE_XENBUS_DRIVER(netfront, , 2335static const struct xenbus_device_id netfront_ids[] = {
2336 { "vif" },
2337 { "" }
2338};
2339
2340static struct xenbus_driver netfront_driver = {
2341 .ids = netfront_ids,
2342 .probe = netfront_probe, 2342 .probe = netfront_probe,
2343 .remove = xennet_remove, 2343 .remove = xennet_remove,
2344 .resume = netfront_resume, 2344 .resume = netfront_resume,
2345 .otherend_changed = netback_changed, 2345 .otherend_changed = netback_changed,
2346); 2346};
2347 2347
2348static int __init netif_init(void) 2348static int __init netif_init(void)
2349{ 2349{
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 53df39a22c8a..116ca3746adb 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -1136,11 +1136,13 @@ static const struct xenbus_device_id xenpci_ids[] = {
1136 {""}, 1136 {""},
1137}; 1137};
1138 1138
1139static DEFINE_XENBUS_DRIVER(xenpci, "pcifront", 1139static struct xenbus_driver xenpci_driver = {
1140 .name = "pcifront",
1141 .ids = xenpci_ids,
1140 .probe = pcifront_xenbus_probe, 1142 .probe = pcifront_xenbus_probe,
1141 .remove = pcifront_xenbus_remove, 1143 .remove = pcifront_xenbus_remove,
1142 .otherend_changed = pcifront_backend_changed, 1144 .otherend_changed = pcifront_backend_changed,
1143); 1145};
1144 1146
1145static int __init pcifront_init(void) 1147static int __init pcifront_init(void)
1146{ 1148{
diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index cc14c8ddd369..34199d206ba6 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -998,11 +998,12 @@ static const struct xenbus_device_id scsifront_ids[] = {
998 { "" } 998 { "" }
999}; 999};
1000 1000
1001static DEFINE_XENBUS_DRIVER(scsifront, , 1001static struct xenbus_driver scsifront_driver = {
1002 .ids = scsifront_ids,
1002 .probe = scsifront_probe, 1003 .probe = scsifront_probe,
1003 .remove = scsifront_remove, 1004 .remove = scsifront_remove,
1004 .otherend_changed = scsifront_backend_changed, 1005 .otherend_changed = scsifront_backend_changed,
1005); 1006};
1006 1007
1007static int __init scsifront_init(void) 1008static int __init scsifront_init(void)
1008{ 1009{
diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index 2dc2831840ca..c3d8af917ffc 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -347,8 +347,6 @@ static int xen_console_remove(struct xencons_info *info)
347} 347}
348 348
349#ifdef CONFIG_HVC_XEN_FRONTEND 349#ifdef CONFIG_HVC_XEN_FRONTEND
350static struct xenbus_driver xencons_driver;
351
352static int xencons_remove(struct xenbus_device *dev) 350static int xencons_remove(struct xenbus_device *dev)
353{ 351{
354 return xen_console_remove(dev_get_drvdata(&dev->dev)); 352 return xen_console_remove(dev_get_drvdata(&dev->dev));
@@ -502,13 +500,14 @@ static const struct xenbus_device_id xencons_ids[] = {
502 { "" } 500 { "" }
503}; 501};
504 502
505 503static struct xenbus_driver xencons_driver = {
506static DEFINE_XENBUS_DRIVER(xencons, "xenconsole", 504 .name = "xenconsole",
505 .ids = xencons_ids,
507 .probe = xencons_probe, 506 .probe = xencons_probe,
508 .remove = xencons_remove, 507 .remove = xencons_remove,
509 .resume = xencons_resume, 508 .resume = xencons_resume,
510 .otherend_changed = xencons_backend_changed, 509 .otherend_changed = xencons_backend_changed,
511); 510};
512#endif /* CONFIG_HVC_XEN_FRONTEND */ 511#endif /* CONFIG_HVC_XEN_FRONTEND */
513 512
514static int __init xen_hvc_init(void) 513static int __init xen_hvc_init(void)
diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c
index 901014bbc821..09dc44736c1a 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -684,12 +684,13 @@ static const struct xenbus_device_id xenfb_ids[] = {
684 { "" } 684 { "" }
685}; 685};
686 686
687static DEFINE_XENBUS_DRIVER(xenfb, , 687static struct xenbus_driver xenfb_driver = {
688 .ids = xenfb_ids,
688 .probe = xenfb_probe, 689 .probe = xenfb_probe,
689 .remove = xenfb_remove, 690 .remove = xenfb_remove,
690 .resume = xenfb_resume, 691 .resume = xenfb_resume,
691 .otherend_changed = xenfb_backend_changed, 692 .otherend_changed = xenfb_backend_changed,
692); 693};
693 694
694static int __init xenfb_init(void) 695static int __init xenfb_init(void)
695{ 696{
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
index c214daab4829..ad8d30c088fe 100644
--- a/drivers/xen/xen-pciback/xenbus.c
+++ b/drivers/xen/xen-pciback/xenbus.c
@@ -719,11 +719,13 @@ static const struct xenbus_device_id xen_pcibk_ids[] = {
719 {""}, 719 {""},
720}; 720};
721 721
722static DEFINE_XENBUS_DRIVER(xen_pcibk, DRV_NAME, 722static struct xenbus_driver xen_pcibk_driver = {
723 .name = DRV_NAME,
724 .ids = xen_pcibk_ids,
723 .probe = xen_pcibk_xenbus_probe, 725 .probe = xen_pcibk_xenbus_probe,
724 .remove = xen_pcibk_xenbus_remove, 726 .remove = xen_pcibk_xenbus_remove,
725 .otherend_changed = xen_pcibk_frontend_changed, 727 .otherend_changed = xen_pcibk_frontend_changed,
726); 728};
727 729
728const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; 730const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;
729 731
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index ad11258a78d6..3e32146472a5 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -2056,11 +2056,12 @@ static const struct xenbus_device_id scsiback_ids[] = {
2056 { "" } 2056 { "" }
2057}; 2057};
2058 2058
2059static DEFINE_XENBUS_DRIVER(scsiback, , 2059static struct xenbus_driver scsiback_driver = {
2060 .ids = scsiback_ids,
2060 .probe = scsiback_probe, 2061 .probe = scsiback_probe,
2061 .remove = scsiback_remove, 2062 .remove = scsiback_remove,
2062 .otherend_changed = scsiback_frontend_changed 2063 .otherend_changed = scsiback_frontend_changed
2063); 2064};
2064 2065
2065static void scsiback_init_pend(void *p) 2066static void scsiback_init_pend(void *p)
2066{ 2067{
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 3c0a74b3e9b1..564b31584860 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -297,9 +297,13 @@ void xenbus_dev_shutdown(struct device *_dev)
297EXPORT_SYMBOL_GPL(xenbus_dev_shutdown); 297EXPORT_SYMBOL_GPL(xenbus_dev_shutdown);
298 298
299int xenbus_register_driver_common(struct xenbus_driver *drv, 299int xenbus_register_driver_common(struct xenbus_driver *drv,
300 struct xen_bus_type *bus) 300 struct xen_bus_type *bus,
301 struct module *owner, const char *mod_name)
301{ 302{
303 drv->driver.name = drv->name ? drv->name : drv->ids[0].devicetype;
302 drv->driver.bus = &bus->bus; 304 drv->driver.bus = &bus->bus;
305 drv->driver.owner = owner;
306 drv->driver.mod_name = mod_name;
303 307
304 return driver_register(&drv->driver); 308 return driver_register(&drv->driver);
305} 309}
diff --git a/drivers/xen/xenbus/xenbus_probe.h b/drivers/xen/xenbus/xenbus_probe.h
index 1085ec294a19..c9ec7ca1f7ab 100644
--- a/drivers/xen/xenbus/xenbus_probe.h
+++ b/drivers/xen/xenbus/xenbus_probe.h
@@ -60,7 +60,9 @@ extern int xenbus_match(struct device *_dev, struct device_driver *_drv);
60extern int xenbus_dev_probe(struct device *_dev); 60extern int xenbus_dev_probe(struct device *_dev);
61extern int xenbus_dev_remove(struct device *_dev); 61extern int xenbus_dev_remove(struct device *_dev);
62extern int xenbus_register_driver_common(struct xenbus_driver *drv, 62extern int xenbus_register_driver_common(struct xenbus_driver *drv,
63 struct xen_bus_type *bus); 63 struct xen_bus_type *bus,
64 struct module *owner,
65 const char *mod_name);
64extern int xenbus_probe_node(struct xen_bus_type *bus, 66extern int xenbus_probe_node(struct xen_bus_type *bus,
65 const char *type, 67 const char *type,
66 const char *nodename); 68 const char *nodename);
diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c
index 5125dce11a60..04f7f85a5edf 100644
--- a/drivers/xen/xenbus/xenbus_probe_backend.c
+++ b/drivers/xen/xenbus/xenbus_probe_backend.c
@@ -234,13 +234,15 @@ int xenbus_dev_is_online(struct xenbus_device *dev)
234} 234}
235EXPORT_SYMBOL_GPL(xenbus_dev_is_online); 235EXPORT_SYMBOL_GPL(xenbus_dev_is_online);
236 236
237int xenbus_register_backend(struct xenbus_driver *drv) 237int __xenbus_register_backend(struct xenbus_driver *drv, struct module *owner,
238 const char *mod_name)
238{ 239{
239 drv->read_otherend_details = read_frontend_details; 240 drv->read_otherend_details = read_frontend_details;
240 241
241 return xenbus_register_driver_common(drv, &xenbus_backend); 242 return xenbus_register_driver_common(drv, &xenbus_backend,
243 owner, mod_name);
242} 244}
243EXPORT_SYMBOL_GPL(xenbus_register_backend); 245EXPORT_SYMBOL_GPL(__xenbus_register_backend);
244 246
245static int backend_probe_and_watch(struct notifier_block *notifier, 247static int backend_probe_and_watch(struct notifier_block *notifier,
246 unsigned long event, 248 unsigned long event,
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index cb385c10d2b1..bcb53bdc469c 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -317,13 +317,15 @@ static void wait_for_devices(struct xenbus_driver *xendrv)
317 print_device_status); 317 print_device_status);
318} 318}
319 319
320int xenbus_register_frontend(struct xenbus_driver *drv) 320int __xenbus_register_frontend(struct xenbus_driver *drv, struct module *owner,
321 const char *mod_name)
321{ 322{
322 int ret; 323 int ret;
323 324
324 drv->read_otherend_details = read_backend_details; 325 drv->read_otherend_details = read_backend_details;
325 326
326 ret = xenbus_register_driver_common(drv, &xenbus_frontend); 327 ret = xenbus_register_driver_common(drv, &xenbus_frontend,
328 owner, mod_name);
327 if (ret) 329 if (ret)
328 return ret; 330 return ret;
329 331
@@ -332,7 +334,7 @@ int xenbus_register_frontend(struct xenbus_driver *drv)
332 334
333 return 0; 335 return 0;
334} 336}
335EXPORT_SYMBOL_GPL(xenbus_register_frontend); 337EXPORT_SYMBOL_GPL(__xenbus_register_frontend);
336 338
337static DECLARE_WAIT_QUEUE_HEAD(backend_state_wq); 339static DECLARE_WAIT_QUEUE_HEAD(backend_state_wq);
338static int backend_state; 340static int backend_state;
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index 0324c6d340c1..b78f21caf55a 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -86,6 +86,7 @@ struct xenbus_device_id
86 86
87/* A xenbus driver. */ 87/* A xenbus driver. */
88struct xenbus_driver { 88struct xenbus_driver {
89 const char *name; /* defaults to ids[0].devicetype */
89 const struct xenbus_device_id *ids; 90 const struct xenbus_device_id *ids;
90 int (*probe)(struct xenbus_device *dev, 91 int (*probe)(struct xenbus_device *dev,
91 const struct xenbus_device_id *id); 92 const struct xenbus_device_id *id);
@@ -100,20 +101,22 @@ struct xenbus_driver {
100 int (*is_ready)(struct xenbus_device *dev); 101 int (*is_ready)(struct xenbus_device *dev);
101}; 102};
102 103
103#define DEFINE_XENBUS_DRIVER(var, drvname, methods...) \
104struct xenbus_driver var ## _driver = { \
105 .driver.name = drvname + 0 ?: var ## _ids->devicetype, \
106 .driver.owner = THIS_MODULE, \
107 .ids = var ## _ids, ## methods \
108}
109
110static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv) 104static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
111{ 105{
112 return container_of(drv, struct xenbus_driver, driver); 106 return container_of(drv, struct xenbus_driver, driver);
113} 107}
114 108
115int __must_check xenbus_register_frontend(struct xenbus_driver *); 109int __must_check __xenbus_register_frontend(struct xenbus_driver *drv,
116int __must_check xenbus_register_backend(struct xenbus_driver *); 110 struct module *owner,
111 const char *mod_name);
112int __must_check __xenbus_register_backend(struct xenbus_driver *drv,
113 struct module *owner,
114 const char *mod_name);
115
116#define xenbus_register_frontend(drv) \
117 __xenbus_register_frontend(drv, THIS_MODULE, KBUILD_MODNAME);
118#define xenbus_register_backend(drv) \
119 __xenbus_register_backend(drv, THIS_MODULE, KBUILD_MODNAME);
117 120
118void xenbus_unregister_driver(struct xenbus_driver *drv); 121void xenbus_unregister_driver(struct xenbus_driver *drv);
119 122