[v2,03/11] i2c: brcmstb: Convert to devm_platform_ioremap_resource()

Message ID 20230710063351.17490-3-frank.li@vivo.com
State New
Headers
Series [v2,01/11] i2c: at91: Use devm_platform_get_and_ioremap_resource() |

Commit Message

李扬韬 July 10, 2023, 6:33 a.m. UTC
  Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/i2c/busses/i2c-brcmstb.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
  

Comments

Kamal Dasu July 10, 2023, 6:21 p.m. UTC | #1
On Mon, Jul 10, 2023 at 2:34 AM Yangtao Li <frank.li@vivo.com> wrote:
>
> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Reviewed-by:  Kamal Dasu <kamal.dasu@broadcom.com>
> ---
>  drivers/i2c/busses/i2c-brcmstb.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
> index cf92cbcb8c86..0d422487161a 100644
> --- a/drivers/i2c/busses/i2c-brcmstb.c
> +++ b/drivers/i2c/busses/i2c-brcmstb.c
> @@ -594,11 +594,10 @@ static int bcm2711_release_bsc(struct brcmstb_i2c_dev *dev)
>
>  static int brcmstb_i2c_probe(struct platform_device *pdev)
>  {
> -       int rc = 0;
>         struct brcmstb_i2c_dev *dev;
>         struct i2c_adapter *adap;
> -       struct resource *iomem;
>         const char *int_name;
> +       int rc;
>
>         /* Allocate memory for private data structure */
>         dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
> @@ -614,18 +613,15 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
>         init_completion(&dev->done);
>
>         /* Map hardware registers */
> -       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       dev->base = devm_ioremap_resource(dev->device, iomem);
> -       if (IS_ERR(dev->base)) {
> -               rc = -ENOMEM;
> -               goto probe_errorout;
> -       }
> +       dev->base = devm_platform_ioremap_resource(pdev, 0);
> +       if (IS_ERR(dev->base))
> +               return PTR_ERR(dev->base);
>
>         if (of_device_is_compatible(dev->device->of_node,
>                                     "brcm,bcm2711-hdmi-i2c")) {
>                 rc = bcm2711_release_bsc(dev);
>                 if (rc)
> -                       goto probe_errorout;
> +                       return rc;
>         }
>
>         rc = of_property_read_string(dev->device->of_node, "interrupt-names",
> @@ -678,16 +674,13 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
>         adap->dev.of_node = pdev->dev.of_node;
>         rc = i2c_add_adapter(adap);
>         if (rc)
> -               goto probe_errorout;
> +               return rc;
>
>         dev_info(dev->device, "%s@%dhz registered in %s mode\n",
>                  int_name ? int_name : " ", dev->clk_freq_hz,
>                  (dev->irq >= 0) ? "interrupt" : "polling");
>
>         return 0;
> -
> -probe_errorout:
> -       return rc;
>  }
>
>  static void brcmstb_i2c_remove(struct platform_device *pdev)
> --
> 2.39.0
>
  
Florian Fainelli July 10, 2023, 9 p.m. UTC | #2
On 7/10/2023 8:33 AM, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
  
Andi Shyti July 12, 2023, 3:43 p.m. UTC | #3
Hi Yangtao,

On Mon, Jul 10, 2023 at 02:33:42PM +0800, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Andi
  

Patch

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index cf92cbcb8c86..0d422487161a 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -594,11 +594,10 @@  static int bcm2711_release_bsc(struct brcmstb_i2c_dev *dev)
 
 static int brcmstb_i2c_probe(struct platform_device *pdev)
 {
-	int rc = 0;
 	struct brcmstb_i2c_dev *dev;
 	struct i2c_adapter *adap;
-	struct resource *iomem;
 	const char *int_name;
+	int rc;
 
 	/* Allocate memory for private data structure */
 	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -614,18 +613,15 @@  static int brcmstb_i2c_probe(struct platform_device *pdev)
 	init_completion(&dev->done);
 
 	/* Map hardware registers */
-	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	dev->base = devm_ioremap_resource(dev->device, iomem);
-	if (IS_ERR(dev->base)) {
-		rc = -ENOMEM;
-		goto probe_errorout;
-	}
+	dev->base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(dev->base))
+		return PTR_ERR(dev->base);
 
 	if (of_device_is_compatible(dev->device->of_node,
 				    "brcm,bcm2711-hdmi-i2c")) {
 		rc = bcm2711_release_bsc(dev);
 		if (rc)
-			goto probe_errorout;
+			return rc;
 	}
 
 	rc = of_property_read_string(dev->device->of_node, "interrupt-names",
@@ -678,16 +674,13 @@  static int brcmstb_i2c_probe(struct platform_device *pdev)
 	adap->dev.of_node = pdev->dev.of_node;
 	rc = i2c_add_adapter(adap);
 	if (rc)
-		goto probe_errorout;
+		return rc;
 
 	dev_info(dev->device, "%s@%dhz registered in %s mode\n",
 		 int_name ? int_name : " ", dev->clk_freq_hz,
 		 (dev->irq >= 0) ? "interrupt" : "polling");
 
 	return 0;
-
-probe_errorout:
-	return rc;
 }
 
 static void brcmstb_i2c_remove(struct platform_device *pdev)