Skip to content

Commit 38f7d3b

Browse files
author
Patrice Chotard
committedOct 12, 2021
cmd: bind: Fix driver binding on a device
Fix a regression brings by commit 84f8e36 ("cmd: bind: allow to bind driver with driver data") As example, the following bind command doesn't work: bind /soc/usb-otg@49000000 usb_ether As usb_ether driver has no compatible string, it can't be find by lists_bind_fdt(). In bind_by_node_path(), which called lists_bind_fdt(), the driver entry is known, pass it to lists_bind_fdt() to force the driver entry selection. For this, add a new parameter struct *driver to lists_bind_fdt(). Fix also all lists_bind_fdt() callers. Fixes: 84f8e36 ("cmd: bind: allow to bind driver with driver data") Signed-off-by: Patrice Chotard <[email protected]> Reported-by: Herbert Poetzl <[email protected]> Cc: Marek Vasut <[email protected]> Cc: Herbert Poetzl <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Simon Glass <[email protected]>
1 parent 089e433 commit 38f7d3b

File tree

10 files changed

+13
-10
lines changed

10 files changed

+13
-10
lines changed
 

‎board/congatec/cgtqmx8/spl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void spl_board_init(void)
3232
offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "nxp,imx8-pd");
3333
while (offset != -FDT_ERR_NOTFOUND) {
3434
lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset),
35-
NULL, true);
35+
NULL, NULL, true);
3636
offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
3737
"nxp,imx8-pd");
3838
}

‎cmd/bind.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static int bind_by_node_path(const char *path, const char *drv_name)
152152
}
153153

154154
ofnode = ofnode_path(path);
155-
ret = lists_bind_fdt(parent, ofnode, &dev, false);
155+
ret = lists_bind_fdt(parent, ofnode, &dev, drv, false);
156156

157157
if (!dev || ret) {
158158
printf("Unable to bind. err:%d\n", ret);

‎drivers/core/device.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ int dev_enable_by_path(const char *path)
11351135
if (ret)
11361136
return ret;
11371137

1138-
return lists_bind_fdt(parent, node, NULL, false);
1138+
return lists_bind_fdt(parent, node, NULL, NULL, false);
11391139
}
11401140
#endif
11411141

‎drivers/core/lists.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static int driver_check_compatible(const struct udevice_id *of_match,
182182
}
183183

184184
int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
185-
bool pre_reloc_only)
185+
struct driver *drv, bool pre_reloc_only)
186186
{
187187
struct driver *driver = ll_entry_start(struct driver, driver);
188188
const int n_ents = ll_entry_count(struct driver, driver);
@@ -225,6 +225,8 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
225225
for (entry = driver; entry != driver + n_ents; entry++) {
226226
ret = driver_check_compatible(entry->of_match, &id,
227227
compat);
228+
if ((drv) && (drv == entry))
229+
break;
228230
if (!ret)
229231
break;
230232
}

‎drivers/core/root.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int dm_scan_fdt_node(struct udevice *parent, ofnode parent_node,
276276
pr_debug(" - ignoring disabled device\n");
277277
continue;
278278
}
279-
err = lists_bind_fdt(parent, node, NULL, pre_reloc_only);
279+
err = lists_bind_fdt(parent, node, NULL, NULL, pre_reloc_only);
280280
if (err && !ret) {
281281
ret = err;
282282
debug("%s: ret=%d\n", node_name, ret);

‎drivers/misc/imx8/scu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static int imx8_scu_bind(struct udevice *dev)
219219

220220
debug("%s(dev=%p)\n", __func__, dev);
221221
ofnode_for_each_subnode(node, dev_ofnode(dev)) {
222-
ret = lists_bind_fdt(dev, node, &child, true);
222+
ret = lists_bind_fdt(dev, node, &child, NULL, true);
223223
if (ret)
224224
return ret;
225225
debug("bind child dev %s\n", child->name);

‎drivers/serial/serial-uclass.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int serial_check_stdout(const void *blob, struct udevice **devp)
6969
* anyway.
7070
*/
7171
if (node > 0 && !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
72-
devp, false)) {
72+
devp, NULL, false)) {
7373
if (!device_probe(*devp))
7474
return 0;
7575
}

‎drivers/timer/timer-uclass.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ int notrace dm_timer_init(void)
146146
* If the timer is not marked to be bound before
147147
* relocation, bind it anyway.
148148
*/
149-
if (!lists_bind_fdt(dm_root(), node, &dev, false)) {
149+
if (!lists_bind_fdt(dm_root(), node, &dev, NULL, false)) {
150150
ret = device_probe(dev);
151151
if (ret)
152152
return ret;

‎include/dm/lists.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
5353
* @parent: parent device (root)
5454
* @node: device tree node to bind
5555
* @devp: if non-NULL, returns a pointer to the bound device
56+
* @drv: if non-NULL, force this driver to be bound
5657
* @pre_reloc_only: If true, bind only nodes with special devicetree properties,
5758
* or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
5859
* @return 0 if device was bound, -EINVAL if the device tree is invalid,
5960
* other -ve value on error
6061
*/
6162
int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
62-
bool pre_reloc_only);
63+
struct driver *drv, bool pre_reloc_only);
6364

6465
/**
6566
* device_bind_driver() - bind a device to a driver

‎test/dm/nop.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static int noptest_bind(struct udevice *parent)
2525
const char *bind_flag = ofnode_read_string(ofnode, "bind");
2626

2727
if (bind_flag && (strcmp(bind_flag, "True") == 0))
28-
lists_bind_fdt(parent, ofnode, &dev, false);
28+
lists_bind_fdt(parent, ofnode, &dev, NULL, false);
2929
ofnode = dev_read_next_subnode(ofnode);
3030
}
3131

0 commit comments

Comments
 (0)
Please sign in to comment.