Message ID | 20230619204700.6665-4-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3243582vqr; Mon, 19 Jun 2023 13:51:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/es0pnghnV/pKxy6UaRCwgX5Uke30z+kn8YOw76d9+GLnYPxmaePbCEC3kBiZYiFldbL0 X-Received: by 2002:a05:6a20:4299:b0:121:d74e:8b46 with SMTP id o25-20020a056a20429900b00121d74e8b46mr2218296pzj.55.1687207895991; Mon, 19 Jun 2023 13:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687207895; cv=none; d=google.com; s=arc-20160816; b=ZSLVWeJdkCW3s+hN2lfk6SAStTb48RhEuoaL1Ig7ro2ur1hSu/FizVZM/WwoxAbgkK sHXXTm+yFhw+u7uXR0qLKV0mvp74aWcAn6DGj8sPoBgMUUPkATR7YuuTBrOhcA8FL5D7 HsSJwh6xLY2ElRqO4BZJ4SpvkUU0WmufeH3qT/k7ZEOlyFOaUcym8vHfLiSV1u0b7E1D qb8Z6NBDyEs/VShXGG3EKi8p9s1HkzMHTnk4d/Kbex0RFMQd+nk0UK3A1+LpbwLiYYyV rXs3+3iw9oe8PjUaKiyIPvgBjUtWJFGB91sWS7VPJkYzQAk8c1EWRS0alDQVRXhRRRJH npwQ== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ccjdX+IZqQAhgyk6xPOcJY+ngvdDgr2cEw+3he/cnkM=; b=lDr45bL3ZmVf2vWksnAYeDg14U+zIRmNgwD7v5idDi35GOg2JdlA7dVnjesqTVg+YF GMDP5cYtOzmMNdMJpf6sAFY5YTcCWlYZZeaMOkxNTLy79LMgGcoAlR7FhoJRFqB1ldis cOllmDk2o2rKGPR9h0aURENa1QjJo5WLNM9x1QxKOk9mlZmD+zE9gQ2fz6mPTQEG+SAC rliROy/6ObD3/z/fZXGfmD67+VBfaueIS+x3rdm0KobfpXd2LZ4vKlKEsq5swDTl/IsV KA6nW+2780zZ8lXoUQm/8cn1DVQjHlOV1mJxvo0VZmuNEyeLJvSBZLtwajJlFaoG/pp1 rbpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=jHYqsvXA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r12-20020aa7988c000000b0066874556a58si189901pfl.213.2023.06.19.13.51.20; Mon, 19 Jun 2023 13:51:35 -0700 (PDT) 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=pass header.i=@gmail.com header.s=20221208 header.b=jHYqsvXA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229875AbjFSUrd (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Mon, 19 Jun 2023 16:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbjFSUr1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 19 Jun 2023 16:47:27 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D57F1A3; Mon, 19 Jun 2023 13:47:24 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31272fcedf6so1056097f8f.2; Mon, 19 Jun 2023 13:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687207643; x=1689799643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ccjdX+IZqQAhgyk6xPOcJY+ngvdDgr2cEw+3he/cnkM=; b=jHYqsvXA6NiTfeCcqKVcOiRIKTt+m2BZuSNb260ylv7/IACNKLfLYiqzemybP73R7r E/cN0oKUQtbleX04sIgx0XWdlndkVtGIgOtq1JGz3fBggnfoZzhCzPobJVyvq78WBhi3 Jv5wWJaHtzIVPu98JdDMdLI7YpEwnmQ2fb+TzOU/533Ypi+Kh40R9a0BcOEuH+k/tyzk lKdHnqhkGNit4/GxpXJgLxQ9Bqh3oIY5iLMPn0DUmvdd4c4EtqssVw0tDoDaIGZHumqe LJvTUul00cc/6PGucXfyjJtbtveK2sex0Z8cZsyyD9IROs71j3KltUJxgSdzBn22EkKs jr/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687207643; x=1689799643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ccjdX+IZqQAhgyk6xPOcJY+ngvdDgr2cEw+3he/cnkM=; b=iQ4iNkmWuXmo/LfzyjT2dcexZcd2rNabGJAFYaVzqMYi1cEGT0pXJHw1pfvRG0/LCq k98plSkvUiFIrGOs7W4+H+K6gN2xPOP7xIJjzkzqVJ8G5EQZvzeNhAyEM+MGTm0BasRF HN1Qnhh8/THdGO5b+R5sLgotIpdndqdyc1pPZ5tsDDNx/MYRY5YuMJPm1ELC+w4RyJM1 FUt/2+iR8k0YYv3e5UnFvJXRNU3G3g/vDWYb70K1Juvmw7hw+C1HxGAHThFI8FGDld8q HdDfD0icU1zsQx6suYs2bUIl0EkOutT7a7H98O8VouhWACW7P/smfn3nG1bCAc5JkkFS rvYg== X-Gm-Message-State: AC+VfDwdv37asNIHY5OMtI/GguNBczFe0hEcD4udRqvE7hIAp5qKx3ur 1x8sxJZKasgYLoU1EYStvWg= X-Received: by 2002:a5d:6292:0:b0:30f:cf67:564e with SMTP id k18-20020a5d6292000000b0030fcf67564emr7527330wru.62.1687207642690; Mon, 19 Jun 2023 13:47:22 -0700 (PDT) Received: from localhost.localdomain (93-34-93-173.ip49.fastwebnet.it. [93.34.93.173]) by smtp.googlemail.com with ESMTPSA id k10-20020adff5ca000000b0030ae87bd3e3sm434043wrp.18.2023.06.19.13.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:47:22 -0700 (PDT) From: Christian Marangi <ansuelsmth@gmail.com> To: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>, Andrew Lunn <andrew@lunn.ch>, Christian Marangi <ansuelsmth@gmail.com>, "David S. Miller" <davem@davemloft.net>, Dan Carpenter <dan.carpenter@linaro.org>, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [net-next PATCH v5 3/3] leds: trigger: netdev: expose hw_control status via sysfs Date: Mon, 19 Jun 2023 22:47:00 +0200 Message-Id: <20230619204700.6665-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230619204700.6665-1-ansuelsmth@gmail.com> References: <20230619204700.6665-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769165706670429661?= X-GMAIL-MSGID: =?utf-8?q?1769165706670429661?= |
Series |
leds: trigger: netdev: add additional modes
|
|
Commit Message
Christian Marangi
June 19, 2023, 8:47 p.m. UTC
Expose hw_control status via sysfs for the netdev trigger to give userspace better understanding of the current state of the trigger and the LED. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> --- drivers/leds/trigger/ledtrig-netdev.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
Comments
> +static ssize_t hw_control_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct led_netdev_data *trigger_data = led_trigger_get_drvdata > (dev); > + > + return sprintf(buf, "%d\n", trigger_data->hw_control); > > [Kalesh]: How about using sysfs_emit? Currently, there are zero instances of sysfs_emit() in ledtrig-netdev, and in any files in drivers/leds/trigger/, or even drivers/leds. So i think it would be better to keep this consistent with the rest of the code in this file, and have a follow up patchset which reviews and converts the 52 sprintf() in drivers/leds. Andrew
On Mon, 19 Jun 2023, Christian Marangi wrote: > Expose hw_control status via sysfs for the netdev trigger to give > userspace better understanding of the current state of the trigger and > the LED. > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > --- > drivers/leds/trigger/ledtrig-netdev.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) Acked-by: Lee Jones <lee@kernel.org>
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index 2c1c9e95860e..32b66703068a 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c @@ -406,6 +406,16 @@ static ssize_t interval_store(struct device *dev, static DEVICE_ATTR_RW(interval); +static ssize_t hw_control_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev); + + return sprintf(buf, "%d\n", trigger_data->hw_control); +} + +static DEVICE_ATTR_RO(hw_control); + static struct attribute *netdev_trig_attrs[] = { &dev_attr_device_name.attr, &dev_attr_link.attr, @@ -417,6 +427,7 @@ static struct attribute *netdev_trig_attrs[] = { &dev_attr_rx.attr, &dev_attr_tx.attr, &dev_attr_interval.attr, + &dev_attr_hw_control.attr, NULL }; ATTRIBUTE_GROUPS(netdev_trig);