From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Wed, 18 Jun 2014 01:42:17 +0200 Subject: [U-Boot] [PATCH v4 09/15] dm: Cast away the const-ness of the global_data pointer In-Reply-To: References: <1402082012-4152-1-git-send-email-sjg@chromium.org> <201406080700.08646.marex@denx.de> Message-ID: <201406180142.17889.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thursday, June 12, 2014 at 05:26:50 AM, Simon Glass wrote: > Hi Marek, > > On 8 June 2014 01:00, Marek Vasut 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 > >> --- > > > > [...] > > > >> - 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 ? Sorry, I might be completely wrong. Best regards, Marek Vasut