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/mpc52xx_psc_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/mpc52xx_psc_spi.c')
-rw-r--r-- | drivers/spi/mpc52xx_psc_spi.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 68c77a911595..bdae9f908978 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -261,9 +261,6 @@ static void mpc52xx_psc_spi_work(struct work_struct *work) | |||
261 | spin_unlock_irq(&mps->lock); | 261 | spin_unlock_irq(&mps->lock); |
262 | } | 262 | } |
263 | 263 | ||
264 | /* the spi->mode bits understood by this driver: */ | ||
265 | #define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST) | ||
266 | |||
267 | static int mpc52xx_psc_spi_setup(struct spi_device *spi) | 264 | static int mpc52xx_psc_spi_setup(struct spi_device *spi) |
268 | { | 265 | { |
269 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); | 266 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); |
@@ -273,12 +270,6 @@ static int mpc52xx_psc_spi_setup(struct spi_device *spi) | |||
273 | if (spi->bits_per_word%8) | 270 | if (spi->bits_per_word%8) |
274 | return -EINVAL; | 271 | return -EINVAL; |
275 | 272 | ||
276 | if (spi->mode & ~MODEBITS) { | ||
277 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | ||
278 | spi->mode & ~MODEBITS); | ||
279 | return -EINVAL; | ||
280 | } | ||
281 | |||
282 | if (!cs) { | 273 | if (!cs) { |
283 | cs = kzalloc(sizeof *cs, GFP_KERNEL); | 274 | cs = kzalloc(sizeof *cs, GFP_KERNEL); |
284 | if (!cs) | 275 | if (!cs) |
@@ -385,6 +376,9 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
385 | dev_set_drvdata(dev, master); | 376 | dev_set_drvdata(dev, master); |
386 | mps = spi_master_get_devdata(master); | 377 | mps = spi_master_get_devdata(master); |
387 | 378 | ||
379 | /* the spi->mode bits understood by this driver: */ | ||
380 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; | ||
381 | |||
388 | mps->irq = irq; | 382 | mps->irq = irq; |
389 | if (pdata == NULL) { | 383 | if (pdata == NULL) { |
390 | dev_warn(dev, "probe called without platform data, no " | 384 | dev_warn(dev, "probe called without platform data, no " |