* [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource()
@ 2023-07-05 9:01 Yangtao Li
2023-07-05 9:01 ` [PATCH 2/4] phy: rockchip: phy-rockchip-typec: " Yangtao Li
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Yangtao Li @ 2023-07-05 9:01 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I; +Cc: Yangtao Li, linux-phy, linux-kernel
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/phy/marvell/phy-mvebu-cp110-comphy.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
index 34672e868a1e..ddaddb3c498f 100644
--- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
+++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
@@ -1011,8 +1011,7 @@ static int mvebu_comphy_probe(struct platform_device *pdev)
"marvell,system-controller");
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- priv->base = devm_ioremap_resource(&pdev->dev, res);
+ priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
--
2.39.0
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 2/4] phy: rockchip: phy-rockchip-typec: Use devm_platform_get_and_ioremap_resource() 2023-07-05 9:01 [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Yangtao Li @ 2023-07-05 9:01 ` Yangtao Li 2023-07-11 13:39 ` Heiko Stuebner 2023-07-05 9:01 ` [PATCH 3/4] phy: renesas: r8a779f0-ether-serdes: Convert to devm_platform_ioremap_resource() Yangtao Li ` (2 subsequent siblings) 3 siblings, 1 reply; 11+ messages in thread From: Yangtao Li @ 2023-07-05 9:01 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner Cc: Yangtao Li, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel Convert platform_get_resource(), devm_ioremap_resource() to a single call to devm_platform_get_and_ioremap_resource(), as this is exactly what this function does. Signed-off-by: Yangtao Li <frank.li@vivo.com> --- drivers/phy/rockchip/phy-rockchip-typec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c index 8b1667be4915..4efcb78b0ab1 100644 --- a/drivers/phy/rockchip/phy-rockchip-typec.c +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -1116,8 +1116,7 @@ static int rockchip_typec_phy_probe(struct platform_device *pdev) return -EINVAL; } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - tcphy->base = devm_ioremap_resource(dev, res); + tcphy->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(tcphy->base)) return PTR_ERR(tcphy->base); -- 2.39.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/4] phy: rockchip: phy-rockchip-typec: Use devm_platform_get_and_ioremap_resource() 2023-07-05 9:01 ` [PATCH 2/4] phy: rockchip: phy-rockchip-typec: " Yangtao Li @ 2023-07-11 13:39 ` Heiko Stuebner 0 siblings, 0 replies; 11+ messages in thread From: Heiko Stuebner @ 2023-07-11 13:39 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I, Yangtao Li Cc: Yangtao Li, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel Am Mittwoch, 5. Juli 2023, 11:01:24 CEST schrieb Yangtao Li: > Convert platform_get_resource(), devm_ioremap_resource() to a single > call to devm_platform_get_and_ioremap_resource(), as this is exactly > what this function does. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Though I guess we should check if the res variable can be removed too. devm_platform_get_and_ioremap_resource() checks for its "res" parameter to be not-NULL. So if nothing in the driver itself is using the actual resource, res could be removed and get replaced by "NULL" when calling devm_platform_get_and_ioremap_resource() Heiko > --- > drivers/phy/rockchip/phy-rockchip-typec.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c > index 8b1667be4915..4efcb78b0ab1 100644 > --- a/drivers/phy/rockchip/phy-rockchip-typec.c > +++ b/drivers/phy/rockchip/phy-rockchip-typec.c > @@ -1116,8 +1116,7 @@ static int rockchip_typec_phy_probe(struct platform_device *pdev) > return -EINVAL; > } > > - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - tcphy->base = devm_ioremap_resource(dev, res); > + tcphy->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); > if (IS_ERR(tcphy->base)) > return PTR_ERR(tcphy->base); > > -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/4] phy: renesas: r8a779f0-ether-serdes: Convert to devm_platform_ioremap_resource() 2023-07-05 9:01 [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Yangtao Li 2023-07-05 9:01 ` [PATCH 2/4] phy: rockchip: phy-rockchip-typec: " Yangtao Li @ 2023-07-05 9:01 ` Yangtao Li 2023-07-05 9:01 ` [PATCH 4/4] phy: mediatek: tphy: " Yangtao Li 2023-07-11 5:11 ` (subset) [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Vinod Koul 3 siblings, 0 replies; 11+ messages in thread From: Yangtao Li @ 2023-07-05 9:01 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I; +Cc: Yangtao Li, linux-phy, linux-kernel Use devm_platform_ioremap_resource() to simplify code. Signed-off-by: Yangtao Li <frank.li@vivo.com> --- drivers/phy/renesas/r8a779f0-ether-serdes.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/phy/renesas/r8a779f0-ether-serdes.c b/drivers/phy/renesas/r8a779f0-ether-serdes.c index 55b7bdfc10d3..67f4c6f8ff91 100644 --- a/drivers/phy/renesas/r8a779f0-ether-serdes.c +++ b/drivers/phy/renesas/r8a779f0-ether-serdes.c @@ -339,22 +339,15 @@ static int r8a779f0_eth_serdes_probe(struct platform_device *pdev) { struct r8a779f0_eth_serdes_drv_data *dd; struct phy_provider *provider; - struct resource *res; int i; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "invalid resource\n"); - return -EINVAL; - } - dd = devm_kzalloc(&pdev->dev, sizeof(*dd), GFP_KERNEL); if (!dd) return -ENOMEM; platform_set_drvdata(pdev, dd); dd->pdev = pdev; - dd->addr = devm_ioremap_resource(&pdev->dev, res); + dd->addr = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(dd->addr)) return PTR_ERR(dd->addr); -- 2.39.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] phy: mediatek: tphy: Convert to devm_platform_ioremap_resource() 2023-07-05 9:01 [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Yangtao Li 2023-07-05 9:01 ` [PATCH 2/4] phy: rockchip: phy-rockchip-typec: " Yangtao Li 2023-07-05 9:01 ` [PATCH 3/4] phy: renesas: r8a779f0-ether-serdes: Convert to devm_platform_ioremap_resource() Yangtao Li @ 2023-07-05 9:01 ` Yangtao Li 2023-07-05 9:22 ` AngeloGioacchino Del Regno 2023-07-11 5:11 ` (subset) [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Vinod Koul 3 siblings, 1 reply; 11+ messages in thread From: Yangtao Li @ 2023-07-05 9:01 UTC (permalink / raw) To: Chunfeng Yun, Vinod Koul, Kishon Vijay Abraham I, Matthias Brugger, AngeloGioacchino Del Regno Cc: Yangtao Li, linux-arm-kernel, linux-mediatek, linux-phy, linux-kernel Use devm_platform_ioremap_resource() to simplify code. Signed-off-by: Yangtao Li <frank.li@vivo.com> --- drivers/phy/mediatek/phy-mtk-tphy.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c index 0d110e50bbfd..cb7a4e6ea017 100644 --- a/drivers/phy/mediatek/phy-mtk-tphy.c +++ b/drivers/phy/mediatek/phy-mtk-tphy.c @@ -1554,7 +1554,6 @@ static int mtk_tphy_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct device_node *child_np; struct phy_provider *provider; - struct resource *sif_res; struct mtk_tphy *tphy; struct resource res; int port, retval; @@ -1576,15 +1575,12 @@ static int mtk_tphy_probe(struct platform_device *pdev) tphy->dev = dev; platform_set_drvdata(pdev, tphy); - sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); /* SATA phy of V1 needn't it if not shared with PCIe or USB */ - if (sif_res && tphy->pdata->version == MTK_PHY_V1) { + if (tphy->pdata->version == MTK_PHY_V1) { /* get banks shared by multiple phys */ - tphy->sif_base = devm_ioremap_resource(dev, sif_res); - if (IS_ERR(tphy->sif_base)) { - dev_err(dev, "failed to remap sif regs\n"); + tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(tphy->sif_base) && PTR_ERR(tphy->sif_base) != -EINVAL) return PTR_ERR(tphy->sif_base); - } } if (tphy->pdata->version < MTK_PHY_V3) { -- 2.39.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] phy: mediatek: tphy: Convert to devm_platform_ioremap_resource() 2023-07-05 9:01 ` [PATCH 4/4] phy: mediatek: tphy: " Yangtao Li @ 2023-07-05 9:22 ` AngeloGioacchino Del Regno 2023-07-05 9:30 ` Yangtao Li 0 siblings, 1 reply; 11+ messages in thread From: AngeloGioacchino Del Regno @ 2023-07-05 9:22 UTC (permalink / raw) To: Yangtao Li, Chunfeng Yun, Vinod Koul, Kishon Vijay Abraham I, Matthias Brugger Cc: linux-arm-kernel, linux-mediatek, linux-phy, linux-kernel Il 05/07/23 11:01, Yangtao Li ha scritto: > Use devm_platform_ioremap_resource() to simplify code. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > --- > drivers/phy/mediatek/phy-mtk-tphy.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c > index 0d110e50bbfd..cb7a4e6ea017 100644 > --- a/drivers/phy/mediatek/phy-mtk-tphy.c > +++ b/drivers/phy/mediatek/phy-mtk-tphy.c > @@ -1554,7 +1554,6 @@ static int mtk_tphy_probe(struct platform_device *pdev) > struct device_node *np = dev->of_node; > struct device_node *child_np; > struct phy_provider *provider; > - struct resource *sif_res; > struct mtk_tphy *tphy; > struct resource res; > int port, retval; > @@ -1576,15 +1575,12 @@ static int mtk_tphy_probe(struct platform_device *pdev) > tphy->dev = dev; > platform_set_drvdata(pdev, tphy); > > - sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > /* SATA phy of V1 needn't it if not shared with PCIe or USB */ > - if (sif_res && tphy->pdata->version == MTK_PHY_V1) { > + if (tphy->pdata->version == MTK_PHY_V1) { > /* get banks shared by multiple phys */ > - tphy->sif_base = devm_ioremap_resource(dev, sif_res); > - if (IS_ERR(tphy->sif_base)) { > - dev_err(dev, "failed to remap sif regs\n"); > + tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(tphy->sif_base) && PTR_ERR(tphy->sif_base) != -EINVAL) That's wrong. You want to return any error unconditionally, as the V1 PHY *needs* the sif iospace and there's nothing afterwards retrying this. Please fix. Regards, Angelo > return PTR_ERR(tphy->sif_base); > - } > } > > if (tphy->pdata->version < MTK_PHY_V3) { -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] phy: mediatek: tphy: Convert to devm_platform_ioremap_resource() 2023-07-05 9:22 ` AngeloGioacchino Del Regno @ 2023-07-05 9:30 ` Yangtao Li 2023-07-05 10:00 ` AngeloGioacchino Del Regno 0 siblings, 1 reply; 11+ messages in thread From: Yangtao Li @ 2023-07-05 9:30 UTC (permalink / raw) To: AngeloGioacchino Del Regno, Chunfeng Yun, Vinod Koul, Kishon Vijay Abraham I, Matthias Brugger Cc: linux-arm-kernel, linux-mediatek, linux-phy, linux-kernel HI AngeloGioacchino, On 2023/7/5 17:22, AngeloGioacchino Del Regno wrote: > Il 05/07/23 11:01, Yangtao Li ha scritto: >> Use devm_platform_ioremap_resource() to simplify code. >> >> Signed-off-by: Yangtao Li <frank.li@vivo.com> >> --- >> drivers/phy/mediatek/phy-mtk-tphy.c | 10 +++------- >> 1 file changed, 3 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c >> b/drivers/phy/mediatek/phy-mtk-tphy.c >> index 0d110e50bbfd..cb7a4e6ea017 100644 >> --- a/drivers/phy/mediatek/phy-mtk-tphy.c >> +++ b/drivers/phy/mediatek/phy-mtk-tphy.c >> @@ -1554,7 +1554,6 @@ static int mtk_tphy_probe(struct >> platform_device *pdev) >> struct device_node *np = dev->of_node; >> struct device_node *child_np; >> struct phy_provider *provider; >> - struct resource *sif_res; >> struct mtk_tphy *tphy; >> struct resource res; >> int port, retval; >> @@ -1576,15 +1575,12 @@ static int mtk_tphy_probe(struct >> platform_device *pdev) >> tphy->dev = dev; >> platform_set_drvdata(pdev, tphy); >> - sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> /* SATA phy of V1 needn't it if not shared with PCIe or USB */ >> - if (sif_res && tphy->pdata->version == MTK_PHY_V1) { >> + if (tphy->pdata->version == MTK_PHY_V1) { >> /* get banks shared by multiple phys */ >> - tphy->sif_base = devm_ioremap_resource(dev, sif_res); >> - if (IS_ERR(tphy->sif_base)) { >> - dev_err(dev, "failed to remap sif regs\n"); >> + tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); >> + if (IS_ERR(tphy->sif_base) && PTR_ERR(tphy->sif_base) != >> -EINVAL) > > That's wrong. You want to return any error unconditionally, as the V1 > PHY *needs* > the sif iospace and there's nothing afterwards retrying this. When sif_res is not configured, an IOMEM_ERR_PTR(-EINVAL) error will be returned in __devm_ioremap_resource. This kind of error is ignored in the newly added code, and the driving probe process will not be interrupted at this time. What did I miss? Thx, Yangtao > > Please fix. > > Regards, > Angelo > >> return PTR_ERR(tphy->sif_base); >> - } >> } >> if (tphy->pdata->version < MTK_PHY_V3) { > > -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] phy: mediatek: tphy: Convert to devm_platform_ioremap_resource() 2023-07-05 9:30 ` Yangtao Li @ 2023-07-05 10:00 ` AngeloGioacchino Del Regno 2023-07-11 5:07 ` Vinod Koul 2023-07-11 8:57 ` Chunfeng Yun (云春峰) 0 siblings, 2 replies; 11+ messages in thread From: AngeloGioacchino Del Regno @ 2023-07-05 10:00 UTC (permalink / raw) To: Yangtao Li, Chunfeng Yun, Vinod Koul, Kishon Vijay Abraham I, Matthias Brugger Cc: linux-arm-kernel, linux-mediatek, linux-phy, linux-kernel Il 05/07/23 11:30, Yangtao Li ha scritto: > HI AngeloGioacchino, > > On 2023/7/5 17:22, AngeloGioacchino Del Regno wrote: >> Il 05/07/23 11:01, Yangtao Li ha scritto: >>> Use devm_platform_ioremap_resource() to simplify code. >>> >>> Signed-off-by: Yangtao Li <frank.li@vivo.com> >>> --- >>> drivers/phy/mediatek/phy-mtk-tphy.c | 10 +++------- >>> 1 file changed, 3 insertions(+), 7 deletions(-) >>> >>> diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c >>> b/drivers/phy/mediatek/phy-mtk-tphy.c >>> index 0d110e50bbfd..cb7a4e6ea017 100644 >>> --- a/drivers/phy/mediatek/phy-mtk-tphy.c >>> +++ b/drivers/phy/mediatek/phy-mtk-tphy.c >>> @@ -1554,7 +1554,6 @@ static int mtk_tphy_probe(struct platform_device *pdev) >>> struct device_node *np = dev->of_node; >>> struct device_node *child_np; >>> struct phy_provider *provider; >>> - struct resource *sif_res; >>> struct mtk_tphy *tphy; >>> struct resource res; >>> int port, retval; >>> @@ -1576,15 +1575,12 @@ static int mtk_tphy_probe(struct platform_device *pdev) >>> tphy->dev = dev; >>> platform_set_drvdata(pdev, tphy); >>> - sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >>> /* SATA phy of V1 needn't it if not shared with PCIe or USB */ >>> - if (sif_res && tphy->pdata->version == MTK_PHY_V1) { >>> + if (tphy->pdata->version == MTK_PHY_V1) { >>> /* get banks shared by multiple phys */ >>> - tphy->sif_base = devm_ioremap_resource(dev, sif_res); >>> - if (IS_ERR(tphy->sif_base)) { >>> - dev_err(dev, "failed to remap sif regs\n"); >>> + tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); >>> + if (IS_ERR(tphy->sif_base) && PTR_ERR(tphy->sif_base) != -EINVAL) >> >> That's wrong. You want to return any error unconditionally, as the V1 PHY *needs* >> the sif iospace and there's nothing afterwards retrying this. > > > When sif_res is not configured, an IOMEM_ERR_PTR(-EINVAL) error will be returned in > __devm_ioremap_resource. > > This kind of error is ignored in the newly added code, and the driving probe > process will not be interrupted at this time. > > What did I miss? > As I said, MTK_PHY_V1 *needs* sif; devm_platform_ioremap_resource() returns a handle to that iospace, or error. tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(tphy->sif_base)) return PTR_ERR(tphy->sif_base); Regards, Angelo > Thx, > > Yangtao > > >> >> Please fix. >> >> Regards, >> Angelo >> >>> return PTR_ERR(tphy->sif_base); >>> - } >>> } >>> if (tphy->pdata->version < MTK_PHY_V3) { >> >> -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] phy: mediatek: tphy: Convert to devm_platform_ioremap_resource() 2023-07-05 10:00 ` AngeloGioacchino Del Regno @ 2023-07-11 5:07 ` Vinod Koul 2023-07-11 8:57 ` Chunfeng Yun (云春峰) 1 sibling, 0 replies; 11+ messages in thread From: Vinod Koul @ 2023-07-11 5:07 UTC (permalink / raw) To: AngeloGioacchino Del Regno Cc: Yangtao Li, Chunfeng Yun, Kishon Vijay Abraham I, Matthias Brugger, linux-arm-kernel, linux-mediatek, linux-phy, linux-kernel On 05-07-23, 12:00, AngeloGioacchino Del Regno wrote: > Il 05/07/23 11:30, Yangtao Li ha scritto: > > HI AngeloGioacchino, > > > > On 2023/7/5 17:22, AngeloGioacchino Del Regno wrote: > > > Il 05/07/23 11:01, Yangtao Li ha scritto: > > > > Use devm_platform_ioremap_resource() to simplify code. > > > > > > > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > > > > --- > > > > drivers/phy/mediatek/phy-mtk-tphy.c | 10 +++------- > > > > 1 file changed, 3 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c > > > > b/drivers/phy/mediatek/phy-mtk-tphy.c > > > > index 0d110e50bbfd..cb7a4e6ea017 100644 > > > > --- a/drivers/phy/mediatek/phy-mtk-tphy.c > > > > +++ b/drivers/phy/mediatek/phy-mtk-tphy.c > > > > @@ -1554,7 +1554,6 @@ static int mtk_tphy_probe(struct platform_device *pdev) > > > > struct device_node *np = dev->of_node; > > > > struct device_node *child_np; > > > > struct phy_provider *provider; > > > > - struct resource *sif_res; > > > > struct mtk_tphy *tphy; > > > > struct resource res; > > > > int port, retval; > > > > @@ -1576,15 +1575,12 @@ static int mtk_tphy_probe(struct platform_device *pdev) > > > > tphy->dev = dev; > > > > platform_set_drvdata(pdev, tphy); > > > > - sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > > > /* SATA phy of V1 needn't it if not shared with PCIe or USB */ > > > > - if (sif_res && tphy->pdata->version == MTK_PHY_V1) { > > > > + if (tphy->pdata->version == MTK_PHY_V1) { > > > > /* get banks shared by multiple phys */ > > > > - tphy->sif_base = devm_ioremap_resource(dev, sif_res); > > > > - if (IS_ERR(tphy->sif_base)) { > > > > - dev_err(dev, "failed to remap sif regs\n"); > > > > + tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); > > > > + if (IS_ERR(tphy->sif_base) && PTR_ERR(tphy->sif_base) != -EINVAL) > > > > > > That's wrong. You want to return any error unconditionally, as the V1 PHY *needs* > > > the sif iospace and there's nothing afterwards retrying this. > > > > > > When sif_res is not configured, an IOMEM_ERR_PTR(-EINVAL) error will be > > returned in __devm_ioremap_resource. > > > > This kind of error is ignored in the newly added code, and the driving > > probe process will not be interrupted at this time. > > > > What did I miss? > > > > As I said, MTK_PHY_V1 *needs* sif; devm_platform_ioremap_resource() returns a > handle to that iospace, or error. > > tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); > if (IS_ERR(tphy->sif_base)) > return PTR_ERR(tphy->sif_base); That does sound right to me -- ~Vinod -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] phy: mediatek: tphy: Convert to devm_platform_ioremap_resource() 2023-07-05 10:00 ` AngeloGioacchino Del Regno 2023-07-11 5:07 ` Vinod Koul @ 2023-07-11 8:57 ` Chunfeng Yun (云春峰) 1 sibling, 0 replies; 11+ messages in thread From: Chunfeng Yun (云春峰) @ 2023-07-11 8:57 UTC (permalink / raw) To: matthias.bgg@gmail.com, frank.li@vivo.com, vkoul@kernel.org, angelogioacchino.delregno@collabora.com, kishon@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-phy@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org On Wed, 2023-07-05 at 12:00 +0200, AngeloGioacchino Del Regno wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > Il 05/07/23 11:30, Yangtao Li ha scritto: > > HI AngeloGioacchino, > > > > On 2023/7/5 17:22, AngeloGioacchino Del Regno wrote: > >> Il 05/07/23 11:01, Yangtao Li ha scritto: > >>> Use devm_platform_ioremap_resource() to simplify code. > >>> > >>> Signed-off-by: Yangtao Li <frank.li@vivo.com> > >>> --- > >>> drivers/phy/mediatek/phy-mtk-tphy.c | 10 +++------- > >>> 1 file changed, 3 insertions(+), 7 deletions(-) > >>> > >>> diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c > >>> b/drivers/phy/mediatek/phy-mtk-tphy.c > >>> index 0d110e50bbfd..cb7a4e6ea017 100644 > >>> --- a/drivers/phy/mediatek/phy-mtk-tphy.c > >>> +++ b/drivers/phy/mediatek/phy-mtk-tphy.c > >>> @@ -1554,7 +1554,6 @@ static int mtk_tphy_probe(struct > platform_device *pdev) > >>> struct device_node *np = dev->of_node; > >>> struct device_node *child_np; > >>> struct phy_provider *provider; > >>> - struct resource *sif_res; > >>> struct mtk_tphy *tphy; > >>> struct resource res; > >>> int port, retval; > >>> @@ -1576,15 +1575,12 @@ static int mtk_tphy_probe(struct > platform_device *pdev) > >>> tphy->dev = dev; > >>> platform_set_drvdata(pdev, tphy); > >>> - sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > >>> /* SATA phy of V1 needn't it if not shared with PCIe or USB > */ > >>> - if (sif_res && tphy->pdata->version == MTK_PHY_V1) { > >>> + if (tphy->pdata->version == MTK_PHY_V1) { > >>> /* get banks shared by multiple phys */ > >>> - tphy->sif_base = devm_ioremap_resource(dev, sif_res); > >>> - if (IS_ERR(tphy->sif_base)) { > >>> - dev_err(dev, "failed to remap sif regs\n"); > >>> + tphy->sif_base = devm_platform_ioremap_resource(pdev, > 0); > >>> + if (IS_ERR(tphy->sif_base) && PTR_ERR(tphy->sif_base) != > -EINVAL) > >> > >> That's wrong. You want to return any error unconditionally, as the > V1 PHY *needs* > >> the sif iospace and there's nothing afterwards retrying this. > > > > > > When sif_res is not configured, an IOMEM_ERR_PTR(-EINVAL) error > will be returned in > > __devm_ioremap_resource. > > > > This kind of error is ignored in the newly added code, and the > driving probe > > process will not be interrupted at this time. > > > > What did I miss? > > > > As I said, MTK_PHY_V1 *needs* sif; devm_platform_ioremap_resource() > returns a > handle to that iospace, or error. > > tphy->sif_base = devm_platform_ioremap_resource(pdev, 0); > if (IS_ERR(tphy->sif_base)) > return PTR_ERR(tphy->sif_base); Yes, it's right, thanks > > Regards, > Angelo > > > Thx, > > > > Yangtao > > > > > >> > >> Please fix. > >> > >> Regards, > >> Angelo > >> > >>> return PTR_ERR(tphy->sif_base); > >>> - } > >>> } > >>> if (tphy->pdata->version < MTK_PHY_V3) { > >> > >> > > > -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: (subset) [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() 2023-07-05 9:01 [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Yangtao Li ` (2 preceding siblings ...) 2023-07-05 9:01 ` [PATCH 4/4] phy: mediatek: tphy: " Yangtao Li @ 2023-07-11 5:11 ` Vinod Koul 3 siblings, 0 replies; 11+ messages in thread From: Vinod Koul @ 2023-07-11 5:11 UTC (permalink / raw) To: Kishon Vijay Abraham I, Yangtao Li; +Cc: linux-phy, linux-kernel On Wed, 05 Jul 2023 17:01:23 +0800, Yangtao Li wrote: > Convert platform_get_resource(), devm_ioremap_resource() to a single > call to devm_platform_get_and_ioremap_resource(), as this is exactly > what this function does. > > Applied, thanks! [1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() commit: babfcaf544d890fe96a54184ccabde9c2afa520f [2/4] phy: rockchip: phy-rockchip-typec: Use devm_platform_get_and_ioremap_resource() commit: 161f7ca9455c27eb0d228def6516d73a9cb841bf [3/4] phy: renesas: r8a779f0-ether-serdes: Convert to devm_platform_ioremap_resource() commit: f21829b8b928ca2aedbed839ab9dec5d079c42dd Best regards, -- ~Vinod -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-07-11 13:39 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-07-05 9:01 [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Yangtao Li 2023-07-05 9:01 ` [PATCH 2/4] phy: rockchip: phy-rockchip-typec: " Yangtao Li 2023-07-11 13:39 ` Heiko Stuebner 2023-07-05 9:01 ` [PATCH 3/4] phy: renesas: r8a779f0-ether-serdes: Convert to devm_platform_ioremap_resource() Yangtao Li 2023-07-05 9:01 ` [PATCH 4/4] phy: mediatek: tphy: " Yangtao Li 2023-07-05 9:22 ` AngeloGioacchino Del Regno 2023-07-05 9:30 ` Yangtao Li 2023-07-05 10:00 ` AngeloGioacchino Del Regno 2023-07-11 5:07 ` Vinod Koul 2023-07-11 8:57 ` Chunfeng Yun (云春峰) 2023-07-11 5:11 ` (subset) [PATCH 1/4] phy: marvell: phy-mvebu-cp110-comphy: Use devm_platform_get_and_ioremap_resource() Vinod Koul
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).