public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: bart.hartgers@gmail.com
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bart Hartgers <bart.hartgers@gmail.com>
Subject: [PATCH 3/7] ark3116: (3rd try) Replace cmget
Date: Sun, 25 Oct 2009 18:51:00 +0100	[thread overview]
Message-ID: <20091025175321.276761473@gmail.com> (raw)
In-Reply-To: 20091025175057.270011110@gmail.com

[-- Attachment #1: 0020_ark3116_cmget.patch --]
[-- Type: text/plain, Size: 1869 bytes --]

Signed-off-by: Bart Hartgers <bart.hartgers@gmail.com>
---
Index: linux-2.6.32-rc4/drivers/usb/serial/ark3116.c
===================================================================
--- linux-2.6.32-rc4.orig/drivers/usb/serial/ark3116.c	2009-10-18 16:20:02.000000000 +0200
+++ linux-2.6.32-rc4/drivers/usb/serial/ark3116.c	2009-10-18 16:20:13.000000000 +0200
@@ -526,32 +526,21 @@ static int ark3116_ioctl(struct tty_stru
 static int ark3116_tiocmget(struct tty_struct *tty, struct file *file)
 {
 	struct usb_serial_port *port = tty->driver_data;
-	struct usb_serial *serial = port->serial;
-	char *buf;
-	char temp;
-
-	/* seems like serial port status info (RTS, CTS, ...) is stored
-	 * in reg(?) 0x0006
-	 * pcb connection point 11 = GND -> sets bit4 of response
-	 * pcb connection point  7 = GND -> sets bit6 of response
-	 */
-
-	buf = kmalloc(1, GFP_KERNEL);
-	if (!buf) {
-		dbg("error kmalloc");
-		return -ENOMEM;
-	}
-
-	/* read register */
-	ARK3116_RCV_QUIET(serial, 0xFE, 0xC0, 0x0000, 0x0006, buf);
-	temp = buf[0];
-	kfree(buf);
-
-	/* i do not really know if bit4=CTS and bit6=DSR... just a
-	 * quick guess!
-	 */
-	return (temp & (1<<4) ? TIOCM_CTS : 0)
-	       | (temp & (1<<6) ? TIOCM_DSR : 0);
+	struct ark3116_private *priv = usb_get_serial_port_data(port);
+
+	/* read modem status */
+	unsigned status = atomic_read(&priv->msr);
+	/* modem control is output */
+	unsigned ctrl = atomic_read(&priv->mcr);
+
+	return  (status & UART_MSR_DSR  ? TIOCM_DSR  : 0) |
+		(status & UART_MSR_CTS  ? TIOCM_CTS  : 0) |
+		(status & UART_MSR_RI   ? TIOCM_RI   : 0) |
+		(status & UART_MSR_DCD  ? TIOCM_CD   : 0) |
+		(ctrl   & UART_MCR_DTR  ? TIOCM_DTR  : 0) |
+		(ctrl   & UART_MCR_RTS  ? TIOCM_RTS  : 0) |
+		(ctrl   & UART_MCR_OUT1 ? TIOCM_OUT1 : 0) |
+		(ctrl   & UART_MCR_OUT2 ? TIOCM_OUT2 : 0);
 }
 
 static struct usb_driver ark3116_driver = {

-- 

  parent reply	other threads:[~2009-10-25 17:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-25 17:50 [PATCH 0/7] ark3116: (3rd try) driver rework bart.hartgers
2009-10-25 17:50 ` [PATCH 1/7] ark3116: (3rd try) Setup some basic infrastructure for new ark3116 driver bart.hartgers
2009-10-27 17:46   ` Greg KH
2009-10-27 21:35     ` Bart Hartgers
2009-10-27 22:11       ` Greg KH
2009-10-25 17:50 ` [PATCH 2/7] ark3116: (3rd try) Make existing functions 16450-aware and add close and release functions bart.hartgers
2009-10-25 19:56   ` Oliver Neukum
2009-10-25 17:51 ` bart.hartgers [this message]
2009-10-25 19:52   ` [PATCH 3/7] ark3116: (3rd try) Replace cmget Oliver Neukum
2009-10-25 19:56     ` Bart Hartgers
2009-10-25 22:08       ` Oliver Neukum
2009-10-25 17:51 ` [PATCH 4/7] ark3116: (3rd try) Add atomic set-and-clear function bart.hartgers
2009-10-25 17:51 ` [PATCH 5/7] ark3116: (3rd try) Add cmset and break bart.hartgers
2009-10-25 17:51 ` [PATCH 6/7] ark3116: (3rd try) Callbacks for interrupt and bulk read bart.hartgers
2009-10-25 17:51 ` [PATCH 7/7] ark3116: (3rd try) Cleanup of now unneeded functions bart.hartgers
2009-10-25 17:53 ` [PATCH 0/7] ark3116: (3rd try) driver rework Greg KH

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=20091025175321.276761473@gmail.com \
    --to=bart.hartgers@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox