All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hugo Villeneuve <hugo@hugovil.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org, kubakici@wp.pl,
	indrakanti_ram@hotmail.com, phil@raspberrypi.org
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	hugo@hugovil.com, Hugo Villeneuve <hvilleneuve@dimonoff.com>,
	stable@vger.kernel.org
Subject: [PATCH v2 02/16] serial: sc16is7xx: add check for unsupported SPI modes during probe
Date: Thu, 21 Dec 2023 18:18:09 -0500	[thread overview]
Message-ID: <20231221231823.2327894-3-hugo@hugovil.com> (raw)
In-Reply-To: <20231221231823.2327894-1-hugo@hugovil.com>

From: Hugo Villeneuve <hvilleneuve@dimonoff.com>

The original comment is confusing because it implies that variants other
than the SC16IS762 supports other SPI modes beside SPI_MODE_0.

Extract from datasheet:
    The SC16IS762 differs from the SC16IS752 in that it supports SPI clock
    speeds up to 15 Mbit/s instead of the 4 Mbit/s supported by the
    SC16IS752... In all other aspects, the SC16IS762 is functionally and
    electrically the same as the SC16IS752.

The same is also true of the SC16IS760 variant versus the SC16IS740 and
SC16IS750 variants.

For all variants, only SPI mode 0 is supported.

Change comment and abort probing if the specified SPI mode is not
SPI_MODE_0.

Fixes: 2c837a8a8f9f ("sc16is7xx: spi interface is added")
Cc: stable@vger.kernel.org
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
 drivers/tty/serial/sc16is7xx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 17b90f971f96..798fa115b28a 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1733,7 +1733,10 @@ static int sc16is7xx_spi_probe(struct spi_device *spi)
 
 	/* Setup SPI bus */
 	spi->bits_per_word	= 8;
-	/* only supports mode 0 on SC16IS762 */
+	/* For all variants, only mode 0 is supported */
+	if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0)
+		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;
 	ret = spi_setup(spi);
-- 
2.39.2


  parent reply	other threads:[~2023-12-21 23:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 23:18 [PATCH v2 00/16] serial: sc16is7xx: fixes, cleanups and improvements Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 01/16] serial: sc16is7xx: fix invalid sc16is7xx_lines bitfield in case of probe error Hugo Villeneuve
2023-12-21 23:18 ` Hugo Villeneuve [this message]
2023-12-21 23:18 ` [PATCH v2 03/16] serial: sc16is7xx: set safe default SPI clock frequency Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 04/16] serial: sc16is7xx: remove obsolete loop in sc16is7xx_port_irq() Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 05/16] serial: sc16is7xx: improve do/while loop in sc16is7xx_irq() Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 06/16] serial: sc16is7xx: use DECLARE_BITMAP for sc16is7xx_lines bitfield Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 07/16] serial: sc16is7xx: use spi_get_device_match_data() Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 08/16] serial: sc16is7xx: use i2c_get_match_data() Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 09/16] serial: sc16is7xx: add driver name to struct uart_driver Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 10/16] serial: sc16is7xx: add macro for max number of UART ports Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 11/16] serial: sc16is7xx: add explicit return for some switch default cases Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 12/16] serial: sc16is7xx: replace hardcoded divisor value with BIT() macro Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 13/16] serial: sc16is7xx: drop unneeded MODULE_ALIAS Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 14/16] serial: sc16is7xx: refactor FIFO access functions to increase commonality Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 15/16] serial: sc16is7xx: reorder code to remove prototype declarations Hugo Villeneuve
2023-12-21 23:18 ` [PATCH v2 16/16] serial: sc16is7xx: refactor EFR lock Hugo Villeneuve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231221231823.2327894-3-hugo@hugovil.com \
    --to=hugo@hugovil.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hvilleneuve@dimonoff.com \
    --cc=indrakanti_ram@hotmail.com \
    --cc=jirislaby@kernel.org \
    --cc=kubakici@wp.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=phil@raspberrypi.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.