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 /include/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 'include/xen')
-rw-r--r-- | include/xen/xenbus.h | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index b1b6676c1c43..e8c599b237c2 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h | |||
@@ -85,8 +85,6 @@ struct xenbus_device_id | |||
85 | 85 | ||
86 | /* A xenbus driver. */ | 86 | /* A xenbus driver. */ |
87 | struct xenbus_driver { | 87 | struct xenbus_driver { |
88 | char *name; | ||
89 | struct module *owner; | ||
90 | const struct xenbus_device_id *ids; | 88 | const struct xenbus_device_id *ids; |
91 | int (*probe)(struct xenbus_device *dev, | 89 | int (*probe)(struct xenbus_device *dev, |
92 | const struct xenbus_device_id *id); | 90 | const struct xenbus_device_id *id); |
@@ -101,31 +99,20 @@ struct xenbus_driver { | |||
101 | int (*is_ready)(struct xenbus_device *dev); | 99 | int (*is_ready)(struct xenbus_device *dev); |
102 | }; | 100 | }; |
103 | 101 | ||
104 | static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv) | 102 | #define DEFINE_XENBUS_DRIVER(var, drvname, methods...) \ |
105 | { | 103 | struct xenbus_driver var ## _driver = { \ |
106 | return container_of(drv, struct xenbus_driver, driver); | 104 | .driver.name = drvname + 0 ?: var ## _ids->devicetype, \ |
105 | .driver.owner = THIS_MODULE, \ | ||
106 | .ids = var ## _ids, ## methods \ | ||
107 | } | 107 | } |
108 | 108 | ||
109 | int __must_check __xenbus_register_frontend(struct xenbus_driver *drv, | 109 | static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv) |
110 | struct module *owner, | ||
111 | const char *mod_name); | ||
112 | |||
113 | static inline int __must_check | ||
114 | xenbus_register_frontend(struct xenbus_driver *drv) | ||
115 | { | 110 | { |
116 | WARN_ON(drv->owner != THIS_MODULE); | 111 | return container_of(drv, struct xenbus_driver, driver); |
117 | return __xenbus_register_frontend(drv, THIS_MODULE, KBUILD_MODNAME); | ||
118 | } | 112 | } |
119 | 113 | ||
120 | int __must_check __xenbus_register_backend(struct xenbus_driver *drv, | 114 | int __must_check xenbus_register_frontend(struct xenbus_driver *); |
121 | struct module *owner, | 115 | int __must_check xenbus_register_backend(struct xenbus_driver *); |
122 | const char *mod_name); | ||
123 | static inline int __must_check | ||
124 | xenbus_register_backend(struct xenbus_driver *drv) | ||
125 | { | ||
126 | WARN_ON(drv->owner != THIS_MODULE); | ||
127 | return __xenbus_register_backend(drv, THIS_MODULE, KBUILD_MODNAME); | ||
128 | } | ||
129 | 116 | ||
130 | void xenbus_unregister_driver(struct xenbus_driver *drv); | 117 | void xenbus_unregister_driver(struct xenbus_driver *drv); |
131 | 118 | ||