spi: sirf: replace kmalloc by devm_kzalloc
Subsystems (2)
PATCH 1/2 spi: sirf: replace kmalloc by devm_kzalloc
From: Qipan Li <[email protected]>
--- drivers/spi/spi-sirf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/spi/spi-sirf.c +2 -5
@@ -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);
Signature · 1 line
2.3.5
PATCH 2/2 spi: sirf: add support for USP-based SPI
From: Qipan Li <[email protected]>
USP is a general purpose serial port in SiRFSoC, which can work as SPI. the most data flow of USP and pure SPI is same with main differences in registers layout.
this patch moves registers layout to private data, and use flags to differentiate other minor differences between prima2-spi, prima2-usp and atlas7-usp for hardware configuration.
--- Documentation/devicetree/bindings/spi/spi-sirf.txt | 3 +- drivers/spi/spi-sirf.c | 723 +++++++++++++++------ 2 files changed, 537 insertions(+), 189 deletions(-)
Documentation/devicetree/bindings/spi/spi-sirf.txt +2 -1
@@ -1,7 +1,8 @@ * CSR SiRFprimaII Serial Peripheral Interface Required properties: -- compatible : Should be "sirf,prima2-spi" +- compatible : Should be "sirf,prima2-spi", "sirf,prima2-usp" + or "sirf,atlas7-usp" - reg : Offset and length of the register set for the device - interrupts : Should contain SPI interrupt - resets: phandle to the reset controller asserting this device in
drivers/spi/spi-sirf.c +535 -188
1,039 lines not on this page · raw message
Signature · 1 line
2.3.5
PATCH 1/2 spi: sirf: replace kmalloc by devm_kzalloc
In reply to Barry SongQuoted 13 lines · Barry Song
From: Qipan Li <[email protected]>
Signed-off-by Qipan Li <[email protected]>Signed-off-by Barry Song <[email protected]>--- drivers/spi/spi-sirf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/spi/spi-sirf.c +0
-0
drivers/spi/spi-sirf.c static int spi_sirfsoc_probe(struct platform_device *pdev) · line 764
Quoted 8 lines
drivers/spi/spi-sirf.c +1
-1@@ -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 at 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
Mark Brown
maintainerPATCH 1/2 spi: sirf: replace kmalloc by devm_kzalloc
Quoted 2 lines · Geert Uytterhoeven
What about setting
SPI_MASTER_MUST_RXand/orSPI_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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150507/74ac5c30/attachment.sig>
Mark Brown
maintainerPATCH 1/2 spi: sirf: replace kmalloc by devm_kzalloc
In reply to Barry SongQuoted 2 lines · Barry Song
From: Qipan Li <[email protected]>
Applied since it's an improvement but please do update to use the core
features like Geert suggested.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150507/944ff8c7/attachment.sig>
PATCH 1/2 spi: sirf: replace kmalloc by devm_kzalloc
2015-05-07 17:46 GMT+08:00 Mark Brown <[email protected]>:
Quoted 6 lines · Barry Song
Quoted 2 lines
From: Qipan Li <[email protected]>
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
Mark Brown
maintainerPATCH 2/2 spi: sirf: add support for USP-based SPI
In reply to Barry SongOn Thu, May 07, 2015 at 07:13:11AM +0000, Barry Song wrote:
This all looks mostly fine, there are a few comments below but they're all coding style things rather than anything else so should be easy enough to address.
drivers/spi/spi-sirf.c line 138
Quoted 3 lines
drivers/spi/spi-sirf.c +3
-0+#define SIRFSOC_SPI_FIFO_LEVEL_MASK (s) ((s->spi_type == SIRF_REAL_SPI) ? \ + 0xFF : ((s->is_atlas7_usp == 1) ? \ + 0x1FF : 0x7F))
This pattern isn't very legible and isn't going to scale if there's more types added (eg, some new variant with a bigger FIFO). Can you make these static inline functions with switch and if statements instead? It looks like they should all fit into that pattern.
It'd probably help make the patch easier to read if the changes to use these functions were added as separate patches - add the functions and convert everything to use them, then in a separate patch add the options for the new variants.
drivers/spi/spi-sirf.c line 234
Quoted 3 lines
drivers/spi/spi-sirf.c +3
-0+ .spi_dummy_delay_ctrl = 0x144, +}; +struct sirf_spi_register sirf_usp_spi = {
Can we have blank lines between the structs please? Also the structs should be declared as static const so they're not in the global namespace.
Quoted 4 lines
drivers/spi/spi-sirf.c +4
-0+if (sspi->spi_type ==SIRF_REAL_SPI ) { +u32 regval =readl (sspi->base + spi_reg->spi_ctrl); + +writel (regval, sspi->base + spi_reg->spi_ctrl);
...
drivers/spi/spi-sirf.c static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) · line 742
Quoted 3 lines
drivers/spi/spi-sirf.c +3
-0+ }else { +u32 regval =readl (sspi->base + + spi_reg->usp_pin_io_data);
Please write this as a switch statement so it's easier to handle an new
variants. Similarly for any other things that handle variants with if
statements.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150507/dcf1df74/attachment.sig>