Hi Morimoto, On Mon, 27 Jun 2011 16:00:08 +0900, kuninori.morimoto.gx@xxxxxxxxxxx wrote: > I'm using i2c_xxx function on some board. > And sometimes I need very small kernel which doesn't need CONFIG_I2C. > > But then (.config doesn't have CONFIG_I2C), the compile will fail. > like this > > error: implicit declaration of function 'i2c_get_adapter' > error: implicit declaration of function 'i2c_transfer' > > In this case, should I use #ifdef CONFIG_I2C in my code to solve this compile issue ? Yes. > Or is below #else in i2c.h good idea ? > > --- i2c.h --------- > #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) > ... > extern struct i2c_adapter *i2c_get_adapter(int nr); > ... > #else > ... > #define i2c_get_adapter(nr) NULL > ... > #endif I don't think this is a good idea in general. If the kernel lacks I2C support, and your code uses it, then this is dead code, and you're much better excluding that code completely from your build. Most likely you'll be able to drop whole functions. I wouldn't count on the compiler to optimize it all properly, and you said you want a very small kernel. Of course we could make better comments if we could see your actual code. Maybe some ifdef magic in i2c.h would make sense for a few items, as we already do for i2c_register_board_info for example. -- Jean Delvare -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html