From patchwork Wed Feb 24 17:46:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Lemieux X-Patchwork-Id: 8410411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 192C7C0553 for ; Wed, 24 Feb 2016 17:49:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B3D520222 for ; Wed, 24 Feb 2016 17:49:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF2C020364 for ; Wed, 24 Feb 2016 17:49:32 +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 1aYdXg-00027g-Jy; Wed, 24 Feb 2016 17:48:04 +0000 Received: from mail-io0-x242.google.com ([2607:f8b0:4001:c06::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYdXE-0001nf-5L for linux-arm-kernel@lists.infradead.org; Wed, 24 Feb 2016 17:47:38 +0000 Received: by mail-io0-x242.google.com with SMTP id g203so3222112iof.0 for ; Wed, 24 Feb 2016 09:47:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HwhetoxegrtFYoOBpXovc6iOYAXNKdL99i718UQAMLs=; b=q45LkLW5pUFNj9/Fsut9vStDr5zP3kkwdoIC1aoKidQP45xYwoSCWyL3ZREfiFvVnL EGMaUCkoOWDq+MgeuiYu9yojfX7F5JS12NhPQkMJWljyy84Qme20qAdLyQKm2FsH7mQF srT/4HvnbgB+8lNHlMg604tDYKRD5bXY2O3YHwHzb4/AZ63DgdUmUqBhI+aX+6yWdRkj katPkkLeG3jRCe6bGQ51Y81+OL8ia9P58tjmNz+2Z4WeEFdnZ5ut8Fdtb2lmivGJk1FT rqEaF2myUMdFAK09Ocm3CHUo2H6YjU3uwW9iB9zXN8cYeqTRHRfZeXPt32SjKRw0/hqX 4nYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HwhetoxegrtFYoOBpXovc6iOYAXNKdL99i718UQAMLs=; b=NdLuUkUB3BCrn9RbyYeYFhiQ6SV15mS6wfvZ47hcj5S1zSonOk/BB9wm2B+kU8AVst UMwVUrvufxadNLLV5JCecNgJBCvxLsWqJtzzE9kTlhWWRjgpLSA5w2v9R8rvJha+XBXR +PBSwXc7JpchI9vocSmEnYmSOzZDPlbwVlQjzPYRZJX8sXsw8hFJHNjS1bhZlt2mNjNe KGvgjPEdHXv95Rsk1j3EKFvrUAtPMLsDuQ4GLeIeyJFZu6fSdoa/5LX+SFemE7AZOVuf EvR7jCRftXmooDvuj3+mRZohdLSqZJFTl4u/sqF69ppN/atj4upR/6UPaAbhU5A8OgqA ibcw== X-Gm-Message-State: AG10YOTY++3NyipwDJUP7moT3nIFzDy+W66ekRYGw0enhy1jgyriHZ5mK4kgnbOxt0E+5A== X-Received: by 10.50.92.70 with SMTP id ck6mr21899554igb.80.1456336039508; Wed, 24 Feb 2016 09:47:19 -0800 (PST) Received: from CABRO3AP00510.americas.tsp.ad ([74.51.240.241]) by smtp.gmail.com with ESMTPSA id pk7sm13494524igb.17.2016.02.24.09.47.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2016 09:47:18 -0800 (PST) From: Sylvain Lemieux To: linux-arm-kernel@lists.infradead.org, wim@iguana.be, manabian@gmail.com Subject: [PATCH v3 4/6] watchdog: pnx4008: restart: support "cmd" from userspace Date: Wed, 24 Feb 2016 12:46:56 -0500 Message-Id: <1456336018-6620-5-git-send-email-slemieux.tyco@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1456336018-6620-1-git-send-email-slemieux.tyco@gmail.com> References: <1456336018-6620-1-git-send-email-slemieux.tyco@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160224_094736_491623_EAD7BD67 X-CRM114-Status: GOOD ( 13.67 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stigge@antcom.de, linux-watchdog@vger.kernel.org, linux@roeck-us.net, vz@mleia.com 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=-3.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 From: Sylvain Lemieux Added support to verify if a "cmd" is passed from the userspace program rebooting the system; - if a valid "cmd" is available, handle it; - If the received "cmd" is not supported, use the default reboot mode. Signed-off-by: Sylvain Lemieux --- Changes from v2 to v3: - no logical change; updated to work with new revision of patch #2. Changes from v1 to v2: - Rename patch title; was "arm: lpc32xx: restart: support "cmd" from userspace" - Add change to "pnx-4008" driver instead of "mach-lpc32xx". drivers/watchdog/pnx4008_wdt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c index fbf027e..e97b611 100644 --- a/drivers/watchdog/pnx4008_wdt.c +++ b/drivers/watchdog/pnx4008_wdt.c @@ -130,6 +130,21 @@ static int pnx4008_wdt_set_timeout(struct watchdog_device *wdd, static int pnx4008_restart_handler(struct notifier_block *this, unsigned long mode, void *cmd) { + const char *boot_cmd = (const char *)cmd; + + /* + * Verify if a "cmd" passed from the userspace program rebooting + * the system; if available, handle it. + * - For details, see the 'reboot' syscall in kernel/reboot.c + * - If the received "cmd" is not supported, use the default mode. + */ + if (boot_cmd) { + if (boot_cmd[0] == 'h') + mode = (unsigned long)REBOOT_HARD; + else if (boot_cmd[0] == 's') + mode = (unsigned long)REBOOT_SOFT; + } + if (mode == (unsigned long)REBOOT_SOFT) { /* Force match output active */ writel(EXT_MATCH0, WDTIM_EMR(wdt_base));