Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[pandora-kernel.git] / drivers / isdn / gigaset / interface.c
index 956381c..820a309 100644 (file)
@@ -107,7 +107,7 @@ static int if_config(struct cardstate *cs, int *arg)
                return -EBUSY;
 
        if (!cs->connected) {
-               err("not connected!");
+               pr_err("%s: not connected\n", __func__);
                return -ENODEV;
        }
 
@@ -143,9 +143,6 @@ static const struct tty_operations if_ops = {
        .set_termios =          if_set_termios,
        .throttle =             if_throttle,
        .unthrottle =           if_unthrottle,
-#if 0
-       .break_ctl =            serial_break,
-#endif
        .tiocmget =             if_tiocmget,
        .tiocmset =             if_tiocmset,
 };
@@ -188,7 +185,7 @@ static void if_close(struct tty_struct *tty, struct file *filp)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return;
        }
 
@@ -196,7 +193,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
 
        mutex_lock(&cs->mutex);
 
-       if (!cs->open_count)
+       if (!cs->connected)
+               gig_dbg(DEBUG_IF, "not connected");     /* nothing to do */
+       else if (!cs->open_count)
                dev_warn(cs->dev, "%s: device not opened\n", __func__);
        else {
                if (!--cs->open_count) {
@@ -222,7 +221,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return -ENODEV;
        }
 
@@ -231,7 +230,10 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
        if (mutex_lock_interruptible(&cs->mutex))
                return -ERESTARTSYS; // FIXME -EINTR?
 
-       if (!cs->open_count)
+       if (!cs->connected) {
+               gig_dbg(DEBUG_IF, "not connected");
+               retval = -ENODEV;
+       } else if (!cs->open_count)
                dev_warn(cs->dev, "%s: device not opened\n", __func__);
        else {
                retval = 0;
@@ -251,13 +253,6 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
                                retval = put_user(int_arg, (int __user *) arg);
                        break;
                case GIGASET_BRKCHARS:
-                       //FIXME test if MS_LOCKED
-                       if (!cs->connected) {
-                               gig_dbg(DEBUG_ANY,
-                                   "can't communicate with unplugged device");
-                               retval = -ENODEV;
-                               break;
-                       }
                        retval = copy_from_user(&buf,
                                        (const unsigned char __user *) arg, 6)
                                ? -EFAULT : 0;
@@ -297,7 +292,7 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return -ENODEV;
        }
 
@@ -323,7 +318,7 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return -ENODEV;
        }
 
@@ -334,7 +329,7 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
                return -ERESTARTSYS; // FIXME -EINTR?
 
        if (!cs->connected) {
-               gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
+               gig_dbg(DEBUG_IF, "not connected");
                retval = -ENODEV;
        } else {
                mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR);
@@ -354,7 +349,7 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return -ENODEV;
        }
 
@@ -363,14 +358,14 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
        if (mutex_lock_interruptible(&cs->mutex))
                return -ERESTARTSYS; // FIXME -EINTR?
 
-       if (!cs->open_count)
+       if (!cs->connected) {
+               gig_dbg(DEBUG_IF, "not connected");
+               retval = -ENODEV;
+       } else if (!cs->open_count)
                dev_warn(cs->dev, "%s: device not opened\n", __func__);
        else if (cs->mstate != MS_LOCKED) {
                dev_warn(cs->dev, "can't write to unlocked device\n");
                retval = -EBUSY;
-       } else if (!cs->connected) {
-               gig_dbg(DEBUG_ANY, "can't write to unplugged device");
-               retval = -EBUSY; //FIXME
        } else {
                retval = cs->ops->write_cmd(cs, buf, count,
                                            &cs->if_wake_tasklet);
@@ -388,7 +383,7 @@ static int if_write_room(struct tty_struct *tty)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return -ENODEV;
        }
 
@@ -397,14 +392,14 @@ static int if_write_room(struct tty_struct *tty)
        if (mutex_lock_interruptible(&cs->mutex))
                return -ERESTARTSYS; // FIXME -EINTR?
 
-       if (!cs->open_count)
+       if (!cs->connected) {
+               gig_dbg(DEBUG_IF, "not connected");
+               retval = -ENODEV;
+       } else if (!cs->open_count)
                dev_warn(cs->dev, "%s: device not opened\n", __func__);
        else if (cs->mstate != MS_LOCKED) {
                dev_warn(cs->dev, "can't write to unlocked device\n");
                retval = -EBUSY;
-       } else if (!cs->connected) {
-               gig_dbg(DEBUG_ANY, "can't write to unplugged device");
-               retval = -EBUSY; //FIXME
        } else
                retval = cs->ops->write_room(cs);
 
@@ -420,7 +415,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return -ENODEV;
        }
 
@@ -429,14 +424,14 @@ static int if_chars_in_buffer(struct tty_struct *tty)
        if (mutex_lock_interruptible(&cs->mutex))
                return -ERESTARTSYS; // FIXME -EINTR?
 
-       if (!cs->open_count)
+       if (!cs->connected) {
+               gig_dbg(DEBUG_IF, "not connected");
+               retval = -ENODEV;
+       } else if (!cs->open_count)
                dev_warn(cs->dev, "%s: device not opened\n", __func__);
        else if (cs->mstate != MS_LOCKED) {
                dev_warn(cs->dev, "can't write to unlocked device\n");
                retval = -EBUSY;
-       } else if (!cs->connected) {
-               gig_dbg(DEBUG_ANY, "can't write to unplugged device");
-               retval = -EBUSY; //FIXME
        } else
                retval = cs->ops->chars_in_buffer(cs);
 
@@ -451,7 +446,7 @@ static void if_throttle(struct tty_struct *tty)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return;
        }
 
@@ -459,7 +454,9 @@ static void if_throttle(struct tty_struct *tty)
 
        mutex_lock(&cs->mutex);
 
-       if (!cs->open_count)
+       if (!cs->connected)
+               gig_dbg(DEBUG_IF, "not connected");     /* nothing to do */
+       else if (!cs->open_count)
                dev_warn(cs->dev, "%s: device not opened\n", __func__);
        else {
                //FIXME
@@ -474,7 +471,7 @@ static void if_unthrottle(struct tty_struct *tty)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return;
        }
 
@@ -482,7 +479,9 @@ static void if_unthrottle(struct tty_struct *tty)
 
        mutex_lock(&cs->mutex);
 
-       if (!cs->open_count)
+       if (!cs->connected)
+               gig_dbg(DEBUG_IF, "not connected");     /* nothing to do */
+       else if (!cs->open_count)
                dev_warn(cs->dev, "%s: device not opened\n", __func__);
        else {
                //FIXME
@@ -501,7 +500,7 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
 
        cs = (struct cardstate *) tty->driver_data;
        if (!cs) {
-               err("cs==NULL in %s", __func__);
+               pr_err("%s: no cardstate\n", __func__);
                return;
        }
 
@@ -509,13 +508,13 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
 
        mutex_lock(&cs->mutex);
 
-       if (!cs->open_count) {
-               dev_warn(cs->dev, "%s: device not opened\n", __func__);
+       if (!cs->connected) {
+               gig_dbg(DEBUG_IF, "not connected");
                goto out;
        }
 
-       if (!cs->connected) {
-               gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
+       if (!cs->open_count) {
+               dev_warn(cs->dev, "%s: device not opened\n", __func__);
                goto out;
        }
 
@@ -565,29 +564,6 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
 
        cs->ops->set_line_ctrl(cs, cflag);
 
-#if 0
-       //FIXME this hangs M101 [ts 2005-03-09]
-       //FIXME do we need this?
-       /*
-        * Set flow control: well, I do not really now how to handle DTR/RTS.
-        * Just do what we have seen with SniffUSB on Win98.
-        */
-       /* Drop DTR/RTS if no flow control otherwise assert */
-       gig_dbg(DEBUG_IF, "%u: control_state %x",
-               cs->minor_index, control_state);
-       new_state = control_state;
-       if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
-               new_state |= TIOCM_DTR | TIOCM_RTS;
-       else
-               new_state &= ~(TIOCM_DTR | TIOCM_RTS);
-       if (new_state != control_state) {
-               gig_dbg(DEBUG_IF, "%u: new_state %x",
-                       cs->minor_index, new_state);
-               gigaset_set_modem_ctrl(cs, control_state, new_state);
-               control_state = new_state;
-       }
-#endif
-
        /* save off the modified port settings */
        cs->control_state = control_state;
 
@@ -701,7 +677,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
 
        ret = tty_register_driver(tty);
        if (ret < 0) {
-               err("failed to register tty driver (error %d)", ret);
+               pr_err("error %d registering tty driver\n", ret);
                goto error;
        }
        gig_dbg(DEBUG_IF, "tty driver initialized");
@@ -709,7 +685,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
        return;
 
 enomem:
-       err("could not allocate tty structures");
+       pr_err("out of memory\n");
 error:
        if (drv->tty)
                put_tty_driver(drv->tty);