dm: Avoid accessing seq directly

At present various drivers etc. access the device's 'seq' member directly.
This makes it harder to change the meaning of that member. Change access
to go through a function instead.

The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2020-12-16 21:20:07 -07:00
parent 0b2fa98aa5
commit 8b85dfc675
98 changed files with 211 additions and 197 deletions

View File

@ -42,7 +42,7 @@ struct mxc_i2c_bus {
/*
* board file can use this index to locate which i2c_pads_info is for
* i2c_idle_bus. When pinmux is implement, this entry can be
* discarded. Here we do not use dev->seq, because we do not want to
* discarded. Here we do not use dev_seq(dev), because we do not want to
* export device to board file.
*/
int index;

View File

@ -638,7 +638,7 @@ static int broadwell_get_count(const struct udevice *dev)
static int cpu_x86_broadwell_probe(struct udevice *dev)
{
if (dev->seq == 0) {
if (dev_seq(dev) == 0) {
cpu_core_init(dev);
return broadwell_init(dev);
}

View File

@ -425,7 +425,7 @@ static int model_206ax_get_count(const struct udevice *dev)
static int cpu_x86_model_206ax_probe(struct udevice *dev)
{
if (dev->seq == 0)
if (dev_seq(dev) == 0)
model_206ax_init(dev);
return 0;

View File

@ -153,9 +153,9 @@ int board_late_init(void)
puts("Boot from EMMC but without SD1 enabled!\n");
return -1;
}
debug("mmc1 device found at %p, seq %d\n", dev, dev->seq);
debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev));
mode = "mmc";
bootseq = dev->seq;
bootseq = dev_seq(dev);
break;
case SD_MODE:
puts("SD_MODE\n");
@ -164,10 +164,10 @@ int board_late_init(void)
puts("Boot from SD0 but without SD0 enabled!\n");
return -1;
}
debug("mmc0 device found at %p, seq %d\n", dev, dev->seq);
debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev));
mode = "mmc";
bootseq = dev->seq;
bootseq = dev_seq(dev);
break;
case SD1_LSHFT_MODE:
puts("LVL_SHFT_");
@ -179,10 +179,10 @@ int board_late_init(void)
puts("Boot from SD1 but without SD1 enabled!\n");
return -1;
}
debug("mmc1 device found at %p, seq %d\n", dev, dev->seq);
debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev));
mode = "mmc";
bootseq = dev->seq;
bootseq = dev_seq(dev);
break;
default:
mode = "";

View File

@ -596,10 +596,10 @@ int board_late_init(void)
puts("Boot from EMMC but without SD0 enabled!\n");
return -1;
}
debug("mmc0 device found at %p, seq %d\n", dev, dev->seq);
debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev));
mode = "mmc";
bootseq = dev->seq;
bootseq = dev_seq(dev);
break;
case SD_MODE:
puts("SD_MODE\n");
@ -610,10 +610,10 @@ int board_late_init(void)
puts("Boot from SD0 but without SD0 enabled!\n");
return -1;
}
debug("mmc0 device found at %p, seq %d\n", dev, dev->seq);
debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev));
mode = "mmc";
bootseq = dev->seq;
bootseq = dev_seq(dev);
env_set("modeboot", "sdboot");
break;
case SD1_LSHFT_MODE:
@ -628,10 +628,10 @@ int board_late_init(void)
puts("Boot from SD1 but without SD1 enabled!\n");
return -1;
}
debug("mmc1 device found at %p, seq %d\n", dev, dev->seq);
debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev));
mode = "mmc";
bootseq = dev->seq;
bootseq = dev_seq(dev);
env_set("modeboot", "sdboot");
break;
case NAND_MODE:

View File

@ -35,7 +35,7 @@ static void show_bus(struct udevice *bus)
printf("Bus %d:\t%s", bus->req_seq, bus->name);
if (device_active(bus))
printf(" (active %d)", bus->seq);
printf(" (active %d)", dev_seq(bus));
printf("\n");
for (device_find_first_child(bus, &dev);
dev;
@ -147,7 +147,7 @@ static int do_axi_bus_num(struct cmd_tbl *cmdtp, int flag, int argc,
struct udevice *bus;
if (!axi_get_cur_bus(&bus))
bus_no = bus->seq;
bus_no = dev_seq(bus);
else
bus_no = -1;

View File

@ -32,7 +32,7 @@ static int print_cpu_list(bool detail)
int ret, i;
ret = cpu_get_desc(dev, buf, sizeof(buf));
printf("%3d: %-10s %s\n", dev->seq, dev->name,
printf("%3d: %-10s %s\n", dev_seq(dev), dev->name,
ret ? "<no description>" : buf);
if (!detail)
continue;

View File

@ -1702,7 +1702,7 @@ static void show_bus(struct udevice *bus)
printf("Bus %d:\t%s", bus->req_seq, bus->name);
if (device_active(bus))
printf(" (active %d)", bus->seq);
printf(" (active %d)", dev_seq(bus));
printf("\n");
for (device_find_first_child(bus, &dev);
dev;
@ -1825,7 +1825,7 @@ static int do_i2c_bus_num(struct cmd_tbl *cmdtp, int flag, int argc,
struct udevice *bus;
if (!i2c_get_cur_bus(&bus))
bus_no = bus->seq;
bus_no = dev_seq(bus);
else
bus_no = -1;
#else

View File

@ -34,7 +34,7 @@ static int do_misc_list(struct cmd_tbl *cmdtp, int flag,
for (uclass_first_device(UCLASS_MISC, &dev);
dev;
uclass_next_device(&dev)) {
printf("%-20s %5d %10s\n", dev->name, dev->seq,
printf("%-20s %5d %10s\n", dev->name, dev_seq(dev),
dev->driver->name);
}

View File

@ -77,7 +77,7 @@ static void show_osd(struct udevice *osd)
{
printf("OSD %d:\t%s", osd->req_seq, osd->name);
if (device_active(osd))
printf(" (active %d)", osd->seq);
printf(" (active %d)", dev_seq(osd));
printf("\n");
}
@ -235,7 +235,7 @@ static int do_osd_num(struct cmd_tbl *cmdtp, int flag, int argc,
struct udevice *osd;
if (!osd_get_osd_cur(&osd))
osd_no = osd->seq;
osd_no = dev_seq(osd);
else
osd_no = -1;
printf("Current osd is %d\n", osd_no);

View File

@ -334,7 +334,7 @@ static void pciinfo(struct udevice *bus, bool short_listing)
{
struct udevice *dev;
pciinfo_header(bus->seq, short_listing);
pciinfo_header(dev_seq(bus), short_listing);
for (device_find_first_child(bus, &dev);
dev;
@ -343,11 +343,12 @@ static void pciinfo(struct udevice *bus, bool short_listing)
pplat = dev_get_parent_plat(dev);
if (short_listing) {
printf("%02x.%02x.%02x ", bus->seq,
printf("%02x.%02x.%02x ", dev_seq(bus),
PCI_DEV(pplat->devfn), PCI_FUNC(pplat->devfn));
pci_header_show_brief(dev);
} else {
printf("\nFound PCI device %02x.%02x.%02x:\n", bus->seq,
printf("\nFound PCI device %02x.%02x.%02x:\n",
dev_seq(bus),
PCI_DEV(pplat->devfn), PCI_FUNC(pplat->devfn));
pci_header_show(dev);
}

View File

@ -41,7 +41,7 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
return CMD_RET_USAGE;
}
printf("dev: %d @ %s\n", currdev->seq, currdev->name);
printf("dev: %d @ %s\n", dev_seq(currdev), currdev->name);
}
return CMD_RET_SUCCESS;
@ -66,7 +66,7 @@ static int do_list(struct cmd_tbl *cmdtp, int flag, int argc,
printf("| %-*.*s| %-*.*s| %s @ %d\n",
LIMIT_DEV, LIMIT_DEV, dev->name,
LIMIT_PARENT, LIMIT_PARENT, dev->parent->name,
dev_get_uclass_name(dev->parent), dev->parent->seq);
dev_get_uclass_name(dev->parent), dev_seq(dev->parent));
}
if (ret)

View File

@ -47,7 +47,7 @@ static int print_remoteproc_list(void)
break;
}
printf("%d - Name:'%s' type:'%s' supports: %s%s%s%s%s%s\n",
dev->seq,
dev_seq(dev),
uc_pdata->name,
type,
ops->load ? "load " : "",

View File

@ -21,7 +21,7 @@ static int w1_bus(void)
printf("one wire interface not found\n");
return CMD_RET_FAILURE;
}
printf("Bus %d:\t%s", bus->seq, bus->name);
printf("Bus %d:\t%s", dev_seq(bus), bus->name);
if (device_active(bus))
printf(" (active)");
printf("\n");
@ -31,7 +31,7 @@ static int w1_bus(void)
device_find_next_child(&dev)) {
ret = device_probe(dev);
printf("\t%s (%d) uclass %s : ", dev->name, dev->seq,
printf("\t%s (%d) uclass %s : ", dev->name, dev_seq(dev),
dev->uclass->uc_drv->name);
if (ret)

View File

@ -655,7 +655,7 @@ int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq,
return -ENODEV;
list_for_each_entry(dev, &parent->child_head, sibling_node) {
if ((find_req_seq ? dev->req_seq : dev->seq) ==
if ((find_req_seq ? dev->req_seq : dev_seq(dev)) ==
seq_or_req_seq) {
*devp = dev;
return 0;

View File

@ -67,8 +67,8 @@ static void dm_display_line(struct udevice *dev, int index)
printf("%-3i %c %s @ %08lx", index,
dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
dev->name, (ulong)map_to_sysmem(dev));
if (dev->seq != -1 || dev->req_seq != -1)
printf(", seq %d, (req %d)", dev->seq, dev->req_seq);
if (dev_seq(dev) != -1 || dev->req_seq != -1)
printf(", seq %d, (req %d)", dev_seq(dev), dev->req_seq);
puts("\n");
}

View File

@ -311,8 +311,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
uclass_foreach_dev(dev, uc) {
log_debug(" - %d %d '%s'\n",
dev->req_seq, dev->seq, dev->name);
if ((find_req_seq ? dev->req_seq : dev->seq) ==
dev->req_seq, dev_seq(dev), dev->name);
if ((find_req_seq ? dev->req_seq : dev_seq(dev)) ==
seq_or_req_seq) {
*devp = dev;
log_debug(" - found\n");
@ -695,7 +695,7 @@ int uclass_resolve_seq(struct udevice *dev)
int seq = 0;
int ret;
assert(dev->seq == -1);
assert(dev_seq(dev) == -1);
ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup);
if (!ret) {
dm_warn("Device '%s': seq %d is in use by '%s'\n",

View File

@ -202,7 +202,7 @@ static int octeon_gpio_probe(struct udevice *dev)
uc_priv->bank_name = strdup(dev->name);
end = strchr(uc_priv->bank_name, '@');
end[0] = 'A' + dev->seq;
end[0] = 'A' + dev_seq(dev);
end[1] = '\0';
debug("%s(%s): base address: %p, pin count: %d\n",

View File

@ -110,7 +110,7 @@ static int ast_i2c_probe(struct udevice *dev)
{
struct ast2500_scu *scu;
debug("Enabling I2C%u\n", dev->seq);
debug("Enabling I2C%u\n", dev_seq(dev));
/*
* Get all I2C devices out of Reset.
@ -307,7 +307,7 @@ static int ast_i2c_set_speed(struct udevice *dev, unsigned int speed)
struct ast_i2c_regs *regs = priv->regs;
ulong i2c_rate, divider;
debug("Setting speed for I2C%d to <%u>\n", dev->seq, speed);
debug("Setting speed for I2C%d to <%u>\n", dev_seq(dev), speed);
if (!speed) {
debug("No valid speed specified\n");
return -EINVAL;

View File

@ -470,7 +470,7 @@ static int davinci_i2c_probe(struct udevice *dev)
{
struct i2c_bus *i2c_bus = dev_get_priv(dev);
i2c_bus->id = dev->seq;
i2c_bus->id = dev_seq(dev);
i2c_bus->regs = dev_read_addr_ptr(dev);
i2c_bus->speed = 100000;

View File

@ -533,7 +533,7 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)
dev_read_u32_default(dev, "clock-frequency",
I2C_SPEED_STANDARD_RATE);
i2c_bus->node = node;
i2c_bus->bus_num = dev->seq;
i2c_bus->bus_num = dev_seq(dev);
exynos_pinmux_config(i2c_bus->id, PINMUX_FLAG_HS_MODE);

View File

@ -298,7 +298,7 @@ static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags)
i2c_gpio_send_stop(bus, delay);
debug("%s: bus: %d (%s) chip: %x flags: %x ret: %d\n",
__func__, dev->seq, dev->name, chip, chip_flags, ret);
__func__, dev_seq(dev), dev->name, chip, chip_flags, ret);
return ret;
}

View File

@ -289,7 +289,7 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
return clock_rate;
}
} else {
clock_rate = imx_get_i2cclk(bus->seq);
clock_rate = imx_get_i2cclk(dev_seq(bus));
if (!clock_rate)
return -EPERM;
}
@ -377,7 +377,7 @@ static int bus_i2c_init(struct udevice *bus, int speed)
val = readl(&regs->mcr) & ~LPI2C_MCR_MEN_MASK;
writel(val | LPI2C_MCR_MEN(1), &regs->mcr);
debug("i2c : controller bus %d, speed %d:\n", bus->seq, speed);
debug("i2c : controller bus %d, speed %d:\n", dev_seq(bus), speed);
return ret;
}
@ -452,11 +452,11 @@ static int imx_lpi2c_probe(struct udevice *bus)
return -EINVAL;
i2c_bus->base = addr;
i2c_bus->index = bus->seq;
i2c_bus->index = dev_seq(bus);
i2c_bus->bus = bus;
/* power up i2c resource */
ret = init_i2c_power(bus->seq);
ret = init_i2c_power(dev_seq(bus));
if (ret) {
debug("init_i2c_power err = %d\n", ret);
return ret;
@ -486,7 +486,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
}
} else {
/* To i.MX7ULP, only i2c4-7 can be handled by A7 core */
ret = enable_i2c_clk(1, bus->seq);
ret = enable_i2c_clk(1, dev_seq(bus));
if (ret < 0)
return ret;
}
@ -496,7 +496,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
return ret;
debug("i2c : controller bus %d at 0x%lx , speed %d: ",
bus->seq, i2c_bus->base,
dev_seq(bus), i2c_bus->base,
i2c_bus->speed);
return 0;

View File

@ -282,7 +282,11 @@ U_BOOT_I2C_ADAP_COMPLETE(lpc32xx_2, lpc32xx_i2c_init, NULL,
static int lpc32xx_i2c_probe(struct udevice *bus)
{
struct lpc32xx_i2c_dev *dev = dev_get_plat(bus);
bus->seq = dev->index;
/*
* FIXME: This is not permitted
* dev_seq(bus) = dev->index;
*/
__i2c_init(dev->base, dev->speed, 0, dev->index);
return 0;

View File

@ -914,7 +914,7 @@ static int mxc_i2c_probe(struct udevice *bus)
}
i2c_bus->base = addr;
i2c_bus->index = bus->seq;
i2c_bus->index = dev_seq(bus);
i2c_bus->bus = bus;
/* Enable clk */
@ -930,7 +930,7 @@ static int mxc_i2c_probe(struct udevice *bus)
return ret;
}
#else
ret = enable_i2c_clk(1, bus->seq);
ret = enable_i2c_clk(1, dev_seq(bus));
if (ret < 0)
return ret;
#endif
@ -942,7 +942,7 @@ static int mxc_i2c_probe(struct udevice *bus)
ret = fdt_stringlist_search(fdt, node, "pinctrl-names", "gpio");
if (ret < 0) {
debug("i2c bus %d at 0x%2lx, no gpio pinctrl state.\n",
bus->seq, i2c_bus->base);
dev_seq(bus), i2c_bus->base);
} else {
ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
"scl-gpios", 0, &i2c_bus->scl_gpio,
@ -955,7 +955,7 @@ static int mxc_i2c_probe(struct udevice *bus)
ret || ret2) {
dev_err(bus,
"i2c bus %d at %lu, fail to request scl/sda gpio\n",
bus->seq, i2c_bus->base);
dev_seq(bus), i2c_bus->base);
return -EINVAL;
}
}
@ -966,7 +966,7 @@ static int mxc_i2c_probe(struct udevice *bus)
*/
debug("i2c : controller bus %d at %lu , speed %d: ",
bus->seq, i2c_bus->base,
dev_seq(bus), i2c_bus->base,
i2c_bus->speed);
return 0;

View File

@ -240,7 +240,7 @@ static int nx_i2c_probe(struct udevice *dev)
return -EINVAL;
bus->regs = (struct nx_i2c_regs *)addr;
bus->bus_num = dev->seq;
bus->bus_num = dev_seq(dev);
/* i2c node parsing */
i2c_process_node(dev);

View File

@ -811,7 +811,7 @@ static int octeon_i2c_probe(struct udevice *dev)
if (ret)
return ret;
debug("TWSI bus %d at %p\n", dev->seq, twsi->base);
debug("TWSI bus %d at %p\n", dev_seq(dev), twsi->base);
/* Start with standard speed, real speed set via DT or cmd */
return twsi_init(twsi->base, i2c_slave_addr);

View File

@ -318,7 +318,7 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)
dev_read_u32_default(dev, "clock-frequency",
I2C_SPEED_STANDARD_RATE);
i2c_bus->node = node;
i2c_bus->bus_num = dev->seq;
i2c_bus->bus_num = dev_seq(dev);
exynos_pinmux_config(i2c_bus->id, 0);

View File

@ -362,7 +362,7 @@ static int tegra_i2c_probe(struct udevice *dev)
int ret;
bool is_dvc;
i2c_bus->id = dev->seq;
i2c_bus->id = dev_seq(dev);
i2c_bus->type = dev_get_driver_data(dev);
i2c_bus->regs = (struct i2c_ctlr *)dev_read_addr(dev);
if ((ulong)i2c_bus->regs == FDT_ADDR_T_NONE) {
@ -408,7 +408,8 @@ static int tegra_i2c_probe(struct udevice *dev)
}
i2c_init_controller(i2c_bus);
debug("%s: controller bus %d at %p, speed %d: ",
is_dvc ? "dvc" : "i2c", dev->seq, i2c_bus->regs, i2c_bus->speed);
is_dvc ? "dvc" : "i2c", dev_seq(dev), i2c_bus->regs,
i2c_bus->speed);
return 0;
}

View File

@ -1542,7 +1542,7 @@ static int fsl_esdhc_probe(struct udevice *dev)
* work as expected.
*/
init_clk_usdhc(dev->seq);
init_clk_usdhc(dev_seq(dev));
#if CONFIG_IS_ENABLED(CLK)
/* Assigned clock already set clock */
@ -1559,7 +1559,7 @@ static int fsl_esdhc_probe(struct udevice *dev)
priv->sdhc_clk = clk_get_rate(&priv->per_clk);
#else
priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev->seq);
priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev_seq(dev));
if (priv->sdhc_clk <= 0) {
dev_err(dev, "Unable to get clk for %s\n", dev->name);
return -EINVAL;

View File

@ -131,7 +131,7 @@ static int sandbox_sf_probe(struct udevice *dev)
int ret = 0;
int cs = -1;
debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev);
debug("%s: bus %d, looking for emul=%p: ", __func__, dev_seq(bus), dev);
ret = sandbox_spi_get_emul(state, bus, dev, &emul);
if (ret) {
printf("Error: Unknown chip select for device '%s'\n",
@ -565,7 +565,7 @@ int sandbox_spi_get_emul(struct sandbox_state *state,
struct udevice **emulp)
{
struct sandbox_spi_info *info;
int busnum = bus->seq;
int busnum = dev_seq(bus);
int cs = spi_chip_select(slave);
int ret;

View File

@ -1451,7 +1451,7 @@ static int fecmxc_probe(struct udevice *dev)
fec_reg_setup(priv);
priv->dev_id = dev->seq;
priv->dev_id = dev_seq(dev);
#ifdef CONFIG_DM_ETH_PHY
bus = eth_phy_get_mdio_bus(dev);
@ -1459,9 +1459,10 @@ static int fecmxc_probe(struct udevice *dev)
if (!bus) {
#ifdef CONFIG_FEC_MXC_MDIO_BASE
bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE,
dev_seq(dev));
#else
bus = fec_get_miibus((ulong)priv->eth, dev->seq);
bus = fec_get_miibus((ulong)priv->eth, dev_seq(dev));
#endif
}
if (!bus) {

View File

@ -187,7 +187,7 @@ static int mc_fixup_mac_addr(void *blob, int nodeoffset,
#ifdef CONFIG_DM_ETH
struct eth_pdata *plat = dev_get_plat(eth_dev);
unsigned char *enetaddr = plat->enetaddr;
int eth_index = eth_dev->seq;
int eth_index = dev_seq(eth_dev);
#else
unsigned char *enetaddr = eth_dev->enetaddr;
int eth_index = eth_dev->index;

View File

@ -502,7 +502,7 @@ static int mcdmafec_probe(struct udevice *dev)
int retval;
const u32 *val;
info->index = dev->seq;
info->index = dev_seq(dev);
info->iobase = pdata->iobase;
info->miibase = pdata->iobase;
info->phy_addr = -1;

View File

@ -171,7 +171,7 @@ static int ftgmac100_mdio_init(struct udevice *dev)
bus->write = ftgmac100_mdio_write;
bus->priv = priv;
ret = mdio_register_seq(bus, dev->seq);
ret = mdio_register_seq(bus, dev_seq(dev));
if (ret) {
free(bus);
return ret;

View File

@ -528,7 +528,7 @@ static int higmac_probe(struct udevice *dev)
bus->priv = priv;
priv->bus = bus;
ret = mdio_register_seq(bus, dev->seq);
ret = mdio_register_seq(bus, dev_seq(dev));
if (ret)
return ret;

View File

@ -524,7 +524,7 @@ static int mcffec_probe(struct udevice *dev)
int retval, fec_idx;
const u32 *val;
info->index = dev->seq;
info->index = dev_seq(dev);
info->iobase = pdata->iobase;
info->phy_addr = -1;

View File

@ -452,11 +452,12 @@ int nicvf_write_hwaddr(struct udevice *dev)
* u-boot framework updates MAC to random address.
* Use this hook to update mac address in environment.
*/
if (!eth_env_get_enetaddr_by_index("eth", dev->seq, ethaddr)) {
eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
if (!eth_env_get_enetaddr_by_index("eth", dev_seq(dev), ethaddr)) {
eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
pdata->enetaddr);
debug("%s: pMAC %pM\n", __func__, pdata->enetaddr);
}
eth_env_get_enetaddr_by_index("eth", dev->seq, ethaddr);
eth_env_get_enetaddr_by_index("eth", dev_seq(dev), ethaddr);
if (memcmp(ethaddr, pdata->enetaddr, ARP_HLEN)) {
debug("%s: pMAC %pM\n", __func__, pdata->enetaddr);
nicvf_hw_set_mac_addr(nic, dev);
@ -540,7 +541,7 @@ int nicvf_initialize(struct udevice *dev)
if (is_valid_ethaddr(ethaddr)) {
memcpy(pdata->enetaddr, ethaddr, ARP_HLEN);
eth_env_set_enetaddr_by_index("eth", dev->seq, ethaddr);
eth_env_set_enetaddr_by_index("eth", dev_seq(dev), ethaddr);
}
debug("%s enetaddr %pM ethaddr %pM\n", __func__,
pdata->enetaddr, ethaddr);

View File

@ -335,7 +335,7 @@ int octeontx_smi_probe(struct udevice *dev)
priv = malloc(sizeof(*priv));
if (!bus || !priv) {
printf("Failed to allocate OcteonTX MDIO bus # %u\n",
dev->seq);
dev_seq(dev));
return -1;
}

View File

@ -736,7 +736,7 @@ int nix_lf_setup_mac(struct udevice *dev)
*/
if (memcmp(nix->lmac->mac_addr, pdata->enetaddr, ARP_HLEN)) {
memcpy(nix->lmac->mac_addr, pdata->enetaddr, 6);
eth_env_set_enetaddr_by_index("eth", rvu->dev->seq,
eth_env_set_enetaddr_by_index("eth", dev_seq(rvu->dev),
pdata->enetaddr);
cgx_lmac_mac_filter_setup(nix->lmac);
/* Update user given MAC address to ATF for update

View File

@ -34,7 +34,7 @@ int rvu_pf_init(struct rvu_pf *rvu)
/* to make post_probe happy */
if (is_valid_ethaddr(nix->lmac->mac_addr)) {
memcpy(pdata->enetaddr, nix->lmac->mac_addr, 6);
eth_env_set_enetaddr_by_index("eth", rvu->dev->seq,
eth_env_set_enetaddr_by_index("eth", dev_seq(rvu->dev),
pdata->enetaddr);
}
@ -59,7 +59,7 @@ int rvu_pf_probe(struct udevice *dev)
debug("%s: name: %s\n", __func__, dev->name);
rvu->pf_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_2, PCI_REGION_MEM);
rvu->pfid = dev->seq + 1; // RVU PF's start from 1;
rvu->pfid = dev_seq(dev) + 1; // RVU PF's start from 1;
rvu->dev = dev;
if (!rvu_af_dev) {
printf("%s: Error: Could not find RVU AF device\n",
@ -80,7 +80,7 @@ int rvu_pf_probe(struct udevice *dev)
* modify device name to include index/sequence number,
* for better readability, this is 1:1 mapping with eth0/1/2.. names.
*/
sprintf(name, "rvu_pf#%d", dev->seq);
sprintf(name, "rvu_pf#%d", dev_seq(dev));
device_set_name(dev, name);
debug("%s: name: %s\n", __func__, dev->name);
return err;

View File

@ -697,7 +697,7 @@ static int axi_emac_probe(struct udevice *dev)
priv->bus->write = axiemac_miiphy_write;
priv->bus->priv = priv;
ret = mdio_register_seq(priv->bus, dev->seq);
ret = mdio_register_seq(priv->bus, dev_seq(dev));
if (ret)
return ret;

View File

@ -568,7 +568,7 @@ static int emaclite_probe(struct udevice *dev)
emaclite->bus->write = emaclite_miiphy_write;
emaclite->bus->priv = emaclite;
ret = mdio_register_seq(emaclite->bus, dev->seq);
ret = mdio_register_seq(emaclite->bus, dev_seq(dev));
if (ret)
return ret;

View File

@ -705,7 +705,7 @@ static int zynq_gem_probe(struct udevice *dev)
priv->bus->write = zynq_gem_miiphy_write;
priv->bus->priv = priv;
ret = mdio_register_seq(priv->bus, dev->seq);
ret = mdio_register_seq(priv->bus, dev_seq(dev));
if (ret)
goto err2;

View File

@ -638,7 +638,7 @@ static int pcie_advk_probe(struct udevice *dev)
dev_warn(pcie->dev, "PCIE Reset on GPIO support is missing\n");
}
pcie->first_busno = dev->seq;
pcie->first_busno = dev_seq(dev);
pcie->dev = pci_get_controller(dev);
return pcie_advk_setup_hw(pcie);

View File

@ -65,7 +65,7 @@ pci_dev_t dm_pci_get_bdf(const struct udevice *dev)
if (!device_active(bus))
log_err("PCI: Device '%s' on unprobed bus '%s'\n", dev->name,
bus->name);
return PCI_ADD_BUS(bus->seq, pplat->devfn);
return PCI_ADD_BUS(dev_seq(bus), pplat->devfn);
}
/**
@ -81,8 +81,8 @@ static int pci_get_bus_max(void)
ret = uclass_get(UCLASS_PCI, &uc);
uclass_foreach_dev(bus, uc) {
if (bus->seq > ret)
ret = bus->seq;
if (dev_seq(bus) > ret)
ret = dev_seq(bus);
}
debug("%s: ret=%d\n", __func__, ret);
@ -513,7 +513,7 @@ static void set_vga_bridge_bits(struct udevice *dev)
struct udevice *parent = dev->parent;
u16 bc;
while (parent->seq != 0) {
while (dev_seq(parent) != 0) {
dm_pci_read_config16(parent, PCI_BRIDGE_CONTROL, &bc);
bc |= PCI_BRIDGE_CTL_VGA;
dm_pci_write_config16(parent, PCI_BRIDGE_CONTROL, bc);
@ -529,7 +529,7 @@ int pci_auto_config_devices(struct udevice *bus)
struct udevice *dev;
int ret;
sub_bus = bus->seq;
sub_bus = dev_seq(bus);
debug("%s: start\n", __func__);
pciauto_config_init(hose);
for (ret = device_find_first_child(bus, &dev);
@ -645,9 +645,9 @@ int dm_pci_hose_probe_bus(struct udevice *bus)
}
if (!ea_pos) {
if (sub_bus != bus->seq) {
if (sub_bus != dev_seq(bus)) {
debug("%s: Internal error, bus '%s' got seq %d, expected %d\n",
__func__, bus->name, bus->seq, sub_bus);
__func__, bus->name, dev_seq(bus), sub_bus);
return -EPIPE;
}
sub_bus = pci_get_bus_max();
@ -771,7 +771,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,
return -EPERM;
/* Bind a generic driver so that the device can be used */
sprintf(name, "pci_%x:%x.%x", parent->seq, PCI_DEV(bdf),
sprintf(name, "pci_%x:%x.%x", dev_seq(parent), PCI_DEV(bdf),
PCI_FUNC(bdf));
str = strdup(name);
if (!str)
@ -803,9 +803,9 @@ int pci_bind_bus_devices(struct udevice *bus)
int ret;
found_multi = false;
end = PCI_BDF(bus->seq, PCI_MAX_PCI_DEVICES - 1,
end = PCI_BDF(dev_seq(bus), PCI_MAX_PCI_DEVICES - 1,
PCI_MAX_PCI_FUNCTIONS - 1);
for (bdf = PCI_BDF(bus->seq, 0, 0); bdf <= end;
for (bdf = PCI_BDF(dev_seq(bus), 0, 0); bdf <= end;
bdf += PCI_BDF(0, 0, 1)) {
struct pci_child_plat *pplat;
struct udevice *dev;
@ -832,7 +832,7 @@ int pci_bind_bus_devices(struct udevice *bus)
found_multi = header_type & 0x80;
debug("%s: bus %d/%s: found device %x, function %d", __func__,
bus->seq, bus->name, PCI_DEV(bdf), PCI_FUNC(bdf));
dev_seq(bus), bus->name, PCI_DEV(bdf), PCI_FUNC(bdf));
pci_bus_read_config(bus, bdf, PCI_DEVICE_ID, &device,
PCI_SIZE_16);
pci_bus_read_config(bus, bdf, PCI_CLASS_REVISION, &class,
@ -1010,7 +1010,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
{
struct pci_controller *hose;
debug("%s, bus=%d/%s, parent=%s\n", __func__, bus->seq, bus->name,
debug("%s, bus=%d/%s, parent=%s\n", __func__, dev_seq(bus), bus->name,
bus->parent->name);
hose = bus->uclass_priv;
@ -1025,8 +1025,8 @@ static int pci_uclass_pre_probe(struct udevice *bus)
hose->ctlr = parent_hose->bus;
}
hose->bus = bus;
hose->first_busno = bus->seq;
hose->last_busno = bus->seq;
hose->first_busno = dev_seq(bus);
hose->last_busno = dev_seq(bus);
if (dev_of_valid(bus)) {
hose->skip_auto_config_until_reloc =
dev_read_bool(bus,
@ -1041,7 +1041,7 @@ static int pci_uclass_post_probe(struct udevice *bus)
struct pci_controller *hose = dev_get_uclass_priv(bus);
int ret;
debug("%s: probing bus %d\n", __func__, bus->seq);
debug("%s: probing bus %d\n", __func__, dev_seq(bus));
ret = pci_bind_bus_devices(bus);
if (ret)
return ret;
@ -1068,7 +1068,7 @@ static int pci_uclass_post_probe(struct udevice *bus)
* Note we only call this 1) after U-Boot is relocated, and 2)
* root bus has finished probing.
*/
if ((gd->flags & GD_FLG_RELOC) && bus->seq == 0 && ll_boot_init()) {
if ((gd->flags & GD_FLG_RELOC) && dev_seq(bus) == 0 && ll_boot_init()) {
ret = fsp_init_phase_pci();
if (ret)
return ret;
@ -1732,7 +1732,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en)
&class, PCI_SIZE_16);
debug("%s: bus %d/%s: found VF %x:%x\n", __func__,
bus->seq, bus->name, PCI_DEV(bdf), PCI_FUNC(bdf));
dev_seq(bus), bus->name, PCI_DEV(bdf), PCI_FUNC(bdf));
/* Find this device in the device tree */
ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev);
@ -1763,7 +1763,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en)
pplat->virtid = vf * vf_stride + vf_offset;
debug("%s: bus %d/%s: found VF %x:%x %x:%x class %lx id %x\n",
__func__, dev->seq, dev->name, PCI_DEV(bdf),
__func__, dev_seq(dev), dev->name, PCI_DEV(bdf),
PCI_FUNC(bdf), vendor, device, class, pplat->virtid);
bdf += PCI_BDF(0, 0, vf_stride);
}

View File

@ -189,8 +189,8 @@ void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus)
/* Configure bus number registers */
dm_pci_write_config8(dev, PCI_PRIMARY_BUS,
PCI_BUS(dm_pci_get_bdf(dev)) - ctlr->seq);
dm_pci_write_config8(dev, PCI_SECONDARY_BUS, sub_bus - ctlr->seq);
PCI_BUS(dm_pci_get_bdf(dev)) - dev_seq(ctlr));
dm_pci_write_config8(dev, PCI_SECONDARY_BUS, sub_bus - dev_seq(ctlr));
dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, 0xff);
if (pci_mem) {
@ -265,7 +265,7 @@ void dm_pciauto_postscan_setup_bridge(struct udevice *dev, int sub_bus)
pci_io = ctlr_hose->pci_io;
/* Configure bus number registers */
dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, sub_bus - ctlr->seq);
dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, sub_bus - dev_seq(ctlr));
if (pci_mem) {
/* Round memory allocator to 1MB boundary */

View File

@ -500,13 +500,13 @@ static int pcie_dw_mvebu_probe(struct udevice *dev)
debug("PCIE Reset on GPIO support is missing\n");
#endif /* DM_GPIO */
pcie->first_busno = dev->seq;
pcie->first_busno = dev_seq(dev);
/* Don't register host if link is down */
if (!pcie_dw_mvebu_pcie_link_up(pcie->ctrl_base, LINK_SPEED_GEN_3)) {
printf("PCIE-%d: Link down\n", dev->seq);
printf("PCIE-%d: Link down\n", dev_seq(dev));
} else {
printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev->seq,
printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev_seq(dev),
pcie_dw_get_link_speed(pcie->ctrl_base),
pcie_dw_get_link_width(pcie->ctrl_base),
hose->first_busno);

View File

@ -634,7 +634,7 @@ static int pcie_dw_ti_probe(struct udevice *dev)
generic_phy_init(&phy1);
generic_phy_power_on(&phy1);
pci->first_busno = dev->seq;
pci->first_busno = dev_seq(dev);
pci->dev = dev;
pcie_dw_setup_host(pci);
@ -644,11 +644,11 @@ static int pcie_dw_ti_probe(struct udevice *dev)
pcie_am654_set_mode(pci, DW_PCIE_RC_TYPE);
if (!pcie_dw_ti_pcie_link_up(pci, LINK_SPEED_GEN_2)) {
printf("PCIE-%d: Link down\n", dev->seq);
printf("PCIE-%d: Link down\n", dev_seq(dev));
return -ENODEV;
}
printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev->seq,
printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev_seq(dev),
pcie_dw_get_link_speed(pci),
pcie_dw_get_link_width(pci),
hose->first_busno);

View File

@ -146,7 +146,7 @@ static int pci_generic_ecam_probe(struct udevice *dev)
{
struct generic_ecam_pcie *pcie = dev_get_priv(dev);
pcie->first_busno = dev->seq;
pcie->first_busno = dev_seq(dev);
return 0;
}

View File

@ -29,16 +29,16 @@ static int fsl_pcie_addr_valid(struct fsl_pcie *pcie, pci_dev_t bdf)
if (!pcie->enabled)
return -ENXIO;
if (PCI_BUS(bdf) < bus->seq)
if (PCI_BUS(bdf) < dev_seq(bus))
return -EINVAL;
if (PCI_BUS(bdf) > bus->seq && (!fsl_pcie_link_up(pcie) || pcie->mode))
if (PCI_BUS(bdf) > dev_seq(bus) && (!fsl_pcie_link_up(pcie) || pcie->mode))
return -EINVAL;
if (PCI_BUS(bdf) == bus->seq && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0))
if (PCI_BUS(bdf) == dev_seq(bus) && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0))
return -EINVAL;
if (PCI_BUS(bdf) == (bus->seq + 1) && (PCI_DEV(bdf) > 0))
if (PCI_BUS(bdf) == (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0))
return -EINVAL;
return 0;
@ -57,7 +57,7 @@ static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf,
return 0;
}
bdf = bdf - PCI_BDF(bus->seq, 0, 0);
bdf = bdf - PCI_BDF(dev_seq(bus), 0, 0);
val = bdf | (offset & 0xfc) | ((offset & 0xf00) << 16) | 0x80000000;
out_be32(&regs->cfg_addr, val);
@ -93,7 +93,7 @@ static int fsl_pcie_write_config(struct udevice *bus, pci_dev_t bdf,
if (fsl_pcie_addr_valid(pcie, bdf))
return 0;
bdf = bdf - PCI_BDF(bus->seq, 0, 0);
bdf = bdf - PCI_BDF(dev_seq(bus), 0, 0);
val = bdf | (offset & 0xfc) | ((offset & 0xf00) << 16) | 0x80000000;
out_be32(&regs->cfg_addr, val);
@ -123,7 +123,7 @@ static int fsl_pcie_hose_read_config(struct fsl_pcie *pcie, uint offset,
int ret;
struct udevice *bus = pcie->bus;
ret = fsl_pcie_read_config(bus, PCI_BDF(bus->seq, 0, 0),
ret = fsl_pcie_read_config(bus, PCI_BDF(dev_seq(bus), 0, 0),
offset, valuep, size);
return ret;
@ -134,7 +134,7 @@ static int fsl_pcie_hose_write_config(struct fsl_pcie *pcie, uint offset,
{
struct udevice *bus = pcie->bus;
return fsl_pcie_write_config(bus, PCI_BDF(bus->seq, 0, 0),
return fsl_pcie_write_config(bus, PCI_BDF(dev_seq(bus), 0, 0),
offset, value, size);
}

View File

@ -369,7 +369,7 @@ static int pcie_intel_fpga_probe(struct udevice *dev)
struct intel_fpga_pcie *pcie = dev_get_priv(dev);
pcie->bus = pci_get_controller(dev);
pcie->first_busno = dev->seq;
pcie->first_busno = dev_seq(dev);
/* clear all interrupts */
cra_writel(pcie, P2A_INT_STS_ALL, P2A_INT_STATUS);

View File

@ -479,7 +479,7 @@ static int fdt_fixup_pci_vfs(void *blob, struct extra_iommu_entry *entry,
for (bus = dev; device_is_on_pci_bus(bus);)
bus = bus->parent;
bdf = entry->bdf - PCI_BDF(bus->seq, 0, 0) + (vf_offset << 8);
bdf = entry->bdf - PCI_BDF(dev_seq(bus), 0, 0) + (vf_offset << 8);
for (i = 0; i < entry->num_vfs; i++) {
if (fdt_fixup_pcie_device_ls(blob, bdf, pcie_rc) < 0)
@ -518,7 +518,7 @@ static void fdt_fixup_pcie_ls(void *blob)
pcie_rc = dev_get_priv(bus);
/* the DT fixup must be relative to the hose first_busno */
bdf = dm_pci_get_bdf(dev) - PCI_BDF(bus->seq, 0, 0);
bdf = dm_pci_get_bdf(dev) - PCI_BDF(dev_seq(bus), 0, 0);
if (fdt_fixup_pcie_device_ls(blob, bdf, pcie_rc) < 0)
break;

View File

@ -191,13 +191,13 @@ static int ls_pcie_g4_addr_valid(struct ls_pcie_g4 *pcie, pci_dev_t bdf)
if (!pcie->enabled)
return -ENXIO;
if (PCI_BUS(bdf) < bus->seq)
if (PCI_BUS(bdf) < dev_seq(bus))
return -EINVAL;
if ((PCI_BUS(bdf) > bus->seq) && (!ls_pcie_g4_link_up(pcie)))
if ((PCI_BUS(bdf) > dev_seq(bus)) && (!ls_pcie_g4_link_up(pcie)))
return -EINVAL;
if (PCI_BUS(bdf) <= (bus->seq + 1) && (PCI_DEV(bdf) > 0))
if (PCI_BUS(bdf) <= (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0))
return -EINVAL;
return 0;
@ -209,7 +209,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf,
struct udevice *bus = pcie->bus;
u32 target;
if (PCI_BUS(bdf) == bus->seq) {
if (PCI_BUS(bdf) == dev_seq(bus)) {
if (offset < INDIRECT_ADDR_BNDRY) {
ccsr_set_page(pcie, 0);
return pcie->ccsr + offset;
@ -219,7 +219,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf,
return pcie->ccsr + OFFSET_TO_PAGE_ADDR(offset);
}
target = PAB_TARGET_BUS(PCI_BUS(bdf) - bus->seq) |
target = PAB_TARGET_BUS(PCI_BUS(bdf) - dev_seq(bus)) |
PAB_TARGET_DEV(PCI_DEV(bdf)) |
PAB_TARGET_FUNC(PCI_FUNC(bdf));

View File

@ -166,7 +166,7 @@ static void fdt_fixup_pcie_ls_gen4(void *blob)
}
/* the DT fixup must be relative to the hose first_busno */
bdf = dm_pci_get_bdf(dev) - PCI_BDF(bus->seq, 0, 0);
bdf = dm_pci_get_bdf(dev) - PCI_BDF(dev_seq(bus), 0, 0);
/* map PCI b.d.f to streamID in LUT */
ls_pcie_g4_lut_set_mapping(pcie, index, bdf >> 8, streamid);
/* update msi-map in device tree */

View File

@ -130,13 +130,13 @@ static int ls_pcie_addr_valid(struct ls_pcie_rc *pcie_rc, pci_dev_t bdf)
if (!pcie_rc->enabled)
return -ENXIO;
if (PCI_BUS(bdf) < bus->seq)
if (PCI_BUS(bdf) < dev_seq(bus))
return -EINVAL;
if ((PCI_BUS(bdf) > bus->seq) && (!ls_pcie_link_up(pcie)))
if ((PCI_BUS(bdf) > dev_seq(bus)) && (!ls_pcie_link_up(pcie)))
return -EINVAL;
if (PCI_BUS(bdf) <= (bus->seq + 1) && (PCI_DEV(bdf) > 0))
if (PCI_BUS(bdf) <= (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0))
return -EINVAL;
return 0;
@ -152,16 +152,16 @@ int ls_pcie_conf_address(const struct udevice *bus, pci_dev_t bdf,
if (ls_pcie_addr_valid(pcie_rc, bdf))
return -EINVAL;
if (PCI_BUS(bdf) == bus->seq) {
if (PCI_BUS(bdf) == dev_seq(bus)) {
*paddress = pcie->dbi + offset;
return 0;
}
busdev = PCIE_ATU_BUS(PCI_BUS(bdf) - bus->seq) |
busdev = PCIE_ATU_BUS(PCI_BUS(bdf) - dev_seq(bus)) |
PCIE_ATU_DEV(PCI_DEV(bdf)) |
PCIE_ATU_FUNC(PCI_FUNC(bdf));
if (PCI_BUS(bdf) == bus->seq + 1) {
if (PCI_BUS(bdf) == dev_seq(bus) + 1) {
ls_pcie_cfg0_set_busdev(pcie_rc, busdev);
*paddress = pcie_rc->cfg0 + offset;
} else {

View File

@ -261,7 +261,7 @@ static struct mtk_pcie_port *mtk_pcie_find_port(const struct udevice *bus,
return NULL;
}
while (dev->parent->seq != 0)
while (dev_seq(dev->parent) != 0)
dev = dev->parent;
pplat = dev_get_parent_plat(dev);

View File

@ -373,7 +373,7 @@ static int rockchip_pcie_init_port(struct udevice *dev)
/* Configure Address Translation. */
ret = rockchip_pcie_atr_init(priv);
if (ret) {
dev_err(dev, "PCIE-%d: ATR init failed\n", dev->seq);
dev_err(dev, "PCIE-%d: ATR init failed\n", dev_seq(dev));
goto err_power_off_phy;
}
@ -528,7 +528,7 @@ static int rockchip_pcie_probe(struct udevice *dev)
struct pci_controller *hose = dev_get_uclass_priv(ctlr);
int ret;
priv->first_busno = dev->seq;
priv->first_busno = dev_seq(dev);
priv->dev = dev;
ret = rockchip_pcie_parse_dt(dev);
@ -544,7 +544,7 @@ static int rockchip_pcie_probe(struct udevice *dev)
return ret;
dev_info(dev, "PCIE-%d: Link up (Bus%d)\n",
dev->seq, hose->first_busno);
dev_seq(dev), hose->first_busno);
return 0;
}

View File

@ -85,7 +85,7 @@ static int coldfire_serial_probe(struct udevice *dev)
{
struct coldfire_serial_plat *plat = dev->plat;
plat->port = dev->seq;
plat->port = dev_seq(dev);
return mcf_serial_init_common((uart_t *)plat->base,
plat->port, plat->baudrate);

View File

@ -187,7 +187,7 @@ static int s5p_serial_of_to_plat(struct udevice *dev)
plat->reg = (struct s5p_uart *)addr;
plat->port_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"id", dev->seq);
"id", dev_seq(dev));
return 0;
}

View File

@ -98,7 +98,7 @@ static int altera_spi_xfer(struct udevice *dev, unsigned int bitlen,
uint32_t reg, data, start;
debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
bus->seq, slave_plat->cs, bitlen, bytes, flags);
dev_seq(bus), slave_plat->cs, bitlen, bytes, flags);
if (bitlen == 0)
goto done;

View File

@ -240,7 +240,7 @@ static int coldfire_spi_set_speed(struct udevice *bus, uint max_hz)
cfspi->baudrate = max_hz;
/* Read current setup */
bus_setup = readl(&dspi->ctar[bus->seq]);
bus_setup = readl(&dspi->ctar[dev_seq(bus)]);
tmp = (prescaler[3] * scaler[15]);
/* Maximum and minimum baudrate it can handle */
@ -294,7 +294,7 @@ static int coldfire_spi_set_speed(struct udevice *bus, uint max_hz)
bus_setup &= ~(DSPI_CTAR_PBR(0x03) | DSPI_CTAR_BR(0x0f));
bus_setup |= (DSPI_CTAR_PBR(best_i) | DSPI_CTAR_BR(best_j));
writel(bus_setup, &dspi->ctar[bus->seq]);
writel(bus_setup, &dspi->ctar[dev_seq(bus)]);
return 0;
}
@ -318,7 +318,7 @@ static int coldfire_spi_set_mode(struct udevice *bus, uint mode)
if (cfspi->mode & SPI_MODE_MOD) {
if ((cfspi->mode & SPI_MODE_XFER_SZ_MASK) == 0)
bus_setup |=
readl(&dspi->ctar[bus->seq]) & MCF_FRM_SZ_16BIT;
readl(&dspi->ctar[dev_seq(bus)]) & MCF_FRM_SZ_16BIT;
else
bus_setup |=
((cfspi->mode & SPI_MODE_XFER_SZ_MASK) >> 1);
@ -329,14 +329,14 @@ static int coldfire_spi_set_mode(struct udevice *bus, uint mode)
bus_setup |= (cfspi->mode & SPI_MODE_DLY_SCA_MASK) >> 4;
} else {
bus_setup |=
(readl(&dspi->ctar[bus->seq]) & MCF_CTAR_MODE_MASK);
(readl(&dspi->ctar[dev_seq(bus)]) & MCF_CTAR_MODE_MASK);
}
cfspi->charbit =
((readl(&dspi->ctar[bus->seq]) & MCF_FRM_SZ_16BIT) ==
((readl(&dspi->ctar[dev_seq(bus)]) & MCF_FRM_SZ_16BIT) ==
MCF_FRM_SZ_16BIT) ? 16 : 8;
setbits_be32(&dspi->ctar[bus->seq], bus_setup);
setbits_be32(&dspi->ctar[dev_seq(bus)], bus_setup);
return 0;
}

View File

@ -511,7 +511,7 @@ static int fsl_dspi_probe(struct udevice *bus)
DSPI_MCR_CRXF | DSPI_MCR_CTXF;
fsl_dspi_init_mcr(priv, mcr_cfg_val);
debug("%s probe done, bus-num %d.\n", bus->name, bus->seq);
debug("%s probe done, bus-num %d.\n", bus->name, dev_seq(bus));
return 0;
}
@ -527,7 +527,7 @@ static int fsl_dspi_claim_bus(struct udevice *dev)
priv = dev_get_priv(bus);
/* processor special preparation work */
cpu_dspi_claim_bus(bus->seq, slave_plat->cs);
cpu_dspi_claim_bus(dev_seq(bus), slave_plat->cs);
/* configure transfer mode */
fsl_dspi_cfg_ctar_mode(priv, slave_plat->cs, priv->mode);
@ -559,7 +559,7 @@ static int fsl_dspi_release_bus(struct udevice *dev)
dspi_halt(priv, 1);
/* processor special release work */
cpu_dspi_release_bus(bus->seq, slave_plat->cs);
cpu_dspi_release_bus(dev_seq(bus), slave_plat->cs);
return 0;
}

View File

@ -527,7 +527,7 @@ static int fsl_espi_probe(struct udevice *bus)
fsl->max_transfer_length = ESPI_MAX_DATA_TRANSFER_LEN;
fsl->speed_hz = plat->speed_hz;
debug("%s probe done, bus-num %d.\n", bus->name, bus->seq);
debug("%s probe done, bus-num %d.\n", bus->name, dev_seq(bus));
return 0;
}

View File

@ -593,7 +593,7 @@ static int octeon_spi_probe(struct udevice *dev)
if (ret)
return ret;
debug("SPI bus %s %d at %p\n", dev->name, dev->seq, priv->base);
debug("SPI bus %s %d at %p\n", dev->name, dev_seq(dev), priv->base);
return 0;
}

View File

@ -247,7 +247,7 @@ static int pic32_spi_xfer(struct udevice *slave, unsigned int bitlen,
slave_plat = dev_get_parent_plat(slave);
debug("spi_xfer: bus:%i cs:%i flags:%lx\n",
bus->seq, slave_plat->cs, flags);
dev_seq(bus), slave_plat->cs, flags);
debug("msg tx %p, rx %p submitted of %d byte(s)\n",
tx_buf, rx_buf, len);
@ -384,7 +384,7 @@ static int pic32_spi_probe(struct udevice *bus)
fdt_size_t size;
int ret;
debug("%s: %d, bus: %i\n", __func__, __LINE__, bus->seq);
debug("%s: %d, bus: %i\n", __func__, __LINE__, dev_seq(bus));
addr = fdtdec_get_addr_size(gd->fdt_blob, node, "reg", &size);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;

View File

@ -72,7 +72,7 @@ static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen,
return -EINVAL;
}
busnum = bus->seq;
busnum = dev_seq(bus);
cs = spi_chip_select(slave);
if (busnum >= CONFIG_SANDBOX_SPI_MAX_BUS ||
cs >= CONFIG_SANDBOX_SPI_MAX_CS) {

View File

@ -231,7 +231,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen,
int ret;
debug("%s: slave %u:%u dout %p din %p bitlen %u\n",
__func__, bus->seq, spi_chip_select(dev), dout, din, bitlen);
__func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen);
if (bitlen % 8)
return -1;
num_bytes = bitlen / 8;

View File

@ -217,7 +217,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen,
int ret;
debug("%s: slave %u:%u dout %p din %p bitlen %u\n",
__func__, bus->seq, spi_chip_select(dev), dout, din, bitlen);
__func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen);
if (bitlen % 8)
return -1;
num_bytes = bitlen / 8;

View File

@ -211,7 +211,7 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
int ret;
debug("%s: slave %u:%u dout %p din %p bitlen %u\n",
__func__, bus->seq, spi_chip_select(dev), dout, din, bitlen);
__func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen);
if (bitlen % 8)
return -1;
num_bytes = bitlen / 8;

View File

@ -223,7 +223,7 @@ static int tegra210_qspi_xfer(struct udevice *dev, unsigned int bitlen,
int num_bytes, tm, ret;
debug("%s: slave %u:%u dout %p din %p bitlen %u\n",
__func__, bus->seq, spi_chip_select(dev), dout, din, bitlen);
__func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen);
if (bitlen % 8)
return -1;
num_bytes = bitlen / 8;

View File

@ -255,7 +255,7 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen,
int ret;
debug("spi_xfer: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n",
bus->seq, slave_plat->cs, bitlen, bytes, flags);
dev_seq(bus), slave_plat->cs, bitlen, bytes, flags);
if (bitlen == 0)
goto done;

View File

@ -568,7 +568,7 @@ static int zynq_qspi_xfer(struct udevice *dev, unsigned int bitlen,
priv->len = bitlen / 8;
debug("zynq_qspi_xfer: bus:%i cs:%i bitlen:%i len:%i flags:%lx\n",
bus->seq, slave_plat->cs, bitlen, priv->len, flags);
dev_seq(bus), slave_plat->cs, bitlen, priv->len, flags);
/*
* Festering sore.

View File

@ -242,7 +242,7 @@ static int zynq_spi_xfer(struct udevice *dev, unsigned int bitlen,
u32 ts, status;
debug("spi_xfer: bus:%i cs:%i bitlen:%i len:%i flags:%lx\n",
bus->seq, slave_plat->cs, bitlen, len, flags);
dev_seq(bus), slave_plat->cs, bitlen, len, flags);
if (bitlen % 8) {
debug("spi_xfer: Non byte aligned SPI transfer\n");

View File

@ -821,7 +821,7 @@ static int max3420_udc_probe(struct udevice *dev)
struct max3420_udc *udc = dev_get_priv(dev);
struct dm_spi_slave_plat *slave_pdata;
struct udevice *bus = dev->parent;
int busnum = bus->seq;
int busnum = dev_seq(bus);
unsigned int cs;
uint speed, mode;
struct udevice *spid;

View File

@ -321,7 +321,7 @@ static int ehci_usb_probe(struct udevice *dev)
mdelay(1);
priv->ehci = ehci;
priv->portnr = dev->seq;
priv->portnr = dev_seq(dev);
priv->init_type = type;
ret = device_get_supply_regulator(dev, "vbus-supply",

View File

@ -596,7 +596,7 @@ static int ehci_usb_probe(struct udevice *dev)
}
priv->ehci = ehci;
priv->portnr = dev->seq;
priv->portnr = dev_seq(dev);
priv->init_type = type;
#if CONFIG_IS_ENABLED(DM_REGULATOR)

View File

@ -383,7 +383,7 @@ static int omap_ehci_probe(struct udevice *dev)
struct ehci_hcor *hcor;
priv->ehci = dev_read_addr_ptr(dev);
priv->portnr = dev->seq;
priv->portnr = dev_seq(dev);
priv->init_type = plat->init_type;
hccr = (struct ehci_hccr *)&priv->ehci->hccapbase;

View File

@ -222,7 +222,7 @@ static int vf_usb_of_to_plat(struct udevice *dev)
int node = dev_of_offset(dev);
const char *mode;
priv->portnr = dev->seq;
priv->portnr = dev_seq(dev);
priv->ehci = dev_read_addr_ptr(dev);
mode = fdt_getprop(dt_blob, node, "dr_mode", NULL);

View File

@ -23,7 +23,7 @@ static void usbmon_trace(struct udevice *bus, ulong pipe,
type = (pipe & USB_PIPE_TYPE_MASK) >> USB_PIPE_TYPE_SHIFT;
debug("0 0 S %c%c:%d:%03ld:%ld", types[type],
pipe & USB_DIR_IN ? 'i' : 'o',
bus->seq,
dev_seq(bus),
(pipe & USB_PIPE_DEV_MASK) >> USB_PIPE_DEV_SHIFT,
(pipe & USB_PIPE_EP_MASK) >> USB_PIPE_EP_SHIFT);
if (setup) {

View File

@ -701,7 +701,7 @@ int usb_scan_device(struct udevice *parent, int port,
return ret;
ret = usb_find_and_bind_driver(parent, &udev->descriptor,
iface,
udev->controller_dev->seq,
dev_seq(udev->controller_dev),
udev->devnum, port, &dev);
if (ret)
return ret;

View File

@ -606,9 +606,9 @@ static int vidconsole_post_probe(struct udevice *dev)
if (!priv->tab_width_frac)
priv->tab_width_frac = VID_TO_POS(priv->x_charsize) * 8;
if (dev->seq) {
if (dev_seq(dev)) {
snprintf(sdev->name, sizeof(sdev->name), "vidconsole%d",
dev->seq);
dev_seq(dev));
} else {
strcpy(sdev->name, "vidconsole");
}

View File

@ -240,7 +240,7 @@ static int virtio_uclass_post_probe(struct udevice *udev)
}
snprintf(dev_name, sizeof(dev_name), "%s#%d",
virtio_drv_name[uc_priv->device], udev->seq);
virtio_drv_name[uc_priv->device], dev_seq(udev));
str = strdup(dev_name);
if (!str)
return -ENOMEM;

View File

@ -113,7 +113,7 @@ static const struct udevice_id ast_wdt_ids[] = {
static int ast_wdt_probe(struct udevice *dev)
{
debug("%s() wdt%u\n", __func__, dev->seq);
debug("%s() wdt%u\n", __func__, dev_seq(dev));
ast_wdt_stop(dev);
return 0;

View File

@ -108,7 +108,7 @@ static int at91_wdt_probe(struct udevice *dev)
if (!priv->regs)
return -EINVAL;
debug("%s: Probing wdt%u\n", __func__, dev->seq);
debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
return 0;
}

View File

@ -223,7 +223,7 @@ static int cdns_wdt_stop(struct udevice *dev)
*/
static int cdns_wdt_probe(struct udevice *dev)
{
debug("%s: Probing wdt%u\n", __func__, dev->seq);
debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
return 0;
}

View File

@ -242,7 +242,7 @@ static int omap3_wdt_probe(struct udevice *dev)
return -EINVAL;
priv->wdt_trgr_pattern = 0x1234;
debug("%s: Probing wdt%u\n", __func__, dev->seq);
debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
return 0;
}

View File

@ -158,7 +158,7 @@ static int orion_wdt_probe(struct udevice *dev)
struct orion_wdt_priv *priv = dev_get_priv(dev);
int ret;
debug("%s: Probing wdt%u\n", __func__, dev->seq);
debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
orion_wdt_stop(dev);
ret = clk_get_by_name(dev, "fixed", &priv->clk);

View File

@ -88,7 +88,7 @@ static int sbsa_gwdt_expire_now(struct udevice *dev, ulong flags)
static int sbsa_gwdt_probe(struct udevice *dev)
{
debug("%s: Probing wdt%u (sbsa-gwdt)\n", __func__, dev->seq);
debug("%s: Probing wdt%u (sbsa-gwdt)\n", __func__, dev_seq(dev));
return 0;
}

View File

@ -105,7 +105,7 @@ static int sp805_wdt_expire_now(struct udevice *dev, ulong flags)
static int sp805_wdt_probe(struct udevice *dev)
{
debug("%s: Probing wdt%u (sp805-wdt)\n", __func__, dev->seq);
debug("%s: Probing wdt%u (sp805-wdt)\n", __func__, dev_seq(dev));
return 0;
}

View File

@ -80,7 +80,7 @@ static const struct udevice_id tangier_wdt_ids[] = {
static int tangier_wdt_probe(struct udevice *dev)
{
debug("%s: Probing wdt%u\n", __func__, dev->seq);
debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
return 0;
}

View File

@ -85,7 +85,7 @@ static int xlnx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
static int xlnx_wdt_probe(struct udevice *dev)
{
debug("%s: Probing wdt%u\n", __func__, dev->seq);
debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
return 0;
}

View File

@ -128,7 +128,7 @@ static int xlnx_wwdt_probe(struct udevice *dev)
struct xlnx_wwdt_plat *plat = dev_get_plat(dev);
struct xlnx_wwdt_priv *wdt = dev_get_priv(dev);
dev_dbg(dev, "%s: Probing wdt%u\n", __func__, dev->seq);
dev_dbg(dev, "%s: Probing wdt%u\n", __func__, dev_seq(dev));
ret = regmap_init_mem(dev_ofnode(dev), &wdt->regs);
if (ret) {

View File

@ -182,6 +182,11 @@ static inline bool dev_has_of_node(struct udevice *dev)
return ofnode_valid(dev->node);
}
static inline int dev_seq(const struct udevice *dev)
{
return dev->seq;
}
/**
* struct udevice_id - Lists the compatible strings supported by a driver
* @compatible: Compatible string

View File

@ -934,7 +934,7 @@ struct dm_pci_ops {
* PCI buses must support reading and writing configuration values
* so that the bus can be scanned and its devices configured.
*
* Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always.
* Normally PCI_BUS(@bdf) is the same as @dev_seq(bus), but not always.
* If bridges exist it is possible to use the top-level bus to
* access a sub-bus. In that case @bus will be the top-level bus
* and PCI_BUS(bdf) will be a different (higher) value

View File

@ -116,7 +116,7 @@ enum spi_polarity {
* claimed.
* @bus: ID of the bus that the slave is attached to. For
* driver model this is the sequence number of the SPI
* bus (bus->seq) so does not need to be stored
* bus (dev_seq(bus)) so does not need to be stored
* @cs: ID of the chip select connected to the slave.
* @mode: SPI mode to use for this slave (see SPI mode flags)
* @wordlen: Size of SPI word in number of bits

View File

@ -624,7 +624,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
DEVICE_PATH_SUB_TYPE_MSG_SD :
DEVICE_PATH_SUB_TYPE_MSG_MMC;
sddp->dp.length = sizeof(*sddp);
sddp->slot_number = dev->seq;
sddp->slot_number = dev_seq(dev);
return &sddp[1];
}
#endif
@ -677,7 +677,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
DEVICE_PATH_SUB_TYPE_MSG_SD :
DEVICE_PATH_SUB_TYPE_MSG_MMC;
sddp->dp.length = sizeof(*sddp);
sddp->slot_number = dev->seq;
sddp->slot_number = dev_seq(dev);
return &sddp[1];
}

View File

@ -137,7 +137,7 @@ struct udevice *eth_get_dev_by_name(const char *devname)
continue;
/* Check for the name or the sequence number to match */
if (strcmp(it->name, devname) == 0 ||
(endp > startp && it->seq == seq))
(endp > startp && dev_seq(it) == seq))
return it;
}
@ -189,7 +189,7 @@ void eth_halt_state_only(void)
int eth_get_dev_index(void)
{
if (eth_get_dev())
return eth_get_dev()->seq;
return dev_seq(eth_get_dev());
return -1;
}
@ -202,7 +202,7 @@ static int eth_write_hwaddr(struct udevice *dev)
return -EINVAL;
/* seq is valid since the device is active */
if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev->seq)) {
if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev_seq(dev))) {
pdata = dev->plat;
if (!is_valid_ethaddr(pdata->enetaddr)) {
printf("\nError: %s address %pM illegal value\n",
@ -434,11 +434,11 @@ int eth_initialize(void)
bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
do {
if (dev->seq != -1) {
if (dev_seq(dev) != -1) {
if (num_devices)
printf(", ");
printf("eth%d: %s", dev->seq, dev->name);
printf("eth%d: %s", dev_seq(dev), dev->name);
if (ethprime && dev == prime_dev)
printf(" [PRIME]");
@ -446,7 +446,7 @@ int eth_initialize(void)
eth_write_hwaddr(dev);
if (dev->seq != -1)
if (dev_seq(dev) != -1)
num_devices++;
uclass_next_device_check(&dev);
} while (dev);
@ -547,7 +547,7 @@ static int eth_post_probe(struct udevice *dev)
eth_get_ops(dev)->read_rom_hwaddr(dev);
}
eth_env_get_enetaddr_by_index("eth", dev->seq, env_enetaddr);
eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr);
if (!is_zero_ethaddr(env_enetaddr)) {
if (!is_zero_ethaddr(pdata->enetaddr) &&
memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) {
@ -562,13 +562,14 @@ static int eth_post_probe(struct udevice *dev)
/* Override the ROM MAC address */
memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);
} else if (is_valid_ethaddr(pdata->enetaddr)) {
eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
pdata->enetaddr);
} else if (is_zero_ethaddr(pdata->enetaddr) ||
!is_valid_ethaddr(pdata->enetaddr)) {
#ifdef CONFIG_NET_RANDOM_ETHADDR
net_random_ethaddr(pdata->enetaddr);
printf("\nWarning: %s (eth%d) using random MAC address - %pM\n",
dev->name, dev->seq, pdata->enetaddr);
dev->name, dev_seq(dev), pdata->enetaddr);
#else
printf("\nError: %s address not set.\n",
dev->name);