Commit c98f6fed authored by Paul Barker's avatar Paul Barker Committed by Heinrich Schuchardt
Browse files

spi: Implement spi_set_speed

This function is already defined in spi.h but no implementation of it
currently exists in the tree. The implementation is based on the static
function spi_set_speed_mode(). The function prototype is modified so
that an success or error condition can be returned to the caller.

Signed-off-by: default avatarPaul Barker <>
Reviewed-by: Heinrich Schuchardt's avatarHeinrich Schuchardt <>
parent 0e49f5c2
......@@ -130,6 +130,21 @@ void spi_release_bus(struct spi_slave *slave)
int spi_set_speed(struct spi_slave *slave, uint hz)
struct dm_spi_ops *ops;
int ret;
ops = spi_get_ops(slave->dev->parent);
if (ops->set_speed)
ret = ops->set_speed(slave->dev->parent, hz);
ret = -EINVAL;
if (ret)
dev_err(slave->dev, "Cannot set speed (err=%d)\n", ret);
return ret;
int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
......@@ -352,8 +352,10 @@ void spi_cs_deactivate(struct spi_slave *slave);
* This sets a new speed to be applied for next spi_xfer().
* @slave: The SPI slave
* @hz: The transfer speed
* Returns: 0 on success, or a negative value on error.
void spi_set_speed(struct spi_slave *slave, uint hz);
int spi_set_speed(struct spi_slave *slave, uint hz);
* Write 8 bits, then read 8 bits.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment