Skip to content

Commit 77f3381

Browse files
jwrdegoedeWolfram Sang
authored andcommitted
i2c: i2c-designware-platdrv: Cleanup setting of the adapter number
i2c-designware-platdrv assumes that if the pdev has an apci-companion it should use a dynamic adapter-nr and otherwise it will use pdev->id as adapter-nr. Before this commit the setting of the adapter.nr was somewhat convoluted, in the acpi_companion case it was set from dw_i2c_acpi_configure, in the non acpi_companion case it was set from dw_i2c_set_fifo_size based on tx_fifo_depth not being set yet indicating that dw_i2c_acpi_configure was not executed. This cleans this up, directly setting the adapter-nr from dw_i2c_plat_probe for both cases. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent bf263c3 commit 77f3381

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)
8686
struct i2c_timings *t = &dev->timings;
8787
u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0;
8888

89-
dev->adapter.nr = -1;
9089
dev->tx_fifo_depth = 32;
9190
dev->rx_fifo_depth = 32;
9291

@@ -219,7 +218,7 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
219218
dev->mode = DW_IC_SLAVE;
220219
}
221220

222-
static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id)
221+
static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev)
223222
{
224223
u32 param, tx_fifo_depth, rx_fifo_depth;
225224

@@ -233,7 +232,6 @@ static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id)
233232
if (!dev->tx_fifo_depth) {
234233
dev->tx_fifo_depth = tx_fifo_depth;
235234
dev->rx_fifo_depth = rx_fifo_depth;
236-
dev->adapter.nr = id;
237235
} else if (tx_fifo_depth >= 2) {
238236
dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth,
239237
tx_fifo_depth);
@@ -358,13 +356,17 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
358356
div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000);
359357
}
360358

361-
dw_i2c_set_fifo_size(dev, pdev->id);
359+
dw_i2c_set_fifo_size(dev);
362360

363361
adap = &dev->adapter;
364362
adap->owner = THIS_MODULE;
365363
adap->class = I2C_CLASS_DEPRECATED;
366364
ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
367365
adap->dev.of_node = pdev->dev.of_node;
366+
if (has_acpi_companion(&pdev->dev))
367+
adap->nr = -1;
368+
else
369+
adap->nr = pdev->id;
368370

369371
dev_pm_set_driver_flags(&pdev->dev,
370372
DPM_FLAG_SMART_PREPARE |

0 commit comments

Comments
 (0)