Article View: linux.kernel.netdev
Article #27299Re: [PATCH net-next v9 2/2] net: phy: dap8211r: add PHY LED control support
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 08:46
Date: Sat, 05 Dec 2026 08:46
128 lines
12438 bytes
12438 bytes
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:343)
can return a set of hardware-control rules that the hardware is not…
--
net: phy: dap8211r: add PHY LED control support
This adds LED support for the three LEDs on the DAP8211R PHY. It adds a
dap8211r_write_ext() helper and the led_brightness_set, led_hw_is_supported,
led_hw_control_set and led_hw_control_get callbacks. Brightness is driven
through the force mode bits in LED_COMCON, and hardware control is driven
through the per-LED LED_x_CON rule registers.
> diff --git a/drivers/net/phy/dap8211r.c b/drivers/net/phy/dap8211r.c
> index 1fe20efd394d7..c6d18312c8c34 100644
> --- a/drivers/net/phy/dap8211r.c
> +++ b/drivers/net/phy/dap8211r.c
[ ... ]
> @@ -114,6 +190,196 @@ static int dap8211r_modify_ext(struct phy_device *phydev, u16 reg, u16 mask, u16
> return ret;
> }
>
[ ... ]
> +static int dap8211r_led_hw_control_get(struct phy_device *phydev, u8 index, unsigned long *rules)
> +{
> + u16 led_reg;
> + int led_mode = 0;
> +
> + switch (index) {
> + case DAP8211R_LED_ID_0 ... DAP8211R_LED_ID_2:
> + led_reg = DAP8211R_LED_0_CON + index;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + led_mode = dap8211r_read_ext(phydev, led_reg);
> + if (led_mode < 0)
> + return led_mode;
[Severity: Medium]
Can this return rules that the hardware is not actually following?
This function only reads LED_x_CON. It never checks FORCE_EN(index) in
DAP8211R_LED_COMCON. So when the LED is in force mode, it still returns 0
along with whatever LED_x_CON happens to hold.
The led_hw_control_get description in include/linux/phy.h says the callback
should "Set *@rules to how the HW is currently blinking" and return an error
"if the current blinking cannot be represented in rules". The kernel-doc
above this function also promises -EOPNOTSUPP for that case.
netdev_trig_activate() trusts a 0 return:
drivers/leds/trigger/ledtrig-netdev.c:netdev_trig_activate() {
...
trigger_data->hw_control = true;
set_device_name(trigger_data, name, strlen(name));
rc = led_cdev->hw_control_get(led_cdev, &mode);
if (!rc)
trigger_data->mode = mode;
...
}
On this path, set_device_name() skips set_baseline_state(). That means
hw_control_set() is never called and FORCE_EN is never cleared.
This sequence looks like it would hit the problem:
echo none > trigger
echo 1 > brightness
dap8211r_led_brightness_set()
LED_x_CON = 0, FORCE_EN | FORCE_ON set
echo netdev > trigger (PHY attached)
netdev_trig_activate()
hw_control_get() reads LED_x_CON = 0, returns 0 with mode = 0
After that, the trigger reports hardware control with no rules, but the LED
stays forced on. This lasts until a later mode, device_name or netdev event
calls hw_control_set().
The same thing would happen if firmware or a bootloader leaves FORCE_EN set
with non-zero LED_x_CON rules. Those rules would be reported as active while
the LED is forced.
Would it make sense to also read DAP8211R_LED_COMCON here and return
-EOPNOTSUPP when FORCE_EN(index) is set?
A related question is what happens when only half of a two-register update
succeeds. In dap8211r_led_hw_control_set():
ret = dap8211r_write_ext(phydev, led_reg, led_mode);
if (ret)
return ret;
return dap8211r_modify_ext(phydev, DAP8211R_LED_COMCON,
DAP8211R_LED_FORCE_EN(index), 0);
If the COMCON modify fails, the LED stays forced, but hw_control_get()
reports the new rules. set_baseline_state() also ignores the return value
of hw_control_set().
In dap8211r_led_brightness_set(), LED_x_CON is zeroed before the COMCON
modify. If that modify fails, the LED has lost its rules and is not in
force mode either.
Should either of these restore the first register when the second access
fails?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204081448.3199171-1-a.shimko.dev%40gmail.com
Technical Details
Message-ID:
<179646040477.3146.15286579704926683101@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377900-linux-kernel-netdev=dewy.ruReferences:
<20261204081448.3199171-3-a.shimko.dev@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377900-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v9 2/2] net: phy: dap8211r: add PHY LED control support Date: Sat, 05 Dec 2026 08:46:44 +0000 Organization: Usenet Network Message-ID: <179646040477.3146.15286579704926683101@kernel.org> References: <20261204081448.3199171-3-a.shimko.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2990134"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:U7Lc7/8Jt4J4CjqavTcMFKWYoNY= sha256:2BBxIk/o55j5xgt2BNLqfWvMm/R0ve05qMGYodQyq8E= sha1:91qnXzX2kr22oEm03Ita4UFs71E= sha256:D3eogt+1Vr9TU15T5Ii6FdGa8fGZ5+r4TjbJhb+iDfA= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id F29E2117DA6; Sat, 5 Dec 2026 11:47:07 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.541 X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uTINYuDOO4cd; Sat, 5 Dec 2026 11:47:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377900-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 23758117DB3; Sat, 5 Dec 2026 11:46:55 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 70D412D387; Sat, 5 Dec 2026 08:46:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796460412; b=XVEg71V5yJHaoDXNh8LZTRFthkyUGS9XpK/OXblIzXuBGh7vNQqDPzUF94GSV4ul7jjX AH7Zf8imNLLgCsMNbD+cf3jFfef/C55EKGyRWQOz05J3A5VzX5feHbOReCWwn8Xeu4AsU nHxutBnhI+1XmBp1QcbCl5dpprcX3FpsDLE2PpSIRgHnVUNiLVH3WUwyYdbJxfxymHJEY 7GLdy5gj9rYq1czMEkmC3pwhR4Swy9UruZdDQ60CVVgyS7Gql7zgHukOE28GPpeyJUORj EG9PjwFnoLtEZmhqsHndtMLE+1hplbCgPLbIUvZBlgc+wr9j82CxO8SYgiAQXuw17BA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796460412; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=aZWs10Lg4XaYeqoFiDPKbd2q4bopyjVoHIlJ7ldv6gM=; b=LNbVYL/8iATR2Z9FoAT8zsMVp0mttyoVQ5aStQjArxR23uY0kG07lmVXDk0DYNg0+jd8 E0QIaM9rH3+tVTCWtIPwNaY9Av+2YsIw6Cwg2tp3oyPzJBmhBEsQzArjaVII/QE0Mn380 9vAvASi/UbtlUMd3hy3otgFKbiYUsVmKkeU6wQwS3Uufp+R3OzT/c5xqGxW/ZqXNi2vYr YZOxDpFq6EGkkPpp1v12MqxZh4+cCpRWuo9oTMx+S3nY9uq0FHsQUcDRNbiDl2fmeOmxR G6hvjvGnPxez8I3iFMeAt32hn2ebmKmsMzsOJwcHefQg8Pep83tKe7eD7g4jwXXs3xg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JpFkBwBT; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47FBE606A334; Sat, 5 Dec 2026 08:46:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JpFkBwBT X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796460406; b=iRO4qX8eKjmkw0QL1CoOTTooHcHcL4HGzdxOico7cbrMHOs3w9Q1P/u3yPKPFbt8GVI3 /ohPbXePaNYj585mSiT24V6dSA6yORYE5VDZLcypIZvbR6MeNNO02fGTTN4XsCIriPQpE CCghpd+X4I9gg243SILLD2I0v8fXbMoppeeqZBjDNqp2pX7KcjAuliy4azv8dGI7y+/Jt wi0RIqxe9Gn8PAVbAVJlMGW0FIRogROOdIPIeiKfub5gnVN3kg+qCy90BtAbi8tq7iAaY 1Y/Yoaz0lClq+blk71VOIPH5HXnPeGInmQUFVgidUxK5Gv7wJyVdztRMO/GbWQFhbqw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796460406; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=aZWs10Lg4XaYeqoFiDPKbd2q4bopyjVoHIlJ7ldv6gM=; b=Eq8BrMtVHabYoQQPx4LncYaHBo5RAI7Iss/ih6WFqwlOZpHKZYLtsSc5XAAkNMEX5bks 3IEQ4PueWoca8xcIRFq9g2QRSnI86MMH3nuDioicSzgNEjh3+X3nq6Um1PwoYkne1U+HI gc6L0BE5mmwUGEEb3iucosAcVVS0hknn22RypEYIoPWVwbsyFt/FMdY9GE9XwwSrqOEA8 qOz9Z2Ov7zDtlYRxtYnZixGfuCcXuuWBt2a5WEksDoXmb7Fl4oUOWhoRHbbjOeGGShHxO QOh3UeteNRmi/d6BNiTNDAnzasv6Gqv/7iraKLnniVxeRb4x95gM0ywP0g5DIZmbFGQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JpFkBwBT; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66AC4606A322; Sat, 5 Dec 2026 08:46:46 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 344861F0092B; Sat, 5 Dec 2026 08:46:45 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796460406; bh=aZWs10Lg4XaYeqoFiDPKbd2q4bopyjVoHIlJ7ldv6gM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=JpFkBwBT2wb20xmNOMO9EUiy6eysqL1ymUAzpkKLTH5sNqBvEWnbtcz9sekcSWwbh +lVYaJCtGQ5wjh7MM2mJHehxi8dkpdiNPbzGssM/JEf2+PfFyiUTfh1tIlpey0oDGr kvgRMApJrh2sGzU/IfODW2+UWaH9cuDBn8OnTaIItvsPyZf+9AoTMTodMsMTUyrXAM BG6wu2JVFbNAaEvblh0I/rLaY/52+NLvaxYXYc1v07NseuCWR/5jwwDkL3/+/1GvR9 m8WmxrUPPF7tsMXR+aH8vbsVIrjvCD2imWEV06C/QsPhb1eTGu6P9cxR35jB04Pdui mcz5VkwpV9/mg== X-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 X-In-Reply-To: <20261204081448.3199171-3-a.shimko.dev@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list