All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 09/15] dm: Cast away the const-ness of the global_data pointer
Date: Tue, 10 Jun 2014 17:53:42 -0600	[thread overview]
Message-ID: <1402444428-11356-10-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1402444428-11356-1-git-send-email-sjg@chromium.org>

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>
---

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..70ea97f 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 f6867e4..d16d6fc 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 ea3df36..67318fa 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()		(((gd_t *)gd)->dm_root)
+#define DM_UCLASS_ROOT()		(((gd_t *)gd)->uclass_root)
+
 #endif
-- 
2.0.0.526.g5318336

  parent reply	other threads:[~2014-06-10 23:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10 23:53 [U-Boot] [PATCH v5 0/15] Collected driver model bug-fixes and docs Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 01/15] Add an I/O tracing feature Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 02/15] arm: Support iotrace feature Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 03/15] sandbox: " Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 04/15] Makefile: Support include files for .dts files Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 05/15] dm: Rename struct device_id to udevice_id Simon Glass
2014-06-11 13:49   ` Jon Loeliger
2014-06-11 16:12     ` Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 06/15] dm: Update README to encourage conversion to driver model Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 07/15] dm: Use case-insensitive comparison for GPIO banks Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 08/15] dm: Add missing header files in lists and root Simon Glass
2014-06-10 23:53 ` Simon Glass [this message]
2014-06-10 23:53 ` [U-Boot] [PATCH v5 10/15] dm: Allow driver model tests only for sandbox Simon Glass
2014-06-11 14:23   ` Jon Loeliger
2014-06-10 23:53 ` [U-Boot] [PATCH v5 11/15] dm: Fix printf() strings in the 'dm' command Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 12/15] tegra: dts: Bring in GPIO bindings from linux Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 13/15] tegra: Enable driver model Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 14/15] dm: Tidy up four minor code nits Simon Glass
2014-06-10 23:53 ` [U-Boot] [PATCH v5 15/15] dm: Expand and improve the device lifecycle docs Simon Glass
2014-06-11 14:19   ` Jon Loeliger
2014-06-12  2:09     ` Simon Glass
2014-06-11 14:26 ` [U-Boot] [PATCH v5 0/15] Collected driver model bug-fixes and docs Jon Loeliger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402444428-11356-10-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.