X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=drivers%2Fisdn%2Fgigaset%2Finterface.c;h=25750864d206be390d65f6c1799ca4c69fce42e2;hb=01371500b245ae63f542d74140a3d8ccb74d0318;hp=3a81d9c65141b17d40490c0cbd0b339c71a187b1;hpb=5b67e8dd5ae889fea7d01b905a570fa9a37b8785;p=firefly-linux-kernel-4.4.55.git diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 3a81d9c65141..25750864d206 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -9,8 +9,6 @@ * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * ===================================================================== - * Version: $Id: interface.c,v 1.14.4.15 2006/02/04 18:28:16 hjlipp Exp $ - * ===================================================================== */ #include "gigaset.h" @@ -24,7 +22,7 @@ static int if_lock(struct cardstate *cs, int *arg) { int cmd = *arg; - dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd); + gig_dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd); if (cmd > 1) return -EINVAL; @@ -44,12 +42,12 @@ static int if_lock(struct cardstate *cs, int *arg) cs->waiting = 1; if (!gigaset_add_event(cs, &cs->at_state, EV_IF_LOCK, - NULL, cmd, NULL)) { + NULL, cmd, NULL)) { cs->waiting = 0; return -ENOMEM; } - dbg(DEBUG_CMD, "scheduling IF_LOCK"); + gig_dbg(DEBUG_CMD, "scheduling IF_LOCK"); gigaset_schedule_event(cs); wait_event(cs->waitqueue, !cs->waiting); @@ -68,7 +66,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4]) static const unsigned compat[4] = GIG_COMPAT; unsigned cmd = arg[0]; - dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd); + gig_dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd); switch (cmd) { case GIGVER_DRIVER: @@ -80,12 +78,12 @@ static int if_version(struct cardstate *cs, unsigned arg[4]) case GIGVER_FWBASE: cs->waiting = 1; if (!gigaset_add_event(cs, &cs->at_state, EV_IF_VER, - NULL, 0, arg)) { + NULL, 0, arg)) { cs->waiting = 0; return -ENOMEM; } - dbg(DEBUG_CMD, "scheduling IF_VER"); + gig_dbg(DEBUG_CMD, "scheduling IF_VER"); gigaset_schedule_event(cs); wait_event(cs->waitqueue, !cs->waiting); @@ -101,7 +99,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4]) static int if_config(struct cardstate *cs, int *arg) { - dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg); + gig_dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg); if (*arg != 1) return -EINVAL; @@ -119,7 +117,7 @@ static int if_config(struct cardstate *cs, int *arg) static int if_open(struct tty_struct *tty, struct file *filp); static void if_close(struct tty_struct *tty, struct file *filp); static int if_ioctl(struct tty_struct *tty, struct file *file, - unsigned int cmd, unsigned long arg); + unsigned int cmd, unsigned long arg); static int if_write_room(struct tty_struct *tty); static int if_chars_in_buffer(struct tty_struct *tty); static void if_throttle(struct tty_struct *tty); @@ -127,9 +125,9 @@ static void if_unthrottle(struct tty_struct *tty); static void if_set_termios(struct tty_struct *tty, struct termios *old); static int if_tiocmget(struct tty_struct *tty, struct file *file); static int if_tiocmset(struct tty_struct *tty, struct file *file, - unsigned int set, unsigned int clear); + unsigned int set, unsigned int clear); static int if_write(struct tty_struct *tty, - const unsigned char *buf, int count); + const unsigned char *buf, int count); static struct tty_operations if_ops = { .open = if_open, @@ -153,8 +151,8 @@ static int if_open(struct tty_struct *tty, struct file *filp) struct cardstate *cs; unsigned long flags; - dbg(DEBUG_IF, "%d+%d: %s()", tty->driver->minor_start, tty->index, - __FUNCTION__); + gig_dbg(DEBUG_IF, "%d+%d: %s()", + tty->driver->minor_start, tty->index, __func__); tty->driver_data = NULL; @@ -173,7 +171,6 @@ static int if_open(struct tty_struct *tty, struct file *filp) cs->tty = tty; spin_unlock_irqrestore(&cs->lock, flags); tty->low_latency = 1; //FIXME test - //FIXME } up(&cs->sem); @@ -187,22 +184,21 @@ static void if_close(struct tty_struct *tty, struct file *filp) cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); down(&cs->sem); if (!cs->open_count) - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); else { if (!--cs->open_count) { spin_lock_irqsave(&cs->lock, flags); cs->tty = NULL; spin_unlock_irqrestore(&cs->lock, flags); - //FIXME } } @@ -210,7 +206,7 @@ static void if_close(struct tty_struct *tty, struct file *filp) } static int if_ioctl(struct tty_struct *tty, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { struct cardstate *cs; int retval = -ENODEV; @@ -220,17 +216,17 @@ static int if_ioctl(struct tty_struct *tty, struct file *file, cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return -ENODEV; } - dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __FUNCTION__, cmd); + gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd); if (down_interruptible(&cs->sem)) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); else { retval = 0; switch (cmd) { @@ -250,32 +246,35 @@ static int if_ioctl(struct tty_struct *tty, struct file *file, break; case GIGASET_BRKCHARS: //FIXME test if MS_LOCKED - gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", - 6, (const unsigned char *) arg, 1); if (!atomic_read(&cs->connected)) { - dbg(DEBUG_ANY, "can't communicate with unplugged device"); + 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; - if (retval >= 0) + (const unsigned char __user *) arg, 6) + ? -EFAULT : 0; + if (retval >= 0) { + gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", + 6, (const unsigned char *) arg); retval = cs->ops->brkchars(cs, buf); + } break; case GIGASET_VERSION: - retval = copy_from_user(version, (unsigned __user *) arg, - sizeof version) ? -EFAULT : 0; + retval = copy_from_user(version, + (unsigned __user *) arg, sizeof version) + ? -EFAULT : 0; if (retval >= 0) retval = if_version(cs, version); if (retval >= 0) - retval = copy_to_user((unsigned __user *) arg, version, - sizeof version) - ? -EFAULT : 0; + retval = copy_to_user((unsigned __user *) arg, + version, sizeof version) + ? -EFAULT : 0; break; - default: - dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x", - __FUNCTION__, cmd); + default: + gig_dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x", + __func__, cmd); retval = -ENOIOCTLCMD; } } @@ -292,11 +291,11 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file) cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return -ENODEV; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); if (down_interruptible(&cs->sem)) return -ERESTARTSYS; // FIXME -EINTR? @@ -310,7 +309,7 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file) } static int if_tiocmset(struct tty_struct *tty, struct file *file, - unsigned int set, unsigned int clear) + unsigned int set, unsigned int clear) { struct cardstate *cs; int retval; @@ -318,18 +317,18 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file, cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return -ENODEV; } - dbg(DEBUG_IF, - "%u: %s(0x%x, 0x%x)", cs->minor_index, __FUNCTION__, set, clear); + gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)", + cs->minor_index, __func__, set, clear); if (down_interruptible(&cs->sem)) return -ERESTARTSYS; // FIXME -EINTR? if (!atomic_read(&cs->connected)) { - dbg(DEBUG_ANY, "can't communicate with unplugged device"); + gig_dbg(DEBUG_ANY, "can't communicate with unplugged device"); retval = -ENODEV; } else { mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR); @@ -349,26 +348,26 @@ 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", __FUNCTION__); + err("cs==NULL in %s", __func__); return -ENODEV; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); if (down_interruptible(&cs->sem)) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); else if (atomic_read(&cs->mstate) != MS_LOCKED) { warn("can't write to unlocked device"); retval = -EBUSY; } else if (!atomic_read(&cs->connected)) { - dbg(DEBUG_ANY, "can't write to unplugged device"); + 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); + &cs->if_wake_tasklet); } up(&cs->sem); @@ -383,22 +382,22 @@ static int if_write_room(struct tty_struct *tty) cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return -ENODEV; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); if (down_interruptible(&cs->sem)) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); else if (atomic_read(&cs->mstate) != MS_LOCKED) { warn("can't write to unlocked device"); retval = -EBUSY; //FIXME } else if (!atomic_read(&cs->connected)) { - dbg(DEBUG_ANY, "can't write to unplugged device"); + gig_dbg(DEBUG_ANY, "can't write to unplugged device"); retval = -EBUSY; //FIXME } else retval = cs->ops->write_room(cs); @@ -415,22 +414,22 @@ static int if_chars_in_buffer(struct tty_struct *tty) cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return -ENODEV; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); if (down_interruptible(&cs->sem)) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); else if (atomic_read(&cs->mstate) != MS_LOCKED) { warn("can't write to unlocked device"); retval = -EBUSY; } else if (!atomic_read(&cs->connected)) { - dbg(DEBUG_ANY, "can't write to unplugged device"); + gig_dbg(DEBUG_ANY, "can't write to unplugged device"); retval = -EBUSY; //FIXME } else retval = cs->ops->chars_in_buffer(cs); @@ -446,16 +445,16 @@ static void if_throttle(struct tty_struct *tty) cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); down(&cs->sem); if (!cs->open_count) - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); else { //FIXME } @@ -469,16 +468,16 @@ static void if_unthrottle(struct tty_struct *tty) cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); down(&cs->sem); if (!cs->open_count) - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); else { //FIXME } @@ -496,21 +495,21 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old) cs = (struct cardstate *) tty->driver_data; if (!cs) { - err("cs==NULL in %s", __FUNCTION__); + err("cs==NULL in %s", __func__); return; } - dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); + gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); down(&cs->sem); if (!cs->open_count) { - warn("%s: device not opened", __FUNCTION__); + warn("%s: device not opened", __func__); goto out; } if (!atomic_read(&cs->connected)) { - dbg(DEBUG_ANY, "can't communicate with unplugged device"); + gig_dbg(DEBUG_ANY, "can't communicate with unplugged device"); goto out; } @@ -518,8 +517,8 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old) iflag = tty->termios->c_iflag; cflag = tty->termios->c_cflag; old_cflag = old ? old->c_cflag : cflag; //FIXME? - dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x", cs->minor_index, - iflag, cflag, old_cflag); + gig_dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x", + cs->minor_index, iflag, cflag, old_cflag); /* get a local copy of the current port settings */ control_state = cs->control_state; @@ -531,14 +530,15 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old) * Premature optimization is the root of all evil. */ - /* reassert DTR and (maybe) RTS on transition from B0 */ + /* reassert DTR and (maybe) RTS on transition from B0 */ if ((old_cflag & CBAUD) == B0) { new_state = control_state | TIOCM_DTR; /* don't set RTS if using hardware flow control */ if (!(old_cflag & CRTSCTS)) new_state |= TIOCM_RTS; - dbg(DEBUG_IF, "%u: from B0 - set DTR%s", cs->minor_index, - (new_state & TIOCM_RTS) ? " only" : "/RTS"); + gig_dbg(DEBUG_IF, "%u: from B0 - set DTR%s", + cs->minor_index, + (new_state & TIOCM_RTS) ? " only" : "/RTS"); cs->ops->set_modem_ctrl(cs, control_state, new_state); control_state = new_state; } @@ -547,7 +547,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old) if ((cflag & CBAUD) == B0) { /* Drop RTS and DTR */ - dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index); + gig_dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index); new_state = control_state & ~(TIOCM_DTR | TIOCM_RTS); cs->ops->set_modem_ctrl(cs, control_state, new_state); control_state = new_state; @@ -567,15 +567,17 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old) * Just do what we have seen with SniffUSB on Win98. */ /* Drop DTR/RTS if no flow control otherwise assert */ - dbg(DEBUG_IF, "%u: control_state %x", cs->minor_index, control_state); + 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) { - dbg(DEBUG_IF, "%u: new_state %x", cs->minor_index, new_state); - gigaset_set_modem_ctrl(cs, control_state, new_state); // FIXME: mct_u232.c sets the old state here. is this a bug? + 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 @@ -600,7 +602,7 @@ static void if_wake(unsigned long data) if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup) { - dbg(DEBUG_IF, "write wakeup call"); + gig_dbg(DEBUG_IF, "write wakeup call"); tty->ldisc.write_wakeup(tty); } @@ -635,14 +637,14 @@ void gigaset_if_free(struct cardstate *cs) } void gigaset_if_receive(struct cardstate *cs, - unsigned char *buffer, size_t len) + unsigned char *buffer, size_t len) { unsigned long flags; struct tty_struct *tty; spin_lock_irqsave(&cs->lock, flags); if ((tty = cs->tty) == NULL) - dbg(DEBUG_ANY, "receive on closed device"); + gig_dbg(DEBUG_ANY, "receive on closed device"); else { tty_buffer_request_room(tty, len); tty_insert_flip_string(tty, buffer, len); @@ -655,13 +657,13 @@ EXPORT_SYMBOL_GPL(gigaset_if_receive); /* gigaset_if_initdriver * Initialize tty interface. * parameters: - * 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 + * 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, const char *devfsname) { unsigned minors = drv->minors; int ret; @@ -696,7 +698,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, warn("failed to register tty driver (error %d)", ret); goto error; } - dbg(DEBUG_IF, "tty driver initialized"); + gig_dbg(DEBUG_IF, "tty driver initialized"); drv->have_tty = 1; return;