From: "Jan Beulich" Subject: [PATCH, v2] linux-2.6.18: consolidate and simplify struct xenbus_driver instantiation Date: Fri, 16 Dec 2011 09:23:37 +0000 Message-ID: <4EEB1C2902000078000686EE@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartCAE56209.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartCAE56209.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The 'name' and 'owner' 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 (and at once to abstract out - for the unmodified drivers build - the absence of the 'owner' field in Linux prior to 2.6.10). Also add a module alias for the vtpm frontend driver (overlooked in 141:5e294e29a43e). v2: 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). Signed-off-by: Jan Beulich --- a/drivers/char/tpm/tpm_xen.c +++ b/drivers/char/tpm/tpm_xen.c @@ -475,26 +475,24 @@ static int tpmif_connect(struct xenbus_d return 0; } =20 -static struct xenbus_device_id tpmfront_ids[] =3D { +static const struct xenbus_device_id tpmfront_ids[] =3D { { "vtpm" }, { "" } }; +MODULE_ALIAS("xen:vtpm"); =20 -static struct xenbus_driver tpmfront =3D { - .name =3D "vtpm", - .owner =3D THIS_MODULE, - .ids =3D tpmfront_ids, +static DEFINE_XENBUS_DRIVER(tpmfront, , .probe =3D tpmfront_probe, .remove =3D tpmfront_remove, .resume =3D tpmfront_resume, .otherend_changed =3D backend_changed, .suspend =3D tpmfront_suspend, .suspend_cancel =3D tpmfront_suspend_cancel, -}; +); =20 static void __init init_tpm_xenbus(void) { - xenbus_register_frontend(&tpmfront); + xenbus_register_frontend(&tpmfront_driver); } =20 static int tpmif_allocate_tx_buffers(struct tpm_private *tp) --- a/drivers/xen/blkback/xenbus.c +++ b/drivers/xen/blkback/xenbus.c @@ -542,18 +542,14 @@ static const struct xenbus_device_id blk { "" } }; =20 - -static struct xenbus_driver blkback =3D { - .name =3D "vbd", - .owner =3D THIS_MODULE, - .ids =3D blkback_ids, +static DEFINE_XENBUS_DRIVER(blkback, , .probe =3D blkback_probe, .remove =3D blkback_remove, .otherend_changed =3D frontend_changed -}; +); =20 =20 void blkif_xenbus_init(void) { - xenbus_register_backend(&blkback); + xenbus_register_backend(&blkback_driver); } --- a/drivers/xen/blkfront/blkfront.c +++ b/drivers/xen/blkfront/blkfront.c @@ -934,16 +934,13 @@ static const struct xenbus_device_id blk }; MODULE_ALIAS("xen:vbd"); =20 -static struct xenbus_driver blkfront =3D { - .name =3D "vbd", - .owner =3D THIS_MODULE, - .ids =3D blkfront_ids, +static DEFINE_XENBUS_DRIVER(blkfront, , .probe =3D blkfront_probe, .remove =3D blkfront_remove, .resume =3D blkfront_resume, .otherend_changed =3D backend_changed, .is_ready =3D blkfront_is_ready, -}; +); =20 =20 static int __init xlblk_init(void) @@ -951,14 +948,14 @@ static int __init xlblk_init(void) if (!is_running_on_xen()) return -ENODEV; =20 - return xenbus_register_frontend(&blkfront); + return xenbus_register_frontend(&blkfront_driver); } module_init(xlblk_init); =20 =20 static void __exit xlblk_exit(void) { - return xenbus_unregister_driver(&blkfront); + return xenbus_unregister_driver(&blkfront_driver); } module_exit(xlblk_exit); =20 --- a/drivers/xen/blktap/xenbus.c +++ b/drivers/xen/blktap/xenbus.c @@ -490,18 +490,14 @@ static const struct xenbus_device_id blk { "" } }; =20 - -static struct xenbus_driver blktap =3D { - .name =3D "tap", - .owner =3D THIS_MODULE, - .ids =3D blktap_ids, +static DEFINE_XENBUS_DRIVER(blktap, , .probe =3D blktap_probe, .remove =3D blktap_remove, .otherend_changed =3D tap_frontend_changed -}; +); =20 =20 void tap_blkif_xenbus_init(void) { - xenbus_register_backend(&blktap); + xenbus_register_backend(&blktap_driver); } --- a/drivers/xen/fbfront/xenfb.c +++ b/drivers/xen/fbfront/xenfb.c @@ -857,15 +857,12 @@ static const struct xenbus_device_id xen }; MODULE_ALIAS("xen:vfb"); =20 -static struct xenbus_driver xenfb_driver =3D { - .name =3D "vfb", - .owner =3D THIS_MODULE, - .ids =3D xenfb_ids, +static DEFINE_XENBUS_DRIVER(xenfb, , .probe =3D xenfb_probe, .remove =3D xenfb_remove, .resume =3D xenfb_resume, .otherend_changed =3D xenfb_backend_changed, -}; +); =20 static int __init xenfb_init(void) { --- a/drivers/xen/fbfront/xenkbd.c +++ b/drivers/xen/fbfront/xenkbd.c @@ -335,15 +335,12 @@ static const struct xenbus_device_id xen }; MODULE_ALIAS("xen:vkbd"); =20 -static struct xenbus_driver xenkbd_driver =3D { - .name =3D "vkbd", - .owner =3D THIS_MODULE, - .ids =3D xenkbd_ids, +static DEFINE_XENBUS_DRIVER(xenkbd, , .probe =3D xenkbd_probe, .remove =3D xenkbd_remove, .resume =3D xenkbd_resume, .otherend_changed =3D xenkbd_backend_changed, -}; +); =20 static int __init xenkbd_init(void) { --- a/drivers/xen/netback/xenbus.c +++ b/drivers/xen/netback/xenbus.c @@ -437,19 +437,15 @@ static const struct xenbus_device_id net { "" } }; =20 - -static struct xenbus_driver netback =3D { - .name =3D "vif", - .owner =3D THIS_MODULE, - .ids =3D netback_ids, +static DEFINE_XENBUS_DRIVER(netback, , .probe =3D netback_probe, .remove =3D netback_remove, .uevent =3D netback_uevent, .otherend_changed =3D frontend_changed, -}; +); =20 =20 void netif_xenbus_init(void) { - xenbus_register_backend(&netback); + xenbus_register_backend(&netback_driver); } --- a/drivers/xen/netfront/netfront.c +++ b/drivers/xen/netfront/netfront.c @@ -2197,18 +2197,14 @@ static const struct xenbus_device_id net }; MODULE_ALIAS("xen:vif"); =20 - -static struct xenbus_driver netfront_driver =3D { - .name =3D "vif", - .owner =3D THIS_MODULE, - .ids =3D netfront_ids, +static DEFINE_XENBUS_DRIVER(netfront, , .probe =3D netfront_probe, .remove =3D __devexit_p(netfront_remove), .suspend =3D netfront_suspend, .suspend_cancel =3D netfront_suspend_cancel, .resume =3D netfront_resume, .otherend_changed =3D backend_changed, -}; +); =20 =20 static int __init netif_init(void) --- a/drivers/xen/pciback/xenbus.c +++ b/drivers/xen/pciback/xenbus.c @@ -676,19 +676,16 @@ static int pciback_xenbus_remove(struct=20 return 0; } =20 -static const struct xenbus_device_id xenpci_ids[] =3D { +static const struct xenbus_device_id pciback_ids[] =3D { {"pci"}, {{0}}, }; =20 -static struct xenbus_driver xenbus_pciback_driver =3D { - .name =3D "pciback", - .owner =3D THIS_MODULE, - .ids =3D xenpci_ids, +static DEFINE_XENBUS_DRIVER(pciback, "pciback", .probe =3D pciback_xenbus_probe, .remove =3D pciback_xenbus_remove, .otherend_changed =3D pciback_frontend_changed, -}; +); =20 int __init pciback_xenbus_register(void) { @@ -700,11 +697,11 @@ int __init pciback_xenbus_register(void) "pciback_workqueue failed\n"); return -EFAULT; } - return xenbus_register_backend(&xenbus_pciback_driver); + return xenbus_register_backend(&pciback_driver); } =20 void __exit pciback_xenbus_unregister(void) { destroy_workqueue(pciback_wq); - xenbus_unregister_driver(&xenbus_pciback_driver); + xenbus_unregister_driver(&pciback_driver); } --- a/drivers/xen/pcifront/xenbus.c +++ b/drivers/xen/pcifront/xenbus.c @@ -456,27 +456,24 @@ static int pcifront_xenbus_remove(struct return 0; } =20 -static const struct xenbus_device_id xenpci_ids[] =3D { +static const struct xenbus_device_id pcifront_ids[] =3D { {"pci"}, {{0}}, }; MODULE_ALIAS("xen:pci"); =20 -static struct xenbus_driver xenbus_pcifront_driver =3D { - .name =3D "pcifront", - .owner =3D THIS_MODULE, - .ids =3D xenpci_ids, +static DEFINE_XENBUS_DRIVER(pcifront, "pcifront", .probe =3D pcifront_xenbus_probe, .remove =3D pcifront_xenbus_remove, .otherend_changed =3D pcifront_backend_changed, -}; +); =20 static int __init pcifront_init(void) { if (!is_running_on_xen()) return -ENODEV; =20 - return xenbus_register_frontend(&xenbus_pcifront_driver); + return xenbus_register_frontend(&pcifront_driver); } =20 /* Initialize after the Xen PCI Frontend Stub is initialized */ --- a/drivers/xen/scsiback/xenbus.c +++ b/drivers/xen/scsiback/xenbus.c @@ -352,26 +352,23 @@ fail: } =20 =20 -static struct xenbus_device_id scsiback_ids[] =3D { +static const struct xenbus_device_id scsiback_ids[] =3D { { "vscsi" }, { "" } }; =20 -static struct xenbus_driver scsiback =3D { - .name =3D "vscsi", - .owner =3D THIS_MODULE, - .ids =3D scsiback_ids, +static DEFINE_XENBUS_DRIVER(scsiback, , .probe =3D scsiback_probe, .remove =3D scsiback_remove, .otherend_changed =3D scsiback_frontend_changed -}; +); =20 int scsiback_xenbus_init(void) { - return xenbus_register_backend(&scsiback); + return xenbus_register_backend(&scsiback_driver); } =20 void scsiback_xenbus_unregister(void) { - xenbus_unregister_driver(&scsiback); + xenbus_unregister_driver(&scsiback_driver); } --- a/drivers/xen/scsifront/xenbus.c +++ b/drivers/xen/scsifront/xenbus.c @@ -398,21 +398,18 @@ static void scsifront_backend_changed(st } =20 =20 -static struct xenbus_device_id scsifront_ids[] =3D { +static const struct xenbus_device_id scsifront_ids[] =3D { { "vscsi" }, { "" } }; MODULE_ALIAS("xen:vscsi"); =20 -static struct xenbus_driver scsifront_driver =3D { - .name =3D "vscsi", - .owner =3D THIS_MODULE, - .ids =3D scsifront_ids, +static DEFINE_XENBUS_DRIVER(scsifront, , .probe =3D scsifront_probe, .remove =3D scsifront_remove, /* .resume =3D scsifront_resume, */ .otherend_changed =3D scsifront_backend_changed, -}; +); =20 int scsifront_xenbus_init(void) { --- a/drivers/xen/tpmback/xenbus.c +++ b/drivers/xen/tpmback/xenbus.c @@ -251,23 +251,19 @@ static const struct xenbus_device_id tpm { "" } }; =20 - -static struct xenbus_driver tpmback =3D { - .name =3D "vtpm", - .owner =3D THIS_MODULE, - .ids =3D tpmback_ids, +static DEFINE_XENBUS_DRIVER(tpmback, , .probe =3D tpmback_probe, .remove =3D tpmback_remove, .otherend_changed =3D frontend_changed, -}; +); =20 =20 void tpmif_xenbus_init(void) { - xenbus_register_backend(&tpmback); + xenbus_register_backend(&tpmback_driver); } =20 void tpmif_xenbus_exit(void) { - xenbus_unregister_driver(&tpmback); + xenbus_unregister_driver(&tpmback_driver); } --- a/drivers/xen/usbback/xenbus.c +++ b/drivers/xen/usbback/xenbus.c @@ -317,14 +317,11 @@ static const struct xenbus_device_id usb { "" }, }; =20 -static struct xenbus_driver usbback_driver =3D { - .name =3D "vusb", - .owner =3D THIS_MODULE, - .ids =3D usbback_ids, +static DEFINE_XENBUS_DRIVER(usbback, , .probe =3D usbback_probe, .otherend_changed =3D frontend_changed, .remove =3D usbback_remove, -}; +); =20 int __init usbback_xenbus_init(void) { --- a/drivers/xen/usbfront/xenbus.c +++ b/drivers/xen/usbfront/xenbus.c @@ -379,14 +379,11 @@ static const struct xenbus_device_id usb }; MODULE_ALIAS("xen:vusb"); =20 -static struct xenbus_driver usbfront_driver =3D { - .name =3D "vusb", - .owner =3D THIS_MODULE, - .ids =3D usbfront_ids, +static DEFINE_XENBUS_DRIVER(usbfront, , .probe =3D usbfront_probe, .otherend_changed =3D backend_changed, .remove =3D usbfront_remove, -}; +); =20 static int __init usbfront_init(void) { --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -382,11 +382,7 @@ int xenbus_register_driver_common(struct if (bus->error) return bus->error; =20 - drv->driver.name =3D drv->name; drv->driver.bus =3D &bus->bus; -#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,6,10) - drv->driver.owner =3D drv->owner; -#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) drv->driver.probe =3D xenbus_dev_probe; drv->driver.remove =3D xenbus_dev_remove; --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -93,8 +94,6 @@ struct xenbus_device_id =20 /* A xenbus driver. */ struct xenbus_driver { - char *name; - struct module *owner; const struct xenbus_device_id *ids; int (*probe)(struct xenbus_device *dev, const struct xenbus_device_id *id); @@ -110,6 +109,19 @@ struct xenbus_driver { int (*is_ready)(struct xenbus_device *dev); }; =20 +#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,6,10) +# define XENBUS_DRIVER_SET_OWNER(mod) .driver.owner =3D mod, +#else +# define XENBUS_DRIVER_SET_OWNER(mod) +#endif + +#define DEFINE_XENBUS_DRIVER(var, drvname, methods...) \ +struct xenbus_driver var ## _driver =3D { \ + .driver.name =3D drvname + 0 ?: var ## _ids->devicetype, \ + XENBUS_DRIVER_SET_OWNER(THIS_MODULE) \ + .ids =3D var ## _ids, ## methods \ +} + static inline struct xenbus_driver *to_xenbus_driver(struct device_driver = *drv) { return container_of(drv, struct xenbus_driver, driver); --=__PartCAE56209.0__= Content-Type: text/plain; name="xen-xenbus-driver-cleanup.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-xenbus-driver-cleanup.patch" consolidate and simplify struct xenbus_driver instantiation=0A=0AThe = 'name' and 'owner' members are redundant with the identically named=0Afield= s in the 'driver' sub-structure. Rather than switching each=0Ainstance to = specify these fields explicitly, introduce a macro to=0Asimplify this (and = at once to abstract out - for the unmodified drivers=0Abuild - the absence = of the 'owner' field in Linux prior to 2.6.10).=0A=0AAlso add a module = alias for the vtpm frontend driver (overlooked in=0A141:5e294e29a43e).=0A= =0Av2: Eliminate further redundancy by allowing the drvname argument = to=0ADEFINE_XENBUS_DRIVER() to be blank (in which case the first entry = from=0Athe ID table will be used for .driver.name).=0A=0ASigned-off-by: = Jan Beulich =0A=0A--- a/drivers/char/tpm/tpm_xen.c=0A+++= b/drivers/char/tpm/tpm_xen.c=0A@@ -475,26 +475,24 @@ static int tpmif_conn= ect(struct xenbus_d=0A return 0;=0A }=0A =0A-static struct xenbus_device_i= d tpmfront_ids[] =3D {=0A+static const struct xenbus_device_id tpmfront_ids= [] =3D {=0A { "vtpm" },=0A { "" }=0A };=0A+MODULE_ALIAS("xen:vtpm");= =0A =0A-static struct xenbus_driver tpmfront =3D {=0A- .name =3D = "vtpm",=0A- .owner =3D THIS_MODULE,=0A- .ids =3D tpmfront_ids,=0A+s= tatic DEFINE_XENBUS_DRIVER(tpmfront, ,=0A .probe =3D tpmfront_probe,= =0A .remove =3D tpmfront_remove,=0A .resume =3D tpmfront_resume= ,=0A .otherend_changed =3D backend_changed,=0A .suspend =3D = tpmfront_suspend,=0A .suspend_cancel =3D tpmfront_suspend_cancel,=0A-};= =0A+);=0A =0A static void __init init_tpm_xenbus(void)=0A {=0A- xenbus_regi= ster_frontend(&tpmfront);=0A+ xenbus_register_frontend(&tpmfront_driver);= =0A }=0A =0A static int tpmif_allocate_tx_buffers(struct tpm_private = *tp)=0A--- a/drivers/xen/blkback/xenbus.c=0A+++ b/drivers/xen/blkback/xenbu= s.c=0A@@ -542,18 +542,14 @@ static const struct xenbus_device_id blk=0A = { "" }=0A };=0A =0A-=0A-static struct xenbus_driver blkback =3D {=0A- = .name =3D "vbd",=0A- .owner =3D THIS_MODULE,=0A- .ids =3D blkback_id= s,=0A+static DEFINE_XENBUS_DRIVER(blkback, ,=0A .probe =3D = blkback_probe,=0A .remove =3D blkback_remove,=0A .otherend_changed = =3D frontend_changed=0A-};=0A+);=0A =0A =0A void blkif_xenbus_init(void)=0A= {=0A- xenbus_register_backend(&blkback);=0A+ xenbus_register_backend(&bl= kback_driver);=0A }=0A--- a/drivers/xen/blkfront/blkfront.c=0A+++ = b/drivers/xen/blkfront/blkfront.c=0A@@ -934,16 +934,13 @@ static const = struct xenbus_device_id blk=0A };=0A MODULE_ALIAS("xen:vbd");=0A =0A-static= struct xenbus_driver blkfront =3D {=0A- .name =3D "vbd",=0A- = .owner =3D THIS_MODULE,=0A- .ids =3D blkfront_ids,=0A+static DEFINE_XEN= BUS_DRIVER(blkfront, ,=0A .probe =3D blkfront_probe,=0A .remove = =3D blkfront_remove,=0A .resume =3D blkfront_resume,=0A = .otherend_changed =3D backend_changed,=0A .is_ready =3D blkfront_is_r= eady,=0A-};=0A+);=0A =0A =0A static int __init xlblk_init(void)=0A@@ = -951,14 +948,14 @@ static int __init xlblk_init(void)=0A if = (!is_running_on_xen())=0A return -ENODEV;=0A =0A- return = xenbus_register_frontend(&blkfront);=0A+ return xenbus_register_fron= tend(&blkfront_driver);=0A }=0A module_init(xlblk_init);=0A =0A =0A static = void __exit xlblk_exit(void)=0A {=0A- return xenbus_unregister_driver(&bl= kfront);=0A+ return xenbus_unregister_driver(&blkfront_driver);=0A }=0A = module_exit(xlblk_exit);=0A =0A--- a/drivers/xen/blktap/xenbus.c=0A+++ = b/drivers/xen/blktap/xenbus.c=0A@@ -490,18 +490,14 @@ static const struct = xenbus_device_id blk=0A { "" }=0A };=0A =0A-=0A-static struct = xenbus_driver blktap =3D {=0A- .name =3D "tap",=0A- .owner =3D = THIS_MODULE,=0A- .ids =3D blktap_ids,=0A+static DEFINE_XENBUS_DRIVER= (blktap, ,=0A .probe =3D blktap_probe,=0A .remove =3D blktap_remove,= =0A .otherend_changed =3D tap_frontend_changed=0A-};=0A+);=0A =0A =0A = void tap_blkif_xenbus_init(void)=0A {=0A- xenbus_register_backend(&bl= ktap);=0A+ xenbus_register_backend(&blktap_driver);=0A }=0A--- = a/drivers/xen/fbfront/xenfb.c=0A+++ b/drivers/xen/fbfront/xenfb.c=0A@@ = -857,15 +857,12 @@ static const struct xenbus_device_id xen=0A };=0A = MODULE_ALIAS("xen:vfb");=0A =0A-static struct xenbus_driver xenfb_driver = =3D {=0A- .name =3D "vfb",=0A- .owner =3D THIS_MODULE,=0A- = .ids =3D xenfb_ids,=0A+static DEFINE_XENBUS_DRIVER(xenfb, ,=0A .probe =3D = xenfb_probe,=0A .remove =3D xenfb_remove,=0A .resume =3D = xenfb_resume,=0A .otherend_changed =3D xenfb_backend_changed,=0A-};= =0A+);=0A =0A static int __init xenfb_init(void)=0A {=0A--- a/drivers/xen/f= bfront/xenkbd.c=0A+++ b/drivers/xen/fbfront/xenkbd.c=0A@@ -335,15 +335,12 = @@ static const struct xenbus_device_id xen=0A };=0A MODULE_ALIAS("xen:vkbd= ");=0A =0A-static struct xenbus_driver xenkbd_driver =3D {=0A- .name =3D = "vkbd",=0A- .owner =3D THIS_MODULE,=0A- .ids =3D xenkbd_ids,=0A+sta= tic DEFINE_XENBUS_DRIVER(xenkbd, ,=0A .probe =3D xenkbd_probe,=0A = .remove =3D xenkbd_remove,=0A .resume =3D xenkbd_resume,=0A .otherend_c= hanged =3D xenkbd_backend_changed,=0A-};=0A+);=0A =0A static int __init = xenkbd_init(void)=0A {=0A--- a/drivers/xen/netback/xenbus.c=0A+++ = b/drivers/xen/netback/xenbus.c=0A@@ -437,19 +437,15 @@ static const struct = xenbus_device_id net=0A { "" }=0A };=0A =0A-=0A-static struct = xenbus_driver netback =3D {=0A- .name =3D "vif",=0A- .owner =3D = THIS_MODULE,=0A- .ids =3D netback_ids,=0A+static DEFINE_XENBUS_DRIVE= R(netback, ,=0A .probe =3D netback_probe,=0A .remove =3D = netback_remove,=0A .uevent =3D netback_uevent,=0A .otherend_changed = =3D frontend_changed,=0A-};=0A+);=0A =0A =0A void netif_xenbus_init(void)= =0A {=0A- xenbus_register_backend(&netback);=0A+ xenbus_register_bac= kend(&netback_driver);=0A }=0A--- a/drivers/xen/netfront/netfront.c=0A+++ = b/drivers/xen/netfront/netfront.c=0A@@ -2197,18 +2197,14 @@ static const = struct xenbus_device_id net=0A };=0A MODULE_ALIAS("xen:vif");=0A =0A-=0A-st= atic struct xenbus_driver netfront_driver =3D {=0A- .name =3D = "vif",=0A- .owner =3D THIS_MODULE,=0A- .ids =3D netfront_ids,=0A+s= tatic DEFINE_XENBUS_DRIVER(netfront, ,=0A .probe =3D netfront_probe,= =0A .remove =3D __devexit_p(netfront_remove),=0A .suspend =3D = netfront_suspend,=0A .suspend_cancel =3D netfront_suspend_cancel,=0A = .resume =3D netfront_resume,=0A .otherend_changed =3D backend_chang= ed,=0A-};=0A+);=0A =0A =0A static int __init netif_init(void)=0A--- = a/drivers/xen/pciback/xenbus.c=0A+++ b/drivers/xen/pciback/xenbus.c=0A@@ = -676,19 +676,16 @@ static int pciback_xenbus_remove(struct =0A return = 0;=0A }=0A =0A-static const struct xenbus_device_id xenpci_ids[] =3D = {=0A+static const struct xenbus_device_id pciback_ids[] =3D {=0A = {"pci"},=0A {{0}},=0A };=0A =0A-static struct xenbus_driver xenbus_pcib= ack_driver =3D {=0A- .name =3D "pciback",=0A- = .owner =3D THIS_MODULE,=0A- .ids = =3D xenpci_ids,=0A+static DEFINE_XENBUS_DRIVER(pciback, "pciback",=0A = .probe =3D pciback_xenbus_probe,=0A .remove = =3D pciback_xenbus_remove,=0A .otherend_changed =3D pciback_fronten= d_changed,=0A-};=0A+);=0A =0A int __init pciback_xenbus_register(void)=0A = {=0A@@ -700,11 +697,11 @@ int __init pciback_xenbus_register(void)=0A = "pciback_workqueue failed\n");=0A return -EFAULT;=0A = }=0A- return xenbus_register_backend(&xenbus_pciback_driver);=0A+= return xenbus_register_backend(&pciback_driver);=0A }=0A =0A void = __exit pciback_xenbus_unregister(void)=0A {=0A destroy_workqueue(pciback_w= q);=0A- xenbus_unregister_driver(&xenbus_pciback_driver);=0A+ xenbus_unre= gister_driver(&pciback_driver);=0A }=0A--- a/drivers/xen/pcifront/xenbus.c= =0A+++ b/drivers/xen/pcifront/xenbus.c=0A@@ -456,27 +456,24 @@ static int = pcifront_xenbus_remove(struct=0A return 0;=0A }=0A =0A-static const = struct xenbus_device_id xenpci_ids[] =3D {=0A+static const struct = xenbus_device_id pcifront_ids[] =3D {=0A {"pci"},=0A {{0}},=0A = };=0A MODULE_ALIAS("xen:pci");=0A =0A-static struct xenbus_driver = xenbus_pcifront_driver =3D {=0A- .name =3D = "pcifront",=0A- .owner =3D THIS_MODULE,=0A- .ids = =3D xenpci_ids,=0A+static DEFINE_XENBUS_DRIVER(pcifront, "pcifront"= ,=0A .probe =3D pcifront_xenbus_probe,=0A .remove = =3D pcifront_xenbus_remove,=0A .otherend_changed =3D = pcifront_backend_changed,=0A-};=0A+);=0A =0A static int __init pcifront_ini= t(void)=0A {=0A if (!is_running_on_xen())=0A return = -ENODEV;=0A =0A- return xenbus_register_frontend(&xenbus_pcifront_dr= iver);=0A+ return xenbus_register_frontend(&pcifront_driver);=0A }=0A = =0A /* Initialize after the Xen PCI Frontend Stub is initialized */=0A--- = a/drivers/xen/scsiback/xenbus.c=0A+++ b/drivers/xen/scsiback/xenbus.c=0A@@ = -352,26 +352,23 @@ fail:=0A }=0A =0A =0A-static struct xenbus_device_id = scsiback_ids[] =3D {=0A+static const struct xenbus_device_id scsiback_ids[]= =3D {=0A { "vscsi" },=0A { "" }=0A };=0A =0A-static struct = xenbus_driver scsiback =3D {=0A- .name =3D = "vscsi",=0A- .owner =3D THIS_MODULE,=0A- .ids = =3D scsiback_ids,=0A+static DEFINE_XENBUS_DRIVER(scsiback, ,=0A = .probe =3D scsiback_probe,=0A .remove = =3D scsiback_remove,=0A .otherend_changed =3D scsiback_fronte= nd_changed=0A-};=0A+);=0A =0A int scsiback_xenbus_init(void)=0A {=0A- = return xenbus_register_backend(&scsiback);=0A+ return xenbus_register_back= end(&scsiback_driver);=0A }=0A =0A void scsiback_xenbus_unregister(void)=0A= {=0A- xenbus_unregister_driver(&scsiback);=0A+ xenbus_unregister_d= river(&scsiback_driver);=0A }=0A--- a/drivers/xen/scsifront/xenbus.c=0A+++ = b/drivers/xen/scsifront/xenbus.c=0A@@ -398,21 +398,18 @@ static void = scsifront_backend_changed(st=0A }=0A =0A =0A-static struct xenbus_device_id= scsifront_ids[] =3D {=0A+static const struct xenbus_device_id scsifront_id= s[] =3D {=0A { "vscsi" },=0A { "" }=0A };=0A MODULE_ALIAS("xen:v= scsi");=0A =0A-static struct xenbus_driver scsifront_driver =3D {=0A- = .name =3D "vscsi",=0A- .owner = =3D THIS_MODULE,=0A- .ids =3D scsifront_ids,=0A+stati= c DEFINE_XENBUS_DRIVER(scsifront, ,=0A .probe =3D = scsifront_probe,=0A .remove =3D scsifront_remove,=0A = /* .resume =3D scsifront_resume, */=0A .otherend_c= hanged =3D scsifront_backend_changed,=0A-};=0A+);=0A =0A int scsifront_xen= bus_init(void)=0A {=0A--- a/drivers/xen/tpmback/xenbus.c=0A+++ b/drivers/xe= n/tpmback/xenbus.c=0A@@ -251,23 +251,19 @@ static const struct xenbus_devic= e_id tpm=0A { "" }=0A };=0A =0A-=0A-static struct xenbus_driver = tpmback =3D {=0A- .name =3D "vtpm",=0A- .owner =3D THIS_MODULE,=0A-= .ids =3D tpmback_ids,=0A+static DEFINE_XENBUS_DRIVER(tpmback, ,=0A = .probe =3D tpmback_probe,=0A .remove =3D tpmback_remove,=0A = .otherend_changed =3D frontend_changed,=0A-};=0A+);=0A =0A =0A void = tpmif_xenbus_init(void)=0A {=0A- xenbus_register_backend(&tpmback);= =0A+ xenbus_register_backend(&tpmback_driver);=0A }=0A =0A void = tpmif_xenbus_exit(void)=0A {=0A- xenbus_unregister_driver(&tpmback);= =0A+ xenbus_unregister_driver(&tpmback_driver);=0A }=0A--- a/drivers/xen= /usbback/xenbus.c=0A+++ b/drivers/xen/usbback/xenbus.c=0A@@ -317,14 = +317,11 @@ static const struct xenbus_device_id usb=0A { "" },=0A };=0A = =0A-static struct xenbus_driver usbback_driver =3D {=0A- .name =3D = "vusb",=0A- .owner =3D THIS_MODULE,=0A- .ids =3D usbback_ids,=0A+st= atic DEFINE_XENBUS_DRIVER(usbback, ,=0A .probe =3D usbback_probe,= =0A .otherend_changed =3D frontend_changed,=0A .remove =3D = usbback_remove,=0A-};=0A+);=0A =0A int __init usbback_xenbus_init(void)=0A = {=0A--- a/drivers/xen/usbfront/xenbus.c=0A+++ b/drivers/xen/usbfront/xenbus= .c=0A@@ -379,14 +379,11 @@ static const struct xenbus_device_id usb=0A = };=0A MODULE_ALIAS("xen:vusb");=0A =0A-static struct xenbus_driver = usbfront_driver =3D {=0A- .name =3D "vusb",=0A- .owner =3D = THIS_MODULE,=0A- .ids =3D usbfront_ids,=0A+static DEFINE_XENBUS_DRIV= ER(usbfront, ,=0A .probe =3D usbfront_probe,=0A .otherend_changed = =3D backend_changed,=0A .remove =3D usbfront_remove,=0A-};=0A+);=0A= =0A static int __init usbfront_init(void)=0A {=0A--- a/drivers/xen/xenbus/= xenbus_probe.c=0A+++ b/drivers/xen/xenbus/xenbus_probe.c=0A@@ -382,11 = +382,7 @@ int xenbus_register_driver_common(struct=0A if (bus->error)=0A = return bus->error;=0A =0A- drv->driver.name =3D = drv->name;=0A drv->driver.bus =3D &bus->bus;=0A-#if LINUX_VERSION_CODE = >=3D KERNEL_VERSION(2,6,10)=0A- drv->driver.owner =3D drv->owner;=0A-#endif= =0A #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)=0A drv->driver.probe = =3D xenbus_dev_probe;=0A drv->driver.remove =3D xenbus_dev_remove;= =0A--- a/include/xen/xenbus.h=0A+++ b/include/xen/xenbus.h=0A@@ -40,6 = +40,7 @@=0A #include =0A #include =0A = #include =0A+#include =0A #include =0A #include =0A #include = =0A@@ -93,8 +94,6 @@ struct xenbus_device_id=0A = =0A /* A xenbus driver. */=0A struct xenbus_driver {=0A- char = *name;=0A- struct module *owner;=0A const struct xenbus_device_= id *ids;=0A int (*probe)(struct xenbus_device *dev,=0A = const struct xenbus_device_id *id);=0A@@ -110,6 +109,19 @@ struct = xenbus_driver {=0A int (*is_ready)(struct xenbus_device *dev);=0A = };=0A =0A+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,6,10)=0A+# define = XENBUS_DRIVER_SET_OWNER(mod) .driver.owner =3D mod,=0A+#else=0A+# define = XENBUS_DRIVER_SET_OWNER(mod)=0A+#endif=0A+=0A+#define DEFINE_XENBUS_DRIVER(= var, drvname, methods...) \=0A+struct xenbus_driver var ## = _driver =3D { \=0A+ .driver.name =3D drvname + = 0 ?: var ## _ids->devicetype, \=0A+ XENBUS_DRIVER_SET_OWNER(THIS_MODULE= ) \=0A+ .ids =3D var ## _ids, ## methods = \=0A+}=0A+=0A static inline struct xenbus_driver *to_xenbus= _driver(struct device_driver *drv)=0A {=0A return container_of(drv, = struct xenbus_driver, driver);=0A --=__PartCAE56209.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartCAE56209.0__=--