From: netdev-bot+sashiko@kernel.org
To: a.shimko.dev@gmail.com
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, maxime.chevallier@bootlin.com, pavel@ucw.cz,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-leds@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v5 3/3] net: phy: dap8211r: add PHY LED control support
Date: Wed, 25 Nov 2026 09:52:16 +0000 [thread overview]
Message-ID: <179560033613.3135.13122318439070700886@kernel.org> (raw)
In-Reply-To: <20261124094914.2993988-4-a.shimko.dev@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] dap8211r_led_hw_control_get()
(drivers/net/phy/dap8211r.c:322-369) returns 0 with an incomplete rule…
--
net: phy: dap8211r: add PHY LED control support
This commit adds LED support for the three LEDs on the DAP8211R PHY. It
adds a dap8211r_write_ext() helper and implements the led_brightness_set,
led_hw_is_supported, led_hw_control_set and led_hw_control_get callbacks.
> diff --git a/drivers/net/phy/dap8211r.c b/drivers/net/phy/dap8211r.c
> index 1fe20efd394d7..9b65b5c57de81 100644
> --- a/drivers/net/phy/dap8211r.c
> +++ b/drivers/net/phy/dap8211r.c
[ ... ]
> +/**
> + * dap8211r_led_hw_control_set() - Write the LED control register
> + * @phydev: PHY device structure
> + * @index: LED index
> + * @rules: Bitmask of requested netdev trigger rules
> + *
> + * Disables force mode and translates the requested trigger rules into
> + * the corresponding bit positions of the LED control register and writes
> + * the resulting value to the PHY.
> + *
> + * Note that the ACT_BLINK bit (13) must be set together with TX/RX rules,
> + * otherwise the LED will not blink on traffic if no other rule (such as
> + * link or duplex) is active.
[ ... ]
> + ret = dap8211r_write_ext(phydev, led_reg, led_mode);
> + if (ret)
> + return ret;
[ ... ]
> +/**
> + * dap8211r_led_hw_control_get() - Read the current LED configuration
[ ... ]
> + * Return: 0 on success, -EINVAL for an invalid LED index, -EOPNOTSUPP if the
> + * current hardware configuration cannot be represented in rules, or a
> + * negative error code
> + */
> +static int dap8211r_led_hw_control_get(struct phy_device *phydev, u8 index, unsigned long *rules)
> +{
[ ... ]
> + led_mode = dap8211r_read_ext(phydev, led_reg);
> + if (led_mode < 0)
> + return led_mode;
> +
> + if (led_mode & ~DAP8211R_LED_SUPPORTED_MASK)
> + return -EOPNOTSUPP;
[ ... ]
> + if ((led_mode & DAP8211R_LED_RX) &&
> + (led_mode & DAP8211R_LED_ACT_BLINK))
> + __set_bit(TRIGGER_NETDEV_RX, rules);
> +
> + if ((led_mode & DAP8211R_LED_TX) &&
> + (led_mode & DAP8211R_LED_ACT_BLINK))
> + __set_bit(TRIGGER_NETDEV_TX, rules);
[Severity: Medium]
Should dap8211r_led_hw_control_get() return -EOPNOTSUPP when LED_n_CON
holds a state that can't be expressed as rules?
The only check that rejects a state is led_mode & ~DAP8211R_LED_SUPPORTED_MASK.
That mask includes ACT_BLINK, TX and RX. As a result, two register states
pass the check, get reported incompletely, and the function still returns 0:
- RX and/or TX set without ACT_BLINK. For example, LINK_1000 | RX | TX
is reported as only TRIGGER_NETDEV_LINK_1000. The comment above
dap8211r_led_hw_control_set() describes this as a working hardware
mode when a link or duplex rule is active.
- ACT_BLINK set on its own, which is reported as no rules at all.
The kernel-doc for this function says -EOPNOTSUPP is returned if "the
current hardware configuration cannot be represented in rules". The
led_hw_control_get contract in include/linux/phy.h says the same.
netdev_trig_activate() trusts a 0 return:
drivers/leds/trigger/ledtrig-netdev.c:netdev_trig_activate() {
...
rc = led_cdev->hw_control_get(led_cdev, &mode);
if (!rc)
trigger_data->mode = mode;
...
}
After that, either the NETDEV_REGISTER replay from
register_netdevice_notifier() or a later NETDEV_UP/CHANGE event runs:
netdev_trig_notify()
set_baseline_state()
phy_led_hw_control_set()
dap8211r_led_hw_control_set()
dap8211r_write_ext(phydev, led_reg, led_mode)
This writes the whole register with the reduced rules. Would that clear
the RX/TX activity bits set by the reset defaults or the bootloader? It
would also leave sysfs reporting a different mode from the one the LED
was running before the trigger was activated.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124094914.2993988-1-a.shimko.dev%40gmail.com
prev parent reply other threads:[~2026-11-25 9:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:49 [PATCH net-next v5 0/3] net: phy: dap8211r: add " Artem Shimko
2026-11-24 9:49 ` [PATCH net-next v5 1/3] net: phy: dap8211r: fix kernel-doc comments for extended register helpers Artem Shimko
2026-11-24 9:49 ` [PATCH net-next v5 2/3] dt-bindings: net: dptel,dap8211r: add LED nodes Artem Shimko
2026-11-24 9:49 ` [PATCH net-next v5 3/3] net: phy: dap8211r: add PHY LED control support Artem Shimko
2026-11-24 21:47 ` Andrew Lunn
2026-11-25 9:52 ` netdev-bot+sashiko [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=179560033613.3135.13122318439070700886@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=a.shimko.dev@gmail.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavel@ucw.cz \
--cc=robh@kernel.org \
/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®