@@ -751,7 +751,7 @@ size_t sdram_size_mb(struct rk3288_pmu *pmu)
#ifdef CONFIG_SPL_BUILD
static int setup_sdram(struct udevice *dev)
{
- struct dram_info *priv = dev_get_priv(dev);
+ struct dram_info *priv = dev_get_priv(dev, struct dram_info);
struct rk3288_sdram_params params;
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
@@ -798,7 +798,7 @@ static int setup_sdram(struct udevice *dev)
static int rk3288_dmc_probe(struct udevice *dev)
{
- struct dram_info *priv = dev_get_priv(dev);
+ struct dram_info *priv = dev_get_priv(dev, struct dram_info);
struct regmap *map;
int ret;
@@ -852,7 +852,7 @@ static int rk3288_dmc_probe(struct udevice *dev)
static int rk3288_dmc_get_info(struct udevice *dev, struct ram_info *info)
{
- struct dram_info *priv = dev_get_priv(dev);
+ struct dram_info *priv = dev_get_priv(dev, struct dram_info);
*info = priv->info;
@@ -874,5 +874,5 @@ U_BOOT_DRIVER(dmc_rk3288) = {
.of_match = rk3288_dmc_ids,
.ops = &rk3288_dmc_ops,
.probe = rk3288_dmc_probe,
- .priv_auto_alloc_size = sizeof(struct dram_info),
+ .priv_alloc = dm_alloc(struct dram_info),
};
@@ -238,7 +238,7 @@ static int load_sipi_vector(atomic_t **ap_countp)
params->stack_size = CONFIG_AP_STACK_SIZE;
size = params->stack_size * CONFIG_MAX_CPUS;
- stack = memalign(size, 4096);
+ stack = memalign(4096, size);
if (!stack)
return -ENOMEM;
params->stack_top = (u32)(stack + size);
@@ -617,7 +617,7 @@ they are needed, or perhaps until after relocation.
When a device needs to be used, U-Boot activates it, by following these
steps (see device_probe()):
- a. If priv_auto_alloc_size is non-zero, then the device-private space
+ a. If priv_alloc.size is non-zero, then the device-private space
is allocated for the device and zeroed. It will be accessible as
dev->priv. The driver can put anything it likes in there, but should use
it for run-time information, not platform data (which should be static
@@ -677,7 +677,7 @@ steps (see device_probe()):
- uclass data in dev->uclass_priv (for things the uclass stores
about this device)
- Note: If you don't use priv_auto_alloc_size then you will need to
+ Note: If you don't use priv_alloc.size then you will need to
allocate the priv space here yourself. The same applies also to
platdata_auto_alloc_size. Remember to free them in the remove() method.
@@ -305,7 +305,7 @@ DM can auto-allocate this also:
U_BOOT_DRIVER(spi_exynos) = {
...
- .priv_auto_alloc_size = sizeof(struct exynos_spi_priv),
+ .priv_alloc = dm_alloc(struct exynos_spi_priv),
Note that this is created before the probe method is called, and destroyed
@@ -326,7 +326,7 @@ what you can copy out to set things up.
static int exynos_spi_probe(struct udevice *bus)
{
struct exynos_spi_platdata *plat = dev_get_platdata(bus);
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
priv->regs = plat->regs;
if (plat->periph_id == PERIPH_ID_SPI1 ||
@@ -401,7 +401,7 @@ Here is an example for the speed part:
static int exynos_spi_set_speed(struct udevice *bus, uint speed)
{
struct exynos_spi_platdata *plat = bus->platdata;
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
int ret;
if (speed > plat->frequency)
@@ -424,7 +424,7 @@ comes from the old spi_claim_bus(). Here is an example:
static int exynos_spi_set_mode(struct udevice *bus, uint mode)
{
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
uint32_t reg;
reg = readl(&priv->regs->ch_cfg);
@@ -456,7 +456,7 @@ needed. It is anything unrelated to speed and mode:
static int exynos_spi_claim_bus(struct udevice *bus)
{
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
exynos_pinmux_config(priv->periph_id, PINMUX_FLAG_NONE);
spi_flush_fifo(priv->regs);
@@ -491,7 +491,7 @@ is a call to spi_flush_fifo, so we add:
static int exynos_spi_release_bus(struct udevice *bus)
{
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
spi_flush_fifo(priv->regs);
@@ -534,7 +534,7 @@ static void spi_cs_activate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct exynos_spi_platdata *pdata = dev_get_platdata(bus);
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
/* If it's too soon to do another transaction, wait */
if (pdata->deactivate_delay_us &&
@@ -40,7 +40,7 @@ U_BOOT_DRIVER(usb_ehci) = {
.remove = tegra_ehci_usb_remove,
.ops = &ehci_usb_ops,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
- .priv_auto_alloc_size = sizeof(struct fdt_usb),
+ .priv_alloc = dm_alloc(struct fdt_usb),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
@@ -54,7 +54,7 @@ The ops here are ehci_usb_ops. All EHCI drivers will use these same ops in
most cases, since they are all EHCI-compatible. For EHCI there are also some
special operations that can be overridden when calling ehci_register().
-The driver can use priv_auto_alloc_size to set the size of its private data.
+The driver can use priv_alloc.size to set the size of its private data.
This can hold run-time information needed by the driver for operation. It
exists when the device is probed (not when it is bound) and is removed when
the driver is removed.
@@ -340,7 +340,7 @@ static uint32_t rkclk_pll_get_rate(struct rk3288_cru *cru,
static ulong rk3288_clk_get_rate(struct udevice *dev)
{
struct rk3288_clk_plat *plat = dev_get_platdata(dev);
- struct rk3288_clk_priv *priv = dev_get_priv(dev);
+ struct rk3288_clk_priv *priv = dev_get_priv(dev, struct rk3288_clk_priv);
debug("%s\n", dev->name);
return rkclk_pll_get_rate(priv->cru, plat->clk_id);
@@ -349,7 +349,7 @@ static ulong rk3288_clk_get_rate(struct udevice *dev)
static ulong rk3288_clk_set_rate(struct udevice *dev, ulong rate)
{
struct rk3288_clk_plat *plat = dev_get_platdata(dev);
- struct rk3288_clk_priv *priv = dev_get_priv(dev);
+ struct rk3288_clk_priv *priv = dev_get_priv(dev, struct rk3288_clk_priv);
debug("%s\n", dev->name);
switch (plat->clk_id) {
@@ -510,7 +510,7 @@ static ulong rockchip_spi_set_clk(struct rk3288_cru *cru, uint clk_general_rate,
ulong rk3288_set_periph_rate(struct udevice *dev, int periph, ulong rate)
{
- struct rk3288_clk_priv *priv = dev_get_priv(dev);
+ struct rk3288_clk_priv *priv = dev_get_priv(dev, struct rk3288_clk_priv);
ulong new_rate;
switch (periph) {
@@ -541,10 +541,10 @@ static struct clk_ops rk3288_clk_ops = {
static int rk3288_clk_probe(struct udevice *dev)
{
struct rk3288_clk_plat *plat = dev_get_platdata(dev);
- struct rk3288_clk_priv *priv = dev_get_priv(dev);
+ struct rk3288_clk_priv *priv = dev_get_priv(dev, struct rk3288_clk_priv);
if (plat->clk_id != CLK_OSC) {
- struct rk3288_clk_priv *parent_priv = dev_get_priv(dev->parent);
+ struct rk3288_clk_priv *parent_priv = dev_get_priv(dev->parent, struct rk3288_clk_priv);
priv->cru = parent_priv->cru;
priv->grf = parent_priv->grf;
@@ -610,7 +610,7 @@ U_BOOT_DRIVER(clk_rk3288) = {
.name = "clk_rk3288",
.id = UCLASS_CLK,
.of_match = rk3288_clk_ids,
- .priv_auto_alloc_size = sizeof(struct rk3288_clk_priv),
+ .priv_alloc = dm_alloc(struct rk3288_clk_priv),
.platdata_auto_alloc_size = sizeof(struct rk3288_clk_plat),
.ops = &rk3288_clk_ops,
.bind = rk3288_clk_bind,
@@ -17,14 +17,15 @@ struct sandbox_clk_priv {
static ulong sandbox_clk_get_rate(struct udevice *dev)
{
- struct sandbox_clk_priv *priv = dev_get_priv(dev);
+ struct sandbox_clk_priv *priv = dev_get_priv(dev,
+ struct sandbox_clk_priv);
return priv->rate;
}
static ulong sandbox_clk_set_rate(struct udevice *dev, ulong rate)
{
- struct sandbox_clk_priv *priv = dev_get_priv(dev);
+ struct sandbox_clk_priv *priv = dev_get_priv(dev, struct sandbox_clk_priv);
if (!rate)
return -EINVAL;
@@ -34,7 +35,7 @@ static ulong sandbox_clk_set_rate(struct udevice *dev, ulong rate)
ulong sandbox_get_periph_rate(struct udevice *dev, int periph)
{
- struct sandbox_clk_priv *priv = dev_get_priv(dev);
+ struct sandbox_clk_priv *priv = dev_get_priv(dev, struct sandbox_clk_priv);
if (periph < PERIPH_ID_FIRST || periph >= PERIPH_ID_COUNT)
return -EINVAL;
@@ -43,7 +44,7 @@ ulong sandbox_get_periph_rate(struct udevice *dev, int periph)
ulong sandbox_set_periph_rate(struct udevice *dev, int periph, ulong rate)
{
- struct sandbox_clk_priv *priv = dev_get_priv(dev);
+ struct sandbox_clk_priv *priv = dev_get_priv(dev, struct sandbox_clk_priv);
ulong old_rate;
if (periph < PERIPH_ID_FIRST || periph >= PERIPH_ID_COUNT)
@@ -56,7 +57,7 @@ ulong sandbox_set_periph_rate(struct udevice *dev, int periph, ulong rate)
static int sandbox_clk_probe(struct udevice *dev)
{
- struct sandbox_clk_priv *priv = dev_get_priv(dev);
+ struct sandbox_clk_priv *priv = dev_get_priv(dev, struct sandbox_clk_priv);
priv->rate = SANDBOX_CLK_RATE;
@@ -80,6 +81,6 @@ U_BOOT_DRIVER(clk_sandbox) = {
.id = UCLASS_CLK,
.of_match = sandbox_clk_ids,
.ops = &sandbox_clk_ops,
- .priv_auto_alloc_size = sizeof(struct sandbox_clk_priv),
+ .priv_alloc = dm_alloc(struct sandbox_clk_priv),
.probe = sandbox_clk_probe,
};
@@ -55,3 +55,13 @@ config DM_SEQ_ALIAS
Most boards will have a '/aliases' node containing the path to
numbered devices (e.g. serial0 = &serial0). This feature can be
disabled if it is not required, to save code space in SPL.
+
+config DM_ALLOC_CHECK
+ bool "Check access to auto-allocated structures"
+ depends on DM
+ help
+ Driver model provides a mechanism to check point access and report
+ any suspicious type casts or accesses. This works by naming the
+ auto-allocated structures and checking the names at run-time.
+ This option adds some size to U-Boot so can be disabled for
+ production systems.
@@ -119,7 +119,7 @@ void device_free(struct udevice *dev)
{
int size;
- if (dev->driver->priv_auto_alloc_size) {
+ if (dev->driver->priv_alloc.size) {
free(dev->priv);
dev->priv = NULL;
}
@@ -220,8 +220,8 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
assert(drv);
/* Allocate private data if requested */
- if (drv->priv_auto_alloc_size) {
- dev->priv = alloc_priv(drv->priv_auto_alloc_size, drv->flags);
+ if (drv->priv_alloc.size) {
+ dev->priv = alloc_priv(drv->priv_alloc.size, drv->flags);
if (!dev->priv) {
ret = -ENOMEM;
goto fail;
@@ -347,15 +347,16 @@ void *dev_get_uclass_platdata(struct udevice *dev)
return dev->uclass_platdata;
}
-void *dev_get_priv(struct udevice *dev)
+#ifdef CONFIG_DM_ALLOC_CHECK
+/* Example checking function */
+void *dev_get_priv_checked(struct udevice *dev, const char *name)
{
- if (!dev) {
- dm_warn("%s: null device\n", __func__);
- return NULL;
- }
-
+ if (strcmp(dev->driver->priv_alloc.name, name))
+ dm_warn("Invalid access to device priv: dev=%s, expecting '%s', requested '%s'\n",
+ dev->name, dev->driver->priv_alloc.name, name);
return dev->priv;
}
+#endif
void *dev_get_uclass_priv(struct udevice *dev)
{
@@ -63,8 +63,8 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
uc = calloc(1, sizeof(*uc));
if (!uc)
return -ENOMEM;
- if (uc_drv->priv_auto_alloc_size) {
- uc->priv = calloc(1, uc_drv->priv_auto_alloc_size);
+ if (uc_drv->priv_alloc.size) {
+ uc->priv = calloc(1, uc_drv->priv_alloc.size);
if (!uc->priv) {
ret = -ENOMEM;
goto fail_mem;
@@ -85,7 +85,7 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
return 0;
fail:
- if (uc_drv->priv_auto_alloc_size) {
+ if (uc_drv->priv_alloc.size) {
free(uc->priv);
uc->priv = NULL;
}
@@ -123,7 +123,7 @@ int uclass_destroy(struct uclass *uc)
if (uc_drv->destroy)
uc_drv->destroy(uc);
list_del(&uc->sibling_node);
- if (uc_drv->priv_auto_alloc_size)
+ if (uc_drv->priv_alloc.size)
free(uc->priv);
free(uc);
@@ -29,7 +29,7 @@ struct shape_data {
static int shape_hello(struct udevice *dev, int ch)
{
const struct dm_demo_pdata *pdata = dev_get_platdata(dev);
- struct shape_data *data = dev_get_priv(dev);
+ struct shape_data *data = dev_get_priv(dev, struct shape_data);
static const struct shape {
int start;
int end;
@@ -86,7 +86,7 @@ static int shape_hello(struct udevice *dev, int ch)
static int shape_status(struct udevice *dev, int *status)
{
- struct shape_data *data = dev_get_priv(dev);
+ struct shape_data *data = dev_get_priv(dev, struct shape_data);
*status = data->num_chars;
return 0;
@@ -94,7 +94,7 @@ static int shape_status(struct udevice *dev, int *status)
static int set_light(struct udevice *dev, int light)
{
- struct shape_data *priv = dev_get_priv(dev);
+ struct shape_data *priv = dev_get_priv(dev, struct shape_data);
struct gpio_desc *desc;
int ret;
int i;
@@ -113,7 +113,7 @@ static int set_light(struct udevice *dev, int light)
static int get_light(struct udevice *dev)
{
- struct shape_data *priv = dev_get_priv(dev);
+ struct shape_data *priv = dev_get_priv(dev, struct shape_data);
struct gpio_desc *desc;
uint value = 0;
int ret;
@@ -159,7 +159,7 @@ static int shape_ofdata_to_platdata(struct udevice *dev)
static int dm_shape_probe(struct udevice *dev)
{
- struct shape_data *priv = dev_get_priv(dev);
+ struct shape_data *priv = dev_get_priv(dev, struct shape_data);
int ret;
ret = gpio_request_list_by_name(dev, "light-gpios", priv->gpio_desc,
@@ -175,7 +175,7 @@ static int dm_shape_probe(struct udevice *dev)
static int dm_shape_remove(struct udevice *dev)
{
- struct shape_data *priv = dev_get_priv(dev);
+ struct shape_data *priv = dev_get_priv(dev, struct shape_data);
return gpio_free_list(dev, priv->gpio_desc, priv->gpio_count);
}
@@ -193,6 +193,6 @@ U_BOOT_DRIVER(demo_shape_drv) = {
.ops = &shape_ops,
.probe = dm_shape_probe,
.remove = dm_shape_remove,
- .priv_auto_alloc_size = sizeof(struct shape_data),
+ .priv_alloc = dm_alloc(struct shape_data),
.platdata_auto_alloc_size = sizeof(struct dm_demo_pdata),
};
@@ -451,7 +451,7 @@ struct at91_port_priv {
/* set GPIO pin 'gpio' as an input */
static int at91_gpio_direction_input(struct udevice *dev, unsigned offset)
{
- struct at91_port_priv *port = dev_get_priv(dev);
+ struct at91_port_priv *port = dev_get_priv(dev, struct at91_port_priv);
at91_set_port_input(port->regs, offset, 0);
@@ -462,7 +462,7 @@ static int at91_gpio_direction_input(struct udevice *dev, unsigned offset)
static int at91_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
- struct at91_port_priv *port = dev_get_priv(dev);
+ struct at91_port_priv *port = dev_get_priv(dev, struct at91_port_priv);
at91_set_port_output(port->regs, offset, value);
@@ -472,7 +472,7 @@ static int at91_gpio_direction_output(struct udevice *dev, unsigned offset,
/* read GPIO IN value of pin 'gpio' */
static int at91_gpio_get_value(struct udevice *dev, unsigned offset)
{
- struct at91_port_priv *port = dev_get_priv(dev);
+ struct at91_port_priv *port = dev_get_priv(dev, struct at91_port_priv);
return at91_get_port_value(port->regs, offset);
}
@@ -481,7 +481,7 @@ static int at91_gpio_get_value(struct udevice *dev, unsigned offset)
static int at91_gpio_set_value(struct udevice *dev, unsigned offset,
int value)
{
- struct at91_port_priv *port = dev_get_priv(dev);
+ struct at91_port_priv *port = dev_get_priv(dev, struct at91_port_priv);
at91_set_port_value(port->regs, offset, value);
@@ -490,7 +490,7 @@ static int at91_gpio_set_value(struct udevice *dev, unsigned offset,
static int at91_gpio_get_function(struct udevice *dev, unsigned offset)
{
- struct at91_port_priv *port = dev_get_priv(dev);
+ struct at91_port_priv *port = dev_get_priv(dev, struct at91_port_priv);
/* GPIOF_FUNC is not implemented yet */
if (at91_get_port_output(port->regs, offset))
@@ -509,7 +509,7 @@ static const struct dm_gpio_ops gpio_at91_ops = {
static int at91_gpio_probe(struct udevice *dev)
{
- struct at91_port_priv *port = dev_get_priv(dev);
+ struct at91_port_priv *port = dev_get_priv(dev, struct at91_port_priv);
struct at91_port_platdata *plat = dev_get_platdata(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
@@ -525,6 +525,6 @@ U_BOOT_DRIVER(gpio_at91) = {
.id = UCLASS_GPIO,
.ops = &gpio_at91_ops,
.probe = at91_gpio_probe,
- .priv_auto_alloc_size = sizeof(struct at91_port_priv),
+ .priv_alloc = dm_alloc(struct at91_port_priv),
};
#endif
@@ -17,7 +17,7 @@ struct bcm2835_gpios {
static int bcm2835_gpio_direction_input(struct udevice *dev, unsigned gpio)
{
- struct bcm2835_gpios *gpios = dev_get_priv(dev);
+ struct bcm2835_gpios *gpios = dev_get_priv(dev, struct bcm2835_gpios);
unsigned val;
val = readl(&gpios->reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
@@ -31,7 +31,7 @@ static int bcm2835_gpio_direction_input(struct udevice *dev, unsigned gpio)
static int bcm2835_gpio_direction_output(struct udevice *dev, unsigned gpio,
int value)
{
- struct bcm2835_gpios *gpios = dev_get_priv(dev);
+ struct bcm2835_gpios *gpios = dev_get_priv(dev, struct bcm2835_gpios);
unsigned val;
gpio_set_value(gpio, value);
@@ -64,7 +64,7 @@ static int bcm2835_get_value(const struct bcm2835_gpios *gpios, unsigned gpio)
static int bcm2835_gpio_get_value(struct udevice *dev, unsigned gpio)
{
- const struct bcm2835_gpios *gpios = dev_get_priv(dev);
+ const struct bcm2835_gpios *gpios = dev_get_priv(dev, struct bcm2835_gpios);
return bcm2835_get_value(gpios, gpio);
}
@@ -72,7 +72,7 @@ static int bcm2835_gpio_get_value(struct udevice *dev, unsigned gpio)
static int bcm2835_gpio_set_value(struct udevice *dev, unsigned gpio,
int value)
{
- struct bcm2835_gpios *gpios = dev_get_priv(dev);
+ struct bcm2835_gpios *gpios = dev_get_priv(dev, struct bcm2835_gpios);
u32 *output_reg = value ? gpios->reg->gpset : gpios->reg->gpclr;
writel(1 << BCM2835_GPIO_COMMON_SHIFT(gpio),
@@ -83,7 +83,7 @@ static int bcm2835_gpio_set_value(struct udevice *dev, unsigned gpio,
static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset)
{
- struct bcm2835_gpios *gpios = dev_get_priv(dev);
+ struct bcm2835_gpios *gpios = dev_get_priv(dev, struct bcm2835_gpios);
/* GPIOF_FUNC is not implemented yet */
if (bcm2835_gpio_is_output(gpios, offset))
@@ -103,7 +103,7 @@ static const struct dm_gpio_ops gpio_bcm2835_ops = {
static int bcm2835_gpio_probe(struct udevice *dev)
{
- struct bcm2835_gpios *gpios = dev_get_priv(dev);
+ struct bcm2835_gpios *gpios = dev_get_priv(dev, struct bcm2835_gpios);
struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
@@ -119,5 +119,5 @@ U_BOOT_DRIVER(gpio_bcm2835) = {
.id = UCLASS_GPIO,
.ops = &gpio_bcm2835_ops,
.probe = bcm2835_gpio_probe,
- .priv_auto_alloc_size = sizeof(struct bcm2835_gpios),
+ .priv_alloc = dm_alloc(struct bcm2835_gpios),
};
@@ -367,7 +367,7 @@ static int ich6_gpio_probe(struct udevice *dev)
{
struct ich6_bank_platdata *plat = dev_get_platdata(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
- struct ich6_bank_priv *bank = dev_get_priv(dev);
+ struct ich6_bank_priv *bank = dev_get_priv(dev, struct ich6_bank_priv);
if (gd->arch.gpio_map) {
setup_pch_gpios(plat->base_addr, gd->arch.gpio_map);
@@ -386,7 +386,7 @@ static int ich6_gpio_probe(struct udevice *dev)
static int ich6_gpio_request(struct udevice *dev, unsigned offset,
const char *label)
{
- struct ich6_bank_priv *bank = dev_get_priv(dev);
+ struct ich6_bank_priv *bank = dev_get_priv(dev, struct ich6_bank_priv);
u32 tmplong;
/*
@@ -406,7 +406,7 @@ static int ich6_gpio_request(struct udevice *dev, unsigned offset,
static int ich6_gpio_direction_input(struct udevice *dev, unsigned offset)
{
- struct ich6_bank_priv *bank = dev_get_priv(dev);
+ struct ich6_bank_priv *bank = dev_get_priv(dev, struct ich6_bank_priv);
return _ich6_gpio_set_direction(inl(bank->io_sel), offset, 0);
}
@@ -415,7 +415,7 @@ static int ich6_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
int ret;
- struct ich6_bank_priv *bank = dev_get_priv(dev);
+ struct ich6_bank_priv *bank = dev_get_priv(dev, struct ich6_bank_priv);
ret = _ich6_gpio_set_direction(inl(bank->io_sel), offset, 1);
if (ret)
@@ -426,7 +426,7 @@ static int ich6_gpio_direction_output(struct udevice *dev, unsigned offset,
static int ich6_gpio_get_value(struct udevice *dev, unsigned offset)
{
- struct ich6_bank_priv *bank = dev_get_priv(dev);
+ struct ich6_bank_priv *bank = dev_get_priv(dev, struct ich6_bank_priv);
u32 tmplong;
int r;
@@ -438,13 +438,13 @@ static int ich6_gpio_get_value(struct udevice *dev, unsigned offset)
static int ich6_gpio_set_value(struct udevice *dev, unsigned offset,
int value)
{
- struct ich6_bank_priv *bank = dev_get_priv(dev);
+ struct ich6_bank_priv *bank = dev_get_priv(dev, struct ich6_bank_priv);
return _ich6_gpio_set_value(bank->lvl, offset, value);
}
static int ich6_gpio_get_function(struct udevice *dev, unsigned offset)
{
- struct ich6_bank_priv *bank = dev_get_priv(dev);
+ struct ich6_bank_priv *bank = dev_get_priv(dev, struct ich6_bank_priv);
u32 mask = 1UL << offset;
if (!(inl(bank->use_sel) & mask))
@@ -476,6 +476,6 @@ U_BOOT_DRIVER(gpio_ich6) = {
.ops = &gpio_ich6_ops,
.ofdata_to_platdata = gpio_ich6_ofdata_to_platdata,
.probe = ich6_gpio_probe,
- .priv_auto_alloc_size = sizeof(struct ich6_bank_priv),
+ .priv_alloc = dm_alloc(struct ich6_bank_priv),
.platdata_auto_alloc_size = sizeof(struct ich6_bank_platdata),
};
@@ -289,5 +289,5 @@ U_BOOT_DRIVER(gpio_lpc32xx) = {
.id = UCLASS_GPIO,
.ops = &gpio_lpc32xx_ops,
.probe = lpc32xx_gpio_probe,
- .priv_auto_alloc_size = sizeof(struct lpc32xx_gpio_platdata),
+ .priv_alloc = dm_alloc(struct lpc32xx_gpio_platdata),
};
@@ -201,7 +201,7 @@ static int mxc_gpio_bank_get_value(struct gpio_regs *regs, int offset)
/* set GPIO pin 'gpio' as an input */
static int mxc_gpio_direction_input(struct udevice *dev, unsigned offset)
{
- struct mxc_bank_info *bank = dev_get_priv(dev);
+ struct mxc_bank_info *bank = dev_get_priv(dev, struct mxc_bank_info);
/* Configure GPIO direction as input. */
mxc_gpio_bank_direction(bank->regs, offset, MXC_GPIO_DIRECTION_IN);
@@ -213,7 +213,7 @@ static int mxc_gpio_direction_input(struct udevice *dev, unsigned offset)
static int mxc_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
- struct mxc_bank_info *bank = dev_get_priv(dev);
+ struct mxc_bank_info *bank = dev_get_priv(dev, struct mxc_bank_info);
/* Configure GPIO output value. */
mxc_gpio_bank_set_value(bank->regs, offset, value);
@@ -227,7 +227,7 @@ static int mxc_gpio_direction_output(struct udevice *dev, unsigned offset,
/* read GPIO IN value of pin 'gpio' */
static int mxc_gpio_get_value(struct udevice *dev, unsigned offset)
{
- struct mxc_bank_info *bank = dev_get_priv(dev);
+ struct mxc_bank_info *bank = dev_get_priv(dev, struct mxc_bank_info);
return mxc_gpio_bank_get_value(bank->regs, offset);
}
@@ -236,7 +236,7 @@ static int mxc_gpio_get_value(struct udevice *dev, unsigned offset)
static int mxc_gpio_set_value(struct udevice *dev, unsigned offset,
int value)
{
- struct mxc_bank_info *bank = dev_get_priv(dev);
+ struct mxc_bank_info *bank = dev_get_priv(dev, struct mxc_bank_info);
mxc_gpio_bank_set_value(bank->regs, offset, value);
@@ -245,7 +245,7 @@ static int mxc_gpio_set_value(struct udevice *dev, unsigned offset,
static int mxc_gpio_get_function(struct udevice *dev, unsigned offset)
{
- struct mxc_bank_info *bank = dev_get_priv(dev);
+ struct mxc_bank_info *bank = dev_get_priv(dev, struct mxc_bank_info);
/* GPIOF_FUNC is not implemented yet */
if (mxc_gpio_is_output(bank->regs, offset))
@@ -264,7 +264,7 @@ static const struct dm_gpio_ops gpio_mxc_ops = {
static int mxc_gpio_probe(struct udevice *dev)
{
- struct mxc_bank_info *bank = dev_get_priv(dev);
+ struct mxc_bank_info *bank = dev_get_priv(dev, struct mxc_bank_info);
struct mxc_gpio_plat *plat = dev_get_platdata(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
int banknum;
@@ -327,7 +327,7 @@ U_BOOT_DRIVER(gpio_mxc) = {
.id = UCLASS_GPIO,
.ops = &gpio_mxc_ops,
.probe = mxc_gpio_probe,
- .priv_auto_alloc_size = sizeof(struct mxc_bank_info),
+ .priv_alloc = dm_alloc(struct mxc_bank_info),
.of_match = mxc_gpio_ids,
.bind = mxc_gpio_bind,
};
@@ -247,7 +247,7 @@ int gpio_free(unsigned gpio)
/* set GPIO pin 'gpio' as an input */
static int omap_gpio_direction_input(struct udevice *dev, unsigned offset)
{
- struct gpio_bank *bank = dev_get_priv(dev);
+ struct gpio_bank *bank = dev_get_priv(dev, struct gpio_bank);
/* Configure GPIO direction as input. */
_set_gpio_direction(bank, offset, 1);
@@ -259,7 +259,7 @@ static int omap_gpio_direction_input(struct udevice *dev, unsigned offset)
static int omap_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
- struct gpio_bank *bank = dev_get_priv(dev);
+ struct gpio_bank *bank = dev_get_priv(dev, struct gpio_bank);
_set_gpio_dataout(bank, offset, value);
_set_gpio_direction(bank, offset, 0);
@@ -270,7 +270,7 @@ static int omap_gpio_direction_output(struct udevice *dev, unsigned offset,
/* read GPIO IN value of pin 'gpio' */
static int omap_gpio_get_value(struct udevice *dev, unsigned offset)
{
- struct gpio_bank *bank = dev_get_priv(dev);
+ struct gpio_bank *bank = dev_get_priv(dev, struct gpio_bank);
return _get_gpio_value(bank, offset);
}
@@ -279,7 +279,7 @@ static int omap_gpio_get_value(struct udevice *dev, unsigned offset)
static int omap_gpio_set_value(struct udevice *dev, unsigned offset,
int value)
{
- struct gpio_bank *bank = dev_get_priv(dev);
+ struct gpio_bank *bank = dev_get_priv(dev, struct gpio_bank);
_set_gpio_dataout(bank, offset, value);
@@ -288,7 +288,7 @@ static int omap_gpio_set_value(struct udevice *dev, unsigned offset,
static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
{
- struct gpio_bank *bank = dev_get_priv(dev);
+ struct gpio_bank *bank = dev_get_priv(dev, struct gpio_bank);
/* GPIOF_FUNC is not implemented yet */
if (_get_gpio_direction(bank, offset) == OMAP_GPIO_DIR_OUT)
@@ -307,7 +307,7 @@ static const struct dm_gpio_ops gpio_omap_ops = {
static int omap_gpio_probe(struct udevice *dev)
{
- struct gpio_bank *bank = dev_get_priv(dev);
+ struct gpio_bank *bank = dev_get_priv(dev, struct gpio_bank);
struct omap_gpio_platdata *plat = dev_get_platdata(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
char name[18], *str;
@@ -329,7 +329,7 @@ U_BOOT_DRIVER(gpio_omap) = {
.id = UCLASS_GPIO,
.ops = &gpio_omap_ops,
.probe = omap_gpio_probe,
- .priv_auto_alloc_size = sizeof(struct gpio_bank),
+ .priv_alloc = dm_alloc(struct gpio_bank),
};
#endif /* CONFIG_DM_GPIO */
@@ -27,7 +27,7 @@ struct rockchip_gpio_priv {
static int rockchip_gpio_direction_input(struct udevice *dev, unsigned offset)
{
- struct rockchip_gpio_priv *priv = dev_get_priv(dev);
+ struct rockchip_gpio_priv *priv = dev_get_priv(dev, struct rockchip_gpio_priv);
struct rockchip_gpio_regs *regs = priv->regs;
clrbits_le32(®s->swport_ddr, OFFSET_TO_BIT(offset));
@@ -38,7 +38,7 @@ static int rockchip_gpio_direction_input(struct udevice *dev, unsigned offset)
static int rockchip_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
- struct rockchip_gpio_priv *priv = dev_get_priv(dev);
+ struct rockchip_gpio_priv *priv = dev_get_priv(dev, struct rockchip_gpio_priv);
struct rockchip_gpio_regs *regs = priv->regs;
int mask = OFFSET_TO_BIT(offset);
@@ -50,7 +50,7 @@ static int rockchip_gpio_direction_output(struct udevice *dev, unsigned offset,
static int rockchip_gpio_get_value(struct udevice *dev, unsigned offset)
{
- struct rockchip_gpio_priv *priv = dev_get_priv(dev);
+ struct rockchip_gpio_priv *priv = dev_get_priv(dev, struct rockchip_gpio_priv);
struct rockchip_gpio_regs *regs = priv->regs;
return readl(®s->ext_port) & OFFSET_TO_BIT(offset);
@@ -59,7 +59,7 @@ static int rockchip_gpio_get_value(struct udevice *dev, unsigned offset)
static int rockchip_gpio_set_value(struct udevice *dev, unsigned offset,
int value)
{
- struct rockchip_gpio_priv *priv = dev_get_priv(dev);
+ struct rockchip_gpio_priv *priv = dev_get_priv(dev, struct rockchip_gpio_priv);
struct rockchip_gpio_regs *regs = priv->regs;
int mask = OFFSET_TO_BIT(offset);
@@ -85,7 +85,7 @@ static int rockchip_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
static int rockchip_gpio_probe(struct udevice *dev)
{
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
- struct rockchip_gpio_priv *priv = dev_get_priv(dev);
+ struct rockchip_gpio_priv *priv = dev_get_priv(dev, struct rockchip_gpio_priv);
char *end;
int bank;
@@ -118,6 +118,6 @@ U_BOOT_DRIVER(gpio_rockchip) = {
.id = UCLASS_GPIO,
.of_match = rockchip_gpio_ids,
.ops = &gpio_rockchip_ops,
- .priv_auto_alloc_size = sizeof(struct rockchip_gpio_priv),
+ .priv_alloc = dm_alloc(struct rockchip_gpio_priv),
.probe = rockchip_gpio_probe,
};
@@ -190,7 +190,7 @@ int s5p_gpio_get_pin(unsigned gpio)
/* set GPIO pin 'gpio' as an input */
static int exynos_gpio_direction_input(struct udevice *dev, unsigned offset)
{
- struct exynos_bank_info *state = dev_get_priv(dev);
+ struct exynos_bank_info *state = dev_get_priv(dev, struct exynos_bank_info);
/* Configure GPIO direction as input. */
s5p_gpio_cfg_pin(state->bank, offset, S5P_GPIO_INPUT);
@@ -202,7 +202,7 @@ static int exynos_gpio_direction_input(struct udevice *dev, unsigned offset)
static int exynos_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
- struct exynos_bank_info *state = dev_get_priv(dev);
+ struct exynos_bank_info *state = dev_get_priv(dev, struct exynos_bank_info);
/* Configure GPIO output value. */
s5p_gpio_set_value(state->bank, offset, value);
@@ -216,7 +216,7 @@ static int exynos_gpio_direction_output(struct udevice *dev, unsigned offset,
/* read GPIO IN value of pin 'gpio' */
static int exynos_gpio_get_value(struct udevice *dev, unsigned offset)
{
- struct exynos_bank_info *state = dev_get_priv(dev);
+ struct exynos_bank_info *state = dev_get_priv(dev, struct exynos_bank_info);
return s5p_gpio_get_value(state->bank, offset);
}
@@ -225,7 +225,7 @@ static int exynos_gpio_get_value(struct udevice *dev, unsigned offset)
static int exynos_gpio_set_value(struct udevice *dev, unsigned offset,
int value)
{
- struct exynos_bank_info *state = dev_get_priv(dev);
+ struct exynos_bank_info *state = dev_get_priv(dev, struct exynos_bank_info);
s5p_gpio_set_value(state->bank, offset, value);
@@ -263,7 +263,7 @@ void gpio_set_rate(int gpio, int mode)
int exynos_set_pull(struct udevice *dev, unsigned offset, enum gpio_pull pull)
{
- struct exynos_bank_info *state = dev_get_priv(dev);
+ struct exynos_bank_info *state = dev_get_priv(dev, struct exynos_bank_info);
int val = S5P_GPIO_PULL_NONE;
if (pull == GPIO_PULL_DOWN)
@@ -278,7 +278,7 @@ int exynos_set_pull(struct udevice *dev, unsigned offset, enum gpio_pull pull)
#ifndef CONFIG_SPL_BUILD
static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
{
- struct exynos_bank_info *state = dev_get_priv(dev);
+ struct exynos_bank_info *state = dev_get_priv(dev, struct exynos_bank_info);
int cfg;
cfg = s5p_gpio_get_cfg_pin(state->bank, offset);
@@ -390,7 +390,7 @@ U_BOOT_DRIVER(gpio_exynos) = {
.of_match = exynos_gpio_ids,
.bind = gpio_exynos_bind,
.probe = gpio_exynos_probe,
- .priv_auto_alloc_size = sizeof(struct exynos_bank_info),
+ .priv_alloc = dm_alloc(struct exynos_bank_info),
.ops = &gpio_exynos_ops,
};
#endif
@@ -25,7 +25,7 @@ struct gpio_state {
static u8 *get_gpio_flags(struct udevice *dev, unsigned offset)
{
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
- struct gpio_state *state = dev_get_priv(dev);
+ struct gpio_state *state = dev_get_priv(dev, struct gpio_state);
if (offset >= uc_priv->gpio_count) {
static u8 invalid_flags;
@@ -139,7 +139,7 @@ static void set_level(unsigned gpio, int high)
static int tegra_gpio_request(struct udevice *dev, unsigned offset,
const char *label)
{
- struct tegra_port_info *state = dev_get_priv(dev);
+ struct tegra_port_info *state = dev_get_priv(dev, struct tegra_port_info);
/* Configure as a GPIO */
set_config(state->base_gpio + offset, 1);
@@ -150,7 +150,7 @@ static int tegra_gpio_request(struct udevice *dev, unsigned offset,
/* set GPIO pin 'gpio' as an input */
static int tegra_gpio_direction_input(struct udevice *dev, unsigned offset)
{
- struct tegra_port_info *state = dev_get_priv(dev);
+ struct tegra_port_info *state = dev_get_priv(dev, struct tegra_port_info);
/* Configure GPIO direction as input. */
set_direction(state->base_gpio + offset, 0);
@@ -162,7 +162,7 @@ static int tegra_gpio_direction_input(struct udevice *dev, unsigned offset)
static int tegra_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
- struct tegra_port_info *state = dev_get_priv(dev);
+ struct tegra_port_info *state = dev_get_priv(dev, struct tegra_port_info);
int gpio = state->base_gpio + offset;
/* Configure GPIO output value. */
@@ -177,7 +177,7 @@ static int tegra_gpio_direction_output(struct udevice *dev, unsigned offset,
/* read GPIO IN value of pin 'gpio' */
static int tegra_gpio_get_value(struct udevice *dev, unsigned offset)
{
- struct tegra_port_info *state = dev_get_priv(dev);
+ struct tegra_port_info *state = dev_get_priv(dev, struct tegra_port_info);
int gpio = state->base_gpio + offset;
int val;
@@ -192,7 +192,7 @@ static int tegra_gpio_get_value(struct udevice *dev, unsigned offset)
/* write GPIO OUT value to pin 'gpio' */
static int tegra_gpio_set_value(struct udevice *dev, unsigned offset, int value)
{
- struct tegra_port_info *state = dev_get_priv(dev);
+ struct tegra_port_info *state = dev_get_priv(dev, struct tegra_port_info);
int gpio = state->base_gpio + offset;
debug("gpio_set_value: pin = %d (port %d:bit %d), value = %d\n",
@@ -226,7 +226,7 @@ void gpio_config_table(const struct tegra_gpio_config *config, int len)
static int tegra_gpio_get_function(struct udevice *dev, unsigned offset)
{
- struct tegra_port_info *state = dev_get_priv(dev);
+ struct tegra_port_info *state = dev_get_priv(dev, struct tegra_port_info);
int gpio = state->base_gpio + offset;
if (!get_config(gpio))
@@ -380,7 +380,7 @@ U_BOOT_DRIVER(gpio_tegra) = {
.of_match = tegra_gpio_ids,
.bind = gpio_tegra_bind,
.probe = gpio_tegra_probe,
- .priv_auto_alloc_size = sizeof(struct tegra_port_info),
+ .priv_alloc = dm_alloc(struct tegra_port_info),
.ops = &gpio_tegra_ops,
.flags = DM_FLAG_PRE_RELOC,
};
@@ -23,7 +23,7 @@ struct vybrid_gpios {
static int vybrid_gpio_direction_input(struct udevice *dev, unsigned gpio)
{
- const struct vybrid_gpios *gpios = dev_get_priv(dev);
+ const struct vybrid_gpios *gpios = dev_get_priv(dev, struct vybrid_gpios);
gpio = gpio + (gpios->chip * VYBRID_GPIO_COUNT);
imx_iomux_gpio_set_direction(gpio, VF610_GPIO_DIRECTION_IN);
@@ -34,7 +34,7 @@ static int vybrid_gpio_direction_input(struct udevice *dev, unsigned gpio)
static int vybrid_gpio_direction_output(struct udevice *dev, unsigned gpio,
int value)
{
- const struct vybrid_gpios *gpios = dev_get_priv(dev);
+ const struct vybrid_gpios *gpios = dev_get_priv(dev, struct vybrid_gpios);
gpio = gpio + (gpios->chip * VYBRID_GPIO_COUNT);
gpio_set_value(gpio, value);
@@ -45,7 +45,7 @@ static int vybrid_gpio_direction_output(struct udevice *dev, unsigned gpio,
static int vybrid_gpio_get_value(struct udevice *dev, unsigned gpio)
{
- const struct vybrid_gpios *gpios = dev_get_priv(dev);
+ const struct vybrid_gpios *gpios = dev_get_priv(dev, struct vybrid_gpios);
return ((readl(&gpios->reg->gpio_pdir) & (1 << gpio))) ? 1 : 0;
}
@@ -53,7 +53,7 @@ static int vybrid_gpio_get_value(struct udevice *dev, unsigned gpio)
static int vybrid_gpio_set_value(struct udevice *dev, unsigned gpio,
int value)
{
- const struct vybrid_gpios *gpios = dev_get_priv(dev);
+ const struct vybrid_gpios *gpios = dev_get_priv(dev, struct vybrid_gpios);
if (value)
writel((1 << gpio), &gpios->reg->gpio_psor);
else
@@ -64,7 +64,7 @@ static int vybrid_gpio_set_value(struct udevice *dev, unsigned gpio,
static int vybrid_gpio_get_function(struct udevice *dev, unsigned gpio)
{
- const struct vybrid_gpios *gpios = dev_get_priv(dev);
+ const struct vybrid_gpios *gpios = dev_get_priv(dev, struct vybrid_gpios);
u32 g_state = 0;
gpio = gpio + (gpios->chip * VYBRID_GPIO_COUNT);
@@ -93,7 +93,7 @@ static const struct dm_gpio_ops gpio_vybrid_ops = {
static int vybrid_gpio_probe(struct udevice *dev)
{
- struct vybrid_gpios *gpios = dev_get_priv(dev);
+ struct vybrid_gpios *gpios = dev_get_priv(dev, struct vybrid_gpios);
struct vybrid_gpio_platdata *plat = dev_get_platdata(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
@@ -163,7 +163,7 @@ U_BOOT_DRIVER(gpio_vybrid) = {
.id = UCLASS_GPIO,
.ops = &gpio_vybrid_ops,
.probe = vybrid_gpio_probe,
- .priv_auto_alloc_size = sizeof(struct vybrid_gpios),
+ .priv_alloc = dm_alloc(struct vybrid_gpios),
.of_match = vybrid_gpio_ids,
.bind = vybrid_gpio_bind,
};
@@ -253,7 +253,7 @@ static int i2c_gpio_read_data(struct i2c_gpio_bus *bus, uchar chip,
static int i2c_gpio_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs)
{
- struct i2c_gpio_bus *bus = dev_get_priv(dev);
+ struct i2c_gpio_bus *bus = dev_get_priv(dev, struct i2c_gpio_bus);
int ret;
for (; nmsgs > 0; nmsgs--, msg++) {
@@ -276,7 +276,7 @@ static int i2c_gpio_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs)
static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags)
{
- struct i2c_gpio_bus *bus = dev_get_priv(dev);
+ struct i2c_gpio_bus *bus = dev_get_priv(dev, struct i2c_gpio_bus);
struct gpio_desc *scl = &bus->gpios[PIN_SCL];
struct gpio_desc *sda = &bus->gpios[PIN_SDA];
unsigned int delay = bus->udelay;
@@ -294,7 +294,7 @@ static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags)
static int i2c_gpio_set_bus_speed(struct udevice *dev, unsigned int speed_hz)
{
- struct i2c_gpio_bus *bus = dev_get_priv(dev);
+ struct i2c_gpio_bus *bus = dev_get_priv(dev, struct i2c_gpio_bus);
struct gpio_desc *scl = &bus->gpios[PIN_SCL];
struct gpio_desc *sda = &bus->gpios[PIN_SDA];
@@ -307,7 +307,7 @@ static int i2c_gpio_set_bus_speed(struct udevice *dev, unsigned int speed_hz)
static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
{
- struct i2c_gpio_bus *bus = dev_get_priv(dev);
+ struct i2c_gpio_bus *bus = dev_get_priv(dev, struct i2c_gpio_bus);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int ret;
@@ -342,6 +342,6 @@ U_BOOT_DRIVER(i2c_gpio) = {
.id = UCLASS_I2C,
.of_match = i2c_gpio_ids,
.ofdata_to_platdata = i2c_gpio_ofdata_to_platdata,
- .priv_auto_alloc_size = sizeof(struct i2c_gpio_bus),
+ .priv_alloc = dm_alloc(struct i2c_gpio_bus),
.ops = &i2c_gpio_ops,
};
@@ -113,7 +113,7 @@ static int uniphier_fi2c_probe(struct udevice *dev)
{
fdt_addr_t addr;
fdt_size_t size;
- struct uniphier_fi2c_dev *priv = dev_get_priv(dev);
+ struct uniphier_fi2c_dev *priv = dev_get_priv(dev, struct uniphier_fi2c_dev);
int ret;
addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg",
@@ -138,7 +138,7 @@ static int uniphier_fi2c_probe(struct udevice *dev)
static int uniphier_fi2c_remove(struct udevice *dev)
{
- struct uniphier_fi2c_dev *priv = dev_get_priv(dev);
+ struct uniphier_fi2c_dev *priv = dev_get_priv(dev, struct uniphier_fi2c_dev);
unmap_sysmem(priv->regs);
@@ -284,7 +284,7 @@ static int uniphier_fi2c_xfer(struct udevice *bus, struct i2c_msg *msg,
int nmsgs)
{
int ret;
- struct uniphier_fi2c_dev *dev = dev_get_priv(bus);
+ struct uniphier_fi2c_dev *dev = dev_get_priv(bus, struct uniphier_fi2c_dev);
bool stop;
ret = check_device_busy(dev->regs);
@@ -313,7 +313,7 @@ static int uniphier_fi2c_set_bus_speed(struct udevice *bus, unsigned int speed)
{
int ret;
unsigned int clk_count;
- struct uniphier_fi2c_dev *dev = dev_get_priv(bus);
+ struct uniphier_fi2c_dev *dev = dev_get_priv(bus, struct uniphier_fi2c_dev);
struct uniphier_fi2c_regs __iomem *regs = dev->regs;
/* max supported frequency is 400 kHz */
@@ -362,6 +362,6 @@ U_BOOT_DRIVER(uniphier_fi2c) = {
.of_match = uniphier_fi2c_of_match,
.probe = uniphier_fi2c_probe,
.remove = uniphier_fi2c_remove,
- .priv_auto_alloc_size = sizeof(struct uniphier_fi2c_dev),
+ .priv_alloc = dm_alloc(struct uniphier_fi2c_dev),
.ops = &uniphier_fi2c_ops,
};
@@ -49,7 +49,7 @@ static int uniphier_i2c_probe(struct udevice *dev)
{
fdt_addr_t addr;
fdt_size_t size;
- struct uniphier_i2c_dev *priv = dev_get_priv(dev);
+ struct uniphier_i2c_dev *priv = dev_get_priv(dev, struct uniphier_i2c_dev);
addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
@@ -68,7 +68,7 @@ static int uniphier_i2c_probe(struct udevice *dev)
static int uniphier_i2c_remove(struct udevice *dev)
{
- struct uniphier_i2c_dev *priv = dev_get_priv(dev);
+ struct uniphier_i2c_dev *priv = dev_get_priv(dev, struct uniphier_i2c_dev);
unmap_sysmem(priv->regs);
@@ -159,7 +159,7 @@ static int uniphier_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
int nmsgs)
{
int ret = 0;
- struct uniphier_i2c_dev *dev = dev_get_priv(bus);
+ struct uniphier_i2c_dev *dev = dev_get_priv(bus, struct uniphier_i2c_dev);
bool stop;
for (; nmsgs > 0; nmsgs--, msg++) {
@@ -182,7 +182,7 @@ static int uniphier_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
static int uniphier_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
{
- struct uniphier_i2c_dev *priv = dev_get_priv(bus);
+ struct uniphier_i2c_dev *priv = dev_get_priv(bus, struct uniphier_i2c_dev);
/* max supported frequency is 400 kHz */
if (speed > 400000)
@@ -222,6 +222,6 @@ U_BOOT_DRIVER(uniphier_i2c) = {
.of_match = uniphier_i2c_of_match,
.probe = uniphier_i2c_probe,
.remove = uniphier_i2c_remove,
- .priv_auto_alloc_size = sizeof(struct uniphier_i2c_dev),
+ .priv_alloc = dm_alloc(struct uniphier_i2c_dev),
.ops = &uniphier_i2c_ops,
};
@@ -24,7 +24,7 @@ struct i2c_arbitrator_priv {
int i2c_arbitrator_deselect(struct udevice *mux, struct udevice *bus,
uint channel)
{
- struct i2c_arbitrator_priv *priv = dev_get_priv(mux);
+ struct i2c_arbitrator_priv *priv = dev_get_priv(mux, struct i2c_arbitrator_priv);
int ret;
debug("%s: %s\n", __func__, mux->name);
@@ -37,7 +37,7 @@ int i2c_arbitrator_deselect(struct udevice *mux, struct udevice *bus,
int i2c_arbitrator_select(struct udevice *mux, struct udevice *bus,
uint channel)
{
- struct i2c_arbitrator_priv *priv = dev_get_priv(mux);
+ struct i2c_arbitrator_priv *priv = dev_get_priv(mux, struct i2c_arbitrator_priv);
unsigned start;
int ret;
@@ -88,7 +88,7 @@ err:
static int i2c_arbitrator_probe(struct udevice *dev)
{
- struct i2c_arbitrator_priv *priv = dev_get_priv(dev);
+ struct i2c_arbitrator_priv *priv = dev_get_priv(dev, struct i2c_arbitrator_priv);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int ret;
@@ -119,7 +119,7 @@ err:
static int i2c_arbitrator_remove(struct udevice *dev)
{
- struct i2c_arbitrator_priv *priv = dev_get_priv(dev);
+ struct i2c_arbitrator_priv *priv = dev_get_priv(dev, struct i2c_arbitrator_priv);
dm_gpio_free(dev, &priv->ap_claim);
dm_gpio_free(dev, &priv->ec_claim);
@@ -144,5 +144,5 @@ U_BOOT_DRIVER(i2c_arbitrator) = {
.probe = i2c_arbitrator_probe,
.remove = i2c_arbitrator_remove,
.ops = &i2c_arbitrator_ops,
- .priv_auto_alloc_size = sizeof(struct i2c_arbitrator_priv),
+ .priv_alloc = dm_alloc(struct i2c_arbitrator_priv),
};
@@ -641,14 +641,14 @@ U_BOOT_I2C_ADAP_COMPLETE(mxc3, mxc_i2c_init, mxc_i2c_probe,
static int mxc_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
{
- struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
+ struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus, struct mxc_i2c_bus);
return bus_i2c_set_bus_speed(i2c_bus, speed);
}
static int mxc_i2c_probe(struct udevice *bus)
{
- struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
+ struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus, struct mxc_i2c_bus);
fdt_addr_t addr;
int ret;
@@ -689,7 +689,7 @@ static int mxc_i2c_probe_chip(struct udevice *bus, u32 chip_addr,
u32 chip_flags)
{
int ret;
- struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
+ struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus, struct mxc_i2c_bus);
ret = i2c_init_transfer(i2c_bus, chip_addr, 0, 0);
if (ret < 0) {
@@ -704,7 +704,7 @@ static int mxc_i2c_probe_chip(struct udevice *bus, u32 chip_addr,
static int mxc_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
{
- struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
+ struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus, struct mxc_i2c_bus);
int ret = 0;
ulong base = i2c_bus->base;
int reg_shift = i2c_bus->driver_data & I2C_QUIRK_FLAG ?
@@ -772,7 +772,7 @@ U_BOOT_DRIVER(i2c_mxc) = {
.id = UCLASS_I2C,
.of_match = mxc_i2c_ids,
.probe = mxc_i2c_probe,
- .priv_auto_alloc_size = sizeof(struct mxc_i2c_bus),
+ .priv_alloc = dm_alloc(struct mxc_i2c_bus),
.ops = &mxc_i2c_ops,
};
#endif
@@ -321,7 +321,7 @@ i2c_exit:
static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
int nmsgs)
{
- struct rk_i2c *i2c = dev_get_priv(bus);
+ struct rk_i2c *i2c = dev_get_priv(bus, struct rk_i2c);
int ret;
debug("i2c_xfer: %d messages\n", nmsgs);
@@ -345,7 +345,7 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
int rockchip_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
{
- struct rk_i2c *i2c = dev_get_priv(bus);
+ struct rk_i2c *i2c = dev_get_priv(bus, struct rk_i2c);
rk_i2c_set_clk(i2c, speed);
@@ -354,7 +354,7 @@ int rockchip_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
static int rockchip_i2c_probe(struct udevice *bus)
{
- struct rk_i2c *i2c = dev_get_priv(bus);
+ struct rk_i2c *i2c = dev_get_priv(bus, struct rk_i2c);
int ret;
ret = uclass_get_device(UCLASS_PINCTRL, 0, &i2c->pinctrl);
@@ -386,6 +386,6 @@ U_BOOT_DRIVER(i2c_rockchip) = {
.id = UCLASS_I2C,
.of_match = rockchip_i2c_ids,
.probe = rockchip_i2c_probe,
- .priv_auto_alloc_size = sizeof(struct rk_i2c),
+ .priv_alloc = dm_alloc(struct rk_i2c),
.ops = &rockchip_i2c_ops,
};
@@ -1287,7 +1287,7 @@ U_BOOT_I2C_ADAP_COMPLETE(s3c0, s3c24x0_i2c_init, s3c24x0_i2c_probe,
static int exynos_hs_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
int nmsgs)
{
- struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
+ struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev, struct s3c24x0_i2c_bus);
struct exynos5_hsi2c *hsregs = i2c_bus->hsregs;
int ret;
@@ -1363,7 +1363,7 @@ err:
static int s3c24x0_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
int nmsgs)
{
- struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
+ struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev, struct s3c24x0_i2c_bus);
struct s3c24x0_i2c *i2c = i2c_bus->regs;
ulong start_time;
int ret, i;
@@ -1389,7 +1389,7 @@ static int s3c24x0_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
{
const void *blob = gd->fdt_blob;
- struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
+ struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev, struct s3c24x0_i2c_bus);
int node, flags;
i2c_bus->is_highspeed = dev_get_driver_data(dev);
@@ -1436,7 +1436,7 @@ U_BOOT_DRIVER(i2c_s3c) = {
.of_match = s3c_i2c_ids,
.ofdata_to_platdata = s3c_i2c_ofdata_to_platdata,
.per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
- .priv_auto_alloc_size = sizeof(struct s3c24x0_i2c_bus),
+ .priv_alloc = dm_alloc(struct s3c24x0_i2c_bus),
.ops = &s3c_i2c_ops,
};
@@ -1461,7 +1461,7 @@ U_BOOT_DRIVER(hs_i2c) = {
.of_match = exynos_hs_i2c_ids,
.ofdata_to_platdata = s3c_i2c_ofdata_to_platdata,
.per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
- .priv_auto_alloc_size = sizeof(struct s3c24x0_i2c_bus),
+ .priv_alloc = dm_alloc(struct s3c24x0_i2c_bus),
.ops = &exynos_hs_i2c_ops,
};
#endif /* CONFIG_DM_I2C */
@@ -63,7 +63,7 @@ static int get_emul(struct udevice *dev, struct udevice **devp,
void sandbox_i2c_set_test_mode(struct udevice *bus, bool test_mode)
{
- struct sandbox_i2c_priv *priv = dev_get_priv(bus);
+ struct sandbox_i2c_priv *priv = dev_get_priv(bus, struct sandbox_i2c_priv);
priv->test_mode = test_mode;
}
@@ -72,7 +72,7 @@ static int sandbox_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
int nmsgs)
{
struct dm_i2c_bus *i2c = dev_get_uclass_priv(bus);
- struct sandbox_i2c_priv *priv = dev_get_priv(bus);
+ struct sandbox_i2c_priv *priv = dev_get_priv(bus, struct sandbox_i2c_priv);
struct dm_i2c_ops *ops;
struct udevice *emul, *dev;
bool is_read;
@@ -119,5 +119,5 @@ U_BOOT_DRIVER(i2c_sandbox) = {
.id = UCLASS_I2C,
.of_match = sandbox_i2c_ids,
.ops = &sandbox_i2c_ops,
- .priv_auto_alloc_size = sizeof(struct sandbox_i2c_priv),
+ .priv_alloc = dm_alloc(struct sandbox_i2c_priv),
};
@@ -322,7 +322,7 @@ static int tegra_i2c_read_data(struct i2c_bus *i2c_bus, u32 addr, u8 *data,
static int tegra_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
{
- struct i2c_bus *i2c_bus = dev_get_priv(dev);
+ struct i2c_bus *i2c_bus = dev_get_priv(dev, struct i2c_bus);
i2c_bus->speed = speed;
i2c_init_controller(i2c_bus);
@@ -332,7 +332,7 @@ static int tegra_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
static int tegra_i2c_probe(struct udevice *dev)
{
- struct i2c_bus *i2c_bus = dev_get_priv(dev);
+ struct i2c_bus *i2c_bus = dev_get_priv(dev, struct i2c_bus);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
bool is_dvc;
@@ -424,7 +424,7 @@ static int i2c_read_data(struct i2c_bus *i2c_bus, uchar chip, uchar *buffer,
static int tegra_i2c_probe_chip(struct udevice *bus, uint chip_addr,
uint chip_flags)
{
- struct i2c_bus *i2c_bus = dev_get_priv(bus);
+ struct i2c_bus *i2c_bus = dev_get_priv(bus, struct i2c_bus);
int rc;
u8 reg;
@@ -438,7 +438,7 @@ static int tegra_i2c_probe_chip(struct udevice *bus, uint chip_addr,
static int tegra_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
int nmsgs)
{
- struct i2c_bus *i2c_bus = dev_get_priv(bus);
+ struct i2c_bus *i2c_bus = dev_get_priv(bus, struct i2c_bus);
int ret;
debug("i2c_xfer: %d messages\n", nmsgs);
@@ -496,6 +496,6 @@ U_BOOT_DRIVER(i2c_tegra) = {
.id = UCLASS_I2C,
.of_match = tegra_i2c_ids,
.probe = tegra_i2c_probe,
- .priv_auto_alloc_size = sizeof(struct i2c_bus),
+ .priv_alloc = dm_alloc(struct i2c_bus),
.ops = &tegra_i2c_ops,
};
@@ -20,7 +20,7 @@ struct led_gpio_priv {
static int gpio_led_set_on(struct udevice *dev, int on)
{
- struct led_gpio_priv *priv = dev_get_priv(dev);
+ struct led_gpio_priv *priv = dev_get_priv(dev, struct led_gpio_priv);
if (!dm_gpio_is_valid(&priv->gpio))
return -EREMOTEIO;
@@ -31,7 +31,7 @@ static int gpio_led_set_on(struct udevice *dev, int on)
static int led_gpio_probe(struct udevice *dev)
{
struct led_uclass_plat *uc_plat = dev_get_uclass_platdata(dev);
- struct led_gpio_priv *priv = dev_get_priv(dev);
+ struct led_gpio_priv *priv = dev_get_priv(dev, struct led_gpio_priv);
/* Ignore the top-level LED node */
if (!uc_plat->label)
@@ -46,7 +46,7 @@ static int led_gpio_remove(struct udevice *dev)
* address this more generally.
*/
#ifndef CONFIG_SANDBOX
- struct led_gpio_priv *priv = dev_get_priv(dev);
+ struct led_gpio_priv *priv = dev_get_priv(dev, struct led_gpio_priv);
if (dm_gpio_is_valid(&priv->gpio))
dm_gpio_free(dev, &priv->gpio);
@@ -100,7 +100,7 @@ U_BOOT_DRIVER(led_gpio) = {
.id = UCLASS_LED,
.of_match = led_gpio_ids,
.ops = &gpio_led_ops,
- .priv_auto_alloc_size = sizeof(struct led_gpio_priv),
+ .priv_alloc = dm_alloc(struct led_gpio_priv),
.bind = led_gpio_bind,
.probe = led_gpio_probe,
.remove = led_gpio_remove,
@@ -472,7 +472,7 @@ static int process_cmd(struct ec_state *ec,
int cros_ec_sandbox_packet(struct udevice *udev, int out_bytes, int in_bytes)
{
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
- struct ec_state *ec = dev_get_priv(dev->dev);
+ struct ec_state *ec = dev_get_priv(dev->dev, struct ec_state);
struct ec_host_request *req_hdr = (struct ec_host_request *)dev->dout;
const void *req_data = req_hdr + 1;
struct ec_host_response *resp_hdr = (struct ec_host_response *)dev->din;
@@ -497,7 +497,7 @@ int cros_ec_sandbox_packet(struct udevice *udev, int out_bytes, int in_bytes)
void cros_ec_check_keyboard(struct cros_ec_dev *dev)
{
- struct ec_state *ec = dev_get_priv(dev->dev);
+ struct ec_state *ec = dev_get_priv(dev->dev, struct ec_state);
ulong start;
printf("Press keys for EC to detect on reset (ESC=recovery)...");
@@ -568,6 +568,6 @@ U_BOOT_DRIVER(cros_ec_sandbox) = {
.id = UCLASS_CROS_EC,
.of_match = cros_ec_ids,
.probe = cros_ec_probe,
- .priv_auto_alloc_size = sizeof(struct ec_state),
+ .priv_alloc = dm_alloc(struct ec_state),
.ops = &cros_ec_ops,
};
@@ -42,7 +42,7 @@ U_BOOT_DRIVER(i2c_eeprom_std) = {
.id = UCLASS_I2C_EEPROM,
.of_match = i2c_eeprom_std_ids,
.probe = i2c_eeprom_std_probe,
- .priv_auto_alloc_size = sizeof(struct i2c_eeprom),
+ .priv_alloc = dm_alloc(struct i2c_eeprom),
.ops = &i2c_eeprom_std_ops,
};
@@ -51,7 +51,7 @@ void sandbox_i2c_eeprom_set_offset_len(struct udevice *dev, int offset_len)
static int sandbox_i2c_eeprom_xfer(struct udevice *emul, struct i2c_msg *msg,
int nmsgs)
{
- struct sandbox_i2c_flash *priv = dev_get_priv(emul);
+ struct sandbox_i2c_flash *priv = dev_get_priv(emul, struct sandbox_i2c_flash);
uint offset = 0;
debug("\n%s\n", __func__);
@@ -133,7 +133,7 @@ static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev)
static int sandbox_i2c_eeprom_probe(struct udevice *dev)
{
struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev);
- struct sandbox_i2c_flash *priv = dev_get_priv(dev);
+ struct sandbox_i2c_flash *priv = dev_get_priv(dev, struct sandbox_i2c_flash);
priv->data = calloc(1, plat->size);
if (!priv->data)
@@ -144,7 +144,7 @@ static int sandbox_i2c_eeprom_probe(struct udevice *dev)
static int sandbox_i2c_eeprom_remove(struct udevice *dev)
{
- struct sandbox_i2c_flash *priv = dev_get_priv(dev);
+ struct sandbox_i2c_flash *priv = dev_get_priv(dev, struct sandbox_i2c_flash);
free(priv->data);
@@ -163,7 +163,7 @@ U_BOOT_DRIVER(sandbox_i2c_emul) = {
.ofdata_to_platdata = sandbox_i2c_eeprom_ofdata_to_platdata,
.probe = sandbox_i2c_eeprom_probe,
.remove = sandbox_i2c_eeprom_remove,
- .priv_auto_alloc_size = sizeof(struct sandbox_i2c_flash),
+ .priv_alloc = dm_alloc(struct sandbox_i2c_flash),
.platdata_auto_alloc_size = sizeof(struct sandbox_i2c_flash_plat_data),
.ops = &sandbox_i2c_emul_ops,
};
@@ -194,7 +194,7 @@ static void sandbox_swap_case_do_op(enum swap_case_op op, char *str, int len)
int sandbox_swap_case_read_io(struct udevice *dev, unsigned int addr,
ulong *valuep, enum pci_size_t size)
{
- struct swap_case_priv *priv = dev_get_priv(dev);
+ struct swap_case_priv *priv = dev_get_priv(dev, struct swap_case_priv);
unsigned int offset;
int barnum;
int ret;
@@ -212,7 +212,7 @@ int sandbox_swap_case_read_io(struct udevice *dev, unsigned int addr,
int sandbox_swap_case_write_io(struct udevice *dev, unsigned int addr,
ulong value, enum pci_size_t size)
{
- struct swap_case_priv *priv = dev_get_priv(dev);
+ struct swap_case_priv *priv = dev_get_priv(dev, struct swap_case_priv);
unsigned int offset;
int barnum;
int ret;
@@ -229,7 +229,7 @@ int sandbox_swap_case_write_io(struct udevice *dev, unsigned int addr,
static int sandbox_swap_case_map_physmem(struct udevice *dev,
phys_addr_t addr, unsigned long *lenp, void **ptrp)
{
- struct swap_case_priv *priv = dev_get_priv(dev);
+ struct swap_case_priv *priv = dev_get_priv(dev, struct swap_case_priv);
unsigned int offset, avail;
int barnum;
int ret;
@@ -254,7 +254,7 @@ static int sandbox_swap_case_map_physmem(struct udevice *dev,
static int sandbox_swap_case_unmap_physmem(struct udevice *dev,
const void *vaddr, unsigned long len)
{
- struct swap_case_priv *priv = dev_get_priv(dev);
+ struct swap_case_priv *priv = dev_get_priv(dev, struct swap_case_priv);
sandbox_swap_case_do_op(priv->op, (void *)vaddr, len);
@@ -281,6 +281,6 @@ U_BOOT_DRIVER(sandbox_swap_case_emul) = {
.id = UCLASS_PCI_EMUL,
.of_match = sandbox_swap_case_ids,
.ops = &sandbox_swap_case_emul_ops,
- .priv_auto_alloc_size = sizeof(struct swap_case_priv),
+ .priv_alloc = dm_alloc(struct swap_case_priv),
.platdata_auto_alloc_size = sizeof(struct swap_case_platdata),
};
@@ -25,7 +25,7 @@ struct rockchip_mmc_priv {
static uint rockchip_mmc_get_mmc_clk(struct dwmci_host *host, uint freq)
{
struct udevice *dev = host->priv;
- struct rockchip_mmc_priv *priv = dev_get_priv(dev);
+ struct rockchip_mmc_priv *priv = dev_get_priv(dev, struct rockchip_mmc_priv);
int ret;
ret = clk_set_periph_rate(priv->clk, PERIPH_ID_SDMMC0 + host->dev_index,
@@ -40,7 +40,7 @@ static uint rockchip_mmc_get_mmc_clk(struct dwmci_host *host, uint freq)
static int rockchip_mmc_ofdata_to_platdata(struct udevice *dev)
{
- struct rockchip_mmc_priv *priv = dev_get_priv(dev);
+ struct rockchip_mmc_priv *priv = dev_get_priv(dev, struct rockchip_mmc_priv);
struct dwmci_host *host = &priv->host;
host->name = dev->name;
@@ -59,7 +59,7 @@ static int rockchip_mmc_ofdata_to_platdata(struct udevice *dev)
int rockchip_mmc_probe(struct udevice *dev)
{
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
- struct rockchip_mmc_priv *priv = dev_get_priv(dev);
+ struct rockchip_mmc_priv *priv = dev_get_priv(dev, struct rockchip_mmc_priv);
struct dwmci_host *host = &priv->host;
u32 minmax[2];
int ret;
@@ -94,5 +94,5 @@ U_BOOT_DRIVER(rockchip_mmc_drv) = {
.of_match = rockchip_mmc_ids,
.ofdata_to_platdata = rockchip_mmc_ofdata_to_platdata,
.probe = rockchip_mmc_probe,
- .priv_auto_alloc_size = sizeof(struct dwmci_host),
+ .priv_alloc = dm_alloc(struct dwmci_host),
};
@@ -109,7 +109,7 @@ struct sandbox_spi_flash_plat_data {
static int sandbox_sf_probe(struct udevice *dev)
{
/* spec = idcode:file */
- struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
+ struct sandbox_spi_flash *sbsf = dev_get_priv(dev, struct sandbox_spi_flash);
const char *file;
size_t len, idname_len;
const struct spi_flash_params *data;
@@ -204,7 +204,7 @@ static int sandbox_sf_probe(struct udevice *dev)
static int sandbox_sf_remove(struct udevice *dev)
{
- struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
+ struct sandbox_spi_flash *sbsf = dev_get_priv(dev, struct sandbox_spi_flash);
os_close(sbsf->fd);
@@ -213,7 +213,7 @@ static int sandbox_sf_remove(struct udevice *dev)
static void sandbox_sf_cs_activate(struct udevice *dev)
{
- struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
+ struct sandbox_spi_flash *sbsf = dev_get_priv(dev, struct sandbox_spi_flash);
debug("sandbox_sf: CS activated; state is fresh!\n");
@@ -331,7 +331,7 @@ int sandbox_erase_part(struct sandbox_spi_flash *sbsf, int size)
static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
const void *rxp, void *txp, unsigned long flags)
{
- struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
+ struct sandbox_spi_flash *sbsf = dev_get_priv(dev, struct sandbox_spi_flash);
const uint8_t *rx = rxp;
uint8_t *tx = txp;
uint cnt, pos = 0;
@@ -691,7 +691,7 @@ U_BOOT_DRIVER(sandbox_sf_emul) = {
.ofdata_to_platdata = sandbox_sf_ofdata_to_platdata,
.probe = sandbox_sf_probe,
.remove = sandbox_sf_remove,
- .priv_auto_alloc_size = sizeof(struct sandbox_spi_flash),
+ .priv_alloc = dm_alloc(struct sandbox_spi_flash),
.platdata_auto_alloc_size = sizeof(struct sandbox_spi_flash_plat_data),
.ops = &sandbox_sf_emul_ops,
};
@@ -496,7 +496,7 @@ U_BOOT_DRIVER(spi_flash_std) = {
.id = UCLASS_SPI_FLASH,
.of_match = spi_flash_std_ids,
.probe = spi_flash_std_probe,
- .priv_auto_alloc_size = sizeof(struct spi_flash),
+ .priv_alloc = dm_alloc(struct spi_flash),
.ops = &spi_flash_std_ops,
};
@@ -517,14 +517,14 @@ static int designware_eth_start(struct udevice *dev)
static int designware_eth_send(struct udevice *dev, void *packet, int length)
{
- struct dw_eth_dev *priv = dev_get_priv(dev);
+ struct dw_eth_dev *priv = dev_get_priv(dev, struct dw_eth_dev);
return _dw_eth_send(priv, packet, length);
}
static int designware_eth_recv(struct udevice *dev, uchar **packetp)
{
- struct dw_eth_dev *priv = dev_get_priv(dev);
+ struct dw_eth_dev *priv = dev_get_priv(dev, struct dw_eth_dev);
return _dw_eth_recv(priv, packetp);
}
@@ -532,14 +532,14 @@ static int designware_eth_recv(struct udevice *dev, uchar **packetp)
static int designware_eth_free_pkt(struct udevice *dev, uchar *packet,
int length)
{
- struct dw_eth_dev *priv = dev_get_priv(dev);
+ struct dw_eth_dev *priv = dev_get_priv(dev, struct dw_eth_dev);
return _dw_free_pkt(priv);
}
static void designware_eth_stop(struct udevice *dev)
{
- struct dw_eth_dev *priv = dev_get_priv(dev);
+ struct dw_eth_dev *priv = dev_get_priv(dev, struct dw_eth_dev);
return _dw_eth_halt(priv);
}
@@ -547,7 +547,7 @@ static void designware_eth_stop(struct udevice *dev)
static int designware_eth_write_hwaddr(struct udevice *dev)
{
struct eth_pdata *pdata = dev_get_platdata(dev);
- struct dw_eth_dev *priv = dev_get_priv(dev);
+ struct dw_eth_dev *priv = dev_get_priv(dev, struct dw_eth_dev);
return _dw_write_hwaddr(priv, pdata->enetaddr);
}
@@ -555,7 +555,7 @@ static int designware_eth_write_hwaddr(struct udevice *dev)
static int designware_eth_probe(struct udevice *dev)
{
struct eth_pdata *pdata = dev_get_platdata(dev);
- struct dw_eth_dev *priv = dev_get_priv(dev);
+ struct dw_eth_dev *priv = dev_get_priv(dev, struct dw_eth_dev);
int ret;
debug("%s, iobase=%lx, priv=%p\n", __func__, pdata->iobase, priv);
@@ -612,7 +612,7 @@ U_BOOT_DRIVER(eth_sandbox) = {
.ofdata_to_platdata = designware_eth_ofdata_to_platdata,
.probe = designware_eth_probe,
.ops = &designware_eth_ops,
- .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
+ .priv_alloc = dm_alloc(struct dw_eth_dev),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
@@ -20,7 +20,7 @@ static struct in_addr arp_ip;
static int sb_eth_raw_start(struct udevice *dev)
{
- struct eth_sandbox_raw_priv *priv = dev_get_priv(dev);
+ struct eth_sandbox_raw_priv *priv = dev_get_priv(dev, struct eth_sandbox_raw_priv);
struct eth_pdata *pdata = dev_get_platdata(dev);
const char *interface;
@@ -41,7 +41,7 @@ static int sb_eth_raw_start(struct udevice *dev)
static int sb_eth_raw_send(struct udevice *dev, void *packet, int length)
{
- struct eth_sandbox_raw_priv *priv = dev_get_priv(dev);
+ struct eth_sandbox_raw_priv *priv = dev_get_priv(dev, struct eth_sandbox_raw_priv);
debug("eth_sandbox_raw: Send packet %d\n", length);
@@ -68,7 +68,7 @@ static int sb_eth_raw_send(struct udevice *dev, void *packet, int length)
static int sb_eth_raw_recv(struct udevice *dev, uchar **packetp)
{
struct eth_pdata *pdata = dev_get_platdata(dev);
- struct eth_sandbox_raw_priv *priv = dev_get_priv(dev);
+ struct eth_sandbox_raw_priv *priv = dev_get_priv(dev, struct eth_sandbox_raw_priv);
int retval = 0;
int length;
@@ -127,7 +127,7 @@ static int sb_eth_raw_recv(struct udevice *dev, uchar **packetp)
static void sb_eth_raw_stop(struct udevice *dev)
{
- struct eth_sandbox_raw_priv *priv = dev_get_priv(dev);
+ struct eth_sandbox_raw_priv *priv = dev_get_priv(dev, struct eth_sandbox_raw_priv);
debug("eth_sandbox_raw: Stop\n");
@@ -160,6 +160,6 @@ U_BOOT_DRIVER(eth_sandbox_raw) = {
.of_match = sb_eth_raw_ids,
.ofdata_to_platdata = sb_eth_raw_ofdata_to_platdata,
.ops = &sb_eth_raw_ops,
- .priv_auto_alloc_size = sizeof(struct eth_sandbox_raw_priv),
+ .priv_alloc = dm_alloc(struct eth_sandbox_raw_priv),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
};
@@ -56,7 +56,7 @@ void sandbox_eth_skip_timeout(void)
static int sb_eth_start(struct udevice *dev)
{
- struct eth_sandbox_priv *priv = dev_get_priv(dev);
+ struct eth_sandbox_priv *priv = dev_get_priv(dev, struct eth_sandbox_priv);
debug("eth_sandbox: Start\n");
@@ -68,7 +68,7 @@ static int sb_eth_start(struct udevice *dev)
static int sb_eth_send(struct udevice *dev, void *packet, int length)
{
- struct eth_sandbox_priv *priv = dev_get_priv(dev);
+ struct eth_sandbox_priv *priv = dev_get_priv(dev, struct eth_sandbox_priv);
struct ethernet_hdr *eth = packet;
debug("eth_sandbox: Send packet %d\n", length);
@@ -154,7 +154,7 @@ static int sb_eth_send(struct udevice *dev, void *packet, int length)
static int sb_eth_recv(struct udevice *dev, uchar **packetp)
{
- struct eth_sandbox_priv *priv = dev_get_priv(dev);
+ struct eth_sandbox_priv *priv = dev_get_priv(dev, struct eth_sandbox_priv);
if (skip_timeout) {
sandbox_timer_add_offset(10000UL);
@@ -220,6 +220,6 @@ U_BOOT_DRIVER(eth_sandbox) = {
.ofdata_to_platdata = sb_eth_ofdata_to_platdata,
.remove = sb_eth_remove,
.ops = &sb_eth_ops,
- .priv_auto_alloc_size = sizeof(struct eth_sandbox_priv),
+ .priv_alloc = dm_alloc(struct eth_sandbox_priv),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
};
@@ -522,14 +522,14 @@ static int sunxi_emac_eth_start(struct udevice *dev)
static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)
{
- struct emac_eth_dev *priv = dev_get_priv(dev);
+ struct emac_eth_dev *priv = dev_get_priv(dev, struct emac_eth_dev);
return _sunxi_emac_eth_send(priv, packet, length);
}
static int sunxi_emac_eth_recv(struct udevice *dev, uchar **packetp)
{
- struct emac_eth_dev *priv = dev_get_priv(dev);
+ struct emac_eth_dev *priv = dev_get_priv(dev, struct emac_eth_dev);
int rx_len;
rx_len = _sunxi_emac_eth_recv(priv, priv->rx_buf);
@@ -546,7 +546,7 @@ static void sunxi_emac_eth_stop(struct udevice *dev)
static int sunxi_emac_eth_probe(struct udevice *dev)
{
struct eth_pdata *pdata = dev_get_platdata(dev);
- struct emac_eth_dev *priv = dev_get_priv(dev);
+ struct emac_eth_dev *priv = dev_get_priv(dev, struct emac_eth_dev);
priv->regs = (struct emac_regs *)pdata->iobase;
sunxi_emac_board_setup(priv);
@@ -582,6 +582,6 @@ U_BOOT_DRIVER(eth_sunxi_emac) = {
.ofdata_to_platdata = sunxi_emac_eth_ofdata_to_platdata,
.probe = sunxi_emac_eth_probe,
.ops = &sunxi_emac_eth_ops,
- .priv_auto_alloc_size = sizeof(struct emac_eth_dev),
+ .priv_alloc = dm_alloc(struct emac_eth_dev),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
};
@@ -63,5 +63,5 @@ UCLASS_DRIVER(pci_emul) = {
.name = "pci_emul",
.post_probe = sandbox_pci_emul_post_probe,
.pre_remove = sandbox_pci_emul_pre_remove,
- .priv_auto_alloc_size = sizeof(struct sandbox_pci_priv),
+ .priv_alloc = dm_alloc(struct sandbox_pci_priv),
};
@@ -314,7 +314,7 @@ static void pinctrl_rk3288_hdmi_config(struct rk3288_grf *grf, int hdmi_id)
static int rk3288_pinctrl_request(struct udevice *dev, int func, int flags)
{
- struct rk3288_pinctrl_priv *priv = dev_get_priv(dev);
+ struct rk3288_pinctrl_priv *priv = dev_get_priv(dev, struct rk3288_pinctrl_priv);
debug("%s: func=%x, flags=%x\n", __func__, func, flags);
switch (func) {
@@ -405,7 +405,7 @@ static struct pinctrl_ops rk3288_pinctrl_ops = {
static int rk3288_pinctrl_probe(struct udevice *dev)
{
- struct rk3288_pinctrl_priv *priv = dev_get_priv(dev);
+ struct rk3288_pinctrl_priv *priv = dev_get_priv(dev, struct rk3288_pinctrl_priv);
priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
priv->pmu = syscon_get_first_range(ROCKCHIP_SYSCON_PMU);
@@ -423,7 +423,7 @@ U_BOOT_DRIVER(pinctrl_rk3288) = {
.name = "pinctrl_rk3288",
.id = UCLASS_PINCTRL,
.of_match = rk3288_pinctrl_ids,
- .priv_auto_alloc_size = sizeof(struct rk3288_pinctrl_priv),
+ .priv_alloc = dm_alloc(struct rk3288_pinctrl_priv),
.ops = &rk3288_pinctrl_ops,
.probe = rk3288_pinctrl_probe,
};
@@ -230,7 +230,7 @@ U_BOOT_DRIVER(sandbox_i2c_rtc_emul) = {
.id = UCLASS_I2C_EMUL,
.of_match = sandbox_i2c_rtc_ids,
.bind = sandbox_i2c_rtc_bind,
- .priv_auto_alloc_size = sizeof(struct sandbox_i2c_rtc),
+ .priv_alloc = dm_alloc(struct sandbox_i2c_rtc),
.platdata_auto_alloc_size = sizeof(struct sandbox_i2c_rtc_plat_data),
.ops = &sandbox_i2c_rtc_emul_ops,
};
@@ -139,7 +139,7 @@ struct atmel_serial_priv {
int atmel_serial_setbrg(struct udevice *dev, int baudrate)
{
- struct atmel_serial_priv *priv = dev_get_priv(dev);
+ struct atmel_serial_priv *priv = dev_get_priv(dev, struct atmel_serial_priv);
atmel_serial_setbrg_internal(priv->usart, 0 /* ignored */, baudrate);
atmel_serial_activate(priv->usart);
@@ -149,7 +149,7 @@ int atmel_serial_setbrg(struct udevice *dev, int baudrate)
static int atmel_serial_getc(struct udevice *dev)
{
- struct atmel_serial_priv *priv = dev_get_priv(dev);
+ struct atmel_serial_priv *priv = dev_get_priv(dev, struct atmel_serial_priv);
if (!(readl(&priv->usart->csr) & USART3_BIT(RXRDY)))
return -EAGAIN;
@@ -159,7 +159,7 @@ static int atmel_serial_getc(struct udevice *dev)
static int atmel_serial_putc(struct udevice *dev, const char ch)
{
- struct atmel_serial_priv *priv = dev_get_priv(dev);
+ struct atmel_serial_priv *priv = dev_get_priv(dev, struct atmel_serial_priv);
if (!(readl(&priv->usart->csr) & USART3_BIT(TXRDY)))
return -EAGAIN;
@@ -171,7 +171,7 @@ static int atmel_serial_putc(struct udevice *dev, const char ch)
static int atmel_serial_pending(struct udevice *dev, bool input)
{
- struct atmel_serial_priv *priv = dev_get_priv(dev);
+ struct atmel_serial_priv *priv = dev_get_priv(dev, struct atmel_serial_priv);
uint32_t csr = readl(&priv->usart->csr);
if (input)
@@ -190,7 +190,7 @@ static const struct dm_serial_ops atmel_serial_ops = {
static int atmel_serial_probe(struct udevice *dev)
{
struct atmel_serial_platdata *plat = dev->platdata;
- struct atmel_serial_priv *priv = dev_get_priv(dev);
+ struct atmel_serial_priv *priv = dev_get_priv(dev, struct atmel_serial_priv);
priv->usart = (atmel_usart3_t *)plat->base_addr;
atmel_serial_init_internal(priv->usart);
@@ -204,6 +204,6 @@ U_BOOT_DRIVER(serial_atmel) = {
.probe = atmel_serial_probe,
.ops = &atmel_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
- .priv_auto_alloc_size = sizeof(struct atmel_serial_priv),
+ .priv_alloc = dm_alloc(struct atmel_serial_priv),
};
#endif
@@ -63,7 +63,7 @@ static void output_ansi_reset(void)
static int sandbox_serial_probe(struct udevice *dev)
{
struct sandbox_state *state = state_get_current();
- struct sandbox_serial_priv *priv = dev_get_priv(dev);
+ struct sandbox_serial_priv *priv = dev_get_priv(dev, struct sandbox_serial_priv);
if (state->term_raw != STATE_TERM_COOKED)
os_tty_raw(0, state->term_raw == STATE_TERM_RAW_WITH_SIGS);
@@ -84,7 +84,7 @@ static int sandbox_serial_remove(struct udevice *dev)
static int sandbox_serial_putc(struct udevice *dev, const char ch)
{
- struct sandbox_serial_priv *priv = dev_get_priv(dev);
+ struct sandbox_serial_priv *priv = dev_get_priv(dev, struct sandbox_serial_priv);
struct sandbox_serial_platdata *plat = dev->platdata;
if (priv->start_of_line && plat->colour != -1) {
@@ -182,7 +182,7 @@ U_BOOT_DRIVER(serial_sandbox) = {
.of_match = sandbox_serial_ids,
.ofdata_to_platdata = sandbox_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct sandbox_serial_platdata),
- .priv_auto_alloc_size = sizeof(struct sandbox_serial_priv),
+ .priv_alloc = dm_alloc(struct sandbox_serial_priv),
.probe = sandbox_serial_probe,
.remove = sandbox_serial_remove,
.ops = &sandbox_serial_ops,
@@ -33,7 +33,7 @@ U_BOOT_DRIVER(serial_ns16550) = {
.of_match = dw_serial_ids,
.ofdata_to_platdata = dw_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
- .priv_auto_alloc_size = sizeof(struct NS16550),
+ .priv_alloc = dm_alloc(struct NS16550),
.probe = ns16550_serial_probe,
.ops = &ns16550_serial_ops,
};
@@ -40,7 +40,7 @@ U_BOOT_DRIVER(serial_omap_ns16550) = {
.of_match = of_match_ptr(omap_serial_ids),
.ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
- .priv_auto_alloc_size = sizeof(struct NS16550),
+ .priv_alloc = dm_alloc(struct NS16550),
.probe = ns16550_serial_probe,
.ops = &ns16550_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
@@ -304,7 +304,7 @@ struct pl01x_priv {
static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
{
struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
- struct pl01x_priv *priv = dev_get_priv(dev);
+ struct pl01x_priv *priv = dev_get_priv(dev, struct pl01x_priv);
pl01x_generic_setbrg(priv->regs, priv->type, plat->clock, baudrate);
@@ -314,7 +314,7 @@ static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
static int pl01x_serial_probe(struct udevice *dev)
{
struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
- struct pl01x_priv *priv = dev_get_priv(dev);
+ struct pl01x_priv *priv = dev_get_priv(dev, struct pl01x_priv);
priv->regs = (struct pl01x_regs *)plat->base;
priv->type = plat->type;
@@ -323,21 +323,21 @@ static int pl01x_serial_probe(struct udevice *dev)
static int pl01x_serial_getc(struct udevice *dev)
{
- struct pl01x_priv *priv = dev_get_priv(dev);
+ struct pl01x_priv *priv = dev_get_priv(dev, struct pl01x_priv);
return pl01x_getc(priv->regs);
}
static int pl01x_serial_putc(struct udevice *dev, const char ch)
{
- struct pl01x_priv *priv = dev_get_priv(dev);
+ struct pl01x_priv *priv = dev_get_priv(dev, struct pl01x_priv);
return pl01x_putc(priv->regs, ch);
}
static int pl01x_serial_pending(struct udevice *dev, bool input)
{
- struct pl01x_priv *priv = dev_get_priv(dev);
+ struct pl01x_priv *priv = dev_get_priv(dev, struct pl01x_priv);
unsigned int fr = readl(&priv->regs->fr);
if (input)
@@ -385,7 +385,7 @@ U_BOOT_DRIVER(serial_pl01x) = {
.probe = pl01x_serial_probe,
.ops = &pl01x_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
- .priv_auto_alloc_size = sizeof(struct pl01x_priv),
+ .priv_alloc = dm_alloc(struct pl01x_priv),
};
#endif
@@ -33,7 +33,7 @@ U_BOOT_DRIVER(serial_ns16550) = {
.of_match = ppc_serial_ids,
.ofdata_to_platdata = ppc_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
- .priv_auto_alloc_size = sizeof(struct NS16550),
+ .priv_alloc = dm_alloc(struct NS16550),
.probe = ns16550_serial_probe,
.ops = &ns16550_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
@@ -36,7 +36,7 @@ U_BOOT_DRIVER(serial_ns16550) = {
.of_match = rockchip_serial_ids,
.ofdata_to_platdata = rockchip_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
- .priv_auto_alloc_size = sizeof(struct NS16550),
+ .priv_alloc = dm_alloc(struct NS16550),
.probe = ns16550_serial_probe,
.ops = &ns16550_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
@@ -150,21 +150,21 @@ static int sh_serial_getc_generic(struct uart_port *port)
static int sh_serial_pending(struct udevice *dev, bool input)
{
- struct uart_port *priv = dev_get_priv(dev);
+ struct uart_port *priv = dev_get_priv(dev, struct uart_port);
return sh_serial_tstc_generic(priv);
}
static int sh_serial_putc(struct udevice *dev, const char ch)
{
- struct uart_port *priv = dev_get_priv(dev);
+ struct uart_port *priv = dev_get_priv(dev, struct uart_port);
return serial_raw_putc(priv, ch);
}
static int sh_serial_getc(struct udevice *dev)
{
- struct uart_port *priv = dev_get_priv(dev);
+ struct uart_port *priv = dev_get_priv(dev, struct uart_port);
return sh_serial_getc_generic(priv);
}
@@ -172,7 +172,7 @@ static int sh_serial_getc(struct udevice *dev)
static int sh_serial_setbrg(struct udevice *dev, int baudrate)
{
struct sh_serial_platdata *plat = dev_get_platdata(dev);
- struct uart_port *priv = dev_get_priv(dev);
+ struct uart_port *priv = dev_get_priv(dev, struct uart_port);
sh_serial_setbrg_generic(priv, plat->clk, baudrate);
@@ -182,7 +182,7 @@ static int sh_serial_setbrg(struct udevice *dev, int baudrate)
static int sh_serial_probe(struct udevice *dev)
{
struct sh_serial_platdata *plat = dev_get_platdata(dev);
- struct uart_port *priv = dev_get_priv(dev);
+ struct uart_port *priv = dev_get_priv(dev, struct uart_port);
priv->membase = (unsigned char *)plat->base;
priv->mapbase = plat->base;
@@ -207,7 +207,7 @@ U_BOOT_DRIVER(serial_sh) = {
.probe = sh_serial_probe,
.ops = &sh_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
- .priv_auto_alloc_size = sizeof(struct uart_port),
+ .priv_alloc = dm_alloc(struct uart_port),
};
#else /* CONFIG_DM_SERIAL */
@@ -47,7 +47,7 @@ U_BOOT_DRIVER(serial_ns16550) = {
.ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
#endif
- .priv_auto_alloc_size = sizeof(struct NS16550),
+ .priv_alloc = dm_alloc(struct NS16550),
.probe = ns16550_serial_probe,
.ops = &ns16550_serial_ops,
.flags = DM_FLAG_PRE_RELOC,
@@ -88,7 +88,7 @@ static int uniphier_serial_pending(struct udevice *dev, bool input)
static int uniphier_serial_probe(struct udevice *dev)
{
u32 tmp;
- struct uniphier_serial_private_data *priv = dev_get_priv(dev);
+ struct uniphier_serial_private_data *priv = dev_get_priv(dev, struct uniphier_serial_private_data);
struct uniphier_serial_platform_data *plat = dev_get_platdata(dev);
struct uniphier_serial __iomem *port;
@@ -146,7 +146,7 @@ U_BOOT_DRIVER(uniphier_serial) = {
.ofdata_to_platdata = of_match_ptr(uniphier_serial_ofdata_to_platdata),
.probe = uniphier_serial_probe,
.remove = uniphier_serial_remove,
- .priv_auto_alloc_size = sizeof(struct uniphier_serial_private_data),
+ .priv_alloc = dm_alloc(struct uniphier_serial_private_data),
.platdata_auto_alloc_size =
sizeof(struct uniphier_serial_platform_data),
.ops = &uniphier_serial_ops,
@@ -38,7 +38,7 @@ U_BOOT_DRIVER(serial_ns16550) = {
.of_match = x86_serial_ids,
.ofdata_to_platdata = x86_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
- .priv_auto_alloc_size = sizeof(struct NS16550),
+ .priv_alloc = dm_alloc(struct NS16550),
.probe = ns16550_serial_probe,
.ops = &ns16550_serial_ops,
};
@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int cadence_spi_write_speed(struct udevice *bus, uint hz)
{
struct cadence_spi_platdata *plat = bus->platdata;
- struct cadence_spi_priv *priv = dev_get_priv(bus);
+ struct cadence_spi_priv *priv = dev_get_priv(bus, struct cadence_spi_priv);
cadence_qspi_apb_config_baudrate_div(priv->regbase,
CONFIG_CQSPI_REF_CLK, hz);
@@ -40,7 +40,7 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)
static int spi_calibration(struct udevice *bus)
{
struct cadence_spi_platdata *plat = bus->platdata;
- struct cadence_spi_priv *priv = dev_get_priv(bus);
+ struct cadence_spi_priv *priv = dev_get_priv(bus, struct cadence_spi_priv);
void *base = priv->regbase;
u8 opcode_rdid = 0x9F;
unsigned int idcode = 0, temp = 0;
@@ -120,7 +120,7 @@ static int spi_calibration(struct udevice *bus)
static int cadence_spi_set_speed(struct udevice *bus, uint hz)
{
struct cadence_spi_platdata *plat = bus->platdata;
- struct cadence_spi_priv *priv = dev_get_priv(bus);
+ struct cadence_spi_priv *priv = dev_get_priv(bus, struct cadence_spi_priv);
int err;
/* Disable QSPI */
@@ -147,7 +147,7 @@ static int cadence_spi_set_speed(struct udevice *bus, uint hz)
static int cadence_spi_probe(struct udevice *bus)
{
struct cadence_spi_platdata *plat = bus->platdata;
- struct cadence_spi_priv *priv = dev_get_priv(bus);
+ struct cadence_spi_priv *priv = dev_get_priv(bus, struct cadence_spi_priv);
priv->regbase = plat->regbase;
priv->ahbbase = plat->ahbbase;
@@ -162,7 +162,7 @@ static int cadence_spi_probe(struct udevice *bus)
static int cadence_spi_set_mode(struct udevice *bus, uint mode)
{
- struct cadence_spi_priv *priv = dev_get_priv(bus);
+ struct cadence_spi_priv *priv = dev_get_priv(bus, struct cadence_spi_priv);
unsigned int clk_pol = (mode & SPI_CPOL) ? 1 : 0;
unsigned int clk_pha = (mode & SPI_CPHA) ? 1 : 0;
@@ -183,7 +183,7 @@ static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen,
{
struct udevice *bus = dev->parent;
struct cadence_spi_platdata *plat = bus->platdata;
- struct cadence_spi_priv *priv = dev_get_priv(bus);
+ struct cadence_spi_priv *priv = dev_get_priv(bus, struct cadence_spi_priv);
void *base = priv->regbase;
u8 *cmd_buf = priv->cmd_buf;
size_t data_bytes;
@@ -339,6 +339,6 @@ U_BOOT_DRIVER(cadence_spi) = {
.ops = &cadence_spi_ops,
.ofdata_to_platdata = cadence_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct cadence_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct cadence_spi_priv),
+ .priv_alloc = dm_alloc(struct cadence_spi_priv),
.probe = cadence_spi_probe,
};
@@ -179,7 +179,7 @@ static void spi_hw_init(struct dw_spi_priv *priv)
static int dw_spi_probe(struct udevice *bus)
{
struct dw_spi_platdata *plat = dev_get_platdata(bus);
- struct dw_spi_priv *priv = dev_get_priv(bus);
+ struct dw_spi_priv *priv = dev_get_priv(bus, struct dw_spi_priv);
priv->regs = plat->regs;
priv->freq = plat->frequency;
@@ -296,7 +296,7 @@ static int dw_spi_xfer(struct udevice *dev, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
{
struct udevice *bus = dev->parent;
- struct dw_spi_priv *priv = dev_get_priv(bus);
+ struct dw_spi_priv *priv = dev_get_priv(bus, struct dw_spi_priv);
const u8 *tx = dout;
u8 *rx = din;
int ret = 0;
@@ -359,7 +359,7 @@ static int dw_spi_xfer(struct udevice *dev, unsigned int bitlen,
static int dw_spi_set_speed(struct udevice *bus, uint speed)
{
struct dw_spi_platdata *plat = bus->platdata;
- struct dw_spi_priv *priv = dev_get_priv(bus);
+ struct dw_spi_priv *priv = dev_get_priv(bus, struct dw_spi_priv);
u16 clk_div;
if (speed > plat->frequency)
@@ -385,7 +385,7 @@ static int dw_spi_set_speed(struct udevice *bus, uint speed)
static int dw_spi_set_mode(struct udevice *bus, uint mode)
{
- struct dw_spi_priv *priv = dev_get_priv(bus);
+ struct dw_spi_priv *priv = dev_get_priv(bus, struct dw_spi_priv);
/*
* Can't set mode yet. Since this depends on if rx, tx, or
@@ -420,6 +420,6 @@ U_BOOT_DRIVER(dw_spi) = {
.ops = &dw_spi_ops,
.ofdata_to_platdata = dw_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct dw_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct dw_spi_priv),
+ .priv_alloc = dm_alloc(struct dw_spi_priv),
.probe = dw_spi_probe,
};
@@ -212,7 +212,7 @@ static void spi_cs_activate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct exynos_spi_platdata *pdata = dev_get_platdata(bus);
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
/* If it's too soon to do another transaction, wait */
if (pdata->deactivate_delay_us &&
@@ -238,7 +238,7 @@ static void spi_cs_deactivate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct exynos_spi_platdata *pdata = dev_get_platdata(bus);
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
setbits_le32(&priv->regs->cs_reg, SPI_SLAVE_SIG_INACT);
@@ -279,7 +279,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
static int exynos_spi_probe(struct udevice *bus)
{
struct exynos_spi_platdata *plat = dev_get_platdata(bus);
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
priv->regs = plat->regs;
if (plat->periph_id == PERIPH_ID_SPI1 ||
@@ -299,7 +299,7 @@ static int exynos_spi_probe(struct udevice *bus)
static int exynos_spi_claim_bus(struct udevice *dev)
{
struct udevice *bus = dev->parent;
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
exynos_pinmux_config(priv->periph_id, PINMUX_FLAG_NONE);
spi_flush_fifo(priv->regs);
@@ -312,7 +312,7 @@ static int exynos_spi_claim_bus(struct udevice *dev)
static int exynos_spi_release_bus(struct udevice *dev)
{
struct udevice *bus = dev->parent;
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
spi_flush_fifo(priv->regs);
@@ -323,7 +323,7 @@ static int exynos_spi_xfer(struct udevice *dev, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
{
struct udevice *bus = dev->parent;
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
int upto, todo;
int bytelen;
int ret = 0;
@@ -367,7 +367,7 @@ static int exynos_spi_xfer(struct udevice *dev, unsigned int bitlen,
static int exynos_spi_set_speed(struct udevice *bus, uint speed)
{
struct exynos_spi_platdata *plat = bus->platdata;
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
int ret;
if (speed > plat->frequency)
@@ -383,7 +383,7 @@ static int exynos_spi_set_speed(struct udevice *bus, uint speed)
static int exynos_spi_set_mode(struct udevice *bus, uint mode)
{
- struct exynos_spi_priv *priv = dev_get_priv(bus);
+ struct exynos_spi_priv *priv = dev_get_priv(bus, struct exynos_spi_priv);
uint32_t reg;
reg = readl(&priv->regs->ch_cfg);
@@ -426,6 +426,6 @@ U_BOOT_DRIVER(exynos_spi) = {
.ops = &exynos_spi_ops,
.ofdata_to_platdata = exynos_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct exynos_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct exynos_spi_priv),
+ .priv_alloc = dm_alloc(struct exynos_spi_priv),
.probe = exynos_spi_probe,
};
@@ -531,7 +531,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
static int fsl_dspi_child_pre_probe(struct udevice *dev)
{
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
- struct fsl_dspi_priv *priv = dev_get_priv(dev->parent);
+ struct fsl_dspi_priv *priv = dev_get_priv(dev->parent, struct fsl_dspi_priv);
if (slave_plat->cs >= priv->num_chipselect) {
debug("DSPI invalid chipselect number %d(max %d)!\n",
@@ -550,7 +550,7 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev)
static int fsl_dspi_probe(struct udevice *bus)
{
struct fsl_dspi_platdata *plat = dev_get_platdata(bus);
- struct fsl_dspi_priv *priv = dev_get_priv(bus);
+ struct fsl_dspi_priv *priv = dev_get_priv(bus, struct fsl_dspi_priv);
struct dm_spi_bus *dm_spi_bus;
uint mcr_cfg_val;
@@ -619,7 +619,7 @@ static int fsl_dspi_claim_bus(struct udevice *dev)
static int fsl_dspi_release_bus(struct udevice *dev)
{
struct udevice *bus = dev->parent;
- struct fsl_dspi_priv *priv = dev_get_priv(bus);
+ struct fsl_dspi_priv *priv = dev_get_priv(bus, struct fsl_dspi_priv);
struct dm_spi_slave_platdata *slave_plat =
dev_get_parent_platdata(dev);
@@ -687,14 +687,14 @@ static int fsl_dspi_xfer(struct udevice *dev, unsigned int bitlen,
static int fsl_dspi_set_speed(struct udevice *bus, uint speed)
{
- struct fsl_dspi_priv *priv = dev_get_priv(bus);
+ struct fsl_dspi_priv *priv = dev_get_priv(bus, struct fsl_dspi_priv);
return fsl_dspi_cfg_speed(priv, speed);
}
static int fsl_dspi_set_mode(struct udevice *bus, uint mode)
{
- struct fsl_dspi_priv *priv = dev_get_priv(bus);
+ struct fsl_dspi_priv *priv = dev_get_priv(bus, struct fsl_dspi_priv);
debug("DSPI set_mode: mode 0x%x.\n", mode);
@@ -729,7 +729,7 @@ U_BOOT_DRIVER(fsl_dspi) = {
.ops = &fsl_dspi_ops,
.ofdata_to_platdata = fsl_dspi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct fsl_dspi_platdata),
- .priv_auto_alloc_size = sizeof(struct fsl_dspi_priv),
+ .priv_alloc = dm_alloc(struct fsl_dspi_priv),
.probe = fsl_dspi_probe,
.child_pre_probe = fsl_dspi_child_pre_probe,
.bind = fsl_dspi_bind,
@@ -924,7 +924,7 @@ static int fsl_qspi_probe(struct udevice *bus)
{
u32 total_size;
struct fsl_qspi_platdata *plat = dev_get_platdata(bus);
- struct fsl_qspi_priv *priv = dev_get_priv(bus);
+ struct fsl_qspi_priv *priv = dev_get_priv(bus, struct fsl_qspi_priv);
struct dm_spi_bus *dm_spi_bus;
dm_spi_bus = bus->uclass_priv;
@@ -1104,7 +1104,7 @@ U_BOOT_DRIVER(fsl_qspi) = {
.ops = &fsl_qspi_ops,
.ofdata_to_platdata = fsl_qspi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct fsl_qspi_platdata),
- .priv_auto_alloc_size = sizeof(struct fsl_qspi_priv),
+ .priv_alloc = dm_alloc(struct fsl_qspi_priv),
.probe = fsl_qspi_probe,
.child_pre_probe = fsl_qspi_child_pre_probe,
};
@@ -411,7 +411,7 @@ static int ich_spi_xfer(struct udevice *dev, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
{
struct udevice *bus = dev_get_parent(dev);
- struct ich_spi_priv *ctlr = dev_get_priv(bus);
+ struct ich_spi_priv *ctlr = dev_get_priv(bus, struct ich_spi_priv);
uint16_t control;
int16_t opcode_index;
int with_address;
@@ -629,7 +629,7 @@ int spi_write_protect_region(struct udevice *dev, uint32_t lower_limit,
uint32_t length, int hint)
{
struct udevice *bus = dev->parent;
- struct ich_spi_priv *ctlr = dev_get_priv(bus);
+ struct ich_spi_priv *ctlr = dev_get_priv(bus, struct ich_spi_priv);
uint32_t tmplong;
uint32_t upper_limit;
@@ -672,7 +672,7 @@ int spi_write_protect_region(struct udevice *dev, uint32_t lower_limit,
static int ich_spi_probe(struct udevice *bus)
{
struct ich_spi_platdata *plat = dev_get_platdata(bus);
- struct ich_spi_priv *priv = dev_get_priv(bus);
+ struct ich_spi_priv *priv = dev_get_priv(bus, struct ich_spi_priv);
uint8_t bios_cntl;
int ret;
@@ -717,7 +717,7 @@ static int ich_spi_ofdata_to_platdata(struct udevice *bus)
static int ich_spi_set_speed(struct udevice *bus, uint speed)
{
- struct ich_spi_priv *priv = dev_get_priv(bus);
+ struct ich_spi_priv *priv = dev_get_priv(bus, struct ich_spi_priv);
priv->cur_speed = speed;
@@ -735,7 +735,7 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
{
struct udevice *bus = dev_get_parent(dev);
struct ich_spi_platdata *plat = dev_get_platdata(bus);
- struct ich_spi_priv *priv = dev_get_priv(bus);
+ struct ich_spi_priv *priv = dev_get_priv(bus, struct ich_spi_priv);
struct spi_slave *slave = dev_get_parentdata(dev);
/*
@@ -777,7 +777,7 @@ U_BOOT_DRIVER(ich_spi) = {
.ops = &ich_spi_ops,
.ofdata_to_platdata = ich_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ich_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct ich_spi_priv),
+ .priv_alloc = dm_alloc(struct ich_spi_priv),
.child_pre_probe = ich_spi_child_pre_probe,
.probe = ich_spi_probe,
};
@@ -146,7 +146,7 @@ static int rockchip_spi_ofdata_to_platdata(struct udevice *bus)
static int rockchip_spi_probe(struct udevice *bus)
{
struct rockchip_spi_platdata *plat = dev_get_platdata(bus);
- struct rockchip_spi_priv *priv = dev_get_priv(bus);
+ struct rockchip_spi_priv *priv = dev_get_priv(bus, struct rockchip_spi_priv);
int ret;
debug("%s: probe\n", __func__);
@@ -182,7 +182,7 @@ static int rockchip_spi_claim_bus(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct rockchip_spi_platdata *plat = dev_get_platdata(bus);
- struct rockchip_spi_priv *priv = dev_get_priv(bus);
+ struct rockchip_spi_priv *priv = dev_get_priv(bus, struct rockchip_spi_priv);
struct rockchip_spi *regs = priv->regs;
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
u8 spi_dfs, spi_tf;
@@ -267,7 +267,7 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
{
struct udevice *bus = dev->parent;
- struct rockchip_spi_priv *priv = dev_get_priv(bus);
+ struct rockchip_spi_priv *priv = dev_get_priv(bus, struct rockchip_spi_priv);
struct rockchip_spi *regs = priv->regs;
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
int len = bitlen >> 3;
@@ -326,7 +326,7 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen,
static int rockchip_spi_set_speed(struct udevice *bus, uint speed)
{
- struct rockchip_spi_priv *priv = dev_get_priv(bus);
+ struct rockchip_spi_priv *priv = dev_get_priv(bus, struct rockchip_spi_priv);
if (speed > 48000000)
return -EINVAL;
@@ -339,7 +339,7 @@ static int rockchip_spi_set_speed(struct udevice *bus, uint speed)
static int rockchip_spi_set_mode(struct udevice *bus, uint mode)
{
- struct rockchip_spi_priv *priv = dev_get_priv(bus);
+ struct rockchip_spi_priv *priv = dev_get_priv(bus, struct rockchip_spi_priv);
priv->mode = mode;
@@ -370,6 +370,6 @@ U_BOOT_DRIVER(rockchip_spi) = {
.ops = &rockchip_spi_ops,
.ofdata_to_platdata = rockchip_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct rockchip_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct rockchip_spi_priv),
+ .priv_alloc = dm_alloc(struct rockchip_spi_priv),
.probe = rockchip_spi_probe,
};
@@ -100,7 +100,7 @@ static int soft_spi_release_bus(struct udevice *dev)
static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
{
- struct soft_spi_priv *priv = dev_get_priv(dev);
+ struct soft_spi_priv *priv = dev_get_priv(dev, struct soft_spi_priv);
struct soft_spi_platdata *plat = dev->platdata;
uchar tmpdin = 0;
uchar tmpdout = 0;
@@ -172,7 +172,7 @@ static int soft_spi_set_speed(struct udevice *dev, unsigned int speed)
static int soft_spi_set_mode(struct udevice *dev, unsigned int mode)
{
- struct soft_spi_priv *priv = dev_get_priv(dev);
+ struct soft_spi_priv *priv = dev_get_priv(dev, struct soft_spi_priv);
priv->mode = mode;
@@ -231,6 +231,6 @@ U_BOOT_DRIVER(soft_spi) = {
.ops = &soft_spi_ops,
.ofdata_to_platdata = soft_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct soft_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct soft_spi_priv),
+ .priv_alloc = dm_alloc(struct soft_spi_priv),
.probe = soft_spi_probe,
};
@@ -142,7 +142,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus)
static int tegra114_spi_probe(struct udevice *bus)
{
struct tegra_spi_platdata *plat = dev_get_platdata(bus);
- struct tegra114_spi_priv *priv = dev_get_priv(bus);
+ struct tegra114_spi_priv *priv = dev_get_priv(bus, struct tegra114_spi_priv);
struct spi_regs *regs;
ulong rate;
@@ -198,7 +198,7 @@ static void spi_cs_activate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
- struct tegra114_spi_priv *priv = dev_get_priv(bus);
+ struct tegra114_spi_priv *priv = dev_get_priv(bus, struct tegra114_spi_priv);
/* If it's too soon to do another transaction, wait */
if (pdata->deactivate_delay_us &&
@@ -222,7 +222,7 @@ static void spi_cs_deactivate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
- struct tegra114_spi_priv *priv = dev_get_priv(bus);
+ struct tegra114_spi_priv *priv = dev_get_priv(bus, struct tegra114_spi_priv);
setbits_le32(&priv->regs->command1, SPI_CMD1_CS_SW_VAL);
@@ -238,7 +238,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen,
unsigned long flags)
{
struct udevice *bus = dev->parent;
- struct tegra114_spi_priv *priv = dev_get_priv(bus);
+ struct tegra114_spi_priv *priv = dev_get_priv(bus, struct tegra114_spi_priv);
struct spi_regs *regs = priv->regs;
u32 reg, tmpdout, tmpdin = 0;
const u8 *dout = data_out;
@@ -369,7 +369,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen,
static int tegra114_spi_set_speed(struct udevice *bus, uint speed)
{
struct tegra_spi_platdata *plat = bus->platdata;
- struct tegra114_spi_priv *priv = dev_get_priv(bus);
+ struct tegra114_spi_priv *priv = dev_get_priv(bus, struct tegra114_spi_priv);
if (speed > plat->frequency)
speed = plat->frequency;
@@ -381,7 +381,7 @@ static int tegra114_spi_set_speed(struct udevice *bus, uint speed)
static int tegra114_spi_set_mode(struct udevice *bus, uint mode)
{
- struct tegra114_spi_priv *priv = dev_get_priv(bus);
+ struct tegra114_spi_priv *priv = dev_get_priv(bus, struct tegra114_spi_priv);
priv->mode = mode;
debug("%s: regs=%p, mode=%d\n", __func__, priv->regs, priv->mode);
@@ -411,6 +411,6 @@ U_BOOT_DRIVER(tegra114_spi) = {
.ops = &tegra114_spi_ops,
.ofdata_to_platdata = tegra114_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct tegra114_spi_priv),
+ .priv_alloc = dm_alloc(struct tegra114_spi_priv),
.probe = tegra114_spi_probe,
};
@@ -114,7 +114,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus)
static int tegra20_sflash_probe(struct udevice *bus)
{
struct tegra_spi_platdata *plat = dev_get_platdata(bus);
- struct tegra20_sflash_priv *priv = dev_get_priv(bus);
+ struct tegra20_sflash_priv *priv = dev_get_priv(bus, struct tegra20_sflash_priv);
priv->regs = (struct spi_regs *)plat->base;
@@ -128,7 +128,7 @@ static int tegra20_sflash_probe(struct udevice *bus)
static int tegra20_sflash_claim_bus(struct udevice *dev)
{
struct udevice *bus = dev->parent;
- struct tegra20_sflash_priv *priv = dev_get_priv(bus);
+ struct tegra20_sflash_priv *priv = dev_get_priv(bus, struct tegra20_sflash_priv);
struct spi_regs *regs = priv->regs;
u32 reg;
@@ -167,7 +167,7 @@ static void spi_cs_activate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
- struct tegra20_sflash_priv *priv = dev_get_priv(bus);
+ struct tegra20_sflash_priv *priv = dev_get_priv(bus, struct tegra20_sflash_priv);
/* If it's too soon to do another transaction, wait */
if (pdata->deactivate_delay_us &&
@@ -186,7 +186,7 @@ static void spi_cs_deactivate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
- struct tegra20_sflash_priv *priv = dev_get_priv(bus);
+ struct tegra20_sflash_priv *priv = dev_get_priv(bus, struct tegra20_sflash_priv);
/* CS is negated on Tegra, so drive a 0 to get a 1 */
clrbits_le32(&priv->regs->command, SPI_CMD_CS_VAL);
@@ -201,7 +201,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen,
unsigned long flags)
{
struct udevice *bus = dev->parent;
- struct tegra20_sflash_priv *priv = dev_get_priv(bus);
+ struct tegra20_sflash_priv *priv = dev_get_priv(bus, struct tegra20_sflash_priv);
struct spi_regs *regs = priv->regs;
u32 reg, tmpdout, tmpdin = 0;
const u8 *dout = data_out;
@@ -308,7 +308,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen,
static int tegra20_sflash_set_speed(struct udevice *bus, uint speed)
{
struct tegra_spi_platdata *plat = bus->platdata;
- struct tegra20_sflash_priv *priv = dev_get_priv(bus);
+ struct tegra20_sflash_priv *priv = dev_get_priv(bus, struct tegra20_sflash_priv);
if (speed > plat->frequency)
speed = plat->frequency;
@@ -320,7 +320,7 @@ static int tegra20_sflash_set_speed(struct udevice *bus, uint speed)
static int tegra20_sflash_set_mode(struct udevice *bus, uint mode)
{
- struct tegra20_sflash_priv *priv = dev_get_priv(bus);
+ struct tegra20_sflash_priv *priv = dev_get_priv(bus, struct tegra20_sflash_priv);
priv->mode = mode;
debug("%s: regs=%p, mode=%d\n", __func__, priv->regs, priv->mode);
@@ -348,6 +348,6 @@ U_BOOT_DRIVER(tegra20_sflash) = {
.ops = &tegra20_sflash_ops,
.ofdata_to_platdata = tegra20_sflash_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct tegra20_sflash_priv),
+ .priv_alloc = dm_alloc(struct tegra20_sflash_priv),
.probe = tegra20_sflash_probe,
};
@@ -130,7 +130,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus)
static int tegra30_spi_probe(struct udevice *bus)
{
struct tegra_spi_platdata *plat = dev_get_platdata(bus);
- struct tegra30_spi_priv *priv = dev_get_priv(bus);
+ struct tegra30_spi_priv *priv = dev_get_priv(bus, struct tegra30_spi_priv);
priv->regs = (struct spi_regs *)plat->base;
@@ -144,7 +144,7 @@ static int tegra30_spi_probe(struct udevice *bus)
static int tegra30_spi_claim_bus(struct udevice *dev)
{
struct udevice *bus = dev->parent;
- struct tegra30_spi_priv *priv = dev_get_priv(bus);
+ struct tegra30_spi_priv *priv = dev_get_priv(bus, struct tegra30_spi_priv);
struct spi_regs *regs = priv->regs;
u32 reg;
@@ -171,7 +171,7 @@ static void spi_cs_activate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
- struct tegra30_spi_priv *priv = dev_get_priv(bus);
+ struct tegra30_spi_priv *priv = dev_get_priv(bus, struct tegra30_spi_priv);
/* If it's too soon to do another transaction, wait */
if (pdata->deactivate_delay_us &&
@@ -190,7 +190,7 @@ static void spi_cs_deactivate(struct udevice *dev)
{
struct udevice *bus = dev->parent;
struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
- struct tegra30_spi_priv *priv = dev_get_priv(bus);
+ struct tegra30_spi_priv *priv = dev_get_priv(bus, struct tegra30_spi_priv);
/* CS is negated on Tegra, so drive a 0 to get a 1 */
clrbits_le32(&priv->regs->command, SLINK_CMD_CS_VAL);
@@ -205,7 +205,7 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
unsigned long flags)
{
struct udevice *bus = dev->parent;
- struct tegra30_spi_priv *priv = dev_get_priv(bus);
+ struct tegra30_spi_priv *priv = dev_get_priv(bus, struct tegra30_spi_priv);
struct spi_regs *regs = priv->regs;
u32 reg, tmpdout, tmpdin = 0;
const u8 *dout = data_out;
@@ -318,7 +318,7 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
static int tegra30_spi_set_speed(struct udevice *bus, uint speed)
{
struct tegra_spi_platdata *plat = bus->platdata;
- struct tegra30_spi_priv *priv = dev_get_priv(bus);
+ struct tegra30_spi_priv *priv = dev_get_priv(bus, struct tegra30_spi_priv);
if (speed > plat->frequency)
speed = plat->frequency;
@@ -330,7 +330,7 @@ static int tegra30_spi_set_speed(struct udevice *bus, uint speed)
static int tegra30_spi_set_mode(struct udevice *bus, uint mode)
{
- struct tegra30_spi_priv *priv = dev_get_priv(bus);
+ struct tegra30_spi_priv *priv = dev_get_priv(bus, struct tegra30_spi_priv);
priv->mode = mode;
debug("%s: regs=%p, mode=%d\n", __func__, priv->regs, priv->mode);
@@ -361,6 +361,6 @@ U_BOOT_DRIVER(tegra30_spi) = {
.ops = &tegra30_spi_ops,
.ofdata_to_platdata = tegra30_spi_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
- .priv_auto_alloc_size = sizeof(struct tegra30_spi_priv),
+ .priv_alloc = dm_alloc(struct tegra30_spi_priv),
.probe = tegra30_spi_probe,
};
@@ -47,7 +47,7 @@ static int read_cpu_temperature(struct udevice *dev)
unsigned int reg, n_meas;
const struct imx_thermal_plat *pdata = dev_get_platdata(dev);
struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs;
- struct thermal_data *priv = dev_get_priv(dev);
+ struct thermal_data *priv = dev_get_priv(dev, struct thermal_data);
u32 fuse = priv->fuse;
int t1, n1;
u32 c1, c2;
@@ -126,7 +126,7 @@ static int read_cpu_temperature(struct udevice *dev)
int imx_thermal_get_temp(struct udevice *dev, int *temp)
{
- struct thermal_data *priv = dev_get_priv(dev);
+ struct thermal_data *priv = dev_get_priv(dev, struct thermal_data);
int cpu_tmp = 0;
cpu_tmp = read_cpu_temperature(dev);
@@ -156,7 +156,7 @@ static int imx_thermal_probe(struct udevice *dev)
unsigned int fuse = ~0;
const struct imx_thermal_plat *pdata = dev_get_platdata(dev);
- struct thermal_data *priv = dev_get_priv(dev);
+ struct thermal_data *priv = dev_get_priv(dev, struct thermal_data);
/* Read Temperature calibration data fuse */
fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse);
@@ -182,6 +182,6 @@ U_BOOT_DRIVER(imx_thermal) = {
.id = UCLASS_THERMAL,
.ops = &imx_thermal_ops,
.probe = imx_thermal_probe,
- .priv_auto_alloc_size = sizeof(struct thermal_data),
+ .priv_alloc = dm_alloc(struct thermal_data),
.flags = DM_FLAG_PRE_RELOC,
};
@@ -180,7 +180,7 @@ static int sandbox_flash_control(struct udevice *dev, struct usb_device *udev,
unsigned long pipe, void *buff, int len,
struct devrequest *setup)
{
- struct sandbox_flash_priv *priv = dev_get_priv(dev);
+ struct sandbox_flash_priv *priv = dev_get_priv(dev, struct sandbox_flash_priv);
if (pipe == usb_rcvctrlpipe(udev, 0)) {
switch (setup->request) {
@@ -303,7 +303,7 @@ static int handle_ufi_command(struct sandbox_flash_priv *priv, const void *buff,
static int sandbox_flash_bulk(struct udevice *dev, struct usb_device *udev,
unsigned long pipe, void *buff, int len)
{
- struct sandbox_flash_priv *priv = dev_get_priv(dev);
+ struct sandbox_flash_priv *priv = dev_get_priv(dev, struct sandbox_flash_priv);
int ep = usb_pipeendpoint(pipe);
struct umass_bbb_cbw *cbw = buff;
@@ -391,7 +391,7 @@ static int sandbox_flash_bind(struct udevice *dev)
static int sandbox_flash_probe(struct udevice *dev)
{
struct sandbox_flash_plat *plat = dev_get_platdata(dev);
- struct sandbox_flash_priv *priv = dev_get_priv(dev);
+ struct sandbox_flash_priv *priv = dev_get_priv(dev, struct sandbox_flash_priv);
priv->fd = os_open(plat->pathname, OS_O_RDONLY);
if (priv->fd != -1)
@@ -418,6 +418,6 @@ U_BOOT_DRIVER(usb_sandbox_flash) = {
.probe = sandbox_flash_probe,
.ofdata_to_platdata = sandbox_flash_ofdata_to_platdata,
.ops = &sandbox_usb_flash_ops,
- .priv_auto_alloc_size = sizeof(struct sandbox_flash_priv),
+ .priv_alloc = dm_alloc(struct sandbox_flash_priv),
.platdata_auto_alloc_size = sizeof(struct sandbox_flash_plat),
};
@@ -135,7 +135,7 @@ static struct udevice *hub_find_device(struct udevice *hub, int port)
static int clrset_post_state(struct udevice *hub, int port, int clear, int set)
{
- struct sandbox_hub_priv *priv = dev_get_priv(hub);
+ struct sandbox_hub_priv *priv = dev_get_priv(hub, struct sandbox_hub_priv);
int *status = &priv->status[port];
int *change = &priv->change[port];
int ret = 0;
@@ -175,7 +175,7 @@ static int sandbox_hub_submit_control_msg(struct udevice *bus,
void *buffer, int length,
struct devrequest *setup)
{
- struct sandbox_hub_priv *priv = dev_get_priv(bus);
+ struct sandbox_hub_priv *priv = dev_get_priv(bus, struct sandbox_hub_priv);
int ret = 0;
if (pipe == usb_rcvctrlpipe(udev, 0)) {
@@ -297,7 +297,7 @@ U_BOOT_DRIVER(usb_sandbox_hub) = {
.of_match = sandbox_usb_hub_ids,
.bind = sandbox_hub_bind,
.ops = &sandbox_usb_hub_ops,
- .priv_auto_alloc_size = sizeof(struct sandbox_hub_priv),
+ .priv_alloc = dm_alloc(struct sandbox_hub_priv),
.per_child_platdata_auto_alloc_size =
sizeof(struct sandbox_hub_platdata),
.child_post_bind = sandbox_child_post_bind,
@@ -214,7 +214,7 @@ static void reset_usb_phy(struct exynos_usb_phy *usb)
static int ehci_usb_probe(struct udevice *dev)
{
struct exynos_ehci_platdata *plat = dev_get_platdata(dev);
- struct exynos_ehci *ctx = dev_get_priv(dev);
+ struct exynos_ehci *ctx = dev_get_priv(dev, struct exynos_ehci);
struct ehci_hcor *hcor;
ctx->hcd = (struct ehci_hccr *)plat->hcd_base;
@@ -233,7 +233,7 @@ static int ehci_usb_probe(struct udevice *dev)
static int ehci_usb_remove(struct udevice *dev)
{
- struct exynos_ehci *ctx = dev_get_priv(dev);
+ struct exynos_ehci *ctx = dev_get_priv(dev, struct exynos_ehci);
int ret;
ret = ehci_deregister(dev);
@@ -257,7 +257,7 @@ U_BOOT_DRIVER(usb_ehci) = {
.probe = ehci_usb_probe,
.remove = ehci_usb_remove,
.ops = &ehci_usb_ops,
- .priv_auto_alloc_size = sizeof(struct exynos_ehci),
+ .priv_alloc = dm_alloc(struct exynos_ehci),
.platdata_auto_alloc_size = sizeof(struct exynos_ehci_platdata),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
@@ -1645,7 +1645,7 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
uint tweaks, enum usb_init_type init)
{
struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
- struct ehci_ctrl *ctrl = dev_get_priv(dev);
+ struct ehci_ctrl *ctrl = dev_get_priv(dev, struct ehci_ctrl);
int ret;
debug("%s: dev='%s', ctrl=%p, hccr=%p, hcor=%p, init=%d\n", __func__,
@@ -1677,7 +1677,7 @@ err:
int ehci_deregister(struct udevice *dev)
{
- struct ehci_ctrl *ctrl = dev_get_priv(dev);
+ struct ehci_ctrl *ctrl = dev_get_priv(dev, struct ehci_ctrl);
ehci_shutdown(ctrl);
@@ -27,7 +27,7 @@ static int ehci_usb_probe(struct udevice *dev)
{
struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
struct usb_platdata *plat = dev_get_platdata(dev);
- struct ehci_sunxi_priv *priv = dev_get_priv(dev);
+ struct ehci_sunxi_priv *priv = dev_get_priv(dev, struct ehci_sunxi_priv);
struct ehci_hccr *hccr = (struct ehci_hccr *)dev_get_addr(dev);
struct ehci_hcor *hcor;
@@ -60,7 +60,7 @@ static int ehci_usb_probe(struct udevice *dev)
static int ehci_usb_remove(struct udevice *dev)
{
struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
- struct ehci_sunxi_priv *priv = dev_get_priv(dev);
+ struct ehci_sunxi_priv *priv = dev_get_priv(dev, struct ehci_sunxi_priv);
int ret;
ret = ehci_deregister(dev);
@@ -96,6 +96,6 @@ U_BOOT_DRIVER(usb_ehci) = {
.remove = ehci_usb_remove,
.ops = &ehci_usb_ops,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
- .priv_auto_alloc_size = sizeof(struct ehci_sunxi_priv),
+ .priv_alloc = dm_alloc(struct ehci_sunxi_priv),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
@@ -773,7 +773,7 @@ static const struct ehci_ops tegra_ehci_ops = {
static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
{
- struct fdt_usb *priv = dev_get_priv(dev);
+ struct fdt_usb *priv = dev_get_priv(dev, struct fdt_usb);
int ret;
ret = fdt_decode_usb(gd->fdt_blob, dev->of_offset, priv);
@@ -788,7 +788,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
static int ehci_usb_probe(struct udevice *dev)
{
struct usb_platdata *plat = dev_get_platdata(dev);
- struct fdt_usb *priv = dev_get_priv(dev);
+ struct fdt_usb *priv = dev_get_priv(dev, struct fdt_usb);
struct ehci_hccr *hccr;
struct ehci_hcor *hcor;
static bool clk_done;
@@ -835,6 +835,6 @@ U_BOOT_DRIVER(usb_ehci) = {
.remove = ehci_usb_remove,
.ops = &ehci_usb_ops,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
- .priv_auto_alloc_size = sizeof(struct fdt_usb),
+ .priv_alloc = dm_alloc(struct fdt_usb),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
@@ -28,7 +28,7 @@ static int ohci_usb_probe(struct udevice *dev)
{
struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
struct usb_bus_priv *bus_priv = dev_get_uclass_priv(dev);
- struct ohci_sunxi_priv *priv = dev_get_priv(dev);
+ struct ohci_sunxi_priv *priv = dev_get_priv(dev, struct ohci_sunxi_priv);
struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev);
bus_priv->companion = true;
@@ -62,7 +62,7 @@ static int ohci_usb_probe(struct udevice *dev)
static int ohci_usb_remove(struct udevice *dev)
{
struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
- struct ohci_sunxi_priv *priv = dev_get_priv(dev);
+ struct ohci_sunxi_priv *priv = dev_get_priv(dev, struct ohci_sunxi_priv);
int ret;
ret = ohci_deregister(dev);
@@ -99,6 +99,6 @@ U_BOOT_DRIVER(usb_ohci) = {
.remove = ohci_usb_remove,
.ops = &ohci_usb_ops,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
- .priv_auto_alloc_size = sizeof(struct ohci_sunxi_priv),
+ .priv_alloc = dm_alloc(struct ohci_sunxi_priv),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
@@ -358,7 +358,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
ret = device_probe(dev);
if (ret)
return ret;
- *ctlrp = dev_get_priv(dev);
+ *ctlrp = dev_get_priv(dev, struct ehci_ctrl);
return 0;
}
@@ -753,7 +753,7 @@ UCLASS_DRIVER(usb) = {
.name = "usb",
.flags = DM_UC_FLAG_SEQ_ALIAS,
.post_bind = usb_post_bind,
- .priv_auto_alloc_size = sizeof(struct usb_uclass_priv),
+ .priv_alloc = dm_alloc(struct usb_uclass_priv),
.per_child_auto_alloc_size = sizeof(struct usb_device),
.per_device_auto_alloc_size = sizeof(struct usb_bus_priv),
.child_post_bind = usb_child_post_bind,
@@ -283,7 +283,7 @@ static void exynos_xhci_core_exit(struct exynos_xhci *exynos)
static int xhci_usb_probe(struct udevice *dev)
{
struct exynos_xhci_platdata *plat = dev_get_platdata(dev);
- struct exynos_xhci *ctx = dev_get_priv(dev);
+ struct exynos_xhci *ctx = dev_get_priv(dev, struct exynos_xhci);
struct xhci_hcor *hcor;
int ret;
@@ -308,7 +308,7 @@ static int xhci_usb_probe(struct udevice *dev)
static int xhci_usb_remove(struct udevice *dev)
{
- struct exynos_xhci *ctx = dev_get_priv(dev);
+ struct exynos_xhci *ctx = dev_get_priv(dev, struct exynos_xhci);
int ret;
ret = xhci_deregister(dev);
@@ -333,6 +333,6 @@ U_BOOT_DRIVER(usb_xhci) = {
.remove = xhci_usb_remove,
.ops = &xhci_usb_ops,
.platdata_auto_alloc_size = sizeof(struct exynos_xhci_platdata),
- .priv_auto_alloc_size = sizeof(struct exynos_xhci),
+ .priv_alloc = dm_alloc(struct exynos_xhci),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
@@ -1180,7 +1180,7 @@ static int xhci_alloc_device(struct udevice *dev, struct usb_device *udev)
int xhci_register(struct udevice *dev, struct xhci_hccr *hccr,
struct xhci_hcor *hcor)
{
- struct xhci_ctrl *ctrl = dev_get_priv(dev);
+ struct xhci_ctrl *ctrl = dev_get_priv(dev, struct xhci_ctrl);
struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
int ret;
@@ -1216,7 +1216,7 @@ err:
int xhci_deregister(struct udevice *dev)
{
- struct xhci_ctrl *ctrl = dev_get_priv(dev);
+ struct xhci_ctrl *ctrl = dev_get_priv(dev, struct xhci_ctrl);
xhci_lowlevel_stop(ctrl);
xhci_cleanup(ctrl);
@@ -1464,7 +1464,7 @@ static int tegra_dc_dp_check_sink(struct tegra_dp_priv *dp,
int tegra_dp_enable(struct udevice *dev, int panel_bpp,
const struct display_timing *timing)
{
- struct tegra_dp_priv *priv = dev_get_priv(dev);
+ struct tegra_dp_priv *priv = dev_get_priv(dev, struct tegra_dp_priv);
struct tegra_dp_link_config slink_cfg, *link_cfg = &slink_cfg;
struct tegra_dc_sor_data *sor;
int data;
@@ -1564,7 +1564,7 @@ static int tegra_dp_ofdata_to_platdata(struct udevice *dev)
static int tegra_dp_read_edid(struct udevice *dev, u8 *buf, int buf_size)
{
- struct tegra_dp_priv *priv = dev_get_priv(dev);
+ struct tegra_dp_priv *priv = dev_get_priv(dev, struct tegra_dp_priv);
const int tegra_edid_i2c_address = 0x50;
u32 aux_stat = 0;
@@ -1582,7 +1582,7 @@ static const struct dm_display_port_ops dp_tegra_ops = {
static int dp_tegra_probe(struct udevice *dev)
{
struct tegra_dp_plat *plat = dev_get_platdata(dev);
- struct tegra_dp_priv *priv = dev_get_priv(dev);
+ struct tegra_dp_priv *priv = dev_get_priv(dev, struct tegra_dp_priv);
priv->regs = (struct dpaux_ctlr *)plat->base;
priv->enabled = false;
@@ -1602,6 +1602,6 @@ U_BOOT_DRIVER(dp_tegra) = {
.ofdata_to_platdata = tegra_dp_ofdata_to_platdata,
.probe = dp_tegra_probe,
.ops = &dp_tegra_ops,
- .priv_auto_alloc_size = sizeof(struct tegra_dp_priv),
+ .priv_alloc = dm_alloc(struct tegra_dp_priv),
.platdata_auto_alloc_size = sizeof(struct tegra_dp_plat),
};
new file mode 100644
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _DM_ALLOC_H
+#define _DM_ALLOC_H
+
+/**
+ * struct dm_alloc: Information about a structure to be allocated
+ *
+ * @size: Size to allocate (0 for manually allocated)
+ * @name: Structure name, e.g. "struct spi_priv"
+ */
+struct dm_alloc {
+ int size;
+#ifdef CONFIG_DM_ALLOC_CHECK
+ const char *name;
+#endif
+};
+
+#ifdef CONFIG_DM_ALLOC_CHECK
+#define dm_alloc(_struct) \
+ { \
+ .size = sizeof(_struct), \
+ .name = #_struct, \
+ }
+#else
+#define dm_alloc(_struct) \
+ { \
+ .size = sizeof(_struct), \
+ }
+#endif
+
+#endif
@@ -11,6 +11,7 @@
#ifndef _DM_DEVICE_H
#define _DM_DEVICE_H
+#include <dm/alloc.h>
#include <dm/uclass-id.h>
#include <fdtdec.h>
#include <linker_lists.h>
@@ -147,7 +148,7 @@ struct udevice_id {
* memory allocated but it has not yet been probed.
* @child_post_remove: Called after a child device is removed. The device
* has memory allocated but its device_remove() method has been called.
- * @priv_auto_alloc_size: If non-zero this is the size of the private data
+ * @priv_alloc.size: If non-zero this is the size of the private data
* to be allocated in the device's ->priv pointer. If zero, then the driver
* is responsible for allocating any data required.
* @platdata_auto_alloc_size: If non-zero this is the size of the
@@ -182,7 +183,7 @@ struct driver {
int (*child_post_bind)(struct udevice *dev);
int (*child_pre_probe)(struct udevice *dev);
int (*child_post_remove)(struct udevice *dev);
- int priv_auto_alloc_size;
+ struct dm_alloc priv_alloc;
int platdata_auto_alloc_size;
int per_child_auto_alloc_size;
int per_child_platdata_auto_alloc_size;
@@ -237,7 +238,7 @@ void *dev_get_uclass_platdata(struct udevice *dev);
* @return parent data, or NULL if none
*/
void *dev_get_parentdata(struct udevice *dev);
-
+void *dev_get_priv_checked(struct udevice *dev, const char *name);
/**
* dev_get_priv() - Get the private data for a device
*
@@ -246,7 +247,12 @@ void *dev_get_parentdata(struct udevice *dev);
* @dev Device to check
* @return private data, or NULL if none
*/
-void *dev_get_priv(struct udevice *dev);
+#ifdef CONFIG_DM_ALLOC_CHECK
+#define dev_get_priv(_dev, _struct) \
+ (_struct *)dev_get_priv_checked(_dev, #_struct)
+#else
+#define dev_get_priv(_dev, _struct) ((_dev)->priv)
+#endif
/**
* struct dev_get_parent() - Get the parent of a device
@@ -91,7 +91,7 @@ struct uclass_driver {
int (*child_pre_probe)(struct udevice *dev);
int (*init)(struct uclass *class);
int (*destroy)(struct uclass *class);
- int priv_auto_alloc_size;
+ struct dm_alloc priv_alloc;
int per_device_auto_alloc_size;
int per_device_platdata_auto_alloc_size;
int per_child_auto_alloc_size;
@@ -564,7 +564,7 @@ UCLASS_DRIVER(eth) = {
.pre_unbind = eth_pre_unbind,
.post_probe = eth_post_probe,
.pre_remove = eth_pre_remove,
- .priv_auto_alloc_size = sizeof(struct eth_uclass_priv),
+ .priv_alloc = dm_alloc(struct eth_uclass_priv),
.per_device_auto_alloc_size = sizeof(struct eth_device_priv),
.flags = DM_UC_FLAG_SEQ_ALIAS,
};
@@ -55,7 +55,7 @@ static int testbus_child_pre_probe(struct udevice *dev)
static int testbus_child_pre_probe_uclass(struct udevice *dev)
{
- struct dm_test_priv *priv = dev_get_priv(dev);
+ struct dm_test_priv *priv = dev_get_priv(dev, struct dm_test_priv);
priv->uclass_flag++;
@@ -87,7 +87,7 @@ U_BOOT_DRIVER(testbus_drv) = {
.id = UCLASS_TEST_BUS,
.probe = testbus_drv_probe,
.child_post_bind = testbus_child_post_bind,
- .priv_auto_alloc_size = sizeof(struct dm_test_priv),
+ .priv_alloc = dm_alloc(struct dm_test_priv),
.platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
.per_child_auto_alloc_size = sizeof(struct dm_test_parent_data),
.per_child_platdata_auto_alloc_size =
@@ -502,13 +502,13 @@ static int dm_test_bus_child_pre_probe_uclass(struct unit_test_state *uts)
for (device_find_first_child(bus, &dev), child_count = 0;
dev;
device_find_next_child(&dev)) {
- struct dm_test_priv *priv = dev_get_priv(dev);
+ struct dm_test_priv *priv = dev_get_priv(dev, struct dm_test_priv);
/* Check that things happened in the right order */
ut_asserteq_ptr(NULL, priv);
ut_assertok(device_probe(dev));
- priv = dev_get_priv(dev);
+ priv = dev->priv;
ut_assert(priv != NULL);
ut_asserteq(1, priv->uclass_flag);
ut_asserteq(1, priv->uclass_total);
@@ -21,7 +21,7 @@ static struct unit_test_state *uts = &global_dm_test_state;
static int testdrv_ping(struct udevice *dev, int pingval, int *pingret)
{
const struct dm_test_pdata *pdata = dev_get_platdata(dev);
- struct dm_test_priv *priv = dev_get_priv(dev);
+ struct dm_test_priv *priv = dev_get_priv(dev, struct dm_test_priv);
*pingret = pingval + pdata->ping_add;
priv->ping_total += *pingret;
@@ -36,7 +36,7 @@ static const struct test_ops test_ops = {
static int test_bind(struct udevice *dev)
{
/* Private data should not be allocated */
- ut_assert(!dev_get_priv(dev));
+ ut_assert(!dev->priv);
dm_testdrv_op_count[DM_TEST_OP_BIND]++;
return 0;
@@ -44,7 +44,7 @@ static int test_bind(struct udevice *dev)
static int test_probe(struct udevice *dev)
{
- struct dm_test_priv *priv = dev_get_priv(dev);
+ struct dm_test_priv *priv = dev_get_priv(dev, struct dm_test_priv);
/* Private data should be allocated */
ut_assert(priv);
@@ -57,7 +57,7 @@ static int test_probe(struct udevice *dev)
static int test_remove(struct udevice *dev)
{
/* Private data should still be allocated */
- ut_assert(dev_get_priv(dev));
+ ut_assert(dev->priv);
dm_testdrv_op_count[DM_TEST_OP_REMOVE]++;
return 0;
@@ -80,7 +80,7 @@ U_BOOT_DRIVER(test_drv) = {
.probe = test_probe,
.remove = test_remove,
.unbind = test_unbind,
- .priv_auto_alloc_size = sizeof(struct dm_test_priv),
+ .priv_alloc = dm_alloc(struct dm_test_priv),
};
U_BOOT_DRIVER(test2_drv) = {
@@ -91,7 +91,7 @@ U_BOOT_DRIVER(test2_drv) = {
.probe = test_probe,
.remove = test_remove,
.unbind = test_unbind,
- .priv_auto_alloc_size = sizeof(struct dm_test_priv),
+ .priv_alloc = dm_alloc(struct dm_test_priv),
};
static int test_manual_drv_ping(struct udevice *dev, int pingval, int *pingret)
@@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret)
{
const struct dm_test_pdata *pdata = dev->platdata;
- struct dm_test_priv *priv = dev_get_priv(dev);
+ struct dm_test_priv *priv = dev_get_priv(dev, struct dm_test_priv);
*pingret = pingval + pdata->ping_add;
priv->ping_total += *pingret;
@@ -47,7 +47,7 @@ static int testfdt_ofdata_to_platdata(struct udevice *dev)
static int testfdt_drv_probe(struct udevice *dev)
{
- struct dm_test_priv *priv = dev_get_priv(dev);
+ struct dm_test_priv *priv = dev_get_priv(dev, struct dm_test_priv);
priv->ping_total += DM_TEST_START_TOTAL;
@@ -78,7 +78,7 @@ U_BOOT_DRIVER(testfdt_drv) = {
.ofdata_to_platdata = testfdt_ofdata_to_platdata,
.probe = testfdt_drv_probe,
.ops = &test_ops,
- .priv_auto_alloc_size = sizeof(struct dm_test_priv),
+ .priv_alloc = dm_alloc(struct dm_test_priv),
.platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
};
@@ -126,8 +126,7 @@ int dm_check_devices(struct unit_test_state *uts, int num_devices)
debug("dev=%d, base=%d: %s\n", i, base,
fdt_get_name(gd->fdt_blob, dev->of_offset, NULL));
- ut_assert(!dm_check_operations(uts, dev, base,
- dev_get_priv(dev)));
+ ut_assert(!dm_check_operations(uts, dev, base, dev->priv));
}
return 0;
@@ -155,7 +154,7 @@ static int dm_test_fdt(struct unit_test_state *uts)
for (i = 0; i < num_devices; i++) {
ret = uclass_find_device(UCLASS_TEST_FDT, i, &dev);
ut_assert(!ret);
- ut_assert(!dev_get_priv(dev));
+ ut_assert(!dev->priv);
ut_assert(dev->platdata);
}
@@ -123,7 +123,7 @@ UCLASS_DRIVER(test) = {
.pre_remove = test_pre_remove,
.init = test_init,
.destroy = test_destroy,
- .priv_auto_alloc_size = sizeof(struct dm_test_uclass_priv),
+ .priv_alloc = dm_alloc(struct dm_test_uclass_priv),
.per_device_auto_alloc_size = sizeof(struct dm_test_uclass_perdev_priv),
.per_device_platdata_auto_alloc_size =
sizeof(struct dm_test_perdev_uc_pdata),
With driver model drivers can have things stored in several places. There is driver-private data, then the uclass can attach things to a device. If the device is on a bus then its bus may attach parent data to the device too. At present everything is done through void pointers. It would be nice to have a way to check that the correct C struct is used in each case. Here is a proposed implementation of a way of checking structures in driver model. It relies on turning the existing dev_get_priv() function into a macro which (if checking is enabled) checks that the structure names match. Each xxx_auto_alloc_size turns into a structure containing a string (the structure name) and the size. The dev_get_priv() macro has an extra parameter which is the structure being accessed: struct eth_pdata *priv = dev_get_priv(dev, struct eth_pdata); and you get an error like this when things are wrong: Invalid access to device priv: dev=eth@10002000, expecting 'struct eth_sandbox_priv', requested 'struct eth_pdata' A new Kconfg option is added to turn this on, since it bloats the code a little. The next step would be to extend it to all pointers in the device and uclass. This is mostly a mechanical code change. Finally we should have a way of checking that the device pointer itself is valid. For example if someone passes an invalid address like 0x12345 as the 'struct udevice' then at present we will dutifully look for the devices' driver and perform an invalid memory access. If we want to check for memory corruption one way would be to add a magic numnber before each allocated memory area. Perhaps this is more the role of dlmalloc(), but if required it could be attached to Masahiro's devres feature, which already prepends some data to every allocated area. Comments welcome. I'd like to figure this out soon as it involves trivial but invasive patches to change each driver. Signed-off-by: Simon Glass <sjg@chromium.org> --- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 8 +++--- arch/x86/cpu/mp_init.c | 2 +- doc/driver-model/README.txt | 4 +-- doc/driver-model/spi-howto.txt | 14 +++++------ doc/driver-model/usb-info.txt | 4 +-- drivers/clk/clk_rk3288.c | 12 ++++----- drivers/clk/clk_sandbox.c | 13 +++++----- drivers/core/Kconfig | 10 ++++++++ drivers/core/device-remove.c | 2 +- drivers/core/device.c | 17 +++++++------ drivers/core/uclass.c | 8 +++--- drivers/demo/demo-shape.c | 14 +++++------ drivers/gpio/at91_gpio.c | 14 +++++------ drivers/gpio/bcm2835_gpio.c | 14 +++++------ drivers/gpio/intel_ich6_gpio.c | 16 ++++++------ drivers/gpio/lpc32xx_gpio.c | 2 +- drivers/gpio/mxc_gpio.c | 14 +++++------ drivers/gpio/omap_gpio.c | 14 +++++------ drivers/gpio/rk_gpio.c | 12 ++++----- drivers/gpio/s5p_gpio.c | 14 +++++------ drivers/gpio/sandbox.c | 2 +- drivers/gpio/tegra_gpio.c | 14 +++++------ drivers/gpio/vybrid_gpio.c | 14 +++++------ drivers/i2c/i2c-gpio.c | 10 ++++---- drivers/i2c/i2c-uniphier-f.c | 10 ++++---- drivers/i2c/i2c-uniphier.c | 10 ++++---- drivers/i2c/muxes/i2c-arb-gpio-challenge.c | 10 ++++---- drivers/i2c/mxc_i2c.c | 10 ++++---- drivers/i2c/rk_i2c.c | 8 +++--- drivers/i2c/s3c24x0_i2c.c | 10 ++++---- drivers/i2c/sandbox_i2c.c | 6 ++--- drivers/i2c/tegra_i2c.c | 10 ++++---- drivers/led/led_gpio.c | 8 +++--- drivers/misc/cros_ec_sandbox.c | 6 ++--- drivers/misc/i2c_eeprom.c | 2 +- drivers/misc/i2c_eeprom_emul.c | 8 +++--- drivers/misc/swap_case.c | 10 ++++---- drivers/mmc/rockchip_mmc.c | 8 +++--- drivers/mtd/spi/sandbox.c | 10 ++++---- drivers/mtd/spi/sf_probe.c | 2 +- drivers/net/designware.c | 14 +++++------ drivers/net/sandbox-raw.c | 10 ++++---- drivers/net/sandbox.c | 8 +++--- drivers/net/sunxi_emac.c | 8 +++--- drivers/pci/pci-emul-uclass.c | 2 +- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 6 ++--- drivers/rtc/i2c_rtc_emul.c | 2 +- drivers/serial/atmel_usart.c | 12 ++++----- drivers/serial/sandbox.c | 6 ++--- drivers/serial/serial_dw.c | 2 +- drivers/serial/serial_omap.c | 2 +- drivers/serial/serial_pl01x.c | 12 ++++----- drivers/serial/serial_ppc.c | 2 +- drivers/serial/serial_rockchip.c | 2 +- drivers/serial/serial_sh.c | 12 ++++----- drivers/serial/serial_tegra.c | 2 +- drivers/serial/serial_uniphier.c | 4 +-- drivers/serial/serial_x86.c | 2 +- drivers/spi/cadence_qspi.c | 14 +++++------ drivers/spi/designware_spi.c | 10 ++++---- drivers/spi/exynos_spi.c | 18 +++++++------- drivers/spi/fsl_dspi.c | 12 ++++----- drivers/spi/fsl_qspi.c | 4 +-- drivers/spi/ich.c | 12 ++++----- drivers/spi/rk_spi.c | 12 ++++----- drivers/spi/soft_spi.c | 6 ++--- drivers/spi/tegra114_spi.c | 14 +++++------ drivers/spi/tegra20_sflash.c | 16 ++++++------ drivers/spi/tegra20_slink.c | 16 ++++++------ drivers/thermal/imx_thermal.c | 8 +++--- drivers/usb/emul/sandbox_flash.c | 8 +++--- drivers/usb/emul/sandbox_hub.c | 6 ++--- drivers/usb/host/ehci-exynos.c | 6 ++--- drivers/usb/host/ehci-hcd.c | 4 +-- drivers/usb/host/ehci-sunxi.c | 6 ++--- drivers/usb/host/ehci-tegra.c | 6 ++--- drivers/usb/host/ohci-sunxi.c | 6 ++--- drivers/usb/host/usb-uclass.c | 4 +-- drivers/usb/host/xhci-exynos5.c | 6 ++--- drivers/usb/host/xhci.c | 4 +-- drivers/video/tegra124/dp.c | 8 +++--- include/dm/alloc.h | 37 ++++++++++++++++++++++++++++ include/dm/device.h | 14 ++++++++--- include/dm/uclass.h | 2 +- net/eth.c | 2 +- test/dm/bus.c | 8 +++--- test/dm/test-driver.c | 12 ++++----- test/dm/test-fdt.c | 11 ++++----- test/dm/test-uclass.c | 2 +- 89 files changed, 416 insertions(+), 362 deletions(-) create mode 100644 include/dm/alloc.h