dm: core: Replace of_offset with accessor

At present devices use a simple integer offset to record the device tree
node associated with the device. In preparation for supporting a live
device tree, which uses a node pointer instead, refactor existing code to
access this field through an inline function.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2017-01-17 16:52:55 -07:00
parent 8aa41363eb
commit e160f7d430
220 changed files with 445 additions and 407 deletions

View File

@@ -998,7 +998,7 @@ int cros_ec_register(struct udevice *dev)
{
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
char id[MSG_BYTES];
cdev->dev = dev;

View File

@@ -522,7 +522,7 @@ int cros_ec_probe(struct udevice *dev)
int err;
memcpy(ec, &s_state, sizeof(*ec));
err = cros_ec_decode_ec_flash(blob, dev->of_offset, &ec->ec_config);
err = cros_ec_decode_ec_flash(blob, dev_of_offset(dev), &ec->ec_config);
if (err)
return err;
@@ -531,7 +531,7 @@ int cros_ec_probe(struct udevice *dev)
keyb_dev;
device_find_next_child(&keyb_dev)) {
if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) {
node = keyb_dev->of_offset;
node = dev_of_offset(keyb_dev);
break;
}
}

View File

@@ -115,9 +115,9 @@ static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev)
{
struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev);
plat->size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
plat->size = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"sandbox,size", 32);
plat->filename = fdt_getprop(gd->fdt_blob, dev->of_offset,
plat->filename = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
"sandbox,filename", NULL);
if (!plat->filename) {
debug("%s: No filename for device '%s'\n", __func__,

View File

@@ -112,19 +112,19 @@ static int tegra186_bpmp_bind(struct udevice *dev)
debug("%s(dev=%p)\n", __func__, dev);
ret = device_bind_driver_to_node(dev, "tegra186_clk", "tegra186_clk",
dev->of_offset, &child);
dev_of_offset(dev), &child);
if (ret)
return ret;
ret = device_bind_driver_to_node(dev, "tegra186_reset",
"tegra186_reset", dev->of_offset,
"tegra186_reset", dev_of_offset(dev),
&child);
if (ret)
return ret;
ret = device_bind_driver_to_node(dev, "tegra186_power_domain",
"tegra186_power_domain",
dev->of_offset, &child);
dev_of_offset(dev), &child);
if (ret)
return ret;
@@ -141,7 +141,7 @@ static ulong tegra186_bpmp_get_shmem(struct udevice *dev, int index)
struct fdtdec_phandle_args args;
fdt_addr_t reg;
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
"shmem", NULL, 0, index, &args);
if (ret < 0) {
error("fdtdec_parse_phandle_with_args() failed: %d\n", ret);

View File

@@ -22,12 +22,12 @@ static int tegra_car_bpmp_bind(struct udevice *dev)
debug("%s(dev=%p)\n", __func__, dev);
ret = device_bind_driver_to_node(dev, "tegra_car_clk", "tegra_car_clk",
dev->of_offset, &child);
dev_of_offset(dev), &child);
if (ret)
return ret;
ret = device_bind_driver_to_node(dev, "tegra_car_reset",
"tegra_car_reset", dev->of_offset,
"tegra_car_reset", dev_of_offset(dev),
&child);
if (ret)
return ret;