linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Peltier <grantpeltier93@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
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
Date: Wed, 22 Apr 2020 10:22:28 -0500	[thread overview]
Message-ID: <20200422152228.GA32630@raspberrypi> (raw)
In-Reply-To: <20200422020404.GA126375@roeck-us.net>

On Tue, Apr 21, 2020 at 07:04:04PM -0700, Guenter Roeck wrote:
> 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 ?

I tried with a variety of buffer sizes from 4 (data size) to 32 (max block size)
and it always returned an error. I believe that i2c_smbus_read_block_data()
attempts to do a legitimate SMBus block read which depends on the controller
interpretting and reading the correct number of bytes as signaled from the
client. This is in line with the docstring for the function and the fact that
the BCM2835 responds with false (0) from i2c_check_functionality() for
I2C_FUNC_SMBUS_READ_BLOCK_DATA. On the other hand,
i2c_smbus_read_i2c_block_data() appears to do a fixed length read similar to
the function that I wrote above.

Thanks,
Grant
 

  reply	other threads:[~2020-04-22 15:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 19:03 [PATCH 0/2] hwmon: (pmbus) add debugfs features for Gen 2 Renesas digital multiphase Grant Peltier
2020-04-20 19:03 ` [PATCH 1/2] hwmon: (pmbus/isl68137) add debugfs config and black box endpoints Grant Peltier
2020-04-21 18:58   ` Guenter Roeck
2020-04-21 21:49     ` Grant Peltier
2020-04-22  2:04       ` Guenter Roeck
2020-04-22 15:22         ` Grant Peltier [this message]
2020-04-20 19:04 ` [PATCH 2/2] docs: hwmon: Update driver documentation for debugfs Grant Peltier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200422152228.GA32630@raspberrypi \
    --to=grantpeltier93@gmail.com \
    --cc=adam.vaughn.xh@renesas.com \
    --cc=grant.peltier.jg@renesas.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).