mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Gregory Clement <gregory.clement@bootlin.com>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	John Crispin <john@phrozen.org>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, Lee Jones <lee@kernel.org>,
	linux-leds@vger.kernel.org
Subject: Re: [net-next PATCH v2 02/14] net: dsa: qca8k: add LEDs basic support
Date: Fri, 10 Mar 2023 01:58:09 +0100	[thread overview]
Message-ID: <98054351-b124-467c-9be6-d8a7c357c268@lunn.ch> (raw)
In-Reply-To: <640a7775.5d0a0220.110eb.3e41@mx.google.com>

> > > +static enum led_brightness
> > > +qca8k_led_brightness_get(struct qca8k_led *led)
> > > +{
> > > +	struct qca8k_led_pattern_en reg_info;
> > > +	struct qca8k_priv *priv = led->priv;
> > > +	u32 val;
> > > +	int ret;
> > > +
> > > +	qca8k_get_enable_led_reg(led->port_num, led->led_num, &reg_info);
> > > +
> > > +	ret = regmap_read(priv->regmap, reg_info.reg, &val);
> > > +	if (ret)
> > > +		return 0;
> > > +
> > > +	val >>= reg_info.shift;
> > > +
> > > +	if (led->port_num == 0 || led->port_num == 4) {
> > > +		val &= QCA8K_LED_PATTERN_EN_MASK;
> > > +		val >>= QCA8K_LED_PATTERN_EN_SHIFT;
> > > +	} else {
> > > +		val &= QCA8K_LED_PHY123_PATTERN_EN_MASK;
> > > +	}
> > > +
> > > +	return val > 0 ? 1 : 0;
> > > +}
> > 
> > What will this return when in the future you add hardware offload, and
> > the LED is actually blinking because of frames being sent etc?
> > 
> > Is it better to not implement _get() when it is unclear what it should
> > return when offload is in operation?
> > 
> 
> My idea was that anything that is not 'always off' will have brightness
> 1. So also in accelerated blink brightness should be 1.
> 
> My idea of get was that it should reflect if the led is active or always
> off. Is it wrong?
 
brigntness_get seems to be used in two situations:

When the LED is first registered, it can be called to get the current
state of the LED. This then initialized cdev->brightness.

When the brightness sysfs file is read, there is first a call to
brightness_get to allow it to update the value in cdev->brightness
before returning the value in the read.

I think always returning 1 could be confusing. Take the example that
the LED is indicating link, there is no link, so it is off. Yet a read
of the brightness sysfs file will return 1?

I would say, it either needs to return the instantaneous brightness,
or it should not be implemented at all. When we come to implement
offloading, we might want to consider hiding the brightness sysfs
file. But we can solve that later.

      Andrew

  reply	other threads:[~2023-03-10  0:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 22:35 [net-next PATCH v2 00/14] net: Add basic LED support for switch/phy Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 01/14] net: dsa: qca8k: move qca8k_port_to_phy() to header Christian Marangi
2023-03-09 23:58   ` Andrew Lunn
2023-03-09 22:35 ` [net-next PATCH v2 02/14] net: dsa: qca8k: add LEDs basic support Christian Marangi
2023-03-10  0:12   ` Andrew Lunn
2023-03-10  0:18     ` Christian Marangi
2023-03-10  0:58       ` Andrew Lunn [this message]
2023-03-09 22:35 ` [net-next PATCH v2 03/14] net: dsa: qca8k: add LEDs blink_set() support Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 04/14] net: phy: Add a binding for PHY LEDs Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 05/14] net: phy: phy_device: Call into the PHY driver to set LED brightness Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 06/14] net: phy: marvell: Add software control of the LEDs Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 07/14] net: phy: phy_device: Call into the PHY driver to set LED blinking Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 08/14] net: phy: marvell: Implement led_blink_set() Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 09/14] dt-bindings: net: dsa: dsa-port: Document support for LEDs node Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 10/14] dt-bindings: net: dsa: qca8k: add LEDs definition example Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 11/14] arm: qcom: dt: Drop unevaluated properties in switch nodes for rb3011 Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 12/14] arm: qcom: dt: Add Switch LED for each port " Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 13/14] dt-bindings: net: phy: Document support for LEDs node Christian Marangi
2023-03-09 22:35 ` [net-next PATCH v2 14/14] arm: mvebu: dt: Add PHY LED support for 370-rd WAN port Christian Marangi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98054351-b124-467c-9be6-d8a7c357c268@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=gregory.clement@bootlin.com \
    --cc=hkallweit1@gmail.com \
    --cc=john@phrozen.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®