From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 357683EA71; Wed, 21 Feb 2024 13:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708521077; cv=none; b=CGlDGtjjjNSrsmpCO74L8vB+DUOY6GALvAYcA4NPLIARDhTJHunJAiJZ1REPpU/vCsFnQBMNd8Blxw2f1/fWGoflTufMMZQDJgZmpewWtr3yD7km5iW0tFKI624bYQVk7WQydnvuy9iuvcjmuIztVDgKYMnHO24sS2P5BeG0Dqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708521077; c=relaxed/simple; bh=WgE6adk4WOcN324paTBUl/KGqBHpykKVP+IpKP5DKfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JlV3JDGoZikerO3U87PHsTBmcHGfqQI4gD6l2nxcOgALY4T27ckSTwePI5XeJ9eBzzrc2DSa403g1xGZdpY0hsA0qlG7kIzzAqWY3fljmACEv0P7/9Sxjoa3Tly3CnR1CQWo9Melg4kZKBOlJpIFcsKNahpd+xpJkz4jIT+s65U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aXQN1G0C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aXQN1G0C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39DCFC433C7; Wed, 21 Feb 2024 13:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708521077; bh=WgE6adk4WOcN324paTBUl/KGqBHpykKVP+IpKP5DKfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aXQN1G0CNDJyCUD9thSD+x6WgaHlKofRFTimTdpWdxjU9wOKk5K7+L5LdFCcDhGKf /YamK8xdecg233T1tD4P1nisi+ZQAxDZU94Ey53Xpr1vP8Y6Hn2Msmsfn2//iUU00G b70pc2XIj9tpiavkYtKNcDM+WND5ouKuiVWL6vdw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hugo Villeneuve , Sasha Levin Subject: [PATCH 4.19 009/202] serial: sc16is7xx: add check for unsupported SPI modes during probe Date: Wed, 21 Feb 2024 14:05:10 +0100 Message-ID: <20240221125932.054921908@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221125931.742034354@linuxfoundation.org> References: <20240221125931.742034354@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hugo Villeneuve [ Upstream commit 6d710b769c1f5f0d55c9ad9bb49b7dce009ec103 ] 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: Signed-off-by: Hugo Villeneuve Link: https://lore.kernel.org/r/20231221231823.2327894-3-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 07898a46fd96..800cb94e4b91 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1407,7 +1407,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 ? : 4 * HZ_PER_MHZ; ret = spi_setup(spi); -- 2.43.0