From patchwork Wed Aug 29 07:42:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10579615 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74D3A1805 for ; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6592E2A7A5 for ; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55FCB2A7B7; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0FFF2A7B7 for ; Wed, 29 Aug 2018 07:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbeH2LiS (ORCPT ); Wed, 29 Aug 2018 07:38:18 -0400 Received: from sauhun.de ([88.99.104.3]:44860 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727264AbeH2LiS (ORCPT ); Wed, 29 Aug 2018 07:38:18 -0400 Received: from localhost (p54B3352D.dip0.t-ipconnect.de [84.179.53.45]) by pokefinder.org (Postfix) with ESMTPSA id 98DAF343CE5; Wed, 29 Aug 2018 09:42:43 +0200 (CEST) From: Wolfram Sang To: linux-watchdog@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , Wolfram Sang Subject: [RFC PATCH v3 1/4] watchdog: core: add mechanism to prevent removing if NOWAYOUT Date: Wed, 29 Aug 2018 09:42:38 +0200 Message-Id: <20180829074241.1943-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> References: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To prevent removing if NOWAYOUT, we invalidate the .remove function and suppress the bind/unbind attributes in sysfs. These are driver capabilities, so we need to set it up at runtime during init. To avoid boilerplate, introduce module_watchdog_driver() similar to module_driver(). On top of that, we then build module_watchdog_platform_driver(). Others may follow, if needed. Signed-off-by: Wolfram Sang --- include/linux/watchdog.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index 44985c4a1e86..c8ecbc53c807 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h @@ -216,4 +216,21 @@ extern void watchdog_unregister_device(struct watchdog_device *); /* devres register variant */ int devm_watchdog_register_device(struct device *dev, struct watchdog_device *); +#define module_watchdog_driver(__driver, __register, __unregister, __nowayout, ...) \ +static int __init __driver##_init(void) \ +{ \ + __driver.driver.suppress_bind_attrs = !!(__nowayout); \ + return __register(&(__driver) ##__VA_ARGS__); \ +} \ +module_init(__driver##_init); \ +static void __exit __driver##_exit(void) \ +{ \ + __unregister(&(__driver), ##__VA_ARGS__); \ +} \ +module_exit(__driver##_exit) + +#define module_watchdog_platform_driver(__platform_driver, __nowayout) \ + module_watchdog_driver(__platform_driver, platform_driver_register, \ + platform_driver_unregister, __nowayout) + #endif /* ifndef _LINUX_WATCHDOG_H */ From patchwork Wed Aug 29 07:42:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10579617 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6DB25A4 for ; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 995592A7A5 for ; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DEE42A7B7; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 506442A7B8 for ; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbeH2LiT (ORCPT ); Wed, 29 Aug 2018 07:38:19 -0400 Received: from sauhun.de ([88.99.104.3]:44870 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727677AbeH2LiT (ORCPT ); Wed, 29 Aug 2018 07:38:19 -0400 Received: from localhost (p54B3352D.dip0.t-ipconnect.de [84.179.53.45]) by pokefinder.org (Postfix) with ESMTPSA id 2A2B5343CE7; Wed, 29 Aug 2018 09:42:44 +0200 (CEST) From: Wolfram Sang To: linux-watchdog@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , Wolfram Sang Subject: [RFC PATCH v3 2/4] watchdog: renesas_wdt: avoid removing if NOWAYOUT Date: Wed, 29 Aug 2018 09:42:39 +0200 Message-Id: <20180829074241.1943-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> References: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new macro to prevent removing the driver if NOWAYOUT. Signed-off-by: Wolfram Sang --- drivers/watchdog/renesas_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index f45cb183fa75..92339c744cce 100644 --- a/drivers/watchdog/renesas_wdt.c +++ b/drivers/watchdog/renesas_wdt.c @@ -302,7 +302,7 @@ static struct platform_driver rwdt_driver = { .probe = rwdt_probe, .remove = rwdt_remove, }; -module_platform_driver(rwdt_driver); +module_watchdog_platform_driver(rwdt_driver, nowayout); MODULE_DESCRIPTION("Renesas WDT Watchdog Driver"); MODULE_LICENSE("GPL v2"); From patchwork Wed Aug 29 07:42:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10579619 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35CD9180E for ; Wed, 29 Aug 2018 07:42:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 296E42A7A5 for ; Wed, 29 Aug 2018 07:42:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E1892A7B8; Wed, 29 Aug 2018 07:42:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3CE62A7A5 for ; Wed, 29 Aug 2018 07:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727677AbeH2LiT (ORCPT ); Wed, 29 Aug 2018 07:38:19 -0400 Received: from sauhun.de ([88.99.104.3]:44876 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727072AbeH2LiT (ORCPT ); Wed, 29 Aug 2018 07:38:19 -0400 Received: from localhost (p54B3352D.dip0.t-ipconnect.de [84.179.53.45]) by pokefinder.org (Postfix) with ESMTPSA id B1D1C343CE6; Wed, 29 Aug 2018 09:42:44 +0200 (CEST) From: Wolfram Sang To: linux-watchdog@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , Wolfram Sang Subject: [RFC PATCH v3 3/4] watchdog: core: add module_watchdog_pci_driver() Date: Wed, 29 Aug 2018 09:42:40 +0200 Message-Id: <20180829074241.1943-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> References: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow PCI drivers to prevent removing if NOWAYOUT, too. Note: This is only a build-tested proof-of-concept! Signed-off-by: Wolfram Sang --- include/linux/watchdog.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index c8ecbc53c807..7f097d6f94d4 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h @@ -233,4 +233,8 @@ module_exit(__driver##_exit) module_watchdog_driver(__platform_driver, platform_driver_register, \ platform_driver_unregister, __nowayout) +#define module_watchdog_pci_driver(__pci_driver, __nowayout) \ + module_watchdog_driver(__pci_driver, pci_register_driver, \ + pci_unregister_driver, __nowayout) + #endif /* ifndef _LINUX_WATCHDOG_H */ From patchwork Wed Aug 29 07:42:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10579621 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB6E75A4 for ; Wed, 29 Aug 2018 07:42:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE64B2A7A5 for ; Wed, 29 Aug 2018 07:42:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2FC82A7B8; Wed, 29 Aug 2018 07:42:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7569E2A7A5 for ; Wed, 29 Aug 2018 07:42:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbeH2LiU (ORCPT ); Wed, 29 Aug 2018 07:38:20 -0400 Received: from sauhun.de ([88.99.104.3]:44884 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727264AbeH2LiU (ORCPT ); Wed, 29 Aug 2018 07:38:20 -0400 Received: from localhost (p54B3352D.dip0.t-ipconnect.de [84.179.53.45]) by pokefinder.org (Postfix) with ESMTPSA id 52287343CE8; Wed, 29 Aug 2018 09:42:45 +0200 (CEST) From: Wolfram Sang To: linux-watchdog@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , Wolfram Sang Subject: [RFC PATCH v3 4/4] watchdog: i6300esb: avoid removing if NOWAYOUT Date: Wed, 29 Aug 2018 09:42:41 +0200 Message-Id: <20180829074241.1943-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> References: <20180829074241.1943-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new macro to prevent removing the driver if NOWAYOUT. Signed-off-by: Wolfram Sang --- drivers/watchdog/i6300esb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c index 950c71a8bb22..939224789e2a 100644 --- a/drivers/watchdog/i6300esb.c +++ b/drivers/watchdog/i6300esb.c @@ -356,7 +356,7 @@ static struct pci_driver esb_driver = { .remove = esb_remove, }; -module_pci_driver(esb_driver); +module_watchdog_pci_driver(esb_driver, nowayout); MODULE_AUTHOR("Ross Biro and David Härdeman"); MODULE_DESCRIPTION("Watchdog driver for Intel 6300ESB chipsets");