[PATCH 1/1] dm: fix logic of lists_bind_fdt()

Simon Glass sjg at chromium.org
Tue Jul 26 21:52:54 CEST 2022


On 7/12/22 12:58, Simon Glass wrote:
> Hi Heinrich,
>
> On Mon, 11 Jul 2022 at 00:25, Heinrich Schuchardt
> <heinrich.schuchardt at canonical.com> wrote:
>>
>> If parameter drv of lists_bind_fdt() is specified, we shall bind only to
>> this very driver and to no other.
>>
>> If the driver drv has an of_match property, we shall only bind to the
>> driver if it matches the compatible string of the device.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
>> ---
>>   drivers/core/lists.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> Reviewed-by: Simon Glass <sjg at chromium.org>
>
> Any chance of a test for this case?
>
> Regards,
> Simon

Here are two examples that need to be fixed:

=> unbind /tpm2
=> bind /tpm2 pwm_sandbox
=> dm tree
  Class     Index  Probed  Driver                Name
-----------------------------------------------------------
  tpm           0  [   ]   sandbox_tpm2          `-- tpm2

tpm2 should not bind to another driver than the specified one.


=> unbind /tpm2
=> bind /tpm2 usb_ether
=> dm tree
  Class     Index  Probed  Driver                Name
-----------------------------------------------------------
  ethernet      8  [   ]   usb_ether             `-- tpm2

As tpm2 has a compatible string it should never bind to usb_ether.



The expected behavior is:

=> unbind /tpm2
=> bind /tpm2 pwm_sandbox
Unable to bind. err:0
=> bind /tpm2 usb_ether
Unable to bind. err:0



The patch needs some rework.

lists_bind_fdt() checks if the device has a compatible string. If not it
errors out with "Device '%s' has no compatible string\n".

If drv->of_match == NULL, we can equally error out because the driver
cannot be a match.

Best regards

Heinrich



Applied to u-boot-dm, thanks!


More information about the U-Boot mailing list