public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 09/15] dm: Cast away the const-ness of the global_data pointer
Date: Fri, 20 Jun 2014 06:12:50 +0200	[thread overview]
Message-ID: <201406200612.50542.marex@denx.de> (raw)
In-Reply-To: <CAPnjgZ1mG9jrRXTZnDffYyWzywj=a_0UfEp+SMxQtHYnHxHoWw@mail.gmail.com>

On Friday, June 20, 2014 at 06:07:02 AM, Simon Glass wrote:
> Hi Marek,
> 
> On 17 June 2014 23:36, Simon Glass <sjg@chromium.org> wrote:
> > Hi Marek,
> > 
> > On 17 June 2014 16:42, Marek Vasut <marex@denx.de> wrote:
> >> On Thursday, June 12, 2014 at 05:26:50 AM, Simon Glass wrote:
> >>> Hi Marek,
> >>> 
> >>> On 8 June 2014 01:00, Marek Vasut <marex@denx.de> wrote:
> >>> > On Friday, June 06, 2014 at 09:13:26 PM, Simon Glass wrote:
> >>> >> 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>
> >>> >> ---
> >>> > 
> >>> > [...]
> >>> > 
> >>> >> -     ret = device_bind_by_name(NULL, &root_info, &gd->dm_root);
> >>> >> +     ret = device_bind_by_name(NULL, &root_info, &DM_ROOT());
> >>> > 
> >>> > [...]
> >>> > 
> >>> >> +/* Cast away any volatile pointer */
> >>> >> +#define DM_ROOT()            (((gd_t *)gd)->dm_root)
> >>> >> +#define DM_UCLASS_ROOT()             (((gd_t *)gd)->uclass_root)
> >>> > 
> >>> > Can you implement this "DM_ROOT()" macro as a function instead ? I
> >>> > believe that'd be much nicer , would have typechecking etc., usual
> >>> > stuff.
> >>> 
> >>> I had a look at this. I don't see how I can do it, but you might have
> >>> ideas.
> >>> 
> >>> In this function call I need to pass a pointer without its const bit.
> >>> I made it const since nothing should change the dm root except driver
> >>> model itself.
> >> 
> >> All right, I will just be doing a little guesswork here. Shall you not
> >> have some functions to change the DM root then instead of exposing the
> >> DM root ? Such functions shall not be exported publicly , but available
> >> via separate header file too ?
> > 
> > Firstly I should retitle the commit - it is of course the volatile
> > that I'm trying to get rid of as it says in the commit message. I
> > might have just been trying to confuse everyone.
> > 
> > I have code like this:
> > 
> > INIT_LIST_HEAD(&gd->uclass_root);
> > 
> > I don't see how I can turn this into a function. I suppose I could
> > init the list head in a temporary variable and then assign it to
> > gd->uclass_root, perhaps with memcpy(), but that doesn't really seem
> > any better to me.
> > 
> >> Sorry, I might be completely wrong.
> > 
> > Well I'm not saying it's pretty, so if you have time and come up with
> > a better option please let me know.
> > 
> > Also, this is not exported 'publicly'. It is in device-internal.h
> 
> Please let me know on this one. If you have a better option please let me
> know.
> 
> Otherwise I'd like to do a dm pull request soon to get these fixes
> into the release.

Ah, please get the PR out. We can tweak this later I'm sure. Apologies for 
holding you and the PR.

  reply	other threads:[~2014-06-20  4:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 19:13 [U-Boot] [PATCH v4 0/15] Collected driver model bug-fixes and docs Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 01/15] Add an I/O tracing feature Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 02/15] arm: Support iotrace feature Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 03/15] sandbox: " Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 04/15] Makefile: Support include files for .dts files Simon Glass
2014-06-06 20:29   ` Jon Loeliger
2014-06-06 20:44     ` Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 05/15] dm: Rename struct device_id to udevice_id Simon Glass
2014-06-06 20:26   ` Jon Loeliger
2014-06-06 20:30     ` Jon Loeliger
2014-06-06 20:36     ` Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 06/15] dm: Update README to encourage conversion to driver model Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 07/15] dm: Use case-insensitive comparison for GPIO banks Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 08/15] dm: Add missing header files in lists and root Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 09/15] dm: Cast away the const-ness of the global_data pointer Simon Glass
2014-06-08  5:00   ` Marek Vasut
2014-06-12  3:26     ` Simon Glass
2014-06-12  3:29       ` Simon Glass
2014-06-17 23:42       ` Marek Vasut
2014-06-18  5:36         ` Simon Glass
2014-06-20  4:07           ` Simon Glass
2014-06-20  4:12             ` Marek Vasut [this message]
2014-06-20 20:34               ` Simon Glass
2014-06-20 21:45                 ` Marek Vasut
2014-06-06 19:13 ` [U-Boot] [PATCH v4 10/15] dm: Allow driver model tests only for sandbox Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 11/15] dm: Fix printf() strings in the 'dm' command Simon Glass
2014-06-08 22:46   ` Andre Renaud
2014-06-12  3:34     ` Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 12/15] tegra: dts: Bring in GPIO bindings from linux Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 13/15] tegra: Enable driver model Simon Glass
2014-06-06 19:13 ` [U-Boot] [PATCH v4 14/15] dm: Tidy up four minor code nits Simon Glass
2014-06-08  5:01   ` Marek Vasut
2014-06-06 19:13 ` [U-Boot] [PATCH v4 15/15] dm: Expand and improve the device lifecycle docs Simon Glass
2014-06-06 19:52   ` Pavel Herrmann
2014-06-06 20:42     ` Simon Glass

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=201406200612.50542.marex@denx.de \
    --to=marex@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox