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

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@canonical.com --- drivers/core/lists.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 93514a744d..c49695b24f 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -223,10 +223,14 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, compat);
for (entry = driver; entry != driver + n_ents; entry++) { + if (drv) { + if (drv != entry) + continue; + if (!entry->of_match) + break; + } ret = driver_check_compatible(entry->of_match, &id, compat); - if ((drv) && (drv == entry)) - break; if (!ret) break; }

Hi Heinrich,
On Mon, 11 Jul 2022 at 00:25, Heinrich Schuchardt heinrich.schuchardt@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@canonical.com
drivers/core/lists.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Any chance of a test for this case?
Regards, Simon

On 7/12/22 12:58, Simon Glass wrote:
Hi Heinrich,
On Mon, 11 Jul 2022 at 00:25, Heinrich Schuchardt heinrich.schuchardt@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@canonical.com
drivers/core/lists.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@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

On 7/12/22 12:58, Simon Glass wrote:
Hi Heinrich,
On Mon, 11 Jul 2022 at 00:25, Heinrich Schuchardt heinrich.schuchardt@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@canonical.com
drivers/core/lists.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@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!
participants (2)
-
Heinrich Schuchardt
-
Simon Glass