On Thu, Oct 31, 2013 at 10:01:45AM +0800, Axel Lin wrote:
> Also move platform_get_resource() call close to devm_ioremap_resource().
> The implementation of devm_ioremap_resource() will also check mem parameter
> and emit proper error.
> 
> Signed-off-by: Axel Lin <[email protected]>

Acked-by: Christian Ruppert <[email protected]>

> ---
>  drivers/gpio/gpio-tb10x.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
> index 833d0f4..45bfed1 100644
> --- a/drivers/gpio/gpio-tb10x.c
> +++ b/drivers/gpio/gpio-tb10x.c
> @@ -194,23 +194,16 @@ static int tb10x_gpio_probe(struct platform_device 
> *pdev)
>       if (of_property_read_u32(dn, "abilis,ngpio", &ngpio))
>               return -EINVAL;
>  
> -     mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -     if (!mem) {
> -             dev_err(&pdev->dev, "No memory resource defined.\n");
> -             return -EINVAL;
> -     }
> -
>       tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL);
>       if (tb10x_gpio == NULL)
>               return -ENOMEM;
>  
>       spin_lock_init(&tb10x_gpio->spinlock);
>  
> +     mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>       tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem);
> -     if (!tb10x_gpio->base) {
> -             dev_err(&pdev->dev, "Could not remap reg space.\n");
> -             goto fail_ioremap;
> -     }
> +     if (IS_ERR(tb10x_gpio->base))
> +             return PTR_ERR(tb10x_gpio->base);
>  
>       tb10x_gpio->gc.label            = of_node_full_name(dn);
>       tb10x_gpio->gc.dev              = &pdev->dev;
> @@ -285,7 +278,6 @@ fail_request_irq:
>  fail_get_irq:
>       gpiochip_remove(&tb10x_gpio->gc);
>  fail_gpiochip_registration:
> -fail_ioremap:
>       return ret;
>  }
>  
> -- 
> 1.8.1.2
> 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to