From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 50B1627713; Tue, 9 Jul 2024 11:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720524453; cv=none; b=MORmtHu7gPaGZRilguUsmaAD0Zipg6VWOI7SneN66Di/2FbRg+2DCxyjxxthEGrJIvYmTtH90anaEWSP1G2rZFgUGMsMZFJse2z+QbEs802YQ0Y55Vx9klkAx0BOjLGhtjMCduZh7LZ+Xdw/77fohBKgM7J6zFZ87e03mcdjk7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720524453; c=relaxed/simple; bh=8iVUYOd+7oeneKgFuIbu/QBxgGU78d3hbo1H8VITdbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uBs63mkM6miFhT+NH34VBm3PMBUWBH/rPbw+QzNQDgcgW//astLDvwbKA7zDdeAp2x9CdNg2fTOVY/4zyyHXwwDZM81xp4tngx3JcnDJsjdcAxyTevNijJzYezRCWuGtxHq03UpS0OJVxQRPeUzJqVg+RXy+VaBap7/IuEO+Xf4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=G8Jdv9k5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="G8Jdv9k5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD06AC3277B; Tue, 9 Jul 2024 11:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720524453; bh=8iVUYOd+7oeneKgFuIbu/QBxgGU78d3hbo1H8VITdbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G8Jdv9k5FZgpjDbRpSYUB6aZNb56Q9sscniNFcT51c3rEb4tUupnbPBr5TRVKabaY IDBlE34TtdRNsDNf+Tr320FboAjo5HlqEFwQCYA+LDA6R/QOUTVHgAueJYfXHfBJBW dYtBaTec5lj+iBGqYM/kJNPRAai4N/cCkPrD1wwI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jim Wylder , Mark Brown , Sasha Levin Subject: [PATCH 6.9 185/197] regmap-i2c: Subtract reg size from max_write Date: Tue, 9 Jul 2024 13:10:39 +0200 Message-ID: <20240709110716.099996580@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709110708.903245467@linuxfoundation.org> References: <20240709110708.903245467@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jim Wylder [ Upstream commit 611b7eb19d0a305d4de00280e4a71a1b15c507fc ] Currently, when an adapter defines a max_write_len quirk, the data will be chunked into data sizes equal to the max_write_len quirk value. But the payload will be increased by the size of the register address before transmission. The resulting value always ends up larger than the limit set by the quirk. Avoid this error by setting regmap's max_write to the quirk's max_write_len minus the number of bytes for the register and padding. This allows the chunking to work correctly for this limited case without impacting other use-cases. Signed-off-by: Jim Wylder Link: https://msgid.link/r/20240523211437.2839942-1-jwylder@google.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/base/regmap/regmap-i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap-i2c.c b/drivers/base/regmap/regmap-i2c.c index 3ec611dc0c09f..a905e955bbfc7 100644 --- a/drivers/base/regmap/regmap-i2c.c +++ b/drivers/base/regmap/regmap-i2c.c @@ -350,7 +350,8 @@ static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c, if (quirks->max_write_len && (bus->max_raw_write == 0 || bus->max_raw_write > quirks->max_write_len)) - max_write = quirks->max_write_len; + max_write = quirks->max_write_len - + (config->reg_bits + config->pad_bits) / BITS_PER_BYTE; if (max_read || max_write) { ret_bus = kmemdup(bus, sizeof(*bus), GFP_KERNEL); -- 2.43.0