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
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
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]>
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]>
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
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!
> Should desirable changes be split into better update steps?
It is done. It has already been applied.
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!