xen: remove DEFINE_XENBUS_DRIVER() macro
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 8 Sep 2014 16:30:41 +0000 (17:30 +0100)
committerDavid Vrabel <david.vrabel@citrix.com>
Mon, 6 Oct 2014 09:27:57 +0000 (10:27 +0100)
The DEFINE_XENBUS_DRIVER() macro looks a bit weird and causes sparse
errors.

Replace the uses with standard structure definitions instead.  This is
similar to pci and usb device registration.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
17 files changed:
drivers/block/xen-blkback/xenbus.c
drivers/block/xen-blkfront.c
drivers/char/tpm/xen-tpmfront.c
drivers/input/misc/xen-kbdfront.c
drivers/net/xen-netback/xenbus.c
drivers/net/xen-netfront.c
drivers/pci/xen-pcifront.c
drivers/scsi/xen-scsifront.c
drivers/tty/hvc/hvc_xen.c
drivers/video/fbdev/xen-fbfront.c
drivers/xen/xen-pciback/xenbus.c
drivers/xen/xen-scsiback.c
drivers/xen/xenbus/xenbus_probe.c
drivers/xen/xenbus/xenbus_probe.h
drivers/xen/xenbus/xenbus_probe_backend.c
drivers/xen/xenbus/xenbus_probe_frontend.c
include/xen/xenbus.h

index 3a8b810b4980582ddcb61bb1fc23f112adbe02d6..0b13b1c9a01e397fbb557e676beb77742c9737bc 100644 (file)
@@ -907,22 +907,17 @@ static int connect_ring(struct backend_info *be)
        return 0;
 }
 
-
-/* ** Driver Registration ** */
-
-
 static const struct xenbus_device_id xen_blkbk_ids[] = {
        { "vbd" },
        { "" }
 };
 
-
-static DEFINE_XENBUS_DRIVER(xen_blkbk, ,
+static struct xenbus_driver xen_blkbk_driver = {
+       .ids  = xen_blkbk_ids,
        .probe = xen_blkbk_probe,
        .remove = xen_blkbk_remove,
        .otherend_changed = frontend_changed
-);
-
+};
 
 int xen_blkif_xenbus_init(void)
 {
index 5deb235bd18fe07adb2efb09a7c77508aadfaeec..37af03e9d859d113f28c8ccb2be70be98a5ce831 100644 (file)
@@ -2055,13 +2055,14 @@ static const struct xenbus_device_id blkfront_ids[] = {
        { "" }
 };
 
-static DEFINE_XENBUS_DRIVER(blkfront, ,
+static struct xenbus_driver blkfront_driver = {
+       .ids  = blkfront_ids,
        .probe = blkfront_probe,
        .remove = blkfront_remove,
        .resume = blkfront_resume,
        .otherend_changed = blkback_changed,
        .is_ready = blkfront_is_ready,
-);
+};
 
 static int __init xlblk_init(void)
 {
index 2064b4527040be68920c3ef9e557b090ca587f7a..441b44e5422691c7ed1a38a84ca8d0fa661849e1 100644 (file)
@@ -367,12 +367,13 @@ static const struct xenbus_device_id tpmfront_ids[] = {
 };
 MODULE_ALIAS("xen:vtpm");
 
-static DEFINE_XENBUS_DRIVER(tpmfront, ,
-               .probe = tpmfront_probe,
-               .remove = tpmfront_remove,
-               .resume = tpmfront_resume,
-               .otherend_changed = backend_changed,
-       );
+static struct xenbus_driver tpmfront_driver = {
+       .ids = tpmfront_ids,
+       .probe = tpmfront_probe,
+       .remove = tpmfront_remove,
+       .resume = tpmfront_resume,
+       .otherend_changed = backend_changed,
+};
 
 static int __init xen_tpmfront_init(void)
 {
index fbfdc10573be00bd471b440be7860b24f261caaa..1af28b06c713b80aafc1edbf6ff31cc49d5a5fe5 100644 (file)
@@ -365,12 +365,13 @@ static const struct xenbus_device_id xenkbd_ids[] = {
        { "" }
 };
 
-static DEFINE_XENBUS_DRIVER(xenkbd, ,
+static struct xenbus_driver xenkbd_driver = {
+       .ids = xenkbd_ids,
        .probe = xenkbd_probe,
        .remove = xenkbd_remove,
        .resume = xenkbd_resume,
        .otherend_changed = xenkbd_backend_changed,
-);
+};
 
 static int __init xenkbd_init(void)
 {
index 9c47b897b6d212c3de827ddde941acb325111546..8079c31ac5e64372fe978405c8faa72981998320 100644 (file)
@@ -937,22 +937,18 @@ static int read_xenbus_vif_flags(struct backend_info *be)
        return 0;
 }
 
-
-/* ** Driver Registration ** */
-
-
 static const struct xenbus_device_id netback_ids[] = {
        { "vif" },
        { "" }
 };
 
-
-static DEFINE_XENBUS_DRIVER(netback, ,
+static struct xenbus_driver netback_driver = {
+       .ids = netback_ids,
        .probe = netback_probe,
        .remove = netback_remove,
        .uevent = netback_uevent,
        .otherend_changed = frontend_changed,
-);
+};
 
 int xenvif_xenbus_init(void)
 {
index ca82f545ec2ca12678ca4f4ce6669c0b564f8bb2..fa671442f420806224bc85ee5f6b5200f7b5478c 100644 (file)
@@ -2300,12 +2300,6 @@ static void xennet_sysfs_delif(struct net_device *netdev)
 
 #endif /* CONFIG_SYSFS */
 
-static const struct xenbus_device_id netfront_ids[] = {
-       { "vif" },
-       { "" }
-};
-
-
 static int xennet_remove(struct xenbus_device *dev)
 {
        struct netfront_info *info = dev_get_drvdata(&dev->dev);
@@ -2338,12 +2332,18 @@ static int xennet_remove(struct xenbus_device *dev)
        return 0;
 }
 
-static DEFINE_XENBUS_DRIVER(netfront, ,
+static const struct xenbus_device_id netfront_ids[] = {
+       { "vif" },
+       { "" }
+};
+
+static struct xenbus_driver netfront_driver = {
+       .ids = netfront_ids,
        .probe = netfront_probe,
        .remove = xennet_remove,
        .resume = netfront_resume,
        .otherend_changed = netback_changed,
-);
+};
 
 static int __init netif_init(void)
 {
index 53df39a22c8acb20f6dda5dff8aa4050516dbfb2..116ca3746adb47cd5887bad8b8014ccdb5641b9c 100644 (file)
@@ -1136,11 +1136,13 @@ static const struct xenbus_device_id xenpci_ids[] = {
        {""},
 };
 
-static DEFINE_XENBUS_DRIVER(xenpci, "pcifront",
+static struct xenbus_driver xenpci_driver = {
+       .name                   = "pcifront",
+       .ids                    = xenpci_ids,
        .probe                  = pcifront_xenbus_probe,
        .remove                 = pcifront_xenbus_remove,
        .otherend_changed       = pcifront_backend_changed,
-);
+};
 
 static int __init pcifront_init(void)
 {
index cc14c8ddd369580cc89b63cdf2cafb6c7947acb8..34199d206ba64ee29cfa76564a951b9daa3f17ad 100644 (file)
@@ -998,11 +998,12 @@ static const struct xenbus_device_id scsifront_ids[] = {
        { "" }
 };
 
-static DEFINE_XENBUS_DRIVER(scsifront, ,
+static struct xenbus_driver scsifront_driver = {
+       .ids                    = scsifront_ids,
        .probe                  = scsifront_probe,
        .remove                 = scsifront_remove,
        .otherend_changed       = scsifront_backend_changed,
-);
+};
 
 static int __init scsifront_init(void)
 {
index 2dc2831840ca1852efb1cec280ced8b2e0afb0ae..c3d8af917ffc0dd03e4fcb2d7caeae7185aceb85 100644 (file)
@@ -347,8 +347,6 @@ static int xen_console_remove(struct xencons_info *info)
 }
 
 #ifdef CONFIG_HVC_XEN_FRONTEND
-static struct xenbus_driver xencons_driver;
-
 static int xencons_remove(struct xenbus_device *dev)
 {
        return xen_console_remove(dev_get_drvdata(&dev->dev));
@@ -502,13 +500,14 @@ static const struct xenbus_device_id xencons_ids[] = {
        { "" }
 };
 
-
-static DEFINE_XENBUS_DRIVER(xencons, "xenconsole",
+static struct xenbus_driver xencons_driver = {
+       .name = "xenconsole",
+       .ids = xencons_ids,
        .probe = xencons_probe,
        .remove = xencons_remove,
        .resume = xencons_resume,
        .otherend_changed = xencons_backend_changed,
-);
+};
 #endif /* CONFIG_HVC_XEN_FRONTEND */
 
 static int __init xen_hvc_init(void)
index 901014bbc8210b4ac876df7db9c8a0a4493256eb..09dc44736c1ac72160f5d9aa4d13ab1912151be9 100644 (file)
@@ -684,12 +684,13 @@ static const struct xenbus_device_id xenfb_ids[] = {
        { "" }
 };
 
-static DEFINE_XENBUS_DRIVER(xenfb, ,
+static struct xenbus_driver xenfb_driver = {
+       .ids = xenfb_ids,
        .probe = xenfb_probe,
        .remove = xenfb_remove,
        .resume = xenfb_resume,
        .otherend_changed = xenfb_backend_changed,
-);
+};
 
 static int __init xenfb_init(void)
 {
index c214daab482910b203b436520d876a618ffcca9b..ad8d30c088fe4b37d4c62b5f863e2561e4724509 100644 (file)
@@ -719,11 +719,13 @@ static const struct xenbus_device_id xen_pcibk_ids[] = {
        {""},
 };
 
-static DEFINE_XENBUS_DRIVER(xen_pcibk, DRV_NAME,
+static struct xenbus_driver xen_pcibk_driver = {
+       .name                   = DRV_NAME,
+       .ids                    = xen_pcibk_ids,
        .probe                  = xen_pcibk_xenbus_probe,
        .remove                 = xen_pcibk_xenbus_remove,
        .otherend_changed       = xen_pcibk_frontend_changed,
-);
+};
 
 const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;
 
index ad11258a78d6b98c715a6b7ece82226fdb4db7e8..3e32146472a52c535e48cbfdae294c62985e8862 100644 (file)
@@ -2056,11 +2056,12 @@ static const struct xenbus_device_id scsiback_ids[] = {
        { "" }
 };
 
-static DEFINE_XENBUS_DRIVER(scsiback, ,
+static struct xenbus_driver scsiback_driver = {
+       .ids                    = scsiback_ids,
        .probe                  = scsiback_probe,
        .remove                 = scsiback_remove,
        .otherend_changed       = scsiback_frontend_changed
-);
+};
 
 static void scsiback_init_pend(void *p)
 {
index 3c0a74b3e9b15af5355c8619294805f59030f75d..564b31584860432634a898a8fce9c7dc155a6662 100644 (file)
@@ -297,9 +297,13 @@ void xenbus_dev_shutdown(struct device *_dev)
 EXPORT_SYMBOL_GPL(xenbus_dev_shutdown);
 
 int xenbus_register_driver_common(struct xenbus_driver *drv,
-                                 struct xen_bus_type *bus)
+                                 struct xen_bus_type *bus,
+                                 struct module *owner, const char *mod_name)
 {
+       drv->driver.name = drv->name ? drv->name : drv->ids[0].devicetype;
        drv->driver.bus = &bus->bus;
+       drv->driver.owner = owner;
+       drv->driver.mod_name = mod_name;
 
        return driver_register(&drv->driver);
 }
index 1085ec294a1987a5620b24c4a2e120528d13cac0..c9ec7ca1f7ab6f4e3f78099c434d2533f0881b2f 100644 (file)
@@ -60,7 +60,9 @@ extern int xenbus_match(struct device *_dev, struct device_driver *_drv);
 extern int xenbus_dev_probe(struct device *_dev);
 extern int xenbus_dev_remove(struct device *_dev);
 extern int xenbus_register_driver_common(struct xenbus_driver *drv,
-                                        struct xen_bus_type *bus);
+                                        struct xen_bus_type *bus,
+                                        struct module *owner,
+                                        const char *mod_name);
 extern int xenbus_probe_node(struct xen_bus_type *bus,
                             const char *type,
                             const char *nodename);
index 5125dce11a6083da92fc5942a09c2aa786f181d8..04f7f85a5edf88ae21a01c6acae092b3a17c5a83 100644 (file)
@@ -234,13 +234,15 @@ int xenbus_dev_is_online(struct xenbus_device *dev)
 }
 EXPORT_SYMBOL_GPL(xenbus_dev_is_online);
 
-int xenbus_register_backend(struct xenbus_driver *drv)
+int __xenbus_register_backend(struct xenbus_driver *drv, struct module *owner,
+                             const char *mod_name)
 {
        drv->read_otherend_details = read_frontend_details;
 
-       return xenbus_register_driver_common(drv, &xenbus_backend);
+       return xenbus_register_driver_common(drv, &xenbus_backend,
+                                            owner, mod_name);
 }
-EXPORT_SYMBOL_GPL(xenbus_register_backend);
+EXPORT_SYMBOL_GPL(__xenbus_register_backend);
 
 static int backend_probe_and_watch(struct notifier_block *notifier,
                                   unsigned long event,
index cb385c10d2b15679729810dd24e5c9bb3cd9117c..bcb53bdc469c43a66914eec1f63acc05936d482f 100644 (file)
@@ -317,13 +317,15 @@ static void wait_for_devices(struct xenbus_driver *xendrv)
                         print_device_status);
 }
 
-int xenbus_register_frontend(struct xenbus_driver *drv)
+int __xenbus_register_frontend(struct xenbus_driver *drv, struct module *owner,
+                              const char *mod_name)
 {
        int ret;
 
        drv->read_otherend_details = read_backend_details;
 
-       ret = xenbus_register_driver_common(drv, &xenbus_frontend);
+       ret = xenbus_register_driver_common(drv, &xenbus_frontend,
+                                           owner, mod_name);
        if (ret)
                return ret;
 
@@ -332,7 +334,7 @@ int xenbus_register_frontend(struct xenbus_driver *drv)
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(xenbus_register_frontend);
+EXPORT_SYMBOL_GPL(__xenbus_register_frontend);
 
 static DECLARE_WAIT_QUEUE_HEAD(backend_state_wq);
 static int backend_state;
index 0324c6d340c19df3ef67d03b3307ce8ac082730c..b78f21caf55aa074d3f883d0a0269f1c7d268339 100644 (file)
@@ -86,6 +86,7 @@ struct xenbus_device_id
 
 /* A xenbus driver. */
 struct xenbus_driver {
+       const char *name;       /* defaults to ids[0].devicetype */
        const struct xenbus_device_id *ids;
        int (*probe)(struct xenbus_device *dev,
                     const struct xenbus_device_id *id);
@@ -100,20 +101,22 @@ struct xenbus_driver {
        int (*is_ready)(struct xenbus_device *dev);
 };
 
-#define DEFINE_XENBUS_DRIVER(var, drvname, methods...)         \
-struct xenbus_driver var ## _driver = {                                \
-       .driver.name = drvname + 0 ?: var ## _ids->devicetype,  \
-       .driver.owner = THIS_MODULE,                            \
-       .ids = var ## _ids, ## methods                          \
-}
-
 static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
 {
        return container_of(drv, struct xenbus_driver, driver);
 }
 
-int __must_check xenbus_register_frontend(struct xenbus_driver *);
-int __must_check xenbus_register_backend(struct xenbus_driver *);
+int __must_check __xenbus_register_frontend(struct xenbus_driver *drv,
+                                           struct module *owner,
+                                           const char *mod_name);
+int __must_check __xenbus_register_backend(struct xenbus_driver *drv,
+                                          struct module *owner,
+                                          const char *mod_name);
+
+#define xenbus_register_frontend(drv) \
+       __xenbus_register_frontend(drv, THIS_MODULE, KBUILD_MODNAME);
+#define xenbus_register_backend(drv) \
+       __xenbus_register_backend(drv, THIS_MODULE, KBUILD_MODNAME);
 
 void xenbus_unregister_driver(struct xenbus_driver *drv);