diff options
author | Hans de Goede <hdegoede@redhat.com> | 2019-03-12 10:55:53 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2019-03-13 13:06:56 -0400 |
commit | 77f3381a83c2f66daeb6719a1191a87280d57f62 (patch) | |
tree | 232df842bd2ce7cf4f2d78fd7bd80735b5959b79 /drivers/i2c | |
parent | bf263c35b2ebe7f1674205f6b36487250299b5a7 (diff) |
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>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-designware-platdrv.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index ead5e7de3e4d..30529839cbd2 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c | |||
@@ -86,7 +86,6 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) | |||
86 | struct i2c_timings *t = &dev->timings; | 86 | struct i2c_timings *t = &dev->timings; |
87 | u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0; | 87 | u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0; |
88 | 88 | ||
89 | dev->adapter.nr = -1; | ||
90 | dev->tx_fifo_depth = 32; | 89 | dev->tx_fifo_depth = 32; |
91 | dev->rx_fifo_depth = 32; | 90 | dev->rx_fifo_depth = 32; |
92 | 91 | ||
@@ -219,7 +218,7 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev) | |||
219 | dev->mode = DW_IC_SLAVE; | 218 | dev->mode = DW_IC_SLAVE; |
220 | } | 219 | } |
221 | 220 | ||
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) |
223 | { | 222 | { |
224 | u32 param, tx_fifo_depth, rx_fifo_depth; | 223 | u32 param, tx_fifo_depth, rx_fifo_depth; |
225 | 224 | ||
@@ -233,7 +232,6 @@ static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id) | |||
233 | if (!dev->tx_fifo_depth) { | 232 | if (!dev->tx_fifo_depth) { |
234 | dev->tx_fifo_depth = tx_fifo_depth; | 233 | dev->tx_fifo_depth = tx_fifo_depth; |
235 | dev->rx_fifo_depth = rx_fifo_depth; | 234 | dev->rx_fifo_depth = rx_fifo_depth; |
236 | dev->adapter.nr = id; | ||
237 | } else if (tx_fifo_depth >= 2) { | 235 | } else if (tx_fifo_depth >= 2) { |
238 | dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth, | 236 | dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth, |
239 | tx_fifo_depth); | 237 | tx_fifo_depth); |
@@ -358,13 +356,17 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) | |||
358 | div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000); | 356 | div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000); |
359 | } | 357 | } |
360 | 358 | ||
361 | dw_i2c_set_fifo_size(dev, pdev->id); | 359 | dw_i2c_set_fifo_size(dev); |
362 | 360 | ||
363 | adap = &dev->adapter; | 361 | adap = &dev->adapter; |
364 | adap->owner = THIS_MODULE; | 362 | adap->owner = THIS_MODULE; |
365 | adap->class = I2C_CLASS_DEPRECATED; | 363 | adap->class = I2C_CLASS_DEPRECATED; |
366 | ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); | 364 | ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); |
367 | adap->dev.of_node = pdev->dev.of_node; | 365 | 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; | ||
368 | 370 | ||
369 | dev_pm_set_driver_flags(&pdev->dev, | 371 | dev_pm_set_driver_flags(&pdev->dev, |
370 | DPM_FLAG_SMART_PREPARE | | 372 | DPM_FLAG_SMART_PREPARE | |