Re: [PATCH] usb: serial: return -ENODEV if disconnected during TIOCMIWAIT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 04, 2016 at 09:09:55AM +0100, Oliver Neukum wrote:
> On Sun, 2016-01-03 at 17:22 +0100, Johan Hovold wrote:
> > On Mon, Dec 21, 2015 at 02:17:22PM +0100, Oliver Neukum wrote:
> > > Disconnecting a device is not just a hang up. The device is gone.
> > > We should tell user space the truth immediately.
> > 
> > I'm not sure about this one. The usb-serial drivers have always returned
> > -EIO on hangup, whatever the reason, and there's nothing wrong with
> > that implementation.
> > 
> > Also note that any further ioctls after returning will also fail with
> > -EIO.
> > 
> > I think it makes sense to just stick to -EIO here.
> 
> But write() is happy to return -ENODEV.

A disconnect during write() typically also sets errno to EIO (or isn't
detected at all if the buffer is small enough). Consecutive calls also
fail with -EIO.

We always return -ENODEV for usb-serial devices that do not have a bulk
out end-point though, but then the errno does not imply that the device
is gone but rather that the operation is not supported by the device.

You may also be "lucky" and have write return -ENODEV in case you get a
disconnect that has not been fully processed just before a first write
(that calls usb_submit_urb instead of cache the data). But this would be
the exception and not something that userspace should rely on.

And if the timing is slightly altered, the tty layer will again set
errno to -EIO.

> I'd say that -EIO is the error return of last resort. If we have
> anything specific to report we ought to use it. And if a device is
> gone, it is gone.  There is no use hiding it.

What errno is set to for a failing ioctl is entirely up to the driver,
and all tty drivers (but recently cdc-acm) returns -EIO on hangup, which
is perfectly fine.

Now, we could extend this long-since established behaviour, but I'm not
sure it's worth it given that any further calls using the hung up tty
device will also return with errno set to -EIO by the tty layer. And
this we can't easily change.

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux