Skip to content

Commit 73db144

Browse files
jbeulichkonradwilk
authored andcommitted
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>
1 parent 2e16341 commit 73db144

File tree

13 files changed

+44
-92
lines changed

13 files changed

+44
-92
lines changed

drivers/block/xen-blkback/xenbus.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,17 +787,14 @@ static const struct xenbus_device_id xen_blkbk_ids[] = {
787787
};
788788

789789

790-
static struct xenbus_driver xen_blkbk = {
791-
.name = "vbd",
792-
.owner = THIS_MODULE,
793-
.ids = xen_blkbk_ids,
790+
static DEFINE_XENBUS_DRIVER(xen_blkbk, ,
794791
.probe = xen_blkbk_probe,
795792
.remove = xen_blkbk_remove,
796793
.otherend_changed = frontend_changed
797-
};
794+
);
798795

799796

800797
int xen_blkif_xenbus_init(void)
801798
{
802-
return xenbus_register_backend(&xen_blkbk);
799+
return xenbus_register_backend(&xen_blkbk_driver);
803800
}

drivers/block/xen-blkfront.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,16 +1437,13 @@ static const struct xenbus_device_id blkfront_ids[] = {
14371437
{ "" }
14381438
};
14391439

1440-
static struct xenbus_driver blkfront = {
1441-
.name = "vbd",
1442-
.owner = THIS_MODULE,
1443-
.ids = blkfront_ids,
1440+
static DEFINE_XENBUS_DRIVER(blkfront, ,
14441441
.probe = blkfront_probe,
14451442
.remove = blkfront_remove,
14461443
.resume = blkfront_resume,
14471444
.otherend_changed = blkback_changed,
14481445
.is_ready = blkfront_is_ready,
1449-
};
1446+
);
14501447

14511448
static int __init xlblk_init(void)
14521449
{
@@ -1461,7 +1458,7 @@ static int __init xlblk_init(void)
14611458
return -ENODEV;
14621459
}
14631460

1464-
ret = xenbus_register_frontend(&blkfront);
1461+
ret = xenbus_register_frontend(&blkfront_driver);
14651462
if (ret) {
14661463
unregister_blkdev(XENVBD_MAJOR, DEV_NAME);
14671464
return ret;
@@ -1474,7 +1471,7 @@ module_init(xlblk_init);
14741471

14751472
static void __exit xlblk_exit(void)
14761473
{
1477-
return xenbus_unregister_driver(&blkfront);
1474+
return xenbus_unregister_driver(&blkfront_driver);
14781475
}
14791476
module_exit(xlblk_exit);
14801477

drivers/input/misc/xen-kbdfront.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,12 @@ static const struct xenbus_device_id xenkbd_ids[] = {
361361
{ "" }
362362
};
363363

364-
static struct xenbus_driver xenkbd_driver = {
365-
.name = "vkbd",
366-
.owner = THIS_MODULE,
367-
.ids = xenkbd_ids,
364+
static DEFINE_XENBUS_DRIVER(xenkbd, ,
368365
.probe = xenkbd_probe,
369366
.remove = xenkbd_remove,
370367
.resume = xenkbd_resume,
371368
.otherend_changed = xenkbd_backend_changed,
372-
};
369+
);
373370

374371
static int __init xenkbd_init(void)
375372
{

drivers/net/xen-netback/xenbus.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,17 +474,14 @@ static const struct xenbus_device_id netback_ids[] = {
474474
};
475475

476476

477-
static struct xenbus_driver netback = {
478-
.name = "vif",
479-
.owner = THIS_MODULE,
480-
.ids = netback_ids,
477+
static DEFINE_XENBUS_DRIVER(netback, ,
481478
.probe = netback_probe,
482479
.remove = netback_remove,
483480
.uevent = netback_uevent,
484481
.otherend_changed = frontend_changed,
485-
};
482+
);
486483

487484
int xenvif_xenbus_init(void)
488485
{
489-
return xenbus_register_backend(&netback);
486+
return xenbus_register_backend(&netback_driver);
490487
}

drivers/net/xen-netfront.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ static void xennet_sysfs_delif(struct net_device *netdev)
19101910

19111911
#endif /* CONFIG_SYSFS */
19121912

1913-
static struct xenbus_device_id netfront_ids[] = {
1913+
static const struct xenbus_device_id netfront_ids[] = {
19141914
{ "vif" },
19151915
{ "" }
19161916
};
@@ -1937,15 +1937,12 @@ static int __devexit xennet_remove(struct xenbus_device *dev)
19371937
return 0;
19381938
}
19391939

1940-
static struct xenbus_driver netfront_driver = {
1941-
.name = "vif",
1942-
.owner = THIS_MODULE,
1943-
.ids = netfront_ids,
1940+
static DEFINE_XENBUS_DRIVER(netfront, ,
19441941
.probe = netfront_probe,
19451942
.remove = __devexit_p(xennet_remove),
19461943
.resume = netfront_resume,
19471944
.otherend_changed = netback_changed,
1948-
};
1945+
);
19491946

19501947
static int __init netif_init(void)
19511948
{

drivers/pci/xen-pcifront.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,14 +1126,11 @@ static const struct xenbus_device_id xenpci_ids[] = {
11261126
{""},
11271127
};
11281128

1129-
static struct xenbus_driver xenbus_pcifront_driver = {
1130-
.name = "pcifront",
1131-
.owner = THIS_MODULE,
1132-
.ids = xenpci_ids,
1129+
static DEFINE_XENBUS_DRIVER(xenpci, "pcifront",
11331130
.probe = pcifront_xenbus_probe,
11341131
.remove = pcifront_xenbus_remove,
11351132
.otherend_changed = pcifront_backend_changed,
1136-
};
1133+
);
11371134

11381135
static int __init pcifront_init(void)
11391136
{
@@ -1142,12 +1139,12 @@ static int __init pcifront_init(void)
11421139

11431140
pci_frontend_registrar(1 /* enable */);
11441141

1145-
return xenbus_register_frontend(&xenbus_pcifront_driver);
1142+
return xenbus_register_frontend(&xenpci_driver);
11461143
}
11471144

11481145
static void __exit pcifront_cleanup(void)
11491146
{
1150-
xenbus_unregister_driver(&xenbus_pcifront_driver);
1147+
xenbus_unregister_driver(&xenpci_driver);
11511148
pci_frontend_registrar(0 /* disable */);
11521149
}
11531150
module_init(pcifront_init);

drivers/video/xen-fbfront.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,20 +671,17 @@ static void xenfb_backend_changed(struct xenbus_device *dev,
671671
}
672672
}
673673

674-
static struct xenbus_device_id xenfb_ids[] = {
674+
static const struct xenbus_device_id xenfb_ids[] = {
675675
{ "vfb" },
676676
{ "" }
677677
};
678678

679-
static struct xenbus_driver xenfb_driver = {
680-
.name = "vfb",
681-
.owner = THIS_MODULE,
682-
.ids = xenfb_ids,
679+
static DEFINE_XENBUS_DRIVER(xenfb, ,
683680
.probe = xenfb_probe,
684681
.remove = xenfb_remove,
685682
.resume = xenfb_resume,
686683
.otherend_changed = xenfb_backend_changed,
687-
};
684+
);
688685

689686
static int __init xenfb_init(void)
690687
{

drivers/xen/xen-pciback/xenbus.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -707,19 +707,16 @@ static int xen_pcibk_xenbus_remove(struct xenbus_device *dev)
707707
return 0;
708708
}
709709

710-
static const struct xenbus_device_id xenpci_ids[] = {
710+
static const struct xenbus_device_id xen_pcibk_ids[] = {
711711
{"pci"},
712712
{""},
713713
};
714714

715-
static struct xenbus_driver xenbus_xen_pcibk_driver = {
716-
.name = DRV_NAME,
717-
.owner = THIS_MODULE,
718-
.ids = xenpci_ids,
715+
static DEFINE_XENBUS_DRIVER(xen_pcibk, DRV_NAME,
719716
.probe = xen_pcibk_xenbus_probe,
720717
.remove = xen_pcibk_xenbus_remove,
721718
.otherend_changed = xen_pcibk_frontend_changed,
722-
};
719+
);
723720

724721
const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend;
725722

@@ -735,11 +732,11 @@ int __init xen_pcibk_xenbus_register(void)
735732
if (passthrough)
736733
xen_pcibk_backend = &xen_pcibk_passthrough_backend;
737734
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);
739736
}
740737

741738
void __exit xen_pcibk_xenbus_unregister(void)
742739
{
743740
destroy_workqueue(xen_pcibk_wq);
744-
xenbus_unregister_driver(&xenbus_xen_pcibk_driver);
741+
xenbus_unregister_driver(&xen_pcibk_driver);
745742
}

drivers/xen/xenbus/xenbus_probe.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,9 @@ void xenbus_dev_shutdown(struct device *_dev)
291291
EXPORT_SYMBOL_GPL(xenbus_dev_shutdown);
292292

293293
int xenbus_register_driver_common(struct xenbus_driver *drv,
294-
struct xen_bus_type *bus,
295-
struct module *owner,
296-
const char *mod_name)
294+
struct xen_bus_type *bus)
297295
{
298-
drv->driver.name = drv->name;
299296
drv->driver.bus = &bus->bus;
300-
drv->driver.owner = owner;
301-
drv->driver.mod_name = mod_name;
302297

303298
return driver_register(&drv->driver);
304299
}

drivers/xen/xenbus/xenbus_probe.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ extern int xenbus_match(struct device *_dev, struct device_driver *_drv);
5353
extern int xenbus_dev_probe(struct device *_dev);
5454
extern int xenbus_dev_remove(struct device *_dev);
5555
extern int xenbus_register_driver_common(struct xenbus_driver *drv,
56-
struct xen_bus_type *bus,
57-
struct module *owner,
58-
const char *mod_name);
56+
struct xen_bus_type *bus);
5957
extern int xenbus_probe_node(struct xen_bus_type *bus,
6058
const char *type,
6159
const char *nodename);

0 commit comments

Comments
 (0)