dm: Simplify livetree handling
Subsystems (17)
cover dm: Simplify livetree handling
At present there are separate code paths for livetree and flattree in places where they can be made common. Also there are a few functions that support flattree but can be moved over to use the livetree API (i.e. ofnode instead of a DT offset).
This series tidies up these areas.
Simon Glass (11):
dm: core: Rename device_bind() to device_bind_offset()
dm: core: Rename device_bind_ofnode() to device_bind()
dm: core: Add a livetree function to check node status
dm: Remove uses of device_bind_offset()
dm: Drop uses of dev_set_of_offset()
dm: core: Drop dev_set_of_offset()
dm: core: Drop device_bind_offset()
dm: core: Add an ofnode function to get the devicetree root
dm: core: Combine the flattree and livetree binding code
dm: core: Drop unused parameter from dm_scan_fdt()
dm: core: Drop unused parameter from dm_extended_scan_fdt()
drivers/clk/at91/compat.c | 20 ++--- drivers/clk/clk.c | 2 +- drivers/core/device.c | 10 +-- drivers/core/ofnode.c | 10 +++ drivers/core/root.c | 97 ++++++--------------- drivers/firmware/scmi/scmi_agent-uclass.c | 4 +- drivers/gpio/dwapb_gpio.c | 4 +- drivers/gpio/mt7621_gpio.c | 5 +- drivers/gpio/s5p_gpio.c | 6 +- drivers/gpio/sunxi_gpio.c | 5 +- drivers/gpio/tegra186_gpio.c | 3 +- drivers/gpio/tegra_gpio.c | 4 +- drivers/misc/i2c_eeprom.c | 4 +- drivers/mtd/spi/sandbox.c | 2 +- drivers/net/mvpp2.c | 4 +- drivers/pci/pci-uclass.c | 4 +- drivers/pci/pci_mvebu.c | 4 +- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 2 +- drivers/pinctrl/meson/pinctrl-meson.c | 5 +- drivers/pinctrl/mscc/pinctrl-jr2.c | 2 +- drivers/pinctrl/mscc/pinctrl-luton.c | 2 +- drivers/pinctrl/mscc/pinctrl-ocelot.c | 2 +- drivers/pinctrl/mscc/pinctrl-serval.c | 2 +- drivers/pinctrl/mscc/pinctrl-servalt.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 +- drivers/usb/host/usb-uclass.c | 4 +- include/dm/device-internal.h | 10 +-- include/dm/device.h | 5 -- include/dm/ofnode.h | 23 +++++ include/dm/root.h | 8 +- test/dm/core.c | 6 +- test/dm/ofnode.c | 12 +++ test/dm/test-fdt.c | 4 +- test/dm/test-main.c | 4 +- 34 files changed, 130 insertions(+), 159 deletions(-)
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 1/11 dm: core: Rename device_bind() to device_bind_offset()
This function is not necessary anymore, since device_bind_ofnode() does the same thing and works with both flattree and livetree.
Rename it to indicate that it is special.
---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/clk.c | 2 +- drivers/core/device.c | 6 +++--- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 5 +++-- drivers/net/mvpp2.c | 2 +- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 +++-- drivers/pinctrl/meson/pinctrl-meson.c | 2 +- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 ++-- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 8 ++++---- include/power/regulator.h | 2 +- 20 files changed, 39 insertions(+), 37 deletions(-)
arch/x86/cpu/apollolake/spl.c +1 -1
@@ -86,7 +86,7 @@ static int apl_flash_probe(struct udevice *dev)/* * Manually set the parent of the SPI flash to SPI, since dtoc doesn't. We also * need to allocate the parent_platdata since by the time this function is -* called device_bind() has already gone past that step. +* called device_bind_offset() has already gone past that step. */ static int apl_flash_bind (struct udevice *dev) {
drivers/clk/clk.c +1 -1
@@ -36,7 +36,7 @@ int clk_register(struct clk *clk, const char *drv_name,return -ENOENT ; } - ret =device_bind (parent, drv, name,NULL ,-1 , &clk->dev); + ret =device_bind_offset (parent, drv, name,NULL ,-1 , &clk->dev);if (ret) {printf ("%s: CLK: %s driver bind error [%d]!\n" , __func__, name, ret);
drivers/core/device.c +3 -3
@@ -232,9 +232,9 @@ int device_bind_with_driver_data(struct udevice *parent, 0, devp); } -int device_bind (struct udevice *parent,const struct driver *drv, -const char *name,void *platdata,int of_offset, -struct udevice **devp) +int device_bind_offset (struct udevice *parent,const struct driver *drv, +const char *name,void *platdata,int of_offset, +struct udevice **devp) {return device_bind_common (parent, drv, name, platdata,0 ,offset_to_ofnode (of_offset),0 , devp);
drivers/gpio/mt7621_gpio.c +2 -2
@@ -157,8 +157,8 @@ static int gpio_mediatek_bind(struct udevice *parent) plat->gpio_count =MTK_BANK_WIDTH ; plat->bank = bank; - ret =device_bind (parent, parent->driver, - plat->bank_name, plat,-1 , &dev); + ret =device_bind_offset (parent, parent->driver, + plat->bank_name, plat,-1 , &dev);if (ret)return ret;
drivers/gpio/s5p_gpio.c +2 -2
@@ -332,8 +332,8 @@ static int gpio_exynos_bind(struct udevice *parent)return -ENOMEM ; plat->bank_name =fdt_get_name (blob, node,NULL ); - ret =device_bind (parent, parent->driver, - plat->bank_name, plat,-1 , &dev); + ret =device_bind_offset (parent, parent->driver, + plat->bank_name, plat,-1 , &dev);if (ret)return ret;
drivers/gpio/sunxi_gpio.c +2 -2
@@ -305,8 +305,8 @@ static int gpio_sunxi_bind(struct udevice *parent) plat->bank_name =gpio_bank_name (soc_data->start + bank); plat->gpio_count =SUNXI_GPIOS_PER_BANK ; - ret =device_bind (parent, parent->driver, - plat->bank_name, plat,-1 , &dev); + ret =device_bind_offset (parent, parent->driver, + plat->bank_name, plat,-1 , &dev);if (ret)return ret;dev_set_of_offset (dev,dev_of_offset (parent));
drivers/gpio/tegra186_gpio.c +2 -2
@@ -190,8 +190,8 @@ static int tegra186_gpio_bind(struct udevice *parent) plat->name = ctlr_data->ports[port].name; plat->regs = &(regs[ctlr_data->ports[port].offset /4 ]); - ret =device_bind (parent, parent->driver, plat->name, plat, --1 , &dev); + ret =device_bind_offset (parent, parent->driver, plat->name, + plat,-1 , &dev);if (ret)return ret;dev_set_of_offset (dev,dev_of_offset (parent));
drivers/gpio/tegra_gpio.c +3 -2
@@ -360,8 +360,9 @@ static int gpio_tegra_bind(struct udevice *parent) plat->base_gpio =TEGRA_GPIOS_PER_PORT * base_port; plat->port_name =gpio_port_name (base_port); - ret =device_bind (parent, parent->driver, - plat->port_name, plat,-1 , &dev); + ret =device_bind_offset (parent, parent->driver, + plat->port_name, plat,-1 , + &dev);if (ret)return ret;dev_set_of_offset (dev,dev_of_offset (parent));
drivers/net/mvpp2.c +1 -1
@@ -5477,7 +5477,7 @@ static int mvpp2_base_bind(struct udevice *parent)sprintf (name,"mvpp2-%d" , id);/* Create child device UCLASS_ETH and bind it */ -device_bind (parent, &mvpp2_driver, name, plat, subnode, &dev); +device_bind_offset (parent, &mvpp2_driver, name, plat, subnode, &dev);dev_set_of_offset (dev, subnode); }
drivers/pinctrl/broadcom/pinctrl-bcm283x.c +3 -2
@@ -125,8 +125,9 @@ int bcm283x_pinctl_probe(struct udevice *dev)struct udevice *pdev;/* Create GPIO device as well */ - ret =device_bind (dev,lists_driver_lookup_name ("gpio_bcm2835" ), -"gpio_bcm2835" ,NULL ,dev_of_offset (dev), &pdev); + ret =device_bind_offset (dev,lists_driver_lookup_name ("gpio_bcm2835" ), +"gpio_bcm2835" ,NULL ,dev_of_offset (dev), + &pdev);if (ret) {/* * While we really want the pinctrl driver to work to make
drivers/pinctrl/meson/pinctrl-meson.c +1 -1
@@ -419,7 +419,7 @@ int meson_pinctrl_probe(struct udevice *dev)sprintf (name,"meson-gpio" );/* Create child device UCLASS_GPIO and bind it */ -device_bind (dev, priv->data->gpio_driver, name,NULL , gpio, &gpio_dev); +device_bind_offset (dev, priv->data->gpio_driver, name,NULL , gpio, &gpio_dev);dev_set_of_offset (gpio_dev, gpio);return 0 ;
drivers/pinctrl/mscc/pinctrl-jr2.c +2 -2
@@ -299,8 +299,8 @@ static int jr2_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind (dev, &jr2_gpio_driver,"jr2-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind_offset (dev, &jr2_gpio_driver,"jr2-gpio" ,NULL , +dev_of_offset (dev),NULL );if (ret)return ret;
drivers/pinctrl/mscc/pinctrl-luton.c +2 -2
@@ -165,8 +165,8 @@ int luton_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind (dev, &luton_gpio_driver,"luton-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind_offset (dev, &luton_gpio_driver,"luton-gpio" ,NULL , +dev_of_offset (dev),NULL );return 0 ; }
drivers/pinctrl/mscc/pinctrl-ocelot.c +2 -2
@@ -181,8 +181,8 @@ int ocelot_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind (dev, &ocelot_gpio_driver,"ocelot-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind_offset (dev, &ocelot_gpio_driver,"ocelot-gpio" ,NULL , +dev_of_offset (dev),NULL );return ret; }
drivers/pinctrl/mscc/pinctrl-serval.c +2 -2
@@ -209,8 +209,8 @@ static int serval_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind (dev, &serval_gpio_driver,"serval-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind_offset (dev, &serval_gpio_driver,"serval-gpio" ,NULL , +dev_of_offset (dev),NULL );if (ret)return ret;
drivers/pinctrl/mscc/pinctrl-servalt.c +2 -2
@@ -245,8 +245,8 @@ static int servalt_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind (dev, &servalt_gpio_driver,"servalt-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind_offset (dev, &servalt_gpio_driver,"servalt-gpio" ,NULL , +dev_of_offset (dev),NULL );if (ret)return ret;
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +2 -2
@@ -567,8 +567,8 @@ static int armada_37xx_gpiochip_register(struct udevice *parent,sprintf (name,"armada-37xx-gpio" );/* Create child device UCLASS_GPIO and bind it */ -device_bind (parent, &armada_37xx_gpio_driver, name,NULL , subnode, - &dev); +device_bind_offset (parent, &armada_37xx_gpio_driver, name,NULL , + subnode, &dev);dev_set_of_offset (dev, subnode);return 0 ;
drivers/power/regulator/Kconfig +1 -1
@@ -11,7 +11,7 @@ config DM_REGULATOR - 'include/power/regulator.h' - 'drivers/power/pmic/pmic-uclass.c' - 'drivers/power/pmic/regulator-uclass.c' - It's important to call the device_bind() with the proper node offset, + It's important to call the device_bind_offset() with the proper node offset, when binding the regulator devices. The pmic_bind_childs() can be used for this purpose if PMIC I/O driver is implemented or dm_scan_fdt_dev() otherwise. Detailed information can be found in the header file.
include/dm/device-internal.h +4 -4
@@ -16,7 +16,7 @@ struct device_node;struct udevice ;/** -* device_bind() - Create a device and bind it to a driver +* device_bind_offset() - Create a device and bind it to a driver * * Called to set up a new device attached to a driver. The device will either * have platdata, or a device tree node which can be used to create the
@@ -36,9 +36,9 @@ struct udevice;* @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ -int device_bind (struct udevice *parent,const struct driver *drv, -const char *name,void *platdata,int of_offset, -struct udevice **devp); +int device_bind_offset (struct udevice *parent,const struct driver *drv, +const char *name,void *platdata,int of_offset, +struct udevice **devp); int device_bind_ofnode(struct udevice *parent, const struct driver *drv, const char *name, void *platdata, ofnode node,
include/power/regulator.h +1 -1
@@ -48,7 +48,7 @@* If regulator-name property is not provided, node name will be chosen. * * Regulator bind: -* For each regulator device, the device_bind() should be called with passed +* For each regulator device, the device_bind_offset() should be called with passed * device tree offset. This is required for this uclass's '.post_bind' method, * which does the scan on the device node, for the 'regulator-name' constraint. * If the parent is not a PMIC device, and the child is not bind by function:
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 1/11 dm: core: Rename device_bind() to device_bind_offset()
This function is not necessary anymore, since device_bind_ofnode() does the same thing and works with both flattree and livetree.
Rename it to indicate that it is special.
---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/clk.c | 2 +- drivers/core/device.c | 6 +++--- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 5 +++-- drivers/net/mvpp2.c | 2 +- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 +++-- drivers/pinctrl/meson/pinctrl-meson.c | 2 +- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 ++-- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 8 ++++---- include/power/regulator.h | 2 +- 20 files changed, 39 insertions(+), 37 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 2/11 dm: core: Rename device_bind_ofnode() to device_bind()
In reply to Simon GlassThis is the standard function to use when binding devices. Drop the '_ofnode' suffix to make this clear.
---
drivers/core/device.c | 6 +++--- drivers/firmware/scmi/scmi_agent-uclass.c | 4 ++-- drivers/gpio/dwapb_gpio.c | 4 ++-- drivers/misc/i2c_eeprom.c | 4 ++-- drivers/mtd/spi/sandbox.c | 2 +- drivers/pci/pci-uclass.c | 4 ++-- drivers/pci/pci_mvebu.c | 4 ++-- drivers/usb/host/usb-uclass.c | 4 ++-- include/dm/device-internal.h | 6 +++--- test/dm/core.c | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-)
drivers/core/device.c +3 -3
@@ -240,9 +240,9 @@ int device_bind_offset(struct udevice *parent, const struct driver *drv, offset_to_ofnode(of_offset), 0, devp); } -int device_bind_ofnode (struct udevice *parent,const struct driver *drv, -const char *name,void *platdata,ofnode node, -struct udevice **devp) +int device_bind (struct udevice *parent,const struct driver *drv, +const char *name,void *platdata,ofnode node, +struct udevice **devp) {return device_bind_common (parent, drv, name, platdata,0 , node,0 , devp);
drivers/firmware/scmi/scmi_agent-uclass.c +2 -2
@@ -89,8 +89,8 @@ static int scmi_bind_protocols(struct udevice *dev)continue ; } - ret =device_bind_ofnode (dev, drv,ofnode_get_name (node), -NULL , node,NULL ); + ret =device_bind (dev, drv,ofnode_get_name (node),NULL , node, +NULL );if (ret)break ; }
drivers/gpio/dwapb_gpio.c +2 -2
@@ -202,8 +202,8 @@ static int gpio_dwapb_bind(struct udevice *dev) } } - ret =device_bind_ofnode (dev, dev->driver, plat->name, - plat, node, &subdev); + ret =device_bind (dev, dev->driver, plat->name, plat, node, + &subdev);if (ret)return ret;
drivers/misc/i2c_eeprom.c +2 -2
@@ -131,8 +131,8 @@ static int i2c_eeprom_std_bind(struct udevice *dev)if (!name)continue ; -device_bind_ofnode (dev,DM_GET_DRIVER (i2c_eeprom_partition), - name,NULL , partition,NULL ); +device_bind (dev,DM_GET_DRIVER (i2c_eeprom_partition), name, +NULL , partition,NULL ); }return 0 ;
drivers/mtd/spi/sandbox.c +1 -1
@@ -538,7 +538,7 @@ int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs, str =strdup (name);if (!str)return -ENOMEM ; - ret =device_bind_ofnode (bus, drv, str,NULL , node, &emul); + ret =device_bind (bus, drv, str,NULL , node, &emul);if (ret) {free (str); printf("Cannot create emul device for spec '%s' (err=%d)\n",
drivers/pci/pci-uclass.c +2 -2
@@ -750,8 +750,8 @@ static int pci_find_and_bind_driver(struct udevice *parent,* find another driver. For now this doesn't seem * necesssary, so just bind the first match. */ - ret =device_bind_ofnode (parent, drv, drv->name,NULL , - node, &dev); + ret =device_bind (parent, drv, drv->name,NULL , node, + &dev);if (ret) goto error;debug ("%s: Match found: %s\n" , __func__, drv->name);
drivers/pci/pci_mvebu.c +2 -2
@@ -501,8 +501,8 @@ static int mvebu_pcie_bind(struct udevice *parent)return -ENOMEM ;/* Create child device UCLASS_PCI and bind it */ -device_bind_ofnode (parent, &pcie_mvebu_drv, pcie->name, pcie, - subnode, &dev); +device_bind (parent, &pcie_mvebu_drv, pcie->name, pcie, subnode, + &dev); }return 0 ;
drivers/usb/host/usb-uclass.c +2 -2
@@ -581,8 +581,8 @@ static int usb_find_and_bind_driver(struct udevice *parent,* find another driver. For now this doesn't seem * necesssary, so just bind the first match. */ - ret =device_bind_ofnode (parent, drv, drv->name,NULL , - node, &dev); + ret =device_bind (parent, drv, drv->name,NULL , node, + &dev);if (ret) goto error;debug ("%s: Match found: %s\n" , __func__, drv->name);
include/dm/device-internal.h +3 -3
@@ -40,9 +40,9 @@ int device_bind_offset(struct udevice *parent, const struct driver *drv, const char *name, void *platdata, int of_offset, struct udevice **devp); -int device_bind_ofnode (struct udevice *parent,const struct driver *drv, -const char *name,void *platdata,ofnode node, -struct udevice **devp); +int device_bind (struct udevice *parent,const struct driver *drv, +const char *name,void *platdata,ofnode node, +struct udevice **devp);/** * device_bind_with_driver_data() - Create a device and bind it to a driver
test/dm/core.c +2 -2
@@ -1052,8 +1052,8 @@ static int dm_test_inactive_child(struct unit_test_state *uts)*/ ut_asserteq (-ENODEV ,device_find_first_inactive_child (parent,UCLASS_TEST , &dev1)); -ut_assertok (device_bind_ofnode (parent,DM_GET_DRIVER (test_drv), -"test_child" ,0 ,ofnode_null (), &dev1)); +ut_assertok (device_bind (parent,DM_GET_DRIVER (test_drv), +"test_child" ,0 ,ofnode_null (), &dev1));ut_assertok (device_find_first_inactive_child (parent,UCLASS_TEST , &dev2));
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 2/11 dm: core: Rename device_bind_ofnode() to device_bind()
This is the standard function to use when binding devices. Drop the '_ofnode' suffix to make this clear.
---
drivers/core/device.c | 6 +++--- drivers/firmware/scmi/scmi_agent-uclass.c | 4 ++-- drivers/gpio/dwapb_gpio.c | 4 ++-- drivers/misc/i2c_eeprom.c | 4 ++-- drivers/mtd/spi/sandbox.c | 2 +- drivers/pci/pci-uclass.c | 4 ++-- drivers/pci/pci_mvebu.c | 4 ++-- drivers/usb/host/usb-uclass.c | 4 ++-- include/dm/device-internal.h | 6 +++--- test/dm/core.c | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 3/11 dm: core: Add a livetree function to check node status
In reply to Simon GlassAdd a way to find out if a node is enabled or not, based on its 'status' property.
---
drivers/core/ofnode.c | 10 ++++++++++ include/dm/ofnode.h | 11 +++++++++++ test/dm/ofnode.c | 12 ++++++++++++ 3 files changed, 33 insertions(+)
drivers/core/ofnode.c +10 -0
@@ -226,6 +226,16 @@ int ofnode_read_u32_array(ofnode node, const char *propname, } } +bool ofnode_is_enabled (ofnode node) +{ +if (ofnode_is_np (node)) { +return of_device_is_available (ofnode_to_np (node)); + }else { +return fdtdec_get_is_enabled (gd->fdt_blob, +ofnode_to_offset (node)); + } +} +ofnode ofnode_first_subnode (ofnode node) {assert (ofnode_valid (node));
include/dm/ofnode.h +11 -0
@@ -345,6 +345,17 @@ const char *ofnode_read_string(ofnode node, const char *propname);*/ int ofnode_read_u32_array (ofnode node,const char *propname,u32 *out_values,size_t sz); +/** +* ofnode_is_enabled() - Checks whether a node is enabled. +* This looks for a 'status' property. If this exists, then returns true if +* the status is 'okay' and false otherwise. If there is no status property, +* it returns true on the assumption that anything mentioned should be enabled +* by default. +* +* @node: node to examine +* @return false (not enabled) or true (enabled) +*/ +bool ofnode_is_enabled (ofnode node);/** * ofnode_read_bool() - read a boolean value from a property
test/dm/ofnode.c +12 -0
@@ -249,3 +249,15 @@ static int dm_test_ofnode_get_child_count(struct unit_test_state *uts) }DM_TEST (dm_test_ofnode_get_child_count,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT ); + +static int dm_test_ofnode_is_enabled (struct unit_test_state *uts) +{ +ofnode root_node =ofnode_path ("/" ); +ofnode node =ofnode_path ("/usb at 0" ); + +ut_assert (ofnode_is_enabled (root_node)); +ut_assert (!ofnode_is_enabled (node)); + +return 0 ; +} +DM_TEST (dm_test_ofnode_is_enabled,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT );
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 3/11 dm: core: Add a livetree function to check node status
Add a way to find out if a node is enabled or not, based on its 'status' property.
---
drivers/core/ofnode.c | 10 ++++++++++ include/dm/ofnode.h | 11 +++++++++++ test/dm/ofnode.c | 12 ++++++++++++ 3 files changed, 33 insertions(+)
Applied to u-boot-dm, thanks!
PATCH 4/11 dm: Remove uses of device_bind_offset()
In reply to Simon GlassThis function is not needed since the standard device_bind() can be used instead.
---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/at91/compat.c | 20 ++++++++------------ drivers/clk/clk.c | 2 +- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 6 +++--- drivers/net/mvpp2.c | 4 ++-- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 4 +++- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-)
arch/x86/cpu/apollolake/spl.c +1 -1
@@ -86,7 +86,7 @@ static int apl_flash_probe(struct udevice *dev)/* * Manually set the parent of the SPI flash to SPI, since dtoc doesn't. We also * need to allocate the parent_platdata since by the time this function is -* called device_bind_offset() has already gone past that step. +* called device_bind() has already gone past that step. */ static int apl_flash_bind (struct udevice *dev) {
drivers/clk/at91/compat.c +8 -12
@@ -62,34 +62,30 @@ static int at91_pmc_core_probe(struct udevice *dev)*/ int at91_clk_sub_device_bind (struct udevice *dev,const char *drv_name) { -const void *fdt = gd->fdt_blob; -int offset =dev_of_offset (dev); +ofnode parent =dev_ofnode (dev); +ofnode node;bool pre_reloc_only = !(gd->flags &GD_FLG_RELOC );const char *name;int ret; -for (offset =fdt_first_subnode (fdt, offset); - offset >0 ; - offset =fdt_next_subnode (fdt, offset)) { -if (pre_reloc_only && - !ofnode_pre_reloc (offset_to_ofnode (offset))) +ofnode_for_each_subnode (node, parent) { +if (pre_reloc_only && !ofnode_pre_reloc (node))continue ;/* * If this node has "compatible" property, this is not * a clock sub-node, but a normal device. skip. */ -fdt_get_property (fdt, offset,"compatible" , &ret); -if (ret >=0 ) +if (ofnode_read_prop (node,"compatible" ,NULL ))continue ;if (ret != -FDT_ERR_NOTFOUND )return ret; - name =fdt_get_name (fdt, offset,NULL ); + name =ofnode_get_name (node);if (!name)return -EINVAL ; - ret =device_bind_driver_to_node (dev, drv_name, name, -offset_to_ofnode (offset),NULL ); + ret =device_bind_driver_to_node (dev, drv_name, name, node, +NULL );if (ret)return ret; }
drivers/clk/clk.c +1 -1
@@ -36,7 +36,7 @@ int clk_register(struct clk *clk, const char *drv_name,return -ENOENT ; } - ret =device_bind_offset (parent, drv, name,NULL ,-1 , &clk->dev); + ret =device_bind (parent, drv, name,NULL ,ofnode_null (), &clk->dev);if (ret) {printf ("%s: CLK: %s driver bind error [%d]!\n" , __func__, name, ret);
drivers/gpio/mt7621_gpio.c +2 -2
@@ -157,8 +157,8 @@ static int gpio_mediatek_bind(struct udevice *parent) plat->gpio_count =MTK_BANK_WIDTH ; plat->bank = bank; - ret =device_bind_offset (parent, parent->driver, - plat->bank_name, plat,-1 , &dev); + ret =device_bind (parent, parent->driver, plat->bank_name, plat, +ofnode_null (), &dev);if (ret)return ret;
drivers/gpio/s5p_gpio.c +2 -2
@@ -332,8 +332,8 @@ static int gpio_exynos_bind(struct udevice *parent)return -ENOMEM ; plat->bank_name =fdt_get_name (blob, node,NULL ); - ret =device_bind_offset (parent, parent->driver, - plat->bank_name, plat,-1 , &dev); + ret =device_bind (parent, parent->driver, plat->bank_name, plat, +ofnode_null (), &dev);if (ret)return ret;
drivers/gpio/sunxi_gpio.c +2 -2
@@ -305,8 +305,8 @@ static int gpio_sunxi_bind(struct udevice *parent) plat->bank_name =gpio_bank_name (soc_data->start + bank); plat->gpio_count =SUNXI_GPIOS_PER_BANK ; - ret =device_bind_offset (parent, parent->driver, - plat->bank_name, plat,-1 , &dev); + ret =device_bind (parent, parent->driver, plat->bank_name, plat, +ofnode_null (), &dev);if (ret)return ret;dev_set_of_offset (dev,dev_of_offset (parent));
drivers/gpio/tegra186_gpio.c +2 -2
@@ -190,8 +190,8 @@ static int tegra186_gpio_bind(struct udevice *parent) plat->name = ctlr_data->ports[port].name; plat->regs = &(regs[ctlr_data->ports[port].offset /4 ]); - ret =device_bind_offset (parent, parent->driver, plat->name, - plat,-1 , &dev); + ret =device_bind (parent, parent->driver, plat->name, plat, +ofnode_null (), &dev);if (ret)return ret;dev_set_of_offset (dev,dev_of_offset (parent));
drivers/gpio/tegra_gpio.c +3 -3
@@ -360,9 +360,9 @@ static int gpio_tegra_bind(struct udevice *parent) plat->base_gpio =TEGRA_GPIOS_PER_PORT * base_port; plat->port_name =gpio_port_name (base_port); - ret =device_bind_offset (parent, parent->driver, - plat->port_name, plat,-1 , - &dev); + ret =device_bind (parent, parent->driver, + plat->port_name, plat,ofnode_null (), + &dev);if (ret)return ret;dev_set_of_offset (dev,dev_of_offset (parent));
drivers/net/mvpp2.c +2 -2
@@ -5477,8 +5477,8 @@ static int mvpp2_base_bind(struct udevice *parent)sprintf (name,"mvpp2-%d" , id);/* Create child device UCLASS_ETH and bind it */ -device_bind_offset (parent, &mvpp2_driver, name, plat, subnode, &dev); -dev_set_of_offset (dev, subnode); +device_bind (parent, &mvpp2_driver, name, plat, +offset_to_ofnode (subnode), &dev); }return 0 ;
drivers/pinctrl/broadcom/pinctrl-bcm283x.c +2 -3
@@ -125,9 +125,8 @@ int bcm283x_pinctl_probe(struct udevice *dev)struct udevice *pdev;/* Create GPIO device as well */ - ret =device_bind_offset (dev,lists_driver_lookup_name ("gpio_bcm2835" ), -"gpio_bcm2835" ,NULL ,dev_of_offset (dev), - &pdev); + ret =device_bind (dev,lists_driver_lookup_name ("gpio_bcm2835" ), +"gpio_bcm2835" ,NULL ,dev_ofnode (dev), &pdev);if (ret) {/* * While we really want the pinctrl driver to work to make
drivers/pinctrl/meson/pinctrl-meson.c +3 -1
@@ -347,6 +347,7 @@ int meson_pinctrl_probe(struct udevice *dev)int na, ns;char *name; +/* FIXME: Should use livetree */ na =fdt_address_cells (gd->fdt_blob,dev_of_offset (dev->parent));if (na <1 ) {debug ("bad #address-cells\n" );
@@ -419,7 +420,8 @@ int meson_pinctrl_probe(struct udevice *dev)sprintf (name,"meson-gpio" );/* Create child device UCLASS_GPIO and bind it */ -device_bind_offset (dev, priv->data->gpio_driver, name,NULL , gpio, &gpio_dev); +device_bind (dev, priv->data->gpio_driver, name,NULL , +offset_to_ofnode (gpio), &gpio_dev);dev_set_of_offset (gpio_dev, gpio);return 0 ;
drivers/pinctrl/mscc/pinctrl-jr2.c +2 -2
@@ -299,8 +299,8 @@ static int jr2_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind_offset (dev, &jr2_gpio_driver,"jr2-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind (dev, &jr2_gpio_driver,"jr2-gpio" ,NULL , +dev_ofnode (dev),NULL );if (ret)return ret;
drivers/pinctrl/mscc/pinctrl-luton.c +2 -2
@@ -165,8 +165,8 @@ int luton_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind_offset (dev, &luton_gpio_driver,"luton-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind (dev, &luton_gpio_driver,"luton-gpio" ,NULL , +dev_ofnode (dev),NULL );return 0 ; }
drivers/pinctrl/mscc/pinctrl-ocelot.c +2 -2
@@ -181,8 +181,8 @@ int ocelot_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind_offset (dev, &ocelot_gpio_driver,"ocelot-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind (dev, &ocelot_gpio_driver,"ocelot-gpio" ,NULL , +dev_ofnode (dev),NULL );return ret; }
drivers/pinctrl/mscc/pinctrl-serval.c +2 -2
@@ -209,8 +209,8 @@ static int serval_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind_offset (dev, &serval_gpio_driver,"serval-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind (dev, &serval_gpio_driver,"serval-gpio" ,NULL , +dev_ofnode (dev),NULL );if (ret)return ret;
drivers/pinctrl/mscc/pinctrl-servalt.c +2 -2
@@ -245,8 +245,8 @@ static int servalt_pinctrl_probe(struct udevice *dev)if (ret)return ret; - ret =device_bind_offset (dev, &servalt_gpio_driver,"servalt-gpio" ,NULL , -dev_of_offset (dev),NULL ); + ret =device_bind (dev, &servalt_gpio_driver,"servalt-gpio" ,NULL , +dev_ofnode (dev),NULL );if (ret)return ret;
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +4 -4
@@ -547,13 +547,14 @@ static int armada_37xx_gpiochip_register(struct udevice *parent,int subnode;char *name; -/* Lookup GPIO driver */ +/* FIXME: Should not need to lookup GPIO uclass */ drv =lists_uclass_lookup (UCLASS_GPIO );if (!drv) {puts ("Cannot find GPIO driver\n" );return -ENOENT ; } +/* FIXME: Use livtree and check the result of device_bind() below */ fdt_for_each_subnode (subnode, blob, node) {if (fdtdec_get_bool (blob, subnode,"gpio-controller" )) { ret =0 ;
@@ -567,9 +568,8 @@ static int armada_37xx_gpiochip_register(struct udevice *parent,sprintf (name,"armada-37xx-gpio" );/* Create child device UCLASS_GPIO and bind it */ -device_bind_offset (parent, &armada_37xx_gpio_driver, name,NULL , - subnode, &dev); -dev_set_of_offset (dev, subnode); +device_bind (parent, &armada_37xx_gpio_driver, name,NULL , +offset_to_ofnode (subnode), &dev);return 0 ; }
drivers/power/regulator/Kconfig +1 -1
@@ -11,7 +11,7 @@ config DM_REGULATOR - 'include/power/regulator.h' - 'drivers/power/pmic/pmic-uclass.c' - 'drivers/power/pmic/regulator-uclass.c' - It's important to call the device_bind_offset() with the proper node offset, + It's important to call the device_bind() with the proper node offset, when binding the regulator devices. The pmic_bind_childs() can be used for this purpose if PMIC I/O driver is implemented or dm_scan_fdt_dev() otherwise. Detailed information can be found in the header file.
include/dm/device-internal.h +2 -2
@@ -37,8 +37,8 @@ struct udevice;* @return 0 if OK, -ve on error */ int device_bind_offset (struct udevice *parent,const struct driver *drv, -const char *name,void *platdata,int of_offset, -struct udevice **devp); +const char *name,void *platdata,int of_offset, +struct udevice **devp); int device_bind(struct udevice *parent, const struct driver *drv, const char *name, void *platdata, ofnode node,
include/power/regulator.h +1 -1
@@ -48,7 +48,7 @@* If regulator-name property is not provided, node name will be chosen. * * Regulator bind: -* For each regulator device, the device_bind_offset() should be called with passed +* For each regulator device, the device_bind() should be called with passed * device tree offset. This is required for this uclass's '.post_bind' method, * which does the scan on the device node, for the 'regulator-name' constraint. * If the parent is not a PMIC device, and the child is not bind by function:
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 4/11 dm: Remove uses of device_bind_offset()
This function is not needed since the standard device_bind() can be used instead.
---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/at91/compat.c | 20 ++++++++------------ drivers/clk/clk.c | 2 +- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 6 +++--- drivers/net/mvpp2.c | 4 ++-- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 4 +++- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 4/11 dm: Remove uses of device_bind_offset()
Quoted 28 lines · Simon Glass
This function is not needed since the standard
device_bind()can be used instead.Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/at91/compat.c | 20 ++++++++------------ drivers/clk/clk.c | 2 +- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 6 +++--- drivers/net/mvpp2.c | 4 ++-- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 4 +++- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-)
Quoted 2 lines
Applied to u-boot-dm, thanks!
Hi Simon,
I bisected the tree and this commit looks to break sama5d4_xplained_mmc_defconfig :
<debug_uart>
No serial driver found
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Booting u-boot fails when adding this commit.
Could you please help or let me know how I can fix it ?
Thanks,
Eugen
a2703ce10cfcbe6a82ec8ed9ec10df2aeea08e64 is the first bad commit commit a2703ce10cfcbe6a82ec8ed9ec10df2aeea08e64
Author: Simon Glass <[email protected]> Date: Sat Nov 28 17:50:03 2020 -0700
dm: Remove uses of device_bind_offset()
This function is not needed since the standard device_bind() can be
used
instead.
PATCH 4/11 dm: Remove uses of device_bind_offset()
Hi Eugen,
Quoted 57 lines · On Sun, 31 Jan 2021 at 02:18, <[email protected]> wrote:
Quoted 28 lines · Simon Glass
This function is not needed since the standard
device_bind()can be used instead.Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/at91/compat.c | 20 ++++++++------------ drivers/clk/clk.c | 2 +- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 6 +++--- drivers/net/mvpp2.c | 4 ++-- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 4 +++- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-)Quoted 2 lines
Applied to u-boot-dm, thanks!
Hi Simon,
I bisected the tree and this commit looks to break
sama5d4_xplained_mmc_defconfig:<
debug_uart>
No serial driver found
Could not initialize timer (err -19)Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Quoted 7 lines
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Booting u-boot fails when adding this commit.
Could you please help or let me know how I can fix it ?
I suspect the problem could be in the changes to drivers/clk/at91/compat.c although I cannot see why
You could try reverting that change, and just using offset_to_ofnode() in the device_bind_driver_to_node() call. I actually intended to do that at the time due to the risk, but somehow I missed this one.
OTOH it would be good to move the code to livetree and stop using fdt offsets.
Regards,
Simon
PATCH 4/11 dm: Remove uses of device_bind_offset()
Quoted 71 lines · Simon Glass
Hi Eugen,
Quoted 57 lines · On Sun, 31 Jan 2021 at 02:18, <[email protected]> wrote:
Quoted 28 lines · Simon Glass
This function is not needed since the standard
device_bind()can be used instead.Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/at91/compat.c | 20 ++++++++------------ drivers/clk/clk.c | 2 +- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 6 +++--- drivers/net/mvpp2.c | 4 ++-- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 4 +++- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-)Quoted 2 lines
Applied to u-boot-dm, thanks!
Hi Simon,
I bisected the tree and this commit looks to break
sama5d4_xplained_mmc_defconfig:<
debug_uart>
No serial driver found
Could not initialize timer (err -19)Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Quoted 7 lines
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Booting u-boot fails when adding this commit.
Could you please help or let me know how I can fix it ?
I suspect the problem could be in the changes to
drivers/clk/at91/compat.calthough I cannot see why
Quoted 9 lines
You could try reverting that change, and just using
offset_to_ofnode()in thedevice_bind_driver_to_node()call. I actually intended to do that at the time due to the risk, but somehow I missed this one.OTOH it would be good to move the code to livetree and stop using fdt offsets.
Regards,
Simon
I reverted the changes in compat.c and indeed now it boots correctly.
I tried to do the following change on top of your code as you suggested but it does not help:
drivers/clk/at91/compat.c +0 -0
@@ -67,7 +67,7 @@ int at91_clk_sub_device_bind(struct udevice *dev,
const char *drv_name)
bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
const char *name;
int ret;
-
+ int offset = dev_of_offset(dev);
ofnode_for_each_subnode(node, parent) {
if (pre_reloc_only && !ofnode_pre_reloc(node))
continue;
@@ -84,7 +84,7 @@ int at91_clk_sub_device_bind(struct udevice *dev,
const char *drv_name)
name = ofnode_get_name(node);
if (!name)
return -EINVAL;
- ret = device_bind_driver_to_node(dev, drv_name, name, node,
+ ret = device_bind_driver_to_node(dev, drv_name, name,
offset_to_ofnode(offset),
NULL);
if (ret)
return ret;I have a feeling the 'for loop' for the subnodes misses an essential driver and thus it fails booting
PATCH 4/11 dm: Remove uses of device_bind_offset()
Hi Eugen,
Quoted 114 lines · On Mon, 1 Feb 2021 at 01:13, <[email protected]> wrote:
Quoted 71 lines · Simon Glass
Hi Eugen,
Quoted 57 lines · On Sun, 31 Jan 2021 at 02:18, <[email protected]> wrote:
Quoted 28 lines · Simon Glass
This function is not needed since the standard
device_bind()can be used instead.Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/at91/compat.c | 20 ++++++++------------ drivers/clk/clk.c | 2 +- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 6 +++--- drivers/net/mvpp2.c | 4 ++-- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 4 +++- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-)Quoted 2 lines
Applied to u-boot-dm, thanks!
Hi Simon,
I bisected the tree and this commit looks to break
sama5d4_xplained_mmc_defconfig:<
debug_uart>
No serial driver found
Could not initialize timer (err -19)Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Quoted 7 lines
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Booting u-boot fails when adding this commit.
Could you please help or let me know how I can fix it ?
I suspect the problem could be in the changes to
drivers/clk/at91/compat.calthough I cannot see whyQuoted 9 lines
You could try reverting that change, and just using
offset_to_ofnode()in thedevice_bind_driver_to_node()call. I actually intended to do that at the time due to the risk, but somehow I missed this one.OTOH it would be good to move the code to livetree and stop using fdt offsets.
Regards,
SimonI reverted the changes in
compat.cand indeed now it boots correctly.I tried to do the following change on top of your code as you suggested but it does not help:
drivers/clk/at91/compat.c +1
-1@@ -67,7 +67,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);const char *name;int ret; - +int offset =dev_of_offset (dev);ofnode_for_each_subnode (node, parent) {if (pre_reloc_only && !ofnode_pre_reloc (node))continue;drivers/clk/at91/compat.c +1
-1@@ -84,7 +84,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) name =ofnode_get_name (node);if (!name)return -EINVAL ; - ret =device_bind_driver_to_node (dev, drv_name, name, node, + ret =device_bind_driver_to_node (dev, drv_name, name,offset_to_ofnode (offset),NULL );if (ret) return ret;
Quoted 2 lines
I have a feeling the 'for loop' for the subnodes misses an essential driver and thus it fails booting
Then I think reverting all the changes is the best thing in this file. Can you send a patch?
Ultimately this should be figured out, but I cannot see what is wrong and don't have that hardware to try. I do have an old SAM9260/9263 but I'm not sure if that uses the same driver.
Regards,
Simon
PATCH 4/11 dm: Remove uses of device_bind_offset()
Quoted 123 lines · Simon Glass
Hi Eugen,
Quoted 114 lines · On Mon, 1 Feb 2021 at 01:13, <[email protected]> wrote:
Quoted 71 lines · Simon Glass
Hi Eugen,
Quoted 57 lines · On Sun, 31 Jan 2021 at 02:18, <[email protected]> wrote:
Quoted 28 lines · Simon Glass
This function is not needed since the standard
device_bind()can be used instead.Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/apollolake/spl.c | 2 +- drivers/clk/at91/compat.c | 20 ++++++++------------ drivers/clk/clk.c | 2 +- drivers/gpio/mt7621_gpio.c | 4 ++-- drivers/gpio/s5p_gpio.c | 4 ++-- drivers/gpio/sunxi_gpio.c | 4 ++-- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/gpio/tegra_gpio.c | 6 +++--- drivers/net/mvpp2.c | 4 ++-- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 4 +++- drivers/pinctrl/mscc/pinctrl-jr2.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-luton.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-ocelot.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-serval.c | 4 ++-- drivers/pinctrl/mscc/pinctrl-servalt.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- drivers/power/regulator/Kconfig | 2 +- include/dm/device-internal.h | 4 ++-- include/power/regulator.h | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-)Quoted 2 lines
Applied to u-boot-dm, thanks!
Hi Simon,
I bisected the tree and this commit looks to break
sama5d4_xplained_mmc_defconfig:<
debug_uart>
No serial driver found
Could not initialize timer (err -19)Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Quoted 7 lines
Could not initialize timer (err -19)
Could not initialize timer (err -19)
Booting u-boot fails when adding this commit.
Could you please help or let me know how I can fix it ?
I suspect the problem could be in the changes to
drivers/clk/at91/compat.calthough I cannot see whyQuoted 9 lines
You could try reverting that change, and just using
offset_to_ofnode()in thedevice_bind_driver_to_node()call. I actually intended to do that at the time due to the risk, but somehow I missed this one.OTOH it would be good to move the code to livetree and stop using fdt offsets.
Regards,
SimonI reverted the changes in
compat.cand indeed now it boots correctly.I tried to do the following change on top of your code as you suggested but it does not help:
drivers/clk/at91/compat.c +1
-1@@ -67,7 +67,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);const char *name;int ret; - +int offset =dev_of_offset (dev);ofnode_for_each_subnode (node, parent) {if (pre_reloc_only && !ofnode_pre_reloc (node))continue;drivers/clk/at91/compat.c +1
-1@@ -84,7 +84,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) name =ofnode_get_name (node);if (!name)return -EINVAL ; - ret =device_bind_driver_to_node (dev, drv_name, name, node, + ret =device_bind_driver_to_node (dev, drv_name, name,offset_to_ofnode (offset),NULL );if (ret) return ret;Quoted 2 lines
I have a feeling the 'for loop' for the subnodes misses an essential driver and thus it fails booting
Then I think reverting all the changes is the best thing in this file. Can you send a patch?
Quoted 7 lines
Ultimately this should be figured out, but I cannot see what is wrong and don't have that hardware to try. I do have an old SAM9260/9263 but I'm not sure if that uses the same driver.
Regards,
Simon
I can do that, but if you have any hunches, I can test patches for you.
PATCH 5/11 dm: Drop uses of dev_set_of_offset()
In reply to Simon GlassThe need for this can be avoided by passing the correct node to the device_bind() function.
---
drivers/gpio/mt7621_gpio.c | 3 +-- drivers/gpio/s5p_gpio.c | 4 +--- drivers/gpio/sunxi_gpio.c | 3 +-- drivers/gpio/tegra186_gpio.c | 3 +-- drivers/gpio/tegra_gpio.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 1 - 6 files changed, 6 insertions(+), 13 deletions(-)
drivers/gpio/mt7621_gpio.c +1 -2
@@ -158,11 +158,10 @@ static int gpio_mediatek_bind(struct udevice *parent) plat->bank = bank; ret =device_bind (parent, parent->driver, plat->bank_name, plat, -ofnode_null (), &dev); + node, &dev);if (ret)return ret; - dev->node = node; bank++; }
drivers/gpio/s5p_gpio.c +1 -3
@@ -333,12 +333,10 @@ static int gpio_exynos_bind(struct udevice *parent) plat->bank_name =fdt_get_name (blob, node,NULL ); ret =device_bind (parent, parent->driver, plat->bank_name, plat, -ofnode_null (), &dev); +offset_to_ofnode (node), &dev);if (ret)return ret; -dev_set_of_offset (dev, node); - reg =dev_read_addr (dev);if (reg !=FDT_ADDR_T_NONE ) bank = (struct s5p_gpio_bank *)((ulong )base + reg);
drivers/gpio/sunxi_gpio.c +1 -2
@@ -306,10 +306,9 @@ static int gpio_sunxi_bind(struct udevice *parent) plat->gpio_count =SUNXI_GPIOS_PER_BANK ; ret =device_bind (parent, parent->driver, plat->bank_name, plat, -ofnode_null (), &dev); +dev_ofnode (parent), &dev);if (ret)return ret; -dev_set_of_offset (dev,dev_of_offset (parent)); }return 0 ;
drivers/gpio/tegra186_gpio.c +1 -2
@@ -191,10 +191,9 @@ static int tegra186_gpio_bind(struct udevice *parent) plat->regs = &(regs[ctlr_data->ports[port].offset /4 ]); ret =device_bind (parent, parent->driver, plat->name, plat, -ofnode_null (), &dev); +dev_ofnode (parent), &dev);if (ret)return ret; -dev_set_of_offset (dev,dev_of_offset (parent)); }return 0 ;
drivers/gpio/tegra_gpio.c +2 -3
@@ -361,11 +361,10 @@ static int gpio_tegra_bind(struct udevice *parent) plat->port_name =gpio_port_name (base_port); ret =device_bind (parent, parent->driver, - plat->port_name, plat,ofnode_null (), - &dev); + plat->port_name, plat, +dev_ofnode (parent), &dev);if (ret)return ret; -dev_set_of_offset (dev,dev_of_offset (parent)); } }
drivers/pinctrl/meson/pinctrl-meson.c +0 -1
@@ -422,7 +422,6 @@ int meson_pinctrl_probe(struct udevice *dev)/* Create child device UCLASS_GPIO and bind it */ device_bind (dev, priv->data->gpio_driver, name,NULL ,offset_to_ofnode (gpio), &gpio_dev); -dev_set_of_offset (gpio_dev, gpio);return 0 ; }
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 5/11 dm: Drop uses of dev_set_of_offset()
The need for this can be avoided by passing the correct node to the device_bind() function.
---
drivers/gpio/mt7621_gpio.c | 3 +-- drivers/gpio/s5p_gpio.c | 4 +--- drivers/gpio/sunxi_gpio.c | 3 +-- drivers/gpio/tegra186_gpio.c | 3 +-- drivers/gpio/tegra_gpio.c | 5 ++--- drivers/pinctrl/meson/pinctrl-meson.c | 1 - 6 files changed, 6 insertions(+), 13 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 6/11 dm: core: Drop dev_set_of_offset()
In reply to Simon GlassThis pre-livetree function is not needed anymore. Drop it.
---
include/dm/device.h | 5 ----- 1 file changed, 5 deletions(-)
include/dm/device.h +0 -5
@@ -177,11 +177,6 @@ static inline int dev_of_offset(const struct udevice *dev)return ofnode_to_offset (dev->node); } -static inline void dev_set_of_offset (struct udevice *dev,int of_offset) -{ - dev->node =offset_to_ofnode (of_offset); -} -static inline bool dev_has_of_node (struct udevice *dev) {return ofnode_valid (dev->node);
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 6/11 dm: core: Drop dev_set_of_offset()
This pre-livetree function is not needed anymore. Drop it.
---
include/dm/device.h | 5 ----- 1 file changed, 5 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 7/11 dm: core: Drop device_bind_offset()
In reply to Simon GlassThis function is not needed since the standard device_bind() can be used instead. Drop it.
---
drivers/core/device.c | 8 -------- include/dm/device-internal.h | 10 +++------- 2 files changed, 3 insertions(+), 15 deletions(-)
drivers/core/device.c +0 -8
@@ -232,14 +232,6 @@ int device_bind_with_driver_data(struct udevice *parent, 0, devp); } -int device_bind_offset (struct udevice *parent,const struct driver *drv, -const char *name,void *platdata,int of_offset, -struct udevice **devp) -{ -return device_bind_common (parent, drv, name, platdata,0 , -offset_to_ofnode (of_offset),0 , devp); -} -int device_bind (struct udevice *parent,const struct driver *drv,const char *name,void *platdata,ofnode node,struct udevice **devp)
include/dm/device-internal.h +3 -7
@@ -16,7 +16,7 @@ struct device_node;struct udevice ;/** -* device_bind_offset() - Create a device and bind it to a driver +* device_bind() - Create a device and bind it to a driver * * Called to set up a new device attached to a driver. The device will either * have platdata, or a device tree node which can be used to create the
@@ -31,15 +31,11 @@ struct udevice;* @platdata: Pointer to data for this device - the structure is device- * specific but may include the device's I/O address, etc.. This is NULL for * devices which use device tree. -* @of_offset: Offset of device tree node for this device. This is -1 for -* devices which don't use device tree. +* @ofnode: Devicetree node for this device. This is ofnode_null() for +* devices which don't use devicetree or don't have a node. * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ -int device_bind_offset (struct udevice *parent,const struct driver *drv, -const char *name,void *platdata,int of_offset, -struct udevice **devp); -int device_bind (struct udevice *parent,const struct driver *drv,const char *name,void *platdata,ofnode node,struct udevice **devp);
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 7/11 dm: core: Drop device_bind_offset()
This function is not needed since the standard device_bind() can be used instead. Drop it.
---
drivers/core/device.c | 8 -------- include/dm/device-internal.h | 10 +++------- 2 files changed, 3 insertions(+), 15 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 8/11 dm: core: Add an ofnode function to get the devicetree root
In reply to Simon GlassThis is needed in at least one place. Avoid the conditional code in root.c by adding this inline function.
---
drivers/core/root.c | 8 ++------ include/dm/ofnode.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/core/root.c +2 -6
@@ -147,12 +147,8 @@ int dm_init(bool of_live) ret =device_bind_by_name (NULL , false, &root_info, &DM_ROOT_NON_CONST );if (ret)return ret; -#if CONFIG_IS_ENABLED (OF_CONTROL ) -if (CONFIG_IS_ENABLED (OF_LIVE ) && of_live) -DM_ROOT_NON_CONST ->node =np_to_ofnode (gd_of_root ()); -else -DM_ROOT_NON_CONST ->node =offset_to_ofnode (0 ); -#endif +if (CONFIG_IS_ENABLED (OF_CONTROL )) +DM_ROOT_NON_CONST ->node =ofnode_root (); ret =device_probe (DM_ROOT_NON_CONST );if (ret)return ret;
include/dm/ofnode.h +12 -0
@@ -218,6 +218,18 @@ static inline ofnode ofnode_null(void)return node; } +static inline ofnode ofnode_root (void ) +{ +ofnode node; + +if (of_live_active ()) + node.np =gd_of_root (); +else + node.of_offset =0 ; + +return node; +} +/** * ofnode_read_u32() - Read a 32-bit integer from a property *
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 8/11 dm: core: Add an ofnode function to get the devicetree root
This is needed in at least one place. Avoid the conditional code in root.c by adding this inline function.
---
drivers/core/root.c | 8 ++------ include/dm/ofnode.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 9/11 dm: core: Combine the flattree and livetree binding code
In reply to Simon GlassAt present there are two copies of this code. With ofnode we can combine them to reduce duplication. Update the dm_scan_fdt_node() function and adjust its callers.
---
drivers/core/root.c | 74 ++++++++++----------------------------------- 1 file changed, 16 insertions(+), 58 deletions(-)
drivers/core/root.c +16 -58
@@ -199,33 +199,6 @@ int dm_scan_platdata(bool pre_reloc_only) }#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) -static int dm_scan_fdt_live (struct udevice *parent, -const struct device_node *node_parent, -bool pre_reloc_only) -{ -struct device_node *np; -int ret =0 , err; - -for (np = node_parent->child; np; np = np->sibling) { - -if (!of_device_is_available (np)) { -pr_debug (" - ignoring disabled device\n" ); -continue ; - } - err =lists_bind_fdt (parent,np_to_ofnode (np),NULL , - pre_reloc_only); -if (err && !ret) { - ret = err; -debug ("%s: ret=%d\n" , np->name, ret); - } - } - -if (ret) -dm_warn ("Some drivers failed to bind\n" ); - -return ret; -} -/** * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node *
@@ -233,28 +206,30 @@ static int dm_scan_fdt_live(struct udevice *parent,* for each one. * * @parent: Parent device for the devices that will be created -* @blob: Pointer to device tree blob -* @offset: Offset of node to scan +* @node: Node to scan * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC * flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -static int dm_scan_fdt_node (struct udevice *parent,const void *blob, -int offset,bool pre_reloc_only) +static int dm_scan_fdt_node (struct udevice *parent,ofnode parent_node, +bool pre_reloc_only) {int ret =0 , err; +ofnode node; + +if (!ofnode_valid (parent_node)) +return 0 ; -for (offset =fdt_first_subnode (blob, offset); - offset >0 ; - offset =fdt_next_subnode (blob, offset)) { -const char *node_name =fdt_get_name (blob, offset,NULL ); +for (node =ofnode_first_subnode (parent_node); +ofnode_valid (node); + node =ofnode_next_subnode (node)) { +const char *node_name =ofnode_get_name (node); -if (!fdtdec_get_is_enabled (blob, offset)) { +if (!ofnode_is_enabled (node)) {pr_debug (" - ignoring disabled device\n" );continue ; } - err =lists_bind_fdt (parent,offset_to_ofnode (offset),NULL , - pre_reloc_only); + err =lists_bind_fdt (parent, node,NULL , pre_reloc_only);if (err && !ret) { ret = err;debug ("%s: ret=%d\n" , node_name, ret);
@@ -269,24 +244,13 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,int dm_scan_fdt_dev (struct udevice *dev) { -if (!dev_of_valid (dev)) -return 0 ; - -if (of_live_active ()) -return dm_scan_fdt_live (dev,dev_np (dev), - gd->flags &GD_FLG_RELOC ? false : true); - -return dm_scan_fdt_node (dev, gd->fdt_blob,dev_of_offset (dev), +return dm_scan_fdt_node (dev,dev_ofnode (dev), gd->flags &GD_FLG_RELOC ? false : true); }int dm_scan_fdt (const void *blob,bool pre_reloc_only) { -if (of_live_active ()) -return dm_scan_fdt_live (gd->dm_root,gd_of_root (), - pre_reloc_only); - -return dm_scan_fdt_node (gd->dm_root, blob,0 , pre_reloc_only); +return dm_scan_fdt_node (gd->dm_root,ofnode_root (), pre_reloc_only); } static int dm_scan_fdt_ofnode_path(const void *blob, const char *path,
@@ -295,14 +259,8 @@ static int dm_scan_fdt_ofnode_path(const void *blob, const char *path,ofnode node; node =ofnode_path (path); -if (!ofnode_valid (node)) -return 0 ; - -if (of_live_active ()) -return dm_scan_fdt_live (gd->dm_root, node.np, pre_reloc_only); -return dm_scan_fdt_node (gd->dm_root, blob, node.of_offset, - pre_reloc_only); +return dm_scan_fdt_node (gd->dm_root, node, pre_reloc_only); }int dm_extended_scan_fdt (const void *blob,bool pre_reloc_only)
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 9/11 dm: core: Combine the flattree and livetree binding code
At present there are two copies of this code. With ofnode we can combine them to reduce duplication. Update the dm_scan_fdt_node() function and adjust its callers.
---
drivers/core/root.c | 74 ++++++++++----------------------------------- 1 file changed, 16 insertions(+), 58 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 10/11 dm: core: Drop unused parameter from dm_scan_fdt()
In reply to Simon GlassThis doesn't need to be passed the devicetree anymore. Drop it.
---
drivers/core/root.c | 9 ++++----- include/dm/root.h | 3 +-- test/dm/core.c | 2 +- test/dm/test-fdt.c | 2 +- test/dm/test-main.c | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-)
drivers/core/root.c +4 -5
@@ -248,13 +248,12 @@ int dm_scan_fdt_dev(struct udevice *dev) gd->flags & GD_FLG_RELOC ? false : true); } -int dm_scan_fdt (const void *blob,bool pre_reloc_only) +int dm_scan_fdt (bool pre_reloc_only) {return dm_scan_fdt_node (gd->dm_root,ofnode_root (), pre_reloc_only); } -static int dm_scan_fdt_ofnode_path (const void *blob,const char *path, -bool pre_reloc_only) +static int dm_scan_fdt_ofnode_path (const char *path,bool pre_reloc_only) {ofnode node;
@@ -272,7 +271,7 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) "/firmware" }; - ret =dm_scan_fdt (blob, pre_reloc_only); + ret =dm_scan_fdt (pre_reloc_only);if (ret) {debug ("dm_scan_fdt() failed: %d\n" , ret);return ret;
@@ -280,7 +279,7 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only)/* Some nodes aren't devices themselves but may contain some */ for (i =0 ; i <ARRAY_SIZE (nodes); i++) { - ret =dm_scan_fdt_ofnode_path (blob, nodes[i], pre_reloc_only); + ret =dm_scan_fdt_ofnode_path (nodes[i], pre_reloc_only);if (ret) {debug ("dm_scan_fdt() scan for %s failed: %d\n" , nodes[i], ret);
include/dm/root.h +1 -2
@@ -47,12 +47,11 @@ int dm_scan_platdata(bool pre_reloc_only);* This scans the device tree and creates a driver for each node. Only * the top-level subnodes are examined. * -* @blob: Pointer to device tree blob * @pre_reloc_only: If true, bind only nodes with special devicetree properties, * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_scan_fdt (const void *blob,bool pre_reloc_only); +int dm_scan_fdt (bool pre_reloc_only);/** * dm_extended_scan_fdt() - Scan the device tree and bind drivers
test/dm/core.c +1 -1
@@ -486,7 +486,7 @@ static int dm_test_leak(struct unit_test_state *uts)dm_leak_check_start (uts);ut_assertok (dm_scan_platdata (false)); -ut_assertok (dm_scan_fdt (gd->fdt_blob, false)); +ut_assertok (dm_scan_fdt (false));/* Scanning the uclass is enough to probe all the devices */ for (id =UCLASS_ROOT ; id <UCLASS_COUNT ; id++) {
test/dm/test-fdt.c +1 -1
@@ -308,7 +308,7 @@ static int dm_test_fdt_pre_reloc(struct unit_test_state *uts)struct uclass *uc;int ret; - ret =dm_scan_fdt (gd->fdt_blob, true); + ret =dm_scan_fdt (true);ut_assert (!ret); ret =uclass_get (UCLASS_TEST_FDT , &uc);
test/dm/test-main.c +1 -1
@@ -213,7 +213,7 @@ int dm_test_main(const char *test_name)ut_assertok (dm_init (CONFIG_IS_ENABLED (OF_LIVE )));dm_scan_platdata (false);if (!CONFIG_IS_ENABLED (OF_PLATDATA )) -dm_scan_fdt (gd->fdt_blob, false); +dm_scan_fdt (false);return uts->fail_count ?CMD_RET_FAILURE :0 ; }
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 10/11 dm: core: Drop unused parameter from dm_scan_fdt()
This doesn't need to be passed the devicetree anymore. Drop it.
---
drivers/core/root.c | 9 ++++----- include/dm/root.h | 3 +-- test/dm/core.c | 2 +- test/dm/test-fdt.c | 2 +- test/dm/test-main.c | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 11/11 dm: core: Drop unused parameter from dm_extended_scan_fdt()
In reply to Simon GlassThis doesn't need to be passed the devicetree anymore. Drop it. Also rename the function to drop the _fdt suffix.
---
drivers/core/root.c | 6 +++--- include/dm/root.h | 5 ++--- test/dm/test-fdt.c | 2 +- test/dm/test-main.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-)
drivers/core/root.c +3 -3
@@ -262,7 +262,7 @@ static int dm_scan_fdt_ofnode_path(const char *path, bool pre_reloc_only)return dm_scan_fdt_node (gd->dm_root, node, pre_reloc_only); } -int dm_extended_scan_fdt (const void *blob,bool pre_reloc_only) +int dm_extended_scan (bool pre_reloc_only) {int ret, i;const char *const nodes[] = {
@@ -315,9 +315,9 @@ int dm_init_and_scan(bool pre_reloc_only) }if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) { - ret =dm_extended_scan_fdt (gd->fdt_blob, pre_reloc_only); + ret =dm_extended_scan (pre_reloc_only);if (ret) { -debug ("dm_extended_scan_dt() failed: %d\n" , ret); +debug ("dm_extended_scan() failed: %d\n" , ret);return ret; } }
include/dm/root.h +2 -3
@@ -54,18 +54,17 @@ int dm_scan_platdata(bool pre_reloc_only);int dm_scan_fdt (bool pre_reloc_only);/** -* dm_extended_scan_fdt() - Scan the device tree and bind drivers +* dm_extended_scan() - Scan the device tree and bind drivers * * This calls dm_scna_dft() which scans the device tree and creates a driver * for each node. the top-level subnodes are examined and also all sub-nodes * of "clocks" node. * -* @blob: Pointer to device tree blob * @pre_reloc_only: If true, bind only nodes with special devicetree properties, * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_extended_scan_fdt (const void *blob,bool pre_reloc_only); +int dm_extended_scan (bool pre_reloc_only);/** * dm_scan_other() - Scan for other devices
test/dm/test-fdt.c +1 -1
@@ -257,7 +257,7 @@ static int dm_test_fdt(struct unit_test_state *uts)int ret;int i; - ret =dm_extended_scan_fdt (gd->fdt_blob, false); + ret =dm_extended_scan (false);ut_assert (!ret); ret =uclass_get (UCLASS_TEST_FDT , &uc);
test/dm/test-main.c +1 -1
@@ -94,7 +94,7 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,ut_assertok (do_autoprobe (uts));if (!CONFIG_IS_ENABLED (OF_PLATDATA ) && (test->flags &UT_TESTF_SCAN_FDT )) -ut_assertok (dm_extended_scan_fdt (gd->fdt_blob, false)); +ut_assertok (dm_extended_scan (false));/* * Silence the console and rely on console recording to get
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
PATCH 11/11 dm: core: Drop unused parameter from dm_extended_scan_fdt()
This doesn't need to be passed the devicetree anymore. Drop it. Also rename the function to drop the _fdt suffix.
---
drivers/core/root.c | 6 +++--- include/dm/root.h | 5 ++--- test/dm/test-fdt.c | 2 +- test/dm/test-main.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-)
Applied to u-boot-dm, thanks!