From patchwork Tue May 11 06:29:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 434688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8996DC433B4 for ; Tue, 11 May 2021 06:30:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5055261364 for ; Tue, 11 May 2021 06:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbhEKGbI (ORCPT ); Tue, 11 May 2021 02:31:08 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:41867 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbhEKGbH (ORCPT ); Tue, 11 May 2021 02:31:07 -0400 Received: from mail-ed1-f69.google.com ([209.85.208.69]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lgLu4-0002g7-Kg for linux-watchdog@vger.kernel.org; Tue, 11 May 2021 06:30:00 +0000 Received: by mail-ed1-f69.google.com with SMTP id o12-20020aa7d3cc0000b02903891695ceabso10376777edr.3 for ; Mon, 10 May 2021 23:30:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OtH4eWQldqUSkW4yxRjOEpNcMPcTYEmH1QrZivGyJ5I=; b=fT2oLdQ9CHlZoEdVroNi9b3tznDKECMWLzprRbxCQzzuDy7OuGT8BBEOlRTxp/twTK wFw4nBw3Yhys5CtWKudvXQXEHTx+BjeDUuiG1cMIXt4jBF2MRzN/gFhdpvzNPsDjxaWq skaJl+53ZlcXClXDZhkkMaXMjYJIDosct48QU2cO1IsUIAXrzBilGH2P4BgVdKswqet6 9QvNBpgxII4IH5LLbTs1s/DKwrBab7bB48Wx+FtEn8sheh+1tFsPr6AV3dgdBbL7o9W7 fa5/D8YqUgU7orfaS1lfUJ8RA7fwDoYJNWSM7VzteXKVUxQ++2Kh36tZe3bPQ4gePMcr 7yeg== X-Gm-Message-State: AOAM533qAPOzDkgEm0ZtOq4vyHVMp1RnqTVwvzVluEujbzD5sSxFerhd 60vgURUBRQ0ues/T5g72/vWRC66way6um30LurL4H/Jo9Q/Y1cT+YR6byQu2G4o1IOZfuwI/jJs +Bd2zzWOFEJFNZ4hrivhSSU/LibObdwzSBVwaBa+jP6hc X-Received: by 2002:a05:6402:110b:: with SMTP id u11mr35335788edv.356.1620714600385; Mon, 10 May 2021 23:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0sMPdfW5EZzNP18EtpiuVYKvGJqnPmXoBsW2Wozhs74M15B6ytpkafIoFx8aXfada77AYwQ== X-Received: by 2002:a05:6402:110b:: with SMTP id u11mr35335779edv.356.1620714600254; Mon, 10 May 2021 23:30:00 -0700 (PDT) Received: from gollum.fritz.box ([194.191.244.86]) by smtp.gmail.com with ESMTPSA id p22sm13511530edr.4.2021.05.10.23.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 23:29:59 -0700 (PDT) From: Juerg Haefliger X-Google-Original-From: Juerg Haefliger To: wim@linux-watchdog.org, linux@roeck-us.net, linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Juerg Haefliger Subject: [PATCH v2] watchdog: Add {min,max}_timeout sysfs nodes Date: Tue, 11 May 2021 08:29:53 +0200 Message-Id: <20210511062953.485252-1-juergh@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210510131625.21506-1-juergh@canonical.com> References: <20210510131625.21506-1-juergh@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The valid range for the 'timeout' value is useful information so expose the min and max timeout values via sysfs. Signed-off-by: Juerg Haefliger Reviewed-by: Guenter Roeck --- v1->v2: - replace sprintf() with sysfs_emit(). drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index fe68a97973a5..7c1007ab1b71 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -526,6 +526,24 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(timeout); +static ssize_t min_timeout_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct watchdog_device *wdd = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%u\n", wdd->min_timeout); +} +static DEVICE_ATTR_RO(min_timeout); + +static ssize_t max_timeout_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct watchdog_device *wdd = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%u\n", wdd->max_timeout); +} +static DEVICE_ATTR_RO(max_timeout); + static ssize_t pretimeout_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -610,6 +628,8 @@ static struct attribute *wdt_attrs[] = { &dev_attr_state.attr, &dev_attr_identity.attr, &dev_attr_timeout.attr, + &dev_attr_min_timeout.attr, + &dev_attr_max_timeout.attr, &dev_attr_pretimeout.attr, &dev_attr_timeleft.attr, &dev_attr_bootstatus.attr,