public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com,
	clemens@ladisch.de, sakari.ailus@maxwell.research.nokia.com
Subject: Re: [RFC/PATCH v7 01/12] media: Media device node support
Date: Thu, 6 Jan 2011 15:46:12 -0800	[thread overview]
Message-ID: <20110106234612.GA2097@suse.de> (raw)
In-Reply-To: <201101070027.11150.hverkuil@xs4all.nl>

On Fri, Jan 07, 2011 at 12:27:11AM +0100, Hans Verkuil wrote:
> On Thursday, January 06, 2011 23:19:12 Greg KH wrote:
> 
> <snip>
> 
> > > > > +static ssize_t media_read(struct file *filp, char __user *buf,
> > > > > +		size_t sz, loff_t *off)
> > > > > +{
> > > > > +	struct media_devnode *mdev = media_devnode_data(filp);
> > > > > +
> > > > > +	if (!mdev->fops->read)
> > > > > +		return -EINVAL;
> > > > > +	if (!media_devnode_is_registered(mdev))
> > > > > +		return -EIO;
> > > > 
> > > > How could this happen?
> > > 
> > > This can happen when a USB device is disconnected for instance.
> > 
> > But what's to keep that from happening on the next line as well?
> 
> Nothing.
> 
> > That
> > doesn't seem like a check you can ever be sure about, so I wouldn't do
> > it at all.
> 
> Actually, there is a reason why this was done for v4l (and now the media
> API): typically, once a USB disconnect happens V4L drivers will call
> video_unregister_device() which calls device_unregister. Afterwards the
> device node should reject any new file operations except for release().
> 
> Obviously, this check can be done in the driver as well, but doing this
> check in the V4L core has the advantage of 1) consistent return codes and
> 2) drivers no longer have to check.
> 
> Of course, since the disconnect can happen at any time drivers still need
> to be able to handle errors from the USB subsystem due to disconnects, but
> that is something they always have to do.
> 
> > 
> > > > And are you sure -EIO is correct?
> > > 
> > > -ENXIO is probably better (I always confuse that with -ENODEV).
> 
> I wondered why V4L uses -EIO and I think it is related to the V4L2 specification
> of the read() function:
> 
> EIO
> I/O error. This indicates some hardware problem or a failure to communicate with
> a remote device (USB camera etc.).
> 
> Well, I guess a disconnect can be seen as a failure to communicate :-)
> 
> I think that ENODEV is much better. After all, there is no device
> anymore after a disconnect.
> 
> Is there some standard for this?

I've always thought that -ENODEV was good for when the device
disappeared.

thanks,

greg k-h

  reply	other threads:[~2011-01-06 23:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 11:36 [RFC/PATCH v7 00/12] Media controller (core and V4L2) Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 01/12] media: Media device node support Laurent Pinchart
2010-12-23  3:32   ` Greg KH
2010-12-24 11:59     ` Laurent Pinchart
2011-01-06 22:19       ` Greg KH
2011-01-06 23:27         ` Hans Verkuil
2011-01-06 23:46           ` Greg KH [this message]
2011-01-10 14:09         ` Laurent Pinchart
2010-12-23  3:34   ` Greg KH
2010-12-20 11:36 ` [RFC/PATCH v7 02/12] media: Media device Laurent Pinchart
2010-12-23  3:33   ` Greg KH
2010-12-24 12:01     ` Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 03/12] media: Entities, pads and links Laurent Pinchart
2010-12-21 16:22   ` Hans Verkuil
2010-12-23  9:05     ` Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 04/12] media: Entity graph traversal Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 05/12] media: Reference count and power handling Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 06/12] media: Media device information query Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 07/12] media: Entities, pads and links enumeration Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 08/12] media: Links setup Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 09/12] media: Pipelines and media streams Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 10/12] v4l: Add a media_device pointer to the v4l2_device structure Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 11/12] v4l: Make video_device inherit from media_entity Laurent Pinchart
2010-12-20 11:36 ` [RFC/PATCH v7 12/12] v4l: Make v4l2_subdev " Laurent Pinchart
  -- strict thread matches above, loose matches on Subject: below --
2011-01-07  0:24 [RFC/PATCH v7 01/12] media: Media device node support Andy Walls
2011-01-07  0:31 ` Greg KH
2011-01-07  1:04 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=20110106234612.GA2097@suse.de \
    --to=gregkh@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=clemens@ladisch.de \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --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