From patchwork Mon May 5 16:09:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 345767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DE05014031F for ; Tue, 6 May 2014 02:11:25 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6ED2A4B82E; Mon, 5 May 2014 18:11:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QrQ91TciCSTf; Mon, 5 May 2014 18:11:04 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6E87E4B841; Mon, 5 May 2014 18:09:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 84A724B826 for ; Mon, 5 May 2014 18:09:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dYW0Hicvu+xH for ; Mon, 5 May 2014 18:09:46 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-vc0-f202.google.com (mail-vc0-f202.google.com [209.85.220.202]) by theia.denx.de (Postfix) with ESMTPS id 21AB84B819 for ; Mon, 5 May 2014 18:09:31 +0200 (CEST) Received: by mail-vc0-f202.google.com with SMTP id if11so148831vcb.5 for ; Mon, 05 May 2014 09:09:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rk20j4rYuTCi+ygs+E6EIXRdyh5TsNcmWQtIeNc6sj8=; b=fqIL8qBgYZ75oKwilzsXV2TOOhRC9PSR8mwxRiyreW16f5XsnI6D68FT6K9SpaKVkD c+Tm02rTEm5nKOTRkw88m38epToM0PgPZawkJk9tKo9FDFFItqN4MpDggdrh9SiL296r y7Mnlyzw6r4WiSYO/TJBrgdpjA4RzWInfsoHbPoF5nLcy+LaBjPjhaoPjH+47z+3Bcgd hkGOJ3sI2gZ2KWPebCCK8rHkA3fJkmBMx2wtU07IWsTd9g3rT7Wrlrf0GIy4GIU1YlqT eJ3LgaU6oiYRkaOuLKHjSyPZxHvw5QRaDHL5eY53BGGtYVplxxF1OiQfIromrP+BMvWz R8YA== X-Gm-Message-State: ALoCoQkUsB/QRwaCjzjgX/VBnPjWUGgFH0nV2ZOrXB4cO/yjg59sNAnCbR7sjaDs7p4eIDfjAf72 X-Received: by 10.236.130.101 with SMTP id j65mr14231257yhi.29.1399306169925; Mon, 05 May 2014 09:09:29 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id c50si378019yhl.7.2014.05.05.09.09.29 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 May 2014 09:09:29 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id C8B465A418D; Mon, 5 May 2014 09:09:29 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 84EBD22260F; Mon, 5 May 2014 10:09:29 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 5 May 2014 10:09:06 -0600 Message-Id: <1399306150-932-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1399306150-932-1-git-send-email-sjg@chromium.org> References: <1399306150-932-1-git-send-email-sjg@chromium.org> Cc: u-boot-review@google.com, Tom Warren Subject: [U-Boot] [RFC PATCH v2 09/13] dm: Case away the const-ness of the global_data pointer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- Changes in v2: - Add new patch to deal with const-ness of the global_data pointer drivers/core/root.c | 6 +++--- drivers/core/uclass.c | 2 +- include/dm/device-internal.h | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/core/root.c b/drivers/core/root.c index 88d2f45..4427b81 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -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()); - ret = device_bind_by_name(NULL, &root_info, &gd->dm_root); + ret = device_bind_by_name(NULL, &root_info, &DM_ROOT()); 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()); if (ret == -ENOENT) { dm_warn("Some drivers were not found\n"); ret = 0; diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 4df5a8b..afb5fdc 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -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()); if (uc_drv->init) { ret = uc_drv->init(uc); diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index c026e8e..e95b7a9 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -84,4 +84,8 @@ int device_remove(struct device *dev); */ int device_unbind(struct device *dev); +/* Cast away any volatile pointer */ +#define DM_ROOT() (((gd_t *)gd)->dm_root) +#define DM_UCLASS_ROOT() (((gd_t *)gd)->uclass_root) + #endif