lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAVeFuLuP4V4+heh-cpMxQ66jMBkM5XX7YjqabEMGW=GjneqmQ@mail.gmail.com>
Date:	Tue, 13 May 2014 16:55:23 +0900
From:	Alexandre Courbot <gnurou@...il.com>
To:	abdoulaye berthe <berthe.ab@...il.com>
Cc:	Linus Walleij <linus.walleij@...aro.org>,
	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpio: using devm functions for timberdale gpio memory
 allocation This eases memory allocation and provides appropriate logging

A welcome cleanup, but the subject line of your patch is waaay too
long. As a rule of thumb, try to limit it to 50 characters ([PATCH]
tag not included), with slight overlapping tolerated.

Also to better spot which driver is changed, please prefix it with
"gpio: timberdale: "

For this patch, "gpio: timberdale: use devm functions" looks good to me.

The rest of your subject line should be the actual commit message.

Thanks,
Alex.

On Tue, May 13, 2014 at 10:21 AM, abdoulaye berthe <berthe.ab@...il.com> wrote:
> Signed-off-by: abdoulaye berthe <berthe.ab@...il.com>
> ---
>  drivers/gpio/gpio-timberdale.c | 47 ++++++++++++++----------------------------
>  1 file changed, 16 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
> index f9a8fbd..efc7c12 100644
> --- a/drivers/gpio/gpio-timberdale.c
> +++ b/drivers/gpio/gpio-timberdale.c
> @@ -224,6 +224,7 @@ static struct irq_chip timbgpio_irqchip = {
>  static int timbgpio_probe(struct platform_device *pdev)
>  {
>         int err, i;
> +       struct device *dev = &pdev->dev;
>         struct gpio_chip *gc;
>         struct timbgpio *tgpio;
>         struct resource *iomem;
> @@ -231,35 +232,35 @@ static int timbgpio_probe(struct platform_device *pdev)
>         int irq = platform_get_irq(pdev, 0);
>
>         if (!pdata || pdata->nr_pins > 32) {
> -               err = -EINVAL;
> -               goto err_mem;
> +               dev_err(dev, "Invalid platform data\n");
> +               return -EINVAL;
>         }
>
>         iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         if (!iomem) {
> -               err = -EINVAL;
> -               goto err_mem;
> +               dev_err(dev, "Unable to get resource\n");
> +               return -EINVAL;
>         }
>
> -       tgpio = kzalloc(sizeof(*tgpio), GFP_KERNEL);
> +       tgpio = devm_kzalloc(dev, sizeof(struct timbgpio), GFP_KERNEL);
>         if (!tgpio) {
> -               err = -EINVAL;
> -               goto err_mem;
> +               dev_err(dev, "Memory alloc failed\n");
> +               return -EINVAL;
>         }
>         tgpio->irq_base = pdata->irq_base;
>
>         spin_lock_init(&tgpio->lock);
>
> -       if (!request_mem_region(iomem->start, resource_size(iomem),
> -               DRIVER_NAME)) {
> -               err = -EBUSY;
> -               goto err_request;
> +       if (!devm_request_mem_region(dev, iomem->start, resource_size(iomem),
> +                                    DRIVER_NAME)) {
> +               dev_err(dev, "Region already claimed\n");
> +               return -EBUSY;
>         }
>
> -       tgpio->membase = ioremap(iomem->start, resource_size(iomem));
> +       tgpio->membase = devm_ioremap(dev, iomem->start, resource_size(iomem));
>         if (!tgpio->membase) {
> -               err = -ENOMEM;
> -               goto err_ioremap;
> +               dev_err(dev, "Cannot ioremap\n");
> +               return -ENOMEM;
>         }
>
>         gc = &tgpio->gpio;
> @@ -279,7 +280,7 @@ static int timbgpio_probe(struct platform_device *pdev)
>
>         err = gpiochip_add(gc);
>         if (err)
> -               goto err_chipadd;
> +               return err;
>
>         platform_set_drvdata(pdev, tgpio);
>
> @@ -302,17 +303,6 @@ static int timbgpio_probe(struct platform_device *pdev)
>         irq_set_chained_handler(irq, timbgpio_irq);
>
>         return 0;
> -
> -err_chipadd:
> -       iounmap(tgpio->membase);
> -err_ioremap:
> -       release_mem_region(iomem->start, resource_size(iomem));
> -err_request:
> -       kfree(tgpio);
> -err_mem:
> -       printk(KERN_ERR DRIVER_NAME": Failed to register GPIOs: %d\n", err);
> -
> -       return err;
>  }
>
>  static int timbgpio_remove(struct platform_device *pdev)
> @@ -320,7 +310,6 @@ static int timbgpio_remove(struct platform_device *pdev)
>         int err;
>         struct timbgpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
>         struct timbgpio *tgpio = platform_get_drvdata(pdev);
> -       struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         int irq = platform_get_irq(pdev, 0);
>
>         if (irq >= 0 && tgpio->irq_base > 0) {
> @@ -338,10 +327,6 @@ static int timbgpio_remove(struct platform_device *pdev)
>         if (err)
>                 printk(KERN_ERR DRIVER_NAME": failed to remove gpio_chip\n");
>
> -       iounmap(tgpio->membase);
> -       release_mem_region(iomem->start, resource_size(iomem));
> -       kfree(tgpio);
> -
>         return 0;
>  }
>
> --
> 1.8.3.2
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ