From patchwork Mon Jun 1 09:24:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Hubbe X-Patchwork-Id: 6522471 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DA3DD9F40A for ; Mon, 1 Jun 2015 14:25:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D95732052F for ; Mon, 1 Jun 2015 14:25:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D4C320527 for ; Mon, 1 Jun 2015 14:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751542AbbFAOZM (ORCPT ); Mon, 1 Jun 2015 10:25:12 -0400 Received: from mailuogwdur.emc.com ([128.221.224.79]:58596 "EHLO mailuogwdur.emc.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751487AbbFAOZK (ORCPT ); Mon, 1 Jun 2015 10:25:10 -0400 Received: from maildlpprd51.lss.emc.com (maildlpprd51.lss.emc.com [10.106.48.155]) by mailuogwprd54.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id t51EP3f5008032 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 1 Jun 2015 10:25:05 -0400 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd54.lss.emc.com t51EP3f5008032 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=emc.com; s=jan2013; t=1433168706; bh=3nWVscD9StYtjnIALISUzYvzKmw=; h=From:To:Cc:Subject:Date:Message-Id; b=jwvUn8rMPf94TRUNft5pUhOK6hjeSgaurPvYEMT0u+TRng9aEZiK6F7kveTSBAYsW Kmceku2uDTiin+LpwBn6mj1yOp307iiJIVWPNnoyHQ7hgOuABXf0KW08sSRHLaIbJo 4DcqoTHb1v3q/VyqyzRn/n+zIzaqrVeTya3bpC4U= X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd54.lss.emc.com t51EP3f5008032 Received: from mailapphubprd04.lss.emc.com (emcmail.lss.emc.com [10.253.24.71]) by maildlpprd51.lss.emc.com (RSA Interceptor); Mon, 1 Jun 2015 10:24:16 -0400 Received: from HY-R1012-SPA.usd.lab.emc.com.com (hy-r1012-spa.rtp.lab.emc.com [10.6.71.221]) by mailapphubprd04.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id t51EOn8e008008; Mon, 1 Jun 2015 10:24:50 -0400 From: Allen Hubbe To: linux-ntb@googlegroups.com Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jon Mason , Dave Jiang , Allen Hubbe Subject: [PATCH] NTB: Register client drivers with name and owner Date: Mon, 1 Jun 2015 05:24:19 -0400 Message-Id: <93af09225e9d09ae14578bd8e4fae4aa2c5ffea6.1433150439.git.Allen.Hubbe@emc.com> X-Mailer: git-send-email 2.4.0.rc0.44.g244209c.dirty X-RSA-Classifications: Source Code, public X-Sentrion-Hostname: mailuogwprd54.lss.emc.com Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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(-) diff --git a/drivers/ntb/ntb.c b/drivers/ntb/ntb.c index 0e27745b9c4b..23435f2a5486 100644 --- a/drivers/ntb/ntb.c +++ b/drivers/ntb/ntb.c @@ -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) { diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index b70b6a30a0b5..cbf649caabbe 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -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) diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c index a18f895839c3..fe1600566981 100644 --- a/drivers/ntb/test/ntb_pingpong.c +++ b/drivers/ntb/test/ntb_pingpong.c @@ -246,6 +246,5 @@ static struct ntb_client pp_client = { .probe = pp_probe, .remove = pp_remove, }, - .name = DRIVER_NAME, }; module_ntb_client(pp_client); diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c index 49628efc0c2b..c7933936b41d 100644 --- a/drivers/ntb/test/ntb_tool.c +++ b/drivers/ntb/test/ntb_tool.c @@ -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) diff --git a/include/linux/ntb.h b/include/linux/ntb.h index e8f29be3c543..790b8ee181f6 100644 --- a/include/linux/ntb.h +++ b/include/linux/ntb.h @@ -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