diff options
author | Simon Glass | 2017-01-17 16:52:55 -0700 |
---|---|---|
committer | Simon Glass | 2017-02-08 06:12:14 -0700 |
commit | e160f7d430f163bc42757aff3bf2bcac0a459f02 (patch) | |
tree | ce006f94b4a52f6fff567eacd86922c3be6df706 /drivers/spi/pic32_spi.c | |
parent | 8aa41363ebf46b9ff63b311bd2aa793c67a49def (diff) |
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>
Diffstat (limited to 'drivers/spi/pic32_spi.c')
-rw-r--r-- | drivers/spi/pic32_spi.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/spi/pic32_spi.c b/drivers/spi/pic32_spi.c index 25ca1f3e1ba..78d78bc54ba 100644 --- a/drivers/spi/pic32_spi.c +++ b/drivers/spi/pic32_spi.c @@ -377,13 +377,14 @@ static int pic32_spi_probe(struct udevice *bus) { struct pic32_spi_priv *priv = dev_get_priv(bus); struct dm_spi_bus *dm_spi = dev_get_uclass_priv(bus); + int node = dev_of_offset(bus); struct udevice *clkdev; fdt_addr_t addr; fdt_size_t size; int ret; debug("%s: %d, bus: %i\n", __func__, __LINE__, bus->seq); - addr = fdtdec_get_addr_size(gd->fdt_blob, bus->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(gd->fdt_blob, node, "reg", &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; @@ -391,8 +392,8 @@ static int pic32_spi_probe(struct udevice *bus) if (!priv->regs) return -EINVAL; - dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset, - "spi-max-frequency", 250000000); + dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, node, "spi-max-frequency", + 250000000); /* get clock rate */ ret = clk_get_by_index(bus, 0, &clkdev); if (ret < 0) { @@ -413,8 +414,7 @@ static int pic32_spi_probe(struct udevice *bus) * of the ongoing transfer. To avoid this sort of error we will drive * /CS manually by toggling cs-gpio pins. */ - ret = gpio_request_by_name_nodev(gd->fdt_blob, bus->of_offset, - "cs-gpios", 0, + ret = gpio_request_by_name_nodev(gd->fdt_blob, node, "cs-gpios", 0, &priv->cs_gpio, GPIOD_IS_OUT); if (ret) { printf("pic32-spi: error, cs-gpios not found\n"); |