lkml.org 
[lkml]   [2020]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] spi: Limit the spi device max speed to controller's max speed
    Date
    Make sure the max_speed_hz of spi_device does not override
    the max_speed_hz of controller.

    Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    ---
    drivers/spi/spi.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
    index cd3c395b4e90..51d7c004fbab 100644
    --- a/drivers/spi/spi.c
    +++ b/drivers/spi/spi.c
    @@ -3378,7 +3378,8 @@ int spi_setup(struct spi_device *spi)
    if (status)
    return status;

    - if (!spi->max_speed_hz)
    + if (!spi->max_speed_hz ||
    + spi->max_speed_hz > spi->controller->max_speed_hz)
    spi->max_speed_hz = spi->controller->max_speed_hz;

    mutex_lock(&spi->controller->io_mutex);
    --
    2.25.1
    \
     
     \ /
      Last update: 2020-12-09 18:37    [W:3.332 / U:0.052 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site