From: Mathieu OTHACEHE <m.othacehe@gmail.com>
To: johan@kernel.org
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Mathieu OTHACEHE <m.othacehe@gmail.com>
Subject: [PATCH 30/36] usb: serial: ti_usb_3410_5052: Remove backpointer in ti_port
Date: Thu, 12 May 2016 10:49:02 +0200 [thread overview]
Message-ID: <1463042948-12205-31-git-send-email-m.othacehe@gmail.com> (raw)
In-Reply-To: <1463042948-12205-1-git-send-email-m.othacehe@gmail.com>
In ti_port structure, remove useless tp_tdev backpointer.
Also remove pointer to usb_serial_port.
Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
drivers/usb/serial/ti_usb_3410_5052.c | 44 ++++++++++++++++-------------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 1d8d8ef..ae77084 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -274,8 +274,6 @@ struct ti_port {
u8 tp_shadow_mcr;
u8 tp_uart_mode; /* 232 or 485 modes */
unsigned int tp_uart_base_addr;
- struct ti_device *tp_tdev;
- struct usb_serial_port *tp_port;
spinlock_t tp_lock;
};
@@ -304,8 +302,8 @@ static int ti_tiocmset(struct tty_struct *tty,
static void ti_break(struct tty_struct *tty, int break_state);
static void ti_interrupt_callback(struct urb *urb);
-static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
-static int ti_get_lsr(struct ti_port *tport, u8 *lsr);
+static int ti_set_mcr(struct usb_serial_port *port, unsigned int mcr);
+static int ti_get_lsr(struct usb_serial_port *port, u8 *lsr);
static void ti_handle_new_msr(struct usb_serial_port *port, u8 msr);
static int ti_download_firmware(struct usb_serial *serial);
@@ -631,6 +629,7 @@ static void ti_release(struct usb_serial *serial)
static int ti_port_probe(struct usb_serial_port *port)
{
struct ti_port *tport;
+ struct ti_device *tdev;
tport = kzalloc(sizeof(*tport), GFP_KERNEL);
if (!tport)
@@ -642,10 +641,9 @@ static int ti_port_probe(struct usb_serial_port *port)
else
tport->tp_uart_base_addr = TI_UART2_BASE_ADDR;
- tport->tp_port = port;
- tport->tp_tdev = usb_get_serial_data(port->serial);
+ tdev = usb_get_serial_data(port->serial);
- if (tport->tp_tdev->td_rs485_only)
+ if (tdev->td_rs485_only)
tport->tp_uart_mode = TI_UART_485_RECEIVER_DISABLED;
else
tport->tp_uart_mode = TI_UART_232;
@@ -672,8 +670,8 @@ static int ti_port_remove(struct usb_serial_port *port)
static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
{
struct ti_port *tport = usb_get_serial_port_data(port);
+ struct ti_device *tdev = usb_get_serial_data(port->serial);
struct usb_serial *serial = port->serial;
- struct ti_device *tdev;
struct urb *urb;
int port_number;
int status;
@@ -683,8 +681,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
TI_PIPE_TIMEOUT_ENABLE |
(TI_TRANSFER_TIMEOUT << 2));
- tdev = tport->tp_tdev;
-
/* only one open on any port on a device at a time */
if (mutex_lock_interruptible(&tdev->td_open_close_lock))
return -ERESTARTSYS;
@@ -804,11 +800,11 @@ static void ti_close(struct usb_serial_port *port)
/* if mutex_lock is interrupted, continue anyway */
do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock);
- --tport->tp_tdev->td_open_port_count;
- if (tport->tp_tdev->td_open_port_count <= 0) {
+ tdev->td_open_port_count--;
+ if (tdev->td_open_port_count <= 0) {
/* last port is closed, shut down interrupt urb */
usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
- tport->tp_tdev->td_open_port_count = 0;
+ tdev->td_open_port_count = 0;
}
if (do_unlock)
mutex_unlock(&tdev->td_open_close_lock);
@@ -816,11 +812,10 @@ static void ti_close(struct usb_serial_port *port)
static bool ti_tx_empty(struct usb_serial_port *port)
{
- struct ti_port *tport = usb_get_serial_port_data(port);
int ret;
u8 lsr;
- ret = ti_get_lsr(tport, &lsr);
+ ret = ti_get_lsr(port, &lsr);
if (!ret && !(lsr & TI_LSR_TX_EMPTY))
return false;
@@ -901,6 +896,7 @@ static void ti_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{
struct ti_port *tport = usb_get_serial_port_data(port);
+ struct ti_device *tdev = usb_get_serial_data(port->serial);
struct ti_uart_config *config;
tcflag_t cflag, iflag;
int baud;
@@ -995,7 +991,7 @@ static void ti_set_termios(struct tty_struct *tty,
baud = tty_get_baud_rate(tty);
if (!baud)
baud = 9600;
- if (tport->tp_tdev->td_is_3410)
+ if (tdev->td_is_3410)
config->wBaudRate = (TI_3410_BAUD_BASE + baud / 2) / baud;
else
config->wBaudRate = (TI_5052_BAUD_BASE + baud / 2) / baud;
@@ -1029,7 +1025,7 @@ static void ti_set_termios(struct tty_struct *tty,
else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
mcr |= TI_MCR_DTR | TI_MCR_RTS;
- status = ti_set_mcr(tport, mcr);
+ status = ti_set_mcr(port, mcr);
if (status) {
dev_err(&port->dev,
"cannot set modem control on port %d: %d\n",
@@ -1094,7 +1090,7 @@ static int ti_tiocmset(struct tty_struct *tty,
mcr &= ~TI_MCR_LOOP;
spin_unlock_irqrestore(&tport->tp_lock, flags);
- return ti_set_mcr(tport, mcr);
+ return ti_set_mcr(port, mcr);
}
@@ -1184,14 +1180,15 @@ exit:
status);
}
-static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
+static int ti_set_mcr(struct usb_serial_port *port, unsigned int mcr)
{
+ struct ti_port *tport = usb_get_serial_port_data(port);
unsigned long flags;
int status;
- status = ti_write_byte(tport->tp_port,
- tport->tp_uart_base_addr + TI_UART_OFFSET_MCR,
- TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr);
+ status = ti_write_byte(port,
+ tport->tp_uart_base_addr + TI_UART_OFFSET_MCR,
+ TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr);
spin_lock_irqsave(&tport->tp_lock, flags);
if (!status)
@@ -1202,10 +1199,9 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
}
-static int ti_get_lsr(struct ti_port *tport, u8 *lsr)
+static int ti_get_lsr(struct usb_serial_port *port, u8 *lsr)
{
int size, status;
- struct usb_serial_port *port = tport->tp_port;
int port_number = port->port_number;
struct ti_port_status *data;
--
2.8.2
next prev parent reply other threads:[~2016-05-12 8:54 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 8:48 [PATCH 00/36] usb: serial: ti_usb_3410_5052: clean driver Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 01/36] usb: serial: ti_usb_3410_5052: Remove useless comments Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 02/36] usb: serial: ti_usb_3410_5052: use __packed instead of __attribute__((packed)) Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 03/36] usb: serial: ti_usb_3410_5052: Remove ti_usb_3410_5052.h Mathieu OTHACEHE
2016-07-15 10:49 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 04/36] usb: serial: ti_usb_3410_5052: Use inline functions rather than macro Mathieu OTHACEHE
2016-05-12 12:00 ` Sergei Shtylyov
2016-07-15 10:50 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 05/36] usb: serial: ti_usb_3410_5052: Remove unused data structures Mathieu OTHACEHE
2016-07-15 10:53 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 06/36] usb: serial: ti_usb_3410_5052: Do not use __uX types Mathieu OTHACEHE
2016-07-15 11:03 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 07/36] usb: serial: ti_usb_3410_5052: Remove closing_wait module parameter Mathieu OTHACEHE
2016-07-15 11:08 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 08/36] usb: serial: ti_usb_3410_5052: Remove useless dev_dbg messages Mathieu OTHACEHE
2016-07-15 11:12 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 09/36] usb: serial: ti_usb_3410_5052: Use kzalloc instead of kmalloc Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 10/36] usb: serial: ti_usb_3410_5052: Remove useless NULL-testing Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 11/36] usb: serial: ti_usb_3410_5052: Use C_X macros instead of c_cflag manipulation Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 12/36] usb: serial: ti_usb_3410_5052: Use generic read/write callbacks Mathieu OTHACEHE
2016-07-15 11:19 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 13/36] usb: serial: ti_usb_3410_5052: Remove unused variables Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 14/36] usb: serial: ti_usb_3410_5052: Use macros instead of magic values Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 15/36] usb: serial: ti_usb_3410_5052: Remove in_sync and out_sync functions Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 16/36] usb: serial: ti_usb_3410_5052: Use bulk_out_size in TIOCGSERIAL Mathieu OTHACEHE
2016-07-15 11:27 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 17/36] usb: serial: ti_usb_3410_5052: Remove useless tty_wakeup Mathieu OTHACEHE
2016-07-15 11:33 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 18/36] usb: serial: ti_usb_3410_5052: Change ti_write_byte function arguments Mathieu OTHACEHE
2016-07-15 11:36 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 19/36] usb: serial: ti_usb_3410_5052: Do not modify interrupt context Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 20/36] usb: serial: ti_usb_3410_5052: Remove usb_serial pointer in ti_port Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 21/36] usb: serial: ti_usb_3410_5052: Use generic close function Mathieu OTHACEHE
2016-07-15 12:08 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 22/36] usb: serial: ti_usb_3410_5052: Change ti_get/set_serial_info function arguments Mathieu OTHACEHE
2016-07-15 12:09 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 23/36] usb: serial: ti_usb_3410_5052: Do not set shadow mcr in open callback Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 24/36] usb: serial: ti_usb_3410_5052: Use usb_serial_generic_open Mathieu OTHACEHE
2016-07-15 12:12 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 25/36] usb: serial: ti_usb_3410_5052: Check old_termios parameter in set_termios Mathieu OTHACEHE
2016-07-15 12:14 ` Johan Hovold
2016-05-12 8:48 ` [PATCH 26/36] usb: serial: ti_usb_3410_5052: Fix firmware downloading Mathieu OTHACEHE
2016-05-12 8:48 ` [PATCH 27/36] usb: serial: ti_usb_3410_5052: Standardize debug and error messages Mathieu OTHACEHE
2016-05-12 8:49 ` [PATCH 28/36] usb: serial: ti_usb_3410_5052: Use variables for vendor and product Mathieu OTHACEHE
2016-05-12 8:49 ` [PATCH 29/36] usb: serial: ti_usb_3410_5052: Set shadow msr before waking up waiters Mathieu OTHACEHE
2016-05-12 8:49 ` Mathieu OTHACEHE [this message]
2016-05-12 8:49 ` [PATCH 31/36] usb: serial: ti_usb_3410_5052: Use a mutex to protect shadow mcr Mathieu OTHACEHE
2016-05-12 8:49 ` [PATCH 32/36] usb: serial: ti_usb_3410_5052: Remove prefixes from private structures Mathieu OTHACEHE
2016-05-12 8:49 ` [PATCH 33/36] usb: serial: ti_usb_3410_5052: Add CMSPAR support Mathieu OTHACEHE
2016-05-12 8:49 ` [PATCH 34/36] usb: serial: ti_usb_3410_5052: Fix indentation problems Mathieu OTHACEHE
2016-05-12 8:49 ` [PATCH 35/36] usb: serial: ti_usb_3410_5052: Remove function prototypes Mathieu OTHACEHE
2016-07-15 12:18 ` Johan Hovold
2016-05-12 8:49 ` [PATCH 36/36] usb: serial: ti_usb_3410_5052: Add myself as an author Mathieu OTHACEHE
2016-07-15 10:48 ` [PATCH 00/36] usb: serial: ti_usb_3410_5052: clean driver Johan Hovold
2016-07-15 12:20 ` 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=1463042948-12205-31-git-send-email-m.othacehe@gmail.com \
--to=m.othacehe@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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
Powered by JetHome