Re: [PATCH v5 15/16] leds: Add common LED binding parsing support to LED class/core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Matti,

On 11/19/19 8:21 AM, Vaittinen, Matti wrote:
> Hello Jacek,
> 
> On Mon, 2019-11-18 at 22:55 +0100, Jacek Anaszewski wrote:
>> Hi Matti,
>>
>> Thank you for the patch. If your driver does not depend
>> on it then please send is separately.
> 
> The BD71828 depends on device-tree node look-up. It does not utilize
> the common property parsing. I could of course do the child dt-node
> walking in BD71828 driver - but it kind of breaks my motivation to do
> the LED core improvement if I anyways need to do the parsing in BD71828
> driver ;)

If you do not plan on spending too much time on contributing this
set then I propose adhering to the currently used parsing schema :-)

And you have to know that from this development cycle I handed
over LED tree maintenance to Pavel Machek, so you will require
to have his acceptance in the first place.

>>  Besides, we would require
>> to convert many of current LED drivers to verify how the
>> proposed parsing mechanism will work with them.
> 
> I see the risk you are pointing out. And I actually think we could
> default to old mechanism if of_match or match_property is not given
> (for now). I could then see the existing drivers who use init_data -
> and ensure those are initializing the new match_property and of_match
> in init_data with 0. That would be quite trivial task.
> 
> That would allow us to convert and test existing drivers one-by-one
> while allowing new drivers to offload the LED node look-up and common
> property parsing to LED core. No risk, but less drivers to convert in
> the future - and simpler drivers to maintain when all of them do not
> need to duplicate node look-up or basic property parsing ;)

I personally would prefer to do the massive driver update to using
the new mechanism. I know that this is time consuming but we are not
in a hurry.

> To make this more concrete:
> 
> We can only do the new DT node look-up if either
> if (init_data->match_property.name && init_data->match_property.size)
> or
> if (init_data->of_match)
> That would keep the node-lookup same for all existing drivers.
> 
> Eg, 
> led_find_fwnode could for now just do:
> 
> struct fwnode_handle *led_find_fwnode(struct device *parent,
> 				      struct led_init_data *init_data)
> {
> 	/*
>         * This should never be called W/O init data.
> 	*/
> 	if (!init_data)
> 		return NULL;
> 
> 	/*
> 	 * For old drivers which do not populate new match information
> 	 * just directly use the given init_data->fwnode no matter if
> 	 * it is NULL or not. - as old functionality did.
> 	 */
> 	if ( (!init_data->match_property.name ||
> 	      !init_data->match_property.size) && !init_data->of_match)
> 		return init_data->fwnode;
> 
> 	/* match information was given - do node look-up */
> 	...
> }
> 
> Furthermore, the common property parsing could also be (for now) done
> only if match data is given:
> 
> 	/*
> 	 * For now only allow core to parse DT properties if
> 	 * parsing is explicitly requested by driver or if core has
> 	 * found new match data from init_data and then set the flag
> 	 */
> 	if (INVENT_A_COOL_NEW_FLAG_NAME_HERE)
> 		led_add_props(led_cdev, &props);
> 
> or just simply: 
> 	if ((init_data->match_property.name &&
> 	    init_data->match_property.size) || init_data->of_match)
> 		led_add_props(led_cdev, &props);
> 
> (but this won't allow driver to ask for common parsing even if it was
> verified for this drv to work - hence I like the flag better)
> 
> And if you don't feel confident I can even drop the "common property
> parsing" from the series and leave only the "node look-up if match-data 
> was given" to it.
> 
> Anyways, I would like to introduce this support while I am working with
> the BD71828 driver which really has the LEDs - but I can modify the
> patch series so that it only impacts to drivers which implement the new
> match data in init_data and leave old drivers to be converted one-by-
> one when they can be tested.
> 
>>  I've been testing
>> my LED name composition series using QEMU and stubbing things in
>> drivers where necessary and I propose to use the same approach
>> in this case.
> 
> I don't plan to do any mass-conversion as it is somewhat risky. I can

You do not need hardware to test DT parsing as I mentioned before,
so I don't see too much risk involved.

> do conversion to some of the drivers (simple ones which I can
> understand without too much of pain) - and ask if anyone having access
> to actual HW with LEDs could be kind enough to test the patch for the
> device. Tested drivers can then be taken in-tree as examples. And who
> knows, maybe there is some developers looking for a hobby project with
> access to LED controller to help with the rest ;) I don't have the
> ambition to change all of the LED drivers but I think I can give my 10
> cents by contributing the mechanism and doing few examples :)

If you want to introduce good, robust mechanism, then it should be
tested against widest possible spectrum of use cases.

> Anyways, please let me know if you think you could accept patch which
> won't change existing driver functionality - but allows new drivers to
> not duplicate the code. Else I'll just duplicate the lookup code in one
> more driver and hope I don't have another PMIC with LED controller on
> my table too soon...
> 
> (I am having "some" pressure to do few other tasks I recently got. So I
> am afraid I won't have too much time to invest on LEDs this year :(
> Thus setting up the qemu and starting with stubbing is really not an
> option for me at this phase).

As mentioned before - I no longer apply patches so you will need to
consult Pavel, but I bet he will have similar opinion.

-- 
Best regards,
Jacek Anaszewski



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux