i2c: designware: Cleanups (part 1)
Subsystems (3)
Andy Shevchenko
reviewercover i2c: designware: Cleanups (part 1)
This is the subset of the patches [1] that should not affect any functionality. Here is the unification of ID tables, a couple of function prototypes, and other small cleanups.
In any case this is Cc'ed to AMD who reported a problem in [1] presumably in the patch that is *not* included here.
Andy Shevchenko (7):
i2c: designware: Replace a while-loop by for-loop
i2c: designware: Let PCI core to take care about interrupt vectors
i2c: designware: Add missing 'c' into PCI IDs variable name
i2c: designware: Unify terminator in device ID tables
i2c: designware: Always provide device ID tables
i2c: designware: Drop return value from i2c_dw_acpi_configure()
i2c: designware: Drop return value from dw_i2c_of_configure()
drivers/i2c/busses/i2c-designware-common.c | 4 +- drivers/i2c/busses/i2c-designware-core.h | 4 +- drivers/i2c/busses/i2c-designware-pcidrv.c | 22 +++------ drivers/i2c/busses/i2c-designware-platdrv.c | 50 +++++++++++++-------- 4 files changed, 42 insertions(+), 38 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Andy Shevchenko
reviewerPATCH 1/7 i2c: designware: Replace a while-loop by for-loop
Replace a while-loop by for-loop in i2c_dw_probe_lock_support() to save a few lines of code.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +1 -4
@@ -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 ; }
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Andy Shevchenko
reviewerPATCH 2/7 i2c: designware: Let PCI core to take care about interrupt vectors
In reply to Andy ShevchenkoPCI core, after pcim_enable_device(), takes care about the allocated IRQ vectors, no need to do it explicitly and break the cleaning up order.
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +3 -11
@@ -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[] = {
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Andy Shevchenko
reviewerPATCH 3/7 i2c: designware: Add missing 'c' into PCI IDs variable name
In reply to Andy ShevchenkoAdd missing 'c' into i2c_designware_pci_ids variable name.
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +3 -3
@@ -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);
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Andy Shevchenko
reviewerPATCH 4/7 i2c: designware: Unify terminator in device ID tables
In reply to Andy ShevchenkoMake the terminator entry look the same in all device ID tables.
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 2 +- drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +1 -1
@@ -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);
drivers/i2c/busses/i2c-designware-platdrv.c +2 -2
@@ -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
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Andy Shevchenko
reviewerPATCH 5/7 i2c: designware: Always provide device ID tables
In reply to Andy ShevchenkoThere 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.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 36 ++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +28 -8
@@ -149,14 +149,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 +469,34 @@ 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 }, + {} +}; +MODULE_DEVICE_TABLE (acpi, dw_i2c_acpi_match); +static const struct platform_device_id dw_i2c_platform_ids[] = { {"i2c_designware" }, {}
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
kernel test robot
build botRe: [PATCH v1 5/7] i2c: designware: Always provide device ID tables
kernel test robot noticed the following build warnings:
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.11-rc3 next-20240816] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-designware-Replace-a-while-loop-by-for-loop/20240817-011616 base: https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host patch link: https://lore.kernel.org/r/20240816171225.3506844-6-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 5/7] i2c: designware: Always provide device ID tables config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20240817/[email protected]/config) compiler: s390-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240817/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/i2c/busses/i2c-designware-platdrv.c:480:36: warning: 'dw_i2c_acpi_match' defined but not used [-Wunused-const-variable=]
480 | static const struct acpi_device_id dw_i2c_acpi_match[] = {
| ^~~~~~~~~~~~~~~~~vim +/dw_i2c_acpi_match +480 drivers/i2c/busses/i2c-designware-platdrv.c
479
> 480 static const struct acpi_device_id dw_i2c_acpi_match[] = { 481 { "80860F41", ACCESS_NO_IRQ_SUSPEND },
482 { "808622C1", ACCESS_NO_IRQ_SUSPEND },
483 { "AMD0010", ACCESS_INTR_MASK },
484 { "AMDI0010", ACCESS_INTR_MASK },
485 { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
486 { "AMDI0510", 0 },
487 { "APMC0D0F", 0 },
488 { "HISI02A1", 0 },
489 { "HISI02A2", 0 },
490 { "HISI02A3", 0 },
491 { "HYGO0010", ACCESS_INTR_MASK },
492 { "INT33C2", 0 },
493 { "INT33C3", 0 },
494 { "INT3432", 0 },
495 { "INT3433", 0 },
496 {}
497 };
498 MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
499
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v1 5/7] i2c: designware: Always provide device ID tables
In reply to Andy Shevchenkokernel test robot noticed the following build errors:
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on andi-shyti/i2c/i2c-host]
[also build test ERROR on linus/master v6.11-rc3 next-20240816] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-designware-Replace-a-while-loop-by-for-loop/20240817-011616 base: https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host patch link: https://lore.kernel.org/r/20240816171225.3506844-6-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 5/7] i2c: designware: Always provide device ID tables config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20240817/[email protected]/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240817/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/i2c/busses/i2c-designware-platdrv.c:480:36: error: redefinition of 'dw_i2c_acpi_match'
480 | static const struct acpi_device_id dw_i2c_acpi_match[] = {
| ^
drivers/i2c/busses/i2c-designware-platdrv.c:44:36: note: previous definition is here
44 | static const struct acpi_device_id dw_i2c_acpi_match[] = {
| ^1 error generated.
vim +/dw_i2c_acpi_match +480 drivers/i2c/busses/i2c-designware-platdrv.c
479
> 480 static const struct acpi_device_id dw_i2c_acpi_match[] = { 481 { "80860F41", ACCESS_NO_IRQ_SUSPEND },
482 { "808622C1", ACCESS_NO_IRQ_SUSPEND },
483 { "AMD0010", ACCESS_INTR_MASK },
484 { "AMDI0010", ACCESS_INTR_MASK },
485 { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
486 { "AMDI0510", 0 },
487 { "APMC0D0F", 0 },
488 { "HISI02A1", 0 },
489 { "HISI02A2", 0 },
490 { "HISI02A3", 0 },
491 { "HYGO0010", ACCESS_INTR_MASK },
492 { "INT33C2", 0 },
493 { "INT33C3", 0 },
494 { "INT3432", 0 },
495 { "INT3433", 0 },
496 {}
497 };
498 MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
499
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v1 5/7] i2c: designware: Always provide device ID tables
In reply to Andy Shevchenkokernel test robot noticed the following build warnings:
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.11-rc3 next-20240816] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-designware-Replace-a-while-loop-by-for-loop/20240817-011616 base: https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host patch link: https://lore.kernel.org/r/20240816171225.3506844-6-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 5/7] i2c: designware: Always provide device ID tables config: i386-buildonly-randconfig-001-20240817 (https://download.01.org/0day-ci/archive/20240817/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240817/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/i2c/busses/i2c-designware-platdrv.c:480:36: warning: 'dw_i2c_acpi_match' defined but not used [-Wunused-const-variable=]
480 | static const struct acpi_device_id dw_i2c_acpi_match[] = {
| ^~~~~~~~~~~~~~~~~
>> drivers/i2c/busses/i2c-designware-platdrv.c:472:34: warning: 'dw_i2c_of_match' defined but not used [-Wunused-const-variable=]
472 | static const struct of_device_id dw_i2c_of_match[] = {
| ^~~~~~~~~~~~~~~vim +/dw_i2c_of_match +472 drivers/i2c/busses/i2c-designware-platdrv.c
471
> 472 static const struct of_device_id dw_i2c_of_match[] = { 473 { .compatible = "snps,designware-i2c", },
474 { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
475 { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
476 {}
477 };
478 MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
479
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Andy Shevchenko
reviewerPATCH 6/7 i2c: designware: Drop return value from i2c_dw_acpi_configure()
In reply to Andy Shevchenkoi2c_dw_acpi_configure() is called without checking of the returned value, hence just drop it by converting to void.
--- drivers/i2c/busses/i2c-designware-common.c | 4 +--- drivers/i2c/busses/i2c-designware-core.h | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +1 -3
@@ -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);
drivers/i2c/busses/i2c-designware-core.h +2 -2
@@ -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
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Andy Shevchenko
reviewerPATCH 7/7 i2c: designware: Drop return value from dw_i2c_of_configure()
In reply to Andy Shevchenkodw_i2c_of_configure() is called without checking of the returned value, hence just drop it by converting to void.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +2 -5
@@ -133,7 +133,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);
@@ -146,8 +146,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)
@@ -155,9 +153,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
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac