Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1811562pxb; Mon, 13 Sep 2021 06:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx/NH5uGTWEW0qnLYKQPy8qRg8inQYVFDskHlXvH+wc123Q32BNfgOLBPJkQ6EuxrNO1mu X-Received: by 2002:a17:906:a18b:: with SMTP id s11mr12739097ejy.8.1631538533528; Mon, 13 Sep 2021 06:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631538533; cv=none; d=google.com; s=arc-20160816; b=T9Izm/cMYMbPi8BfXdJ9IPRu9J9CacDS2goHsbCgWOVGQJXGP741xSWeQ25W4fx070 p8mK5xuhFTj3gsGhNrHSRPs7R9V/v0/FHREZkNbZkX/C8P2U2NziMRWOxUNv0JEVyqJD 06h6GGNipDEsQgiZX/sgCyG/AihiFlXKKDPF8hE8+R3HIBT5qOS+Y0yXnMi96hojcO1r 7sly9+eKYqz/UakyCFFHyiuTgj7CZYheJmSger6XznwWLFGFnD3K9f3Qip2ESXrqZQHe iZyWsk5z1x3hZKrmRQQ9PDo7RGcGyo/R7ReL+86el4EqBLq136vsdRLt212KmpP+Gwk3 cDZQ== 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=SnhgUKVfFb/6e87FBg0KFMGT8EGSflyNY6+o3wDQLRo=; b=jrNoOPfBazU01ToEvASz5P2qM1kZrCZLPC7KXqXmVQHFyWnetemVDX2DiZsGJ7aHLO Ji2rFQbeXuRxD5Fhh1AOIh9kIhmgRAB56ZVlJycHOZL7hvCtQFvFe/ts19zPgUYnI+or lH7TPlKYkH58jWmu2O6pygjnKxwIiqLEwyB2/+6/KOCLWVaO8IT9EYNIy+p9sczQRKxS hPNdrlOcnegCqDpx16kKOzs2axCC6ygsUIKxGiwYvtkjAp5cjxa27h09p8ImDCYqvUoN DwrZriXq5540/r8k6zLSBIaAlOfIljrfmPHuil/XqxwhZeSde7dc1ET1/RWvZ7V6kKl2 uHFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=VY8IIUMD; 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 n2si2011526edi.385.2021.09.13.06.08.26; Mon, 13 Sep 2021 06:08:53 -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=VY8IIUMD; 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 S236867AbhIMNC1 (ORCPT + 99 others); Mon, 13 Sep 2021 09:02:27 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:25653 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236776AbhIMNC0 (ORCPT ); Mon, 13 Sep 2021 09:02:26 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18D5sXGg002737; Mon, 13 Sep 2021 08:01:06 -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=SnhgUKVfFb/6e87FBg0KFMGT8EGSflyNY6+o3wDQLRo=; b=VY8IIUMDa+H9XiMmL06xo9m3tFUjtMfyaCsZ/yyhCYOvKcloZAo8WJVz5xMtcr629z3e xITy5UDkCxFRUZevykoDcA7XSDh13V/Cuf0yJOWDWuMyEueZDpBDNfHLFRopUHIiNZve 8sjWt2gs+AAlGZtjiUJ8Nq7XI+NDjMgJbXA/AhNo4pWNKdhsuujdY1aGwG3t0rKIMUyd zHOAalE+nt6mLwMkUEWp8VVfMesfRwnj3DDqRjT9VK8+2i6I5HlTzxYObSSBNPgi569A CxYO1IB1tZAFkOFUduXBIOsgSSLoRVJ6VIOK1z+ROR+LsrSoJKasQNgaRbgLcVAwGIFz ow== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3b1hb38we8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 13 Sep 2021 08:01:05 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 13 Sep 2021 14:01:03 +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; Mon, 13 Sep 2021 14:01:03 +0100 Received: from aryzen.ad.cirrus.com (unknown [198.61.64.203]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 95D05B16; Mon, 13 Sep 2021 13:01:02 +0000 (UTC) From: Lucas Tanure To: Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" CC: , , Lucas Tanure Subject: [PATCH v2] regmap: spi: Set regmap max raw r/w from max_transfer_size Date: Mon, 13 Sep 2021 14:01:01 +0100 Message-ID: <20210913130101.1577964-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: VZbm4NYyttwWhC75DCgOGCVvKO-wIOJx X-Proofpoint-ORIG-GUID: VZbm4NYyttwWhC75DCgOGCVvKO-wIOJx 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 --- Changes v2: Sent as single patch 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 c1894e93c3788..0e6552e57ecf9 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