Commit ee389f0a authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://kernel.bkbits.net/jgarzik/irda-2.5

into home.osdl.org:/home/torvalds/v2.5/linux
parents 87d890b8 eaab542a
...@@ -212,13 +212,6 @@ static int irtty_set_dtr_rts(struct sir_dev *dev, int dtr, int rts) ...@@ -212,13 +212,6 @@ static int irtty_set_dtr_rts(struct sir_dev *dev, int dtr, int rts)
/* called from sir_dev when there is more data to send /* called from sir_dev when there is more data to send
* context is either netdev->hard_xmit or some transmit-completion bh * context is either netdev->hard_xmit or some transmit-completion bh
* i.e. we are under spinlock here and must not sleep. * i.e. we are under spinlock here and must not sleep.
*
* Note: as of 2.5.44 the usb-serial driver calls down() on a semaphore
* hence we are hitting the might_sleep bugcatcher. IMHO the whole tty-api
* would be pretty pointless if write_room/write would be allowed to sleep.
* Furthermore other tty ldiscs (like ppp) do also require the driver not
* to sleep there. Hence this is considered a current limitation of
* usb-serial.
*/ */
static int irtty_do_write(struct sir_dev *dev, const unsigned char *ptr, size_t len) static int irtty_do_write(struct sir_dev *dev, const unsigned char *ptr, size_t len)
...@@ -269,16 +262,15 @@ static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp, ...@@ -269,16 +262,15 @@ static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
struct sirtty_cb *priv = tty->disc_data; struct sirtty_cb *priv = tty->disc_data;
int i; int i;
if (unlikely(!priv || priv->magic!=IRTTY_MAGIC)) ASSERT(priv != NULL, return;);
return; ASSERT(priv->magic == IRTTY_MAGIC, return;);
/* Please use ASSERT - Fix ASSERT as needed - Jean II */
if (unlikely(count==0)) /* yes, this happens */ if (unlikely(count==0)) /* yes, this happens */
return; return;
dev = priv->dev; dev = priv->dev;
if (!dev) { if (!dev) {
printk(KERN_ERR "%s(), not ready yet!\n", __FUNCTION__); WARNING("%s(), not ready yet!\n", __FUNCTION__);
return; return;
} }
...@@ -306,8 +298,8 @@ static int irtty_receive_room(struct tty_struct *tty) ...@@ -306,8 +298,8 @@ static int irtty_receive_room(struct tty_struct *tty)
{ {
struct sirtty_cb *priv = tty->disc_data; struct sirtty_cb *priv = tty->disc_data;
if (unlikely(!priv || priv->magic!=IRTTY_MAGIC)) ASSERT(priv != NULL, return 0;);
return 0; ASSERT(priv->magic == IRTTY_MAGIC, return 0;);
return 65536; /* We can handle an infinite amount of data. :-) */ return 65536; /* We can handle an infinite amount of data. :-) */
} }
...@@ -323,8 +315,8 @@ static void irtty_write_wakeup(struct tty_struct *tty) ...@@ -323,8 +315,8 @@ static void irtty_write_wakeup(struct tty_struct *tty)
{ {
struct sirtty_cb *priv = tty->disc_data; struct sirtty_cb *priv = tty->disc_data;
if (unlikely(!priv || priv->magic!=IRTTY_MAGIC)) ASSERT(priv != NULL, return;);
return; ASSERT(priv->magic == IRTTY_MAGIC, return;);
tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
...@@ -559,7 +551,7 @@ static int irtty_open(struct tty_struct *tty) ...@@ -559,7 +551,7 @@ static int irtty_open(struct tty_struct *tty)
up(&irtty_sem); up(&irtty_sem);
printk(KERN_INFO "%s - done\n", __FUNCTION__); IRDA_DEBUG(0, "%s - %s: irda line discipline opened\n", __FUNCTION__, tty->name);
return 0; return 0;
...@@ -580,8 +572,8 @@ static void irtty_close(struct tty_struct *tty) ...@@ -580,8 +572,8 @@ static void irtty_close(struct tty_struct *tty)
{ {
struct sirtty_cb *priv = tty->disc_data; struct sirtty_cb *priv = tty->disc_data;
if (!priv || priv->magic != IRTTY_MAGIC) ASSERT(priv != NULL, return;);
return; ASSERT(priv->magic == IRTTY_MAGIC, return;);
/* Hm, with a dongle attached the dongle driver wants /* Hm, with a dongle attached the dongle driver wants
* to close the dongle - which requires the use of * to close the dongle - which requires the use of
...@@ -610,6 +602,8 @@ static void irtty_close(struct tty_struct *tty) ...@@ -610,6 +602,8 @@ static void irtty_close(struct tty_struct *tty)
tty->driver->stop(tty); tty->driver->stop(tty);
kfree(priv); kfree(priv);
IRDA_DEBUG(0, "%s - %s: irda line discipline closed\n", __FUNCTION__, tty->name);
} }
/* ------------------------------------------------------- */ /* ------------------------------------------------------- */
......
...@@ -201,14 +201,12 @@ void sirdev_write_complete(struct sir_dev *dev) ...@@ -201,14 +201,12 @@ void sirdev_write_complete(struct sir_dev *dev)
int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count) int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count)
{ {
if (!dev || !dev->netdev) { if (!dev || !dev->netdev) {
IRDA_DEBUG(0, "%s(), not ready yet!\n", __FUNCTION__); WARNING("%s(), not ready yet!\n", __FUNCTION__);
/* Use WARNING instead of IRDA_DEBUG */
return -1; return -1;
} }
if (!dev->irlap) { if (!dev->irlap) {
IRDA_DEBUG(0, "%s - too early: %p / %d!\n", __FUNCTION__, cp, count); WARNING("%s - too early: %p / %d!\n", __FUNCTION__, cp, count);
/* Use WARNING instead of IRDA_DEBUG */
return -1; return -1;
} }
...@@ -218,7 +216,7 @@ int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count) ...@@ -218,7 +216,7 @@ int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count)
*/ */
irda_device_set_media_busy(dev->netdev, TRUE); irda_device_set_media_busy(dev->netdev, TRUE);
dev->stats.rx_dropped++; dev->stats.rx_dropped++;
printk(KERN_INFO "%s; rx-drop: %d\n", __FUNCTION__, count); IRDA_DEBUG(0, "%s; rx-drop: %d\n", __FUNCTION__, count);
return 0; return 0;
} }
...@@ -431,7 +429,6 @@ static int sirdev_alloc_buffers(struct sir_dev *dev) ...@@ -431,7 +429,6 @@ static int sirdev_alloc_buffers(struct sir_dev *dev)
return -ENOMEM; return -ENOMEM;
skb_reserve(dev->rx_buff.skb, 1); skb_reserve(dev->rx_buff.skb, 1);
dev->rx_buff.head = dev->rx_buff.skb->data; dev->rx_buff.head = dev->rx_buff.skb->data;
/* No need to memset the buffer, unless you are really pedantic */
dev->tx_buff.head = kmalloc(dev->tx_buff.truesize, GFP_KERNEL); dev->tx_buff.head = kmalloc(dev->tx_buff.truesize, GFP_KERNEL);
if (dev->tx_buff.head == NULL) { if (dev->tx_buff.head == NULL) {
...@@ -439,8 +436,6 @@ static int sirdev_alloc_buffers(struct sir_dev *dev) ...@@ -439,8 +436,6 @@ static int sirdev_alloc_buffers(struct sir_dev *dev)
dev->rx_buff.skb = NULL; dev->rx_buff.skb = NULL;
dev->rx_buff.head = NULL; dev->rx_buff.head = NULL;
return -ENOMEM; return -ENOMEM;
/* Hu ??? This should not be here, Martin ? */
memset(dev->tx_buff.head, 0, dev->tx_buff.truesize);
} }
dev->tx_buff.data = dev->tx_buff.head; dev->tx_buff.data = dev->tx_buff.head;
...@@ -492,7 +487,7 @@ static int sirdev_open(struct net_device *ndev) ...@@ -492,7 +487,7 @@ static int sirdev_open(struct net_device *ndev)
netif_wake_queue(ndev); netif_wake_queue(ndev);
printk(KERN_INFO "%s - done, speed = %d\n", __FUNCTION__, dev->speed); IRDA_DEBUG(2, "%s - done, speed = %d\n", __FUNCTION__, dev->speed);
return 0; return 0;
...@@ -512,7 +507,7 @@ static int sirdev_close(struct net_device *ndev) ...@@ -512,7 +507,7 @@ static int sirdev_close(struct net_device *ndev)
struct sir_dev *dev = ndev->priv; struct sir_dev *dev = ndev->priv;
const struct sir_driver *drv; const struct sir_driver *drv;
printk(KERN_INFO "%s\n", __FUNCTION__); // IRDA_DEBUG(0, "%s\n", __FUNCTION__);
netif_stop_queue(ndev); netif_stop_queue(ndev);
...@@ -570,7 +565,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n ...@@ -570,7 +565,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
struct net_device *ndev; struct net_device *ndev;
struct sir_dev *dev; struct sir_dev *dev;
printk(KERN_INFO "%s - %s\n", __FUNCTION__, name); IRDA_DEBUG(0, "%s - %s\n", __FUNCTION__, name);
/* instead of adding tests to protect against drv->do_write==NULL /* instead of adding tests to protect against drv->do_write==NULL
* at several places we refuse to create a sir_dev instance for * at several places we refuse to create a sir_dev instance for
...@@ -584,8 +579,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n ...@@ -584,8 +579,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
*/ */
dev = kmalloc(sizeof(*dev), GFP_KERNEL); dev = kmalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) { if (dev == NULL) {
printk(KERN_ERR "IrDA: Can't allocate memory for " ERROR("%s - Can't allocate memory for IrDA control block!\n", __FUNCTION__);
"IrDA control block!\n");
goto out; goto out;
} }
memset(dev, 0, sizeof(*dev)); memset(dev, 0, sizeof(*dev));
...@@ -638,7 +632,7 @@ int sirdev_put_instance(struct sir_dev *dev) ...@@ -638,7 +632,7 @@ int sirdev_put_instance(struct sir_dev *dev)
{ {
int err = 0; int err = 0;
printk(KERN_INFO "%s\n", __FUNCTION__); IRDA_DEBUG(0, "%s\n", __FUNCTION__);
atomic_set(&dev->enable_rx, 0); atomic_set(&dev->enable_rx, 0);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/suspend.h>
#include <net/irda/irda.h> #include <net/irda/irda.h>
...@@ -107,44 +108,12 @@ static void run_irda_queue(void) ...@@ -107,44 +108,12 @@ static void run_irda_queue(void)
spin_unlock_irqrestore(&irda_rq_queue.lock, flags); spin_unlock_irqrestore(&irda_rq_queue.lock, flags);
} }
static int irda_rt_prio = 0; /* MODULE_PARM? */
static int irda_thread(void *startup) static int irda_thread(void *startup)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
daemonize("kIrDAd"); daemonize("kIrDAd");
set_fs(KERNEL_DS);
if (irda_rt_prio > 0) {
#if 0 /* works but requires EXPORT_SYMBOL(setscheduler) */
struct sched_param param;
param.sched_priority = irda_rt_prio;
setscheduler(0, SCHED_FIFO, &param);
#endif
#if 0 /* doesn't work - has some tendency to trigger instant reboot!
* looks like we would have to deactivate current on the
* runqueue - which is only possible inside of kernel/sched.h
*/
/* runqueues are per-cpu and we are current on this cpu. Hence
* The tasklist_lock with irq-off protects our runqueue too
* and we don't have to lock it (which would be impossible,
* because it is private in kernel/sched.c)
*/
read_lock_irq(&tasklist_lock);
current->rt_priority = (irda_rt_prio<MAX_RT_PRIO)
? irda_rt_prio : MAX_RT_PRIO-1;
current->policy = SCHED_FIFO;
current->prio = MAX_USER_RT_PRIO-1 - irda_rt_prio;
read_unlock_irq(&tasklist_lock);
#endif
}
irda_rq_queue.thread = current; irda_rq_queue.thread = current;
complete((struct completion *)startup); complete((struct completion *)startup);
...@@ -166,6 +135,10 @@ static int irda_thread(void *startup) ...@@ -166,6 +135,10 @@ static int irda_thread(void *startup)
set_task_state(current, TASK_RUNNING); set_task_state(current, TASK_RUNNING);
remove_wait_queue(&irda_rq_queue.kick, &wait); remove_wait_queue(&irda_rq_queue.kick, &wait);
/* make swsusp happy with our thread */
if (current->flags & PF_FREEZE)
refrigerator(PF_IOTHREAD);
run_irda_queue(); run_irda_queue();
} }
...@@ -442,7 +415,6 @@ static void irda_config_fsm(void *data) ...@@ -442,7 +415,6 @@ static void irda_config_fsm(void *data)
case SIRDEV_STATE_COMPLETE: case SIRDEV_STATE_COMPLETE:
/* config change finished, so we are not busy any longer */ /* config change finished, so we are not busy any longer */
sirdev_enable_rx(dev); sirdev_enable_rx(dev);
printk(KERN_INFO "%s - up\n", __FUNCTION__);
up(&fsm->sem); up(&fsm->sem);
return; return;
} }
...@@ -462,9 +434,7 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par ...@@ -462,9 +434,7 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
struct sir_fsm *fsm = &dev->fsm; struct sir_fsm *fsm = &dev->fsm;
int xmit_was_down; int xmit_was_down;
// IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param); IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param);
printk(KERN_INFO "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param);
if (in_interrupt()) { if (in_interrupt()) {
if (down_trylock(&fsm->sem)) { if (down_trylock(&fsm->sem)) {
...@@ -474,12 +444,10 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par ...@@ -474,12 +444,10 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
} }
else else
down(&fsm->sem); down(&fsm->sem);
printk(KERN_INFO "%s - down\n", __FUNCTION__);
if (fsm->state == SIRDEV_STATE_DEAD) { if (fsm->state == SIRDEV_STATE_DEAD) {
/* race with sirdev_close should never happen */ /* race with sirdev_close should never happen */
ERROR("%s(), instance staled!\n", __FUNCTION__); ERROR("%s(), instance staled!\n", __FUNCTION__);
printk(KERN_INFO "%s - up\n", __FUNCTION__);
up(&fsm->sem); up(&fsm->sem);
return -ESTALE; /* or better EPIPE? */ return -ESTALE; /* or better EPIPE? */
} }
...@@ -501,7 +469,6 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par ...@@ -501,7 +469,6 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
atomic_set(&dev->enable_rx, 1); atomic_set(&dev->enable_rx, 1);
if (!xmit_was_down) if (!xmit_was_down)
netif_wake_queue(dev->netdev); netif_wake_queue(dev->netdev);
printk(KERN_INFO "%s - up\n", __FUNCTION__);
up(&fsm->sem); up(&fsm->sem);
return -EAGAIN; return -EAGAIN;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment