diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2009-06-17 19:26:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-18 16:03:42 -0400 |
commit | e7db06b5d5afcef15c4c3e61c3a7441ed7ad1407 (patch) | |
tree | c0d1e01d49fdb3f288da28ffc3b349810c4e1b61 /drivers/spi/xilinx_spi.c | |
parent | 7d0771970c51e736758525dd71fb82dd036b823a (diff) |
spi: move more spi_setup() functionality into core
Move some common spi_setup() error checks into the SPI framework from the
spi_master controller drivers:
- Add a new "mode_bits" field to spi_master
- Use that in spi_setup to validate the spi->mode value being
requested. Setting this new field is now mandatory for any
controller supporting more than vanilla SPI_MODE_0.
- Update all spi_master drivers to:
* Initialize that field
* Remove current spi_setup() checks using that value.
This is a net minor code shrink.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/xilinx_spi.c')
-rw-r--r-- | drivers/spi/xilinx_spi.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 2d7e6b81fb4a..46b8c5c2f45e 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c | |||
@@ -158,9 +158,6 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi, | |||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | /* the spi->mode bits understood by this driver: */ | ||
162 | #define MODEBITS (SPI_CPOL | SPI_CPHA) | ||
163 | |||
164 | static int xilinx_spi_setup(struct spi_device *spi) | 161 | static int xilinx_spi_setup(struct spi_device *spi) |
165 | { | 162 | { |
166 | struct spi_bitbang *bitbang; | 163 | struct spi_bitbang *bitbang; |
@@ -170,12 +167,6 @@ static int xilinx_spi_setup(struct spi_device *spi) | |||
170 | xspi = spi_master_get_devdata(spi->master); | 167 | xspi = spi_master_get_devdata(spi->master); |
171 | bitbang = &xspi->bitbang; | 168 | bitbang = &xspi->bitbang; |
172 | 169 | ||
173 | if (spi->mode & ~MODEBITS) { | ||
174 | dev_err(&spi->dev, "%s, unsupported mode bits %x\n", | ||
175 | __func__, spi->mode & ~MODEBITS); | ||
176 | return -EINVAL; | ||
177 | } | ||
178 | |||
179 | retval = xilinx_spi_setup_transfer(spi, NULL); | 170 | retval = xilinx_spi_setup_transfer(spi, NULL); |
180 | if (retval < 0) | 171 | if (retval < 0) |
181 | return retval; | 172 | return retval; |
@@ -327,6 +318,9 @@ static int __init xilinx_spi_of_probe(struct of_device *ofdev, | |||
327 | goto put_master; | 318 | goto put_master; |
328 | } | 319 | } |
329 | 320 | ||
321 | /* the spi->mode bits understood by this driver: */ | ||
322 | master->mode_bits = SPI_CPOL | SPI_CPHA; | ||
323 | |||
330 | xspi = spi_master_get_devdata(master); | 324 | xspi = spi_master_get_devdata(master); |
331 | xspi->bitbang.master = spi_master_get(master); | 325 | xspi->bitbang.master = spi_master_get(master); |
332 | xspi->bitbang.chipselect = xilinx_spi_chipselect; | 326 | xspi->bitbang.chipselect = xilinx_spi_chipselect; |