diff mbox series

mmc: jz4740: Use device_get_match_data()

Message ID 20231006224343.441720-1-robh@kernel.org (mailing list archive)
State Handled Elsewhere
Headers show
Series mmc: jz4740: Use device_get_match_data() | expand

Commit Message

Rob Herring Oct. 6, 2023, 10:43 p.m. UTC
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/mmc/host/jz4740_mmc.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Paul Cercueil Oct. 6, 2023, 10:49 p.m. UTC | #1
Hi Rob,

Le vendredi 06 octobre 2023 à 17:43 -0500, Rob Herring a écrit :
> Use preferred device_get_match_data() instead of of_match_device() to
> get the driver match data. With this, adjust the includes to
> explicitly
> include the correct headers.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  drivers/mmc/host/jz4740_mmc.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mmc/host/jz4740_mmc.c
> b/drivers/mmc/host/jz4740_mmc.c
> index f379ce5b582d..6a45991ca056 100644
> --- a/drivers/mmc/host/jz4740_mmc.c
> +++ b/drivers/mmc/host/jz4740_mmc.c
> @@ -18,9 +18,10 @@
>  #include <linux/mmc/host.h>
>  #include <linux/mmc/slot-gpio.h>
>  #include <linux/module.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/scatterlist.h>
>  
> @@ -1040,7 +1041,6 @@ static int jz4740_mmc_probe(struct
> platform_device* pdev)
>         int ret;
>         struct mmc_host *mmc;
>         struct jz4740_mmc_host *host;
> -       const struct of_device_id *match;
>  
>         mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev-
> >dev);
>         if (!mmc) {
> @@ -1050,13 +1050,8 @@ static int jz4740_mmc_probe(struct
> platform_device* pdev)
>  
>         host = mmc_priv(mmc);
>  
> -       match = of_match_device(jz4740_mmc_of_match, &pdev->dev);
> -       if (match) {
> -               host->version = (enum jz4740_mmc_version)match->data;
> -       } else {
> -               /* JZ4740 should be the only one using legacy probe
> */
> -               host->version = JZ_MMC_JZ4740;
> -       }
> +       /* Default if no match is JZ4740 */
> +       host->version = (enum
> jz4740_mmc_version)device_get_match_data(&pdev->dev);

Pretty clever.

Reviewed-by: Paul Cercueil <paul@crapouillou.net>

Cheers,
-Paul

>  
>         ret = mmc_of_parse(mmc);
>         if (ret) {
> @@ -1200,7 +1195,7 @@ static struct platform_driver jz4740_mmc_driver
> = {
>         .driver = {
>                 .name = "jz4740-mmc",
>                 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> -               .of_match_table = of_match_ptr(jz4740_mmc_of_match),
> +               .of_match_table = jz4740_mmc_of_match,
>                 .pm = pm_sleep_ptr(&jz4740_mmc_pm_ops),
>         },
>  };
Ulf Hansson Oct. 10, 2023, 2:27 p.m. UTC | #2
On Sat, 7 Oct 2023 at 00:43, Rob Herring <robh@kernel.org> wrote:
>
> Use preferred device_get_match_data() instead of of_match_device() to
> get the driver match data. With this, adjust the includes to explicitly
> include the correct headers.
>
> Signed-off-by: Rob Herring <robh@kernel.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/jz4740_mmc.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
> index f379ce5b582d..6a45991ca056 100644
> --- a/drivers/mmc/host/jz4740_mmc.c
> +++ b/drivers/mmc/host/jz4740_mmc.c
> @@ -18,9 +18,10 @@
>  #include <linux/mmc/host.h>
>  #include <linux/mmc/slot-gpio.h>
>  #include <linux/module.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/scatterlist.h>
>
> @@ -1040,7 +1041,6 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
>         int ret;
>         struct mmc_host *mmc;
>         struct jz4740_mmc_host *host;
> -       const struct of_device_id *match;
>
>         mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev->dev);
>         if (!mmc) {
> @@ -1050,13 +1050,8 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
>
>         host = mmc_priv(mmc);
>
> -       match = of_match_device(jz4740_mmc_of_match, &pdev->dev);
> -       if (match) {
> -               host->version = (enum jz4740_mmc_version)match->data;
> -       } else {
> -               /* JZ4740 should be the only one using legacy probe */
> -               host->version = JZ_MMC_JZ4740;
> -       }
> +       /* Default if no match is JZ4740 */
> +       host->version = (enum jz4740_mmc_version)device_get_match_data(&pdev->dev);
>
>         ret = mmc_of_parse(mmc);
>         if (ret) {
> @@ -1200,7 +1195,7 @@ static struct platform_driver jz4740_mmc_driver = {
>         .driver = {
>                 .name = "jz4740-mmc",
>                 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> -               .of_match_table = of_match_ptr(jz4740_mmc_of_match),
> +               .of_match_table = jz4740_mmc_of_match,
>                 .pm = pm_sleep_ptr(&jz4740_mmc_pm_ops),
>         },
>  };
> --
> 2.40.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index f379ce5b582d..6a45991ca056 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -18,9 +18,10 @@ 
 #include <linux/mmc/host.h>
 #include <linux/mmc/slot-gpio.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/scatterlist.h>
 
@@ -1040,7 +1041,6 @@  static int jz4740_mmc_probe(struct platform_device* pdev)
 	int ret;
 	struct mmc_host *mmc;
 	struct jz4740_mmc_host *host;
-	const struct of_device_id *match;
 
 	mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev->dev);
 	if (!mmc) {
@@ -1050,13 +1050,8 @@  static int jz4740_mmc_probe(struct platform_device* pdev)
 
 	host = mmc_priv(mmc);
 
-	match = of_match_device(jz4740_mmc_of_match, &pdev->dev);
-	if (match) {
-		host->version = (enum jz4740_mmc_version)match->data;
-	} else {
-		/* JZ4740 should be the only one using legacy probe */
-		host->version = JZ_MMC_JZ4740;
-	}
+	/* Default if no match is JZ4740 */
+	host->version = (enum jz4740_mmc_version)device_get_match_data(&pdev->dev);
 
 	ret = mmc_of_parse(mmc);
 	if (ret) {
@@ -1200,7 +1195,7 @@  static struct platform_driver jz4740_mmc_driver = {
 	.driver = {
 		.name = "jz4740-mmc",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.of_match_table = of_match_ptr(jz4740_mmc_of_match),
+		.of_match_table = jz4740_mmc_of_match,
 		.pm = pm_sleep_ptr(&jz4740_mmc_pm_ops),
 	},
 };