mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Jonathan Corbet <corbet@lwn.net>,
	linux-media@vger.kernel.org,
	sakari.ailus@maxwell.research.nokia.com,
	linux-kernel@vger.kernel.org
Subject: What should poll() return when a device is unregistered ? (was "media: Media device node support")
Date: Mon, 22 Nov 2010 11:41:27 +0100	[thread overview]
Message-ID: <201011221141.27945.laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <201011221008.06852.hverkuil@xs4all.nl>

Hi Hans,

On Monday 22 November 2010 10:08:06 Hans Verkuil wrote:
> On Monday, November 22, 2010 00:35:54 Laurent Pinchart wrote:
> > Hi Jonathan,
> > 
> > I forgot to answer one of your comments.
> > 
> > On Wednesday 17 November 2010 01:31:15 Jonathan Corbet wrote:
> > 
> > [snip]
> > 
> > > > +static unsigned int media_poll(struct file *filp,
> > > > +			       struct poll_table_struct *poll)
> > > > +{
> > > > +	struct media_devnode *mdev = media_devnode_data(filp);
> > > > +
> > > > +	if (!mdev->fops->poll || !media_devnode_is_registered(mdev))
> > > > +		return DEFAULT_POLLMASK;
> > > > +	return mdev->fops->poll(filp, poll);
> > > > +}
> > > 
> > > If it's not registered, I would expect poll() to return an error.
> > 
> > Agreed. I'll return POLLERR | POLLHUP in that case. Is that fine with you
> > ?
> 
> When I looked at this for the core code I decided to just return POLLERR.

I've copied the usbdevfs code which returns POLLERR | POLLHUP when devices are 
disconnected.

> That seemed to be what the majority of other usb drivers do. ALSA returns
> POLLERR | POLLNVAL, by the way, which I think is a poor choice.

Indeed, POLLNVAL has a clear semantics that doesn't apply here.

> This doesn't really seem to be standardized :-(

CC'ing LKML with the question.

POLLERR | POLLHUP and POLLERR won't make a difference to select(), but we 
should still standardize on a poll() return code when devices are unregistered 
and/or - for hot-pluggable devices - disconnected (for V4L devices 
unregistered usually means disconnected) ?

-- 
Regards,

Laurent Pinchart

       reply	other threads:[~2010-11-22 10:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1285241696-16826-1-git-send-email-laurent.pinchart@ideasonboard.com>
     [not found] ` <201011220035.55615.laurent.pinchart@ideasonboard.com>
     [not found]   ` <201011221008.06852.hverkuil@xs4all.nl>
2010-11-22 10:41     ` Laurent Pinchart [this message]
2010-11-22 11:36       ` Hans Verkuil
2010-11-22 12:51         ` Andy Walls
2010-11-22 16:19           ` Laurent Pinchart
2010-11-22 23:00             ` Andy Walls

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=201011221141.27945.laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=corbet@lwn.net \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@maxwell.research.nokia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®