Define i2c_designware in a header file
Subsystems (7)
v3 cover Define i2c_designware in a header file
This patch series depends upon the following two patches being applied:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
There is no reason why each driver should have to repeat the "i2c_designware" string all over the place, because when that happens we see the reverts like the above being necessary.
Given the dependency on the two other patches above, it would make sense to route this via the networking tree, or wait until a v6.9-rc containing the above two changes gets merged into one of the i2c/mfd trees.
Changes in v3:
- incorporate Andy's change removing the MODULE_ALIAS
- created a separate inclusion group as requested by Andy
- changed the string format in txgbe_phy.c
Changes in v2:
- avoid changing i2c-designware-pcidrv.c more than necessary
- move constant to include/linux/platform_data/i2c-designware.h
- add comments as to how this constant is used and why
Andy Shevchenko (1):
i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
Florian Fainelli (4):
i2c: designware: Create shared header hosting driver name
mfd: intel-lpss: Utilize i2c-designware.h
mfd: intel_quark_i2c_gpio: Utilize i2c-designware.h
net: txgbe: Utilize i2c-designware.h
MAINTAINERS | 1 + drivers/i2c/busses/i2c-designware-pcidrv.c | 2 -- drivers/i2c/busses/i2c-designware-platdrv.c | 12 +++++++++--- drivers/mfd/intel-lpss.c | 3 ++- drivers/mfd/intel_quark_i2c_gpio.c | 6 ++++-- drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c | 6 ++++-- include/linux/platform_data/i2c-designware.h | 12 ++++++++++++ 7 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 include/linux/platform_data/i2c-designware.h
Signature · 1 line
2.34.1
PATCH v3 1/5 i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
From: Andy Shevchenko <[email protected]>
As Krzysztof Kozlowski pointed out the better is to use MODULE_DEVICE_TABLE() as it will be consistent with the content of the real ID table of the platform devices.
While at it, drop unneeded and unused module alias in PCI glue driver as PCI already has its own ID table and automatic loading should just work.
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 2 -- drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +0 -2
@@ -424,8 +424,6 @@ static struct pci_driver dw_i2c_driver = { };module_pci_driver (dw_i2c_driver); -/* Work with hotplug and coldplug */ -MODULE_ALIAS ("i2c_designware-pci" );MODULE_AUTHOR ("Baruch Siach <[email protected]>" );MODULE_DESCRIPTION ("Synopsys DesignWare PCI I2C bus adapter" );MODULE_LICENSE ("GPL" );
drivers/i2c/busses/i2c-designware-platdrv.c +6 -2
@@ -479,8 +479,11 @@ 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 ) }; -/* Work with hotplug and coldplug */ -MODULE_ALIAS ("platform:i2c_designware" ); +static const struct platform_device_id dw_i2c_platform_ids[] = { + {"i2c_designware" }, + {} +}; +MODULE_DEVICE_TABLE (platform, dw_i2c_platform_ids);static struct platform_driver dw_i2c_driver = { .probe = dw_i2c_plat_probe,
@@ -491,6 +494,7 @@ static struct platform_driver dw_i2c_driver = { .acpi_match_table = ACPI_PTR(dw_i2c_acpi_match), .pm = pm_ptr(&dw_i2c_dev_pm_ops), }, + .id_table = dw_i2c_platform_ids, };static int __init dw_i2c_init_driver (void )
Signature · 1 line
2.34.1
PATCH v3 2/5 i2c: designware: Create shared header hosting driver name
In reply to Florian FainelliWe have a number of drivers that reference the string "i2c_designware" towards two goals:
- ensure their device gets bound to the i2c_designware platform_driver
- create a clock lookup reference that matches the i2c_designware instance number for the i2c-designware-platdrv.c driver to be able to lookup the input reference clock
Since this string is copied in a bunch of different places and since it is possible to get this named wrong (see [1] and [2]) with unintended consequences, create a header file that hosts that define for other drivers to use and all agree on the correct name to use.
--- MAINTAINERS | 1 + drivers/i2c/busses/i2c-designware-platdrv.c | 4 +++- include/linux/platform_data/i2c-designware.h | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 include/linux/platform_data/i2c-designware.h
MAINTAINERS +1 -0
@@ -21438,6 +21438,7 @@ R: Jan Dabros <[email protected]> L: [email protected] S: Supported F: drivers/i2c/busses/i2c-designware-* +F: include/linux/platform_data/i2c-designware.h SYNOPSYS DESIGNWARE MMC/SD/SDIO DRIVER M: Jaehoon Chung <[email protected]>
drivers/i2c/busses/i2c-designware-platdrv.c +3 -1
@@ -33,6 +33,8 @@#include <linux/suspend.h> #include <linux/units.h> +#include <linux/platform_data/i2c-designware.h> +#include "i2c-designware-core.h" static u32 i2c_dw_get_clk_rate_khz (struct dw_i2c_dev *dev)
@@ -489,7 +491,7 @@ static struct platform_driver dw_i2c_driver = { .probe = dw_i2c_plat_probe, .remove_new = dw_i2c_plat_remove, .driver = { - .name = "i2c_designware", + .name = I2C_DESIGNWARE_NAME, .of_match_table = of_match_ptr(dw_i2c_of_match), .acpi_match_table = ACPI_PTR(dw_i2c_acpi_match), .pm = pm_ptr(&dw_i2c_dev_pm_ops),
include/linux/platform_data/i2c-designware.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __I2C_DESIGNWARE_PDATA_H__ +#define __I2C_DESIGNWARE_PDATA_H__ + +/* +* This is the i2c-designware-platdrv.c platform driver name. This name is used +* to bind the device to the driver as well as by the driver itself to request +* the input reference clock. +*/ +#define I2C_DESIGNWARE_NAME "i2c_designware" + +#endif /* __I2C_DESIGNWARE_PDATA_H__ */
Signature · 1 line
2.34.1
PATCH v3 3/5 mfd: intel-lpss: Utilize i2c-designware.h
In reply to Florian FainelliRather than open code the i2c_designware string, utilize the newly defined constant in i2c-designware.h.
--- drivers/mfd/intel-lpss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mfd/intel-lpss.c +2 -1
@@ -33,6 +33,7 @@#include <linux/io-64-nonatomic-lo-hi.h> #include <linux/dma/idma64.h> +#include <linux/platform_data/i2c-designware.h> #include "intel-lpss.h"
@@ -116,7 +117,7 @@ static const struct mfd_cell intel_lpss_idma64_cell = { };static const struct mfd_cell intel_lpss_i2c_cell = { - .name ="i2c_designware" , + .name =I2C_DESIGNWARE_NAME , .num_resources =ARRAY_SIZE (intel_lpss_dev_resources), .resources = intel_lpss_dev_resources, };
Signature · 1 line
2.34.1
PATCH v3 4/5 mfd: intel_quark_i2c_gpio: Utilize i2c-designware.h
In reply to Florian FainelliRather than open code the i2c_designware string, utilize the newly defined constant in i2c-designware.h.
--- drivers/mfd/intel_quark_i2c_gpio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mfd/intel_quark_i2c_gpio.c +4 -2
@@ -19,6 +19,8 @@#include <linux/i2c.h> #include <linux/property.h> +#include <linux/platform_data/i2c-designware.h> +/* PCI BAR for register base address */ #define MFD_I2C_BAR 0#define MFD_GPIO_BAR 1
@@ -30,7 +32,7 @@#define INTEL_QUARK_IORES_MEM 0#define INTEL_QUARK_IORES_IRQ 1 -#define INTEL_QUARK_I2C_CONTROLLER_CLK "i2c_designware.0" +#define INTEL_QUARK_I2C_CONTROLLER_CLK I2C_DESIGNWARE_NAME ".0"/* The Quark I2C controller source clock */ #define INTEL_QUARK_I2C_CLK_HZ 33000000
@@ -136,7 +138,7 @@ static const struct software_node *intel_quark_gpio_node_group[] = {static struct mfd_cell intel_quark_mfd_cells[] = { [MFD_I2C_BAR ] = { .id =MFD_I2C_BAR , - .name ="i2c_designware" , + .name =I2C_DESIGNWARE_NAME , .acpi_match = &intel_quark_acpi_match_i2c, .num_resources =ARRAY_SIZE (intel_quark_i2c_res), .resources = intel_quark_i2c_res,
Signature · 1 line
2.34.1
Re: [PATCH v3 4/5] mfd: intel_quark_i2c_gpio: Utilize i2c-designware.h
Quoted 2 lines · Florian Fainelli
Rather than open code the
i2c_designwarestring, utilize the newly defined constant ini2c-designware.h.
P.S>
Note, my tags for MFD patches does not imply that I agree on the general idea of this series, it's just in case if it will be approved by the respective maintainers (I²C / MFD / etc).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andi Shyti
maintainerRe: [PATCH v3 4/5] mfd: intel_quark_i2c_gpio: Utilize i2c-designware.h
Hi Andy,
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Florian Fainelli
Rather than open code the
i2c_designwarestring, utilize the newly defined constant ini2c-designware.h.Acked-by Andy Shevchenko <[email protected]>
P.S>
Note, my tags for MFD patches does not imply that I agree on the general idea of this series, it's just in case if it will be approved by the respective maintainers (I²C / MFD / etc).
I waited a bit to see if more comments were coming.
Do you have a better approach in mind?
Andi
Re: [PATCH v3 4/5] mfd: intel_quark_i2c_gpio: Utilize i2c-designware.h
Quoted 7 lines · Andi Shyti
Hi Andy,
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · Florian Fainelli
Rather than open code the
i2c_designwarestring, utilize the newly defined constant ini2c-designware.h.
Quoted 9 lines
Quoted 6 lines
Acked-by Andy Shevchenko <[email protected]>
P.S>
Note, my tags for MFD patches does not imply that I agree on the general idea of this series, it's just in case if it will be approved by the respective maintainers (I²C / MFD / etc).I waited a bit to see if more comments were coming.
Well I had doubts about the idea will it help maintaining code or do the opposite but didn't receive a reply from the patch author:
https://lore.kernel.org/linux-i2c/[email protected]/
Also Lee Jones have similar concerns:
Lee Jones
maintainerRe: [PATCH v3 4/5] mfd: intel_quark_i2c_gpio: Utilize i2c-designware.h
Quoted 17 lines · Jarkko Nikula
Quoted 7 lines · Andi Shyti
Hi Andy,
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · Florian Fainelli
Rather than open code the
i2c_designwarestring, utilize the newly defined constant ini2c-designware.h.Quoted 9 lines
Quoted 6 lines
Acked-by Andy Shevchenko <[email protected]>
P.S>
Note, my tags for MFD patches does not imply that I agree on the general idea of this series, it's just in case if it will be approved by the respective maintainers (I²C / MFD / etc).I waited a bit to see if more comments were coming.
Quoted 8 lines
Well I had doubts about the idea will it help maintaining code or do the opposite but didn't receive a reply from the patch author:
https://lore.kernel.org/linux-i2c/[email protected]/
Also Lee Jones have similar concerns:
Right. It's a NACK from me, sorry.
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v3 4/5] mfd: intel_quark_i2c_gpio: Utilize i2c-designware.h
In reply to Jarkko NikulaQuoted 15 lines · Jarkko Nikula
Quoted 14 lines · Andi Shyti
Hi Andy,
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Florian Fainelli
Rather than open code the
i2c_designwarestring, utilize the newly defined constant ini2c-designware.h.Acked-by Andy Shevchenko <[email protected]>
P.S>
Note, my tags for MFD patches does not imply that I agree on the general idea of this series, it's just in case if it will be approved by the respective maintainers (I²C / MFD / etc).
Quoted 5 lines
Quoted 2 lines
I waited a bit to see if more comments were coming.
Well I had doubts about the idea will it help maintaining code or do the opposite but didn't receive a reply from the patch author:
I read your message and the fact that you provided a diff as a suggestion as to what would become acceptable if incorporating your suggested change, and made that a v3. If this was not acceptable to you from the get go, it would have been clearer with an explicit Nack like what others have done now.
Quoted 5 lines
Also Lee Jones have similar concerns:
Yes, so clearly I failed to convince all of you that if someone was able to trip over that problem, something should be done about it. No problem, these are not driver I maintain, so if someone hits the same issue, lore has the patches now.
Signature · 1 line
Florian
PATCH v3 5/5 net: txgbe: Utilize i2c-designware.h
In reply to Florian FainelliRather than open code the i2c_designware string, utilize the newly defined constant in i2c-designware.h.
--- drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c +4 -2
@@ -13,6 +13,8 @@#include <linux/pcs/pcs-xpcs.h> #include <linux/phylink.h> +#include <linux/platform_data/i2c-designware.h> +#include "../libwx/wx_type.h" #include "../libwx/wx_lib.h" #include "../libwx/wx_hw.h"
@@ -571,7 +573,7 @@ static int txgbe_clock_register(struct txgbe *txgbe)char clk_name[32 ];struct clk *clk; -snprintf (clk_name,sizeof (clk_name),"i2c_designware.%d" , +snprintf (clk_name,sizeof (clk_name),I2C_DESIGNWARE_NAME ".%d" ,pci_dev_id (pdev)); clk =clk_register_fixed_rate (NULL , clk_name,NULL ,0 ,156250000 );
@@ -634,7 +636,7 @@ static int txgbe_i2c_register(struct txgbe *txgbe) info.parent = &pdev->dev; info.fwnode =software_node_fwnode (txgbe->nodes.group[SWNODE_I2C ]); - info.name ="i2c_designware" ; + info.name =I2C_DESIGNWARE_NAME ; info.id =pci_dev_id (pdev); info.res = &DEFINE_RES_IRQ (pdev->irq);
Signature · 1 line
2.34.1
Re: (subset) [PATCH v3 0/5] Define i2c_designware in a header file
In reply to Florian FainelliHi
Quoted 10 lines · Florian Fainelli
This patch series depends upon the following two patches being applied:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/There is no reason why each driver should have to repeat the "
i2c_designware" string all over the place, because when that happens we see the reverts like the above being necessary.[...]
Applied to i2c/i2c-host on
git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
Thank you,
Andi
Patches applied
===============
[1/5] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
commit: 91647e64f0f5677ace84165dc25dc99579147b8f
[2/5] i2c: designware: Create shared header hosting driver name
commit: 856cd5f13de7cebca44db5ff4bc2ca73490dd8d7Re: (subset) [PATCH v3 0/5] Define i2c_designware in a header file
Hi Andi
Quoted 7 lines · Andi Shyti
Applied to i2c/i2c-host on
git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.gitThank you,
Andi
Quoted 7 lines
Patches applied
===============
[1/5] i2c: designware: ReplaceMODULE_ALIAS()withMODULE_DEVICE_TABLE()commit: 91647e64f0f5677ace84165dc25dc99579147b8f [2/5] i2c: designware: Create shared header hosting driver name commit: 856cd5f13de7cebca44db5ff4bc2ca73490dd8d7
Was the second patch applied accidentally?
Andy Shevchenko
reviewerRe: (subset) [PATCH v3 0/5] Define i2c_designware in a header file
Quoted 8 lines · Jarkko Nikula
Quoted 7 lines · Andi Shyti
Applied to i2c/i2c-host on
git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.gitThank you,
Andi
Quoted 8 lines
Quoted 7 lines
Patches applied
===============
[1/5] i2c: designware: ReplaceMODULE_ALIAS()withMODULE_DEVICE_TABLE()commit: 91647e64f0f5677ace84165dc25dc99579147b8f [2/5] i2c: designware: Create shared header hosting driver name commit: 856cd5f13de7cebca44db5ff4bc2ca73490dd8d7Was the second patch applied accidentally?
+1 here, asked the same in private communication.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andi Shyti
maintainerRe: (subset) [PATCH v3 0/5] Define i2c_designware in a header file
Hi,
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Jarkko Nikula
Quoted 14 lines · Andi Shyti
Applied to i2c/i2c-host on
git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.gitThank you,
AndiPatches applied
===============
[1/5] i2c: designware: ReplaceMODULE_ALIAS()withMODULE_DEVICE_TABLE()commit: 91647e64f0f5677ace84165dc25dc99579147b8f [2/5] i2c: designware: Create shared header hosting driver name commit: 856cd5f13de7cebca44db5ff4bc2ca73490dd8d7
Quoted 3 lines
Quoted 1 line
Was the second patch applied accidentally?
+1 here, asked the same in private communication.
yes, it is, I had this applied in my branch before reviving the thread. I then pushed and thanked for everything.
Thanks for your prompt reaction :-)
Andi