From: "Ji-Ze Hong \(Peter Hong\)" <hpeter@gmail.com>
To: peter_hong@fintek.com.tw, johan@kernel.org, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
"Ji-Ze Hong \(Peter Hong\)" <hpeter+linux_kernel@gmail.com>
Subject: [V9,1/4] USB: serial: f81232: fix interrupt worker not stop
Date: Tue, 30 Apr 2019 09:22:29 +0800 [thread overview]
Message-ID: <1556587352-19500-1-git-send-email-hpeter+linux_kernel@gmail.com> (raw)
The F81232 will use interrupt worker to handle MSR change.
This patch will fix the issue that interrupt work should stop
in close() and suspend().
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
---
v9:
1: change the sequence from patch index from 2 to 1.
2: using tty_port_initialized() to determinate port open state.
v8:
1: no change
v7:
1: first introduce to this series patch.
drivers/usb/serial/f81232.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 0dcdcb4b2cde..d43ec999bc5e 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -556,9 +556,12 @@ static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
static void f81232_close(struct usb_serial_port *port)
{
+ struct f81232_private *port_priv = usb_get_serial_port_data(port);
+
f81232_port_disable(port);
usb_serial_generic_close(port);
usb_kill_urb(port->interrupt_in_urb);
+ flush_work(&port_priv->interrupt_work);
}
static void f81232_dtr_rts(struct usb_serial_port *port, int on)
@@ -632,6 +635,40 @@ static int f81232_port_remove(struct usb_serial_port *port)
return 0;
}
+static int f81232_suspend(struct usb_serial *serial, pm_message_t message)
+{
+ struct usb_serial_port *port = serial->port[0];
+ struct f81232_private *port_priv = usb_get_serial_port_data(port);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i)
+ usb_kill_urb(port->read_urbs[i]);
+
+ usb_kill_urb(port->interrupt_in_urb);
+
+ if (port_priv)
+ flush_work(&port_priv->interrupt_work);
+
+ return 0;
+}
+
+static int f81232_resume(struct usb_serial *serial)
+{
+ struct usb_serial_port *port = serial->port[0];
+ int result;
+
+ if (tty_port_initialized(&port->port)) {
+ result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
+ if (result) {
+ dev_err(&port->dev, "submit interrupt urb failed: %d",
+ result);
+ return result;
+ }
+ }
+
+ return usb_serial_generic_resume(serial);
+}
+
static struct usb_serial_driver f81232_device = {
.driver = {
.owner = THIS_MODULE,
@@ -655,6 +692,8 @@ static struct usb_serial_driver f81232_device = {
.read_int_callback = f81232_read_int_callback,
.port_probe = f81232_port_probe,
.port_remove = f81232_port_remove,
+ .suspend = f81232_suspend,
+ .resume = f81232_resume,
};
static struct usb_serial_driver * const serial_drivers[] = {
WARNING: multiple messages have this Message-ID (diff)
From: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>
To: peter_hong@fintek.com.tw, johan@kernel.org, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
"Ji-Ze Hong (Peter Hong)" <hpeter+linux_kernel@gmail.com>
Subject: [PATCH V9 1/4] USB: serial: f81232: fix interrupt worker not stop
Date: Tue, 30 Apr 2019 09:22:29 +0800 [thread overview]
Message-ID: <1556587352-19500-1-git-send-email-hpeter+linux_kernel@gmail.com> (raw)
Message-ID: <20190430012229.5yFoxu4g1MmNiCdVqPTsCcpmFt1mB6GQ0AzN6wv93JA@z> (raw)
The F81232 will use interrupt worker to handle MSR change.
This patch will fix the issue that interrupt work should stop
in close() and suspend().
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
---
v9:
1: change the sequence from patch index from 2 to 1.
2: using tty_port_initialized() to determinate port open state.
v8:
1: no change
v7:
1: first introduce to this series patch.
drivers/usb/serial/f81232.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 0dcdcb4b2cde..d43ec999bc5e 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -556,9 +556,12 @@ static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
static void f81232_close(struct usb_serial_port *port)
{
+ struct f81232_private *port_priv = usb_get_serial_port_data(port);
+
f81232_port_disable(port);
usb_serial_generic_close(port);
usb_kill_urb(port->interrupt_in_urb);
+ flush_work(&port_priv->interrupt_work);
}
static void f81232_dtr_rts(struct usb_serial_port *port, int on)
@@ -632,6 +635,40 @@ static int f81232_port_remove(struct usb_serial_port *port)
return 0;
}
+static int f81232_suspend(struct usb_serial *serial, pm_message_t message)
+{
+ struct usb_serial_port *port = serial->port[0];
+ struct f81232_private *port_priv = usb_get_serial_port_data(port);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i)
+ usb_kill_urb(port->read_urbs[i]);
+
+ usb_kill_urb(port->interrupt_in_urb);
+
+ if (port_priv)
+ flush_work(&port_priv->interrupt_work);
+
+ return 0;
+}
+
+static int f81232_resume(struct usb_serial *serial)
+{
+ struct usb_serial_port *port = serial->port[0];
+ int result;
+
+ if (tty_port_initialized(&port->port)) {
+ result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
+ if (result) {
+ dev_err(&port->dev, "submit interrupt urb failed: %d",
+ result);
+ return result;
+ }
+ }
+
+ return usb_serial_generic_resume(serial);
+}
+
static struct usb_serial_driver f81232_device = {
.driver = {
.owner = THIS_MODULE,
@@ -655,6 +692,8 @@ static struct usb_serial_driver f81232_device = {
.read_int_callback = f81232_read_int_callback,
.port_probe = f81232_port_probe,
.port_remove = f81232_port_remove,
+ .suspend = f81232_suspend,
+ .resume = f81232_resume,
};
static struct usb_serial_driver * const serial_drivers[] = {
--
2.7.4
next reply other threads:[~2019-04-30 1:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 1:22 Ji-Ze Hong (Peter Hong) [this message]
2019-04-30 1:22 ` [PATCH V9 1/4] USB: serial: f81232: fix interrupt worker not stop Ji-Ze Hong (Peter Hong)
2019-04-30 1:22 ` [V9,4/4] USB: serial: f81232: implement break control Ji-Ze Hong (Peter Hong)
2019-04-30 1:22 ` [PATCH V9 4/4] " Ji-Ze Hong (Peter Hong)
2019-05-03 6:59 ` [V9,4/4] " Johan Hovold
2019-05-03 6:59 ` [PATCH V9 4/4] " Johan Hovold
2019-05-06 2:52 ` [V9,4/4] " Ji-Ze Hong (Peter Hong)
2019-05-06 2:52 ` [PATCH V9 4/4] " Ji-Ze Hong (Peter Hong)
2019-05-07 9:16 ` Johan Hovold
-- strict thread matches above, loose matches on Subject: below --
2019-04-30 1:22 [V9,2/4] USB: serial: f81232: clear overrun flag Ji-Ze Hong (Peter Hong)
2019-04-30 1:22 ` [PATCH V9 2/4] " Ji-Ze Hong (Peter Hong)
2019-04-30 1:22 [V9,3/4] USB: serial: f81232: add high baud rate support Ji-Ze Hong (Peter Hong)
2019-04-30 1:22 ` [PATCH V9 3/4] " Ji-Ze Hong (Peter Hong)
2019-05-03 6:53 [V9,1/4] USB: serial: f81232: fix interrupt worker not stop Johan Hovold
2019-05-03 6:53 ` [PATCH V9 1/4] " Johan Hovold
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=1556587352-19500-1-git-send-email-hpeter+linux_kernel@gmail.com \
--to=hpeter@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpeter+linux_kernel@gmail.com \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter_hong@fintek.com.tw \
/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.