[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20140529084959.GA26220@omega>
Date: Thu, 29 May 2014 10:50:02 +0200
From: Alexander Aring <alex.aring@...il.com>
To: Varka Bhadram <varkabhadram@...il.com>
Cc: alan@...nal11.us, Varka Bhadram <varkab@...c.in>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-zigbee-devel@...ts.sourceforge.net, alex.aing@...il.com,
davem@...emloft.net
Subject: Re: [Linux-zigbee-devel] [PATCH net-next v2] mrf24j40: add managed
API's provided by device layer
Hi Varka,
On Thu, May 29, 2014 at 11:35:35AM +0530, Varka Bhadram wrote:
> forgot to use devm_* for spi buff.
> sorry for that.
>
> -Varka Bhadram
>
> Signed-off-by: Varka Bhadram <varkab@...c.in>
> ---
> drivers/net/ieee802154/mrf24j40.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
> index 78a6552..90aed9b 100644
> --- a/drivers/net/ieee802154/mrf24j40.c
> +++ b/drivers/net/ieee802154/mrf24j40.c
> @@ -618,10 +618,10 @@ static int mrf24j40_probe(struct spi_device *spi)
>
> printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq);
>
> - devrec = kzalloc(sizeof(struct mrf24j40), GFP_KERNEL);
> + devrec = devm_kzalloc(&spi->dev, sizeof(struct mrf24j40), GFP_KERNEL);
> if (!devrec)
> goto err_devrec;
> - devrec->buf = kzalloc(3, GFP_KERNEL);
> + devrec->buf = devm_kzalloc(&spi->dev, 3, GFP_KERNEL);
> if (!devrec->buf)
> goto err_buf;
>
> @@ -676,12 +676,13 @@ static int mrf24j40_probe(struct spi_device *spi)
> val &= ~0x3; /* Clear RX mode (normal) */
> write_short_reg(devrec, REG_RXMCR, val);
>
> - ret = request_threaded_irq(spi->irq,
> - NULL,
> - mrf24j40_isr,
> - IRQF_TRIGGER_LOW|IRQF_ONESHOT,
> - dev_name(&spi->dev),
> - devrec);
> + ret = devm_request_threaded_irq(&spi->dev,
> + spi->irq,
> + NULL,
> + mrf24j40_isr,
> + IRQF_TRIGGER_LOW|IRQF_ONESHOT,
> + dev_name(&spi->dev),
> + devrec);
>
when using devm_* it's also freed when the probe function failed, so you
can also remove the error path handling.
err_alloc_dev:
kfree(devrec->buf);
err_buf:
kfree(devrec);
and so on...
- Alex
--
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