2021-04-23 09:06:53

by dingsenjie

[permalink] [raw]
Subject: [PATCH] soc: ti: Use devm_platform_ioremap_resource_byname

From: dingsenjie <[email protected]>

Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately

Signed-off-by: dingsenjie <[email protected]>
---
drivers/soc/ti/k3-ringacc.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index b495b0d..aa8ebd4 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -1352,7 +1352,6 @@ static int k3_ringacc_init(struct platform_device *pdev,
const struct soc_device_attribute *soc;
void __iomem *base_fifo, *base_rt;
struct device *dev = &pdev->dev;
- struct resource *res;
int ret, i;

dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
@@ -1373,24 +1372,19 @@ static int k3_ringacc_init(struct platform_device *pdev,
ringacc->dma_ring_reset_quirk = soc_data->dma_ring_reset_quirk;
}

- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rt");
- base_rt = devm_ioremap_resource(dev, res);
+ base_rt = devm_platform_ioremap_resource_byname(pdev, "rt");
if (IS_ERR(base_rt))
return PTR_ERR(base_rt);

- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fifos");
- base_fifo = devm_ioremap_resource(dev, res);
+ base_fifo = devm_platform_ioremap_resource_byname(pdev, "fifos");
if (IS_ERR(base_fifo))
return PTR_ERR(base_fifo);

- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "proxy_gcfg");
- ringacc->proxy_gcfg = devm_ioremap_resource(dev, res);
+ ringacc->proxy_gcfg = devm_platform_ioremap_resource_byname(pdev, "proxy_gcfg");
if (IS_ERR(ringacc->proxy_gcfg))
return PTR_ERR(ringacc->proxy_gcfg);

- res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
- "proxy_target");
- ringacc->proxy_target_base = devm_ioremap_resource(dev, res);
+ ringacc->proxy_target_base = devm_platform_ioremap_resource_byname(pdev, "proxy_target");
if (IS_ERR(ringacc->proxy_target_base))
return PTR_ERR(ringacc->proxy_target_base);

@@ -1458,7 +1452,6 @@ struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev,
struct device *dev = &pdev->dev;
struct k3_ringacc *ringacc;
void __iomem *base_rt;
- struct resource *res;
int i;

ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL);
@@ -1473,8 +1466,7 @@ struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev,

mutex_init(&ringacc->req_lock);

- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ringrt");
- base_rt = devm_ioremap_resource(dev, res);
+ base_rt = devm_platform_ioremap_resource_byname(pdev, "ringrt");
if (IS_ERR(base_rt))
return ERR_CAST(base_rt);

--
1.9.1


2021-04-23 19:08:35

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH] soc: ti: Use devm_platform_ioremap_resource_byname



On 23/04/2021 12:04, [email protected] wrote:
> From: dingsenjie <[email protected]>
>
> Use the devm_platform_ioremap_resource_byname() helper instead of
> calling platform_get_resource_byname() and devm_ioremap_resource()
> separately
>
> Signed-off-by: dingsenjie <[email protected]>
> ---
> drivers/soc/ti/k3-ringacc.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)

Reviewed-by: Grygorii Strashko <[email protected]>

>
> diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
> index b495b0d..aa8ebd4 100644
> --- a/drivers/soc/ti/k3-ringacc.c
> +++ b/drivers/soc/ti/k3-ringacc.c
> @@ -1352,7 +1352,6 @@ static int k3_ringacc_init(struct platform_device *pdev,
> const struct soc_device_attribute *soc;
> void __iomem *base_fifo, *base_rt;
> struct device *dev = &pdev->dev;
> - struct resource *res;
> int ret, i;
>
> dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
> @@ -1373,24 +1372,19 @@ static int k3_ringacc_init(struct platform_device *pdev,
> ringacc->dma_ring_reset_quirk = soc_data->dma_ring_reset_quirk;
> }
>
> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rt");
> - base_rt = devm_ioremap_resource(dev, res);
> + base_rt = devm_platform_ioremap_resource_byname(pdev, "rt");
> if (IS_ERR(base_rt))
> return PTR_ERR(base_rt);
>
> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fifos");
> - base_fifo = devm_ioremap_resource(dev, res);
> + base_fifo = devm_platform_ioremap_resource_byname(pdev, "fifos");
> if (IS_ERR(base_fifo))
> return PTR_ERR(base_fifo);
>
> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "proxy_gcfg");
> - ringacc->proxy_gcfg = devm_ioremap_resource(dev, res);
> + ringacc->proxy_gcfg = devm_platform_ioremap_resource_byname(pdev, "proxy_gcfg");
> if (IS_ERR(ringacc->proxy_gcfg))
> return PTR_ERR(ringacc->proxy_gcfg);
>
> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> - "proxy_target");
> - ringacc->proxy_target_base = devm_ioremap_resource(dev, res);
> + ringacc->proxy_target_base = devm_platform_ioremap_resource_byname(pdev, "proxy_target");
> if (IS_ERR(ringacc->proxy_target_base))
> return PTR_ERR(ringacc->proxy_target_base);
>
> @@ -1458,7 +1452,6 @@ struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev,
> struct device *dev = &pdev->dev;
> struct k3_ringacc *ringacc;
> void __iomem *base_rt;
> - struct resource *res;
> int i;
>
> ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL);
> @@ -1473,8 +1466,7 @@ struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev,
>
> mutex_init(&ringacc->req_lock);
>
> - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ringrt");
> - base_rt = devm_ioremap_resource(dev, res);
> + base_rt = devm_platform_ioremap_resource_byname(pdev, "ringrt");
> if (IS_ERR(base_rt))
> return ERR_CAST(base_rt);
>
>

--
Best regards,
grygorii