linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Fabian Frederick <fabf@skynet.be>,
	Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>,
	Jiri Slaby <jslaby@suse.cz>,
	linux-serial@vger.kernel.org
Subject: [PATCH 06/13 linux-next] TTY: jsm: use container_of to resolve jsm_channel from uart_port
Date: Sun,  5 Oct 2014 19:01:07 +0200	[thread overview]
Message-ID: <1412528475-1449-7-git-send-email-fabf@skynet.be> (raw)
In-Reply-To: <1412528475-1449-1-git-send-email-fabf@skynet.be>

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 drivers/tty/serial/jsm/jsm_tty.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 3e5c156..8814680 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -77,7 +77,8 @@ static unsigned int jsm_tty_tx_empty(struct uart_port *port)
 static unsigned int jsm_tty_get_mctrl(struct uart_port *port)
 {
 	int result;
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
 
@@ -98,7 +99,8 @@ static unsigned int jsm_tty_get_mctrl(struct uart_port *port)
  */
 static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
 
@@ -133,7 +135,8 @@ static void jsm_tty_write(struct uart_port *port)
 
 static void jsm_tty_start_tx(struct uart_port *port)
 {
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
 
@@ -145,7 +148,8 @@ static void jsm_tty_start_tx(struct uart_port *port)
 
 static void jsm_tty_stop_tx(struct uart_port *port)
 {
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
 
@@ -157,7 +161,8 @@ static void jsm_tty_stop_tx(struct uart_port *port)
 static void jsm_tty_send_xchar(struct uart_port *port, char ch)
 {
 	unsigned long lock_flags;
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 	struct ktermios *termios;
 
 	spin_lock_irqsave(&port->lock, lock_flags);
@@ -172,7 +177,8 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)
 
 static void jsm_tty_stop_rx(struct uart_port *port)
 {
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	channel->ch_bd->bd_ops->disable_receiver(channel);
 }
@@ -180,7 +186,8 @@ static void jsm_tty_stop_rx(struct uart_port *port)
 static void jsm_tty_break(struct uart_port *port, int break_state)
 {
 	unsigned long lock_flags;
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	spin_lock_irqsave(&port->lock, lock_flags);
 	if (break_state == -1)
@@ -194,7 +201,8 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
 static int jsm_tty_open(struct uart_port *port)
 {
 	struct jsm_board *brd;
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 	struct ktermios *termios;
 
 	/* Get board pointer from our array of majors we have allocated */
@@ -273,7 +281,8 @@ static void jsm_tty_close(struct uart_port *port)
 {
 	struct jsm_board *bd;
 	struct ktermios *ts;
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	jsm_dbg(CLOSE, &channel->ch_bd->pci_dev, "start\n");
 
@@ -307,7 +316,8 @@ static void jsm_tty_set_termios(struct uart_port *port,
 				 struct ktermios *old_termios)
 {
 	unsigned long lock_flags;
-	struct jsm_channel *channel = (struct jsm_channel *)port;
+	struct jsm_channel *channel =
+		container_of(port, struct jsm_channel, uart_port);
 
 	spin_lock_irqsave(&port->lock, lock_flags);
 	channel->ch_c_cflag	= termios->c_cflag;
-- 
1.9.1


  parent reply	other threads:[~2014-10-05 17:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-05 17:01 [PATCH 00/13 linux-next] drivers/tty: use container_of where possible Fabian Frederick
2014-10-05 17:01 ` [PATCH 01/13 linux-next] serial: use container_of to resolve uart_sio_port from uart_port Fabian Frederick
2014-10-05 17:01 ` [PATCH 02/13 linux-next] serial: sa1100: use container_of to resolve sa1100_port " Fabian Frederick
2014-10-05 17:01 ` [PATCH 03/13 linux-next] serial: use container_of to resolve uart_ip22zilog_port " Fabian Frederick
2014-10-05 17:01 ` [PATCH 04/13 linux-next] serial: mpsc: use container_of to resolve mpsc_port_info " Fabian Frederick
2014-10-05 17:01 ` [PATCH 05/13 linux-next] serial: cpm_uart: use container_of to resolve uart_cpm_port " Fabian Frederick
2014-10-05 17:01 ` Fabian Frederick [this message]
2014-10-05 17:01 ` [PATCH 07/13 linux-next] tty: use container_of to resolve uart_pmac_port " Fabian Frederick
2014-10-05 17:01 ` [PATCH 08/13 linux-next] serial: sunsu: use container_of to resolve uart_sunsu_port " Fabian Frederick
2014-10-05 20:57   ` David Miller
2014-10-05 17:01 ` [PATCH 09/13 linux-next] serial: sunsab: " Fabian Frederick
2014-10-05 20:57   ` David Miller
2014-10-05 17:19 ` [PATCH 10/13 linux-next] serial: amba-pl010: use container_of to resolve uart_amba_port " Fabian Frederick
2014-10-05 17:19   ` [PATCH 11/13 linux-next] serial: pnx8xxx: use container_of to resolve pnx8xxx_port " Fabian Frederick
2014-10-05 17:19   ` [PATCH 12/13 linux-next] serial: use container_of to resolve uart_sunzilog_port " Fabian Frederick
2014-10-05 20:58     ` David Miller
2014-10-05 17:19   ` [PATCH 13/13 linux-next] tty: ar933x_uart: use container_of to resolve ar933x_uart_port " Fabian Frederick

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=1412528475-1449-7-git-send-email-fabf@skynet.be \
    --to=fabf@skynet.be \
    --cc=cascardo@linux.vnet.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@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;
as well as URLs for NNTP newsgroup(s).