Skip to contentSkip to conversation

spi: Remove duplicate code to set default bits_per_word setting

PATCH Applied Axel Lin 5 participants 5 messages Jan 17, 2014 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 spi: Remove duplicate code to set default bits_per_word setting

The implementation in spi_setup() already set spi->bits_per_word = 8 when spi->bits_per_word is 0 before calling spi->master->setup.
So we don't need to do it again in setup() callback.

Cc Matt Porter <[email protected]>
Cc Alison Wang <[email protected]>
Cc Chao Fu <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Barry Song <[email protected]>
Cc Tomoya MORINAGA <[email protected]>
---
 drivers/spi/spi-davinci.c      | 4 ----
 drivers/spi/spi-fsl-dspi.c     | 3 ---
 drivers/spi/spi-mxs.c          | 9 ---------
 drivers/spi/spi-rspi.c         | 2 --
 drivers/spi/spi-sc18is602.c    | 3 ---
 drivers/spi/spi-sh.c           | 3 ---
 drivers/spi/spi-sirf.c         | 7 -------
 drivers/spi/spi-topcliff-pch.c | 6 ------
 8 files changed, 37 deletions(-)
drivers/spi/spi-davinci.c +0 -4
index 79d40c8..5e7389f 100644
@@ -396,10 +396,6 @@ static int davinci_spi_setup(struct spi_device *spi)
 	dspi = spi_master_get_devdata(spi->master);
 	pdata = &dspi->pdata;
 
-	/* if bits per word length is zero then set it default 8 */
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
-
 	if (!(spi->mode & SPI_NO_CS)) {
 		if ((pdata->chip_sel == NULL) ||
 		    (pdata->chip_sel[spi->chip_select] == SPI_INTERN_CS))
drivers/spi/spi-fsl-dspi.c +0 -3
index a37f156..ec79f72 100644
@@ -375,9 +375,6 @@ static int dspi_setup(struct spi_device *spi)
 	if (!spi->max_speed_hz)
 		return -EINVAL;
 
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
-
 	return dspi_setup_transfer(spi, NULL);
 }
 
drivers/spi/spi-mxs.c +0 -9
index 3adebfa..79e5aa2 100644
@@ -111,14 +111,6 @@ static int mxs_spi_setup_transfer(struct spi_device *dev,
 	return 0;
 }
 
-static int mxs_spi_setup(struct spi_device *dev)
-{
-	if (!dev->bits_per_word)
-		dev->bits_per_word = 8;
-
-	return 0;
-}
-
 static u32 mxs_spi_cs_to_reg(unsigned cs)
 {
 	u32 select = 0;
@@ -502,7 +494,6 @@ static int mxs_spi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	master->transfer_one_message = mxs_spi_transfer_one;
-	master->setup = mxs_spi_setup;
 	master->bits_per_word_mask = SPI_BPW_MASK(8);
 	master->mode_bits = SPI_CPOL | SPI_CPHA;
 	master->num_chipselect = 3;
drivers/spi/spi-rspi.c +0 -2
index c26840c..28987d9 100644
@@ -802,8 +802,6 @@ static int rspi_setup(struct spi_device *spi)
 {
 	struct rspi_data *rspi = spi_master_get_devdata(spi->master);
 
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
 	rspi->max_speed_hz = spi->max_speed_hz;
 
 	rspi->spcmd = SPCMD_SSLKP;
drivers/spi/spi-sc18is602.c +0 -3
index c981d21..121c2e1 100644
@@ -247,9 +247,6 @@ error:
 
 static int sc18is602_setup(struct spi_device *spi)
 {
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
-
 	if (spi->mode & ~(SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST))
 		return -EINVAL;
 
drivers/spi/spi-sh.c +0 -3
index 9fea8cc..f6f2c70 100644
@@ -352,9 +352,6 @@ static int spi_sh_setup(struct spi_device *spi)
 {
 	struct spi_sh_data *ss = spi_master_get_devdata(spi->master);
 
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
-
 	pr_debug("%s: enter\n", __func__);
 
 	spi_sh_write(ss, 0xfe, SPI_SH_CR1);	/* SPI sycle stop */
drivers/spi/spi-sirf.c +0 -7
index ed5e501..e430689 100644
@@ -536,16 +536,9 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 
 static int spi_sirfsoc_setup(struct spi_device *spi)
 {
-	struct sirfsoc_spi *sspi;
-
 	if (!spi->max_speed_hz)
 		return -EINVAL;
 
-	sspi = spi_master_get_devdata(spi->master);
-
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
-
 	return spi_sirfsoc_setup_transfer(spi, NULL);
 }
 
drivers/spi/spi-topcliff-pch.c +0 -6
index 338fc11..2e7f38c 100644
@@ -466,12 +466,6 @@ static void pch_spi_reset(struct spi_master *master)
 
 static int pch_spi_setup(struct spi_device *pspi)
 {
-	/* check bits per word */
-	if (pspi->bits_per_word == 0) {
-		pspi->bits_per_word = 8;
-		dev_dbg(&pspi->dev, "%s 8 bits per word\n", __func__);
-	}
-
 	/* Check baud rate setting */
 	/* if baud rate of chip is greater than
 	   max we can support,return error */
Signature · 8 lines
1.8.1.2



--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Axel Lin

The implementation in spi_setup() already set spi->bits_per_word = 8 when spi->bits_per_word is 0 before calling spi->master->setup.
So we don't need to do it again in setup() callback.

Quoted 9 lines
Cc Matt Porter <[email protected]>
Cc Alison Wang <[email protected]>
Cc Chao Fu <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Barry Song <[email protected]>
Cc Tomoya MORINAGA <[email protected]>

Good catch,

for spi-mxs:

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#3 lore raw
Quoted 4 lines · Axel Lin

The implementation in spi_setup() already set spi->bits_per_word = 8 when spi->bits_per_word is 0 before calling spi->master->setup.
So we don't need to do it again in setup() callback.

Quoted 9 lines
Cc Matt Porter <[email protected]>
Cc Alison Wang <[email protected]>
Cc Chao Fu <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Barry Song <[email protected]>
Cc Tomoya MORINAGA <[email protected]>

for CSR sirfsoc.

-barry

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc. New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by on v1 1/1
#4 lore raw
In reply to Axel Lin
Quoted 10 lines · Axel Lin

The implementation in spi_setup() already set spi->bits_per_word = 8 when spi->bits_per_word is 0 before calling spi->master->setup.
So we don't need to do it again in setup() callback.

Cc Matt Porter <[email protected]>
Cc Alison Wang <[email protected]>
Cc Chao Fu <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
Cc Guenter Roeck <[email protected]>

For spi-sc18is602.c:

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#5 lore raw
In reply to Axel Lin
Quoted 3 lines · Axel Lin

The implementation in spi_setup() already set spi->bits_per_word = 8 when spi->bits_per_word is 0 before calling spi->master->setup.
So we don't need to do it again in setup() callback.

Applied, thanks.