diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-02-28 05:39:33 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-13 05:47:05 -0400 |
commit | 09e99bca8324c3335794b86802486bb5191861d5 (patch) | |
tree | 7ec8af731667aae1757272a1ac1f14e55138e2d9 | |
parent | c5c67e31bc1b96658169b5b553b9be42e2ca6368 (diff) |
spi: sc18is602: Convert to let spi core validate transfer speed
Set master->max_speed_hz and master->min_speed_hz then spi core will handle
checking transfer speed. So we can remove the same checking in this driver.
This patch also remove testing if hz is 0 because spi->max_speed_hz will be
default set to master->min_speed_hz if it was not set. So the transfer speed
will never set to 0.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi-sc18is602.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c index 7fba10bba3b0..237f2e7a7179 100644 --- a/drivers/spi/spi-sc18is602.c +++ b/drivers/spi/spi-sc18is602.c | |||
@@ -183,17 +183,9 @@ static int sc18is602_setup_transfer(struct sc18is602 *hw, u32 hz, u8 mode) | |||
183 | static int sc18is602_check_transfer(struct spi_device *spi, | 183 | static int sc18is602_check_transfer(struct spi_device *spi, |
184 | struct spi_transfer *t, int tlen) | 184 | struct spi_transfer *t, int tlen) |
185 | { | 185 | { |
186 | uint32_t hz; | ||
187 | |||
188 | if (t && t->len + tlen > SC18IS602_BUFSIZ) | 186 | if (t && t->len + tlen > SC18IS602_BUFSIZ) |
189 | return -EINVAL; | 187 | return -EINVAL; |
190 | 188 | ||
191 | hz = spi->max_speed_hz; | ||
192 | if (t && t->speed_hz) | ||
193 | hz = t->speed_hz; | ||
194 | if (hz == 0) | ||
195 | return -EINVAL; | ||
196 | |||
197 | return 0; | 189 | return 0; |
198 | } | 190 | } |
199 | 191 | ||
@@ -207,14 +199,13 @@ static int sc18is602_transfer_one(struct spi_master *master, | |||
207 | 199 | ||
208 | hw->tlen = 0; | 200 | hw->tlen = 0; |
209 | list_for_each_entry(t, &m->transfers, transfer_list) { | 201 | list_for_each_entry(t, &m->transfers, transfer_list) { |
210 | u32 hz = t->speed_hz ? : spi->max_speed_hz; | ||
211 | bool do_transfer; | 202 | bool do_transfer; |
212 | 203 | ||
213 | status = sc18is602_check_transfer(spi, t, hw->tlen); | 204 | status = sc18is602_check_transfer(spi, t, hw->tlen); |
214 | if (status < 0) | 205 | if (status < 0) |
215 | break; | 206 | break; |
216 | 207 | ||
217 | status = sc18is602_setup_transfer(hw, hz, spi->mode); | 208 | status = sc18is602_setup_transfer(hw, t->speed_hz, spi->mode); |
218 | if (status < 0) | 209 | if (status < 0) |
219 | break; | 210 | break; |
220 | 211 | ||
@@ -305,6 +296,8 @@ static int sc18is602_probe(struct i2c_client *client, | |||
305 | master->setup = sc18is602_setup; | 296 | master->setup = sc18is602_setup; |
306 | master->transfer_one_message = sc18is602_transfer_one; | 297 | master->transfer_one_message = sc18is602_transfer_one; |
307 | master->dev.of_node = np; | 298 | master->dev.of_node = np; |
299 | master->min_speed_hz = hw->freq / 128; | ||
300 | master->max_speed_hz = hw->freq / 4; | ||
308 | 301 | ||
309 | error = devm_spi_register_master(dev, master); | 302 | error = devm_spi_register_master(dev, master); |
310 | if (error) | 303 | if (error) |