* [PATCH v1 1/5] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure()
2024-08-22 17:58 [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andy Shevchenko
@ 2024-08-22 17:58 ` Andy Shevchenko
2024-08-22 17:58 ` [PATCH v1 2/5] i2c: designware: Consolidate firmware parsing and configuring code Andy Shevchenko
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-22 17:58 UTC (permalink / raw)
To: Andi Shyti, Jarkko Nikula, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips, Mario Limonciello
For the sake of consistency, rename dw_i2c_of_configure() and change
its parameter to be aligned with the i2c_dw_acpi_configure().
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 | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index cd24d2b8becf..981a2d399c9f 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -110,9 +110,10 @@ static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
return 0;
}
-static void dw_i2c_of_configure(struct platform_device *pdev)
+static void i2c_dw_of_configure(struct device *device)
{
- struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
+ struct platform_device *pdev = to_platform_device(device);
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
switch (dev->flags & MODEL_MASK) {
case MODEL_MSCC_OCELOT:
@@ -130,7 +131,7 @@ static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
return -ENODEV;
}
-static inline void dw_i2c_of_configure(struct platform_device *pdev)
+static inline void i2c_dw_of_configure(struct device *device)
{
}
#endif
@@ -276,7 +277,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
i2c_dw_adjust_bus_speed(dev);
if (pdev->dev.of_node)
- dw_i2c_of_configure(pdev);
+ i2c_dw_of_configure(&pdev->dev);
if (has_acpi_companion(&pdev->dev))
i2c_dw_acpi_configure(&pdev->dev);
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 2/5] i2c: designware: Consolidate firmware parsing and configuring code
2024-08-22 17:58 [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andy Shevchenko
2024-08-22 17:58 ` [PATCH v1 1/5] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure() Andy Shevchenko
@ 2024-08-22 17:58 ` Andy Shevchenko
2024-08-22 17:58 ` [PATCH v1 3/5] i2c: designware: Unify the firmware type checks Andy Shevchenko
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-22 17:58 UTC (permalink / raw)
To: Andi Shyti, Jarkko Nikula, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips, Mario Limonciello
We have the same code flows in the PCI and plaform drivers. Moreover,
the flow requires the common code to export a few functions. Instead,
consolidate that flow under new function called
i2c_dw_fw_parse_and_configure() and drop unneeded exports.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 68 +++++++++++++++++++--
drivers/i2c/busses/i2c-designware-core.h | 9 +--
drivers/i2c/busses/i2c-designware-pcidrv.c | 11 +---
drivers/i2c/busses/i2c-designware-platdrv.c | 48 +--------------
4 files changed, 66 insertions(+), 70 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index f0d7cad92f1c..b0d3c47d93ce 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -20,6 +20,7 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/swab.h>
@@ -188,7 +189,7 @@ static const u32 supported_speeds[] = {
I2C_MAX_STANDARD_MODE_FREQ,
};
-int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
+static int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
{
struct i2c_timings *t = &dev->timings;
unsigned int i;
@@ -208,7 +209,44 @@ int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
return -EINVAL;
}
-EXPORT_SYMBOL_GPL(i2c_dw_validate_speed);
+
+#ifdef CONFIG_OF
+
+#include <linux/platform_device.h>
+
+#define MSCC_ICPU_CFG_TWI_DELAY 0x0
+#define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0)
+#define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4
+
+static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
+{
+ writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE,
+ dev->ext + MSCC_ICPU_CFG_TWI_DELAY);
+
+ return 0;
+}
+
+static void i2c_dw_of_configure(struct device *device)
+{
+ struct platform_device *pdev = to_platform_device(device);
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
+
+ switch (dev->flags & MODEL_MASK) {
+ case MODEL_MSCC_OCELOT:
+ dev->ext = devm_platform_ioremap_resource(pdev, 1);
+ if (!IS_ERR(dev->ext))
+ dev->set_sda_hold_time = mscc_twi_set_sda_hold_time;
+ break;
+ default:
+ break;
+ }
+}
+
+#else /* CONFIG_OF */
+
+static inline void i2c_dw_of_configure(struct device *device) { }
+
+#endif /* CONFIG_OF */
#ifdef CONFIG_ACPI
@@ -255,7 +293,7 @@ static void i2c_dw_acpi_params(struct device *device, char method[],
kfree(buf.pointer);
}
-void i2c_dw_acpi_configure(struct device *device)
+static void i2c_dw_acpi_configure(struct device *device)
{
struct dw_i2c_dev *dev = dev_get_drvdata(device);
struct i2c_timings *t = &dev->timings;
@@ -286,7 +324,6 @@ void i2c_dw_acpi_configure(struct device *device)
break;
}
}
-EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure);
static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
{
@@ -308,11 +345,13 @@ static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
#else /* CONFIG_ACPI */
+static inline void i2c_dw_acpi_configure(struct device *device) { }
+
static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; }
#endif /* CONFIG_ACPI */
-void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
+static void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
{
u32 acpi_speed = i2c_dw_acpi_round_bus_speed(dev->dev);
struct i2c_timings *t = &dev->timings;
@@ -328,7 +367,24 @@ void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
else
t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
}
-EXPORT_SYMBOL_GPL(i2c_dw_adjust_bus_speed);
+
+int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev)
+{
+ struct i2c_timings *t = &dev->timings;
+ struct device *device = dev->dev;
+
+ i2c_parse_fw_timings(device, t, false);
+
+ i2c_dw_adjust_bus_speed(dev);
+
+ if (device->of_node)
+ i2c_dw_of_configure(device);
+ if (has_acpi_companion(device))
+ i2c_dw_acpi_configure(device);
+
+ return i2c_dw_validate_speed(dev);
+}
+EXPORT_SYMBOL_GPL(i2c_dw_fw_parse_and_configure);
static u32 i2c_dw_read_scl_reg(struct dw_i2c_dev *dev, u32 reg)
{
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index ebcf816b731c..b9f97f4eedf5 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -416,11 +416,4 @@ int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev);
int i2c_dw_amdpsp_probe_lock_support(struct dw_i2c_dev *dev);
#endif
-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)
-void i2c_dw_acpi_configure(struct device *device);
-#else
-static inline void i2c_dw_acpi_configure(struct device *device) { }
-#endif
+int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev);
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index cbbcbcc265c9..14186230622d 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -253,7 +253,6 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
int r;
struct dw_pci_controller *controller;
struct dw_scl_sda_cfg *cfg;
- struct i2c_timings *t;
if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers))
return dev_err_probe(&pdev->dev, -EINVAL,
@@ -288,9 +287,6 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
dev->irq = pci_irq_vector(pdev, 0);
dev->flags |= controller->flags;
- t = &dev->timings;
- i2c_parse_fw_timings(&pdev->dev, t, false);
-
pci_set_drvdata(pdev, dev);
if (controller->setup) {
@@ -299,12 +295,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
return r;
}
- i2c_dw_adjust_bus_speed(dev);
-
- if (has_acpi_companion(&pdev->dev))
- i2c_dw_acpi_configure(&pdev->dev);
-
- r = i2c_dw_validate_speed(dev);
+ r = i2c_dw_fw_parse_and_configure(dev);
if (r)
return r;
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 981a2d399c9f..7e2f26d0593e 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -21,7 +21,6 @@
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
-#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
@@ -97,43 +96,11 @@ static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
dev->map = devm_regmap_init(dev->dev, NULL, dev, &bt1_i2c_cfg);
return PTR_ERR_OR_ZERO(dev->map);
}
-
-#define MSCC_ICPU_CFG_TWI_DELAY 0x0
-#define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0)
-#define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4
-
-static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
-{
- writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE,
- dev->ext + MSCC_ICPU_CFG_TWI_DELAY);
-
- return 0;
-}
-
-static void i2c_dw_of_configure(struct device *device)
-{
- struct platform_device *pdev = to_platform_device(device);
- struct dw_i2c_dev *dev = dev_get_drvdata(device);
-
- switch (dev->flags & MODEL_MASK) {
- case MODEL_MSCC_OCELOT:
- dev->ext = devm_platform_ioremap_resource(pdev, 1);
- if (!IS_ERR(dev->ext))
- dev->set_sda_hold_time = mscc_twi_set_sda_hold_time;
- break;
- default:
- break;
- }
-}
#else
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
{
return -ENODEV;
}
-
-static inline void i2c_dw_of_configure(struct device *device)
-{
-}
#endif
static int txgbe_i2c_request_regs(struct dw_i2c_dev *dev)
@@ -242,7 +209,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
{
struct i2c_adapter *adap;
struct dw_i2c_dev *dev;
- struct i2c_timings *t;
int irq, ret;
irq = platform_get_irq(pdev, 0);
@@ -271,18 +237,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
reset_control_deassert(dev->rst);
- t = &dev->timings;
- i2c_parse_fw_timings(&pdev->dev, t, false);
-
- i2c_dw_adjust_bus_speed(dev);
-
- if (pdev->dev.of_node)
- i2c_dw_of_configure(&pdev->dev);
-
- if (has_acpi_companion(&pdev->dev))
- i2c_dw_acpi_configure(&pdev->dev);
-
- ret = i2c_dw_validate_speed(dev);
+ ret = i2c_dw_fw_parse_and_configure(dev);
if (ret)
goto exit_reset;
@@ -310,6 +265,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
goto exit_reset;
if (dev->clk) {
+ struct i2c_timings *t = &dev->timings;
u64 clk_khz;
dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 3/5] i2c: designware: Unify the firmware type checks
2024-08-22 17:58 [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andy Shevchenko
2024-08-22 17:58 ` [PATCH v1 1/5] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure() Andy Shevchenko
2024-08-22 17:58 ` [PATCH v1 2/5] i2c: designware: Consolidate firmware parsing and configuring code Andy Shevchenko
@ 2024-08-22 17:58 ` Andy Shevchenko
2024-08-22 17:58 ` [PATCH v1 4/5] i2c: designware: Move exports to I2C_DW namespaces Andy Shevchenko
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-22 17:58 UTC (permalink / raw)
To: Andi Shyti, Jarkko Nikula, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips, Mario Limonciello
Instead of asymmetrical checks for the firmware type use
the is_*_node() calls.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index b0d3c47d93ce..2c460093b7ab 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/swab.h>
#include <linux/types.h>
@@ -372,14 +373,15 @@ int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev)
{
struct i2c_timings *t = &dev->timings;
struct device *device = dev->dev;
+ struct fwnode_handle *fwnode = dev_fwnode(device);
i2c_parse_fw_timings(device, t, false);
i2c_dw_adjust_bus_speed(dev);
- if (device->of_node)
+ if (is_of_node(fwnode))
i2c_dw_of_configure(device);
- if (has_acpi_companion(device))
+ else if (is_acpi_node(fwnode))
i2c_dw_acpi_configure(device);
return i2c_dw_validate_speed(dev);
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 4/5] i2c: designware: Move exports to I2C_DW namespaces
2024-08-22 17:58 [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andy Shevchenko
` (2 preceding siblings ...)
2024-08-22 17:58 ` [PATCH v1 3/5] i2c: designware: Unify the firmware type checks Andy Shevchenko
@ 2024-08-22 17:58 ` Andy Shevchenko
2024-08-22 17:58 ` [PATCH v1 5/5] i2c: designware: Remove ->disable() callback Andy Shevchenko
2024-08-23 0:45 ` [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andi Shyti
5 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-22 17:58 UTC (permalink / raw)
To: Andi Shyti, Jarkko Nikula, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips
Reduce scope of the I²C DesignWare driver exports to I2C_DW namespaces.
This will prevent abuse of the symbols and clean up global namespace.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 2 ++
drivers/i2c/busses/i2c-designware-master.c | 3 +++
drivers/i2c/busses/i2c-designware-pcidrv.c | 2 ++
drivers/i2c/busses/i2c-designware-platdrv.c | 2 ++
drivers/i2c/busses/i2c-designware-slave.c | 3 +++
5 files changed, 12 insertions(+)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 2c460093b7ab..2601876f76ad 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -28,6 +28,8 @@
#include <linux/types.h>
#include <linux/units.h>
+#define DEFAULT_SYMBOL_NAMESPACE I2C_DW_COMMON
+
#include "i2c-designware-core.h"
static char *abort_sources[] = {
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index d3b466592be4..a890a73e197e 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -22,6 +22,8 @@
#include <linux/regmap.h>
#include <linux/reset.h>
+#define DEFAULT_SYMBOL_NAMESPACE I2C_DW
+
#include "i2c-designware-core.h"
#define AMD_TIMEOUT_MIN_US 25
@@ -1037,3 +1039,4 @@ EXPORT_SYMBOL_GPL(i2c_dw_probe_master);
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus master adapter");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(I2C_DW_COMMON);
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 14186230622d..2f2085700594 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -410,3 +410,5 @@ module_pci_driver(dw_i2c_driver);
MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(I2C_DW);
+MODULE_IMPORT_NS(I2C_DW_COMMON);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 7e2f26d0593e..7a3f4e96d59e 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -462,3 +462,5 @@ module_exit(dw_i2c_exit_driver);
MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(I2C_DW);
+MODULE_IMPORT_NS(I2C_DW_COMMON);
diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
index 78e2c47e3d7d..5995361b5615 100644
--- a/drivers/i2c/busses/i2c-designware-slave.c
+++ b/drivers/i2c/busses/i2c-designware-slave.c
@@ -16,6 +16,8 @@
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
+#define DEFAULT_SYMBOL_NAMESPACE I2C_DW
+
#include "i2c-designware-core.h"
static void i2c_dw_configure_fifo_slave(struct dw_i2c_dev *dev)
@@ -279,3 +281,4 @@ EXPORT_SYMBOL_GPL(i2c_dw_probe_slave);
MODULE_AUTHOR("Luis Oliveira <lolivei@synopsys.com>");
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus slave adapter");
MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(I2C_DW_COMMON);
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 5/5] i2c: designware: Remove ->disable() callback
2024-08-22 17:58 [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andy Shevchenko
` (3 preceding siblings ...)
2024-08-22 17:58 ` [PATCH v1 4/5] i2c: designware: Move exports to I2C_DW namespaces Andy Shevchenko
@ 2024-08-22 17:58 ` Andy Shevchenko
2024-08-23 0:45 ` [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andi Shyti
5 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-22 17:58 UTC (permalink / raw)
To: Andi Shyti, Jarkko Nikula, Andy Shevchenko, linux-i2c,
linux-kernel
Cc: Mika Westerberg, Jan Dabros, Narasimhan.V, Borislav Petkov,
Kim Phillips
Commit 90312351fd1e ("i2c: designware: MASTER mode as separated driver")
introduced ->disable() callback but there is no real use for it. Both
i2c-designware-master.c and i2c-designware-slave.c set it to the same
i2c_dw_disable() and scope is inside the same kernel module.
That said, replace the callback by explicitly calling the i2c_dw_disable().
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 1 +
drivers/i2c/busses/i2c-designware-core.h | 4 +---
drivers/i2c/busses/i2c-designware-master.c | 1 -
drivers/i2c/busses/i2c-designware-pcidrv.c | 5 +++--
drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++--
drivers/i2c/busses/i2c-designware-slave.c | 3 +--
6 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 2601876f76ad..b60c55587e48 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -734,6 +734,7 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)
i2c_dw_release_lock(dev);
}
+EXPORT_SYMBOL_GPL(i2c_dw_disable);
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter core");
MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index b9f97f4eedf5..723d599cca93 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -237,7 +237,6 @@ struct reset_control;
* @semaphore_idx: Index of table with semaphore type attached to the bus. It's
* -1 if there is no semaphore.
* @shared_with_punit: true if this bus is shared with the SoCs PUNIT
- * @disable: function to disable the controller
* @init: function to initialize the I2C hardware
* @set_sda_hold_time: callback to retrieve IP specific SDA hold timing
* @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE
@@ -295,7 +294,6 @@ struct dw_i2c_dev {
void (*release_lock)(void);
int semaphore_idx;
bool shared_with_punit;
- void (*disable)(struct dw_i2c_dev *dev);
int (*init)(struct dw_i2c_dev *dev);
int (*set_sda_hold_time)(struct dw_i2c_dev *dev);
int mode;
@@ -342,7 +340,6 @@ int i2c_dw_wait_bus_not_busy(struct dw_i2c_dev *dev);
int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev);
int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev);
u32 i2c_dw_func(struct i2c_adapter *adap);
-void i2c_dw_disable(struct dw_i2c_dev *dev);
static inline void __i2c_dw_enable(struct dw_i2c_dev *dev)
{
@@ -375,6 +372,7 @@ static inline void __i2c_dw_read_intr_mask(struct dw_i2c_dev *dev,
}
void __i2c_dw_disable(struct dw_i2c_dev *dev);
+void i2c_dw_disable(struct dw_i2c_dev *dev);
extern void i2c_dw_configure_master(struct dw_i2c_dev *dev);
extern int i2c_dw_probe_master(struct dw_i2c_dev *dev);
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index a890a73e197e..e46f1b22c360 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -949,7 +949,6 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
init_completion(&dev->cmd_complete);
dev->init = i2c_dw_init_master;
- dev->disable = i2c_dw_disable;
ret = i2c_dw_init_regmap(dev);
if (ret)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 2f2085700594..dd188ccd961e 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -198,7 +198,7 @@ static int __maybe_unused i2c_dw_pci_runtime_suspend(struct device *dev)
{
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
- i_dev->disable(i_dev);
+ i2c_dw_disable(i_dev);
return 0;
}
@@ -339,7 +339,8 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
{
struct dw_i2c_dev *dev = pci_get_drvdata(pdev);
- dev->disable(dev);
+ i2c_dw_disable(dev);
+
pm_runtime_forbid(&pdev->dev);
pm_runtime_get_noresume(&pdev->dev);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 7a3f4e96d59e..e49c68c6e142 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -328,7 +328,7 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
i2c_del_adapter(&dev->adapter);
- dev->disable(dev);
+ i2c_dw_disable(dev);
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_put_sync(&pdev->dev);
@@ -357,7 +357,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev)
if (i_dev->shared_with_punit)
return 0;
- i_dev->disable(i_dev);
+ i2c_dw_disable(i_dev);
i2c_dw_prepare_clk(i_dev, false);
return 0;
diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
index 5995361b5615..7035296aa24c 100644
--- a/drivers/i2c/busses/i2c-designware-slave.c
+++ b/drivers/i2c/busses/i2c-designware-slave.c
@@ -90,7 +90,7 @@ static int i2c_dw_unreg_slave(struct i2c_client *slave)
struct dw_i2c_dev *dev = i2c_get_adapdata(slave->adapter);
regmap_write(dev->map, DW_IC_INTR_MASK, 0);
- dev->disable(dev);
+ i2c_dw_disable(dev);
synchronize_irq(dev->irq);
dev->slave = NULL;
pm_runtime_put(dev->dev);
@@ -237,7 +237,6 @@ int i2c_dw_probe_slave(struct dw_i2c_dev *dev)
int ret;
dev->init = i2c_dw_init_slave;
- dev->disable = i2c_dw_disable;
ret = i2c_dw_init_regmap(dev);
if (ret)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v1 0/5] i2c: designware: Cleanups (part 2)
2024-08-22 17:58 [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andy Shevchenko
` (4 preceding siblings ...)
2024-08-22 17:58 ` [PATCH v1 5/5] i2c: designware: Remove ->disable() callback Andy Shevchenko
@ 2024-08-23 0:45 ` Andi Shyti
2024-08-23 13:31 ` Andy Shevchenko
5 siblings, 1 reply; 8+ messages in thread
From: Andi Shyti @ 2024-08-23 0:45 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jarkko Nikula, linux-i2c, linux-kernel, Mika Westerberg,
Jan Dabros, Narasimhan.V, Borislav Petkov, Kim Phillips
Hi Andy,
On Thu, Aug 22, 2024 at 08:58:36PM GMT, Andy Shevchenko wrote:
> This is the subset of the patches [1] that should not affect any
> functionality. Here are:
> - consolidation of FW parsing and configuring code
> - some function renaming / dropping
> - switching to export namespace
>
> In any case this is Cc'ed to AMD who reported a problem in [1]
> presumably in the patch that is *not* included here.
>
> Link: https://lore.kernel.org/linux-i2c/20231207141653.2785124-1-andriy.shevchenko@linux.intel.com/ [1]
>
> Andy Shevchenko (5):
> i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure()
> i2c: designware: Consolidate firmware parsing and configuring code
> i2c: designware: Unify the firmware type checks
> i2c: designware: Move exports to I2C_DW namespaces
> i2c: designware: Remove ->disable() callback
I merged these patches in i2c/i2c-host. Normally I leave patches
a bit longer in the list, but they have been reviewed and
discussed.
If there will come some observations from others, we are in time
to change them.
Thanks,
Andi
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v1 0/5] i2c: designware: Cleanups (part 2)
2024-08-23 0:45 ` [PATCH v1 0/5] i2c: designware: Cleanups (part 2) Andi Shyti
@ 2024-08-23 13:31 ` Andy Shevchenko
0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2024-08-23 13:31 UTC (permalink / raw)
To: Andi Shyti
Cc: Jarkko Nikula, linux-i2c, linux-kernel, Mika Westerberg,
Jan Dabros, Narasimhan.V, Borislav Petkov, Kim Phillips
On Fri, Aug 23, 2024 at 02:45:58AM +0200, Andi Shyti wrote:
> On Thu, Aug 22, 2024 at 08:58:36PM GMT, Andy Shevchenko wrote:
> > This is the subset of the patches [1] that should not affect any
> > functionality. Here are:
> > - consolidation of FW parsing and configuring code
> > - some function renaming / dropping
> > - switching to export namespace
> >
> > In any case this is Cc'ed to AMD who reported a problem in [1]
> > presumably in the patch that is *not* included here.
> >
> > Link: https://lore.kernel.org/linux-i2c/20231207141653.2785124-1-andriy.shevchenko@linux.intel.com/ [1]
> >
> > Andy Shevchenko (5):
> > i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure()
> > i2c: designware: Consolidate firmware parsing and configuring code
> > i2c: designware: Unify the firmware type checks
> > i2c: designware: Move exports to I2C_DW namespaces
> > i2c: designware: Remove ->disable() callback
>
> I merged these patches in i2c/i2c-host.
Thank you!
> Normally I leave patches a bit longer in the list, but they have been
> reviewed and discussed.
FWIW, there is no change done to them except rebasing to avoid that suspicious
PM patch to be included.
> If there will come some observations from others, we are in time
> to change them.
Yes, I am here to help.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread