Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp622634img; Fri, 22 Mar 2019 05:21:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzG8ZcCU6ewL1W7AqKZEg3mGpHijkMuXzHuT3KYT29RM84qgRb/JqfDPACydPrmjSkkvPQV X-Received: by 2002:a63:594a:: with SMTP id j10mr8640956pgm.279.1553257270312; Fri, 22 Mar 2019 05:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553257270; cv=none; d=google.com; s=arc-20160816; b=kl+UPYCUDNcq3WQjuxXq42JwQhXpztqlOV1C/eSgFefXIweQHdWkUjvTp3/7PRw6os U2j2yQQDJ8GWKtWYreuXCv0kCyFj+a/Buz5Mczir3cHmqu3A33mdbQD1QzUxQRVhjB3i MPD71owwXAe0K5FcWQcj+y/3EhLSbHNy4Y4JAVYfjcd+I5h9KAhKVFa59SbXbEqitgl8 vl0gvsqrBu7UkJWY0zlmLlGcL7Q+i8m4F1jU/mmsV4YMLaSMXKl+Dj3orsmLtH7EIIXx znlJxOtOfBOW6dBucQHvYBeTWR6qzY5rWIotpmfoY6cn/RbCwVOGvlYhxkDs3oSp5g62 nmAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lrQuOxrsUxdEexGDj6BKBC+fH6dIS9DOa8/aFt/noWU=; b=D7eooiHjHGGXG+A4gSfj+8aNZKB+2s8+xkX3Dforu3CGwgVfbYrxq33oP4zybhlYHp EPu0STFgTnChKszcuOU+NEyIaiDiMFsN39zeO7EQlAIlfMjiMNpHDxPbFQbny4mNXrIo GJKGUwkiHnRDGv6Oap4bQbQzVuilB47piCPlpWGBRcgc/AdDtn/hj7kNYrwsHnOlKjKA fZUzYAfFBp+3BCTqZQFP9veFhtc5zImfb2jJKpLfIeCPEQmheyk3hW0s0gqhkefE7Neu Sf8lnx+pHFqL4TgWzbg4P6TBM2w8ceMJKpQLxitEB0aDHv/or1Eo3RqfkZdTvVMWaRHq EuNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U3hLYo8L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f34si7010210plf.343.2019.03.22.05.20.55; Fri, 22 Mar 2019 05:21:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U3hLYo8L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390587AbfCVMTK (ORCPT + 99 others); Fri, 22 Mar 2019 08:19:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:58062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390564AbfCVMTG (ORCPT ); Fri, 22 Mar 2019 08:19:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2CE2C2082C; Fri, 22 Mar 2019 12:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553257145; bh=98W8Wh5yq0ShJtzO9Wtg3C2MLwm63G5r2GooQsljt10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U3hLYo8LjZpCmewivu85JUsOc9gNAtBNnhekrrxm88QNvqkkKqP8QC5RPgueA3EO5 gkSbCYdFCua8x9uxjDZ6y9NLlKV1+PDsmOHzIdKGJOTewGv06PNfb9dFe4Q4Og3Lbr FdM5xUwE7+6XT73vHZSinx+plrX4lTE61+1DC9Eo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolaus Voss , Guenter Roeck , Heikki Krogerus Subject: [PATCH 5.0 146/238] usb: typec: tps6598x: handle block writes separately with plain-I2C adapters Date: Fri, 22 Mar 2019 12:16:05 +0100 Message-Id: <20190322111306.990467263@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111258.383569278@linuxfoundation.org> References: <20190322111258.383569278@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikolaus Voss commit 8a863a608d47fa5d9dd15cf841817f73f804cf91 upstream. Commit 1a2f474d328f handles block _reads_ separately with plain-I2C adapters, but the problem described with regmap-i2c not handling SMBus block transfers (i.e. read and writes) correctly also exists with writes. As workaround, this patch adds a block write function the same way 1a2f474d328f adds a block read function. Fixes: 1a2f474d328f ("usb: typec: tps6598x: handle block reads separately with plain-I2C adapters") Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") Signed-off-by: Nikolaus Voss Cc: stable Reviewed-by: Guenter Roeck Acked-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tps6598x.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) --- a/drivers/usb/typec/tps6598x.c +++ b/drivers/usb/typec/tps6598x.c @@ -110,6 +110,20 @@ tps6598x_block_read(struct tps6598x *tps return 0; } +static int tps6598x_block_write(struct tps6598x *tps, u8 reg, + void *val, size_t len) +{ + u8 data[TPS_MAX_LEN + 1]; + + if (!tps->i2c_protocol) + return regmap_raw_write(tps->regmap, reg, val, len); + + data[0] = len; + memcpy(&data[1], val, len); + + return regmap_raw_write(tps->regmap, reg, data, sizeof(data)); +} + static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val) { return tps6598x_block_read(tps, reg, val, sizeof(u16)); @@ -127,23 +141,23 @@ static inline int tps6598x_read64(struct static inline int tps6598x_write16(struct tps6598x *tps, u8 reg, u16 val) { - return regmap_raw_write(tps->regmap, reg, &val, sizeof(u16)); + return tps6598x_block_write(tps, reg, &val, sizeof(u16)); } static inline int tps6598x_write32(struct tps6598x *tps, u8 reg, u32 val) { - return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32)); + return tps6598x_block_write(tps, reg, &val, sizeof(u32)); } static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val) { - return regmap_raw_write(tps->regmap, reg, &val, sizeof(u64)); + return tps6598x_block_write(tps, reg, &val, sizeof(u64)); } static inline int tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val) { - return regmap_raw_write(tps->regmap, reg, &val, sizeof(u32)); + return tps6598x_block_write(tps, reg, &val, sizeof(u32)); } static int tps6598x_read_partner_identity(struct tps6598x *tps) @@ -229,8 +243,8 @@ static int tps6598x_exec_cmd(struct tps6 return -EBUSY; if (in_len) { - ret = regmap_raw_write(tps->regmap, TPS_REG_DATA1, - in_data, in_len); + ret = tps6598x_block_write(tps, TPS_REG_DATA1, + in_data, in_len); if (ret) return ret; }