* [PATCH net-next] r8169: improve checking for valid LED modes
@ 2024-02-07 7:16 Heiner Kallweit
2024-02-08 16:21 ` Simon Horman
2024-02-09 21:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Heiner Kallweit @ 2024-02-07 7:16 UTC (permalink / raw)
To: Realtek linux nic maintainers, Jakub Kicinski, Paolo Abeni,
Eric Dumazet, David Miller
Cc: netdev
After 3a2746320403 ("leds: trigger: netdev: Display only supported link
speed attribute") the check for valid link modes can be simplified.
In addition factor it out, so that it can be re-used by the upcoming
LED support for RTL8125.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8169_leds.c | 38 ++++++++++++-----------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_leds.c b/drivers/net/ethernet/realtek/r8169_leds.c
index f082bd7d6..78078eca3 100644
--- a/drivers/net/ethernet/realtek/r8169_leds.c
+++ b/drivers/net/ethernet/realtek/r8169_leds.c
@@ -20,11 +20,6 @@
#define RTL8168_NUM_LEDS 3
-#define RTL8168_SUPPORTED_MODES \
- (BIT(TRIGGER_NETDEV_LINK_1000) | BIT(TRIGGER_NETDEV_LINK_100) | \
- BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_RX) | \
- BIT(TRIGGER_NETDEV_TX))
-
struct r8169_led_classdev {
struct led_classdev led;
struct net_device *ndev;
@@ -33,28 +28,35 @@ struct r8169_led_classdev {
#define lcdev_to_r8169_ldev(lcdev) container_of(lcdev, struct r8169_led_classdev, led)
+static bool r8169_trigger_mode_is_valid(unsigned long flags)
+{
+ bool rx, tx;
+
+ if (flags & BIT(TRIGGER_NETDEV_HALF_DUPLEX))
+ return false;
+ if (flags & BIT(TRIGGER_NETDEV_FULL_DUPLEX))
+ return false;
+
+ rx = flags & BIT(TRIGGER_NETDEV_RX);
+ tx = flags & BIT(TRIGGER_NETDEV_TX);
+
+ return rx == tx;
+}
+
static int rtl8168_led_hw_control_is_supported(struct led_classdev *led_cdev,
unsigned long flags)
{
struct r8169_led_classdev *ldev = lcdev_to_r8169_ldev(led_cdev);
struct rtl8169_private *tp = netdev_priv(ldev->ndev);
int shift = ldev->index * 4;
- bool rx, tx;
-
- if (flags & ~RTL8168_SUPPORTED_MODES)
- goto nosupp;
- rx = flags & BIT(TRIGGER_NETDEV_RX);
- tx = flags & BIT(TRIGGER_NETDEV_TX);
- if (rx != tx)
- goto nosupp;
+ if (!r8169_trigger_mode_is_valid(flags)) {
+ /* Switch LED off to indicate that mode isn't supported */
+ rtl8168_led_mod_ctrl(tp, 0x000f << shift, 0);
+ return -EOPNOTSUPP;
+ }
return 0;
-
-nosupp:
- /* Switch LED off to indicate that mode isn't supported */
- rtl8168_led_mod_ctrl(tp, 0x000f << shift, 0);
- return -EOPNOTSUPP;
}
static int rtl8168_led_hw_control_set(struct led_classdev *led_cdev,
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] r8169: improve checking for valid LED modes
2024-02-07 7:16 [PATCH net-next] r8169: improve checking for valid LED modes Heiner Kallweit
@ 2024-02-08 16:21 ` Simon Horman
2024-02-09 21:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-02-08 16:21 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Realtek linux nic maintainers, Jakub Kicinski, Paolo Abeni,
Eric Dumazet, David Miller, netdev
On Wed, Feb 07, 2024 at 08:16:40AM +0100, Heiner Kallweit wrote:
> After 3a2746320403 ("leds: trigger: netdev: Display only supported link
> speed attribute") the check for valid link modes can be simplified.
> In addition factor it out, so that it can be re-used by the upcoming
> LED support for RTL8125.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] r8169: improve checking for valid LED modes
2024-02-07 7:16 [PATCH net-next] r8169: improve checking for valid LED modes Heiner Kallweit
2024-02-08 16:21 ` Simon Horman
@ 2024-02-09 21:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-09 21:00 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: nic_swsd, kuba, pabeni, edumazet, davem, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 7 Feb 2024 08:16:40 +0100 you wrote:
> After 3a2746320403 ("leds: trigger: netdev: Display only supported link
> speed attribute") the check for valid link modes can be simplified.
> In addition factor it out, so that it can be re-used by the upcoming
> LED support for RTL8125.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>
> [...]
Here is the summary with links:
- [net-next] r8169: improve checking for valid LED modes
https://git.kernel.org/netdev/net-next/c/4c49b6824a60
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-09 21:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 7:16 [PATCH net-next] r8169: improve checking for valid LED modes Heiner Kallweit
2024-02-08 16:21 ` Simon Horman
2024-02-09 21:00 ` patchwork-bot+netdevbpf
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).