Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp592787lqb; Fri, 24 May 2024 07:36:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZbY3O3YSnRt06/bbiDAQK9prS2SEGGTfMUQ9IKfkHZs0FhuK2ItuvRXSqb9brWadCMym7vrnNZTzoEVs99k2IW/63R1bsC79EdH0icA== X-Google-Smtp-Source: AGHT+IGmCDrbinw7nCYyPQeuAedEBzD06E8XDkLHGdo+TOpYZXf+LRpZsv4wP9/cEi6kNJi/ZvRI X-Received: by 2002:a17:906:a59:b0:a59:ad15:6142 with SMTP id a640c23a62f3a-a626501324cmr167886466b.77.1716561413445; Fri, 24 May 2024 07:36:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716561413; cv=pass; d=google.com; s=arc-20160816; b=QO7J3zG1qsxr20ulWwfOoB98V5RdPFNbX+R0TV1tnwOM0NELtEgOSmSLidFRIgKw7k H6fa2CUTvl3Q6KMWjDcJOb/IkMcUo9xf6sCNh+2VrcO9iZXpe9w1Gy6rcsn8VTJ/aLq3 JtzUlQX4zrI0KnC/qR7LePDRbPRhksSUeRwFBtkadUAmz5eCccDdQtC866Uj8fWgiQcp qPKfCDQBPIcOjSCLBfjES5Etjd3n6+7PWT2G6J80IbctB02H2tl1szg8cXWM8KEZjcCy JIRdQ5zbJRovzBtTIaLJWH+gyYi2f9im5eDh8UqstRZIV72d+ihJHpc+eACAeegbX5+5 cOiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=vTUqpwB46+S1HwE5N5i7HBLwsrVchHYHKhwYvBsIB4E=; fh=KVBLTmyg6CDyIw6JjeGZitr2gNK+N9yLoHdeXgx1jHI=; b=GnxSJO5vh5l9AIHYRXBBSaHYxVPxk7BWGylmJ6+mWZO12Kj5pPWNbRG/Po81/JoGzM jcPZkZoZ7yKT3xBiYdsliwskw84BL4pkTzeeSaqo2zdrZJeT/kA4A+KiDPZkhaQCxmnA iDiBri/Tl7674PCQkXyJ/3+0ROSKQwpgZXDASMlQWznHlo1hkjtLfwEXK6OPoU89Ly3d 49XPEd9o3TUMwhU6rkEvxVzGJ1BdAtX7bo15Z1FMywHBBH0a1hfFmzE3PaAJSDjeUmBR QG0DQM6HbBBG7T5E/cDlvoNthfQwWVyj2pFvEryprhtJgUYOLyq0NiZ3B8Meg9TpFgI9 mmnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qInGtlCn; arc=pass (i=1 spf=pass spfdomain=flex--jwylder.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-188805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188805-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc37a33si89097866b.475.2024.05.24.07.36.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 07:36:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qInGtlCn; arc=pass (i=1 spf=pass spfdomain=flex--jwylder.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-188805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188805-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2AFC61F21082 for ; Fri, 24 May 2024 14:36:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AD4212C476; Fri, 24 May 2024 14:36:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qInGtlCn" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBC3586AE2 for ; Fri, 24 May 2024 14:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561409; cv=none; b=A2YdiygNJdJhblJeZQi36/qqMm3TKYMhL1KWlUQ4gZqxthrs7ayHRln2rmUHmh5DWivPSSlD5EhHvZfvsefF7h5vfVnF3lySuPEATKn/jKtWv2dYnhFOLHZc4z/Xrxy8BYHNRTc6Sbx3sc1ONj0uS6aSxfAqzbi5TTRCLCBpzwk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561409; c=relaxed/simple; bh=ZooK+41W0K/jFlibqaPJFgKsS9QnWZNfVY5jj0tbSZ8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=mWpN6v7SHce8GOT970u57gUTNwOtX0m5ugEVQRSgjuOkWy5kBm6HILN4RDB6gu/BdT4tFax8Dthh5C6P3NoJ5yKhrLVLByPC3JBEORvaiAPbY/ZVYoFrPFuxMhYbxRinrPZpZugwpFpFqA3aW4X8Hel3KsfetFGFmT2AJAKhRh4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jwylder.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qInGtlCn; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jwylder.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-df771b5e942so544918276.2 for ; Fri, 24 May 2024 07:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716561407; x=1717166207; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=vTUqpwB46+S1HwE5N5i7HBLwsrVchHYHKhwYvBsIB4E=; b=qInGtlCnPNnUJWOgBjvOYbWvWKwtN6JU4UDDlZiFnRx+MuVZ1LNnXJNseOempyOGbk 3syynN0sYgYsdu20Q6jmoU9IP+I6uIsFsxgWSo3H5481jXkZIrTOuEsODw34zxpFuRPB wG6jWzfTS0U87A3Ei4vL5KBXDH89XHP/IxjtGMZJOBKw6MCIgFZCab2kaNm4hU37Uxab Id1ZRwv0HeMbyg8o7OLqyKfUKGtEjCuJVWcs3I7QTS1Cq81Q3Nn5RksX0JM8oqBR/4oO H6I+O02G8qOvmd5ejKn1ejVtYrSa25qwv8TjkSYVWlQAr9WelBTHBfzgMvY7Mg55iF/+ Y+SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716561407; x=1717166207; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vTUqpwB46+S1HwE5N5i7HBLwsrVchHYHKhwYvBsIB4E=; b=shVuSwasxv9U36s1FqUuE1pfDcjdPNyP0I45Z5d65dcfw86Z5GixBDmCoHyHWeu6+j HP47CEI+pMtpTCZDkYz47GhHNEzQg3F0KLueK5YypdSpWAfV51rFFIzwIH6jozV9Ogzd XHygrDmgmqg8u7zNBNA/JyI/yIR08wf1Dq5ROKp4i8xETyv46sC8kMbxad0eUyJtGWxg O4broo/4ukEZIWk7X6fiKDUmIcWTLgRWblvI9O8/s3I1u/i5mbSy+PvE+lqmsKcYk8CA zXvFkdhMJ94iE4e8sh29o/RPmCYNXwUG/2P8xzZwm6Tex4o9OJXqai/bU/+y5O3nHIU+ pzDQ== X-Forwarded-Encrypted: i=1; AJvYcCWxqpIzTRPwD/HtCorOvW1ub7da0YMnxBVylfqMEfT2dkPGLdiIi7Xo3trKtMw/0fhYc9sy4SCeqlp5VaTL6GENzMA9vyt29FFhyFq1 X-Gm-Message-State: AOJu0YxQ2xNm7p/+iM0LKv3tNVuLuiSos7hD1Is7cjEANg573vAikw0g i/TeYiueoiN8MoGyMKpbyN6/2Cckk/mpjaN9BLCYzNItC48zdAVHQeW6l08MLYbLoUqyZmOoD5l U58gBlA== X-Received: from tetrad.chi.corp.google.com ([2620:15c:2:a:76b0:ffd9:14f8:518c]) (user=jwylder job=sendgmr) by 2002:a05:6902:10c1:b0:df7:6f84:f377 with SMTP id 3f1490d57ef6-df77204ce31mr164400276.0.1716561406892; Fri, 24 May 2024 07:36:46 -0700 (PDT) Date: Fri, 24 May 2024 09:36:36 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240524143638.3057944-1-jwylder@google.com> Subject: [PATCH v3] regmap-i2c: Subtract reg size from max_write From: Jim Wylder To: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Jim Wylder , kernel-team@android.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 --- V1 -> V2: Also subtract padding in addition to register bytes V2 -> V3: Added version change descriptions 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 3ec611dc0c09..a905e955bbfc 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.45.1.288.g0e0cd299f1-goog