patch-2.4.21 linux-2.4.21/drivers/net/irda/irtty.c
Next file: linux-2.4.21/drivers/net/irda/smc-ircc.c
Previous file: linux-2.4.21/drivers/net/irda/donauboe.h
Back to the patch index
Back to the overall index
- Lines: 71
- Date:
2003-06-13 07:51:35.000000000 -0700
- Orig file:
linux-2.4.20/drivers/net/irda/irtty.c
- Orig date:
2002-11-28 15:53:13.000000000 -0800
diff -urN linux-2.4.20/drivers/net/irda/irtty.c linux-2.4.21/drivers/net/irda/irtty.c
@@ -966,9 +966,14 @@
IRDA_DEBUG(3, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd);
- /* Disable interrupts & save flags */
- save_flags(flags);
- cli();
+ /* Locking :
+ * irda_device_dongle_init() can't be locked.
+ * irda_task_execute() doesn't need to be locked (but
+ * irtty_change_speed() should protect itself).
+ * As this driver doesn't have spinlock protection, keep
+ * old fashion locking :-(
+ * Jean II
+ */
switch (cmd) {
case SIOCSBANDWIDTH: /* Set bandwidth */
@@ -994,14 +999,17 @@
dongle->write = irtty_raw_write;
dongle->set_dtr_rts = irtty_set_dtr_rts;
- self->dongle = dongle;
-
- /* Now initialize the dongle! */
+ /* Now initialize the dongle!
+ * Safe to do unlocked : self->dongle is still NULL. */
dongle->issue->open(dongle, &self->qos);
/* Reset dongle */
irda_task_execute(dongle, dongle->issue->reset, NULL, NULL,
NULL);
+
+ /* Make dongle available to driver only now to avoid
+ * race conditions - Jean II */
+ self->dongle = dongle;
break;
case SIOCSMEDIABUSY: /* Set media busy */
if (!capable(CAP_NET_ADMIN))
@@ -1015,21 +1023,27 @@
case SIOCSDTRRTS:
if (!capable(CAP_NET_ADMIN))
ret = -EPERM;
- else
+ else {
+ save_flags(flags);
+ cli();
irtty_set_dtr_rts(dev, irq->ifr_dtr, irq->ifr_rts);
+ restore_flags(flags);
+ }
break;
case SIOCSMODE:
if (!capable(CAP_NET_ADMIN))
ret = -EPERM;
- else
+ else {
+ save_flags(flags);
+ cli();
irtty_set_mode(dev, irq->ifr_mode);
+ restore_flags(flags);
+ }
break;
default:
ret = -EOPNOTSUPP;
}
- restore_flags(flags);
-
return ret;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)