[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 9 Sep 2020 22:58:55 +0200
From: Pavel Machek <pavel@....cz>
To: Jacek Anaszewski <jacek.anaszewski@...il.com>
Cc: linux-leds@...r.kernel.org, devicetree@...r.kernel.org,
Dan Murphy <dmurphy@...com>, Rob Herring <robh+dt@...nel.org>,
linux-kernel@...r.kernel.org, Alexander Dahl <ada@...rsis.com>
Subject: Re: [PATCH v3 1/2] leds: pwm: Allow automatic labels for DT based
devices
Hi!
> >>> pwm_init_state(led_data->pwm, &led_data->pwmstate);
> >>>- ret = devm_led_classdev_register(dev, &led_data->cdev);
> >>>+ if (fwnode) {
> >>>+ init_data.fwnode = fwnode;
> >>>+ ret = devm_led_classdev_register_ext(dev, &led_data->cdev,
> >>>+ &init_data);
> >>>+ } else {
> >>>+ ret = devm_led_classdev_register(dev, &led_data->cdev);
> >>>+ }
> >>
> >>Can you always use _ext version, even with null fwnode?
> >
> >I did not try on real hardware, but from reading the code I would say
> >the following would happen: led_classdev_register_ext() calls
> >led_compose_name(parent, init_data, composed_name) which itself calls
> >led_parse_fwnode_props(dev, fwnode, &props); that returns early due to
> >fwnode==NULL without changing props, thus this stays as initialized
> >with {}, so led_compose_name() would return -EINVAL which would let
> >led_classdev_register_ext() fail, too.
> >
> >>If not, can you fix the core to accept that? Having that conditional
> >>in driver is ugly.
> >
> >It is ugly, although the approach is inspired by the leds-gpio driver.
> >I'll see if I can come up with a change to led-core, but I'm also open
> >for suggestions. ;-)
>
> devm_led_classdev_register() calls devm_led_classdev_register_ext()
> with NULL passed in place of init_data, so you could do something like
> below to achieve the same without touching LED core:
>
> struct led_init_data init_data_impl = { .fwnode = fwnode };
> struct led_init_data *init_data = NULL;
>
> if (fwnode)
> init_data = &init_data_impl;
>
> devm_led_classdev_register_ext(dev, &led_data->cdev, init_data);
Umm.. This is not too great, either. Maybe I'd really prefer the
change to the LED core.
> >fyi: Peter Ujfalusi answered and would give his Ack to the changed
> >dual license for the yaml file. You can expect that for v4.
Good :-).
Best regards,
pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)
Powered by blists - more mailing lists