Merge branch 'master' into upstream
[safe/jmp/linux-2.6] / drivers / isdn / gigaset / interface.c
index ac408ac..bd2e426 100644 (file)
@@ -33,7 +33,7 @@ static int if_lock(struct cardstate *cs, int *arg)
        }
 
        if (!cmd && atomic_read(&cs->mstate) == MS_LOCKED
-           && atomic_read(&cs->connected)) {
+           && cs->connected) {
                cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS);
                cs->ops->baud_rate(cs, B115200);
                cs->ops->set_line_ctrl(cs, CS8);
@@ -107,6 +107,11 @@ static int if_config(struct cardstate *cs, int *arg)
        if (atomic_read(&cs->mstate) != MS_LOCKED)
                return -EBUSY;
 
+       if (!cs->connected) {
+               err("not connected!");
+               return -ENODEV;
+       }
+
        *arg = 0;
        return gigaset_enterconfigmode(cs);
 }
@@ -246,7 +251,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
                        break;
                case GIGASET_BRKCHARS:
                        //FIXME test if MS_LOCKED
-                       if (!atomic_read(&cs->connected)) {
+                       if (!cs->connected) {
                                gig_dbg(DEBUG_ANY,
                                    "can't communicate with unplugged device");
                                retval = -ENODEV;
@@ -327,7 +332,7 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
        if (mutex_lock_interruptible(&cs->mutex))
                return -ERESTARTSYS; // FIXME -EINTR?
 
-       if (!atomic_read(&cs->connected)) {
+       if (!cs->connected) {
                gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
                retval = -ENODEV;
        } else {
@@ -362,7 +367,7 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
        else if (atomic_read(&cs->mstate) != MS_LOCKED) {
                warn("can't write to unlocked device");
                retval = -EBUSY;
-       } else if (!atomic_read(&cs->connected)) {
+       } else if (!cs->connected) {
                gig_dbg(DEBUG_ANY, "can't write to unplugged device");
                retval = -EBUSY; //FIXME
        } else {
@@ -396,7 +401,7 @@ static int if_write_room(struct tty_struct *tty)
        else if (atomic_read(&cs->mstate) != MS_LOCKED) {
                warn("can't write to unlocked device");
                retval = -EBUSY; //FIXME
-       } else if (!atomic_read(&cs->connected)) {
+       } else if (!cs->connected) {
                gig_dbg(DEBUG_ANY, "can't write to unplugged device");
                retval = -EBUSY; //FIXME
        } else
@@ -428,7 +433,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
        else if (atomic_read(&cs->mstate) != MS_LOCKED) {
                warn("can't write to unlocked device");
                retval = -EBUSY;
-       } else if (!atomic_read(&cs->connected)) {
+       } else if (!cs->connected) {
                gig_dbg(DEBUG_ANY, "can't write to unplugged device");
                retval = -EBUSY; //FIXME
        } else
@@ -508,7 +513,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
                goto out;
        }
 
-       if (!atomic_read(&cs->connected)) {
+       if (!cs->connected) {
                gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
                goto out;
        }
@@ -620,7 +625,14 @@ void gigaset_if_init(struct cardstate *cs)
                return;
 
        tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs);
-       tty_register_device(drv->tty, cs->minor_index, NULL);
+       cs->class = tty_register_device(drv->tty, cs->minor_index, NULL);
+
+       if (!IS_ERR(cs->class))
+               class_set_devdata(cs->class, cs);
+       else {
+               warn("could not register device to the tty subsystem");
+               cs->class = NULL;
+       }
 }
 
 void gigaset_if_free(struct cardstate *cs)
@@ -633,6 +645,7 @@ void gigaset_if_free(struct cardstate *cs)
 
        tasklet_disable(&cs->if_wake_tasklet);
        tasklet_kill(&cs->if_wake_tasklet);
+       cs->class = NULL;
        tty_unregister_device(drv->tty, cs->minor_index);
 }
 
@@ -660,10 +673,9 @@ EXPORT_SYMBOL_GPL(gigaset_if_receive);
  *     drv             Driver
  *     procname        Name of the driver (e.g. for /proc/tty/drivers)
  *     devname         Name of the device files (prefix without minor number)
- *     devfsname       Devfs name of the device files without %d
  */
 void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
-                          const char *devname, const char *devfsname)
+                          const char *devname)
 {
        unsigned minors = drv->minors;
        int ret;
@@ -679,7 +691,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
        tty->major =            GIG_MAJOR,
        tty->type =             TTY_DRIVER_TYPE_SERIAL,
        tty->subtype =          SERIAL_TYPE_NORMAL,
-       tty->flags =            TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS,
+       tty->flags =            TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 
        tty->driver_name =      procname;
        tty->name =             devname;
@@ -687,7 +699,6 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
        tty->num =              drv->minors;
 
        tty->owner =            THIS_MODULE;
-       tty->devfs_name =       devfsname;
 
        tty->init_termios          = tty_std_termios; //FIXME
        tty->init_termios.c_cflag  = B9600 | CS8 | CREAD | HUPCL | CLOCAL; //FIXME