2023-05-15 18:34:07

by Andrew Davis

[permalink] [raw]
Subject: [PATCH v2 1/2] i2c: davinci: Use platform table macro over module_alias

Generates the same platform module alias. More standard usage.

Signed-off-by: Andrew Davis <[email protected]>
---
drivers/i2c/busses/i2c-davinci.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 9750310f2c96..c55bd937def7 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -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,
--
2.39.2



2023-05-15 20:08:06

by Andrew Davis

[permalink] [raw]
Subject: [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.

Signed-off-by: Andrew Davis <[email protected]>
---
drivers/i2c/busses/i2c-davinci.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index c55bd937def7..135f76593e6f 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -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);

--
2.39.2


2023-05-16 14:49:53

by Bartosz Golaszewski

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

On Mon, May 15, 2023 at 7:50 PM Andrew Davis <[email protected]> wrote:
>
> 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.
>
> Signed-off-by: Andrew Davis <[email protected]>
> ---
> drivers/i2c/busses/i2c-davinci.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
> index c55bd937def7..135f76593e6f 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -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);
>
> --
> 2.39.2
>

Reviewed-by: Bartosz Golaszewski <[email protected]>

2023-05-16 14:51:43

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] i2c: davinci: Use platform table macro over module_alias

On Mon, May 15, 2023 at 7:50 PM Andrew Davis <[email protected]> wrote:
>
> Generates the same platform module alias. More standard usage.
>
> Signed-off-by: Andrew Davis <[email protected]>
> ---
> drivers/i2c/busses/i2c-davinci.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
> index 9750310f2c96..c55bd937def7 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -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,
> --
> 2.39.2
>

Reviewed-by: Bartosz Golaszewski <[email protected]>

2023-06-07 09:41:46

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] i2c: davinci: Use platform table macro over module_alias

Hi Andrew,

On Mon, May 15, 2023 at 12:50:41PM -0500, Andrew Davis wrote:
> Generates the same platform module alias. More standard usage.
>
> Signed-off-by: Andrew Davis <[email protected]>

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

Thanks,

Wolfram


Attachments:
(No filename) (354.00 B)
signature.asc (849.00 B)
Download all attachments

2023-06-07 09:43:30

by Wolfram Sang

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

On Mon, May 15, 2023 at 12:50:42PM -0500, Andrew Davis wrote:
> 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.
>
> Signed-off-by: Andrew Davis <[email protected]>

Applied to for-next, thanks!


Attachments:
(No filename) (311.00 B)
signature.asc (849.00 B)
Download all attachments

2023-06-08 11:39:45

by Wolfram Sang

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


> Should desirable changes be split into better update steps?

It is done. It has already been applied.


Attachments:
(No filename) (111.00 B)
signature.asc (849.00 B)
Download all attachments

2023-06-23 08:58:33

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] i2c: davinci: Use platform table macro over module_alias

On Wed, Jun 07, 2023 at 11:32:38AM +0200, Wolfram Sang wrote:
> Hi Andrew,
>
> On Mon, May 15, 2023 at 12:50:41PM -0500, Andrew Davis wrote:
> > Generates the same platform module alias. More standard usage.
> >
> > Signed-off-by: Andrew Davis <[email protected]>
>
> 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!


Attachments:
(No filename) (461.00 B)
signature.asc (849.00 B)
Download all attachments