Re: [PATCH v2] net: phy: leds: Add support for "link" trigger
From: Maciej S. Szmigiero
Date: Wed Nov 01 2017 - 08:43:10 EST
Hi Andrew,
On 01.11.2017 13:37, Andrew Lunn wrote:
> Hi Maciej
>
> I don't particularly like the
>
> if (!phy->link)
> goto out_change_speed;
>
> part of the existing code. Makes me thing of BASIC. goto is good for
> error handling, but this is not an error.
>
> If you feel like it, maybe you can refactor this code? Add a function like:
>
> phy_led_trigger_no_link(struct phy_device *phy)
> {
> if (phy->last_triggered) {
> led_trigger_event(&phy->last_triggered->trigger,
> LED_OFF);
> phy->last_triggered = NULL;
> }
> }
>
> and call it, rather than using goto? It then becomes a lot more
> obvious what your change is doing, turning the LED off when there is
> no link.
All right, will do this, too.
> Thanks
> Andrew
>
Maciej