From: Doug Anderson Date: Thu, 28 Aug 2014 23:43:48 +0000 (-0700) Subject: spi/rockchip: Avoid accidentally turning off the clock X-Git-Tag: firefly_0821_release~176^2~3308^2~1^2^8 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5d1d150d7d775db1dccb4dc4676075d456dea392;p=firefly-linux-kernel-4.4.55.git spi/rockchip: Avoid accidentally turning off the clock If our client is requesting a clock that is above the maximum clock then the following division will result in 0: rs->max_freq / rs->speed We'll then program 0 into the SPI_BAUDR register. The Rockchip TRM says: "If the value is 0, the serial output clock (sclk_out) is disabled." It's much better to end up with the fastest possible clock rather than a clock that is off, so enforce a minimum value. Signed-off-by: Doug Anderson Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 6321326eb751..cd0e08b0c9f6 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -499,7 +499,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs) } /* div doesn't support odd number */ - div = rs->max_freq / rs->speed; + div = max_t(u32, rs->max_freq / rs->speed, 1); div = (div + 1) & 0xfffe; spi_enable_chip(rs, 0);