On Tue, 31 Jul 2007, Timur Tabi wrote:
Takashi Iwai wrote:
Also,
#ifdef CONFIG_I2C
isn't enough. It should be
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
I asked about that a while ago, and I never got an answer. Where does CONFIG_I2C_MODULE come from? I don't see it in any Kconfig or any header file. And if I2C can be a module, then why wouldn't CONFIG_I2C also be defined?
If config FOO is compiled in (i.e. it's "y"), CONFIG_FOO will be defined. If it's a module, CONFIG_FOO_MODULE will be defined. It's one or the other, not both.
If you want your code to comple differently if it has i2c available, you should do this:
#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) /* code that needs i2c goes here, i2c_transfer(), etc. */ #endif
Note that just checking defined(CONFIG_I2C_MODULE) isn't correct. If your code is compiled in and i2c is a module, you can't call i2c functions or the kernel won't link.
Of course, if you need i2c to work in any reasonble way, you should just have your driver depend on i2c in Kconfig.