Skip to contentSkip to conversation

i2c: davinci: Use platform table macro over module_alias

PATCH Applied Andrew Davis 4 participants 12 messages May 15, 2023 – Jun 23, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 i2c: davinci: Use platform table macro over module_alias

Generates the same platform module alias. More standard usage.

---
 drivers/i2c/busses/i2c-davinci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-davinci.c +6 -2
index 9750310f2c96..c55bd937def7 100644
@@ -940,12 +940,16 @@ static const struct dev_pm_ops davinci_i2c_pm = {
 #define davinci_i2c_pm_ops NULL
 #endif
 
-/* work with hotplug and coldplug */
-MODULE_ALIAS("platform:i2c_davinci");
+static const struct platform_device_id davinci_i2c_driver_ids[] = {
+	{ .name = "i2c_davinci", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, davinci_i2c_driver_ids);
 
 static struct platform_driver davinci_i2c_driver = {
 	.probe		= davinci_i2c_probe,
 	.remove		= davinci_i2c_remove,
+	.id_table	= davinci_i2c_driver_ids,
 	.driver		= {
 		.name	= "i2c_davinci",
 		.pm	= davinci_i2c_pm_ops,
Signature · 7 lines
2.39.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

PATCH v2 2/2 i2c: davinci: Use struct name not type with devm_kzalloc()

This reduces chance of error if the type of "dev" changes. While here remove extra error print out, this is not usually done for memory allocation failures.

---
 drivers/i2c/busses/i2c-davinci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-davinci.c +2 -5
index c55bd937def7..135f76593e6f 100644
@@ -767,12 +767,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n");
 
-	dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
-			GFP_KERNEL);
-	if (!dev) {
-		dev_err(&pdev->dev, "Memory allocation failed\n");
+	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+	if (!dev)
 		return -ENOMEM;
-	}
 
 	init_completion(&dev->cmd_complete);
 
Signature · 7 lines
2.39.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc()

Quoted 30 lines · Andrew Davis

This reduces chance of error if the type of "dev" changes. While here remove extra error print out, this is not usually done for memory allocation failures.

---
 drivers/i2c/busses/i2c-davinci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-davinci.c +2 -6
index c55bd937def7..135f76593e6f 100644
@@ -767,12 +767,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
        if (irq < 0)
                return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n");
 
-       dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
-                       GFP_KERNEL);
-       if (!dev) {
-               dev_err(&pdev->dev, "Memory allocation failed\n");
+       dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+       if (!dev)
                return -ENOMEM;
-       }
 
        init_completion(&dev->cmd_complete);
 
--
Quoted 2 lines

2.39.2

Applied
#3 lore raw

Re: [PATCH v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc()

In reply to Andrew Davis
Quoted 5 lines · Andrew Davis

This reduces chance of error if the type of "dev" changes. While here remove extra error print out, this is not usually done for memory allocation failures.

Applied to for-next, thanks!

#4 lore raw

Re: [PATCH v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc()

In reply to Andrew Davis
Quoted 3 lines

This reduces chance of error if the type of "dev" changes. While here remove extra error print out, this is not usually done for memory allocation failures.

https://lore.kernel.org/linux-i2c/[email protected]/
http://patchwork.ozlabs.org/project/linux-i2c/patch/[email protected]/

I find that this change approach does not fit to the known requirement “Solve only one problem per patch.”.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.4-rc5#n81

Should desirable changes be split into better update steps?

See also:
[PATCH 0/2] I2C-DaVinci: Adjustments for davinci_i2c_probe()
https://lore.kernel.org/linux-i2c/[email protected]/
https://lkml.org/lkml/2018/2/2/541

* [1/2] i2c-davinci: Delete an error message for a failed memory allocation in davinci_i2c_probe()
https://patchwork.ozlabs.org/project/linux-i2c/patch/[email protected]/

* [2/2] i2c-davinci: Improve a size determination in davinci_i2c_probe()
https://patchwork.ozlabs.org/project/linux-i2c/patch/[email protected]/

Regards,
Markus

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

Re: [PATCH v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc()

Quoted 2 lines

Should desirable changes be split into better update steps?

It is done. It has already been applied.

#7 lore raw

Re: [v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc()

Quoted 2 lines

Will the patch review attention grow anyhow for affected aspects?

What are "affected aspects" in this case?

Reviewed-by on v2 1/2
#9 lore raw
In reply to Andrew Davis
Quoted 32 lines · Andrew Davis

Generates the same platform module alias. More standard usage.

---
 drivers/i2c/busses/i2c-davinci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-davinci.c +6 -3
index 9750310f2c96..c55bd937def7 100644
@@ -940,12 +940,16 @@ static const struct dev_pm_ops davinci_i2c_pm = {
 #define davinci_i2c_pm_ops NULL
 #endif
 
-/* work with hotplug and coldplug */
-MODULE_ALIAS("platform:i2c_davinci");
+static const struct platform_device_id davinci_i2c_driver_ids[] = {
+       { .name = "i2c_davinci", },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, davinci_i2c_driver_ids);
 
 static struct platform_driver davinci_i2c_driver = {
        .probe          = davinci_i2c_probe,
        .remove         = davinci_i2c_remove,
+       .id_table       = davinci_i2c_driver_ids,
        .driver         = {
                .name   = "i2c_davinci",
                .pm     = davinci_i2c_pm_ops,
--
Quoted 2 lines

2.39.2

#11 lore raw
Quoted 9 lines · Wolfram Sang

Hi Andrew,

Quoted 3 lines · Andrew Davis

Generates the same platform module alias. More standard usage.

Could you kindly rebase this to my i2c/for-mergewindow branch? It seems it conflicts with the "callback returning void" conversion.

I did this now and applied to for-next, thanks!