dm: rename device struct to udevice

using UBI and DM together leads in compiler error, as
both define a "struct device", so rename "struct device"
in include/dm/device.h to "struct udevice", as we use
linux code (MTD/UBI/UBIFS some USB code,...) and cannot
change the linux "struct device"

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Marek Vasut <marex@denx.de>
This commit is contained in:
Heiko Schocher 2014-05-22 12:43:05 +02:00 committed by Tom Rini
parent 9665fa8f9e
commit 54c5d08a09
30 changed files with 193 additions and 191 deletions

View File

@ -29,7 +29,7 @@
* @param gp GPIO number * @param gp GPIO number
* @return -1 on error, 0 if GPIO is low, >0 if high * @return -1 on error, 0 if GPIO is low, >0 if high
*/ */
int sandbox_gpio_get_value(struct device *dev, unsigned int offset); int sandbox_gpio_get_value(struct udevice *dev, unsigned int offset);
/** /**
* Set the simulated value of a GPIO (used only in sandbox test code) * Set the simulated value of a GPIO (used only in sandbox test code)
@ -38,7 +38,7 @@ int sandbox_gpio_get_value(struct device *dev, unsigned int offset);
* @param value value to set (0 for low, non-zero for high) * @param value value to set (0 for low, non-zero for high)
* @return -1 on error, 0 if ok * @return -1 on error, 0 if ok
*/ */
int sandbox_gpio_set_value(struct device *dev, unsigned int offset, int value); int sandbox_gpio_set_value(struct udevice *dev, unsigned int offset, int value);
/** /**
* Return the simulated direction of a GPIO (used only in sandbox test code) * Return the simulated direction of a GPIO (used only in sandbox test code)
@ -46,7 +46,7 @@ int sandbox_gpio_set_value(struct device *dev, unsigned int offset, int value);
* @param gp GPIO number * @param gp GPIO number
* @return -1 on error, 0 if GPIO is input, >0 if output * @return -1 on error, 0 if GPIO is input, >0 if output
*/ */
int sandbox_gpio_get_direction(struct device *dev, unsigned int offset); int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset);
/** /**
* Set the simulated direction of a GPIO (used only in sandbox test code) * Set the simulated direction of a GPIO (used only in sandbox test code)
@ -55,7 +55,7 @@ int sandbox_gpio_get_direction(struct device *dev, unsigned int offset);
* @param output 0 to set as input, 1 to set as output * @param output 0 to set as input, 1 to set as output
* @return -1 on error, 0 if ok * @return -1 on error, 0 if ok
*/ */
int sandbox_gpio_set_direction(struct device *dev, unsigned int offset, int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset,
int output); int output);
#endif #endif

View File

@ -11,7 +11,7 @@
#include <dm-demo.h> #include <dm-demo.h>
#include <asm/io.h> #include <asm/io.h>
struct device *demo_dev; struct udevice *demo_dev;
static int do_demo_hello(cmd_tbl_t *cmdtp, int flag, int argc, static int do_demo_hello(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[]) char * const argv[])
@ -41,7 +41,7 @@ static int do_demo_status(cmd_tbl_t *cmdtp, int flag, int argc,
int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{ {
struct device *dev; struct udevice *dev;
int i, ret; int i, ret;
puts("Demo uclass entries:\n"); puts("Demo uclass entries:\n");

View File

@ -30,7 +30,7 @@ static const char * const gpio_function[] = {
"unknown", "unknown",
}; };
static void show_gpio(struct device *dev, const char *bank_name, int offset) static void show_gpio(struct udevice *dev, const char *bank_name, int offset)
{ {
struct dm_gpio_ops *ops = gpio_get_ops(dev); struct dm_gpio_ops *ops = gpio_get_ops(dev);
char buf[80]; char buf[80];
@ -62,7 +62,7 @@ static void show_gpio(struct device *dev, const char *bank_name, int offset)
static int do_gpio_status(const char *gpio_name) static int do_gpio_status(const char *gpio_name)
{ {
struct device *dev; struct udevice *dev;
int newline = 0; int newline = 0;
int ret; int ret;

View File

@ -122,7 +122,7 @@ What is going on?
Let's start at the top. The demo command is in common/cmd_demo.c. It does Let's start at the top. The demo command is in common/cmd_demo.c. It does
the usual command procesing and then: the usual command procesing and then:
struct device *demo_dev; struct udevice *demo_dev;
ret = uclass_get_device(UCLASS_DEMO, devnum, &demo_dev); ret = uclass_get_device(UCLASS_DEMO, devnum, &demo_dev);
@ -147,7 +147,7 @@ this particular device may use one or other of them.
The code for demo_hello() is in drivers/demo/demo-uclass.c: The code for demo_hello() is in drivers/demo/demo-uclass.c:
int demo_hello(struct device *dev, int ch) int demo_hello(struct udevice *dev, int ch)
{ {
const struct demo_ops *ops = device_get_ops(dev); const struct demo_ops *ops = device_get_ops(dev);
@ -160,7 +160,7 @@ int demo_hello(struct device *dev, int ch)
As you can see it just calls the relevant driver method. One of these is As you can see it just calls the relevant driver method. One of these is
in drivers/demo/demo-simple.c: in drivers/demo/demo-simple.c:
static int simple_hello(struct device *dev, int ch) static int simple_hello(struct udevice *dev, int ch)
{ {
const struct dm_demo_pdata *pdata = dev_get_platdata(dev); const struct dm_demo_pdata *pdata = dev_get_platdata(dev);
@ -321,7 +321,7 @@ instead of struct instance, struct platdata, etc.)
this concept relates to a class of drivers (or a subsystem). We shouldn't this concept relates to a class of drivers (or a subsystem). We shouldn't
use 'class' since it is a C++ reserved word, so U-Boot class (uclass) seems use 'class' since it is a C++ reserved word, so U-Boot class (uclass) seems
better than 'core'. better than 'core'.
- Remove 'struct driver_instance' and just use a single 'struct device'. - Remove 'struct driver_instance' and just use a single 'struct udevice'.
This removes a level of indirection that doesn't seem necessary. This removes a level of indirection that doesn't seem necessary.
- Built in device tree support, to avoid the need for platdata - Built in device tree support, to avoid the need for platdata
- Removed the concept of driver relocation, and just make it possible for - Removed the concept of driver relocation, and just make it possible for

View File

@ -30,9 +30,9 @@
* @dev: The device that is to be stripped of its children * @dev: The device that is to be stripped of its children
* @return 0 on success, -ve on error * @return 0 on success, -ve on error
*/ */
static int device_chld_unbind(struct device *dev) static int device_chld_unbind(struct udevice *dev)
{ {
struct device *pos, *n; struct udevice *pos, *n;
int ret, saved_ret = 0; int ret, saved_ret = 0;
assert(dev); assert(dev);
@ -51,9 +51,9 @@ static int device_chld_unbind(struct device *dev)
* @dev: The device whose children are to be removed * @dev: The device whose children are to be removed
* @return 0 on success, -ve on error * @return 0 on success, -ve on error
*/ */
static int device_chld_remove(struct device *dev) static int device_chld_remove(struct udevice *dev)
{ {
struct device *pos, *n; struct udevice *pos, *n;
int ret; int ret;
assert(dev); assert(dev);
@ -67,10 +67,10 @@ static int device_chld_remove(struct device *dev)
return 0; return 0;
} }
int device_bind(struct device *parent, struct driver *drv, const char *name, int device_bind(struct udevice *parent, struct driver *drv, const char *name,
void *platdata, int of_offset, struct device **devp) void *platdata, int of_offset, struct udevice **devp)
{ {
struct device *dev; struct udevice *dev;
struct uclass *uc; struct uclass *uc;
int ret = 0; int ret = 0;
@ -82,7 +82,7 @@ int device_bind(struct device *parent, struct driver *drv, const char *name,
if (ret) if (ret)
return ret; return ret;
dev = calloc(1, sizeof(struct device)); dev = calloc(1, sizeof(struct udevice));
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
@ -129,8 +129,8 @@ fail_bind:
return ret; return ret;
} }
int device_bind_by_name(struct device *parent, const struct driver_info *info, int device_bind_by_name(struct udevice *parent, const struct driver_info *info,
struct device **devp) struct udevice **devp)
{ {
struct driver *drv; struct driver *drv;
@ -142,7 +142,7 @@ int device_bind_by_name(struct device *parent, const struct driver_info *info,
-1, devp); -1, devp);
} }
int device_unbind(struct device *dev) int device_unbind(struct udevice *dev)
{ {
struct driver *drv; struct driver *drv;
int ret; int ret;
@ -181,7 +181,7 @@ int device_unbind(struct device *dev)
* device_free() - Free memory buffers allocated by a device * device_free() - Free memory buffers allocated by a device
* @dev: Device that is to be started * @dev: Device that is to be started
*/ */
static void device_free(struct device *dev) static void device_free(struct udevice *dev)
{ {
int size; int size;
@ -200,7 +200,7 @@ static void device_free(struct device *dev)
} }
} }
int device_probe(struct device *dev) int device_probe(struct udevice *dev)
{ {
struct driver *drv; struct driver *drv;
int size = 0; int size = 0;
@ -279,7 +279,7 @@ fail:
return ret; return ret;
} }
int device_remove(struct device *dev) int device_remove(struct udevice *dev)
{ {
struct driver *drv; struct driver *drv;
int ret; int ret;
@ -327,7 +327,7 @@ err:
return ret; return ret;
} }
void *dev_get_platdata(struct device *dev) void *dev_get_platdata(struct udevice *dev)
{ {
if (!dev) { if (!dev) {
dm_warn("%s: null device", __func__); dm_warn("%s: null device", __func__);
@ -337,7 +337,7 @@ void *dev_get_platdata(struct device *dev)
return dev->platdata; return dev->platdata;
} }
void *dev_get_priv(struct device *dev) void *dev_get_priv(struct udevice *dev)
{ {
if (!dev) { if (!dev) {
dm_warn("%s: null device", __func__); dm_warn("%s: null device", __func__);

View File

@ -60,13 +60,13 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id)
return NULL; return NULL;
} }
int lists_bind_drivers(struct device *parent) int lists_bind_drivers(struct udevice *parent)
{ {
struct driver_info *info = struct driver_info *info =
ll_entry_start(struct driver_info, driver_info); ll_entry_start(struct driver_info, driver_info);
const int n_ents = ll_entry_count(struct driver_info, driver_info); const int n_ents = ll_entry_count(struct driver_info, driver_info);
struct driver_info *entry; struct driver_info *entry;
struct device *dev; struct udevice *dev;
int result = 0; int result = 0;
int ret; int ret;
@ -116,12 +116,12 @@ static int driver_check_compatible(const void *blob, int offset,
return -ENOENT; return -ENOENT;
} }
int lists_bind_fdt(struct device *parent, const void *blob, int offset) int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
{ {
struct driver *driver = ll_entry_start(struct driver, driver); struct driver *driver = ll_entry_start(struct driver, driver);
const int n_ents = ll_entry_count(struct driver, driver); const int n_ents = ll_entry_count(struct driver, driver);
struct driver *entry; struct driver *entry;
struct device *dev; struct udevice *dev;
const char *name; const char *name;
int result = 0; int result = 0;
int ret; int ret;

View File

@ -24,7 +24,7 @@ static const struct driver_info root_info = {
.name = "root_driver", .name = "root_driver",
}; };
struct device *dm_root(void) struct udevice *dm_root(void)
{ {
if (!gd->dm_root) { if (!gd->dm_root) {
dm_warn("Virtual root driver does not exist!\n"); dm_warn("Virtual root driver does not exist!\n");

View File

@ -101,7 +101,7 @@ fail_mem:
int uclass_destroy(struct uclass *uc) int uclass_destroy(struct uclass *uc)
{ {
struct uclass_driver *uc_drv; struct uclass_driver *uc_drv;
struct device *dev, *tmp; struct udevice *dev, *tmp;
int ret; int ret;
list_for_each_entry_safe(dev, tmp, &uc->dev_head, uclass_node) { list_for_each_entry_safe(dev, tmp, &uc->dev_head, uclass_node) {
@ -137,10 +137,10 @@ int uclass_get(enum uclass_id id, struct uclass **ucp)
return 0; return 0;
} }
int uclass_find_device(enum uclass_id id, int index, struct device **devp) int uclass_find_device(enum uclass_id id, int index, struct udevice **devp)
{ {
struct uclass *uc; struct uclass *uc;
struct device *dev; struct udevice *dev;
int ret; int ret;
*devp = NULL; *devp = NULL;
@ -158,9 +158,9 @@ int uclass_find_device(enum uclass_id id, int index, struct device **devp)
return -ENODEV; return -ENODEV;
} }
int uclass_get_device(enum uclass_id id, int index, struct device **devp) int uclass_get_device(enum uclass_id id, int index, struct udevice **devp)
{ {
struct device *dev; struct udevice *dev;
int ret; int ret;
*devp = NULL; *devp = NULL;
@ -177,10 +177,10 @@ int uclass_get_device(enum uclass_id id, int index, struct device **devp)
return 0; return 0;
} }
int uclass_first_device(enum uclass_id id, struct device **devp) int uclass_first_device(enum uclass_id id, struct udevice **devp)
{ {
struct uclass *uc; struct uclass *uc;
struct device *dev; struct udevice *dev;
int ret; int ret;
*devp = NULL; *devp = NULL;
@ -190,7 +190,7 @@ int uclass_first_device(enum uclass_id id, struct device **devp)
if (list_empty(&uc->dev_head)) if (list_empty(&uc->dev_head))
return 0; return 0;
dev = list_first_entry(&uc->dev_head, struct device, uclass_node); dev = list_first_entry(&uc->dev_head, struct udevice, uclass_node);
ret = device_probe(dev); ret = device_probe(dev);
if (ret) if (ret)
return ret; return ret;
@ -199,16 +199,17 @@ int uclass_first_device(enum uclass_id id, struct device **devp)
return 0; return 0;
} }
int uclass_next_device(struct device **devp) int uclass_next_device(struct udevice **devp)
{ {
struct device *dev = *devp; struct udevice *dev = *devp;
int ret; int ret;
*devp = NULL; *devp = NULL;
if (list_is_last(&dev->uclass_node, &dev->uclass->dev_head)) if (list_is_last(&dev->uclass_node, &dev->uclass->dev_head))
return 0; return 0;
dev = list_entry(dev->uclass_node.next, struct device, uclass_node); dev = list_entry(dev->uclass_node.next, struct udevice,
uclass_node);
ret = device_probe(dev); ret = device_probe(dev);
if (ret) if (ret)
return ret; return ret;
@ -217,7 +218,7 @@ int uclass_next_device(struct device **devp)
return 0; return 0;
} }
int uclass_bind_device(struct device *dev) int uclass_bind_device(struct udevice *dev)
{ {
struct uclass *uc; struct uclass *uc;
int ret; int ret;
@ -237,7 +238,7 @@ int uclass_bind_device(struct device *dev)
return 0; return 0;
} }
int uclass_unbind_device(struct device *dev) int uclass_unbind_device(struct udevice *dev)
{ {
struct uclass *uc; struct uclass *uc;
int ret; int ret;
@ -253,7 +254,7 @@ int uclass_unbind_device(struct device *dev)
return 0; return 0;
} }
int uclass_post_probe_device(struct device *dev) int uclass_post_probe_device(struct udevice *dev)
{ {
struct uclass_driver *uc_drv = dev->uclass->uc_drv; struct uclass_driver *uc_drv = dev->uclass->uc_drv;
@ -263,7 +264,7 @@ int uclass_post_probe_device(struct device *dev)
return 0; return 0;
} }
int uclass_pre_remove_device(struct device *dev) int uclass_pre_remove_device(struct udevice *dev)
{ {
struct uclass_driver *uc_drv; struct uclass_driver *uc_drv;
struct uclass *uc; struct uclass *uc;

View File

@ -23,7 +23,7 @@ struct shape_data {
}; };
/* Crazy little function to draw shapes on the console */ /* Crazy little function to draw shapes on the console */
static int shape_hello(struct device *dev, int ch) static int shape_hello(struct udevice *dev, int ch)
{ {
const struct dm_demo_pdata *pdata = dev_get_platdata(dev); 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);
@ -81,7 +81,7 @@ static int shape_hello(struct device *dev, int ch)
return 0; return 0;
} }
static int shape_status(struct device *dev, int *status) 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);
@ -94,7 +94,7 @@ static const struct demo_ops shape_ops = {
.status = shape_status, .status = shape_status,
}; };
static int shape_ofdata_to_platdata(struct device *dev) static int shape_ofdata_to_platdata(struct udevice *dev)
{ {
struct dm_demo_pdata *pdata = dev_get_platdata(dev); struct dm_demo_pdata *pdata = dev_get_platdata(dev);
int ret; int ret;

View File

@ -12,7 +12,7 @@
#include <dm-demo.h> #include <dm-demo.h>
#include <asm/io.h> #include <asm/io.h>
static int simple_hello(struct device *dev, int ch) static int simple_hello(struct udevice *dev, int ch)
{ {
const struct dm_demo_pdata *pdata = dev_get_platdata(dev); const struct dm_demo_pdata *pdata = dev_get_platdata(dev);
@ -26,7 +26,7 @@ static const struct demo_ops simple_ops = {
.hello = simple_hello, .hello = simple_hello,
}; };
static int demo_shape_ofdata_to_platdata(struct device *dev) static int demo_shape_ofdata_to_platdata(struct udevice *dev)
{ {
/* Parse the data that is common with all demo devices */ /* Parse the data that is common with all demo devices */
return demo_parse_dt(dev); return demo_parse_dt(dev);

View File

@ -22,7 +22,7 @@ UCLASS_DRIVER(demo) = {
.id = UCLASS_DEMO, .id = UCLASS_DEMO,
}; };
int demo_hello(struct device *dev, int ch) int demo_hello(struct udevice *dev, int ch)
{ {
const struct demo_ops *ops = device_get_ops(dev); const struct demo_ops *ops = device_get_ops(dev);
@ -32,7 +32,7 @@ int demo_hello(struct device *dev, int ch)
return ops->hello(dev, ch); return ops->hello(dev, ch);
} }
int demo_status(struct device *dev, int *status) int demo_status(struct udevice *dev, int *status)
{ {
const struct demo_ops *ops = device_get_ops(dev); const struct demo_ops *ops = device_get_ops(dev);
@ -42,7 +42,7 @@ int demo_status(struct device *dev, int *status)
return ops->status(dev, status); return ops->status(dev, status);
} }
int demo_parse_dt(struct device *dev) int demo_parse_dt(struct udevice *dev)
{ {
struct dm_demo_pdata *pdata = dev_get_platdata(dev); struct dm_demo_pdata *pdata = dev_get_platdata(dev);
int dn = dev->of_offset; int dn = dev->of_offset;

View File

@ -17,11 +17,11 @@
* or GPIO blocks registered with the GPIO controller. Returns * or GPIO blocks registered with the GPIO controller. Returns
* entry on success, NULL on error. * entry on success, NULL on error.
*/ */
static int gpio_to_device(unsigned int gpio, struct device **devp, static int gpio_to_device(unsigned int gpio, struct udevice **devp,
unsigned int *offset) unsigned int *offset)
{ {
struct gpio_dev_priv *uc_priv; struct gpio_dev_priv *uc_priv;
struct device *dev; struct udevice *dev;
int ret; int ret;
for (ret = uclass_first_device(UCLASS_GPIO, &dev); for (ret = uclass_first_device(UCLASS_GPIO, &dev);
@ -40,11 +40,11 @@ static int gpio_to_device(unsigned int gpio, struct device **devp,
return ret ? ret : -EINVAL; return ret ? ret : -EINVAL;
} }
int gpio_lookup_name(const char *name, struct device **devp, int gpio_lookup_name(const char *name, struct udevice **devp,
unsigned int *offsetp, unsigned int *gpiop) unsigned int *offsetp, unsigned int *gpiop)
{ {
struct gpio_dev_priv *uc_priv; struct gpio_dev_priv *uc_priv;
struct device *dev; struct udevice *dev;
int ret; int ret;
if (devp) if (devp)
@ -86,7 +86,7 @@ int gpio_lookup_name(const char *name, struct device **devp,
int gpio_request(unsigned gpio, const char *label) int gpio_request(unsigned gpio, const char *label)
{ {
unsigned int offset; unsigned int offset;
struct device *dev; struct udevice *dev;
int ret; int ret;
ret = gpio_to_device(gpio, &dev, &offset); ret = gpio_to_device(gpio, &dev, &offset);
@ -110,7 +110,7 @@ int gpio_request(unsigned gpio, const char *label)
int gpio_free(unsigned gpio) int gpio_free(unsigned gpio)
{ {
unsigned int offset; unsigned int offset;
struct device *dev; struct udevice *dev;
int ret; int ret;
ret = gpio_to_device(gpio, &dev, &offset); ret = gpio_to_device(gpio, &dev, &offset);
@ -133,7 +133,7 @@ int gpio_free(unsigned gpio)
int gpio_direction_input(unsigned gpio) int gpio_direction_input(unsigned gpio)
{ {
unsigned int offset; unsigned int offset;
struct device *dev; struct udevice *dev;
int ret; int ret;
ret = gpio_to_device(gpio, &dev, &offset); ret = gpio_to_device(gpio, &dev, &offset);
@ -155,7 +155,7 @@ int gpio_direction_input(unsigned gpio)
int gpio_direction_output(unsigned gpio, int value) int gpio_direction_output(unsigned gpio, int value)
{ {
unsigned int offset; unsigned int offset;
struct device *dev; struct udevice *dev;
int ret; int ret;
ret = gpio_to_device(gpio, &dev, &offset); ret = gpio_to_device(gpio, &dev, &offset);
@ -177,7 +177,7 @@ int gpio_direction_output(unsigned gpio, int value)
int gpio_get_value(unsigned gpio) int gpio_get_value(unsigned gpio)
{ {
unsigned int offset; unsigned int offset;
struct device *dev; struct udevice *dev;
int ret; int ret;
ret = gpio_to_device(gpio, &dev, &offset); ret = gpio_to_device(gpio, &dev, &offset);
@ -199,7 +199,7 @@ int gpio_get_value(unsigned gpio)
int gpio_set_value(unsigned gpio, int value) int gpio_set_value(unsigned gpio, int value)
{ {
unsigned int offset; unsigned int offset;
struct device *dev; struct udevice *dev;
int ret; int ret;
ret = gpio_to_device(gpio, &dev, &offset); ret = gpio_to_device(gpio, &dev, &offset);
@ -209,7 +209,7 @@ int gpio_set_value(unsigned gpio, int value)
return gpio_get_ops(dev)->set_value(dev, offset, value); return gpio_get_ops(dev)->set_value(dev, offset, value);
} }
const char *gpio_get_bank_info(struct device *dev, int *bit_count) const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)
{ {
struct gpio_dev_priv *priv; struct gpio_dev_priv *priv;
@ -225,7 +225,7 @@ const char *gpio_get_bank_info(struct device *dev, int *bit_count)
static int gpio_renumber(void) static int gpio_renumber(void)
{ {
struct gpio_dev_priv *uc_priv; struct gpio_dev_priv *uc_priv;
struct device *dev; struct udevice *dev;
struct uclass *uc; struct uclass *uc;
unsigned base; unsigned base;
int ret; int ret;
@ -247,12 +247,12 @@ static int gpio_renumber(void)
return 0; return 0;
} }
static int gpio_post_probe(struct device *dev) static int gpio_post_probe(struct udevice *dev)
{ {
return gpio_renumber(); return gpio_renumber();
} }
static int gpio_pre_remove(struct device *dev) static int gpio_pre_remove(struct udevice *dev)
{ {
return gpio_renumber(); return gpio_renumber();
} }

View File

@ -22,7 +22,7 @@ struct gpio_state {
}; };
/* Access routines for GPIO state */ /* Access routines for GPIO state */
static u8 *get_gpio_flags(struct device *dev, unsigned offset) static u8 *get_gpio_flags(struct udevice *dev, unsigned offset)
{ {
struct gpio_dev_priv *uc_priv = dev->uclass_priv; struct gpio_dev_priv *uc_priv = dev->uclass_priv;
struct gpio_state *state = dev_get_priv(dev); struct gpio_state *state = dev_get_priv(dev);
@ -36,12 +36,12 @@ static u8 *get_gpio_flags(struct device *dev, unsigned offset)
return &state[offset].flags; return &state[offset].flags;
} }
static int get_gpio_flag(struct device *dev, unsigned offset, int flag) static int get_gpio_flag(struct udevice *dev, unsigned offset, int flag)
{ {
return (*get_gpio_flags(dev, offset) & flag) != 0; return (*get_gpio_flags(dev, offset) & flag) != 0;
} }
static int set_gpio_flag(struct device *dev, unsigned offset, int flag, static int set_gpio_flag(struct udevice *dev, unsigned offset, int flag,
int value) int value)
{ {
u8 *gpio = get_gpio_flags(dev, offset); u8 *gpio = get_gpio_flags(dev, offset);
@ -54,7 +54,7 @@ static int set_gpio_flag(struct device *dev, unsigned offset, int flag,
return 0; return 0;
} }
static int check_reserved(struct device *dev, unsigned offset, static int check_reserved(struct udevice *dev, unsigned offset,
const char *func) const char *func)
{ {
if (!get_gpio_flag(dev, offset, GPIOF_RESERVED)) { if (!get_gpio_flag(dev, offset, GPIOF_RESERVED)) {
@ -70,24 +70,24 @@ static int check_reserved(struct device *dev, unsigned offset,
* Back-channel sandbox-internal-only access to GPIO state * Back-channel sandbox-internal-only access to GPIO state
*/ */
int sandbox_gpio_get_value(struct device *dev, unsigned offset) int sandbox_gpio_get_value(struct udevice *dev, unsigned offset)
{ {
if (get_gpio_flag(dev, offset, GPIOF_OUTPUT)) if (get_gpio_flag(dev, offset, GPIOF_OUTPUT))
debug("sandbox_gpio: get_value on output gpio %u\n", offset); debug("sandbox_gpio: get_value on output gpio %u\n", offset);
return get_gpio_flag(dev, offset, GPIOF_HIGH); return get_gpio_flag(dev, offset, GPIOF_HIGH);
} }
int sandbox_gpio_set_value(struct device *dev, unsigned offset, int value) int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value)
{ {
return set_gpio_flag(dev, offset, GPIOF_HIGH, value); return set_gpio_flag(dev, offset, GPIOF_HIGH, value);
} }
int sandbox_gpio_get_direction(struct device *dev, unsigned offset) int sandbox_gpio_get_direction(struct udevice *dev, unsigned offset)
{ {
return get_gpio_flag(dev, offset, GPIOF_OUTPUT); return get_gpio_flag(dev, offset, GPIOF_OUTPUT);
} }
int sandbox_gpio_set_direction(struct device *dev, unsigned offset, int output) int sandbox_gpio_set_direction(struct udevice *dev, unsigned offset, int output)
{ {
return set_gpio_flag(dev, offset, GPIOF_OUTPUT, output); return set_gpio_flag(dev, offset, GPIOF_OUTPUT, output);
} }
@ -97,7 +97,7 @@ int sandbox_gpio_set_direction(struct device *dev, unsigned offset, int output)
*/ */
/* set GPIO port 'offset' as an input */ /* set GPIO port 'offset' as an input */
static int sb_gpio_direction_input(struct device *dev, unsigned offset) static int sb_gpio_direction_input(struct udevice *dev, unsigned offset)
{ {
debug("%s: offset:%u\n", __func__, offset); debug("%s: offset:%u\n", __func__, offset);
@ -108,7 +108,7 @@ static int sb_gpio_direction_input(struct device *dev, unsigned offset)
} }
/* set GPIO port 'offset' as an output, with polarity 'value' */ /* set GPIO port 'offset' as an output, with polarity 'value' */
static int sb_gpio_direction_output(struct device *dev, unsigned offset, static int sb_gpio_direction_output(struct udevice *dev, unsigned offset,
int value) int value)
{ {
debug("%s: offset:%u, value = %d\n", __func__, offset, value); debug("%s: offset:%u, value = %d\n", __func__, offset, value);
@ -121,7 +121,7 @@ static int sb_gpio_direction_output(struct device *dev, unsigned offset,
} }
/* read GPIO IN value of port 'offset' */ /* read GPIO IN value of port 'offset' */
static int sb_gpio_get_value(struct device *dev, unsigned offset) static int sb_gpio_get_value(struct udevice *dev, unsigned offset)
{ {
debug("%s: offset:%u\n", __func__, offset); debug("%s: offset:%u\n", __func__, offset);
@ -132,7 +132,7 @@ static int sb_gpio_get_value(struct device *dev, unsigned offset)
} }
/* write GPIO OUT value to port 'offset' */ /* write GPIO OUT value to port 'offset' */
static int sb_gpio_set_value(struct device *dev, unsigned offset, int value) static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value)
{ {
debug("%s: offset:%u, value = %d\n", __func__, offset, value); debug("%s: offset:%u, value = %d\n", __func__, offset, value);
@ -148,7 +148,7 @@ static int sb_gpio_set_value(struct device *dev, unsigned offset, int value)
return sandbox_gpio_set_value(dev, offset, value); return sandbox_gpio_set_value(dev, offset, value);
} }
static int sb_gpio_request(struct device *dev, unsigned offset, static int sb_gpio_request(struct udevice *dev, unsigned offset,
const char *label) const char *label)
{ {
struct gpio_dev_priv *uc_priv = dev->uclass_priv; struct gpio_dev_priv *uc_priv = dev->uclass_priv;
@ -171,7 +171,7 @@ static int sb_gpio_request(struct device *dev, unsigned offset,
return set_gpio_flag(dev, offset, GPIOF_RESERVED, 1); return set_gpio_flag(dev, offset, GPIOF_RESERVED, 1);
} }
static int sb_gpio_free(struct device *dev, unsigned offset) static int sb_gpio_free(struct udevice *dev, unsigned offset)
{ {
struct gpio_state *state = dev_get_priv(dev); struct gpio_state *state = dev_get_priv(dev);
@ -184,7 +184,7 @@ static int sb_gpio_free(struct device *dev, unsigned offset)
return set_gpio_flag(dev, offset, GPIOF_RESERVED, 0); return set_gpio_flag(dev, offset, GPIOF_RESERVED, 0);
} }
static int sb_gpio_get_state(struct device *dev, unsigned int offset, static int sb_gpio_get_state(struct udevice *dev, unsigned int offset,
char *buf, int bufsize) char *buf, int bufsize)
{ {
struct gpio_dev_priv *uc_priv = dev->uclass_priv; struct gpio_dev_priv *uc_priv = dev->uclass_priv;
@ -213,7 +213,7 @@ static const struct dm_gpio_ops gpio_sandbox_ops = {
.get_state = sb_gpio_get_state, .get_state = sb_gpio_get_state,
}; };
static int sandbox_gpio_ofdata_to_platdata(struct device *dev) static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev)
{ {
struct gpio_dev_priv *uc_priv = dev->uclass_priv; struct gpio_dev_priv *uc_priv = dev->uclass_priv;
@ -225,7 +225,7 @@ static int sandbox_gpio_ofdata_to_platdata(struct device *dev)
return 0; return 0;
} }
static int gpio_sandbox_probe(struct device *dev) static int gpio_sandbox_probe(struct udevice *dev)
{ {
struct gpio_dev_priv *uc_priv = dev->uclass_priv; struct gpio_dev_priv *uc_priv = dev->uclass_priv;

View File

@ -65,7 +65,7 @@ typedef struct global_data {
struct global_data *new_gd; /* relocated global data */ struct global_data *new_gd; /* relocated global data */
#ifdef CONFIG_DM #ifdef CONFIG_DM
struct device *dm_root; /* Root instance for Driver Model */ struct udevice *dm_root;/* Root instance for Driver Model */
struct list_head uclass_root; /* Head of core tree */ struct list_head uclass_root; /* Head of core tree */
#endif #endif

View File

@ -86,7 +86,7 @@ enum {
GPIOF_UNKNOWN, GPIOF_UNKNOWN,
}; };
struct device; struct udevice;
/** /**
* struct struct dm_gpio_ops - Driver model GPIO operations * struct struct dm_gpio_ops - Driver model GPIO operations
@ -116,15 +116,15 @@ struct device;
* all devices. Be careful not to confuse offset with gpio in the parameters. * all devices. Be careful not to confuse offset with gpio in the parameters.
*/ */
struct dm_gpio_ops { struct dm_gpio_ops {
int (*request)(struct device *dev, unsigned offset, const char *label); int (*request)(struct udevice *dev, unsigned offset, const char *label);
int (*free)(struct device *dev, unsigned offset); int (*free)(struct udevice *dev, unsigned offset);
int (*direction_input)(struct device *dev, unsigned offset); int (*direction_input)(struct udevice *dev, unsigned offset);
int (*direction_output)(struct device *dev, unsigned offset, int (*direction_output)(struct udevice *dev, unsigned offset,
int value); int value);
int (*get_value)(struct device *dev, unsigned offset); int (*get_value)(struct udevice *dev, unsigned offset);
int (*set_value)(struct device *dev, unsigned offset, int value); int (*set_value)(struct udevice *dev, unsigned offset, int value);
int (*get_function)(struct device *dev, unsigned offset); int (*get_function)(struct udevice *dev, unsigned offset);
int (*get_state)(struct device *dev, unsigned offset, char *state, int (*get_state)(struct udevice *dev, unsigned offset, char *state,
int maxlen); int maxlen);
}; };
@ -166,7 +166,7 @@ struct gpio_dev_priv {
* @offset_count: Returns number of GPIOs within this bank * @offset_count: Returns number of GPIOs within this bank
* @return bank name of this device * @return bank name of this device
*/ */
const char *gpio_get_bank_info(struct device *dev, int *offset_count); const char *gpio_get_bank_info(struct udevice *dev, int *offset_count);
/** /**
* gpio_lookup_name - Look up a GPIO name and return its details * gpio_lookup_name - Look up a GPIO name and return its details
@ -179,7 +179,7 @@ const char *gpio_get_bank_info(struct device *dev, int *offset_count);
* @offsetp: Returns the offset number within this device * @offsetp: Returns the offset number within this device
* @gpiop: Returns the absolute GPIO number, numbered from 0 * @gpiop: Returns the absolute GPIO number, numbered from 0
*/ */
int gpio_lookup_name(const char *name, struct device **devp, int gpio_lookup_name(const char *name, struct udevice **devp,
unsigned int *offsetp, unsigned int *gpiop); unsigned int *offsetp, unsigned int *gpiop);
#endif /* _ASM_GENERIC_GPIO_H_ */ #endif /* _ASM_GENERIC_GPIO_H_ */

View File

@ -23,14 +23,14 @@ struct dm_demo_pdata {
}; };
struct demo_ops { struct demo_ops {
int (*hello)(struct device *dev, int ch); int (*hello)(struct udevice *dev, int ch);
int (*status)(struct device *dev, int *status); int (*status)(struct udevice *dev, int *status);
}; };
int demo_hello(struct device *dev, int ch); int demo_hello(struct udevice *dev, int ch);
int demo_status(struct device *dev, int *status); int demo_status(struct udevice *dev, int *status);
int demo_list(void); int demo_list(void);
int demo_parse_dt(struct device *dev); int demo_parse_dt(struct udevice *dev);
#endif #endif

View File

@ -11,7 +11,7 @@
#ifndef _DM_DEVICE_INTERNAL_H #ifndef _DM_DEVICE_INTERNAL_H
#define _DM_DEVICE_INTERNAL_H #define _DM_DEVICE_INTERNAL_H
struct device; struct udevice;
/** /**
* device_bind() - Create a device and bind it to a driver * device_bind() - Create a device and bind it to a driver
@ -34,9 +34,9 @@ struct device;
* @devp: Returns a pointer to the bound device * @devp: Returns a pointer to the bound device
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int device_bind(struct device *parent, struct driver *drv, int device_bind(struct udevice *parent, struct driver *drv,
const char *name, void *platdata, int of_offset, const char *name, void *platdata, int of_offset,
struct device **devp); struct udevice **devp);
/** /**
* device_bind_by_name: Create a device and bind it to a driver * device_bind_by_name: Create a device and bind it to a driver
@ -49,8 +49,8 @@ int device_bind(struct device *parent, struct driver *drv,
* @devp: Returns a pointer to the bound device * @devp: Returns a pointer to the bound device
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int device_bind_by_name(struct device *parent, const struct driver_info *info, int device_bind_by_name(struct udevice *parent, const struct driver_info *info,
struct device **devp); struct udevice **devp);
/** /**
* device_probe() - Probe a device, activating it * device_probe() - Probe a device, activating it
@ -61,7 +61,7 @@ int device_bind_by_name(struct device *parent, const struct driver_info *info,
* @dev: Pointer to device to probe * @dev: Pointer to device to probe
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int device_probe(struct device *dev); int device_probe(struct udevice *dev);
/** /**
* device_remove() - Remove a device, de-activating it * device_remove() - Remove a device, de-activating it
@ -72,7 +72,7 @@ int device_probe(struct device *dev);
* @dev: Pointer to device to remove * @dev: Pointer to device to remove
* @return 0 if OK, -ve on error (an error here is normally a very bad thing) * @return 0 if OK, -ve on error (an error here is normally a very bad thing)
*/ */
int device_remove(struct device *dev); int device_remove(struct udevice *dev);
/** /**
* device_unbind() - Unbind a device, destroying it * device_unbind() - Unbind a device, destroying it
@ -82,6 +82,6 @@ int device_remove(struct device *dev);
* @dev: Pointer to device to unbind * @dev: Pointer to device to unbind
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int device_unbind(struct device *dev); int device_unbind(struct udevice *dev);
#endif #endif

View File

@ -24,7 +24,7 @@ struct driver_info;
#define DM_FLAG_ALLOC_PDATA (2 << 0) #define DM_FLAG_ALLOC_PDATA (2 << 0)
/** /**
* struct device - An instance of a driver * struct udevice - An instance of a driver
* *
* This holds information about a device, which is a driver bound to a * This holds information about a device, which is a driver bound to a
* particular port or peripheral (essentially a driver instance). * particular port or peripheral (essentially a driver instance).
@ -53,12 +53,12 @@ struct driver_info;
* @sibling_node: Next device in list of all devices * @sibling_node: Next device in list of all devices
* @flags: Flags for this device DM_FLAG_... * @flags: Flags for this device DM_FLAG_...
*/ */
struct device { struct udevice {
struct driver *driver; struct driver *driver;
const char *name; const char *name;
void *platdata; void *platdata;
int of_offset; int of_offset;
struct device *parent; struct udevice *parent;
void *priv; void *priv;
struct uclass *uclass; struct uclass *uclass;
void *uclass_priv; void *uclass_priv;
@ -122,11 +122,11 @@ struct driver {
char *name; char *name;
enum uclass_id id; enum uclass_id id;
const struct device_id *of_match; const struct device_id *of_match;
int (*bind)(struct device *dev); int (*bind)(struct udevice *dev);
int (*probe)(struct device *dev); int (*probe)(struct udevice *dev);
int (*remove)(struct device *dev); int (*remove)(struct udevice *dev);
int (*unbind)(struct device *dev); int (*unbind)(struct udevice *dev);
int (*ofdata_to_platdata)(struct device *dev); int (*ofdata_to_platdata)(struct udevice *dev);
int priv_auto_alloc_size; int priv_auto_alloc_size;
int platdata_auto_alloc_size; int platdata_auto_alloc_size;
const void *ops; /* driver-specific operations */ const void *ops; /* driver-specific operations */
@ -144,7 +144,7 @@ struct driver {
* @dev Device to check * @dev Device to check
* @return platform data, or NULL if none * @return platform data, or NULL if none
*/ */
void *dev_get_platdata(struct device *dev); void *dev_get_platdata(struct udevice *dev);
/** /**
* dev_get_priv() - Get the private data for a device * dev_get_priv() - Get the private data for a device
@ -154,6 +154,6 @@ void *dev_get_platdata(struct device *dev);
* @dev Device to check * @dev Device to check
* @return private data, or NULL if none * @return private data, or NULL if none
*/ */
void *dev_get_priv(struct device *dev); void *dev_get_priv(struct udevice *dev);
#endif #endif

View File

@ -32,8 +32,8 @@ struct driver *lists_driver_lookup_name(const char *name);
*/ */
struct uclass_driver *lists_uclass_lookup(enum uclass_id id); struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
int lists_bind_drivers(struct device *parent); int lists_bind_drivers(struct udevice *parent);
int lists_bind_fdt(struct device *parent, const void *blob, int offset); int lists_bind_fdt(struct udevice *parent, const void *blob, int offset);
#endif #endif

View File

@ -10,7 +10,7 @@
#ifndef _DM_ROOT_H_ #ifndef _DM_ROOT_H_
#define _DM_ROOT_H_ #define _DM_ROOT_H_
struct device; struct udevice;
/** /**
* dm_root() - Return pointer to the top of the driver tree * dm_root() - Return pointer to the top of the driver tree
@ -19,7 +19,7 @@ struct device;
* *
* @return pointer to root device, or NULL if not inited yet * @return pointer to root device, or NULL if not inited yet
*/ */
struct device *dm_root(void); struct udevice *dm_root(void);
/** /**
* dm_scan_platdata() - Scan all platform data and bind drivers * dm_scan_platdata() - Scan all platform data and bind drivers

View File

@ -30,7 +30,7 @@ struct dm_test_pdata {
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
struct test_ops { struct test_ops {
int (*ping)(struct device *dev, int pingval, int *pingret); int (*ping)(struct udevice *dev, int pingval, int *pingret);
}; };
/* Operations that our test driver supports */ /* Operations that our test driver supports */
@ -102,8 +102,8 @@ extern struct dm_test_state global_test_state;
* @skip_post_probe: Skip uclass post-probe processing * @skip_post_probe: Skip uclass post-probe processing
*/ */
struct dm_test_state { struct dm_test_state {
struct device *root; struct udevice *root;
struct device *testdev; struct udevice *testdev;
int fail_count; int fail_count;
int force_fail_alloc; int force_fail_alloc;
int skip_post_probe; int skip_post_probe;
@ -138,8 +138,8 @@ struct dm_test {
} }
/* Declare ping methods for the drivers */ /* Declare ping methods for the drivers */
int test_ping(struct device *dev, int pingval, int *pingret); int test_ping(struct udevice *dev, int pingval, int *pingret);
int testfdt_ping(struct device *dev, int pingval, int *pingret); int testfdt_ping(struct udevice *dev, int pingval, int *pingret);
/** /**
* dm_check_operations() - Check that we can perform ping operations * dm_check_operations() - Check that we can perform ping operations
@ -152,7 +152,7 @@ int testfdt_ping(struct device *dev, int pingval, int *pingret);
* @priv: Pointer to private test information * @priv: Pointer to private test information
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int dm_check_operations(struct dm_test_state *dms, struct device *dev, int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
uint32_t base, struct dm_test_priv *priv); uint32_t base, struct dm_test_priv *priv);
/** /**

View File

@ -21,7 +21,7 @@
* @return the uclass pointer of a child at the given index or * @return the uclass pointer of a child at the given index or
* return NULL on error. * return NULL on error.
*/ */
int uclass_find_device(enum uclass_id id, int index, struct device **devp); int uclass_find_device(enum uclass_id id, int index, struct udevice **devp);
/** /**
* uclass_bind_device() - Associate device with a uclass * uclass_bind_device() - Associate device with a uclass
@ -31,7 +31,7 @@ int uclass_find_device(enum uclass_id id, int index, struct device **devp);
* @dev: Pointer to the device * @dev: Pointer to the device
* #return 0 on success, -ve on error * #return 0 on success, -ve on error
*/ */
int uclass_bind_device(struct device *dev); int uclass_bind_device(struct udevice *dev);
/** /**
* uclass_unbind_device() - Deassociate device with a uclass * uclass_unbind_device() - Deassociate device with a uclass
@ -41,7 +41,7 @@ int uclass_bind_device(struct device *dev);
* @dev: Pointer to the device * @dev: Pointer to the device
* #return 0 on success, -ve on error * #return 0 on success, -ve on error
*/ */
int uclass_unbind_device(struct device *dev); int uclass_unbind_device(struct udevice *dev);
/** /**
* uclass_post_probe_device() - Deal with a device that has just been probed * uclass_post_probe_device() - Deal with a device that has just been probed
@ -52,7 +52,7 @@ int uclass_unbind_device(struct device *dev);
* @dev: Pointer to the device * @dev: Pointer to the device
* #return 0 on success, -ve on error * #return 0 on success, -ve on error
*/ */
int uclass_post_probe_device(struct device *dev); int uclass_post_probe_device(struct udevice *dev);
/** /**
* uclass_pre_remove_device() - Handle a device which is about to be removed * uclass_pre_remove_device() - Handle a device which is about to be removed
@ -62,7 +62,7 @@ int uclass_post_probe_device(struct device *dev);
* @dev: Pointer to the device * @dev: Pointer to the device
* #return 0 on success, -ve on error * #return 0 on success, -ve on error
*/ */
int uclass_pre_remove_device(struct device *dev); int uclass_pre_remove_device(struct udevice *dev);
/** /**
* uclass_find() - Find uclass by its id * uclass_find() - Find uclass by its id

View File

@ -37,7 +37,7 @@ struct uclass {
struct list_head sibling_node; struct list_head sibling_node;
}; };
struct device; struct udevice;
/** /**
* struct uclass_driver - Driver for the uclass * struct uclass_driver - Driver for the uclass
@ -65,10 +65,10 @@ struct device;
struct uclass_driver { struct uclass_driver {
const char *name; const char *name;
enum uclass_id id; enum uclass_id id;
int (*post_bind)(struct device *dev); int (*post_bind)(struct udevice *dev);
int (*pre_unbind)(struct device *dev); int (*pre_unbind)(struct udevice *dev);
int (*post_probe)(struct device *dev); int (*post_probe)(struct udevice *dev);
int (*pre_remove)(struct device *dev); int (*pre_remove)(struct udevice *dev);
int (*init)(struct uclass *class); int (*init)(struct uclass *class);
int (*destroy)(struct uclass *class); int (*destroy)(struct uclass *class);
int priv_auto_alloc_size; int priv_auto_alloc_size;
@ -101,7 +101,7 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
* @ucp: Returns pointer to uclass (there is only one per for each ID) * @ucp: Returns pointer to uclass (there is only one per for each ID)
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int uclass_get_device(enum uclass_id id, int index, struct device **ucp); int uclass_get_device(enum uclass_id id, int index, struct udevice **ucp);
/** /**
* uclass_first_device() - Get the first device in a uclass * uclass_first_device() - Get the first device in a uclass
@ -110,7 +110,7 @@ int uclass_get_device(enum uclass_id id, int index, struct device **ucp);
* @devp: Returns pointer to the first device in that uclass, or NULL if none * @devp: Returns pointer to the first device in that uclass, or NULL if none
* @return 0 if OK (found or not found), -1 on error * @return 0 if OK (found or not found), -1 on error
*/ */
int uclass_first_device(enum uclass_id id, struct device **devp); int uclass_first_device(enum uclass_id id, struct udevice **devp);
/** /**
* uclass_next_device() - Get the next device in a uclass * uclass_next_device() - Get the next device in a uclass
@ -119,7 +119,7 @@ int uclass_first_device(enum uclass_id id, struct device **devp);
* to the next device in the same uclass, or NULL if none * to the next device in the same uclass, or NULL if none
* @return 0 if OK (found or not found), -1 on error * @return 0 if OK (found or not found), -1 on error
*/ */
int uclass_next_device(struct device **devp); int uclass_next_device(struct udevice **devp);
/** /**
* uclass_foreach_dev() - Helper function to iteration through devices * uclass_foreach_dev() - Helper function to iteration through devices
@ -127,7 +127,7 @@ int uclass_next_device(struct device **devp);
* This creates a for() loop which works through the available devices in * This creates a for() loop which works through the available devices in
* a uclass in order from start to end. * a uclass in order from start to end.
* *
* @pos: struct device * to hold the current device. Set to NULL when there * @pos: struct udevice * to hold the current device. Set to NULL when there
* are no more devices. * are no more devices.
* uc: uclass to scan * uc: uclass to scan
*/ */

View File

@ -16,12 +16,12 @@
#include <dm/test.h> #include <dm/test.h>
#include <dm/uclass-internal.h> #include <dm/uclass-internal.h>
static int display_succ(struct device *in, char *buf) static int display_succ(struct udevice *in, char *buf)
{ {
int len; int len;
int ip = 0; int ip = 0;
char local[16]; char local[16];
struct device *pos, *n, *prev = NULL; struct udevice *pos, *n, *prev = NULL;
printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in)); printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in));
if (in->flags & DM_FLAG_ACTIVATED) if (in->flags & DM_FLAG_ACTIVATED)
@ -49,7 +49,7 @@ static int display_succ(struct device *in, char *buf)
return 0; return 0;
} }
static int dm_dump(struct device *dev) static int dm_dump(struct udevice *dev)
{ {
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
@ -59,7 +59,7 @@ static int dm_dump(struct device *dev)
static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc, static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[]) char * const argv[])
{ {
struct device *root; struct udevice *root;
root = dm_root(); root = dm_root();
printf("ROOT %08x\n", map_to_sysmem(root)); printf("ROOT %08x\n", map_to_sysmem(root));
@ -74,7 +74,7 @@ static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
int id; int id;
for (id = 0; id < UCLASS_COUNT; id++) { for (id = 0; id < UCLASS_COUNT; id++) {
struct device *dev; struct udevice *dev;
ret = uclass_get(id, &uc); ret = uclass_get(id, &uc);
if (ret) if (ret)

View File

@ -60,7 +60,7 @@ static struct driver_info driver_info_manual = {
/* Test that binding with platdata occurs correctly */ /* Test that binding with platdata occurs correctly */
static int dm_test_autobind(struct dm_test_state *dms) static int dm_test_autobind(struct dm_test_state *dms)
{ {
struct device *dev; struct udevice *dev;
/* /*
* We should have a single class (UCLASS_ROOT) and a single root * We should have a single class (UCLASS_ROOT) and a single root
@ -95,7 +95,7 @@ DM_TEST(dm_test_autobind, 0);
static int dm_test_autoprobe(struct dm_test_state *dms) static int dm_test_autoprobe(struct dm_test_state *dms)
{ {
int expected_base_add; int expected_base_add;
struct device *dev; struct udevice *dev;
struct uclass *uc; struct uclass *uc;
int i; int i;
@ -157,7 +157,7 @@ DM_TEST(dm_test_autoprobe, DM_TESTF_SCAN_PDATA);
static int dm_test_platdata(struct dm_test_state *dms) static int dm_test_platdata(struct dm_test_state *dms)
{ {
const struct dm_test_pdata *pdata; const struct dm_test_pdata *pdata;
struct device *dev; struct udevice *dev;
int i; int i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@ -175,7 +175,7 @@ DM_TEST(dm_test_platdata, DM_TESTF_SCAN_PDATA);
static int dm_test_lifecycle(struct dm_test_state *dms) static int dm_test_lifecycle(struct dm_test_state *dms)
{ {
int op_count[DM_TEST_OP_COUNT]; int op_count[DM_TEST_OP_COUNT];
struct device *dev, *test_dev; struct udevice *dev, *test_dev;
int pingret; int pingret;
int ret; int ret;
@ -229,7 +229,7 @@ DM_TEST(dm_test_lifecycle, DM_TESTF_SCAN_PDATA | DM_TESTF_PROBE_TEST);
/* Test that we can bind/unbind and the lists update correctly */ /* Test that we can bind/unbind and the lists update correctly */
static int dm_test_ordering(struct dm_test_state *dms) static int dm_test_ordering(struct dm_test_state *dms)
{ {
struct device *dev, *dev_penultimate, *dev_last, *test_dev; struct udevice *dev, *dev_penultimate, *dev_last, *test_dev;
int pingret; int pingret;
ut_assertok(device_bind_by_name(dms->root, &driver_info_manual, ut_assertok(device_bind_by_name(dms->root, &driver_info_manual,
@ -281,7 +281,7 @@ static int dm_test_ordering(struct dm_test_state *dms)
DM_TEST(dm_test_ordering, DM_TESTF_SCAN_PDATA); DM_TEST(dm_test_ordering, DM_TESTF_SCAN_PDATA);
/* Check that we can perform operations on a device (do a ping) */ /* Check that we can perform operations on a device (do a ping) */
int dm_check_operations(struct dm_test_state *dms, struct device *dev, int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
uint32_t base, struct dm_test_priv *priv) uint32_t base, struct dm_test_priv *priv)
{ {
int expected; int expected;
@ -311,7 +311,7 @@ int dm_check_operations(struct dm_test_state *dms, struct device *dev,
/* Check that we can perform operations on devices */ /* Check that we can perform operations on devices */
static int dm_test_operations(struct dm_test_state *dms) static int dm_test_operations(struct dm_test_state *dms)
{ {
struct device *dev; struct udevice *dev;
int i; int i;
/* /*
@ -341,7 +341,7 @@ DM_TEST(dm_test_operations, DM_TESTF_SCAN_PDATA);
/* Remove all drivers and check that things work */ /* Remove all drivers and check that things work */
static int dm_test_remove(struct dm_test_state *dms) static int dm_test_remove(struct dm_test_state *dms)
{ {
struct device *dev; struct udevice *dev;
int i; int i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@ -367,7 +367,7 @@ static int dm_test_leak(struct dm_test_state *dms)
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
struct mallinfo start, end; struct mallinfo start, end;
struct device *dev; struct udevice *dev;
int ret; int ret;
int id; int id;
@ -435,10 +435,10 @@ DM_TEST(dm_test_uclass, 0);
* this array. * this array.
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
static int create_children(struct dm_test_state *dms, struct device *parent, static int create_children(struct dm_test_state *dms, struct udevice *parent,
int count, int key, struct device *child[]) int count, int key, struct udevice *child[])
{ {
struct device *dev; struct udevice *dev;
int i; int i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@ -460,10 +460,10 @@ static int create_children(struct dm_test_state *dms, struct device *parent,
static int dm_test_children(struct dm_test_state *dms) static int dm_test_children(struct dm_test_state *dms)
{ {
struct device *top[NODE_COUNT]; struct udevice *top[NODE_COUNT];
struct device *child[NODE_COUNT]; struct udevice *child[NODE_COUNT];
struct device *grandchild[NODE_COUNT]; struct udevice *grandchild[NODE_COUNT];
struct device *dev; struct udevice *dev;
int total; int total;
int ret; int ret;
int i; int i;

View File

@ -17,7 +17,7 @@ static int dm_test_gpio(struct dm_test_state *dms)
{ {
unsigned int offset, gpio; unsigned int offset, gpio;
struct dm_gpio_ops *ops; struct dm_gpio_ops *ops;
struct device *dev; struct udevice *dev;
const char *name; const char *name;
int offset_count; int offset_count;
char buf[80]; char buf[80];

View File

@ -18,7 +18,7 @@
int dm_testdrv_op_count[DM_TEST_OP_COUNT]; int dm_testdrv_op_count[DM_TEST_OP_COUNT];
static struct dm_test_state *dms = &global_test_state; static struct dm_test_state *dms = &global_test_state;
static int testdrv_ping(struct device *dev, int pingval, int *pingret) static int testdrv_ping(struct udevice *dev, int pingval, int *pingret)
{ {
const struct dm_test_pdata *pdata = dev_get_platdata(dev); 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);
@ -33,7 +33,7 @@ static const struct test_ops test_ops = {
.ping = testdrv_ping, .ping = testdrv_ping,
}; };
static int test_bind(struct device *dev) static int test_bind(struct udevice *dev)
{ {
/* Private data should not be allocated */ /* Private data should not be allocated */
ut_assert(!dev_get_priv(dev)); ut_assert(!dev_get_priv(dev));
@ -42,7 +42,7 @@ static int test_bind(struct device *dev)
return 0; return 0;
} }
static int test_probe(struct device *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);
@ -54,7 +54,7 @@ static int test_probe(struct device *dev)
return 0; return 0;
} }
static int test_remove(struct device *dev) static int test_remove(struct udevice *dev)
{ {
/* Private data should still be allocated */ /* Private data should still be allocated */
ut_assert(dev_get_priv(dev)); ut_assert(dev_get_priv(dev));
@ -63,7 +63,7 @@ static int test_remove(struct device *dev)
return 0; return 0;
} }
static int test_unbind(struct device *dev) static int test_unbind(struct udevice *dev)
{ {
/* Private data should not be allocated */ /* Private data should not be allocated */
ut_assert(!dev->priv); ut_assert(!dev->priv);
@ -94,7 +94,7 @@ U_BOOT_DRIVER(test2_drv) = {
.priv_auto_alloc_size = sizeof(struct dm_test_priv), .priv_auto_alloc_size = sizeof(struct dm_test_priv),
}; };
static int test_manual_drv_ping(struct device *dev, int pingval, int *pingret) static int test_manual_drv_ping(struct udevice *dev, int pingval, int *pingret)
{ {
*pingret = pingval + 2; *pingret = pingval + 2;
@ -105,14 +105,14 @@ static const struct test_ops test_manual_ops = {
.ping = test_manual_drv_ping, .ping = test_manual_drv_ping,
}; };
static int test_manual_bind(struct device *dev) static int test_manual_bind(struct udevice *dev)
{ {
dm_testdrv_op_count[DM_TEST_OP_BIND]++; dm_testdrv_op_count[DM_TEST_OP_BIND]++;
return 0; return 0;
} }
static int test_manual_probe(struct device *dev) static int test_manual_probe(struct udevice *dev)
{ {
dm_testdrv_op_count[DM_TEST_OP_PROBE]++; dm_testdrv_op_count[DM_TEST_OP_PROBE]++;
if (!dms->force_fail_alloc) if (!dms->force_fail_alloc)
@ -123,13 +123,13 @@ static int test_manual_probe(struct device *dev)
return 0; return 0;
} }
static int test_manual_remove(struct device *dev) static int test_manual_remove(struct udevice *dev)
{ {
dm_testdrv_op_count[DM_TEST_OP_REMOVE]++; dm_testdrv_op_count[DM_TEST_OP_REMOVE]++;
return 0; return 0;
} }
static int test_manual_unbind(struct device *dev) static int test_manual_unbind(struct udevice *dev)
{ {
dm_testdrv_op_count[DM_TEST_OP_UNBIND]++; dm_testdrv_op_count[DM_TEST_OP_UNBIND]++;
return 0; return 0;

View File

@ -18,7 +18,7 @@
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
static int testfdt_drv_ping(struct device *dev, int pingval, int *pingret) static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret)
{ {
const struct dm_test_pdata *pdata = dev->platdata; 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);
@ -33,7 +33,7 @@ static const struct test_ops test_ops = {
.ping = testfdt_drv_ping, .ping = testfdt_drv_ping,
}; };
static int testfdt_ofdata_to_platdata(struct device *dev) static int testfdt_ofdata_to_platdata(struct udevice *dev)
{ {
struct dm_test_pdata *pdata = dev_get_platdata(dev); struct dm_test_pdata *pdata = dev_get_platdata(dev);
@ -44,7 +44,7 @@ static int testfdt_ofdata_to_platdata(struct device *dev)
return 0; return 0;
} }
static int testfdt_drv_probe(struct device *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);
@ -75,7 +75,7 @@ U_BOOT_DRIVER(testfdt_drv) = {
}; };
/* From here is the testfdt uclass code */ /* From here is the testfdt uclass code */
int testfdt_ping(struct device *dev, int pingval, int *pingret) int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
{ {
const struct test_ops *ops = device_get_ops(dev); const struct test_ops *ops = device_get_ops(dev);
@ -94,7 +94,7 @@ UCLASS_DRIVER(testfdt) = {
static int dm_test_fdt(struct dm_test_state *dms) static int dm_test_fdt(struct dm_test_state *dms)
{ {
const int num_drivers = 3; const int num_drivers = 3;
struct device *dev; struct udevice *dev;
struct uclass *uc; struct uclass *uc;
int ret; int ret;
int i; int i;

View File

@ -32,7 +32,7 @@ static int dm_test_init(struct dm_test_state *dms)
/* Ensure all the test devices are probed */ /* Ensure all the test devices are probed */
static int do_autoprobe(struct dm_test_state *dms) static int do_autoprobe(struct dm_test_state *dms)
{ {
struct device *dev; struct udevice *dev;
int ret; int ret;
/* Scanning the uclass is enough to probe all the devices */ /* Scanning the uclass is enough to probe all the devices */

View File

@ -18,7 +18,7 @@
static struct dm_test_state *dms = &global_test_state; static struct dm_test_state *dms = &global_test_state;
int test_ping(struct device *dev, int pingval, int *pingret) int test_ping(struct udevice *dev, int pingval, int *pingret)
{ {
const struct test_ops *ops = device_get_ops(dev); const struct test_ops *ops = device_get_ops(dev);
@ -28,24 +28,25 @@ int test_ping(struct device *dev, int pingval, int *pingret)
return ops->ping(dev, pingval, pingret); return ops->ping(dev, pingval, pingret);
} }
static int test_post_bind(struct device *dev) static int test_post_bind(struct udevice *dev)
{ {
dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++; dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++;
return 0; return 0;
} }
static int test_pre_unbind(struct device *dev) static int test_pre_unbind(struct udevice *dev)
{ {
dm_testdrv_op_count[DM_TEST_OP_PRE_UNBIND]++; dm_testdrv_op_count[DM_TEST_OP_PRE_UNBIND]++;
return 0; return 0;
} }
static int test_post_probe(struct device *dev) static int test_post_probe(struct udevice *dev)
{ {
struct device *prev = list_entry(dev->uclass_node.prev, struct device, struct udevice *prev = list_entry(dev->uclass_node.prev,
uclass_node); struct udevice, uclass_node);
struct dm_test_uclass_perdev_priv *priv = dev->uclass_priv; struct dm_test_uclass_perdev_priv *priv = dev->uclass_priv;
struct uclass *uc = dev->uclass; struct uclass *uc = dev->uclass;
@ -68,7 +69,7 @@ static int test_post_probe(struct device *dev)
return 0; return 0;
} }
static int test_pre_remove(struct device *dev) static int test_pre_remove(struct udevice *dev)
{ {
dm_testdrv_op_count[DM_TEST_OP_PRE_REMOVE]++; dm_testdrv_op_count[DM_TEST_OP_PRE_REMOVE]++;