[U-Boot] [PATCH V3 05/13] i2c: Create common default i2c_set_bus_num() function

Stefano Babic
2011-10-10T15:31:39Z

On 10/10/2011 05:19 PM, Mike Frysinger wrote:
> On Monday 10 October 2011 06:50:12 Stefano Babic wrote:

Hi Mike,

>> +int __def_i2c_set_bus_num(unsigned int bus)
>> +{
>> + return 0;
>> +}
>> +int i2c_set_bus_num(unsigned int)
>> + __attribute__((weak, alias("__def_i2c_set_bus_num")));
>
> any reason this can't just be:
> __weak int i2c_set_bus_num(unsigned int bus)
> {
> return 0;
> }
>
> i can understand having a default func when it actually does something, but i
> don't see much value in a stub that returns 0

It seems to me that this is the commonly used style in u-boot. The same
happens for the i2c_init_board, some lines before, and in a lot of other
modules:

void __def_i2c_init_board(void)
{
return;
}
void i2c_init_board(void)
__attribute__((weak, alias("__def_i2c_init_board")));

Simply grepping in u-boot code, the default function is defined even if
it does nothing,

Regards,
Stefano

--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================