@@ -74,22 +74,22 @@ MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
static struct bus_type ntb_bus;
static void ntb_dev_release(struct device *dev);
-int ntb_register_client(struct ntb_client *client)
+int __ntb_register_client(struct ntb_client *client, struct module *mod,
+ const char *mod_name)
{
if (!client)
return -EINVAL;
- if (!client->name)
- return -EINVAL;
if (!ntb_client_ops_is_valid(&client->ops))
return -EINVAL;
memset(&client->drv, 0, sizeof(client->drv));
client->drv.bus = &ntb_bus;
- client->drv.name = client->name;
+ client->drv.name = mod_name;
+ client->drv.owner = mod;
return driver_register(&client->drv);
}
-EXPORT_SYMBOL(ntb_register_client);
+EXPORT_SYMBOL(__ntb_register_client);
void ntb_unregister_client(struct ntb_client *client)
{
@@ -1948,7 +1948,6 @@ static struct ntb_client ntb_transport_client = {
.probe = ntb_transport_probe,
.remove = ntb_transport_free,
},
- .name = NTB_TRANSPORT_NAME,
};
static int __init ntb_transport_init(void)
@@ -246,6 +246,5 @@ static struct ntb_client pp_client = {
.probe = pp_probe,
.remove = pp_remove,
},
- .name = DRIVER_NAME,
};
module_ntb_client(pp_client);
@@ -527,7 +527,6 @@ static struct ntb_client tool_client = {
.probe = tool_probe,
.remove = tool_remove,
},
- .name = DRIVER_NAME,
};
static int __init tool_init(void)
@@ -304,12 +304,10 @@ static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
/**
* struct ntb_client - client interested in ntb devices
* @drv: Linux driver object.
- * @name: Client driver name.
* @ops: See &ntb_client_ops.
*/
struct ntb_client {
struct device_driver drv;
- const char *name;
const struct ntb_client_ops ops;
};
@@ -353,7 +351,11 @@ struct ntb_dev {
*
* Return: Zero if the client is registered, otherwise an error number.
*/
-int ntb_register_client(struct ntb_client *client);
+#define ntb_register_client(__client) \
+ __ntb_register_client((__client), THIS_MODULE, KBUILD_MODNAME)
+
+int __ntb_register_client(struct ntb_client *client, struct module *mod,
+ const char *mod_name);
/**
* ntb_unregister_client() - unregister a client for interest in ntb devices
Following the example of pci_register_driver, change ntb_register_client to be a macro, calling __ntb_register_client with THIS_MODULE and KBUILD_MODNAME to initialize the driver .owner and .name members. Signed-off-by: Allen Hubbe <Allen.Hubbe@emc.com> --- drivers/ntb/ntb.c | 10 +++++----- drivers/ntb/ntb_transport.c | 1 - drivers/ntb/test/ntb_pingpong.c | 1 - drivers/ntb/test/ntb_tool.c | 1 - include/linux/ntb.h | 8 +++++--- 5 files changed, 10 insertions(+), 11 deletions(-)