Skip to contentSkip to conversation

i2c: designware: Cleanups (part 3)

PATCH Applied Andy Shevchenko 2 participants 5 messages Sep 10, 2024 – Sep 11, 2024

Subsystems (3)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

cover i2c: designware: Cleanups (part 3)

This is the subset of the patches [1] that should not affect any functionality, i.e. consolidation setting of the firmware node.

Andy Shevchenko (3):
i2c: designware: Uninline i2c_dw_probe()
i2c: designware: Propagate firmware node
i2c: designware: Use pci_get_drvdata()

 drivers/i2c/busses/i2c-designware-common.c  | 16 ++++++++++++++++
 drivers/i2c/busses/i2c-designware-core.h    | 17 ++---------------
 drivers/i2c/busses/i2c-designware-pcidrv.c  |  6 ++----
 drivers/i2c/busses/i2c-designware-platdrv.c |  3 ---
 4 files changed, 20 insertions(+), 22 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
author reviewer
#1 lore raw

PATCH 1/3 i2c: designware: Uninline i2c_dw_probe()

Since i2c_dw_probe() is going to be extended, uninline it to reduce the noise in the common header.

---
 drivers/i2c/busses/i2c-designware-common.c | 14 ++++++++++++++
 drivers/i2c/busses/i2c-designware-core.h   | 17 ++---------------
 2 files changed, 16 insertions(+), 15 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +14 -0
index fb65fe6d8122..a6dbccd85565 100644
@@ -737,6 +737,20 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)
 }
 EXPORT_SYMBOL_GPL(i2c_dw_disable);
 
+int i2c_dw_probe(struct dw_i2c_dev *dev)
+{
+	switch (dev->mode) {
+	case DW_IC_SLAVE:
+		return i2c_dw_probe_slave(dev);
+	case DW_IC_MASTER:
+		return i2c_dw_probe_master(dev);
+	default:
+		dev_err(dev->dev, "Wrong operation mode: %d\n", dev->mode);
+		return -EINVAL;
+	}
+}
+EXPORT_SYMBOL_GPL(i2c_dw_probe);
+
 static int i2c_dw_prepare(struct device *device)
 {
 	/*
drivers/i2c/busses/i2c-designware-core.h +2 -15
index c6bd6f65a2d3..1ac2afd03a0a 100644
@@ -10,9 +10,7 @@
  */
 
 #include <linux/bits.h>
-#include <linux/compiler_types.h>
 #include <linux/completion.h>
-#include <linux/dev_printk.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
 #include <linux/pm.h>
@@ -388,19 +386,6 @@ static inline void i2c_dw_configure_slave(struct dw_i2c_dev *dev) { }
 static inline int i2c_dw_probe_slave(struct dw_i2c_dev *dev) { return -EINVAL; }
 #endif
 
-static inline int i2c_dw_probe(struct dw_i2c_dev *dev)
-{
-	switch (dev->mode) {
-	case DW_IC_SLAVE:
-		return i2c_dw_probe_slave(dev);
-	case DW_IC_MASTER:
-		return i2c_dw_probe_master(dev);
-	default:
-		dev_err(dev->dev, "Wrong operation mode: %d\n", dev->mode);
-		return -EINVAL;
-	}
-}
-
 static inline void i2c_dw_configure(struct dw_i2c_dev *dev)
 {
 	if (i2c_detect_slave_mode(dev->dev))
@@ -409,6 +394,8 @@ static inline void i2c_dw_configure(struct dw_i2c_dev *dev)
 		i2c_dw_configure_master(dev);
 }
 
+int i2c_dw_probe(struct dw_i2c_dev *dev);
+
 #if IS_ENABLED(CONFIG_I2C_DESIGNWARE_BAYTRAIL)
 int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev);
 #endif
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
author reviewer
#2 lore raw

PATCH 2/3 i2c: designware: Propagate firmware node

In reply to Andy Shevchenko

Propagate firmware node by using a specific API call, i.e. device_set_node().

---
 drivers/i2c/busses/i2c-designware-common.c  | 2 ++
 drivers/i2c/busses/i2c-designware-pcidrv.c  | 2 --
 drivers/i2c/busses/i2c-designware-platdrv.c | 3 ---
 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +2 -0
index a6dbccd85565..080204182bb5 100644
@@ -739,6 +739,8 @@ EXPORT_SYMBOL_GPL(i2c_dw_disable);
 
 int i2c_dw_probe(struct dw_i2c_dev *dev)
 {
+	device_set_node(&dev->adapter.dev, dev_fwnode(dev->dev));
+
 	switch (dev->mode) {
 	case DW_IC_SLAVE:
 		return i2c_dw_probe_slave(dev);
drivers/i2c/busses/i2c-designware-pcidrv.c +0 -2
index 04377533f3ae..64f7bd8c7faf 100644
@@ -9,7 +9,6 @@
  * Copyright (C) 2009 Provigent Ltd.
  * Copyright (C) 2011, 2015, 2016 Intel Corporation.
  */
-#include <linux/acpi.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/errno.h>
@@ -273,7 +272,6 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 	adap = &dev->adapter;
 	adap->owner = THIS_MODULE;
 	adap->class = 0;
-	ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
 	adap->nr = controller->bus_num;
 
 	r = i2c_dw_probe(dev);
drivers/i2c/busses/i2c-designware-platdrv.c +0 -3
index 732e444d0dfc..36041e624e3e 100644
@@ -8,7 +8,6 @@
  * Copyright (C) 2007 MontaVista Software Inc.
  * Copyright (C) 2009 Provigent Ltd.
  */
-#include <linux/acpi.h>
 #include <linux/clk-provider.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
@@ -279,8 +278,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	adap->owner = THIS_MODULE;
 	adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ?
 					I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED;
-	ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
-	adap->dev.of_node = pdev->dev.of_node;
 	adap->nr = -1;
 
 	if (dev->flags & ACCESS_NO_IRQ_SUSPEND) {
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
author reviewer
#3 lore raw

PATCH 3/3 i2c: designware: Use pci_get_drvdata()

In reply to Andy Shevchenko

Use the wrapper function for getting the driver data using pci_dev instead of using dev_get_drvdata() with &pdev->dev, so we can directly pass a struct pci_dev. This is a purely cosmetic change.

---
 drivers/i2c/busses/i2c-designware-pcidrv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +2 -2
index 64f7bd8c7faf..7b2c5d71a7fc 100644
@@ -102,7 +102,7 @@ static u32 mfld_get_clk_rate_khz(struct dw_i2c_dev *dev)
 
 static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
 {
-	struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev);
+	struct dw_i2c_dev *dev = pci_get_drvdata(pdev);
 
 	switch (pdev->device) {
 	case 0x0817:
@@ -152,7 +152,7 @@ static u32 navi_amd_get_clk_rate_khz(struct dw_i2c_dev *dev)
 
 static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
 {
-	struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev);
+	struct dw_i2c_dev *dev = pci_get_drvdata(pdev);
 
 	dev->flags |= MODEL_AMD_NAVI_GPU | ACCESS_POLLING;
 	dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ;
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
maintainer Applied
#4 lore raw
In reply to Andy Shevchenko

Hi Andy,

Quoted 4 lines

Andy Shevchenko (3):
i2c: designware: Uninline i2c_dw_probe()
i2c: designware: Propagate firmware node
i2c: designware: Use pci_get_drvdata()

Merged to i2c/i2c-host.

Thanks,
Andi