From patchwork Tue Feb 6 21:42:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 197662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1854009dyb; Tue, 6 Feb 2024 14:14:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IER4DG7tZqA1U0w0Gu0tVMV0MEv9/HADmh4VmXhK6FtnFMUrwdcSufHGS98bIDA+WaxOxhw X-Received: by 2002:a17:902:ed44:b0:1d9:8bb4:3fdf with SMTP id y4-20020a170902ed4400b001d98bb43fdfmr2866514plb.10.1707257695442; Tue, 06 Feb 2024 14:14:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707257695; cv=pass; d=google.com; s=arc-20160816; b=sovvMllNx+Q1e/NynYO1dFdarf2q4bAx8wRwxOicG6LECezbp2TRv9E/r9btK4va2C /o3qbZ8uN2AVJJhuzrqxSKDIuunU8fThpXkn8tZtN5HJL275Sec8ecRYJfv1d/zLup80 JhQG4z/vx2XgS7nFXxvWJC5gdOklOKTZVy8ZtwafPx9rs1ut4ZVt3CJZiVOC24oNg38q nvMJZPOBKxq++UMvj+xhDwhJfhMRTXk2Jaz66aN7wXvW9TwM0K6wPZh/lpBRiLjb7fRb kNj5LxCOms+eRNS+GqWD93h/AMScWzuFSjd6f97nb77ISL8GPLpEG+nQjiKIs+94Bbzv +oUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:cc:to:from:dkim-signature; bh=/gIgOLz3wVbfgBdtwAQlAKb78cdDXKUGPHpE/f9zKGA=; fh=rU5oQpic7BYKm/eHtBws823weiChb30DBMNSHK9Qi9M=; b=JT2ZoFokSdtN2DNtjSApE3+zoxCr79Vv8oR/7PX+WVi/SOHQ3cnXH3/kxAViRB+wnw RSGM86+TtxxDzpVVPRXZqTtiIOs9nl5ooylCFoWW3igiic1gsjUSRj/VwtmB1WIL1bw5 xbDfMVh7pspJ0h4MBUSXscdLVFicDiLO11T68MM8z1MDM2yOZZ+QJ8O7woiegp8X5d2/ r8n8/6HPw6L36tKDJ/zY7Y1xb19ZtS/wc95lqRM4I7jipzagNsmh4+3wVmvE/Ay7kh1a 6u9pTaZOOJEWdLoajMEQkyztJrPdD0XYIvjDDGGpPmmV3na4pjdeWC9zz67EcNV5EQCQ rf8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=tZKBoaC3; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55679-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55679-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXKon9meaGXsTEl5LJQQfIr/qWsLqGOVvRfFG/0teyjALoxTu/vWlTp0pxWXjfVvBM1GZ871YF/WoaOKF4fY1f2EOWwrg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 5-20020a170902c14500b001d941c96b6dsi7142plj.647.2024.02.06.14.14.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 14:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55679-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=tZKBoaC3; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55679-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55679-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 347F928639C for ; Tue, 6 Feb 2024 22:14:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E99601C2B3; Tue, 6 Feb 2024 22:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="tZKBoaC3" Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (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 81AD71C282; Tue, 6 Feb 2024 22:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707257675; cv=none; b=YnXCm4uUdCx0UevGlT3zyJkTZFdVuj9L/KJwVxfu7E2wRYAzsL94/B/lFCyOguASv2x7HutGvmthlpcpb5zAgK2XXgL+EjFrDZJkOPmxmp16+jeVAWngCBHmhctVe1WLzCWy2VcWNxP6M61beCoQj+VaXCeX76Vy6VNVt2PknsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707257675; c=relaxed/simple; bh=iX/jZ6x7JPoYKfE3wKn+A8vOt4Aa7voggEBapOK97Ys=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=oXHiidwUXdOQ7Fzu/YoVToHlQlebzff0YJw/Lmb690T46svKtAFimPZIWvTXpZfIJn1BdUqfeZ1eL2mbKoSg3BeAtm3rK6Tt/jDtYLK/FaqI7XI/WjA6AxxlhbRA17KWhqmE+a8lO/4xAqwz7LOENq5KFNCWjbnt1AAM08h6QN4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=tZKBoaC3; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=/gIgOLz3wVbfgBdtwAQlAKb78cdDXKUGPHpE/f9zKGA=; b=tZKBoaC3ZXbwdefK2ul98OxQOu +NLmQ458ajNMpM/OUl+yI5we2ugABI4KlRluVAZXMcdob+jH65KXAlGOPqsyzDT2Y7uJu24uQyK38 HrTD1yTEoLl+a3++D+L20vtGNU3qAXwkoAQ8qWGyDGqMxFVRUUVGqu1aUky3toR9lrfY=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:41434 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rXTCm-0006XX-Dx; Tue, 06 Feb 2024 16:42:13 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve Date: Tue, 6 Feb 2024 16:42:05 -0500 Message-Id: <20240206214208.2141067-2-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240206214208.2141067-1-hugo@hugovil.com> References: <20240206214208.2141067-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_SCC_BODY_TEXT_LINE No description available. Subject: [PATCH 1/4] serial: sc16is7xx: simplify and improve Kconfig help text X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790189445466309009 X-GMAIL-MSGID: 1790189445466309009 From: Hugo Villeneuve Simplify and improve Kconfig help text for SC16IS7XX driver: Especially get rid of the confusing: "If required say y, and say n to..." in each of the I2C and SPI portions. Capitalize SPI keyword for consistency. Display list of supported ICs each on a separate line (and aligned) to facilitate locating a specific IC model. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/Kconfig | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index ffcf4882b25f..48087e34ff52 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1028,9 +1028,18 @@ config SERIAL_SC16IS7XX select SERIAL_CORE depends on (SPI_MASTER && !I2C) || I2C help - This selects support for SC16IS7xx serial ports. - Supported ICs are SC16IS740, SC16IS741, SC16IS750, SC16IS752, - SC16IS760 and SC16IS762. Select supported buses using options below. + Core driver for NXP SC16IS7xx serial ports. + Supported ICs are: + + SC16IS740 + SC16IS741 + SC16IS750 + SC16IS752 + SC16IS760 + SC16IS762 + + You also must select at least one of I2C and SPI interface + drivers below. config SERIAL_SC16IS7XX_I2C bool "SC16IS7xx for I2C interface" @@ -1041,9 +1050,7 @@ config SERIAL_SC16IS7XX_I2C default y help Enable SC16IS7xx driver on I2C bus, - If required say y, and say n to i2c if not required, - Enabled by default to support oldconfig. - You must select at least one bus for the driver to be built. + enabled by default to support oldconfig. config SERIAL_SC16IS7XX_SPI bool "SC16IS7xx for spi interface" @@ -1052,10 +1059,7 @@ config SERIAL_SC16IS7XX_SPI select SERIAL_SC16IS7XX_CORE if SERIAL_SC16IS7XX select REGMAP_SPI if SPI_MASTER help - Enable SC16IS7xx driver on SPI bus, - If required say y, and say n to spi if not required, - This is additional support to existing driver. - You must select at least one bus for the driver to be built. + Enable SC16IS7xx driver on SPI bus. config SERIAL_TIMBERDALE tristate "Support for timberdale UART" From patchwork Tue Feb 6 21:42:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 197663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1854245dyb; Tue, 6 Feb 2024 14:15:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFr3qOHASQo5DMbvNfc4je8PwC0Nr9KyAxShM4bVt3RXI8wNJO9YjgXYeLGQxbXW+z9KaLl X-Received: by 2002:a17:906:41:b0:a37:1e9a:c549 with SMTP id 1-20020a170906004100b00a371e9ac549mr2596987ejg.49.1707257730184; Tue, 06 Feb 2024 14:15:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707257730; cv=pass; d=google.com; s=arc-20160816; b=FZh1+290JHXS6ogCiqYsDJ4WpizAsNFHY3zZ4/0rHgQrWB0R2KKVMZXDl+D2053qCA nNgjVu24JAnZuj2sXX0Bu/bL3vED9h7zXDdHnDeREWaSV1Eg4GwgrJWlIhI00PPsSAEY J50MqveiLWzTa+E6fMvNDVm61CXXPkg4j7+kweKI8T3jx2G1QwgOYd4sT12zT4Hykh2G 866q20/PPaecGYanqkiOYmkpQMIqT94/Hzy2VV4f5KBpDpnzxW0KPfFZIJiMFyteKotq 93RZFEAIxoS0Ncmf5peGpJ5jicQcUEQ9qdctq27i3BQbJpTpMbTTdQwcIrNF21PNg+he yPFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:cc:to:from:dkim-signature; bh=6RD4RJOYd6dXTQ3nh6scgF6n1Uy+4SPZ1fVgqYq83Ds=; fh=kyXNMpVONscSdlWbpTHVEPgCf+X8YNIzIqONfb/QgNI=; b=J/4ot33ruDByCuMI1VcxIFqO/+PHR4VzFMQEJ2lSobWk+ep3+QHxiQd1um5WBELCxu jz6ce7hcyrplOjOFk2GE7sWyPFuMkztUBtKpbaX61qVD6KIEw55Drz4VDd1ealQQKZ5j M4WqYCia6OhT/Hlx/1Z2kxPZXlm4gP8vBDoUhyLhDy510BPTAPj8s5bJYxmkl+WNtfnu em2zoTdBfGaWJx1N6yNAHejTGpk8Bnjl8InFgCc/qPED/Lj2ukJhGnLS08/2NxhcyBiW /51M3Qdnf3njRoz0eDSKJLXzob9jKdwGs/bRQky+3I0+LZm6br3AdosY1f/uT2ko0PDF XCSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=fg2Yng19; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55681-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55681-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWqZrfgnKp6uQNBt9csspAjTvtLGdUWrBdU3o66PswZ1ghe9fkRuPwIgpbNO/w9uIL1b40TCFzAP3gRjGx6NshZuVCKuw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h5-20020a170906590500b00a3849110ae2si11156ejq.857.2024.02.06.14.15.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 14:15:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55681-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=fg2Yng19; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55681-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55681-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 90C091F25E3E for ; Tue, 6 Feb 2024 22:15:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 770341BF2A; Tue, 6 Feb 2024 22:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="fg2Yng19" Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (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 417301C69C; Tue, 6 Feb 2024 22:14:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707257681; cv=none; b=qWEo0N7PBHSYD0rqvPjgg6+lwCWjcE+yxHoIZ/7b6Q61t1g742Wf1F3pQE3Dm30bUiYYzkHIPBuyxNpWwJD3pZLPbW58O2DqTDZJ541Poeal6gN5qKDUebvTv82ADenvh9dVuX48J+NWFQGbLnoxN+iWxQEgCGsxk6Tt9rdZ0A4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707257681; c=relaxed/simple; bh=4wcsiogy5GuT23oFHQg43T5PE/N7FkEccJv3pheAc3A=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=ioAPQQpGO30rJm3mO0kK57CFn+LsQOOgk2ox8H5oTwcv0bHz7MVDM+Fzzrcebwgjzry9TEUOUHpJ3uc7XV00E+z4x5aNuFIx/kSbDwocsLpL+TnarO6kKU2rUR6jcQqT+fXmsAvN1gJbyo1DBlbNfpNw9NTD2d5nl4Yo+JZse5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=fg2Yng19; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=6RD4RJOYd6dXTQ3nh6scgF6n1Uy+4SPZ1fVgqYq83Ds=; b=fg2Yng19J12rbTKVLLQyPEHQCU JBKAjKlYiW7dEJ8rrO6vdjEaIRPu4nZ8Z8xgA8CsfdaUEmO2cqYv4Dr9E9zzhMUITYH9arSp0pq2m xS8gn5qg5t5f1dNwg3GfZuPManJM3RGC7tn+HT2u3HxDv5xxySCNmFTpRVEOn09YesIQ=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:41434 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rXTCo-0006XX-LM; Tue, 06 Feb 2024 16:42:17 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve , Andy Shevchenko Date: Tue, 6 Feb 2024 16:42:06 -0500 Message-Id: <20240206214208.2141067-3-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240206214208.2141067-1-hugo@hugovil.com> References: <20240206214208.2141067-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_SCC_BODY_TEXT_LINE No description available. Subject: [PATCH 2/4] serial: sc16is7xx: split into core and I2C/SPI parts (core) X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790189482054958036 X-GMAIL-MSGID: 1790189482054958036 From: Hugo Villeneuve Split the common code from sc16is7xx driver and move the I2C and SPI bus parts into interface-specific source files. sc16is7xx becomes the core functions which can support multiple bus interfaces like I2C and SPI. No functional change intended. Suggested-by: Andy Shevchenko Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/Kconfig | 19 +-- drivers/tty/serial/Makefile | 4 +- drivers/tty/serial/sc16is7xx.c | 223 +++++------------------------ drivers/tty/serial/sc16is7xx.h | 41 ++++++ drivers/tty/serial/sc16is7xx_i2c.c | 71 +++++++++ drivers/tty/serial/sc16is7xx_spi.c | 94 ++++++++++++ 6 files changed, 248 insertions(+), 204 deletions(-) create mode 100644 drivers/tty/serial/sc16is7xx.h create mode 100644 drivers/tty/serial/sc16is7xx_i2c.c create mode 100644 drivers/tty/serial/sc16is7xx_spi.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 48087e34ff52..40343fdf7896 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1020,13 +1020,10 @@ config SERIAL_SCCNXP_CONSOLE help Support for console on SCCNXP serial ports. -config SERIAL_SC16IS7XX_CORE - tristate - config SERIAL_SC16IS7XX tristate "SC16IS7xx serial support" select SERIAL_CORE - depends on (SPI_MASTER && !I2C) || I2C + depends on SPI_MASTER || I2C help Core driver for NXP SC16IS7xx serial ports. Supported ICs are: @@ -1042,22 +1039,18 @@ config SERIAL_SC16IS7XX drivers below. config SERIAL_SC16IS7XX_I2C - bool "SC16IS7xx for I2C interface" + tristate "SC16IS7xx for I2C interface" depends on SERIAL_SC16IS7XX depends on I2C - select SERIAL_SC16IS7XX_CORE if SERIAL_SC16IS7XX - select REGMAP_I2C if I2C - default y + select REGMAP_I2C help - Enable SC16IS7xx driver on I2C bus, - enabled by default to support oldconfig. + Enable SC16IS7xx driver on I2C bus. config SERIAL_SC16IS7XX_SPI - bool "SC16IS7xx for spi interface" + tristate "SC16IS7xx for SPI interface" depends on SERIAL_SC16IS7XX depends on SPI_MASTER - select SERIAL_SC16IS7XX_CORE if SERIAL_SC16IS7XX - select REGMAP_SPI if SPI_MASTER + select REGMAP_SPI help Enable SC16IS7xx driver on SPI bus. diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index b25e9b54a660..9f51b933915a 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -75,7 +75,9 @@ obj-$(CONFIG_SERIAL_SA1100) += sa1100.o obj-$(CONFIG_SERIAL_SAMSUNG) += samsung_tty.o obj-$(CONFIG_SERIAL_SB1250_DUART) += sb1250-duart.o obj-$(CONFIG_SERIAL_SCCNXP) += sccnxp.o -obj-$(CONFIG_SERIAL_SC16IS7XX_CORE) += sc16is7xx.o +obj-$(CONFIG_SERIAL_SC16IS7XX_SPI) += sc16is7xx_spi.o +obj-$(CONFIG_SERIAL_SC16IS7XX_I2C) += sc16is7xx_i2c.o +obj-$(CONFIG_SERIAL_SC16IS7XX) += sc16is7xx.o obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o obj-$(CONFIG_SERIAL_SIFIVE) += sifive.o obj-$(CONFIG_SERIAL_SPRD) += sprd_serial.o diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 929206a9a6e1..5b53c88b7133 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1,19 +1,19 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * SC16IS7xx tty serial driver - Copyright (C) 2014 GridPoint - * Author: Jon Ringle + * SC16IS7xx tty serial driver - common code * - * Based on max310x.c, by Alexander Shiyan + * Copyright (C) 2014 GridPoint + * Author: Jon Ringle + * Based on max310x.c, by Alexander Shiyan */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include #include +#include #include -#include +#include #include #include #include @@ -22,14 +22,13 @@ #include #include #include -#include #include #include #include -#define SC16IS7XX_NAME "sc16is7xx" +#include "sc16is7xx.h" + #define SC16IS7XX_MAX_DEVS 8 -#define SC16IS7XX_MAX_PORTS 2 /* Maximum number of UART ports per IC. */ /* SC16IS7XX register definitions */ #define SC16IS7XX_RHR_REG (0x00) /* RX FIFO */ @@ -302,16 +301,9 @@ /* Misc definitions */ -#define SC16IS7XX_SPI_READ_BIT BIT(7) #define SC16IS7XX_FIFO_SIZE (64) #define SC16IS7XX_GPIOS_PER_BANK 4 -struct sc16is7xx_devtype { - char name[10]; - int nr_gpio; - int nr_uart; -}; - #define SC16IS7XX_RECONF_MD (1 << 0) #define SC16IS7XX_RECONF_IER (1 << 1) #define SC16IS7XX_RECONF_RS485 (1 << 2) @@ -492,35 +484,40 @@ static void sc16is7xx_stop_rx(struct uart_port *port) sc16is7xx_ier_clear(port, SC16IS7XX_IER_RDI_BIT); } -static const struct sc16is7xx_devtype sc16is74x_devtype = { +const struct sc16is7xx_devtype sc16is74x_devtype = { .name = "SC16IS74X", .nr_gpio = 0, .nr_uart = 1, }; +EXPORT_SYMBOL_GPL(sc16is74x_devtype); -static const struct sc16is7xx_devtype sc16is750_devtype = { +const struct sc16is7xx_devtype sc16is750_devtype = { .name = "SC16IS750", .nr_gpio = 8, .nr_uart = 1, }; +EXPORT_SYMBOL_GPL(sc16is750_devtype); -static const struct sc16is7xx_devtype sc16is752_devtype = { +const struct sc16is7xx_devtype sc16is752_devtype = { .name = "SC16IS752", .nr_gpio = 8, .nr_uart = 2, }; +EXPORT_SYMBOL_GPL(sc16is752_devtype); -static const struct sc16is7xx_devtype sc16is760_devtype = { +const struct sc16is7xx_devtype sc16is760_devtype = { .name = "SC16IS760", .nr_gpio = 8, .nr_uart = 1, }; +EXPORT_SYMBOL_GPL(sc16is760_devtype); -static const struct sc16is7xx_devtype sc16is762_devtype = { +const struct sc16is7xx_devtype sc16is762_devtype = { .name = "SC16IS762", .nr_gpio = 8, .nr_uart = 2, }; +EXPORT_SYMBOL_GPL(sc16is762_devtype); static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) { @@ -1463,9 +1460,8 @@ static const struct serial_rs485 sc16is7xx_rs485_supported = { .delay_rts_after_send = 1, /* Not supported but keep returning -EINVAL */ }; -static int sc16is7xx_probe(struct device *dev, - const struct sc16is7xx_devtype *devtype, - struct regmap *regmaps[], int irq) +int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, + struct regmap *regmaps[], int irq) { unsigned long freq = 0, *pfreq = dev_get_platdata(dev); unsigned int val; @@ -1657,8 +1653,9 @@ static int sc16is7xx_probe(struct device *dev, return ret; } +EXPORT_SYMBOL_GPL(sc16is7xx_probe); -static void sc16is7xx_remove(struct device *dev) +void sc16is7xx_remove(struct device *dev) { struct sc16is7xx_port *s = dev_get_drvdata(dev); int i; @@ -1680,8 +1677,9 @@ static void sc16is7xx_remove(struct device *dev) clk_disable_unprepare(s->clk); } +EXPORT_SYMBOL_GPL(sc16is7xx_remove); -static const struct of_device_id __maybe_unused sc16is7xx_dt_ids[] = { +const struct of_device_id __maybe_unused sc16is7xx_dt_ids[] = { { .compatible = "nxp,sc16is740", .data = &sc16is74x_devtype, }, { .compatible = "nxp,sc16is741", .data = &sc16is74x_devtype, }, { .compatible = "nxp,sc16is750", .data = &sc16is750_devtype, }, @@ -1690,9 +1688,10 @@ static const struct of_device_id __maybe_unused sc16is7xx_dt_ids[] = { { .compatible = "nxp,sc16is762", .data = &sc16is762_devtype, }, { } }; +EXPORT_SYMBOL_GPL(sc16is7xx_dt_ids); MODULE_DEVICE_TABLE(of, sc16is7xx_dt_ids); -static struct regmap_config regcfg = { +struct regmap_config sc16is7xx_regcfg = { .reg_bits = 5, .pad_bits = 3, .val_bits = 8, @@ -1705,8 +1704,9 @@ static struct regmap_config regcfg = { .max_raw_write = SC16IS7XX_FIFO_SIZE, .max_register = SC16IS7XX_EFCR_REG, }; +EXPORT_SYMBOL_GPL(sc16is7xx_regcfg); -static const char *sc16is7xx_regmap_name(u8 port_id) +const char *sc16is7xx_regmap_name(u8 port_id) { switch (port_id) { case 0: return "port0"; @@ -1716,184 +1716,27 @@ static const char *sc16is7xx_regmap_name(u8 port_id) return NULL; } } +EXPORT_SYMBOL_GPL(sc16is7xx_regmap_name); -static unsigned int sc16is7xx_regmap_port_mask(unsigned int port_id) +unsigned int sc16is7xx_regmap_port_mask(unsigned int port_id) { /* CH1,CH0 are at bits 2:1. */ return port_id << 1; } - -#ifdef CONFIG_SERIAL_SC16IS7XX_SPI -static int sc16is7xx_spi_probe(struct spi_device *spi) -{ - const struct sc16is7xx_devtype *devtype; - struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; - unsigned int i; - int ret; - - /* Setup SPI bus */ - spi->bits_per_word = 8; - /* 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); - if (ret) - return ret; - - devtype = spi_get_device_match_data(spi); - if (!devtype) - return dev_err_probe(&spi->dev, -ENODEV, "Failed to match device\n"); - - for (i = 0; i < devtype->nr_uart; i++) { - regcfg.name = sc16is7xx_regmap_name(i); - /* - * If read_flag_mask is 0, the regmap code sets it to a default - * of 0x80. Since we specify our own mask, we must add the READ - * bit ourselves: - */ - regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i) | - SC16IS7XX_SPI_READ_BIT; - regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); - regmaps[i] = devm_regmap_init_spi(spi, ®cfg); - } - - return sc16is7xx_probe(&spi->dev, devtype, regmaps, spi->irq); -} - -static void sc16is7xx_spi_remove(struct spi_device *spi) -{ - sc16is7xx_remove(&spi->dev); -} - -static const struct spi_device_id sc16is7xx_spi_id_table[] = { - { "sc16is74x", (kernel_ulong_t)&sc16is74x_devtype, }, - { "sc16is740", (kernel_ulong_t)&sc16is74x_devtype, }, - { "sc16is741", (kernel_ulong_t)&sc16is74x_devtype, }, - { "sc16is750", (kernel_ulong_t)&sc16is750_devtype, }, - { "sc16is752", (kernel_ulong_t)&sc16is752_devtype, }, - { "sc16is760", (kernel_ulong_t)&sc16is760_devtype, }, - { "sc16is762", (kernel_ulong_t)&sc16is762_devtype, }, - { } -}; - -MODULE_DEVICE_TABLE(spi, sc16is7xx_spi_id_table); - -static struct spi_driver sc16is7xx_spi_uart_driver = { - .driver = { - .name = SC16IS7XX_NAME, - .of_match_table = sc16is7xx_dt_ids, - }, - .probe = sc16is7xx_spi_probe, - .remove = sc16is7xx_spi_remove, - .id_table = sc16is7xx_spi_id_table, -}; -#endif - -#ifdef CONFIG_SERIAL_SC16IS7XX_I2C -static int sc16is7xx_i2c_probe(struct i2c_client *i2c) -{ - const struct sc16is7xx_devtype *devtype; - struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; - unsigned int i; - - devtype = i2c_get_match_data(i2c); - if (!devtype) - return dev_err_probe(&i2c->dev, -ENODEV, "Failed to match device\n"); - - for (i = 0; i < devtype->nr_uart; i++) { - regcfg.name = sc16is7xx_regmap_name(i); - regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i); - regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); - regmaps[i] = devm_regmap_init_i2c(i2c, ®cfg); - } - - return sc16is7xx_probe(&i2c->dev, devtype, regmaps, i2c->irq); -} - -static void sc16is7xx_i2c_remove(struct i2c_client *client) -{ - sc16is7xx_remove(&client->dev); -} - -static const struct i2c_device_id sc16is7xx_i2c_id_table[] = { - { "sc16is74x", (kernel_ulong_t)&sc16is74x_devtype, }, - { "sc16is740", (kernel_ulong_t)&sc16is74x_devtype, }, - { "sc16is741", (kernel_ulong_t)&sc16is74x_devtype, }, - { "sc16is750", (kernel_ulong_t)&sc16is750_devtype, }, - { "sc16is752", (kernel_ulong_t)&sc16is752_devtype, }, - { "sc16is760", (kernel_ulong_t)&sc16is760_devtype, }, - { "sc16is762", (kernel_ulong_t)&sc16is762_devtype, }, - { } -}; -MODULE_DEVICE_TABLE(i2c, sc16is7xx_i2c_id_table); - -static struct i2c_driver sc16is7xx_i2c_uart_driver = { - .driver = { - .name = SC16IS7XX_NAME, - .of_match_table = sc16is7xx_dt_ids, - }, - .probe = sc16is7xx_i2c_probe, - .remove = sc16is7xx_i2c_remove, - .id_table = sc16is7xx_i2c_id_table, -}; - -#endif +EXPORT_SYMBOL_GPL(sc16is7xx_regmap_port_mask); static int __init sc16is7xx_init(void) { - int ret; - - ret = uart_register_driver(&sc16is7xx_uart); - if (ret) { - pr_err("Registering UART driver failed\n"); - return ret; - } - -#ifdef CONFIG_SERIAL_SC16IS7XX_I2C - ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver); - if (ret < 0) { - pr_err("failed to init sc16is7xx i2c --> %d\n", ret); - goto err_i2c; - } -#endif - -#ifdef CONFIG_SERIAL_SC16IS7XX_SPI - ret = spi_register_driver(&sc16is7xx_spi_uart_driver); - if (ret < 0) { - pr_err("failed to init sc16is7xx spi --> %d\n", ret); - goto err_spi; - } -#endif - return ret; - -#ifdef CONFIG_SERIAL_SC16IS7XX_SPI -err_spi: -#endif -#ifdef CONFIG_SERIAL_SC16IS7XX_I2C - i2c_del_driver(&sc16is7xx_i2c_uart_driver); -err_i2c: -#endif - uart_unregister_driver(&sc16is7xx_uart); - return ret; + return uart_register_driver(&sc16is7xx_uart); } module_init(sc16is7xx_init); static void __exit sc16is7xx_exit(void) { -#ifdef CONFIG_SERIAL_SC16IS7XX_I2C - i2c_del_driver(&sc16is7xx_i2c_uart_driver); -#endif - -#ifdef CONFIG_SERIAL_SC16IS7XX_SPI - spi_unregister_driver(&sc16is7xx_spi_uart_driver); -#endif uart_unregister_driver(&sc16is7xx_uart); } module_exit(sc16is7xx_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Jon Ringle "); -MODULE_DESCRIPTION("SC16IS7XX serial driver"); +MODULE_DESCRIPTION("SC16IS7xx tty serial core driver"); diff --git a/drivers/tty/serial/sc16is7xx.h b/drivers/tty/serial/sc16is7xx.h new file mode 100644 index 000000000000..410f34b1005c --- /dev/null +++ b/drivers/tty/serial/sc16is7xx.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* SC16IS7xx SPI/I2C tty serial driver */ + +#ifndef _SC16IS7XX_H_ +#define _SC16IS7XX_H_ + +#include +#include +#include +#include +#include + +#define SC16IS7XX_NAME "sc16is7xx" +#define SC16IS7XX_MAX_PORTS 2 /* Maximum number of UART ports per IC. */ + +struct sc16is7xx_devtype { + char name[10]; + int nr_gpio; + int nr_uart; +}; + +extern struct regmap_config sc16is7xx_regcfg; + +extern const struct of_device_id __maybe_unused sc16is7xx_dt_ids[]; + +extern const struct sc16is7xx_devtype sc16is74x_devtype; +extern const struct sc16is7xx_devtype sc16is750_devtype; +extern const struct sc16is7xx_devtype sc16is752_devtype; +extern const struct sc16is7xx_devtype sc16is760_devtype; +extern const struct sc16is7xx_devtype sc16is762_devtype; + +const char *sc16is7xx_regmap_name(u8 port_id); + +unsigned int sc16is7xx_regmap_port_mask(unsigned int port_id); + +int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, + struct regmap *regmaps[], int irq); + +void sc16is7xx_remove(struct device *dev); + +#endif /* _SC16IS7XX_H_ */ diff --git a/drivers/tty/serial/sc16is7xx_i2c.c b/drivers/tty/serial/sc16is7xx_i2c.c new file mode 100644 index 000000000000..70f0c329cc13 --- /dev/null +++ b/drivers/tty/serial/sc16is7xx_i2c.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* SC16IS7xx I2C interface driver */ + +#include +#include +#include +#include + +#include "sc16is7xx.h" + +static int sc16is7xx_i2c_probe(struct i2c_client *i2c) +{ + const struct sc16is7xx_devtype *devtype; + struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; + unsigned int i; + + devtype = i2c_get_match_data(i2c); + if (!devtype) + return dev_err_probe(&i2c->dev, -ENODEV, "Failed to match device\n"); + + for (i = 0; i < devtype->nr_uart; i++) { + sc16is7xx_regcfg.name = sc16is7xx_regmap_name(i); + sc16is7xx_regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i); + sc16is7xx_regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); + regmaps[i] = devm_regmap_init_i2c(i2c, &sc16is7xx_regcfg); + } + + return sc16is7xx_probe(&i2c->dev, devtype, regmaps, i2c->irq); +} + +static void sc16is7xx_i2c_remove(struct i2c_client *client) +{ + sc16is7xx_remove(&client->dev); +} + +static const struct i2c_device_id sc16is7xx_i2c_id_table[] = { + { "sc16is74x", (kernel_ulong_t)&sc16is74x_devtype, }, + { "sc16is740", (kernel_ulong_t)&sc16is74x_devtype, }, + { "sc16is741", (kernel_ulong_t)&sc16is74x_devtype, }, + { "sc16is750", (kernel_ulong_t)&sc16is750_devtype, }, + { "sc16is752", (kernel_ulong_t)&sc16is752_devtype, }, + { "sc16is760", (kernel_ulong_t)&sc16is760_devtype, }, + { "sc16is762", (kernel_ulong_t)&sc16is762_devtype, }, + { } +}; +MODULE_DEVICE_TABLE(i2c, sc16is7xx_i2c_id_table); + +static struct i2c_driver sc16is7xx_i2c_driver = { + .driver = { + .name = SC16IS7XX_NAME, + .of_match_table = sc16is7xx_dt_ids, + }, + .probe = sc16is7xx_i2c_probe, + .remove = sc16is7xx_i2c_remove, + .id_table = sc16is7xx_i2c_id_table, +}; + +static int __init sc16is7xx_i2c_init(void) +{ + return i2c_add_driver(&sc16is7xx_i2c_driver); +} +module_init(sc16is7xx_i2c_init); + +static void __exit sc16is7xx_i2c_exit(void) +{ + i2c_del_driver(&sc16is7xx_i2c_driver); +} +module_exit(sc16is7xx_i2c_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("SC16IS7xx I2C interface driver"); diff --git a/drivers/tty/serial/sc16is7xx_spi.c b/drivers/tty/serial/sc16is7xx_spi.c new file mode 100644 index 000000000000..3942fc1b7455 --- /dev/null +++ b/drivers/tty/serial/sc16is7xx_spi.c @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* SC16IS7xx SPI interface driver */ + +#include +#include +#include +#include +#include + +#include "sc16is7xx.h" + +/* SPI definitions */ +#define SC16IS7XX_SPI_READ_BIT BIT(7) + +static int sc16is7xx_spi_probe(struct spi_device *spi) +{ + const struct sc16is7xx_devtype *devtype; + struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; + unsigned int i; + int ret; + + /* Setup SPI bus */ + spi->bits_per_word = 8; + /* 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); + if (ret) + return ret; + + devtype = spi_get_device_match_data(spi); + if (!devtype) + return dev_err_probe(&spi->dev, -ENODEV, "Failed to match device\n"); + + for (i = 0; i < devtype->nr_uart; i++) { + sc16is7xx_regcfg.name = sc16is7xx_regmap_name(i); + /* + * If read_flag_mask is 0, the regmap code sets it to a default + * of 0x80. Since we specify our own mask, we must add the READ + * bit ourselves: + */ + sc16is7xx_regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i) | + SC16IS7XX_SPI_READ_BIT; + sc16is7xx_regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); + regmaps[i] = devm_regmap_init_spi(spi, &sc16is7xx_regcfg); + } + + return sc16is7xx_probe(&spi->dev, devtype, regmaps, spi->irq); +} + +static void sc16is7xx_spi_remove(struct spi_device *spi) +{ + sc16is7xx_remove(&spi->dev); +} + +static const struct spi_device_id sc16is7xx_spi_id_table[] = { + { "sc16is74x", (kernel_ulong_t)&sc16is74x_devtype, }, + { "sc16is740", (kernel_ulong_t)&sc16is74x_devtype, }, + { "sc16is741", (kernel_ulong_t)&sc16is74x_devtype, }, + { "sc16is750", (kernel_ulong_t)&sc16is750_devtype, }, + { "sc16is752", (kernel_ulong_t)&sc16is752_devtype, }, + { "sc16is760", (kernel_ulong_t)&sc16is760_devtype, }, + { "sc16is762", (kernel_ulong_t)&sc16is762_devtype, }, + { } +}; +MODULE_DEVICE_TABLE(spi, sc16is7xx_spi_id_table); + +static struct spi_driver sc16is7xx_spi_driver = { + .driver = { + .name = SC16IS7XX_NAME, + .of_match_table = sc16is7xx_dt_ids, + }, + .probe = sc16is7xx_spi_probe, + .remove = sc16is7xx_spi_remove, + .id_table = sc16is7xx_spi_id_table, +}; + +static int __init sc16is7xx_spi_init(void) +{ + return spi_register_driver(&sc16is7xx_spi_driver); +} +module_init(sc16is7xx_spi_init); + +static void __exit sc16is7xx_spi_exit(void) +{ + spi_unregister_driver(&sc16is7xx_spi_driver); +} +module_exit(sc16is7xx_spi_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("SC16IS7xx SPI interface driver"); From patchwork Tue Feb 6 21:42:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 197652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1840296dyb; Tue, 6 Feb 2024 13:42:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHaTTPQLzwFrEENF8rFGOTRQiIv1RLfRdCIdyh42sJzQZiKb3vUuNGmoMmKzivcUpYP56JlvNuh8BHTOtPU4q2bVMF4w== X-Google-Smtp-Source: AGHT+IHCXgbOFpLl3+EPVoDiIVl/yOteQybElWyIBtn+fFNa2bj2Mkp5etVEuU2LTN0H+SfefYtB X-Received: by 2002:ac2:4c45:0:b0:511:4f74:43f6 with SMTP id o5-20020ac24c45000000b005114f7443f6mr2931464lfk.65.1707255766791; Tue, 06 Feb 2024 13:42:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707255766; cv=pass; d=google.com; s=arc-20160816; b=IFC35JepD1vVdX0cn9w5UXRcnoulYd903NWi4OztkeV0IsLCtlIg8z7qgWmh1cQs7r 2NN/PJHZ6r1Zi0CSpI8qrBTsy+/to4ogMMNN8XhD3+SvtFfjFz9pQ7dGycNzaN77VaUe 99oGvEFkcy5U0C8iEB2bH7Wu7W9y+DTEpG6w3kROKCGPn6OIb+78bZUBJJINlFqHkDOh nIoSPtHElMeRmsb/XCw/nSQyD/VdHOPrWnIdrwtTBcxT1b2/bAUsGNdIZEpTAh6k290+ E7rYIlm9pTDZFjzslQVtJ7CVFNmPojhTh5s+/82SLDf23OCpzkY2xBWzigFPeyyQRPeB vptQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:cc:to:from:dkim-signature; bh=fRQcONYVjPAuJ2IXtLvfbv954R7Ufy3J7dtvn6r3BZs=; fh=uJboq8H2v+kCQX74GEKbSSfqaYjoHnNFaxC+3Z4LK+M=; b=MbJZOTslFLFR6QZfwiLAbgc+29v4yTXC5WBoYZQPVCXINbxZYl4Y/SfL/41cpmpY8N 7gzaIPfENTACbPUbNyEAENbnncKZH30fGtUz3/y9mmb16LfJq/YnfThgtAuujYORXeAi /r1syymN7DWloxijii93ENpuSMbfoMq92GPlZwnxM6gd7m1PD9XRNO8bKwlmjwzxkn/a q2QpAKppiviiLoFN8trjIeCntSmlwYh71+ZMnzXW5nPrVvH74A+IuIyHQCboG5kjtZJQ WZfcjUXgE0OevlG9SSGWq9vspXnx3Gm9CAq3KQphGyUHfuy96NP1ssw4SkWGjqEF9RSz qn5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b="fwsW/SiH"; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55641-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55641-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXnoujo2nRm+sO7SORciKIqKpJ40N+pn7xJwu1zNDJxQGhA0Xc29+COqoX60kgX9DXWOOta4vBNMemBaOJPU4F6DYYYUA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lf7-20020a170906ae4700b00a3841ab6521si698349ejb.553.2024.02.06.13.42.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 13:42:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55641-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b="fwsW/SiH"; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55641-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55641-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 641561F22578 for ; Tue, 6 Feb 2024 21:42:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5A271C283; Tue, 6 Feb 2024 21:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="fwsW/SiH" Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (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 E511F1BF27; Tue, 6 Feb 2024 21:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707255742; cv=none; b=BEsRG1aM7jT2oMPq891dESPJQIKEwKwqhZVapBqtg4KGyb8m1Zt9MOaqHErFmgZBtmBm7HJlm0iZovo9B+ASdNu4hXOdsyyuql9Hg0DqGMkBFK7MsA7QUsHJIyRu22GTwgxZVRhoQ84tgCTN1PgCn/rXKhC3CTnd8b4g1QBDWkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707255742; c=relaxed/simple; bh=q9fwZBAXTcQtKBv6I5CxylABhvION6OPfRGnEWczYgM=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=hAFDS2Zz1yS/pF95W+XQltKCpr6ym7ca1/zqap9Zs91zURURqRCE1l0dbi2VHAP0zd8ox9b7VvQLmTEYLF/T9cWkywxi6UojRcjHkOV/4du3EI9uPC6FbMB6LBsgl4DkOZml/Bw8U9UcIKS7xATthNbUJtQlfL2aTn0QbCrC9eM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=fwsW/SiH; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=fRQcONYVjPAuJ2IXtLvfbv954R7Ufy3J7dtvn6r3BZs=; b=fwsW/SiHMdayWibIXMwqX98qqb /ZOySCo2eS5wf4JshM66p90SZT4ETeTQZEGXn7ueG6RaWUL/+jGMyeHsEeKcCslATc3N4nZ3KwVAr cWS25rpAKvnh7QB16RPHhvx3ZgUiTkNQrsIKEANHKFPS59DWgmpLQrPZ+qvKMc5EMNOQ=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:41434 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rXTCs-0006XX-8A; Tue, 06 Feb 2024 16:42:19 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve Date: Tue, 6 Feb 2024 16:42:07 -0500 Message-Id: <20240206214208.2141067-4-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240206214208.2141067-1-hugo@hugovil.com> References: <20240206214208.2141067-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_SCC_BODY_TEXT_LINE No description available. Subject: [PATCH 3/4] serial: sc16is7xx: split into core and I2C/SPI parts (sc16is7xx_lines) X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790187422758536651 X-GMAIL-MSGID: 1790187422758536651 From: Hugo Villeneuve Before, sc16is7xx_lines was checked for a free (zero) bit first, and then later it was set only if UART port registration succeeded. Now that sc16is7xx_lines is shared for the I2C and SPI drivers, make sure it is reserved and modified atomically, and use a new variable to hold the status of UART port regisration. Remove need to check for previous port registration in sc16is7xx_remove(), because if sc16is7xx_probe() succeeded, we are guaranteed to have successfully registered both ports. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 5b53c88b7133..5073ebfc45bf 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1468,6 +1468,7 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, u32 uartclk = 0; int i, ret; struct sc16is7xx_port *s; + bool port_registered[SC16IS7XX_MAX_PORTS]; for (i = 0; i < devtype->nr_uart; i++) if (IS_ERR(regmaps[i])) @@ -1533,8 +1534,10 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, SC16IS7XX_IOCONTROL_SRESET_BIT); for (i = 0; i < devtype->nr_uart; ++i) { - s->p[i].port.line = find_first_zero_bit(sc16is7xx_lines, - SC16IS7XX_MAX_DEVS); + port_registered[i] = false; + + s->p[i].port.line = find_and_set_bit(sc16is7xx_lines, + SC16IS7XX_MAX_DEVS); if (s->p[i].port.line >= SC16IS7XX_MAX_DEVS) { ret = -ERANGE; goto out_ports; @@ -1584,7 +1587,7 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, if (ret) goto out_ports; - set_bit(s->p[i].port.line, sc16is7xx_lines); + port_registered[i] = true; /* Enable EFR */ sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, @@ -1642,9 +1645,11 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, #endif out_ports: - for (i = 0; i < devtype->nr_uart; i++) - if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines)) + for (i = 0; i < devtype->nr_uart; i++) { + clear_bit(s->p[i].port.line, sc16is7xx_lines); + if (port_registered[i]) uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); + } kthread_stop(s->kworker_task); @@ -1667,8 +1672,8 @@ void sc16is7xx_remove(struct device *dev) for (i = 0; i < s->devtype->nr_uart; i++) { kthread_cancel_delayed_work_sync(&s->p[i].ms_work); - if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines)) - uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); + clear_bit(s->p[i].port.line, sc16is7xx_lines); + uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); sc16is7xx_power(&s->p[i].port, 0); } From patchwork Tue Feb 6 21:42:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 197653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1840373dyb; Tue, 6 Feb 2024 13:42:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsboWu7dlusVrGMHO0+0u8nFbksUNYoBB6UvATyWosYhsDQjHfkyWiE4AUzsq3es0TBjBO X-Received: by 2002:a17:903:22c6:b0:1d9:bff2:67dd with SMTP id y6-20020a17090322c600b001d9bff267ddmr3859293plg.0.1707255779795; Tue, 06 Feb 2024 13:42:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707255779; cv=pass; d=google.com; s=arc-20160816; b=MYNA2jltba9eF8rDmMy5ERMJkNNry22IpAstKIrDRw651GwKReJenRaiyqFo4hpfys iWRQeyt3NzP8AxV+i/0yIfVq5DPvlWJftRcI9JHgzwc5t9OOtBCAV20TW3k8OmOCReAx e4nnB9Hy4Fr4uizdvcp50JLlEOtZI/UV68W5M36+BlqD9gF07ZK/hNohpIcndEUWhogD oX2Ty5ntjhf7axILtbg/ZaGP6cKajLK3WH8uq7Q610PyEjX5XJ0dxz0pXGcbtz6z0jvX kQ9N36ck5s3gyJP0VAPpVug8BStTUXlHkK84an9yRkR0gRorsbFnNzE4PcvArAcNANa6 olQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:cc:to:from:dkim-signature; bh=S8GKrBx7k32D5TQmOeQBgeGGSVzTirjzknxQ6smCCHw=; fh=W1hbR8m4pF11hwYviPN5Y0B5OOZj/tQEYwuo4QUhRfs=; b=pv7WoHIBi37psfWMLVybj6ZQDOqHQ18QH3kCCfg1OoGWlNiRmGXN0eHdMyRWvNp+rZ DDjNrSJvU6JWPLHUrw4Zxd3oHZD+rh3IvOjSlZx15TxOYazEOFiOGwC/aYDUr5pCNpp5 wRDLLJ83yjxecftka7Bk62L3jlp41/WINvAnNsaaos1gSfm9bavuKvh4iXCeYzPSgBqo hMoIy1HmM/nhxyTkNoMIxl0S/LZN01NBBv904WyS7MAdUXaxWPft/lb6Qsh1S6EvMsnx /azF59XyfphGVTGGZ4VVnT8LfnEn9dzkbdmTwqpDvZsAl1a0m5SfSSs2/Bg+zZAJkk82 Ynvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=VdUKMERz; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55642-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55642-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWiWXQYzT6IhqiiacGtVEILH5NndGkca7Vk0mx1E4vFBUSksHHK3vwYaUF6i32x6JhOsUB7b9kKx4MMOoRNN/3kS/X0Qw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x6-20020a170902ec8600b001d8d6c1fcbcsi2291183plg.64.2024.02.06.13.42.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 13:42:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55642-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=VdUKMERz; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-55642-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55642-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E08802893A4 for ; Tue, 6 Feb 2024 21:42:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FD6E1C69D; Tue, 6 Feb 2024 21:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="VdUKMERz" Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (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 9F9B91B963; Tue, 6 Feb 2024 21:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707255744; cv=none; b=GhmQAYO5fy0Sgb1WulJX7GTqJsA/U6E7lhn36m39/YcFRuwjxTdkhDVSCepo+hUVpxJUJTSuCsTAcTYJ+6LNNDC4hG2Jw9gxbqG8i82M52SPZyHPr39Nl9oE1gRmf5PyejvrTiMlK76pQ+BVoPwMDTLp+WddEue5hqpuhcZN3qM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707255744; c=relaxed/simple; bh=sV3k/j9J5B++drgSu+cGIrn3j32CbFIY0tqZsiotMlU=; h=From:To:Cc:Date:Message-Id:In-Reply-To:References:MIME-Version: Subject; b=NM3PY+QLNBgl5rIDDWUMuo0VTCJ3oZNVOnmmyliP7XutipW79VVFz/Ta6RvoxvXVhNxIHgQTX74rVW1i40Qn5KRC8/lsCRaxFvluN0S8LwQepOfUnVP69FAHailvsaa1/rpvBBedYzpYdpCh2IavaU5lLYM+pBlg48SD/BsXyVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=VdUKMERz; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=S8GKrBx7k32D5TQmOeQBgeGGSVzTirjzknxQ6smCCHw=; b=VdUKMERzJuOYo8CYPfpAAw1yyg HMOFPakOOiSF9GphkQb9HQPguSMGozhvzln1MryMY/MwYaff6+ZOdijyV2FAXYXfuUfXLIH6H6p8y VwJWFGZC7MAn4U+L0pPf7AtIDw/SyUCsxHZZZ8i1g7GxxwbkYDUH5QpVC1qdAMUBlA3A=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:41434 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rXTCu-0006XX-3M; Tue, 06 Feb 2024 16:42:21 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve Date: Tue, 6 Feb 2024 16:42:08 -0500 Message-Id: <20240206214208.2141067-5-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240206214208.2141067-1-hugo@hugovil.com> References: <20240206214208.2141067-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_SCC_BODY_TEXT_LINE No description available. Subject: [PATCH 4/4] serial: sc16is7xx: split into core and I2C/SPI parts (sc16is7xx_regcfg) X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790187436377231360 X-GMAIL-MSGID: 1790187436377231360 From: Hugo Villeneuve Since each I2C/SPI probe function can modify sc16is7xx_regcfg at the same time, change structure to be constant and do the required modifications on a local copy. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 2 +- drivers/tty/serial/sc16is7xx.h | 2 +- drivers/tty/serial/sc16is7xx_i2c.c | 11 +++++++---- drivers/tty/serial/sc16is7xx_spi.c | 11 +++++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 5073ebfc45bf..706c8b18250b 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1696,7 +1696,7 @@ const struct of_device_id __maybe_unused sc16is7xx_dt_ids[] = { EXPORT_SYMBOL_GPL(sc16is7xx_dt_ids); MODULE_DEVICE_TABLE(of, sc16is7xx_dt_ids); -struct regmap_config sc16is7xx_regcfg = { +const struct regmap_config sc16is7xx_regcfg = { .reg_bits = 5, .pad_bits = 3, .val_bits = 8, diff --git a/drivers/tty/serial/sc16is7xx.h b/drivers/tty/serial/sc16is7xx.h index 410f34b1005c..8d03357e35c7 100644 --- a/drivers/tty/serial/sc16is7xx.h +++ b/drivers/tty/serial/sc16is7xx.h @@ -19,7 +19,7 @@ struct sc16is7xx_devtype { int nr_uart; }; -extern struct regmap_config sc16is7xx_regcfg; +extern const struct regmap_config sc16is7xx_regcfg; extern const struct of_device_id __maybe_unused sc16is7xx_dt_ids[]; diff --git a/drivers/tty/serial/sc16is7xx_i2c.c b/drivers/tty/serial/sc16is7xx_i2c.c index 70f0c329cc13..5667c56cf2aa 100644 --- a/drivers/tty/serial/sc16is7xx_i2c.c +++ b/drivers/tty/serial/sc16is7xx_i2c.c @@ -12,17 +12,20 @@ static int sc16is7xx_i2c_probe(struct i2c_client *i2c) { const struct sc16is7xx_devtype *devtype; struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; + struct regmap_config regcfg; unsigned int i; devtype = i2c_get_match_data(i2c); if (!devtype) return dev_err_probe(&i2c->dev, -ENODEV, "Failed to match device\n"); + memcpy(®cfg, &sc16is7xx_regcfg, sizeof(struct regmap_config)); + for (i = 0; i < devtype->nr_uart; i++) { - sc16is7xx_regcfg.name = sc16is7xx_regmap_name(i); - sc16is7xx_regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i); - sc16is7xx_regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); - regmaps[i] = devm_regmap_init_i2c(i2c, &sc16is7xx_regcfg); + regcfg.name = sc16is7xx_regmap_name(i); + regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i); + regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); + regmaps[i] = devm_regmap_init_i2c(i2c, ®cfg); } return sc16is7xx_probe(&i2c->dev, devtype, regmaps, i2c->irq); diff --git a/drivers/tty/serial/sc16is7xx_spi.c b/drivers/tty/serial/sc16is7xx_spi.c index 3942fc1b7455..55c1d4ad83f5 100644 --- a/drivers/tty/serial/sc16is7xx_spi.c +++ b/drivers/tty/serial/sc16is7xx_spi.c @@ -16,6 +16,7 @@ static int sc16is7xx_spi_probe(struct spi_device *spi) { const struct sc16is7xx_devtype *devtype; struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; + struct regmap_config regcfg; unsigned int i; int ret; @@ -35,17 +36,19 @@ static int sc16is7xx_spi_probe(struct spi_device *spi) if (!devtype) return dev_err_probe(&spi->dev, -ENODEV, "Failed to match device\n"); + memcpy(®cfg, &sc16is7xx_regcfg, sizeof(struct regmap_config)); + for (i = 0; i < devtype->nr_uart; i++) { - sc16is7xx_regcfg.name = sc16is7xx_regmap_name(i); + regcfg.name = sc16is7xx_regmap_name(i); /* * If read_flag_mask is 0, the regmap code sets it to a default * of 0x80. Since we specify our own mask, we must add the READ * bit ourselves: */ - sc16is7xx_regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i) | + regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i) | SC16IS7XX_SPI_READ_BIT; - sc16is7xx_regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); - regmaps[i] = devm_regmap_init_spi(spi, &sc16is7xx_regcfg); + regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); + regmaps[i] = devm_regmap_init_spi(spi, ®cfg); } return sc16is7xx_probe(&spi->dev, devtype, regmaps, spi->irq);