i2c: designware: Clean up MODEL_* definitions
Subsystems (3)
Andy Shevchenko
reviewercover i2c: designware: Clean up MODEL_* definitions
The current way of recognizing models is not scalable and in most of the cases just a replacement of well established device_is_compatible() approach.
For now take the low-hanging fruits and partially clean up those MODEL_* definitions.
Andy Shevchenko (2):
i2c: designware: Remove not-going-to-be-supported code for Baikal SoC
i2c: designware: Use device_is_compatible() instead of custom approach
drivers/i2c/busses/Kconfig | 1 - drivers/i2c/busses/i2c-designware-common.c | 6 +- drivers/i2c/busses/i2c-designware-core.h | 2 - drivers/i2c/busses/i2c-designware-platdrv.c | 70 +-------------------- 4 files changed, 2 insertions(+), 77 deletions(-)
Signature · 1 line
2.50.1
Andy Shevchenko
reviewerPATCH 1/2 i2c: designware: Remove not-going-to-be-supported code for Baikal SoC
As noticed in the discussion [1] the Baikal SoC and platforms are not going to be finalized, hence remove stale code.
--- drivers/i2c/busses/Kconfig | 1 - drivers/i2c/busses/i2c-designware-core.h | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 68 --------------------- 3 files changed, 70 deletions(-)
drivers/i2c/busses/Kconfig +0 -1
@@ -580,7 +580,6 @@ if I2C_DESIGNWARE_CORE config I2C_DESIGNWARE_PLATFORM tristate "Synopsys DesignWare Platform driver" depends on (ACPI && COMMON_CLK) || !ACPI - select MFD_SYSCON if MIPS_BAIKAL_T1 default I2C_DESIGNWARE_CORE help If you say yes to this option, support will be included for the
drivers/i2c/busses/i2c-designware-core.h +0 -1
@@ -314,7 +314,6 @@ struct dw_i2c_dev {#define ACCESS_POLLING BIT(3)#define MODEL_MSCC_OCELOT BIT(8) -#define MODEL_BAIKAL_BT1 BIT(9)#define MODEL_AMD_NAVI_GPU BIT(10)#define MODEL_WANGXUN_SP BIT(11)#define MODEL_MASK GENMASK(11, 8)
drivers/i2c/busses/i2c-designware-platdrv.c +0 -68
86 lines not on this page · raw message
Signature · 1 line
2.50.1
Re: [PATCH v1 1/2] i2c: designware: Remove not-going-to-be-supported code for Baikal SoC
Quoted 5 lines · Andy Shevchenko
As noticed in the discussion [1] the Baikal SoC and platforms are not going to be finalized, hence remove stale code.
Signed-off-by Andy Shevchenko <[email protected]>
Andi Shyti
maintainerRe: [PATCH v1 1/2] i2c: designware: Remove not-going-to-be-supported code for Baikal SoC
In reply to Andy ShevchenkoQuoted 5 lines · Andy Shevchenko
As noticed in the discussion [1] the Baikal SoC and platforms are not going to be finalized, hence remove stale code.
Signed-off-by Andy Shevchenko <[email protected]>
Until you guys sort things out with patch 2, I'm applying patch 1.
Thanks,
Andi
Andy Shevchenko
reviewerPATCH 2/2 i2c: designware: Use device_is_compatible() instead of custom approach
In reply to Andy ShevchenkoWe use MODEL_MSCC_OCELOT effectively is a flag for comparing against "compatible" property. Use device_is_compatible() directly to make it clear.
--- drivers/i2c/busses/i2c-designware-common.c | 6 +----- drivers/i2c/busses/i2c-designware-core.h | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +1 -5
@@ -238,14 +238,10 @@ 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 : +if (device_is_compatible (dev->dev,"mscc,ocelot-i2c" )) { 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 ; } }
drivers/i2c/busses/i2c-designware-core.h +0 -1
@@ -313,7 +313,6 @@ struct dw_i2c_dev {#define ARBITRATION_SEMAPHORE BIT(2)#define ACCESS_POLLING BIT(3) -#define MODEL_MSCC_OCELOT BIT(8)#define MODEL_AMD_NAVI_GPU BIT(10)#define MODEL_WANGXUN_SP BIT(11)#define MODEL_MASK GENMASK(11, 8)
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
@@ -267,7 +267,7 @@ static void dw_i2c_plat_remove(struct platform_device *pdev) }static const struct of_device_id dw_i2c_of_match[] = { - { .compatible ="mscc,ocelot-i2c" , .data = (void *)MODEL_MSCC_OCELOT }, + { .compatible ="mscc,ocelot-i2c" }, { .compatible ="snps,designware-i2c" }, {} };
Signature · 1 line
2.50.1
Mika Westerberg
maintainerRe: [PATCH v1 2/2] i2c: designware: Use device_is_compatible() instead of custom approach
Quoted 1 line · Andy Shevchenko
We use
MODEL_MSCC_OCELOTeffectively is a flag for comparing against
as a flag?
Quoted 2 lines
"compatible" property. Use
device_is_compatible()directly to make it clear.
Okay but if something else ever needs this same quirk then we would need to add new entry here and also to the IDs list.
With the flag you can have the IDs in a single place not all over the driver.
Quoted 55 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-designware-common.c | 6 +----- drivers/i2c/busses/i2c-designware-core.h | 1 - drivers/i2c/busses/i2c-designware-platdrv.c | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-)drivers/i2c/busses/i2c-designware-common.c +1
-5@@ -238,14 +238,10 @@ 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 : +if (device_is_compatible (dev->dev,"mscc,ocelot-i2c" )) { 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 ; } }drivers/i2c/busses/i2c-designware-core.h +0
-1@@ -313,7 +313,6 @@ struct dw_i2c_dev {#define ARBITRATION_SEMAPHORE BIT(2)#define ACCESS_POLLING BIT(3) -#define MODEL_MSCC_OCELOT BIT(8)#define MODEL_AMD_NAVI_GPU BIT(10)#define MODEL_WANGXUN_SP BIT(11)#define MODEL_MASK GENMASK(11, 8)drivers/i2c/busses/i2c-designware-platdrv.c +1
-1@@ -267,7 +267,7 @@ static void dw_i2c_plat_remove(struct platform_device *pdev) }static const struct of_device_id dw_i2c_of_match[] = { - { .compatible ="mscc,ocelot-i2c" , .data = (void *)MODEL_MSCC_OCELOT }, + { .compatible ="mscc,ocelot-i2c" }, { .compatible ="snps,designware-i2c" }, {} };Signature · 1 line
2.50.1
Andy Shevchenko
reviewerRe: [PATCH v1 2/2] i2c: designware: Use device_is_compatible() instead of custom approach
Quoted 4 lines · Mika Westerberg
Quoted 1 line · Andy Shevchenko
We use
MODEL_MSCC_OCELOTeffectively is a flag for comparing againstas a flag?
Yes, sorry for the typo.
Quoted 5 lines
Quoted 2 lines
"compatible" property. Use
device_is_compatible()directly to make it clear.Okay but if something else ever needs this same quirk then we would need to add new entry here and also to the IDs list.
Yes, that's how DT works and there are, of course, examples all over the kernel, first that comes to my mind: drivers/mmc/host/sdhci-pltfm.c.
Quoted 2 lines
With the flag you can have the IDs in a single place not all over the driver.
Makes the reality harder to read. If I know that the same quirk is used by different platform (in terms of compatible string) I will see it immediately from the code. Flag is meaningless.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mika Westerberg
maintainerRe: [PATCH v1 2/2] i2c: designware: Use device_is_compatible() instead of custom approach
Quoted 17 lines · Andy Shevchenko
Quoted 4 lines · Mika Westerberg
Quoted 1 line · Andy Shevchenko
We use
MODEL_MSCC_OCELOTeffectively is a flag for comparing againstas a flag?
Yes, sorry for the typo.
Quoted 5 lines
Quoted 2 lines
"compatible" property. Use
device_is_compatible()directly to make it clear.Okay but if something else ever needs this same quirk then we would need to add new entry here and also to the IDs list.
Yes, that's how DT works and there are, of course, examples all over the kernel, first that comes to my mind:
drivers/mmc/host/sdhci-pltfm.c.
Quoted 6 lines
Quoted 2 lines
With the flag you can have the IDs in a single place not all over the driver.
Makes the reality harder to read. If I know that the same quirk is used by different platform (in terms of compatible string) I will see it immediately from the code. Flag is meaningless.
Well with the flag you get the help from the compiler if you typo it but with the string comparison you are on your own. Therefore I prefer the flag and as I said it also avoid duplicating the compatible string.
Andy Shevchenko
reviewerRe: [PATCH v1 2/2] i2c: designware: Use device_is_compatible() instead of custom approach
Quoted 21 lines · Mika Westerberg
Quoted 20 lines · Andy Shevchenko
Quoted 4 lines · Mika Westerberg
Quoted 1 line · Andy Shevchenko
We use
MODEL_MSCC_OCELOTeffectively is a flag for comparing againstas a flag?
Yes, sorry for the typo.
Quoted 5 lines
Quoted 2 lines
"compatible" property. Use
device_is_compatible()directly to make it clear.Okay but if something else ever needs this same quirk then we would need to add new entry here and also to the IDs list.
Yes, that's how DT works and there are, of course, examples all over the kernel, first that comes to my mind:
drivers/mmc/host/sdhci-pltfm.c.Quoted 2 lines
With the flag you can have the IDs in a single place not all over the driver.
Quoted 6 lines
Quoted 3 lines
Makes the reality harder to read. If I know that the same quirk is used by different platform (in terms of compatible string) I will see it immediately from the code. Flag is meaningless.
Well with the flag you get the help from the compiler if you typo it but with the string comparison you are on your own.
It only affects the development cycle, isn't it obvious that any quirk should be tested by the author, otherwise it won't work.
Quoted 2 lines
Therefore I prefer the flag and as I said it also avoid duplicating the compatible string.
Duplicating compatible string is not a problem, linker nowadays combines the same strings into one. In case you are worrying about the space, it's not a problem.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mika Westerberg
maintainerRe: [PATCH v1 2/2] i2c: designware: Use device_is_compatible() instead of custom approach
Quoted 26 lines · Andy Shevchenko
Quoted 25 lines · Mika Westerberg
Quoted 23 lines · Andy Shevchenko
Quoted 4 lines · Mika Westerberg
Quoted 1 line · Andy Shevchenko
We use
MODEL_MSCC_OCELOTeffectively is a flag for comparing againstas a flag?
Yes, sorry for the typo.
Quoted 5 lines
Quoted 2 lines
"compatible" property. Use
device_is_compatible()directly to make it clear.Okay but if something else ever needs this same quirk then we would need to add new entry here and also to the IDs list.
Yes, that's how DT works and there are, of course, examples all over the kernel, first that comes to my mind:
drivers/mmc/host/sdhci-pltfm.c.Quoted 2 lines
With the flag you can have the IDs in a single place not all over the driver.
Makes the reality harder to read. If I know that the same quirk is used by different platform (in terms of compatible string) I will see it immediately from the code. Flag is meaningless.
Quoted 5 lines
Quoted 2 lines
Well with the flag you get the help from the compiler if you typo it but with the string comparison you are on your own.
It only affects the development cycle, isn't it obvious that any quirk should be tested by the author, otherwise it won't work.
Of course but then are these "cleanups" that probably will not be tested that well if at all. If it is possible to take advantage of the compiler then I prefer that.
Quoted 6 lines
Quoted 2 lines
Therefore I prefer the flag and as I said it also avoid duplicating the compatible string.
Duplicating compatible string is not a problem, linker nowadays combines the same strings into one. In case you are worrying about the space, it's not a problem.
I don't care about the space but just duplication.
Andi Shyti
maintainerRe: [PATCH v1 2/2] i2c: designware: Use device_is_compatible() instead of custom approach
In reply to Andy ShevchenkoHi,
Quoted 5 lines · Andy Shevchenko
We use
MODEL_MSCC_OCELOTeffectively is a flag for comparing against "compatible" property. Usedevice_is_compatible()directly to make it clear.Signed-off-by Andy Shevchenko <[email protected]>
I'm coming into the discussion and I personally like Andy's approach. As a third party, I believe this patch has reached the consensus and I'm taking it in i2c/i2c-host.
Thanks Andy,
Andi
Andy Shevchenko
reviewerRe: [PATCH v1 2/2] i2c: designware: Use device_is_compatible() instead of custom approach
Quoted 10 lines · Andi Shyti
Quoted 5 lines · Andy Shevchenko
We use
MODEL_MSCC_OCELOTeffectively is a flag for comparing against "compatible" property. Usedevice_is_compatible()directly to make it clear.Signed-off-by Andy Shevchenko <[email protected]>I'm coming into the discussion and I personally like Andy's approach. As a third party, I believe this patch has reached the consensus and I'm taking it in i2c/i2c-host.
Thank you!
Signature · 2 lines
With Best Regards, Andy Shevchenko