Skip to content

Commit c840492

Browse files
jonasjelonekAndi Shyti
authored andcommitted
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 <jelonek.jonas@gmail.com> Tested-by: Sven Eckelmann <sven@narfation.org> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250927101931.71575-4-jelonek.jonas@gmail.com
1 parent 0395a5e commit c840492

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

drivers/i2c/busses/i2c-rtl9300.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct rtl9300_i2c_chan {
2020
struct i2c_adapter adap;
2121
struct rtl9300_i2c *i2c;
2222
enum rtl9300_bus_freq bus_freq;
23-
u8 sda_pin;
23+
u8 sda_num;
2424
};
2525

2626
enum rtl9300_i2c_reg_scope {
@@ -67,7 +67,7 @@ struct rtl9300_i2c {
6767
struct regmap_field *fields[F_NUM_FIELDS];
6868
u32 reg_base;
6969
u32 data_reg;
70-
u8 sda_pin;
70+
u8 sda_num;
7171
struct mutex lock;
7272
};
7373

@@ -102,11 +102,11 @@ static int rtl9300_i2c_config_io(struct rtl9300_i2c *i2c, u8 sda_pin)
102102

103103
drv_data = (struct rtl9300_i2c_drv_data *)device_get_match_data(i2c->dev);
104104

105-
ret = regmap_field_update_bits(i2c->fields[F_SDA_SEL], BIT(sda_pin), BIT(sda_pin));
105+
ret = regmap_field_update_bits(i2c->fields[F_SDA_SEL], BIT(sda_num), BIT(sda_num));
106106
if (ret)
107107
return ret;
108108

109-
ret = regmap_field_write(i2c->fields[F_SDA_OUT_SEL], sda_pin);
109+
ret = regmap_field_write(i2c->fields[F_SDA_OUT_SEL], sda_num);
110110
if (ret)
111111
return ret;
112112

@@ -243,11 +243,11 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
243243
int len = 0, ret;
244244

245245
mutex_lock(&i2c->lock);
246-
if (chan->sda_pin != i2c->sda_pin) {
246+
if (chan->sda_num != i2c->sda_num) {
247247
ret = rtl9300_i2c_config_io(i2c, chan->sda_pin);
248248
if (ret)
249249
goto out_unlock;
250-
i2c->sda_pin = chan->sda_pin;
250+
i2c->sda_num = chan->sda_num;
251251
}
252252

253253
switch (size) {
@@ -374,7 +374,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
374374
struct fwnode_handle *child;
375375
struct rtl9300_i2c_drv_data *drv_data;
376376
struct reg_field fields[F_NUM_FIELDS];
377-
u32 clock_freq, sda_pin;
377+
u32 clock_freq, sda_num;
378378
int ret, i = 0;
379379

380380
i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
@@ -414,7 +414,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
414414
struct rtl9300_i2c_chan *chan = &i2c->chans[i];
415415
struct i2c_adapter *adap = &chan->adap;
416416

417-
ret = fwnode_property_read_u32(child, "reg", &sda_pin);
417+
ret = fwnode_property_read_u32(child, "reg", &sda_num);
418418
if (ret)
419419
return ret;
420420

@@ -431,11 +431,11 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
431431
break;
432432
default:
433433
dev_warn(i2c->dev, "SDA%d clock-frequency %d not supported using default\n",
434-
sda_pin, clock_freq);
434+
sda_num, clock_freq);
435435
break;
436436
}
437437

438-
chan->sda_pin = sda_pin;
438+
chan->sda_num = sda_num;
439439
chan->i2c = i2c;
440440
adap = &i2c->chans[i].adap;
441441
adap->owner = THIS_MODULE;
@@ -445,14 +445,14 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
445445
adap->dev.parent = dev;
446446
i2c_set_adapdata(adap, chan);
447447
adap->dev.of_node = to_of_node(child);
448-
snprintf(adap->name, sizeof(adap->name), "%s SDA%d\n", dev_name(dev), sda_pin);
448+
snprintf(adap->name, sizeof(adap->name), "%s SDA%d\n", dev_name(dev), sda_num);
449449
i++;
450450

451451
ret = devm_i2c_add_adapter(dev, adap);
452452
if (ret)
453453
return ret;
454454
}
455-
i2c->sda_pin = 0xff;
455+
i2c->sda_num = 0xff;
456456

457457
return 0;
458458
}

0 commit comments

Comments
 (0)