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

spi: ep93xx: 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. So we can remove the same checking in this driver.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Mika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Axel Lin and committed by
Mark Brown
56fc0b42 38dbfb59

+5 -16
+5 -16
drivers/spi/spi-ep93xx.c
··· 73 73 * @clk: clock for the controller 74 74 * @regs_base: pointer to ioremap()'d registers 75 75 * @sspdr_phys: physical address of the SSPDR register 76 - * @min_rate: minimum clock rate (in Hz) supported by the controller 77 - * @max_rate: maximum clock rate (in Hz) supported by the controller 78 76 * @wait: wait here until given transfer is completed 79 77 * @current_msg: message that is currently processed (or %NULL if none) 80 78 * @tx: current byte in transfer to transmit ··· 93 95 struct clk *clk; 94 96 void __iomem *regs_base; 95 97 unsigned long sspdr_phys; 96 - unsigned long min_rate; 97 - unsigned long max_rate; 98 98 struct completion wait; 99 99 struct spi_message *current_msg; 100 100 size_t tx; ··· 195 199 * @div_scr: pointer to return the scr divider 196 200 */ 197 201 static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi, 198 - unsigned long rate, 199 - u8 *div_cpsr, u8 *div_scr) 202 + u32 rate, u8 *div_cpsr, u8 *div_scr) 200 203 { 204 + struct spi_master *master = platform_get_drvdata(espi->pdev); 201 205 unsigned long spi_clk_rate = clk_get_rate(espi->clk); 202 206 int cpsr, scr; 203 207 ··· 206 210 * controller. Note that minimum value is already checked in 207 211 * ep93xx_spi_transfer_one_message(). 208 212 */ 209 - rate = clamp(rate, espi->min_rate, espi->max_rate); 213 + rate = clamp(rate, master->min_speed_hz, master->max_speed_hz); 210 214 211 215 /* 212 216 * Calculate divisors so that we can get speed according the ··· 731 735 struct spi_message *msg) 732 736 { 733 737 struct ep93xx_spi *espi = spi_master_get_devdata(master); 734 - struct spi_transfer *t; 735 - 736 - /* first validate each transfer */ 737 - list_for_each_entry(t, &msg->transfers, transfer_list) { 738 - if (t->speed_hz < espi->min_rate) 739 - return -EINVAL; 740 - } 741 738 742 739 msg->state = NULL; 743 740 msg->status = 0; ··· 906 917 * Calculate maximum and minimum supported clock rates 907 918 * for the controller. 908 919 */ 909 - espi->max_rate = clk_get_rate(espi->clk) / 2; 910 - espi->min_rate = clk_get_rate(espi->clk) / (254 * 256); 920 + master->max_speed_hz = clk_get_rate(espi->clk) / 2; 921 + master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); 911 922 espi->pdev = pdev; 912 923 913 924 espi->sspdr_phys = res->start + SSPDR;