From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_MUTT 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 B836FC43381 for ; Tue, 26 Feb 2019 17:43:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 886222184D for ; Tue, 26 Feb 2019 17:43:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QCuuhdWX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727732AbfBZRnf (ORCPT ); Tue, 26 Feb 2019 12:43:35 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:32768 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727704AbfBZRnf (ORCPT ); Tue, 26 Feb 2019 12:43:35 -0500 Received: by mail-pf1-f196.google.com with SMTP id i19so6596812pfd.0 for ; Tue, 26 Feb 2019 09:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oo3p3T8pFSSfaIp8YTAfaoeJbLz2j+Y38TD13e8wGvQ=; b=QCuuhdWXNWZaWMmdysdLRi8JozKjTwsrFFazLYW9+h8Nq7qGrF7D5BsomoIAIxvK4U t7BpEIwtEEoOASPsaNazkyXQpjAz8F+XfS+TXBsmLFmhvNL1MFRm8QrF2k/RWTgwwhRn Jk+gvx51hTlWIRQn5hh6dAOldqoYolgjHbNmgbl0r5Q4FCwXnGpwX9L6toMzGyYTsjhA c0ww3Aw66w8OcRm8F9qSpIIpDjNRNGZgzTCXL+9xiFYcKMA6wUBFlHTbtFGp3fLcjORj R5spfauBFAL3QlYIgTiSsFXui7KaKc1+l3joyhpBxSjrj2UtcmSb6j/xqbdTPlPbxhdH rrDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=oo3p3T8pFSSfaIp8YTAfaoeJbLz2j+Y38TD13e8wGvQ=; b=XXSTdHK4XjytML5Wd+QJ2cxNjgHXUdtUBYmXlN+qGYPCdJlibNApZYowyVgWRQC4bI FClin1CL3BjRa1abk3bCBmFLr32Xmrv36RK1LwUTyVmmcP3kKvH3fvDf/UghkHiILPE3 oLkqWY2weui3nZK1ffFpuF+iTEGDmWHaMdF1utGn2zGFQg38SGBEVGB7DRXnTBZigVJJ yh9Kc+sH06TrnCCz61vS8YMsNoE6YH6BdCwlvIeE4q4/PXcApfZHZM4oFR3uz6aAFwqM GQnRtx90DU7uC68S5Zb/yWPjrlnuwOuaueSqJj1lf5a2BRuU727wWTbql6KJu0LK5T/p YHNA== X-Gm-Message-State: AHQUAuaJT9LzBlFhP14LiQCuW2nEwSlllBsn39zzQ1J2bvpTndlibHm7 cMLG67U/lRthG8w3sFH0k40aY9JL X-Google-Smtp-Source: AHgI3IafUK0MXhC5KnwBbYH6Gre+hi7MST9caUS75RZmk7X8bOlcNdCYso+VSB5/Pdze4/fO2N5CnA== X-Received: by 2002:a63:4c18:: with SMTP id z24mr25666283pga.62.1551203014717; Tue, 26 Feb 2019 09:43:34 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w10sm19865325pge.8.2019.02.26.09.43.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 09:43:34 -0800 (PST) Date: Tue, 26 Feb 2019 09:43:33 -0800 From: Guenter Roeck To: Suwan Kim Cc: sw.kim@os.korea.ac.kr, Nikolaus Voss , stable , Heikki Krogerus , Greg Kroah-Hartman Subject: Re: [RFC 1/3] usb: typec: tps6598x: handle block writes separately with plain-I2C adapters Message-ID: <20190226174333.GB8682@roeck-us.net> References: <20190226153810.5638-1-suwan.kim027@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190226153810.5638-1-suwan.kim027@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, Feb 27, 2019 at 12:38:08AM +0900, Suwan Kim wrote: > From: Nikolaus Voss > > 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 Sorry, I am lost. What is this about ? Guenter > --- > drivers/usb/typec/tps6598x.c | 26 ++++++++++++++++++++------ > 1 file changed, 20 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c > index 9947c87d2a1e..c674abe3cf99 100644 > --- a/drivers/usb/typec/tps6598x.c > +++ b/drivers/usb/typec/tps6598x.c > @@ -126,6 +126,20 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) > 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)); > @@ -143,23 +157,23 @@ static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val) > > 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) > @@ -245,8 +259,8 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > 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; > } > -- > 2.20.1 >