diff mbox series

[-next] pinctrl: mediatek: use devm_platform_ioremap_resource_byname()

Message ID 20200917064151.2184010-1-wangxiaojun11@huawei.com
State Accepted
Commit 48548c786572f96cae5b7238da5338aa11cc9d34
Headers show
Series [-next] pinctrl: mediatek: use devm_platform_ioremap_resource_byname() | expand

Commit Message

Wang Xiaojun Sept. 17, 2020, 6:41 a.m. UTC
Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately.

Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
---
 drivers/pinctrl/mediatek/pinctrl-moore.c         | 11 ++---------
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c |  9 +--------
 drivers/pinctrl/mediatek/pinctrl-paris.c         | 11 ++---------
 3 files changed, 5 insertions(+), 26 deletions(-)

Comments

Sean Wang Sept. 27, 2020, 6:29 p.m. UTC | #1
On Wed, Sep 16, 2020 at 11:39 PM Wang Xiaojun <wangxiaojun11@huawei.com> wrote:
>

> Use the devm_platform_ioremap_resource_byname() helper instead of

> calling platform_get_resource_byname() and devm_ioremap_resource()

> separately.

>

> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>


Acked-by: Sean Wang <sean.wang@kernel.org>


> ---

>  drivers/pinctrl/mediatek/pinctrl-moore.c         | 11 ++---------

>  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c |  9 +--------

>  drivers/pinctrl/mediatek/pinctrl-paris.c         | 11 ++---------

>  3 files changed, 5 insertions(+), 26 deletions(-)

>

> diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c

> index aa1068d2867f..5e00f93ac998 100644

> --- a/drivers/pinctrl/mediatek/pinctrl-moore.c

> +++ b/drivers/pinctrl/mediatek/pinctrl-moore.c

> @@ -589,7 +589,6 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,

>                             const struct mtk_pin_soc *soc)

>  {

>         struct pinctrl_pin_desc *pins;

> -       struct resource *res;

>         struct mtk_pinctrl *hw;

>         int err, i;

>

> @@ -612,14 +611,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,

>                 return -ENOMEM;

>

>         for (i = 0; i < hw->soc->nbase_names; i++) {

> -               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

> -                                                  hw->soc->base_names[i]);

> -               if (!res) {

> -                       dev_err(&pdev->dev, "missing IO resource\n");

> -                       return -ENXIO;

> -               }

> -

> -               hw->base[i] = devm_ioremap_resource(&pdev->dev, res);

> +               hw->base[i] = devm_platform_ioremap_resource_byname(pdev,

> +                                               hw->soc->base_names[i]);

>                 if (IS_ERR(hw->base[i]))

>                         return PTR_ERR(hw->base[i]);

>         }

> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c

> index 2f3dfb56c3fa..e8622c7e117a 100644

> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c

> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c

> @@ -354,7 +354,6 @@ static const struct mtk_eint_xt mtk_eint_xt = {

>  int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)

>  {

>         struct device_node *np = pdev->dev.of_node;

> -       struct resource *res;

>

>         if (!IS_ENABLED(CONFIG_EINT_MTK))

>                 return 0;

> @@ -366,13 +365,7 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)

>         if (!hw->eint)

>                 return -ENOMEM;

>

> -       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "eint");

> -       if (!res) {

> -               dev_err(&pdev->dev, "Unable to get eint resource\n");

> -               return -ENODEV;

> -       }

> -

> -       hw->eint->base = devm_ioremap_resource(&pdev->dev, res);

> +       hw->eint->base = devm_platform_ioremap_resource_byname(pdev, "eint");

>         if (IS_ERR(hw->eint->base))

>                 return PTR_ERR(hw->eint->base);

>

> diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c

> index a23c18251965..623af4410b07 100644

> --- a/drivers/pinctrl/mediatek/pinctrl-paris.c

> +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c

> @@ -940,7 +940,6 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,

>  {

>         struct pinctrl_pin_desc *pins;

>         struct mtk_pinctrl *hw;

> -       struct resource *res;

>         int err, i;

>

>         hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);

> @@ -963,14 +962,8 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,

>                 return -ENOMEM;

>

>         for (i = 0; i < hw->soc->nbase_names; i++) {

> -               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

> -                                                  hw->soc->base_names[i]);

> -               if (!res) {

> -                       dev_err(&pdev->dev, "missing IO resource\n");

> -                       return -ENXIO;

> -               }

> -

> -               hw->base[i] = devm_ioremap_resource(&pdev->dev, res);

> +               hw->base[i] = devm_platform_ioremap_resource_byname(pdev,

> +                                       hw->soc->base_names[i]);

>                 if (IS_ERR(hw->base[i]))

>                         return PTR_ERR(hw->base[i]);

>         }

> --

> 2.25.1

>
Linus Walleij Sept. 30, 2020, 8:50 a.m. UTC | #2
On Thu, Sep 17, 2020 at 8:40 AM Wang Xiaojun <wangxiaojun11@huawei.com> wrote:

> Use the devm_platform_ioremap_resource_byname() helper instead of

> calling platform_get_resource_byname() and devm_ioremap_resource()

> separately.

>

> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>


Patch applied.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
index aa1068d2867f..5e00f93ac998 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -589,7 +589,6 @@  int mtk_moore_pinctrl_probe(struct platform_device *pdev,
 			    const struct mtk_pin_soc *soc)
 {
 	struct pinctrl_pin_desc *pins;
-	struct resource *res;
 	struct mtk_pinctrl *hw;
 	int err, i;
 
@@ -612,14 +611,8 @@  int mtk_moore_pinctrl_probe(struct platform_device *pdev,
 		return -ENOMEM;
 
 	for (i = 0; i < hw->soc->nbase_names; i++) {
-		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						   hw->soc->base_names[i]);
-		if (!res) {
-			dev_err(&pdev->dev, "missing IO resource\n");
-			return -ENXIO;
-		}
-
-		hw->base[i] = devm_ioremap_resource(&pdev->dev, res);
+		hw->base[i] = devm_platform_ioremap_resource_byname(pdev,
+						hw->soc->base_names[i]);
 		if (IS_ERR(hw->base[i]))
 			return PTR_ERR(hw->base[i]);
 	}
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 2f3dfb56c3fa..e8622c7e117a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -354,7 +354,6 @@  static const struct mtk_eint_xt mtk_eint_xt = {
 int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct resource *res;
 
 	if (!IS_ENABLED(CONFIG_EINT_MTK))
 		return 0;
@@ -366,13 +365,7 @@  int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
 	if (!hw->eint)
 		return -ENOMEM;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "eint");
-	if (!res) {
-		dev_err(&pdev->dev, "Unable to get eint resource\n");
-		return -ENODEV;
-	}
-
-	hw->eint->base = devm_ioremap_resource(&pdev->dev, res);
+	hw->eint->base = devm_platform_ioremap_resource_byname(pdev, "eint");
 	if (IS_ERR(hw->eint->base))
 		return PTR_ERR(hw->eint->base);
 
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index a23c18251965..623af4410b07 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -940,7 +940,6 @@  int mtk_paris_pinctrl_probe(struct platform_device *pdev,
 {
 	struct pinctrl_pin_desc *pins;
 	struct mtk_pinctrl *hw;
-	struct resource *res;
 	int err, i;
 
 	hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
@@ -963,14 +962,8 @@  int mtk_paris_pinctrl_probe(struct platform_device *pdev,
 		return -ENOMEM;
 
 	for (i = 0; i < hw->soc->nbase_names; i++) {
-		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						   hw->soc->base_names[i]);
-		if (!res) {
-			dev_err(&pdev->dev, "missing IO resource\n");
-			return -ENXIO;
-		}
-
-		hw->base[i] = devm_ioremap_resource(&pdev->dev, res);
+		hw->base[i] = devm_platform_ioremap_resource_byname(pdev,
+					hw->soc->base_names[i]);
 		if (IS_ERR(hw->base[i]))
 			return PTR_ERR(hw->base[i]);
 	}