linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data()
@ 2020-11-24 16:39 Fabio Estevam
  2020-11-24 16:39 ` [PATCH 2/3] usb: chipidea: usbmisc_imx: " Fabio Estevam
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Fabio Estevam @ 2020-11-24 16:39 UTC (permalink / raw)
  To: Peter.Chen; +Cc: gregkh, linux-usb, Fabio Estevam

The retrieval of driver data via of_device_get_match_data() can make
the code simpler.

Use of_device_get_match_data() to simplify the code. 

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/usb/phy/phy-mxs-usb.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 67b39dc62b37..8a262c5a0408 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -714,14 +714,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	struct clk *clk;
 	struct mxs_phy *mxs_phy;
 	int ret;
-	const struct of_device_id *of_id;
 	struct device_node *np = pdev->dev.of_node;
 	u32 val;
 
-	of_id = of_match_device(mxs_phy_dt_ids, &pdev->dev);
-	if (!of_id)
-		return -ENODEV;
-
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
@@ -797,7 +792,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	mxs_phy->phy.charger_detect	= mxs_phy_charger_detect;
 
 	mxs_phy->clk = clk;
-	mxs_phy->data = of_id->data;
+	mxs_phy->data = of_device_get_match_data(&pdev->dev);
 
 	platform_set_drvdata(pdev, mxs_phy);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] usb: chipidea: usbmisc_imx: Use of_device_get_match_data()
  2020-11-24 16:39 [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data() Fabio Estevam
@ 2020-11-24 16:39 ` Fabio Estevam
  2020-11-24 16:39 ` [PATCH 3/3] usb: chipidea: ci_hdrc_imx: " Fabio Estevam
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Fabio Estevam @ 2020-11-24 16:39 UTC (permalink / raw)
  To: Peter.Chen; +Cc: gregkh, linux-usb, Fabio Estevam

The retrieval of driver data via of_device_get_match_data() can make
the code simpler.

Use of_device_get_match_data() to simplify the code.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/usb/chipidea/usbmisc_imx.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 6d8331e7da99..4545b23bda3f 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -1134,11 +1134,6 @@ MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
 static int usbmisc_imx_probe(struct platform_device *pdev)
 {
 	struct imx_usbmisc *data;
-	const struct of_device_id *of_id;
-
-	of_id = of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
-	if (!of_id)
-		return -ENODEV;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
@@ -1150,7 +1145,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
 	if (IS_ERR(data->base))
 		return PTR_ERR(data->base);
 
-	data->ops = (const struct usbmisc_ops *)of_id->data;
+	data->ops = of_device_get_match_data(&pdev->dev);
 	platform_set_drvdata(pdev, data);
 
 	return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] usb: chipidea: ci_hdrc_imx: Use of_device_get_match_data()
  2020-11-24 16:39 [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data() Fabio Estevam
  2020-11-24 16:39 ` [PATCH 2/3] usb: chipidea: usbmisc_imx: " Fabio Estevam
@ 2020-11-24 16:39 ` Fabio Estevam
  2020-11-25  1:15 ` [PATCH 1/3] usb: phy: phy-mxs-usb: " Peter Chen
  2020-11-25  4:48 ` Peter Chen
  3 siblings, 0 replies; 8+ messages in thread
From: Fabio Estevam @ 2020-11-24 16:39 UTC (permalink / raw)
  To: Peter.Chen; +Cc: gregkh, linux-usb, Fabio Estevam

The retrieval of driver data via of_device_get_match_data() can make
the code simpler.

Use of_device_get_match_data() to simplify the code.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 25c65accf089..8fa712148e5d 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -319,16 +319,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 		.notify_event	= ci_hdrc_imx_notify_event,
 	};
 	int ret;
-	const struct of_device_id *of_id;
 	const struct ci_hdrc_imx_platform_flag *imx_platform_flag;
 	struct device_node *np = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 
-	of_id = of_match_device(ci_hdrc_imx_dt_ids, dev);
-	if (!of_id)
-		return -ENODEV;
-
-	imx_platform_flag = of_id->data;
+	imx_platform_flag = of_device_get_match_data(&pdev->dev);
 
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data()
  2020-11-24 16:39 [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data() Fabio Estevam
  2020-11-24 16:39 ` [PATCH 2/3] usb: chipidea: usbmisc_imx: " Fabio Estevam
  2020-11-24 16:39 ` [PATCH 3/3] usb: chipidea: ci_hdrc_imx: " Fabio Estevam
@ 2020-11-25  1:15 ` Peter Chen
  2020-11-25  1:21   ` Fabio Estevam
  2020-11-25  4:48 ` Peter Chen
  3 siblings, 1 reply; 8+ messages in thread
From: Peter Chen @ 2020-11-25  1:15 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org

On 20-11-24 13:39:10, Fabio Estevam wrote:
> The retrieval of driver data via of_device_get_match_data() can make
> the code simpler.
> 
> Use of_device_get_match_data() to simplify the code. 
> 
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
> ---
>  drivers/usb/phy/phy-mxs-usb.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index 67b39dc62b37..8a262c5a0408 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -714,14 +714,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
>  	struct clk *clk;
>  	struct mxs_phy *mxs_phy;
>  	int ret;
> -	const struct of_device_id *of_id;
>  	struct device_node *np = pdev->dev.of_node;
>  	u32 val;
>  
> -	of_id = of_match_device(mxs_phy_dt_ids, &pdev->dev);
> -	if (!of_id)
> -		return -ENODEV;
> -
>  	base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(base))
>  		return PTR_ERR(base);
> @@ -797,7 +792,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
>  	mxs_phy->phy.charger_detect	= mxs_phy_charger_detect;
>  
>  	mxs_phy->clk = clk;
> -	mxs_phy->data = of_id->data;
> +	mxs_phy->data = of_device_get_match_data(&pdev->dev);

You may forget the error handling for it, eg, -ENODEV.

Peter
>  
>  	platform_set_drvdata(pdev, mxs_phy);
>  
> -- 
> 2.17.1
> 

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data()
  2020-11-25  1:15 ` [PATCH 1/3] usb: phy: phy-mxs-usb: " Peter Chen
@ 2020-11-25  1:21   ` Fabio Estevam
  2020-11-25  1:58     ` Peter Chen
  0 siblings, 1 reply; 8+ messages in thread
From: Fabio Estevam @ 2020-11-25  1:21 UTC (permalink / raw)
  To: Peter Chen; +Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org

Hi Peter,

On Tue, Nov 24, 2020 at 10:15 PM Peter Chen <peter.chen@nxp.com> wrote:

> > -     mxs_phy->data = of_id->data;
> > +     mxs_phy->data = of_device_get_match_data(&pdev->dev);
>
> You may forget the error handling for it, eg, -ENODEV.

How can this happen?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data()
  2020-11-25  1:21   ` Fabio Estevam
@ 2020-11-25  1:58     ` Peter Chen
  2020-11-25  2:13       ` Fabio Estevam
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Chen @ 2020-11-25  1:58 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org

On 20-11-24 22:21:40, Fabio Estevam wrote:
> Hi Peter,
> 
> On Tue, Nov 24, 2020 at 10:15 PM Peter Chen <peter.chen@nxp.com> wrote:
> 
> > > -     mxs_phy->data = of_id->data;
> > > +     mxs_phy->data = of_device_get_match_data(&pdev->dev);
> >
> > You may forget the error handling for it, eg, -ENODEV.
> 
> How can this happen?

When adding the new SoCs, the new compatible is added at dts, but forget
adding at device driver's of_device_id table?

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data()
  2020-11-25  1:58     ` Peter Chen
@ 2020-11-25  2:13       ` Fabio Estevam
  0 siblings, 0 replies; 8+ messages in thread
From: Fabio Estevam @ 2020-11-25  2:13 UTC (permalink / raw)
  To: Peter Chen; +Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org

On Tue, Nov 24, 2020 at 10:58 PM Peter Chen <peter.chen@nxp.com> wrote:

> When adding the new SoCs, the new compatible is added at dts, but forget
> adding at device driver's of_device_id table?

In this case, the probe function will not even be called if there is
no matching.

Please see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.10-rc5&id=e6c7c258f035ffec9d8a808c1bc34b6a5beae0ef

and
https://www.alsa-project.org/pipermail/alsa-devel/2017-January/117275.html

There is no need for doing a NULL check on of_device_get_match_data()
on a DT-only driver.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data()
  2020-11-24 16:39 [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data() Fabio Estevam
                   ` (2 preceding siblings ...)
  2020-11-25  1:15 ` [PATCH 1/3] usb: phy: phy-mxs-usb: " Peter Chen
@ 2020-11-25  4:48 ` Peter Chen
  3 siblings, 0 replies; 8+ messages in thread
From: Peter Chen @ 2020-11-25  4:48 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org

 
> 
> Signed-off-by: Fabio Estevam <festevam@gmail.com>

Acked-by: Peter Chen <peter.chen@nxp.com>

Peter
> ---
>  drivers/usb/phy/phy-mxs-usb.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index 67b39dc62b37..8a262c5a0408 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -714,14 +714,9 @@ static int mxs_phy_probe(struct platform_device
> *pdev)
>  	struct clk *clk;
>  	struct mxs_phy *mxs_phy;
>  	int ret;
> -	const struct of_device_id *of_id;
>  	struct device_node *np = pdev->dev.of_node;
>  	u32 val;
> 
> -	of_id = of_match_device(mxs_phy_dt_ids, &pdev->dev);
> -	if (!of_id)
> -		return -ENODEV;
> -
>  	base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(base))
>  		return PTR_ERR(base);
> @@ -797,7 +792,7 @@ static int mxs_phy_probe(struct platform_device
> *pdev)
>  	mxs_phy->phy.charger_detect	= mxs_phy_charger_detect;
> 
>  	mxs_phy->clk = clk;
> -	mxs_phy->data = of_id->data;
> +	mxs_phy->data = of_device_get_match_data(&pdev->dev);
> 
>  	platform_set_drvdata(pdev, mxs_phy);
> 
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-25  4:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-24 16:39 [PATCH 1/3] usb: phy: phy-mxs-usb: Use of_device_get_match_data() Fabio Estevam
2020-11-24 16:39 ` [PATCH 2/3] usb: chipidea: usbmisc_imx: " Fabio Estevam
2020-11-24 16:39 ` [PATCH 3/3] usb: chipidea: ci_hdrc_imx: " Fabio Estevam
2020-11-25  1:15 ` [PATCH 1/3] usb: phy: phy-mxs-usb: " Peter Chen
2020-11-25  1:21   ` Fabio Estevam
2020-11-25  1:58     ` Peter Chen
2020-11-25  2:13       ` Fabio Estevam
2020-11-25  4:48 ` Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).