From c840492ad7487dcb58b0f5f249793e7350114076 Mon Sep 17 00:00:00 2001 From: Jonas Jelonek Date: Sat, 27 Sep 2025 10:19:25 +0000 Subject: [PATCH] i2c: rtl9300: rename internal sda_pin to sda_num Rename the internally used 'sda_pin' to 'sda_num' to make it clear that this is NOT the actual pin number of the GPIO pin but rather the logical SDA channel number. Although the alternate function SDA_Y is sometimes given with the GPIO number, this is not always the case. Thus, avoid any confusion or misconfiguration by giving the variable the correct name. This follows the description change in the devicetree bindings. Signed-off-by: Jonas Jelonek Tested-by: Sven Eckelmann Reviewed-by: Chris Packham Tested-by: Chris Packham # On RTL9302C based board Tested-by: Markus Stockhausen Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/20250927101931.71575-4-jelonek.jonas@gmail.com --- drivers/i2c/busses/i2c-rtl9300.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c index 8483bab72146f..f9b5ac7670c25 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -20,7 +20,7 @@ struct rtl9300_i2c_chan { struct i2c_adapter adap; struct rtl9300_i2c *i2c; enum rtl9300_bus_freq bus_freq; - u8 sda_pin; + u8 sda_num; }; enum rtl9300_i2c_reg_scope { @@ -67,7 +67,7 @@ struct rtl9300_i2c { struct regmap_field *fields[F_NUM_FIELDS]; u32 reg_base; u32 data_reg; - u8 sda_pin; + u8 sda_num; struct mutex lock; }; @@ -102,11 +102,11 @@ static int rtl9300_i2c_config_io(struct rtl9300_i2c *i2c, u8 sda_pin) drv_data = (struct rtl9300_i2c_drv_data *)device_get_match_data(i2c->dev); - ret = regmap_field_update_bits(i2c->fields[F_SDA_SEL], BIT(sda_pin), BIT(sda_pin)); + ret = regmap_field_update_bits(i2c->fields[F_SDA_SEL], BIT(sda_num), BIT(sda_num)); if (ret) return ret; - ret = regmap_field_write(i2c->fields[F_SDA_OUT_SEL], sda_pin); + ret = regmap_field_write(i2c->fields[F_SDA_OUT_SEL], sda_num); if (ret) return ret; @@ -243,11 +243,11 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s int len = 0, ret; mutex_lock(&i2c->lock); - if (chan->sda_pin != i2c->sda_pin) { + if (chan->sda_num != i2c->sda_num) { ret = rtl9300_i2c_config_io(i2c, chan->sda_pin); if (ret) goto out_unlock; - i2c->sda_pin = chan->sda_pin; + i2c->sda_num = chan->sda_num; } switch (size) { @@ -374,7 +374,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev) struct fwnode_handle *child; struct rtl9300_i2c_drv_data *drv_data; struct reg_field fields[F_NUM_FIELDS]; - u32 clock_freq, sda_pin; + u32 clock_freq, sda_num; int ret, i = 0; i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); @@ -414,7 +414,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev) struct rtl9300_i2c_chan *chan = &i2c->chans[i]; struct i2c_adapter *adap = &chan->adap; - ret = fwnode_property_read_u32(child, "reg", &sda_pin); + ret = fwnode_property_read_u32(child, "reg", &sda_num); if (ret) return ret; @@ -431,11 +431,11 @@ static int rtl9300_i2c_probe(struct platform_device *pdev) break; default: dev_warn(i2c->dev, "SDA%d clock-frequency %d not supported using default\n", - sda_pin, clock_freq); + sda_num, clock_freq); break; } - chan->sda_pin = sda_pin; + chan->sda_num = sda_num; chan->i2c = i2c; adap = &i2c->chans[i].adap; adap->owner = THIS_MODULE; @@ -445,14 +445,14 @@ static int rtl9300_i2c_probe(struct platform_device *pdev) adap->dev.parent = dev; i2c_set_adapdata(adap, chan); adap->dev.of_node = to_of_node(child); - snprintf(adap->name, sizeof(adap->name), "%s SDA%d\n", dev_name(dev), sda_pin); + snprintf(adap->name, sizeof(adap->name), "%s SDA%d\n", dev_name(dev), sda_num); i++; ret = devm_i2c_add_adapter(dev, adap); if (ret) return ret; } - i2c->sda_pin = 0xff; + i2c->sda_num = 0xff; return 0; } -- 2.47.3