patch-2.3.40 linux/drivers/usb/acm.c
Next file: linux/drivers/usb/dc2xx.c
Previous file: linux/drivers/usb/Makefile
Back to the patch index
Back to the overall index
- Lines: 154
- Date:
Mon Jan 17 16:24:48 2000
- Orig file:
v2.3.39/linux/drivers/usb/acm.c
- Orig date:
Tue Jan 11 22:31:41 2000
diff -u --recursive --new-file v2.3.39/linux/drivers/usb/acm.c linux/drivers/usb/acm.c
@@ -1,10 +1,10 @@
/*
- * acm.c Version 0.12
+ * acm.c Version 0.14
*
* Copyright (c) 1999 Armin Fuerst <fuerst@in.tum.de>
* Copyright (c) 1999 Pavel Machek <pavel@suse.cz>
* Copyright (c) 1999 Johannes Erdfelt <jerdfelt@valinux.com>
- * Copyright (c) 1999 Vojtech Pavlik <vojtech@suse.cz>
+ * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
*
* USB Abstract Control Model driver for USB modems and ISDN adapters
*
@@ -16,6 +16,7 @@
* v0.11 - fixed flow control, read error doesn't stop reads
* v0.12 - added TIOCM ioctls, added break handling, made struct acm kmalloced
* v0.13 - added termios, added hangup
+ * v0.14 - sized down struct acm
*/
/*
@@ -52,6 +53,14 @@
#include "usb.h"
/*
+ * CMSPAR, some architectures can't have space and mark parity.
+ */
+
+#ifndef CMSPAR
+#define CMSPAR 0
+#endif
+
+/*
* Major and minor numbers.
*/
@@ -121,21 +130,20 @@
struct usb_device *dev; /* the coresponding usb device */
struct usb_interface *iface; /* the interfaces - +0 control +1 data */
struct tty_struct *tty; /* the coresponding tty */
+ struct urb ctrlurb, readurb, writeurb; /* urbs */
+ struct acm_line line; /* line coding (bits, stop, parity) */
unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
unsigned int ctrlout; /* output control lines (DTR, RTS) */
- struct acm_line line; /* line coding (bits, stop, parity) */
unsigned int writesize; /* max packet size for the output bulk endpoint */
- struct urb ctrlurb, readurb, writeurb; /* urbs */
- unsigned int minor; /* acm minor number */
- unsigned int present; /* this device is connected to the usb bus */
unsigned int used; /* someone has this acm's device open */
- unsigned int clocal; /* termios CLOCAL */
+ unsigned int minor; /* acm minor number */
+ unsigned char clocal; /* termios CLOCAL */
};
static struct usb_driver acm_driver;
static struct acm *acm_table[ACM_TTY_MINORS] = { NULL, /* .... */ };
-#define ACM_READY(acm) (acm && acm->present && acm->used)
+#define ACM_READY(acm) (acm && acm->dev && acm->used)
/*
* Functions for ACM control messages.
@@ -180,7 +188,7 @@
case ACM_IRQ_LINE_STATE:
- newctrl = le16_to_cpup(data);
+ newctrl = le16_to_cpup((__u16 *) data);
if (acm->tty && !acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
dbg("calling hangup");
@@ -257,7 +265,7 @@
{
struct acm *acm = acm_table[MINOR(tty->device)];
- if (!acm || !acm->present) return -EINVAL;
+ if (!acm || !acm->dev) return -EINVAL;
tty->driver_data = acm;
acm->tty = tty;
@@ -287,7 +295,7 @@
if (--acm->used) return;
- if (acm->present) {
+ if (acm->dev) {
acm_set_control(acm, acm->ctrlout = 0);
usb_unlink_urb(&acm->ctrlurb);
usb_unlink_urb(&acm->writeurb);
@@ -496,11 +504,14 @@
for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++);
if (acm_table[minor]) {
- dbg("no more free acm devices");
+ err("no more free acm devices");
return NULL;
}
- if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) return NULL;
+ if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) {
+ err("out of memory");
+ return NULL;
+ }
memset(acm, 0, sizeof(struct acm));
ctrlsize = epctrl->wMaxPacketSize;
@@ -508,10 +519,10 @@
acm->writesize = epwrite->wMaxPacketSize;
acm->iface = cfacm->interface;
acm->minor = minor;
- acm->present = 1;
acm->dev = dev;
if (!(buf = kmalloc(ctrlsize + readsize + acm->writesize, GFP_KERNEL))) {
+ err("out of memory");
kfree(acm);
return NULL;
}
@@ -523,15 +534,15 @@
buf += ctrlsize, readsize, acm_read_bulk, acm);
FILL_BULK_URB(&acm->writeurb, dev, usb_sndbulkpipe(dev, epwrite->bEndpointAddress),
- buf += readsize , acm->writesize, acm_write_bulk, acm);
+ buf += readsize, acm->writesize, acm_write_bulk, acm);
printk(KERN_INFO "ttyACM%d: USB ACM device\n", minor);
acm_set_control(acm, acm->ctrlout);
- acm->linecoding.speed = 115200;
- acm->linecoding.databits = 8;
- acm_set_coding(acm, &acm->linecoding);
+ acm->line.speed = cpu_to_le32(9600);
+ acm->line.databits = 8;
+ acm_set_line(acm, &acm->line);
usb_driver_claim_interface(&acm_driver, acm->iface + 0, acm);
usb_driver_claim_interface(&acm_driver, acm->iface + 1, acm);
@@ -546,12 +557,12 @@
{
struct acm *acm = ptr;
- if (!acm || !acm->present) {
+ if (!acm || !acm->dev) {
dbg("disconnect on nonexisting interface");
return;
}
- acm->present = 0;
+ acm->dev = NULL;
usb_unlink_urb(&acm->ctrlurb);
usb_unlink_urb(&acm->readurb);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)