aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/hamradio/mkiss.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/hamradio/mkiss.c')
-rw-r--r--drivers/net/hamradio/mkiss.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index a7286500c186..fda2fc83e9a1 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -244,16 +244,15 @@ static int kiss_esc_crc(unsigned char *s, unsigned char *d, unsigned short crc,
244/* Send one completely decapsulated AX.25 packet to the AX.25 layer. */ 244/* Send one completely decapsulated AX.25 packet to the AX.25 layer. */
245static void ax_bump(struct mkiss *ax) 245static void ax_bump(struct mkiss *ax)
246{ 246{
247 unsigned long flags;
248 struct sk_buff *skb; 247 struct sk_buff *skb;
249 int count; 248 int count;
250 249
251 spin_lock_irqsave(&ax->buflock, flags); 250 spin_lock_bh(&ax->buflock);
252 if (ax->rbuff[0] > 0x0f) { 251 if (ax->rbuff[0] > 0x0f) {
253 if (ax->rbuff[0] & 0x80) { 252 if (ax->rbuff[0] & 0x80) {
254 if (check_crc_16(ax->rbuff, ax->rcount) < 0) { 253 if (check_crc_16(ax->rbuff, ax->rcount) < 0) {
255 ax->dev->stats.rx_errors++; 254 ax->dev->stats.rx_errors++;
256 spin_unlock_irqrestore(&ax->buflock, flags); 255 spin_unlock_bh(&ax->buflock);
257 256
258 return; 257 return;
259 } 258 }
@@ -268,7 +267,7 @@ static void ax_bump(struct mkiss *ax)
268 } else if (ax->rbuff[0] & 0x20) { 267 } else if (ax->rbuff[0] & 0x20) {
269 if (check_crc_flex(ax->rbuff, ax->rcount) < 0) { 268 if (check_crc_flex(ax->rbuff, ax->rcount) < 0) {
270 ax->dev->stats.rx_errors++; 269 ax->dev->stats.rx_errors++;
271 spin_unlock_irqrestore(&ax->buflock, flags); 270 spin_unlock_bh(&ax->buflock);
272 return; 271 return;
273 } 272 }
274 if (ax->crcmode != CRC_MODE_FLEX && ax->crcauto) { 273 if (ax->crcmode != CRC_MODE_FLEX && ax->crcauto) {
@@ -295,7 +294,7 @@ static void ax_bump(struct mkiss *ax)
295 printk(KERN_ERR "mkiss: %s: memory squeeze, dropping packet.\n", 294 printk(KERN_ERR "mkiss: %s: memory squeeze, dropping packet.\n",
296 ax->dev->name); 295 ax->dev->name);
297 ax->dev->stats.rx_dropped++; 296 ax->dev->stats.rx_dropped++;
298 spin_unlock_irqrestore(&ax->buflock, flags); 297 spin_unlock_bh(&ax->buflock);
299 return; 298 return;
300 } 299 }
301 300
@@ -304,13 +303,11 @@ static void ax_bump(struct mkiss *ax)
304 netif_rx(skb); 303 netif_rx(skb);
305 ax->dev->stats.rx_packets++; 304 ax->dev->stats.rx_packets++;
306 ax->dev->stats.rx_bytes += count; 305 ax->dev->stats.rx_bytes += count;
307 spin_unlock_irqrestore(&ax->buflock, flags); 306 spin_unlock_bh(&ax->buflock);
308} 307}
309 308
310static void kiss_unesc(struct mkiss *ax, unsigned char s) 309static void kiss_unesc(struct mkiss *ax, unsigned char s)
311{ 310{
312 unsigned long flags;
313
314 switch (s) { 311 switch (s) {
315 case END: 312 case END:
316 /* drop keeptest bit = VSV */ 313 /* drop keeptest bit = VSV */
@@ -337,18 +334,18 @@ static void kiss_unesc(struct mkiss *ax, unsigned char s)
337 break; 334 break;
338 } 335 }
339 336
340 spin_lock_irqsave(&ax->buflock, flags); 337 spin_lock_bh(&ax->buflock);
341 if (!test_bit(AXF_ERROR, &ax->flags)) { 338 if (!test_bit(AXF_ERROR, &ax->flags)) {
342 if (ax->rcount < ax->buffsize) { 339 if (ax->rcount < ax->buffsize) {
343 ax->rbuff[ax->rcount++] = s; 340 ax->rbuff[ax->rcount++] = s;
344 spin_unlock_irqrestore(&ax->buflock, flags); 341 spin_unlock_bh(&ax->buflock);
345 return; 342 return;
346 } 343 }
347 344
348 ax->dev->stats.rx_over_errors++; 345 ax->dev->stats.rx_over_errors++;
349 set_bit(AXF_ERROR, &ax->flags); 346 set_bit(AXF_ERROR, &ax->flags);
350 } 347 }
351 spin_unlock_irqrestore(&ax->buflock, flags); 348 spin_unlock_bh(&ax->buflock);
352} 349}
353 350
354static int ax_set_mac_address(struct net_device *dev, void *addr) 351static int ax_set_mac_address(struct net_device *dev, void *addr)
@@ -370,7 +367,6 @@ static void ax_changedmtu(struct mkiss *ax)
370{ 367{
371 struct net_device *dev = ax->dev; 368 struct net_device *dev = ax->dev;
372 unsigned char *xbuff, *rbuff, *oxbuff, *orbuff; 369 unsigned char *xbuff, *rbuff, *oxbuff, *orbuff;
373 unsigned long flags;
374 int len; 370 int len;
375 371
376 len = dev->mtu * 2; 372 len = dev->mtu * 2;
@@ -396,7 +392,7 @@ static void ax_changedmtu(struct mkiss *ax)
396 return; 392 return;
397 } 393 }
398 394
399 spin_lock_irqsave(&ax->buflock, flags); 395 spin_lock_bh(&ax->buflock);
400 396
401 oxbuff = ax->xbuff; 397 oxbuff = ax->xbuff;
402 ax->xbuff = xbuff; 398 ax->xbuff = xbuff;
@@ -427,7 +423,7 @@ static void ax_changedmtu(struct mkiss *ax)
427 ax->mtu = dev->mtu + 73; 423 ax->mtu = dev->mtu + 73;
428 ax->buffsize = len; 424 ax->buffsize = len;
429 425
430 spin_unlock_irqrestore(&ax->buflock, flags); 426 spin_unlock_bh(&ax->buflock);
431 427
432 kfree(oxbuff); 428 kfree(oxbuff);
433 kfree(orbuff); 429 kfree(orbuff);
@@ -437,7 +433,6 @@ static void ax_changedmtu(struct mkiss *ax)
437static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) 433static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
438{ 434{
439 struct mkiss *ax = netdev_priv(dev); 435 struct mkiss *ax = netdev_priv(dev);
440 unsigned long flags;
441 unsigned char *p; 436 unsigned char *p;
442 int actual, count; 437 int actual, count;
443 438
@@ -454,7 +449,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
454 449
455 p = icp; 450 p = icp;
456 451
457 spin_lock_irqsave(&ax->buflock, flags); 452 spin_lock_bh(&ax->buflock);
458 if ((*p & 0x0f) != 0) { 453 if ((*p & 0x0f) != 0) {
459 /* Configuration Command (kissparms(1). 454 /* Configuration Command (kissparms(1).
460 * Protocol spec says: never append CRC. 455 * Protocol spec says: never append CRC.
@@ -484,7 +479,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
484 ax->crcauto = (cmd ? 0 : 1); 479 ax->crcauto = (cmd ? 0 : 1);
485 printk(KERN_INFO "mkiss: %s: crc mode %s %d\n", ax->dev->name, (len) ? "set to" : "is", cmd); 480 printk(KERN_INFO "mkiss: %s: crc mode %s %d\n", ax->dev->name, (len) ? "set to" : "is", cmd);
486 } 481 }
487 spin_unlock_irqrestore(&ax->buflock, flags); 482 spin_unlock_bh(&ax->buflock);
488 netif_start_queue(dev); 483 netif_start_queue(dev);
489 484
490 return; 485 return;
@@ -517,7 +512,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
517 count = kiss_esc(p, (unsigned char *)ax->xbuff, len); 512 count = kiss_esc(p, (unsigned char *)ax->xbuff, len);
518 } 513 }
519 } 514 }
520 spin_unlock_irqrestore(&ax->buflock, flags); 515 spin_unlock_bh(&ax->buflock);
521 516
522 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); 517 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
523 actual = ax->tty->ops->write(ax->tty, ax->xbuff, count); 518 actual = ax->tty->ops->write(ax->tty, ax->xbuff, count);
@@ -709,14 +704,13 @@ static DEFINE_RWLOCK(disc_data_lock);
709 704
710static struct mkiss *mkiss_get(struct tty_struct *tty) 705static struct mkiss *mkiss_get(struct tty_struct *tty)
711{ 706{
712 unsigned long flags;
713 struct mkiss *ax; 707 struct mkiss *ax;
714 708
715 read_lock_irqsave(&disc_data_lock, flags); 709 read_lock(&disc_data_lock);
716 ax = tty->disc_data; 710 ax = tty->disc_data;
717 if (ax) 711 if (ax)
718 atomic_inc(&ax->refcnt); 712 atomic_inc(&ax->refcnt);
719 read_unlock_irqrestore(&disc_data_lock, flags); 713 read_unlock(&disc_data_lock);
720 714
721 return ax; 715 return ax;
722} 716}
@@ -815,13 +809,12 @@ out:
815 809
816static void mkiss_close(struct tty_struct *tty) 810static void mkiss_close(struct tty_struct *tty)
817{ 811{
818 unsigned long flags;
819 struct mkiss *ax; 812 struct mkiss *ax;
820 813
821 write_lock_irqsave(&disc_data_lock, flags); 814 write_lock(&disc_data_lock);
822 ax = tty->disc_data; 815 ax = tty->disc_data;
823 tty->disc_data = NULL; 816 tty->disc_data = NULL;
824 write_unlock_irqrestore(&disc_data_lock, flags); 817 write_unlock(&disc_data_lock);
825 818
826 if (!ax) 819 if (!ax)
827 return; 820 return;