linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH v2 3/3] [media] em28xx: add timeout debug information if i2c_debug enabled
Date: Sun, 12 Jan 2014 16:29:26 +0100	[thread overview]
Message-ID: <52D2B4D6.2020806@googlemail.com> (raw)
In-Reply-To: <20140111182737.4cf40c81@samsung.com>

On 11.01.2014 21:27, Mauro Carvalho Chehab wrote:
> Em Sat, 11 Jan 2014 14:14:38 +0100
> Frank Schäfer <fschaefer.oss@googlemail.com> escreveu:
>
>> Am 10.01.2014 09:33, schrieb Mauro Carvalho Chehab:
>>> If i2c_debug is enabled, we splicitly want to know when a
>>> device fails with timeout.
>>>
>>> If i2c_debug==2, this is already provided, for each I2C transfer
>>> that fails.
>>>
>>> However, most of the time, we don't need to go that far. We just
>>> want to know that I2C transfers fail.
>>>
>>> So, add such errors for normal (ret == 0x10) I2C aborted timeouts.
>>>
>>> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
>>> ---
>>>   drivers/media/usb/em28xx/em28xx-i2c.c | 27 ++++++++++++++++++++++++---
>>>   1 file changed, 24 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
>>> index e8eb83160d36..7e1724076ac4 100644
>>> --- a/drivers/media/usb/em28xx/em28xx-i2c.c
>>> +++ b/drivers/media/usb/em28xx/em28xx-i2c.c
>>> @@ -80,6 +80,9 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
>>>   		if (ret == 0x80 + len - 1)
>>>   			return len;
>>>   		if (ret == 0x94 + len - 1) {
>>> +			if (i2c_debug == 1)
>>> +				em28xx_warn("R05 returned 0x%02x: I2C timeout",
>>> +					    ret);
>>>   			return -ENXIO;
>>>   		}
>>>   		if (ret < 0) {
>>> @@ -124,6 +127,9 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
>>>   		if (ret == 0x84 + len - 1)
>>>   			break;
>>>   		if (ret == 0x94 + len - 1) {
>>> +			if (i2c_debug == 1)
>>> +				em28xx_warn("R05 returned 0x%02x: I2C timeout",
>>> +					    ret);
>>>   			return -ENXIO;
>>>   		}
>>>   		if (ret < 0) {
>>> @@ -203,6 +209,9 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
>>>   		if (ret == 0) /* success */
>>>   			return len;
>>>   		if (ret == 0x10) {
>>> +			if (i2c_debug == 1)
>>> +				em28xx_warn("I2C transfer timeout on writing to addr 0x%02x",
>>> +					    addr);
>>>   			return -ENXIO;
>>>   		}
>>>   		if (ret < 0) {
>>> @@ -263,8 +272,12 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
>>>   			    ret);
>>>   		return ret;
>>>   	}
>>> -	if (ret == 0x10)
>>> +	if (ret == 0x10) {
>>> +		if (i2c_debug == 1)
>>> +			em28xx_warn("I2C transfer timeout on writing to addr 0x%02x",
>>> +				    addr);
>>>   		return -ENXIO;
>>> +	}
>>>   
>>>   	em28xx_warn("unknown i2c error (status=%i)\n", ret);
>>>   	return -ETIMEDOUT;
>>> @@ -322,8 +335,12 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
>>>   	 */
>>>   	if (!ret)
>>>   		return len;
>>> -	else if (ret > 0)
>>> +	else if (ret > 0) {
>>> +		if (i2c_debug == 1)
>>> +			em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout",
>>> +				    ret);
>>>   		return -ENXIO;
>>> +	}
>>>   
>>>   	return ret;
>>>   	/*
>>> @@ -373,8 +390,12 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf,
>>>   	 */
>>>   	if (!ret)
>>>   		return len;
>>> -	else if (ret > 0)
>>> +	else if (ret > 0) {
>>> +		if (i2c_debug == 1)
>>> +			em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout",
>>> +				    ret);
>>>   		return -ENXIO;
>>> +	}
>>>   
>>>   	return ret;
>>>   	/*
>> The error description should be "I2C ACK error".
> Ok.
>
>> You are using (i2c_debug == 1) checks here, which should either be
>> changed to (i2c_debug > 0) in case of 3 debug levels.
> Actually, no. If you use i2c_debug = 2, you can't print anything on those
> routines, as otherwise it will be printed on a line that it would supposed
> to be a KERNEL_CONT message.
Hmm ok, so this is to avoid output format issues.
I remember that this is a bit tricky...
That's why I was using some ordinary printks without \n linebreaks.



  reply	other threads:[~2014-01-12 15:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10  8:33 [PATCH v2 0/3] em28xx: improve I2C code Mauro Carvalho Chehab
2014-01-10  8:33 ` [PATCH v2 1/3] [media] em28xx-i2c: Fix error code for I2C error transfers Mauro Carvalho Chehab
2014-01-11 12:29   ` Frank Schäfer
2014-01-11 20:10     ` Mauro Carvalho Chehab
2014-01-12 15:21       ` Frank Schäfer
2014-01-10  8:33 ` [PATCH v2 2/3] [media] em28xx: cleanup I2C debug messages Mauro Carvalho Chehab
2014-01-11 13:09   ` Frank Schäfer
2014-01-11 20:22     ` Mauro Carvalho Chehab
2014-01-12 15:27       ` Frank Schäfer
2014-01-10  8:33 ` [PATCH v2 3/3] [media] em28xx: add timeout debug information if i2c_debug enabled Mauro Carvalho Chehab
2014-01-11 13:14   ` Frank Schäfer
2014-01-11 20:27     ` Mauro Carvalho Chehab
2014-01-12 15:29       ` Frank Schäfer [this message]
2014-01-12 16:45         ` 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=52D2B4D6.2020806@googlemail.com \
    --to=fschaefer.oss@googlemail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=mchehab@infradead.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;
as well as URLs for NNTP newsgroup(s).