public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH v3 11/24] tvp5150: make read operations atomic
Date: Thu, 02 Jan 2014 22:59:56 +0100	[thread overview]
Message-ID: <52C5E15C.8060000@googlemail.com> (raw)
In-Reply-To: <20140102172031.325d89fb@samsung.com>

On 02.01.2014 20:20, Mauro Carvalho Chehab wrote:
> Em Wed, 01 Jan 2014 19:52:08 +0100
> Frank Schäfer <fschaefer.oss@googlemail.com> escreveu:
>
>> Am 28.12.2013 13:16, schrieb Mauro Carvalho Chehab:
>>> From: Mauro Carvalho Chehab <m.chehab@samsung.com>
>>>
>>> Instead of using two I2C operations between write and read,
>>> use just one i2c_transfer. That allows I2C mutexes to not
>>> let any other I2C transfer between the two.
>>>
>>> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
>>> ---
>>>   drivers/media/i2c/tvp5150.c | 22 ++++++++++------------
>>>   1 file changed, 10 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
>>> index 89c0b13463b7..d6ba457fcf67 100644
>>> --- a/drivers/media/i2c/tvp5150.c
>>> +++ b/drivers/media/i2c/tvp5150.c
>>> @@ -58,21 +58,19 @@ static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr)
>>>   	struct i2c_client *c = v4l2_get_subdevdata(sd);
>>>   	unsigned char buffer[1];
>>>   	int rc;
>>> +	struct i2c_msg msg[] = {
>>> +		{ .addr = c->addr, .flags = 0,
>>> +		  .buf = &addr, .len = 1 },
>> I would use        .buf = buffer        here, too.
> Why? The address needed is already at addr, and it is also an unsigned char.
>
> Using buffer would require an extra data copy.
You are still doing this...

>
>>
>>> +		{ .addr = c->addr, .flags = I2C_M_RD,
>>> +		  .buf = buffer, .len = 1 }
>>> +	};
>>>   
>>>   	buffer[0] = addr;
... here. ;)

>>>   
>>> -	rc = i2c_master_send(c, buffer, 1);
>>> -	if (rc < 0) {
>>> -		v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc);
>>> -		return rc;
>>> -	}
>>> -
>>> -	msleep(10);
>> That's the critical change.
> I don't think so. I'm not sure why I added this at the first place on the
> original patch with where I added this driver, but it is very doubtful
> that a msleep() is needed here.
>
> This code is really old (from the time I added support for WinTV USB 2).
>
> I suspect I added the sleep there just because the I2C logs, during the
> driver development phase, to be an exact mimic on what it was got via
> USB dumps.
>
>>> -
>>> -	rc = i2c_master_recv(c, buffer, 1);
>>> -	if (rc < 0) {
>>> -		v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc);
>>> -		return rc;
>>> +	rc = i2c_transfer(c->adapter, msg, 2);
>>> +	if (rc < 0 || rc != 2) {
>>> +		v4l2_err(sd, "i2c i/o error: rc == %d (should be 2)\n", rc);
>>> +		return rc < 0 ? rc : -EIO;
>>>   	}
>>>   
>>>   	v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]);
>> Looks good and works without problems with my HVR-900 and WinTV 2
>> devices (both em28xx).
>>
>


  reply	other threads:[~2014-01-02 21:58 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-28 12:15 [PATCH v3 00/24] em28xx: split analog part into a separate module Mauro Carvalho Chehab
2013-12-28 12:15 ` [PATCH v3 01/24] em28xx: move some video-specific functions to em28xx-video Mauro Carvalho Chehab
2013-12-28 12:15 ` [PATCH v3 02/24] em28xx: some cosmetic changes Mauro Carvalho Chehab
2013-12-28 12:15 ` [PATCH v3 03/24] em28xx: move analog-specific init to em28xx-video Mauro Carvalho Chehab
2013-12-28 12:15 ` [PATCH v3 04/24] em28xx: make em28xx-video to be a separate module Mauro Carvalho Chehab
2013-12-28 12:15 ` [PATCH v3 05/24] em28xx: initialize analog I2C devices at the right place Mauro Carvalho Chehab
2013-12-28 12:15 ` [PATCH v3 06/24] em28xx-cards: remove a now dead code Mauro Carvalho Chehab
2013-12-28 12:15 ` [PATCH v3 07/24] em28xx: fix a cut and paste error Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 08/24] em28xx: add warn messages for timeout Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 09/24] em28xx: improve extension information messages Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 10/24] em28xx: convert i2c wait completion logic to use jiffies Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 11/24] tvp5150: make read operations atomic Mauro Carvalho Chehab
2014-01-01 18:52   ` Frank Schäfer
2014-01-02 19:20     ` Mauro Carvalho Chehab
2014-01-02 21:59       ` Frank Schäfer [this message]
2013-12-28 12:16 ` [PATCH v3 12/24] tuner-xc2028: remove unused code Mauro Carvalho Chehab
2014-01-01 18:53   ` Frank Schäfer
2013-12-28 12:16 ` [PATCH v3 13/24] em28xx: retry I2C ops if failed by timeout Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 14/24] em28xx: remove a false positive warning Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 15/24] em28xx: check if a device has audio earlier Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 16/24] em28xx: properly implement AC97 wait code Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 17/24] em28xx: initialize audio latter Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 18/24] em28xx: improve I2C timeout error message Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 19/24] em28xx: unify module version Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 20/24] em28xx: Fix em28xx deplock Mauro Carvalho Chehab
2014-01-03 17:03   ` Frank Schäfer
2013-12-28 12:16 ` [PATCH v3 21/24] em28xx: USB: adjust for changed 3.8 USB API Mauro Carvalho Chehab
2013-12-28 12:26   ` Hans Verkuil
2013-12-28 12:34     ` Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 22/24] em28xx: use a better value for I2C timeouts Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 23/24] em28xx: don't return -ENODEV for I2C xfer errors Mauro Carvalho Chehab
2013-12-28 12:16 ` [PATCH v3 24/24] em28xx: cleanup I2C debug messages Mauro Carvalho Chehab
2014-01-03 20:29 ` [PATCH v3 00/24] em28xx: split analog part into a separate module Frank Schäfer
2014-01-04 14:09   ` Mauro Carvalho Chehab

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=52C5E15C.8060000@googlemail.com \
    --to=fschaefer.oss@googlemail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=mchehab@infradead.org \
    --cc=mchehab@redhat.com \
    /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