Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp444691pxb; Wed, 15 Sep 2021 05:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8h6xWnNWkvMrYMCQrAVTOqFzg3AeY9Wg+BA2F+2L/flr4mEnYjoT/+MC1w6gcQCx/D+sP X-Received: by 2002:ac2:5ec2:: with SMTP id d2mr17097850lfq.250.1631710179267; Wed, 15 Sep 2021 05:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631710179; cv=none; d=google.com; s=arc-20160816; b=BMBm+/5Z1WvWqh7+5tp+mL7exaWohzTAKjIK0eh4za47aljiLSALOPeE4CwHV1Pkff mR2zrb3prxcxro9Mbo+gVXB5/WOjyXspZFWdqoIknesi93IsOqxpRpHEHXYhmlTTwNuw q6A5sxe3xrwwDgw++ena26T/L3mEj8ohghC4Es65/aUZIN6qZ05im1w//lLmefReEI0L lyDnNsR3MiEX+RltA3dyHzawbLl/FbtzC3iZiHdg4CPAItLgeMZX8JXBNL4q5ZKDS8hu yCymxOwztN5zj4wVnzVApCvAxCM9Ff2WEan23dhDS7Xai3KyOThC4s0FczpgTyeA37Zo Snnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=unRJE/2nGA8KSMmenuNrP/TykT9yg6kqUcCh+92+IYQ=; b=qs0Qfp+WeS+Q4nNimnhfOhMjW1+JXMN3UQw4xPJf48x+zlQo+XX6TxN14qJ2unfmxT pNAoOs0PJ4f6L+VokUQshRINzgqdnNC8NfL/2HqYQmy84adNBVDm7U/U7/RKLmvvVZDy 51HchUJmSO6v3LjJKCzdUNG02PWYBmKIR4yCrKszWlEEG6hXkhU//iRT6j8gpXObjh9/ gCPzZ1UNrkhQ78TGd1Eu4yz7/kRa26LJYiefGgjmiq2kYyO2dqUZZJg7qNEi2nJPC/8v QTSXyQLSGoCLO299nRBY/svJ/1Mrhy3lKU1/jJEZ9LsJDQkSow7RqStOeCtrm+hAYmQn eM+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=C57erIdo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si21003961lfg.275.2021.09.15.05.49.12; Wed, 15 Sep 2021 05:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=C57erIdo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237875AbhIOMp4 (ORCPT + 99 others); Wed, 15 Sep 2021 08:45:56 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:29474 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237823AbhIOMpv (ORCPT ); Wed, 15 Sep 2021 08:45:51 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18F6hhbD001194; Wed, 15 Sep 2021 07:44:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=unRJE/2nGA8KSMmenuNrP/TykT9yg6kqUcCh+92+IYQ=; b=C57erIdoS72MwAU5x8uc36dsafJnnodzpKe1XsVqR1FVsu117koDcllNJvRuQgmMaImP WgNzDH7Oo7+cWi0QAuIxadymk/XdAcvJKK1LGjz+7Hk9n1IyKPb0J6zW7nJ3ujoX1wl0 cze3KJ/u1fAex9N0cihYZef/wSchUlz1nC9nTOyj5gtkwbjqBlPmQYtr+nNZWGhBndTf f8xIkWgYxNQTUBWcrUZ4CJQAjdEd4c6kSIVYFQbzX/cNboknDwKZiRs2EWgy8i8aINcB hpDycYZW3vbOt8i+gIpM+q9Nm3BSmbFLuITjUw+T4B/AAShKzDi+/9WhT+rk0I+BoLoZ LQ== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 3b3af8rc9p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 15 Sep 2021 07:44:28 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 15 Sep 2021 13:44:26 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Wed, 15 Sep 2021 13:44:26 +0100 Received: from aryzen.ad.cirrus.com (unknown [198.61.64.203]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 0784BB2F; Wed, 15 Sep 2021 12:44:26 +0000 (UTC) From: Lucas Tanure To: Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" CC: , , Lucas Tanure , Charles Keepax Subject: [PATCH v4 1/2] regmap: spi: Set regmap max raw r/w from max_transfer_size Date: Wed, 15 Sep 2021 13:44:24 +0100 Message-ID: <20210915124425.34777-1-tanureal@opensource.cirrus.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: edplpCJo8GuEUzMWEpO7jk6G7_qhs3cX X-Proofpoint-ORIG-GUID: edplpCJo8GuEUzMWEpO7jk6G7_qhs3cX X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set regmap raw read/write from spi max_transfer_size so regmap_raw_read/write can split the access into chunks Signed-off-by: Lucas Tanure Reviewed-by: Charles Keepax --- Changes v2: New series Changes v3: None Changes v4: Reviewed-by Charles Keepax drivers/base/regmap/regmap-spi.c | 36 ++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/base/regmap/regmap-spi.c b/drivers/base/regmap/regmap-spi.c index c1894e93c378..0e6552e57ecf 100644 --- a/drivers/base/regmap/regmap-spi.c +++ b/drivers/base/regmap/regmap-spi.c @@ -109,13 +109,37 @@ static const struct regmap_bus regmap_spi = { .val_format_endian_default = REGMAP_ENDIAN_BIG, }; +static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi, + const struct regmap_config *config) +{ + struct spi_master *master = spi->master; + struct regmap_bus *bus = NULL; + size_t max_size = spi_max_transfer_size(spi); + + if (max_size != SIZE_MAX) { + bus = kmemdup(®map_spi, sizeof(*bus), GFP_KERNEL); + if (!bus) + return ERR_PTR(-ENOMEM); + bus->free_on_exit = true; + bus->max_raw_read = max_size; + bus->max_raw_write = max_size; + return bus; + } + + return ®map_spi; +} + struct regmap *__regmap_init_spi(struct spi_device *spi, const struct regmap_config *config, struct lock_class_key *lock_key, const char *lock_name) { - return __regmap_init(&spi->dev, ®map_spi, &spi->dev, config, - lock_key, lock_name); + const struct regmap_bus *bus = regmap_get_spi_bus(spi, config); + + if (IS_ERR(bus)) + return ERR_CAST(bus); + + return __regmap_init(&spi->dev, bus, &spi->dev, config, lock_key, lock_name); } EXPORT_SYMBOL_GPL(__regmap_init_spi); @@ -124,8 +148,12 @@ struct regmap *__devm_regmap_init_spi(struct spi_device *spi, struct lock_class_key *lock_key, const char *lock_name) { - return __devm_regmap_init(&spi->dev, ®map_spi, &spi->dev, config, - lock_key, lock_name); + const struct regmap_bus *bus = regmap_get_spi_bus(spi, config); + + if (IS_ERR(bus)) + return ERR_CAST(bus); + + return __devm_regmap_init(&spi->dev, bus, &spi->dev, config, lock_key, lock_name); } EXPORT_SYMBOL_GPL(__devm_regmap_init_spi); -- 2.33.0