From patchwork Tue Sep 14 14:02:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12493581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2459AC433F5 for ; Tue, 14 Sep 2021 14:02:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0371560F92 for ; Tue, 14 Sep 2021 14:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233517AbhINOEE (ORCPT ); Tue, 14 Sep 2021 10:04:04 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:48053 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232989AbhINOED (ORCPT ); Tue, 14 Sep 2021 10:04:03 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id CACFB5C0115; Tue, 14 Sep 2021 10:02:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 14 Sep 2021 10:02:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=0ZwXiZhi1QvrQjegd1Fbj2eOT8 sE6gEZauag+r4fBZA=; b=mVl9l/jsH6bPWuum34e9qxaaD/1Yo6p81jAOnw8kwe IlPgSIvCurASBPi0xbYYL3HdCJxNbfKV6+uObiRacQaGhI9oG8Yk+yu7svb4EgDn Ea+t1uaXPSPEndcxQBv6IekBCE73P5yQ7cFDCNConFB05ivphgioj0p8OgVLh2cI VcUTBirLnZNIEnIlzjxnMdsiWPGnd5JPlCYdl8SqK0z/qdMSBcSBwAEAFK5u64ju yqkHvRpePbqVP57AGR3GCogzHzjnqynvi77dWRaI1ZXcC4tXfNpv4cax6v29Goja H5REoeNQr7JT+AxKbxaS6+P+lxoMf5jBDDDUP2Q65rdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=0ZwXiZhi1QvrQjegd 1Fbj2eOT8sE6gEZauag+r4fBZA=; b=A679T0hg++tIr+hMnYrzytIOG3tVb/J7N saPp90aCdxt/J952eDfJKpfWYz6r3TERfIK4qWVW1fqfxzvQ1XR+GxM+QjuQZpZr XkzRjbYq2R40cUWFlvLIQp3Y1v3R3cf6B1ry7lT6JUzxWvqozyLszm7aDTLmw79/ HU0GHKe8U9LIglm/MrNzGAY/vZpXjrt7xfgjTnZnjqeA0LjBfTz8uAC4UO5gSMEs HLW1NTGZHzCpL49d0Op/beiEDG2t+znnTPvoTFfbyriJPWd/wXOrtd6PK0xpCOtD DkYGlXknNT/pL+Ea0OVrDhwFHcmBcoiOC/KO47lcFW/7HGK4yCbwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegledgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcurfgv thgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvghrnh epuefgleekvddtjefffeejheevleefveekgfduudfhgefhfeegtdehveejfefffffgnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvghnse hsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Sep 2021 10:02:44 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Sven Peter Subject: [PATCH v2 1/3] usb: typec: tipd: Don't read/write more bytes than required Date: Tue, 14 Sep 2021 16:02:33 +0200 Message-Id: <20210914140235.65955-1-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org tps6598x_block_read/write always read 65 bytes of data even when much less is required when I2C_FUNC_I2C is used. Reduce this to the correct number. Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus --- no changes for v2 drivers/usb/typec/tipd/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 21b3ae25c76d..c18ec3785592 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -123,7 +123,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) if (!tps->i2c_protocol) return regmap_raw_read(tps->regmap, reg, val, len); - ret = regmap_raw_read(tps->regmap, reg, data, sizeof(data)); + ret = regmap_raw_read(tps->regmap, reg, data, len + 1); if (ret) return ret; @@ -145,7 +145,7 @@ static int tps6598x_block_write(struct tps6598x *tps, u8 reg, data[0] = len; memcpy(&data[1], val, len); - return regmap_raw_write(tps->regmap, reg, data, sizeof(data)); + return regmap_raw_write(tps->regmap, reg, data, len + 1); } static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val)