Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp265349lqr; Wed, 5 Jun 2024 05:40:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHa9ypu5KXBeKUFktcn2bfvNfZu9qj1KFoa1iC1YPwIixsaexmHZOuGo+dJxyQ8+xQ5qwPXsf/7CHHRA6eUD8HAe24EB6UZ0PR4ruZEw== X-Google-Smtp-Source: AGHT+IEMPCbvOh61Yfr/A5+sF3jiwIE/yOwMR3VcAb0H5L3w9MFLBe7eEDpDikHnfTHSu91uk9wK X-Received: by 2002:a17:902:f689:b0:1f4:508c:af6 with SMTP id d9443c01a7336-1f6a5a5c8a5mr30679005ad.50.1717591204509; Wed, 05 Jun 2024 05:40:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591204; cv=pass; d=google.com; s=arc-20160816; b=fPobHNfZpoC25aF6zllgkSggCrt5DJeQ3R5DAQw/qg+j22s8bO0OsYrEeHwE6JSk9L oYIJXXIolkM9Vw+M+BwsiKswpLmyZSrEOOvswc3+mKdgY2B13E1DjEKytx7ivzercFtk oNuYnq3f2exyJNqAtyE0wUJ8TRIX4uFxI9ED9YwiiSdl1Qbvhcsoz0kK0UxsKzekDPG3 2HTv+/+BM0++mB7NjJIbh2XRCU1UbRXV0OQSW64+TxQ/fzh+3WOITTXaDvMuahWnoYAy RrNXcbv8HR0HGVX3/GZLMTei+lK56oZe0XY8C5Fu7d32P6DF6dixdJ7eTKX7sCfYASUS QJxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=onWDHspBmcnpswma1QjNp2VCogB9NlFuso36jCV2zj0=; fh=2Wvii+SHL0QXhhk/PaL6KJSZa7hYfSAVbSvLO6ae/Iw=; b=IcdD/bsf4Kkrhi8gTKT7AcPR6FdmG+m4jKBoMDBPGxbrVWGNw/KPL+JNELTPkuokYN 4r9S3T/e9m261jUjMCiQQxsL00hDk80Df0depkQ6dagEiPFXB8g/VpdCdxTTYvWH/gfG MEkhAmCb8m67+VUr9CTBOPOcHpl+kSLMw2mrRsEsV7SZq6UkTZ6D7v9jS9pSf1nyKpyS jDDtT7nWGeSo5TnKCqWT3XC0kewmssJHhQ3ClNXBnhYEGBZkGGqtPv+dDARQgVZ28c6E 0RFE6qahfQ7iNcjD+qmQmlObYaU4d41NjUbiD3y+yMaMDZaIZAuZbHTpI7k7NwNgX2vk hv3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jm1eR8y4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202460-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202460-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6323ddee1si102486045ad.217.2024.06.05.05.40.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:40:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202460-linux.lists.archive=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=@kernel.org header.s=k20201202 header.b=Jm1eR8y4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202460-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202460-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 080A428405F for ; Wed, 5 Jun 2024 12:30:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD36F19E7EF; Wed, 5 Jun 2024 12:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jm1eR8y4" 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 0FFE319E7D8; Wed, 5 Jun 2024 12:02:37 +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=1717588957; cv=none; b=K8ZlLr/JtU2nv3UNyaXES9EbXcDkgy+8GTqs2ilF5PQQy77t9gt0n9dP2b2P1udetUr6RuVPZbT0AGAqGkROykpbFEGoVJuuQePgI0PKU8itiLSi24zf6OeXo6aU4juRuvABzekKfgplge6GmEXlZrEXOCefm3Iusn261z8PF1c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588957; c=relaxed/simple; bh=dRcy6OS1IofzbD1NjQE76rjD0zXix+SxVmT62c0IwPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ogiYQ2cd1sIIotxAzK6Qu6Mbaaht7R4AJO4VosBBMHJv5JFB7erfrZr34AJGa6CEKE1lY09idwkwuuB0NZyt0EaQf4c3JGKgR83eAa2HH1YhBQhewVckdMh/9I9FYRYK3F5fauDvKQFt2Qh3HGVDdpwabO0t6KmRTxnTkXXppE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jm1eR8y4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3649CC4AF0C; Wed, 5 Jun 2024 12:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588956; bh=dRcy6OS1IofzbD1NjQE76rjD0zXix+SxVmT62c0IwPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jm1eR8y43/cqVFizuaUO8UMf3CxyGZjDeTjYoz+z2Zglb/2EnNNrqgy8H/91lPJby QnUQF52ON1fq571ZFnmW3yxOllo/a5e8H/nHmnlhtj6As2b58Aen/aD/EKcE6oA+8Y n6wu/ZC0JoWU/1kdYEoXz7FKJuIh7VTKyePKlj9zWELA27Xd4ZNqUYoV6cXi2JEi41 kRwltnWN4PWbFKeXJO+KlXK+ztDOh0fFY4JRjMd67MCZ/28KpvYzjvX5Ko6NfMWCD6 OQDd6npRjPVAawiyPTcFYNPdovyUsSd/u7jJB4Wm6r9I8M4/ciuMGCtsenXX0UO8B2 lprOvKpPEkGDA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jim Wylder , Mark Brown , Sasha Levin , gregkh@linuxfoundation.org Subject: [PATCH AUTOSEL 6.9 09/23] regmap-i2c: Subtract reg size from max_write Date: Wed, 5 Jun 2024 08:01:52 -0400 Message-ID: <20240605120220.2966127-9-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120220.2966127-1-sashal@kernel.org> References: <20240605120220.2966127-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.9.3 Content-Transfer-Encoding: 8bit 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