diff mbox

[U-Boot,02/20] dm: i2c: sandbox: Add debugging to the speed limit

Message ID 1429555051-22335-3-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass April 20, 2015, 6:37 p.m. UTC
Print a debug() message with the I2C speed is exceeded.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/i2c/sandbox_i2c.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Heiko Schocher April 21, 2015, 5:04 a.m. UTC | #1
Hello Simon,

Am 20.04.2015 20:37, schrieb Simon Glass:
> Print a debug() message with the I2C speed is exceeded.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   drivers/i2c/sandbox_i2c.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
> index d6adc0f..621caec 100644
> --- a/drivers/i2c/sandbox_i2c.c
> +++ b/drivers/i2c/sandbox_i2c.c
> @@ -73,8 +73,10 @@ static int sandbox_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
>   	 * 400KHz for reads
>   	 */
>   	is_read = nmsgs > 1;
> -	if (i2c->speed_hz > (is_read ? 400000 : 100000))
> +	if (i2c->speed_hz > (is_read ? 400000 : 100000)) {
> +		debug("%s: Max speed exceeded\n", __func__);
>   		return -EINVAL;
> +	}

Why different speeds for reading/writing?

bye,
Heiko
>   	return ops->xfer(emul, msg, nmsgs);
>   }
>
>
Simon Glass April 23, 2015, 3:12 p.m. UTC | #2
Hi Heiko,

On 20 April 2015 at 23:04, Heiko Schocher <hs@denx.de> wrote:
> Hello Simon,
>
>
> Am 20.04.2015 20:37, schrieb Simon Glass:
>>
>> Print a debug() message with the I2C speed is exceeded.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>   drivers/i2c/sandbox_i2c.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
>> index d6adc0f..621caec 100644
>> --- a/drivers/i2c/sandbox_i2c.c
>> +++ b/drivers/i2c/sandbox_i2c.c
>> @@ -73,8 +73,10 @@ static int sandbox_i2c_xfer(struct udevice *bus, struct
>> i2c_msg *msg,
>>          * 400KHz for reads
>>          */
>>         is_read = nmsgs > 1;
>> -       if (i2c->speed_hz > (is_read ? 400000 : 100000))
>> +       if (i2c->speed_hz > (is_read ? 400000 : 100000)) {
>> +               debug("%s: Max speed exceeded\n", __func__);
>>                 return -EINVAL;
>> +       }
>
>
> Why different speeds for reading/writing?

This is just test code - in fact a later patch adds a flag to enable
it only when running tests. See test/dm/i2c.c.

Regards,
Simon
Heiko Schocher April 24, 2015, 5:14 a.m. UTC | #3
Hello Simon,

Am 23.04.2015 17:12, schrieb Simon Glass:
> Hi Heiko,
>
> On 20 April 2015 at 23:04, Heiko Schocher <hs@denx.de> wrote:
>> Hello Simon,
>>
>>
>> Am 20.04.2015 20:37, schrieb Simon Glass:
>>>
>>> Print a debug() message with the I2C speed is exceeded.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>    drivers/i2c/sandbox_i2c.c | 4 +++-
>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
>>> index d6adc0f..621caec 100644
>>> --- a/drivers/i2c/sandbox_i2c.c
>>> +++ b/drivers/i2c/sandbox_i2c.c
>>> @@ -73,8 +73,10 @@ static int sandbox_i2c_xfer(struct udevice *bus, struct
>>> i2c_msg *msg,
>>>           * 400KHz for reads
>>>           */
>>>          is_read = nmsgs > 1;
>>> -       if (i2c->speed_hz > (is_read ? 400000 : 100000))
>>> +       if (i2c->speed_hz > (is_read ? 400000 : 100000)) {
>>> +               debug("%s: Max speed exceeded\n", __func__);
>>>                  return -EINVAL;
>>> +       }
>>
>>
>> Why different speeds for reading/writing?
>
> This is just test code - in fact a later patch adds a flag to enable
> it only when running tests. See test/dm/i2c.c.

Ah, thanks for the clarification, so:

Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
Simon Glass May 4, 2015, 2:19 p.m. UTC | #4
On 23 April 2015 at 23:14, Heiko Schocher <hs@denx.de> wrote:
> Hello Simon,
>
>
> Am 23.04.2015 17:12, schrieb Simon Glass:
>>
>> Hi Heiko,
>>
>> On 20 April 2015 at 23:04, Heiko Schocher <hs@denx.de> wrote:
>>>
>>> Hello Simon,
>>>
>>>
>>> Am 20.04.2015 20:37, schrieb Simon Glass:
>>>>
>>>>
>>>> Print a debug() message with the I2C speed is exceeded.
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>> ---
>>>>
>>>>    drivers/i2c/sandbox_i2c.c | 4 +++-
>>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
>>>> index d6adc0f..621caec 100644
>>>> --- a/drivers/i2c/sandbox_i2c.c
>>>> +++ b/drivers/i2c/sandbox_i2c.c
>>>> @@ -73,8 +73,10 @@ static int sandbox_i2c_xfer(struct udevice *bus,
>>>> struct
>>>> i2c_msg *msg,
>>>>           * 400KHz for reads
>>>>           */
>>>>          is_read = nmsgs > 1;
>>>> -       if (i2c->speed_hz > (is_read ? 400000 : 100000))
>>>> +       if (i2c->speed_hz > (is_read ? 400000 : 100000)) {
>>>> +               debug("%s: Max speed exceeded\n", __func__);
>>>>                  return -EINVAL;
>>>> +       }
>>>
>>>
>>>
>>> Why different speeds for reading/writing?
>>
>>
>> This is just test code - in fact a later patch adds a flag to enable
>> it only when running tests. See test/dm/i2c.c.
>
>
> Ah, thanks for the clarification, so:
>
> Acked-by: Heiko Schocher <hs@denx.de>

Applied to u-boot-dm.
diff mbox

Patch

diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
index d6adc0f..621caec 100644
--- a/drivers/i2c/sandbox_i2c.c
+++ b/drivers/i2c/sandbox_i2c.c
@@ -73,8 +73,10 @@  static int sandbox_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
 	 * 400KHz for reads
 	 */
 	is_read = nmsgs > 1;
-	if (i2c->speed_hz > (is_read ? 400000 : 100000))
+	if (i2c->speed_hz > (is_read ? 400000 : 100000)) {
+		debug("%s: Max speed exceeded\n", __func__);
 		return -EINVAL;
+	}
 	return ops->xfer(emul, msg, nmsgs);
 }