Commit 89876a55 authored by Simon Glass's avatar Simon Glass
Browse files

dm: Cast away the const-ness of the global_data pointer



In a very few cases we need to adjust the driver model root device, such as
when setting it up at initialisation. Add a macro to make this easier.
Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent 6a6d8fbe
......@@ -43,9 +43,9 @@ int dm_init(void)
dm_warn("Virtual root driver already exists!\n");
return -EINVAL;
}
INIT_LIST_HEAD(&gd->uclass_root);
INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
ret = device_bind_by_name(NULL, &root_info, &gd->dm_root);
ret = device_bind_by_name(NULL, &root_info, &DM_ROOT_NON_CONST);
if (ret)
return ret;
......@@ -56,7 +56,7 @@ int dm_scan_platdata(void)
{
int ret;
ret = lists_bind_drivers(gd->dm_root);
ret = lists_bind_drivers(DM_ROOT_NON_CONST);
if (ret == -ENOENT) {
dm_warn("Some drivers were not found\n");
ret = 0;
......
......@@ -75,7 +75,7 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
uc->uc_drv = uc_drv;
INIT_LIST_HEAD(&uc->sibling_node);
INIT_LIST_HEAD(&uc->dev_head);
list_add(&uc->sibling_node, &gd->uclass_root);
list_add(&uc->sibling_node, &DM_UCLASS_ROOT_NON_CONST);
if (uc_drv->init) {
ret = uc_drv->init(uc);
......
......@@ -84,4 +84,8 @@ int device_remove(struct udevice *dev);
*/
int device_unbind(struct udevice *dev);
/* Cast away any volatile pointer */
#define DM_ROOT_NON_CONST (((gd_t *)gd)->dm_root)
#define DM_UCLASS_ROOT_NON_CONST (((gd_t *)gd)->uclass_root)
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment