Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp169718lqb; Thu, 23 May 2024 14:22:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHAC/hw1VHFzHUEZPZfL9AiadbJ/VcteJWjviyJEG7ww80fIfPdpc3nAxnYsWspRS2Wwruy2oo1FQt3QcIEziUBWgUCwM6uXNmW40N6w== X-Google-Smtp-Source: AGHT+IHOhySxX+h3rEx1Q8ePgUmd4S+XmcRExOU+r2iju9W3H0sXQg7VMgqEZcYJ1iHV2nPZqO6X X-Received: by 2002:a50:99c2:0:b0:56d:fca5:4245 with SMTP id 4fb4d7f45d1cf-5785198776cmr223234a12.10.1716499352235; Thu, 23 May 2024 14:22:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716499352; cv=pass; d=google.com; s=arc-20160816; b=oYNtlouf6p4ikvEJBWD2CtNBicFxFg+6Br01PBsaXpcm58vMndG7smH7laNi1dG2tG RKkPzEFJHsRkXCTM+EftXISQ0SVBc2gzPFtCpPgQvZe4qY6uSAe/Nxdy7gjSoMdjJ9zT GJt89w8v4PoQnXCkkCeKqKdUf4L23FhpFFM5Uj5aDyrluHn4WezvAosCeVX/Zrj84BT5 1g96idrn4OA9VWcoTtbQqyJwLqWLZ/Hlni8jwUNGZwlp5gZ5MuZKhgq6VRDffECvxF9T tczRubukmZB5GIp1MeKWMua9v/DEwWNBofysDVZwqxT+dgpbm1FkkCxAlN7Ul10r7bcJ ZXGg== 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=2R6UodRaLm6pGjY7twVjUfcDvm1sCMloJlBSSkefp+U=; fh=M8HcYd62Gh3NJtmNc3OAsdf5ZZqnCDElgkNKqQbL7OA=; b=DppAPShlPuQ2OJ79hXQzMdsUz/avuHsqrZds8mdkmbgBCFriqPRN53S9fzraXuXIHx JOI6N+BPbQN4uG9M3fYKKHJ2X7b6dEqkmihbsSH1Y8haLzs+KXWDB+O7qI1xvliKjCrR vTEDBxHC8hBJubn0yuYp0Eu8UPalKJxsYNqOodptUHy1nAMpvIwO404ko5+4+RIhGCH/ M7YYICPtkokd1PfOLH8uK+R4tGRLjwizenLY/DIdS9mv2+XU4zSCK2QczXOatDUlh0vZ TVf6bt+NujPQR8UcBgj8xd5x08YiHukFMw6XyDFw+o5VM5vsKPWTG3pois7TAIe/+7yg mxcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eF0J34zu; 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-188008-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188008-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. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578523316fdsi118434a12.113.2024.05.23.14.22.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 14:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188008-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eF0J34zu; 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-188008-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188008-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 9782B1F2453A for ; Thu, 23 May 2024 21:15:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D08AB127E12; Thu, 23 May 2024 21:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eF0J34zu" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 9970684E1E for ; Thu, 23 May 2024 21:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716498904; cv=none; b=cgfxfhOZDcTLfrBnoHTwdPLLyhTSpfU343M7199TbSl5yi/tb83EIFPoCK0cvYzRG49mGGzce2FCmox4ipdDaXdXtxERDdsB/kJiNE4VUDR64yBxtk5wiPItjO2SIBbFIpWxoe+AJ/bKwny1WJl7QDrQmQXsxOzMrmMoM0oYWTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716498904; c=relaxed/simple; bh=uc+fbO51JAgrHHKzQByvLrZwrpEye8agfALuE4RBUv4=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=gGEJhsZKYNZ8a9kUbXgVsjYVIs+gRniOjXFfuOU/IHldtMsAfJbBXWvcz4fGM8H13f03zmIo/k1fyGmtVYnn+2ZJ7hGwZcM+q0qLlJdce7X/9nU7jjPDyxc2XxUZvyyug+N86yY6kM7w5lvbwWRmc+pivzgORo/oZG5HE84oeQk= 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=eF0J34zu; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-627ebc309c8so37062317b3.3 for ; Thu, 23 May 2024 14:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716498901; x=1717103701; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=2R6UodRaLm6pGjY7twVjUfcDvm1sCMloJlBSSkefp+U=; b=eF0J34zuQvUerYhexvKTtFFn2vWk3EDcm41vtUM6Ocb9UkXIbluHDM2V2RZUUUoTJr /v2HWaJ0fs2Nk3gDKeD6StFD3aLDb6GS5DLlDrZ3p9y8+ILBChMoOImzGGY2ZnCJANoO Coe8ucbBxhK+8IfUcsFTBJKbqwsNzERuuKal/e8hNH7p3Jh7DwC75jA2iaB9K6ZwJo9e +BzeJQdCV9uaCfQ16giZl8TnAdKpgQhGLlEC+9wgmi8r04FHFsYitTZLVXZvM1lFMaCs uyPxgPd+XykOi25VTv5Ykzyme1bVEiEYKmNfqYXG8fzQn9GViaodtnMKtuHsCkM5XXNt nAkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716498901; x=1717103701; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2R6UodRaLm6pGjY7twVjUfcDvm1sCMloJlBSSkefp+U=; b=QoUJ0PnDMcqHaf0xpaRAhmuv08BDMrylzaJx8uP/qoo8NQ5nd5BcIKZFtx3ztkYgQQ IJ4HuDSRnEVAhIGbUbrd7vPSAETFJ0CA81Zi41tmWV10euv8VYo3UaNVNMvt0CnY6kqO 8Olbxl0OlZPGrCSu4OFPiv0MYIRelaA90LnFrHr5kqZbbldJ2ANhvCnr1HlbmEI3w+S9 7t51k+7HujrmshjEeGSiiCP2ZfBu8OCeZSwWSNxVqi/mwV5KoKNcn7GaaL9re+q0Oufj TSgRDy5P5smsXGJxGp0sXkw/2EJZtzaQ5ueBYXWtk05Qil3PHcDikFx3hcVple5UcX4/ e+sQ== X-Forwarded-Encrypted: i=1; AJvYcCUSVreJzGu9L/A9pi7o+o52woFT+O/UZfsNtWAhzFcXr6DI5q25Y2V9McW3DgZjLl+fv2HG/gf7ld3fZ8s4YchRJq66yxDJavqZ4YJG X-Gm-Message-State: AOJu0Yy05U6Lxo8bZUB0j1UrRm8CIBWNnlG7fDWUqS8N1t8CMoGsmLc+ nN9MyHuwF3vAajnVYz62g5PyGPAs0eiJhALe7LeDfbazwwqExyAB24ZNixHXmoCgHwcwdLVgRk+ G+HHrfA== X-Received: from tetrad.chi.corp.google.com ([2620:15c:2:a:aa92:584:c15e:b255]) (user=jwylder job=sendgmr) by 2002:a05:690c:4a02:b0:61a:b2d4:a3fb with SMTP id 00721157ae682-62a08f9ddb9mr867237b3.8.1716498901490; Thu, 23 May 2024 14:15:01 -0700 (PDT) Date: Thu, 23 May 2024 16:14: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: <20240523211437.2839942-1-jwylder@google.com> Subject: [PATCH v2] 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 --- 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