netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev <netdev@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH RFC net-next 8/8] dsa: qca8k: Use DSA common code for LEDs
Date: Wed, 29 Nov 2023 02:55:51 +0100	[thread overview]
Message-ID: <65669a29.5d0a0220.19703.34e3@mx.google.com> (raw)
In-Reply-To: <20231128232135.358638-9-andrew@lunn.ch>

[-- Attachment #1: Type: text/plain, Size: 356 bytes --]

On Wed, Nov 29, 2023 at 12:21:35AM +0100, Andrew Lunn wrote:
> Rather than parse the device tree in the qca8k driver, make use of the
> common code in the DSA core.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Hi,

I attached a fixup patch for this to correctly work. Since we are using
port_num the thing needs to be decrememted by one.

-- 
	Ansuel

[-- Attachment #2: 0001-fixup-dsa-qca8k-Use-DSA-common-code-for-LEDs.patch --]
[-- Type: text/x-diff, Size: 2802 bytes --]

From 95598e6892cb0d392249f099587bd81ea3b664de Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Wed, 29 Nov 2023 02:50:09 +0100
Subject: [PATCH] fixup! dsa: qca8k: Use DSA common code for LEDs

Fix off-by-one from port_num to phy.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/dsa/qca/qca8k-leds.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c
index febae23b65a9..67f42a0dbbd8 100644
--- a/drivers/net/dsa/qca/qca8k-leds.c
+++ b/drivers/net/dsa/qca/qca8k-leds.c
@@ -9,7 +9,7 @@
 static int
 qca8k_get_enable_led_reg(int port_num, int led_num, struct qca8k_led_pattern_en *reg_info)
 {
-	switch (port_num) {
+	switch (qca8k_port_to_phy(port_num)) {
 	case 0:
 		reg_info->reg = QCA8K_LED_CTRL_REG(led_num);
 		reg_info->shift = QCA8K_LED_PHY0123_CONTROL_RULE_SHIFT;
@@ -41,7 +41,7 @@ qca8k_get_control_led_reg(int port_num, int led_num, struct qca8k_led_pattern_en
 	 * 3 control rules for phy0-3 that applies to all their leds
 	 * 3 control rules for phy4
 	 */
-	if (port_num == 4)
+	if (qca8k_port_to_phy(port_num) == 4)
 		reg_info->shift = QCA8K_LED_PHY4_CONTROL_RULE_SHIFT;
 	else
 		reg_info->shift = QCA8K_LED_PHY0123_CONTROL_RULE_SHIFT;
@@ -127,7 +127,8 @@ qca8k_led_brightness_set(struct dsa_switch *ds, int port_num,
 	 * to calculate the shift and the correct reg due to this problem of
 	 * not having a 1:1 map of LED with the regs.
 	 */
-	if (port_num == 0 || port_num == 4) {
+	if (qca8k_port_to_phy(port_num) == 0 ||
+	    qca8k_port_to_phy(port_num) == 4) {
 		mask = QCA8K_LED_PATTERN_EN_MASK;
 		val <<= QCA8K_LED_PATTERN_EN_SHIFT;
 	} else {
@@ -162,7 +163,8 @@ qca8k_led_blink_set(struct dsa_switch *ds, int port_num, u8 led_num,
 
 	qca8k_get_enable_led_reg(port_num, led_num, &reg_info);
 
-	if (port_num == 0 || port_num == 4) {
+	if (qca8k_port_to_phy(port_num) == 0 ||
+	    qca8k_port_to_phy(port_num) == 4) {
 		mask = QCA8K_LED_PATTERN_EN_MASK;
 		val <<= QCA8K_LED_PATTERN_EN_SHIFT;
 	} else {
@@ -187,7 +189,8 @@ qca8k_led_trigger_offload(struct qca8k_priv *priv, int port_num, u8 led_num,
 	if (enable)
 		val = QCA8K_LED_RULE_CONTROLLED;
 
-	if (port_num == 0 || port_num == 4) {
+	if (qca8k_port_to_phy(port_num) == 0 ||
+	    qca8k_port_to_phy(port_num) == 4) {
 		mask = QCA8K_LED_PATTERN_EN_MASK;
 		val <<= QCA8K_LED_PATTERN_EN_SHIFT;
 	} else {
@@ -210,7 +213,8 @@ qca8k_led_hw_control_status(struct qca8k_priv *priv, int port_num, u8 led_num)
 
 	val >>= reg_info.shift;
 
-	if (port_num == 0 || port_num == 4) {
+	if (qca8k_port_to_phy(port_num) == 0 ||
+	    qca8k_port_to_phy(port_num) == 4) {
 		val &= QCA8K_LED_PATTERN_EN_MASK;
 		val >>= QCA8K_LED_PATTERN_EN_SHIFT;
 	} else {
-- 
2.40.1


  reply	other threads:[~2023-11-29  1:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28 23:21 [PATCH RFC net-next 0/8] DSA LED infrastructure, mv88e6xxx and QCA8K Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 1/8] net: dsa: mv88e6xxx: Add helpers for 6352 LED blink and brightness Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 2/8] net: dsa: mv88e6xxx: Tie the low level LED functions to device ops Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 3/8] net: dsa: Plumb LED brightnes and blink into switch API Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 4/8] dsa: Create port LEDs based on DT binding Andrew Lunn
2023-11-29  1:46   ` Christian Marangi
2023-11-29 19:40   ` Simon Horman
2023-11-29 20:07     ` Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 5/8] dsa: Plumb in LED calls needed for hardware offload Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 6/8] dsa: mv88e6xxx: Plumb in LED offload functions Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 7/8] arm: boot: dts: mvebu: linksys-mamba: Add Ethernet LEDs Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 8/8] dsa: qca8k: Use DSA common code for LEDs Andrew Lunn
2023-11-29  1:55   ` Christian Marangi [this message]
2023-11-29  2:16     ` Andrew Lunn
2023-11-29  2:23       ` Christian Marangi
2023-11-29  1:57 ` [PATCH RFC net-next 0/8] DSA LED infrastructure, mv88e6xxx and QCA8K Christian Marangi
2023-11-29 12:38 ` Vladimir Oltean
2023-11-29 15:13   ` Andrew Lunn
2023-11-29 15:43     ` Vladimir Oltean
2023-11-29 16:27       ` Andrew Lunn
2023-11-29 16:44         ` Vladimir Oltean
2023-11-29 21:51 ` Linus Walleij

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=65669a29.5d0a0220.19703.34e3@mx.google.com \
    --to=ansuelsmth@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).