gpio-mcp23s08: Build I2C support even when CONFIG_I2C=m
PATCH 1/1 gpio-mcp23s08: Build I2C support even when CONFIG_I2C=m
The driver has both SPI and I2C pieces. The appropriate pieces are built based on whether SPI and/or I2C is/are enabled. However, it was only checking if I2C was built-in, never if it was built as a module. This patch checks for either since building both this driver and I2C as modules is possible.
--- drivers/gpio/gpio-mcp23s08.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-mcp23s08.c +3 -3
@@ -77,7 +77,7 @@ struct mcp23s08_driver_data {/*----------------------------------------------------------------------*/ -#ifdef CONFIG_I2C +#if defined(CONFIG_I2C ) || defined(CONFIG_I2C_MODULE )static int mcp23008_read (struct mcp23s08 *mcp,unsigned reg) {
@@ -399,7 +399,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,break ;#endif /* CONFIG_SPI_MASTER */ -#ifdef CONFIG_I2C +#if defined(CONFIG_I2C ) || defined(CONFIG_I2C_MODULE )case MCP_TYPE_008 : mcp->ops = &mcp23008_ops; mcp->chip.ngpio =8 ;
@@ -473,7 +473,7 @@ fail:/*----------------------------------------------------------------------*/ -#ifdef CONFIG_I2C +#if defined(CONFIG_I2C ) || defined (CONFIG_I2C_MODULE )static int __devinit mcp230xx_probe (struct i2c_client *client,const struct i2c_device_id *id)
Signature · 1 line
Daniel M. Weeks
Quoted 4 lines · Daniel M. Weeks
The driver has both SPI and I2C pieces. The appropriate pieces are built based on whether SPI and/or I2C is/are enabled. However, it was only checking if I2C was built-in, never if it was built as a module. This patch checks for either since building both this driver and I2C as modules is possible.
Good catch!
Review
Quoted 2 lines
(quoted diff) +1
-1-#ifdef CONFIG_I2C +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
But don't do it like this, there are already helpers for exactly this.
Do:
#if IS_ENABLED(CONFIG_I2C)
Read include/linux/kconfig.h if in doubt...
Looking forward to v2!
Yours,
Linus Walleij