dm: spi: Avoid setting the speed with every transfer

Only set the speed if it has changed from last time. Since the speed will
be 0 when the device is probed it will always be changed on the first
transfer after the device is probed.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2015-02-17 15:29:35 -07:00
parent 172a31bf87
commit 60e2809a84
2 changed files with 9 additions and 3 deletions

View File

@ -63,9 +63,12 @@ int spi_claim_bus(struct spi_slave *slave)
}
if (!speed)
speed = 100000;
ret = spi_set_speed_mode(bus, speed, slave->mode);
if (ret)
return ret;
if (speed != slave->speed) {
ret = spi_set_speed_mode(bus, speed, slave->mode);
if (ret)
return ret;
slave->speed = speed;
}
return ops->claim_bus ? ops->claim_bus(dev) : 0;
}