* [PATCH v2 1/7] i2c: designware: Replace a while-loop by for-loop
2024-08-19 8:39 [PATCH v2 0/7] i2c: designware: Cleanups (part 1) Andy Shevchenko
@ 2024-08-19 8:39 ` Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 2/7] i2c: designware: Let PCI core to take care about interrupt vectors Andy Shevchenko
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-19 8:39 UTC (permalink / raw)
To: Jarkko Nikula, Andi Shyti, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips, Mario Limonciello
Replace a while-loop by for-loop in i2c_dw_probe_lock_support() to
save a few lines of code.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index df3dc1e8093e..d092532375b8 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -238,11 +238,9 @@ static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
int i = 0;
int ret;
- ptr = i2c_dw_semaphore_cb_table;
-
dev->semaphore_idx = -1;
- while (ptr->probe) {
+ for (ptr = i2c_dw_semaphore_cb_table; ptr->probe; ptr++) {
ret = ptr->probe(dev);
if (ret) {
/*
@@ -254,7 +252,6 @@ static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
return ret;
i++;
- ptr++;
continue;
}
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 2/7] i2c: designware: Let PCI core to take care about interrupt vectors
2024-08-19 8:39 [PATCH v2 0/7] i2c: designware: Cleanups (part 1) Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 1/7] i2c: designware: Replace a while-loop by for-loop Andy Shevchenko
@ 2024-08-19 8:39 ` Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 3/7] i2c: designware: Add missing 'c' into PCI IDs variable name Andy Shevchenko
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-19 8:39 UTC (permalink / raw)
To: Jarkko Nikula, Andi Shyti, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips
PCI core, after pcim_enable_device(), takes care about the allocated
IRQ vectors, no need to do it explicitly and break the cleaning up
order.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index a1b379a1e904..507e114332cd 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -295,10 +295,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
if (controller->setup) {
r = controller->setup(pdev, controller);
- if (r) {
- pci_free_irq_vectors(pdev);
+ if (r)
return r;
- }
}
i2c_dw_adjust_bus_speed(dev);
@@ -307,10 +305,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
i2c_dw_acpi_configure(&pdev->dev);
r = i2c_dw_validate_speed(dev);
- if (r) {
- pci_free_irq_vectors(pdev);
+ if (r)
return r;
- }
i2c_dw_configure(dev);
@@ -330,10 +326,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
adap->nr = controller->bus_num;
r = i2c_dw_probe(dev);
- if (r) {
- pci_free_irq_vectors(pdev);
+ if (r)
return r;
- }
if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) {
dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, &dgpu_node);
@@ -359,8 +353,6 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
pm_runtime_get_noresume(&pdev->dev);
i2c_del_adapter(&dev->adapter);
- devm_free_irq(&pdev->dev, dev->irq, dev);
- pci_free_irq_vectors(pdev);
}
static const struct pci_device_id i2_designware_pci_ids[] = {
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 3/7] i2c: designware: Add missing 'c' into PCI IDs variable name
2024-08-19 8:39 [PATCH v2 0/7] i2c: designware: Cleanups (part 1) Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 1/7] i2c: designware: Replace a while-loop by for-loop Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 2/7] i2c: designware: Let PCI core to take care about interrupt vectors Andy Shevchenko
@ 2024-08-19 8:39 ` Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 4/7] i2c: designware: Unify terminator in device ID tables Andy Shevchenko
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-19 8:39 UTC (permalink / raw)
To: Jarkko Nikula, Andi Shyti, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips
Add missing 'c' into i2c_designware_pci_ids variable name.
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 507e114332cd..4cbcdae8cd90 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -355,7 +355,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
i2c_del_adapter(&dev->adapter);
}
-static const struct pci_device_id i2_designware_pci_ids[] = {
+static const struct pci_device_id i2c_designware_pci_ids[] = {
/* Medfield */
{ PCI_VDEVICE(INTEL, 0x0817), medfield },
{ PCI_VDEVICE(INTEL, 0x0818), medfield },
@@ -403,16 +403,16 @@ static const struct pci_device_id i2_designware_pci_ids[] = {
{ PCI_VDEVICE(ATI, 0x7464), navi_amd },
{ 0,}
};
-MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids);
+MODULE_DEVICE_TABLE(pci, i2c_designware_pci_ids);
static struct pci_driver dw_i2c_driver = {
.name = DRIVER_NAME,
- .id_table = i2_designware_pci_ids,
.probe = i2c_dw_pci_probe,
.remove = i2c_dw_pci_remove,
.driver = {
.pm = &i2c_dw_pm_ops,
},
+ .id_table = i2c_designware_pci_ids,
};
module_pci_driver(dw_i2c_driver);
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 4/7] i2c: designware: Unify terminator in device ID tables
2024-08-19 8:39 [PATCH v2 0/7] i2c: designware: Cleanups (part 1) Andy Shevchenko
` (2 preceding siblings ...)
2024-08-19 8:39 ` [PATCH v2 3/7] i2c: designware: Add missing 'c' into PCI IDs variable name Andy Shevchenko
@ 2024-08-19 8:39 ` Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 5/7] i2c: designware: Always provide " Andy Shevchenko
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-19 8:39 UTC (permalink / raw)
To: Jarkko Nikula, Andi Shyti, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips, Mario Limonciello
Make the terminator entry look the same in all device ID tables.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 2 +-
drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 4cbcdae8cd90..cbbcbcc265c9 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -401,7 +401,7 @@ static const struct pci_device_id i2c_designware_pci_ids[] = {
{ PCI_VDEVICE(ATI, 0x73c4), navi_amd },
{ PCI_VDEVICE(ATI, 0x7444), navi_amd },
{ PCI_VDEVICE(ATI, 0x7464), navi_amd },
- { 0,}
+ {}
};
MODULE_DEVICE_TABLE(pci, i2c_designware_pci_ids);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index d092532375b8..9ce74a8be43a 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -58,7 +58,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = {
{ "HISI02A2", 0 },
{ "HISI02A3", 0 },
{ "HYGO0010", ACCESS_INTR_MASK },
- { }
+ {}
};
MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
#endif
@@ -154,7 +154,7 @@ static const struct of_device_id dw_i2c_of_match[] = {
{ .compatible = "snps,designware-i2c", },
{ .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
{ .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
- {},
+ {}
};
MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
#else
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 5/7] i2c: designware: Always provide device ID tables
2024-08-19 8:39 [PATCH v2 0/7] i2c: designware: Cleanups (part 1) Andy Shevchenko
` (3 preceding siblings ...)
2024-08-19 8:39 ` [PATCH v2 4/7] i2c: designware: Unify terminator in device ID tables Andy Shevchenko
@ 2024-08-19 8:39 ` Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 6/7] i2c: designware: Drop return value from i2c_dw_acpi_configure() Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 7/7] i2c: designware: Drop return value from dw_i2c_of_configure() Andy Shevchenko
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-19 8:39 UTC (permalink / raw)
To: Jarkko Nikula, Andi Shyti, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips, Mario Limonciello
There is no need to have ugly ifdeffery and additional macros
for the device ID tables. Always provide them. Since we touch
the ACPI table, make it sorted by ID.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 60 ++++++++++-----------
1 file changed, 29 insertions(+), 31 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 9ce74a8be43a..6328ae943a34 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -40,29 +40,6 @@ static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
return clk_get_rate(dev->clk) / KILO;
}
-#ifdef CONFIG_ACPI
-static const struct acpi_device_id dw_i2c_acpi_match[] = {
- { "INT33C2", 0 },
- { "INT33C3", 0 },
- { "INT3432", 0 },
- { "INT3433", 0 },
- { "INTC10EF", 0 },
- { "80860F41", ACCESS_NO_IRQ_SUSPEND },
- { "808622C1", ACCESS_NO_IRQ_SUSPEND },
- { "AMD0010", ACCESS_INTR_MASK },
- { "AMDI0010", ACCESS_INTR_MASK },
- { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
- { "AMDI0510", 0 },
- { "APMC0D0F", 0 },
- { "HISI02A1", 0 },
- { "HISI02A2", 0 },
- { "HISI02A3", 0 },
- { "HYGO0010", ACCESS_INTR_MASK },
- {}
-};
-MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
-#endif
-
#ifdef CONFIG_OF
#define BT1_I2C_CTL 0x100
#define BT1_I2C_CTL_ADDR_MASK GENMASK(7, 0)
@@ -149,14 +126,6 @@ static int dw_i2c_of_configure(struct platform_device *pdev)
return 0;
}
-
-static const struct of_device_id dw_i2c_of_match[] = {
- { .compatible = "snps,designware-i2c", },
- { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
- { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
- {}
-};
-MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
#else
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
{
@@ -477,6 +446,35 @@ static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
};
+static const struct of_device_id dw_i2c_of_match[] = {
+ { .compatible = "snps,designware-i2c", },
+ { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
+ { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
+ {}
+};
+MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
+
+static const struct acpi_device_id dw_i2c_acpi_match[] = {
+ { "80860F41", ACCESS_NO_IRQ_SUSPEND },
+ { "808622C1", ACCESS_NO_IRQ_SUSPEND },
+ { "AMD0010", ACCESS_INTR_MASK },
+ { "AMDI0010", ACCESS_INTR_MASK },
+ { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
+ { "AMDI0510", 0 },
+ { "APMC0D0F", 0 },
+ { "HISI02A1", 0 },
+ { "HISI02A2", 0 },
+ { "HISI02A3", 0 },
+ { "HYGO0010", ACCESS_INTR_MASK },
+ { "INT33C2", 0 },
+ { "INT33C3", 0 },
+ { "INT3432", 0 },
+ { "INT3433", 0 },
+ { "INTC10EF", 0 },
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
+
static const struct platform_device_id dw_i2c_platform_ids[] = {
{ "i2c_designware" },
{}
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 6/7] i2c: designware: Drop return value from i2c_dw_acpi_configure()
2024-08-19 8:39 [PATCH v2 0/7] i2c: designware: Cleanups (part 1) Andy Shevchenko
` (4 preceding siblings ...)
2024-08-19 8:39 ` [PATCH v2 5/7] i2c: designware: Always provide " Andy Shevchenko
@ 2024-08-19 8:39 ` Andy Shevchenko
2024-08-19 8:39 ` [PATCH v2 7/7] i2c: designware: Drop return value from dw_i2c_of_configure() Andy Shevchenko
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-19 8:39 UTC (permalink / raw)
To: Jarkko Nikula, Andi Shyti, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips
i2c_dw_acpi_configure() is called without checking of the returned
value, hence just drop it by converting to void.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 4 +---
drivers/i2c/busses/i2c-designware-core.h | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 4160c5e57df4..f0d7cad92f1c 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -255,7 +255,7 @@ static void i2c_dw_acpi_params(struct device *device, char method[],
kfree(buf.pointer);
}
-int i2c_dw_acpi_configure(struct device *device)
+void i2c_dw_acpi_configure(struct device *device)
{
struct dw_i2c_dev *dev = dev_get_drvdata(device);
struct i2c_timings *t = &dev->timings;
@@ -285,8 +285,6 @@ int i2c_dw_acpi_configure(struct device *device)
dev->sda_hold_time = fs_ht;
break;
}
-
- return 0;
}
EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure);
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 3e48f446ce53..ebcf816b731c 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -420,7 +420,7 @@ int i2c_dw_validate_speed(struct dw_i2c_dev *dev);
void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev);
#if IS_ENABLED(CONFIG_ACPI)
-int i2c_dw_acpi_configure(struct device *device);
+void i2c_dw_acpi_configure(struct device *device);
#else
-static inline int i2c_dw_acpi_configure(struct device *device) { return -ENODEV; }
+static inline void i2c_dw_acpi_configure(struct device *device) { }
#endif
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 7/7] i2c: designware: Drop return value from dw_i2c_of_configure()
2024-08-19 8:39 [PATCH v2 0/7] i2c: designware: Cleanups (part 1) Andy Shevchenko
` (5 preceding siblings ...)
2024-08-19 8:39 ` [PATCH v2 6/7] i2c: designware: Drop return value from i2c_dw_acpi_configure() Andy Shevchenko
@ 2024-08-19 8:39 ` Andy Shevchenko
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-19 8:39 UTC (permalink / raw)
To: Jarkko Nikula, Andi Shyti, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips, Mario Limonciello
dw_i2c_of_configure() is called without checking of the returned
value, hence just drop it by converting to void.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 6328ae943a34..340c9e9a450a 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -110,7 +110,7 @@ static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
return 0;
}
-static int dw_i2c_of_configure(struct platform_device *pdev)
+static void dw_i2c_of_configure(struct platform_device *pdev)
{
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
@@ -123,8 +123,6 @@ static int dw_i2c_of_configure(struct platform_device *pdev)
default:
break;
}
-
- return 0;
}
#else
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
@@ -132,9 +130,8 @@ static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
return -ENODEV;
}
-static inline int dw_i2c_of_configure(struct platform_device *pdev)
+static inline void dw_i2c_of_configure(struct platform_device *pdev)
{
- return -ENODEV;
}
#endif
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread