Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp215887ybz; Tue, 21 Apr 2020 19:05:30 -0700 (PDT) X-Google-Smtp-Source: APiQypKaw+6n4o4nKMz9mDSL1ibpU46MbforfOf86uiX7HXqdVDT0i48MgikV8luOdLAZKXv8WxV X-Received: by 2002:a05:6402:4a:: with SMTP id f10mr22273399edu.274.1587521130774; Tue, 21 Apr 2020 19:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587521130; cv=none; d=google.com; s=arc-20160816; b=h2Z4iHLIPkn4FVWuzD+7rUvATKHSlIZCbmoTxYuO8HFwO2dBcryWJh3NlPM8DR+GfV +UfJPwzsLtj9/cv/mGk0gytxM8l9+fxUZdECwgPc7GG8ryDXUQXvA4bhq5/cS8aL6jpu LlEkvND2IHV4b9928qf2WmjUtWxvACU1HgZug/My2ci/m25WiX6lacY9jENnd004bTch xsPCF/FXb1piEX9RLm5ImOraoko0nkmSIIPjBMmTULspBaf8QlwGHldhEFb8yqGUn0ak 1EmFK4AIzXAI0asjq4TtfcdschfzLKgjag2ERZDnhxbxSV8xaNz6MQ16UcRTVzPy4AG/ 3Lsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ToKzHi88KUDCwxX2NbfwDgfuG5Ihi+Tt5yodZXzkNFY=; b=kr3lTacPP5/XGfkGKHqDjdy1G90CIx4ELqeUrWj70JwEpzeclX5N9eqnLU1MW36gz+ iC58JLEx0rGGmuTh4fQr7bEpEDHenlwItm4g9GeCNSc/mFIyRKYDPYK8d5rShIsk7GNX ngK8NwqWiHqQu04p6+QBVpR49rsCOBnhHE8KD4oq7yv0Z9Ykueb+K715ybLq8R3Y6RYk Dm+e3AqfsFSU/0jpykxTa6OxunwzNTakPn9zo/JZMpU12WQa6ZtxxS8swYIAFQ19gs/S ksefIWBPvjAKefiH+ZY4Rox6LuB6ciHTAPQwjY8hySlNw2yXcPMiVb+dtl8+Wpm7pK27 iXMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XVhm6vBU; 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 e8si2701957ejt.23.2020.04.21.19.05.08; Tue, 21 Apr 2020 19:05:30 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XVhm6vBU; 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 S1726341AbgDVCEH (ORCPT + 99 others); Tue, 21 Apr 2020 22:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgDVCEG (ORCPT ); Tue, 21 Apr 2020 22:04:06 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D5BC0610D6; Tue, 21 Apr 2020 19:04:06 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id w20so294648pll.4; Tue, 21 Apr 2020 19:04:06 -0700 (PDT) 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=ToKzHi88KUDCwxX2NbfwDgfuG5Ihi+Tt5yodZXzkNFY=; b=XVhm6vBU+VWXvVfdng0/kTGsT3JWJrh5z+CNgLTgSJDOq3Jw3/NWsiP9ZiNvMBNpyB UVTKb5Op/4TkgwME2B0KA4bYV+JmYEV3/DxB8BzOrNHX8eF2eNBd4Nq/s3pmvaoAYq5t pmz6nO0C+Pl+01573VSuP1HpWFJG72ZReLsM5kgzWHiYP8TI0eoVRHlOEdxXUlF/6kC3 /dwdoJWnPtYxd4aCxhykLyanGZMy/H/ubusp5DHRQKmWUnvkiGFLmpKMDDieG1EKoSW0 EVTtyqGfJhg79UNZUHFK7e/pbGXx//yaM7phTKz8SDfky9mfQTWSAaalSZqiiw9UaW2U C0Sw== 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=ToKzHi88KUDCwxX2NbfwDgfuG5Ihi+Tt5yodZXzkNFY=; b=c51fGe4TpyBMMpIU5nBv/Ex+5bd0Kzc98cTRpOuPVW40GNPy/maRcyLS2l2rZXBpix aNHAS39JkCX9YOWaS4Ua9vM41NaxeZjFSpVKLrjpzerVj/v2akgzpVfKJ/dGLh8iNswC XvLV9A6v6S0hyJvW9Pm3t9nwvco5NzDNMQ/0qkJXPPBH5B54T6ElnRdkocbbtmhyUUyp /k/EPB0KKTUPCa4cV3NOLfPfLwdb+974tYdaWwKVc3aK7/JofG0XS2YvvnotLwtF6ynf V8wxGqhdcCSgZszUTLahrwgHQ1SjkZOsVUpQDbSgtStL73Ex7fAN9UavX9SBkjMZ+OOD QH/g== X-Gm-Message-State: AGi0PuYso7o+j9Uiah0mZA+dRuAl2Nwdf822xikWGjCkKuSQKP9aRaFb zkVCwn6O82gGmdP3tORVhMY= X-Received: by 2002:a17:902:8688:: with SMTP id g8mr25431832plo.268.1587521046418; Tue, 21 Apr 2020 19:04:06 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id p68sm3686505pfb.89.2020.04.21.19.04.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Apr 2020 19:04:05 -0700 (PDT) Date: Tue, 21 Apr 2020 19:04:04 -0700 From: Guenter Roeck To: Grant Peltier Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, adam.vaughn.xh@renesas.com, grant.peltier.jg@renesas.com Subject: Re: [PATCH 1/2] hwmon: (pmbus/isl68137) add debugfs config and black box endpoints Message-ID: <20200422020404.GA126375@roeck-us.net> References: <203a7cd37dd95a0127cc06de14986721ab621e93.1587408025.git.grantpeltier93@gmail.com> <20200421185851.GA95204@roeck-us.net> <20200421214917.GA28170@raspberrypi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200421214917.GA28170@raspberrypi> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 21, 2020 at 04:49:17PM -0500, Grant Peltier wrote: > On Tue, Apr 21, 2020 at 11:58:51AM -0700, Guenter Roeck wrote: > > Normally this is emulated for such controllers. I don't recall seeing > > such a need before. The code below duplicates similar code in > > i2c_smbus_xfer_emulated(), which is much more sophisticated. > > Are you sure this is needed ? Can you point me to an affected > > controller ? > > > > > +static s32 raa_smbus_read40(const struct i2c_client *client, u8 command, > > > + unsigned char *data) > > > +{ > > > + int status; > > > + unsigned char msgbuf[1]; > > > + struct i2c_msg msg[2] = { > > > + { > > > + .addr = client->addr, > > > + .flags = client->flags, > > > + .len = 1, > > > + .buf = msgbuf, > > > + }, > > > + { > > > + .addr = client->addr, > > > + .flags = client->flags | I2C_M_RD, > > > + .len = 5, > > > + .buf = data, > > > + }, > > > + }; > > > + > > > + msgbuf[0] = command; > > > + status = i2c_transfer(client->adapter, msg, 2); > > > + if (status != 2) > > > + return status; > > > > i2c_transfer() can return 1 if only one of the two messages was sent. > > > > > + return 0; > > > +} > I have been using BCM2835 for most of my testing. I originally tried using > i2c_smbus_read_block_data() but that was returning errors. However, from your > email, I went back and tried i2c_smbus_read_i2c_block_data() and that appears > to be working so I will switch to that instead. > This is odd, since the function should do a SMBus block read. Did you pass a buffer that was too small, by any chance ? > > > + > > > +/** > > > + * Helper function required since linux SMBus implementation does not currently > > > + * (v5.6) support the SMBus 3.0 "Read 32" protocol > > > + */ > > > +static s32 raa_dmpvr2_smbus_read32(const struct i2c_client *client, u8 command, > > > + unsigned char *data) > > > +{ > > > + int status; > > > + unsigned char msgbuf[1]; > > > + struct i2c_msg msg[2] = { > > > + { > > > + .addr = client->addr, > > > + .flags = client->flags, > > > + .len = 1, > > > + .buf = msgbuf, > > > + }, > > > + { > > > + .addr = client->addr, > > > + .flags = client->flags | I2C_M_RD, > > > + .len = 4, > > > + .buf = data, > > > + }, > > > + }; > > > + > > > + msgbuf[0] = command; > > > + status = i2c_transfer(client->adapter, msg, 2); > > > + if (status != 2) > > > + return status; > > > + return 0; > > > +} > > > > Maybe it would be worthwhile to consider implementing it ? > > > I could add these functions to i2c-core-smbus instead if that is desired. > However, I am unsure if it would be proper to only partially update the SMBus > implementation to match the 3.0 spec. Is there perhaps a better forum to > discuss adding all of the 3.0 changes? > Never mind, just keep it local. I don't like it too much, but getting patches accepted into the i2c core might take several releases, and it would be unfair to impose that on you. Guenter