X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=drivers%2Fisdn%2Fgigaset%2Finterface.c;h=521951a898ece00218d3bd96645e94466c26a349;hb=c174aff95642bcc830102becb9802adeb8f87a5a;hp=458b6462f93779c489440ecce018ead677145d5c;hpb=7e23772f414cdbfb2a08aed237d6e926bb1cb728;p=linux-2.6-omap-h63xx.git diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 458b6462f93..521951a898e 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -28,12 +28,11 @@ static int if_lock(struct cardstate *cs, int *arg) return -EINVAL; if (cmd < 0) { - *arg = atomic_read(&cs->mstate) == MS_LOCKED; //FIXME remove? + *arg = cs->mstate == MS_LOCKED; return 0; } - if (!cmd && atomic_read(&cs->mstate) == MS_LOCKED - && cs->connected) { + if (!cmd && cs->mstate == MS_LOCKED && 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); @@ -104,7 +103,7 @@ static int if_config(struct cardstate *cs, int *arg) if (*arg != 1) return -EINVAL; - if (atomic_read(&cs->mstate) != MS_LOCKED) + if (cs->mstate != MS_LOCKED) return -EBUSY; if (!cs->connected) { @@ -162,7 +161,7 @@ static int if_open(struct tty_struct *tty, struct file *filp) tty->driver_data = NULL; cs = gigaset_get_cs_by_tty(tty); - if (!cs) + if (!cs || !try_module_get(cs->driver->owner)) return -ENODEV; if (mutex_lock_interruptible(&cs->mutex)) @@ -198,7 +197,7 @@ static void if_close(struct tty_struct *tty, struct file *filp) mutex_lock(&cs->mutex); if (!cs->open_count) - warn("%s: device not opened", __func__); + dev_warn(cs->dev, "%s: device not opened\n", __func__); else { if (!--cs->open_count) { spin_lock_irqsave(&cs->lock, flags); @@ -208,6 +207,8 @@ static void if_close(struct tty_struct *tty, struct file *filp) } mutex_unlock(&cs->mutex); + + module_put(cs->driver->owner); } static int if_ioctl(struct tty_struct *tty, struct file *file, @@ -231,7 +232,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file, return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __func__); + dev_warn(cs->dev, "%s: device not opened\n", __func__); else { retval = 0; switch (cmd) { @@ -363,9 +364,9 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __func__); - else if (atomic_read(&cs->mstate) != MS_LOCKED) { - warn("can't write to unlocked device"); + 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"); @@ -397,10 +398,10 @@ static int if_write_room(struct tty_struct *tty) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __func__); - else if (atomic_read(&cs->mstate) != MS_LOCKED) { - warn("can't write to unlocked device"); - retval = -EBUSY; //FIXME + 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 @@ -429,9 +430,9 @@ static int if_chars_in_buffer(struct tty_struct *tty) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) - warn("%s: device not opened", __func__); - else if (atomic_read(&cs->mstate) != MS_LOCKED) { - warn("can't write to unlocked device"); + 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"); @@ -459,7 +460,7 @@ static void if_throttle(struct tty_struct *tty) mutex_lock(&cs->mutex); if (!cs->open_count) - warn("%s: device not opened", __func__); + dev_warn(cs->dev, "%s: device not opened\n", __func__); else { //FIXME } @@ -482,7 +483,7 @@ static void if_unthrottle(struct tty_struct *tty) mutex_lock(&cs->mutex); if (!cs->open_count) - warn("%s: device not opened", __func__); + dev_warn(cs->dev, "%s: device not opened\n", __func__); else { //FIXME } @@ -509,7 +510,7 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old) mutex_lock(&cs->mutex); if (!cs->open_count) { - warn("%s: device not opened", __func__); + dev_warn(cs->dev, "%s: device not opened\n", __func__); goto out; } @@ -599,19 +600,9 @@ out: static void if_wake(unsigned long data) { struct cardstate *cs = (struct cardstate *) data; - struct tty_struct *tty; - - tty = cs->tty; - if (!tty) - return; - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) { - gig_dbg(DEBUG_IF, "write wakeup call"); - tty->ldisc.write_wakeup(tty); - } - - wake_up_interruptible(&tty->write_wait); + if (cs->tty) + tty_wakeup(cs->tty); } /*** interface to common ***/ @@ -625,14 +616,18 @@ void gigaset_if_init(struct cardstate *cs) return; tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); + + mutex_lock(&cs->mutex); cs->tty_dev = tty_register_device(drv->tty, cs->minor_index, NULL); if (!IS_ERR(cs->tty_dev)) dev_set_drvdata(cs->tty_dev, cs); else { - warn("could not register device to the tty subsystem"); + dev_warn(cs->dev, + "could not register device to the tty subsystem\n"); cs->tty_dev = NULL; } + mutex_unlock(&cs->mutex); } void gigaset_if_free(struct cardstate *cs)