Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp418219pxb; Wed, 15 Sep 2021 05:14:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJyUWk3i0lOGdWd9368G+m8j2UBPuo4iwOoeG+1NmwD0fZzYhExYO2m4pTDxhldeEdrJTg X-Received: by 2002:a2e:b60f:: with SMTP id r15mr19999340ljn.330.1631708078047; Wed, 15 Sep 2021 05:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631708078; cv=none; d=google.com; s=arc-20160816; b=I+6NmONcyeH9TRMhlQOpN7VLaJQVa51zAaSlAxJx5GwBzC224zpTOTqkXpHp1HqXb9 mvhAwL96BpE4TZLLOIsW+auKuQnbZ6Wv6tBHqzsMTmSaXYJ0ibywgOmWSTBY8NA2D8Oc mxzQRVwPqsW8KrCcXRSDX2Xi0J6UxUXLbh+cP1piyV8HUORwtYXoFGUGPDOUOJtkQKj4 vNGkxjXzCcQEokiVR7D1KCPMyiLT8VeZRpAX3z9eDfGAYTNyQqRqay/TYGXv0UA5kl2a PtJww6bNK5MiWgtVAEvQpWRcY+19q6LYA0WuePp4uBUUI45amwAgFeRO8c4X6eQGY7/F +Jkw== 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=AJLgP73HU1MgxAMOefytUcAIFWSgMpjDsTMIioDQXHo=; b=mEkRhEBlzEw8EgHxHQ0RVFe3tD1iUnEygZQ9UPFDEVMxUceShtH88lQCClF8pc08nW MPQq95S3gEcbh+Icx1I0dH2ZfqvuCPc3pClHysiWfH+BB6y/LyY504R9xURk5qqFgJY5 +4dcThJN2zgRDWeX5Yc87cQ5+N9luaXRswk6luAuVsG/foYB6W9EsKWAHlweIx8H5vnk dpedM9JcZaj4R4714hnhJqIHm29RwLKXsw7lYJTaqr4SNZRCgJGIy+R7bHI/Lp3OcnGQ n3bisCesw42aXlkACZT9X1g9p5ShCjvGaA0Ex4q6wXDnIxBRkhBW4EcIx3bDFcQjl5hQ 2TdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=br8orGwk; 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 10si19197555ljt.410.2021.09.15.05.14.10; Wed, 15 Sep 2021 05:14:38 -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=br8orGwk; 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 S236617AbhIOMLQ (ORCPT + 99 others); Wed, 15 Sep 2021 08:11:16 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:27908 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236610AbhIOMLP (ORCPT ); Wed, 15 Sep 2021 08:11:15 -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 18F5eGFL026124; Wed, 15 Sep 2021 07:09:54 -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=AJLgP73HU1MgxAMOefytUcAIFWSgMpjDsTMIioDQXHo=; b=br8orGwk0avxRTVpIpjSXHgcQsRHvhv3sM6J5BSPKOksbquvcAY/jMiv6ZHWXMqubY+w /+D9X7JQ2e7yY4+f9nXcycSJ6Xq+Kcvz0peZdB6ctMT6nrPMy/P0HT7vY4xkvmw9swdi T4r2tFmCrhMutA8AarY7bLx8l0ZYCOFauCeK4Ra7oXmKWA1HJqxACxSG9cTM20/QDVLs Qm1bfxrPPZZawXAZpJOzvbveiW0yU1MR3O46H/Cr89LtOHkCEel23gjLXEiDwQo6zOYQ 5KyKfX50WwT0qrXNPtJhdg1rf6JdV6yQFXcspj/hQTBenuL8RzUgcPXngVtFQUfAMb/4 Ww== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3b3287grj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 15 Sep 2021 07:09:54 -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; Wed, 15 Sep 2021 13:09:52 +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:09:52 +0100 Received: from aryzen.ad.cirrus.com (unknown [198.61.64.203]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 6FABDB2F; Wed, 15 Sep 2021 12:09:52 +0000 (UTC) From: Lucas Tanure To: Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" CC: , , Lucas Tanure Subject: [PATCH v3 1/2] regmap: spi: Set regmap max raw r/w from max_transfer_size Date: Wed, 15 Sep 2021 13:09:50 +0100 Message-ID: <20210915120951.29907-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: QGDsf0XeRzGlAx53pV8PK715MJbpuD2Y X-Proofpoint-ORIG-GUID: QGDsf0XeRzGlAx53pV8PK715MJbpuD2Y 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: New series Changes v3: None 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