From: Hans Verkuil <hverkuil@xs4all.nl>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org, Dinesh.Ram@cern.ch,
edubezval@gmail.com, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv2 06/11] si4713: Added the USB driver for Si4713
Date: Fri, 13 Dec 2013 14:26:24 +0100 [thread overview]
Message-ID: <52AB0B00.5090202@xs4all.nl> (raw)
In-Reply-To: <20131209134737.1a2f19c4@samsung.com>
Hi Mauro,
On 12/09/2013 04:47 PM, Mauro Carvalho Chehab wrote:
> Em Fri, 6 Dec 2013 11:17:09 +0100
> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
>
>> From: Dinesh Ram <Dinesh.Ram@cern.ch>
>>
>> This is the USB driver for the Silicon Labs development board.
>> It contains the Si4713 FM transmitter chip.
>>
>> Signed-off-by: Dinesh Ram <dinesh.ram@cern.ch>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>> Tested-by: Eduardo Valentin <edubezval@gmail.com>
>> Acked-by: Eduardo Valentin <edubezval@gmail.com>
>> ---
>> drivers/media/radio/si4713/Kconfig | 15 +
>> drivers/media/radio/si4713/Makefile | 1 +
>> drivers/media/radio/si4713/radio-usb-si4713.c | 540 ++++++++++++++++++++++++++
>> 3 files changed, 556 insertions(+)
>> create mode 100644 drivers/media/radio/si4713/radio-usb-si4713.c
>>
<snip>
>> diff --git a/drivers/media/radio/si4713/radio-usb-si4713.c b/drivers/media/radio/si4713/radio-usb-si4713.c
>> new file mode 100644
>> index 0000000..d978844
>> --- /dev/null
>> +++ b/drivers/media/radio/si4713/radio-usb-si4713.c
<snip>
>> + if (time_is_before_jiffies(until_jiffies))
>> + return -EIO;
>
> According with include/linux/jiffies.h:
>
> time_is_before_jiffies(a) return true if a is before jiffies.
>
> I suspect that you want to do just the opposite here: to return -EIO if
> you passed the timeout given by until_jiffies.
Don't confuse me :-)
Using before_jiffies is correct. If 'until_jiffies < jiffies', then we give up
and return -EIO. So until_jiffies is before jiffies. Or in other words:
jiffies is after until_jiffies.
I think that a macro like "jiffies_is_after_time(a)" would be easier to
understand.
<snip>
>> +static int si4713_i2c_read(struct si4713_usb_device *radio, char *data, int len)
>> +{
>> + unsigned long until_jiffies = jiffies + usecs_to_jiffies(USB_RESP_TIMEOUT) + 1;
>> + int retval;
>> +
>> + /* receive the response */
>> + for (;;) {
>> + retval = usb_control_msg(radio->usbdev,
>> + usb_rcvctrlpipe(radio->usbdev, 0),
>> + 0x01, 0xa1, 0x033f, 0, radio->buffer,
>> + BUFFER_LENGTH, USB_TIMEOUT);
>> + if (retval < 0)
>> + return retval;
>> +
>> + /*
>> + * Check that we get a valid reply back (buffer[1] == 0) and
>> + * that CTS is set before returning, otherwise we wait and try
>> + * again. The i2c driver also does the CTS check, but the timeouts
>> + * used there are much too small for this USB driver, so we wait
>> + * for it here.
>> + */
>> + if (radio->buffer[1] == 0 && (radio->buffer[2] & SI4713_CTS)) {
>> + memcpy(data, radio->buffer + 2, len);
>> + return 0;
>> + }
>> + if (time_is_before_jiffies(until_jiffies)) {
>> + /* Zero the status value, ensuring CTS isn't set */
>> + data[0] = 0;
>> + return 0;
>> + }
>
> Again, I think that the timeout condition is wrong here.
Ditto, the code is correct.
>
>> + msleep(3);
>> + }
>> +}
Regards,
Hans
next prev parent reply other threads:[~2013-12-13 13:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 10:17 [PATCHv2 00/11] si4713: add si4713 usb driver Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 01/11] si4713: Reorganized drivers/media/radio directory Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 02/11] si4713: Modified i2c driver to handle cases where interrupts are not used Hans Verkuil
2013-12-09 15:58 ` Mauro Carvalho Chehab
2013-12-06 10:17 ` [PATCHv2 03/11] si4713: Reorganized includes in si4713.c/h Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 04/11] si4713: Bug fix for si4713_tx_tune_power() method in the i2c driver Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 05/11] si4713: HID blacklist Si4713 USB development board Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 06/11] si4713: Added the USB driver for Si4713 Hans Verkuil
2013-12-09 15:47 ` Mauro Carvalho Chehab
2013-12-09 16:22 ` Hans Verkuil
2013-12-13 13:26 ` Hans Verkuil [this message]
2013-12-06 10:17 ` [PATCHv2 07/11] si4713: Added MAINTAINERS entry for radio-usb-si4713 driver Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 08/11] si4713: move supply list to si4713_platform_data Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 09/11] si4713: si4713_set_rds_radio_text overwrites terminating \0 Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 10/11] si4713: print product number Hans Verkuil
2013-12-06 10:17 ` [PATCHv2 11/11] si4713: coding style cleanups Hans Verkuil
2013-12-06 13:26 ` edubezval
2013-12-09 15:51 ` Mauro Carvalho Chehab
2013-12-09 16:17 ` Hans Verkuil
2013-12-09 18:37 ` Mauro Carvalho Chehab
2013-12-09 15:59 ` [PATCHv2 00/11] si4713: add si4713 usb driver 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=52AB0B00.5090202@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=Dinesh.Ram@cern.ch \
--cc=edubezval@gmail.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.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 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.