Skip to content

Commit

Permalink
serial: sc16is7xx: set safe default SPI clock frequency
Browse files Browse the repository at this point in the history
15 MHz is supported only by 76x variants.

If the SPI clock frequency is not specified, use a safe default clock value
of 4 MHz that is supported by all variants.

Also use HZ_PER_MHZ macro to improve readability.

Fixes: 2c837a8 ("sc16is7xx: spi interface is added")
Cc:  <stable@vger.kernel.org>
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20231221231823.2327894-4-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
hvilleneuvedoo authored and gregkh committed Jan 4, 2024
1 parent 6d710b7 commit 3ef79cd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/tty/serial/sc16is7xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/tty_flip.h>
#include <linux/spi/spi.h>
#include <linux/uaccess.h>
#include <linux/units.h>
#include <uapi/linux/sched/types.h>

#define SC16IS7XX_NAME "sc16is7xx"
Expand Down Expand Up @@ -1738,7 +1739,7 @@ static int sc16is7xx_spi_probe(struct spi_device *spi)
return dev_err_probe(&spi->dev, -EINVAL, "Unsupported SPI mode\n");

spi->mode = spi->mode ? : SPI_MODE_0;
spi->max_speed_hz = spi->max_speed_hz ? : 15000000;
spi->max_speed_hz = spi->max_speed_hz ? : 4 * HZ_PER_MHZ;
ret = spi_setup(spi);
if (ret)
return ret;
Expand Down

0 comments on commit 3ef79cd

Please sign in to comment.