All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ellen Wang <ellen@cumulusnetworks.com>
To: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>,
	borneo.antonio@gmail.com, dbarksdale@uplogix.com,
	jkosina@suse.cz, linux-input@vger.kernel.org,
	linux-i2c@vger.kernel.org
Subject: Re: [PATCH v2] HID: cp2112: support large i2c transfers in hid-cp2112
Date: Fri, 10 Jul 2015 13:18:42 -0700	[thread overview]
Message-ID: <55A028A2.3040204@cumulusnetworks.com> (raw)
In-Reply-To: <559E2BA6.4020904@linaro.org>

On 07/09/2015 01:07 AM, Vaibhav Hiremath wrote:
> ...
>>>> +        count += ret;
>>>> +        if (count > msgs->len) {
>>>> +            /*
>>>> +             * The hardware returned too much data.
>>>> +             * This is mostly harmless because cp2112_read()
>>>> +             * has a limit check so didn't overrun our
>>>> +             * buffer.  Nevertheless, we return an error
>>>> +             * because something is seriously wrong and
>>>> +             * it shouldn't go unnoticed.
>>>> +             */
>>>> +            hid_err(hdev, "long read: %d > %zd\n",
>>>> +                ret, msgs->len - count + ret);
>>>
>>> You may want to take another look here.
>>> 'ret' will be either,
>>>
>>>      - ret = msgs->len
>>>          Not applicable
>>>      - ret > msgs->len
>>>          (count > msgs->len) will happen in one single
>>>          iteration, and will
>>>      - ret < msgs->len
>>>          (count > msgs->len) will happen in multiple iterations
>>>          where count keeps incrementing based on ret
>>>
>>> In the 2 scenarios above, I believe you would want to show,
>>>
>>>      actual read bytes > requested read bytes
>>>
>>>
>>> Am I missing something here?
>>
>> (count > msgs->len) should never happen, so there's really no predicting
>> it.  Or do you mean something else?
>>
>
> I meant the message which you are printing above seems wrong to me.

It does print the size of the read request.  I guess I could have 
written it as msgs->len - (count - ret).

Or I'm still missing what you mean.

      reply	other threads:[~2015-07-10 20:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 10:25 [PATCH v2] HID: cp2112: support large i2c transfers in hid-cp2112 Ellen Wang
     [not found] ` <1436351118-3360-1-git-send-email-ellen-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-07-08 12:07   ` Vaibhav Hiremath
     [not found]     ` <559D126B.6050505-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-07-08 18:08       ` Ellen Wang
2015-07-09  8:07         ` Vaibhav Hiremath
2015-07-10 20:18           ` Ellen Wang [this message]

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=55A028A2.3040204@cumulusnetworks.com \
    --to=ellen@cumulusnetworks.com \
    --cc=borneo.antonio@gmail.com \
    --cc=dbarksdale@uplogix.com \
    --cc=jkosina@suse.cz \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=vaibhav.hiremath@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.