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.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,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 DD1F0C43381 for ; Tue, 26 Feb 2019 15:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB1CE20851 for ; Tue, 26 Feb 2019 15:50:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hVkmImMb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726542AbfBZPuF (ORCPT ); Tue, 26 Feb 2019 10:50:05 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44859 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726478AbfBZPuE (ORCPT ); Tue, 26 Feb 2019 10:50:04 -0500 Received: by mail-pl1-f196.google.com with SMTP id c4so6410007pls.11 for ; Tue, 26 Feb 2019 07:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZnzePZnegy7EfHpwqGrzMr48O71X5rg8Q5dgpjc3SEs=; b=hVkmImMb+5GFb6kwjE3WNAsh796SlP2Le4wLJ+p6JJEzJ8KJkMh+TcqeTxQzIiSsAO mRNwmHqZThliMfPe3bo8ZI4dpLQ7uzJV0Ehtc6//ZyBpzP1bavREjLjKQsv8uZs8G5RU TUZqx/D46diA9H+sX6vSH8BJ8BZ1Qygkr4yGbTinkwckUh1hHeTbAagHFwXEVasI3Tno tmF/0tfCUdIRt2UvrKg/pJgEFfhkRYT8HFQ+K45s+FmbvLMSW7sCEaeQg2XBUNq9pVx4 p2nD5zrpL6CtdwqReA9XhXVVK0RdsWimAKd7T2xLgptayUZbOeLCjI6O+Sd4tVGfIoUR owsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZnzePZnegy7EfHpwqGrzMr48O71X5rg8Q5dgpjc3SEs=; b=e5T/ibsdG3zw4gz9ujL566qTjyaVCIrwVofpVfnElbiV+pGpoef9w0/ZdrgZiRhTVI 1AHa7kKcgyKEUL8s0sUKVy4WbMbF26bsf11ecq5kpefhNLiqJ1qzW0akSiJvqhj+yB9g VvO+2BEOMws+auHTwtdq9eweYfHru+JAp70Poy/uLMPGWQgaZCnpVawXtqq+K51aRtG6 n4GH4r5Q7AWsHnDI25bd+FXIT4LQTBOlaLnsv0/TlaU0m0IYl4rudpLa4ZV4LtcR2IqZ GGGxGfVqb2hzn4zIh+qxZV2cw0DGfsjAn0oHfURgVmIt0XzoD2vZ2k30Vxgo7LI6Olh0 7Tdg== X-Gm-Message-State: AHQUAuYaY1bNRIEZ3XxmyjPJr7yVsotjS95B//NXqLS1MKOIYkNSPLLF 0SdeVtKacqJDrUDN+pLVoVo= X-Google-Smtp-Source: AHgI3IYCwS3rvds4Fimui40mHlToPlOdW+NVMoooAHjhFRV+kMfIM/s2+Ml5lJd9fxg/CPhJ8qWl/w== X-Received: by 2002:a17:902:9a98:: with SMTP id w24mr26256921plp.247.1551196204147; Tue, 26 Feb 2019 07:50:04 -0800 (PST) Received: from localhost.localdomain ([125.142.23.13]) by smtp.gmail.com with ESMTPSA id f65sm6067294pff.21.2019.02.26.07.50.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 07:50:03 -0800 (PST) Date: Wed, 27 Feb 2019 00:49:59 +0900 From: Suwan Kim Cc: Nikolaus Voss , stable , Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Subject: Re: [RFC 1/3] usb: typec: tps6598x: handle block writes separately with plain-I2C adapters Message-ID: <20190226154957.GA6422@localhost.localdomain> 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.11.3 (2019-02-01) To: unlisted-recipients:; (no To-header on input) 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 > --- > 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 > Sorry, I sent the mail by mistake... Ignore this mail. Sorry!