spi: s3c64xx: Zero dma_slave_config struct in prepare_dma()
Subsystems (3)
PATCH 1/3 spi: s3c64xx: Zero dma_slave_config struct in prepare_dma()
Not all fields of dma_slave_config struct are being initialized by prepare_dma() function, leaving those which are not in undefined state, which can confuse DMA drivers using them.
This patch adds call to memset() to zero the struct before initializing a subset of its fields.
--- drivers/spi/spi-s3c64xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-s3c64xx.c +2 -0
@@ -389,6 +389,8 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,struct scatterlist sg;struct dma_async_tx_descriptor *desc; +memset (&config,0 ,sizeof (config)); +if (dma->direction ==DMA_DEV_TO_MEM ) { sdd =container_of ((void *)dma, struct s3c64xx_spi_driver_data, rx_dma);
Signature · 1 line
1.8.3.2
PATCH 2/3 spi: s3c64xx: Do not request CS GPIO on subsequent calls to .setup()
Comments in linux/spi/spi.h and observed behavior show that .setup() callback can be called multiple times without corresponding calls to .cleanup(), what was incorrectly assumed by spi-s3c64xx driver, leading to failures trying to request CS GPIO multiple times.
This patch modifies the behavior of spi-s3c64xx driver to request CS GPIO only on first call to .setup() after last .cleanup().
--- drivers/spi/spi-s3c64xx.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/spi/spi-s3c64xx.c +12 -11
@@ -1068,20 +1068,21 @@ static int s3c64xx_spi_setup(struct spi_device *spi)return -ENODEV ; } -/* Request gpio only if cs line is asserted by gpio pins */ -if (sdd->cs_gpio) { - err =gpio_request_one (cs->line,GPIOF_OUT_INIT_HIGH , -dev_name (&spi->dev)); -if (err) { -dev_err (&spi->dev, -"Failed to get /CS gpio [%d]: %d\n" , - cs->line, err); - goto err_gpio_req; +if (!spi_get_ctldata (spi)) { +/* Request gpio only if cs line is asserted by gpio pins */ +if (sdd->cs_gpio) { + err =gpio_request_one (cs->line,GPIOF_OUT_INIT_HIGH , +dev_name (&spi->dev)); +if (err) { +dev_err (&spi->dev, +"Failed to get /CS gpio [%d]: %d\n" , + cs->line, err); + goto err_gpio_req; + } } - } -if (!spi_get_ctldata (spi))spi_set_ctldata (spi, cs); + } sci = sdd->cntrlr_info;
Signature · 1 line
1.8.3.2
PATCH 3/3 spi: s3c64xx: Use dmaengine_prep_slave_single() to prepare DMA transfers
In reply to Tomasz FigaSince the driver supports only contiguous buffers, there is no need to manually construct a scatterlist with just a single entry, when there is a dedicated helper for this purpose.
This patch modifies prepare_dma() function to use available helper instead of manually creating a scatterlist.
--- drivers/spi/spi-s3c64xx.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/spi/spi-s3c64xx.c +2 -9
@@ -386,7 +386,6 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma, {struct s3c64xx_spi_driver_data *sdd;struct dma_slave_config config; -struct scatterlist sg;struct dma_async_tx_descriptor *desc;memset (&config,0 ,sizeof (config));
@@ -409,14 +408,8 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,dmaengine_slave_config (dma->ch, &config); } -sg_init_table (&sg,1 ); -sg_dma_len (&sg) = len; -sg_set_page (&sg,pfn_to_page (PFN_DOWN (buf)), - len,offset_in_page (buf)); -sg_dma_address (&sg) = buf; - - desc =dmaengine_prep_slave_sg (dma->ch, - &sg,1 , dma->direction,DMA_PREP_INTERRUPT ); + desc =dmaengine_prep_slave_single (dma->ch, buf, len, + dma->direction,DMA_PREP_INTERRUPT ); desc->callback = s3c64xx_spi_dmacb; desc->callback_param = dma;
Signature · 1 line
1.8.3.2
Mark Brown
maintainerPATCH 1/3 spi: s3c64xx: Zero dma_slave_config struct in prepare_dma()
In reply to Tomasz FigaQuoted 3 lines · Tomasz Figa
Not all fields of
dma_slave_configstruct are being initialized byprepare_dma()function, leaving those which are not in undefined state, which can confuse DMA drivers using them.
Applied all, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130811/106d0ab1/attachment.sig>