From: Gerhard Sittig <gsi@denx.de>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Mark Brown <broonie@kernel.org>,
linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] spi: switch to devm_spi_alloc_master
Date: Sun, 2 Feb 2014 13:33:27 +0100 [thread overview]
Message-ID: <20140202123327.GR20094@book.gsilab.sittig.org> (raw)
In-Reply-To: <1391163792-21819-4-git-send-email-maxime.ripard@free-electrons.com>
On Fri, Jan 31, 2014 at 11:23 +0100, Maxime Ripard wrote:
>
> Make the existing users of devm_spi_register_master use the
> devm_spi_alloc_master function to avoid leaking memory.
>
> [ ... ]
> drivers/spi/spi-mpc512x-psc.c | 19 ++++++++-----------
Note that the context for the MPC512x SPI driver will change in
3.14-rc1, so you will have to rebase after the merge window.
> diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
> index 46d2313..f376595 100644
> --- a/drivers/spi/spi-mpc512x-psc.c
> +++ b/drivers/spi/spi-mpc512x-psc.c
> @@ -479,7 +479,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
> char clk_name[16];
> struct clk *clk;
>
> - master = spi_alloc_master(dev, sizeof *mps);
> + master = devm_spi_alloc_master(dev, sizeof *mps);
> if (master == NULL)
> return -ENOMEM;
>
> @@ -507,8 +507,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
> tempp = devm_ioremap(dev, regaddr, size);
> if (!tempp) {
> dev_err(dev, "could not ioremap I/O port range\n");
> - ret = -EFAULT;
> - goto free_master;
> + return -EFAULT;
> }
> mps->psc = tempp;
> mps->fifo =
> @@ -516,19 +515,19 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
> ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
> "mpc512x-psc-spi", mps);
> if (ret)
> - goto free_master;
> + return ret;
> init_completion(&mps->txisrdone);
>
> psc_num = master->bus_num;
> snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num);
> clk = devm_clk_get(dev, clk_name);
> - if (IS_ERR(clk)) {
> - ret = PTR_ERR(clk);
> - goto free_master;
> - }
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> +
> ret = clk_prepare_enable(clk);
> if (ret)
> - goto free_master;
> + return ret;
> +
> mps->clk_mclk = clk;
> mps->mclk_rate = clk_get_rate(clk);
>
> @@ -544,8 +543,6 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
>
> free_clock:
> clk_disable_unprepare(mps->clk_mclk);
> -free_master:
> - spi_master_put(master);
>
> return ret;
> }
Reading the diff in the SPI master driver, the change appears to
be balanced, and replacing 'goto free_master' with immediate
return looks appropriate.
Can't comment on the correctness of removing the spi_master_put()
call when switching from spi_alloc_master() to
devm_spi_alloc_master(). This gets discussed in the other
subthread, dealing with the generic subsystem approach.
virtually yours
Gerhard Sittig
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de
next prev parent reply other threads:[~2014-02-02 12:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-31 10:23 [PATCH 0/3] spi: core: Introduce devm_spi_alloc_master Maxime Ripard
2014-01-31 10:23 ` [PATCH 1/3] spi: core: Add devm_spi_alloc_master Maxime Ripard
2014-01-31 10:23 ` [PATCH 2/3] spi: core: Update the devm_spi_register_master documentation Maxime Ripard
2014-01-31 10:23 ` [PATCH 3/3] spi: switch to devm_spi_alloc_master Maxime Ripard
2014-01-31 16:18 ` Stephen Warren
2014-01-31 22:49 ` Maxime Ripard
2014-02-02 12:33 ` Gerhard Sittig [this message]
2014-01-31 12:12 ` [PATCH 0/3] spi: core: Introduce devm_spi_alloc_master Mark Brown
2014-01-31 13:31 ` Maxime Ripard
2014-02-01 17:38 ` Mark Brown
2014-02-02 14:54 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140202123327.GR20094@book.gsilab.sittig.org \
--to=gsi@denx.de \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®