Message ID | 20200919053145.7564-1-post@lespocky.de |
---|---|
Headers | show |
Series | leds: pwm: Make automatic labels work | expand |
Hi! > Since commit 141f15c66d94 ("leds: pwm: remove header") that platform > interface is not usable from outside and there seems to be no in tree > user anymore. All in-tree users of the leds-pwm driver seem to use DT > currently. Getting rid of the old platform interface will allow the > leds-pwm driver to switch over from 'devm_led_classdev_register()' to > 'devm_led_classdev_register_ext()' later. > @@ -61,6 +56,7 @@ static int led_pwm_set(struct led_classdev *led_cdev, > return pwm_apply_state(led_dat->pwm, &led_dat->pwmstate); > } > > +__attribute__((nonnull)) > static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, > struct led_pwm *led, struct fwnode_handle *fwnode) > { This normally goes elsewhere -- right? I'd expect: static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, struct led_pwm *led, struct fwnode_handle *fwnode) __attribute__((nonnull)) Best regards, Pavel
On Sat 2020-09-19 07:31:44, Alexander Dahl wrote: > If LEDs are configured through device tree and the property 'label' is > omitted, the label is supposed to be generated from the properties > 'function' and 'color' if present. While this works fine for e.g. the > 'leds-gpio' driver, it did not for 'leds-pwm'. > > The reason is, you get this label naming magic only if you add a LED > device through 'devm_led_classdev_register_ext()' and pass a pointer to > the current device tree node. > > For the following node from dts the LED appeared as 'led-5' in sysfs > before and as 'red:debug' after this change. Thanks, applied. Pavel
Besides Pavel's note about the __attribute__((nonnull)) position
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Hello Pavel, Am Samstag, 19. September 2020, 11:44:18 CEST schrieb Pavel Machek: > > Since commit 141f15c66d94 ("leds: pwm: remove header") that platform > > interface is not usable from outside and there seems to be no in tree > > user anymore. All in-tree users of the leds-pwm driver seem to use DT > > currently. Getting rid of the old platform interface will allow the > > leds-pwm driver to switch over from 'devm_led_classdev_register()' to > > 'devm_led_classdev_register_ext()' later. > > > > @@ -61,6 +56,7 @@ static int led_pwm_set(struct led_classdev *led_cdev, > > > > return pwm_apply_state(led_dat->pwm, &led_dat->pwmstate); > > > > } > > > > +__attribute__((nonnull)) > > > > static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, > > > > struct led_pwm *led, struct fwnode_handle *fwnode) > > > > { > > This normally goes elsewhere -- right? I'd expect: > > > static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, > struct led_pwm *led, struct fwnode_handle *fwnode) > __attribute__((nonnull)) I found both variants in kernel code. I can live with both variants and have no strong preference. My initial intention to add it was to get a compiler warning in case someone does not pass a fwnode here, e.g. when using that old platform_data approach (which is supposed to be removed with this patch). You might call it a self check on my own changes. I can also drop that attribute if you don't want that kind of stuff in linux-leds. Greets Alex
Hi! > > > +__attribute__((nonnull)) > > > > > > static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, > > > > > > struct led_pwm *led, struct fwnode_handle *fwnode) > > > > > > { > > > > This normally goes elsewhere -- right? I'd expect: > > > > > > static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, > > struct led_pwm *led, struct fwnode_handle *fwnode) > > __attribute__((nonnull)) > > I found both variants in kernel code. I can live with both variants and have > no strong preference. > > My initial intention to add it was to get a compiler warning in case someone > does not pass a fwnode here, e.g. when using that old platform_data approach > (which is supposed to be removed with this patch). You might call it a self > check on my own changes. I can also drop that attribute if you don't want > that kind of stuff in linux-leds. I'm okay with it at the second place :-). Thanks, Pavel
Hello Pavel, On Wed, Sep 30, 2020 at 07:24:41PM +0200, Pavel Machek wrote: > Hi! > > > > > +__attribute__((nonnull)) > > > > > > > > static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, > > > > > > > > struct led_pwm *led, struct fwnode_handle *fwnode) > > > > > > > > { > > > > > > This normally goes elsewhere -- right? I'd expect: > > > > > > > > > static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, > > > struct led_pwm *led, struct fwnode_handle *fwnode) > > > __attribute__((nonnull)) > > > > I found both variants in kernel code. I can live with both variants and have > > no strong preference. > > > > My initial intention to add it was to get a compiler warning in case someone > > does not pass a fwnode here, e.g. when using that old platform_data approach > > (which is supposed to be removed with this patch). You might call it a self > > check on my own changes. I can also drop that attribute if you don't want > > that kind of stuff in linux-leds. > > I'm okay with it at the second place :-). Should have tried this before, but I actually did now. O:-) If I move the attribute behind, I get this on a W=1 build: CC drivers/leds/leds-pwm.o /home/alex/src/linux/leds/drivers/leds/leds-pwm.c:58:1: error: attributes should be specified before the declarator in a function definition static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, ^~~~~~ Because it won't build then, I'll keep it where it is. Meanwhile I worked on all the DT remarks by Rob and I will send v6 soon. Greets Alex