diff mbox

[1/2] spi: sirf: replace kmalloc by devm_kzalloc

Message ID 1430982791-8681-1-git-send-email-21cnbao@gmail.com (mailing list archive)
State Accepted
Commit a34bcbedf8c9f6e960a09ed677d320392b1fe8d0
Headers show

Commit Message

Barry Song May 7, 2015, 7:13 a.m. UTC
From: Qipan Li <Qipan.Li@csr.com>

Signed-off-by: Qipan Li <Qipan.Li@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
 drivers/spi/spi-sirf.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Geert Uytterhoeven May 7, 2015, 7:25 a.m. UTC | #1
On Thu, May 7, 2015 at 9:13 AM, Barry Song <21cnbao@gmail.com> wrote:
> From: Qipan Li <Qipan.Li@csr.com>
>
> Signed-off-by: Qipan Li <Qipan.Li@csr.com>
> Signed-off-by: Barry Song <Baohua.Song@csr.com>
> ---
>  drivers/spi/spi-sirf.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
> index a69ccb7..ae4bd11 100644
> --- a/drivers/spi/spi-sirf.c
> +++ b/drivers/spi/spi-sirf.c
> @@ -758,7 +758,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
>         /* We are not using dummy delay between command and data */
>         writel(0, sspi->base + SIRFSOC_SPI_DUMMY_DELAY_CTL);
>
> -       sspi->dummypage = kmalloc(2 * PAGE_SIZE, GFP_KERNEL);
> +       sspi->dummypage = devm_kzalloc(&pdev->dev, 2 * PAGE_SIZE, GFP_KERNEL);
>         if (!sspi->dummypage) {
>                 ret = -ENOMEM;
>                 goto free_clk;

What about setting SPI_MASTER_MUST_RX and/or SPI_MASTER_MUST_TX,
and removing the dummy page instead, so the spi core will handle it for you?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown May 7, 2015, 9:41 a.m. UTC | #2
On Thu, May 07, 2015 at 09:25:02AM +0200, Geert Uytterhoeven wrote:

> What about setting SPI_MASTER_MUST_RX and/or SPI_MASTER_MUST_TX,
> and removing the dummy page instead, so the spi core will handle it for you?

Yes, that's what it's there for.
Mark Brown May 7, 2015, 9:46 a.m. UTC | #3
On Thu, May 07, 2015 at 07:13:10AM +0000, Barry Song wrote:
> From: Qipan Li <Qipan.Li@csr.com>
> 

Applied since it's an improvement but please do update to use the core
features like Geert suggested.
Barry Song May 7, 2015, 10 a.m. UTC | #4
2015-05-07 17:46 GMT+08:00 Mark Brown <broonie@kernel.org>:
> On Thu, May 07, 2015 at 07:13:10AM +0000, Barry Song wrote:
>> From: Qipan Li <Qipan.Li@csr.com>
>>
>
> Applied since it's an improvement but please do update to use the core
> features like Geert suggested.

it looks like a good idea from Geert. we will have an incremental
patch for this.

-barry
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index a69ccb7..ae4bd11 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -758,7 +758,7 @@  static int spi_sirfsoc_probe(struct platform_device *pdev)
 	/* We are not using dummy delay between command and data */
 	writel(0, sspi->base + SIRFSOC_SPI_DUMMY_DELAY_CTL);
 
-	sspi->dummypage = kmalloc(2 * PAGE_SIZE, GFP_KERNEL);
+	sspi->dummypage = devm_kzalloc(&pdev->dev, 2 * PAGE_SIZE, GFP_KERNEL);
 	if (!sspi->dummypage) {
 		ret = -ENOMEM;
 		goto free_clk;
@@ -766,12 +766,10 @@  static int spi_sirfsoc_probe(struct platform_device *pdev)
 
 	ret = spi_bitbang_start(&sspi->bitbang);
 	if (ret)
-		goto free_dummypage;
+		goto free_clk;
 	dev_info(&pdev->dev, "registerred, bus number = %d\n", master->bus_num);
 
 	return 0;
-free_dummypage:
-	kfree(sspi->dummypage);
 free_clk:
 	clk_disable_unprepare(sspi->clk);
 	clk_put(sspi->clk);
@@ -794,7 +792,6 @@  static int  spi_sirfsoc_remove(struct platform_device *pdev)
 	sspi = spi_master_get_devdata(master);
 
 	spi_bitbang_stop(&sspi->bitbang);
-	kfree(sspi->dummypage);
 	clk_disable_unprepare(sspi->clk);
 	clk_put(sspi->clk);
 	dma_release_channel(sspi->rx_chan);