2023-07-25 15:39:34

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 0/9] i2c: designware: code consolidation & cleanups

Mainly this is about firmware parsing and configuring code
consolidation. Besides that some cleanups here and there.

Andy Shevchenko (9):
i2c: designware: Move has_acpi_companion() to common code
i2c: designware: Change i2c_dw_acpi_configure() prototype
i2c: designware: Align dw_i2c_of_configure() with
i2c_dw_acpi_configure()
i2c: designware: Propagate firmware node
i2c: designware: Always provide ID tables
i2c: designware: Consolidate firmware parsing and configure code
i2c: desingware: Unify firmware type checks
i2c: designware: Get rid of redundant 'else'
i2c: designware: Fix spelling and other issues in the comments

drivers/i2c/busses/i2c-designware-amdpsp.c | 10 +-
drivers/i2c/busses/i2c-designware-common.c | 84 +++++++++++---
drivers/i2c/busses/i2c-designware-core.h | 25 ++---
drivers/i2c/busses/i2c-designware-master.c | 15 ++-
drivers/i2c/busses/i2c-designware-pcidrv.c | 13 +--
drivers/i2c/busses/i2c-designware-platdrv.c | 117 ++++++--------------
drivers/i2c/busses/i2c-designware-slave.c | 6 +-
7 files changed, 131 insertions(+), 139 deletions(-)

--
2.40.0.1.gaa8946217a0b



2023-07-25 15:41:30

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 5/9] i2c: designware: Always provide ID tables

There is no need to have ugly ifdeffery and additional macros
for the ID tables. Always provide them. Since we touch the
ACPI table, make it sorted by ID.

While at it, group MODULE_ALIAS() with other MODULE_*() macros.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 65 ++++++++++-----------
1 file changed, 31 insertions(+), 34 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 512fb1d8ddfc..d2ffd041c0c7 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -40,28 +40,6 @@ static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
return clk_get_rate(dev->clk) / KILO;
}

-#ifdef CONFIG_ACPI
-static const struct acpi_device_id dw_i2c_acpi_match[] = {
- { "INT33C2", 0 },
- { "INT33C3", 0 },
- { "INT3432", 0 },
- { "INT3433", 0 },
- { "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 },
- { }
-};
-MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
-#endif
-
#ifdef CONFIG_OF
#define BT1_I2C_CTL 0x100
#define BT1_I2C_CTL_ADDR_MASK GENMASK(7, 0)
@@ -152,14 +130,6 @@ static void i2c_dw_of_configure(struct dw_i2c_dev *dev)
if (dev_of_node(dev->dev))
i2c_dw_of_do_configure(dev, dev->dev);
}
-
-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)
{
@@ -485,16 +455,41 @@ static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
#define DW_I2C_DEV_PMOPS NULL
#endif

-/* Work with hotplug and coldplug */
-MODULE_ALIAS("platform:i2c_designware");
+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 struct platform_driver dw_i2c_driver = {
.probe = dw_i2c_plat_probe,
.remove_new = dw_i2c_plat_remove,
.driver = {
.name = "i2c_designware",
- .of_match_table = of_match_ptr(dw_i2c_of_match),
- .acpi_match_table = ACPI_PTR(dw_i2c_acpi_match),
+ .of_match_table = dw_i2c_of_match,
+ .acpi_match_table = dw_i2c_acpi_match,
.pm = DW_I2C_DEV_PMOPS,
},
};
@@ -511,6 +506,8 @@ static void __exit dw_i2c_exit_driver(void)
}
module_exit(dw_i2c_exit_driver);

+/* Work with hotplug and coldplug */
+MODULE_ALIAS("platform:i2c_designware");
MODULE_AUTHOR("Baruch Siach <[email protected]>");
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter");
MODULE_LICENSE("GPL");
--
2.40.0.1.gaa8946217a0b


2023-07-25 15:46:49

by Mario Limonciello

[permalink] [raw]
Subject: Re: [PATCH v1 0/9] i2c: designware: code consolidation & cleanups

On 7/25/2023 09:30, Andy Shevchenko wrote:
> Mainly this is about firmware parsing and configuring code
> consolidation. Besides that some cleanups here and there.
>
> Andy Shevchenko (9):
> i2c: designware: Move has_acpi_companion() to common code
> i2c: designware: Change i2c_dw_acpi_configure() prototype
> i2c: designware: Align dw_i2c_of_configure() with
> i2c_dw_acpi_configure()
> i2c: designware: Propagate firmware node
> i2c: designware: Always provide ID tables
> i2c: designware: Consolidate firmware parsing and configure code
> i2c: desingware: Unify firmware type checks
> i2c: designware: Get rid of redundant 'else'
> i2c: designware: Fix spelling and other issues in the comments
>
> drivers/i2c/busses/i2c-designware-amdpsp.c | 10 +-
> drivers/i2c/busses/i2c-designware-common.c | 84 +++++++++++---
> drivers/i2c/busses/i2c-designware-core.h | 25 ++---
> drivers/i2c/busses/i2c-designware-master.c | 15 ++-
> drivers/i2c/busses/i2c-designware-pcidrv.c | 13 +--
> drivers/i2c/busses/i2c-designware-platdrv.c | 117 ++++++--------------
> drivers/i2c/busses/i2c-designware-slave.c | 6 +-
> 7 files changed, 131 insertions(+), 139 deletions(-)
>

Reviewed-by: Mario Limonciello <[email protected]>

2023-07-28 13:55:30

by Jarkko Nikula

[permalink] [raw]
Subject: Re: [PATCH v1 5/9] i2c: designware: Always provide ID tables

On 7/25/23 17:30, Andy Shevchenko wrote:
> There is no need to have ugly ifdeffery and additional macros
> for the ID tables. Always provide them. Since we touch the
> ACPI table, make it sorted by ID.
>
> While at it, group MODULE_ALIAS() with other MODULE_*() macros.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> drivers/i2c/busses/i2c-designware-platdrv.c | 65 ++++++++++-----------
> 1 file changed, 31 insertions(+), 34 deletions(-)
>
Acked-by: Jarkko Nikula <[email protected]>

(minor comment below if you plan to update)

> +/* Work with hotplug and coldplug */
> +MODULE_ALIAS("platform:i2c_designware");

Perhaps this comment can be retired, i.e. dropped.

2023-07-31 21:08:35

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 5/9] i2c: designware: Always provide ID tables

On Fri, Jul 28, 2023 at 03:33:59PM +0300, Jarkko Nikula wrote:
> On 7/25/23 17:30, Andy Shevchenko wrote:

...

> > +/* Work with hotplug and coldplug */
> > +MODULE_ALIAS("platform:i2c_designware");
>
> Perhaps this comment can be retired, i.e. dropped.

Then it needs to be done in a separate patch, because in the other file the
comment will be left untouched.


--
With Best Regards,
Andy Shevchenko



2023-08-04 21:29:52

by Andi Shyti

[permalink] [raw]
Subject: Re: [PATCH v1 5/9] i2c: designware: Always provide ID tables

Hi Andy,

On Mon, Jul 31, 2023 at 11:05:05PM +0300, Andy Shevchenko wrote:
> On Fri, Jul 28, 2023 at 03:33:59PM +0300, Jarkko Nikula wrote:
> > On 7/25/23 17:30, Andy Shevchenko wrote:
>
> ...
>
> > > +/* Work with hotplug and coldplug */
> > > +MODULE_ALIAS("platform:i2c_designware");
> >
> > Perhaps this comment can be retired, i.e. dropped.
>
> Then it needs to be done in a separate patch, because in the other file the
> comment will be left untouched.

You are being a bit too religios here... if you want to stick to
this, then you need to send a patch for sorting by ID, a patch
for grouping together MODULE_*, a patch to remove this comment
and a patch to always provide the id table.

I think, "while at it", you can safely remove the redundant
comment :)

It doesn't make too much difference to me anyway:

Reviewed-by: Andi Shyti <[email protected]>

Andi

2023-08-07 16:14:25

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 5/9] i2c: designware: Always provide ID tables

On Fri, Aug 04, 2023 at 11:00:55PM +0200, Andi Shyti wrote:
> On Mon, Jul 31, 2023 at 11:05:05PM +0300, Andy Shevchenko wrote:
> > On Fri, Jul 28, 2023 at 03:33:59PM +0300, Jarkko Nikula wrote:
> > > On 7/25/23 17:30, Andy Shevchenko wrote:

...

> > > > +/* Work with hotplug and coldplug */
> > > > +MODULE_ALIAS("platform:i2c_designware");
> > >
> > > Perhaps this comment can be retired, i.e. dropped.
> >
> > Then it needs to be done in a separate patch, because in the other file the
> > comment will be left untouched.
>
> You are being a bit too religios here...

No, it's being consistent. Either we remove them both or don't touch.

> if you want to stick to
> this, then you need to send a patch for sorting by ID, a patch
> for grouping together MODULE_*, a patch to remove this comment
> and a patch to always provide the id table.
>
> I think, "while at it", you can safely remove the redundant
> comment :)
>
> It doesn't make too much difference to me anyway:
>
> Reviewed-by: Andi Shyti <[email protected]>

Thank you!

--
With Best Regards,
Andy Shevchenko