summaryrefslogtreecommitdiff
path: root/drivers/i2c/busses/i2c-stm32f7.c
diff options
context:
space:
mode:
authorAlain Volmat <alain.volmat@st.com>2020-09-15 11:11:41 +0200
committerWolfram Sang <wsa@kernel.org>2020-09-18 23:03:13 +0200
commitb62590a92058f3edf8884b46312848e8aafe0922 (patch)
tree67a794013f7b112ed1f57cef58407bc09ae1dce5 /drivers/i2c/busses/i2c-stm32f7.c
parentb713aa86df99f117f2ccee0ce22be03a54d24a90 (diff)
i2c: stm32: name slave slot to ease maintenance
Name slave slots in order to ease code maintenance. Signed-off-by: Alain Volmat <alain.volmat@st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-stm32f7.c')
-rw-r--r--drivers/i2c/busses/i2c-stm32f7.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 425eff5b18e0..e02dca90a54b 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -152,7 +152,12 @@
#define STM32F7_I2C_MAX_LEN 0xff
#define STM32F7_I2C_DMA_LEN_MIN 0x16
-#define STM32F7_I2C_MAX_SLAVE 0x3
+enum {
+ STM32F7_SLAVE_HOSTNOTIFY,
+ STM32F7_SLAVE_7_10_BITS_ADDR,
+ STM32F7_SLAVE_7_BITS_ADDR,
+ STM32F7_I2C_MAX_SLAVE
+};
#define STM32F7_I2C_DNF_DEFAULT 0
#define STM32F7_I2C_DNF_MAX 16
@@ -1327,19 +1332,20 @@ static int stm32f7_i2c_get_free_slave_id(struct stm32f7_i2c_dev *i2c_dev,
int i;
/*
- * slave[0] support only SMBus Host address (0x8)
- * slave[1] supports 7-bit and 10-bit slave address
- * slave[2] supports 7-bit slave address only
+ * slave[STM32F7_SLAVE_HOSTNOTIFY] support only SMBus Host address (0x8)
+ * slave[STM32F7_SLAVE_7_10_BITS_ADDR] supports 7-bit and 10-bit slave address
+ * slave[STM32F7_SLAVE_7_BITS_ADDR] supports 7-bit slave address only
*/
if (i2c_dev->smbus_mode && (slave->addr == 0x08)) {
- if (i2c_dev->slave[0])
+ if (i2c_dev->slave[STM32F7_SLAVE_HOSTNOTIFY])
goto fail;
- *id = 0;
+ *id = STM32F7_SLAVE_HOSTNOTIFY;
return 0;
}
- for (i = STM32F7_I2C_MAX_SLAVE - 1; i > 0; i--) {
- if (i == 2 && (slave->flags & I2C_CLIENT_TEN))
+ for (i = STM32F7_I2C_MAX_SLAVE - 1; i > STM32F7_SLAVE_HOSTNOTIFY; i--) {
+ if ((i == STM32F7_SLAVE_7_BITS_ADDR) &&
+ (slave->flags & I2C_CLIENT_TEN))
continue;
if (!i2c_dev->slave[i]) {
*id = i;