linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RS485 serial communication on ColdFire
@ 2013-01-13 23:21 Kevin Nguyen
  2013-01-14  3:33 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Nguyen @ 2013-01-13 23:21 UTC (permalink / raw)
  To: linux-serial

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

Hi

I've attached the patch that adds support RS485 communication in
ColdFire serial driver.

As defined in Documentation/serial/serial-rs485.txt, switching between
read or write mode can be done by toggling RTS signal that is
supported by ColdFire chips.

I actually wrote it more than a year ago (on Linux 3.2) but haven't
seen any similar patch for ColdFire microcontrollers so that I think
it would be useful for someone using this serial driver for RS485
communication. It is tested on my MCF5271 board.

Your comments are appreciated.

Cheers
--
Quoc-Viet (Kevin) Nguyen

[-- Attachment #2: 0001-mcf-Add-support-RS485-in-ColdFire-serial-driver.patch --]
[-- Type: application/octet-stream, Size: 5194 bytes --]

From 002fe4516d01fbf794450fd6bf95ff66e795d5fa Mon Sep 17 00:00:00 2001
From: Quoc-Viet Nguyen <afelion@gmail.com>
Date: Tue, 8 Jan 2013 17:56:39 +1000
Subject: [PATCH] mcf: Add support RS485 in ColdFire serial driver

Signed-off-by: Quoc-Viet Nguyen <afelion@gmail.com>
---
 drivers/tty/serial/Kconfig |    6 ++++
 drivers/tty/serial/mcf.c   |   82 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 925a1e5..09da953 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1042,6 +1042,12 @@ config SERIAL_MCF_CONSOLE
 	help
 	  Enable a ColdFire internal serial port to be the system console.
 
+config SERIAL_MCF_RS485
+	bool "ColdFire serial RS485 support"
+	depends on SERIAL_MCF
+	help
+	  Automatically switching read/write mode by toggling /RTS signal.
+
 config SERIAL_PMACZILOG
 	tristate "Mac or PowerMac z85c30 ESCC support"
 	depends on (M68K && MAC) || (PPC_OF && PPC_PMAC)
diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 9afca09..c462707 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -27,6 +27,7 @@
 #include <asm/mcfsim.h>
 #include <asm/mcfuart.h>
 #include <asm/nettel.h>
+#include <asm/uaccess.h>
 
 /****************************************************************************/
 
@@ -55,6 +56,9 @@ struct mcf_uart {
 	struct uart_port	port;
 	unsigned int		sigs;		/* Local copy of line sigs */
 	unsigned char		imr;		/* Local IMR mirror */
+#if defined(CONFIG_SERIAL_MCF_RS485)
+	struct serial_rs485	rs485;
+#endif
 };
 
 /****************************************************************************/
@@ -101,6 +105,14 @@ static void mcf_start_tx(struct uart_port *port)
 {
 	struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
 
+#if defined(CONFIG_SERIAL_MCF_RS485)
+	if (pp->rs485.flags & SER_RS485_ENABLED) {
+		/* Enable Transmitter */
+		writeb(MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR);
+		/* Manually assert RTS */
+		writeb(MCFUART_UOP_RTS, port->membase + MCFUART_UOP1);
+	}
+#endif
 	pp->imr |= MCFUART_UIR_TXREADY;
 	writeb(pp->imr, port->membase + MCFUART_UIMR);
 }
@@ -248,6 +260,15 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
 		mr2 |= MCFUART_MR2_TXCTS;
 	}
 
+#if defined(CONFIG_SERIAL_MCF_RS485)
+	{
+		struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
+		if (pp->rs485.flags & SER_RS485_ENABLED) {
+			printk(KERN_DEBUG "Setting UART to RS485\n");
+			mr2 |= MCFUART_MR2_TXRTS;
+		}
+	}
+#endif
 	spin_lock_irqsave(&port->lock, flags);
 	uart_update_timeout(port, termios->c_cflag, baud);
 	writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR);
@@ -342,6 +363,11 @@ static void mcf_tx_chars(struct mcf_uart *pp)
 	if (xmit->head == xmit->tail) {
 		pp->imr &= ~MCFUART_UIR_TXREADY;
 		writeb(pp->imr, port->membase + MCFUART_UIMR);
+#if defined(CONFIG_SERIAL_MCF_RS485)
+		/* disable Transmitter to negate automatically RTS */
+		if (pp->rs485.flags & SER_RS485_ENABLED)
+			writeb(MCFUART_UCR_TXDISABLE, port->membase + MCFUART_UCR);
+#endif
 	}
 }
 
@@ -418,6 +444,59 @@ static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser)
 
 /****************************************************************************/
 
+#if defined(CONFIG_SERIAL_MCF_RS485)
+static void 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;
+	unsigned char mr1, mr2;
+
+	spin_lock_irqsave(&port->lock, flags);
+	/* get mode register */
+	mr1 = readb(port->membase + MCFUART_UMR);
+	mr2 = readb(port->membase + MCFUART_UMR);
+	if (rs485->flags & SER_RS485_ENABLED) {
+		printk(KERN_DEBUG "Setting UART to RS485\n");
+		/* Automatically negate RTS after TX is complete */
+		mr2 |= MCFUART_MR2_TXRTS;
+	} else {
+		printk(KERN_DEBUG "Setting UART to RS232\n");
+		mr2 &= ~MCFUART_MR2_TXRTS;
+	}
+	writeb(mr1, port->membase + MCFUART_UMR);
+	writeb(mr2, port->membase + MCFUART_UMR);
+	pp->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;
+}
+#endif
+
+/****************************************************************************/
+
 /*
  *	Define the basic serial functions we support.
  */
@@ -438,6 +517,9 @@ static const struct uart_ops mcf_uart_ops = {
 	.release_port	= mcf_release_port,
 	.config_port	= mcf_config_port,
 	.verify_port	= mcf_verify_port,
+#if defined(CONFIG_SERIAL_MCF_RS485)
+	.ioctl		= mcf_ioctl,
+#endif
 };
 
 static struct mcf_uart mcf_ports[4];
-- 
1.7.10.4


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

* Re: [PATCH] RS485 serial communication on ColdFire
  2013-01-13 23:21 [PATCH] RS485 serial communication on ColdFire Kevin Nguyen
@ 2013-01-14  3:33 ` Greg KH
  2013-01-14  8:12   ` Kevin Nguyen
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2013-01-14  3:33 UTC (permalink / raw)
  To: Kevin Nguyen; +Cc: linux-serial

On Mon, Jan 14, 2013 at 09:21:52AM +1000, Kevin Nguyen wrote:
> Hi
> 
> I've attached the patch that adds support RS485 communication in
> ColdFire serial driver.
> 
> As defined in Documentation/serial/serial-rs485.txt, switching between
> read or write mode can be done by toggling RTS signal that is
> supported by ColdFire chips.
> 
> I actually wrote it more than a year ago (on Linux 3.2) but haven't
> seen any similar patch for ColdFire microcontrollers so that I think
> it would be useful for someone using this serial driver for RS485
> communication. It is tested on my MCF5271 board.
> 
> Your comments are appreciated.

Is there any way to do this so that the option can be enabled at
runtime, instead of build time?  Also, getting rid of a lot of the
#ifdefs in the .c file would be great to accomplish.

thanks,

greg k-h

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

* Re: [PATCH] RS485 serial communication on ColdFire
  2013-01-14  3:33 ` Greg KH
@ 2013-01-14  8:12   ` Kevin Nguyen
  2013-01-14 14:28     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Nguyen @ 2013-01-14  8:12 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-serial

[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]

Hi Greg,

The RS485 mode can be switched on/off from userspace by using the flag
SER_RS485_ENABLED, therefore I've removed those #ifdefs in the patch.

Regards

On Mon, Jan 14, 2013 at 1:33 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Mon, Jan 14, 2013 at 09:21:52AM +1000, Kevin Nguyen wrote:
>> Hi
>>
>> I've attached the patch that adds support RS485 communication in
>> ColdFire serial driver.
>>
>> As defined in Documentation/serial/serial-rs485.txt, switching between
>> read or write mode can be done by toggling RTS signal that is
>> supported by ColdFire chips.
>>
>> I actually wrote it more than a year ago (on Linux 3.2) but haven't
>> seen any similar patch for ColdFire microcontrollers so that I think
>> it would be useful for someone using this serial driver for RS485
>> communication. It is tested on my MCF5271 board.
>>
>> Your comments are appreciated.
>
> Is there any way to do this so that the option can be enabled at
> runtime, instead of build time?  Also, getting rid of a lot of the
> #ifdefs in the .c file would be great to accomplish.
>
> thanks,
>
> greg k-h



-- 
Quoc-Viet (Kevin) Nguyen

[-- Attachment #2: 0001-mcf-Add-support-RS485-in-ColdFire-serial-driver.patch --]
[-- Type: application/octet-stream, Size: 4537 bytes --]

From 99a0806accd090dbb97bb6be2ff92af60a3db099 Mon Sep 17 00:00:00 2001
From: Quoc-Viet Nguyen <afelion@gmail.com>
Date: Tue, 8 Jan 2013 17:56:39 +1000
Subject: [PATCH] mcf: Add support RS485 in ColdFire serial driver

Signed-off-by: Quoc-Viet Nguyen <afelion@gmail.com>
---
 drivers/tty/serial/mcf.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 9afca09..fbcc494 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -27,6 +27,7 @@
 #include <asm/mcfsim.h>
 #include <asm/mcfuart.h>
 #include <asm/nettel.h>
+#include <asm/uaccess.h>
 
 /****************************************************************************/
 
@@ -55,6 +56,7 @@ 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;
 };
 
 /****************************************************************************/
@@ -101,6 +103,12 @@ 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) {
+		/* Enable Transmitter */
+		writeb(MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR);
+		/* Manually assert RTS */
+		writeb(MCFUART_UOP_RTS, port->membase + MCFUART_UOP1);
+	}
 	pp->imr |= MCFUART_UIR_TXREADY;
 	writeb(pp->imr, port->membase + MCFUART_UIMR);
 }
@@ -196,6 +204,7 @@ static void mcf_shutdown(struct uart_port *port)
 static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
 	struct ktermios *old)
 {
+	struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
 	unsigned long flags;
 	unsigned int baud, baudclk;
 #if defined(CONFIG_M5272)
@@ -248,6 +257,11 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
 		mr2 |= MCFUART_MR2_TXCTS;
 	}
 
+	if (pp->rs485.flags & SER_RS485_ENABLED) {
+		printk(KERN_DEBUG "Setting UART to RS485\n");
+		mr2 |= MCFUART_MR2_TXRTS;
+	}
+
 	spin_lock_irqsave(&port->lock, flags);
 	uart_update_timeout(port, termios->c_cflag, baud);
 	writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR);
@@ -342,6 +356,9 @@ static void mcf_tx_chars(struct mcf_uart *pp)
 	if (xmit->head == xmit->tail) {
 		pp->imr &= ~MCFUART_UIR_TXREADY;
 		writeb(pp->imr, port->membase + MCFUART_UIMR);
+		/* disable Transmitter to negate automatically RTS */
+		if (pp->rs485.flags & SER_RS485_ENABLED)
+			writeb(MCFUART_UCR_TXDISABLE, port->membase + MCFUART_UCR);
 	}
 }
 
@@ -418,6 +435,57 @@ static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser)
 
 /****************************************************************************/
 
+static void 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;
+	unsigned char mr1, mr2;
+
+	spin_lock_irqsave(&port->lock, flags);
+	/* get mode register */
+	mr1 = readb(port->membase + MCFUART_UMR);
+	mr2 = readb(port->membase + MCFUART_UMR);
+	if (rs485->flags & SER_RS485_ENABLED) {
+		printk(KERN_DEBUG "Setting UART to RS485\n");
+		/* Automatically negate RTS after TX is complete */
+		mr2 |= MCFUART_MR2_TXRTS;
+	} else {
+		printk(KERN_DEBUG "Setting UART to RS232\n");
+		mr2 &= ~MCFUART_MR2_TXRTS;
+	}
+	writeb(mr1, port->membase + MCFUART_UMR);
+	writeb(mr2, port->membase + MCFUART_UMR);
+	pp->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;
+}
+
+/****************************************************************************/
+
 /*
  *	Define the basic serial functions we support.
  */
@@ -438,6 +506,7 @@ 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];
-- 
1.7.10.4


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

* Re: [PATCH] RS485 serial communication on ColdFire
  2013-01-14  8:12   ` Kevin Nguyen
@ 2013-01-14 14:28     ` Greg KH
  2013-01-15  2:09       ` Kevin Nguyen
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2013-01-14 14:28 UTC (permalink / raw)
  To: Kevin Nguyen; +Cc: linux-serial

On Mon, Jan 14, 2013 at 06:12:34PM +1000, Kevin Nguyen wrote:
> Hi Greg,
> 
> The RS485 mode can be switched on/off from userspace by using the flag
> SER_RS485_ENABLED, therefore I've removed those #ifdefs in the patch.

Much better, thanks.

Can you also remove the debugging printk() messages you added?  Or,
convert them to dev_dbg() calls instead?  If you run your patch through
the scripts/checkpatch.pl tool, it should tell you things like this.

thanks,

greg k-h

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

* Re: [PATCH] RS485 serial communication on ColdFire
  2013-01-14 14:28     ` Greg KH
@ 2013-01-15  2:09       ` Kevin Nguyen
  2013-01-15  2:30         ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Nguyen @ 2013-01-15  2:09 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-serial

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

On Tue, Jan 15, 2013 at 12:28 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> Can you also remove the debugging printk() messages you added?  Or,
> convert them to dev_dbg() calls instead?  If you run your patch through
> the scripts/checkpatch.pl tool, it should tell you things like this.

Those issues are fixed in the patch attached.

Thanks
--
Quoc-Viet (Kevin) Nguyen

[-- Attachment #2: 0001-mcf-Add-support-RS485-in-ColdFire-serial-driver.patch --]
[-- Type: application/octet-stream, Size: 4604 bytes --]

From 8630b0b865688c95fb10f202e365e4eaca3ba3bc Mon Sep 17 00:00:00 2001
From: Quoc-Viet Nguyen <afelion@gmail.com>
Date: Tue, 15 Jan 2013 09:32:53 +1000
Subject: [PATCH] mcf: Add support RS485 in ColdFire serial driver

Signed-off-by: Quoc-Viet Nguyen <afelion@gmail.com>
---
 drivers/tty/serial/mcf.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 9afca09..7f770df 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -23,6 +23,7 @@
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 #include <linux/io.h>
+#include <linux/uaccess.h>
 #include <asm/coldfire.h>
 #include <asm/mcfsim.h>
 #include <asm/mcfuart.h>
@@ -55,6 +56,7 @@ 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 */
 };
 
 /****************************************************************************/
@@ -101,6 +103,12 @@ 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) {
+		/* Enable Transmitter */
+		writeb(MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR);
+		/* Manually assert RTS */
+		writeb(MCFUART_UOP_RTS, port->membase + MCFUART_UOP1);
+	}
 	pp->imr |= MCFUART_UIR_TXREADY;
 	writeb(pp->imr, port->membase + MCFUART_UIMR);
 }
@@ -196,6 +204,7 @@ static void mcf_shutdown(struct uart_port *port)
 static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
 	struct ktermios *old)
 {
+	struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
 	unsigned long flags;
 	unsigned int baud, baudclk;
 #if defined(CONFIG_M5272)
@@ -248,6 +257,11 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
 		mr2 |= MCFUART_MR2_TXCTS;
 	}
 
+	if (pp->rs485.flags & SER_RS485_ENABLED) {
+		dev_dbg(port->dev, "Setting UART to RS485\n");
+		mr2 |= MCFUART_MR2_TXRTS;
+	}
+
 	spin_lock_irqsave(&port->lock, flags);
 	uart_update_timeout(port, termios->c_cflag, baud);
 	writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR);
@@ -342,6 +356,10 @@ static void mcf_tx_chars(struct mcf_uart *pp)
 	if (xmit->head == xmit->tail) {
 		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)
+			writeb(MCFUART_UCR_TXDISABLE,
+				port->membase + MCFUART_UCR);
 	}
 }
 
@@ -418,6 +436,58 @@ 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)
+{
+	struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
+	unsigned long flags;
+	unsigned char mr1, mr2;
+
+	spin_lock_irqsave(&port->lock, flags);
+	/* Get mode registers */
+	mr1 = readb(port->membase + MCFUART_UMR);
+	mr2 = readb(port->membase + MCFUART_UMR);
+	if (rs485->flags & SER_RS485_ENABLED) {
+		dev_dbg(port->dev, "Setting UART to RS485\n");
+		/* Automatically negate RTS after TX completes */
+		mr2 |= MCFUART_MR2_TXRTS;
+	} else {
+		dev_dbg(port->dev, "Setting UART to RS232\n");
+		mr2 &= ~MCFUART_MR2_TXRTS;
+	}
+	writeb(mr1, port->membase + MCFUART_UMR);
+	writeb(mr2, port->membase + MCFUART_UMR);
+	pp->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;
+}
+
+/****************************************************************************/
+
 /*
  *	Define the basic serial functions we support.
  */
@@ -438,6 +508,7 @@ 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];
-- 
1.7.10.4


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

* Re: [PATCH] RS485 serial communication on ColdFire
  2013-01-15  2:09       ` Kevin Nguyen
@ 2013-01-15  2:30         ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2013-01-15  2:30 UTC (permalink / raw)
  To: Kevin Nguyen; +Cc: linux-serial

On Tue, Jan 15, 2013 at 12:09:28PM +1000, Kevin Nguyen wrote:
> On Tue, Jan 15, 2013 at 12:28 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> > Can you also remove the debugging printk() messages you added?  Or,
> > convert them to dev_dbg() calls instead?  If you run your patch through
> > the scripts/checkpatch.pl tool, it should tell you things like this.
> 
> Those issues are fixed in the patch attached.

Nice, I'll queue this up later this week unless someone objects.

thanks,

greg k-h

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

end of thread, other threads:[~2013-01-15  2:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-13 23:21 [PATCH] RS485 serial communication on ColdFire Kevin Nguyen
2013-01-14  3:33 ` Greg KH
2013-01-14  8:12   ` Kevin Nguyen
2013-01-14 14:28     ` Greg KH
2013-01-15  2:09       ` Kevin Nguyen
2013-01-15  2:30         ` Greg KH

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