]> git.sur5r.net Git - u-boot/commitdiff
dm: Cast away the const-ness of the global_data pointer
authorSimon Glass <sjg@chromium.org>
Thu, 12 Jun 2014 05:29:49 +0000 (23:29 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 20 Jun 2014 17:55:49 +0000 (11:55 -0600)
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: Simon Glass <sjg@chromium.org>
drivers/core/root.c
drivers/core/uclass.c
include/dm/device-internal.h

index f31be72cd05dc0e82930130bbbe8a50405ff5121..1cbb096494d2638a57c1a9d7998cda9685054896 100644 (file)
@@ -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;
index f6867e4a23226cf5b7aa631f431da314f256dfc8..34723ec42a75fccca2df41a95c3b5a37ae0ec9d6 100644 (file)
@@ -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);
index ea3df36632d80fc907412e4d5c71771006206d53..26e5cf530ebc8b6bb81ec34c72abc0a4ecd268f2 100644 (file)
@@ -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