From patchwork Mon Feb 29 17:31:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Lemieux X-Patchwork-Id: 8456651 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 7FFD0C0553 for ; Mon, 29 Feb 2016 17:36:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4AED201F5 for ; Mon, 29 Feb 2016 17:36:19 +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 D81D92017D for ; Mon, 29 Feb 2016 17:36:18 +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 1aaRiQ-0005TG-Uw; Mon, 29 Feb 2016 17:34:38 +0000 Received: from mail-ig0-x243.google.com ([2607:f8b0:4001:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aaRfh-0002tf-00 for linux-arm-kernel@lists.infradead.org; Mon, 29 Feb 2016 17:31:51 +0000 Received: by mail-ig0-x243.google.com with SMTP id hb3so9672167igb.0 for ; Mon, 29 Feb 2016 09:31:28 -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=udrY/I1tMrUZW97tmW5jb9TCj2FSOJIFTdd6Ug2caU4=; b=zIiuW20DOkdO24B8QwFloU9tRqP5GDuTd/CweYwOuF5c7oR5G9/VwzR5f1g1s8EnJz lHG8ie/DZ/TK7vFT0JHo1sUHU/DvqunlsZT3FNQph9gVeASC+qrUF/Ego1SA9wJGf02s k/f81d+BWTXZFCU8rnMqNGcwQU9O2Iso0z02nnRyNbUhzLOnYcVLZDrrLPRFy/eqAl5u rpe7zIUMErPp8pOjpE/jADItkyz/uGOO0QNGBhT09sSnCusAOdmJJB2sbrmmHyuziq+0 0bDmfIdg6cCv8Y0Q+isrQ/hD2u+CyFL98pWCPNEJhQYThcQl5SuxiE0BH7UgJVZdd0Oa BTWA== 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=udrY/I1tMrUZW97tmW5jb9TCj2FSOJIFTdd6Ug2caU4=; b=Cxig5OHbFCAiKNpu+zdfHAa9P2Bf/pFqodkrZNxSO+RkxxLymcNZEbxYvr8Ou43qEX veGZH7THzwh8gDvmo1n3PCQPtcBzdH2lJCFj3/1LYWpNeqoEoS9l9jC4Ty0rAY2PB3C2 YWyBaRyJ151Y3ZgyKLhKhT+uho+V865nCIs3Fso7w7sue4o7sNHmEVj9QeBv/PJOUZQS egj+sTlZh/0ipRZBcFAnhphlBiARroeDGr3UpCr1UUbnHuiq5a3KOPwwklG3g5onHqo4 Ve4XCtb8GtvlpysznuOwpNDlFXSfstS6+qGN2IN9lbJhdq/fmq/AYielJ02cGuD0lxha eEGA== X-Gm-Message-State: AD7BkJIgHGHBLkrvJAIW134c9Ee0cxcYV9oCWcomMZnYzsFDDnrsq1Bn9kyBTfyrDyccQA== X-Received: by 10.50.70.67 with SMTP id k3mr11271547igu.89.1456767087823; Mon, 29 Feb 2016 09:31:27 -0800 (PST) Received: from CABRO3AP00510.americas.tsp.ad ([74.51.240.241]) by smtp.gmail.com with ESMTPSA id wi7sm2414748igb.1.2016.02.29.09.31.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Feb 2016 09:31:26 -0800 (PST) From: Sylvain Lemieux To: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, linux@roeck-us.net, manabian@gmail.com Subject: [PATCH v5 4/6] watchdog: pnx4008: restart: support "cmd" from userspace Date: Mon, 29 Feb 2016 12:31:06 -0500 Message-Id: <1456767068-14449-5-git-send-email-slemieux.tyco@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1456767068-14449-1-git-send-email-slemieux.tyco@gmail.com> References: <1456767068-14449-1-git-send-email-slemieux.tyco@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160229_093149_353494_3950C08D X-CRM114-Status: GOOD ( 13.69 ) 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, wim@iguana.be, linux-watchdog@vger.kernel.org, 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 v4 to v5: - no logical change; updated to work with new revision of patch #2. Changes from v3 to v4: - none. 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 e05bfecf..df76231 100644 --- a/drivers/watchdog/pnx4008_wdt.c +++ b/drivers/watchdog/pnx4008_wdt.c @@ -129,6 +129,21 @@ static int pnx4008_wdt_set_timeout(struct watchdog_device *wdd, static int pnx4008_restart_handler(struct watchdog_device *wdd, 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));