Hi Marek,

On 8 June 2014 01:00, Marek Vasut <ma...@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 <s...@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.

>> +     ret = device_bind_by_name(NULL, &root_info, &DM_ROOT());

In the above line, I don't think I can make it a function. Similarly
one good think about the function is that I can grep for it easily.

So I'm thinking of using something like this:

/* 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)

It is no-longer a function, but I can easily find it. Plus it is
explicit as to what it is for, with the NON_CONST suffix.

Regards,
Simon
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to