linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/12] serial/max310x: Remove obsolete #ifset TIOC[SG]RS485
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 02/12] serial/sc16is7xx: " Ricardo Ribalda Delgado
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

Commit e676253b19b2 ("serial/8250: Add support for RS485 IOCTLs") added
references to TIOC[SG]RS48 on 8250_core.c. This change triggered the
need to define them in all the arches that uses tty/serial.

This made #ifdef TIOC[SG]RS48 obsolete.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/max310x.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 82573dc..670aba4 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -877,7 +877,6 @@ static void max310x_set_termios(struct uart_port *port,
 static int max310x_ioctl(struct uart_port *port, unsigned int cmd,
 			 unsigned long arg)
 {
-#if defined(TIOCSRS485) && defined(TIOCGRS485)
 	struct serial_rs485 rs485;
 	unsigned int val;
 
@@ -920,7 +919,6 @@ static int max310x_ioctl(struct uart_port *port, unsigned int cmd,
 	default:
 		break;
 	}
-#endif
 
 	return -ENOIOCTLCMD;
 }
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 02/12] serial/sc16is7xx: Remove obsolete #ifset TIOC[SG]RS485
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
  2014-10-08 19:57 ` [PATCH 01/12] serial/max310x: Remove obsolete #ifset TIOC[SG]RS485 Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls Ricardo Ribalda Delgado
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

Commit e676253b19b2 ("serial/8250: Add support for RS485 IOCTLs") added
references to TIOC[SG]RS48 on 8250_core.c. This change triggered the
need to define them in all the arches that uses tty/serial.

This made #ifdef TIOC[SG]RS48 obsolete.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/sc16is7xx.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 3284c31..3ab5d1b 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -830,7 +830,6 @@ static void sc16is7xx_set_termios(struct uart_port *port,
 	uart_update_timeout(port, termios->c_cflag, baud);
 }
 
-#if defined(TIOCSRS485) && defined(TIOCGRS485)
 static void sc16is7xx_config_rs485(struct uart_port *port,
 				   struct serial_rs485 *rs485)
 {
@@ -848,12 +847,10 @@ static void sc16is7xx_config_rs485(struct uart_port *port,
 				      0);
 	}
 }
-#endif
 
 static int sc16is7xx_ioctl(struct uart_port *port, unsigned int cmd,
 			   unsigned long arg)
 {
-#if defined(TIOCSRS485) && defined(TIOCGRS485)
 	struct serial_rs485 rs485;
 
 	switch (cmd) {
@@ -872,7 +869,6 @@ static int sc16is7xx_ioctl(struct uart_port *port, unsigned int cmd,
 	default:
 		break;
 	}
-#endif
 
 	return -ENOIOCTLCMD;
 }
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls.
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
  2014-10-08 19:57 ` [PATCH 01/12] serial/max310x: Remove obsolete #ifset TIOC[SG]RS485 Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 02/12] serial/sc16is7xx: " Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 20:11   ` Alan Cox
  2014-10-08 19:57 ` [PATCH 04/12] serial/8250: Copy RS485 fields to serial_core Ricardo Ribalda Delgado
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

The following drivers: 8250_core, atmel_serial, max310x, mcf, omap-serial
and sci16is7xx implement code to handle RS485 ioctls.

In order to avoid code duplication, we implement a simple ioctl handler
on the serial_core layer.

This handler can be used by all the other drivers instead of duplicating
code.

Until this is the only RS485 ioctl handler, it will try first the
rs485_config callback and if it is not present it will call the driver
specific ioctl.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/serial_core.c | 45 ++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_core.h      |  3 +++
 2 files changed, 48 insertions(+)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index df3a8c7..6015fd2 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1151,6 +1151,39 @@ static int uart_get_icount(struct tty_struct *tty,
 	return 0;
 }
 
+static int uart_get_rs485_config(struct uart_port *port,
+			 struct serial_rs485 __user *rs485)
+{
+	if (!port->rs485_config)
+		return -ENOIOCTLCMD;
+
+	if (copy_to_user(rs485, &port->rs485, sizeof(port->rs485)))
+		return -EFAULT;
+	return 0;
+}
+
+static int uart_set_rs485_config(struct uart_port *port,
+			 struct serial_rs485 __user *rs485_user)
+{
+	struct serial_rs485 rs485;
+	int ret;
+
+	if (!port->rs485_config)
+		return -ENOIOCTLCMD;
+
+	if (copy_from_user(&rs485, rs485_user, sizeof(rs485_user)))
+		return -EFAULT;
+
+	ret = port->rs485_config(port, &rs485);
+	if (ret)
+		return ret;
+
+	if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485)))
+		return -EFAULT;
+
+	return 0;
+}
+
 /*
  * Called via sys_ioctl.  We can use spin_lock_irq() here.
  */
@@ -1218,6 +1251,18 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd,
 	 * protected against the tty being hung up.
 	 */
 	switch (cmd) {
+	case TIOCGRS485:
+		ret = uart_get_rs485_config(state->uart_port, uarg);
+		break;
+
+	case TIOCSRS485:
+		ret = uart_set_rs485_config(state->uart_port, uarg);
+		break;
+	}
+	if (ret != -ENOIOCTLCMD)
+		goto out;
+
+	switch (cmd) {
 	case TIOCSERGETLSR: /* Get line status register */
 		ret = uart_get_lsr_info(tty, state, uarg);
 		break;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 21c2e05..60a4ebf 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -131,6 +131,8 @@ struct uart_port {
 	void			(*pm)(struct uart_port *, unsigned int state,
 				      unsigned int old);
 	void			(*handle_break)(struct uart_port *);
+	int			(*rs485_config)(struct uart_port *,
+						struct serial_rs485 *rs485);
 	unsigned int		irq;			/* irq number */
 	unsigned long		irqflags;		/* irq flags  */
 	unsigned int		uartclk;		/* base uart clock */
@@ -214,6 +216,7 @@ struct uart_port {
 	unsigned char		unused[2];
 	struct attribute_group	*attr_group;		/* port specific attributes */
 	const struct attribute_group **tty_groups;	/* all attributes (serial core use only) */
+	struct serial_rs485     rs485;
 	void			*private_data;		/* generic platform data pointer */
 };
 
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/12] serial/8250: Copy RS485 fields to serial_core
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (2 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 05/12] 8250/fintek: Use rs485 handler from serial_core Ricardo Ribalda Delgado
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby,
	Sebastian Andrzej Siewior, Tony Lindgren, Peter Hurley,
	Yoshihiro YUNOMAE, Andy Shevchenko, Ingo Molnar, linux-kernel

Initialize recently added rs485 fields on serial_core

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/8250/8250_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 139f3d2..6cdd4cf 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -3589,6 +3589,8 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
 		uart->rs485		= up->rs485;
 		uart->port.throttle	= up->port.throttle;
 		uart->port.unthrottle	= up->port.unthrottle;
+		uart->port.rs485_config	= up->port.rs485_config;
+		uart->port.rs485	= up->port.rs485;
 
 		/* Take tx_loadsz from fifosize if it wasn't set separately */
 		if (uart->port.fifosize && !uart->tx_loadsz)
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 05/12] 8250/fintek: Use rs485 handler from serial_core
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (3 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 04/12] serial/8250: Copy RS485 fields to serial_core Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 06/12] serial/8250: Remove obsolete handling of rs485 ioctls Ricardo Ribalda Delgado
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

In order to remove the handler for rs485 ioctls on serial_8250, all the
drivers must use the implementation on serial_core.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/8250/8250_fintek.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index 1bb28cb..1e6899bc 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -89,11 +89,11 @@ static int fintek_8250_check_id(void)
 	return 0;
 }
 
-static int fintek_8250_rs4850_config(struct uart_8250_port *uart,
+static int fintek_8250_rs485_config(struct uart_port *port,
 			      struct serial_rs485 *rs485)
 {
 	uint8_t config = 0;
-	int index = fintek_8250_get_index(uart->port.iobase);
+	int index = fintek_8250_get_index(port->iobase);
 
 	if (index < 0)
 		return -EINVAL;
@@ -134,6 +134,8 @@ static int fintek_8250_rs4850_config(struct uart_8250_port *uart,
 	outb(config, DATA_PORT);
 	fintek_8250_exit_key();
 
+	port->rs485 = *rs485;
+
 	return 0;
 }
 
@@ -166,7 +168,7 @@ fintek_8250_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
 	uart.port.irq = pnp_irq(dev, 0);
 	uart.port.iobase = pnp_port_start(dev, 0);
 	uart.port.iotype = UPIO_PORT;
-	uart.rs485_config = fintek_8250_rs4850_config;
+	uart.port.rs485_config = fintek_8250_rs485_config;
 
 	uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
 	if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 06/12] serial/8250: Remove obsolete handling of rs485 ioctls
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (4 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 05/12] 8250/fintek: Use rs485 handler from serial_core Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 07/12] serial/sc16is7xx: Use the rs485 functions on serial_core Ricardo Ribalda Delgado
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby,
	Sebastian Andrzej Siewior, Tony Lindgren, Peter Hurley,
	Yoshihiro YUNOMAE, Andy Shevchenko, Ingo Molnar, linux-kernel

There is no more users for this functions. All the 8250 drivers are
using the rs485 handler on serial_core instead.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/8250/8250_core.c | 39 -------------------------------------
 include/linux/serial_8250.h         |  3 ---
 2 files changed, 42 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 6cdd4cf..5d62129 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2975,42 +2975,6 @@ serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
 	return 0;
 }
 
-static int serial8250_ioctl(struct uart_port *port, unsigned int cmd,
-			   unsigned long arg)
-{
-	struct uart_8250_port *up =
-		container_of(port, struct uart_8250_port, port);
-	int ret;
-	struct serial_rs485 rs485_config;
-
-	if (!up->rs485_config)
-		return -ENOIOCTLCMD;
-
-	switch (cmd) {
-	case TIOCSRS485:
-		if (copy_from_user(&rs485_config, (void __user *)arg,
-				   sizeof(rs485_config)))
-			return -EFAULT;
-
-		ret = up->rs485_config(up, &rs485_config);
-		if (ret)
-			return ret;
-
-		memcpy(&up->rs485, &rs485_config, sizeof(rs485_config));
-
-		return 0;
-	case TIOCGRS485:
-		if (copy_to_user((void __user *)arg, &up->rs485,
-				 sizeof(up->rs485)))
-			return -EFAULT;
-		return 0;
-	default:
-		break;
-	}
-
-	return -ENOIOCTLCMD;
-}
-
 static const char *
 serial8250_type(struct uart_port *port)
 {
@@ -3042,7 +3006,6 @@ static struct uart_ops serial8250_pops = {
 	.request_port	= serial8250_request_port,
 	.config_port	= serial8250_config_port,
 	.verify_port	= serial8250_verify_port,
-	.ioctl		= serial8250_ioctl,
 #ifdef CONFIG_CONSOLE_POLL
 	.poll_get_char = serial8250_get_poll_char,
 	.poll_put_char = serial8250_put_poll_char,
@@ -3585,8 +3548,6 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
 		uart->port.fifosize	= up->port.fifosize;
 		uart->tx_loadsz		= up->tx_loadsz;
 		uart->capabilities	= up->capabilities;
-		uart->rs485_config	= up->rs485_config;
-		uart->rs485		= up->rs485;
 		uart->port.throttle	= up->port.throttle;
 		uart->port.unthrottle	= up->port.unthrottle;
 		uart->port.rs485_config	= up->port.rs485_config;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 3df10d5..e02acf0 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -97,13 +97,10 @@ struct uart_8250_port {
 	unsigned char		msr_saved_flags;
 
 	struct uart_8250_dma	*dma;
-	struct serial_rs485     rs485;
 
 	/* 8250 specific callbacks */
 	int			(*dl_read)(struct uart_8250_port *);
 	void			(*dl_write)(struct uart_8250_port *, int);
-	int			(*rs485_config)(struct uart_8250_port *,
-						struct serial_rs485 *rs485);
 };
 
 static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 07/12] serial/sc16is7xx: Use the rs485 functions on serial_core
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (5 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 06/12] serial/8250: Remove obsolete handling of rs485 ioctls Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 08/12] serial/mcf: " Ricardo Ribalda Delgado
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

In order to unify all the rs485 ioctl handling.
Use the implementation of TIOC[GS]RS485 ioctl handling on serial_core.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/sc16is7xx.c | 53 ++++++++++--------------------------------
 1 file changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 3ab5d1b..8c04f59 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -304,8 +304,6 @@ struct sc16is7xx_one {
 	struct uart_port		port;
 	struct work_struct		tx_work;
 	struct work_struct		md_work;
-
-	struct serial_rs485		rs485;
 };
 
 struct sc16is7xx_port {
@@ -657,15 +655,15 @@ static void sc16is7xx_stop_tx(struct uart_port* port)
 	struct circ_buf *xmit = &one->port.state->xmit;
 
 	/* handle rs485 */
-	if (one->rs485.flags & SER_RS485_ENABLED) {
+	if (port->rs485.flags & SER_RS485_ENABLED) {
 		/* do nothing if current tx not yet completed */
 		int lsr = sc16is7xx_port_read(port, SC16IS7XX_LSR_REG);
 		if (!(lsr & SC16IS7XX_LSR_TEMT_BIT))
 			return;
 
 		if (uart_circ_empty(xmit) &&
-		    (one->rs485.delay_rts_after_send > 0))
-			mdelay(one->rs485.delay_rts_after_send);
+		    (port->rs485.delay_rts_after_send > 0))
+			mdelay(port->rs485.delay_rts_after_send);
 	}
 
 	sc16is7xx_port_update(port, SC16IS7XX_IER_REG,
@@ -688,9 +686,9 @@ static void sc16is7xx_start_tx(struct uart_port *port)
 	struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
 
 	/* handle rs485 */
-	if ((one->rs485.flags & SER_RS485_ENABLED) &&
-	    (one->rs485.delay_rts_before_send > 0)) {
-		mdelay(one->rs485.delay_rts_before_send);
+	if ((port->rs485.flags & SER_RS485_ENABLED) &&
+	    (port->rs485.delay_rts_before_send > 0)) {
+		mdelay(port->rs485.delay_rts_before_send);
 	}
 
 	if (!work_pending(&one->tx_work))
@@ -830,47 +828,20 @@ static void sc16is7xx_set_termios(struct uart_port *port,
 	uart_update_timeout(port, termios->c_cflag, baud);
 }
 
-static void sc16is7xx_config_rs485(struct uart_port *port,
+static int sc16is7xx_config_rs485(struct uart_port *port,
 				   struct serial_rs485 *rs485)
 {
-	struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
-
-	one->rs485 = *rs485;
-
-	if (one->rs485.flags & SER_RS485_ENABLED) {
+	if (port->rs485.flags & SER_RS485_ENABLED)
 		sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG,
 				      SC16IS7XX_EFCR_AUTO_RS485_BIT,
 				      SC16IS7XX_EFCR_AUTO_RS485_BIT);
-	} else {
+	else
 		sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG,
 				      SC16IS7XX_EFCR_AUTO_RS485_BIT,
 				      0);
-	}
-}
-
-static int sc16is7xx_ioctl(struct uart_port *port, unsigned int cmd,
-			   unsigned long arg)
-{
-	struct serial_rs485 rs485;
+	port->rs485 = *rs485;
 
-	switch (cmd) {
-	case TIOCSRS485:
-		if (copy_from_user(&rs485, (void __user *)arg, sizeof(rs485)))
-			return -EFAULT;
-
-		sc16is7xx_config_rs485(port, &rs485);
-		return 0;
-	case TIOCGRS485:
-		if (copy_to_user((void __user *)arg,
-				 &(to_sc16is7xx_one(port, port)->rs485),
-				 sizeof(rs485)))
-			return -EFAULT;
-		return 0;
-	default:
-		break;
-	}
-
-	return -ENOIOCTLCMD;
+	return 0;
 }
 
 static int sc16is7xx_startup(struct uart_port *port)
@@ -996,7 +967,6 @@ static const struct uart_ops sc16is7xx_ops = {
 	.release_port	= sc16is7xx_null_void,
 	.config_port	= sc16is7xx_config_port,
 	.verify_port	= sc16is7xx_verify_port,
-	.ioctl		= sc16is7xx_ioctl,
 	.pm		= sc16is7xx_pm,
 };
 
@@ -1126,6 +1096,7 @@ static int sc16is7xx_probe(struct device *dev,
 		s->p[i].port.flags	= UPF_FIXED_TYPE | UPF_LOW_LATENCY;
 		s->p[i].port.iotype	= UPIO_PORT;
 		s->p[i].port.uartclk	= freq;
+		s->p[i].port.rs485_config = sc16is7xx_config_rs485;
 		s->p[i].port.ops	= &sc16is7xx_ops;
 		/* Disable all interrupts */
 		sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IER_REG, 0);
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 08/12] serial/mcf: Use the rs485 functions on serial_core
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (6 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 07/12] serial/sc16is7xx: Use the rs485 functions on serial_core Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 09/12] serial/atmel: " Ricardo Ribalda Delgado
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

In order to unify all the rs485 ioctl handling.
Use the implementation of TIOC[GS]RS485 ioctl handling on serial_core.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/mcf.c | 37 +++++++------------------------------
 1 file changed, 7 insertions(+), 30 deletions(-)

diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index bc896dc..d7be1f1 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -57,7 +57,6 @@ struct mcf_uart {
 	struct uart_port	port;
 	unsigned int		sigs;		/* Local copy of line sigs */
 	unsigned char		imr;		/* Local IMR mirror */
-	struct serial_rs485	rs485;		/* RS485 settings */
 };
 
 /****************************************************************************/
@@ -104,7 +103,7 @@ static void mcf_start_tx(struct uart_port *port)
 {
 	struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
 
-	if (pp->rs485.flags & SER_RS485_ENABLED) {
+	if (port->rs485.flags & SER_RS485_ENABLED) {
 		/* Enable Transmitter */
 		writeb(MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR);
 		/* Manually assert RTS */
@@ -258,7 +257,7 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
 		mr2 |= MCFUART_MR2_TXCTS;
 	}
 
-	if (pp->rs485.flags & SER_RS485_ENABLED) {
+	if (port->rs485.flags & SER_RS485_ENABLED) {
 		dev_dbg(port->dev, "Setting UART to RS485\n");
 		mr2 |= MCFUART_MR2_TXRTS;
 	}
@@ -360,7 +359,7 @@ static void mcf_tx_chars(struct mcf_uart *pp)
 		pp->imr &= ~MCFUART_UIR_TXREADY;
 		writeb(pp->imr, port->membase + MCFUART_UIMR);
 		/* Disable TX to negate RTS automatically */
-		if (pp->rs485.flags & SER_RS485_ENABLED)
+		if (port->rs485.flags & SER_RS485_ENABLED)
 			writeb(MCFUART_UCR_TXDISABLE,
 				port->membase + MCFUART_UCR);
 	}
@@ -440,7 +439,7 @@ static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser)
 /****************************************************************************/
 
 /* Enable or disable the RS485 support */
-static void mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
+static int mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
 {
 	struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
 	unsigned long flags;
@@ -460,32 +459,9 @@ static void mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
 	}
 	writeb(mr1, port->membase + MCFUART_UMR);
 	writeb(mr2, port->membase + MCFUART_UMR);
-	pp->rs485 = *rs485;
+	port->rs485 = *rs485;
 	spin_unlock_irqrestore(&port->lock, flags);
-}
 
-static int mcf_ioctl(struct uart_port *port, unsigned int cmd,
-		unsigned long arg)
-{
-	switch (cmd) {
-	case TIOCSRS485: {
-		struct serial_rs485 rs485;
-		if (copy_from_user(&rs485, (struct serial_rs485 *)arg,
-				sizeof(struct serial_rs485)))
-			return -EFAULT;
-		mcf_config_rs485(port, &rs485);
-		break;
-	}
-	case TIOCGRS485: {
-		struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
-		if (copy_to_user((struct serial_rs485 *)arg, &pp->rs485,
-				sizeof(struct serial_rs485)))
-			return -EFAULT;
-		break;
-	}
-	default:
-		return -ENOIOCTLCMD;
-	}
 	return 0;
 }
 
@@ -510,7 +486,6 @@ static const struct uart_ops mcf_uart_ops = {
 	.release_port	= mcf_release_port,
 	.config_port	= mcf_config_port,
 	.verify_port	= mcf_verify_port,
-	.ioctl		= mcf_ioctl,
 };
 
 static struct mcf_uart mcf_ports[4];
@@ -538,6 +513,7 @@ int __init early_mcf_setup(struct mcf_platform_uart *platp)
 		port->irq = platp[i].irq;
 		port->uartclk = MCF_BUSCLK;
 		port->flags = UPF_BOOT_AUTOCONF;
+		port->rs485_config = mcf_config_rs485;
 		port->ops = &mcf_uart_ops;
 	}
 
@@ -663,6 +639,7 @@ static int mcf_probe(struct platform_device *pdev)
 		port->uartclk = MCF_BUSCLK;
 		port->ops = &mcf_uart_ops;
 		port->flags = UPF_BOOT_AUTOCONF;
+		port->rs485_config = mcf_config_rs485;
 
 		uart_add_one_port(&mcf_driver, port);
 	}
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 09/12] serial/atmel: Use the rs485 functions on serial_core
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (7 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 08/12] serial/mcf: " Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 10/12] serial/omap: " Ricardo Ribalda Delgado
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Nicolas Ferre, Greg Kroah-Hartman,
	Jiri Slaby, linux-kernel

In order to unify all the rs485 ioctl handling.
Use the implementation of TIOC[GS]RS485 ioctl handling on serial_core.

Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/atmel_serial.c | 79 ++++++++++++---------------------------
 1 file changed, 24 insertions(+), 55 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index d7d4584..e8df8e4 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -166,7 +166,6 @@ struct atmel_uart_port {
 
 	struct circ_buf		rx_ring;
 
-	struct serial_rs485	rs485;		/* rs485 settings */
 	struct mctrl_gpios	*gpios;
 	int			gpio_irq[UART_GPIO_MAX];
 	unsigned int		tx_done_mask;
@@ -289,7 +288,8 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
 }
 
 /* Enable or disable the rs485 support */
-void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
+static int atmel_config_rs485(struct uart_port *port,
+			      struct serial_rs485 *rs485conf)
 {
 	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
 	unsigned int mode;
@@ -305,7 +305,7 @@ void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
 	/* Resetting serial mode to RS232 (0x0) */
 	mode &= ~ATMEL_US_USMODE;
 
-	atmel_port->rs485 = *rs485conf;
+	port->rs485 = *rs485conf;
 
 	if (rs485conf->flags & SER_RS485_ENABLED) {
 		dev_dbg(port->dev, "Setting UART to RS485\n");
@@ -328,6 +328,7 @@ void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
 
 	spin_unlock_irqrestore(&port->lock, flags);
 
+	return 0;
 }
 
 /*
@@ -371,11 +372,10 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
 	/* Resetting serial mode to RS232 (0x0) */
 	mode &= ~ATMEL_US_USMODE;
 
-	if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
+	if (port->rs485.flags & SER_RS485_ENABLED) {
 		dev_dbg(port->dev, "Setting UART to RS485\n");
-		if ((atmel_port->rs485.delay_rts_after_send) > 0)
-			UART_PUT_TTGR(port,
-					atmel_port->rs485.delay_rts_after_send);
+		if ((port->rs485.delay_rts_after_send) > 0)
+			UART_PUT_TTGR(port, port->rs485.delay_rts_after_send);
 		mode |= ATMEL_US_USMODE_RS485;
 	} else {
 		dev_dbg(port->dev, "Setting UART to RS232\n");
@@ -422,8 +422,8 @@ static void atmel_stop_tx(struct uart_port *port)
 	/* Disable interrupts */
 	UART_PUT_IDR(port, atmel_port->tx_done_mask);
 
-	if ((atmel_port->rs485.flags & SER_RS485_ENABLED) &&
-	    !(atmel_port->rs485.flags & SER_RS485_RX_DURING_TX))
+	if ((port->rs485.flags & SER_RS485_ENABLED) &&
+	    !(port->rs485.flags & SER_RS485_RX_DURING_TX))
 		atmel_start_rx(port);
 }
 
@@ -440,8 +440,8 @@ static void atmel_start_tx(struct uart_port *port)
 			   really need this.*/
 			return;
 
-		if ((atmel_port->rs485.flags & SER_RS485_ENABLED) &&
-		    !(atmel_port->rs485.flags & SER_RS485_RX_DURING_TX))
+		if ((port->rs485.flags & SER_RS485_ENABLED) &&
+		    !(port->rs485.flags & SER_RS485_RX_DURING_TX))
 			atmel_stop_rx(port);
 
 		/* re-enable PDC transmit */
@@ -806,7 +806,7 @@ static void atmel_tx_dma(struct uart_port *port)
 		atmel_port->cookie_tx = dmaengine_submit(desc);
 
 	} else {
-		if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
+		if (port->rs485.flags & SER_RS485_ENABLED) {
 			/* DMA done, stop TX, start RX for RS485 */
 			atmel_start_rx(port);
 		}
@@ -1239,8 +1239,8 @@ static void atmel_tx_pdc(struct uart_port *port)
 		/* Enable interrupts */
 		UART_PUT_IER(port, atmel_port->tx_done_mask);
 	} else {
-		if ((atmel_port->rs485.flags & SER_RS485_ENABLED) &&
-		    !(atmel_port->rs485.flags & SER_RS485_RX_DURING_TX)) {
+		if ((port->rs485.flags & SER_RS485_ENABLED) &&
+		    !(port->rs485.flags & SER_RS485_RX_DURING_TX)) {
 			/* DMA done, stop TX, start RX for RS485 */
 			atmel_start_rx(port);
 		}
@@ -1551,7 +1551,7 @@ static int atmel_init_property(struct atmel_uart_port *atmel_port,
 	return 0;
 }
 
-static void atmel_init_rs485(struct atmel_uart_port *atmel_port,
+static void atmel_init_rs485(struct uart_port *port,
 				struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -1562,7 +1562,7 @@ static void atmel_init_rs485(struct atmel_uart_port *atmel_port,
 		/* rs485 properties */
 		if (of_property_read_u32_array(np, "rs485-rts-delay",
 					rs485_delay, 2) == 0) {
-			struct serial_rs485 *rs485conf = &atmel_port->rs485;
+			struct serial_rs485 *rs485conf = &port->rs485;
 
 			rs485conf->delay_rts_before_send = rs485_delay[0];
 			rs485conf->delay_rts_after_send = rs485_delay[1];
@@ -1576,7 +1576,7 @@ static void atmel_init_rs485(struct atmel_uart_port *atmel_port,
 			rs485conf->flags |= SER_RS485_ENABLED;
 		}
 	} else {
-		atmel_port->rs485       = pdata->rs485;
+		port->rs485       = pdata->rs485;
 	}
 
 }
@@ -1910,7 +1910,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 {
 	unsigned long flags;
 	unsigned int mode, imr, quot, baud;
-	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
 
 	/* Get current mode register */
 	mode = UART_GET_MR(port) & ~(ATMEL_US_USCLKS | ATMEL_US_CHRL
@@ -2012,10 +2011,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 	/* Resetting serial mode to RS232 (0x0) */
 	mode &= ~ATMEL_US_USMODE;
 
-	if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
-		if ((atmel_port->rs485.delay_rts_after_send) > 0)
-			UART_PUT_TTGR(port,
-					atmel_port->rs485.delay_rts_after_send);
+	if (port->rs485.flags & SER_RS485_ENABLED) {
+		if ((port->rs485.delay_rts_after_send) > 0)
+			UART_PUT_TTGR(port, port->rs485.delay_rts_after_send);
 		mode |= ATMEL_US_USMODE_RS485;
 	}
 
@@ -2147,35 +2145,6 @@ static void atmel_poll_put_char(struct uart_port *port, unsigned char ch)
 }
 #endif
 
-static int
-atmel_ioctl(struct uart_port *port, unsigned int cmd, unsigned long arg)
-{
-	struct serial_rs485 rs485conf;
-
-	switch (cmd) {
-	case TIOCSRS485:
-		if (copy_from_user(&rs485conf, (struct serial_rs485 *) arg,
-					sizeof(rs485conf)))
-			return -EFAULT;
-
-		atmel_config_rs485(port, &rs485conf);
-		break;
-
-	case TIOCGRS485:
-		if (copy_to_user((struct serial_rs485 *) arg,
-					&(to_atmel_uart_port(port)->rs485),
-					sizeof(rs485conf)))
-			return -EFAULT;
-		break;
-
-	default:
-		return -ENOIOCTLCMD;
-	}
-	return 0;
-}
-
-
-
 static struct uart_ops atmel_pops = {
 	.tx_empty	= atmel_tx_empty,
 	.set_mctrl	= atmel_set_mctrl,
@@ -2196,7 +2165,6 @@ static struct uart_ops atmel_pops = {
 	.config_port	= atmel_config_port,
 	.verify_port	= atmel_verify_port,
 	.pm		= atmel_serial_pm,
-	.ioctl		= atmel_ioctl,
 #ifdef CONFIG_CONSOLE_POLL
 	.poll_get_char	= atmel_poll_get_char,
 	.poll_put_char	= atmel_poll_put_char,
@@ -2216,7 +2184,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
 	if (!atmel_init_property(atmel_port, pdev))
 		atmel_set_ops(port);
 
-	atmel_init_rs485(atmel_port, pdev);
+	atmel_init_rs485(port, pdev);
 
 	port->iotype		= UPIO_MEM;
 	port->flags		= UPF_BOOT_AUTOCONF;
@@ -2225,6 +2193,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
 	port->dev		= &pdev->dev;
 	port->mapbase	= pdev->resource[0].start;
 	port->irq	= pdev->resource[1].start;
+	port->rs485_config	= atmel_config_rs485;
 
 	tasklet_init(&atmel_port->tasklet, atmel_tasklet_func,
 			(unsigned long)port);
@@ -2259,7 +2228,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
 	}
 
 	/* Use TXEMPTY for interrupt when rs485 else TXRDY or ENDTX|TXBUFE */
-	if (atmel_port->rs485.flags & SER_RS485_ENABLED)
+	if (port->rs485.flags & SER_RS485_ENABLED)
 		atmel_port->tx_done_mask = ATMEL_US_TXEMPTY;
 	else if (atmel_use_pdc_tx(port)) {
 		port->fifosize = PDC_BUFFER_SIZE;
@@ -2605,7 +2574,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
 	device_init_wakeup(&pdev->dev, 1);
 	platform_set_drvdata(pdev, port);
 
-	if (port->rs485.flags & SER_RS485_ENABLED) {
+	if (port->uart.rs485.flags & SER_RS485_ENABLED) {
 		UART_PUT_MR(&port->uart, ATMEL_US_USMODE_NORMAL);
 		UART_PUT_CR(&port->uart, ATMEL_US_RTSEN);
 	}
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 10/12] serial/omap: Use the rs485 functions on serial_core
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (8 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 09/12] serial/atmel: " Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 11/12] drivers/max310: " Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 12/12] serial_core: Remove call to driver-specific TIO[GS]RS485] Ricardo Ribalda Delgado
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

In order to unify all the rs485 ioctl handling
Use the implementation of TIOC[GS]RS485 ioctl handling on serial_core.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/omap-serial.c | 71 +++++++++++++---------------------------
 1 file changed, 23 insertions(+), 48 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 18c30ca..9d4726f 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -163,7 +163,6 @@ struct uart_omap_port {
 	u8			wakeups_enabled;
 	u32			features;
 
-	struct serial_rs485	rs485;
 	int			rts_gpio;
 
 	struct pm_qos_request	pm_qos_request;
@@ -316,7 +315,7 @@ static void serial_omap_stop_tx(struct uart_port *port)
 	pm_runtime_get_sync(up->dev);
 
 	/* Handle RS-485 */
-	if (up->rs485.flags & SER_RS485_ENABLED) {
+	if (port->rs485.flags & SER_RS485_ENABLED) {
 		if (up->scr & OMAP_UART_SCR_TX_EMPTY) {
 			/* THR interrupt is fired when both TX FIFO and TX
 			 * shift register are empty. This means there's nothing
@@ -327,11 +326,13 @@ static void serial_omap_stop_tx(struct uart_port *port)
 			 */
 			up->scr &= ~OMAP_UART_SCR_TX_EMPTY;
 			serial_out(up, UART_OMAP_SCR, up->scr);
-			res = (up->rs485.flags & SER_RS485_RTS_AFTER_SEND) ? 1 : 0;
+			res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ?
+				1 : 0;
 			if (gpio_get_value(up->rts_gpio) != res) {
-				if (up->rs485.delay_rts_after_send > 0)
-					mdelay(up->rs485.delay_rts_after_send);
-				gpio_set_value(up->rts_gpio, res);
+				if (port->rs485.delay_rts_after_send > 0)
+					mdelay(
+					port->rs485.delay_rts_after_send);
+				gpio_set_value(port->rts_gpio, res);
 			}
 		} else {
 			/* We're asked to stop, but there's still stuff in the
@@ -353,8 +354,8 @@ static void serial_omap_stop_tx(struct uart_port *port)
 		serial_out(up, UART_IER, up->ier);
 	}
 
-	if ((up->rs485.flags & SER_RS485_ENABLED) &&
-	    !(up->rs485.flags & SER_RS485_RX_DURING_TX)) {
+	if ((port->rs485.flags & SER_RS485_ENABLED) &&
+	    !(port->rs485.flags & SER_RS485_RX_DURING_TX)) {
 		/*
 		 * Empty the RX FIFO, we are not interested in anything
 		 * received during the half-duplex transmission.
@@ -429,22 +430,22 @@ static void serial_omap_start_tx(struct uart_port *port)
 	pm_runtime_get_sync(up->dev);
 
 	/* Handle RS-485 */
-	if (up->rs485.flags & SER_RS485_ENABLED) {
+	if (port->rs485.flags & SER_RS485_ENABLED) {
 		/* Fire THR interrupts when FIFO is below trigger level */
 		up->scr &= ~OMAP_UART_SCR_TX_EMPTY;
 		serial_out(up, UART_OMAP_SCR, up->scr);
 
 		/* if rts not already enabled */
-		res = (up->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0;
+		res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0;
 		if (gpio_get_value(up->rts_gpio) != res) {
 			gpio_set_value(up->rts_gpio, res);
-			if (up->rs485.delay_rts_before_send > 0)
-				mdelay(up->rs485.delay_rts_before_send);
+			if (port->rs485.delay_rts_before_send > 0)
+				mdelay(port->rs485.delay_rts_before_send);
 		}
 	}
 
-	if ((up->rs485.flags & SER_RS485_ENABLED) &&
-	    !(up->rs485.flags & SER_RS485_RX_DURING_TX))
+	if ((port->rs485.flags & SER_RS485_ENABLED) &&
+	    !(port->rs485.flags & SER_RS485_RX_DURING_TX))
 		serial_omap_stop_rx(port);
 
 	serial_omap_enable_ier_thri(up);
@@ -1355,7 +1356,7 @@ static inline void serial_omap_add_console_port(struct uart_omap_port *up)
 #endif
 
 /* Enable or disable the rs485 support */
-static void
+static int
 serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
 {
 	struct uart_omap_port *up = to_uart_omap_port(port);
@@ -1372,7 +1373,7 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
 	serial_out(up, UART_IER, 0);
 
 	/* store new config */
-	up->rs485 = *rs485conf;
+	port->rs485 = *rs485conf;
 
 	/*
 	 * Just as a precaution, only allow rs485
@@ -1380,12 +1381,12 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
 	 */
 	if (gpio_is_valid(up->rts_gpio)) {
 		/* enable / disable rts */
-		val = (up->rs485.flags & SER_RS485_ENABLED) ?
+		val = (port->rs485.flags & SER_RS485_ENABLED) ?
 			SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND;
-		val = (up->rs485.flags & val) ? 1 : 0;
+		val = (port->rs485.flags & val) ? 1 : 0;
 		gpio_set_value(up->rts_gpio, val);
 	} else
-		up->rs485.flags &= ~SER_RS485_ENABLED;
+		port->rs485.flags &= ~SER_RS485_ENABLED;
 
 	/* Enable interrupts */
 	up->ier = mode;
@@ -1394,7 +1395,7 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
 	/* If RS-485 is disabled, make sure the THR interrupt is fired when
 	 * TX FIFO is below the trigger level.
 	 */
-	if (!(up->rs485.flags & SER_RS485_ENABLED) &&
+	if (!(port->rs485.flags & SER_RS485_ENABLED) &&
 	    (up->scr & OMAP_UART_SCR_TX_EMPTY)) {
 		up->scr &= ~OMAP_UART_SCR_TX_EMPTY;
 		serial_out(up, UART_OMAP_SCR, up->scr);
@@ -1403,36 +1404,10 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
 	spin_unlock_irqrestore(&up->port.lock, flags);
 	pm_runtime_mark_last_busy(up->dev);
 	pm_runtime_put_autosuspend(up->dev);
-}
-
-static int
-serial_omap_ioctl(struct uart_port *port, unsigned int cmd, unsigned long arg)
-{
-	struct serial_rs485 rs485conf;
-
-	switch (cmd) {
-	case TIOCSRS485:
-		if (copy_from_user(&rs485conf, (void __user *) arg,
-					sizeof(rs485conf)))
-			return -EFAULT;
 
-		serial_omap_config_rs485(port, &rs485conf);
-		break;
-
-	case TIOCGRS485:
-		if (copy_to_user((void __user *) arg,
-					&(to_uart_omap_port(port)->rs485),
-					sizeof(rs485conf)))
-			return -EFAULT;
-		break;
-
-	default:
-		return -ENOIOCTLCMD;
-	}
 	return 0;
 }
 
-
 static struct uart_ops serial_omap_pops = {
 	.tx_empty	= serial_omap_tx_empty,
 	.set_mctrl	= serial_omap_set_mctrl,
@@ -1453,7 +1428,6 @@ static struct uart_ops serial_omap_pops = {
 	.request_port	= serial_omap_request_port,
 	.config_port	= serial_omap_config_port,
 	.verify_port	= serial_omap_verify_port,
-	.ioctl		= serial_omap_ioctl,
 #ifdef CONFIG_CONSOLE_POLL
 	.poll_put_char  = serial_omap_poll_put_char,
 	.poll_get_char  = serial_omap_poll_get_char,
@@ -1587,7 +1561,7 @@ static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev)
 static int serial_omap_probe_rs485(struct uart_omap_port *up,
 				   struct device_node *np)
 {
-	struct serial_rs485 *rs485conf = &up->rs485;
+	struct serial_rs485 *rs485conf = &up->port.rs485;
 	u32 rs485_delay[2];
 	enum of_gpio_flags flags;
 	int ret;
@@ -1702,6 +1676,7 @@ static int serial_omap_probe(struct platform_device *pdev)
 	up->port.membase = base;
 	up->port.flags = omap_up_info->flags;
 	up->port.uartclk = omap_up_info->uartclk;
+	up->port.rs485_config = serial_omap_config_rs485;
 	if (!up->port.uartclk) {
 		up->port.uartclk = DEFAULT_CLK_SPEED;
 		dev_warn(&pdev->dev,
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 11/12] drivers/max310: Use the rs485 functions on serial_core
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (9 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 10/12] serial/omap: " Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  2014-10-08 19:57 ` [PATCH 12/12] serial_core: Remove call to driver-specific TIO[GS]RS485] Ricardo Ribalda Delgado
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

In order to unify all the rs485 ioctl handling
Use the implementation of TIOC[GS]RS485 ioctl handling on serial_core.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/max310x.c | 70 +++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 43 deletions(-)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 670aba4..5ad9713 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -874,53 +874,37 @@ static void max310x_set_termios(struct uart_port *port,
 	uart_update_timeout(port, termios->c_cflag, baud);
 }
 
-static int max310x_ioctl(struct uart_port *port, unsigned int cmd,
-			 unsigned long arg)
+static int max310x_rs485_config(struct uart_port *port,
+				struct serial_rs485 *rs485)
 {
-	struct serial_rs485 rs485;
 	unsigned int val;
 
-	switch (cmd) {
-	case TIOCSRS485:
-		if (copy_from_user(&rs485, (void __user *)arg, sizeof(rs485)))
-			return -EFAULT;
-		if (rs485.delay_rts_before_send > 0x0f ||
-		    rs485.delay_rts_after_send > 0x0f)
-			return -ERANGE;
-		val = (rs485.delay_rts_before_send << 4) |
-		      rs485.delay_rts_after_send;
-		max310x_port_write(port, MAX310X_HDPIXDELAY_REG, val);
-		if (rs485.flags & SER_RS485_ENABLED) {
-			max310x_port_update(port, MAX310X_MODE1_REG,
-					    MAX310X_MODE1_TRNSCVCTRL_BIT,
-					    MAX310X_MODE1_TRNSCVCTRL_BIT);
-			max310x_port_update(port, MAX310X_MODE2_REG,
-					    MAX310X_MODE2_ECHOSUPR_BIT,
-					    MAX310X_MODE2_ECHOSUPR_BIT);
-		} else {
-			max310x_port_update(port, MAX310X_MODE1_REG,
-					    MAX310X_MODE1_TRNSCVCTRL_BIT, 0);
-			max310x_port_update(port, MAX310X_MODE2_REG,
-					    MAX310X_MODE2_ECHOSUPR_BIT, 0);
-		}
-		return 0;
-	case TIOCGRS485:
-		memset(&rs485, 0, sizeof(rs485));
-		val = max310x_port_read(port, MAX310X_MODE1_REG);
-		rs485.flags = (val & MAX310X_MODE1_TRNSCVCTRL_BIT) ?
-			      SER_RS485_ENABLED : 0;
-		rs485.flags |= SER_RS485_RTS_ON_SEND;
-		val = max310x_port_read(port, MAX310X_HDPIXDELAY_REG);
-		rs485.delay_rts_before_send = val >> 4;
-		rs485.delay_rts_after_send = val & 0x0f;
-		if (copy_to_user((void __user *)arg, &rs485, sizeof(rs485)))
-			return -EFAULT;
-		return 0;
-	default:
-		break;
+	if (rs485->delay_rts_before_send > 0x0f ||
+		    rs485->delay_rts_after_send > 0x0f)
+		return -ERANGE;
+
+	val = (rs485->delay_rts_before_send << 4) |
+		rs485->delay_rts_after_send;
+	max310x_port_write(port, MAX310X_HDPIXDELAY_REG, val);
+	if (rs485->flags & SER_RS485_ENABLED) {
+		max310x_port_update(port, MAX310X_MODE1_REG,
+				MAX310X_MODE1_TRNSCVCTRL_BIT,
+				MAX310X_MODE1_TRNSCVCTRL_BIT);
+		max310x_port_update(port, MAX310X_MODE2_REG,
+				MAX310X_MODE2_ECHOSUPR_BIT,
+				MAX310X_MODE2_ECHOSUPR_BIT);
+	} else {
+		max310x_port_update(port, MAX310X_MODE1_REG,
+				MAX310X_MODE1_TRNSCVCTRL_BIT, 0);
+		max310x_port_update(port, MAX310X_MODE2_REG,
+				MAX310X_MODE2_ECHOSUPR_BIT, 0);
 	}
 
-	return -ENOIOCTLCMD;
+	rs485->flags &= SER_RS485_RTS_ON_SEND | SER_RS485_ENABLED;
+	memset(rs485->padding, 0, sizeof(rs485->padding));
+	port->rs485 = *rs485;
+
+	return 0;
 }
 
 static int max310x_startup(struct uart_port *port)
@@ -1015,7 +999,6 @@ static const struct uart_ops max310x_ops = {
 	.release_port	= max310x_null_void,
 	.config_port	= max310x_config_port,
 	.verify_port	= max310x_verify_port,
-	.ioctl		= max310x_ioctl,
 };
 
 static int __maybe_unused max310x_suspend(struct device *dev)
@@ -1216,6 +1199,7 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
 		s->p[i].port.iobase	= i * 0x20;
 		s->p[i].port.membase	= (void __iomem *)~0;
 		s->p[i].port.uartclk	= uartclk;
+		s->p[i].port.rs485_config = max310x_rs485_config;
 		s->p[i].port.ops	= &max310x_ops;
 		/* Disable all interrupts */
 		max310x_port_write(&s->p[i].port, MAX310X_IRQEN_REG, 0);
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 12/12] serial_core: Remove call to driver-specific TIO[GS]RS485]
       [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
                   ` (10 preceding siblings ...)
  2014-10-08 19:57 ` [PATCH 11/12] drivers/max310: " Ricardo Ribalda Delgado
@ 2014-10-08 19:57 ` Ricardo Ribalda Delgado
  11 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 19:57 UTC (permalink / raw)
  To: One Thousand Gnomes, Alan Cox, linux-serial
  Cc: Ricardo Ribalda Delgado, Greg Kroah-Hartman, Jiri Slaby, linux-kernel

Once there is no more handlers for TIOC[GS]RS485 there is no need to
call the driver specific ioctl when the generic implementation is
missing.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/tty/serial/serial_core.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 6015fd2..b59c925 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1154,9 +1154,6 @@ static int uart_get_icount(struct tty_struct *tty,
 static int uart_get_rs485_config(struct uart_port *port,
 			 struct serial_rs485 __user *rs485)
 {
-	if (!port->rs485_config)
-		return -ENOIOCTLCMD;
-
 	if (copy_to_user(rs485, &port->rs485, sizeof(port->rs485)))
 		return -EFAULT;
 	return 0;
@@ -1250,7 +1247,12 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd,
 	 * All these rely on hardware being present and need to be
 	 * protected against the tty being hung up.
 	 */
+
 	switch (cmd) {
+	case TIOCSERGETLSR: /* Get line status register */
+		ret = uart_get_lsr_info(tty, state, uarg);
+		break;
+
 	case TIOCGRS485:
 		ret = uart_get_rs485_config(state->uart_port, uarg);
 		break;
@@ -1258,15 +1260,6 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd,
 	case TIOCSRS485:
 		ret = uart_set_rs485_config(state->uart_port, uarg);
 		break;
-	}
-	if (ret != -ENOIOCTLCMD)
-		goto out;
-
-	switch (cmd) {
-	case TIOCSERGETLSR: /* Get line status register */
-		ret = uart_get_lsr_info(tty, state, uarg);
-		break;
-
 	default: {
 		struct uart_port *uport = state->uart_port;
 		if (uport->ops->ioctl)
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls.
  2014-10-08 19:57 ` [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls Ricardo Ribalda Delgado
@ 2014-10-08 20:11   ` Alan Cox
  2014-10-08 20:43     ` Ricardo Ribalda Delgado
  2014-10-09  8:07     ` Ricardo Ribalda Delgado
  0 siblings, 2 replies; 18+ messages in thread
From: Alan Cox @ 2014-10-08 20:11 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: One Thousand Gnomes, linux-serial, Greg Kroah-Hartman,
	Jiri Slaby, linux-kernel

On Wed, 2014-10-08 at 21:57 +0200, Ricardo Ribalda Delgado wrote:
> The following drivers: 8250_core, atmel_serial, max310x, mcf, omap-serial
> and sci16is7xx implement code to handle RS485 ioctls.

>  
> +static int uart_get_rs485_config(struct uart_port *port,
> +			 struct serial_rs485 __user *rs485)
> +{
> +	if (!port->rs485_config)
> +		return -ENOIOCTLCMD;
> +
> +	if (copy_to_user(rs485, &port->rs485, sizeof(port->rs485)))
> +		return -EFAULT;
> +	return 0;
> +}
> +
> +static int uart_set_rs485_config(struct uart_port *port,
> +			 struct serial_rs485 __user *rs485_user)
> +{
> +	struct serial_rs485 rs485;
> +	int ret;
> +
> +	if (!port->rs485_config)
> +		return -ENOIOCTLCMD;
> +
> +	if (copy_from_user(&rs485, rs485_user, sizeof(rs485_user)))
> +		return -EFAULT;
> +
> +	ret = port->rs485_config(port, &rs485);
> +	if (ret)
> +		return ret;
> +
> +	if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485)))
> +		return -EFAULT;
> +
> +	return 0;
> +

What is the locking between setting/getting/driver use of the config ?
This really needs a lock (termios sem I think is perhaps appropriate
given when the values are normally referenced).

Alan



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls.
  2014-10-08 20:11   ` Alan Cox
@ 2014-10-08 20:43     ` Ricardo Ribalda Delgado
  2014-10-08 23:29       ` Alan Cox
  2014-10-09  8:07     ` Ricardo Ribalda Delgado
  1 sibling, 1 reply; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-08 20:43 UTC (permalink / raw)
  To: Alan Cox
  Cc: One Thousand Gnomes, linux-serial, Greg Kroah-Hartman, Jiri Slaby, LKML

Hello Alan

This patchset adds no extra locking features, if the drivers did not
implement a locking mechanism (and none did) there is chance of
conflict.

I can add a call to lock/unlock around uart_[gs]et_rs485_config. And
then, inside the drivers, use the lock when the structure is used.

I would prefer to add it as new patches in the patchset, so in case
this adds some bugs they can be bisected easily.

Thanks for your fast reply



On Wed, Oct 8, 2014 at 10:11 PM, Alan Cox <alan@linux.intel.com> wrote:
> On Wed, 2014-10-08 at 21:57 +0200, Ricardo Ribalda Delgado wrote:
>> The following drivers: 8250_core, atmel_serial, max310x, mcf, omap-serial
>> and sci16is7xx implement code to handle RS485 ioctls.
>
>>
>> +static int uart_get_rs485_config(struct uart_port *port,
>> +                      struct serial_rs485 __user *rs485)
>> +{
>> +     if (!port->rs485_config)
>> +             return -ENOIOCTLCMD;
>> +
>> +     if (copy_to_user(rs485, &port->rs485, sizeof(port->rs485)))
>> +             return -EFAULT;
>> +     return 0;
>> +}
>> +
>> +static int uart_set_rs485_config(struct uart_port *port,
>> +                      struct serial_rs485 __user *rs485_user)
>> +{
>> +     struct serial_rs485 rs485;
>> +     int ret;
>> +
>> +     if (!port->rs485_config)
>> +             return -ENOIOCTLCMD;
>> +
>> +     if (copy_from_user(&rs485, rs485_user, sizeof(rs485_user)))
>> +             return -EFAULT;
>> +
>> +     ret = port->rs485_config(port, &rs485);
>> +     if (ret)
>> +             return ret;
>> +
>> +     if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485)))
>> +             return -EFAULT;
>> +
>> +     return 0;
>> +
>
> What is the locking between setting/getting/driver use of the config ?
> This really needs a lock (termios sem I think is perhaps appropriate
> given when the values are normally referenced).
>
> Alan
>
>



-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls.
  2014-10-08 20:43     ` Ricardo Ribalda Delgado
@ 2014-10-08 23:29       ` Alan Cox
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Cox @ 2014-10-08 23:29 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: One Thousand Gnomes, linux-serial, Greg Kroah-Hartman, Jiri Slaby, LKML

On Wed, 2014-10-08 at 22:43 +0200, Ricardo Ribalda Delgado wrote:
> Hello Alan
> 
> This patchset adds no extra locking features, if the drivers did not
> implement a locking mechanism (and none did) there is chance of
> conflict.
> 
> I can add a call to lock/unlock around uart_[gs]et_rs485_config. And
> then, inside the drivers, use the lock when the structure is used.
> 
> I would prefer to add it as new patches in the patchset, so in case
> this adds some bugs they can be bisected easily.


Makes sense.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls.
  2014-10-08 20:11   ` Alan Cox
  2014-10-08 20:43     ` Ricardo Ribalda Delgado
@ 2014-10-09  8:07     ` Ricardo Ribalda Delgado
  2014-10-09 14:16       ` Alan Cox
  1 sibling, 1 reply; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-10-09  8:07 UTC (permalink / raw)
  To: Alan Cox
  Cc: One Thousand Gnomes, linux-serial, Greg Kroah-Hartman, Jiri Slaby, LKML

Hello Alan

>
> What is the locking between setting/getting/driver use of the config ?
> This really needs a lock (termios sem I think is perhaps appropriate
> given when the values are normally referenced).

I tried implementing it with the sermios sem
((&(uart_port)->state->port.tty->termios_rwsem)), but some drivers
access the rs485 structure inside their irq handler. So I have see
options here

1) Protect the structure with uart_port->lock spinlock
2) Assume that an assignment is atomic on critical sections where I
cannot hold the rwsem.

I think 1) is more correct. Any issues that I continue in this
direction? Any better idea?


Thanks!

-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls.
  2014-10-09  8:07     ` Ricardo Ribalda Delgado
@ 2014-10-09 14:16       ` Alan Cox
  2014-11-05 19:37         ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 18+ messages in thread
From: Alan Cox @ 2014-10-09 14:16 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: One Thousand Gnomes, linux-serial, Greg Kroah-Hartman, Jiri Slaby, LKML

On Thu, 2014-10-09 at 10:07 +0200, Ricardo Ribalda Delgado wrote:
> Hello Alan
> 
> >
> > What is the locking between setting/getting/driver use of the config ?
> > This really needs a lock (termios sem I think is perhaps appropriate
> > given when the values are normally referenced).
> 
> I tried implementing it with the sermios sem
> ((&(uart_port)->state->port.tty->termios_rwsem)), but some drivers
> access the rs485 structure inside their irq handler. So I have see
> options here
> 
> 1) Protect the structure with uart_port->lock spinlock
> 2) Assume that an assignment is atomic on critical sections where I
> cannot hold the rwsem.
> 
> I think 1) is more correct. Any issues that I continue in this
> direction? Any better idea?

For uart #1 sounds right to me too.

Alan



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls.
  2014-10-09 14:16       ` Alan Cox
@ 2014-11-05 19:37         ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 18+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-05 19:37 UTC (permalink / raw)
  To: Alan Cox
  Cc: One Thousand Gnomes, linux-serial, Greg Kroah-Hartman, Jiri Slaby, LKML

Hello Alan

After almost one month with no other comments I am planning to resend
the patchset including the lock patch. May I add your Reviewed or
Acked by to any of the patches?

Thanks :)

On Thu, Oct 9, 2014 at 4:16 PM, Alan Cox <alan@linux.intel.com> wrote:
> On Thu, 2014-10-09 at 10:07 +0200, Ricardo Ribalda Delgado wrote:
>> Hello Alan
>>
>> >
>> > What is the locking between setting/getting/driver use of the config ?
>> > This really needs a lock (termios sem I think is perhaps appropriate
>> > given when the values are normally referenced).
>>
>> I tried implementing it with the sermios sem
>> ((&(uart_port)->state->port.tty->termios_rwsem)), but some drivers
>> access the rs485 structure inside their irq handler. So I have see
>> options here
>>
>> 1) Protect the structure with uart_port->lock spinlock
>> 2) Assume that an assignment is atomic on critical sections where I
>> cannot hold the rwsem.
>>
>> I think 1) is more correct. Any issues that I continue in this
>> direction? Any better idea?
>
> For uart #1 sounds right to me too.
>
> Alan
>
>



-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-11-05 19:38 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1412798258-23655-1-git-send-email-ricardo.ribalda@gmail.com>
2014-10-08 19:57 ` [PATCH 01/12] serial/max310x: Remove obsolete #ifset TIOC[SG]RS485 Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 02/12] serial/sc16is7xx: " Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 03/12] serial_core: Handle TIOC[GS]RS485 ioctls Ricardo Ribalda Delgado
2014-10-08 20:11   ` Alan Cox
2014-10-08 20:43     ` Ricardo Ribalda Delgado
2014-10-08 23:29       ` Alan Cox
2014-10-09  8:07     ` Ricardo Ribalda Delgado
2014-10-09 14:16       ` Alan Cox
2014-11-05 19:37         ` Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 04/12] serial/8250: Copy RS485 fields to serial_core Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 05/12] 8250/fintek: Use rs485 handler from serial_core Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 06/12] serial/8250: Remove obsolete handling of rs485 ioctls Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 07/12] serial/sc16is7xx: Use the rs485 functions on serial_core Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 08/12] serial/mcf: " Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 09/12] serial/atmel: " Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 10/12] serial/omap: " Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 11/12] drivers/max310: " Ricardo Ribalda Delgado
2014-10-08 19:57 ` [PATCH 12/12] serial_core: Remove call to driver-specific TIO[GS]RS485] Ricardo Ribalda Delgado

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).