spi: spi-ep93xx: remove 'dss' from per chip private data
PATCH 5/8 spi: spi-ep93xx: remove 'dss' from per chip private data
This value is only needed to set the bits per word for each transfer of a message. There is no reason to set the value in ep93xx_spi_enable() because ep93xx_spi_process_transfer() sets it again for each transfer.
Just pass the t->bits_per_word directly to ep93xx_spi_chip_setup() in ep93xx_spi_process_transfer() and remove 'dss' from the per chip private data.
--- drivers/spi/spi-ep93xx.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/spi/spi-ep93xx.c +7 -13
@@ -140,7 +140,6 @@ struct ep93xx_spi {* @rate: max rate in hz this chip supports * @div_cpsr: cpsr (pre-scaler) divider * @div_scr: scr divider -* @dss: bits per word (4 - 16 bits) * @ops: private chip operations * * This structure is used to store hardware register specific settings for each
@@ -152,13 +151,9 @@ struct ep93xx_spi_chip {unsigned long rate;u8 div_cpsr;u8 div_scr; -u8 dss;struct ep93xx_spi_chip_ops *ops; }; -/* converts bits per word to CR0.DSS value */ -#define bits_per_word_to_dss (bpw) ((bpw) - 1) -static int ep93xx_spi_enable (const struct ep93xx_spi *espi) {u8 regval;
@@ -308,8 +303,6 @@ static int ep93xx_spi_setup(struct spi_device *spi) chip->rate = spi->max_speed_hz; } - chip->dss =bits_per_word_to_dss (spi->bits_per_word); -ep93xx_spi_cs_control (spi, false);return 0 ; }
@@ -386,22 +379,25 @@ static void ep93xx_spi_cleanup(struct spi_device *spi)* ep93xx_spi_chip_setup() - configures hardware according to given @chip * @espi: ep93xx SPI controller struct * @chip: chip specific settings +* @bits_per_word: transfer bits_per_word * * This function sets up the actual hardware registers with settings given in * @chip. Note that no validation is done so make sure that callers validate * settings before calling this. */ static void ep93xx_spi_chip_setup (const struct ep93xx_spi *espi, -const struct ep93xx_spi_chip *chip) +const struct ep93xx_spi_chip *chip, +u8 bits_per_word) {u16 cr0; cr0 = chip->div_scr <<SSPCR0_SCR_SHIFT ; cr0 |= (chip->spi->mode & (SPI_CPHA |SPI_CPOL )) <<SSPCR0_MODE_SHIFT ; - cr0 |= chip->dss; + cr0 |= (bits_per_word -1 );dev_dbg (&espi->pdev->dev,"setup: mode %d, cpsr %d, scr %d, dss %d\n" , - chip->spi->mode, chip->div_cpsr, chip->div_scr, chip->dss); + chip->spi->mode, chip->div_cpsr, chip->div_scr, + bits_per_word -1 );dev_dbg (&espi->pdev->dev,"setup: cr0 %#x" , cr0);writeb (chip->div_cpsr, espi->regs_base +SSPCPSR );
@@ -688,9 +684,7 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi *espi,return ; } - chip->dss =bits_per_word_to_dss (t->bits_per_word); - -ep93xx_spi_chip_setup (espi, chip); +ep93xx_spi_chip_setup (espi, chip, t->bits_per_word); espi->word_xfer = (t->bits_per_word >8 ) ? true : false; espi->rx =0 ;
Signature · 9 lines
1.8.1.4 ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev
Quoted 30 lines · H Hartley Sweeten
This value is only needed to set the bits per word for each transfer of a message. There is no reason to set the value in
ep93xx_spi_enable()becauseep93xx_spi_process_transfer()sets it again for each transfer.Just pass the
t->bits_per_worddirectly toep93xx_spi_chip_setup()inep93xx_spi_process_transfer()and remove 'dss' from the per chip private data.Signed-off-by H Hartley Sweeten <[email protected]>Cc Ryan Mallon <[email protected]>Cc Mika Westerberg <[email protected]>Cc Mark Brown <[email protected]>Cc Grant Likely <[email protected]>--- drivers/spi/spi-ep93xx.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)drivers/spi/spi-ep93xx.c +0
-1@@ -140,7 +140,6 @@ struct ep93xx_spi {* @rate: max rate in hz this chip supports * @div_cpsr: cpsr (pre-scaler) divider * @div_scr: scr divider -* @dss: bits per word (4 - 16 bits) * @ops: private chip operations * * This structure is used to store hardware register specific settings for each
drivers/spi/spi-ep93xx.c struct ep93xx_spi_chip { · line 160
Quoted 9 lines
drivers/spi/spi-ep93xx.c +0
-3@@ -152,13 +151,9 @@ struct ep93xx_spi_chip {unsigned long rate;u8 div_cpsr;u8 div_scr; -u8 dss;struct ep93xx_spi_chip_ops *ops; }; -/* converts bits per word to CR0.DSS value */ -#define bits_per_word_to_dss (bpw) ((bpw) - 1)
I think you should keep this macro...
Quoted 24 lines
drivers/spi/spi-ep93xx.c +1
-3-static int ep93xx_spi_enable (const struct ep93xx_spi *espi) {u8 regval;@@ -308,8 +303,6 @@ static int ep93xx_spi_setup(struct spi_device *spi) chip->rate = spi->max_speed_hz; } - chip->dss =bits_per_word_to_dss (spi->bits_per_word); -ep93xx_spi_cs_control (spi, false);return 0 ; }@@ -386,22 +379,25 @@ static void ep93xx_spi_cleanup(struct spi_device *spi)* ep93xx_spi_chip_setup() - configures hardware according to given @chip * @espi: ep93xx SPI controller struct * @chip: chip specific settings +* @bits_per_word: transfer bits_per_word * * This function sets up the actual hardware registers with settings given in * @chip. Note that no validation is done so make sure that callers validate * settings before calling this. */ static void ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
drivers/spi/spi-ep93xx.c static void ep93xx_spi_cleanup(struct spi_device *spi) · line 396
Quoted 10 lines
drivers/spi/spi-ep93xx.c +3
-2- const struct ep93xx_spi_chip *chip) +const struct ep93xx_spi_chip *chip, + u8 bits_per_word) { u16 cr0; cr0 = chip->div_scr <<SSPCR0_SCR_SHIFT ; cr0 |= (chip->spi->mode & (SPI_CPHA |SPI_CPOL )) <<SSPCR0_MODE_SHIFT ; - cr0 |= chip->dss; + cr0 |= (bits_per_word -1 );
... and use it here. It makes things less confusing, at least to me.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.