usb: phy: phy-mxs-usb: Use of_device_get_match_data()
Fabio Estevam
reviewerPATCH 1/3 usb: phy: phy-mxs-usb: Use of_device_get_match_data()
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.
--- drivers/usb/phy/phy-mxs-usb.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +1 -6
@@ -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);
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 2/3 usb: chipidea: usbmisc_imx: Use of_device_get_match_data()
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.
--- drivers/usb/chipidea/usbmisc_imx.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +1 -6
@@ -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 ;
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 3/3 usb: chipidea: ci_hdrc_imx: Use of_device_get_match_data()
In reply to Fabio EstevamThe 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.
--- drivers/usb/chipidea/ci_hdrc_imx.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +1 -6
@@ -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)
Signature · 1 line
2.17.1
Quoted 30 lines · 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 <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/usb/phy/phy-mxs-usb.c +0
-5@@ -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);
drivers/usb/phy/phy-mxs-usb.c static int mxs_phy_probe(struct platform_device *pdev) · line 795
Quoted 5 lines
drivers/usb/phy/phy-mxs-usb.c +1
-1@@ -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
Quoted 6 lines
drivers/usb/phy/phy-mxs-usb.c +0
-0platform_set_drvdata (pdev, mxs_phy);Signature · 1 line
2.17.1
Signature · 2 lines
Thanks, Peter Chen
Fabio Estevam
reviewerHi Peter,
Quoted 4 lines · Peter Chen
drivers/usb/phy/phy-mxs-usb.c static int mxs_phy_probe(struct platform_device *pdev) · line 795
Quoted 2 lines
drivers/usb/phy/phy-mxs-usb.c +1
-1- 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?
Quoted 10 lines · Fabio Estevam
Hi Peter,
Quoted 4 lines · Peter Chen
drivers/usb/phy/phy-mxs-usb.c static int mxs_phy_probe(struct platform_device *pdev) · line 795
Quoted 2 lines
drivers/usb/phy/phy-mxs-usb.c +1
-1- 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?
Signature · 2 lines
Thanks, Peter Chen
Fabio Estevam
reviewerQuoted 2 lines · Peter Chen
When adding the new SoCs, the new compatible is added at dts, but forget adding at device driver's
of_device_idtable?
In this case, the probe function will not even be called if there is no matching.
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.
Quoted 3 lines
Signed-off-by Fabio Estevam <[email protected]>
Peter
Quoted 36 lines
--- drivers/usb/phy/phy-mxs-usb.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/usb/phy/phy-mxs-usb.c +0
-5@@ -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))drivers/usb/phy/phy-mxs-usb.c +1
-2return 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