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);