[PATCH v3 1/3] dm: core: Bind another driver with the same compatible string

Michal Simek michal.simek at xilinx.com
Fri Oct 15 15:19:02 CEST 2021



On 10/14/21 17:09, Simon Glass wrote:
> Hi Michal,
> 
> On Wed, 6 Oct 2021 at 08:19, Michal Simek <michal.simek at xilinx.com> wrote:
>>
>> When one IP can have multiple configurations (like timer and PWM) covered
>> by multiple drivers. Because it is the same IP it should also have the same
>> compatible string.
>> Current code look for the first driver which matches compatible string and
>> call bind function. If this is not the right driver which is express by
>> returning -ENODEV ("Driver XYZ refuses to bind") there is no reason not to
>> continue over compatible list to try to find out different driver with the
>> same compatible string which match it.
>>
>> When the first compatible string is found core looks for driver bind()
>> function. If if assigned driver refuse to bind, core continue in a loop to
>> check if there is another driver which match compatible string.
>>
>> This driver is going to be used with cdnc,ttc driver which has driver as
>> timer and also can be used as PWM. The difference is done via #pwm-cells
>> property in DT.
>>
>> Signed-off-by: Michal Simek <michal.simek at xilinx.com>
>> ---
>>
>> Changes in v3:
>> - New patch in series
>>
>>   drivers/core/lists.c | 9 ++++++---
>>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> Can you refactor this to avoid the 'goto'? E.g. put the loop in a new function?

Sent v4 with adding one more loop. There are so many parameters use that 
new function won't really help.

> 
> Also, if pre_reloc_only, it still quits. Don't you want it to continue
> in that case too?

Also fixed in v4.

> 
> Finally, can you add such a driver to sandbox test.dts and add a check
> in test/dm/core.c or similar so that this behaviour is tested?

When the patch is acked I will take a look at writing test case for it.
I have tested it with pwm driver to see proper behavior.

Thanks,
Michal


More information about the U-Boot mailing list