* [PATCH v2] usb: gadget: function: printer: Interface is disabled and returns error
@ 2020-06-30 5:44 qiang.zhang
2020-07-01 12:00 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: qiang.zhang @ 2020-06-30 5:44 UTC (permalink / raw)
To: balbi; +Cc: gregkh, linux-usb
From: Zqiang <qiang.zhang@windriver.com>
After the device is disconnected from the host side, the interface of
the device is reset. If the userspace operates the device again,
an error code should be returned.
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Zqiang <qiang.zhang@windriver.com>
---
drivers/usb/gadget/function/f_printer.c | 36 +++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 9c7ed2539ff7..2b45a61e4213 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -338,6 +338,11 @@ printer_open(struct inode *inode, struct file *fd)
spin_lock_irqsave(&dev->lock, flags);
+ if (dev->interface < 0) {
+ spin_unlock_irqrestore(&dev->lock, flags);
+ return -ENODEV;
+ }
+
if (!dev->printer_cdev_open) {
dev->printer_cdev_open = 1;
fd->private_data = dev;
@@ -430,6 +435,12 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
mutex_lock(&dev->lock_printer_io);
spin_lock_irqsave(&dev->lock, flags);
+ if (dev->interface < 0) {
+ spin_unlock_irqrestore(&dev->lock, flags);
+ mutex_unlock(&dev->lock_printer_io);
+ return -ENODEV;
+ }
+
/* We will use this flag later to check if a printer reset happened
* after we turn interrupts back on.
*/
@@ -561,6 +572,12 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
mutex_lock(&dev->lock_printer_io);
spin_lock_irqsave(&dev->lock, flags);
+ if (dev->interface < 0) {
+ spin_unlock_irqrestore(&dev->lock, flags);
+ mutex_unlock(&dev->lock_printer_io);
+ return -ENODEV;
+ }
+
/* Check if a printer reset happens while we have interrupts on */
dev->reset_printer = 0;
@@ -667,6 +684,13 @@ printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync)
inode_lock(inode);
spin_lock_irqsave(&dev->lock, flags);
+
+ if (dev->interface < 0) {
+ spin_unlock_irqrestore(&dev->lock, flags);
+ inode_unlock(inode);
+ return -ENODEV;
+ }
+
tx_list_empty = (likely(list_empty(&dev->tx_reqs)));
spin_unlock_irqrestore(&dev->lock, flags);
@@ -689,6 +713,13 @@ printer_poll(struct file *fd, poll_table *wait)
mutex_lock(&dev->lock_printer_io);
spin_lock_irqsave(&dev->lock, flags);
+
+ if (dev->interface < 0) {
+ spin_unlock_irqrestore(&dev->lock, flags);
+ mutex_unlock(&dev->lock_printer_io);
+ return EPOLLERR | EPOLLHUP;
+ }
+
setup_rx_reqs(dev);
spin_unlock_irqrestore(&dev->lock, flags);
mutex_unlock(&dev->lock_printer_io);
@@ -722,6 +753,11 @@ printer_ioctl(struct file *fd, unsigned int code, unsigned long arg)
spin_lock_irqsave(&dev->lock, flags);
+ if (dev->interface < 0) {
+ spin_unlock_irqrestore(&dev->lock, flags);
+ return -ENODEV;
+ }
+
switch (code) {
case GADGET_GET_PRINTER_STATUS:
status = (int)dev->printer_status;
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] usb: gadget: function: printer: Interface is disabled and returns error
2020-06-30 5:44 [PATCH v2] usb: gadget: function: printer: Interface is disabled and returns error qiang.zhang
@ 2020-07-01 12:00 ` Greg KH
2020-07-02 1:12 ` 回复: " Zhang, Qiang
2020-07-23 11:41 ` Felipe Balbi
0 siblings, 2 replies; 4+ messages in thread
From: Greg KH @ 2020-07-01 12:00 UTC (permalink / raw)
To: qiang.zhang; +Cc: balbi, linux-usb
On Tue, Jun 30, 2020 at 01:44:07PM +0800, qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
>
> After the device is disconnected from the host side, the interface of
> the device is reset. If the userspace operates the device again,
> an error code should be returned.
>
> Acked-by: Felipe Balbi <balbi@kernel.org>
When did Felipe ack this? I missed that, do you have a pointer to that
on lore.kernel.org somewhere?
> Signed-off-by: Zqiang <qiang.zhang@windriver.com>
> ---
> drivers/usb/gadget/function/f_printer.c | 36 +++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
What changed from v1? That always goes below the --- line.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* 回复: [PATCH v2] usb: gadget: function: printer: Interface is disabled and returns error
2020-07-01 12:00 ` Greg KH
@ 2020-07-02 1:12 ` Zhang, Qiang
2020-07-23 11:41 ` Felipe Balbi
1 sibling, 0 replies; 4+ messages in thread
From: Zhang, Qiang @ 2020-07-02 1:12 UTC (permalink / raw)
To: Greg KH; +Cc: balbi, linux-usb
Sorry Greg KH, please ignore this submission.
________________________________________
发件人: Greg KH <gregkh@linuxfoundation.org>
发送时间: 2020年7月1日 20:00
收件人: Zhang, Qiang
抄送: balbi@kernel.org; linux-usb@vger.kernel.org
主题: Re: [PATCH v2] usb: gadget: function: printer: Interface is disabled and returns error
On Tue, Jun 30, 2020 at 01:44:07PM +0800, qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
>
> After the device is disconnected from the host side, the interface of
> the device is reset. If the userspace operates the device again,
> an error code should be returned.
>
> Acked-by: Felipe Balbi <balbi@kernel.org>
When did Felipe ack this? I missed that, do you have a pointer to that
on lore.kernel.org somewhere?
> Signed-off-by: Zqiang <qiang.zhang@windriver.com>
> ---
> drivers/usb/gadget/function/f_printer.c | 36 +++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
What changed from v1? That always goes below the --- line.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] usb: gadget: function: printer: Interface is disabled and returns error
2020-07-01 12:00 ` Greg KH
2020-07-02 1:12 ` 回复: " Zhang, Qiang
@ 2020-07-23 11:41 ` Felipe Balbi
1 sibling, 0 replies; 4+ messages in thread
From: Felipe Balbi @ 2020-07-23 11:41 UTC (permalink / raw)
To: Greg KH, qiang.zhang; +Cc: linux-usb
[-- Attachment #1: Type: text/plain, Size: 579 bytes --]
Greg KH <gregkh@linuxfoundation.org> writes:
> On Tue, Jun 30, 2020 at 01:44:07PM +0800, qiang.zhang@windriver.com wrote:
>> From: Zqiang <qiang.zhang@windriver.com>
>>
>> After the device is disconnected from the host side, the interface of
>> the device is reset. If the userspace operates the device again,
>> an error code should be returned.
>>
>> Acked-by: Felipe Balbi <balbi@kernel.org>
>
> When did Felipe ack this? I missed that, do you have a pointer to that
> on lore.kernel.org somewhere?
yeah, I don't remember acking this either.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-23 11:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30 5:44 [PATCH v2] usb: gadget: function: printer: Interface is disabled and returns error qiang.zhang
2020-07-01 12:00 ` Greg KH
2020-07-02 1:12 ` 回复: " Zhang, Qiang
2020-07-23 11:41 ` Felipe Balbi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).