aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-02-08 23:15:07 -0500
committerMark Brown <broonie@linaro.org>2014-02-10 09:14:48 -0500
commit425f96d2f635d7a1a101c916830ba7843a6d5a50 (patch)
treef97d4df20de40b01e5377fcd3507488ed2678d8c /drivers/spi
parent38dbfb59d1175ef458d006556061adeaa8751b72 (diff)
spi: txx9: Convert to let spi core handle checking transfer speed
By setting master->max_speed_hz and master->min_speed_hz, spi core will handle checking transfer speed. Then we can remove the same checking in this driver. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-txx9.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c
index 6191ced514b2..523f13df52bb 100644
--- a/drivers/spi/spi-txx9.c
+++ b/drivers/spi/spi-txx9.c
@@ -80,7 +80,6 @@ struct txx9spi {
80 void __iomem *membase; 80 void __iomem *membase;
81 int baseclk; 81 int baseclk;
82 struct clk *clk; 82 struct clk *clk;
83 u32 max_speed_hz, min_speed_hz;
84 int last_chipselect; 83 int last_chipselect;
85 int last_chipselect_val; 84 int last_chipselect_val;
86}; 85};
@@ -117,9 +116,7 @@ static int txx9spi_setup(struct spi_device *spi)
117{ 116{
118 struct txx9spi *c = spi_master_get_devdata(spi->master); 117 struct txx9spi *c = spi_master_get_devdata(spi->master);
119 118
120 if (!spi->max_speed_hz 119 if (!spi->max_speed_hz)
121 || spi->max_speed_hz > c->max_speed_hz
122 || spi->max_speed_hz < c->min_speed_hz)
123 return -EINVAL; 120 return -EINVAL;
124 121
125 if (gpio_direction_output(spi->chip_select, 122 if (gpio_direction_output(spi->chip_select,
@@ -309,15 +306,12 @@ static int txx9spi_transfer(struct spi_device *spi, struct spi_message *m)
309 306
310 /* check each transfer's parameters */ 307 /* check each transfer's parameters */
311 list_for_each_entry(t, &m->transfers, transfer_list) { 308 list_for_each_entry(t, &m->transfers, transfer_list) {
312 u32 speed_hz = t->speed_hz ? : spi->max_speed_hz;
313 u8 bits_per_word = t->bits_per_word; 309 u8 bits_per_word = t->bits_per_word;
314 310
315 if (!t->tx_buf && !t->rx_buf && t->len) 311 if (!t->tx_buf && !t->rx_buf && t->len)
316 return -EINVAL; 312 return -EINVAL;
317 if (t->len & ((bits_per_word >> 3) - 1)) 313 if (t->len & ((bits_per_word >> 3) - 1))
318 return -EINVAL; 314 return -EINVAL;
319 if (speed_hz < c->min_speed_hz || speed_hz > c->max_speed_hz)
320 return -EINVAL;
321 } 315 }
322 316
323 spin_lock_irqsave(&c->lock, flags); 317 spin_lock_irqsave(&c->lock, flags);
@@ -360,8 +354,8 @@ static int txx9spi_probe(struct platform_device *dev)
360 goto exit; 354 goto exit;
361 } 355 }
362 c->baseclk = clk_get_rate(c->clk); 356 c->baseclk = clk_get_rate(c->clk);
363 c->min_speed_hz = DIV_ROUND_UP(c->baseclk, SPI_MAX_DIVIDER + 1); 357 master->min_speed_hz = DIV_ROUND_UP(c->baseclk, SPI_MAX_DIVIDER + 1);
364 c->max_speed_hz = c->baseclk / (SPI_MIN_DIVIDER + 1); 358 master->max_speed_hz = c->baseclk / (SPI_MIN_DIVIDER + 1);
365 359
366 res = platform_get_resource(dev, IORESOURCE_MEM, 0); 360 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
367 if (!res) 361 if (!res)