aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/i386/Kconfig8
-rw-r--r--arch/i386/mm/fault.c5
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c2
-rw-r--r--arch/s390/hypfs/inode.c33
-rw-r--r--arch/s390/kernel/Makefile2
-rw-r--r--arch/s390/kernel/diag.c102
-rw-r--r--arch/s390/kernel/dis.c2
-rw-r--r--arch/s390/kernel/kprobes.c2
-rw-r--r--arch/s390/kernel/s390_ksyms.c1
-rw-r--r--arch/s390/mm/cmm.c1
-rw-r--r--arch/s390/mm/init.c17
-rw-r--r--drivers/isdn/hisax/hfc_usb.c603
-rw-r--r--drivers/isdn/hisax/hfc_usb.h130
-rw-r--r--drivers/net/ppp_generic.c2
-rw-r--r--drivers/net/sky2.c4
-rw-r--r--drivers/s390/block/dasd_diag.c1
-rw-r--r--drivers/s390/char/raw3270.c1
-rw-r--r--drivers/s390/char/vmur.c250
-rw-r--r--drivers/s390/char/vmur.h1
-rw-r--r--drivers/s390/cio/cmf.c10
-rw-r--r--drivers/s390/cio/device.c5
-rw-r--r--drivers/s390/cio/device_id.c48
-rw-r--r--drivers/s390/cio/qdio.c5
-rw-r--r--drivers/usb/host/ehci-hcd.c67
-rw-r--r--drivers/usb/host/ehci-mem.c3
-rw-r--r--drivers/usb/host/ehci-q.c4
-rw-r--r--drivers/usb/host/ehci-sched.c127
-rw-r--r--drivers/usb/host/ehci.h14
-rw-r--r--include/asm-s390/atomic.h26
-rw-r--r--include/asm-s390/cio.h15
-rw-r--r--include/asm-s390/diag.h39
-rw-r--r--include/asm-s390/pgalloc.h2
-rw-r--r--include/linux/pci_ids.h6
-rw-r--r--kernel/printk.c10
-rw-r--r--net/802/psnap.c17
-rw-r--r--net/dccp/ccids/ccid2.c2
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/irda/irmod.c2
-rw-r--r--net/irda/irnetlink.c2
39 files changed, 699 insertions, 874 deletions
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index f16a46e8849c..97b64d7d6bf6 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -614,10 +614,14 @@ config X86_PAE
614 614
615# Common NUMA Features 615# Common NUMA Features
616config NUMA 616config NUMA
617 bool "Numa Memory Allocation and Scheduler Support" 617 bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)"
618 depends on SMP && HIGHMEM64G && (X86_NUMAQ || (X86_SUMMIT || X86_GENERICARCH) && ACPI) 618 depends on SMP && HIGHMEM64G && (X86_NUMAQ || (X86_SUMMIT || X86_GENERICARCH) && ACPI) && EXPERIMENTAL
619 default n if X86_PC 619 default n if X86_PC
620 default y if (X86_NUMAQ || X86_SUMMIT) 620 default y if (X86_NUMAQ || X86_SUMMIT)
621 help
622 NUMA support for i386. This is currently high experimental
623 and should be only used for kernel development. It might also
624 cause boot failures.
621 625
622comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI" 626comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
623 depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI) 627 depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI)
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c
index 01ffdd4964f0..fcb38e7f3543 100644
--- a/arch/i386/mm/fault.c
+++ b/arch/i386/mm/fault.c
@@ -249,9 +249,10 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
249 pmd_k = pmd_offset(pud_k, address); 249 pmd_k = pmd_offset(pud_k, address);
250 if (!pmd_present(*pmd_k)) 250 if (!pmd_present(*pmd_k))
251 return NULL; 251 return NULL;
252 if (!pmd_present(*pmd)) 252 if (!pmd_present(*pmd)) {
253 set_pmd(pmd, *pmd_k); 253 set_pmd(pmd, *pmd_k);
254 else 254 arch_flush_lazy_mmu_mode();
255 } else
255 BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k)); 256 BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k));
256 return pmd_k; 257 return pmd_k;
257} 258}
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 9fb0ce5c7176..114c90f8f560 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -251,6 +251,8 @@ DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8568E, quirk_fsl_pcie_transpare
251DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8568, quirk_fsl_pcie_transparent); 251DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8568, quirk_fsl_pcie_transparent);
252DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8567E, quirk_fsl_pcie_transparent); 252DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8567E, quirk_fsl_pcie_transparent);
253DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8567, quirk_fsl_pcie_transparent); 253DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8567, quirk_fsl_pcie_transparent);
254DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8533E, quirk_fsl_pcie_transparent);
255DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8533, quirk_fsl_pcie_transparent);
254DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8544E, quirk_fsl_pcie_transparent); 256DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8544E, quirk_fsl_pcie_transparent);
255DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8544, quirk_fsl_pcie_transparent); 257DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8544, quirk_fsl_pcie_transparent);
256DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8641, quirk_fsl_pcie_transparent); 258DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8641, quirk_fsl_pcie_transparent);
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index ad4ca75c0f04..5245717295b8 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -60,17 +60,28 @@ static void hypfs_add_dentry(struct dentry *dentry)
60 hypfs_last_dentry = dentry; 60 hypfs_last_dentry = dentry;
61} 61}
62 62
63static inline int hypfs_positive(struct dentry *dentry)
64{
65 return dentry->d_inode && !d_unhashed(dentry);
66}
67
63static void hypfs_remove(struct dentry *dentry) 68static void hypfs_remove(struct dentry *dentry)
64{ 69{
65 struct dentry *parent; 70 struct dentry *parent;
66 71
67 parent = dentry->d_parent; 72 parent = dentry->d_parent;
68 if (S_ISDIR(dentry->d_inode->i_mode)) 73 if (!parent || !parent->d_inode)
69 simple_rmdir(parent->d_inode, dentry); 74 return;
70 else 75 mutex_lock(&parent->d_inode->i_mutex);
71 simple_unlink(parent->d_inode, dentry); 76 if (hypfs_positive(dentry)) {
77 if (S_ISDIR(dentry->d_inode->i_mode))
78 simple_rmdir(parent->d_inode, dentry);
79 else
80 simple_unlink(parent->d_inode, dentry);
81 }
72 d_delete(dentry); 82 d_delete(dentry);
73 dput(dentry); 83 dput(dentry);
84 mutex_unlock(&parent->d_inode->i_mutex);
74} 85}
75 86
76static void hypfs_delete_tree(struct dentry *root) 87static void hypfs_delete_tree(struct dentry *root)
@@ -315,6 +326,7 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent)
315 } 326 }
316 hypfs_update_update(sb); 327 hypfs_update_update(sb);
317 sb->s_root = root_dentry; 328 sb->s_root = root_dentry;
329 printk(KERN_INFO "hypfs: Hypervisor filesystem mounted\n");
318 return 0; 330 return 0;
319 331
320err_tree: 332err_tree:
@@ -356,13 +368,17 @@ static struct dentry *hypfs_create_file(struct super_block *sb,
356 qname.name = name; 368 qname.name = name;
357 qname.len = strlen(name); 369 qname.len = strlen(name);
358 qname.hash = full_name_hash(name, qname.len); 370 qname.hash = full_name_hash(name, qname.len);
371 mutex_lock(&parent->d_inode->i_mutex);
359 dentry = lookup_one_len(name, parent, strlen(name)); 372 dentry = lookup_one_len(name, parent, strlen(name));
360 if (IS_ERR(dentry)) 373 if (IS_ERR(dentry)) {
361 return ERR_PTR(-ENOMEM); 374 dentry = ERR_PTR(-ENOMEM);
375 goto fail;
376 }
362 inode = hypfs_make_inode(sb, mode); 377 inode = hypfs_make_inode(sb, mode);
363 if (!inode) { 378 if (!inode) {
364 dput(dentry); 379 dput(dentry);
365 return ERR_PTR(-ENOMEM); 380 dentry = ERR_PTR(-ENOMEM);
381 goto fail;
366 } 382 }
367 if (mode & S_IFREG) { 383 if (mode & S_IFREG) {
368 inode->i_fop = &hypfs_file_ops; 384 inode->i_fop = &hypfs_file_ops;
@@ -379,6 +395,8 @@ static struct dentry *hypfs_create_file(struct super_block *sb,
379 inode->i_private = data; 395 inode->i_private = data;
380 d_instantiate(dentry, inode); 396 d_instantiate(dentry, inode);
381 dget(dentry); 397 dget(dentry);
398fail:
399 mutex_unlock(&parent->d_inode->i_mutex);
382 return dentry; 400 return dentry;
383} 401}
384 402
@@ -391,7 +409,6 @@ struct dentry *hypfs_mkdir(struct super_block *sb, struct dentry *parent,
391 if (IS_ERR(dentry)) 409 if (IS_ERR(dentry))
392 return dentry; 410 return dentry;
393 hypfs_add_dentry(dentry); 411 hypfs_add_dentry(dentry);
394 parent->d_inode->i_nlink++;
395 return dentry; 412 return dentry;
396} 413}
397 414
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 3195d375bd51..56cb71007cd9 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -6,7 +6,7 @@ EXTRA_AFLAGS := -traditional
6 6
7obj-y := bitmap.o traps.o time.o process.o base.o early.o \ 7obj-y := bitmap.o traps.o time.o process.o base.o early.o \
8 setup.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \ 8 setup.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \
9 semaphore.o s390_ext.o debug.o irq.o ipl.o dis.o 9 semaphore.o s390_ext.o debug.o irq.o ipl.o dis.o diag.o
10 10
11obj-y += $(if $(CONFIG_64BIT),entry64.o,entry.o) 11obj-y += $(if $(CONFIG_64BIT),entry64.o,entry.o)
12obj-y += $(if $(CONFIG_64BIT),reipl64.o,reipl.o) 12obj-y += $(if $(CONFIG_64BIT),reipl64.o,reipl.o)
diff --git a/arch/s390/kernel/diag.c b/arch/s390/kernel/diag.c
new file mode 100644
index 000000000000..c032d11da8a1
--- /dev/null
+++ b/arch/s390/kernel/diag.c
@@ -0,0 +1,102 @@
1/*
2 * Implementation of s390 diagnose codes
3 *
4 * Copyright IBM Corp. 2007
5 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
6 */
7
8#include <linux/module.h>
9#include <asm/diag.h>
10
11/*
12 * Diagnose 10: Release pages
13 */
14void diag10(unsigned long addr)
15{
16 if (addr >= 0x7ff00000)
17 return;
18 asm volatile(
19#ifdef CONFIG_64BIT
20 " sam31\n"
21 " diag %0,%0,0x10\n"
22 "0: sam64\n"
23#else
24 " diag %0,%0,0x10\n"
25 "0:\n"
26#endif
27 EX_TABLE(0b, 0b)
28 : : "a" (addr));
29}
30EXPORT_SYMBOL(diag10);
31
32/*
33 * Diagnose 14: Input spool file manipulation
34 */
35int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode)
36{
37 register unsigned long _ry1 asm("2") = ry1;
38 register unsigned long _ry2 asm("3") = subcode;
39 int rc = 0;
40
41 asm volatile(
42#ifdef CONFIG_64BIT
43 " sam31\n"
44 " diag %2,2,0x14\n"
45 " sam64\n"
46#else
47 " diag %2,2,0x14\n"
48#endif
49 " ipm %0\n"
50 " srl %0,28\n"
51 : "=d" (rc), "+d" (_ry2)
52 : "d" (rx), "d" (_ry1)
53 : "cc");
54
55 return rc;
56}
57EXPORT_SYMBOL(diag14);
58
59/*
60 * Diagnose 210: Get information about a virtual device
61 */
62int diag210(struct diag210 *addr)
63{
64 /*
65 * diag 210 needs its data below the 2GB border, so we
66 * use a static data area to be sure
67 */
68 static struct diag210 diag210_tmp;
69 static DEFINE_SPINLOCK(diag210_lock);
70 unsigned long flags;
71 int ccode;
72
73 spin_lock_irqsave(&diag210_lock, flags);
74 diag210_tmp = *addr;
75
76#ifdef CONFIG_64BIT
77 asm volatile(
78 " lhi %0,-1\n"
79 " sam31\n"
80 " diag %1,0,0x210\n"
81 "0: ipm %0\n"
82 " srl %0,28\n"
83 "1: sam64\n"
84 EX_TABLE(0b, 1b)
85 : "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
86#else
87 asm volatile(
88 " lhi %0,-1\n"
89 " diag %1,0,0x210\n"
90 "0: ipm %0\n"
91 " srl %0,28\n"
92 "1:\n"
93 EX_TABLE(0b, 1b)
94 : "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
95#endif
96
97 *addr = diag210_tmp;
98 spin_unlock_irqrestore(&diag210_lock, flags);
99
100 return ccode;
101}
102EXPORT_SYMBOL(diag210);
diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
index d3057318f2bf..50d2235df732 100644
--- a/arch/s390/kernel/dis.c
+++ b/arch/s390/kernel/dis.c
@@ -577,7 +577,7 @@ static struct insn opcode_b2[] = {
577 { "esta", 0x4a, INSTR_RRE_RR }, 577 { "esta", 0x4a, INSTR_RRE_RR },
578 { "lura", 0x4b, INSTR_RRE_RR }, 578 { "lura", 0x4b, INSTR_RRE_RR },
579 { "tar", 0x4c, INSTR_RRE_AR }, 579 { "tar", 0x4c, INSTR_RRE_AR },
580 { "cpya", INSTR_RRE_AA }, 580 { "cpya", 0x4d, INSTR_RRE_AA },
581 { "sar", 0x4e, INSTR_RRE_AR }, 581 { "sar", 0x4e, INSTR_RRE_AR },
582 { "ear", 0x4f, INSTR_RRE_RA }, 582 { "ear", 0x4f, INSTR_RRE_RA },
583 { "csp", 0x50, INSTR_RRE_RR }, 583 { "csp", 0x50, INSTR_RRE_RR },
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 358d2bbbc481..e40373d9fbce 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -85,7 +85,7 @@ void __kprobes get_instruction_type(struct arch_specific_insn *ainsn)
85 ainsn->reg = (*ainsn->insn & 0xf0) >> 4; 85 ainsn->reg = (*ainsn->insn & 0xf0) >> 4;
86 86
87 /* save the instruction length (pop 5-5) in bytes */ 87 /* save the instruction length (pop 5-5) in bytes */
88 switch (*(__u8 *) (ainsn->insn) >> 4) { 88 switch (*(__u8 *) (ainsn->insn) >> 6) {
89 case 0: 89 case 0:
90 ainsn->ilen = 2; 90 ainsn->ilen = 2;
91 break; 91 break;
diff --git a/arch/s390/kernel/s390_ksyms.c b/arch/s390/kernel/s390_ksyms.c
index 90b5ef529eb7..7234c737f825 100644
--- a/arch/s390/kernel/s390_ksyms.c
+++ b/arch/s390/kernel/s390_ksyms.c
@@ -25,7 +25,6 @@ EXPORT_SYMBOL(_oi_bitmap);
25EXPORT_SYMBOL(_ni_bitmap); 25EXPORT_SYMBOL(_ni_bitmap);
26EXPORT_SYMBOL(_zb_findmap); 26EXPORT_SYMBOL(_zb_findmap);
27EXPORT_SYMBOL(_sb_findmap); 27EXPORT_SYMBOL(_sb_findmap);
28EXPORT_SYMBOL(diag10);
29 28
30/* 29/*
31 * semaphore ops 30 * semaphore ops
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index c5b2f4f078bc..fabc50adc46a 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -20,6 +20,7 @@
20 20
21#include <asm/pgalloc.h> 21#include <asm/pgalloc.h>
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <asm/diag.h>
23 24
24static char *sender = "VMRMSVM"; 25static char *sender = "VMRMSVM";
25module_param(sender, charp, 0400); 26module_param(sender, charp, 0400);
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 9098531a2671..3a25bbf2eb0a 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -42,23 +42,6 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
42pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE))); 42pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
43char empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); 43char empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
44 44
45void diag10(unsigned long addr)
46{
47 if (addr >= 0x7ff00000)
48 return;
49 asm volatile(
50#ifdef CONFIG_64BIT
51 " sam31\n"
52 " diag %0,%0,0x10\n"
53 "0: sam64\n"
54#else
55 " diag %0,%0,0x10\n"
56 "0:\n"
57#endif
58 EX_TABLE(0b,0b)
59 : : "a" (addr));
60}
61
62void show_mem(void) 45void show_mem(void)
63{ 46{
64 int i, total = 0, reserved = 0; 47 int i, total = 0, reserved = 0;
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index b1a26e02df02..60843b3f3b6f 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -1,12 +1,12 @@
1/* 1/*
2 * hfc_usb.c 2 * hfc_usb.c
3 * 3 *
4 * $Id: hfc_usb.c,v 2.3.2.13 2006/02/17 17:17:22 mbachem Exp $ 4 * $Id: hfc_usb.c,v 2.3.2.20 2007/08/20 14:07:54 mbachem Exp $
5 * 5 *
6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip 6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip
7 * 7 *
8 * Authors : Peter Sprenger (sprenger@moving-bytes.de) 8 * Authors : Peter Sprenger (sprenger@moving-bytes.de)
9 * Martin Bachem (info@colognechip.com) 9 * Martin Bachem (m.bachem@gmx.de, info@colognechip.com)
10 * 10 *
11 * based on the first hfc_usb driver of 11 * based on the first hfc_usb driver of
12 * Werner Cornelius (werner@isdn-development.de) 12 * Werner Cornelius (werner@isdn-development.de)
@@ -37,24 +37,25 @@
37#include <linux/kernel_stat.h> 37#include <linux/kernel_stat.h>
38#include <linux/usb.h> 38#include <linux/usb.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/smp_lock.h>
41#include <linux/sched.h>
42#include <linux/moduleparam.h>
40#include "hisax.h" 43#include "hisax.h"
41#include "hisax_if.h" 44#include "hisax_if.h"
42#include "hfc_usb.h" 45#include "hfc_usb.h"
43 46
44static const char *hfcusb_revision = 47static const char *hfcusb_revision =
45 "$Revision: 2.3.2.13 $ $Date: 2006/02/17 17:17:22 $ "; 48 "$Revision: 2.3.2.20 $ $Date: 2007/08/20 14:07:54 $ ";
46 49
47/* Hisax debug support 50/* Hisax debug support
48* use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG 51* debug flags defined in hfc_usb.h as HFCUSB_DBG_[*]
49*/ 52*/
50#ifdef CONFIG_HISAX_DEBUG
51#include <linux/moduleparam.h>
52#define __debug_variable hfc_debug 53#define __debug_variable hfc_debug
53#include "hisax_debug.h" 54#include "hisax_debug.h"
54static u_int debug; 55static u_int debug;
55module_param(debug, uint, 0); 56module_param(debug, uint, 0);
56static int hfc_debug; 57static int hfc_debug;
57#endif 58
58 59
59/* private vendor specific data */ 60/* private vendor specific data */
60typedef struct { 61typedef struct {
@@ -63,9 +64,7 @@ typedef struct {
63 char *vend_name; // device name 64 char *vend_name; // device name
64} hfcsusb_vdata; 65} hfcsusb_vdata;
65 66
66/****************************************/ 67/* VID/PID device list */
67/* data defining the devices to be used */
68/****************************************/
69static struct usb_device_id hfcusb_idtab[] = { 68static struct usb_device_id hfcusb_idtab[] = {
70 { 69 {
71 USB_DEVICE(0x0959, 0x2bd0), 70 USB_DEVICE(0x0959, 0x2bd0),
@@ -90,49 +89,47 @@ static struct usb_device_id hfcusb_idtab[] = {
90 .driver_info = (unsigned long) &((hfcsusb_vdata) 89 .driver_info = (unsigned long) &((hfcsusb_vdata)
91 {LED_SCHEME1, {4, 0, 2, 1}, 90 {LED_SCHEME1, {4, 0, 2, 1},
92 "Stollmann USB TA"}), 91 "Stollmann USB TA"}),
93 }, 92 },
94 { 93 {
95 USB_DEVICE(0x0742, 0x2009), 94 USB_DEVICE(0x0742, 0x2009),
96 .driver_info = (unsigned long) &((hfcsusb_vdata) 95 .driver_info = (unsigned long) &((hfcsusb_vdata)
97 {LED_SCHEME1, {4, 0, 2, 1}, 96 {LED_SCHEME1, {4, 0, 2, 1},
98 "Aceex USB ISDN TA"}), 97 "Aceex USB ISDN TA"}),
99 }, 98 },
100 { 99 {
101 USB_DEVICE(0x0742, 0x200A), 100 USB_DEVICE(0x0742, 0x200A),
102 .driver_info = (unsigned long) &((hfcsusb_vdata) 101 .driver_info = (unsigned long) &((hfcsusb_vdata)
103 {LED_SCHEME1, {4, 0, 2, 1}, 102 {LED_SCHEME1, {4, 0, 2, 1},
104 "OEM USB ISDN TA"}), 103 "OEM USB ISDN TA"}),
105 }, 104 },
106 { 105 {
107 USB_DEVICE(0x08e3, 0x0301), 106 USB_DEVICE(0x08e3, 0x0301),
108 .driver_info = (unsigned long) &((hfcsusb_vdata) 107 .driver_info = (unsigned long) &((hfcsusb_vdata)
109 {LED_SCHEME1, {2, 0, 1, 4}, 108 {LED_SCHEME1, {2, 0, 1, 4},
110 "Olitec USB RNIS"}), 109 "Olitec USB RNIS"}),
111 }, 110 },
112 { 111 {
113 USB_DEVICE(0x07fa, 0x0846), 112 USB_DEVICE(0x07fa, 0x0846),
114 .driver_info = (unsigned long) &((hfcsusb_vdata) 113 .driver_info = (unsigned long) &((hfcsusb_vdata)
115 {LED_SCHEME1, {0x80, -64, -32, -16}, 114 {LED_SCHEME1, {0x80, -64, -32, -16},
116 "Bewan Modem RNIS USB"}), 115 "Bewan Modem RNIS USB"}),
117 }, 116 },
118 { 117 {
119 USB_DEVICE(0x07fa, 0x0847), 118 USB_DEVICE(0x07fa, 0x0847),
120 .driver_info = (unsigned long) &((hfcsusb_vdata) 119 .driver_info = (unsigned long) &((hfcsusb_vdata)
121 {LED_SCHEME1, {0x80, -64, -32, -16}, 120 {LED_SCHEME1, {0x80, -64, -32, -16},
122 "Djinn Numeris USB"}), 121 "Djinn Numeris USB"}),
123 }, 122 },
124 { 123 {
125 USB_DEVICE(0x07b0, 0x0006), 124 USB_DEVICE(0x07b0, 0x0006),
126 .driver_info = (unsigned long) &((hfcsusb_vdata) 125 .driver_info = (unsigned long) &((hfcsusb_vdata)
127 {LED_SCHEME1, {0x80, -64, -32, -16}, 126 {LED_SCHEME1, {0x80, -64, -32, -16},
128 "Twister ISDN TA"}), 127 "Twister ISDN TA"}),
129 }, 128 },
130 { } 129 { }
131}; 130};
132 131
133/***************************************************************/
134/* structure defining input+output fifos (interrupt/bulk mode) */ 132/* structure defining input+output fifos (interrupt/bulk mode) */
135/***************************************************************/
136struct usb_fifo; /* forward definition */ 133struct usb_fifo; /* forward definition */
137typedef struct iso_urb_struct { 134typedef struct iso_urb_struct {
138 struct urb *purb; 135 struct urb *purb;
@@ -140,8 +137,8 @@ typedef struct iso_urb_struct {
140 struct usb_fifo *owner_fifo; /* pointer to owner fifo */ 137 struct usb_fifo *owner_fifo; /* pointer to owner fifo */
141} iso_urb_struct; 138} iso_urb_struct;
142 139
143
144struct hfcusb_data; /* forward definition */ 140struct hfcusb_data; /* forward definition */
141
145typedef struct usb_fifo { 142typedef struct usb_fifo {
146 int fifonum; /* fifo index attached to this structure */ 143 int fifonum; /* fifo index attached to this structure */
147 int active; /* fifo is currently active */ 144 int active; /* fifo is currently active */
@@ -160,15 +157,12 @@ typedef struct usb_fifo {
160 struct hisax_if *hif; /* hisax interface */ 157 struct hisax_if *hif; /* hisax interface */
161 int delete_flg; /* only delete skbuff once */ 158 int delete_flg; /* only delete skbuff once */
162 int last_urblen; /* remember length of last packet */ 159 int last_urblen; /* remember length of last packet */
163
164} usb_fifo; 160} usb_fifo;
165 161
166/*********************************************/
167/* structure holding all data for one device */ 162/* structure holding all data for one device */
168/*********************************************/
169typedef struct hfcusb_data { 163typedef struct hfcusb_data {
170 /* HiSax Interface for loadable Layer1 drivers */ 164 /* HiSax Interface for loadable Layer1 drivers */
171 struct hisax_d_if d_if; /* see hisax_if.h */ 165 struct hisax_d_if d_if; /* see hisax_if.h */
172 struct hisax_b_if b_if[2]; /* see hisax_if.h */ 166 struct hisax_b_if b_if[2]; /* see hisax_if.h */
173 int protocol; 167 int protocol;
174 168
@@ -176,12 +170,13 @@ typedef struct hfcusb_data {
176 int if_used; /* used interface number */ 170 int if_used; /* used interface number */
177 int alt_used; /* used alternate config */ 171 int alt_used; /* used alternate config */
178 int ctrl_paksize; /* control pipe packet size */ 172 int ctrl_paksize; /* control pipe packet size */
179 int ctrl_in_pipe, ctrl_out_pipe; /* handles for control pipe */ 173 int ctrl_in_pipe, /* handles for control pipe */
174 ctrl_out_pipe;
180 int cfg_used; /* configuration index used */ 175 int cfg_used; /* configuration index used */
181 int vend_idx; /* vendor found */ 176 int vend_idx; /* vendor found */
182 int b_mode[2]; /* B-channel mode */ 177 int b_mode[2]; /* B-channel mode */
183 int l1_activated; /* layer 1 activated */ 178 int l1_activated; /* layer 1 activated */
184 int disc_flag; /* 'true' if device was disonnected to avoid some USB actions */ 179 int disc_flag; /* TRUE if device was disonnected to avoid some USB actions */
185 int packet_size, iso_packet_size; 180 int packet_size, iso_packet_size;
186 181
187 /* control pipe background handling */ 182 /* control pipe background handling */
@@ -208,7 +203,6 @@ typedef struct hfcusb_data {
208static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, 203static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len,
209 int finish); 204 int finish);
210 205
211
212static inline const char * 206static inline const char *
213symbolic(struct hfcusb_symbolic_list list[], const int num) 207symbolic(struct hfcusb_symbolic_list list[], const int num)
214{ 208{
@@ -219,10 +213,6 @@ symbolic(struct hfcusb_symbolic_list list[], const int num)
219 return "<unknown ERROR>"; 213 return "<unknown ERROR>";
220} 214}
221 215
222
223/******************************************************/
224/* start next background transfer for control channel */
225/******************************************************/
226static void 216static void
227ctrl_start_transfer(hfcusb_data * hfc) 217ctrl_start_transfer(hfcusb_data * hfc)
228{ 218{
@@ -240,10 +230,6 @@ ctrl_start_transfer(hfcusb_data * hfc)
240 } 230 }
241} /* ctrl_start_transfer */ 231} /* ctrl_start_transfer */
242 232
243/************************************/
244/* queue a control transfer request */
245/* return 0 on success. */
246/************************************/
247static int 233static int
248queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action) 234queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action)
249{ 235{
@@ -260,19 +246,8 @@ queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action)
260 if (++hfc->ctrl_cnt == 1) 246 if (++hfc->ctrl_cnt == 1)
261 ctrl_start_transfer(hfc); 247 ctrl_start_transfer(hfc);
262 return (0); 248 return (0);
263} /* queue_control_request */
264
265static int
266control_action_handler(hfcusb_data * hfc, int reg, int val, int action)
267{
268 if (!action)
269 return (1); /* no action defined */
270 return (0);
271} 249}
272 250
273/***************************************************************/
274/* control completion routine handling background control cmds */
275/***************************************************************/
276static void 251static void
277ctrl_complete(struct urb *urb) 252ctrl_complete(struct urb *urb)
278{ 253{
@@ -282,9 +257,6 @@ ctrl_complete(struct urb *urb)
282 urb->dev = hfc->dev; 257 urb->dev = hfc->dev;
283 if (hfc->ctrl_cnt) { 258 if (hfc->ctrl_cnt) {
284 buf = &hfc->ctrl_buff[hfc->ctrl_out_idx]; 259 buf = &hfc->ctrl_buff[hfc->ctrl_out_idx];
285 control_action_handler(hfc, buf->hfc_reg, buf->reg_val,
286 buf->action);
287
288 hfc->ctrl_cnt--; /* decrement actual count */ 260 hfc->ctrl_cnt--; /* decrement actual count */
289 if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) 261 if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE)
290 hfc->ctrl_out_idx = 0; /* pointer wrap */ 262 hfc->ctrl_out_idx = 0; /* pointer wrap */
@@ -293,9 +265,7 @@ ctrl_complete(struct urb *urb)
293 } 265 }
294} /* ctrl_complete */ 266} /* ctrl_complete */
295 267
296/***************************************************/
297/* write led data to auxport & invert if necessary */ 268/* write led data to auxport & invert if necessary */
298/***************************************************/
299static void 269static void
300write_led(hfcusb_data * hfc, __u8 led_state) 270write_led(hfcusb_data * hfc, __u8 led_state)
301{ 271{
@@ -305,9 +275,6 @@ write_led(hfcusb_data * hfc, __u8 led_state)
305 } 275 }
306} 276}
307 277
308/**************************/
309/* handle LED bits */
310/**************************/
311static void 278static void
312set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset) 279set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset)
313{ 280{
@@ -324,9 +291,7 @@ set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset)
324 } 291 }
325} 292}
326 293
327/**************************/ 294/* handle LED requests */
328/* handle LED requests */
329/**************************/
330static void 295static void
331handle_led(hfcusb_data * hfc, int event) 296handle_led(hfcusb_data * hfc, int event)
332{ 297{
@@ -339,85 +304,73 @@ handle_led(hfcusb_data * hfc, int event)
339 304
340 switch (event) { 305 switch (event) {
341 case LED_POWER_ON: 306 case LED_POWER_ON:
342 set_led_bit(hfc, driver_info->led_bits[0], 307 set_led_bit(hfc, driver_info->led_bits[0], 0);
343 0); 308 set_led_bit(hfc, driver_info->led_bits[1], 1);
344 set_led_bit(hfc, driver_info->led_bits[1], 309 set_led_bit(hfc, driver_info->led_bits[2], 1);
345 1); 310 set_led_bit(hfc, driver_info->led_bits[3], 1);
346 set_led_bit(hfc, driver_info->led_bits[2],
347 1);
348 set_led_bit(hfc, driver_info->led_bits[3],
349 1);
350 break; 311 break;
351 case LED_POWER_OFF: /* no Power off handling */ 312 case LED_POWER_OFF:
313 set_led_bit(hfc, driver_info->led_bits[0], 1);
314 set_led_bit(hfc, driver_info->led_bits[1], 1);
315 set_led_bit(hfc, driver_info->led_bits[2], 1);
316 set_led_bit(hfc, driver_info->led_bits[3], 1);
352 break; 317 break;
353 case LED_S0_ON: 318 case LED_S0_ON:
354 set_led_bit(hfc, driver_info->led_bits[1], 319 set_led_bit(hfc, driver_info->led_bits[1], 0);
355 0);
356 break; 320 break;
357 case LED_S0_OFF: 321 case LED_S0_OFF:
358 set_led_bit(hfc, driver_info->led_bits[1], 322 set_led_bit(hfc, driver_info->led_bits[1], 1);
359 1);
360 break; 323 break;
361 case LED_B1_ON: 324 case LED_B1_ON:
362 set_led_bit(hfc, driver_info->led_bits[2], 325 set_led_bit(hfc, driver_info->led_bits[2], 0);
363 0);
364 break; 326 break;
365 case LED_B1_OFF: 327 case LED_B1_OFF:
366 set_led_bit(hfc, driver_info->led_bits[2], 328 set_led_bit(hfc, driver_info->led_bits[2], 1);
367 1);
368 break; 329 break;
369 case LED_B2_ON: 330 case LED_B2_ON:
370 set_led_bit(hfc, driver_info->led_bits[3], 331 set_led_bit(hfc, driver_info->led_bits[3], 0);
371 0);
372 break; 332 break;
373 case LED_B2_OFF: 333 case LED_B2_OFF:
374 set_led_bit(hfc, driver_info->led_bits[3], 334 set_led_bit(hfc, driver_info->led_bits[3], 1);
375 1);
376 break; 335 break;
377 } 336 }
378 write_led(hfc, hfc->led_state); 337 write_led(hfc, hfc->led_state);
379} 338}
380 339
381/********************************/ 340/* ISDN l1 timer T3 expires */
382/* called when timer t3 expires */
383/********************************/
384static void 341static void
385l1_timer_expire_t3(hfcusb_data * hfc) 342l1_timer_expire_t3(hfcusb_data * hfc)
386{ 343{
387 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, 344 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION,
388 NULL); 345 NULL);
389#ifdef CONFIG_HISAX_DEBUG 346
390 DBG(ISDN_DBG, 347 DBG(HFCUSB_DBG_STATES,
391 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T3 expire)"); 348 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T3 expire)");
392#endif 349
393 hfc->l1_activated = false; 350 hfc->l1_activated = 0;
394 handle_led(hfc, LED_S0_OFF); 351 handle_led(hfc, LED_S0_OFF);
395 /* deactivate : */ 352 /* deactivate : */
396 queue_control_request(hfc, HFCUSB_STATES, 0x10, 1); 353 queue_control_request(hfc, HFCUSB_STATES, 0x10, 1);
397 queue_control_request(hfc, HFCUSB_STATES, 3, 1); 354 queue_control_request(hfc, HFCUSB_STATES, 3, 1);
398} 355}
399 356
400/********************************/ 357/* ISDN l1 timer T4 expires */
401/* called when timer t4 expires */
402/********************************/
403static void 358static void
404l1_timer_expire_t4(hfcusb_data * hfc) 359l1_timer_expire_t4(hfcusb_data * hfc)
405{ 360{
406 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, 361 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION,
407 NULL); 362 NULL);
408#ifdef CONFIG_HISAX_DEBUG 363
409 DBG(ISDN_DBG, 364 DBG(HFCUSB_DBG_STATES,
410 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T4 expire)"); 365 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T4 expire)");
411#endif 366
412 hfc->l1_activated = false; 367 hfc->l1_activated = 0;
413 handle_led(hfc, LED_S0_OFF); 368 handle_led(hfc, LED_S0_OFF);
414} 369}
415 370
416/*****************************/ 371/* S0 state changed */
417/* handle S0 state changes */
418/*****************************/
419static void 372static void
420state_handler(hfcusb_data * hfc, __u8 state) 373s0_state_handler(hfcusb_data * hfc, __u8 state)
421{ 374{
422 __u8 old_state; 375 __u8 old_state;
423 376
@@ -425,38 +378,29 @@ state_handler(hfcusb_data * hfc, __u8 state)
425 if (state == old_state || state < 1 || state > 8) 378 if (state == old_state || state < 1 || state > 8)
426 return; 379 return;
427 380
428#ifdef CONFIG_HISAX_DEBUG 381 DBG(HFCUSB_DBG_STATES, "HFC-S USB: S0 statechange(%d -> %d)",
429 DBG(ISDN_DBG, "HFC-S USB: new S0 state:%d old_state:%d", state, 382 old_state, state);
430 old_state); 383
431#endif
432 if (state < 4 || state == 7 || state == 8) { 384 if (state < 4 || state == 7 || state == 8) {
433 if (timer_pending(&hfc->t3_timer)) 385 if (timer_pending(&hfc->t3_timer))
434 del_timer(&hfc->t3_timer); 386 del_timer(&hfc->t3_timer);
435#ifdef CONFIG_HISAX_DEBUG 387 DBG(HFCUSB_DBG_STATES, "HFC-S USB: T3 deactivated");
436 DBG(ISDN_DBG, "HFC-S USB: T3 deactivated");
437#endif
438 } 388 }
439 if (state >= 7) { 389 if (state >= 7) {
440 if (timer_pending(&hfc->t4_timer)) 390 if (timer_pending(&hfc->t4_timer))
441 del_timer(&hfc->t4_timer); 391 del_timer(&hfc->t4_timer);
442#ifdef CONFIG_HISAX_DEBUG 392 DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 deactivated");
443 DBG(ISDN_DBG, "HFC-S USB: T4 deactivated");
444#endif
445 } 393 }
446 394
447 if (state == 7 && !hfc->l1_activated) { 395 if (state == 7 && !hfc->l1_activated) {
448 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, 396 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
449 PH_ACTIVATE | INDICATION, NULL); 397 PH_ACTIVATE | INDICATION, NULL);
450#ifdef CONFIG_HISAX_DEBUG 398 DBG(HFCUSB_DBG_STATES, "HFC-S USB: PH_ACTIVATE | INDICATION sent");
451 DBG(ISDN_DBG, "HFC-S USB: PH_ACTIVATE | INDICATION sent"); 399 hfc->l1_activated = 1;
452#endif
453 hfc->l1_activated = true;
454 handle_led(hfc, LED_S0_ON); 400 handle_led(hfc, LED_S0_ON);
455 } else if (state <= 3 /* && activated */ ) { 401 } else if (state <= 3 /* && activated */ ) {
456 if (old_state == 7 || old_state == 8) { 402 if (old_state == 7 || old_state == 8) {
457#ifdef CONFIG_HISAX_DEBUG 403 DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 activated");
458 DBG(ISDN_DBG, "HFC-S USB: T4 activated");
459#endif
460 if (!timer_pending(&hfc->t4_timer)) { 404 if (!timer_pending(&hfc->t4_timer)) {
461 hfc->t4_timer.expires = 405 hfc->t4_timer.expires =
462 jiffies + (HFC_TIMER_T4 * HZ) / 1000; 406 jiffies + (HFC_TIMER_T4 * HZ) / 1000;
@@ -466,18 +410,15 @@ state_handler(hfcusb_data * hfc, __u8 state)
466 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, 410 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
467 PH_DEACTIVATE | INDICATION, 411 PH_DEACTIVATE | INDICATION,
468 NULL); 412 NULL);
469#ifdef CONFIG_HISAX_DEBUG 413 DBG(HFCUSB_DBG_STATES,
470 DBG(ISDN_DBG,
471 "HFC-S USB: PH_DEACTIVATE | INDICATION sent"); 414 "HFC-S USB: PH_DEACTIVATE | INDICATION sent");
472#endif 415 hfc->l1_activated = 0;
473 hfc->l1_activated = false;
474 handle_led(hfc, LED_S0_OFF); 416 handle_led(hfc, LED_S0_OFF);
475 } 417 }
476 } 418 }
477 hfc->l1_state = state; 419 hfc->l1_state = state;
478} 420}
479 421
480/* prepare iso urb */
481static void 422static void
482fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, 423fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
483 void *buf, int num_packets, int packet_size, int interval, 424 void *buf, int num_packets, int packet_size, int interval,
@@ -503,15 +444,16 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
503} 444}
504 445
505/* allocs urbs and start isoc transfer with two pending urbs to avoid 446/* allocs urbs and start isoc transfer with two pending urbs to avoid
506 gaps in the transfer chain */ 447 * gaps in the transfer chain
448 */
507static int 449static int
508start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, 450start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,
509 usb_complete_t complete, int packet_size) 451 usb_complete_t complete, int packet_size)
510{ 452{
511 int i, k, errcode; 453 int i, k, errcode;
512 454
513 printk(KERN_INFO "HFC-S USB: starting ISO-chain for Fifo %i\n", 455 DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting ISO-URBs for fifo:%d\n",
514 fifo->fifonum); 456 fifo->fifonum);
515 457
516 /* allocate Memory for Iso out Urbs */ 458 /* allocate Memory for Iso out Urbs */
517 for (i = 0; i < 2; i++) { 459 for (i = 0; i < 2; i++) {
@@ -556,10 +498,9 @@ start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,
556 498
557 errcode = usb_submit_urb(fifo->iso[i].purb, GFP_KERNEL); 499 errcode = usb_submit_urb(fifo->iso[i].purb, GFP_KERNEL);
558 fifo->active = (errcode >= 0) ? 1 : 0; 500 fifo->active = (errcode >= 0) ? 1 : 0;
559 if (errcode < 0) { 501 if (errcode < 0)
560 printk(KERN_INFO "HFC-S USB: %s URB nr:%d\n", 502 printk(KERN_INFO "HFC-S USB: usb_submit_urb URB nr:%d, error(%i): '%s'\n",
561 symbolic(urb_errlist, errcode), i); 503 i, errcode, symbolic(urb_errlist, errcode));
562 };
563 } 504 }
564 return (fifo->active); 505 return (fifo->active);
565} 506}
@@ -572,16 +513,15 @@ stop_isoc_chain(usb_fifo * fifo)
572 513
573 for (i = 0; i < 2; i++) { 514 for (i = 0; i < 2; i++) {
574 if (fifo->iso[i].purb) { 515 if (fifo->iso[i].purb) {
575#ifdef CONFIG_HISAX_DEBUG 516 DBG(HFCUSB_DBG_INIT,
576 DBG(USB_DBG,
577 "HFC-S USB: Stopping iso chain for fifo %i.%i", 517 "HFC-S USB: Stopping iso chain for fifo %i.%i",
578 fifo->fifonum, i); 518 fifo->fifonum, i);
579#endif
580 usb_kill_urb(fifo->iso[i].purb); 519 usb_kill_urb(fifo->iso[i].purb);
581 usb_free_urb(fifo->iso[i].purb); 520 usb_free_urb(fifo->iso[i].purb);
582 fifo->iso[i].purb = NULL; 521 fifo->iso[i].purb = NULL;
583 } 522 }
584 } 523 }
524
585 usb_kill_urb(fifo->urb); 525 usb_kill_urb(fifo->urb);
586 usb_free_urb(fifo->urb); 526 usb_free_urb(fifo->urb);
587 fifo->urb = NULL; 527 fifo->urb = NULL;
@@ -594,9 +534,6 @@ static int iso_packets[8] =
594 ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D 534 ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D
595}; 535};
596 536
597/*****************************************************/
598/* transmit completion routine for all ISO tx fifos */
599/*****************************************************/
600static void 537static void
601tx_iso_complete(struct urb *urb) 538tx_iso_complete(struct urb *urb)
602{ 539{
@@ -607,20 +544,38 @@ tx_iso_complete(struct urb *urb)
607 errcode; 544 errcode;
608 int frame_complete, transp_mode, fifon, status; 545 int frame_complete, transp_mode, fifon, status;
609 __u8 threshbit; 546 __u8 threshbit;
610 __u8 threshtable[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 };
611 547
612 fifon = fifo->fifonum; 548 fifon = fifo->fifonum;
613 status = urb->status; 549 status = urb->status;
614 550
615 tx_offset = 0; 551 tx_offset = 0;
616 552
553 /* ISO transfer only partially completed,
554 look at individual frame status for details */
555 if (status == -EXDEV) {
556 DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete with -EXDEV"
557 ", urb->status %d, fifonum %d\n",
558 status, fifon);
559
560 for (k = 0; k < iso_packets[fifon]; ++k) {
561 errcode = urb->iso_frame_desc[k].status;
562 if (errcode)
563 DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete "
564 "packet %i, status: %i\n",
565 k, errcode);
566 }
567
568 // clear status, so go on with ISO transfers
569 status = 0;
570 }
571
617 if (fifo->active && !status) { 572 if (fifo->active && !status) {
618 transp_mode = 0; 573 transp_mode = 0;
619 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) 574 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS)
620 transp_mode = true; 575 transp_mode = 1;
621 576
622 /* is FifoFull-threshold set for our channel? */ 577 /* is FifoFull-threshold set for our channel? */
623 threshbit = threshtable[fifon] & hfc->threshold_mask; 578 threshbit = (hfc->threshold_mask & (1 << fifon));
624 num_isoc_packets = iso_packets[fifon]; 579 num_isoc_packets = iso_packets[fifon];
625 580
626 /* predict dataflow to avoid fifo overflow */ 581 /* predict dataflow to avoid fifo overflow */
@@ -635,8 +590,9 @@ tx_iso_complete(struct urb *urb)
635 tx_iso_complete, urb->context); 590 tx_iso_complete, urb->context);
636 memset(context_iso_urb->buffer, 0, 591 memset(context_iso_urb->buffer, 0,
637 sizeof(context_iso_urb->buffer)); 592 sizeof(context_iso_urb->buffer));
638 frame_complete = false; 593 frame_complete = 0;
639 /* Generate next Iso Packets */ 594
595 /* Generate next ISO Packets */
640 for (k = 0; k < num_isoc_packets; ++k) { 596 for (k = 0; k < num_isoc_packets; ++k) {
641 if (fifo->skbuff) { 597 if (fifo->skbuff) {
642 len = fifo->skbuff->len; 598 len = fifo->skbuff->len;
@@ -661,7 +617,7 @@ tx_iso_complete(struct urb *urb)
661 /* add 2 byte flags and 16bit CRC at end of ISDN frame */ 617 /* add 2 byte flags and 16bit CRC at end of ISDN frame */
662 fifo->bit_line += 32; 618 fifo->bit_line += 32;
663 } 619 }
664 frame_complete = true; 620 frame_complete = 1;
665 } 621 }
666 622
667 memcpy(context_iso_urb->buffer + 623 memcpy(context_iso_urb->buffer +
@@ -688,7 +644,7 @@ tx_iso_complete(struct urb *urb)
688 } 644 }
689 645
690 if (frame_complete) { 646 if (frame_complete) {
691 fifo->delete_flg = true; 647 fifo->delete_flg = 1;
692 fifo->hif->l1l2(fifo->hif, 648 fifo->hif->l1l2(fifo->hif,
693 PH_DATA | CONFIRM, 649 PH_DATA | CONFIRM,
694 (void *) (unsigned long) fifo->skbuff-> 650 (void *) (unsigned long) fifo->skbuff->
@@ -696,30 +652,26 @@ tx_iso_complete(struct urb *urb)
696 if (fifo->skbuff && fifo->delete_flg) { 652 if (fifo->skbuff && fifo->delete_flg) {
697 dev_kfree_skb_any(fifo->skbuff); 653 dev_kfree_skb_any(fifo->skbuff);
698 fifo->skbuff = NULL; 654 fifo->skbuff = NULL;
699 fifo->delete_flg = false; 655 fifo->delete_flg = 0;
700 } 656 }
701 frame_complete = false; 657 frame_complete = 0;
702 } 658 }
703 } 659 }
704 errcode = usb_submit_urb(urb, GFP_ATOMIC); 660 errcode = usb_submit_urb(urb, GFP_ATOMIC);
705 if (errcode < 0) { 661 if (errcode < 0) {
706 printk(KERN_INFO 662 printk(KERN_INFO
707 "HFC-S USB: error submitting ISO URB: %d \n", 663 "HFC-S USB: error submitting ISO URB: %d\n",
708 errcode); 664 errcode);
709 } 665 }
710 } else { 666 } else {
711 if (status && !hfc->disc_flag) { 667 if (status && !hfc->disc_flag) {
712 printk(KERN_INFO 668 printk(KERN_INFO
713 "HFC-S USB: tx_iso_complete : urb->status %s (%i), fifonum=%d\n", 669 "HFC-S USB: tx_iso_complete: error(%i): '%s', fifonum=%d\n",
714 symbolic(urb_errlist, status), status, 670 status, symbolic(urb_errlist, status), fifon);
715 fifon);
716 } 671 }
717 } 672 }
718} /* tx_iso_complete */ 673}
719 674
720/*****************************************************/
721/* receive completion routine for all ISO tx fifos */
722/*****************************************************/
723static void 675static void
724rx_iso_complete(struct urb *urb) 676rx_iso_complete(struct urb *urb)
725{ 677{
@@ -731,21 +683,25 @@ rx_iso_complete(struct urb *urb)
731 unsigned int iso_status; 683 unsigned int iso_status;
732 __u8 *buf; 684 __u8 *buf;
733 static __u8 eof[8]; 685 static __u8 eof[8];
734#ifdef CONFIG_HISAX_DEBUG
735 __u8 i;
736#endif
737 686
738 fifon = fifo->fifonum; 687 fifon = fifo->fifonum;
739 status = urb->status; 688 status = urb->status;
740 689
741 if (urb->status == -EOVERFLOW) { 690 if (urb->status == -EOVERFLOW) {
742#ifdef CONFIG_HISAX_DEBUG 691 DBG(HFCUSB_DBG_VERBOSE_USB,
743 DBG(USB_DBG, 692 "HFC-USB: ignoring USB DATAOVERRUN fifo(%i)", fifon);
744 "HFC-USB: ignoring USB DATAOVERRUN for fifo %i \n", 693 status = 0;
745 fifon); 694 }
746#endif 695
696 /* ISO transfer only partially completed,
697 look at individual frame status for details */
698 if (status == -EXDEV) {
699 DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: rx_iso_complete with -EXDEV "
700 "urb->status %d, fifonum %d\n",
701 status, fifon);
747 status = 0; 702 status = 0;
748 } 703 }
704
749 if (fifo->active && !status) { 705 if (fifo->active && !status) {
750 num_isoc_packets = iso_packets[fifon]; 706 num_isoc_packets = iso_packets[fifon];
751 maxlen = fifo->usb_packet_maxlen; 707 maxlen = fifo->usb_packet_maxlen;
@@ -754,40 +710,38 @@ rx_iso_complete(struct urb *urb)
754 offset = urb->iso_frame_desc[k].offset; 710 offset = urb->iso_frame_desc[k].offset;
755 buf = context_iso_urb->buffer + offset; 711 buf = context_iso_urb->buffer + offset;
756 iso_status = urb->iso_frame_desc[k].status; 712 iso_status = urb->iso_frame_desc[k].status;
757#ifdef CONFIG_HISAX_DEBUG 713
758 if (iso_status && !hfc->disc_flag) 714 if (iso_status && !hfc->disc_flag)
759 DBG(USB_DBG, 715 DBG(HFCUSB_DBG_VERBOSE_USB,
760 "HFC-S USB: ISO packet failure - status:%x", 716 "HFC-S USB: rx_iso_complete "
761 iso_status); 717 "ISO packet %i, status: %i\n",
718 k, iso_status);
762 719
763 if ((fifon == 5) && (debug > 1)) { 720 if (fifon == HFCUSB_D_RX) {
764 printk(KERN_INFO 721 DBG(HFCUSB_DBG_VERBOSE_USB,
765 "HFC-S USB: ISO-D-RX lst_urblen:%2d " 722 "HFC-S USB: ISO-D-RX lst_urblen:%2d "
766 "act_urblen:%2d max-urblen:%2d " 723 "act_urblen:%2d max-urblen:%2d EOF:0x%0x",
767 "EOF:0x%0x DATA: ",
768 fifo->last_urblen, len, maxlen, 724 fifo->last_urblen, len, maxlen,
769 eof[5]); 725 eof[5]);
770 for (i = 0; i < len; i++) 726
771 printk("%.2x ", buf[i]); 727 DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len);
772 printk("\n");
773 } 728 }
774#endif 729
775 if (fifo->last_urblen != maxlen) { 730 if (fifo->last_urblen != maxlen) {
776 /* the threshold mask is in the 2nd status byte */ 731 /* the threshold mask is in the 2nd status byte */
777 hfc->threshold_mask = buf[1]; 732 hfc->threshold_mask = buf[1];
778 /* care for L1 state only for D-Channel 733 /* care for L1 state only for D-Channel
779 to avoid overlapped iso completions */ 734 to avoid overlapped iso completions */
780 if (fifon == 5) { 735 if (fifon == HFCUSB_D_RX) {
781 /* the S0 state is in the upper half 736 /* the S0 state is in the upper half
782 of the 1st status byte */ 737 of the 1st status byte */
783 state_handler(hfc, buf[0] >> 4); 738 s0_state_handler(hfc, buf[0] >> 4);
784 } 739 }
785 eof[fifon] = buf[0] & 1; 740 eof[fifon] = buf[0] & 1;
786 if (len > 2) 741 if (len > 2)
787 collect_rx_frame(fifo, buf + 2, 742 collect_rx_frame(fifo, buf + 2,
788 len - 2, 743 len - 2,
789 (len < 744 (len < maxlen) ?
790 maxlen) ?
791 eof[fifon] : 0); 745 eof[fifon] : 0);
792 } else { 746 } else {
793 collect_rx_frame(fifo, buf, len, 747 collect_rx_frame(fifo, buf, len,
@@ -804,41 +758,37 @@ rx_iso_complete(struct urb *urb)
804 rx_iso_complete, urb->context); 758 rx_iso_complete, urb->context);
805 errcode = usb_submit_urb(urb, GFP_ATOMIC); 759 errcode = usb_submit_urb(urb, GFP_ATOMIC);
806 if (errcode < 0) { 760 if (errcode < 0) {
807 printk(KERN_INFO 761 printk(KERN_ERR
808 "HFC-S USB: error submitting ISO URB: %d \n", 762 "HFC-S USB: error submitting ISO URB: %d\n",
809 errcode); 763 errcode);
810 } 764 }
811 } else { 765 } else {
812 if (status && !hfc->disc_flag) { 766 if (status && !hfc->disc_flag) {
813 printk(KERN_INFO 767 printk(KERN_ERR
814 "HFC-S USB: rx_iso_complete : " 768 "HFC-S USB: rx_iso_complete : "
815 "urb->status %d, fifonum %d\n", 769 "urb->status %d, fifonum %d\n",
816 status, fifon); 770 status, fifon);
817 } 771 }
818 } 772 }
819} /* rx_iso_complete */ 773}
820 774
821/*****************************************************/ 775/* collect rx data from INT- and ISO-URBs */
822/* collect data from interrupt or isochron in */
823/*****************************************************/
824static void 776static void
825collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) 777collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
826{ 778{
827 hfcusb_data *hfc = fifo->hfc; 779 hfcusb_data *hfc = fifo->hfc;
828 int transp_mode, fifon; 780 int transp_mode, fifon;
829#ifdef CONFIG_HISAX_DEBUG 781
830 int i;
831#endif
832 fifon = fifo->fifonum; 782 fifon = fifo->fifonum;
833 transp_mode = 0; 783 transp_mode = 0;
834 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) 784 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS)
835 transp_mode = true; 785 transp_mode = 1;
836 786
837 if (!fifo->skbuff) { 787 if (!fifo->skbuff) {
838 fifo->skbuff = dev_alloc_skb(fifo->max_size + 3); 788 fifo->skbuff = dev_alloc_skb(fifo->max_size + 3);
839 if (!fifo->skbuff) { 789 if (!fifo->skbuff) {
840 printk(KERN_INFO 790 printk(KERN_ERR
841 "HFC-S USB: cannot allocate buffer (dev_alloc_skb) fifo:%d\n", 791 "HFC-S USB: cannot allocate buffer for fifo(%d)\n",
842 fifon); 792 fifon);
843 return; 793 return;
844 } 794 }
@@ -847,17 +797,11 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
847 if (fifo->skbuff->len + len < fifo->max_size) { 797 if (fifo->skbuff->len + len < fifo->max_size) {
848 memcpy(skb_put(fifo->skbuff, len), data, len); 798 memcpy(skb_put(fifo->skbuff, len), data, len);
849 } else { 799 } else {
850#ifdef CONFIG_HISAX_DEBUG 800 DBG(HFCUSB_DBG_FIFO_ERR,
851 printk(KERN_INFO "HFC-S USB: "); 801 "HCF-USB: got frame exceeded fifo->max_size(%d) fifo(%d)",
852 for (i = 0; i < 15; i++)
853 printk("%.2x ",
854 fifo->skbuff->data[fifo->skbuff->
855 len - 15 + i]);
856 printk("\n");
857#endif
858 printk(KERN_INFO
859 "HCF-USB: got frame exceeded fifo->max_size:%d on fifo:%d\n",
860 fifo->max_size, fifon); 802 fifo->max_size, fifon);
803 DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff);
804 skb_trim(fifo->skbuff, 0);
861 } 805 }
862 } 806 }
863 if (transp_mode && fifo->skbuff->len >= 128) { 807 if (transp_mode && fifo->skbuff->len >= 128) {
@@ -870,6 +814,13 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
870 if (finish) { 814 if (finish) {
871 if ((!fifo->skbuff->data[fifo->skbuff->len - 1]) 815 if ((!fifo->skbuff->data[fifo->skbuff->len - 1])
872 && (fifo->skbuff->len > 3)) { 816 && (fifo->skbuff->len > 3)) {
817
818 if (fifon == HFCUSB_D_RX) {
819 DBG(HFCUSB_DBG_DCHANNEL,
820 "HFC-S USB: D-RX len(%d)", fifo->skbuff->len);
821 DBG_SKB(HFCUSB_DBG_DCHANNEL, fifo->skbuff);
822 }
823
873 /* remove CRC & status */ 824 /* remove CRC & status */
874 skb_trim(fifo->skbuff, fifo->skbuff->len - 3); 825 skb_trim(fifo->skbuff, fifo->skbuff->len - 3);
875 if (fifon == HFCUSB_PCM_RX) { 826 if (fifon == HFCUSB_PCM_RX) {
@@ -882,39 +833,17 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
882 fifo->skbuff); 833 fifo->skbuff);
883 fifo->skbuff = NULL; /* buffer was freed from upper layer */ 834 fifo->skbuff = NULL; /* buffer was freed from upper layer */
884 } else { 835 } else {
885 if (fifo->skbuff->len > 3) { 836 DBG(HFCUSB_DBG_FIFO_ERR,
886 printk(KERN_INFO 837 "HFC-S USB: ERROR frame len(%d) fifo(%d)",
887 "HFC-S USB: got frame %d bytes but CRC ERROR on fifo:%d!!!\n", 838 fifo->skbuff->len, fifon);
888 fifo->skbuff->len, fifon); 839 DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff);
889#ifdef CONFIG_HISAX_DEBUG
890 if (debug > 1) {
891 printk(KERN_INFO "HFC-S USB: ");
892 for (i = 0; i < 15; i++)
893 printk("%.2x ",
894 fifo->skbuff->
895 data[fifo->skbuff->
896 len - 15 + i]);
897 printk("\n");
898 }
899#endif
900 }
901#ifdef CONFIG_HISAX_DEBUG
902 else {
903 printk(KERN_INFO
904 "HFC-S USB: frame to small (%d bytes)!!!\n",
905 fifo->skbuff->len);
906 }
907#endif
908 skb_trim(fifo->skbuff, 0); 840 skb_trim(fifo->skbuff, 0);
909 } 841 }
910 } 842 }
911} 843}
912 844
913/***********************************************/
914/* receive completion routine for all rx fifos */
915/***********************************************/
916static void 845static void
917rx_complete(struct urb *urb) 846rx_int_complete(struct urb *urb)
918{ 847{
919 int len; 848 int len;
920 int status; 849 int status;
@@ -922,18 +851,14 @@ rx_complete(struct urb *urb)
922 usb_fifo *fifo = (usb_fifo *) urb->context; 851 usb_fifo *fifo = (usb_fifo *) urb->context;
923 hfcusb_data *hfc = fifo->hfc; 852 hfcusb_data *hfc = fifo->hfc;
924 static __u8 eof[8]; 853 static __u8 eof[8];
925#ifdef CONFIG_HISAX_DEBUG
926 __u8 i;
927#endif
928 854
929 urb->dev = hfc->dev; /* security init */ 855 urb->dev = hfc->dev; /* security init */
930 856
931 fifon = fifo->fifonum; 857 fifon = fifo->fifonum;
932 if ((!fifo->active) || (urb->status)) { 858 if ((!fifo->active) || (urb->status)) {
933#ifdef CONFIG_HISAX_DEBUG 859 DBG(HFCUSB_DBG_INIT, "HFC-S USB: RX-Fifo %i is going down (%i)",
934 DBG(USB_DBG, "HFC-S USB: RX-Fifo %i is going down (%i)",
935 fifon, urb->status); 860 fifon, urb->status);
936#endif 861
937 fifo->urb->interval = 0; /* cancel automatic rescheduling */ 862 fifo->urb->interval = 0; /* cancel automatic rescheduling */
938 if (fifo->skbuff) { 863 if (fifo->skbuff) {
939 dev_kfree_skb_any(fifo->skbuff); 864 dev_kfree_skb_any(fifo->skbuff);
@@ -945,22 +870,20 @@ rx_complete(struct urb *urb)
945 buf = fifo->buffer; 870 buf = fifo->buffer;
946 maxlen = fifo->usb_packet_maxlen; 871 maxlen = fifo->usb_packet_maxlen;
947 872
948#ifdef CONFIG_HISAX_DEBUG 873 if (fifon == HFCUSB_D_RX) {
949 if ((fifon == 5) && (debug > 1)) { 874 DBG(HFCUSB_DBG_VERBOSE_USB,
950 printk(KERN_INFO 875 "HFC-S USB: INT-D-RX lst_urblen:%2d "
951 "HFC-S USB: INT-D-RX lst_urblen:%2d act_urblen:%2d max-urblen:%2d EOF:0x%0x DATA: ", 876 "act_urblen:%2d max-urblen:%2d EOF:0x%0x",
952 fifo->last_urblen, len, maxlen, eof[5]); 877 fifo->last_urblen, len, maxlen,
953 for (i = 0; i < len; i++) 878 eof[5]);
954 printk("%.2x ", buf[i]); 879 DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len);
955 printk("\n");
956 } 880 }
957#endif
958 881
959 if (fifo->last_urblen != fifo->usb_packet_maxlen) { 882 if (fifo->last_urblen != fifo->usb_packet_maxlen) {
960 /* the threshold mask is in the 2nd status byte */ 883 /* the threshold mask is in the 2nd status byte */
961 hfc->threshold_mask = buf[1]; 884 hfc->threshold_mask = buf[1];
962 /* the S0 state is in the upper half of the 1st status byte */ 885 /* the S0 state is in the upper half of the 1st status byte */
963 state_handler(hfc, buf[0] >> 4); 886 s0_state_handler(hfc, buf[0] >> 4);
964 eof[fifon] = buf[0] & 1; 887 eof[fifon] = buf[0] & 1;
965 /* if we have more than the 2 status bytes -> collect data */ 888 /* if we have more than the 2 status bytes -> collect data */
966 if (len > 2) 889 if (len > 2)
@@ -975,20 +898,19 @@ rx_complete(struct urb *urb)
975 status = usb_submit_urb(urb, GFP_ATOMIC); 898 status = usb_submit_urb(urb, GFP_ATOMIC);
976 if (status) { 899 if (status) {
977 printk(KERN_INFO 900 printk(KERN_INFO
978 "HFC-S USB: error resubmitting URN at rx_complete...\n"); 901 "HFC-S USB: %s error resubmitting URB fifo(%d)\n",
902 __FUNCTION__, fifon);
979 } 903 }
980} /* rx_complete */ 904}
981 905
982/***************************************************/ 906/* start initial INT-URB for certain fifo */
983/* start the interrupt transfer for the given fifo */
984/***************************************************/
985static void 907static void
986start_int_fifo(usb_fifo * fifo) 908start_int_fifo(usb_fifo * fifo)
987{ 909{
988 int errcode; 910 int errcode;
989 911
990 printk(KERN_INFO "HFC-S USB: starting intr IN fifo:%d\n", 912 DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting RX INT-URB for fifo:%d\n",
991 fifo->fifonum); 913 fifo->fifonum);
992 914
993 if (!fifo->urb) { 915 if (!fifo->urb) {
994 fifo->urb = usb_alloc_urb(0, GFP_KERNEL); 916 fifo->urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -997,33 +919,28 @@ start_int_fifo(usb_fifo * fifo)
997 } 919 }
998 usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe, 920 usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe,
999 fifo->buffer, fifo->usb_packet_maxlen, 921 fifo->buffer, fifo->usb_packet_maxlen,
1000 rx_complete, fifo, fifo->intervall); 922 rx_int_complete, fifo, fifo->intervall);
1001 fifo->active = 1; /* must be marked active */ 923 fifo->active = 1; /* must be marked active */
1002 errcode = usb_submit_urb(fifo->urb, GFP_KERNEL); 924 errcode = usb_submit_urb(fifo->urb, GFP_KERNEL);
1003 if (errcode) { 925 if (errcode) {
1004 printk(KERN_INFO 926 printk(KERN_ERR
1005 "HFC-S USB: submit URB error(start_int_info): status:%i\n", 927 "HFC-S USB: submit URB error(start_int_info): status:%i\n",
1006 errcode); 928 errcode);
1007 fifo->active = 0; 929 fifo->active = 0;
1008 fifo->skbuff = NULL; 930 fifo->skbuff = NULL;
1009 } 931 }
1010} /* start_int_fifo */ 932}
1011 933
1012/*****************************/
1013/* set the B-channel mode */
1014/*****************************/
1015static void 934static void
1016set_hfcmode(hfcusb_data * hfc, int channel, int mode) 935setup_bchannel(hfcusb_data * hfc, int channel, int mode)
1017{ 936{
1018 __u8 val, idx_table[2] = { 0, 2 }; 937 __u8 val, idx_table[2] = { 0, 2 };
1019 938
1020 if (hfc->disc_flag) { 939 if (hfc->disc_flag) {
1021 return; 940 return;
1022 } 941 }
1023#ifdef CONFIG_HISAX_DEBUG 942 DBG(HFCUSB_DBG_STATES, "HFC-S USB: setting channel %d to mode %d",
1024 DBG(ISDN_DBG, "HFC-S USB: setting channel %d to mode %d", channel, 943 channel, mode);
1025 mode);
1026#endif
1027 hfc->b_mode[channel] = mode; 944 hfc->b_mode[channel] = mode;
1028 945
1029 /* setup CON_HDLC */ 946 /* setup CON_HDLC */
@@ -1080,20 +997,17 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1080 switch (pr) { 997 switch (pr) {
1081 case PH_ACTIVATE | REQUEST: 998 case PH_ACTIVATE | REQUEST:
1082 if (fifo->fifonum == HFCUSB_D_TX) { 999 if (fifo->fifonum == HFCUSB_D_TX) {
1083#ifdef CONFIG_HISAX_DEBUG 1000 DBG(HFCUSB_DBG_STATES,
1084 DBG(ISDN_DBG,
1085 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST"); 1001 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST");
1086#endif 1002
1087 if (hfc->l1_state != 3 1003 if (hfc->l1_state != 3
1088 && hfc->l1_state != 7) { 1004 && hfc->l1_state != 7) {
1089 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, 1005 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
1090 PH_DEACTIVATE | 1006 PH_DEACTIVATE |
1091 INDICATION, 1007 INDICATION,
1092 NULL); 1008 NULL);
1093#ifdef CONFIG_HISAX_DEBUG 1009 DBG(HFCUSB_DBG_STATES,
1094 DBG(ISDN_DBG,
1095 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)"); 1010 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)");
1096#endif
1097 } else { 1011 } else {
1098 if (hfc->l1_state == 7) { /* l1 already active */ 1012 if (hfc->l1_state == 7) { /* l1 already active */
1099 hfc->d_if.ifc.l1l2(&hfc-> 1013 hfc->d_if.ifc.l1l2(&hfc->
@@ -1103,10 +1017,8 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1103 | 1017 |
1104 INDICATION, 1018 INDICATION,
1105 NULL); 1019 NULL);
1106#ifdef CONFIG_HISAX_DEBUG 1020 DBG(HFCUSB_DBG_STATES,
1107 DBG(ISDN_DBG,
1108 "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)"); 1021 "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)");
1109#endif
1110 } else { 1022 } else {
1111 /* force sending sending INFO1 */ 1023 /* force sending sending INFO1 */
1112 queue_control_request(hfc, 1024 queue_control_request(hfc,
@@ -1132,11 +1044,9 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1132 } 1044 }
1133 } 1045 }
1134 } else { 1046 } else {
1135#ifdef CONFIG_HISAX_DEBUG 1047 DBG(HFCUSB_DBG_STATES,
1136 DBG(ISDN_DBG, 1048 "HFC_USB: hfc_usb_d_l2l1 B-chan: PH_ACTIVATE | REQUEST");
1137 "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_ACTIVATE | REQUEST"); 1049 setup_bchannel(hfc,
1138#endif
1139 set_hfcmode(hfc,
1140 (fifo->fifonum == 1050 (fifo->fifonum ==
1141 HFCUSB_B1_TX) ? 0 : 1, 1051 HFCUSB_B1_TX) ? 0 : 1,
1142 (long) arg); 1052 (long) arg);
@@ -1147,18 +1057,12 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1147 break; 1057 break;
1148 case PH_DEACTIVATE | REQUEST: 1058 case PH_DEACTIVATE | REQUEST:
1149 if (fifo->fifonum == HFCUSB_D_TX) { 1059 if (fifo->fifonum == HFCUSB_D_TX) {
1150#ifdef CONFIG_HISAX_DEBUG 1060 DBG(HFCUSB_DBG_STATES,
1151 DBG(ISDN_DBG,
1152 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST"); 1061 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST");
1153#endif
1154 printk(KERN_INFO
1155 "HFC-S USB: ISDN TE device should not deativate...\n");
1156 } else { 1062 } else {
1157#ifdef CONFIG_HISAX_DEBUG 1063 DBG(HFCUSB_DBG_STATES,
1158 DBG(ISDN_DBG,
1159 "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST"); 1064 "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST");
1160#endif 1065 setup_bchannel(hfc,
1161 set_hfcmode(hfc,
1162 (fifo->fifonum == 1066 (fifo->fifonum ==
1163 HFCUSB_B1_TX) ? 0 : 1, 1067 HFCUSB_B1_TX) ? 0 : 1,
1164 (int) L1_MODE_NULL); 1068 (int) L1_MODE_NULL);
@@ -1171,25 +1075,20 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1171 if (fifo->skbuff && fifo->delete_flg) { 1075 if (fifo->skbuff && fifo->delete_flg) {
1172 dev_kfree_skb_any(fifo->skbuff); 1076 dev_kfree_skb_any(fifo->skbuff);
1173 fifo->skbuff = NULL; 1077 fifo->skbuff = NULL;
1174 fifo->delete_flg = false; 1078 fifo->delete_flg = 0;
1175 } 1079 }
1176 fifo->skbuff = arg; /* we have a new buffer */ 1080 fifo->skbuff = arg; /* we have a new buffer */
1177 break; 1081 break;
1178 default: 1082 default:
1179 printk(KERN_INFO 1083 DBG(HFCUSB_DBG_STATES,
1180 "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x\n", 1084 "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x", pr);
1181 pr);
1182 break; 1085 break;
1183 } 1086 }
1184} 1087}
1185 1088
1186/***************************************************************************/ 1089/* initial init HFC-S USB chip registers, HiSax interface, USB URBs */
1187/* usb_init is called once when a new matching device is detected to setup */
1188/* main parameters. It registers the driver at the main hisax module. */
1189/* on success 0 is returned. */
1190/***************************************************************************/
1191static int 1090static int
1192usb_init(hfcusb_data * hfc) 1091hfc_usb_init(hfcusb_data * hfc)
1193{ 1092{
1194 usb_fifo *fifo; 1093 usb_fifo *fifo;
1195 int i, err; 1094 int i, err;
@@ -1214,11 +1113,11 @@ usb_init(hfcusb_data * hfc)
1214 /* aux = output, reset off */ 1113 /* aux = output, reset off */
1215 write_usb(hfc, HFCUSB_CIRM, 0x10); 1114 write_usb(hfc, HFCUSB_CIRM, 0x10);
1216 1115
1217 /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */ 1116 /* set USB_SIZE to match wMaxPacketSize for INT or BULK transfers */
1218 write_usb(hfc, HFCUSB_USB_SIZE, 1117 write_usb(hfc, HFCUSB_USB_SIZE,
1219 (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4)); 1118 (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4));
1220 1119
1221 /* set USB_SIZE_I to match the wMaxPacketSize for ISO transfers */ 1120 /* set USB_SIZE_I to match wMaxPacketSize for ISO transfers */
1222 write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); 1121 write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size);
1223 1122
1224 /* enable PCM/GCI master mode */ 1123 /* enable PCM/GCI master mode */
@@ -1257,8 +1156,8 @@ usb_init(hfcusb_data * hfc)
1257 hfc->b_mode[0] = L1_MODE_NULL; 1156 hfc->b_mode[0] = L1_MODE_NULL;
1258 hfc->b_mode[1] = L1_MODE_NULL; 1157 hfc->b_mode[1] = L1_MODE_NULL;
1259 1158
1260 hfc->l1_activated = false; 1159 hfc->l1_activated = 0;
1261 hfc->disc_flag = false; 1160 hfc->disc_flag = 0;
1262 hfc->led_state = 0; 1161 hfc->led_state = 0;
1263 hfc->led_new_data = 0; 1162 hfc->led_new_data = 0;
1264 hfc->old_led_state = 0; 1163 hfc->old_led_state = 0;
@@ -1349,11 +1248,9 @@ usb_init(hfcusb_data * hfc)
1349 handle_led(hfc, LED_POWER_ON); 1248 handle_led(hfc, LED_POWER_ON);
1350 1249
1351 return (0); 1250 return (0);
1352} /* usb_init */ 1251}
1353 1252
1354/*************************************************/ 1253/* initial callback for each plugged USB device */
1355/* function called to probe a new plugged device */
1356/*************************************************/
1357static int 1254static int
1358hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) 1255hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1359{ 1256{
@@ -1378,11 +1275,6 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1378 } 1275 }
1379 } 1276 }
1380 1277
1381#ifdef CONFIG_HISAX_DEBUG
1382 DBG(USB_DBG,
1383 "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", ifnum,
1384 iface->desc.bAlternateSetting, intf->minor);
1385#endif
1386 printk(KERN_INFO 1278 printk(KERN_INFO
1387 "HFC-S USB: probing interface(%d) actalt(%d) minor(%d)\n", 1279 "HFC-S USB: probing interface(%d) actalt(%d) minor(%d)\n",
1388 ifnum, iface->desc.bAlternateSetting, intf->minor); 1280 ifnum, iface->desc.bAlternateSetting, intf->minor);
@@ -1403,15 +1295,11 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1403 1295
1404 /* check for config EOL element */ 1296 /* check for config EOL element */
1405 while (validconf[cfg_used][0]) { 1297 while (validconf[cfg_used][0]) {
1406 cfg_found = true; 1298 cfg_found = 1;
1407 vcf = validconf[cfg_used]; 1299 vcf = validconf[cfg_used];
1408 /* first endpoint descriptor */ 1300 /* first endpoint descriptor */
1409 ep = iface->endpoint; 1301 ep = iface->endpoint;
1410#ifdef CONFIG_HISAX_DEBUG 1302
1411 DBG(USB_DBG,
1412 "HFC-S USB: (if=%d alt=%d cfg_used=%d)\n",
1413 ifnum, probe_alt_setting, cfg_used);
1414#endif
1415 memcpy(cmptbl, vcf, 16 * sizeof(int)); 1303 memcpy(cmptbl, vcf, 16 * sizeof(int));
1416 1304
1417 /* check for all endpoints in this alternate setting */ 1305 /* check for all endpoints in this alternate setting */
@@ -1425,7 +1313,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1425 idx++; 1313 idx++;
1426 attr = ep->desc.bmAttributes; 1314 attr = ep->desc.bmAttributes;
1427 if (cmptbl[idx] == EP_NUL) { 1315 if (cmptbl[idx] == EP_NUL) {
1428 cfg_found = false; 1316 cfg_found = 0;
1429 } 1317 }
1430 if (attr == USB_ENDPOINT_XFER_INT 1318 if (attr == USB_ENDPOINT_XFER_INT
1431 && cmptbl[idx] == EP_INT) 1319 && cmptbl[idx] == EP_INT)
@@ -1438,16 +1326,9 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1438 cmptbl[idx] = EP_NUL; 1326 cmptbl[idx] = EP_NUL;
1439 1327
1440 /* check if all INT endpoints match minimum interval */ 1328 /* check if all INT endpoints match minimum interval */
1441 if (attr == USB_ENDPOINT_XFER_INT 1329 if ((attr == USB_ENDPOINT_XFER_INT)
1442 && ep->desc.bInterval < 1330 && (ep->desc.bInterval < vcf[17])) {
1443 vcf[17]) { 1331 cfg_found = 0;
1444#ifdef CONFIG_HISAX_DEBUG
1445 if (cfg_found)
1446 DBG(USB_DBG,
1447 "HFC-S USB: Interrupt Endpoint interval < %d found - skipping config",
1448 vcf[17]);
1449#endif
1450 cfg_found = false;
1451 } 1332 }
1452 ep++; 1333 ep++;
1453 } 1334 }
@@ -1455,7 +1336,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1455 /* all entries must be EP_NOP or EP_NUL for a valid config */ 1336 /* all entries must be EP_NOP or EP_NUL for a valid config */
1456 if (cmptbl[i] != EP_NOP 1337 if (cmptbl[i] != EP_NOP
1457 && cmptbl[i] != EP_NUL) 1338 && cmptbl[i] != EP_NUL)
1458 cfg_found = false; 1339 cfg_found = 0;
1459 } 1340 }
1460 if (cfg_found) { 1341 if (cfg_found) {
1461 if (cfg_used < small_match) { 1342 if (cfg_used < small_match) {
@@ -1464,23 +1345,16 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1464 probe_alt_setting; 1345 probe_alt_setting;
1465 iface_used = iface; 1346 iface_used = iface;
1466 } 1347 }
1467#ifdef CONFIG_HISAX_DEBUG
1468 DBG(USB_DBG,
1469 "HFC-USB: small_match=%x %x\n",
1470 small_match, alt_used);
1471#endif
1472 } 1348 }
1473 cfg_used++; 1349 cfg_used++;
1474 } 1350 }
1475 alt_idx++; 1351 alt_idx++;
1476 } /* (alt_idx < intf->num_altsetting) */ 1352 } /* (alt_idx < intf->num_altsetting) */
1477 1353
1478 /* found a valid USB Ta Endpint config */ 1354 /* found a valid USB Ta Endpint config */
1479 if (small_match != 0xffff) { 1355 if (small_match != 0xffff) {
1480 iface = iface_used; 1356 iface = iface_used;
1481 if (! 1357 if (!(context = kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
1482 (context =
1483 kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
1484 return (-ENOMEM); /* got no mem */ 1358 return (-ENOMEM); /* got no mem */
1485 1359
1486 ep = iface->endpoint; 1360 ep = iface->endpoint;
@@ -1613,20 +1487,15 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1613 driver_info; 1487 driver_info;
1614 printk(KERN_INFO "HFC-S USB: detected \"%s\"\n", 1488 printk(KERN_INFO "HFC-S USB: detected \"%s\"\n",
1615 driver_info->vend_name); 1489 driver_info->vend_name);
1616#ifdef CONFIG_HISAX_DEBUG 1490
1617 DBG(USB_DBG, 1491 DBG(HFCUSB_DBG_INIT,
1618 "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d)\n", 1492 "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d), E-Channel(%d)",
1619 conf_str[small_match], context->if_used, 1493 conf_str[small_match], context->if_used,
1620 context->alt_used); 1494 context->alt_used,
1621 printk(KERN_INFO 1495 validconf[small_match][18]);
1622 "HFC-S USB: E-channel (\"ECHO:\") logging "); 1496
1623 if (validconf[small_match][18])
1624 printk(" possible\n");
1625 else
1626 printk("NOT possible\n");
1627#endif
1628 /* init the chip and register the driver */ 1497 /* init the chip and register the driver */
1629 if (usb_init(context)) { 1498 if (hfc_usb_init(context)) {
1630 usb_kill_urb(context->ctrl_urb); 1499 usb_kill_urb(context->ctrl_urb);
1631 usb_free_urb(context->ctrl_urb); 1500 usb_free_urb(context->ctrl_urb);
1632 context->ctrl_urb = NULL; 1501 context->ctrl_urb = NULL;
@@ -1643,17 +1512,19 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1643 return (-EIO); 1512 return (-EIO);
1644} 1513}
1645 1514
1646/****************************************************/ 1515/* callback for unplugged USB device */
1647/* function called when an active device is removed */
1648/****************************************************/
1649static void 1516static void
1650hfc_usb_disconnect(struct usb_interface 1517hfc_usb_disconnect(struct usb_interface
1651 *intf) 1518 *intf)
1652{ 1519{
1653 hfcusb_data *context = usb_get_intfdata(intf); 1520 hfcusb_data *context = usb_get_intfdata(intf);
1654 int i; 1521 int i;
1522
1523 handle_led(context, LED_POWER_OFF);
1524 schedule_timeout((10 * HZ) / 1000);
1525
1655 printk(KERN_INFO "HFC-S USB: device disconnect\n"); 1526 printk(KERN_INFO "HFC-S USB: device disconnect\n");
1656 context->disc_flag = true; 1527 context->disc_flag = 1;
1657 usb_set_intfdata(intf, NULL); 1528 usb_set_intfdata(intf, NULL);
1658 if (!context) 1529 if (!context)
1659 return; 1530 return;
@@ -1661,25 +1532,22 @@ hfc_usb_disconnect(struct usb_interface
1661 del_timer(&context->t3_timer); 1532 del_timer(&context->t3_timer);
1662 if (timer_pending(&context->t4_timer)) 1533 if (timer_pending(&context->t4_timer))
1663 del_timer(&context->t4_timer); 1534 del_timer(&context->t4_timer);
1535
1664 /* tell all fifos to terminate */ 1536 /* tell all fifos to terminate */
1665 for (i = 0; i < HFCUSB_NUM_FIFOS; i++) { 1537 for (i = 0; i < HFCUSB_NUM_FIFOS; i++) {
1666 if (context->fifos[i].usb_transfer_mode == USB_ISOC) { 1538 if (context->fifos[i].usb_transfer_mode == USB_ISOC) {
1667 if (context->fifos[i].active > 0) { 1539 if (context->fifos[i].active > 0) {
1668 stop_isoc_chain(&context->fifos[i]); 1540 stop_isoc_chain(&context->fifos[i]);
1669#ifdef CONFIG_HISAX_DEBUG 1541 DBG(HFCUSB_DBG_INIT,
1670 DBG(USB_DBG, 1542 "HFC-S USB: %s stopping ISOC chain Fifo(%i)",
1671 "HFC-S USB: hfc_usb_disconnect: stopping ISOC chain Fifo no %i", 1543 __FUNCTION__, i);
1672 i);
1673#endif
1674 } 1544 }
1675 } else { 1545 } else {
1676 if (context->fifos[i].active > 0) { 1546 if (context->fifos[i].active > 0) {
1677 context->fifos[i].active = 0; 1547 context->fifos[i].active = 0;
1678#ifdef CONFIG_HISAX_DEBUG 1548 DBG(HFCUSB_DBG_INIT,
1679 DBG(USB_DBG, 1549 "HFC-S USB: %s unlinking URB for Fifo(%i)",
1680 "HFC-S USB: hfc_usb_disconnect: unlinking URB for Fifo no %i", 1550 __FUNCTION__, i);
1681 i);
1682#endif
1683 } 1551 }
1684 usb_kill_urb(context->fifos[i].urb); 1552 usb_kill_urb(context->fifos[i].urb);
1685 usb_free_urb(context->fifos[i].urb); 1553 usb_free_urb(context->fifos[i].urb);
@@ -1692,34 +1560,29 @@ hfc_usb_disconnect(struct usb_interface
1692 context->ctrl_urb = NULL; 1560 context->ctrl_urb = NULL;
1693 hisax_unregister(&context->d_if); 1561 hisax_unregister(&context->d_if);
1694 kfree(context); /* free our structure again */ 1562 kfree(context); /* free our structure again */
1695} /* hfc_usb_disconnect */ 1563}
1696 1564
1697/************************************/
1698/* our driver information structure */
1699/************************************/
1700static struct usb_driver hfc_drv = { 1565static struct usb_driver hfc_drv = {
1701 .name = "hfc_usb", 1566 .name = "hfc_usb",
1702 .id_table = hfcusb_idtab, 1567 .id_table = hfcusb_idtab,
1703 .probe = hfc_usb_probe, 1568 .probe = hfc_usb_probe,
1704 .disconnect = hfc_usb_disconnect, 1569 .disconnect = hfc_usb_disconnect,
1705}; 1570};
1571
1706static void __exit 1572static void __exit
1707hfc_usb_exit(void) 1573hfc_usb_mod_exit(void)
1708{ 1574{
1709#ifdef CONFIG_HISAX_DEBUG 1575 usb_deregister(&hfc_drv); /* release our driver */
1710 DBG(USB_DBG, "HFC-S USB: calling \"hfc_usb_exit\" ...");
1711#endif
1712 usb_deregister(&hfc_drv); /* release our driver */
1713 printk(KERN_INFO "HFC-S USB: module removed\n"); 1576 printk(KERN_INFO "HFC-S USB: module removed\n");
1714} 1577}
1715 1578
1716static int __init 1579static int __init
1717hfc_usb_init(void) 1580hfc_usb_mod_init(void)
1718{ 1581{
1582 char revstr[30], datestr[30], dummy[30];
1719#ifndef CONFIG_HISAX_DEBUG 1583#ifndef CONFIG_HISAX_DEBUG
1720 unsigned int debug = -1; 1584 hfc_debug = debug;
1721#endif 1585#endif
1722 char revstr[30], datestr[30], dummy[30];
1723 sscanf(hfcusb_revision, 1586 sscanf(hfcusb_revision,
1724 "%s %s $ %s %s %s $ ", dummy, revstr, 1587 "%s %s $ %s %s %s $ ", dummy, revstr,
1725 dummy, datestr, dummy); 1588 dummy, datestr, dummy);
@@ -1734,8 +1597,8 @@ hfc_usb_init(void)
1734 return (0); 1597 return (0);
1735} 1598}
1736 1599
1737module_init(hfc_usb_init); 1600module_init(hfc_usb_mod_init);
1738module_exit(hfc_usb_exit); 1601module_exit(hfc_usb_mod_exit);
1739MODULE_AUTHOR(DRIVER_AUTHOR); 1602MODULE_AUTHOR(DRIVER_AUTHOR);
1740MODULE_DESCRIPTION(DRIVER_DESC); 1603MODULE_DESCRIPTION(DRIVER_DESC);
1741MODULE_LICENSE("GPL"); 1604MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/hfc_usb.h b/drivers/isdn/hisax/hfc_usb.h
index 471f2354dfde..e79f56568d30 100644
--- a/drivers/isdn/hisax/hfc_usb.h
+++ b/drivers/isdn/hisax/hfc_usb.h
@@ -1,8 +1,8 @@
1/* 1/*
2* hfc_usb.h 2 * hfc_usb.h
3* 3 *
4* $Id: hfc_usb.h,v 4.2 2005/04/07 15:27:17 martinb1 Exp $ 4 * $Id: hfc_usb.h,v 1.1.2.5 2007/08/20 14:36:03 mbachem Exp $
5*/ 5 */
6 6
7#ifndef __HFC_USB_H__ 7#ifndef __HFC_USB_H__
8#define __HFC_USB_H__ 8#define __HFC_USB_H__
@@ -10,25 +10,20 @@
10#define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)" 10#define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)"
11#define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver" 11#define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver"
12 12
13#define VERBOSE_USB_DEBUG
14 13
14#define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */
15#define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */
16#define HFC_TIMER_T4 500 /* time for state change interval */
15 17
16/***********/ 18#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */
17/* defines */ 19#define HFCUSB_L1_DRX 1 /* D-frame received */
18/***********/ 20#define HFCUSB_L1_ERX 2 /* E-frame received */
19#define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */ 21#define HFCUSB_L1_DTX 4 /* D-frames completed */
20#define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */
21#define HFC_TIMER_T4 500 /* time for state change interval */
22 22
23#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ 23#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */
24#define HFCUSB_L1_DRX 1 /* D-frame received */
25#define HFCUSB_L1_ERX 2 /* E-frame received */
26#define HFCUSB_L1_DTX 4 /* D-frames completed */
27 24
28#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ 25#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
29 26#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */
30#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
31#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */
32 27
33#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ 28#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */
34#define HFCUSB_CIRM 0x00 /* cirm register index */ 29#define HFCUSB_CIRM 0x00 /* cirm register index */
@@ -52,9 +47,8 @@
52 47
53#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */ 48#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */
54 49
55/******************/ 50
56/* fifo registers */ 51/* fifo registers */
57/******************/
58#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ 52#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */
59#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ 53#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */
60#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ 54#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */
@@ -66,9 +60,9 @@
66#define HFCUSB_PCM_RX 7 60#define HFCUSB_PCM_RX 7
67 61
68/* 62/*
69* used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just 63 * used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just
70* supports ISO out, while the Cologne Chip EVAL TA just supports BULK out 64 * supports ISO out, while the Cologne Chip EVAL TA just supports BULK out
71*/ 65 */
72#define USB_INT 0 66#define USB_INT 0
73#define USB_BULK 1 67#define USB_BULK 1
74#define USB_ISOC 2 68#define USB_ISOC 2
@@ -77,49 +71,36 @@
77#define ISOC_PACKETS_B 8 71#define ISOC_PACKETS_B 8
78#define ISO_BUFFER_SIZE 128 72#define ISO_BUFFER_SIZE 128
79 73
80// ISO send definitions 74/* Fifo flow Control for TX ISO */
81#define SINK_MAX 68 75#define SINK_MAX 68
82#define SINK_MIN 48 76#define SINK_MIN 48
83#define SINK_DMIN 12 77#define SINK_DMIN 12
84#define SINK_DMAX 18 78#define SINK_DMAX 18
85#define BITLINE_INF (-64*8) 79#define BITLINE_INF (-64*8)
86 80
87 81/* HFC-S USB register access by Control-URSs */
88/**********/
89/* macros */
90/**********/
91#define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT) 82#define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT)
92#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) 83#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT)
93
94
95/*******************/
96/* Debugging Flags */
97/*******************/
98#define USB_DBG 1
99#define ISDN_DBG 2
100
101
102/* *********************/
103/* USB related defines */
104/***********************/
105#define HFC_CTRL_BUFSIZE 32 84#define HFC_CTRL_BUFSIZE 32
106 85
107
108
109/*************************************************/
110/* entry and size of output/input control buffer */ 86/* entry and size of output/input control buffer */
111/*************************************************/
112typedef struct { 87typedef struct {
113 __u8 hfc_reg; /* register number */ 88 __u8 hfc_reg; /* register number */
114 __u8 reg_val; /* value to be written (or read) */ 89 __u8 reg_val; /* value to be written (or read) */
115 int action; /* data for action handler */ 90 int action; /* data for action handler */
116} ctrl_buft; 91} ctrl_buft;
117 92
93/* Debugging Flags */
94#define HFCUSB_DBG_INIT 0x0001
95#define HFCUSB_DBG_STATES 0x0002
96#define HFCUSB_DBG_DCHANNEL 0x0080
97#define HFCUSB_DBG_FIFO_ERR 0x4000
98#define HFCUSB_DBG_VERBOSE_USB 0x8000
118 99
119/********************/ 100/*
120/* URB error codes: */ 101 * URB error codes:
121/********************/ 102 * Used to represent a list of values and their respective symbolic names
122/* Used to represent a list of values and their respective symbolic names */ 103 */
123struct hfcusb_symbolic_list { 104struct hfcusb_symbolic_list {
124 const int num; 105 const int num;
125 const char *name; 106 const char *name;
@@ -134,20 +115,20 @@ static struct hfcusb_symbolic_list urb_errlist[] = {
134 {-ENXIO, "URB already queued"}, 115 {-ENXIO, "URB already queued"},
135 {-EFBIG, "Too much ISO frames requested"}, 116 {-EFBIG, "Too much ISO frames requested"},
136 {-ENOSR, "Buffer error (overrun)"}, 117 {-ENOSR, "Buffer error (overrun)"},
137 {-EPIPE, "Specified endpoint is stalled"}, 118 {-EPIPE, "Specified endpoint is stalled (device not responding)"},
138 {-EOVERFLOW, "Babble (bad cable?)"}, 119 {-EOVERFLOW, "Babble (bad cable?)"},
139 {-EPROTO, "Bit-stuff error (bad cable?)"}, 120 {-EPROTO, "Bit-stuff error (bad cable?)"},
140 {-EILSEQ, "CRC or missing token"}, 121 {-EILSEQ, "CRC/Timeout"},
141 {-ETIME, "Device did not respond"}, 122 {-ETIMEDOUT, "NAK (device does not respond)"},
142 {-ESHUTDOWN, "Device unplugged"}, 123 {-ESHUTDOWN, "Device unplugged"},
143 {-1, NULL} 124 {-1, NULL}
144}; 125};
145 126
146 127
147/*****************************************************/ 128/*
148/* device dependant information to support different */ 129 * device dependant information to support different
149/* ISDN Ta's using the HFC-S USB chip */ 130 * ISDN Ta's using the HFC-S USB chip
150/*****************************************************/ 131 */
151 132
152/* USB descriptor need to contain one of the following EndPoint combination: */ 133/* USB descriptor need to contain one of the following EndPoint combination: */
153#define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT 134#define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT
@@ -155,16 +136,19 @@ static struct hfcusb_symbolic_list urb_errlist[] = {
155#define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT 136#define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT
156#define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT 137#define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT
157 138
158#define EP_NUL 1 // Endpoint at this position not allowed 139#define EP_NUL 1 // Endpoint at this position not allowed
159#define EP_NOP 2 // all type of endpoints allowed at this position 140#define EP_NOP 2 // all type of endpoints allowed at this position
160#define EP_ISO 3 // Isochron endpoint mandatory at this position 141#define EP_ISO 3 // Isochron endpoint mandatory at this position
161#define EP_BLK 4 // Bulk endpoint mandatory at this position 142#define EP_BLK 4 // Bulk endpoint mandatory at this position
162#define EP_INT 5 // Interrupt endpoint mandatory at this position 143#define EP_INT 5 // Interrupt endpoint mandatory at this position
163 144
164/* this array represents all endpoints possible in the HCF-USB the last 145/*
165* 3 entries are the configuration number, the minimum interval for 146 * List of all supported endpoint configuration sets, used to find the
166* Interrupt endpoints & boolean if E-channel logging possible 147 * best matching endpoint configuration within a devices' USB descriptor.
167*/ 148 * We need at least 3 RX endpoints, and 3 TX endpoints, either
149 * INT-in and ISO-out, or ISO-in and ISO-out)
150 * with 4 RX endpoints even E-Channel logging is possible
151 */
168static int validconf[][19] = { 152static int validconf[][19] = {
169 // INT in, ISO out config 153 // INT in, ISO out config
170 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT, 154 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT,
@@ -193,7 +177,6 @@ static char *conf_str[] = {
193}; 177};
194#endif 178#endif
195 179
196
197typedef struct { 180typedef struct {
198 int vendor; // vendor id 181 int vendor; // vendor id
199 int prod_id; // product id 182 int prod_id; // product id
@@ -202,9 +185,9 @@ typedef struct {
202 signed short led_bits[8]; // array of 8 possible LED bitmask settings 185 signed short led_bits[8]; // array of 8 possible LED bitmask settings
203} vendor_data; 186} vendor_data;
204 187
205#define LED_OFF 0 // no LED support 188#define LED_OFF 0 // no LED support
206#define LED_SCHEME1 1 // LED standard scheme 189#define LED_SCHEME1 1 // LED standard scheme
207#define LED_SCHEME2 2 // not used yet... 190#define LED_SCHEME2 2 // not used yet...
208 191
209#define LED_POWER_ON 1 192#define LED_POWER_ON 1
210#define LED_POWER_OFF 2 193#define LED_POWER_OFF 2
@@ -217,11 +200,8 @@ typedef struct {
217#define LED_B2_OFF 9 200#define LED_B2_OFF 9
218#define LED_B2_DATA 10 201#define LED_B2_DATA 10
219 202
220#define LED_NORMAL 0 // LEDs are normal 203#define LED_NORMAL 0 // LEDs are normal
221#define LED_INVERTED 1 // LEDs are inverted 204#define LED_INVERTED 1 // LEDs are inverted
222
223/* time in ms to perform a Flashing LED when B-Channel has traffic */
224#define LED_TIME 250
225 205
226 206
227#endif // __HFC_USB_H__ 207#endif // __HFC_USB_H__
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index ef3325b69233..9293c82ef2af 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1726,7 +1726,7 @@ ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb)
1726 } 1726 }
1727 /* the decompressor still expects the A/C bytes in the hdr */ 1727 /* the decompressor still expects the A/C bytes in the hdr */
1728 len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2, 1728 len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2,
1729 skb->len + 2, ns->data, ppp->mru + PPP_HDRLEN); 1729 skb->len + 2, ns->data, obuff_size);
1730 if (len < 0) { 1730 if (len < 0) {
1731 /* Pass the compressed frame to pppd as an 1731 /* Pass the compressed frame to pppd as an
1732 error indication. */ 1732 error indication. */
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index e7a2eadcc3b0..757592436390 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -696,8 +696,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
696 int i; 696 int i;
697 const u8 *addr = hw->dev[port]->dev_addr; 697 const u8 *addr = hw->dev[port]->dev_addr;
698 698
699 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); 699 sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
700 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR); 700 sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR);
701 701
702 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); 702 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
703 703
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index eccac1c3b71b..d32c60dbdd82 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -24,6 +24,7 @@
24#include <asm/s390_ext.h> 24#include <asm/s390_ext.h>
25#include <asm/todclk.h> 25#include <asm/todclk.h>
26#include <asm/vtoc.h> 26#include <asm/vtoc.h>
27#include <asm/diag.h>
27 28
28#include "dasd_int.h" 29#include "dasd_int.h"
29#include "dasd_diag.h" 30#include "dasd_diag.h"
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 4f2f81b16cfa..2edd5fb6d3dc 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -21,6 +21,7 @@
21#include <asm/ccwdev.h> 21#include <asm/ccwdev.h>
22#include <asm/cio.h> 22#include <asm/cio.h>
23#include <asm/ebcdic.h> 23#include <asm/ebcdic.h>
24#include <asm/diag.h>
24 25
25#include "raw3270.h" 26#include "raw3270.h"
26 27
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 04b19bdc09da..d70a6e65bf14 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -14,6 +14,7 @@
14#include <asm/cio.h> 14#include <asm/cio.h>
15#include <asm/ccwdev.h> 15#include <asm/ccwdev.h>
16#include <asm/debug.h> 16#include <asm/debug.h>
17#include <asm/diag.h>
17 18
18#include "vmur.h" 19#include "vmur.h"
19 20
@@ -68,8 +69,26 @@ static struct ccw_driver ur_driver = {
68 .set_offline = ur_set_offline, 69 .set_offline = ur_set_offline,
69}; 70};
70 71
72static DEFINE_MUTEX(vmur_mutex);
73
71/* 74/*
72 * Allocation, freeing, getting and putting of urdev structures 75 * Allocation, freeing, getting and putting of urdev structures
76 *
77 * Each ur device (urd) contains a reference to its corresponding ccw device
78 * (cdev) using the urd->cdev pointer. Each ccw device has a reference to the
79 * ur device using the cdev->dev.driver_data pointer.
80 *
81 * urd references:
82 * - ur_probe gets a urd reference, ur_remove drops the reference
83 * (cdev->dev.driver_data)
84 * - ur_open gets a urd reference, ur_relase drops the reference
85 * (urf->urd)
86 *
87 * cdev references:
88 * - urdev_alloc get a cdev reference (urd->cdev)
89 * - urdev_free drops the cdev reference (urd->cdev)
90 *
91 * Setting and clearing of cdev->dev.driver_data is protected by the ccwdev lock
73 */ 92 */
74static struct urdev *urdev_alloc(struct ccw_device *cdev) 93static struct urdev *urdev_alloc(struct ccw_device *cdev)
75{ 94{
@@ -78,42 +97,61 @@ static struct urdev *urdev_alloc(struct ccw_device *cdev)
78 urd = kzalloc(sizeof(struct urdev), GFP_KERNEL); 97 urd = kzalloc(sizeof(struct urdev), GFP_KERNEL);
79 if (!urd) 98 if (!urd)
80 return NULL; 99 return NULL;
81 urd->cdev = cdev;
82 urd->reclen = cdev->id.driver_info; 100 urd->reclen = cdev->id.driver_info;
83 ccw_device_get_id(cdev, &urd->dev_id); 101 ccw_device_get_id(cdev, &urd->dev_id);
84 mutex_init(&urd->io_mutex); 102 mutex_init(&urd->io_mutex);
85 mutex_init(&urd->open_mutex); 103 mutex_init(&urd->open_mutex);
104 atomic_set(&urd->ref_count, 1);
105 urd->cdev = cdev;
106 get_device(&cdev->dev);
86 return urd; 107 return urd;
87} 108}
88 109
89static void urdev_free(struct urdev *urd) 110static void urdev_free(struct urdev *urd)
90{ 111{
112 TRACE("urdev_free: %p\n", urd);
113 if (urd->cdev)
114 put_device(&urd->cdev->dev);
91 kfree(urd); 115 kfree(urd);
92} 116}
93 117
94/* 118static void urdev_get(struct urdev *urd)
95 * This is how the character device driver gets a reference to a 119{
96 * ur device. When this call returns successfully, a reference has 120 atomic_inc(&urd->ref_count);
97 * been taken (by get_device) on the underlying kobject. The recipient 121}
98 * of this urdev pointer must eventually drop it with urdev_put(urd) 122
99 * which does the corresponding put_device(). 123static struct urdev *urdev_get_from_cdev(struct ccw_device *cdev)
100 */ 124{
125 struct urdev *urd;
126 unsigned long flags;
127
128 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
129 urd = cdev->dev.driver_data;
130 if (urd)
131 urdev_get(urd);
132 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
133 return urd;
134}
135
101static struct urdev *urdev_get_from_devno(u16 devno) 136static struct urdev *urdev_get_from_devno(u16 devno)
102{ 137{
103 char bus_id[16]; 138 char bus_id[16];
104 struct ccw_device *cdev; 139 struct ccw_device *cdev;
140 struct urdev *urd;
105 141
106 sprintf(bus_id, "0.0.%04x", devno); 142 sprintf(bus_id, "0.0.%04x", devno);
107 cdev = get_ccwdev_by_busid(&ur_driver, bus_id); 143 cdev = get_ccwdev_by_busid(&ur_driver, bus_id);
108 if (!cdev) 144 if (!cdev)
109 return NULL; 145 return NULL;
110 146 urd = urdev_get_from_cdev(cdev);
111 return cdev->dev.driver_data; 147 put_device(&cdev->dev);
148 return urd;
112} 149}
113 150
114static void urdev_put(struct urdev *urd) 151static void urdev_put(struct urdev *urd)
115{ 152{
116 put_device(&urd->cdev->dev); 153 if (atomic_dec_and_test(&urd->ref_count))
154 urdev_free(urd);
117} 155}
118 156
119/* 157/*
@@ -245,6 +283,7 @@ static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
245 return; 283 return;
246 } 284 }
247 urd = cdev->dev.driver_data; 285 urd = cdev->dev.driver_data;
286 BUG_ON(!urd);
248 /* On special conditions irb is an error pointer */ 287 /* On special conditions irb is an error pointer */
249 if (IS_ERR(irb)) 288 if (IS_ERR(irb))
250 urd->io_request_rc = PTR_ERR(irb); 289 urd->io_request_rc = PTR_ERR(irb);
@@ -262,9 +301,15 @@ static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
262static ssize_t ur_attr_reclen_show(struct device *dev, 301static ssize_t ur_attr_reclen_show(struct device *dev,
263 struct device_attribute *attr, char *buf) 302 struct device_attribute *attr, char *buf)
264{ 303{
265 struct urdev *urd = dev->driver_data; 304 struct urdev *urd;
305 int rc;
266 306
267 return sprintf(buf, "%zu\n", urd->reclen); 307 urd = urdev_get_from_cdev(to_ccwdev(dev));
308 if (!urd)
309 return -ENODEV;
310 rc = sprintf(buf, "%zu\n", urd->reclen);
311 urdev_put(urd);
312 return rc;
268} 313}
269 314
270static DEVICE_ATTR(reclen, 0444, ur_attr_reclen_show, NULL); 315static DEVICE_ATTR(reclen, 0444, ur_attr_reclen_show, NULL);
@@ -379,31 +424,6 @@ static ssize_t ur_write(struct file *file, const char __user *udata,
379 return do_write(urf->urd, udata, count, urf->dev_reclen, ppos); 424 return do_write(urf->urd, udata, count, urf->dev_reclen, ppos);
380} 425}
381 426
382static int do_diag_14(unsigned long rx, unsigned long ry1,
383 unsigned long subcode)
384{
385 register unsigned long _ry1 asm("2") = ry1;
386 register unsigned long _ry2 asm("3") = subcode;
387 int rc = 0;
388
389 asm volatile(
390#ifdef CONFIG_64BIT
391 " sam31\n"
392 " diag %2,2,0x14\n"
393 " sam64\n"
394#else
395 " diag %2,2,0x14\n"
396#endif
397 " ipm %0\n"
398 " srl %0,28\n"
399 : "=d" (rc), "+d" (_ry2)
400 : "d" (rx), "d" (_ry1)
401 : "cc");
402
403 TRACE("diag 14: subcode=0x%lx, cc=%i\n", subcode, rc);
404 return rc;
405}
406
407/* 427/*
408 * diagnose code 0x14 subcode 0x0028 - position spool file to designated 428 * diagnose code 0x14 subcode 0x0028 - position spool file to designated
409 * record 429 * record
@@ -415,7 +435,7 @@ static int diag_position_to_record(int devno, int record)
415{ 435{
416 int cc; 436 int cc;
417 437
418 cc = do_diag_14(record, devno, 0x28); 438 cc = diag14(record, devno, 0x28);
419 switch (cc) { 439 switch (cc) {
420 case 0: 440 case 0:
421 return 0; 441 return 0;
@@ -440,7 +460,7 @@ static int diag_read_file(int devno, char *buf)
440{ 460{
441 int cc; 461 int cc;
442 462
443 cc = do_diag_14((unsigned long) buf, devno, 0x00); 463 cc = diag14((unsigned long) buf, devno, 0x00);
444 switch (cc) { 464 switch (cc) {
445 case 0: 465 case 0:
446 return 0; 466 return 0;
@@ -533,7 +553,7 @@ static int diag_read_next_file_info(struct file_control_block *buf, int spid)
533{ 553{
534 int cc; 554 int cc;
535 555
536 cc = do_diag_14((unsigned long) buf, spid, 0xfff); 556 cc = diag14((unsigned long) buf, spid, 0xfff);
537 switch (cc) { 557 switch (cc) {
538 case 0: 558 case 0:
539 return 0; 559 return 0;
@@ -750,64 +770,63 @@ static struct file_operations ur_fops = {
750 770
751/* 771/*
752 * ccw_device infrastructure: 772 * ccw_device infrastructure:
753 * ur_probe gets its own ref to the device (i.e. get_device), 773 * ur_probe creates the struct urdev (with refcount = 1), the device
754 * creates the struct urdev, the device attributes, sets up 774 * attributes, sets up the interrupt handler and validates the virtual
755 * the interrupt handler and validates the virtual unit record device. 775 * unit record device.
756 * ur_remove removes the device attributes, frees the struct urdev 776 * ur_remove removes the device attributes and drops the reference to
757 * and drops (put_device) the ref to the device we got in ur_probe. 777 * struct urdev.
778 *
779 * ur_probe, ur_remove, ur_set_online and ur_set_offline are serialized
780 * by the vmur_mutex lock.
781 *
782 * urd->char_device is used as indication that the online function has
783 * been completed successfully.
758 */ 784 */
759static int ur_probe(struct ccw_device *cdev) 785static int ur_probe(struct ccw_device *cdev)
760{ 786{
761 struct urdev *urd; 787 struct urdev *urd;
762 int rc; 788 int rc;
763 789
764 TRACE("ur_probe: cdev=%p state=%d\n", cdev, *(int *) cdev->private); 790 TRACE("ur_probe: cdev=%p\n", cdev);
765
766 if (!get_device(&cdev->dev))
767 return -ENODEV;
768 791
792 mutex_lock(&vmur_mutex);
769 urd = urdev_alloc(cdev); 793 urd = urdev_alloc(cdev);
770 if (!urd) { 794 if (!urd) {
771 rc = -ENOMEM; 795 rc = -ENOMEM;
772 goto fail; 796 goto fail_unlock;
773 } 797 }
798
774 rc = ur_create_attributes(&cdev->dev); 799 rc = ur_create_attributes(&cdev->dev);
775 if (rc) { 800 if (rc) {
776 rc = -ENOMEM; 801 rc = -ENOMEM;
777 goto fail; 802 goto fail_urdev_put;
778 } 803 }
779 cdev->dev.driver_data = urd;
780 cdev->handler = ur_int_handler; 804 cdev->handler = ur_int_handler;
781 805
782 /* validate virtual unit record device */ 806 /* validate virtual unit record device */
783 urd->class = get_urd_class(urd); 807 urd->class = get_urd_class(urd);
784 if (urd->class < 0) { 808 if (urd->class < 0) {
785 rc = urd->class; 809 rc = urd->class;
786 goto fail; 810 goto fail_remove_attr;
787 } 811 }
788 if ((urd->class != DEV_CLASS_UR_I) && (urd->class != DEV_CLASS_UR_O)) { 812 if ((urd->class != DEV_CLASS_UR_I) && (urd->class != DEV_CLASS_UR_O)) {
789 rc = -ENOTSUPP; 813 rc = -ENOTSUPP;
790 goto fail; 814 goto fail_remove_attr;
791 } 815 }
816 spin_lock_irq(get_ccwdev_lock(cdev));
817 cdev->dev.driver_data = urd;
818 spin_unlock_irq(get_ccwdev_lock(cdev));
792 819
820 mutex_unlock(&vmur_mutex);
793 return 0; 821 return 0;
794 822
795fail: 823fail_remove_attr:
796 urdev_free(urd);
797 put_device(&cdev->dev);
798 return rc;
799}
800
801static void ur_remove(struct ccw_device *cdev)
802{
803 struct urdev *urd = cdev->dev.driver_data;
804
805 TRACE("ur_remove\n");
806 if (cdev->online)
807 ur_set_offline(cdev);
808 ur_remove_attributes(&cdev->dev); 824 ur_remove_attributes(&cdev->dev);
809 urdev_free(urd); 825fail_urdev_put:
810 put_device(&cdev->dev); 826 urdev_put(urd);
827fail_unlock:
828 mutex_unlock(&vmur_mutex);
829 return rc;
811} 830}
812 831
813static int ur_set_online(struct ccw_device *cdev) 832static int ur_set_online(struct ccw_device *cdev)
@@ -816,20 +835,29 @@ static int ur_set_online(struct ccw_device *cdev)
816 int minor, major, rc; 835 int minor, major, rc;
817 char node_id[16]; 836 char node_id[16];
818 837
819 TRACE("ur_set_online: cdev=%p state=%d\n", cdev, 838 TRACE("ur_set_online: cdev=%p\n", cdev);
820 *(int *) cdev->private);
821 839
822 if (!try_module_get(ur_driver.owner)) 840 mutex_lock(&vmur_mutex);
823 return -EINVAL; 841 urd = urdev_get_from_cdev(cdev);
842 if (!urd) {
843 /* ur_remove already deleted our urd */
844 rc = -ENODEV;
845 goto fail_unlock;
846 }
847
848 if (urd->char_device) {
849 /* Another ur_set_online was faster */
850 rc = -EBUSY;
851 goto fail_urdev_put;
852 }
824 853
825 urd = (struct urdev *) cdev->dev.driver_data;
826 minor = urd->dev_id.devno; 854 minor = urd->dev_id.devno;
827 major = MAJOR(ur_first_dev_maj_min); 855 major = MAJOR(ur_first_dev_maj_min);
828 856
829 urd->char_device = cdev_alloc(); 857 urd->char_device = cdev_alloc();
830 if (!urd->char_device) { 858 if (!urd->char_device) {
831 rc = -ENOMEM; 859 rc = -ENOMEM;
832 goto fail_module_put; 860 goto fail_urdev_put;
833 } 861 }
834 862
835 cdev_init(urd->char_device, &ur_fops); 863 cdev_init(urd->char_device, &ur_fops);
@@ -858,29 +886,79 @@ static int ur_set_online(struct ccw_device *cdev)
858 TRACE("ur_set_online: device_create rc=%d\n", rc); 886 TRACE("ur_set_online: device_create rc=%d\n", rc);
859 goto fail_free_cdev; 887 goto fail_free_cdev;
860 } 888 }
861 889 urdev_put(urd);
890 mutex_unlock(&vmur_mutex);
862 return 0; 891 return 0;
863 892
864fail_free_cdev: 893fail_free_cdev:
865 cdev_del(urd->char_device); 894 cdev_del(urd->char_device);
866fail_module_put: 895 urd->char_device = NULL;
867 module_put(ur_driver.owner); 896fail_urdev_put:
868 897 urdev_put(urd);
898fail_unlock:
899 mutex_unlock(&vmur_mutex);
869 return rc; 900 return rc;
870} 901}
871 902
872static int ur_set_offline(struct ccw_device *cdev) 903static int ur_set_offline_force(struct ccw_device *cdev, int force)
873{ 904{
874 struct urdev *urd; 905 struct urdev *urd;
906 int rc;
875 907
876 TRACE("ur_set_offline: cdev=%p cdev->private=%p state=%d\n", 908 TRACE("ur_set_offline: cdev=%p\n", cdev);
877 cdev, cdev->private, *(int *) cdev->private); 909 urd = urdev_get_from_cdev(cdev);
878 urd = (struct urdev *) cdev->dev.driver_data; 910 if (!urd)
911 /* ur_remove already deleted our urd */
912 return -ENODEV;
913 if (!urd->char_device) {
914 /* Another ur_set_offline was faster */
915 rc = -EBUSY;
916 goto fail_urdev_put;
917 }
918 if (!force && (atomic_read(&urd->ref_count) > 2)) {
919 /* There is still a user of urd (e.g. ur_open) */
920 TRACE("ur_set_offline: BUSY\n");
921 rc = -EBUSY;
922 goto fail_urdev_put;
923 }
879 device_destroy(vmur_class, urd->char_device->dev); 924 device_destroy(vmur_class, urd->char_device->dev);
880 cdev_del(urd->char_device); 925 cdev_del(urd->char_device);
881 module_put(ur_driver.owner); 926 urd->char_device = NULL;
927 rc = 0;
882 928
883 return 0; 929fail_urdev_put:
930 urdev_put(urd);
931 return rc;
932}
933
934static int ur_set_offline(struct ccw_device *cdev)
935{
936 int rc;
937
938 mutex_lock(&vmur_mutex);
939 rc = ur_set_offline_force(cdev, 0);
940 mutex_unlock(&vmur_mutex);
941 return rc;
942}
943
944static void ur_remove(struct ccw_device *cdev)
945{
946 unsigned long flags;
947
948 TRACE("ur_remove\n");
949
950 mutex_lock(&vmur_mutex);
951
952 if (cdev->online)
953 ur_set_offline_force(cdev, 1);
954 ur_remove_attributes(&cdev->dev);
955
956 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
957 urdev_put(cdev->dev.driver_data);
958 cdev->dev.driver_data = NULL;
959 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
960
961 mutex_unlock(&vmur_mutex);
884} 962}
885 963
886/* 964/*
diff --git a/drivers/s390/char/vmur.h b/drivers/s390/char/vmur.h
index 2b3c564e0472..fa959644735a 100644
--- a/drivers/s390/char/vmur.h
+++ b/drivers/s390/char/vmur.h
@@ -70,6 +70,7 @@ struct urdev {
70 size_t reclen; /* Record length for *write* CCWs */ 70 size_t reclen; /* Record length for *write* CCWs */
71 int class; /* VM device class */ 71 int class; /* VM device class */
72 int io_request_rc; /* return code from I/O request */ 72 int io_request_rc; /* return code from I/O request */
73 atomic_t ref_count; /* reference counter */
73}; 74};
74 75
75/* 76/*
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 02fd00b55e1b..34a796913b06 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -594,6 +594,9 @@ alloc_cmb (struct ccw_device *cdev)
594 free_pages((unsigned long)mem, get_order(size)); 594 free_pages((unsigned long)mem, get_order(size));
595 } else if (!mem) { 595 } else if (!mem) {
596 /* no luck */ 596 /* no luck */
597 printk(KERN_WARNING "cio: failed to allocate area "
598 "for measuring %d subchannels\n",
599 cmb_area.num_channels);
597 ret = -ENOMEM; 600 ret = -ENOMEM;
598 goto out; 601 goto out;
599 } else { 602 } else {
@@ -1279,13 +1282,6 @@ init_cmf(void)
1279 case CMF_BASIC: 1282 case CMF_BASIC:
1280 format_string = "basic"; 1283 format_string = "basic";
1281 cmbops = &cmbops_basic; 1284 cmbops = &cmbops_basic;
1282 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1283 printk(KERN_ERR "cio: Basic channel measurement "
1284 "facility can only use 1 to 4096 devices\n"
1285 KERN_ERR "when the cmf driver is built"
1286 " as a loadable module\n");
1287 return 1;
1288 }
1289 break; 1285 break;
1290 case CMF_EXTENDED: 1286 case CMF_EXTENDED:
1291 format_string = "extended"; 1287 format_string = "extended";
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 297659fa0e26..e44d92eac8e9 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -117,7 +117,10 @@ static int ccw_uevent(struct device *dev, char **envp, int num_envp,
117 snprint_alias(modalias_buf, sizeof(modalias_buf), id, ""); 117 snprint_alias(modalias_buf, sizeof(modalias_buf), id, "");
118 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 118 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
119 "MODALIAS=%s", modalias_buf); 119 "MODALIAS=%s", modalias_buf);
120 return ret; 120 if (ret)
121 return ret;
122 envp[i] = NULL;
123 return 0;
121} 124}
122 125
123struct bus_type ccw_bus_type; 126struct bus_type ccw_bus_type;
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index 60b9347f7c92..f232832f2b22 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -17,6 +17,7 @@
17#include <asm/delay.h> 17#include <asm/delay.h>
18#include <asm/cio.h> 18#include <asm/cio.h>
19#include <asm/lowcore.h> 19#include <asm/lowcore.h>
20#include <asm/diag.h>
20 21
21#include "cio.h" 22#include "cio.h"
22#include "cio_debug.h" 23#include "cio_debug.h"
@@ -25,51 +26,6 @@
25#include "ioasm.h" 26#include "ioasm.h"
26 27
27/* 28/*
28 * diag210 is used under VM to get information about a virtual device
29 */
30int
31diag210(struct diag210 * addr)
32{
33 /*
34 * diag 210 needs its data below the 2GB border, so we
35 * use a static data area to be sure
36 */
37 static struct diag210 diag210_tmp;
38 static DEFINE_SPINLOCK(diag210_lock);
39 unsigned long flags;
40 int ccode;
41
42 spin_lock_irqsave(&diag210_lock, flags);
43 diag210_tmp = *addr;
44
45#ifdef CONFIG_64BIT
46 asm volatile(
47 " lhi %0,-1\n"
48 " sam31\n"
49 " diag %1,0,0x210\n"
50 "0: ipm %0\n"
51 " srl %0,28\n"
52 "1: sam64\n"
53 EX_TABLE(0b,1b)
54 : "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
55#else
56 asm volatile(
57 " lhi %0,-1\n"
58 " diag %1,0,0x210\n"
59 "0: ipm %0\n"
60 " srl %0,28\n"
61 "1:\n"
62 EX_TABLE(0b,1b)
63 : "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
64#endif
65
66 *addr = diag210_tmp;
67 spin_unlock_irqrestore(&diag210_lock, flags);
68
69 return ccode;
70}
71
72/*
73 * Input : 29 * Input :
74 * devno - device number 30 * devno - device number
75 * ps - pointer to sense ID data area 31 * ps - pointer to sense ID data area
@@ -349,5 +305,3 @@ ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event)
349 break; 305 break;
350 } 306 }
351} 307}
352
353EXPORT_SYMBOL(diag210);
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 03347aed2b3e..d8d479876ec7 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -195,6 +195,8 @@ qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
195again: 195again:
196 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt); 196 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt);
197 rc = qdio_check_ccq(q, ccq); 197 rc = qdio_check_ccq(q, ccq);
198 if ((ccq == 96) && (tmp_cnt != *cnt))
199 rc = 0;
198 if (rc == 1) { 200 if (rc == 1) {
199 QDIO_DBF_TEXT5(1,trace,"eqAGAIN"); 201 QDIO_DBF_TEXT5(1,trace,"eqAGAIN");
200 goto again; 202 goto again;
@@ -740,7 +742,8 @@ qdio_get_outbound_buffer_frontier(struct qdio_q *q)
740 first_not_to_check=f+qdio_min(atomic_read(&q->number_of_buffers_used), 742 first_not_to_check=f+qdio_min(atomic_read(&q->number_of_buffers_used),
741 (QDIO_MAX_BUFFERS_PER_Q-1)); 743 (QDIO_MAX_BUFFERS_PER_Q-1));
742 744
743 if ((!q->is_iqdio_q)&&(!q->hydra_gives_outbound_pcis)) 745 if (((!q->is_iqdio_q) && (!q->hydra_gives_outbound_pcis)) ||
746 (q->queue_type == QDIO_IQDIO_QFMT_ASYNCH))
744 SYNC_MEMORY; 747 SYNC_MEMORY;
745 748
746check_next: 749check_next:
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c4e15ed1405a..35cdba10411b 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -275,58 +275,6 @@ static void ehci_work(struct ehci_hcd *ehci);
275 275
276/*-------------------------------------------------------------------------*/ 276/*-------------------------------------------------------------------------*/
277 277
278#ifdef CONFIG_CPU_FREQ
279
280#include <linux/cpufreq.h>
281
282static void ehci_cpufreq_pause (struct ehci_hcd *ehci)
283{
284 unsigned long flags;
285
286 spin_lock_irqsave(&ehci->lock, flags);
287 if (!ehci->cpufreq_changing++)
288 qh_inactivate_split_intr_qhs(ehci);
289 spin_unlock_irqrestore(&ehci->lock, flags);
290}
291
292static void ehci_cpufreq_unpause (struct ehci_hcd *ehci)
293{
294 unsigned long flags;
295
296 spin_lock_irqsave(&ehci->lock, flags);
297 if (!--ehci->cpufreq_changing)
298 qh_reactivate_split_intr_qhs(ehci);
299 spin_unlock_irqrestore(&ehci->lock, flags);
300}
301
302/*
303 * ehci_cpufreq_notifier is needed to avoid MMF errors that occur when
304 * EHCI controllers that don't cache many uframes get delayed trying to
305 * read main memory during CPU frequency transitions. This can cause
306 * split interrupt transactions to not be completed in the required uframe.
307 * This has been observed on the Broadcom/ServerWorks HT1000 controller.
308 */
309static int ehci_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
310 void *data)
311{
312 struct ehci_hcd *ehci = container_of(nb, struct ehci_hcd,
313 cpufreq_transition);
314
315 switch (val) {
316 case CPUFREQ_PRECHANGE:
317 ehci_cpufreq_pause(ehci);
318 break;
319 case CPUFREQ_POSTCHANGE:
320 ehci_cpufreq_unpause(ehci);
321 break;
322 }
323 return 0;
324}
325
326#endif
327
328/*-------------------------------------------------------------------------*/
329
330static void ehci_watchdog (unsigned long param) 278static void ehci_watchdog (unsigned long param)
331{ 279{
332 struct ehci_hcd *ehci = (struct ehci_hcd *) param; 280 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
@@ -460,10 +408,6 @@ static void ehci_stop (struct usb_hcd *hcd)
460 ehci_writel(ehci, 0, &ehci->regs->intr_enable); 408 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
461 spin_unlock_irq(&ehci->lock); 409 spin_unlock_irq(&ehci->lock);
462 410
463#ifdef CONFIG_CPU_FREQ
464 cpufreq_unregister_notifier(&ehci->cpufreq_transition,
465 CPUFREQ_TRANSITION_NOTIFIER);
466#endif
467 /* let companion controllers work when we aren't */ 411 /* let companion controllers work when we aren't */
468 ehci_writel(ehci, 0, &ehci->regs->configured_flag); 412 ehci_writel(ehci, 0, &ehci->regs->configured_flag);
469 413
@@ -569,17 +513,6 @@ static int ehci_init(struct usb_hcd *hcd)
569 } 513 }
570 ehci->command = temp; 514 ehci->command = temp;
571 515
572#ifdef CONFIG_CPU_FREQ
573 INIT_LIST_HEAD(&ehci->split_intr_qhs);
574 /*
575 * If the EHCI controller caches enough uframes, this probably
576 * isn't needed unless there are so many low/full speed devices
577 * that the controller's can't cache it all.
578 */
579 ehci->cpufreq_transition.notifier_call = ehci_cpufreq_notifier;
580 cpufreq_register_notifier(&ehci->cpufreq_transition,
581 CPUFREQ_TRANSITION_NOTIFIER);
582#endif
583 return 0; 516 return 0;
584} 517}
585 518
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index 8816d09903d0..0431397836f6 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -94,9 +94,6 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags)
94 qh->qh_dma = dma; 94 qh->qh_dma = dma;
95 // INIT_LIST_HEAD (&qh->qh_list); 95 // INIT_LIST_HEAD (&qh->qh_list);
96 INIT_LIST_HEAD (&qh->qtd_list); 96 INIT_LIST_HEAD (&qh->qtd_list);
97#ifdef CONFIG_CPU_FREQ
98 INIT_LIST_HEAD (&qh->split_intr_qhs);
99#endif
100 97
101 /* dummy td enables safe urb queuing */ 98 /* dummy td enables safe urb queuing */
102 qh->dummy = ehci_qtd_alloc (ehci, flags); 99 qh->dummy = ehci_qtd_alloc (ehci, flags);
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 2284028f8aa5..140bfa423e07 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -312,10 +312,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
312 struct urb *urb; 312 struct urb *urb;
313 u32 token = 0; 313 u32 token = 0;
314 314
315 /* ignore QHs that are currently inactive */
316 if (qh->hw_info1 & __constant_cpu_to_le32(QH_INACTIVATE))
317 break;
318
319 qtd = list_entry (entry, struct ehci_qtd, qtd_list); 315 qtd = list_entry (entry, struct ehci_qtd, qtd_list);
320 urb = qtd->urb; 316 urb = qtd->urb;
321 317
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index d4a8ace49676..e682f2342ef8 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -479,109 +479,6 @@ static int disable_periodic (struct ehci_hcd *ehci)
479} 479}
480 480
481/*-------------------------------------------------------------------------*/ 481/*-------------------------------------------------------------------------*/
482#ifdef CONFIG_CPU_FREQ
483
484static int safe_to_modify_i (struct ehci_hcd *ehci, struct ehci_qh *qh)
485{
486 int now; /* current (frame * 8) + uframe */
487 int prev_start, next_start; /* uframes from/to split start */
488 int start_uframe = ffs(le32_to_cpup (&qh->hw_info2) & QH_SMASK);
489 int end_uframe = fls((le32_to_cpup (&qh->hw_info2) & QH_CMASK) >> 8);
490 int split_duration = end_uframe - start_uframe;
491
492 now = readl(&ehci->regs->frame_index) % (ehci->periodic_size << 3);
493
494 next_start = ((1024 << 3) + (qh->start << 3) + start_uframe - now)
495 % (qh->period << 3);
496 prev_start = (qh->period << 3) - next_start;
497
498 /*
499 * Make sure there will be at least one uframe when qh is safe.
500 */
501 if ((qh->period << 3) <= (ehci->i_thresh + 2 + split_duration))
502 /* never safe */
503 return -EINVAL;
504
505 /*
506 * Wait 1 uframe after transaction should have started, to make
507 * sure controller has time to write back overlay, so we can
508 * check QTD_STS_STS to see if transaction is in progress.
509 */
510 if ((next_start > ehci->i_thresh) && (prev_start > 1))
511 /* safe to set "i" bit if split isn't in progress */
512 return (qh->hw_token & STATUS_BIT(ehci)) ? 0 : 1;
513 else
514 return 0;
515}
516
517/* Set inactivate bit for all the split interrupt QHs. */
518static void qh_inactivate_split_intr_qhs (struct ehci_hcd *ehci)
519{
520 struct ehci_qh *qh;
521 int not_done, safe;
522 u32 inactivate = INACTIVATE_BIT(ehci);
523 u32 active = ACTIVE_BIT(ehci);
524
525 do {
526 not_done = 0;
527 list_for_each_entry(qh, &ehci->split_intr_qhs,
528 split_intr_qhs) {
529 if (qh->hw_info1 & inactivate)
530 /* already off */
531 continue;
532 /*
533 * To avoid setting "I" after the start split happens,
534 * don't set it if the QH might be cached in the
535 * controller. Some HCs (Broadcom/ServerWorks HT1000)
536 * will stop in the middle of a split transaction when
537 * the "I" bit is set.
538 */
539 safe = safe_to_modify_i(ehci, qh);
540 if (safe == 0) {
541 not_done = 1;
542 } else if (safe > 0) {
543 qh->was_active = qh->hw_token & active;
544 qh->hw_info1 |= inactivate;
545 }
546 }
547 } while (not_done);
548 wmb();
549}
550
551static void qh_reactivate_split_intr_qhs (struct ehci_hcd *ehci)
552{
553 struct ehci_qh *qh;
554 u32 token;
555 int not_done, safe;
556 u32 inactivate = INACTIVATE_BIT(ehci);
557 u32 active = ACTIVE_BIT(ehci);
558 u32 halt = HALT_BIT(ehci);
559
560 do {
561 not_done = 0;
562 list_for_each_entry(qh, &ehci->split_intr_qhs, split_intr_qhs) {
563 if (!(qh->hw_info1 & inactivate)) /* already on */
564 continue;
565 /*
566 * Don't reactivate if cached, or controller might
567 * overwrite overlay after we modify it!
568 */
569 safe = safe_to_modify_i(ehci, qh);
570 if (safe == 0) {
571 not_done = 1;
572 } else if (safe > 0) {
573 /* See EHCI 1.0 section 4.15.2.4. */
574 token = qh->hw_token;
575 qh->hw_token = (token | halt) & ~active;
576 wmb();
577 qh->hw_info1 &= ~inactivate;
578 wmb();
579 qh->hw_token = (token & ~halt) | qh->was_active;
580 }
581 }
582 } while (not_done);
583}
584#endif
585 482
586/* periodic schedule slots have iso tds (normal or split) first, then a 483/* periodic schedule slots have iso tds (normal or split) first, then a
587 * sparse tree for active interrupt transfers. 484 * sparse tree for active interrupt transfers.
@@ -599,17 +496,6 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
599 period, hc32_to_cpup(ehci, &qh->hw_info2) & (QH_CMASK | QH_SMASK), 496 period, hc32_to_cpup(ehci, &qh->hw_info2) & (QH_CMASK | QH_SMASK),
600 qh, qh->start, qh->usecs, qh->c_usecs); 497 qh, qh->start, qh->usecs, qh->c_usecs);
601 498
602#ifdef CONFIG_CPU_FREQ
603 /*
604 * If low/full speed interrupt QHs are inactive (because of
605 * cpufreq changing processor speeds), start QH with I flag set--
606 * it will automatically be cleared when cpufreq is done.
607 */
608 if (ehci->cpufreq_changing)
609 if (!(qh->hw_info1 & (cpu_to_le32(1 << 13))))
610 qh->hw_info1 |= INACTIVATE_BIT(ehci);
611#endif
612
613 /* high bandwidth, or otherwise every microframe */ 499 /* high bandwidth, or otherwise every microframe */
614 if (period == 0) 500 if (period == 0)
615 period = 1; 501 period = 1;
@@ -658,12 +544,6 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
658 ? ((qh->usecs + qh->c_usecs) / qh->period) 544 ? ((qh->usecs + qh->c_usecs) / qh->period)
659 : (qh->usecs * 8); 545 : (qh->usecs * 8);
660 546
661#ifdef CONFIG_CPU_FREQ
662 /* add qh to list of low/full speed interrupt QHs, if applicable */
663 if (!(qh->hw_info1 & (cpu_to_le32(1 << 13)))) {
664 list_add(&qh->split_intr_qhs, &ehci->split_intr_qhs);
665 }
666#endif
667 /* maybe enable periodic schedule processing */ 547 /* maybe enable periodic schedule processing */
668 if (!ehci->periodic_sched++) 548 if (!ehci->periodic_sched++)
669 return enable_periodic (ehci); 549 return enable_periodic (ehci);
@@ -683,13 +563,6 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
683 // THEN 563 // THEN
684 // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */); 564 // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */);
685 565
686#ifdef CONFIG_CPU_FREQ
687 /* remove qh from list of low/full speed interrupt QHs */
688 if (!(qh->hw_info1 & (cpu_to_le32(1 << 13)))) {
689 list_del_init(&qh->split_intr_qhs);
690 }
691#endif
692
693 /* high bandwidth, or otherwise part of every microframe */ 566 /* high bandwidth, or otherwise part of every microframe */
694 if ((period = qh->period) == 0) 567 if ((period = qh->period) == 0)
695 period = 1; 568 period = 1;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 2c68a04230c1..951d69fec513 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -71,12 +71,6 @@ struct ehci_hcd { /* one per controller */
71 __u32 hcs_params; /* cached register copy */ 71 __u32 hcs_params; /* cached register copy */
72 spinlock_t lock; 72 spinlock_t lock;
73 73
74#ifdef CONFIG_CPU_FREQ
75 struct notifier_block cpufreq_transition;
76 int cpufreq_changing;
77 struct list_head split_intr_qhs;
78#endif
79
80 /* async schedule support */ 74 /* async schedule support */
81 struct ehci_qh *async; 75 struct ehci_qh *async;
82 struct ehci_qh *reclaim; 76 struct ehci_qh *reclaim;
@@ -439,10 +433,6 @@ struct ehci_qh {
439 __hc32 hw_next; /* see EHCI 3.6.1 */ 433 __hc32 hw_next; /* see EHCI 3.6.1 */
440 __hc32 hw_info1; /* see EHCI 3.6.2 */ 434 __hc32 hw_info1; /* see EHCI 3.6.2 */
441#define QH_HEAD 0x00008000 435#define QH_HEAD 0x00008000
442#define QH_INACTIVATE 0x00000080
443
444#define INACTIVATE_BIT(ehci) cpu_to_hc32(ehci, QH_INACTIVATE)
445
446 __hc32 hw_info2; /* see EHCI 3.6.2 */ 436 __hc32 hw_info2; /* see EHCI 3.6.2 */
447#define QH_SMASK 0x000000ff 437#define QH_SMASK 0x000000ff
448#define QH_CMASK 0x0000ff00 438#define QH_CMASK 0x0000ff00
@@ -492,10 +482,6 @@ struct ehci_qh {
492 unsigned short start; /* where polling starts */ 482 unsigned short start; /* where polling starts */
493#define NO_FRAME ((unsigned short)~0) /* pick new start */ 483#define NO_FRAME ((unsigned short)~0) /* pick new start */
494 struct usb_device *dev; /* access to TT */ 484 struct usb_device *dev; /* access to TT */
495#ifdef CONFIG_CPU_FREQ
496 struct list_head split_intr_qhs; /* list of split qhs */
497 __le32 was_active; /* active bit before "i" set */
498#endif
499} __attribute__ ((aligned (32))); 485} __attribute__ ((aligned (32)));
500 486
501/*-------------------------------------------------------------------------*/ 487/*-------------------------------------------------------------------------*/
diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h
index ea486952f778..2d184655bc5d 100644
--- a/include/asm-s390/atomic.h
+++ b/include/asm-s390/atomic.h
@@ -67,8 +67,17 @@ typedef struct {
67 67
68#endif /* __GNUC__ */ 68#endif /* __GNUC__ */
69 69
70#define atomic_read(v) ((v)->counter) 70static inline int atomic_read(const atomic_t *v)
71#define atomic_set(v,i) (((v)->counter) = (i)) 71{
72 barrier();
73 return v->counter;
74}
75
76static inline void atomic_set(atomic_t *v, int i)
77{
78 v->counter = i;
79 barrier();
80}
72 81
73static __inline__ int atomic_add_return(int i, atomic_t * v) 82static __inline__ int atomic_add_return(int i, atomic_t * v)
74{ 83{
@@ -182,8 +191,17 @@ typedef struct {
182 191
183#endif /* __GNUC__ */ 192#endif /* __GNUC__ */
184 193
185#define atomic64_read(v) ((v)->counter) 194static inline long long atomic64_read(const atomic64_t *v)
186#define atomic64_set(v,i) (((v)->counter) = (i)) 195{
196 barrier();
197 return v->counter;
198}
199
200static inline void atomic64_set(atomic64_t *v, long long i)
201{
202 v->counter = i;
203 barrier();
204}
187 205
188static __inline__ long long atomic64_add_return(long long i, atomic64_t * v) 206static __inline__ long long atomic64_add_return(long long i, atomic64_t * v)
189{ 207{
diff --git a/include/asm-s390/cio.h b/include/asm-s390/cio.h
index f738d2827582..1982fb344164 100644
--- a/include/asm-s390/cio.h
+++ b/include/asm-s390/cio.h
@@ -258,19 +258,6 @@ struct ciw {
258/* Sick revalidation of device. */ 258/* Sick revalidation of device. */
259#define CIO_REVALIDATE 0x0008 259#define CIO_REVALIDATE 0x0008
260 260
261struct diag210 {
262 __u16 vrdcdvno : 16; /* device number (input) */
263 __u16 vrdclen : 16; /* data block length (input) */
264 __u32 vrdcvcla : 8; /* virtual device class (output) */
265 __u32 vrdcvtyp : 8; /* virtual device type (output) */
266 __u32 vrdcvsta : 8; /* virtual device status (output) */
267 __u32 vrdcvfla : 8; /* virtual device flags (output) */
268 __u32 vrdcrccl : 8; /* real device class (output) */
269 __u32 vrdccrty : 8; /* real device type (output) */
270 __u32 vrdccrmd : 8; /* real device model (output) */
271 __u32 vrdccrft : 8; /* real device feature (output) */
272} __attribute__ ((packed,aligned(4)));
273
274struct ccw_dev_id { 261struct ccw_dev_id {
275 u8 ssid; 262 u8 ssid;
276 u16 devno; 263 u16 devno;
@@ -285,8 +272,6 @@ static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
285 return 0; 272 return 0;
286} 273}
287 274
288extern int diag210(struct diag210 *addr);
289
290extern void wait_cons_dev(void); 275extern void wait_cons_dev(void);
291 276
292extern void css_schedule_reprobe(void); 277extern void css_schedule_reprobe(void);
diff --git a/include/asm-s390/diag.h b/include/asm-s390/diag.h
new file mode 100644
index 000000000000..72b2e2f2d32d
--- /dev/null
+++ b/include/asm-s390/diag.h
@@ -0,0 +1,39 @@
1/*
2 * s390 diagnose functions
3 *
4 * Copyright IBM Corp. 2007
5 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
6 */
7
8#ifndef _ASM_S390_DIAG_H
9#define _ASM_S390_DIAG_H
10
11/*
12 * Diagnose 10: Release pages
13 */
14extern void diag10(unsigned long addr);
15
16/*
17 * Diagnose 14: Input spool file manipulation
18 */
19extern int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode);
20
21/*
22 * Diagnose 210: Get information about a virtual device
23 */
24struct diag210 {
25 u16 vrdcdvno; /* device number (input) */
26 u16 vrdclen; /* data block length (input) */
27 u8 vrdcvcla; /* virtual device class (output) */
28 u8 vrdcvtyp; /* virtual device type (output) */
29 u8 vrdcvsta; /* virtual device status (output) */
30 u8 vrdcvfla; /* virtual device flags (output) */
31 u8 vrdcrccl; /* real device class (output) */
32 u8 vrdccrty; /* real device type (output) */
33 u8 vrdccrmd; /* real device model (output) */
34 u8 vrdccrft; /* real device feature (output) */
35} __attribute__((packed, aligned(4)));
36
37extern int diag210(struct diag210 *addr);
38
39#endif /* _ASM_S390_DIAG_H */
diff --git a/include/asm-s390/pgalloc.h b/include/asm-s390/pgalloc.h
index 56c8a6c80e2e..e45d3c9a4b7e 100644
--- a/include/asm-s390/pgalloc.h
+++ b/include/asm-s390/pgalloc.h
@@ -19,8 +19,6 @@
19 19
20#define check_pgt_cache() do {} while (0) 20#define check_pgt_cache() do {} while (0)
21 21
22extern void diag10(unsigned long addr);
23
24/* 22/*
25 * Page allocation orders. 23 * Page allocation orders.
26 */ 24 */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 07fc57429b58..8938d59013c6 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2092,8 +2092,10 @@
2092#define PCI_DEVICE_ID_MPC8568 0x0021 2092#define PCI_DEVICE_ID_MPC8568 0x0021
2093#define PCI_DEVICE_ID_MPC8567E 0x0022 2093#define PCI_DEVICE_ID_MPC8567E 0x0022
2094#define PCI_DEVICE_ID_MPC8567 0x0023 2094#define PCI_DEVICE_ID_MPC8567 0x0023
2095#define PCI_DEVICE_ID_MPC8544E 0x0030 2095#define PCI_DEVICE_ID_MPC8533E 0x0030
2096#define PCI_DEVICE_ID_MPC8544 0x0031 2096#define PCI_DEVICE_ID_MPC8533 0x0031
2097#define PCI_DEVICE_ID_MPC8544E 0x0032
2098#define PCI_DEVICE_ID_MPC8544 0x0033
2097#define PCI_DEVICE_ID_MPC8641 0x7010 2099#define PCI_DEVICE_ID_MPC8641 0x7010
2098#define PCI_DEVICE_ID_MPC8641D 0x7011 2100#define PCI_DEVICE_ID_MPC8641D 0x7011
2099 2101
diff --git a/kernel/printk.c b/kernel/printk.c
index 5c7c325b29cc..8451dfc31d25 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1085,10 +1085,12 @@ EXPORT_SYMBOL(unregister_console);
1085 1085
1086static int __init disable_boot_consoles(void) 1086static int __init disable_boot_consoles(void)
1087{ 1087{
1088 if (console_drivers->flags & CON_BOOT) { 1088 if (console_drivers != NULL) {
1089 printk(KERN_INFO "turn off boot console %s%d\n", 1089 if (console_drivers->flags & CON_BOOT) {
1090 console_drivers->name, console_drivers->index); 1090 printk(KERN_INFO "turn off boot console %s%d\n",
1091 return unregister_console(console_drivers); 1091 console_drivers->name, console_drivers->index);
1092 return unregister_console(console_drivers);
1093 }
1092 } 1094 }
1093 return 0; 1095 return 0;
1094} 1096}
diff --git a/net/802/psnap.c b/net/802/psnap.c
index 04ee43e7538f..31128cb92a23 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -55,6 +55,9 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
55 .type = __constant_htons(ETH_P_SNAP), 55 .type = __constant_htons(ETH_P_SNAP),
56 }; 56 };
57 57
58 if (unlikely(!pskb_may_pull(skb, 5)))
59 goto drop;
60
58 rcu_read_lock(); 61 rcu_read_lock();
59 proto = find_snap_client(skb_transport_header(skb)); 62 proto = find_snap_client(skb_transport_header(skb));
60 if (proto) { 63 if (proto) {
@@ -62,14 +65,18 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
62 skb->transport_header += 5; 65 skb->transport_header += 5;
63 skb_pull_rcsum(skb, 5); 66 skb_pull_rcsum(skb, 5);
64 rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev); 67 rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev);
65 } else {
66 skb->sk = NULL;
67 kfree_skb(skb);
68 rc = 1;
69 } 68 }
70
71 rcu_read_unlock(); 69 rcu_read_unlock();
70
71 if (unlikely(!proto))
72 goto drop;
73
74out:
72 return rc; 75 return rc;
76
77drop:
78 kfree_skb(skb);
79 goto out;
73} 80}
74 81
75/* 82/*
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index 248d20f4c7c4..d29b88fe723c 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -298,7 +298,7 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
298 int rc; 298 int rc;
299 299
300 ccid2_pr_debug("allocating more space in history\n"); 300 ccid2_pr_debug("allocating more space in history\n");
301 rc = ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, GFP_KERNEL); 301 rc = ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, gfp_any());
302 BUG_ON(rc); /* XXX what do we do? */ 302 BUG_ON(rc); /* XXX what do we do? */
303 303
304 next = hctx->ccid2hctx_seqh->ccid2s_next; 304 next = hctx->ccid2hctx_seqh->ccid2s_next;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 50d86e94d9ed..5dead399fe64 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -794,7 +794,7 @@ slow_path:
794 /* 794 /*
795 * Copy a block of the IP datagram. 795 * Copy a block of the IP datagram.
796 */ 796 */
797 if (skb_copy_bits(skb, ptr, skb_transport_header(skb), len)) 797 if (skb_copy_bits(skb, ptr, skb_transport_header(frag), len))
798 BUG(); 798 BUG();
799 left -= len; 799 left -= len;
800 800
diff --git a/net/irda/irmod.c b/net/irda/irmod.c
index 1900937b3328..8ba703da2797 100644
--- a/net/irda/irmod.c
+++ b/net/irda/irmod.c
@@ -128,8 +128,8 @@ static int __init irda_init(void)
128 out_err_3: 128 out_err_3:
129#ifdef CONFIG_SYSCTL 129#ifdef CONFIG_SYSCTL
130 irda_sysctl_unregister(); 130 irda_sysctl_unregister();
131#endif
132 out_err_2: 131 out_err_2:
132#endif
133#ifdef CONFIG_PROC_FS 133#ifdef CONFIG_PROC_FS
134 irda_proc_unregister(); 134 irda_proc_unregister();
135#endif 135#endif
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c
index 694ea4d92fa8..1e429c929739 100644
--- a/net/irda/irnetlink.c
+++ b/net/irda/irnetlink.c
@@ -106,7 +106,7 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info)
106 } 106 }
107 107
108 if(nla_put_string(msg, IRDA_NL_ATTR_IFNAME, 108 if(nla_put_string(msg, IRDA_NL_ATTR_IFNAME,
109 dev->name)); 109 dev->name))
110 goto err_out; 110 goto err_out;
111 111
112 if(nla_put_u32(msg, IRDA_NL_ATTR_MODE, irlap->mode)) 112 if(nla_put_u32(msg, IRDA_NL_ATTR_MODE, irlap->mode))