[U-Boot] U-Boot, dm, ubi: struct device is declared twice

Simon Glass sjg at chromium.org
Fri May 2 16:29:29 CEST 2014


Hi,

On 2 May 2014 01:16, Heiko Schocher <hs at denx.de> wrote:
> Hello Marek,
>
> Am 02.05.2014 08:06, schrieb Marek Vasut:
>
>> On Friday, May 02, 2014 at 07:19:01 AM, Heiko Schocher wrote:
>>>
>>> Hello Simon, Marek,
>>>
>>> just updating to current mainline code and defining
>>> CONFIG_SYS_GENERIC_BOARD pops up the following error:
>>>
>>>    CC      common/board_r.o
>>> In file included from include/linux/mtd/flashchip.h:21:0,
>>>                    from include/linux/mtd/nand.h:31,
>>>                    from include/nand.h:39,
>>>                    from common/board_r.c:40:
>>> include/ubi_uboot.h:202:8: error: redefinition of 'struct device'
>>>    struct device {
>>>           ^
>>> In file included from include/dm.h:10:0,
>>>                    from common/board_r.c:21:
>>> include/dm/device.h:56:8: note: originally defined here
>>>    struct device {
>>>           ^
>>> make[1]: *** [common/board_r.o] Fehler 1
>>> make: *** [common] Fehler 2
>>> pollux:u-boot hs [20140502] $
>>>
>>> for a not yet mainlined imx6 board using UBI/UBIFS on nand. I am
>>> currently sync current Linux MTD/UBI and UBIFS code to U-Boot, but
>>> I think this error should pop up for all boards using DM and UBI ...
>>
>>
>> In the ideal case, we should use the same struct device for both UBI and
>> DM, but
>
>
> Yes, that was also my first thought ...
>
>
>> we cannot do that. Thus, renaming the DM struct device would be the best
>> option
>> for now.
>
>
> Ok. I prepare a patch for this.

Linux also has struct device, so I wondered how it avoids this problem
and took a look.

This header file seems like a special thing for U-Boot - I wonder if
it would be better to use #define at the top of the C file for the
compatibility stuff (#define device ubi_device) rather than modify dm?
It does seem very strange to me, particularly as from what I can tell,
struct device is just a cut down version of the Linux struct.

Regards,
Simon


More information about the U-Boot mailing list