aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/Makefile2
-rw-r--r--drivers/isdn/capi/capi.c2
-rw-r--r--drivers/isdn/capi/kcapi.c4
-rw-r--r--drivers/isdn/gigaset/isocdata.c5
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c27
-rw-r--r--drivers/isdn/hardware/mISDN/hfc_pci.h4
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c37
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c25
-rw-r--r--drivers/isdn/hysdn/hysdn_pof.h2
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c352
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c6
-rw-r--r--drivers/isdn/mISDN/socket.c4
-rw-r--r--drivers/isdn/mISDN/timerdev.c22
13 files changed, 252 insertions, 240 deletions
diff --git a/drivers/isdn/Makefile b/drivers/isdn/Makefile
index 8380a4568d11..f1f777570e8e 100644
--- a/drivers/isdn/Makefile
+++ b/drivers/isdn/Makefile
@@ -5,7 +5,7 @@
5obj-$(CONFIG_ISDN_I4L) += i4l/ 5obj-$(CONFIG_ISDN_I4L) += i4l/
6obj-$(CONFIG_ISDN_CAPI) += capi/ 6obj-$(CONFIG_ISDN_CAPI) += capi/
7obj-$(CONFIG_MISDN) += mISDN/ 7obj-$(CONFIG_MISDN) += mISDN/
8obj-$(CONFIG_ISDN_CAPI) += hardware/ 8obj-$(CONFIG_ISDN) += hardware/
9obj-$(CONFIG_ISDN_DIVERSION) += divert/ 9obj-$(CONFIG_ISDN_DIVERSION) += divert/
10obj-$(CONFIG_ISDN_DRV_HISAX) += hisax/ 10obj-$(CONFIG_ISDN_DRV_HISAX) += hisax/
11obj-$(CONFIG_ISDN_DRV_ICN) += icn/ 11obj-$(CONFIG_ISDN_DRV_ICN) += icn/
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 871b0cbca5e4..798d7f3e42ef 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1231,7 +1231,7 @@ static int capinc_tty_ioctl(struct tty_struct *tty, struct file * file,
1231 int error = 0; 1231 int error = 0;
1232 switch (cmd) { 1232 switch (cmd) {
1233 default: 1233 default:
1234 error = n_tty_ioctl (tty, file, cmd, arg); 1234 error = n_tty_ioctl_helper(tty, file, cmd, arg);
1235 break; 1235 break;
1236 } 1236 }
1237 return error; 1237 return error;
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 75726ea0fbbd..5360c4fd4739 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -828,15 +828,18 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
828 return -ESRCH; 828 return -ESRCH;
829 if (card->load_firmware == NULL) { 829 if (card->load_firmware == NULL) {
830 printk(KERN_DEBUG "kcapi: load: no load function\n"); 830 printk(KERN_DEBUG "kcapi: load: no load function\n");
831 capi_ctr_put(card);
831 return -ESRCH; 832 return -ESRCH;
832 } 833 }
833 834
834 if (ldef.t4file.len <= 0) { 835 if (ldef.t4file.len <= 0) {
835 printk(KERN_DEBUG "kcapi: load: invalid parameter: length of t4file is %d ?\n", ldef.t4file.len); 836 printk(KERN_DEBUG "kcapi: load: invalid parameter: length of t4file is %d ?\n", ldef.t4file.len);
837 capi_ctr_put(card);
836 return -EINVAL; 838 return -EINVAL;
837 } 839 }
838 if (ldef.t4file.data == NULL) { 840 if (ldef.t4file.data == NULL) {
839 printk(KERN_DEBUG "kcapi: load: invalid parameter: dataptr is 0\n"); 841 printk(KERN_DEBUG "kcapi: load: invalid parameter: dataptr is 0\n");
842 capi_ctr_put(card);
840 return -EINVAL; 843 return -EINVAL;
841 } 844 }
842 845
@@ -849,6 +852,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
849 852
850 if (card->cardstate != CARD_DETECTED) { 853 if (card->cardstate != CARD_DETECTED) {
851 printk(KERN_INFO "kcapi: load: contr=%d not in detect state\n", ldef.contr); 854 printk(KERN_INFO "kcapi: load: contr=%d not in detect state\n", ldef.contr);
855 capi_ctr_put(card);
852 return -EBUSY; 856 return -EBUSY;
853 } 857 }
854 card->cardstate = CARD_LOADING; 858 card->cardstate = CARD_LOADING;
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index e30a7773f93c..fbce5222d83c 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -247,7 +247,6 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
247#ifdef CONFIG_GIGASET_DEBUG 247#ifdef CONFIG_GIGASET_DEBUG
248 unsigned char c; 248 unsigned char c;
249 static char dbgline[3 * 32 + 1]; 249 static char dbgline[3 * 32 + 1];
250 static const char hexdigit[] = "0123456789abcdef";
251 int i = 0; 250 int i = 0;
252 while (count-- > 0) { 251 while (count-- > 0) {
253 if (i > sizeof(dbgline) - 4) { 252 if (i > sizeof(dbgline) - 4) {
@@ -258,8 +257,8 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
258 c = *bytes++; 257 c = *bytes++;
259 dbgline[i] = (i && !(i % 12)) ? '-' : ' '; 258 dbgline[i] = (i && !(i % 12)) ? '-' : ' ';
260 i++; 259 i++;
261 dbgline[i++] = hexdigit[(c >> 4) & 0x0f]; 260 dbgline[i++] = hex_asc_hi(c);
262 dbgline[i++] = hexdigit[c & 0x0f]; 261 dbgline[i++] = hex_asc_lo(c);
263 } 262 }
264 dbgline[i] = '\0'; 263 dbgline[i] = '\0';
265 gig_dbg(level, "%s:%s", tag, dbgline); 264 gig_dbg(level, "%s:%s", tag, dbgline);
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 5e89fa177816..07052ed2a0c5 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -571,6 +571,7 @@ gigaset_tty_close(struct tty_struct *tty)
571 } 571 }
572 572
573 /* prevent other callers from entering ldisc methods */ 573 /* prevent other callers from entering ldisc methods */
574 /* FIXME: should use the tty state flags */
574 tty->disc_data = NULL; 575 tty->disc_data = NULL;
575 576
576 if (!cs->hw.ser) 577 if (!cs->hw.ser)
@@ -642,10 +643,11 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
642 return -ENXIO; 643 return -ENXIO;
643 644
644 switch (cmd) { 645 switch (cmd) {
645 case TCGETS: 646
646 case TCGETA: 647 case FIONREAD:
647 /* pass through to underlying serial device */ 648 /* unused, always return zero */
648 rc = n_tty_ioctl(tty, file, cmd, arg); 649 val = 0;
650 rc = put_user(val, p);
649 break; 651 break;
650 652
651 case TCFLSH: 653 case TCFLSH:
@@ -659,20 +661,13 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
659 flush_send_queue(cs); 661 flush_send_queue(cs);
660 break; 662 break;
661 } 663 }
662 /* flush the serial port's buffer */ 664 /* Pass through */
663 rc = n_tty_ioctl(tty, file, cmd, arg);
664 break;
665
666 case FIONREAD:
667 /* unused, always return zero */
668 val = 0;
669 rc = put_user(val, p);
670 break;
671 665
672 default: 666 default:
673 rc = -ENOIOCTLCMD; 667 /* pass through to underlying serial device */
668 rc = n_tty_ioctl_helper(tty, file, cmd, arg);
669 break;
674 } 670 }
675
676 cs_put(cs); 671 cs_put(cs);
677 return rc; 672 return rc;
678} 673}
@@ -680,6 +675,8 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
680/* 675/*
681 * Poll on the tty. 676 * Poll on the tty.
682 * Unused, always return zero. 677 * Unused, always return zero.
678 *
679 * FIXME: should probably return an exception - especially on hangup
683 */ 680 */
684static unsigned int 681static unsigned int
685gigaset_tty_poll(struct tty_struct *tty, struct file *file, poll_table *wait) 682gigaset_tty_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
diff --git a/drivers/isdn/hardware/mISDN/hfc_pci.h b/drivers/isdn/hardware/mISDN/hfc_pci.h
index fd2c9be6d849..5783d22a18fe 100644
--- a/drivers/isdn/hardware/mISDN/hfc_pci.h
+++ b/drivers/isdn/hardware/mISDN/hfc_pci.h
@@ -183,8 +183,8 @@
183#define D_FREG_MASK 0xF 183#define D_FREG_MASK 0xF
184 184
185struct zt { 185struct zt {
186 unsigned short z1; /* Z1 pointer 16 Bit */ 186 __le16 z1; /* Z1 pointer 16 Bit */
187 unsigned short z2; /* Z2 pointer 16 Bit */ 187 __le16 z2; /* Z2 pointer 16 Bit */
188}; 188};
189 189
190struct dfifo { 190struct dfifo {
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 2649ea55a9e8..1eac03f39d00 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -140,7 +140,7 @@
140 * #define HFC_REGISTER_DEBUG 140 * #define HFC_REGISTER_DEBUG
141 */ 141 */
142 142
143static const char *hfcmulti_revision = "2.00"; 143static const char *hfcmulti_revision = "2.02";
144 144
145#include <linux/module.h> 145#include <linux/module.h>
146#include <linux/pci.h> 146#include <linux/pci.h>
@@ -427,12 +427,12 @@ write_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
427{ 427{
428 outb(A_FIFO_DATA0, (hc->pci_iobase)+4); 428 outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
429 while (len>>2) { 429 while (len>>2) {
430 outl(*(u32 *)data, hc->pci_iobase); 430 outl(cpu_to_le32(*(u32 *)data), hc->pci_iobase);
431 data += 4; 431 data += 4;
432 len -= 4; 432 len -= 4;
433 } 433 }
434 while (len>>1) { 434 while (len>>1) {
435 outw(*(u16 *)data, hc->pci_iobase); 435 outw(cpu_to_le16(*(u16 *)data), hc->pci_iobase);
436 data += 2; 436 data += 2;
437 len -= 2; 437 len -= 2;
438 } 438 }
@@ -447,17 +447,19 @@ void
447write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len) 447write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
448{ 448{
449 while (len>>2) { 449 while (len>>2) {
450 writel(*(u32 *)data, (hc->pci_membase)+A_FIFO_DATA0); 450 writel(cpu_to_le32(*(u32 *)data),
451 hc->pci_membase + A_FIFO_DATA0);
451 data += 4; 452 data += 4;
452 len -= 4; 453 len -= 4;
453 } 454 }
454 while (len>>1) { 455 while (len>>1) {
455 writew(*(u16 *)data, (hc->pci_membase)+A_FIFO_DATA0); 456 writew(cpu_to_le16(*(u16 *)data),
457 hc->pci_membase + A_FIFO_DATA0);
456 data += 2; 458 data += 2;
457 len -= 2; 459 len -= 2;
458 } 460 }
459 while (len) { 461 while (len) {
460 writeb(*data, (hc->pci_membase)+A_FIFO_DATA0); 462 writeb(*data, hc->pci_membase + A_FIFO_DATA0);
461 data++; 463 data++;
462 len--; 464 len--;
463 } 465 }
@@ -468,12 +470,12 @@ read_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
468{ 470{
469 outb(A_FIFO_DATA0, (hc->pci_iobase)+4); 471 outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
470 while (len>>2) { 472 while (len>>2) {
471 *(u32 *)data = inl(hc->pci_iobase); 473 *(u32 *)data = le32_to_cpu(inl(hc->pci_iobase));
472 data += 4; 474 data += 4;
473 len -= 4; 475 len -= 4;
474 } 476 }
475 while (len>>1) { 477 while (len>>1) {
476 *(u16 *)data = inw(hc->pci_iobase); 478 *(u16 *)data = le16_to_cpu(inw(hc->pci_iobase));
477 data += 2; 479 data += 2;
478 len -= 2; 480 len -= 2;
479 } 481 }
@@ -490,18 +492,18 @@ read_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
490{ 492{
491 while (len>>2) { 493 while (len>>2) {
492 *(u32 *)data = 494 *(u32 *)data =
493 readl((hc->pci_membase)+A_FIFO_DATA0); 495 le32_to_cpu(readl(hc->pci_membase + A_FIFO_DATA0));
494 data += 4; 496 data += 4;
495 len -= 4; 497 len -= 4;
496 } 498 }
497 while (len>>1) { 499 while (len>>1) {
498 *(u16 *)data = 500 *(u16 *)data =
499 readw((hc->pci_membase)+A_FIFO_DATA0); 501 le16_to_cpu(readw(hc->pci_membase + A_FIFO_DATA0));
500 data += 2; 502 data += 2;
501 len -= 2; 503 len -= 2;
502 } 504 }
503 while (len) { 505 while (len) {
504 *data = readb((hc->pci_membase)+A_FIFO_DATA0); 506 *data = readb(hc->pci_membase + A_FIFO_DATA0);
505 data++; 507 data++;
506 len--; 508 len--;
507 } 509 }
@@ -3971,7 +3973,7 @@ open_bchannel(struct hfc_multi *hc, struct dchannel *dch,
3971 struct bchannel *bch; 3973 struct bchannel *bch;
3972 int ch; 3974 int ch;
3973 3975
3974 if (!test_bit(rq->adr.channel, &dch->dev.channelmap[0])) 3976 if (!test_channelmap(rq->adr.channel, dch->dev.channelmap))
3975 return -EINVAL; 3977 return -EINVAL;
3976 if (rq->protocol == ISDN_P_NONE) 3978 if (rq->protocol == ISDN_P_NONE)
3977 return -EINVAL; 3979 return -EINVAL;
@@ -4587,7 +4589,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
4587 list_add(&bch->ch.list, &dch->dev.bchannels); 4589 list_add(&bch->ch.list, &dch->dev.bchannels);
4588 hc->chan[ch].bch = bch; 4590 hc->chan[ch].bch = bch;
4589 hc->chan[ch].port = 0; 4591 hc->chan[ch].port = 0;
4590 test_and_set_bit(bch->nr, &dch->dev.channelmap[0]); 4592 set_channelmap(bch->nr, dch->dev.channelmap);
4591 } 4593 }
4592 /* set optical line type */ 4594 /* set optical line type */
4593 if (port[Port_cnt] & 0x001) { 4595 if (port[Port_cnt] & 0x001) {
@@ -4755,7 +4757,7 @@ init_multi_port(struct hfc_multi *hc, int pt)
4755 list_add(&bch->ch.list, &dch->dev.bchannels); 4757 list_add(&bch->ch.list, &dch->dev.bchannels);
4756 hc->chan[i + ch].bch = bch; 4758 hc->chan[i + ch].bch = bch;
4757 hc->chan[i + ch].port = pt; 4759 hc->chan[i + ch].port = pt;
4758 test_and_set_bit(bch->nr, &dch->dev.channelmap[0]); 4760 set_channelmap(bch->nr, dch->dev.channelmap);
4759 } 4761 }
4760 /* set master clock */ 4762 /* set master clock */
4761 if (port[Port_cnt] & 0x001) { 4763 if (port[Port_cnt] & 0x001) {
@@ -5050,12 +5052,12 @@ static void __devexit hfc_remove_pci(struct pci_dev *pdev)
5050 5052
5051static const struct hm_map hfcm_map[] = { 5053static const struct hm_map hfcm_map[] = {
5052/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0}, 5054/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0},
5053/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S}, 5055/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S, 0},
5054/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0}, 5056/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0},
5055/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0}, 5057/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0},
5056/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0}, 5058/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0},
5057/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0}, 5059/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0},
5058/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, 0, 0}, 5060/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, DIP_4S, 0},
5059/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0}, 5061/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0},
5060/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO}, 5062/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO},
5061/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0}, 5063/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0},
@@ -5251,9 +5253,6 @@ HFCmulti_init(void)
5251 if (debug & DEBUG_HFCMULTI_INIT) 5253 if (debug & DEBUG_HFCMULTI_INIT)
5252 printk(KERN_DEBUG "%s: init entered\n", __func__); 5254 printk(KERN_DEBUG "%s: init entered\n", __func__);
5253 5255
5254#ifdef __BIG_ENDIAN
5255#error "not running on big endian machines now"
5256#endif
5257 hfc_interrupt = symbol_get(ztdummy_extern_interrupt); 5256 hfc_interrupt = symbol_get(ztdummy_extern_interrupt);
5258 register_interrupt = symbol_get(ztdummy_register_interrupt); 5257 register_interrupt = symbol_get(ztdummy_register_interrupt);
5259 unregister_interrupt = symbol_get(ztdummy_unregister_interrupt); 5258 unregister_interrupt = symbol_get(ztdummy_unregister_interrupt);
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 3231814e7efa..cd8302af40eb 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -43,7 +43,7 @@ MODULE_LICENSE("GPL");
43module_param(debug, uint, 0); 43module_param(debug, uint, 0);
44 44
45static LIST_HEAD(HFClist); 45static LIST_HEAD(HFClist);
46DEFINE_RWLOCK(HFClock); 46static DEFINE_RWLOCK(HFClock);
47 47
48enum { 48enum {
49 HFC_CCD_2BD0, 49 HFC_CCD_2BD0,
@@ -88,7 +88,7 @@ struct hfcPCI_hw {
88 unsigned char bswapped; 88 unsigned char bswapped;
89 unsigned char protocol; 89 unsigned char protocol;
90 int nt_timer; 90 int nt_timer;
91 unsigned char *pci_io; /* start of PCI IO memory */ 91 unsigned char __iomem *pci_io; /* start of PCI IO memory */
92 dma_addr_t dmahandle; 92 dma_addr_t dmahandle;
93 void *fifos; /* FIFO memory */ 93 void *fifos; /* FIFO memory */
94 int last_bfifo_cnt[2]; 94 int last_bfifo_cnt[2];
@@ -153,7 +153,7 @@ release_io_hfcpci(struct hfc_pci *hc)
153 pci_write_config_word(hc->pdev, PCI_COMMAND, 0); 153 pci_write_config_word(hc->pdev, PCI_COMMAND, 0);
154 del_timer(&hc->hw.timer); 154 del_timer(&hc->hw.timer);
155 pci_free_consistent(hc->pdev, 0x8000, hc->hw.fifos, hc->hw.dmahandle); 155 pci_free_consistent(hc->pdev, 0x8000, hc->hw.fifos, hc->hw.dmahandle);
156 iounmap((void *)hc->hw.pci_io); 156 iounmap(hc->hw.pci_io);
157} 157}
158 158
159/* 159/*
@@ -366,8 +366,7 @@ static void hfcpci_clear_fifo_tx(struct hfc_pci *hc, int fifo)
366 bzt->f2 = MAX_B_FRAMES; 366 bzt->f2 = MAX_B_FRAMES;
367 bzt->f1 = bzt->f2; /* init F pointers to remain constant */ 367 bzt->f1 = bzt->f2; /* init F pointers to remain constant */
368 bzt->za[MAX_B_FRAMES].z1 = cpu_to_le16(B_FIFO_SIZE + B_SUB_VAL - 1); 368 bzt->za[MAX_B_FRAMES].z1 = cpu_to_le16(B_FIFO_SIZE + B_SUB_VAL - 1);
369 bzt->za[MAX_B_FRAMES].z2 = cpu_to_le16( 369 bzt->za[MAX_B_FRAMES].z2 = cpu_to_le16(B_FIFO_SIZE + B_SUB_VAL - 2);
370 le16_to_cpu(bzt->za[MAX_B_FRAMES].z1 - 1));
371 if (fifo_state) 370 if (fifo_state)
372 hc->hw.fifo_en |= fifo_state; 371 hc->hw.fifo_en |= fifo_state;
373 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en); 372 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
@@ -482,7 +481,7 @@ receive_dmsg(struct hfc_pci *hc)
482 df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) | 481 df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) |
483 (MAX_D_FRAMES + 1); /* next buffer */ 482 (MAX_D_FRAMES + 1); /* next buffer */
484 df->za[df->f2 & D_FREG_MASK].z2 = 483 df->za[df->f2 & D_FREG_MASK].z2 =
485 cpu_to_le16((zp->z2 + rcnt) & (D_FIFO_SIZE - 1)); 484 cpu_to_le16((le16_to_cpu(zp->z2) + rcnt) & (D_FIFO_SIZE - 1));
486 } else { 485 } else {
487 dch->rx_skb = mI_alloc_skb(rcnt - 3, GFP_ATOMIC); 486 dch->rx_skb = mI_alloc_skb(rcnt - 3, GFP_ATOMIC);
488 if (!dch->rx_skb) { 487 if (!dch->rx_skb) {
@@ -523,10 +522,10 @@ receive_dmsg(struct hfc_pci *hc)
523/* 522/*
524 * check for transparent receive data and read max one threshold size if avail 523 * check for transparent receive data and read max one threshold size if avail
525 */ 524 */
526int 525static int
527hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata) 526hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
528{ 527{
529 unsigned short *z1r, *z2r; 528 __le16 *z1r, *z2r;
530 int new_z2, fcnt, maxlen; 529 int new_z2, fcnt, maxlen;
531 u_char *ptr, *ptr1; 530 u_char *ptr, *ptr1;
532 531
@@ -576,7 +575,7 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
576/* 575/*
577 * B-channel main receive routine 576 * B-channel main receive routine
578 */ 577 */
579void 578static void
580main_rec_hfcpci(struct bchannel *bch) 579main_rec_hfcpci(struct bchannel *bch)
581{ 580{
582 struct hfc_pci *hc = bch->hw; 581 struct hfc_pci *hc = bch->hw;
@@ -724,7 +723,7 @@ hfcpci_fill_fifo(struct bchannel *bch)
724 struct bzfifo *bz; 723 struct bzfifo *bz;
725 u_char *bdata; 724 u_char *bdata;
726 u_char new_f1, *src, *dst; 725 u_char new_f1, *src, *dst;
727 unsigned short *z1t, *z2t; 726 __le16 *z1t, *z2t;
728 727
729 if ((bch->debug & DEBUG_HW_BCHANNEL) && !(bch->debug & DEBUG_HW_BFIFO)) 728 if ((bch->debug & DEBUG_HW_BCHANNEL) && !(bch->debug & DEBUG_HW_BFIFO))
730 printk(KERN_DEBUG "%s\n", __func__); 729 printk(KERN_DEBUG "%s\n", __func__);
@@ -1679,7 +1678,7 @@ hfcpci_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb)
1679 * called for card init message 1678 * called for card init message
1680 */ 1679 */
1681 1680
1682void 1681static void
1683inithfcpci(struct hfc_pci *hc) 1682inithfcpci(struct hfc_pci *hc)
1684{ 1683{
1685 printk(KERN_DEBUG "inithfcpci: entered\n"); 1684 printk(KERN_DEBUG "inithfcpci: entered\n");
@@ -1966,7 +1965,7 @@ setup_hw(struct hfc_pci *hc)
1966 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); 1965 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
1967 return 1; 1966 return 1;
1968 } 1967 }
1969 hc->hw.pci_io = (char *)(ulong)hc->pdev->resource[1].start; 1968 hc->hw.pci_io = (char __iomem *)(unsigned long)hc->pdev->resource[1].start;
1970 1969
1971 if (!hc->hw.pci_io) { 1970 if (!hc->hw.pci_io) {
1972 printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n"); 1971 printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
@@ -2056,7 +2055,7 @@ setup_card(struct hfc_pci *card)
2056 card->dch.dev.nrbchan = 2; 2055 card->dch.dev.nrbchan = 2;
2057 for (i = 0; i < 2; i++) { 2056 for (i = 0; i < 2; i++) {
2058 card->bch[i].nr = i + 1; 2057 card->bch[i].nr = i + 1;
2059 test_and_set_bit(i + 1, &card->dch.dev.channelmap[0]); 2058 set_channelmap(i + 1, card->dch.dev.channelmap);
2060 card->bch[i].debug = debug; 2059 card->bch[i].debug = debug;
2061 mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM); 2060 mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM);
2062 card->bch[i].hw = card; 2061 card->bch[i].hw = card;
diff --git a/drivers/isdn/hysdn/hysdn_pof.h b/drivers/isdn/hysdn/hysdn_pof.h
index a368d6caca0e..3a72b908900f 100644
--- a/drivers/isdn/hysdn/hysdn_pof.h
+++ b/drivers/isdn/hysdn/hysdn_pof.h
@@ -60,7 +60,7 @@ typedef struct PofRecHdr_tag { /* Pof record header */
60 60
61typedef struct PofTimeStamp_tag { 61typedef struct PofTimeStamp_tag {
62/*00 */ unsigned long UnixTime __attribute__((packed)); 62/*00 */ unsigned long UnixTime __attribute__((packed));
63 /*04 */ unsigned char DateTimeText[0x28] __attribute__((packed)); 63 /*04 */ unsigned char DateTimeText[0x28];
64 /* =40 */ 64 /* =40 */
65/*2C */ 65/*2C */
66} tPofTimeStamp; 66} tPofTimeStamp;
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 127cfdad68e7..77c280ef2eb6 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -1533,8 +1533,10 @@ static int isdn_ppp_mp_bundle_array_init(void)
1533 int sz = ISDN_MAX_CHANNELS*sizeof(ippp_bundle); 1533 int sz = ISDN_MAX_CHANNELS*sizeof(ippp_bundle);
1534 if( (isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL ) 1534 if( (isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL )
1535 return -ENOMEM; 1535 return -ENOMEM;
1536 for( i = 0; i < ISDN_MAX_CHANNELS; i++ ) 1536 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
1537 spin_lock_init(&isdn_ppp_bundle_arr[i].lock); 1537 spin_lock_init(&isdn_ppp_bundle_arr[i].lock);
1538 skb_queue_head_init(&isdn_ppp_bundle_arr[i].frags);
1539 }
1538 return 0; 1540 return 0;
1539} 1541}
1540 1542
@@ -1567,7 +1569,7 @@ static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to )
1567 if ((lp->netdev->pb = isdn_ppp_mp_bundle_alloc()) == NULL) 1569 if ((lp->netdev->pb = isdn_ppp_mp_bundle_alloc()) == NULL)
1568 return -ENOMEM; 1570 return -ENOMEM;
1569 lp->next = lp->last = lp; /* nobody else in a queue */ 1571 lp->next = lp->last = lp; /* nobody else in a queue */
1570 lp->netdev->pb->frags = NULL; 1572 skb_queue_head_init(&lp->netdev->pb->frags);
1571 lp->netdev->pb->frames = 0; 1573 lp->netdev->pb->frames = 0;
1572 lp->netdev->pb->seq = UINT_MAX; 1574 lp->netdev->pb->seq = UINT_MAX;
1573 } 1575 }
@@ -1579,28 +1581,29 @@ static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to )
1579 1581
1580static u32 isdn_ppp_mp_get_seq( int short_seq, 1582static u32 isdn_ppp_mp_get_seq( int short_seq,
1581 struct sk_buff * skb, u32 last_seq ); 1583 struct sk_buff * skb, u32 last_seq );
1582static struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp, 1584static void isdn_ppp_mp_discard(ippp_bundle *mp, struct sk_buff *from,
1583 struct sk_buff * from, struct sk_buff * to ); 1585 struct sk_buff *to);
1584static void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp, 1586static void isdn_ppp_mp_reassembly(isdn_net_dev *net_dev, isdn_net_local *lp,
1585 struct sk_buff * from, struct sk_buff * to ); 1587 struct sk_buff *from, struct sk_buff *to,
1586static void isdn_ppp_mp_free_skb( ippp_bundle * mp, struct sk_buff * skb ); 1588 u32 lastseq);
1589static void isdn_ppp_mp_free_skb(ippp_bundle *mp, struct sk_buff *skb);
1587static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb ); 1590static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb );
1588 1591
1589static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, 1592static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1590 struct sk_buff *skb) 1593 struct sk_buff *skb)
1591{ 1594{
1592 struct ippp_struct *is; 1595 struct sk_buff *newfrag, *frag, *start, *nextf;
1593 isdn_net_local * lpq;
1594 ippp_bundle * mp;
1595 isdn_mppp_stats * stats;
1596 struct sk_buff * newfrag, * frag, * start, *nextf;
1597 u32 newseq, minseq, thisseq; 1596 u32 newseq, minseq, thisseq;
1597 isdn_mppp_stats *stats;
1598 struct ippp_struct *is;
1598 unsigned long flags; 1599 unsigned long flags;
1600 isdn_net_local *lpq;
1601 ippp_bundle *mp;
1599 int slot; 1602 int slot;
1600 1603
1601 spin_lock_irqsave(&net_dev->pb->lock, flags); 1604 spin_lock_irqsave(&net_dev->pb->lock, flags);
1602 mp = net_dev->pb; 1605 mp = net_dev->pb;
1603 stats = &mp->stats; 1606 stats = &mp->stats;
1604 slot = lp->ppp_slot; 1607 slot = lp->ppp_slot;
1605 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 1608 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
1606 printk(KERN_ERR "%s: lp->ppp_slot(%d)\n", 1609 printk(KERN_ERR "%s: lp->ppp_slot(%d)\n",
@@ -1611,20 +1614,19 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1611 return; 1614 return;
1612 } 1615 }
1613 is = ippp_table[slot]; 1616 is = ippp_table[slot];
1614 if( ++mp->frames > stats->max_queue_len ) 1617 if (++mp->frames > stats->max_queue_len)
1615 stats->max_queue_len = mp->frames; 1618 stats->max_queue_len = mp->frames;
1616 1619
1617 if (is->debug & 0x8) 1620 if (is->debug & 0x8)
1618 isdn_ppp_mp_print_recv_pkt(lp->ppp_slot, skb); 1621 isdn_ppp_mp_print_recv_pkt(lp->ppp_slot, skb);
1619 1622
1620 newseq = isdn_ppp_mp_get_seq(is->mpppcfg & SC_IN_SHORT_SEQ, 1623 newseq = isdn_ppp_mp_get_seq(is->mpppcfg & SC_IN_SHORT_SEQ,
1621 skb, is->last_link_seqno); 1624 skb, is->last_link_seqno);
1622
1623 1625
1624 /* if this packet seq # is less than last already processed one, 1626 /* if this packet seq # is less than last already processed one,
1625 * toss it right away, but check for sequence start case first 1627 * toss it right away, but check for sequence start case first
1626 */ 1628 */
1627 if( mp->seq > MP_LONGSEQ_MAX && (newseq & MP_LONGSEQ_MAXBIT) ) { 1629 if (mp->seq > MP_LONGSEQ_MAX && (newseq & MP_LONGSEQ_MAXBIT)) {
1628 mp->seq = newseq; /* the first packet: required for 1630 mp->seq = newseq; /* the first packet: required for
1629 * rfc1990 non-compliant clients -- 1631 * rfc1990 non-compliant clients --
1630 * prevents constant packet toss */ 1632 * prevents constant packet toss */
@@ -1634,7 +1636,7 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1634 spin_unlock_irqrestore(&mp->lock, flags); 1636 spin_unlock_irqrestore(&mp->lock, flags);
1635 return; 1637 return;
1636 } 1638 }
1637 1639
1638 /* find the minimum received sequence number over all links */ 1640 /* find the minimum received sequence number over all links */
1639 is->last_link_seqno = minseq = newseq; 1641 is->last_link_seqno = minseq = newseq;
1640 for (lpq = net_dev->queue;;) { 1642 for (lpq = net_dev->queue;;) {
@@ -1655,22 +1657,31 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1655 * packets */ 1657 * packets */
1656 newfrag = skb; 1658 newfrag = skb;
1657 1659
1658 /* if this new fragment is before the first one, then enqueue it now. */ 1660 /* Insert new fragment into the proper sequence slot. */
1659 if ((frag = mp->frags) == NULL || MP_LT(newseq, MP_SEQ(frag))) { 1661 skb_queue_walk(&mp->frags, frag) {
1660 newfrag->next = frag; 1662 if (MP_SEQ(frag) == newseq) {
1661 mp->frags = frag = newfrag; 1663 isdn_ppp_mp_free_skb(mp, newfrag);
1662 newfrag = NULL; 1664 newfrag = NULL;
1663 } 1665 break;
1666 }
1667 if (MP_LT(newseq, MP_SEQ(frag))) {
1668 __skb_queue_before(&mp->frags, frag, newfrag);
1669 newfrag = NULL;
1670 break;
1671 }
1672 }
1673 if (newfrag)
1674 __skb_queue_tail(&mp->frags, newfrag);
1664 1675
1665 start = MP_FLAGS(frag) & MP_BEGIN_FRAG && 1676 frag = skb_peek(&mp->frags);
1666 MP_SEQ(frag) == mp->seq ? frag : NULL; 1677 start = ((MP_FLAGS(frag) & MP_BEGIN_FRAG) &&
1678 (MP_SEQ(frag) == mp->seq)) ? frag : NULL;
1679 if (!start)
1680 goto check_overflow;
1667 1681
1668 /* 1682 /* main fragment traversing loop
1669 * main fragment traversing loop
1670 * 1683 *
1671 * try to accomplish several tasks: 1684 * try to accomplish several tasks:
1672 * - insert new fragment into the proper sequence slot (once that's done
1673 * newfrag will be set to NULL)
1674 * - reassemble any complete fragment sequence (non-null 'start' 1685 * - reassemble any complete fragment sequence (non-null 'start'
1675 * indicates there is a continguous sequence present) 1686 * indicates there is a continguous sequence present)
1676 * - discard any incomplete sequences that are below minseq -- due 1687 * - discard any incomplete sequences that are below minseq -- due
@@ -1679,71 +1690,46 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1679 * come to complete such sequence and it should be discarded 1690 * come to complete such sequence and it should be discarded
1680 * 1691 *
1681 * loop completes when we accomplished the following tasks: 1692 * loop completes when we accomplished the following tasks:
1682 * - new fragment is inserted in the proper sequence ('newfrag' is
1683 * set to NULL)
1684 * - we hit a gap in the sequence, so no reassembly/processing is 1693 * - we hit a gap in the sequence, so no reassembly/processing is
1685 * possible ('start' would be set to NULL) 1694 * possible ('start' would be set to NULL)
1686 * 1695 *
1687 * algorithm for this code is derived from code in the book 1696 * algorithm for this code is derived from code in the book
1688 * 'PPP Design And Debugging' by James Carlson (Addison-Wesley) 1697 * 'PPP Design And Debugging' by James Carlson (Addison-Wesley)
1689 */ 1698 */
1690 while (start != NULL || newfrag != NULL) { 1699 skb_queue_walk_safe(&mp->frags, frag, nextf) {
1691 1700 thisseq = MP_SEQ(frag);
1692 thisseq = MP_SEQ(frag); 1701
1693 nextf = frag->next; 1702 /* check for misplaced start */
1694 1703 if (start != frag && (MP_FLAGS(frag) & MP_BEGIN_FRAG)) {
1695 /* drop any duplicate fragments */ 1704 printk(KERN_WARNING"isdn_mppp(seq %d): new "
1696 if (newfrag != NULL && thisseq == newseq) { 1705 "BEGIN flag with no prior END", thisseq);
1697 isdn_ppp_mp_free_skb(mp, newfrag); 1706 stats->seqerrs++;
1698 newfrag = NULL; 1707 stats->frame_drops++;
1699 } 1708 isdn_ppp_mp_discard(mp, start, frag);
1700 1709 start = frag;
1701 /* insert new fragment before next element if possible. */ 1710 } else if (MP_LE(thisseq, minseq)) {
1702 if (newfrag != NULL && (nextf == NULL || 1711 if (MP_FLAGS(frag) & MP_BEGIN_FRAG)
1703 MP_LT(newseq, MP_SEQ(nextf)))) {
1704 newfrag->next = nextf;
1705 frag->next = nextf = newfrag;
1706 newfrag = NULL;
1707 }
1708
1709 if (start != NULL) {
1710 /* check for misplaced start */
1711 if (start != frag && (MP_FLAGS(frag) & MP_BEGIN_FRAG)) {
1712 printk(KERN_WARNING"isdn_mppp(seq %d): new "
1713 "BEGIN flag with no prior END", thisseq);
1714 stats->seqerrs++;
1715 stats->frame_drops++;
1716 start = isdn_ppp_mp_discard(mp, start,frag);
1717 nextf = frag->next;
1718 }
1719 } else if (MP_LE(thisseq, minseq)) {
1720 if (MP_FLAGS(frag) & MP_BEGIN_FRAG)
1721 start = frag; 1712 start = frag;
1722 else { 1713 else {
1723 if (MP_FLAGS(frag) & MP_END_FRAG) 1714 if (MP_FLAGS(frag) & MP_END_FRAG)
1724 stats->frame_drops++; 1715 stats->frame_drops++;
1725 if( mp->frags == frag ) 1716 __skb_unlink(skb, &mp->frags);
1726 mp->frags = nextf;
1727 isdn_ppp_mp_free_skb(mp, frag); 1717 isdn_ppp_mp_free_skb(mp, frag);
1728 frag = nextf;
1729 continue; 1718 continue;
1730 } 1719 }
1731 } 1720 }
1732 1721
1733 /* if start is non-null and we have end fragment, then 1722 /* if we have end fragment, then we have full reassembly
1734 * we have full reassembly sequence -- reassemble 1723 * sequence -- reassemble and process packet now
1735 * and process packet now
1736 */ 1724 */
1737 if (start != NULL && (MP_FLAGS(frag) & MP_END_FRAG)) { 1725 if (MP_FLAGS(frag) & MP_END_FRAG) {
1738 minseq = mp->seq = (thisseq+1) & MP_LONGSEQ_MASK; 1726 minseq = mp->seq = (thisseq+1) & MP_LONGSEQ_MASK;
1739 /* Reassemble the packet then dispatch it */ 1727 /* Reassemble the packet then dispatch it */
1740 isdn_ppp_mp_reassembly(net_dev, lp, start, nextf); 1728 isdn_ppp_mp_reassembly(net_dev, lp, start, frag, thisseq);
1741
1742 start = NULL;
1743 frag = NULL;
1744 1729
1745 mp->frags = nextf; 1730 start = NULL;
1746 } 1731 frag = NULL;
1732 }
1747 1733
1748 /* check if need to update start pointer: if we just 1734 /* check if need to update start pointer: if we just
1749 * reassembled the packet and sequence is contiguous 1735 * reassembled the packet and sequence is contiguous
@@ -1754,26 +1740,25 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1754 * below low watermark and set start to the next frag or 1740 * below low watermark and set start to the next frag or
1755 * clear start ptr. 1741 * clear start ptr.
1756 */ 1742 */
1757 if (nextf != NULL && 1743 if (nextf != (struct sk_buff *)&mp->frags &&
1758 ((thisseq+1) & MP_LONGSEQ_MASK) == MP_SEQ(nextf)) { 1744 ((thisseq+1) & MP_LONGSEQ_MASK) == MP_SEQ(nextf)) {
1759 /* if we just reassembled and the next one is here, 1745 /* if we just reassembled and the next one is here,
1760 * then start another reassembly. */ 1746 * then start another reassembly.
1761 1747 */
1762 if (frag == NULL) { 1748 if (frag == NULL) {
1763 if (MP_FLAGS(nextf) & MP_BEGIN_FRAG) 1749 if (MP_FLAGS(nextf) & MP_BEGIN_FRAG)
1764 start = nextf; 1750 start = nextf;
1765 else 1751 else {
1766 { 1752 printk(KERN_WARNING"isdn_mppp(seq %d):"
1767 printk(KERN_WARNING"isdn_mppp(seq %d):" 1753 " END flag with no following "
1768 " END flag with no following " 1754 "BEGIN", thisseq);
1769 "BEGIN", thisseq);
1770 stats->seqerrs++; 1755 stats->seqerrs++;
1771 } 1756 }
1772 } 1757 }
1773 1758 } else {
1774 } else { 1759 if (nextf != (struct sk_buff *)&mp->frags &&
1775 if ( nextf != NULL && frag != NULL && 1760 frag != NULL &&
1776 MP_LT(thisseq, minseq)) { 1761 MP_LT(thisseq, minseq)) {
1777 /* we've got a break in the sequence 1762 /* we've got a break in the sequence
1778 * and we not at the end yet 1763 * and we not at the end yet
1779 * and we did not just reassembled 1764 * and we did not just reassembled
@@ -1782,41 +1767,39 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1782 * discard all the frames below low watermark 1767 * discard all the frames below low watermark
1783 * and start over */ 1768 * and start over */
1784 stats->frame_drops++; 1769 stats->frame_drops++;
1785 mp->frags = isdn_ppp_mp_discard(mp,start,nextf); 1770 isdn_ppp_mp_discard(mp, start, nextf);
1786 } 1771 }
1787 /* break in the sequence, no reassembly */ 1772 /* break in the sequence, no reassembly */
1788 start = NULL; 1773 start = NULL;
1789 } 1774 }
1790 1775 if (!start)
1791 frag = nextf; 1776 break;
1792 } /* while -- main loop */ 1777 }
1793 1778
1794 if (mp->frags == NULL) 1779check_overflow:
1795 mp->frags = frag;
1796
1797 /* rather straighforward way to deal with (not very) possible 1780 /* rather straighforward way to deal with (not very) possible
1798 * queue overflow */ 1781 * queue overflow
1782 */
1799 if (mp->frames > MP_MAX_QUEUE_LEN) { 1783 if (mp->frames > MP_MAX_QUEUE_LEN) {
1800 stats->overflows++; 1784 stats->overflows++;
1801 while (mp->frames > MP_MAX_QUEUE_LEN) { 1785 skb_queue_walk_safe(&mp->frags, frag, nextf) {
1802 frag = mp->frags->next; 1786 if (mp->frames <= MP_MAX_QUEUE_LEN)
1803 isdn_ppp_mp_free_skb(mp, mp->frags); 1787 break;
1804 mp->frags = frag; 1788 __skb_unlink(frag, &mp->frags);
1789 isdn_ppp_mp_free_skb(mp, frag);
1805 } 1790 }
1806 } 1791 }
1807 spin_unlock_irqrestore(&mp->lock, flags); 1792 spin_unlock_irqrestore(&mp->lock, flags);
1808} 1793}
1809 1794
1810static void isdn_ppp_mp_cleanup( isdn_net_local * lp ) 1795static void isdn_ppp_mp_cleanup(isdn_net_local *lp)
1811{ 1796{
1812 struct sk_buff * frag = lp->netdev->pb->frags; 1797 struct sk_buff *skb, *tmp;
1813 struct sk_buff * nextfrag; 1798
1814 while( frag ) { 1799 skb_queue_walk_safe(&lp->netdev->pb->frags, skb, tmp) {
1815 nextfrag = frag->next; 1800 __skb_unlink(skb, &lp->netdev->pb->frags);
1816 isdn_ppp_mp_free_skb(lp->netdev->pb, frag); 1801 isdn_ppp_mp_free_skb(lp->netdev->pb, skb);
1817 frag = nextfrag; 1802 }
1818 }
1819 lp->netdev->pb->frags = NULL;
1820} 1803}
1821 1804
1822static u32 isdn_ppp_mp_get_seq( int short_seq, 1805static u32 isdn_ppp_mp_get_seq( int short_seq,
@@ -1853,72 +1836,115 @@ static u32 isdn_ppp_mp_get_seq( int short_seq,
1853 return seq; 1836 return seq;
1854} 1837}
1855 1838
1856struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp, 1839static void isdn_ppp_mp_discard(ippp_bundle *mp, struct sk_buff *from,
1857 struct sk_buff * from, struct sk_buff * to ) 1840 struct sk_buff *to)
1858{ 1841{
1859 if( from ) 1842 if (from) {
1860 while (from != to) { 1843 struct sk_buff *skb, *tmp;
1861 struct sk_buff * next = from->next; 1844 int freeing = 0;
1862 isdn_ppp_mp_free_skb(mp, from); 1845
1863 from = next; 1846 skb_queue_walk_safe(&mp->frags, skb, tmp) {
1847 if (skb == to)
1848 break;
1849 if (skb == from)
1850 freeing = 1;
1851 if (!freeing)
1852 continue;
1853 __skb_unlink(skb, &mp->frags);
1854 isdn_ppp_mp_free_skb(mp, skb);
1864 } 1855 }
1865 return from; 1856 }
1866} 1857}
1867 1858
1868void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp, 1859static unsigned int calc_tot_len(struct sk_buff_head *queue,
1869 struct sk_buff * from, struct sk_buff * to ) 1860 struct sk_buff *from, struct sk_buff *to)
1870{ 1861{
1871 ippp_bundle * mp = net_dev->pb; 1862 unsigned int tot_len = 0;
1872 int proto; 1863 struct sk_buff *skb;
1873 struct sk_buff * skb; 1864 int found_start = 0;
1865
1866 skb_queue_walk(queue, skb) {
1867 if (skb == from)
1868 found_start = 1;
1869 if (!found_start)
1870 continue;
1871 tot_len += skb->len - MP_HEADER_LEN;
1872 if (skb == to)
1873 break;
1874 }
1875 return tot_len;
1876}
1877
1878/* Reassemble packet using fragments in the reassembly queue from
1879 * 'from' until 'to', inclusive.
1880 */
1881static void isdn_ppp_mp_reassembly(isdn_net_dev *net_dev, isdn_net_local *lp,
1882 struct sk_buff *from, struct sk_buff *to,
1883 u32 lastseq)
1884{
1885 ippp_bundle *mp = net_dev->pb;
1874 unsigned int tot_len; 1886 unsigned int tot_len;
1887 struct sk_buff *skb;
1888 int proto;
1875 1889
1876 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { 1890 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
1877 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", 1891 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n",
1878 __func__, lp->ppp_slot); 1892 __func__, lp->ppp_slot);
1879 return; 1893 return;
1880 } 1894 }
1881 if( MP_FLAGS(from) == (MP_BEGIN_FRAG | MP_END_FRAG) ) { 1895
1882 if( ippp_table[lp->ppp_slot]->debug & 0x40 ) 1896 tot_len = calc_tot_len(&mp->frags, from, to);
1897
1898 if (MP_FLAGS(from) == (MP_BEGIN_FRAG | MP_END_FRAG)) {
1899 if (ippp_table[lp->ppp_slot]->debug & 0x40)
1883 printk(KERN_DEBUG "isdn_mppp: reassembly: frame %d, " 1900 printk(KERN_DEBUG "isdn_mppp: reassembly: frame %d, "
1884 "len %d\n", MP_SEQ(from), from->len ); 1901 "len %d\n", MP_SEQ(from), from->len);
1885 skb = from; 1902 skb = from;
1886 skb_pull(skb, MP_HEADER_LEN); 1903 skb_pull(skb, MP_HEADER_LEN);
1904 __skb_unlink(skb, &mp->frags);
1887 mp->frames--; 1905 mp->frames--;
1888 } else { 1906 } else {
1889 struct sk_buff * frag; 1907 struct sk_buff *walk, *tmp;
1890 int n; 1908 int found_start = 0;
1891 1909
1892 for(tot_len=n=0, frag=from; frag != to; frag=frag->next, n++) 1910 if (ippp_table[lp->ppp_slot]->debug & 0x40)
1893 tot_len += frag->len - MP_HEADER_LEN;
1894
1895 if( ippp_table[lp->ppp_slot]->debug & 0x40 )
1896 printk(KERN_DEBUG"isdn_mppp: reassembling frames %d " 1911 printk(KERN_DEBUG"isdn_mppp: reassembling frames %d "
1897 "to %d, len %d\n", MP_SEQ(from), 1912 "to %d, len %d\n", MP_SEQ(from), lastseq,
1898 (MP_SEQ(from)+n-1) & MP_LONGSEQ_MASK, tot_len ); 1913 tot_len);
1899 if( (skb = dev_alloc_skb(tot_len)) == NULL ) { 1914
1915 skb = dev_alloc_skb(tot_len);
1916 if (!skb)
1900 printk(KERN_ERR "isdn_mppp: cannot allocate sk buff " 1917 printk(KERN_ERR "isdn_mppp: cannot allocate sk buff "
1901 "of size %d\n", tot_len); 1918 "of size %d\n", tot_len);
1902 isdn_ppp_mp_discard(mp, from, to); 1919
1903 return; 1920 found_start = 0;
1904 } 1921 skb_queue_walk_safe(&mp->frags, walk, tmp) {
1922 if (walk == from)
1923 found_start = 1;
1924 if (!found_start)
1925 continue;
1905 1926
1906 while( from != to ) { 1927 if (skb) {
1907 unsigned int len = from->len - MP_HEADER_LEN; 1928 unsigned int len = walk->len - MP_HEADER_LEN;
1929 skb_copy_from_linear_data_offset(walk, MP_HEADER_LEN,
1930 skb_put(skb, len),
1931 len);
1932 }
1933 __skb_unlink(walk, &mp->frags);
1934 isdn_ppp_mp_free_skb(mp, walk);
1908 1935
1909 skb_copy_from_linear_data_offset(from, MP_HEADER_LEN, 1936 if (walk == to)
1910 skb_put(skb,len), 1937 break;
1911 len);
1912 frag = from->next;
1913 isdn_ppp_mp_free_skb(mp, from);
1914 from = frag;
1915 } 1938 }
1916 } 1939 }
1940 if (!skb)
1941 return;
1942
1917 proto = isdn_ppp_strip_proto(skb); 1943 proto = isdn_ppp_strip_proto(skb);
1918 isdn_ppp_push_higher(net_dev, lp, skb, proto); 1944 isdn_ppp_push_higher(net_dev, lp, skb, proto);
1919} 1945}
1920 1946
1921static void isdn_ppp_mp_free_skb(ippp_bundle * mp, struct sk_buff * skb) 1947static void isdn_ppp_mp_free_skb(ippp_bundle *mp, struct sk_buff *skb)
1922{ 1948{
1923 dev_kfree_skb(skb); 1949 dev_kfree_skb(skb);
1924 mp->frames--; 1950 mp->frames--;
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 155b99780c4f..e42150a57780 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -1006,8 +1006,7 @@ open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq)
1006 struct bchannel *bch; 1006 struct bchannel *bch;
1007 int ch; 1007 int ch;
1008 1008
1009 if (!test_bit(rq->adr.channel & 0x1f, 1009 if (!test_channelmap(rq->adr.channel, dch->dev.channelmap))
1010 &dch->dev.channelmap[rq->adr.channel >> 5]))
1011 return -EINVAL; 1010 return -EINVAL;
1012 if (rq->protocol == ISDN_P_NONE) 1011 if (rq->protocol == ISDN_P_NONE)
1013 return -EINVAL; 1012 return -EINVAL;
@@ -1412,8 +1411,7 @@ init_card(struct l1oip *hc, int pri, int bundle)
1412 bch->ch.nr = i + ch; 1411 bch->ch.nr = i + ch;
1413 list_add(&bch->ch.list, &dch->dev.bchannels); 1412 list_add(&bch->ch.list, &dch->dev.bchannels);
1414 hc->chan[i + ch].bch = bch; 1413 hc->chan[i + ch].bch = bch;
1415 test_and_set_bit(bch->nr & 0x1f, 1414 set_channelmap(bch->nr, dch->dev.channelmap);
1416 &dch->dev.channelmap[bch->nr >> 5]);
1417 } 1415 }
1418 ret = mISDN_register_device(&dch->dev, hc->name); 1416 ret = mISDN_register_device(&dch->dev, hc->name);
1419 if (ret) 1417 if (ret)
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 4ba4cc364c9e..e5a20f9542d1 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -379,7 +379,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
379 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols(); 379 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
380 di.protocol = dev->D.protocol; 380 di.protocol = dev->D.protocol;
381 memcpy(di.channelmap, dev->channelmap, 381 memcpy(di.channelmap, dev->channelmap,
382 MISDN_CHMAP_SIZE * 4); 382 sizeof(di.channelmap));
383 di.nrbchan = dev->nrbchan; 383 di.nrbchan = dev->nrbchan;
384 strcpy(di.name, dev->name); 384 strcpy(di.name, dev->name);
385 if (copy_to_user((void __user *)arg, &di, sizeof(di))) 385 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
@@ -637,7 +637,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
637 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols(); 637 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
638 di.protocol = dev->D.protocol; 638 di.protocol = dev->D.protocol;
639 memcpy(di.channelmap, dev->channelmap, 639 memcpy(di.channelmap, dev->channelmap,
640 MISDN_CHMAP_SIZE * 4); 640 sizeof(di.channelmap));
641 di.nrbchan = dev->nrbchan; 641 di.nrbchan = dev->nrbchan;
642 strcpy(di.name, dev->name); 642 strcpy(di.name, dev->name);
643 if (copy_to_user((void __user *)arg, &di, sizeof(di))) 643 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index b5fabc7019d8..e7462924b505 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -124,18 +124,6 @@ mISDN_read(struct file *filep, char *buf, size_t count, loff_t *off)
124 return ret; 124 return ret;
125} 125}
126 126
127static loff_t
128mISDN_llseek(struct file *filep, loff_t offset, int orig)
129{
130 return -ESPIPE;
131}
132
133static ssize_t
134mISDN_write(struct file *filep, const char *buf, size_t count, loff_t *off)
135{
136 return -EOPNOTSUPP;
137}
138
139static unsigned int 127static unsigned int
140mISDN_poll(struct file *filep, poll_table *wait) 128mISDN_poll(struct file *filep, poll_table *wait)
141{ 129{
@@ -157,8 +145,9 @@ mISDN_poll(struct file *filep, poll_table *wait)
157} 145}
158 146
159static void 147static void
160dev_expire_timer(struct mISDNtimer *timer) 148dev_expire_timer(unsigned long data)
161{ 149{
150 struct mISDNtimer *timer = (void *)data;
162 u_long flags; 151 u_long flags;
163 152
164 spin_lock_irqsave(&timer->dev->lock, flags); 153 spin_lock_irqsave(&timer->dev->lock, flags);
@@ -191,7 +180,7 @@ misdn_add_timer(struct mISDNtimerdev *dev, int timeout)
191 spin_unlock_irqrestore(&dev->lock, flags); 180 spin_unlock_irqrestore(&dev->lock, flags);
192 timer->dev = dev; 181 timer->dev = dev;
193 timer->tl.data = (long)timer; 182 timer->tl.data = (long)timer;
194 timer->tl.function = (void *) dev_expire_timer; 183 timer->tl.function = dev_expire_timer;
195 init_timer(&timer->tl); 184 init_timer(&timer->tl);
196 timer->tl.expires = jiffies + ((HZ * (u_long)timeout) / 1000); 185 timer->tl.expires = jiffies + ((HZ * (u_long)timeout) / 1000);
197 add_timer(&timer->tl); 186 add_timer(&timer->tl);
@@ -211,6 +200,9 @@ misdn_del_timer(struct mISDNtimerdev *dev, int id)
211 list_for_each_entry(timer, &dev->pending, list) { 200 list_for_each_entry(timer, &dev->pending, list) {
212 if (timer->id == id) { 201 if (timer->id == id) {
213 list_del_init(&timer->list); 202 list_del_init(&timer->list);
203 /* RED-PEN AK: race -- timer can be still running on
204 * other CPU. Needs reference count I think
205 */
214 del_timer(&timer->tl); 206 del_timer(&timer->tl);
215 ret = timer->id; 207 ret = timer->id;
216 kfree(timer); 208 kfree(timer);
@@ -268,9 +260,7 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
268} 260}
269 261
270static struct file_operations mISDN_fops = { 262static struct file_operations mISDN_fops = {
271 .llseek = mISDN_llseek,
272 .read = mISDN_read, 263 .read = mISDN_read,
273 .write = mISDN_write,
274 .poll = mISDN_poll, 264 .poll = mISDN_poll,
275 .ioctl = mISDN_ioctl, 265 .ioctl = mISDN_ioctl,
276 .open = mISDN_open, 266 .open = mISDN_open,