linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: gregkh@linuxfoundation.org, alan@linux.intel.com
Cc: linux-serial@vger.kernel.org,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: [PATCH 2/7] serial: make 8250's serial_in shareable to other drivers.
Date: Thu,  8 Mar 2012 19:12:09 -0500	[thread overview]
Message-ID: <1331251934-25540-3-git-send-email-paul.gortmaker@windriver.com> (raw)
In-Reply-To: <1331251934-25540-1-git-send-email-paul.gortmaker@windriver.com>

Currently 8250.c has serial_in and serial_out as shortcuts
to doing the port I/O.  They are implemented as macros a
ways down in the file.  This isn't by accident, but is
implicitly required, so cpp doesn't mangle other instances
of the common string "serial_in", as it exists as a field
in the port struct itself.

The above mangling avoidance violates the principle of least
surprise, and it also prevents the shortcuts from being
relocated up to the top of file, or into 8250.h -- either
being a better location than the current one.

Move them to 8250.h so other 8250-like drivers can also use
the shortcuts, and in the process, make the conflicting
names go away by using static inlines instead of macros.
The object file size remains unchanged with this modification.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/tty/serial/8250/8250.c |    5 -----
 drivers/tty/serial/8250/8250.h |   10 ++++++++++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 9674eac..4009e24 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -482,11 +482,6 @@ serial_out_sync(struct uart_8250_port *up, int offset, int value)
 	}
 }
 
-#define serial_in(up, offset)		\
-	(up->port.serial_in(&(up)->port, (offset)))
-#define serial_out(up, offset, value)	\
-	(up->port.serial_out(&(up)->port, (offset), (value)))
-
 /* Uart divisor latch read */
 static inline int _serial_dl_read(struct uart_8250_port *up)
 {
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index ae027be..2868a1d 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -86,6 +86,16 @@ struct serial8250_config {
 #define SERIAL8250_SHARE_IRQS 0
 #endif
 
+static inline int serial_in(struct uart_8250_port *up, int offset)
+{
+	return up->port.serial_in(&up->port, offset);
+}
+
+static inline void serial_out(struct uart_8250_port *up, int offset, int value)
+{
+	up->port.serial_out(&up->port, offset, value);
+}
+
 #if defined(__alpha__) && !defined(CONFIG_PCI)
 /*
  * Digital did something really horribly wrong with the OUT1 and OUT2
-- 
1.7.9.1


  parent reply	other threads:[~2012-03-09  0:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-09  0:12 [PATCH v2 0/7] serial: cleanups that strive to do nothing Paul Gortmaker
2012-03-09  0:12 ` [PATCH 1/7] serial: delete last unused traces of pausing I/O in 8250 Paul Gortmaker
2012-03-09  0:12 ` Paul Gortmaker [this message]
2012-03-09  0:12 ` [PATCH 3/7] serial: delete useless void casts in 8250.c Paul Gortmaker
2012-03-09  0:12 ` [PATCH 4/7] serial: reduce number of indirections in 8250 code Paul Gortmaker
2012-03-09  0:12 ` [PATCH 5/7] serial: introduce generic port in/out helpers Paul Gortmaker
2012-03-09  0:12 ` [PATCH 6/7] serial: use serial_port_in/out vs serial_in/out in 8250 Paul Gortmaker
2012-03-09  0:12 ` [PATCH 7/7] serial: remove back and forth conversions in serial_out_sync Paul Gortmaker
2012-03-09 10:29 ` [PATCH v2 0/7] serial: cleanups that strive to do nothing Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2012-03-02  2:33 [RFC PATCH " Paul Gortmaker
2012-03-02  2:33 ` [PATCH 2/7] serial: make 8250's serial_in shareable to other drivers Paul Gortmaker

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=1331251934-25540-3-git-send-email-paul.gortmaker@windriver.com \
    --to=paul.gortmaker@windriver.com \
    --cc=alan@linux.intel.com \
    --cc=gregkh@linuxfoundation.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).