[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181017195632.xqxevygukhat6hkh@mwanda>
Date: Wed, 17 Oct 2018 22:56:32 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Sasha Levin <sashal@...nel.org>
Cc: Nishad Kamdar <nishadkamdar@...il.com>, devel@...verdev.osuosl.org,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
linux-iio@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, outreachy-kernel@...glegroups.com,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Hartmut Knaack <knaack.h@....de>,
Jonathan Cameron <jic23@...nel.org>
Subject: Re: [PATCH v2] staging: iio: ad7816: Switch to the gpio descriptor
interface
On Wed, Oct 17, 2018 at 10:58:23AM -0400, Sasha Levin wrote:
> On Wed, Oct 17, 2018 at 08:17:20PM +0530, Nishad Kamdar wrote:
> > + chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN);
> > + if (IS_ERR(chip->rdwr_pin)) {
> > + ret = PTR_ERR(chip->rdwr_pin);
> > + dev_err(&spi_dev->dev, "Failed to request rdwr GPIO: %d\n",
> > + ret);
> > return ret;
> > }
> > - gpio_direction_input(chip->rdwr_pin);
> > - ret = devm_gpio_request(&spi_dev->dev, chip->convert_pin,
> > - spi_get_device_id(spi_dev)->name);
> > - if (ret) {
> > - dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n",
> > - chip->convert_pin);
> > + chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert", GPIOD_IN);
> > + if (IS_ERR(chip->convert_pin)) {
> > + ret = PTR_ERR(chip->convert_pin);
> > + dev_err(&spi_dev->dev, "Failed to request convert GPIO: %d\n",
> > + ret);
> > return ret;
> > }
> > - gpio_direction_input(chip->convert_pin);
> > - ret = devm_gpio_request(&spi_dev->dev, chip->busy_pin,
> > - spi_get_device_id(spi_dev)->name);
> > - if (ret) {
> > - dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n",
> > - chip->busy_pin);
> > + chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", GPIOD_IN);
> > + if (IS_ERR(chip->busy_pin)) {
> > + ret = PTR_ERR(chip->busy_pin);
> > + dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n",
> > + ret);
> > return ret;
> > }
>
> Hm, from what I can tell devm_gpio_request() is allocating some memory,
> which makes this a series of 4 allocations.
>
> What happens if the fourth allocation fails? Do we leak the first three?
These are devm_ allocations. They are freed when &spi_dev->dev is
released.
regards,
dan carpenter
Powered by blists - more mailing lists