From patchwork Fri Nov 25 22:23:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 26149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4325338wrr; Fri, 25 Nov 2022 14:31:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6dDl6PHgs46oVTjWu6b6+nET5dMTBMMy6kfkLFuPfOXAFx7p9KKtN/RzY417LUjpDilhRa X-Received: by 2002:a17:90b:2305:b0:218:7bf3:864c with SMTP id mt5-20020a17090b230500b002187bf3864cmr40024814pjb.33.1669415461225; Fri, 25 Nov 2022 14:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415461; cv=none; d=google.com; s=arc-20160816; b=a6t4QwZVxZFjyzM3846Wxj5LSReT6jbFYfOzDtU4K3u1gWt6LtOSfcJOrTKxVaAgcD 4MB0r7iX+YcgkVZh+NRsspLtvIBGO9cy+pqX6pcq/bAE51tC2Kvo/HyO/8ifv2boQJpB EFcUQuIvhBy8RKWio4O0311pdiq1AL9u3ZwTfr+cefe0O5U0QRhrK9TRnHwZjtCQt0OM Bo/Z4vQ4Lwmkm5YFHdMusju2FrO7GME7VL4+k0rHo5FjBe7UASOjCbeoOh8aKoMc1khg D7k0680oopG6zT9WEcfAR0hOYZrOy1r+0HW9wbra6KsApN9H1CYR9UOQWBonSDf8nNaY 0vKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=HEzNPHJHybcHWWVnEv3FMD/dt37sBdGxNoZNTQDQH7U=; b=smcXLR8V3X9SwDERtwJufK+8WGT+Ho/80xMG8yDWZkrK40K3BIyuT9mhVQ7+oUHeOt k1n13KysCLYHlZE3XZgWBja3xA0lz9JepfT+Gn3Y/HmJBrceQwtO2Q445ev5pocUYP1+ cZYkvLM5Kyat3X22qeoxftmdBwjblfA9riN9Jnd8sqh80hjgtaFxRI80EjFtEfIrPiUe fOdPtbVUvgPcM+MXHpNTFABr9e+gqH3HUSIcdlKdxvlSJWmbdEp1SUGst1120f5eXrau o5wAeJak2Y+Od33+GqeKgCbaocCOgV2FmJVCgalEZlCWqyl7M9/2r5uD5Sl9DMAvkiwY sVXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=oGL3K0ft; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a1709027c9500b0018867e3182esi1172134pll.335.2022.11.25.14.30.40; Fri, 25 Nov 2022 14:31:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=oGL3K0ft; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229748AbiKYWXd (ORCPT + 99 others); Fri, 25 Nov 2022 17:23:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbiKYWXb (ORCPT ); Fri, 25 Nov 2022 17:23:31 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18024205E3; Fri, 25 Nov 2022 14:23:31 -0800 (PST) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1669415009; bh=NQ+04B6zJQxzHILCfAFkhF13N2/TELUbaH94zEW62cA=; h=From:To:Cc:Subject:Date:From; b=oGL3K0ftiDi0H3tP1NKq0EhToZqpCPxDfWkxK+snQP0SbS2Z6YbgPIEKrH1XwAbgM 3GBM/xf75lgSbKmoFcGOI/CtOSqc+txkufagdaEHx5NKcEHmCQoD3Tpw7HssaPMDB+ TjmQYH5y76RsYzM+kZusZ/GrMisJiPBRbzEAAb/k= To: Wim Van Sebroeck , Guenter Roeck Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] watchdog: Report firmware_version in sysfs Date: Fri, 25 Nov 2022 23:23:15 +0100 Message-Id: <20221125222315.4925-1-linux@weissschuh.net> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1669414993; l=1549; i=linux@weissschuh.net; s=20211113; h=from:subject; bh=NQ+04B6zJQxzHILCfAFkhF13N2/TELUbaH94zEW62cA=; b=efEVyF6r8ALLabqaD+48qPvQ0ZPwyjpW7rBNapW//ealEWU/pw+w2BVj8w101tmZmFGGOyWW5dNW DN+TjMYLDnZirs1+g8+4WyrgEjNihcAFyYuGLJUfalO3bzzaFbSW X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=9LP6KM4vD/8CwHW7nouRBhWLyQLcK1MkP6aTZbzUlj4= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750508986692334855?= X-GMAIL-MSGID: =?utf-8?q?1750508986692334855?= This synchronizes the information reported by ioctl and sysfs. The mismatch is confusing because "wdctl" from util-linux uses the ioctl when used with root privileges and sysfs without. Signed-off-by: Thomas Weißschuh --- Userspace implementation: https://github.com/util-linux/util-linux/pull/1927 --- drivers/watchdog/watchdog_dev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) base-commit: 0b1dcc2cf55ae6523c6fbd0d741b3ac28c9f4536 diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 55574ed42504..88c76e27873c 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -555,6 +555,15 @@ static ssize_t identity_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(identity); +static ssize_t firmware_version_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct watchdog_device *wdd = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", wdd->info->firmware_version); +} +static DEVICE_ATTR_RO(firmware_version); + static ssize_t state_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -618,6 +627,7 @@ static umode_t wdt_is_visible(struct kobject *kobj, struct attribute *attr, static struct attribute *wdt_attrs[] = { &dev_attr_state.attr, &dev_attr_identity.attr, + &dev_attr_firmware_version.attr, &dev_attr_timeout.attr, &dev_attr_min_timeout.attr, &dev_attr_max_timeout.attr,