Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4598487pxb; Tue, 5 Oct 2021 06:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlIoEZKPkBSTlNW0ImXft01ReVZws7qR17FZ3WsBEukzbIfPcBt6vJwnik0lRO2Z80OTGp X-Received: by 2002:a17:90a:d905:: with SMTP id c5mr3868752pjv.65.1633440826683; Tue, 05 Oct 2021 06:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633440826; cv=none; d=google.com; s=arc-20160816; b=uANh0CDMon5dYI9XOwLNyz3UsubpN4PRApMjuNBi4U0dB2L5r/kXBpRjUKuaLxEkbK T8Hqc9GRUeTgy5NDiVZjhRJd4rPwDR9Nh10SfmB1fVQnK7nTmqzJq59yMSvdNhNjPbI8 SRskpdZYoqhLP/i7E1dP2W2Z1If0O15DJzKeEfv9jA/ZPB6cSBoW4BnBU1pehmdbUEkK nFEqqZQt2oFTNMAst+azRCvLjjD9C2bgYpZHGTXZGYDcHqZTnojlzbgFzaHJKpK6r03u s9m0v9GZgp81MKCwH8u3Uug4ew0OHNdhHrhXIZk4k7VsXVdcCMkY3PYgHjV/oD4JPuFO BDHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=jtIuyFUc/GQgo2brS5lWjKc5AQy0lekPqeQGIz7oxwI=; b=EQwF4jXYx7c62hHV2n35D9vPBD31bcUCLEKktOEzUbo0T+umksDtnh/4+dP6TT1Urg EUrxLaRhKYn+qAmYagvhOMNCzkNgewIeSn5pg55I97YJCdSybmsEARqZkhlgKh2oI91R FhXhxAhp9pvGZVF0IMK3IQqQgqcpdCEbKJR6Wi7+ZsWa/t8frXi7m/lF4py8HaEcgIQ1 Xxeib+zRGsZu0KSY9Lvn0YE7sstH8rsoHiJA6+2l9IHQ8hSapDMx+YCtmFRuf7BDmWP4 K9ZrRBYy4iASaUHKS+LoAHr4ErJ6piT9Fdoy5HvmOs1KxzRZUovDV2S3kSyfKD0I5CgI /daQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si23275218pgl.48.2021.10.05.06.33.33; Tue, 05 Oct 2021 06:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234520AbhJENdm (ORCPT + 99 others); Tue, 5 Oct 2021 09:33:42 -0400 Received: from mail-vs1-f49.google.com ([209.85.217.49]:44891 "EHLO mail-vs1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234209AbhJENdi (ORCPT ); Tue, 5 Oct 2021 09:33:38 -0400 Received: by mail-vs1-f49.google.com with SMTP id 66so7395844vsd.11; Tue, 05 Oct 2021 06:31:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jtIuyFUc/GQgo2brS5lWjKc5AQy0lekPqeQGIz7oxwI=; b=qGcA0SUuG9YMYS/jsz7sN+FpjB7mvda0zJe+bpIBTZlpzadlmT6jVW2gZVuGVhLGWd bU4pD3f5IfKidWUwsasJvh2nW69vL96rJJ7KpbWwt9W6r6AZYchianfQyq3r9FzClSHo hiCqYBN3xt3NTmwzKS78O204F8NO8yjb7r7vTvttOgh22TXVjGCj7+aSrfjQn/l2rlSv WKzPR3qAnbIc00OkQFyObO170EDscpPw5wfnzx7eTdUIiee/1jpKOzQP5G0fnarE1cxd B+UNnZSG7OYtt9g1W3xn7MQMIGNAdqcTMIFuJXOQY53tDLDXYFoR2BPn7kdDI50+GGv2 Y92g== X-Gm-Message-State: AOAM533iXFz9uUbQ1iqPd2K06FZUXo+sSGysxYNeNAhn5UXvbOmbdlCC JXN7IgOTM81pZ7UgkbFZ+cqQcqDdD1PVVFgb07dyW/mITq8= X-Received: by 2002:a67:c295:: with SMTP id k21mr15890974vsj.37.1633440707232; Tue, 05 Oct 2021 06:31:47 -0700 (PDT) MIME-Version: 1.0 References: <20210922160649.28449-1-andrew_gabbasov@mentor.com> In-Reply-To: <20210922160649.28449-1-andrew_gabbasov@mentor.com> From: Geert Uytterhoeven Date: Tue, 5 Oct 2021 15:31:35 +0200 Message-ID: Subject: Re: [PATCH] i2c: rcar: add SMBus block read support To: Andrew Gabbasov Cc: Linux-Renesas , Linux I2C , Linux Kernel Mailing List , Wolfram Sang , Bhuvanesh Surachari Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, On Wed, Sep 22, 2021 at 6:14 PM Andrew Gabbasov wrote: > The smbus block read is not currently supported for rcar i2c devices. > This patchset adds the support to rcar i2c bus so that blocks of data > can be read using SMbus block reads.(using i2c_smbus_read_block_data() > function from the i2c-core-smbus.c). > > Inspired by commit 8e8782c71595 ("i2c: imx: add SMBus block read support") > > This patch (adapted) was tested with v4.14, but due to lack of real > hardware with SMBus block read operations support, using "simulation", > that is manual analysis of data, read from plain I2C devices with > SMBus block read request. > > Signed-off-by: Bhuvanesh Surachari > Signed-off-by: Andrew Gabbasov Thanks for your patch! > --- a/drivers/i2c/busses/i2c-rcar.c > +++ b/drivers/i2c/busses/i2c-rcar.c > @@ -429,9 +431,16 @@ static bool rcar_i2c_dma(struct rcar_i2c_priv *priv) > /* > * The last two bytes needs to be fetched using PIO in > * order for the STOP phase to work. > + * > + * For SMBus block read the first byte was received using PIO. So it might be easier to read, and more maintainable, to keep the old assignments: buf = priv->msg->buf; len = priv->msg->len - 2; and adjust them for SMBus afterwards: if (block_data) { /* For SMBus block read the first byte was received using PIO */ buf++; len--; } ? > */ > - buf = priv->msg->buf; > - len = priv->msg->len - 2; > + if (block_data) { > + buf = priv->msg->buf + 1; > + len = priv->msg->len - 3; > + } else { > + buf = priv->msg->buf; > + len = priv->msg->len - 2; > + } > } else { > /* > * First byte in message was sent using PIO. And below we have another case handling buf and len :-( So perhaps: buf = priv->msg->buf; len = priv->msg->len; if (read) { /* * The last two bytes needs to be fetched using PIO in * order for the STOP phase to work. */ len -= 2; } if (!read || block_data) { /* First byte in message was sent using PIO * buf++; len--; } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds