All of lore.kernel.org
 help / color / mirror / Atom feed
From: Timo Kokkonen <timo.t.kokkonen@iki.fi>
To: Sean Young <sean@mess.org>
Cc: linux-omap@vger.kernel.org, linux-media@vger.kernel.org
Subject: Re: [PATCHv2 1/2] media: rc: Introduce RX51 IR transmitter driver
Date: Mon, 13 Aug 2012 22:41:09 +0300	[thread overview]
Message-ID: <50295855.3020707@iki.fi> (raw)
In-Reply-To: <20120813183647.GA32660@pequod.mess.org>

On 08/13/12 21:36, Sean Young wrote:
> On Fri, Aug 10, 2012 at 01:16:36PM +0300, Timo Kokkonen wrote:
>> +static ssize_t lirc_rx51_write(struct file *file, const char *buf,
>> +			  size_t n, loff_t *ppos)
>> +{
>> +	int count, i;
>> +	struct lirc_rx51 *lirc_rx51 = file->private_data;
>> +
>> +	if (n % sizeof(int))
>> +		return -EINVAL;
>> +
>> +	count = n / sizeof(int);
>> +	if ((count > WBUF_LEN) || (count % 2 == 0))
>> +		return -EINVAL;
>> +
>> +	/* Wait any pending transfers to finish */
>> +	wait_event_interruptible(lirc_rx51->wqueue, lirc_rx51->wbuf_index < 0);
> 
> If a signal arrives then this could return ERESTARTSYS and the condition
> might not have evaluated to true.

hmm.. The whole point of it is to wait if for any possibly pending
transfers to finish. However, we don't allow the device to be opened
more than once and parallel access doesn't make much sense here anyway.
Only way we can end up waiting here is that the process is having
multiple threads writing to the same file descriptor (or has inherited
it from its parent), which doesn't make any sense.

I think we could simply return -EBUSY in case previous transfer is still
going on. I don't see any reason why we should wait here.

> 
>> +
>> +	if (copy_from_user(lirc_rx51->wbuf, buf, n))
>> +		return -EFAULT;
>> +
>> +	/* Sanity check the input pulses */
>> +	for (i = 0; i < count; i++)
>> +		if (lirc_rx51->wbuf[i] < 0)
>> +			return -EINVAL;
>> +
>> +	init_timing_params(lirc_rx51);
>> +	if (count < WBUF_LEN)
>> +		lirc_rx51->wbuf[count] = -1; /* Insert termination mark */
>> +
>> +	/*
>> +	 * Adjust latency requirements so the device doesn't go in too
>> +	 * deep sleep states
>> +	 */
>> +	lirc_rx51->pdata->set_max_mpu_wakeup_lat(lirc_rx51->dev, 50);
>> +
>> +	lirc_rx51_on(lirc_rx51);
>> +	lirc_rx51->wbuf_index = 1;
>> +	pulse_timer_set_timeout(lirc_rx51, lirc_rx51->wbuf[0]);
>> +
>> +	/*
>> +	 * Don't return back to the userspace until the transfer has
>> +	 * finished
>> +	 */
>> +	wait_event_interruptible(lirc_rx51->wqueue, lirc_rx51->wbuf_index < 0);
> 
> same here.
> 
> BTW so the semantics for lirc write() are that they complete when the 
> data has been transmitted. This doesn't play well with signals, polling 
> or non-blocking I/O. Is this deliberate or historical?
> 
> I guess a lirc write() handler should ignore signals completely.
> 

I'll change it to wait_event_timeout instead.

>> +
>> +struct platform_driver lirc_rx51_platform_driver = {
>> +	.probe		= lirc_rx51_probe,
>> +	.remove		= __exit_p(lirc_rx51_remove),
>> +	.suspend	= lirc_rx51_suspend,
>> +	.resume		= lirc_rx51_resume,
>> +	.remove		= __exit_p(lirc_rx51_remove),
> 
> .remove is here twice.

hehe.. I remember I was supposed to write a patch for that five years
ago but I was busy :) Thanks for your review. Will send round three.

-Timo

  reply	other threads:[~2012-08-13 19:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 10:16 [PATCH 0/2] Add Nokia N900 (RX51) IR diode support Timo Kokkonen
2012-08-10 10:16 ` [PATCHv2 1/2] media: rc: Introduce RX51 IR transmitter driver Timo Kokkonen
2012-08-10 11:06   ` Timo Kokkonen
2012-08-10 11:31     ` Timo Kokkonen
2012-08-13 18:36   ` Sean Young
2012-08-13 19:41     ` Timo Kokkonen [this message]
2012-08-10 10:16 ` [PATCHv2 2/2] ARM: mach-omap2: board-rx51-peripherals: Add lirc-rx51 data Timo Kokkonen
2012-08-13 18:05 ` [PATCHv2 0/2] Add Nokia N900 (RX51) IR diode support Timo Kokkonen

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=50295855.3020707@iki.fi \
    --to=timo.t.kokkonen@iki.fi \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=sean@mess.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.