diff mbox series

[v3,09/25] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()

Message ID 20231110182304.3894319-10-andriy.shevchenko@linux.intel.com
State Superseded
Headers show
Series i2c: designware: code consolidation & cleanups | expand

Commit Message

Andy Shevchenko Nov. 10, 2023, 6:11 p.m. UTC
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.

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-pcidrv.c  | 2 --
 drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Mario Limonciello Nov. 10, 2023, 7:39 p.m. UTC | #1
On 11/10/2023 12:11, Andy Shevchenko wrote:
> 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.
> 
> Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   drivers/i2c/busses/i2c-designware-pcidrv.c  | 2 --
>   drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++--
>   2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
> index d2ed4e77afb3..db642e0aa61f 100644
> --- a/drivers/i2c/busses/i2c-designware-pcidrv.c
> +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
> @@ -417,8 +417,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 <baruch@tkos.co.il>");
>   MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter");
>   MODULE_LICENSE("GPL");
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index 4b5e58e1ce5b..5d8427ccc9b4 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -486,8 +486,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,
> @@ -498,6 +501,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)
Jarkko Nikula Nov. 17, 2023, 2:07 p.m. UTC | #2
On 11/10/23 21:39, Mario Limonciello wrote:
> On 11/10/2023 12:11, Andy Shevchenko wrote:
>> 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.
>>
>> Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

I'm using modular build and modules get autoloaded fine after this patch.

Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index d2ed4e77afb3..db642e0aa61f 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -417,8 +417,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 <baruch@tkos.co.il>");
 MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter");
 MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 4b5e58e1ce5b..5d8427ccc9b4 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -486,8 +486,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,
@@ -498,6 +501,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)