From patchwork Tue Feb 16 11:07:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12089837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA2D3C433E0 for ; Tue, 16 Feb 2021 11:12:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F70864DA1 for ; Tue, 16 Feb 2021 11:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbhBPLL5 (ORCPT ); Tue, 16 Feb 2021 06:11:57 -0500 Received: from mga05.intel.com ([192.55.52.43]:36591 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbhBPLLU (ORCPT ); Tue, 16 Feb 2021 06:11:20 -0500 IronPort-SDR: Xc8wtMyjr+79jtNgaACrzDoOzmAIG6VHN3HJOVNABnQvhsb7+BOn+hdjZNAYpLrDrGWVDp3vst SBxA+a0GJGXA== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="267705908" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="267705908" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 03:07:47 -0800 IronPort-SDR: u+q53oNoCbELQJ1jYWb5CE66uod0DukWLUxwHEjP1+ollnjegC/VTvd23HsE7fW8JzmvI2eXXs ACzNoTLTUA8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="418038625" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 16 Feb 2021 03:07:45 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 157991F1; Tue, 16 Feb 2021 13:07:44 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Sudip Mukherjee , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] parport: Introduce module_parport_driver() helper macro Date: Tue, 16 Feb 2021 13:07:39 +0200 Message-Id: <20210216110741.1286-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Introduce module_parport_driver() helper macro to reduce boilerplate in the existing and new code. Signed-off-by: Andy Shevchenko Acked-by: Sudip Mukherjee --- v2: fixed typo in the macro include/linux/parport.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/parport.h b/include/linux/parport.h index 1fb508c19e83..54539b80021e 100644 --- a/include/linux/parport.h +++ b/include/linux/parport.h @@ -301,9 +301,19 @@ int __must_check __parport_register_driver(struct parport_driver *, __parport_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) /* Unregister a high-level driver. */ -extern void parport_unregister_driver (struct parport_driver *); void parport_unregister_driver(struct parport_driver *); +/** + * module_parport_driver() - Helper macro for registering a modular parport driver + * @__parport_driver: struct parport_driver to be used + * + * Helper macro for parport drivers which do not do anything special in module + * init and exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit(). + */ +#define module_parport_driver(__parport_driver) \ + module_driver(__parport_driver, parport_register_driver, parport_unregister_driver) + /* If parport_register_driver doesn't fit your needs, perhaps * parport_find_xxx does. */ extern struct parport *parport_find_number (int); From patchwork Tue Feb 16 11:07:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12089833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AC91C433E6 for ; Tue, 16 Feb 2021 11:10:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11F2964DE0 for ; Tue, 16 Feb 2021 11:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbhBPLKE (ORCPT ); Tue, 16 Feb 2021 06:10:04 -0500 Received: from mga09.intel.com ([134.134.136.24]:49486 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhBPLJU (ORCPT ); Tue, 16 Feb 2021 06:09:20 -0500 IronPort-SDR: F/ONUZqqmfmlElqziYAoT9gvFoUBrv9dl1vGSfft/n1RjT95KIaAACuNsa+zk4AP9X7SS16Bt7 cBstjTbGBvDA== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="182992613" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="182992613" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 03:07:47 -0800 IronPort-SDR: yIB21iHD5n0T4QrLFJY27zSx33lUfLBxLL7myxINaHMWDtx4u7jQgkzd8AQb1V3giPoz0+yPrg 12KxDVBCD1Ww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="377522912" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 16 Feb 2021 03:07:46 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1E692169; Tue, 16 Feb 2021 13:07:45 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Sudip Mukherjee , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] spi: butterfly: Switch to use module_parport_driver() Date: Tue, 16 Feb 2021 13:07:40 +0200 Message-Id: <20210216110741.1286-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210216110741.1286-1-andriy.shevchenko@linux.intel.com> References: <20210216110741.1286-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Switch to use module_parport_driver() to reduce boilerplate code. Note, device_initcall() is a default for module_init(). Signed-off-by: Andy Shevchenko Acked-by: Mark Brown --- v2: added Ack (Mark) drivers/spi/spi-butterfly.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/spi/spi-butterfly.c b/drivers/spi/spi-butterfly.c index 7e71a351f3b7..cceae816cebc 100644 --- a/drivers/spi/spi-butterfly.c +++ b/drivers/spi/spi-butterfly.c @@ -317,18 +317,7 @@ static struct parport_driver butterfly_driver = { .detach = butterfly_detach, .devmodel = true, }; - -static int __init butterfly_init(void) -{ - return parport_register_driver(&butterfly_driver); -} -device_initcall(butterfly_init); - -static void __exit butterfly_exit(void) -{ - parport_unregister_driver(&butterfly_driver); -} -module_exit(butterfly_exit); +module_parport_driver(butterfly_driver); MODULE_DESCRIPTION("Parport Adapter driver for AVR Butterfly"); MODULE_LICENSE("GPL"); From patchwork Tue Feb 16 11:07:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12089835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90121C433E0 for ; Tue, 16 Feb 2021 11:11:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44E7264DE0 for ; Tue, 16 Feb 2021 11:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230081AbhBPLLP (ORCPT ); Tue, 16 Feb 2021 06:11:15 -0500 Received: from mga09.intel.com ([134.134.136.24]:49760 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbhBPLJg (ORCPT ); Tue, 16 Feb 2021 06:09:36 -0500 IronPort-SDR: J9wvyt27RbeQ2cHOsPa1XLuhNKgHi9JxSXO5KyscYAk2LFw2yWZFtu3fYjulZgMoFg6PezHQo3 tv5E8QI7AKmA== X-IronPort-AV: E=McAfee;i="6000,8403,9896"; a="182992614" X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="182992614" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2021 03:07:47 -0800 IronPort-SDR: Iej7RUIaQ4Nz/7fArfd+rv/geugQgFE75rKmfPmnREXq02bkfqiEJQX2XwaO00SPpAAJkV5CtB 2dGSzWaFSrRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="377522914" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 16 Feb 2021 03:07:46 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2774A2D5; Tue, 16 Feb 2021 13:07:45 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Sudip Mukherjee , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] spi: lm70llp: Switch to use module_parport_driver() Date: Tue, 16 Feb 2021 13:07:41 +0200 Message-Id: <20210216110741.1286-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210216110741.1286-1-andriy.shevchenko@linux.intel.com> References: <20210216110741.1286-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Switch to use module_parport_driver() to reduce boilerplate code. Signed-off-by: Andy Shevchenko Acked-by: Mark Brown --- v2: added Ack (Mark), drop unneeded note from the commit message drivers/spi/spi-lm70llp.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/spi/spi-lm70llp.c b/drivers/spi/spi-lm70llp.c index 174dba29b1dd..f914b8d2043e 100644 --- a/drivers/spi/spi-lm70llp.c +++ b/drivers/spi/spi-lm70llp.c @@ -320,18 +320,7 @@ static struct parport_driver spi_lm70llp_drv = { .detach = spi_lm70llp_detach, .devmodel = true, }; - -static int __init init_spi_lm70llp(void) -{ - return parport_register_driver(&spi_lm70llp_drv); -} -module_init(init_spi_lm70llp); - -static void __exit cleanup_spi_lm70llp(void) -{ - parport_unregister_driver(&spi_lm70llp_drv); -} -module_exit(cleanup_spi_lm70llp); +module_parport_driver(spi_lm70llp_drv); MODULE_AUTHOR("Kaiwan N Billimoria "); MODULE_DESCRIPTION(