public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: "José Miguel Gonçalves" <jose.goncalves-ojS98SfuVkU@public.gmane.org>
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>,
	Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: Re: Problem with a hih6130 sensor in a OMAP I2C bus
Date: Mon, 9 Dec 2013 13:22:39 +0100	[thread overview]
Message-ID: <20131209132239.3c0f6402@endymion.delvare> (raw)
In-Reply-To: <52A5AC95.3050803-ojS98SfuVkU@public.gmane.org>

Hi José,

On Mon, 09 Dec 2013 11:42:13 +0000, José Miguel Gonçalves wrote:
> While testing an HIH6130 humidity and temperature sensor with I2C 
> interface in a BeagleBone board I've found that I was unable to read it 
> because the driver always returned EINVAL. With some debugging I've 
> found that the error was due to a test on omap_i2c_xfer_msg() in OMAP 
> I2C driver that invalidates zero length writes. The hwmon hih6130 driver 
> issues such kind of request in hih6130_update_measurements() to issue a 
> measurement request to the sensor.
> 
> I was able to get measurements from the sensor by hacking the hih6130 
> driver replacing the following line in hih6130_update_measurements();
> 
>          ret = i2c_master_send(client, tmp, 0);
> 
> by
> 
>          tmp[0] = 0;
>          ret = i2c_master_send(client, tmp, 1);
> 
> Is this the correct way to fix this issue, or should the fix be in the 
> I2C OMAP driver to accept zero length transfers?

Ideally it should be fixed in the i2c-omap bus driver. However, if
zero-length transfers are explicitly prohibited, it may mean that the
hardware itself can't do it (in which case adding a comment saying so
in the source code would be great.) You'll have to check. The driver
supports several generations of OMAP chipsets so you'll have to check
them all, maybe some can handle zero-length messages and some do not.

If fixing it in the i2c-omap driver is not possible, then working
around it in the hih6130 driver would be acceptable. You'll have to
make sure there is no side effect to sending a single byte to the chip.
If performance is a concern, you may have to enable the workaround only
when zero-byte messages aren't supported. You can check with:

i2c_get_functionality(i2c_adapter) & I2C_FUNC_SMBUS_QUICK

-- 
Jean Delvare

  parent reply	other threads:[~2013-12-09 12:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 11:42 Problem with a hih6130 sensor in a OMAP I2C bus José Miguel Gonçalves
     [not found] ` <52A5AC95.3050803-ojS98SfuVkU@public.gmane.org>
2013-12-09 12:22   ` Jean Delvare [this message]
     [not found]     ` <20131209132239.3c0f6402-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-12-09 13:19       ` José Miguel Gonçalves

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=20131209132239.3c0f6402@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=jose.goncalves-ojS98SfuVkU@public.gmane.org \
    --cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /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