#include <linux/init.h>
#include <asm/uaccess.h>
#include <linux/smp_lock.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
#include <net/irda/irda.h>
#include <net/irda/irda_device.h>
#include "sir-dev.h"
#include "irtty-sir.h"
-MODULE_PARM(qos_mtt_bits, "i");
-MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time");
-
static int qos_mtt_bits = 0x03; /* 5 ms or more */
+module_param(qos_mtt_bits, int, 0);
+MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time");
+
/* ------------------------------------------------------- */
/* device configuration callbacks always invoked with irda-thread context */
{
struct sirtty_cb *priv = dev->priv;
- ASSERT(priv != NULL, return -1;);
- ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
+ IRDA_ASSERT(priv != NULL, return -1;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
return priv->tty->driver->chars_in_buffer(priv->tty);
}
struct sirtty_cb *priv = dev->priv;
struct tty_struct *tty;
- ASSERT(priv != NULL, return;);
- ASSERT(priv->magic == IRTTY_MAGIC, return;);
+ IRDA_ASSERT(priv != NULL, return;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);
tty = priv->tty;
if (tty->driver->wait_until_sent) {
unlock_kernel();
}
else {
- set_task_state(current, TASK_UNINTERRUPTIBLE);
- schedule_timeout(msecs_to_jiffies(USBSERIAL_TX_DONE_DELAY));
+ msleep(USBSERIAL_TX_DONE_DELAY);
}
}
{
struct sirtty_cb *priv = dev->priv;
struct tty_struct *tty;
- struct termios old_termios;
+ struct ktermios old_termios;
int cflag;
- ASSERT(priv != NULL, return -1;);
- ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
+ IRDA_ASSERT(priv != NULL, return -1;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
tty = priv->tty;
int set = 0;
int clear = 0;
- ASSERT(priv != NULL, return -1;);
- ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
+ IRDA_ASSERT(priv != NULL, return -1;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
if (rts)
set |= TIOCM_RTS;
* This function is not yet defined for all tty driver, so
* let's be careful... Jean II
*/
- ASSERT(priv->tty->driver->tiocmset != NULL, return -1;);
+ IRDA_ASSERT(priv->tty->driver->tiocmset != NULL, return -1;);
priv->tty->driver->tiocmset(priv->tty, NULL, set, clear);
return 0;
struct tty_struct *tty;
int writelen;
- ASSERT(priv != NULL, return -1;);
- ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
+ IRDA_ASSERT(priv != NULL, return -1;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
tty = priv->tty;
if (!tty->driver->write)
}
else
writelen = len;
- return tty->driver->write(tty, 0, ptr, writelen);
+ return tty->driver->write(tty, ptr, writelen);
}
/* ------------------------------------------------------- */
struct sirtty_cb *priv = tty->disc_data;
int i;
- ASSERT(priv != NULL, return;);
- ASSERT(priv->magic == IRTTY_MAGIC, return;);
+ IRDA_ASSERT(priv != NULL, return;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);
if (unlikely(count==0)) /* yes, this happens */
return;
dev = priv->dev;
if (!dev) {
- WARNING("%s(), not ready yet!\n", __FUNCTION__);
+ IRDA_WARNING("%s(), not ready yet!\n", __FUNCTION__);
return;
}
sirdev_receive(dev, cp, count);
}
-/*
- * Function irtty_receive_room (tty)
- *
- * Used by the TTY to find out how much data we can receive at a time
- *
-*/
-static int irtty_receive_room(struct tty_struct *tty)
-{
- struct sirtty_cb *priv = tty->disc_data;
-
- ASSERT(priv != NULL, return 0;);
- ASSERT(priv->magic == IRTTY_MAGIC, return 0;);
-
- return 65536; /* We can handle an infinite amount of data. :-) */
-}
-
/*
* Function irtty_write_wakeup (tty)
*
{
struct sirtty_cb *priv = tty->disc_data;
- ASSERT(priv != NULL, return;);
- ASSERT(priv->magic == IRTTY_MAGIC, return;);
+ IRDA_ASSERT(priv != NULL, return;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);
tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
static inline void irtty_stop_receiver(struct tty_struct *tty, int stop)
{
- struct termios old_termios;
+ struct ktermios old_termios;
int cflag;
lock_kernel();
/*****************************************************************/
/* serialize ldisc open/close with sir_dev */
-static DECLARE_MUTEX(irtty_sem);
+static DEFINE_MUTEX(irtty_mutex);
/* notifier from sir_dev when irda% device gets opened (ifup) */
struct tty_struct *tty;
/* serialize with ldisc open/close */
- down(&irtty_sem);
+ mutex_lock(&irtty_mutex);
priv = dev->priv;
if (unlikely(!priv || priv->magic!=IRTTY_MAGIC)) {
- up(&irtty_sem);
+ mutex_unlock(&irtty_mutex);
return -ESTALE;
}
/* Make sure we can receive more data */
irtty_stop_receiver(tty, FALSE);
- up(&irtty_sem);
+ mutex_unlock(&irtty_mutex);
return 0;
}
struct tty_struct *tty;
/* serialize with ldisc open/close */
- down(&irtty_sem);
+ mutex_lock(&irtty_mutex);
priv = dev->priv;
if (unlikely(!priv || priv->magic!=IRTTY_MAGIC)) {
- up(&irtty_sem);
+ mutex_unlock(&irtty_mutex);
return -ESTALE;
}
if (tty->driver->stop)
tty->driver->stop(tty);
- up(&irtty_sem);
+ mutex_unlock(&irtty_mutex);
return 0;
}
/* ------------------------------------------------------- */
-struct sir_driver sir_tty_drv = {
+static struct sir_driver sir_tty_drv = {
.owner = THIS_MODULE,
.driver_name = "sir_tty",
.start_dev = irtty_start_dev,
struct irtty_info { char name[6]; } info;
struct sir_dev *dev;
struct sirtty_cb *priv = tty->disc_data;
- int size = _IOC_SIZE(cmd);
int err = 0;
- ASSERT(priv != NULL, return -ENODEV;);
- ASSERT(priv->magic == IRTTY_MAGIC, return -EBADR;);
+ IRDA_ASSERT(priv != NULL, return -ENODEV;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -EBADR;);
IRDA_DEBUG(3, "%s(cmd=0x%X)\n", __FUNCTION__, cmd);
dev = priv->dev;
- ASSERT(dev != NULL, return -1;);
-
- if (_IOC_DIR(cmd) & _IOC_READ)
- err = verify_area(VERIFY_WRITE, (void *) arg, size);
- else if (_IOC_DIR(cmd) & _IOC_WRITE)
- err = verify_area(VERIFY_READ, (void *) arg, size);
- if (err)
- return err;
-
+ IRDA_ASSERT(dev != NULL, return -1;);
+
switch (cmd) {
case TCGETS:
case TCGETA:
break;
case IRTTY_IOCGET:
- ASSERT(dev->netdev != NULL, return -1;);
+ IRDA_ASSERT(dev->netdev != NULL, return -1;);
memset(&info, 0, sizeof(info));
strncpy(info.name, dev->netdev->name, sizeof(info.name)-1);
- if (copy_to_user((void *)arg, &info, sizeof(info)))
+ if (copy_to_user((void __user *)arg, &info, sizeof(info)))
err = -EFAULT;
break;
default:
if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
-/* from old irtty - but what is it good for?
- * we _are_ the ldisc and we _don't_ implement flush_buffer!
- *
- * if (tty->ldisc.flush_buffer)
- * tty->ldisc.flush_buffer(tty);
- */
-
/* apply mtt override */
sir_tty_drv.qos_mtt_bits = qos_mtt_bits;
priv->dev = dev;
/* serialize with start_dev - in case we were racing with ifup */
- down(&irtty_sem);
+ mutex_lock(&irtty_mutex);
dev->priv = priv;
tty->disc_data = priv;
+ tty->receive_room = 65536;
- up(&irtty_sem);
+ mutex_unlock(&irtty_mutex);
IRDA_DEBUG(0, "%s - %s: irda line discipline opened\n", __FUNCTION__, tty->name);
{
struct sirtty_cb *priv = tty->disc_data;
- ASSERT(priv != NULL, return;);
- ASSERT(priv->magic == IRTTY_MAGIC, return;);
+ IRDA_ASSERT(priv != NULL, return;);
+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);
/* Hm, with a dongle attached the dongle driver wants
* to close the dongle - which requires the use of
*/
/* we are dead now */
- tty->disc_data = 0;
+ tty->disc_data = NULL;
sirdev_put_instance(priv->dev);
.ioctl = irtty_ioctl,
.poll = NULL,
.receive_buf = irtty_receive_buf,
- .receive_room = irtty_receive_room,
.write_wakeup = irtty_write_wakeup,
.owner = THIS_MODULE,
};
int err;
if ((err = tty_register_ldisc(N_IRDA, &irda_ldisc)) != 0)
- ERROR("IrDA: can't register line discipline (err = %d)\n",
- err);
+ IRDA_ERROR("IrDA: can't register line discipline (err = %d)\n",
+ err);
return err;
}
{
int err;
- if ((err = tty_register_ldisc(N_IRDA, NULL))) {
- ERROR("%s(), can't unregister line discipline (err = %d)\n",
- __FUNCTION__, err);
+ if ((err = tty_unregister_ldisc(N_IRDA))) {
+ IRDA_ERROR("%s(), can't unregister line discipline (err = %d)\n",
+ __FUNCTION__, err);
}
}