mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-12 18:35:35 -04:00
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>
This commit is contained in:
committed by
Konrad Rzeszutek Wilk
parent
2e16341438
commit
73db144b58
@@ -85,8 +85,6 @@ struct xenbus_device_id
|
||||
|
||||
/* 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);
|
||||
@@ -101,31 +99,20 @@ 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 *drv,
|
||||
struct module *owner,
|
||||
const char *mod_name);
|
||||
|
||||
static inline int __must_check
|
||||
xenbus_register_frontend(struct xenbus_driver *drv)
|
||||
{
|
||||
WARN_ON(drv->owner != THIS_MODULE);
|
||||
return __xenbus_register_frontend(drv, THIS_MODULE, KBUILD_MODNAME);
|
||||
}
|
||||
|
||||
int __must_check __xenbus_register_backend(struct xenbus_driver *drv,
|
||||
struct module *owner,
|
||||
const char *mod_name);
|
||||
static inline int __must_check
|
||||
xenbus_register_backend(struct xenbus_driver *drv)
|
||||
{
|
||||
WARN_ON(drv->owner != THIS_MODULE);
|
||||
return __xenbus_register_backend(drv, THIS_MODULE, KBUILD_MODNAME);
|
||||
}
|
||||
int __must_check xenbus_register_frontend(struct xenbus_driver *);
|
||||
int __must_check xenbus_register_backend(struct xenbus_driver *);
|
||||
|
||||
void xenbus_unregister_driver(struct xenbus_driver *drv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user