提交 d5fd120e 编写于 作者: J Jean Delvare 提交者: Wolfram Sang

i2c: Only include slave support if selected

Make the slave support depend on CONFIG_I2C_SLAVE. Otherwise it gets
included unconditionally, even when it is not needed.

I2C bus drivers which implement slave support must select
I2C_SLAVE.
Signed-off-by: NJean Delvare <jdelvare@suse.de>
Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
上级 34e81ad5
...@@ -881,6 +881,7 @@ config I2C_XLR ...@@ -881,6 +881,7 @@ config I2C_XLR
config I2C_RCAR config I2C_RCAR
tristate "Renesas R-Car I2C Controller" tristate "Renesas R-Car I2C Controller"
depends on ARCH_SHMOBILE || COMPILE_TEST depends on ARCH_SHMOBILE || COMPILE_TEST
select I2C_SLAVE
help help
If you say yes to this option, support will be included for the If you say yes to this option, support will be included for the
R-Car I2C controller. R-Car I2C controller.
......
...@@ -2972,6 +2972,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, ...@@ -2972,6 +2972,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
} }
EXPORT_SYMBOL(i2c_smbus_xfer); EXPORT_SYMBOL(i2c_smbus_xfer);
#if IS_ENABLED(CONFIG_I2C_SLAVE)
int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb) int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
{ {
int ret; int ret;
...@@ -3019,6 +3020,7 @@ int i2c_slave_unregister(struct i2c_client *client) ...@@ -3019,6 +3020,7 @@ int i2c_slave_unregister(struct i2c_client *client)
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(i2c_slave_unregister); EXPORT_SYMBOL_GPL(i2c_slave_unregister);
#endif
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
MODULE_DESCRIPTION("I2C-Bus main module"); MODULE_DESCRIPTION("I2C-Bus main module");
......
...@@ -228,7 +228,9 @@ struct i2c_client { ...@@ -228,7 +228,9 @@ struct i2c_client {
struct device dev; /* the device structure */ struct device dev; /* the device structure */
int irq; /* irq issued by device */ int irq; /* irq issued by device */
struct list_head detected; struct list_head detected;
#if IS_ENABLED(CONFIG_I2C_SLAVE)
i2c_slave_cb_t slave_cb; /* callback for slave mode */ i2c_slave_cb_t slave_cb; /* callback for slave mode */
#endif
}; };
#define to_i2c_client(d) container_of(d, struct i2c_client, dev) #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
...@@ -253,6 +255,7 @@ static inline void i2c_set_clientdata(struct i2c_client *dev, void *data) ...@@ -253,6 +255,7 @@ static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
/* I2C slave support */ /* I2C slave support */
#if IS_ENABLED(CONFIG_I2C_SLAVE)
enum i2c_slave_event { enum i2c_slave_event {
I2C_SLAVE_REQ_READ_START, I2C_SLAVE_REQ_READ_START,
I2C_SLAVE_REQ_READ_END, I2C_SLAVE_REQ_READ_END,
...@@ -269,6 +272,7 @@ static inline int i2c_slave_event(struct i2c_client *client, ...@@ -269,6 +272,7 @@ static inline int i2c_slave_event(struct i2c_client *client,
{ {
return client->slave_cb(client, event, val); return client->slave_cb(client, event, val);
} }
#endif
/** /**
* struct i2c_board_info - template for device creation * struct i2c_board_info - template for device creation
...@@ -404,8 +408,10 @@ struct i2c_algorithm { ...@@ -404,8 +408,10 @@ struct i2c_algorithm {
/* To determine what the adapter supports */ /* To determine what the adapter supports */
u32 (*functionality) (struct i2c_adapter *); u32 (*functionality) (struct i2c_adapter *);
#if IS_ENABLED(CONFIG_I2C_SLAVE)
int (*reg_slave)(struct i2c_client *client); int (*reg_slave)(struct i2c_client *client);
int (*unreg_slave)(struct i2c_client *client); int (*unreg_slave)(struct i2c_client *client);
#endif
}; };
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册