dm: Remove uses of device_bind_offset()
This function is not needed since the standard device_bind() can be used instead. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
							parent
							
								
									0de1b07406
								
							
						
					
					
						commit
						a2703ce10c
					
				|  | @ -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 |  * 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 |  * 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) | static int apl_flash_bind(struct udevice *dev) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -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) | int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) | ||||||
| { | { | ||||||
| 	const void *fdt = gd->fdt_blob; | 	ofnode parent = dev_ofnode(dev); | ||||||
| 	int offset = dev_of_offset(dev); | 	ofnode node; | ||||||
| 	bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC); | 	bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC); | ||||||
| 	const char *name; | 	const char *name; | ||||||
| 	int ret; | 	int ret; | ||||||
| 
 | 
 | ||||||
| 	for (offset = fdt_first_subnode(fdt, offset); | 	ofnode_for_each_subnode(node, parent) { | ||||||
| 	     offset > 0; | 		if (pre_reloc_only && !ofnode_pre_reloc(node)) | ||||||
| 	     offset = fdt_next_subnode(fdt, offset)) { |  | ||||||
| 		if (pre_reloc_only && |  | ||||||
| 		    !ofnode_pre_reloc(offset_to_ofnode(offset))) |  | ||||||
| 			continue; | 			continue; | ||||||
| 		/*
 | 		/*
 | ||||||
| 		 * If this node has "compatible" property, this is not | 		 * If this node has "compatible" property, this is not | ||||||
| 		 * a clock sub-node, but a normal device. skip. | 		 * a clock sub-node, but a normal device. skip. | ||||||
| 		 */ | 		 */ | ||||||
| 		fdt_get_property(fdt, offset, "compatible", &ret); | 		if (ofnode_read_prop(node, "compatible", NULL)) | ||||||
| 		if (ret >= 0) |  | ||||||
| 			continue; | 			continue; | ||||||
| 
 | 
 | ||||||
| 		if (ret != -FDT_ERR_NOTFOUND) | 		if (ret != -FDT_ERR_NOTFOUND) | ||||||
| 			return ret; | 			return ret; | ||||||
| 
 | 
 | ||||||
| 		name = fdt_get_name(fdt, offset, NULL); | 		name = ofnode_get_name(node); | ||||||
| 		if (!name) | 		if (!name) | ||||||
| 			return -EINVAL; | 			return -EINVAL; | ||||||
| 		ret = device_bind_driver_to_node(dev, drv_name, name, | 		ret = device_bind_driver_to_node(dev, drv_name, name, node, | ||||||
| 					offset_to_ofnode(offset), NULL); | 						 NULL); | ||||||
| 		if (ret) | 		if (ret) | ||||||
| 			return ret; | 			return ret; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -36,7 +36,7 @@ int clk_register(struct clk *clk, const char *drv_name, | ||||||
| 		return -ENOENT; | 		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) { | 	if (ret) { | ||||||
| 		printf("%s: CLK: %s driver bind error [%d]!\n", __func__, name, | 		printf("%s: CLK: %s driver bind error [%d]!\n", __func__, name, | ||||||
| 		       ret); | 		       ret); | ||||||
|  |  | ||||||
|  | @ -157,8 +157,8 @@ static int gpio_mediatek_bind(struct udevice *parent) | ||||||
| 		plat->gpio_count = MTK_BANK_WIDTH; | 		plat->gpio_count = MTK_BANK_WIDTH; | ||||||
| 		plat->bank = bank; | 		plat->bank = bank; | ||||||
| 
 | 
 | ||||||
| 		ret = device_bind_offset(parent, parent->driver, | 		ret = device_bind(parent, parent->driver, plat->bank_name, plat, | ||||||
| 					 plat->bank_name, plat, -1, &dev); | 				  ofnode_null(), &dev); | ||||||
| 		if (ret) | 		if (ret) | ||||||
| 			return ret; | 			return ret; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -332,8 +332,8 @@ static int gpio_exynos_bind(struct udevice *parent) | ||||||
| 			return -ENOMEM; | 			return -ENOMEM; | ||||||
| 
 | 
 | ||||||
| 		plat->bank_name = fdt_get_name(blob, node, NULL); | 		plat->bank_name = fdt_get_name(blob, node, NULL); | ||||||
| 		ret = device_bind_offset(parent, parent->driver, | 		ret = device_bind(parent, parent->driver, plat->bank_name, plat, | ||||||
| 					 plat->bank_name, plat, -1, &dev); | 				  ofnode_null(), &dev); | ||||||
| 		if (ret) | 		if (ret) | ||||||
| 			return ret; | 			return ret; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -305,8 +305,8 @@ static int gpio_sunxi_bind(struct udevice *parent) | ||||||
| 		plat->bank_name = gpio_bank_name(soc_data->start + bank); | 		plat->bank_name = gpio_bank_name(soc_data->start + bank); | ||||||
| 		plat->gpio_count = SUNXI_GPIOS_PER_BANK; | 		plat->gpio_count = SUNXI_GPIOS_PER_BANK; | ||||||
| 
 | 
 | ||||||
| 		ret = device_bind_offset(parent, parent->driver, | 		ret = device_bind(parent, parent->driver, plat->bank_name, plat, | ||||||
| 					 plat->bank_name, plat, -1, &dev); | 				  ofnode_null(), &dev); | ||||||
| 		if (ret) | 		if (ret) | ||||||
| 			return ret; | 			return ret; | ||||||
| 		dev_set_of_offset(dev, dev_of_offset(parent)); | 		dev_set_of_offset(dev, dev_of_offset(parent)); | ||||||
|  |  | ||||||
|  | @ -190,8 +190,8 @@ static int tegra186_gpio_bind(struct udevice *parent) | ||||||
| 		plat->name = ctlr_data->ports[port].name; | 		plat->name = ctlr_data->ports[port].name; | ||||||
| 		plat->regs = &(regs[ctlr_data->ports[port].offset / 4]); | 		plat->regs = &(regs[ctlr_data->ports[port].offset / 4]); | ||||||
| 
 | 
 | ||||||
| 		ret = device_bind_offset(parent, parent->driver, plat->name, | 		ret = device_bind(parent, parent->driver, plat->name, plat, | ||||||
| 					 plat, -1, &dev); | 				  ofnode_null(), &dev); | ||||||
| 		if (ret) | 		if (ret) | ||||||
| 			return ret; | 			return ret; | ||||||
| 		dev_set_of_offset(dev, dev_of_offset(parent)); | 		dev_set_of_offset(dev, dev_of_offset(parent)); | ||||||
|  |  | ||||||
|  | @ -360,9 +360,9 @@ static int gpio_tegra_bind(struct udevice *parent) | ||||||
| 			plat->base_gpio = TEGRA_GPIOS_PER_PORT * base_port; | 			plat->base_gpio = TEGRA_GPIOS_PER_PORT * base_port; | ||||||
| 			plat->port_name = gpio_port_name(base_port); | 			plat->port_name = gpio_port_name(base_port); | ||||||
| 
 | 
 | ||||||
| 			ret = device_bind_offset(parent, parent->driver, | 			ret = device_bind(parent, parent->driver, | ||||||
| 						 plat->port_name, plat, -1, | 					  plat->port_name, plat, ofnode_null(), | ||||||
| 						 &dev); | 					  &dev); | ||||||
| 			if (ret) | 			if (ret) | ||||||
| 				return ret; | 				return ret; | ||||||
| 			dev_set_of_offset(dev, dev_of_offset(parent)); | 			dev_set_of_offset(dev, dev_of_offset(parent)); | ||||||
|  |  | ||||||
|  | @ -5477,8 +5477,8 @@ static int mvpp2_base_bind(struct udevice *parent) | ||||||
| 		sprintf(name, "mvpp2-%d", id); | 		sprintf(name, "mvpp2-%d", id); | ||||||
| 
 | 
 | ||||||
| 		/* Create child device UCLASS_ETH and bind it */ | 		/* Create child device UCLASS_ETH and bind it */ | ||||||
| 		device_bind_offset(parent, &mvpp2_driver, name, plat, subnode, &dev); | 		device_bind(parent, &mvpp2_driver, name, plat, | ||||||
| 		dev_set_of_offset(dev, subnode); | 			    offset_to_ofnode(subnode), &dev); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -125,9 +125,8 @@ int bcm283x_pinctl_probe(struct udevice *dev) | ||||||
| 	struct udevice *pdev; | 	struct udevice *pdev; | ||||||
| 
 | 
 | ||||||
| 	/* Create GPIO device as well */ | 	/* Create GPIO device as well */ | ||||||
| 	ret = device_bind_offset(dev, lists_driver_lookup_name("gpio_bcm2835"), | 	ret = device_bind(dev, lists_driver_lookup_name("gpio_bcm2835"), | ||||||
| 				 "gpio_bcm2835", NULL, dev_of_offset(dev), | 			  "gpio_bcm2835", NULL, dev_ofnode(dev), &pdev); | ||||||
| 				 &pdev); |  | ||||||
| 	if (ret) { | 	if (ret) { | ||||||
| 		/*
 | 		/*
 | ||||||
| 		 * While we really want the pinctrl driver to work to make | 		 * While we really want the pinctrl driver to work to make | ||||||
|  |  | ||||||
|  | @ -347,6 +347,7 @@ int meson_pinctrl_probe(struct udevice *dev) | ||||||
| 	int na, ns; | 	int na, ns; | ||||||
| 	char *name; | 	char *name; | ||||||
| 
 | 
 | ||||||
|  | 	/* FIXME: Should use livetree */ | ||||||
| 	na = fdt_address_cells(gd->fdt_blob, dev_of_offset(dev->parent)); | 	na = fdt_address_cells(gd->fdt_blob, dev_of_offset(dev->parent)); | ||||||
| 	if (na < 1) { | 	if (na < 1) { | ||||||
| 		debug("bad #address-cells\n"); | 		debug("bad #address-cells\n"); | ||||||
|  | @ -419,7 +420,8 @@ int meson_pinctrl_probe(struct udevice *dev) | ||||||
| 	sprintf(name, "meson-gpio"); | 	sprintf(name, "meson-gpio"); | ||||||
| 
 | 
 | ||||||
| 	/* Create child device UCLASS_GPIO and bind it */ | 	/* 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); | 	dev_set_of_offset(gpio_dev, gpio); | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -299,8 +299,8 @@ static int jr2_pinctrl_probe(struct udevice *dev) | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	ret = device_bind_offset(dev, &jr2_gpio_driver, "jr2-gpio", NULL, | 	ret = device_bind(dev, &jr2_gpio_driver, "jr2-gpio", NULL, | ||||||
| 				 dev_of_offset(dev), NULL); | 			  dev_ofnode(dev), NULL); | ||||||
| 
 | 
 | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
|  |  | ||||||
|  | @ -165,8 +165,8 @@ int luton_pinctrl_probe(struct udevice *dev) | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	ret = device_bind_offset(dev, &luton_gpio_driver, "luton-gpio", NULL, | 	ret = device_bind(dev, &luton_gpio_driver, "luton-gpio", NULL, | ||||||
| 				 dev_of_offset(dev), NULL); | 			  dev_ofnode(dev), NULL); | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -181,8 +181,8 @@ int ocelot_pinctrl_probe(struct udevice *dev) | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	ret = device_bind_offset(dev, &ocelot_gpio_driver, "ocelot-gpio", NULL, | 	ret = device_bind(dev, &ocelot_gpio_driver, "ocelot-gpio", NULL, | ||||||
| 				 dev_of_offset(dev), NULL); | 			  dev_ofnode(dev), NULL); | ||||||
| 
 | 
 | ||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -209,8 +209,8 @@ static int serval_pinctrl_probe(struct udevice *dev) | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	ret = device_bind_offset(dev, &serval_gpio_driver, "serval-gpio", NULL, | 	ret = device_bind(dev, &serval_gpio_driver, "serval-gpio", NULL, | ||||||
| 				 dev_of_offset(dev), NULL); | 			  dev_ofnode(dev), NULL); | ||||||
| 
 | 
 | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
|  |  | ||||||
|  | @ -245,8 +245,8 @@ static int servalt_pinctrl_probe(struct udevice *dev) | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	ret = device_bind_offset(dev, &servalt_gpio_driver, "servalt-gpio", NULL, | 	ret = device_bind(dev, &servalt_gpio_driver, "servalt-gpio", NULL, | ||||||
| 				 dev_of_offset(dev), NULL); | 			  dev_ofnode(dev), NULL); | ||||||
| 
 | 
 | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
|  |  | ||||||
|  | @ -547,13 +547,14 @@ static int armada_37xx_gpiochip_register(struct udevice *parent, | ||||||
| 	int subnode; | 	int subnode; | ||||||
| 	char *name; | 	char *name; | ||||||
| 
 | 
 | ||||||
| 	/* Lookup GPIO driver */ | 	/* FIXME: Should not need to lookup GPIO uclass */ | ||||||
| 	drv = lists_uclass_lookup(UCLASS_GPIO); | 	drv = lists_uclass_lookup(UCLASS_GPIO); | ||||||
| 	if (!drv) { | 	if (!drv) { | ||||||
| 		puts("Cannot find GPIO driver\n"); | 		puts("Cannot find GPIO driver\n"); | ||||||
| 		return -ENOENT; | 		return -ENOENT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/* FIXME: Use livtree and check the result of device_bind() below */ | ||||||
| 	fdt_for_each_subnode(subnode, blob, node) { | 	fdt_for_each_subnode(subnode, blob, node) { | ||||||
| 		if (fdtdec_get_bool(blob, subnode, "gpio-controller")) { | 		if (fdtdec_get_bool(blob, subnode, "gpio-controller")) { | ||||||
| 			ret = 0; | 			ret = 0; | ||||||
|  | @ -567,9 +568,8 @@ static int armada_37xx_gpiochip_register(struct udevice *parent, | ||||||
| 	sprintf(name, "armada-37xx-gpio"); | 	sprintf(name, "armada-37xx-gpio"); | ||||||
| 
 | 
 | ||||||
| 	/* Create child device UCLASS_GPIO and bind it */ | 	/* Create child device UCLASS_GPIO and bind it */ | ||||||
| 	device_bind_offset(parent, &armada_37xx_gpio_driver, name, NULL, | 	device_bind(parent, &armada_37xx_gpio_driver, name, NULL, | ||||||
| 			   subnode, &dev); | 		    offset_to_ofnode(subnode), &dev); | ||||||
| 	dev_set_of_offset(dev, subnode); |  | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ config DM_REGULATOR | ||||||
| 	- 'include/power/regulator.h' | 	- 'include/power/regulator.h' | ||||||
| 	- 'drivers/power/pmic/pmic-uclass.c' | 	- 'drivers/power/pmic/pmic-uclass.c' | ||||||
| 	- 'drivers/power/pmic/regulator-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 | 	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() | 	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. | 	otherwise. Detailed information can be found in the header file. | ||||||
|  |  | ||||||
|  | @ -37,8 +37,8 @@ struct udevice; | ||||||
|  * @return 0 if OK, -ve on error |  * @return 0 if OK, -ve on error | ||||||
|  */ |  */ | ||||||
| int device_bind_offset(struct udevice *parent, const struct driver *drv, | int device_bind_offset(struct udevice *parent, const struct driver *drv, | ||||||
| 		       const char *name, void *platdata, int of_offset, | 		const char *name, void *platdata, int of_offset, | ||||||
| 		       struct udevice **devp); | 		struct udevice **devp); | ||||||
| 
 | 
 | ||||||
| int device_bind(struct udevice *parent, const struct driver *drv, | int device_bind(struct udevice *parent, const struct driver *drv, | ||||||
| 		const char *name, void *platdata, ofnode node, | 		const char *name, void *platdata, ofnode node, | ||||||
|  |  | ||||||
|  | @ -48,7 +48,7 @@ | ||||||
|  * If regulator-name property is not provided, node name will be chosen. |  * If regulator-name property is not provided, node name will be chosen. | ||||||
|  * |  * | ||||||
|  * Regulator bind: |  * 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, |  * 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. |  * 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: |  * If the parent is not a PMIC device, and the child is not bind by function: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue