diff options
author | Kees Schoenmakers <k.schoenmakers@sigmae.nl> | 2009-09-19 16:13:18 -0400 |
---|---|---|
committer | Live-CD User <linux@linux.site> | 2009-09-19 16:13:18 -0400 |
commit | 0f608f8926968b4beee2cb00ef05522ad84f36eb (patch) | |
tree | b12f061ef319a12b8ea8089347b4e7aa58d01f25 /drivers/usb/serial | |
parent | f8a7c1a976a6672204c7f4f0f694f33715dfa617 (diff) |
MOS7720 has no tiocmget method
Fix the tiocmget/mset handling on the mos7720 USB serial port.
[Minor space reformatting for coding style - Alan]
Signed-off-by: Kees Schoenmakers <k.schoenmakers@sigmae.nl>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/mos7720.c | 101 |
1 files changed, 64 insertions, 37 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index ccd4dd340d2c..759cdd5ae74d 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -85,7 +85,7 @@ static int debug; | |||
85 | #define MOSCHIP_DEVICE_ID_7720 0x7720 | 85 | #define MOSCHIP_DEVICE_ID_7720 0x7720 |
86 | #define MOSCHIP_DEVICE_ID_7715 0x7715 | 86 | #define MOSCHIP_DEVICE_ID_7715 0x7715 |
87 | 87 | ||
88 | static struct usb_device_id moschip_port_id_table [] = { | 88 | static struct usb_device_id moschip_port_id_table[] = { |
89 | { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, | 89 | { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, |
90 | { } /* terminating entry */ | 90 | { } /* terminating entry */ |
91 | }; | 91 | }; |
@@ -1264,6 +1264,67 @@ static int get_lsr_info(struct tty_struct *tty, | |||
1264 | return 0; | 1264 | return 0; |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | static int mos7720_tiocmget(struct tty_struct *tty, struct file *file) | ||
1268 | { | ||
1269 | struct usb_serial_port *port = tty->driver_data; | ||
1270 | struct moschip_port *mos7720_port = usb_get_serial_port_data(port); | ||
1271 | unsigned int result = 0; | ||
1272 | unsigned int mcr ; | ||
1273 | unsigned int msr ; | ||
1274 | |||
1275 | dbg("%s - port %d", __func__, port->number); | ||
1276 | |||
1277 | mcr = mos7720_port->shadowMCR; | ||
1278 | msr = mos7720_port->shadowMSR; | ||
1279 | |||
1280 | result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */ | ||
1281 | | ((mcr & UART_MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */ | ||
1282 | | ((msr & UART_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */ | ||
1283 | | ((msr & UART_MSR_DCD) ? TIOCM_CAR : 0) /* 0x040 */ | ||
1284 | | ((msr & UART_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */ | ||
1285 | | ((msr & UART_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */ | ||
1286 | |||
1287 | dbg("%s -- %x", __func__, result); | ||
1288 | |||
1289 | return result; | ||
1290 | } | ||
1291 | |||
1292 | static int mos7720_tiocmset(struct tty_struct *tty, struct file *file, | ||
1293 | unsigned int set, unsigned int clear) | ||
1294 | { | ||
1295 | struct usb_serial_port *port = tty->driver_data; | ||
1296 | struct moschip_port *mos7720_port = usb_get_serial_port_data(port); | ||
1297 | unsigned int mcr ; | ||
1298 | unsigned char lmcr; | ||
1299 | |||
1300 | dbg("%s - port %d", __func__, port->number); | ||
1301 | dbg("he was at tiocmget"); | ||
1302 | |||
1303 | mcr = mos7720_port->shadowMCR; | ||
1304 | |||
1305 | if (set & TIOCM_RTS) | ||
1306 | mcr |= UART_MCR_RTS; | ||
1307 | if (set & TIOCM_DTR) | ||
1308 | mcr |= UART_MCR_DTR; | ||
1309 | if (set & TIOCM_LOOP) | ||
1310 | mcr |= UART_MCR_LOOP; | ||
1311 | |||
1312 | if (clear & TIOCM_RTS) | ||
1313 | mcr &= ~UART_MCR_RTS; | ||
1314 | if (clear & TIOCM_DTR) | ||
1315 | mcr &= ~UART_MCR_DTR; | ||
1316 | if (clear & TIOCM_LOOP) | ||
1317 | mcr &= ~UART_MCR_LOOP; | ||
1318 | |||
1319 | mos7720_port->shadowMCR = mcr; | ||
1320 | lmcr = mos7720_port->shadowMCR; | ||
1321 | |||
1322 | send_mos_cmd(port->serial, MOS_WRITE, | ||
1323 | port->number - port->serial->minor, UART_MCR, &lmcr); | ||
1324 | |||
1325 | return 0; | ||
1326 | } | ||
1327 | |||
1267 | static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, | 1328 | static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, |
1268 | unsigned int __user *value) | 1329 | unsigned int __user *value) |
1269 | { | 1330 | { |
@@ -1301,14 +1362,6 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, | |||
1301 | mcr &= ~UART_MCR_LOOP; | 1362 | mcr &= ~UART_MCR_LOOP; |
1302 | break; | 1363 | break; |
1303 | 1364 | ||
1304 | case TIOCMSET: | ||
1305 | /* turn off the RTS and DTR and LOOPBACK | ||
1306 | * and then only turn on what was asked to */ | ||
1307 | mcr &= ~(UART_MCR_RTS | UART_MCR_DTR | UART_MCR_LOOP); | ||
1308 | mcr |= ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0); | ||
1309 | mcr |= ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0); | ||
1310 | mcr |= ((arg & TIOCM_LOOP) ? UART_MCR_LOOP : 0); | ||
1311 | break; | ||
1312 | } | 1365 | } |
1313 | 1366 | ||
1314 | mos7720_port->shadowMCR = mcr; | 1367 | mos7720_port->shadowMCR = mcr; |
@@ -1320,28 +1373,6 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, | |||
1320 | return 0; | 1373 | return 0; |
1321 | } | 1374 | } |
1322 | 1375 | ||
1323 | static int get_modem_info(struct moschip_port *mos7720_port, | ||
1324 | unsigned int __user *value) | ||
1325 | { | ||
1326 | unsigned int result = 0; | ||
1327 | unsigned int msr = mos7720_port->shadowMSR; | ||
1328 | unsigned int mcr = mos7720_port->shadowMCR; | ||
1329 | |||
1330 | result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */ | ||
1331 | | ((mcr & UART_MCR_RTS) ? TIOCM_RTS: 0) /* 0x004 */ | ||
1332 | | ((msr & UART_MSR_CTS) ? TIOCM_CTS: 0) /* 0x020 */ | ||
1333 | | ((msr & UART_MSR_DCD) ? TIOCM_CAR: 0) /* 0x040 */ | ||
1334 | | ((msr & UART_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */ | ||
1335 | | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ | ||
1336 | |||
1337 | |||
1338 | dbg("%s -- %x", __func__, result); | ||
1339 | |||
1340 | if (copy_to_user(value, &result, sizeof(int))) | ||
1341 | return -EFAULT; | ||
1342 | return 0; | ||
1343 | } | ||
1344 | |||
1345 | static int get_serial_info(struct moschip_port *mos7720_port, | 1376 | static int get_serial_info(struct moschip_port *mos7720_port, |
1346 | struct serial_struct __user *retinfo) | 1377 | struct serial_struct __user *retinfo) |
1347 | { | 1378 | { |
@@ -1392,17 +1423,11 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, | |||
1392 | /* FIXME: These should be using the mode methods */ | 1423 | /* FIXME: These should be using the mode methods */ |
1393 | case TIOCMBIS: | 1424 | case TIOCMBIS: |
1394 | case TIOCMBIC: | 1425 | case TIOCMBIC: |
1395 | case TIOCMSET: | ||
1396 | dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", | 1426 | dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", |
1397 | __func__, port->number); | 1427 | __func__, port->number); |
1398 | return set_modem_info(mos7720_port, cmd, | 1428 | return set_modem_info(mos7720_port, cmd, |
1399 | (unsigned int __user *)arg); | 1429 | (unsigned int __user *)arg); |
1400 | 1430 | ||
1401 | case TIOCMGET: | ||
1402 | dbg("%s (%d) TIOCMGET", __func__, port->number); | ||
1403 | return get_modem_info(mos7720_port, | ||
1404 | (unsigned int __user *)arg); | ||
1405 | |||
1406 | case TIOCGSERIAL: | 1431 | case TIOCGSERIAL: |
1407 | dbg("%s (%d) TIOCGSERIAL", __func__, port->number); | 1432 | dbg("%s (%d) TIOCGSERIAL", __func__, port->number); |
1408 | return get_serial_info(mos7720_port, | 1433 | return get_serial_info(mos7720_port, |
@@ -1557,6 +1582,8 @@ static struct usb_serial_driver moschip7720_2port_driver = { | |||
1557 | .attach = mos7720_startup, | 1582 | .attach = mos7720_startup, |
1558 | .release = mos7720_release, | 1583 | .release = mos7720_release, |
1559 | .ioctl = mos7720_ioctl, | 1584 | .ioctl = mos7720_ioctl, |
1585 | .tiocmget = mos7720_tiocmget, | ||
1586 | .tiocmset = mos7720_tiocmset, | ||
1560 | .set_termios = mos7720_set_termios, | 1587 | .set_termios = mos7720_set_termios, |
1561 | .write = mos7720_write, | 1588 | .write = mos7720_write, |
1562 | .write_room = mos7720_write_room, | 1589 | .write_room = mos7720_write_room, |