From patchwork Tue Nov 3 06:11:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 7540071 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 9B918BEEA4 for ; Tue, 3 Nov 2015 06:19:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABA4E207D9 for ; Tue, 3 Nov 2015 06:19:52 +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 B2451207D8 for ; Tue, 3 Nov 2015 06:19:51 +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 1ZtUqp-0003Fr-3Z; Tue, 03 Nov 2015 06:13:47 +0000 Received: from mail-bn1bn0104.outbound.protection.outlook.com ([157.56.110.104] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtUql-0002s7-RC for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2015 06:13:44 +0000 Received: from BLUPR03CA002.namprd03.prod.outlook.com (10.255.124.19) by BN1PR0301MB0724.namprd03.prod.outlook.com (10.160.78.143) with Microsoft SMTP Server (TLS) id 15.1.312.18; Tue, 3 Nov 2015 06:13:21 +0000 Received: from BN1AFFO11FD021.protection.gbl (10.255.124.4) by BLUPR03CA002.outlook.office365.com (10.255.124.19) with Microsoft SMTP Server (TLS) id 15.1.318.15 via Frontend Transport; Tue, 3 Nov 2015 06:13:21 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD021.mail.protection.outlook.com (10.58.52.81) with Microsoft SMTP Server (TLS) id 15.1.318.9 via Frontend Transport; Tue, 3 Nov 2015 06:13:21 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id tA36DHRN019247; Mon, 2 Nov 2015 23:13:18 -0700 From: Robin Gong To: , Subject: [PATCH v2 1/2] watchdog: add WDIOC_SETPRETIMEOUT and WDIOC_GETPRETIMEOUT Date: Tue, 3 Nov 2015 14:11:23 +0800 Message-ID: <1446531084-15365-1-git-send-email-b38343@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD021; 1:foKOaWphcHgmgRqU0SyQtBD1lpg9vniyaLOQ2QDhcHZu7Klgrw6/1rvVEBSYP/67tud45e3buWNlHwOj2LQ/EzaQIsN0sCyNvTm6Vn5HkpeRDAq5yLXlblm5RWtppb4gASa06XIKifCR4x5quiO/PfRA4eLtqKRzIhTnpZfcYumL/XXupcsZC0RfdthBu376gLP7aLrlt7nXi7T5vIvz7MzTnmUzDR6OGu/tq9m9nJ4Iw3hxwxjEhMaIeqVFXqg7OllJ+JvTGOUwUcgICh9XrqmlURkhMk7bnrl02Gsnb153WBlsyCyeSLi6WTcvMnis3klEWswu89NGT2blndMcgqQe/xbdItEAdBD6Urmg8iq2u50bsHhuA5Y1xIQHAxoi X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(87936001)(575784001)(77096005)(104016004)(50986999)(97736004)(19580395003)(81156007)(92566002)(50466002)(19580405001)(69596002)(48376002)(85426001)(5003940100001)(47776003)(189998001)(105606002)(11100500001)(5001770100001)(5008740100001)(36756003)(106466001)(50226001)(6806005)(5007970100001)(33646002)(5001960100002)(229853001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0301MB0724; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 2:Ypc1utKfYAU4X0BvUPUNzM8sQM7O8b/DbqUETJRnF09jL4ZcKcQXenCT77bA2Je9ET90XMRR0Ps0y0X5wYZBxXexKqlbKwbwzAl6FxwdqKY5TLeaiWb8fY2ZpcfVpyGokMkSGgsJXJq8Nfigsu2kbLPdTRsR0Fo99birYRsuCfQ=; 3:gtATebsj3uGoTyJ4sH21XHuo+sifKHMjmXi7UPVaoUR0jSzRzgX6vsuWGPBkgTO5hYVpk05Kmjbdw2Y96xFXzXNBAZ4KxZLjj5vXnuQfaiopPkUXtjYYM6Y9fhKgMQTjr9ZZh+VghXNpWNh+Jt0/JO1D6DAG4pEB/2GZK4srSN7gCoGdM6RQCBR6JE/ba01n2ZiLe7nlXY1SIf7aYKk3uEsLUqZPtEoGKrTnLIRPmcI=; 25:kj5RhdzAeDUCIUMRnf7EIK+LnQwANqsR2atY+lCXg+jOXcYLEG2bL4sAHcZThueV/qVvYZGsN8x38Fj97VH5vmkUxfui2lnFpYlyNyOhjI7n99Anpiy2Gs/Vs42ZLJYt1PjsXMUqaYTL4jN8AqFOjkuUN/BCs17nH+0LZOIYbyiOItVriHtv+jglANB4SP+RXpuJZJBYFs1NTkjaJkOvCDW2Oo8ttqKfwQCgP0MkB5Q/LedLz8ZwuNGgX24vCeeqTgTtmkkalC0lJVv2TPyS3Q== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0724; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 20:bgNO8ejWOsn3f8Ga/V/xPTQQRDkLL9QX4xB4JGNsB8IKaBLP26AxV+lO/DR0v83/ofAxhpzJDlHEXJiyQoY9FGHRtvgL3wx7CJt8pejDNlYFVwXDnn0+lCC5ec++kxR4Xq1sAlY04m9CE5u8a4cAS4zzanqYPEpByAOLd5ACyoY1txVGAxVK8hOVNZw+zxBGpAuubeUAI+5zLzf4dHF30J9hpAKYw7nQ4LXlS7o23v0S7vanqKArEFIkLiikFYorwuGrm0cpGcbEDjVZBn+dj8qfdVkC7SwmkZyjNmKyJwjHRtk9ZOwQg2H/xJY++MEjVPOhsG918r9WL0iNjp8sugw2DDFaD9PEVHYMw7p4r54=; 4:cb8Wiz6Bbe+TJcoWkp4tCurIkPw2KzjNuVI8+Eq9ShBNTxZY01PqLnwJp/ImyZX9bkGbsCau9U0+pEjpiwNpr7Hk5SQXgSY1QJVL0yKvfIy9EG7HM01m9EEtHUr40g3Y/Y74Cs1pdZ3nNsZ9Rxwi69a6fmbc0X6LubEcdCexIzokgkvdRS5V/XahCMKnyBZtNr9f0i/bYTLUlK+dR+pLKmbyQD8RuNYOw7xpx7zNzOzdFz2cLO7Bxfh7evcqS8S7ZwhjpZF5vsCLH1UAiMWy/YLQhTJBh+ebZNQ8rN72+VepTDrDBfrOIYgZ8bN8DRSbj1ehpsxMSPsFiFZwy2XxW7SD+49AQs/vioB/KzOrEYlLrrdHAgRHULIj9s5mdgfv X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN1PR0301MB0724; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0301MB0724; X-Forefront-PRVS: 0749DC2CE6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0724; 23:oc4R8oSDVAPdYgYbIDtTcQ0WpqyzMHgqp/4YvOd?= =?us-ascii?Q?QNlIa5p6R1w/UGaVPMcpPPtwPJFZI6QIJCkI1kgmfUSiMpIOpEm/w501MaMk?= =?us-ascii?Q?7OPjowFM+9iXq3Fqx7MS4cn8C04VkkW8i0CDuUU/ZFQvSYiFe5TSQxWU1bs4?= =?us-ascii?Q?87fPLfgY6tMb1NwkPDK+OSt+YJu4GitsHllDctekE8KnqtfHw36zX4xd+/AC?= =?us-ascii?Q?hV+UT1/YMvyc6Q1H6e1OxZvr/vR3yPlFQED9UWA5CrFp2UmHdfsTkeGUXKZM?= =?us-ascii?Q?0xW/qvLk7744zYRQTr8VhgauixtHVwQo3sg6OvvXo4vdG0o5PlAmKDoA50tV?= =?us-ascii?Q?LlrgRhk6fFME2l+fAy2EenprAiB7eYFusli7S/FmvkLNEy9scdqwGA9ERLqs?= =?us-ascii?Q?1NKJTUfokOOWcIKQhBydqdrlakT6t8st7L+2U+M68XdSQHyV4swsStf/LJo1?= =?us-ascii?Q?jAMxfV0OnoRG4T7SNWjSx5iWL8ORGwcM7xr0B02UJfZmtLiRjPrNO7VDTU1P?= =?us-ascii?Q?sSy+7dz3k93r6DF4v+65+ZG+3RPHljvaK5jdhLScHDYwFMoEGodIwSBFIVPz?= =?us-ascii?Q?1PXmJ87goDZ8Jt4VcdCZvHGM29O9psdFdW5dC6Y/JnnT9NjkAm2jcs9ti/YI?= =?us-ascii?Q?7dEozC/K6DSkwGHF3pUZJtudTYGvMYOgwjWSd8isl8z5q8HmKcq1vUqd5am9?= =?us-ascii?Q?kT+pavAeJi/g5inGXGSUPPLDikTgINtbrbxQ690kQUshbXhbDtFCx4z5efzw?= =?us-ascii?Q?IUpRh0iO+1bKaWKcy/S2RjAjmm3iR6cFgQg/ytumaVDjfj0SCa5zLFoOUYcf?= =?us-ascii?Q?aplHw7+MTtlvtbq3j9i/fUNOOTEM3U3I04/5pu35VUwx6zuTBstx28I7nYNY?= =?us-ascii?Q?Wn8VjUW3x0rONsnMg/ZTHNRNxyacdN6LyX1up7Q9wh2b/EeKBJPTsU/bneYJ?= =?us-ascii?Q?DdKEJnK/BAjxFR/62cGSXUBo7ixHdD9ET9FBPVu5oqKek5HulfVVwtAf5CxK?= =?us-ascii?Q?d81A/ZrEWsLuBf5H84SDsMc+hVwcQZLPEX4+Rbrs1Ey+1lA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0724; 5:e8hLwj3BApeyoReg98WW/fsb6z7E6z5JH4eBjRnK+XvOarg7MD4zjkcqVmBgq6NV9nErhyfx8Hk24g5n0rjWLguqCm+L29jsRGSkIxSu8pJt3MtJvxjtJlN6JESknTlhaGFblarLCag2ZYIMk2qTEQ==; 24:1erqUdMs6CcYRXk17BETwSSWFsA3LXjW9TEy5joKSAak9VXRP6QG0wUObwo5bBGMqpLc3LW1LSS6+ldZsuNFkAzOMn1lyQjALfEEEgf32q4=; 20:djdaoMpwwnwKsI5093yJ3QpdnbbCJjpj7fwwdDL4NHAoFdz7txln74BJavk8NIbt4rdIc61J0pDa7xCNbya8BA== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2015 06:13:21.2317 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0724 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151102_221344_103756_046B2A12 X-CRM114-Status: GOOD ( 18.17 ) 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: linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 Since the watchdog common framework centrialize the IOCTL interfaces of device driver now, the SETPRETIMEOUT and GETPRETIMEOUT need to be added in the common code. Signed-off-by: Robin Gong --- drivers/watchdog/watchdog_dev.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/watchdog.h | 10 ++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 6aaefba..f4a02e5 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -218,6 +218,37 @@ out_timeout: } /* + * watchdog_set_pretimeout: set the watchdog timer pretimeout + * @wddev: the watchdog device to set the timeout for + * @timeout: pretimeout to set in seconds + */ + +static int watchdog_set_pretimeout(struct watchdog_device *wddev, + unsigned int timeout) +{ + int err; + + if (!wddev->ops->set_pretimeout || + !(wddev->info->options & WDIOF_PRETIMEOUT)) + return -EOPNOTSUPP; + if (watchdog_pretimeout_invalid(wddev, timeout)) + return -EINVAL; + + mutex_lock(&wddev->lock); + + if (test_bit(WDOG_UNREGISTERED, &wddev->status)) { + err = -ENODEV; + goto out_timeout; + } + + err = wddev->ops->set_pretimeout(wddev, timeout); + +out_timeout: + mutex_unlock(&wddev->lock); + return err; +} + +/* * watchdog_get_timeleft: wrapper to get the time left before a reboot * @wddev: the watchdog device to get the remaining time from * @timeleft: the time that's left @@ -393,6 +424,12 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, if (err) return err; return put_user(val, p); + case WDIOC_SETPRETIMEOUT: + if (get_user(val, p)) + return -EFAULT; + return watchdog_set_pretimeout(wdd, val); + case WDIOC_GETPRETIMEOUT: + return put_user(wdd->pretimeout, p); default: return -ENOTTY; } diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index d74a0e9..f936152 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h @@ -25,6 +25,7 @@ struct watchdog_device; * @ping: The routine that sends a keepalive ping to the watchdog device. * @status: The routine that shows the status of the watchdog device. * @set_timeout:The routine for setting the watchdog devices timeout value. + * @set_pretimeout:The routine for setting the watchdog devices pretimeout. * @get_timeleft:The routine that get's the time that's left before a reset. * @ref: The ref operation for dyn. allocated watchdog_device structs * @unref: The unref operation for dyn. allocated watchdog_device structs @@ -44,6 +45,7 @@ struct watchdog_ops { int (*ping)(struct watchdog_device *); unsigned int (*status)(struct watchdog_device *); int (*set_timeout)(struct watchdog_device *, unsigned int); + int (*set_pretimeout)(struct watchdog_device *, unsigned int); unsigned int (*get_timeleft)(struct watchdog_device *); void (*ref)(struct watchdog_device *); void (*unref)(struct watchdog_device *); @@ -86,6 +88,7 @@ struct watchdog_device { const struct watchdog_ops *ops; unsigned int bootstatus; unsigned int timeout; + unsigned int pretimeout; unsigned int min_timeout; unsigned int max_timeout; void *driver_data; @@ -123,6 +126,13 @@ static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigne (t < wdd->min_timeout || t > wdd->max_timeout)); } +/* Use the following function to check if a pretimeout value is invalid */ +static inline bool watchdog_pretimeout_invalid(struct watchdog_device *wdd, + unsigned int t) +{ + return wdd->timeout && t >= wdd->timeout; +} + /* Use the following functions to manipulate watchdog driver specific data */ static inline void watchdog_set_drvdata(struct watchdog_device *wdd, void *data) {