]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: Use dm_scan_fdt_dev() directly where possible
authorSimon Glass <sjg@chromium.org>
Tue, 5 Jul 2016 23:10:10 +0000 (17:10 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 27 Jul 2016 20:15:54 +0000 (14:15 -0600)
Quite a few places have a bind() method which just calls dm_scan_fdt_dev().
We may as well call dm_scan_fdt_dev() directly. Update the code to do this.

Signed-off-by: Simon Glass <sjg@chromium.org>
17 files changed:
arch/x86/lib/lpc-uclass.c
common/usb_hub.c
drivers/i2c/i2c-uclass.c
drivers/misc/cros_ec.c
drivers/pch/pch-uclass.c
drivers/pci/pci-uclass.c
drivers/pci/pci_sandbox.c
drivers/pinctrl/pinctrl_pic32.c
drivers/pinctrl/rockchip/pinctrl_rk3036.c
drivers/pinctrl/rockchip/pinctrl_rk3288.c
drivers/power/pmic/pm8916.c
drivers/spi/spi-uclass.c
drivers/spmi/spmi-uclass.c
drivers/usb/emul/usb-emul-uclass.c
drivers/usb/host/usb-uclass.c
test/dm/i2c.c
test/dm/spi.c

index b8254ff48ce449848f132894202d8e4358b18146..eb033e6b3f6312fc0ea82a054af9ac57383941b8 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int lpc_uclass_post_bind(struct udevice *bus)
-{
-       /*
-        * Scan the device tree for devices
-        *
-        * Before relocation, only bind devices marked for pre-relocation
-        * use.
-        */
-       return dm_scan_fdt_dev(bus);
-}
-
 UCLASS_DRIVER(lpc) = {
        .id             = UCLASS_LPC,
        .name           = "lpc",
-       .post_bind      = lpc_uclass_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
 };
index 26ee13e1499f89133d8417c0bcb0dedea46e7bba..ff9cd50eab7c4f7a335572f0e226f53bb285c04c 100644 (file)
@@ -754,12 +754,6 @@ int usb_hub_scan(struct udevice *hub)
        return usb_hub_configure(udev);
 }
 
-static int usb_hub_post_bind(struct udevice *dev)
-{
-       /* Scan the bus for devices */
-       return dm_scan_fdt_dev(dev);
-}
-
 static int usb_hub_post_probe(struct udevice *dev)
 {
        debug("%s\n", __func__);
@@ -781,7 +775,7 @@ U_BOOT_DRIVER(usb_generic_hub) = {
 UCLASS_DRIVER(usb_hub) = {
        .id             = UCLASS_USB_HUB,
        .name           = "usb_hub",
-       .post_bind      = usb_hub_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
        .post_probe     = usb_hub_post_probe,
        .child_pre_probe        = usb_child_pre_probe,
        .per_child_auto_alloc_size = sizeof(struct usb_device),
index 16447b896b0347f886b17fad75729296b08d6c57..dbd3789747dfdacc1ca2fc013203ff8d4f416e05 100644 (file)
@@ -498,16 +498,6 @@ static int i2c_post_probe(struct udevice *dev)
 #endif
 }
 
-static int i2c_post_bind(struct udevice *dev)
-{
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-       /* Scan the bus for devices */
-        return dm_scan_fdt_dev(dev);
-#else
-       return 0;
-#endif
-}
-
 static int i2c_child_post_bind(struct udevice *dev)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
@@ -526,7 +516,9 @@ UCLASS_DRIVER(i2c) = {
        .id             = UCLASS_I2C,
        .name           = "i2c",
        .flags          = DM_UC_FLAG_SEQ_ALIAS,
-       .post_bind      = i2c_post_bind,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+       .post_bind      = dm_scan_fdt_dev,
+#endif
        .post_probe     = i2c_post_probe,
        .per_device_auto_alloc_size = sizeof(struct dm_i2c_bus),
        .per_child_platdata_auto_alloc_size = sizeof(struct dm_i2c_chip),
index f50e73fea6584bf1db14ab5690e74717a5782da6..aea8d61f347df8bceb15450174ab249490da0e59 100644 (file)
@@ -1449,12 +1449,6 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return ret;
 }
 
-int cros_ec_post_bind(struct udevice *dev)
-{
-       /* Scan for available EC devices (e.g. I2C tunnel) */
-       return dm_scan_fdt_dev(dev);
-}
-
 U_BOOT_CMD(
        crosec, 6,      1,      do_cros_ec,
        "CROS-EC utility command",
@@ -1481,5 +1475,5 @@ UCLASS_DRIVER(cros_ec) = {
        .id             = UCLASS_CROS_EC,
        .name           = "cros_ec",
        .per_device_auto_alloc_size = sizeof(struct cros_ec_dev),
-       .post_bind      = cros_ec_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
 };
index 5b2fa1f0a50f70078a97c08b2877b6699b0df31c..af794eb5a128e845b84bd6fe996544b01feb43dd 100644 (file)
@@ -54,19 +54,8 @@ int pch_get_io_base(struct udevice *dev, u32 *iobasep)
        return ops->get_io_base(dev, iobasep);
 }
 
-static int pch_uclass_post_bind(struct udevice *bus)
-{
-       /*
-        * Scan the device tree for devices
-        *
-        * Before relocation, only bind devices marked for pre-relocation
-        * use.
-        */
-       return dm_scan_fdt_dev(bus);
-}
-
 UCLASS_DRIVER(pch) = {
        .id             = UCLASS_PCH,
        .name           = "pch",
-       .post_bind      = pch_uclass_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
 };
index 230d18142df164ee5a6cc6b9a523531865ca8988..342b78c0c4ba566518284fe04d5e64468e921c72 100644 (file)
@@ -752,19 +752,6 @@ error:
        return ret;
 }
 
-static int pci_uclass_post_bind(struct udevice *bus)
-{
-       /*
-        * Scan the device tree for devices. This does not probe the PCI bus,
-        * as this is not permitted while binding. It just finds devices
-        * mentioned in the device tree.
-        *
-        * Before relocation, only bind devices marked for pre-relocation
-        * use.
-        */
-       return dm_scan_fdt_dev(bus);
-}
-
 static int decode_regions(struct pci_controller *hose, const void *blob,
                          int parent_node, int node)
 {
@@ -1245,7 +1232,7 @@ UCLASS_DRIVER(pci) = {
        .id             = UCLASS_PCI,
        .name           = "pci",
        .flags          = DM_UC_FLAG_SEQ_ALIAS,
-       .post_bind      = pci_uclass_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
        .pre_probe      = pci_uclass_pre_probe,
        .post_probe     = pci_uclass_post_probe,
        .child_post_bind = pci_uclass_child_post_bind,
index b5628139b30c1a0287f6d5c1a3e727969a9b24fb..6a84ee386d796e3422325824b02f357898bb0b44 100644 (file)
@@ -51,12 +51,6 @@ static int sandbox_pci_read_config(struct udevice *bus, pci_dev_t devfn,
        return ops->read_config(emul, offset, valuep, size);
 }
 
-static int sandbox_pci_child_post_bind(struct udevice *dev)
-{
-       /* Attach an emulator if we can */
-       return dm_scan_fdt_dev(dev);
-}
-
 static const struct dm_pci_ops sandbox_pci_ops = {
        .read_config = sandbox_pci_read_config,
        .write_config = sandbox_pci_write_config,
@@ -72,7 +66,9 @@ U_BOOT_DRIVER(pci_sandbox) = {
        .id     = UCLASS_PCI,
        .of_match = sandbox_pci_ids,
        .ops    = &sandbox_pci_ops,
-       .child_post_bind = sandbox_pci_child_post_bind,
+
+       /* Attach an emulator if we can */
+       .child_post_bind = dm_scan_fdt_dev,
        .per_child_platdata_auto_alloc_size =
                        sizeof(struct pci_child_platdata),
 };
index 5636f8f47f6a29fcf866eef42827d0833a13fa96..9acac29133cb900259eab828c7aa90a771060dbe 100644 (file)
@@ -340,12 +340,6 @@ static int pic32_pinctrl_probe(struct udevice *dev)
        return 0;
 }
 
-static int pic32_pinctrl_bind(struct udevice *dev)
-{
-       /* scan child GPIO banks */
-       return dm_scan_fdt_dev(dev);
-}
-
 static const struct udevice_id pic32_pinctrl_ids[] = {
        { .compatible = "microchip,pic32mzda-pinctrl" },
        { }
@@ -357,6 +351,6 @@ U_BOOT_DRIVER(pinctrl_pic32) = {
        .of_match       = pic32_pinctrl_ids,
        .ops            = &pic32_pinctrl_ops,
        .probe          = pic32_pinctrl_probe,
-       .bind           = pic32_pinctrl_bind,
+       .bind           = dm_scan_fdt_dev,
        .priv_auto_alloc_size = sizeof(struct pic32_pinctrl_priv),
 };
index 3648678e15fafa0f2ffb591cbc086f0c9f233658..6aea856aa63f119b816ac62ac0879e7e711411f1 100644 (file)
@@ -252,12 +252,6 @@ static struct pinctrl_ops rk3036_pinctrl_ops = {
        .get_periph_id  = rk3036_pinctrl_get_periph_id,
 };
 
-static int rk3036_pinctrl_bind(struct udevice *dev)
-{
-       /* scan child GPIO banks */
-       return dm_scan_fdt_dev(dev);
-}
-
 static int rk3036_pinctrl_probe(struct udevice *dev)
 {
        struct rk3036_pinctrl_priv *priv = dev_get_priv(dev);
@@ -278,6 +272,6 @@ U_BOOT_DRIVER(pinctrl_rk3036) = {
        .of_match       = rk3036_pinctrl_ids,
        .priv_auto_alloc_size = sizeof(struct rk3036_pinctrl_priv),
        .ops            = &rk3036_pinctrl_ops,
-       .bind           = rk3036_pinctrl_bind,
+       .bind           = dm_scan_fdt_dev,
        .probe          = rk3036_pinctrl_probe,
 };
index 4650066a3c85e54f668292a8a273139c44764aeb..ae8a4f1fde681b44ff4545805338e683a531245e 100644 (file)
@@ -663,15 +663,6 @@ static struct pinctrl_ops rk3288_pinctrl_ops = {
        .get_periph_id  = rk3288_pinctrl_get_periph_id,
 };
 
-static int rk3288_pinctrl_bind(struct udevice *dev)
-{
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-       return 0;
-#else
-       return dm_scan_fdt_dev(dev);
-#endif
-}
-
 #ifndef CONFIG_SPL_BUILD
 static int rk3288_pinctrl_parse_tables(struct rk3288_pinctrl_priv *priv,
                                       struct rockchip_pin_bank *banks,
@@ -728,6 +719,8 @@ U_BOOT_DRIVER(pinctrl_rk3288) = {
        .of_match       = rk3288_pinctrl_ids,
        .priv_auto_alloc_size = sizeof(struct rk3288_pinctrl_priv),
        .ops            = &rk3288_pinctrl_ops,
-       .bind           = rk3288_pinctrl_bind,
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       .bind           = dm_scan_fdt_dev,
+#endif
        .probe          = rk3288_pinctrl_probe,
 };
index 6f5608e4568ca12acc3c66cfb3529cad29beac81..2b65c697ec9431a87497b29011638464fcef628e 100644 (file)
@@ -78,17 +78,11 @@ static int pm8916_probe(struct udevice *dev)
        return 0;
 }
 
-
-static int pm8916_bind(struct udevice *dev)
-{
-       return dm_scan_fdt_dev(dev);
-}
-
 U_BOOT_DRIVER(pmic_pm8916) = {
        .name = "pmic_pm8916",
        .id = UCLASS_PMIC,
        .of_match = pm8916_ids,
-       .bind = pm8916_bind,
+       .bind = dm_scan_fdt_dev,
        .probe = pm8916_probe,
        .ops = &pm8916_ops,
        .priv_auto_alloc_size = sizeof(struct pm8916_priv),
index 3d3005c22679e74fa3d116a5787acc03936fe3f4..247abfa72ba1c28f904bd8df846df2e17464e441 100644 (file)
@@ -108,12 +108,6 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
        return dm_spi_xfer(slave->dev, bitlen, dout, din, flags);
 }
 
-static int spi_post_bind(struct udevice *dev)
-{
-       /* Scan the bus for devices */
-       return dm_scan_fdt_dev(dev);
-}
-
 static int spi_child_post_bind(struct udevice *dev)
 {
        struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
@@ -445,7 +439,7 @@ UCLASS_DRIVER(spi) = {
        .id             = UCLASS_SPI,
        .name           = "spi",
        .flags          = DM_UC_FLAG_SEQ_ALIAS,
-       .post_bind      = spi_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
        .post_probe     = spi_post_probe,
        .child_pre_probe = spi_child_pre_probe,
        .per_device_auto_alloc_size = sizeof(struct dm_spi_bus),
index 9fa330b8e9031c68b655d7249c4c244d297fbd97..6edece23d82bf991d0cf0d484cbd60c2b2142475 100644 (file)
@@ -35,13 +35,8 @@ int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
        return ops->write(dev, usid, pid, reg, value);
 }
 
-static int spmi_post_bind(struct udevice *dev)
-{
-       return dm_scan_fdt_dev(dev);
-}
-
 UCLASS_DRIVER(spmi) = {
        .id             = UCLASS_SPMI,
        .name           = "spmi",
-       .post_bind      = spmi_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
 };
index da91d04a087b1816b28a3320ab3a8cf96281f531..6e03c1e0d9e7f1273990fd2967e77a17c2efa862 100644 (file)
@@ -264,12 +264,6 @@ int usb_emul_setup_device(struct udevice *dev, int maxpacketsize,
        return 0;
 }
 
-int usb_emul_post_bind(struct udevice *dev)
-{
-       /* Scan the bus for devices */
-       return dm_scan_fdt_dev(dev);
-}
-
 void usb_emul_reset(struct udevice *dev)
 {
        struct usb_dev_platdata *plat = dev_get_parent_platdata(dev);
@@ -281,7 +275,7 @@ void usb_emul_reset(struct udevice *dev)
 UCLASS_DRIVER(usb_emul) = {
        .id             = UCLASS_USB_EMUL,
        .name           = "usb_emul",
-       .post_bind      = usb_emul_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
        .per_child_auto_alloc_size = sizeof(struct usb_device),
        .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata),
 };
index 070e271db88dc72c9dfd25dc07b58098e89d70a2..be114fc07715b3a900551cc1a55ba2da5198ecdb 100644 (file)
@@ -348,11 +348,6 @@ struct usb_device *usb_get_dev_index(struct udevice *bus, int index)
 }
 #endif
 
-int usb_post_bind(struct udevice *dev)
-{
-       return dm_scan_fdt_dev(dev);
-}
-
 int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
 {
        struct usb_platdata *plat;
@@ -766,7 +761,7 @@ UCLASS_DRIVER(usb) = {
        .id             = UCLASS_USB,
        .name           = "usb",
        .flags          = DM_UC_FLAG_SEQ_ALIAS,
-       .post_bind      = usb_post_bind,
+       .post_bind      = dm_scan_fdt_dev,
        .priv_auto_alloc_size = sizeof(struct usb_uclass_priv),
        .per_child_auto_alloc_size = sizeof(struct usb_device),
        .per_device_auto_alloc_size = sizeof(struct usb_bus_priv),
index 23d612eb81eb77368181891a3ef123d51d88bbcd..e2688bfbe9c06d29cf7806253adc5d5e8ba18ec2 100644 (file)
@@ -31,8 +31,8 @@ static int dm_test_i2c_find(struct unit_test_state *uts)
                                                       false, &bus));
 
        /*
-        * i2c_post_bind() will bind devices to chip selects. Check this then
-        * remove the emulation and the slave device.
+        * The post_bind() method will bind devices to chip selects. Check
+        * this then remove the emulation and the slave device.
         */
        ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
        ut_assertok(dm_i2c_probe(bus, chip, 0, &dev));
index 2e27da72d505c6afe2df467c0f89fad1ad08c4a5..5733096066c9780a4539270856b03ef4840ffab3 100644 (file)
@@ -30,8 +30,8 @@ static int dm_test_spi_find(struct unit_test_state *uts)
                                                       false, &bus));
 
        /*
-        * spi_post_bind() will bind devices to chip selects. Check this then
-        * remove the emulation and the slave device.
+        * The post_bind() method will bind devices to chip selects. Check
+        * this then remove the emulation and the slave device.
         */
        ut_asserteq(0, uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus));
        ut_assertok(spi_cs_info(bus, cs, &info));