From: Christian Marangi <ansuelsmth@gmail.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Jonathan Corbet" <corbet@lwn.net>, "Pavel Machek" <pavel@ucw.cz>,
"John Crispin" <john@phrozen.org>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-leds@vger.kernel.org, "Tim Harvey" <tharvey@gateworks.com>,
"Alexander Stein" <alexander.stein@ew.tq-group.com>,
"Rasmus Villemoes" <rasmus.villemoes@prevas.dk>,
"Marek Behún" <kabel@kernel.org>
Subject: Re: [PATCH v7 01/11] leds: add support for hardware driven LEDs
Date: Fri, 16 Dec 2022 17:45:25 +0100 [thread overview]
Message-ID: <639ca0a4.050a0220.99395.8fd3@mx.google.com> (raw)
In-Reply-To: <Y5tHjwx1Boj3xMok@shell.armlinux.org.uk>
On Thu, Dec 15, 2022 at 04:13:03PM +0000, Russell King (Oracle) wrote:
> Hi Christian,
>
> Thanks for the patch.
>
> I think Andrew's email is offline at the moment.
>
Notice by gmail spamming me "I CAN'T SEND IT AHHHHH"
Holidy times I guess?
> On Thu, Dec 15, 2022 at 12:54:28AM +0100, Christian Marangi wrote:
> > +static bool led_trigger_is_supported(struct led_classdev *led_cdev,
> > + struct led_trigger *trigger)
> > +{
> > + switch (led_cdev->blink_mode) {
> > + case SOFTWARE_CONTROLLED:
> > + if (trigger->supported_blink_modes == HARDWARE_ONLY)
> > + return 0;
> > + break;
> > + case HARDWARE_CONTROLLED:
> > + if (trigger->supported_blink_modes == SOFTWARE_ONLY)
> > + return 0;
> > + break;
> > + case SOFTWARE_HARDWARE_CONTROLLED:
> > + break;
> > + default:
> > + return 0;
> > + }
> > +
> > + return 1;
>
> Should be returning true/false. I'm not sure I'm a fan of the style of
> this though - wouldn't the following be easier to read?
>
> switch (led_cdev->blink_mode) {
> case SOFTWARE_CONTROLLED:
> return trigger->supported_blink_modes != HARDWARE_ONLY;
>
> case HARDWARE_CONTROLLED:
> return trigger->supported_blink_modes != SOFTWARE_ONLY;
>
> case SOFTWARE_HARDWARE_CONTROLLED:
> return true;
> }
> ?
Much better!
>
> Also, does it really need a default case - without it, when the
> led_blink_modes enum is expanded and the switch statement isn't
> updated, we'll get a compiler warning which will prompt this to be
> updated - whereas, with a default case, it won't.
>
I added the default just to mute some compiler warning. But guess if
every enum is handled the warning should not be reported.
> > @@ -188,6 +213,10 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
> > led_set_brightness(led_cdev, LED_OFF);
> > }
> > if (trig) {
> > + /* Make sure the trigger support the LED blink mode */
> > + if (!led_trigger_is_supported(led_cdev, trig))
> > + return -EINVAL;
>
> Shouldn't validation happen before we start taking any actions? In other
> words, before we remove the previous trigger?
>
trigger_set first remove any trigger and set the led off. Then apply the
new trigger. So the validation is done only when a trigger is actually
applied. Think we should understand the best case here.
> > @@ -350,12 +381,26 @@ static inline bool led_sysfs_is_disabled(struct led_classdev *led_cdev)
> >
> > #define TRIG_NAME_MAX 50
> >
> > +enum led_trigger_blink_supported_modes {
> > + SOFTWARE_ONLY = SOFTWARE_CONTROLLED,
> > + HARDWARE_ONLY = HARDWARE_CONTROLLED,
> > + SOFTWARE_HARDWARE = SOFTWARE_HARDWARE_CONTROLLED,
>
> I suspect all these generic names are asking for eventual namespace
> clashes. Maybe prefix them with LED_ ?
Agree they are pretty generic so I can see why... My only concern was
making them too long... Maybe reduce them to SW or HW? LEDS_SW_ONLY...
LEDS_SW_CONTROLLED?
>
> Thanks.
>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
--
Ansuel
next prev parent reply other threads:[~2022-12-16 16:45 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 23:54 [PATCH v7 00/11] Adds support for PHY LEDs with offload triggers Christian Marangi
2022-12-14 23:54 ` [PATCH v7 01/11] leds: add support for hardware driven LEDs Christian Marangi
2022-12-15 16:13 ` Russell King (Oracle)
2022-12-16 16:45 ` Christian Marangi [this message]
2022-12-16 16:51 ` Russell King (Oracle)
2022-12-20 23:35 ` Andrew Lunn
2023-01-03 5:40 ` Bagas Sanjaya
2022-12-14 23:54 ` [PATCH v7 02/11] leds: add function to configure hardware controlled LED Christian Marangi
2022-12-15 16:30 ` Russell King (Oracle)
2022-12-16 16:58 ` Christian Marangi
2022-12-14 23:54 ` [PATCH v7 03/11] leds: trigger: netdev: drop NETDEV_LED_MODE_LINKUP from mode Christian Marangi
2022-12-14 23:54 ` [PATCH v7 04/11] leds: trigger: netdev: rename and expose NETDEV trigger enum modes Christian Marangi
2022-12-20 23:48 ` Andrew Lunn
2022-12-14 23:54 ` [PATCH v7 05/11] leds: trigger: netdev: convert device attr to macro Christian Marangi
2022-12-14 23:54 ` [PATCH v7 06/11] leds: trigger: netdev: add hardware control support Christian Marangi
2022-12-15 15:27 ` Alexander Stein
2022-12-16 17:00 ` Christian Marangi
2023-01-02 12:44 ` Alexander Stein
2022-12-15 17:07 ` Russell King (Oracle)
2022-12-16 17:09 ` Christian Marangi
2022-12-20 23:59 ` Andrew Lunn
2022-12-21 9:54 ` Russell King (Oracle)
2022-12-21 13:00 ` Christian Marangi
2022-12-21 13:10 ` Andrew Lunn
2022-12-14 23:54 ` [PATCH v7 07/11] leds: trigger: netdev: use mutex instead of spinlocks Christian Marangi
2022-12-14 23:54 ` [PATCH v7 08/11] leds: trigger: netdev: add available mode sysfs attr Christian Marangi
2022-12-14 23:54 ` [PATCH v7 09/11] leds: trigger: netdev: add additional hardware only triggers Christian Marangi
2022-12-15 17:35 ` Russell King (Oracle)
2022-12-16 17:17 ` Christian Marangi
2022-12-21 0:12 ` Andrew Lunn
2022-12-21 12:56 ` Christian Marangi
2022-12-14 23:54 ` [PATCH v7 10/11] net: dsa: qca8k: add LEDs support Christian Marangi
2022-12-15 3:54 ` Arun.Ramadoss
2022-12-15 17:49 ` Russell King (Oracle)
2022-12-16 17:48 ` Christian Marangi
2022-12-20 23:11 ` Andrew Lunn
2022-12-14 23:54 ` [PATCH v7 11/11] dt-bindings: net: dsa: qca8k: add LEDs definition example Christian Marangi
2022-12-20 17:39 ` Rob Herring
2022-12-20 23:20 ` Andrew Lunn
2022-12-21 1:41 ` Andrew Lunn
2022-12-21 12:54 ` Christian Marangi
2022-12-21 12:59 ` Andrew Lunn
2022-12-21 15:29 ` Rob Herring
2023-01-29 20:43 ` Sander Vanheule
2023-01-29 22:02 ` Andrew Lunn
2023-01-30 10:59 ` Sander Vanheule
2023-01-30 13:48 ` Andrew Lunn
2022-12-20 23:23 ` Andrew Lunn
2022-12-15 15:34 ` [PATCH v7 00/11] Adds support for PHY LEDs with offload triggers Alexander Stein
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=639ca0a4.050a0220.99395.8fd3@mx.google.com \
--to=ansuelsmth@gmail.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=andrew@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=john@phrozen.org \
--cc=kabel@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pavel@ucw.cz \
--cc=rasmus.villemoes@prevas.dk \
--cc=robh+dt@kernel.org \
--cc=tharvey@gateworks.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;
as well as URLs for NNTP newsgroup(s).