From patchwork Wed Aug 20 00:45:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 4747031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 901469F377 for ; Wed, 20 Aug 2014 00:48:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A785B2016C for ; Wed, 20 Aug 2014 00:48:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 900862015D for ; Wed, 20 Aug 2014 00:48:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJu3L-0007DH-Sx; Wed, 20 Aug 2014 00:47:03 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJu2q-0006jc-1Q for linux-arm-kernel@lists.infradead.org; Wed, 20 Aug 2014 00:46:33 +0000 Received: by mail-pa0-f46.google.com with SMTP id lj1so11017579pab.5 for ; Tue, 19 Aug 2014 17:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=gtPbx3wJ2C4mlY1ab+sbCDWYKi6+gWVV/vjuOi03/0s=; b=Ofb+xHCaw6U0klShRtMdS1TONoOSAxRTEUt8RKcLa6+jGo6jBCuUzfoJgP0yW2O2aX ycaVMbClJur+SmR3JuHOuw703yYzY6BEb4OIDu+1Ers3e16Wh3SvbAsi1qtpKuY309Ay B+jGMju5fWpk8HQuK4Uv1yB5c165XR5USgySSi4KIHf4+3DgI5kPE8RYs0tCqkJqMV7F r5te1WvarSrhSuk8itSo/NXH85LzU15i7Kn8hxxyaJL781oFQBL2uyevV2frxeN4PugD PWpvrp3KOP0mdpfViLlBAZn9BMY/gCgdOqHfwKQSAo/C5W9+Kcxr4HdMoSy/nolvW92X /k5A== X-Received: by 10.70.125.165 with SMTP id mr5mr40026578pdb.102.1408495570800; Tue, 19 Aug 2014 17:46:10 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by mx.google.com with ESMTPSA id c13sm20535025pbu.10.2014.08.19.17.46.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 Aug 2014 17:46:10 -0700 (PDT) From: Guenter Roeck To: Russell King , Wim Van Sebroeck , Catalin Marinas , Maxime Ripard , Andrew Morton Subject: [PATCH v7 06/11] watchdog: alim7101: Register restart handler with kernel restart handler Date: Tue, 19 Aug 2014 17:45:33 -0700 Message-Id: <1408495538-27480-7-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408495538-27480-1-git-send-email-linux@roeck-us.net> References: <1408495538-27480-1-git-send-email-linux@roeck-us.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140819_174632_132436_7A5144E0 X-CRM114-Status: GOOD ( 17.51 ) X-Spam-Score: -0.4 (/) Cc: linux-samsung-soc@vger.kernel.org, linux-watchdog@vger.kernel.org, Arnd Bergmann , linux-pm@vger.kernel.org, Dmitry Eremin-Solenikov , Tomasz Figa , Randy Dunlap , Will Deacon , linux-kernel@vger.kernel.org, Steven Rostedt , Jonas Jensen , Guenter Roeck , linux-doc@vger.kernel.org, David Woodhouse , Ingo Molnar , linux-arm-kernel@lists.infradead.org, Heiko Stuebner X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,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 The kernel core now provides an API to trigger a system restart. Register with it to restart the system instead of misusing the reboot notifier. Signed-off-by: Guenter Roeck Acked-by: Catalin Marinas Acked-by: Heiko Stuebner --- v7: No change. v6: No change. v5: Function and variable renames: *notifier -> *handler. v4: Set restart notifier priority to 128. v3: No change. v2: No change. drivers/watchdog/alim7101_wdt.c | 42 +++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c index 996b2f7..665e0e7 100644 --- a/drivers/watchdog/alim7101_wdt.c +++ b/drivers/watchdog/alim7101_wdt.c @@ -301,6 +301,28 @@ static struct miscdevice wdt_miscdev = { .fops = &wdt_fops, }; +static int wdt_restart_handle(struct notifier_block *this, unsigned long mode, + void *cmd) +{ + /* + * Cobalt devices have no way of rebooting themselves other + * than getting the watchdog to pull reset, so we restart the + * watchdog on reboot with no heartbeat. + */ + wdt_change(WDT_ENABLE); + + /* loop until the watchdog fires */ + while (true) + ; + + return NOTIFY_DONE; +} + +static struct notifier_block wdt_restart_handler = { + .notifier_call = wdt_restart_handle, + .priority = 128, +}; + /* * Notifier for system down */ @@ -311,15 +333,6 @@ static int wdt_notify_sys(struct notifier_block *this, if (code == SYS_DOWN || code == SYS_HALT) wdt_turnoff(); - if (code == SYS_RESTART) { - /* - * Cobalt devices have no way of rebooting themselves other - * than getting the watchdog to pull reset, so we restart the - * watchdog on reboot with no heartbeat - */ - wdt_change(WDT_ENABLE); - pr_info("Watchdog timer is now enabled with no heartbeat - should reboot in ~1 second\n"); - } return NOTIFY_DONE; } @@ -338,6 +351,7 @@ static void __exit alim7101_wdt_unload(void) /* Deregister */ misc_deregister(&wdt_miscdev); unregister_reboot_notifier(&wdt_notifier); + unregister_restart_handler(&wdt_restart_handler); pci_dev_put(alim7101_pmu); } @@ -390,11 +404,17 @@ static int __init alim7101_wdt_init(void) goto err_out; } + rc = register_restart_handler(&wdt_restart_handler); + if (rc) { + pr_err("cannot register restart handler (err=%d)\n", rc); + goto err_out_reboot; + } + rc = misc_register(&wdt_miscdev); if (rc) { pr_err("cannot register miscdev on minor=%d (err=%d)\n", wdt_miscdev.minor, rc); - goto err_out_reboot; + goto err_out_restart; } if (nowayout) @@ -404,6 +424,8 @@ static int __init alim7101_wdt_init(void) timeout, nowayout); return 0; +err_out_restart: + unregister_restart_handler(&wdt_restart_handler); err_out_reboot: unregister_reboot_notifier(&wdt_notifier); err_out: