Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Axel Lin and committed by
Mark Brown
09e99bca c5c67e31

+3 -10
+3 -10
drivers/spi/spi-sc18is602.c
··· 183 183 static int sc18is602_check_transfer(struct spi_device *spi, 184 184 struct spi_transfer *t, int tlen) 185 185 { 186 - uint32_t hz; 187 - 188 186 if (t && t->len + tlen > SC18IS602_BUFSIZ) 189 - return -EINVAL; 190 - 191 - hz = spi->max_speed_hz; 192 - if (t && t->speed_hz) 193 - hz = t->speed_hz; 194 - if (hz == 0) 195 187 return -EINVAL; 196 188 197 189 return 0; ··· 199 207 200 208 hw->tlen = 0; 201 209 list_for_each_entry(t, &m->transfers, transfer_list) { 202 - u32 hz = t->speed_hz ? : spi->max_speed_hz; 203 210 bool do_transfer; 204 211 205 212 status = sc18is602_check_transfer(spi, t, hw->tlen); 206 213 if (status < 0) 207 214 break; 208 215 209 - status = sc18is602_setup_transfer(hw, hz, spi->mode); 216 + status = sc18is602_setup_transfer(hw, t->speed_hz, spi->mode); 210 217 if (status < 0) 211 218 break; 212 219 ··· 296 305 master->setup = sc18is602_setup; 297 306 master->transfer_one_message = sc18is602_transfer_one; 298 307 master->dev.of_node = np; 308 + master->min_speed_hz = hw->freq / 128; 309 + master->max_speed_hz = hw->freq / 4; 299 310 300 311 error = devm_spi_register_master(dev, master); 301 312 if (error)