From patchwork Thu Jun 12 05:29:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 359006 X-Patchwork-Delegate: trini@ti.com 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 D910D1400AB for ; Thu, 12 Jun 2014 15:32:27 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6782D4B8BC; Thu, 12 Jun 2014 07:32:10 +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 ISWRyrc+nsLk; Thu, 12 Jun 2014 07:32:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B89EF4B8E0; Thu, 12 Jun 2014 07:31:07 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 502984B8D0 for ; Thu, 12 Jun 2014 07:30:47 +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 gk80iQYIfqie for ; Thu, 12 Jun 2014 07:30: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-ob0-f202.google.com (mail-ob0-f202.google.com [209.85.214.202]) by theia.denx.de (Postfix) with ESMTPS id 761B74B8AF for ; Thu, 12 Jun 2014 07:30:24 +0200 (CEST) Received: by mail-ob0-f202.google.com with SMTP id va2so170488obc.1 for ; Wed, 11 Jun 2014 22:30:23 -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=baGrMDda/JUCCns1k8hSCPONG5ENm2DGKzpG9y7rNAc=; b=FHwubbER9acW7IJwp8fwXmP4mof0XqUTxiwODnR7XWVFe12TGi926Ssv92y1P0uipp JxlXF5BEeK/zV52CMGffN6mzeba7cKiet30L++AoJtdto4upOc38sSSu9ihUpGxTfLxg e73/073B0t5Ra46HV5q1pqH3ogyqrB4l8iiCdnxzcgRtnsrXGBZAdwrmzfKK3MUkzMGZ PXVJi53xzjSMj6HQ9SE1yOoBHnvMyt3x/zudqNae7xDLZsyd0M1u96gZNAKFJ1rBb7q7 CCf9+ac84hCi6xX8GluVndgwfFcH7tjWPy5F/EYQlXCRq7Y5G0mNQ1u6CI1Wv5bGtfV/ 1lfg== X-Gm-Message-State: ALoCoQnO8saLGCd8aY/Zs0iAYkigjdnqKDN2/LHbVuppKyxyfchm9YP56NMLgSXGdQyz/cnv9iq1 X-Received: by 10.42.83.144 with SMTP id h16mr13504879icl.22.1402551023352; Wed, 11 Jun 2014 22:30:23 -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 c50si1704124yhl.7.2014.06.11.22.30.23 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jun 2014 22:30:23 -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 37F225A4922; Wed, 11 Jun 2014 22:30:23 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 0795A22066A; Wed, 11 Jun 2014 23:30:22 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 11 Jun 2014 23:29:49 -0600 Message-Id: <1402550995-15963-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.0.0.526.g5318336 In-Reply-To: <1402550995-15963-1-git-send-email-sjg@chromium.org> References: <1402550995-15963-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH v6 09/15] dm: Cast 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 v6: - Make DM_ROOT and DM_UCLASS_ROOT simple defines (and rename them) Changes in v5: None Changes in v4: None Changes in v3: - Fix typo in commit subject 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 f31be72..1cbb096 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_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; diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index f6867e4..34723ec 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_NON_CONST); if (uc_drv->init) { ret = uc_drv->init(uc); diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index ea3df36..26e5cf5 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -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