From: Andrew Lunn <andrew@lunn.ch>
To: Chukun Pan <amadeus@jmu.edu.cn>
Cc: "David S . Miller" <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Russell King <linux@armlinux.org.uk>,
Daniel Golle <daniel@makrotopia.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 1/1] net: phy: realtek: Add support for PHY LEDs on RTL8221B
Date: Mon, 20 Apr 2026 14:55:21 +0200 [thread overview]
Message-ID: <92e843f7-aec2-4c6c-bc8f-a869c542fcb4@lunn.ch> (raw)
In-Reply-To: <20260420100800.2435204-1-amadeus@jmu.edu.cn>
On Mon, Apr 20, 2026 at 06:08:00PM +0800, Chukun Pan wrote:
> Realtek RTL8221B Ethernet PHY supports three LED pins which are used to
> indicate link status and activity. Add netdev trigger support for them.
>
> Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
> ---
> Changes in v2:
> - Invert the LED polarity in led_brightness_set to achieve LED_ON.
Nice idea.
> +static int rtl822xb_led_hw_control_set(struct phy_device *phydev, u8 index,
> + unsigned long rules)
> +{
> + u16 val = 0;
> + bool act;
> + int ret;
> +
> + if (index >= RTL8211x_LED_COUNT)
> + return -EINVAL;
> +
> + if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
> + test_bit(TRIGGER_NETDEV_LINK_10, &rules))
> + val |= RTL822X_VND2_LCR_LINK_10;
> +
> + if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
> + test_bit(TRIGGER_NETDEV_LINK_100, &rules))
> + val |= RTL822X_VND2_LCR_LINK_100;
> +
> + if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
> + test_bit(TRIGGER_NETDEV_LINK_1000, &rules))
> + val |= RTL822X_VND2_LCR_LINK_1000;
> +
> + if (test_bit(TRIGGER_NETDEV_LINK, &rules) ||
> + test_bit(TRIGGER_NETDEV_LINK_2500, &rules))
> + val |= RTL822X_VND2_LCR_LINK_2500;
> +
> + ret = phy_write_mmd(phydev, MDIO_MMD_VEND2,
> + RTL822X_VND2_LED(index), val);
> + if (ret < 0)
> + return ret;
> +
> + act = test_bit(TRIGGER_NETDEV_RX, &rules) ||
> + test_bit(TRIGGER_NETDEV_TX, &rules);
> +
> + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_LCR6,
> + RTL822X_VND2_LED_ACT(index), act ?
> + RTL822X_VND2_LED_ACT(index) : 0);
I think to be safe, you probably should set the polarity back to its
default. Or you need to add to the commit message that you have
verified that ledtrig-netdev will always turn the LED off before
offloading to hardware, so resetting the polarity.
Andrew
---
pw-bot: cr
prev parent reply other threads:[~2026-04-20 12:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 10:08 [PATCH v2 1/1] net: phy: realtek: Add support for PHY LEDs on RTL8221B Chukun Pan
2026-04-20 12:55 ` Andrew Lunn [this message]
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=92e843f7-aec2-4c6c-bc8f-a869c542fcb4@lunn.ch \
--to=andrew@lunn.ch \
--cc=amadeus@jmu.edu.cn \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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