From patchwork Tue Nov 3 03:29:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 7539591 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 45A279F327 for ; Tue, 3 Nov 2015 03:34:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 411792072B for ; Tue, 3 Nov 2015 03:34:46 +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 4F15620729 for ; Tue, 3 Nov 2015 03:34:45 +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 1ZtSK9-0002x7-2a; Tue, 03 Nov 2015 03:31:53 +0000 Received: from mail-by2on0113.outbound.protection.outlook.com ([207.46.100.113] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtSK4-0002uF-TU for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2015 03:31:50 +0000 Received: from BN3PR0301CA0033.namprd03.prod.outlook.com (10.160.180.171) by BN1PR0301MB0723.namprd03.prod.outlook.com (10.160.78.142) with Microsoft SMTP Server (TLS) id 15.1.312.18; Tue, 3 Nov 2015 03:31:26 +0000 Received: from BN1BFFO11FD055.protection.gbl (2a01:111:f400:7c10::1:196) by BN3PR0301CA0033.outlook.office365.com (2a01:111:e400:4000::43) with Microsoft SMTP Server (TLS) id 15.1.312.18 via Frontend Transport; Tue, 3 Nov 2015 03:31:25 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) 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.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD055.mail.protection.outlook.com (10.58.145.10) with Microsoft SMTP Server (TLS) id 15.1.318.9 via Frontend Transport; Tue, 3 Nov 2015 03:31:25 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id tA33VLrD017585; Mon, 2 Nov 2015 20:31:23 -0700 From: Robin Gong To: Subject: [PATCH v1 1/2] watchdog: add WDIOC_SETPRETIMEOUT and WDIOC_GETPRETIMEOUT Date: Tue, 3 Nov 2015 11:29:26 +0800 Message-ID: <1446521367-25748-1-git-send-email-b38343@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD055; 1:rh1R6JWM0G92H0vwrQAx6owg7Sf8zTXZ3hkMcXSHeDKUyJsPCFjYxsDGkIuJ2GlJUHlspzkSYTU6bkLBeK3vd2HnZBQLM9zIkQYIw9lrl6MGCGmYGNm0t10D9yoFNxn+RYWLDHOe0UeUVVOts01jdyvrVOeGlkHjA2LXoo4lLynHjYROtuDG7TYSSFnx8J9LbvQU+MC3Rgn1IPXnmtsotnEhZ+81m50l2yrFjy/HZhhj7i4rAPn0E5PSw3nWBto/ZnFrjkMnFgPAuEhkcFkJ7Fr5wIdHBFv5eZFD7i1dQP72WmAyqrzznzD+79PwKh9z/UTxYfwmxKQShxyfIG5XGHqwMVze0zDuGXtaTDzwT8ecLrX5U1CLjLnTd0X7fgNI X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(106466001)(92566002)(19580405001)(575784001)(5003940100001)(11100500001)(5007970100001)(5008740100001)(36756003)(47776003)(6806005)(104016004)(19580395003)(81156007)(48376002)(33646002)(85426001)(189998001)(77096005)(50986999)(50466002)(229853001)(110136002)(5001960100002)(105606002)(87936001)(97736004)(2351001)(50226001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0301MB0723; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0723; 2:a5JOqTVrKofjV1sQzBgnfcznLkVHLqiAzLx7uuiCAho696Kr00YPIamf8QJsQAMDknazFgiBQLOYPY+7TyrlG+62Snp7BB08kO+6mfpDWLo+1K4CkydyDTG3bFRdasDCIpRyUIocxADwmEY70eu0DwhrBvRvPdX3FYz4vzOICyU=; 3:gr77j+vbC/v0R32pRlblWy9aLqRJUyaDiMsNVsbcLQrUvNk8KSh/7hxtv2J+aRYzoTY+Kh/73/Iy2EEosGQJTcPGKJuQtMFFAL30/PZXFRKD5qKjqfM3SRFyssl7luePdcWFdU70GJfiSptR3PxTGAoUof8lSVMCp5IudvewBW4Fp8G+duM6TANUvSUE12ynsLmgXJ9DxCOtnoj9G3sWw2wZu7n8C9KRAaOk1uFwCbI=; 25:MYaB1x3UBfyakDYhnuPISwPIsakY8Us5D76WGHnE5VmJdZ0MgH4VVON1YL4ILs2wIJcIkv01bu5pbSvhEpireBfN7OQ/PcmA/m3Vr6feFEgJO7Ezh9+5/FlNpmd1E+B/YXrjvPTz+2GJWPm6eOKXJ+qgDurTmTemqY/J9CF5V8wtKZ0s9dfbCu/OdKPmioe9xPJ5aOJfPzlI2QYK0DJuI9xGAnHELFneBmwge9lt5cCHTWsfDKHtaLE651RfRAHxmNkGdHMvgpLqvGAtHiFvOg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0723; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0723; 20:csN/8mtkhy4SAa3piF2/1iRzvOR/roDsI9HHKGANYlw8OITf2kbJZsiDwVxJ/Ld1nxYAMOT1w1W/h+1ei0euLgIau3x378BIyP0cO3IzhOW8dTqvDtkuZlJz38pHCEuKmWuSuZBTiWEbGEdXnSijUqC0l/62UZ5WaxNbi+w2Zfhdd1BT0muIS69k4ilD+xf6FNqkO3KGSNP4mIuumuwn/1QxByK91ntOQp+vKeBvTtb8FTNz4pAY7PXGDVGtQtgUMyqOVo9aPBRm8ZIXjlnqOut1hUZMsqWQMnh/OHNgDZ4zSwPd5swC/oVg/rUyXCQCIrDDWzIpWZ2Uts1+LlWgq1sOdcvCh9CG/roJWElE9xM=; 4:upSEiMyBLL8kpUVFLK+P/SEMfjL/aLb0MY8eg5uiuz87UyhVZ5IUGfrIWNXXWzhgH3aj230b9DfM0iSMUuEqYytCI8Fzvkj5ktrKz/2eYXo8CDAXGkxFFKWZwQNRoZzPs3gkxO7KyA3CaeRaAAV6JyRACEcoMGXDyllq5LSjk9Vqr28VkfP53qMMljOims2zaavWTosWpOHDNn7XHNKjQUIw/RHwlNEPPqTN0mmP13t48YVY5OIKkpL3VXxPVaEjuKOuR9WTxxV/O5OqeBSX1vT2/45L+xxc6eiQVcHOSu6QBSw5wB8gezdpOtCk8XrOn68nKLOcJIdlRuquiA8MR6kqExfZn/3iS58Ft2CXqQ2HmebK1x1YM6/kU2YamIs0+1VOYY8GcFytiasyEPNSgA== 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:BN1PR0301MB0723; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0301MB0723; X-Forefront-PRVS: 0749DC2CE6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0723; 23:imTIHvF9s9A9zhVrTROk5Y4cZBsP7RRdmoZXG+X?= =?us-ascii?Q?ZjH4NsU8rgSoenSIny0JXszO3fzmqUrmtsKbNMpmJ2BWbNOgR6d9Z7Oafpz0?= =?us-ascii?Q?yULiUJHVTs4sA0bOV49iL+QjNQyF8sJC/M43275wePyNz2PjXM4qhJdX0znx?= =?us-ascii?Q?Mbw6tI2GODOCX2ScV1oqmZ4pJkXqwU5uYcL6KH2dgbI4lcWsOUL1N3EzDtx6?= =?us-ascii?Q?Ij9t6M3WOfisZk4FGjDDsqm1qQBk58aNLLHJEno0ZPSZ5UEZLRv2OrM1PL1X?= =?us-ascii?Q?L/8Afew+h23qXAbJ4kmTxIp6qjRBiPtsbe8WokBvqJyQwZcqn7t8dkrcSO5x?= =?us-ascii?Q?J61GjYGQxwsKMEOQGm25650k4BeShXinPoy85TK72eNrmiSvF1gbuMn1+1j7?= =?us-ascii?Q?xk2eGKtNIvJGUjP7QYYzi8BIgM4P9mkelb3iJdj+iX8j8ha/JihSC9LUUUu8?= =?us-ascii?Q?u6+7zsgsYBpq+eY85LMrt0sXzxzOZbfZRf4f55FUUoH7m6F3DPbMu64DZy34?= =?us-ascii?Q?ZdaBrj7ZCoxI3f+ByNJNy+ug5+poP7grqQt0Z8GseclPkcdvSNqW40TAk32K?= =?us-ascii?Q?UMx+t0OGFtgqoZcQO/mbQArY8+yEajYrB5ItlB7gnbHfoP3HvFKeLZwULm7A?= =?us-ascii?Q?OSmyJpMlHSxZKfOSE9LmJ8EBfj6deiTBemfz9gLb92GZ/IpICLzPzCS9oNyV?= =?us-ascii?Q?KHtS6kLi9aRWJ1LRIP2jLVNvglEhkK+aiIUZ+JaC4JmYsCX7Bkxr5dqXQG+D?= =?us-ascii?Q?5pyvPsSC1Tge6tosMg81suGBEOZxOz9x2P3nbNpRyC3kH6JanJLJPs7Ku89K?= =?us-ascii?Q?y3E3dmZkuOAJqH29sOJARbqW9nROpxqT4llfujS3haiameE7UcUuGWzc2Yra?= =?us-ascii?Q?nuNIm/C31e0SnpY77Su9KzYqNp2525pD++atwlc36fjZyO9JtOxofs4nvQl6?= =?us-ascii?Q?SEX2LmL0QXCluBMzcXcIz1mBeFMuWHmOiIZ/C3liZZu8n3f6+q0Fu16nM3Hu?= =?us-ascii?Q?EAGIjRtmFecYYaPtFVmepf/eO?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0723; 5:9S2OOh6xbvKMv6j5FwRmV4iNt2pdqzMuZ8o3oBweNBL6AXOpeRSGyLecvbM+uH8yjEIS1fOhAOrlBjmM867QONiGluPgukyyggUSD7PaxZIemfFgq/IqW/ZDvpFz3LhNrh8VLTTJLiznLZtk8SQJNQ==; 24:+AcH8spw7bx5hy0qagvGEDXo6vFerEsU2T/8BXmv+ugID142G+h3AiVtEihw0G35iXp1rIL9JvNNM6rlKiIJWUPurbqJ3pyfsmx+EWBdr1U=; 20:6iI2vWxYcLBhK9LlFVPUpa7+PUKuwxVIIlqjFrd4WuBC6J2aa8tRTKz/nUfi7X3SRjyJ41n0oj62MP54UV/Gyg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2015 03:31:25.1287 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0723 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151102_193149_045224_C2D31293 X-CRM114-Status: GOOD ( 22.26 ) 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 | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/watchdog.h | 9 +++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 6aaefba..02632fe 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 == NULL) || + !(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,13 @@ 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; + err = watchdog_set_pretimeout(wdd, val); + return err; + 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..6ddb2d6 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,12 @@ 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 != 0) && (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) {