diff options
321 files changed, 10508 insertions, 2927 deletions
diff --git a/Documentation/cgroups.txt b/Documentation/cgroups.txt index c298a6690e0d..824fc0274471 100644 --- a/Documentation/cgroups.txt +++ b/Documentation/cgroups.txt | |||
@@ -310,8 +310,8 @@ and then start a subshell 'sh' in that cgroup: | |||
310 | cd /dev/cgroup | 310 | cd /dev/cgroup |
311 | mkdir Charlie | 311 | mkdir Charlie |
312 | cd Charlie | 312 | cd Charlie |
313 | /bin/echo 2-3 > cpus | 313 | /bin/echo 2-3 > cpuset.cpus |
314 | /bin/echo 1 > mems | 314 | /bin/echo 1 > cpuset.mems |
315 | /bin/echo $$ > tasks | 315 | /bin/echo $$ > tasks |
316 | sh | 316 | sh |
317 | # The subshell 'sh' is now running in cgroup Charlie | 317 | # The subshell 'sh' is now running in cgroup Charlie |
diff --git a/Documentation/hwmon/adt7473 b/Documentation/hwmon/adt7473 index 22d8b19046ab..2126de34c711 100644 --- a/Documentation/hwmon/adt7473 +++ b/Documentation/hwmon/adt7473 | |||
@@ -69,7 +69,8 @@ point2: Set the pwm speed at a higher temperature bound. | |||
69 | 69 | ||
70 | The ADT7473 will scale the pwm between the lower and higher pwm speed when | 70 | The ADT7473 will scale the pwm between the lower and higher pwm speed when |
71 | the temperature is between the two temperature boundaries. PWM values range | 71 | the temperature is between the two temperature boundaries. PWM values range |
72 | from 0 (off) to 255 (full speed). | 72 | from 0 (off) to 255 (full speed). Fan speed will be set to maximum when the |
73 | temperature sensor associated with the PWM control exceeds temp#_max. | ||
73 | 74 | ||
74 | Notes | 75 | Notes |
75 | ----- | 76 | ----- |
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index e5a819a4f0c9..f5b7127f54ac 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt | |||
@@ -994,7 +994,17 @@ The Linux kernel has eight basic CPU memory barriers: | |||
994 | DATA DEPENDENCY read_barrier_depends() smp_read_barrier_depends() | 994 | DATA DEPENDENCY read_barrier_depends() smp_read_barrier_depends() |
995 | 995 | ||
996 | 996 | ||
997 | All CPU memory barriers unconditionally imply compiler barriers. | 997 | All memory barriers except the data dependency barriers imply a compiler |
998 | barrier. Data dependencies do not impose any additional compiler ordering. | ||
999 | |||
1000 | Aside: In the case of data dependencies, the compiler would be expected to | ||
1001 | issue the loads in the correct order (eg. `a[b]` would have to load the value | ||
1002 | of b before loading a[b]), however there is no guarantee in the C specification | ||
1003 | that the compiler may not speculate the value of b (eg. is equal to 1) and load | ||
1004 | a before b (eg. tmp = a[1]; if (b != 1) tmp = a[b]; ). There is also the | ||
1005 | problem of a compiler reloading b after having loaded a[b], thus having a newer | ||
1006 | copy of b than a[b]. A consensus has not yet been reached about these problems, | ||
1007 | however the ACCESS_ONCE macro is a good place to start looking. | ||
998 | 1008 | ||
999 | SMP memory barriers are reduced to compiler barriers on uniprocessor compiled | 1009 | SMP memory barriers are reduced to compiler barriers on uniprocessor compiled |
1000 | systems because it is assumed that a CPU will appear to be self-consistent, | 1010 | systems because it is assumed that a CPU will appear to be self-consistent, |
diff --git a/Documentation/video4linux/CARDLIST.cx23885 b/Documentation/video4linux/CARDLIST.cx23885 index 929b90c8387f..191194ea1e25 100644 --- a/Documentation/video4linux/CARDLIST.cx23885 +++ b/Documentation/video4linux/CARDLIST.cx23885 | |||
@@ -5,6 +5,6 @@ | |||
5 | 4 -> DViCO FusionHDTV5 Express [18ac:d500] | 5 | 4 -> DViCO FusionHDTV5 Express [18ac:d500] |
6 | 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797] | 6 | 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797] |
7 | 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717] | 7 | 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717] |
8 | 7 -> Hauppauge WinTV-HVR1200 [0070:71d1] | 8 | 7 -> Hauppauge WinTV-HVR1200 [0070:71d1,0070:71d3] |
9 | 8 -> Hauppauge WinTV-HVR1700 [0070:8101] | 9 | 8 -> Hauppauge WinTV-HVR1700 [0070:8101] |
10 | 9 -> Hauppauge WinTV-HVR1400 [0070:8010] | 10 | 9 -> Hauppauge WinTV-HVR1400 [0070:8010] |
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx index f40e09296f30..1d6a245c828f 100644 --- a/Documentation/video4linux/CARDLIST.em28xx +++ b/Documentation/video4linux/CARDLIST.em28xx | |||
@@ -14,4 +14,4 @@ | |||
14 | 13 -> Terratec Prodigy XS (em2880) [0ccd:0047] | 14 | 13 -> Terratec Prodigy XS (em2880) [0ccd:0047] |
15 | 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840) | 15 | 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840) |
16 | 15 -> V-Gear PocketTV (em2800) | 16 | 15 -> V-Gear PocketTV (em2800) |
17 | 16 -> Hauppauge WinTV HVR 950 (em2880) [2040:6513] | 17 | 16 -> Hauppauge WinTV HVR 950 (em2880) [2040:6513,2040:6517,2040:651b,2040:651f] |
diff --git a/MAINTAINERS b/MAINTAINERS index f5583dc7ea39..bc1c0088dc49 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -367,12 +367,12 @@ S: Maintained for 2.4; PCI support for 2.6. | |||
367 | AMD GEODE CS5536 USB DEVICE CONTROLLER DRIVER | 367 | AMD GEODE CS5536 USB DEVICE CONTROLLER DRIVER |
368 | P: Thomas Dahlmann | 368 | P: Thomas Dahlmann |
369 | M: thomas.dahlmann@amd.com | 369 | M: thomas.dahlmann@amd.com |
370 | L: info-linux@geode.amd.com (subscribers-only) | 370 | L: linux-geode@lists.infradead.org (moderated for non-subscribers) |
371 | S: Supported | 371 | S: Supported |
372 | 372 | ||
373 | AMD GEODE PROCESSOR/CHIPSET SUPPORT | 373 | AMD GEODE PROCESSOR/CHIPSET SUPPORT |
374 | P: Jordan Crouse | 374 | P: Jordan Crouse |
375 | L: info-linux@geode.amd.com (subscribers-only) | 375 | L: linux-geode@lists.infradead.org (moderated for non-subscribers) |
376 | W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html | 376 | W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html |
377 | S: Supported | 377 | S: Supported |
378 | 378 | ||
@@ -1230,6 +1230,15 @@ P: Jaya Kumar | |||
1230 | M: jayakumar.alsa@gmail.com | 1230 | M: jayakumar.alsa@gmail.com |
1231 | S: Maintained | 1231 | S: Maintained |
1232 | 1232 | ||
1233 | CX18 VIDEO4LINUX DRIVER | ||
1234 | P: Hans Verkuil, Andy Walls | ||
1235 | M: hverkuil@xs4all.nl, awalls@radix.net | ||
1236 | L: ivtv-devel@ivtvdriver.org | ||
1237 | L: ivtv-users@ivtvdriver.org | ||
1238 | L: video4linux-list@redhat.com | ||
1239 | W: http://linuxtv.org | ||
1240 | S: Maintained | ||
1241 | |||
1233 | CYBERPRO FB DRIVER | 1242 | CYBERPRO FB DRIVER |
1234 | P: Russell King | 1243 | P: Russell King |
1235 | M: rmk@arm.linux.org.uk | 1244 | M: rmk@arm.linux.org.uk |
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig index 07eb4c4bab82..8e8441587c22 100644 --- a/arch/m68knommu/Kconfig +++ b/arch/m68knommu/Kconfig | |||
@@ -671,6 +671,9 @@ config ROMKERNEL | |||
671 | 671 | ||
672 | endchoice | 672 | endchoice |
673 | 673 | ||
674 | if COLDFIRE | ||
675 | source "kernel/Kconfig.preempt" | ||
676 | endif | ||
674 | source "mm/Kconfig" | 677 | source "mm/Kconfig" |
675 | 678 | ||
676 | endmenu | 679 | endmenu |
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S index 5592e0bf951f..93e69236ed6f 100644 --- a/arch/m68knommu/kernel/vmlinux.lds.S +++ b/arch/m68knommu/kernel/vmlinux.lds.S | |||
@@ -114,6 +114,16 @@ SECTIONS { | |||
114 | *(__kcrctab_gpl) | 114 | *(__kcrctab_gpl) |
115 | __stop___kcrctab_gpl = .; | 115 | __stop___kcrctab_gpl = .; |
116 | 116 | ||
117 | /* Kernel symbol table: Normal unused symbols */ | ||
118 | __start___kcrctab_unused = .; | ||
119 | *(__kcrctab_unused) | ||
120 | __stop___kcrctab_unused = .; | ||
121 | |||
122 | /* Kernel symbol table: GPL-only unused symbols */ | ||
123 | __start___kcrctab_unused_gpl = .; | ||
124 | *(__kcrctab_unused_gpl) | ||
125 | __stop___kcrctab_unused_gpl = .; | ||
126 | |||
117 | /* Kernel symbol table: GPL-future symbols */ | 127 | /* Kernel symbol table: GPL-future symbols */ |
118 | __start___kcrctab_gpl_future = .; | 128 | __start___kcrctab_gpl_future = .; |
119 | *(__kcrctab_gpl_future) | 129 | *(__kcrctab_gpl_future) |
diff --git a/arch/mn10300/boot/install.sh b/arch/mn10300/boot/install.sh index 072951c83976..abba30971191 100644 --- a/arch/mn10300/boot/install.sh +++ b/arch/mn10300/boot/install.sh | |||
@@ -26,42 +26,42 @@ rm -fr $4/../usr/include/linux $4/../usr/include/asm | |||
26 | install -c -m 0755 $2 $4/vmlinuz | 26 | install -c -m 0755 $2 $4/vmlinuz |
27 | install -c -m 0755 $5 $4/boot.rom | 27 | install -c -m 0755 $5 $4/boot.rom |
28 | install -c -m 0755 -d $4/../usr/include/linux | 28 | install -c -m 0755 -d $4/../usr/include/linux |
29 | cd $TOPDIR/include/linux | 29 | cd ${srctree}/include/linux |
30 | for i in `find . -maxdepth 1 -name '*.h' -print`; do | 30 | for i in `find . -maxdepth 1 -name '*.h' -print`; do |
31 | install -c -m 0644 $i $4/../usr/include/linux | 31 | install -c -m 0644 $i $4/../usr/include/linux |
32 | done | 32 | done |
33 | install -c -m 0755 -d $4/../usr/include/linux/byteorder | 33 | install -c -m 0755 -d $4/../usr/include/linux/byteorder |
34 | cd $TOPDIR/include/linux/byteorder | 34 | cd ${srctree}/include/linux/byteorder |
35 | for i in `find . -name '*.h' -print`; do | 35 | for i in `find . -name '*.h' -print`; do |
36 | install -c -m 0644 $i $4/../usr/include/linux/byteorder | 36 | install -c -m 0644 $i $4/../usr/include/linux/byteorder |
37 | done | 37 | done |
38 | install -c -m 0755 -d $4/../usr/include/linux/lockd | 38 | install -c -m 0755 -d $4/../usr/include/linux/lockd |
39 | cd $TOPDIR/include/linux/lockd | 39 | cd ${srctree}/include/linux/lockd |
40 | for i in `find . -name '*.h' -print`; do | 40 | for i in `find . -name '*.h' -print`; do |
41 | install -c -m 0644 $i $4/../usr/include/linux/lockd | 41 | install -c -m 0644 $i $4/../usr/include/linux/lockd |
42 | done | 42 | done |
43 | install -c -m 0755 -d $4/../usr/include/linux/netfilter_ipv4 | 43 | install -c -m 0755 -d $4/../usr/include/linux/netfilter_ipv4 |
44 | cd $TOPDIR/include/linux/netfilter_ipv4 | 44 | cd ${srctree}/include/linux/netfilter_ipv4 |
45 | for i in `find . -name '*.h' -print`; do | 45 | for i in `find . -name '*.h' -print`; do |
46 | install -c -m 0644 $i $4/../usr/include/linux/netfilter_ipv4 | 46 | install -c -m 0644 $i $4/../usr/include/linux/netfilter_ipv4 |
47 | done | 47 | done |
48 | install -c -m 0755 -d $4/../usr/include/linux/nfsd | 48 | install -c -m 0755 -d $4/../usr/include/linux/nfsd |
49 | cd $TOPDIR/include/linux/nfsd | 49 | cd ${srctree}/include/linux/nfsd |
50 | for i in `find . -name '*.h' -print`; do | 50 | for i in `find . -name '*.h' -print`; do |
51 | install -c -m 0644 $i $4/../usr/include/linux/nfsd/$i | 51 | install -c -m 0644 $i $4/../usr/include/linux/nfsd/$i |
52 | done | 52 | done |
53 | install -c -m 0755 -d $4/../usr/include/linux/raid | 53 | install -c -m 0755 -d $4/../usr/include/linux/raid |
54 | cd $TOPDIR/include/linux/raid | 54 | cd ${srctree}/include/linux/raid |
55 | for i in `find . -name '*.h' -print`; do | 55 | for i in `find . -name '*.h' -print`; do |
56 | install -c -m 0644 $i $4/../usr/include/linux/raid | 56 | install -c -m 0644 $i $4/../usr/include/linux/raid |
57 | done | 57 | done |
58 | install -c -m 0755 -d $4/../usr/include/linux/sunrpc | 58 | install -c -m 0755 -d $4/../usr/include/linux/sunrpc |
59 | cd $TOPDIR/include/linux/sunrpc | 59 | cd ${srctree}/include/linux/sunrpc |
60 | for i in `find . -name '*.h' -print`; do | 60 | for i in `find . -name '*.h' -print`; do |
61 | install -c -m 0644 $i $4/../usr/include/linux/sunrpc | 61 | install -c -m 0644 $i $4/../usr/include/linux/sunrpc |
62 | done | 62 | done |
63 | install -c -m 0755 -d $4/../usr/include/asm | 63 | install -c -m 0755 -d $4/../usr/include/asm |
64 | cd $TOPDIR/include/asm | 64 | cd ${srctree}/include/asm |
65 | for i in `find . -name '*.h' -print`; do | 65 | for i in `find . -name '*.h' -print`; do |
66 | install -c -m 0644 $i $4/../usr/include/asm | 66 | install -c -m 0644 $i $4/../usr/include/asm |
67 | done | 67 | done |
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index 1f012843150f..b0ed709d5743 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c | |||
@@ -606,7 +606,7 @@ void show_mem(void) | |||
606 | int i, j; | 606 | int i, j; |
607 | 607 | ||
608 | for (i = 0; i < npmem_ranges; i++) { | 608 | for (i = 0; i < npmem_ranges; i++) { |
609 | zl = node_zonelist(i); | 609 | zl = node_zonelist(i, 0); |
610 | for (j = 0; j < MAX_NR_ZONES; j++) { | 610 | for (j = 0; j < MAX_NR_ZONES; j++) { |
611 | struct zoneref *z; | 611 | struct zoneref *z; |
612 | struct zone *zone; | 612 | struct zone *zone; |
diff --git a/arch/um/Kconfig.char b/arch/um/Kconfig.char index 3a4b396d7979..1b238ebae6b3 100644 --- a/arch/um/Kconfig.char +++ b/arch/um/Kconfig.char | |||
@@ -145,14 +145,14 @@ config LEGACY_PTYS | |||
145 | systems, it is safe to say N. | 145 | systems, it is safe to say N. |
146 | 146 | ||
147 | config RAW_DRIVER | 147 | config RAW_DRIVER |
148 | tristate "RAW driver (/dev/raw/rawN) (OBSOLETE)" | 148 | tristate "RAW driver (/dev/raw/rawN)" |
149 | depends on BLOCK | ||
149 | help | 150 | help |
150 | The raw driver permits block devices to be bound to /dev/raw/rawN. | 151 | The raw driver permits block devices to be bound to /dev/raw/rawN. |
151 | Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O. | 152 | Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O. |
152 | See the raw(8) manpage for more details. | 153 | See the raw(8) manpage for more details. |
153 | 154 | ||
154 | The raw driver is deprecated and will be removed soon. | 155 | Applications should preferably open the device (eg /dev/hda1) |
155 | Applications should simply open the device (eg /dev/hda1) | ||
156 | with the O_DIRECT flag. | 156 | with the O_DIRECT flag. |
157 | 157 | ||
158 | config MAX_RAW_DEVS | 158 | config MAX_RAW_DEVS |
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 025764089ac8..cfeb3f4a44af 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <termios.h> | 11 | #include <termios.h> |
12 | #include <sys/ioctl.h> | 12 | #include <sys/ioctl.h> |
13 | #include "chan_user.h" | 13 | #include "chan_user.h" |
14 | #include "kern_constants.h" | ||
14 | #include "os.h" | 15 | #include "os.h" |
15 | #include "um_malloc.h" | 16 | #include "um_malloc.h" |
16 | #include "user.h" | 17 | #include "user.h" |
diff --git a/arch/um/drivers/cow_sys.h b/arch/um/drivers/cow_sys.h index ca8c9e11a39b..f5701fd2ef90 100644 --- a/arch/um/drivers/cow_sys.h +++ b/arch/um/drivers/cow_sys.h | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | static inline void *cow_malloc(int size) | 9 | static inline void *cow_malloc(int size) |
10 | { | 10 | { |
11 | return kmalloc(size, UM_GFP_KERNEL); | 11 | return uml_kmalloc(size, UM_GFP_KERNEL); |
12 | } | 12 | } |
13 | 13 | ||
14 | static inline void cow_free(void *ptr) | 14 | static inline void cow_free(void *ptr) |
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c index f23c109a055c..f8e85e0bdace 100644 --- a/arch/um/drivers/daemon_user.c +++ b/arch/um/drivers/daemon_user.c | |||
@@ -34,7 +34,7 @@ static struct sockaddr_un *new_addr(void *name, int len) | |||
34 | { | 34 | { |
35 | struct sockaddr_un *sun; | 35 | struct sockaddr_un *sun; |
36 | 36 | ||
37 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); | 37 | sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); |
38 | if (sun == NULL) { | 38 | if (sun == NULL) { |
39 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " | 39 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " |
40 | "failed\n"); | 40 | "failed\n"); |
@@ -83,7 +83,7 @@ static int connect_to_switch(struct daemon_data *pri) | |||
83 | goto out_close; | 83 | goto out_close; |
84 | } | 84 | } |
85 | 85 | ||
86 | sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); | 86 | sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); |
87 | if (sun == NULL) { | 87 | if (sun == NULL) { |
88 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " | 88 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " |
89 | "failed\n"); | 89 | "failed\n"); |
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c index 0a2bb5b64b82..f5a981a16240 100644 --- a/arch/um/drivers/fd.c +++ b/arch/um/drivers/fd.c | |||
@@ -40,7 +40,7 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts) | |||
40 | return NULL; | 40 | return NULL; |
41 | } | 41 | } |
42 | 42 | ||
43 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); | 43 | data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL); |
44 | if (data == NULL) | 44 | if (data == NULL) |
45 | return NULL; | 45 | return NULL; |
46 | 46 | ||
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c index ff1b22b69e9c..368219cc2366 100644 --- a/arch/um/drivers/hostaudio_kern.c +++ b/arch/um/drivers/hostaudio_kern.c | |||
@@ -154,7 +154,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file, | |||
154 | case SNDCTL_DSP_SUBDIVIDE: | 154 | case SNDCTL_DSP_SUBDIVIDE: |
155 | case SNDCTL_DSP_SETFRAGMENT: | 155 | case SNDCTL_DSP_SETFRAGMENT: |
156 | if (get_user(data, (int __user *) arg)) | 156 | if (get_user(data, (int __user *) arg)) |
157 | return EFAULT; | 157 | return -EFAULT; |
158 | break; | 158 | break; |
159 | default: | 159 | default: |
160 | break; | 160 | break; |
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 5f647d7a7292..ee19e91568a2 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <unistd.h> | 15 | #include <unistd.h> |
16 | #include <errno.h> | 16 | #include <errno.h> |
17 | #include <netinet/in.h> | 17 | #include <netinet/in.h> |
18 | #include "kern_constants.h" | ||
18 | #include "mcast.h" | 19 | #include "mcast.h" |
19 | #include "net_user.h" | 20 | #include "net_user.h" |
20 | #include "um_malloc.h" | 21 | #include "um_malloc.h" |
@@ -24,7 +25,7 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port) | |||
24 | { | 25 | { |
25 | struct sockaddr_in *sin; | 26 | struct sockaddr_in *sin; |
26 | 27 | ||
27 | sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL); | 28 | sin = uml_kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL); |
28 | if (sin == NULL) { | 29 | if (sin == NULL) { |
29 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in " | 30 | printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in " |
30 | "failed\n"); | 31 | "failed\n"); |
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c index abf2653f5517..9415dd9e63ef 100644 --- a/arch/um/drivers/net_user.c +++ b/arch/um/drivers/net_user.c | |||
@@ -222,7 +222,7 @@ static void change(char *dev, char *what, unsigned char *addr, | |||
222 | netmask[2], netmask[3]); | 222 | netmask[2], netmask[3]); |
223 | 223 | ||
224 | output_len = UM_KERN_PAGE_SIZE; | 224 | output_len = UM_KERN_PAGE_SIZE; |
225 | output = kmalloc(output_len, UM_GFP_KERNEL); | 225 | output = uml_kmalloc(output_len, UM_GFP_KERNEL); |
226 | if (output == NULL) | 226 | if (output == NULL) |
227 | printk(UM_KERN_ERR "change : failed to allocate output " | 227 | printk(UM_KERN_ERR "change : failed to allocate output " |
228 | "buffer\n"); | 228 | "buffer\n"); |
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c index d269ca387f10..b49bf56a56aa 100644 --- a/arch/um/drivers/port_user.c +++ b/arch/um/drivers/port_user.c | |||
@@ -47,7 +47,7 @@ static void *port_init(char *str, int device, const struct chan_opts *opts) | |||
47 | if (kern_data == NULL) | 47 | if (kern_data == NULL) |
48 | return NULL; | 48 | return NULL; |
49 | 49 | ||
50 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); | 50 | data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL); |
51 | if (data == NULL) | 51 | if (data == NULL) |
52 | goto err; | 52 | goto err; |
53 | 53 | ||
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c index 49c79dda6046..1113911dcb2b 100644 --- a/arch/um/drivers/pty.c +++ b/arch/um/drivers/pty.c | |||
@@ -29,7 +29,7 @@ static void *pty_chan_init(char *str, int device, const struct chan_opts *opts) | |||
29 | { | 29 | { |
30 | struct pty_chan *data; | 30 | struct pty_chan *data; |
31 | 31 | ||
32 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); | 32 | data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL); |
33 | if (data == NULL) | 33 | if (data == NULL) |
34 | return NULL; | 34 | return NULL; |
35 | 35 | ||
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c index 71f0959c1535..4949044773ba 100644 --- a/arch/um/drivers/random.c +++ b/arch/um/drivers/random.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Copyright (C) 2005 Jeff Dike <jdike@addtoit.com> */ | 1 | /* Copyright (C) 2005 - 2008 Jeff Dike <jdike@{linux.intel,addtoit}.com> */ |
2 | |||
2 | /* Much of this ripped from drivers/char/hw_random.c, see there for other | 3 | /* Much of this ripped from drivers/char/hw_random.c, see there for other |
3 | * copyright. | 4 | * copyright. |
4 | * | 5 | * |
@@ -8,16 +9,18 @@ | |||
8 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
9 | #include <linux/module.h> | 10 | #include <linux/module.h> |
10 | #include <linux/fs.h> | 11 | #include <linux/fs.h> |
12 | #include <linux/interrupt.h> | ||
11 | #include <linux/miscdevice.h> | 13 | #include <linux/miscdevice.h> |
12 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
13 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
16 | #include "irq_kern.h" | ||
14 | #include "os.h" | 17 | #include "os.h" |
15 | 18 | ||
16 | /* | 19 | /* |
17 | * core module and version information | 20 | * core module and version information |
18 | */ | 21 | */ |
19 | #define RNG_VERSION "1.0.0" | 22 | #define RNG_VERSION "1.0.0" |
20 | #define RNG_MODULE_NAME "random" | 23 | #define RNG_MODULE_NAME "hw_random" |
21 | 24 | ||
22 | #define RNG_MISCDEV_MINOR 183 /* official */ | 25 | #define RNG_MISCDEV_MINOR 183 /* official */ |
23 | 26 | ||
@@ -26,47 +29,67 @@ | |||
26 | * protects against a module being loaded twice at the same time. | 29 | * protects against a module being loaded twice at the same time. |
27 | */ | 30 | */ |
28 | static int random_fd = -1; | 31 | static int random_fd = -1; |
32 | static DECLARE_WAIT_QUEUE_HEAD(host_read_wait); | ||
29 | 33 | ||
30 | static int rng_dev_open (struct inode *inode, struct file *filp) | 34 | static int rng_dev_open (struct inode *inode, struct file *filp) |
31 | { | 35 | { |
32 | /* enforce read-only access to this chrdev */ | 36 | /* enforce read-only access to this chrdev */ |
33 | if ((filp->f_mode & FMODE_READ) == 0) | 37 | if ((filp->f_mode & FMODE_READ) == 0) |
34 | return -EINVAL; | 38 | return -EINVAL; |
35 | if (filp->f_mode & FMODE_WRITE) | 39 | if ((filp->f_mode & FMODE_WRITE) != 0) |
36 | return -EINVAL; | 40 | return -EINVAL; |
37 | 41 | ||
38 | return 0; | 42 | return 0; |
39 | } | 43 | } |
40 | 44 | ||
45 | static atomic_t host_sleep_count = ATOMIC_INIT(0); | ||
46 | |||
41 | static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, | 47 | static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, |
42 | loff_t * offp) | 48 | loff_t *offp) |
43 | { | 49 | { |
44 | u32 data; | 50 | u32 data; |
45 | int n, ret = 0, have_data; | 51 | int n, ret = 0, have_data; |
46 | 52 | ||
47 | while(size){ | 53 | while (size) { |
48 | n = os_read_file(random_fd, &data, sizeof(data)); | 54 | n = os_read_file(random_fd, &data, sizeof(data)); |
49 | if(n > 0){ | 55 | if (n > 0) { |
50 | have_data = n; | 56 | have_data = n; |
51 | while (have_data && size) { | 57 | while (have_data && size) { |
52 | if (put_user((u8)data, buf++)) { | 58 | if (put_user((u8) data, buf++)) { |
53 | ret = ret ? : -EFAULT; | 59 | ret = ret ? : -EFAULT; |
54 | break; | 60 | break; |
55 | } | 61 | } |
56 | size--; | 62 | size--; |
57 | ret++; | 63 | ret++; |
58 | have_data--; | 64 | have_data--; |
59 | data>>=8; | 65 | data >>= 8; |
60 | } | 66 | } |
61 | } | 67 | } |
62 | else if(n == -EAGAIN){ | 68 | else if (n == -EAGAIN) { |
63 | if (filp->f_flags & O_NONBLOCK) | 69 | DECLARE_WAITQUEUE(wait, current); |
64 | return ret ? : -EAGAIN; | 70 | |
65 | 71 | if (filp->f_flags & O_NONBLOCK) | |
66 | if(need_resched()) | 72 | return ret ? : -EAGAIN; |
67 | schedule_timeout_interruptible(1); | 73 | |
68 | } | 74 | atomic_inc(&host_sleep_count); |
69 | else return n; | 75 | reactivate_fd(random_fd, RANDOM_IRQ); |
76 | add_sigio_fd(random_fd); | ||
77 | |||
78 | add_wait_queue(&host_read_wait, &wait); | ||
79 | set_task_state(current, TASK_INTERRUPTIBLE); | ||
80 | |||
81 | schedule(); | ||
82 | set_task_state(current, TASK_RUNNING); | ||
83 | remove_wait_queue(&host_read_wait, &wait); | ||
84 | |||
85 | if (atomic_dec_and_test(&host_sleep_count)) { | ||
86 | ignore_sigio_fd(random_fd); | ||
87 | deactivate_fd(random_fd, RANDOM_IRQ); | ||
88 | } | ||
89 | } | ||
90 | else | ||
91 | return n; | ||
92 | |||
70 | if (signal_pending (current)) | 93 | if (signal_pending (current)) |
71 | return ret ? : -ERESTARTSYS; | 94 | return ret ? : -ERESTARTSYS; |
72 | } | 95 | } |
@@ -86,6 +109,13 @@ static struct miscdevice rng_miscdev = { | |||
86 | &rng_chrdev_ops, | 109 | &rng_chrdev_ops, |
87 | }; | 110 | }; |
88 | 111 | ||
112 | static irqreturn_t random_interrupt(int irq, void *data) | ||
113 | { | ||
114 | wake_up(&host_read_wait); | ||
115 | |||
116 | return IRQ_HANDLED; | ||
117 | } | ||
118 | |||
89 | /* | 119 | /* |
90 | * rng_init - initialize RNG module | 120 | * rng_init - initialize RNG module |
91 | */ | 121 | */ |
@@ -93,28 +123,33 @@ static int __init rng_init (void) | |||
93 | { | 123 | { |
94 | int err; | 124 | int err; |
95 | 125 | ||
96 | err = os_open_file("/dev/random", of_read(OPENFLAGS()), 0); | 126 | err = os_open_file("/dev/random", of_read(OPENFLAGS()), 0); |
97 | if(err < 0) | 127 | if (err < 0) |
98 | goto out; | 128 | goto out; |
99 | 129 | ||
100 | random_fd = err; | 130 | random_fd = err; |
101 | 131 | ||
102 | err = os_set_fd_block(random_fd, 0); | 132 | err = um_request_irq(RANDOM_IRQ, random_fd, IRQ_READ, random_interrupt, |
103 | if(err) | 133 | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "random", |
134 | NULL); | ||
135 | if (err) | ||
104 | goto err_out_cleanup_hw; | 136 | goto err_out_cleanup_hw; |
105 | 137 | ||
138 | sigio_broken(random_fd, 1); | ||
139 | |||
106 | err = misc_register (&rng_miscdev); | 140 | err = misc_register (&rng_miscdev); |
107 | if (err) { | 141 | if (err) { |
108 | printk (KERN_ERR RNG_MODULE_NAME ": misc device register failed\n"); | 142 | printk (KERN_ERR RNG_MODULE_NAME ": misc device register " |
143 | "failed\n"); | ||
109 | goto err_out_cleanup_hw; | 144 | goto err_out_cleanup_hw; |
110 | } | 145 | } |
146 | out: | ||
147 | return err; | ||
111 | 148 | ||
112 | out: | 149 | err_out_cleanup_hw: |
113 | return err; | 150 | os_close_file(random_fd); |
114 | 151 | random_fd = -1; | |
115 | err_out_cleanup_hw: | 152 | goto out; |
116 | random_fd = -1; | ||
117 | goto out; | ||
118 | } | 153 | } |
119 | 154 | ||
120 | /* | 155 | /* |
@@ -122,6 +157,7 @@ static int __init rng_init (void) | |||
122 | */ | 157 | */ |
123 | static void __exit rng_cleanup (void) | 158 | static void __exit rng_cleanup (void) |
124 | { | 159 | { |
160 | os_close_file(random_fd); | ||
125 | misc_deregister (&rng_miscdev); | 161 | misc_deregister (&rng_miscdev); |
126 | } | 162 | } |
127 | 163 | ||
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c index 8b80505a3fb0..a1c2d2c98a94 100644 --- a/arch/um/drivers/slip_user.c +++ b/arch/um/drivers/slip_user.c | |||
@@ -96,7 +96,7 @@ static int slip_tramp(char **argv, int fd) | |||
96 | pid = err; | 96 | pid = err; |
97 | 97 | ||
98 | output_len = UM_KERN_PAGE_SIZE; | 98 | output_len = UM_KERN_PAGE_SIZE; |
99 | output = kmalloc(output_len, UM_GFP_KERNEL); | 99 | output = uml_kmalloc(output_len, UM_GFP_KERNEL); |
100 | if (output == NULL) { | 100 | if (output == NULL) { |
101 | printk(UM_KERN_ERR "slip_tramp : failed to allocate output " | 101 | printk(UM_KERN_ERR "slip_tramp : failed to allocate output " |
102 | "buffer\n"); | 102 | "buffer\n"); |
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c index c930fedc5172..495858a090e4 100644 --- a/arch/um/drivers/tty.c +++ b/arch/um/drivers/tty.c | |||
@@ -29,7 +29,7 @@ static void *tty_chan_init(char *str, int device, const struct chan_opts *opts) | |||
29 | } | 29 | } |
30 | str++; | 30 | str++; |
31 | 31 | ||
32 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); | 32 | data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL); |
33 | if (data == NULL) | 33 | if (data == NULL) |
34 | return NULL; | 34 | return NULL; |
35 | *data = ((struct tty_chan) { .dev = str, | 35 | *data = ((struct tty_chan) { .dev = str, |
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 5e45e39a8a8d..44ad1607be2d 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
@@ -1178,8 +1178,8 @@ static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask, | |||
1178 | * by one word. Thanks to Lynn Kerby for the fix and James McMechan | 1178 | * by one word. Thanks to Lynn Kerby for the fix and James McMechan |
1179 | * for the original diagnosis. | 1179 | * for the original diagnosis. |
1180 | */ | 1180 | */ |
1181 | if(*cow_offset == ((bitmap_len + sizeof(unsigned long) - 1) / | 1181 | if (*cow_offset == (DIV_ROUND_UP(bitmap_len, |
1182 | sizeof(unsigned long) - 1)) | 1182 | sizeof(unsigned long)) - 1)) |
1183 | (*cow_offset)--; | 1183 | (*cow_offset)--; |
1184 | 1184 | ||
1185 | bitmap_words[0] = bitmap[*cow_offset]; | 1185 | bitmap_words[0] = bitmap[*cow_offset]; |
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index 8a1c18a9b240..da2caa5a21ef 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c | |||
@@ -30,7 +30,7 @@ static void *xterm_init(char *str, int device, const struct chan_opts *opts) | |||
30 | { | 30 | { |
31 | struct xterm_chan *data; | 31 | struct xterm_chan *data; |
32 | 32 | ||
33 | data = kmalloc(sizeof(*data), UM_GFP_KERNEL); | 33 | data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL); |
34 | if (data == NULL) | 34 | if (data == NULL) |
35 | return NULL; | 35 | return NULL; |
36 | *data = ((struct xterm_chan) { .pid = -1, | 36 | *data = ((struct xterm_chan) { .pid = -1, |
diff --git a/arch/um/include/as-layout.h b/arch/um/include/as-layout.h index cac542d8ff70..58e852dfb0ce 100644 --- a/arch/um/include/as-layout.h +++ b/arch/um/include/as-layout.h | |||
@@ -23,16 +23,16 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifdef __ASSEMBLY__ | 25 | #ifdef __ASSEMBLY__ |
26 | #define _AC(X, Y) (Y) | 26 | #define _UML_AC(X, Y) (Y) |
27 | #else | 27 | #else |
28 | #define __AC(X, Y) (X (Y)) | 28 | #define __UML_AC(X, Y) (X(Y)) |
29 | #define _AC(X, Y) __AC(X, Y) | 29 | #define _UML_AC(X, Y) __UML_AC(X, Y) |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #define STUB_START _AC(, 0x100000) | 32 | #define STUB_START _UML_AC(, 0x100000) |
33 | #define STUB_CODE _AC((unsigned long), STUB_START) | 33 | #define STUB_CODE _UML_AC((unsigned long), STUB_START) |
34 | #define STUB_DATA _AC((unsigned long), STUB_CODE + UM_KERN_PAGE_SIZE) | 34 | #define STUB_DATA _UML_AC((unsigned long), STUB_CODE + UM_KERN_PAGE_SIZE) |
35 | #define STUB_END _AC((unsigned long), STUB_DATA + UM_KERN_PAGE_SIZE) | 35 | #define STUB_END _UML_AC((unsigned long), STUB_DATA + UM_KERN_PAGE_SIZE) |
36 | 36 | ||
37 | #ifndef __ASSEMBLY__ | 37 | #ifndef __ASSEMBLY__ |
38 | 38 | ||
diff --git a/arch/um/include/line.h b/arch/um/include/line.h index 979b73e6352d..311a0d3d93af 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/line.h | |||
@@ -58,11 +58,11 @@ struct line { | |||
58 | }; | 58 | }; |
59 | 59 | ||
60 | #define LINE_INIT(str, d) \ | 60 | #define LINE_INIT(str, d) \ |
61 | { .count_lock = SPIN_LOCK_UNLOCKED, \ | 61 | { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \ |
62 | .init_str = str, \ | 62 | .init_str = str, \ |
63 | .init_pri = INIT_STATIC, \ | 63 | .init_pri = INIT_STATIC, \ |
64 | .valid = 1, \ | 64 | .valid = 1, \ |
65 | .lock = SPIN_LOCK_UNLOCKED, \ | 65 | .lock = __SPIN_LOCK_UNLOCKED((str).lock), \ |
66 | .driver = d } | 66 | .driver = d } |
67 | 67 | ||
68 | extern void line_close(struct tty_struct *tty, struct file * filp); | 68 | extern void line_close(struct tty_struct *tty, struct file * filp); |
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 32c799e3a495..e2716ac8889a 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -290,6 +290,7 @@ extern void os_set_ioignore(void); | |||
290 | extern int add_sigio_fd(int fd); | 290 | extern int add_sigio_fd(int fd); |
291 | extern int ignore_sigio_fd(int fd); | 291 | extern int ignore_sigio_fd(int fd); |
292 | extern void maybe_sigio_broken(int fd, int read); | 292 | extern void maybe_sigio_broken(int fd, int read); |
293 | extern void sigio_broken(int fd, int read); | ||
293 | 294 | ||
294 | /* sys-x86_64/prctl.c */ | 295 | /* sys-x86_64/prctl.c */ |
295 | extern int os_arch_prctl(int pid, int code, unsigned long *addr); | 296 | extern int os_arch_prctl(int pid, int code, unsigned long *addr); |
diff --git a/arch/um/include/process.h b/arch/um/include/process.h index 5af9157ff54f..bb873a51262e 100644 --- a/arch/um/include/process.h +++ b/arch/um/include/process.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2000 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -8,18 +8,10 @@ | |||
8 | 8 | ||
9 | #include <signal.h> | 9 | #include <signal.h> |
10 | 10 | ||
11 | extern void sig_handler(int sig, struct sigcontext sc); | 11 | /* Copied from linux/compiler-gcc.h since we can't include it directly */ |
12 | extern void alarm_handler(int sig, struct sigcontext sc); | 12 | #define barrier() __asm__ __volatile__("": : :"memory") |
13 | 13 | ||
14 | #endif | 14 | extern void sig_handler(int sig, struct sigcontext *sc); |
15 | extern void alarm_handler(int sig, struct sigcontext *sc); | ||
15 | 16 | ||
16 | /* | 17 | #endif |
17 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
18 | * Emacs will notice this stuff at the end of the file and automatically | ||
19 | * adjust the settings for this buffer only. This must remain at the end | ||
20 | * of the file. | ||
21 | * --------------------------------------------------------------------------- | ||
22 | * Local variables: | ||
23 | * c-file-style: "linux" | ||
24 | * End: | ||
25 | */ | ||
diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h index cd2327d09c8d..3d31bbacd016 100644 --- a/arch/um/include/skas_ptrace.h +++ b/arch/um/include/skas_ptrace.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -12,14 +12,3 @@ | |||
12 | #include "sysdep/skas_ptrace.h" | 12 | #include "sysdep/skas_ptrace.h" |
13 | 13 | ||
14 | #endif | 14 | #endif |
15 | |||
16 | /* | ||
17 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
18 | * Emacs will notice this stuff at the end of the file and automatically | ||
19 | * adjust the settings for this buffer only. This must remain at the end | ||
20 | * of the file. | ||
21 | * --------------------------------------------------------------------------- | ||
22 | * Local variables: | ||
23 | * c-file-style: "linux" | ||
24 | * End: | ||
25 | */ | ||
diff --git a/arch/um/include/sysdep-i386/ptrace_user.h b/arch/um/include/sysdep-i386/ptrace_user.h index 75650723c38f..ef56247e4143 100644 --- a/arch/um/include/sysdep-i386/ptrace_user.h +++ b/arch/um/include/sysdep-i386/ptrace_user.h | |||
@@ -41,38 +41,10 @@ | |||
41 | #define PT_SP_OFFSET PT_OFFSET(UESP) | 41 | #define PT_SP_OFFSET PT_OFFSET(UESP) |
42 | #define PT_SP(regs) ((regs)[UESP]) | 42 | #define PT_SP(regs) ((regs)[UESP]) |
43 | 43 | ||
44 | #define FP_SIZE ((HOST_XFP_SIZE > HOST_FP_SIZE) ? HOST_XFP_SIZE : HOST_FP_SIZE) | 44 | #define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE) |
45 | 45 | ||
46 | #ifndef FRAME_SIZE | 46 | #ifndef FRAME_SIZE |
47 | #define FRAME_SIZE (17) | 47 | #define FRAME_SIZE (17) |
48 | #endif | 48 | #endif |
49 | #define FRAME_SIZE_OFFSET (FRAME_SIZE * sizeof(unsigned long)) | ||
50 | |||
51 | #define FP_FRAME_SIZE (27) | ||
52 | #define FPX_FRAME_SIZE (128) | ||
53 | |||
54 | #ifdef PTRACE_GETREGS | ||
55 | #define UM_HAVE_GETREGS | ||
56 | #endif | ||
57 | |||
58 | #ifdef PTRACE_SETREGS | ||
59 | #define UM_HAVE_SETREGS | ||
60 | #endif | ||
61 | |||
62 | #ifdef PTRACE_GETFPREGS | ||
63 | #define UM_HAVE_GETFPREGS | ||
64 | #endif | ||
65 | |||
66 | #ifdef PTRACE_SETFPREGS | ||
67 | #define UM_HAVE_SETFPREGS | ||
68 | #endif | ||
69 | |||
70 | #ifdef PTRACE_GETFPXREGS | ||
71 | #define UM_HAVE_GETFPXREGS | ||
72 | #endif | ||
73 | |||
74 | #ifdef PTRACE_SETFPXREGS | ||
75 | #define UM_HAVE_SETFPXREGS | ||
76 | #endif | ||
77 | 49 | ||
78 | #endif | 50 | #endif |
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h index 67e77122aa45..f583c87111a0 100644 --- a/arch/um/include/sysdep-i386/sigcontext.h +++ b/arch/um/include/sysdep-i386/sigcontext.h | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) | 11 | #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) |
12 | 12 | ||
13 | #define GET_FAULTINFO_FROM_SC(fi,sc) \ | 13 | #define GET_FAULTINFO_FROM_SC(fi, sc) \ |
14 | { \ | 14 | { \ |
15 | (fi).cr2 = SC_CR2(sc); \ | 15 | (fi).cr2 = SC_CR2(sc); \ |
16 | (fi).error_code = SC_ERR(sc); \ | 16 | (fi).error_code = SC_ERR(sc); \ |
diff --git a/arch/um/include/sysdep-x86_64/ptrace_user.h b/arch/um/include/sysdep-x86_64/ptrace_user.h index 45c0bd881cb3..4dbccdb58f48 100644 --- a/arch/um/include/sysdep-x86_64/ptrace_user.h +++ b/arch/um/include/sysdep-x86_64/ptrace_user.h | |||
@@ -48,7 +48,8 @@ | |||
48 | #define PT_ORIG_RAX_OFFSET (ORIG_RAX) | 48 | #define PT_ORIG_RAX_OFFSET (ORIG_RAX) |
49 | #define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)]) | 49 | #define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)]) |
50 | 50 | ||
51 | /* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though | 51 | /* |
52 | * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though | ||
52 | * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the | 53 | * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the |
53 | * 2.4 name and value for 2.4 host compatibility. | 54 | * 2.4 name and value for 2.4 host compatibility. |
54 | */ | 55 | */ |
@@ -56,7 +57,8 @@ | |||
56 | #define PTRACE_OLDSETOPTIONS 21 | 57 | #define PTRACE_OLDSETOPTIONS 21 |
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | /* These are before the system call, so the system call number is RAX | 60 | /* |
61 | * These are before the system call, so the system call number is RAX | ||
60 | * rather than ORIG_RAX, and arg4 is R10 rather than RCX | 62 | * rather than ORIG_RAX, and arg4 is R10 rather than RCX |
61 | */ | 63 | */ |
62 | #define REGS_SYSCALL_NR PT_INDEX(RAX) | 64 | #define REGS_SYSCALL_NR PT_INDEX(RAX) |
@@ -73,14 +75,3 @@ | |||
73 | #define FP_SIZE (HOST_FP_SIZE) | 75 | #define FP_SIZE (HOST_FP_SIZE) |
74 | 76 | ||
75 | #endif | 77 | #endif |
76 | |||
77 | /* | ||
78 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
79 | * Emacs will notice this stuff at the end of the file and automatically | ||
80 | * adjust the settings for this buffer only. This must remain at the end | ||
81 | * of the file. | ||
82 | * --------------------------------------------------------------------------- | ||
83 | * Local variables: | ||
84 | * c-file-style: "linux" | ||
85 | * End: | ||
86 | */ | ||
diff --git a/arch/um/include/um_malloc.h b/arch/um/include/um_malloc.h index 0ad17cb83d96..c554d706d106 100644 --- a/arch/um/include/um_malloc.h +++ b/arch/um/include/um_malloc.h | |||
@@ -8,15 +8,12 @@ | |||
8 | 8 | ||
9 | #include "kern_constants.h" | 9 | #include "kern_constants.h" |
10 | 10 | ||
11 | extern void *__kmalloc(int size, int flags); | 11 | extern void *uml_kmalloc(int size, int flags); |
12 | static inline void *kmalloc(int size, int flags) | ||
13 | { | ||
14 | return __kmalloc(size, flags); | ||
15 | } | ||
16 | |||
17 | extern void kfree(const void *ptr); | 12 | extern void kfree(const void *ptr); |
18 | 13 | ||
19 | extern void *vmalloc(unsigned long size); | 14 | extern void *vmalloc(unsigned long size); |
20 | extern void vfree(void *ptr); | 15 | extern void vfree(void *ptr); |
21 | 16 | ||
22 | #endif /* __UM_MALLOC_H__ */ | 17 | #endif /* __UM_MALLOC_H__ */ |
18 | |||
19 | |||
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S index 26090b7f323e..9975e1ab44fb 100644 --- a/arch/um/kernel/dyn.lds.S +++ b/arch/um/kernel/dyn.lds.S | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <asm-generic/vmlinux.lds.h> | 1 | #include <asm-generic/vmlinux.lds.h> |
2 | #include <asm/page.h> | ||
2 | 3 | ||
3 | OUTPUT_FORMAT(ELF_FORMAT) | 4 | OUTPUT_FORMAT(ELF_FORMAT) |
4 | OUTPUT_ARCH(ELF_ARCH) | 5 | OUTPUT_ARCH(ELF_ARCH) |
@@ -21,7 +22,7 @@ SECTIONS | |||
21 | _einittext = .; | 22 | _einittext = .; |
22 | } | 23 | } |
23 | 24 | ||
24 | . = ALIGN(4096); | 25 | . = ALIGN(PAGE_SIZE); |
25 | 26 | ||
26 | /* Read-only sections, merged into text segment: */ | 27 | /* Read-only sections, merged into text segment: */ |
27 | .hash : { *(.hash) } | 28 | .hash : { *(.hash) } |
@@ -68,9 +69,9 @@ SECTIONS | |||
68 | /* .gnu.warning sections are handled specially by elf32.em. */ | 69 | /* .gnu.warning sections are handled specially by elf32.em. */ |
69 | *(.gnu.warning) | 70 | *(.gnu.warning) |
70 | 71 | ||
71 | . = ALIGN(4096); | 72 | . = ALIGN(PAGE_SIZE); |
72 | } =0x90909090 | 73 | } =0x90909090 |
73 | . = ALIGN(4096); | 74 | . = ALIGN(PAGE_SIZE); |
74 | .syscall_stub : { | 75 | .syscall_stub : { |
75 | __syscall_stub_start = .; | 76 | __syscall_stub_start = .; |
76 | *(.__syscall_stub*) | 77 | *(.__syscall_stub*) |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 2eea1ff235e6..b0ee64622ff7 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -375,3 +375,8 @@ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) | |||
375 | return pmd; | 375 | return pmd; |
376 | } | 376 | } |
377 | #endif | 377 | #endif |
378 | |||
379 | void *uml_kmalloc(int size, int flags) | ||
380 | { | ||
381 | return kmalloc(size, flags); | ||
382 | } | ||
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 0d0cea2ac98d..c3e2f369c33c 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c | |||
@@ -75,7 +75,7 @@ static irqreturn_t um_timer(int irq, void *dev) | |||
75 | 75 | ||
76 | static cycle_t itimer_read(void) | 76 | static cycle_t itimer_read(void) |
77 | { | 77 | { |
78 | return os_nsecs(); | 78 | return os_nsecs() / 1000; |
79 | } | 79 | } |
80 | 80 | ||
81 | static struct clocksource itimer_clocksource = { | 81 | static struct clocksource itimer_clocksource = { |
@@ -83,7 +83,7 @@ static struct clocksource itimer_clocksource = { | |||
83 | .rating = 300, | 83 | .rating = 300, |
84 | .read = itimer_read, | 84 | .read = itimer_read, |
85 | .mask = CLOCKSOURCE_MASK(64), | 85 | .mask = CLOCKSOURCE_MASK(64), |
86 | .mult = 1, | 86 | .mult = 1000, |
87 | .shift = 0, | 87 | .shift = 0, |
88 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 88 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
89 | }; | 89 | }; |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 56deed623446..9db85b2ce698 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -150,7 +150,7 @@ __uml_setup("root=", uml_root_setup, | |||
150 | static int __init no_skas_debug_setup(char *line, int *add) | 150 | static int __init no_skas_debug_setup(char *line, int *add) |
151 | { | 151 | { |
152 | printf("'debug' is not necessary to gdb UML in skas mode - run \n"); | 152 | printf("'debug' is not necessary to gdb UML in skas mode - run \n"); |
153 | printf("'gdb linux'"); | 153 | printf("'gdb linux'\n"); |
154 | 154 | ||
155 | return 0; | 155 | return 0; |
156 | } | 156 | } |
@@ -258,6 +258,7 @@ int __init linux_main(int argc, char **argv) | |||
258 | { | 258 | { |
259 | unsigned long avail, diff; | 259 | unsigned long avail, diff; |
260 | unsigned long virtmem_size, max_physmem; | 260 | unsigned long virtmem_size, max_physmem; |
261 | unsigned long stack; | ||
261 | unsigned int i; | 262 | unsigned int i; |
262 | int add; | 263 | int add; |
263 | char * mode; | 264 | char * mode; |
@@ -348,7 +349,9 @@ int __init linux_main(int argc, char **argv) | |||
348 | } | 349 | } |
349 | 350 | ||
350 | virtmem_size = physmem_size; | 351 | virtmem_size = physmem_size; |
351 | avail = TASK_SIZE - start_vm; | 352 | stack = (unsigned long) argv; |
353 | stack &= ~(1024 * 1024 - 1); | ||
354 | avail = stack - start_vm; | ||
352 | if (physmem_size > avail) | 355 | if (physmem_size > avail) |
353 | virtmem_size = avail; | 356 | virtmem_size = avail; |
354 | end_vm = start_vm + virtmem_size; | 357 | end_vm = start_vm + virtmem_size; |
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index 5828c1d54505..11b835248b86 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <asm-generic/vmlinux.lds.h> | 1 | #include <asm-generic/vmlinux.lds.h> |
2 | #include <asm/page.h> | ||
2 | 3 | ||
3 | OUTPUT_FORMAT(ELF_FORMAT) | 4 | OUTPUT_FORMAT(ELF_FORMAT) |
4 | OUTPUT_ARCH(ELF_ARCH) | 5 | OUTPUT_ARCH(ELF_ARCH) |
@@ -26,7 +27,7 @@ SECTIONS | |||
26 | INIT_TEXT | 27 | INIT_TEXT |
27 | _einittext = .; | 28 | _einittext = .; |
28 | } | 29 | } |
29 | . = ALIGN(4096); | 30 | . = ALIGN(PAGE_SIZE); |
30 | 31 | ||
31 | .text : | 32 | .text : |
32 | { | 33 | { |
@@ -39,7 +40,7 @@ SECTIONS | |||
39 | *(.gnu.linkonce.t*) | 40 | *(.gnu.linkonce.t*) |
40 | } | 41 | } |
41 | 42 | ||
42 | . = ALIGN(4096); | 43 | . = ALIGN(PAGE_SIZE); |
43 | .syscall_stub : { | 44 | .syscall_stub : { |
44 | __syscall_stub_start = .; | 45 | __syscall_stub_start = .; |
45 | *(.__syscall_stub*) | 46 | *(.__syscall_stub*) |
@@ -79,7 +80,7 @@ SECTIONS | |||
79 | .sdata : { *(.sdata) } | 80 | .sdata : { *(.sdata) } |
80 | _edata = .; | 81 | _edata = .; |
81 | PROVIDE (edata = .); | 82 | PROVIDE (edata = .); |
82 | . = ALIGN(0x1000); | 83 | . = ALIGN(PAGE_SIZE); |
83 | .sbss : | 84 | .sbss : |
84 | { | 85 | { |
85 | __bss_start = .; | 86 | __bss_start = .; |
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c index 6fb0b174f538..cc72cb2c1af6 100644 --- a/arch/um/os-Linux/drivers/ethertap_user.c +++ b/arch/um/os-Linux/drivers/ethertap_user.c | |||
@@ -52,7 +52,7 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask, | |||
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | 54 | ||
55 | output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL); | 55 | output = uml_kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL); |
56 | if (output == NULL) | 56 | if (output == NULL) |
57 | printk(UM_KERN_ERR "etap_change : Failed to allocate output " | 57 | printk(UM_KERN_ERR "etap_change : Failed to allocate output " |
58 | "buffer\n"); | 58 | "buffer\n"); |
@@ -165,7 +165,7 @@ static int etap_open(void *data) | |||
165 | err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], | 165 | err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], |
166 | control_fds[1], data_fds[0], data_fds[1]); | 166 | control_fds[1], data_fds[0], data_fds[1]); |
167 | output_len = UM_KERN_PAGE_SIZE; | 167 | output_len = UM_KERN_PAGE_SIZE; |
168 | output = kmalloc(output_len, UM_GFP_KERNEL); | 168 | output = uml_kmalloc(output_len, UM_GFP_KERNEL); |
169 | read_output(control_fds[0], output, output_len); | 169 | read_output(control_fds[0], output, output_len); |
170 | 170 | ||
171 | if (output == NULL) | 171 | if (output == NULL) |
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index f25c29a12d00..74ca7aabf4e1 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -71,8 +71,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv) | |||
71 | data.pre_data = pre_data; | 71 | data.pre_data = pre_data; |
72 | data.argv = argv; | 72 | data.argv = argv; |
73 | data.fd = fds[1]; | 73 | data.fd = fds[1]; |
74 | data.buf = __cant_sleep() ? kmalloc(PATH_MAX, UM_GFP_ATOMIC) : | 74 | data.buf = __cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) : |
75 | kmalloc(PATH_MAX, UM_GFP_KERNEL); | 75 | uml_kmalloc(PATH_MAX, UM_GFP_KERNEL); |
76 | pid = clone(helper_child, (void *) sp, CLONE_VM, &data); | 76 | pid = clone(helper_child, (void *) sp, CLONE_VM, &data); |
77 | if (pid < 0) { | 77 | if (pid < 0) { |
78 | ret = -errno; | 78 | ret = -errno; |
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c index abb9b0ffd960..eee69b9f52c9 100644 --- a/arch/um/os-Linux/main.c +++ b/arch/um/os-Linux/main.c | |||
@@ -199,7 +199,7 @@ void *__wrap_malloc(int size) | |||
199 | return __real_malloc(size); | 199 | return __real_malloc(size); |
200 | else if (size <= UM_KERN_PAGE_SIZE) | 200 | else if (size <= UM_KERN_PAGE_SIZE) |
201 | /* finding contiguous pages can be hard*/ | 201 | /* finding contiguous pages can be hard*/ |
202 | ret = kmalloc(size, UM_GFP_KERNEL); | 202 | ret = uml_kmalloc(size, UM_GFP_KERNEL); |
203 | else ret = vmalloc(size); | 203 | else ret = vmalloc(size); |
204 | 204 | ||
205 | /* | 205 | /* |
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c index abf47a7c4abd..eb8f2e4be192 100644 --- a/arch/um/os-Linux/sigio.c +++ b/arch/um/os-Linux/sigio.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | 2 | * Copyright (C) 2002 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -15,6 +15,7 @@ | |||
15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
16 | #include "init.h" | 16 | #include "init.h" |
17 | #include "os.h" | 17 | #include "os.h" |
18 | #include "process.h" | ||
18 | #include "sigio.h" | 19 | #include "sigio.h" |
19 | #include "um_malloc.h" | 20 | #include "um_malloc.h" |
20 | #include "user.h" | 21 | #include "user.h" |
@@ -109,7 +110,7 @@ static int need_poll(struct pollfds *polls, int n) | |||
109 | if (n <= polls->size) | 110 | if (n <= polls->size) |
110 | return 0; | 111 | return 0; |
111 | 112 | ||
112 | new = kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC); | 113 | new = uml_kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC); |
113 | if (new == NULL) { | 114 | if (new == NULL) { |
114 | printk(UM_KERN_ERR "need_poll : failed to allocate new " | 115 | printk(UM_KERN_ERR "need_poll : failed to allocate new " |
115 | "pollfds\n"); | 116 | "pollfds\n"); |
@@ -243,7 +244,7 @@ static struct pollfd *setup_initial_poll(int fd) | |||
243 | { | 244 | { |
244 | struct pollfd *p; | 245 | struct pollfd *p; |
245 | 246 | ||
246 | p = kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL); | 247 | p = uml_kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL); |
247 | if (p == NULL) { | 248 | if (p == NULL) { |
248 | printk(UM_KERN_ERR "setup_initial_poll : failed to allocate " | 249 | printk(UM_KERN_ERR "setup_initial_poll : failed to allocate " |
249 | "poll\n"); | 250 | "poll\n"); |
@@ -338,20 +339,10 @@ out_close1: | |||
338 | close(l_write_sigio_fds[1]); | 339 | close(l_write_sigio_fds[1]); |
339 | } | 340 | } |
340 | 341 | ||
341 | /* Changed during early boot */ | 342 | void sigio_broken(int fd, int read) |
342 | static int pty_output_sigio = 0; | ||
343 | static int pty_close_sigio = 0; | ||
344 | |||
345 | void maybe_sigio_broken(int fd, int read) | ||
346 | { | 343 | { |
347 | int err; | 344 | int err; |
348 | 345 | ||
349 | if (!isatty(fd)) | ||
350 | return; | ||
351 | |||
352 | if ((read || pty_output_sigio) && (!read || pty_close_sigio)) | ||
353 | return; | ||
354 | |||
355 | write_sigio_workaround(); | 346 | write_sigio_workaround(); |
356 | 347 | ||
357 | sigio_lock(); | 348 | sigio_lock(); |
@@ -370,6 +361,21 @@ out: | |||
370 | sigio_unlock(); | 361 | sigio_unlock(); |
371 | } | 362 | } |
372 | 363 | ||
364 | /* Changed during early boot */ | ||
365 | static int pty_output_sigio; | ||
366 | static int pty_close_sigio; | ||
367 | |||
368 | void maybe_sigio_broken(int fd, int read) | ||
369 | { | ||
370 | if (!isatty(fd)) | ||
371 | return; | ||
372 | |||
373 | if ((read || pty_output_sigio) && (!read || pty_close_sigio)) | ||
374 | return; | ||
375 | |||
376 | sigio_broken(fd, read); | ||
377 | } | ||
378 | |||
373 | static void sigio_cleanup(void) | 379 | static void sigio_cleanup(void) |
374 | { | 380 | { |
375 | if (write_sigio_pid == -1) | 381 | if (write_sigio_pid == -1) |
@@ -383,7 +389,7 @@ static void sigio_cleanup(void) | |||
383 | __uml_exitcall(sigio_cleanup); | 389 | __uml_exitcall(sigio_cleanup); |
384 | 390 | ||
385 | /* Used as a flag during SIGIO testing early in boot */ | 391 | /* Used as a flag during SIGIO testing early in boot */ |
386 | static volatile int got_sigio = 0; | 392 | static int got_sigio; |
387 | 393 | ||
388 | static void __init handler(int sig) | 394 | static void __init handler(int sig) |
389 | { | 395 | { |
@@ -498,7 +504,8 @@ static void tty_output(int master, int slave) | |||
498 | if (errno != EAGAIN) | 504 | if (errno != EAGAIN) |
499 | printk(UM_KERN_ERR "tty_output : write failed, errno = %d\n", | 505 | printk(UM_KERN_ERR "tty_output : write failed, errno = %d\n", |
500 | errno); | 506 | errno); |
501 | while (((n = read(slave, buf, sizeof(buf))) > 0) && !got_sigio) | 507 | while (((n = read(slave, buf, sizeof(buf))) > 0) && |
508 | !({ barrier(); got_sigio; })) | ||
502 | ; | 509 | ; |
503 | 510 | ||
504 | if (got_sigio) { | 511 | if (got_sigio) { |
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 3f1694b134cb..5aade6027e40 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "as-layout.h" | 12 | #include "as-layout.h" |
13 | #include "kern_util.h" | 13 | #include "kern_util.h" |
14 | #include "os.h" | 14 | #include "os.h" |
15 | #include "process.h" | ||
15 | #include "sysdep/barrier.h" | 16 | #include "sysdep/barrier.h" |
16 | #include "sysdep/sigcontext.h" | 17 | #include "sysdep/sigcontext.h" |
17 | #include "user.h" | 18 | #include "user.h" |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 1e8cba6550a9..6be028ca1817 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -442,7 +442,7 @@ void userspace(struct uml_pt_regs *regs) | |||
442 | unblock_signals(); | 442 | unblock_signals(); |
443 | break; | 443 | break; |
444 | default: | 444 | default: |
445 | printk(UM_KERN_ERR "userspace - child stopped " | 445 | printk(UM_KERN_ERR "userspace - child stopped " |
446 | "with signal %d\n", sig); | 446 | "with signal %d\n", sig); |
447 | fatal_sigsegv(); | 447 | fatal_sigsegv(); |
448 | } | 448 | } |
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 997d01944f91..b4b36e0f2e89 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "mem_user.h" | 23 | #include "mem_user.h" |
24 | #include "ptrace_user.h" | 24 | #include "ptrace_user.h" |
25 | #include "registers.h" | 25 | #include "registers.h" |
26 | #include "skas.h" | ||
26 | #include "skas_ptrace.h" | 27 | #include "skas_ptrace.h" |
27 | 28 | ||
28 | static void ptrace_child(void) | 29 | static void ptrace_child(void) |
@@ -140,14 +141,27 @@ static int stop_ptraced_child(int pid, int exitcode, int mustexit) | |||
140 | } | 141 | } |
141 | 142 | ||
142 | /* Changed only during early boot */ | 143 | /* Changed only during early boot */ |
143 | int ptrace_faultinfo = 1; | 144 | int ptrace_faultinfo; |
144 | int ptrace_ldt = 1; | 145 | static int disable_ptrace_faultinfo; |
145 | int proc_mm = 1; | 146 | |
146 | int skas_needs_stub = 0; | 147 | int ptrace_ldt; |
148 | static int disable_ptrace_ldt; | ||
149 | |||
150 | int proc_mm; | ||
151 | static int disable_proc_mm; | ||
152 | |||
153 | int have_switch_mm; | ||
154 | static int disable_switch_mm; | ||
155 | |||
156 | int skas_needs_stub; | ||
147 | 157 | ||
148 | static int __init skas0_cmd_param(char *str, int* add) | 158 | static int __init skas0_cmd_param(char *str, int* add) |
149 | { | 159 | { |
150 | ptrace_faultinfo = proc_mm = 0; | 160 | disable_ptrace_faultinfo = 1; |
161 | disable_ptrace_ldt = 1; | ||
162 | disable_proc_mm = 1; | ||
163 | disable_switch_mm = 1; | ||
164 | |||
151 | return 0; | 165 | return 0; |
152 | } | 166 | } |
153 | 167 | ||
@@ -157,15 +171,12 @@ static int __init mode_skas0_cmd_param(char *str, int* add) | |||
157 | __attribute__((alias("skas0_cmd_param"))); | 171 | __attribute__((alias("skas0_cmd_param"))); |
158 | 172 | ||
159 | __uml_setup("skas0", skas0_cmd_param, | 173 | __uml_setup("skas0", skas0_cmd_param, |
160 | "skas0\n" | 174 | "skas0\n" |
161 | " Disables SKAS3 usage, so that SKAS0 is used, unless \n" | 175 | " Disables SKAS3 and SKAS4 usage, so that SKAS0 is used\n\n"); |
162 | " you specify mode=tt.\n\n"); | ||
163 | 176 | ||
164 | __uml_setup("mode=skas0", mode_skas0_cmd_param, | 177 | __uml_setup("mode=skas0", mode_skas0_cmd_param, |
165 | "mode=skas0\n" | 178 | "mode=skas0\n" |
166 | " Disables SKAS3 usage, so that SKAS0 is used, unless you \n" | 179 | " Disables SKAS3 and SKAS4 usage, so that SKAS0 is used.\n\n"); |
167 | " specify mode=tt. Note that this was recently added - on \n" | ||
168 | " older kernels you must use simply \"skas0\".\n\n"); | ||
169 | 180 | ||
170 | /* Changed only during early boot */ | 181 | /* Changed only during early boot */ |
171 | static int force_sysemu_disabled = 0; | 182 | static int force_sysemu_disabled = 0; |
@@ -360,7 +371,7 @@ void __init os_early_checks(void) | |||
360 | 371 | ||
361 | static int __init noprocmm_cmd_param(char *str, int* add) | 372 | static int __init noprocmm_cmd_param(char *str, int* add) |
362 | { | 373 | { |
363 | proc_mm = 0; | 374 | disable_proc_mm = 1; |
364 | return 0; | 375 | return 0; |
365 | } | 376 | } |
366 | 377 | ||
@@ -372,7 +383,7 @@ __uml_setup("noprocmm", noprocmm_cmd_param, | |||
372 | 383 | ||
373 | static int __init noptracefaultinfo_cmd_param(char *str, int* add) | 384 | static int __init noptracefaultinfo_cmd_param(char *str, int* add) |
374 | { | 385 | { |
375 | ptrace_faultinfo = 0; | 386 | disable_ptrace_faultinfo = 1; |
376 | return 0; | 387 | return 0; |
377 | } | 388 | } |
378 | 389 | ||
@@ -384,7 +395,7 @@ __uml_setup("noptracefaultinfo", noptracefaultinfo_cmd_param, | |||
384 | 395 | ||
385 | static int __init noptraceldt_cmd_param(char *str, int* add) | 396 | static int __init noptraceldt_cmd_param(char *str, int* add) |
386 | { | 397 | { |
387 | ptrace_ldt = 0; | 398 | disable_ptrace_ldt = 1; |
388 | return 0; | 399 | return 0; |
389 | } | 400 | } |
390 | 401 | ||
@@ -404,17 +415,15 @@ static inline void check_skas3_ptrace_faultinfo(void) | |||
404 | 415 | ||
405 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); | 416 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
406 | if (n < 0) { | 417 | if (n < 0) { |
407 | ptrace_faultinfo = 0; | ||
408 | if (errno == EIO) | 418 | if (errno == EIO) |
409 | non_fatal("not found\n"); | 419 | non_fatal("not found\n"); |
410 | else | 420 | else |
411 | perror("not found"); | 421 | perror("not found"); |
412 | } | 422 | } else if (disable_ptrace_faultinfo) |
423 | non_fatal("found but disabled on command line\n"); | ||
413 | else { | 424 | else { |
414 | if (!ptrace_faultinfo) | 425 | ptrace_faultinfo = 1; |
415 | non_fatal("found but disabled on command line\n"); | 426 | non_fatal("found\n"); |
416 | else | ||
417 | non_fatal("found\n"); | ||
418 | } | 427 | } |
419 | 428 | ||
420 | stop_ptraced_child(pid, 1, 1); | 429 | stop_ptraced_child(pid, 1, 1); |
@@ -437,38 +446,30 @@ static inline void check_skas3_ptrace_ldt(void) | |||
437 | if (n < 0) { | 446 | if (n < 0) { |
438 | if (errno == EIO) | 447 | if (errno == EIO) |
439 | non_fatal("not found\n"); | 448 | non_fatal("not found\n"); |
440 | else { | 449 | else |
441 | perror("not found"); | 450 | perror("not found"); |
442 | } | 451 | } else if (disable_ptrace_ldt) |
443 | ptrace_ldt = 0; | 452 | non_fatal("found, but use is disabled\n"); |
444 | } | ||
445 | else { | 453 | else { |
446 | if (ptrace_ldt) | 454 | ptrace_ldt = 1; |
447 | non_fatal("found\n"); | 455 | non_fatal("found\n"); |
448 | else | ||
449 | non_fatal("found, but use is disabled\n"); | ||
450 | } | 456 | } |
451 | 457 | ||
452 | stop_ptraced_child(pid, 1, 1); | 458 | stop_ptraced_child(pid, 1, 1); |
453 | #else | ||
454 | /* PTRACE_LDT might be disabled via cmdline option. | ||
455 | * We want to override this, else we might use the stub | ||
456 | * without real need | ||
457 | */ | ||
458 | ptrace_ldt = 1; | ||
459 | #endif | 459 | #endif |
460 | } | 460 | } |
461 | 461 | ||
462 | static inline void check_skas3_proc_mm(void) | 462 | static inline void check_skas3_proc_mm(void) |
463 | { | 463 | { |
464 | non_fatal(" - /proc/mm..."); | 464 | non_fatal(" - /proc/mm..."); |
465 | if (access("/proc/mm", W_OK) < 0) { | 465 | if (access("/proc/mm", W_OK) < 0) |
466 | proc_mm = 0; | ||
467 | perror("not found"); | 466 | perror("not found"); |
468 | } | 467 | else if (disable_proc_mm) |
469 | else if (!proc_mm) | ||
470 | non_fatal("found but disabled on command line\n"); | 468 | non_fatal("found but disabled on command line\n"); |
471 | else non_fatal("found\n"); | 469 | else { |
470 | proc_mm = 1; | ||
471 | non_fatal("found\n"); | ||
472 | } | ||
472 | } | 473 | } |
473 | 474 | ||
474 | void can_do_skas(void) | 475 | void can_do_skas(void) |
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c index b613473b3ec1..c6183e7aec3d 100644 --- a/arch/um/os-Linux/sys-i386/registers.c +++ b/arch/um/os-Linux/sys-i386/registers.c | |||
@@ -5,6 +5,7 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <errno.h> | 7 | #include <errno.h> |
8 | #include <asm/user.h> | ||
8 | #include "kern_constants.h" | 9 | #include "kern_constants.h" |
9 | #include "longjmp.h" | 10 | #include "longjmp.h" |
10 | #include "user.h" | 11 | #include "user.h" |
@@ -74,10 +75,10 @@ int put_fp_registers(int pid, unsigned long *regs) | |||
74 | 75 | ||
75 | void arch_init_registers(int pid) | 76 | void arch_init_registers(int pid) |
76 | { | 77 | { |
77 | unsigned long fpx_regs[HOST_XFP_SIZE]; | 78 | struct user_fxsr_struct fpx_regs; |
78 | int err; | 79 | int err; |
79 | 80 | ||
80 | err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs); | 81 | err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs); |
81 | if (!err) | 82 | if (!err) |
82 | return; | 83 | return; |
83 | 84 | ||
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index e49280599465..bee98f466d66 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c | |||
@@ -9,7 +9,9 @@ | |||
9 | #include <time.h> | 9 | #include <time.h> |
10 | #include <sys/time.h> | 10 | #include <sys/time.h> |
11 | #include "kern_constants.h" | 11 | #include "kern_constants.h" |
12 | #include "kern_util.h" | ||
12 | #include "os.h" | 13 | #include "os.h" |
14 | #include "process.h" | ||
13 | #include "user.h" | 15 | #include "user.h" |
14 | 16 | ||
15 | int set_interval(void) | 17 | int set_interval(void) |
@@ -58,12 +60,17 @@ static inline long long timeval_to_ns(const struct timeval *tv) | |||
58 | long long disable_timer(void) | 60 | long long disable_timer(void) |
59 | { | 61 | { |
60 | struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } }); | 62 | struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } }); |
63 | int remain, max = UM_NSEC_PER_SEC / UM_HZ; | ||
61 | 64 | ||
62 | if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0) | 65 | if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0) |
63 | printk(UM_KERN_ERR "disable_timer - setitimer failed, " | 66 | printk(UM_KERN_ERR "disable_timer - setitimer failed, " |
64 | "errno = %d\n", errno); | 67 | "errno = %d\n", errno); |
65 | 68 | ||
66 | return timeval_to_ns(&time.it_value); | 69 | remain = timeval_to_ns(&time.it_value); |
70 | if (remain > max) | ||
71 | remain = max; | ||
72 | |||
73 | return remain; | ||
67 | } | 74 | } |
68 | 75 | ||
69 | long long os_nsecs(void) | 76 | long long os_nsecs(void) |
@@ -79,7 +86,44 @@ static int after_sleep_interval(struct timespec *ts) | |||
79 | { | 86 | { |
80 | return 0; | 87 | return 0; |
81 | } | 88 | } |
89 | |||
90 | static void deliver_alarm(void) | ||
91 | { | ||
92 | alarm_handler(SIGVTALRM, NULL); | ||
93 | } | ||
94 | |||
95 | static unsigned long long sleep_time(unsigned long long nsecs) | ||
96 | { | ||
97 | return nsecs; | ||
98 | } | ||
99 | |||
82 | #else | 100 | #else |
101 | unsigned long long last_tick; | ||
102 | unsigned long long skew; | ||
103 | |||
104 | static void deliver_alarm(void) | ||
105 | { | ||
106 | unsigned long long this_tick = os_nsecs(); | ||
107 | int one_tick = UM_NSEC_PER_SEC / UM_HZ; | ||
108 | |||
109 | if (last_tick == 0) | ||
110 | last_tick = this_tick - one_tick; | ||
111 | |||
112 | skew += this_tick - last_tick; | ||
113 | |||
114 | while (skew >= one_tick) { | ||
115 | alarm_handler(SIGVTALRM, NULL); | ||
116 | skew -= one_tick; | ||
117 | } | ||
118 | |||
119 | last_tick = this_tick; | ||
120 | } | ||
121 | |||
122 | static unsigned long long sleep_time(unsigned long long nsecs) | ||
123 | { | ||
124 | return nsecs > skew ? nsecs - skew : 0; | ||
125 | } | ||
126 | |||
83 | static inline long long timespec_to_us(const struct timespec *ts) | 127 | static inline long long timespec_to_us(const struct timespec *ts) |
84 | { | 128 | { |
85 | return ((long long) ts->tv_sec * UM_USEC_PER_SEC) + | 129 | return ((long long) ts->tv_sec * UM_USEC_PER_SEC) + |
@@ -102,6 +146,8 @@ static int after_sleep_interval(struct timespec *ts) | |||
102 | */ | 146 | */ |
103 | if (start_usecs > usec) | 147 | if (start_usecs > usec) |
104 | start_usecs = usec; | 148 | start_usecs = usec; |
149 | |||
150 | start_usecs -= skew / UM_NSEC_PER_USEC; | ||
105 | tv = ((struct timeval) { .tv_sec = start_usecs / UM_USEC_PER_SEC, | 151 | tv = ((struct timeval) { .tv_sec = start_usecs / UM_USEC_PER_SEC, |
106 | .tv_usec = start_usecs % UM_USEC_PER_SEC }); | 152 | .tv_usec = start_usecs % UM_USEC_PER_SEC }); |
107 | interval = ((struct itimerval) { { 0, usec }, tv }); | 153 | interval = ((struct itimerval) { { 0, usec }, tv }); |
@@ -113,8 +159,6 @@ static int after_sleep_interval(struct timespec *ts) | |||
113 | } | 159 | } |
114 | #endif | 160 | #endif |
115 | 161 | ||
116 | extern void alarm_handler(int sig, struct sigcontext *sc); | ||
117 | |||
118 | void idle_sleep(unsigned long long nsecs) | 162 | void idle_sleep(unsigned long long nsecs) |
119 | { | 163 | { |
120 | struct timespec ts; | 164 | struct timespec ts; |
@@ -126,10 +170,12 @@ void idle_sleep(unsigned long long nsecs) | |||
126 | */ | 170 | */ |
127 | if (nsecs == 0) | 171 | if (nsecs == 0) |
128 | nsecs = UM_NSEC_PER_SEC / UM_HZ; | 172 | nsecs = UM_NSEC_PER_SEC / UM_HZ; |
173 | |||
174 | nsecs = sleep_time(nsecs); | ||
129 | ts = ((struct timespec) { .tv_sec = nsecs / UM_NSEC_PER_SEC, | 175 | ts = ((struct timespec) { .tv_sec = nsecs / UM_NSEC_PER_SEC, |
130 | .tv_nsec = nsecs % UM_NSEC_PER_SEC }); | 176 | .tv_nsec = nsecs % UM_NSEC_PER_SEC }); |
131 | 177 | ||
132 | if (nanosleep(&ts, &ts) == 0) | 178 | if (nanosleep(&ts, &ts) == 0) |
133 | alarm_handler(SIGVTALRM, NULL); | 179 | deliver_alarm(); |
134 | after_sleep_interval(&ts); | 180 | after_sleep_interval(&ts); |
135 | } | 181 | } |
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c index 6b4499906a6c..c9b176534d65 100644 --- a/arch/um/sys-i386/ptrace.c +++ b/arch/um/sys-i386/ptrace.c | |||
@@ -148,14 +148,13 @@ int peek_user(struct task_struct *child, long addr, long data) | |||
148 | int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) | 148 | int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) |
149 | { | 149 | { |
150 | int err, n, cpu = ((struct thread_info *) child->stack)->cpu; | 150 | int err, n, cpu = ((struct thread_info *) child->stack)->cpu; |
151 | long fpregs[HOST_FP_SIZE]; | 151 | struct user_i387_struct fpregs; |
152 | 152 | ||
153 | BUG_ON(sizeof(*buf) != sizeof(fpregs)); | 153 | err = save_fp_registers(userspace_pid[cpu], (unsigned long *) &fpregs); |
154 | err = save_fp_registers(userspace_pid[cpu], fpregs); | ||
155 | if (err) | 154 | if (err) |
156 | return err; | 155 | return err; |
157 | 156 | ||
158 | n = copy_to_user(buf, fpregs, sizeof(fpregs)); | 157 | n = copy_to_user(buf, &fpregs, sizeof(fpregs)); |
159 | if(n > 0) | 158 | if(n > 0) |
160 | return -EFAULT; | 159 | return -EFAULT; |
161 | 160 | ||
@@ -165,27 +164,26 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) | |||
165 | int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) | 164 | int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) |
166 | { | 165 | { |
167 | int n, cpu = ((struct thread_info *) child->stack)->cpu; | 166 | int n, cpu = ((struct thread_info *) child->stack)->cpu; |
168 | long fpregs[HOST_FP_SIZE]; | 167 | struct user_i387_struct fpregs; |
169 | 168 | ||
170 | BUG_ON(sizeof(*buf) != sizeof(fpregs)); | 169 | n = copy_from_user(&fpregs, buf, sizeof(fpregs)); |
171 | n = copy_from_user(fpregs, buf, sizeof(fpregs)); | ||
172 | if (n > 0) | 170 | if (n > 0) |
173 | return -EFAULT; | 171 | return -EFAULT; |
174 | 172 | ||
175 | return restore_fp_registers(userspace_pid[cpu], fpregs); | 173 | return restore_fp_registers(userspace_pid[cpu], |
174 | (unsigned long *) &fpregs); | ||
176 | } | 175 | } |
177 | 176 | ||
178 | int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) | 177 | int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) |
179 | { | 178 | { |
180 | int err, n, cpu = ((struct thread_info *) child->stack)->cpu; | 179 | int err, n, cpu = ((struct thread_info *) child->stack)->cpu; |
181 | long fpregs[HOST_XFP_SIZE]; | 180 | struct user_fxsr_struct fpregs; |
182 | 181 | ||
183 | BUG_ON(sizeof(*buf) != sizeof(fpregs)); | 182 | err = save_fpx_registers(userspace_pid[cpu], (unsigned long *) &fpregs); |
184 | err = save_fpx_registers(userspace_pid[cpu], fpregs); | ||
185 | if (err) | 183 | if (err) |
186 | return err; | 184 | return err; |
187 | 185 | ||
188 | n = copy_to_user(buf, fpregs, sizeof(fpregs)); | 186 | n = copy_to_user(buf, &fpregs, sizeof(fpregs)); |
189 | if(n > 0) | 187 | if(n > 0) |
190 | return -EFAULT; | 188 | return -EFAULT; |
191 | 189 | ||
@@ -195,14 +193,14 @@ int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) | |||
195 | int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) | 193 | int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) |
196 | { | 194 | { |
197 | int n, cpu = ((struct thread_info *) child->stack)->cpu; | 195 | int n, cpu = ((struct thread_info *) child->stack)->cpu; |
198 | long fpregs[HOST_XFP_SIZE]; | 196 | struct user_fxsr_struct fpregs; |
199 | 197 | ||
200 | BUG_ON(sizeof(*buf) != sizeof(fpregs)); | 198 | n = copy_from_user(&fpregs, buf, sizeof(fpregs)); |
201 | n = copy_from_user(fpregs, buf, sizeof(fpregs)); | ||
202 | if (n > 0) | 199 | if (n > 0) |
203 | return -EFAULT; | 200 | return -EFAULT; |
204 | 201 | ||
205 | return restore_fpx_registers(userspace_pid[cpu], fpregs); | 202 | return restore_fpx_registers(userspace_pid[cpu], |
203 | (unsigned long *) &fpregs); | ||
206 | } | 204 | } |
207 | 205 | ||
208 | long subarch_ptrace(struct task_struct *child, long request, long addr, | 206 | long subarch_ptrace(struct task_struct *child, long request, long addr, |
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c index 39bd32bf84f0..5f883bfe773f 100644 --- a/arch/um/sys-i386/user-offsets.c +++ b/arch/um/sys-i386/user-offsets.c | |||
@@ -22,7 +22,7 @@ void foo(void) | |||
22 | OFFSET(HOST_SC_CR2, sigcontext, cr2); | 22 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
23 | 23 | ||
24 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct)); | 24 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct)); |
25 | DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fpxregs_struct)); | 25 | DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct)); |
26 | 26 | ||
27 | DEFINE(HOST_IP, EIP); | 27 | DEFINE(HOST_IP, EIP); |
28 | DEFINE(HOST_SP, UESP); | 28 | DEFINE(HOST_SP, UESP); |
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c index 2f3443c6e859..973585414a66 100644 --- a/arch/um/sys-x86_64/user-offsets.c +++ b/arch/um/sys-x86_64/user-offsets.c | |||
@@ -24,7 +24,6 @@ void foo(void) | |||
24 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); | 24 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
25 | 25 | ||
26 | DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); | 26 | DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); |
27 | DEFINE(HOST_XFP_SIZE, 0); | ||
28 | DEFINE_LONGS(HOST_RBX, RBX); | 27 | DEFINE_LONGS(HOST_RBX, RBX); |
29 | DEFINE_LONGS(HOST_RCX, RCX); | 28 | DEFINE_LONGS(HOST_RCX, RCX); |
30 | DEFINE_LONGS(HOST_RDI, RDI); | 29 | DEFINE_LONGS(HOST_RDI, RDI); |
diff --git a/arch/x86/kernel/acpi/realmode/wakeup.lds.S b/arch/x86/kernel/acpi/realmode/wakeup.lds.S index 22fab6c4be15..7da00b799cda 100644 --- a/arch/x86/kernel/acpi/realmode/wakeup.lds.S +++ b/arch/x86/kernel/acpi/realmode/wakeup.lds.S | |||
@@ -12,11 +12,6 @@ ENTRY(_start) | |||
12 | 12 | ||
13 | SECTIONS | 13 | SECTIONS |
14 | { | 14 | { |
15 | . = HEADER_OFFSET; | ||
16 | .header : { | ||
17 | *(.header) | ||
18 | } | ||
19 | |||
20 | . = 0; | 15 | . = 0; |
21 | .text : { | 16 | .text : { |
22 | *(.text*) | 17 | *(.text*) |
@@ -50,6 +45,11 @@ SECTIONS | |||
50 | __bss_end = .; | 45 | __bss_end = .; |
51 | } | 46 | } |
52 | 47 | ||
48 | . = HEADER_OFFSET; | ||
49 | .header : { | ||
50 | *(.header) | ||
51 | } | ||
52 | |||
53 | . = ALIGN(16); | 53 | . = ALIGN(16); |
54 | _end = .; | 54 | _end = .; |
55 | 55 | ||
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index 0c37f16b6950..c5ef1af8e79d 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c | |||
@@ -385,11 +385,13 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | |||
385 | if (dma_alloc_from_coherent_mem(dev, size, dma_handle, &memory)) | 385 | if (dma_alloc_from_coherent_mem(dev, size, dma_handle, &memory)) |
386 | return memory; | 386 | return memory; |
387 | 387 | ||
388 | if (!dev) | 388 | if (!dev) { |
389 | dev = &fallback_dev; | 389 | dev = &fallback_dev; |
390 | gfp |= GFP_DMA; | ||
391 | } | ||
390 | dma_mask = dev->coherent_dma_mask; | 392 | dma_mask = dev->coherent_dma_mask; |
391 | if (dma_mask == 0) | 393 | if (dma_mask == 0) |
392 | dma_mask = DMA_32BIT_MASK; | 394 | dma_mask = (gfp & GFP_DMA) ? DMA_24BIT_MASK : DMA_32BIT_MASK; |
393 | 395 | ||
394 | /* Device not DMA able */ | 396 | /* Device not DMA able */ |
395 | if (dev->dma_mask == NULL) | 397 | if (dev->dma_mask == NULL) |
@@ -403,7 +405,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | |||
403 | larger than 16MB and in this case we have a chance of | 405 | larger than 16MB and in this case we have a chance of |
404 | finding fitting memory in the next higher zone first. If | 406 | finding fitting memory in the next higher zone first. If |
405 | not retry with true GFP_DMA. -AK */ | 407 | not retry with true GFP_DMA. -AK */ |
406 | if (dma_mask <= DMA_32BIT_MASK) | 408 | if (dma_mask <= DMA_32BIT_MASK && !(gfp & GFP_DMA)) |
407 | gfp |= GFP_DMA32; | 409 | gfp |= GFP_DMA32; |
408 | #endif | 410 | #endif |
409 | 411 | ||
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index fb03ef380f0e..a7835f282936 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -1303,6 +1303,9 @@ static const struct user_regset_view user_x86_64_view = { | |||
1303 | #define genregs32_get genregs_get | 1303 | #define genregs32_get genregs_get |
1304 | #define genregs32_set genregs_set | 1304 | #define genregs32_set genregs_set |
1305 | 1305 | ||
1306 | #define user_i387_ia32_struct user_i387_struct | ||
1307 | #define user32_fxsr_struct user_fxsr_struct | ||
1308 | |||
1306 | #endif /* CONFIG_X86_64 */ | 1309 | #endif /* CONFIG_X86_64 */ |
1307 | 1310 | ||
1308 | #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION | 1311 | #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION |
@@ -1315,13 +1318,13 @@ static const struct user_regset x86_32_regsets[] = { | |||
1315 | }, | 1318 | }, |
1316 | [REGSET_FP] = { | 1319 | [REGSET_FP] = { |
1317 | .core_note_type = NT_PRFPREG, | 1320 | .core_note_type = NT_PRFPREG, |
1318 | .n = sizeof(struct user_i387_struct) / sizeof(u32), | 1321 | .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32), |
1319 | .size = sizeof(u32), .align = sizeof(u32), | 1322 | .size = sizeof(u32), .align = sizeof(u32), |
1320 | .active = fpregs_active, .get = fpregs_get, .set = fpregs_set | 1323 | .active = fpregs_active, .get = fpregs_get, .set = fpregs_set |
1321 | }, | 1324 | }, |
1322 | [REGSET_XFP] = { | 1325 | [REGSET_XFP] = { |
1323 | .core_note_type = NT_PRXFPREG, | 1326 | .core_note_type = NT_PRXFPREG, |
1324 | .n = sizeof(struct user_i387_struct) / sizeof(u32), | 1327 | .n = sizeof(struct user32_fxsr_struct) / sizeof(u32), |
1325 | .size = sizeof(u32), .align = sizeof(u32), | 1328 | .size = sizeof(u32), .align = sizeof(u32), |
1326 | .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set | 1329 | .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set |
1327 | }, | 1330 | }, |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index c0c68c18a788..6f80b852a196 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <asm/mpspec.h> | 12 | #include <asm/mpspec.h> |
13 | #include <asm/apicdef.h> | 13 | #include <asm/apicdef.h> |
14 | 14 | ||
15 | #ifdef CONFIG_X86_LOCAL_APIC | ||
15 | unsigned int num_processors; | 16 | unsigned int num_processors; |
16 | unsigned disabled_cpus __cpuinitdata; | 17 | unsigned disabled_cpus __cpuinitdata; |
17 | /* Processor that is doing the boot up */ | 18 | /* Processor that is doing the boot up */ |
@@ -23,8 +24,9 @@ EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid); | |||
23 | 24 | ||
24 | /* Bitmask of physically existing CPUs */ | 25 | /* Bitmask of physically existing CPUs */ |
25 | physid_mask_t phys_cpu_present_map; | 26 | physid_mask_t phys_cpu_present_map; |
27 | #endif | ||
26 | 28 | ||
27 | #if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_SMP) | 29 | #if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_X86_SMP) |
28 | /* | 30 | /* |
29 | * Copy data used in early init routines from the initial arrays to the | 31 | * Copy data used in early init routines from the initial arrays to the |
30 | * per cpu data areas. These arrays then become expendable and the | 32 | * per cpu data areas. These arrays then become expendable and the |
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c index f2fc8feb727d..6dff1286ad8a 100644 --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c | |||
@@ -951,7 +951,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c) | |||
951 | static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c) | 951 | static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c) |
952 | { | 952 | { |
953 | if (c->x86 == 0x6 && c->x86_model >= 0xf) | 953 | if (c->x86 == 0x6 && c->x86_model >= 0xf) |
954 | set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability); | 954 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); |
955 | } | 955 | } |
956 | 956 | ||
957 | static void __cpuinit init_centaur(struct cpuinfo_x86 *c) | 957 | static void __cpuinit init_centaur(struct cpuinfo_x86 *c) |
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index 8f75893a6467..0cb7aadc87cd 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c | |||
@@ -231,7 +231,8 @@ native_smp_call_function_mask(cpumask_t mask, | |||
231 | wmb(); | 231 | wmb(); |
232 | 232 | ||
233 | /* Send a message to other CPUs */ | 233 | /* Send a message to other CPUs */ |
234 | if (cpus_equal(mask, allbutself)) | 234 | if (cpus_equal(mask, allbutself) && |
235 | cpus_equal(cpu_online_map, cpu_callout_map)) | ||
235 | send_IPI_allbutself(CALL_FUNCTION_VECTOR); | 236 | send_IPI_allbutself(CALL_FUNCTION_VECTOR); |
236 | else | 237 | else |
237 | send_IPI_mask(mask, CALL_FUNCTION_VECTOR); | 238 | send_IPI_mask(mask, CALL_FUNCTION_VECTOR); |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 6b087ab6cd8f..38988491c622 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -86,6 +86,7 @@ void *x86_bios_cpu_apicid_early_ptr; | |||
86 | 86 | ||
87 | #ifdef CONFIG_X86_32 | 87 | #ifdef CONFIG_X86_32 |
88 | u8 apicid_2_node[MAX_APICID]; | 88 | u8 apicid_2_node[MAX_APICID]; |
89 | static int low_mappings; | ||
89 | #endif | 90 | #endif |
90 | 91 | ||
91 | /* State of each CPU */ | 92 | /* State of each CPU */ |
@@ -326,6 +327,12 @@ static void __cpuinit start_secondary(void *unused) | |||
326 | enable_8259A_irq(0); | 327 | enable_8259A_irq(0); |
327 | } | 328 | } |
328 | 329 | ||
330 | #ifdef CONFIG_X86_32 | ||
331 | while (low_mappings) | ||
332 | cpu_relax(); | ||
333 | __flush_tlb_all(); | ||
334 | #endif | ||
335 | |||
329 | /* This must be done before setting cpu_online_map */ | 336 | /* This must be done before setting cpu_online_map */ |
330 | set_cpu_sibling_map(raw_smp_processor_id()); | 337 | set_cpu_sibling_map(raw_smp_processor_id()); |
331 | wmb(); | 338 | wmb(); |
@@ -1040,14 +1047,20 @@ int __cpuinit native_cpu_up(unsigned int cpu) | |||
1040 | #ifdef CONFIG_X86_32 | 1047 | #ifdef CONFIG_X86_32 |
1041 | /* init low mem mapping */ | 1048 | /* init low mem mapping */ |
1042 | clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY, | 1049 | clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY, |
1043 | min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); | 1050 | min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); |
1044 | flush_tlb_all(); | 1051 | flush_tlb_all(); |
1045 | #endif | 1052 | low_mappings = 1; |
1046 | 1053 | ||
1047 | err = do_boot_cpu(apicid, cpu); | 1054 | err = do_boot_cpu(apicid, cpu); |
1048 | if (err < 0) { | 1055 | |
1056 | zap_low_mappings(); | ||
1057 | low_mappings = 0; | ||
1058 | #else | ||
1059 | err = do_boot_cpu(apicid, cpu); | ||
1060 | #endif | ||
1061 | if (err) { | ||
1049 | Dprintk("do_boot_cpu failed %d\n", err); | 1062 | Dprintk("do_boot_cpu failed %d\n", err); |
1050 | return err; | 1063 | return -EIO; |
1051 | } | 1064 | } |
1052 | 1065 | ||
1053 | /* | 1066 | /* |
@@ -1259,9 +1272,6 @@ void __init native_smp_cpus_done(unsigned int max_cpus) | |||
1259 | setup_ioapic_dest(); | 1272 | setup_ioapic_dest(); |
1260 | #endif | 1273 | #endif |
1261 | check_nmi_watchdog(); | 1274 | check_nmi_watchdog(); |
1262 | #ifdef CONFIG_X86_32 | ||
1263 | zap_low_mappings(); | ||
1264 | #endif | ||
1265 | } | 1275 | } |
1266 | 1276 | ||
1267 | #ifdef CONFIG_HOTPLUG_CPU | 1277 | #ifdef CONFIG_HOTPLUG_CPU |
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c index 58882f9f2637..f6c05d0410fb 100644 --- a/arch/x86/kernel/x8664_ksyms_64.c +++ b/arch/x86/kernel/x8664_ksyms_64.c | |||
@@ -2,6 +2,7 @@ | |||
2 | All C exports should go in the respective C files. */ | 2 | All C exports should go in the respective C files. */ |
3 | 3 | ||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <net/checksum.h> | ||
5 | #include <linux/smp.h> | 6 | #include <linux/smp.h> |
6 | 7 | ||
7 | #include <asm/processor.h> | 8 | #include <asm/processor.h> |
@@ -29,6 +30,8 @@ EXPORT_SYMBOL(__copy_from_user_inatomic); | |||
29 | EXPORT_SYMBOL(copy_page); | 30 | EXPORT_SYMBOL(copy_page); |
30 | EXPORT_SYMBOL(clear_page); | 31 | EXPORT_SYMBOL(clear_page); |
31 | 32 | ||
33 | EXPORT_SYMBOL(csum_partial); | ||
34 | |||
32 | /* | 35 | /* |
33 | * Export string functions. We normally rely on gcc builtin for most of these, | 36 | * Export string functions. We normally rely on gcc builtin for most of these, |
34 | * but gcc sometimes decides not to inline them. | 37 | * but gcc sometimes decides not to inline them. |
diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c index bc503f506903..bf51144d97e1 100644 --- a/arch/x86/lib/csum-partial_64.c +++ b/arch/x86/lib/csum-partial_64.c | |||
@@ -136,8 +136,6 @@ __wsum csum_partial(const void *buff, int len, __wsum sum) | |||
136 | (__force u32)sum); | 136 | (__force u32)sum); |
137 | } | 137 | } |
138 | 138 | ||
139 | EXPORT_SYMBOL(csum_partial); | ||
140 | |||
141 | /* | 139 | /* |
142 | * this routine is used for miscellaneous IP-like checksums, mainly | 140 | * this routine is used for miscellaneous IP-like checksums, mainly |
143 | * in icmp.c | 141 | * in icmp.c |
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index de236e419cb5..ec30d10154b6 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c | |||
@@ -438,8 +438,6 @@ void zap_low_mappings(void) | |||
438 | { | 438 | { |
439 | int i; | 439 | int i; |
440 | 440 | ||
441 | save_pg_dir(); | ||
442 | |||
443 | /* | 441 | /* |
444 | * Zap initial low-memory mappings. | 442 | * Zap initial low-memory mappings. |
445 | * | 443 | * |
@@ -663,16 +661,8 @@ void __init mem_init(void) | |||
663 | test_wp_bit(); | 661 | test_wp_bit(); |
664 | 662 | ||
665 | cpa_init(); | 663 | cpa_init(); |
666 | 664 | save_pg_dir(); | |
667 | /* | ||
668 | * Subtle. SMP is doing it's boot stuff late (because it has to | ||
669 | * fork idle threads) - but it also needs low mappings for the | ||
670 | * protected-mode entry to work. We zap these entries only after | ||
671 | * the WP-bit has been tested. | ||
672 | */ | ||
673 | #ifndef CONFIG_SMP | ||
674 | zap_low_mappings(); | 665 | zap_low_mappings(); |
675 | #endif | ||
676 | } | 666 | } |
677 | 667 | ||
678 | #ifdef CONFIG_MEMORY_HOTPLUG | 668 | #ifdef CONFIG_MEMORY_HOTPLUG |
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 60adbe22efa0..bcb1a8e4b2db 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -555,7 +555,7 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, | |||
555 | "%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n", | 555 | "%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n", |
556 | current->comm, current->pid, | 556 | current->comm, current->pid, |
557 | cattr_name(flags), | 557 | cattr_name(flags), |
558 | offset, offset + size); | 558 | offset, (unsigned long long)(offset + size)); |
559 | return 0; | 559 | return 0; |
560 | } | 560 | } |
561 | 561 | ||
@@ -576,7 +576,7 @@ void map_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot) | |||
576 | "%s:%d /dev/mem expected mapping type %s for %Lx-%Lx, got %s\n", | 576 | "%s:%d /dev/mem expected mapping type %s for %Lx-%Lx, got %s\n", |
577 | current->comm, current->pid, | 577 | current->comm, current->pid, |
578 | cattr_name(want_flags), | 578 | cattr_name(want_flags), |
579 | addr, addr + size, | 579 | addr, (unsigned long long)(addr + size), |
580 | cattr_name(flags)); | 580 | cattr_name(flags)); |
581 | } | 581 | } |
582 | } | 582 | } |
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 8af0f0bae2af..10fb308fded8 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -301,15 +301,13 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | |||
301 | prot = pgprot_val(vma->vm_page_prot); | 301 | prot = pgprot_val(vma->vm_page_prot); |
302 | if (pat_wc_enabled && write_combine) | 302 | if (pat_wc_enabled && write_combine) |
303 | prot |= _PAGE_CACHE_WC; | 303 | prot |= _PAGE_CACHE_WC; |
304 | else if (pat_wc_enabled) | 304 | else if (pat_wc_enabled || boot_cpu_data.x86 > 3) |
305 | /* | 305 | /* |
306 | * ioremap() and ioremap_nocache() defaults to UC MINUS for now. | 306 | * ioremap() and ioremap_nocache() defaults to UC MINUS for now. |
307 | * To avoid attribute conflicts, request UC MINUS here | 307 | * To avoid attribute conflicts, request UC MINUS here |
308 | * aswell. | 308 | * aswell. |
309 | */ | 309 | */ |
310 | prot |= _PAGE_CACHE_UC_MINUS; | 310 | prot |= _PAGE_CACHE_UC_MINUS; |
311 | else if (boot_cpu_data.x86 > 3) | ||
312 | prot |= _PAGE_CACHE_UC; | ||
313 | 311 | ||
314 | vma->vm_page_prot = __pgprot(prot); | 312 | vma->vm_page_prot = __pgprot(prot); |
315 | 313 | ||
diff --git a/block/blktrace.c b/block/blktrace.c index 568588cd16b2..b2cbb4e5d767 100644 --- a/block/blktrace.c +++ b/block/blktrace.c | |||
@@ -476,7 +476,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) | |||
476 | 476 | ||
477 | switch (cmd) { | 477 | switch (cmd) { |
478 | case BLKTRACESETUP: | 478 | case BLKTRACESETUP: |
479 | strcpy(b, bdevname(bdev, b)); | 479 | bdevname(bdev, b); |
480 | ret = blk_trace_setup(q, b, bdev->bd_dev, arg); | 480 | ret = blk_trace_setup(q, b, bdev->bd_dev, arg); |
481 | break; | 481 | break; |
482 | case BLKTRACESTART: | 482 | case BLKTRACESTART: |
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index c70d0b6f666f..c23177e4623f 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -555,7 +555,7 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg) | |||
555 | if (copy_from_user(&cbuts, arg, sizeof(cbuts))) | 555 | if (copy_from_user(&cbuts, arg, sizeof(cbuts))) |
556 | return -EFAULT; | 556 | return -EFAULT; |
557 | 557 | ||
558 | strcpy(b, bdevname(bdev, b)); | 558 | bdevname(bdev, b); |
559 | 559 | ||
560 | buts = (struct blk_user_trace_setup) { | 560 | buts = (struct blk_user_trace_setup) { |
561 | .act_mask = cbuts.act_mask, | 561 | .act_mask = cbuts.act_mask, |
diff --git a/block/genhd.c b/block/genhd.c index fda9c7a63c29..129ad939f9dd 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -653,7 +653,7 @@ void genhd_media_change_notify(struct gendisk *disk) | |||
653 | EXPORT_SYMBOL_GPL(genhd_media_change_notify); | 653 | EXPORT_SYMBOL_GPL(genhd_media_change_notify); |
654 | #endif /* 0 */ | 654 | #endif /* 0 */ |
655 | 655 | ||
656 | dev_t blk_lookup_devt(const char *name) | 656 | dev_t blk_lookup_devt(const char *name, int part) |
657 | { | 657 | { |
658 | struct device *dev; | 658 | struct device *dev; |
659 | dev_t devt = MKDEV(0, 0); | 659 | dev_t devt = MKDEV(0, 0); |
@@ -661,7 +661,11 @@ dev_t blk_lookup_devt(const char *name) | |||
661 | mutex_lock(&block_class_lock); | 661 | mutex_lock(&block_class_lock); |
662 | list_for_each_entry(dev, &block_class.devices, node) { | 662 | list_for_each_entry(dev, &block_class.devices, node) { |
663 | if (strcmp(dev->bus_id, name) == 0) { | 663 | if (strcmp(dev->bus_id, name) == 0) { |
664 | devt = dev->devt; | 664 | struct gendisk *disk = dev_to_disk(dev); |
665 | |||
666 | if (part < disk->minors) | ||
667 | devt = MKDEV(MAJOR(dev->devt), | ||
668 | MINOR(dev->devt) + part); | ||
665 | break; | 669 | break; |
666 | } | 670 | } |
667 | } | 671 | } |
@@ -669,7 +673,6 @@ dev_t blk_lookup_devt(const char *name) | |||
669 | 673 | ||
670 | return devt; | 674 | return devt; |
671 | } | 675 | } |
672 | |||
673 | EXPORT_SYMBOL(blk_lookup_devt); | 676 | EXPORT_SYMBOL(blk_lookup_devt); |
674 | 677 | ||
675 | struct gendisk *alloc_disk(int minors) | 678 | struct gendisk *alloc_disk(int minors) |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 0ef00e8d4153..e085af0ff94f 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -140,7 +140,6 @@ int class_register(struct class *cls) | |||
140 | 140 | ||
141 | pr_debug("device class '%s': registering\n", cls->name); | 141 | pr_debug("device class '%s': registering\n", cls->name); |
142 | 142 | ||
143 | INIT_LIST_HEAD(&cls->children); | ||
144 | INIT_LIST_HEAD(&cls->devices); | 143 | INIT_LIST_HEAD(&cls->devices); |
145 | INIT_LIST_HEAD(&cls->interfaces); | 144 | INIT_LIST_HEAD(&cls->interfaces); |
146 | kset_init(&cls->class_dirs); | 145 | kset_init(&cls->class_dirs); |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 8ce6de5a7e28..937e8258981d 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -53,11 +53,13 @@ int register_memory_notifier(struct notifier_block *nb) | |||
53 | { | 53 | { |
54 | return blocking_notifier_chain_register(&memory_chain, nb); | 54 | return blocking_notifier_chain_register(&memory_chain, nb); |
55 | } | 55 | } |
56 | EXPORT_SYMBOL(register_memory_notifier); | ||
56 | 57 | ||
57 | void unregister_memory_notifier(struct notifier_block *nb) | 58 | void unregister_memory_notifier(struct notifier_block *nb) |
58 | { | 59 | { |
59 | blocking_notifier_chain_unregister(&memory_chain, nb); | 60 | blocking_notifier_chain_unregister(&memory_chain, nb); |
60 | } | 61 | } |
62 | EXPORT_SYMBOL(unregister_memory_notifier); | ||
61 | 63 | ||
62 | /* | 64 | /* |
63 | * register_memory - Setup a sysfs device for a memory block | 65 | * register_memory - Setup a sysfs device for a memory block |
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 2001b0e52dc6..55c1653be00c 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -916,7 +916,7 @@ static int put_char(struct tty_struct *tty, unsigned char ch) | |||
916 | { | 916 | { |
917 | struct slgt_info *info = tty->driver_data; | 917 | struct slgt_info *info = tty->driver_data; |
918 | unsigned long flags; | 918 | unsigned long flags; |
919 | int ret; | 919 | int ret = 0; |
920 | 920 | ||
921 | if (sanity_check(info, tty->name, "put_char")) | 921 | if (sanity_check(info, tty->name, "put_char")) |
922 | return 0; | 922 | return 0; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 087eee0cb809..ee0ea9183080 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -2369,8 +2369,8 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh, | |||
2369 | 2369 | ||
2370 | /* complete a check operation */ | 2370 | /* complete a check operation */ |
2371 | if (test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) { | 2371 | if (test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) { |
2372 | clear_bit(STRIPE_OP_CHECK, &sh->ops.ack); | 2372 | clear_bit(STRIPE_OP_CHECK, &sh->ops.ack); |
2373 | clear_bit(STRIPE_OP_CHECK, &sh->ops.pending); | 2373 | clear_bit(STRIPE_OP_CHECK, &sh->ops.pending); |
2374 | if (s->failed == 0) { | 2374 | if (s->failed == 0) { |
2375 | if (sh->ops.zero_sum_result == 0) | 2375 | if (sh->ops.zero_sum_result == 0) |
2376 | /* parity is correct (on disc, | 2376 | /* parity is correct (on disc, |
@@ -2400,16 +2400,6 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh, | |||
2400 | canceled_check = 1; /* STRIPE_INSYNC is not set */ | 2400 | canceled_check = 1; /* STRIPE_INSYNC is not set */ |
2401 | } | 2401 | } |
2402 | 2402 | ||
2403 | /* check if we can clear a parity disk reconstruct */ | ||
2404 | if (test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete) && | ||
2405 | test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) { | ||
2406 | |||
2407 | clear_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending); | ||
2408 | clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete); | ||
2409 | clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.ack); | ||
2410 | clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending); | ||
2411 | } | ||
2412 | |||
2413 | /* start a new check operation if there are no failures, the stripe is | 2403 | /* start a new check operation if there are no failures, the stripe is |
2414 | * not insync, and a repair is not in flight | 2404 | * not insync, and a repair is not in flight |
2415 | */ | 2405 | */ |
@@ -2424,6 +2414,17 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh, | |||
2424 | } | 2414 | } |
2425 | } | 2415 | } |
2426 | 2416 | ||
2417 | /* check if we can clear a parity disk reconstruct */ | ||
2418 | if (test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete) && | ||
2419 | test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) { | ||
2420 | |||
2421 | clear_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending); | ||
2422 | clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete); | ||
2423 | clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.ack); | ||
2424 | clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending); | ||
2425 | } | ||
2426 | |||
2427 | |||
2427 | /* Wait for check parity and compute block operations to complete | 2428 | /* Wait for check parity and compute block operations to complete |
2428 | * before write-back. If a failure occurred while the check operation | 2429 | * before write-back. If a failure occurred while the check operation |
2429 | * was in flight we need to cycle this stripe through handle_stripe | 2430 | * was in flight we need to cycle this stripe through handle_stripe |
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index ddf57e135c6c..7a7803b5d497 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig | |||
@@ -89,8 +89,7 @@ config DVB_CORE | |||
89 | 89 | ||
90 | config VIDEO_MEDIA | 90 | config VIDEO_MEDIA |
91 | tristate | 91 | tristate |
92 | default DVB_CORE || VIDEO_DEV | 92 | default (DVB_CORE && (VIDEO_DEV = n)) || (VIDEO_DEV && (DVB_CORE = n)) || (DVB_CORE && VIDEO_DEV) |
93 | depends on DVB_CORE || VIDEO_DEV | ||
94 | 93 | ||
95 | comment "Multimedia drivers" | 94 | comment "Multimedia drivers" |
96 | 95 | ||
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig index 5be85ff53e12..d6206540476b 100644 --- a/drivers/media/common/tuners/Kconfig +++ b/drivers/media/common/tuners/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config MEDIA_ATTACH | 1 | config MEDIA_ATTACH |
2 | bool "Load and attach frontend and tuner driver modules as needed" | 2 | bool "Load and attach frontend and tuner driver modules as needed" |
3 | depends on DVB_CORE | 3 | depends on VIDEO_MEDIA |
4 | depends on MODULES | 4 | depends on MODULES |
5 | help | 5 | help |
6 | Remove the static dependency of DVB card drivers on all | 6 | Remove the static dependency of DVB card drivers on all |
@@ -19,10 +19,10 @@ config MEDIA_ATTACH | |||
19 | 19 | ||
20 | config MEDIA_TUNER | 20 | config MEDIA_TUNER |
21 | tristate | 21 | tristate |
22 | default DVB_CORE || VIDEO_DEV | 22 | default VIDEO_MEDIA && I2C |
23 | depends on DVB_CORE || VIDEO_DEV | 23 | depends on VIDEO_MEDIA && I2C |
24 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE | 24 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG |
25 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE | 25 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG |
26 | select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE | 26 | select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE |
27 | select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE | 27 | select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE |
28 | select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE | 28 | select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE |
@@ -46,7 +46,7 @@ if MEDIA_TUNER_CUSTOMIZE | |||
46 | 46 | ||
47 | config MEDIA_TUNER_SIMPLE | 47 | config MEDIA_TUNER_SIMPLE |
48 | tristate "Simple tuner support" | 48 | tristate "Simple tuner support" |
49 | depends on I2C | 49 | depends on VIDEO_MEDIA && I2C |
50 | select MEDIA_TUNER_TDA9887 | 50 | select MEDIA_TUNER_TDA9887 |
51 | default m if MEDIA_TUNER_CUSTOMIZE | 51 | default m if MEDIA_TUNER_CUSTOMIZE |
52 | help | 52 | help |
@@ -54,7 +54,7 @@ config MEDIA_TUNER_SIMPLE | |||
54 | 54 | ||
55 | config MEDIA_TUNER_TDA8290 | 55 | config MEDIA_TUNER_TDA8290 |
56 | tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" | 56 | tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" |
57 | depends on I2C | 57 | depends on VIDEO_MEDIA && I2C |
58 | select MEDIA_TUNER_TDA827X | 58 | select MEDIA_TUNER_TDA827X |
59 | select MEDIA_TUNER_TDA18271 | 59 | select MEDIA_TUNER_TDA18271 |
60 | default m if MEDIA_TUNER_CUSTOMIZE | 60 | default m if MEDIA_TUNER_CUSTOMIZE |
@@ -63,21 +63,21 @@ config MEDIA_TUNER_TDA8290 | |||
63 | 63 | ||
64 | config MEDIA_TUNER_TDA827X | 64 | config MEDIA_TUNER_TDA827X |
65 | tristate "Philips TDA827X silicon tuner" | 65 | tristate "Philips TDA827X silicon tuner" |
66 | depends on DVB_CORE && I2C | 66 | depends on VIDEO_MEDIA && I2C |
67 | default m if DVB_FE_CUSTOMISE | 67 | default m if DVB_FE_CUSTOMISE |
68 | help | 68 | help |
69 | A DVB-T silicon tuner module. Say Y when you want to support this tuner. | 69 | A DVB-T silicon tuner module. Say Y when you want to support this tuner. |
70 | 70 | ||
71 | config MEDIA_TUNER_TDA18271 | 71 | config MEDIA_TUNER_TDA18271 |
72 | tristate "NXP TDA18271 silicon tuner" | 72 | tristate "NXP TDA18271 silicon tuner" |
73 | depends on I2C | 73 | depends on VIDEO_MEDIA && I2C |
74 | default m if DVB_FE_CUSTOMISE | 74 | default m if DVB_FE_CUSTOMISE |
75 | help | 75 | help |
76 | A silicon tuner module. Say Y when you want to support this tuner. | 76 | A silicon tuner module. Say Y when you want to support this tuner. |
77 | 77 | ||
78 | config MEDIA_TUNER_TDA9887 | 78 | config MEDIA_TUNER_TDA9887 |
79 | tristate "TDA 9885/6/7 analog IF demodulator" | 79 | tristate "TDA 9885/6/7 analog IF demodulator" |
80 | depends on I2C | 80 | depends on VIDEO_MEDIA && I2C |
81 | default m if MEDIA_TUNER_CUSTOMIZE | 81 | default m if MEDIA_TUNER_CUSTOMIZE |
82 | help | 82 | help |
83 | Say Y here to include support for Philips TDA9885/6/7 | 83 | Say Y here to include support for Philips TDA9885/6/7 |
@@ -85,67 +85,79 @@ config MEDIA_TUNER_TDA9887 | |||
85 | 85 | ||
86 | config MEDIA_TUNER_TEA5761 | 86 | config MEDIA_TUNER_TEA5761 |
87 | tristate "TEA 5761 radio tuner (EXPERIMENTAL)" | 87 | tristate "TEA 5761 radio tuner (EXPERIMENTAL)" |
88 | depends on I2C && EXPERIMENTAL | 88 | depends on VIDEO_MEDIA && I2C |
89 | depends on EXPERIMENTAL | ||
89 | default m if MEDIA_TUNER_CUSTOMIZE | 90 | default m if MEDIA_TUNER_CUSTOMIZE |
90 | help | 91 | help |
91 | Say Y here to include support for the Philips TEA5761 radio tuner. | 92 | Say Y here to include support for the Philips TEA5761 radio tuner. |
92 | 93 | ||
93 | config MEDIA_TUNER_TEA5767 | 94 | config MEDIA_TUNER_TEA5767 |
94 | tristate "TEA 5767 radio tuner" | 95 | tristate "TEA 5767 radio tuner" |
95 | depends on I2C | 96 | depends on VIDEO_MEDIA && I2C |
96 | default m if MEDIA_TUNER_CUSTOMIZE | 97 | default m if MEDIA_TUNER_CUSTOMIZE |
97 | help | 98 | help |
98 | Say Y here to include support for the Philips TEA5767 radio tuner. | 99 | Say Y here to include support for the Philips TEA5767 radio tuner. |
99 | 100 | ||
100 | config MEDIA_TUNER_MT20XX | 101 | config MEDIA_TUNER_MT20XX |
101 | tristate "Microtune 2032 / 2050 tuners" | 102 | tristate "Microtune 2032 / 2050 tuners" |
102 | depends on I2C | 103 | depends on VIDEO_MEDIA && I2C |
103 | default m if MEDIA_TUNER_CUSTOMIZE | 104 | default m if MEDIA_TUNER_CUSTOMIZE |
104 | help | 105 | help |
105 | Say Y here to include support for the MT2032 / MT2050 tuner. | 106 | Say Y here to include support for the MT2032 / MT2050 tuner. |
106 | 107 | ||
107 | config MEDIA_TUNER_MT2060 | 108 | config MEDIA_TUNER_MT2060 |
108 | tristate "Microtune MT2060 silicon IF tuner" | 109 | tristate "Microtune MT2060 silicon IF tuner" |
109 | depends on I2C | 110 | depends on VIDEO_MEDIA && I2C |
110 | default m if DVB_FE_CUSTOMISE | 111 | default m if DVB_FE_CUSTOMISE |
111 | help | 112 | help |
112 | A driver for the silicon IF tuner MT2060 from Microtune. | 113 | A driver for the silicon IF tuner MT2060 from Microtune. |
113 | 114 | ||
114 | config MEDIA_TUNER_MT2266 | 115 | config MEDIA_TUNER_MT2266 |
115 | tristate "Microtune MT2266 silicon tuner" | 116 | tristate "Microtune MT2266 silicon tuner" |
116 | depends on I2C | 117 | depends on VIDEO_MEDIA && I2C |
117 | default m if DVB_FE_CUSTOMISE | 118 | default m if DVB_FE_CUSTOMISE |
118 | help | 119 | help |
119 | A driver for the silicon baseband tuner MT2266 from Microtune. | 120 | A driver for the silicon baseband tuner MT2266 from Microtune. |
120 | 121 | ||
121 | config MEDIA_TUNER_MT2131 | 122 | config MEDIA_TUNER_MT2131 |
122 | tristate "Microtune MT2131 silicon tuner" | 123 | tristate "Microtune MT2131 silicon tuner" |
123 | depends on I2C | 124 | depends on VIDEO_MEDIA && I2C |
124 | default m if DVB_FE_CUSTOMISE | 125 | default m if DVB_FE_CUSTOMISE |
125 | help | 126 | help |
126 | A driver for the silicon baseband tuner MT2131 from Microtune. | 127 | A driver for the silicon baseband tuner MT2131 from Microtune. |
127 | 128 | ||
128 | config MEDIA_TUNER_QT1010 | 129 | config MEDIA_TUNER_QT1010 |
129 | tristate "Quantek QT1010 silicon tuner" | 130 | tristate "Quantek QT1010 silicon tuner" |
130 | depends on DVB_CORE && I2C | 131 | depends on VIDEO_MEDIA && I2C |
131 | default m if DVB_FE_CUSTOMISE | 132 | default m if DVB_FE_CUSTOMISE |
132 | help | 133 | help |
133 | A driver for the silicon tuner QT1010 from Quantek. | 134 | A driver for the silicon tuner QT1010 from Quantek. |
134 | 135 | ||
135 | config MEDIA_TUNER_XC2028 | 136 | config MEDIA_TUNER_XC2028 |
136 | tristate "XCeive xc2028/xc3028 tuners" | 137 | tristate "XCeive xc2028/xc3028 tuners" |
137 | depends on I2C && FW_LOADER | 138 | depends on VIDEO_MEDIA && I2C |
139 | depends on HOTPLUG | ||
140 | select FW_LOADER | ||
138 | default m if MEDIA_TUNER_CUSTOMIZE | 141 | default m if MEDIA_TUNER_CUSTOMIZE |
139 | help | 142 | help |
140 | Say Y here to include support for the xc2028/xc3028 tuners. | 143 | Say Y here to include support for the xc2028/xc3028 tuners. |
141 | 144 | ||
142 | config MEDIA_TUNER_XC5000 | 145 | config MEDIA_TUNER_XC5000 |
143 | tristate "Xceive XC5000 silicon tuner" | 146 | tristate "Xceive XC5000 silicon tuner" |
144 | depends on I2C | 147 | depends on VIDEO_MEDIA && I2C |
148 | depends on HOTPLUG | ||
149 | select FW_LOADER | ||
145 | default m if DVB_FE_CUSTOMISE | 150 | default m if DVB_FE_CUSTOMISE |
146 | help | 151 | help |
147 | A driver for the silicon tuner XC5000 from Xceive. | 152 | A driver for the silicon tuner XC5000 from Xceive. |
148 | This device is only used inside a SiP called togther with a | 153 | This device is only used inside a SiP called togther with a |
149 | demodulator for now. | 154 | demodulator for now. |
150 | 155 | ||
156 | config MEDIA_TUNER_MXL5005S | ||
157 | tristate "MaxLinear MSL5005S silicon tuner" | ||
158 | depends on VIDEO_MEDIA && I2C | ||
159 | default m if DVB_FE_CUSTOMISE | ||
160 | help | ||
161 | A driver for the silicon tuner MXL5005S from MaxLinear. | ||
162 | |||
151 | endif # MEDIA_TUNER_CUSTOMIZE | 163 | endif # MEDIA_TUNER_CUSTOMIZE |
diff --git a/drivers/media/common/tuners/Makefile b/drivers/media/common/tuners/Makefile index 236d9932fd92..55f7e6706297 100644 --- a/drivers/media/common/tuners/Makefile +++ b/drivers/media/common/tuners/Makefile | |||
@@ -20,6 +20,7 @@ obj-$(CONFIG_MEDIA_TUNER_MT2060) += mt2060.o | |||
20 | obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o | 20 | obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o |
21 | obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o | 21 | obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o |
22 | obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o | 22 | obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o |
23 | obj-$(CONFIG_MEDIA_TUNER_MXL5005S) += mxl5005s.o | ||
23 | 24 | ||
24 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | 25 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
25 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | 26 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends |
diff --git a/drivers/media/common/tuners/mxl5005s.c b/drivers/media/common/tuners/mxl5005s.c new file mode 100644 index 000000000000..5d05b5390f66 --- /dev/null +++ b/drivers/media/common/tuners/mxl5005s.c | |||
@@ -0,0 +1,4110 @@ | |||
1 | /* | ||
2 | MaxLinear MXL5005S VSB/QAM/DVBT tuner driver | ||
3 | |||
4 | Copyright (C) 2008 MaxLinear | ||
5 | Copyright (C) 2006 Steven Toth <stoth@hauppauge.com> | ||
6 | Functions: | ||
7 | mxl5005s_reset() | ||
8 | mxl5005s_writereg() | ||
9 | mxl5005s_writeregs() | ||
10 | mxl5005s_init() | ||
11 | mxl5005s_reconfigure() | ||
12 | mxl5005s_AssignTunerMode() | ||
13 | mxl5005s_set_params() | ||
14 | mxl5005s_get_frequency() | ||
15 | mxl5005s_get_bandwidth() | ||
16 | mxl5005s_release() | ||
17 | mxl5005s_attach() | ||
18 | |||
19 | Copyright (C) 2008 Realtek | ||
20 | Copyright (C) 2008 Jan Hoogenraad | ||
21 | Functions: | ||
22 | mxl5005s_SetRfFreqHz() | ||
23 | |||
24 | This program is free software; you can redistribute it and/or modify | ||
25 | it under the terms of the GNU General Public License as published by | ||
26 | the Free Software Foundation; either version 2 of the License, or | ||
27 | (at your option) any later version. | ||
28 | |||
29 | This program is distributed in the hope that it will be useful, | ||
30 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
32 | GNU General Public License for more details. | ||
33 | |||
34 | You should have received a copy of the GNU General Public License | ||
35 | along with this program; if not, write to the Free Software | ||
36 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
37 | |||
38 | */ | ||
39 | |||
40 | /* | ||
41 | History of this driver (Steven Toth): | ||
42 | I was given a public release of a linux driver that included | ||
43 | support for the MaxLinear MXL5005S silicon tuner. Analysis of | ||
44 | the tuner driver showed clearly three things. | ||
45 | |||
46 | 1. The tuner driver didn't support the LinuxTV tuner API | ||
47 | so the code Realtek added had to be removed. | ||
48 | |||
49 | 2. A significant amount of the driver is reference driver code | ||
50 | from MaxLinear, I felt it was important to identify and | ||
51 | preserve this. | ||
52 | |||
53 | 3. New code has to be added to interface correctly with the | ||
54 | LinuxTV API, as a regular kernel module. | ||
55 | |||
56 | Other than the reference driver enum's, I've clearly marked | ||
57 | sections of the code and retained the copyright of the | ||
58 | respective owners. | ||
59 | */ | ||
60 | #include <linux/kernel.h> | ||
61 | #include <linux/init.h> | ||
62 | #include <linux/module.h> | ||
63 | #include <linux/string.h> | ||
64 | #include <linux/slab.h> | ||
65 | #include <linux/delay.h> | ||
66 | #include "dvb_frontend.h" | ||
67 | #include "mxl5005s.h" | ||
68 | |||
69 | static int debug; | ||
70 | |||
71 | #define dprintk(level, arg...) do { \ | ||
72 | if (level <= debug) \ | ||
73 | printk(arg); \ | ||
74 | } while (0) | ||
75 | |||
76 | #define TUNER_REGS_NUM 104 | ||
77 | #define INITCTRL_NUM 40 | ||
78 | |||
79 | #ifdef _MXL_PRODUCTION | ||
80 | #define CHCTRL_NUM 39 | ||
81 | #else | ||
82 | #define CHCTRL_NUM 36 | ||
83 | #endif | ||
84 | |||
85 | #define MXLCTRL_NUM 189 | ||
86 | #define MASTER_CONTROL_ADDR 9 | ||
87 | |||
88 | /* Enumeration of Master Control Register State */ | ||
89 | enum master_control_state { | ||
90 | MC_LOAD_START = 1, | ||
91 | MC_POWER_DOWN, | ||
92 | MC_SYNTH_RESET, | ||
93 | MC_SEQ_OFF | ||
94 | }; | ||
95 | |||
96 | /* Enumeration of MXL5005 Tuner Modulation Type */ | ||
97 | enum { | ||
98 | MXL_DEFAULT_MODULATION = 0, | ||
99 | MXL_DVBT, | ||
100 | MXL_ATSC, | ||
101 | MXL_QAM, | ||
102 | MXL_ANALOG_CABLE, | ||
103 | MXL_ANALOG_OTA | ||
104 | } tuner_modu_type; | ||
105 | |||
106 | /* MXL5005 Tuner Register Struct */ | ||
107 | struct TunerReg { | ||
108 | u16 Reg_Num; /* Tuner Register Address */ | ||
109 | u16 Reg_Val; /* Current sw programmed value waiting to be writen */ | ||
110 | }; | ||
111 | |||
112 | enum { | ||
113 | /* Initialization Control Names */ | ||
114 | DN_IQTN_AMP_CUT = 1, /* 1 */ | ||
115 | BB_MODE, /* 2 */ | ||
116 | BB_BUF, /* 3 */ | ||
117 | BB_BUF_OA, /* 4 */ | ||
118 | BB_ALPF_BANDSELECT, /* 5 */ | ||
119 | BB_IQSWAP, /* 6 */ | ||
120 | BB_DLPF_BANDSEL, /* 7 */ | ||
121 | RFSYN_CHP_GAIN, /* 8 */ | ||
122 | RFSYN_EN_CHP_HIGAIN, /* 9 */ | ||
123 | AGC_IF, /* 10 */ | ||
124 | AGC_RF, /* 11 */ | ||
125 | IF_DIVVAL, /* 12 */ | ||
126 | IF_VCO_BIAS, /* 13 */ | ||
127 | CHCAL_INT_MOD_IF, /* 14 */ | ||
128 | CHCAL_FRAC_MOD_IF, /* 15 */ | ||
129 | DRV_RES_SEL, /* 16 */ | ||
130 | I_DRIVER, /* 17 */ | ||
131 | EN_AAF, /* 18 */ | ||
132 | EN_3P, /* 19 */ | ||
133 | EN_AUX_3P, /* 20 */ | ||
134 | SEL_AAF_BAND, /* 21 */ | ||
135 | SEQ_ENCLK16_CLK_OUT, /* 22 */ | ||
136 | SEQ_SEL4_16B, /* 23 */ | ||
137 | XTAL_CAPSELECT, /* 24 */ | ||
138 | IF_SEL_DBL, /* 25 */ | ||
139 | RFSYN_R_DIV, /* 26 */ | ||
140 | SEQ_EXTSYNTHCALIF, /* 27 */ | ||
141 | SEQ_EXTDCCAL, /* 28 */ | ||
142 | AGC_EN_RSSI, /* 29 */ | ||
143 | RFA_ENCLKRFAGC, /* 30 */ | ||
144 | RFA_RSSI_REFH, /* 31 */ | ||
145 | RFA_RSSI_REF, /* 32 */ | ||
146 | RFA_RSSI_REFL, /* 33 */ | ||
147 | RFA_FLR, /* 34 */ | ||
148 | RFA_CEIL, /* 35 */ | ||
149 | SEQ_EXTIQFSMPULSE, /* 36 */ | ||
150 | OVERRIDE_1, /* 37 */ | ||
151 | BB_INITSTATE_DLPF_TUNE, /* 38 */ | ||
152 | TG_R_DIV, /* 39 */ | ||
153 | EN_CHP_LIN_B, /* 40 */ | ||
154 | |||
155 | /* Channel Change Control Names */ | ||
156 | DN_POLY = 51, /* 51 */ | ||
157 | DN_RFGAIN, /* 52 */ | ||
158 | DN_CAP_RFLPF, /* 53 */ | ||
159 | DN_EN_VHFUHFBAR, /* 54 */ | ||
160 | DN_GAIN_ADJUST, /* 55 */ | ||
161 | DN_IQTNBUF_AMP, /* 56 */ | ||
162 | DN_IQTNGNBFBIAS_BST, /* 57 */ | ||
163 | RFSYN_EN_OUTMUX, /* 58 */ | ||
164 | RFSYN_SEL_VCO_OUT, /* 59 */ | ||
165 | RFSYN_SEL_VCO_HI, /* 60 */ | ||
166 | RFSYN_SEL_DIVM, /* 61 */ | ||
167 | RFSYN_RF_DIV_BIAS, /* 62 */ | ||
168 | DN_SEL_FREQ, /* 63 */ | ||
169 | RFSYN_VCO_BIAS, /* 64 */ | ||
170 | CHCAL_INT_MOD_RF, /* 65 */ | ||
171 | CHCAL_FRAC_MOD_RF, /* 66 */ | ||
172 | RFSYN_LPF_R, /* 67 */ | ||
173 | CHCAL_EN_INT_RF, /* 68 */ | ||
174 | TG_LO_DIVVAL, /* 69 */ | ||
175 | TG_LO_SELVAL, /* 70 */ | ||
176 | TG_DIV_VAL, /* 71 */ | ||
177 | TG_VCO_BIAS, /* 72 */ | ||
178 | SEQ_EXTPOWERUP, /* 73 */ | ||
179 | OVERRIDE_2, /* 74 */ | ||
180 | OVERRIDE_3, /* 75 */ | ||
181 | OVERRIDE_4, /* 76 */ | ||
182 | SEQ_FSM_PULSE, /* 77 */ | ||
183 | GPIO_4B, /* 78 */ | ||
184 | GPIO_3B, /* 79 */ | ||
185 | GPIO_4, /* 80 */ | ||
186 | GPIO_3, /* 81 */ | ||
187 | GPIO_1B, /* 82 */ | ||
188 | DAC_A_ENABLE, /* 83 */ | ||
189 | DAC_B_ENABLE, /* 84 */ | ||
190 | DAC_DIN_A, /* 85 */ | ||
191 | DAC_DIN_B, /* 86 */ | ||
192 | #ifdef _MXL_PRODUCTION | ||
193 | RFSYN_EN_DIV, /* 87 */ | ||
194 | RFSYN_DIVM, /* 88 */ | ||
195 | DN_BYPASS_AGC_I2C /* 89 */ | ||
196 | #endif | ||
197 | } MXL5005_ControlName; | ||
198 | |||
199 | /* | ||
200 | * The following context is source code provided by MaxLinear. | ||
201 | * MaxLinear source code - Common_MXL.h (?) | ||
202 | */ | ||
203 | |||
204 | /* Constants */ | ||
205 | #define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104 | ||
206 | #define MXL5005S_LATCH_BYTE 0xfe | ||
207 | |||
208 | /* Register address, MSB, and LSB */ | ||
209 | #define MXL5005S_BB_IQSWAP_ADDR 59 | ||
210 | #define MXL5005S_BB_IQSWAP_MSB 0 | ||
211 | #define MXL5005S_BB_IQSWAP_LSB 0 | ||
212 | |||
213 | #define MXL5005S_BB_DLPF_BANDSEL_ADDR 53 | ||
214 | #define MXL5005S_BB_DLPF_BANDSEL_MSB 4 | ||
215 | #define MXL5005S_BB_DLPF_BANDSEL_LSB 3 | ||
216 | |||
217 | /* Standard modes */ | ||
218 | enum { | ||
219 | MXL5005S_STANDARD_DVBT, | ||
220 | MXL5005S_STANDARD_ATSC, | ||
221 | }; | ||
222 | #define MXL5005S_STANDARD_MODE_NUM 2 | ||
223 | |||
224 | /* Bandwidth modes */ | ||
225 | enum { | ||
226 | MXL5005S_BANDWIDTH_6MHZ = 6000000, | ||
227 | MXL5005S_BANDWIDTH_7MHZ = 7000000, | ||
228 | MXL5005S_BANDWIDTH_8MHZ = 8000000, | ||
229 | }; | ||
230 | #define MXL5005S_BANDWIDTH_MODE_NUM 3 | ||
231 | |||
232 | /* MXL5005 Tuner Control Struct */ | ||
233 | struct TunerControl { | ||
234 | u16 Ctrl_Num; /* Control Number */ | ||
235 | u16 size; /* Number of bits to represent Value */ | ||
236 | u16 addr[25]; /* Array of Tuner Register Address for each bit pos */ | ||
237 | u16 bit[25]; /* Array of bit pos in Reg Addr for each bit pos */ | ||
238 | u16 val[25]; /* Binary representation of Value */ | ||
239 | }; | ||
240 | |||
241 | /* MXL5005 Tuner Struct */ | ||
242 | struct mxl5005s_state { | ||
243 | u8 Mode; /* 0: Analog Mode ; 1: Digital Mode */ | ||
244 | u8 IF_Mode; /* for Analog Mode, 0: zero IF; 1: low IF */ | ||
245 | u32 Chan_Bandwidth; /* filter channel bandwidth (6, 7, 8) */ | ||
246 | u32 IF_OUT; /* Desired IF Out Frequency */ | ||
247 | u16 IF_OUT_LOAD; /* IF Out Load Resistor (200/300 Ohms) */ | ||
248 | u32 RF_IN; /* RF Input Frequency */ | ||
249 | u32 Fxtal; /* XTAL Frequency */ | ||
250 | u8 AGC_Mode; /* AGC Mode 0: Dual AGC; 1: Single AGC */ | ||
251 | u16 TOP; /* Value: take over point */ | ||
252 | u8 CLOCK_OUT; /* 0: turn off clk out; 1: turn on clock out */ | ||
253 | u8 DIV_OUT; /* 4MHz or 16MHz */ | ||
254 | u8 CAPSELECT; /* 0: disable On-Chip pulling cap; 1: enable */ | ||
255 | u8 EN_RSSI; /* 0: disable RSSI; 1: enable RSSI */ | ||
256 | |||
257 | /* Modulation Type; */ | ||
258 | /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */ | ||
259 | u8 Mod_Type; | ||
260 | |||
261 | /* Tracking Filter Type */ | ||
262 | /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */ | ||
263 | u8 TF_Type; | ||
264 | |||
265 | /* Calculated Settings */ | ||
266 | u32 RF_LO; /* Synth RF LO Frequency */ | ||
267 | u32 IF_LO; /* Synth IF LO Frequency */ | ||
268 | u32 TG_LO; /* Synth TG_LO Frequency */ | ||
269 | |||
270 | /* Pointers to ControlName Arrays */ | ||
271 | u16 Init_Ctrl_Num; /* Number of INIT Control Names */ | ||
272 | struct TunerControl | ||
273 | Init_Ctrl[INITCTRL_NUM]; /* INIT Control Names Array Pointer */ | ||
274 | |||
275 | u16 CH_Ctrl_Num; /* Number of CH Control Names */ | ||
276 | struct TunerControl | ||
277 | CH_Ctrl[CHCTRL_NUM]; /* CH Control Name Array Pointer */ | ||
278 | |||
279 | u16 MXL_Ctrl_Num; /* Number of MXL Control Names */ | ||
280 | struct TunerControl | ||
281 | MXL_Ctrl[MXLCTRL_NUM]; /* MXL Control Name Array Pointer */ | ||
282 | |||
283 | /* Pointer to Tuner Register Array */ | ||
284 | u16 TunerRegs_Num; /* Number of Tuner Registers */ | ||
285 | struct TunerReg | ||
286 | TunerRegs[TUNER_REGS_NUM]; /* Tuner Register Array Pointer */ | ||
287 | |||
288 | /* Linux driver framework specific */ | ||
289 | struct mxl5005s_config *config; | ||
290 | struct dvb_frontend *frontend; | ||
291 | struct i2c_adapter *i2c; | ||
292 | |||
293 | /* Cache values */ | ||
294 | u32 current_mode; | ||
295 | |||
296 | }; | ||
297 | |||
298 | static u16 MXL_GetMasterControl(u8 *MasterReg, int state); | ||
299 | static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value); | ||
300 | static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value); | ||
301 | static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, | ||
302 | u8 bitVal); | ||
303 | static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, | ||
304 | u8 *RegVal, int *count); | ||
305 | static u32 MXL_Ceiling(u32 value, u32 resolution); | ||
306 | static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal); | ||
307 | static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, | ||
308 | u32 value, u16 controlGroup); | ||
309 | static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val); | ||
310 | static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum, | ||
311 | u8 *RegVal, int *count); | ||
312 | static u32 MXL_GetXtalInt(u32 Xtal_Freq); | ||
313 | static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq); | ||
314 | static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe); | ||
315 | static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe); | ||
316 | static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum, | ||
317 | u8 *RegVal, int *count); | ||
318 | static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, | ||
319 | u8 *datatable, u8 len); | ||
320 | static u16 MXL_IFSynthInit(struct dvb_frontend *fe); | ||
321 | static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, | ||
322 | u32 bandwidth); | ||
323 | static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, | ||
324 | u32 bandwidth); | ||
325 | |||
326 | /* ---------------------------------------------------------------- | ||
327 | * Begin: Custom code salvaged from the Realtek driver. | ||
328 | * Copyright (C) 2008 Realtek | ||
329 | * Copyright (C) 2008 Jan Hoogenraad | ||
330 | * This code is placed under the terms of the GNU General Public License | ||
331 | * | ||
332 | * Released by Realtek under GPLv2. | ||
333 | * Thanks to Realtek for a lot of support we received ! | ||
334 | * | ||
335 | * Revision: 080314 - original version | ||
336 | */ | ||
337 | |||
338 | static int mxl5005s_SetRfFreqHz(struct dvb_frontend *fe, unsigned long RfFreqHz) | ||
339 | { | ||
340 | struct mxl5005s_state *state = fe->tuner_priv; | ||
341 | unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; | ||
342 | unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; | ||
343 | int TableLen; | ||
344 | |||
345 | u32 IfDivval = 0; | ||
346 | unsigned char MasterControlByte; | ||
347 | |||
348 | dprintk(1, "%s() freq=%ld\n", __func__, RfFreqHz); | ||
349 | |||
350 | /* Set MxL5005S tuner RF frequency according to example code. */ | ||
351 | |||
352 | /* Tuner RF frequency setting stage 0 */ | ||
353 | MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET); | ||
354 | AddrTable[0] = MASTER_CONTROL_ADDR; | ||
355 | ByteTable[0] |= state->config->AgcMasterByte; | ||
356 | |||
357 | mxl5005s_writeregs(fe, AddrTable, ByteTable, 1); | ||
358 | |||
359 | /* Tuner RF frequency setting stage 1 */ | ||
360 | MXL_TuneRF(fe, RfFreqHz); | ||
361 | |||
362 | MXL_ControlRead(fe, IF_DIVVAL, &IfDivval); | ||
363 | |||
364 | MXL_ControlWrite(fe, SEQ_FSM_PULSE, 0); | ||
365 | MXL_ControlWrite(fe, SEQ_EXTPOWERUP, 1); | ||
366 | MXL_ControlWrite(fe, IF_DIVVAL, 8); | ||
367 | MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen); | ||
368 | |||
369 | MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START); | ||
370 | AddrTable[TableLen] = MASTER_CONTROL_ADDR ; | ||
371 | ByteTable[TableLen] = MasterControlByte | | ||
372 | state->config->AgcMasterByte; | ||
373 | TableLen += 1; | ||
374 | |||
375 | mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); | ||
376 | |||
377 | /* Wait 30 ms. */ | ||
378 | msleep(150); | ||
379 | |||
380 | /* Tuner RF frequency setting stage 2 */ | ||
381 | MXL_ControlWrite(fe, SEQ_FSM_PULSE, 1); | ||
382 | MXL_ControlWrite(fe, IF_DIVVAL, IfDivval); | ||
383 | MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen); | ||
384 | |||
385 | MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START); | ||
386 | AddrTable[TableLen] = MASTER_CONTROL_ADDR ; | ||
387 | ByteTable[TableLen] = MasterControlByte | | ||
388 | state->config->AgcMasterByte ; | ||
389 | TableLen += 1; | ||
390 | |||
391 | mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); | ||
392 | |||
393 | msleep(100); | ||
394 | |||
395 | return 0; | ||
396 | } | ||
397 | /* End: Custom code taken from the Realtek driver */ | ||
398 | |||
399 | /* ---------------------------------------------------------------- | ||
400 | * Begin: Reference driver code found in the Realtek driver. | ||
401 | * Copyright (C) 2008 MaxLinear | ||
402 | */ | ||
403 | static u16 MXL5005_RegisterInit(struct dvb_frontend *fe) | ||
404 | { | ||
405 | struct mxl5005s_state *state = fe->tuner_priv; | ||
406 | state->TunerRegs_Num = TUNER_REGS_NUM ; | ||
407 | |||
408 | state->TunerRegs[0].Reg_Num = 9 ; | ||
409 | state->TunerRegs[0].Reg_Val = 0x40 ; | ||
410 | |||
411 | state->TunerRegs[1].Reg_Num = 11 ; | ||
412 | state->TunerRegs[1].Reg_Val = 0x19 ; | ||
413 | |||
414 | state->TunerRegs[2].Reg_Num = 12 ; | ||
415 | state->TunerRegs[2].Reg_Val = 0x60 ; | ||
416 | |||
417 | state->TunerRegs[3].Reg_Num = 13 ; | ||
418 | state->TunerRegs[3].Reg_Val = 0x00 ; | ||
419 | |||
420 | state->TunerRegs[4].Reg_Num = 14 ; | ||
421 | state->TunerRegs[4].Reg_Val = 0x00 ; | ||
422 | |||
423 | state->TunerRegs[5].Reg_Num = 15 ; | ||
424 | state->TunerRegs[5].Reg_Val = 0xC0 ; | ||
425 | |||
426 | state->TunerRegs[6].Reg_Num = 16 ; | ||
427 | state->TunerRegs[6].Reg_Val = 0x00 ; | ||
428 | |||
429 | state->TunerRegs[7].Reg_Num = 17 ; | ||
430 | state->TunerRegs[7].Reg_Val = 0x00 ; | ||
431 | |||
432 | state->TunerRegs[8].Reg_Num = 18 ; | ||
433 | state->TunerRegs[8].Reg_Val = 0x00 ; | ||
434 | |||
435 | state->TunerRegs[9].Reg_Num = 19 ; | ||
436 | state->TunerRegs[9].Reg_Val = 0x34 ; | ||
437 | |||
438 | state->TunerRegs[10].Reg_Num = 21 ; | ||
439 | state->TunerRegs[10].Reg_Val = 0x00 ; | ||
440 | |||
441 | state->TunerRegs[11].Reg_Num = 22 ; | ||
442 | state->TunerRegs[11].Reg_Val = 0x6B ; | ||
443 | |||
444 | state->TunerRegs[12].Reg_Num = 23 ; | ||
445 | state->TunerRegs[12].Reg_Val = 0x35 ; | ||
446 | |||
447 | state->TunerRegs[13].Reg_Num = 24 ; | ||
448 | state->TunerRegs[13].Reg_Val = 0x70 ; | ||
449 | |||
450 | state->TunerRegs[14].Reg_Num = 25 ; | ||
451 | state->TunerRegs[14].Reg_Val = 0x3E ; | ||
452 | |||
453 | state->TunerRegs[15].Reg_Num = 26 ; | ||
454 | state->TunerRegs[15].Reg_Val = 0x82 ; | ||
455 | |||
456 | state->TunerRegs[16].Reg_Num = 31 ; | ||
457 | state->TunerRegs[16].Reg_Val = 0x00 ; | ||
458 | |||
459 | state->TunerRegs[17].Reg_Num = 32 ; | ||
460 | state->TunerRegs[17].Reg_Val = 0x40 ; | ||
461 | |||
462 | state->TunerRegs[18].Reg_Num = 33 ; | ||
463 | state->TunerRegs[18].Reg_Val = 0x53 ; | ||
464 | |||
465 | state->TunerRegs[19].Reg_Num = 34 ; | ||
466 | state->TunerRegs[19].Reg_Val = 0x81 ; | ||
467 | |||
468 | state->TunerRegs[20].Reg_Num = 35 ; | ||
469 | state->TunerRegs[20].Reg_Val = 0xC9 ; | ||
470 | |||
471 | state->TunerRegs[21].Reg_Num = 36 ; | ||
472 | state->TunerRegs[21].Reg_Val = 0x01 ; | ||
473 | |||
474 | state->TunerRegs[22].Reg_Num = 37 ; | ||
475 | state->TunerRegs[22].Reg_Val = 0x00 ; | ||
476 | |||
477 | state->TunerRegs[23].Reg_Num = 41 ; | ||
478 | state->TunerRegs[23].Reg_Val = 0x00 ; | ||
479 | |||
480 | state->TunerRegs[24].Reg_Num = 42 ; | ||
481 | state->TunerRegs[24].Reg_Val = 0xF8 ; | ||
482 | |||
483 | state->TunerRegs[25].Reg_Num = 43 ; | ||
484 | state->TunerRegs[25].Reg_Val = 0x43 ; | ||
485 | |||
486 | state->TunerRegs[26].Reg_Num = 44 ; | ||
487 | state->TunerRegs[26].Reg_Val = 0x20 ; | ||
488 | |||
489 | state->TunerRegs[27].Reg_Num = 45 ; | ||
490 | state->TunerRegs[27].Reg_Val = 0x80 ; | ||
491 | |||
492 | state->TunerRegs[28].Reg_Num = 46 ; | ||
493 | state->TunerRegs[28].Reg_Val = 0x88 ; | ||
494 | |||
495 | state->TunerRegs[29].Reg_Num = 47 ; | ||
496 | state->TunerRegs[29].Reg_Val = 0x86 ; | ||
497 | |||
498 | state->TunerRegs[30].Reg_Num = 48 ; | ||
499 | state->TunerRegs[30].Reg_Val = 0x00 ; | ||
500 | |||
501 | state->TunerRegs[31].Reg_Num = 49 ; | ||
502 | state->TunerRegs[31].Reg_Val = 0x00 ; | ||
503 | |||
504 | state->TunerRegs[32].Reg_Num = 53 ; | ||
505 | state->TunerRegs[32].Reg_Val = 0x94 ; | ||
506 | |||
507 | state->TunerRegs[33].Reg_Num = 54 ; | ||
508 | state->TunerRegs[33].Reg_Val = 0xFA ; | ||
509 | |||
510 | state->TunerRegs[34].Reg_Num = 55 ; | ||
511 | state->TunerRegs[34].Reg_Val = 0x92 ; | ||
512 | |||
513 | state->TunerRegs[35].Reg_Num = 56 ; | ||
514 | state->TunerRegs[35].Reg_Val = 0x80 ; | ||
515 | |||
516 | state->TunerRegs[36].Reg_Num = 57 ; | ||
517 | state->TunerRegs[36].Reg_Val = 0x41 ; | ||
518 | |||
519 | state->TunerRegs[37].Reg_Num = 58 ; | ||
520 | state->TunerRegs[37].Reg_Val = 0xDB ; | ||
521 | |||
522 | state->TunerRegs[38].Reg_Num = 59 ; | ||
523 | state->TunerRegs[38].Reg_Val = 0x00 ; | ||
524 | |||
525 | state->TunerRegs[39].Reg_Num = 60 ; | ||
526 | state->TunerRegs[39].Reg_Val = 0x00 ; | ||
527 | |||
528 | state->TunerRegs[40].Reg_Num = 61 ; | ||
529 | state->TunerRegs[40].Reg_Val = 0x00 ; | ||
530 | |||
531 | state->TunerRegs[41].Reg_Num = 62 ; | ||
532 | state->TunerRegs[41].Reg_Val = 0x00 ; | ||
533 | |||
534 | state->TunerRegs[42].Reg_Num = 65 ; | ||
535 | state->TunerRegs[42].Reg_Val = 0xF8 ; | ||
536 | |||
537 | state->TunerRegs[43].Reg_Num = 66 ; | ||
538 | state->TunerRegs[43].Reg_Val = 0xE4 ; | ||
539 | |||
540 | state->TunerRegs[44].Reg_Num = 67 ; | ||
541 | state->TunerRegs[44].Reg_Val = 0x90 ; | ||
542 | |||
543 | state->TunerRegs[45].Reg_Num = 68 ; | ||
544 | state->TunerRegs[45].Reg_Val = 0xC0 ; | ||
545 | |||
546 | state->TunerRegs[46].Reg_Num = 69 ; | ||
547 | state->TunerRegs[46].Reg_Val = 0x01 ; | ||
548 | |||
549 | state->TunerRegs[47].Reg_Num = 70 ; | ||
550 | state->TunerRegs[47].Reg_Val = 0x50 ; | ||
551 | |||
552 | state->TunerRegs[48].Reg_Num = 71 ; | ||
553 | state->TunerRegs[48].Reg_Val = 0x06 ; | ||
554 | |||
555 | state->TunerRegs[49].Reg_Num = 72 ; | ||
556 | state->TunerRegs[49].Reg_Val = 0x00 ; | ||
557 | |||
558 | state->TunerRegs[50].Reg_Num = 73 ; | ||
559 | state->TunerRegs[50].Reg_Val = 0x20 ; | ||
560 | |||
561 | state->TunerRegs[51].Reg_Num = 76 ; | ||
562 | state->TunerRegs[51].Reg_Val = 0xBB ; | ||
563 | |||
564 | state->TunerRegs[52].Reg_Num = 77 ; | ||
565 | state->TunerRegs[52].Reg_Val = 0x13 ; | ||
566 | |||
567 | state->TunerRegs[53].Reg_Num = 81 ; | ||
568 | state->TunerRegs[53].Reg_Val = 0x04 ; | ||
569 | |||
570 | state->TunerRegs[54].Reg_Num = 82 ; | ||
571 | state->TunerRegs[54].Reg_Val = 0x75 ; | ||
572 | |||
573 | state->TunerRegs[55].Reg_Num = 83 ; | ||
574 | state->TunerRegs[55].Reg_Val = 0x00 ; | ||
575 | |||
576 | state->TunerRegs[56].Reg_Num = 84 ; | ||
577 | state->TunerRegs[56].Reg_Val = 0x00 ; | ||
578 | |||
579 | state->TunerRegs[57].Reg_Num = 85 ; | ||
580 | state->TunerRegs[57].Reg_Val = 0x00 ; | ||
581 | |||
582 | state->TunerRegs[58].Reg_Num = 91 ; | ||
583 | state->TunerRegs[58].Reg_Val = 0x70 ; | ||
584 | |||
585 | state->TunerRegs[59].Reg_Num = 92 ; | ||
586 | state->TunerRegs[59].Reg_Val = 0x00 ; | ||
587 | |||
588 | state->TunerRegs[60].Reg_Num = 93 ; | ||
589 | state->TunerRegs[60].Reg_Val = 0x00 ; | ||
590 | |||
591 | state->TunerRegs[61].Reg_Num = 94 ; | ||
592 | state->TunerRegs[61].Reg_Val = 0x00 ; | ||
593 | |||
594 | state->TunerRegs[62].Reg_Num = 95 ; | ||
595 | state->TunerRegs[62].Reg_Val = 0x0C ; | ||
596 | |||
597 | state->TunerRegs[63].Reg_Num = 96 ; | ||
598 | state->TunerRegs[63].Reg_Val = 0x00 ; | ||
599 | |||
600 | state->TunerRegs[64].Reg_Num = 97 ; | ||
601 | state->TunerRegs[64].Reg_Val = 0x00 ; | ||
602 | |||
603 | state->TunerRegs[65].Reg_Num = 98 ; | ||
604 | state->TunerRegs[65].Reg_Val = 0xE2 ; | ||
605 | |||
606 | state->TunerRegs[66].Reg_Num = 99 ; | ||
607 | state->TunerRegs[66].Reg_Val = 0x00 ; | ||
608 | |||
609 | state->TunerRegs[67].Reg_Num = 100 ; | ||
610 | state->TunerRegs[67].Reg_Val = 0x00 ; | ||
611 | |||
612 | state->TunerRegs[68].Reg_Num = 101 ; | ||
613 | state->TunerRegs[68].Reg_Val = 0x12 ; | ||
614 | |||
615 | state->TunerRegs[69].Reg_Num = 102 ; | ||
616 | state->TunerRegs[69].Reg_Val = 0x80 ; | ||
617 | |||
618 | state->TunerRegs[70].Reg_Num = 103 ; | ||
619 | state->TunerRegs[70].Reg_Val = 0x32 ; | ||
620 | |||
621 | state->TunerRegs[71].Reg_Num = 104 ; | ||
622 | state->TunerRegs[71].Reg_Val = 0xB4 ; | ||
623 | |||
624 | state->TunerRegs[72].Reg_Num = 105 ; | ||
625 | state->TunerRegs[72].Reg_Val = 0x60 ; | ||
626 | |||
627 | state->TunerRegs[73].Reg_Num = 106 ; | ||
628 | state->TunerRegs[73].Reg_Val = 0x83 ; | ||
629 | |||
630 | state->TunerRegs[74].Reg_Num = 107 ; | ||
631 | state->TunerRegs[74].Reg_Val = 0x84 ; | ||
632 | |||
633 | state->TunerRegs[75].Reg_Num = 108 ; | ||
634 | state->TunerRegs[75].Reg_Val = 0x9C ; | ||
635 | |||
636 | state->TunerRegs[76].Reg_Num = 109 ; | ||
637 | state->TunerRegs[76].Reg_Val = 0x02 ; | ||
638 | |||
639 | state->TunerRegs[77].Reg_Num = 110 ; | ||
640 | state->TunerRegs[77].Reg_Val = 0x81 ; | ||
641 | |||
642 | state->TunerRegs[78].Reg_Num = 111 ; | ||
643 | state->TunerRegs[78].Reg_Val = 0xC0 ; | ||
644 | |||
645 | state->TunerRegs[79].Reg_Num = 112 ; | ||
646 | state->TunerRegs[79].Reg_Val = 0x10 ; | ||
647 | |||
648 | state->TunerRegs[80].Reg_Num = 131 ; | ||
649 | state->TunerRegs[80].Reg_Val = 0x8A ; | ||
650 | |||
651 | state->TunerRegs[81].Reg_Num = 132 ; | ||
652 | state->TunerRegs[81].Reg_Val = 0x10 ; | ||
653 | |||
654 | state->TunerRegs[82].Reg_Num = 133 ; | ||
655 | state->TunerRegs[82].Reg_Val = 0x24 ; | ||
656 | |||
657 | state->TunerRegs[83].Reg_Num = 134 ; | ||
658 | state->TunerRegs[83].Reg_Val = 0x00 ; | ||
659 | |||
660 | state->TunerRegs[84].Reg_Num = 135 ; | ||
661 | state->TunerRegs[84].Reg_Val = 0x00 ; | ||
662 | |||
663 | state->TunerRegs[85].Reg_Num = 136 ; | ||
664 | state->TunerRegs[85].Reg_Val = 0x7E ; | ||
665 | |||
666 | state->TunerRegs[86].Reg_Num = 137 ; | ||
667 | state->TunerRegs[86].Reg_Val = 0x40 ; | ||
668 | |||
669 | state->TunerRegs[87].Reg_Num = 138 ; | ||
670 | state->TunerRegs[87].Reg_Val = 0x38 ; | ||
671 | |||
672 | state->TunerRegs[88].Reg_Num = 146 ; | ||
673 | state->TunerRegs[88].Reg_Val = 0xF6 ; | ||
674 | |||
675 | state->TunerRegs[89].Reg_Num = 147 ; | ||
676 | state->TunerRegs[89].Reg_Val = 0x1A ; | ||
677 | |||
678 | state->TunerRegs[90].Reg_Num = 148 ; | ||
679 | state->TunerRegs[90].Reg_Val = 0x62 ; | ||
680 | |||
681 | state->TunerRegs[91].Reg_Num = 149 ; | ||
682 | state->TunerRegs[91].Reg_Val = 0x33 ; | ||
683 | |||
684 | state->TunerRegs[92].Reg_Num = 150 ; | ||
685 | state->TunerRegs[92].Reg_Val = 0x80 ; | ||
686 | |||
687 | state->TunerRegs[93].Reg_Num = 156 ; | ||
688 | state->TunerRegs[93].Reg_Val = 0x56 ; | ||
689 | |||
690 | state->TunerRegs[94].Reg_Num = 157 ; | ||
691 | state->TunerRegs[94].Reg_Val = 0x17 ; | ||
692 | |||
693 | state->TunerRegs[95].Reg_Num = 158 ; | ||
694 | state->TunerRegs[95].Reg_Val = 0xA9 ; | ||
695 | |||
696 | state->TunerRegs[96].Reg_Num = 159 ; | ||
697 | state->TunerRegs[96].Reg_Val = 0x00 ; | ||
698 | |||
699 | state->TunerRegs[97].Reg_Num = 160 ; | ||
700 | state->TunerRegs[97].Reg_Val = 0x00 ; | ||
701 | |||
702 | state->TunerRegs[98].Reg_Num = 161 ; | ||
703 | state->TunerRegs[98].Reg_Val = 0x00 ; | ||
704 | |||
705 | state->TunerRegs[99].Reg_Num = 162 ; | ||
706 | state->TunerRegs[99].Reg_Val = 0x40 ; | ||
707 | |||
708 | state->TunerRegs[100].Reg_Num = 166 ; | ||
709 | state->TunerRegs[100].Reg_Val = 0xAE ; | ||
710 | |||
711 | state->TunerRegs[101].Reg_Num = 167 ; | ||
712 | state->TunerRegs[101].Reg_Val = 0x1B ; | ||
713 | |||
714 | state->TunerRegs[102].Reg_Num = 168 ; | ||
715 | state->TunerRegs[102].Reg_Val = 0xF2 ; | ||
716 | |||
717 | state->TunerRegs[103].Reg_Num = 195 ; | ||
718 | state->TunerRegs[103].Reg_Val = 0x00 ; | ||
719 | |||
720 | return 0 ; | ||
721 | } | ||
722 | |||
723 | static u16 MXL5005_ControlInit(struct dvb_frontend *fe) | ||
724 | { | ||
725 | struct mxl5005s_state *state = fe->tuner_priv; | ||
726 | state->Init_Ctrl_Num = INITCTRL_NUM; | ||
727 | |||
728 | state->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ; | ||
729 | state->Init_Ctrl[0].size = 1 ; | ||
730 | state->Init_Ctrl[0].addr[0] = 73; | ||
731 | state->Init_Ctrl[0].bit[0] = 7; | ||
732 | state->Init_Ctrl[0].val[0] = 0; | ||
733 | |||
734 | state->Init_Ctrl[1].Ctrl_Num = BB_MODE ; | ||
735 | state->Init_Ctrl[1].size = 1 ; | ||
736 | state->Init_Ctrl[1].addr[0] = 53; | ||
737 | state->Init_Ctrl[1].bit[0] = 2; | ||
738 | state->Init_Ctrl[1].val[0] = 1; | ||
739 | |||
740 | state->Init_Ctrl[2].Ctrl_Num = BB_BUF ; | ||
741 | state->Init_Ctrl[2].size = 2 ; | ||
742 | state->Init_Ctrl[2].addr[0] = 53; | ||
743 | state->Init_Ctrl[2].bit[0] = 1; | ||
744 | state->Init_Ctrl[2].val[0] = 0; | ||
745 | state->Init_Ctrl[2].addr[1] = 57; | ||
746 | state->Init_Ctrl[2].bit[1] = 0; | ||
747 | state->Init_Ctrl[2].val[1] = 1; | ||
748 | |||
749 | state->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ; | ||
750 | state->Init_Ctrl[3].size = 1 ; | ||
751 | state->Init_Ctrl[3].addr[0] = 53; | ||
752 | state->Init_Ctrl[3].bit[0] = 0; | ||
753 | state->Init_Ctrl[3].val[0] = 0; | ||
754 | |||
755 | state->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ; | ||
756 | state->Init_Ctrl[4].size = 3 ; | ||
757 | state->Init_Ctrl[4].addr[0] = 53; | ||
758 | state->Init_Ctrl[4].bit[0] = 5; | ||
759 | state->Init_Ctrl[4].val[0] = 0; | ||
760 | state->Init_Ctrl[4].addr[1] = 53; | ||
761 | state->Init_Ctrl[4].bit[1] = 6; | ||
762 | state->Init_Ctrl[4].val[1] = 0; | ||
763 | state->Init_Ctrl[4].addr[2] = 53; | ||
764 | state->Init_Ctrl[4].bit[2] = 7; | ||
765 | state->Init_Ctrl[4].val[2] = 1; | ||
766 | |||
767 | state->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ; | ||
768 | state->Init_Ctrl[5].size = 1 ; | ||
769 | state->Init_Ctrl[5].addr[0] = 59; | ||
770 | state->Init_Ctrl[5].bit[0] = 0; | ||
771 | state->Init_Ctrl[5].val[0] = 0; | ||
772 | |||
773 | state->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ; | ||
774 | state->Init_Ctrl[6].size = 2 ; | ||
775 | state->Init_Ctrl[6].addr[0] = 53; | ||
776 | state->Init_Ctrl[6].bit[0] = 3; | ||
777 | state->Init_Ctrl[6].val[0] = 0; | ||
778 | state->Init_Ctrl[6].addr[1] = 53; | ||
779 | state->Init_Ctrl[6].bit[1] = 4; | ||
780 | state->Init_Ctrl[6].val[1] = 1; | ||
781 | |||
782 | state->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ; | ||
783 | state->Init_Ctrl[7].size = 4 ; | ||
784 | state->Init_Ctrl[7].addr[0] = 22; | ||
785 | state->Init_Ctrl[7].bit[0] = 4; | ||
786 | state->Init_Ctrl[7].val[0] = 0; | ||
787 | state->Init_Ctrl[7].addr[1] = 22; | ||
788 | state->Init_Ctrl[7].bit[1] = 5; | ||
789 | state->Init_Ctrl[7].val[1] = 1; | ||
790 | state->Init_Ctrl[7].addr[2] = 22; | ||
791 | state->Init_Ctrl[7].bit[2] = 6; | ||
792 | state->Init_Ctrl[7].val[2] = 1; | ||
793 | state->Init_Ctrl[7].addr[3] = 22; | ||
794 | state->Init_Ctrl[7].bit[3] = 7; | ||
795 | state->Init_Ctrl[7].val[3] = 0; | ||
796 | |||
797 | state->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ; | ||
798 | state->Init_Ctrl[8].size = 1 ; | ||
799 | state->Init_Ctrl[8].addr[0] = 22; | ||
800 | state->Init_Ctrl[8].bit[0] = 2; | ||
801 | state->Init_Ctrl[8].val[0] = 0; | ||
802 | |||
803 | state->Init_Ctrl[9].Ctrl_Num = AGC_IF ; | ||
804 | state->Init_Ctrl[9].size = 4 ; | ||
805 | state->Init_Ctrl[9].addr[0] = 76; | ||
806 | state->Init_Ctrl[9].bit[0] = 0; | ||
807 | state->Init_Ctrl[9].val[0] = 1; | ||
808 | state->Init_Ctrl[9].addr[1] = 76; | ||
809 | state->Init_Ctrl[9].bit[1] = 1; | ||
810 | state->Init_Ctrl[9].val[1] = 1; | ||
811 | state->Init_Ctrl[9].addr[2] = 76; | ||
812 | state->Init_Ctrl[9].bit[2] = 2; | ||
813 | state->Init_Ctrl[9].val[2] = 0; | ||
814 | state->Init_Ctrl[9].addr[3] = 76; | ||
815 | state->Init_Ctrl[9].bit[3] = 3; | ||
816 | state->Init_Ctrl[9].val[3] = 1; | ||
817 | |||
818 | state->Init_Ctrl[10].Ctrl_Num = AGC_RF ; | ||
819 | state->Init_Ctrl[10].size = 4 ; | ||
820 | state->Init_Ctrl[10].addr[0] = 76; | ||
821 | state->Init_Ctrl[10].bit[0] = 4; | ||
822 | state->Init_Ctrl[10].val[0] = 1; | ||
823 | state->Init_Ctrl[10].addr[1] = 76; | ||
824 | state->Init_Ctrl[10].bit[1] = 5; | ||
825 | state->Init_Ctrl[10].val[1] = 1; | ||
826 | state->Init_Ctrl[10].addr[2] = 76; | ||
827 | state->Init_Ctrl[10].bit[2] = 6; | ||
828 | state->Init_Ctrl[10].val[2] = 0; | ||
829 | state->Init_Ctrl[10].addr[3] = 76; | ||
830 | state->Init_Ctrl[10].bit[3] = 7; | ||
831 | state->Init_Ctrl[10].val[3] = 1; | ||
832 | |||
833 | state->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ; | ||
834 | state->Init_Ctrl[11].size = 5 ; | ||
835 | state->Init_Ctrl[11].addr[0] = 43; | ||
836 | state->Init_Ctrl[11].bit[0] = 3; | ||
837 | state->Init_Ctrl[11].val[0] = 0; | ||
838 | state->Init_Ctrl[11].addr[1] = 43; | ||
839 | state->Init_Ctrl[11].bit[1] = 4; | ||
840 | state->Init_Ctrl[11].val[1] = 0; | ||
841 | state->Init_Ctrl[11].addr[2] = 43; | ||
842 | state->Init_Ctrl[11].bit[2] = 5; | ||
843 | state->Init_Ctrl[11].val[2] = 0; | ||
844 | state->Init_Ctrl[11].addr[3] = 43; | ||
845 | state->Init_Ctrl[11].bit[3] = 6; | ||
846 | state->Init_Ctrl[11].val[3] = 1; | ||
847 | state->Init_Ctrl[11].addr[4] = 43; | ||
848 | state->Init_Ctrl[11].bit[4] = 7; | ||
849 | state->Init_Ctrl[11].val[4] = 0; | ||
850 | |||
851 | state->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ; | ||
852 | state->Init_Ctrl[12].size = 6 ; | ||
853 | state->Init_Ctrl[12].addr[0] = 44; | ||
854 | state->Init_Ctrl[12].bit[0] = 2; | ||
855 | state->Init_Ctrl[12].val[0] = 0; | ||
856 | state->Init_Ctrl[12].addr[1] = 44; | ||
857 | state->Init_Ctrl[12].bit[1] = 3; | ||
858 | state->Init_Ctrl[12].val[1] = 0; | ||
859 | state->Init_Ctrl[12].addr[2] = 44; | ||
860 | state->Init_Ctrl[12].bit[2] = 4; | ||
861 | state->Init_Ctrl[12].val[2] = 0; | ||
862 | state->Init_Ctrl[12].addr[3] = 44; | ||
863 | state->Init_Ctrl[12].bit[3] = 5; | ||
864 | state->Init_Ctrl[12].val[3] = 1; | ||
865 | state->Init_Ctrl[12].addr[4] = 44; | ||
866 | state->Init_Ctrl[12].bit[4] = 6; | ||
867 | state->Init_Ctrl[12].val[4] = 0; | ||
868 | state->Init_Ctrl[12].addr[5] = 44; | ||
869 | state->Init_Ctrl[12].bit[5] = 7; | ||
870 | state->Init_Ctrl[12].val[5] = 0; | ||
871 | |||
872 | state->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ; | ||
873 | state->Init_Ctrl[13].size = 7 ; | ||
874 | state->Init_Ctrl[13].addr[0] = 11; | ||
875 | state->Init_Ctrl[13].bit[0] = 0; | ||
876 | state->Init_Ctrl[13].val[0] = 1; | ||
877 | state->Init_Ctrl[13].addr[1] = 11; | ||
878 | state->Init_Ctrl[13].bit[1] = 1; | ||
879 | state->Init_Ctrl[13].val[1] = 0; | ||
880 | state->Init_Ctrl[13].addr[2] = 11; | ||
881 | state->Init_Ctrl[13].bit[2] = 2; | ||
882 | state->Init_Ctrl[13].val[2] = 0; | ||
883 | state->Init_Ctrl[13].addr[3] = 11; | ||
884 | state->Init_Ctrl[13].bit[3] = 3; | ||
885 | state->Init_Ctrl[13].val[3] = 1; | ||
886 | state->Init_Ctrl[13].addr[4] = 11; | ||
887 | state->Init_Ctrl[13].bit[4] = 4; | ||
888 | state->Init_Ctrl[13].val[4] = 1; | ||
889 | state->Init_Ctrl[13].addr[5] = 11; | ||
890 | state->Init_Ctrl[13].bit[5] = 5; | ||
891 | state->Init_Ctrl[13].val[5] = 0; | ||
892 | state->Init_Ctrl[13].addr[6] = 11; | ||
893 | state->Init_Ctrl[13].bit[6] = 6; | ||
894 | state->Init_Ctrl[13].val[6] = 0; | ||
895 | |||
896 | state->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ; | ||
897 | state->Init_Ctrl[14].size = 16 ; | ||
898 | state->Init_Ctrl[14].addr[0] = 13; | ||
899 | state->Init_Ctrl[14].bit[0] = 0; | ||
900 | state->Init_Ctrl[14].val[0] = 0; | ||
901 | state->Init_Ctrl[14].addr[1] = 13; | ||
902 | state->Init_Ctrl[14].bit[1] = 1; | ||
903 | state->Init_Ctrl[14].val[1] = 0; | ||
904 | state->Init_Ctrl[14].addr[2] = 13; | ||
905 | state->Init_Ctrl[14].bit[2] = 2; | ||
906 | state->Init_Ctrl[14].val[2] = 0; | ||
907 | state->Init_Ctrl[14].addr[3] = 13; | ||
908 | state->Init_Ctrl[14].bit[3] = 3; | ||
909 | state->Init_Ctrl[14].val[3] = 0; | ||
910 | state->Init_Ctrl[14].addr[4] = 13; | ||
911 | state->Init_Ctrl[14].bit[4] = 4; | ||
912 | state->Init_Ctrl[14].val[4] = 0; | ||
913 | state->Init_Ctrl[14].addr[5] = 13; | ||
914 | state->Init_Ctrl[14].bit[5] = 5; | ||
915 | state->Init_Ctrl[14].val[5] = 0; | ||
916 | state->Init_Ctrl[14].addr[6] = 13; | ||
917 | state->Init_Ctrl[14].bit[6] = 6; | ||
918 | state->Init_Ctrl[14].val[6] = 0; | ||
919 | state->Init_Ctrl[14].addr[7] = 13; | ||
920 | state->Init_Ctrl[14].bit[7] = 7; | ||
921 | state->Init_Ctrl[14].val[7] = 0; | ||
922 | state->Init_Ctrl[14].addr[8] = 12; | ||
923 | state->Init_Ctrl[14].bit[8] = 0; | ||
924 | state->Init_Ctrl[14].val[8] = 0; | ||
925 | state->Init_Ctrl[14].addr[9] = 12; | ||
926 | state->Init_Ctrl[14].bit[9] = 1; | ||
927 | state->Init_Ctrl[14].val[9] = 0; | ||
928 | state->Init_Ctrl[14].addr[10] = 12; | ||
929 | state->Init_Ctrl[14].bit[10] = 2; | ||
930 | state->Init_Ctrl[14].val[10] = 0; | ||
931 | state->Init_Ctrl[14].addr[11] = 12; | ||
932 | state->Init_Ctrl[14].bit[11] = 3; | ||
933 | state->Init_Ctrl[14].val[11] = 0; | ||
934 | state->Init_Ctrl[14].addr[12] = 12; | ||
935 | state->Init_Ctrl[14].bit[12] = 4; | ||
936 | state->Init_Ctrl[14].val[12] = 0; | ||
937 | state->Init_Ctrl[14].addr[13] = 12; | ||
938 | state->Init_Ctrl[14].bit[13] = 5; | ||
939 | state->Init_Ctrl[14].val[13] = 1; | ||
940 | state->Init_Ctrl[14].addr[14] = 12; | ||
941 | state->Init_Ctrl[14].bit[14] = 6; | ||
942 | state->Init_Ctrl[14].val[14] = 1; | ||
943 | state->Init_Ctrl[14].addr[15] = 12; | ||
944 | state->Init_Ctrl[14].bit[15] = 7; | ||
945 | state->Init_Ctrl[14].val[15] = 0; | ||
946 | |||
947 | state->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ; | ||
948 | state->Init_Ctrl[15].size = 3 ; | ||
949 | state->Init_Ctrl[15].addr[0] = 147; | ||
950 | state->Init_Ctrl[15].bit[0] = 2; | ||
951 | state->Init_Ctrl[15].val[0] = 0; | ||
952 | state->Init_Ctrl[15].addr[1] = 147; | ||
953 | state->Init_Ctrl[15].bit[1] = 3; | ||
954 | state->Init_Ctrl[15].val[1] = 1; | ||
955 | state->Init_Ctrl[15].addr[2] = 147; | ||
956 | state->Init_Ctrl[15].bit[2] = 4; | ||
957 | state->Init_Ctrl[15].val[2] = 1; | ||
958 | |||
959 | state->Init_Ctrl[16].Ctrl_Num = I_DRIVER ; | ||
960 | state->Init_Ctrl[16].size = 2 ; | ||
961 | state->Init_Ctrl[16].addr[0] = 147; | ||
962 | state->Init_Ctrl[16].bit[0] = 0; | ||
963 | state->Init_Ctrl[16].val[0] = 0; | ||
964 | state->Init_Ctrl[16].addr[1] = 147; | ||
965 | state->Init_Ctrl[16].bit[1] = 1; | ||
966 | state->Init_Ctrl[16].val[1] = 1; | ||
967 | |||
968 | state->Init_Ctrl[17].Ctrl_Num = EN_AAF ; | ||
969 | state->Init_Ctrl[17].size = 1 ; | ||
970 | state->Init_Ctrl[17].addr[0] = 147; | ||
971 | state->Init_Ctrl[17].bit[0] = 7; | ||
972 | state->Init_Ctrl[17].val[0] = 0; | ||
973 | |||
974 | state->Init_Ctrl[18].Ctrl_Num = EN_3P ; | ||
975 | state->Init_Ctrl[18].size = 1 ; | ||
976 | state->Init_Ctrl[18].addr[0] = 147; | ||
977 | state->Init_Ctrl[18].bit[0] = 6; | ||
978 | state->Init_Ctrl[18].val[0] = 0; | ||
979 | |||
980 | state->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ; | ||
981 | state->Init_Ctrl[19].size = 1 ; | ||
982 | state->Init_Ctrl[19].addr[0] = 156; | ||
983 | state->Init_Ctrl[19].bit[0] = 0; | ||
984 | state->Init_Ctrl[19].val[0] = 0; | ||
985 | |||
986 | state->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ; | ||
987 | state->Init_Ctrl[20].size = 1 ; | ||
988 | state->Init_Ctrl[20].addr[0] = 147; | ||
989 | state->Init_Ctrl[20].bit[0] = 5; | ||
990 | state->Init_Ctrl[20].val[0] = 0; | ||
991 | |||
992 | state->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ; | ||
993 | state->Init_Ctrl[21].size = 1 ; | ||
994 | state->Init_Ctrl[21].addr[0] = 137; | ||
995 | state->Init_Ctrl[21].bit[0] = 4; | ||
996 | state->Init_Ctrl[21].val[0] = 0; | ||
997 | |||
998 | state->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ; | ||
999 | state->Init_Ctrl[22].size = 1 ; | ||
1000 | state->Init_Ctrl[22].addr[0] = 137; | ||
1001 | state->Init_Ctrl[22].bit[0] = 7; | ||
1002 | state->Init_Ctrl[22].val[0] = 0; | ||
1003 | |||
1004 | state->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ; | ||
1005 | state->Init_Ctrl[23].size = 1 ; | ||
1006 | state->Init_Ctrl[23].addr[0] = 91; | ||
1007 | state->Init_Ctrl[23].bit[0] = 5; | ||
1008 | state->Init_Ctrl[23].val[0] = 1; | ||
1009 | |||
1010 | state->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ; | ||
1011 | state->Init_Ctrl[24].size = 1 ; | ||
1012 | state->Init_Ctrl[24].addr[0] = 43; | ||
1013 | state->Init_Ctrl[24].bit[0] = 0; | ||
1014 | state->Init_Ctrl[24].val[0] = 1; | ||
1015 | |||
1016 | state->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ; | ||
1017 | state->Init_Ctrl[25].size = 2 ; | ||
1018 | state->Init_Ctrl[25].addr[0] = 22; | ||
1019 | state->Init_Ctrl[25].bit[0] = 0; | ||
1020 | state->Init_Ctrl[25].val[0] = 1; | ||
1021 | state->Init_Ctrl[25].addr[1] = 22; | ||
1022 | state->Init_Ctrl[25].bit[1] = 1; | ||
1023 | state->Init_Ctrl[25].val[1] = 1; | ||
1024 | |||
1025 | state->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ; | ||
1026 | state->Init_Ctrl[26].size = 1 ; | ||
1027 | state->Init_Ctrl[26].addr[0] = 134; | ||
1028 | state->Init_Ctrl[26].bit[0] = 2; | ||
1029 | state->Init_Ctrl[26].val[0] = 0; | ||
1030 | |||
1031 | state->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ; | ||
1032 | state->Init_Ctrl[27].size = 1 ; | ||
1033 | state->Init_Ctrl[27].addr[0] = 137; | ||
1034 | state->Init_Ctrl[27].bit[0] = 3; | ||
1035 | state->Init_Ctrl[27].val[0] = 0; | ||
1036 | |||
1037 | state->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ; | ||
1038 | state->Init_Ctrl[28].size = 1 ; | ||
1039 | state->Init_Ctrl[28].addr[0] = 77; | ||
1040 | state->Init_Ctrl[28].bit[0] = 7; | ||
1041 | state->Init_Ctrl[28].val[0] = 0; | ||
1042 | |||
1043 | state->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ; | ||
1044 | state->Init_Ctrl[29].size = 1 ; | ||
1045 | state->Init_Ctrl[29].addr[0] = 166; | ||
1046 | state->Init_Ctrl[29].bit[0] = 7; | ||
1047 | state->Init_Ctrl[29].val[0] = 1; | ||
1048 | |||
1049 | state->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ; | ||
1050 | state->Init_Ctrl[30].size = 3 ; | ||
1051 | state->Init_Ctrl[30].addr[0] = 166; | ||
1052 | state->Init_Ctrl[30].bit[0] = 0; | ||
1053 | state->Init_Ctrl[30].val[0] = 0; | ||
1054 | state->Init_Ctrl[30].addr[1] = 166; | ||
1055 | state->Init_Ctrl[30].bit[1] = 1; | ||
1056 | state->Init_Ctrl[30].val[1] = 1; | ||
1057 | state->Init_Ctrl[30].addr[2] = 166; | ||
1058 | state->Init_Ctrl[30].bit[2] = 2; | ||
1059 | state->Init_Ctrl[30].val[2] = 1; | ||
1060 | |||
1061 | state->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ; | ||
1062 | state->Init_Ctrl[31].size = 3 ; | ||
1063 | state->Init_Ctrl[31].addr[0] = 166; | ||
1064 | state->Init_Ctrl[31].bit[0] = 3; | ||
1065 | state->Init_Ctrl[31].val[0] = 1; | ||
1066 | state->Init_Ctrl[31].addr[1] = 166; | ||
1067 | state->Init_Ctrl[31].bit[1] = 4; | ||
1068 | state->Init_Ctrl[31].val[1] = 0; | ||
1069 | state->Init_Ctrl[31].addr[2] = 166; | ||
1070 | state->Init_Ctrl[31].bit[2] = 5; | ||
1071 | state->Init_Ctrl[31].val[2] = 1; | ||
1072 | |||
1073 | state->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ; | ||
1074 | state->Init_Ctrl[32].size = 3 ; | ||
1075 | state->Init_Ctrl[32].addr[0] = 167; | ||
1076 | state->Init_Ctrl[32].bit[0] = 0; | ||
1077 | state->Init_Ctrl[32].val[0] = 1; | ||
1078 | state->Init_Ctrl[32].addr[1] = 167; | ||
1079 | state->Init_Ctrl[32].bit[1] = 1; | ||
1080 | state->Init_Ctrl[32].val[1] = 1; | ||
1081 | state->Init_Ctrl[32].addr[2] = 167; | ||
1082 | state->Init_Ctrl[32].bit[2] = 2; | ||
1083 | state->Init_Ctrl[32].val[2] = 0; | ||
1084 | |||
1085 | state->Init_Ctrl[33].Ctrl_Num = RFA_FLR ; | ||
1086 | state->Init_Ctrl[33].size = 4 ; | ||
1087 | state->Init_Ctrl[33].addr[0] = 168; | ||
1088 | state->Init_Ctrl[33].bit[0] = 0; | ||
1089 | state->Init_Ctrl[33].val[0] = 0; | ||
1090 | state->Init_Ctrl[33].addr[1] = 168; | ||
1091 | state->Init_Ctrl[33].bit[1] = 1; | ||
1092 | state->Init_Ctrl[33].val[1] = 1; | ||
1093 | state->Init_Ctrl[33].addr[2] = 168; | ||
1094 | state->Init_Ctrl[33].bit[2] = 2; | ||
1095 | state->Init_Ctrl[33].val[2] = 0; | ||
1096 | state->Init_Ctrl[33].addr[3] = 168; | ||
1097 | state->Init_Ctrl[33].bit[3] = 3; | ||
1098 | state->Init_Ctrl[33].val[3] = 0; | ||
1099 | |||
1100 | state->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ; | ||
1101 | state->Init_Ctrl[34].size = 4 ; | ||
1102 | state->Init_Ctrl[34].addr[0] = 168; | ||
1103 | state->Init_Ctrl[34].bit[0] = 4; | ||
1104 | state->Init_Ctrl[34].val[0] = 1; | ||
1105 | state->Init_Ctrl[34].addr[1] = 168; | ||
1106 | state->Init_Ctrl[34].bit[1] = 5; | ||
1107 | state->Init_Ctrl[34].val[1] = 1; | ||
1108 | state->Init_Ctrl[34].addr[2] = 168; | ||
1109 | state->Init_Ctrl[34].bit[2] = 6; | ||
1110 | state->Init_Ctrl[34].val[2] = 1; | ||
1111 | state->Init_Ctrl[34].addr[3] = 168; | ||
1112 | state->Init_Ctrl[34].bit[3] = 7; | ||
1113 | state->Init_Ctrl[34].val[3] = 1; | ||
1114 | |||
1115 | state->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ; | ||
1116 | state->Init_Ctrl[35].size = 1 ; | ||
1117 | state->Init_Ctrl[35].addr[0] = 135; | ||
1118 | state->Init_Ctrl[35].bit[0] = 0; | ||
1119 | state->Init_Ctrl[35].val[0] = 0; | ||
1120 | |||
1121 | state->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ; | ||
1122 | state->Init_Ctrl[36].size = 1 ; | ||
1123 | state->Init_Ctrl[36].addr[0] = 56; | ||
1124 | state->Init_Ctrl[36].bit[0] = 3; | ||
1125 | state->Init_Ctrl[36].val[0] = 0; | ||
1126 | |||
1127 | state->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ; | ||
1128 | state->Init_Ctrl[37].size = 7 ; | ||
1129 | state->Init_Ctrl[37].addr[0] = 59; | ||
1130 | state->Init_Ctrl[37].bit[0] = 1; | ||
1131 | state->Init_Ctrl[37].val[0] = 0; | ||
1132 | state->Init_Ctrl[37].addr[1] = 59; | ||
1133 | state->Init_Ctrl[37].bit[1] = 2; | ||
1134 | state->Init_Ctrl[37].val[1] = 0; | ||
1135 | state->Init_Ctrl[37].addr[2] = 59; | ||
1136 | state->Init_Ctrl[37].bit[2] = 3; | ||
1137 | state->Init_Ctrl[37].val[2] = 0; | ||
1138 | state->Init_Ctrl[37].addr[3] = 59; | ||
1139 | state->Init_Ctrl[37].bit[3] = 4; | ||
1140 | state->Init_Ctrl[37].val[3] = 0; | ||
1141 | state->Init_Ctrl[37].addr[4] = 59; | ||
1142 | state->Init_Ctrl[37].bit[4] = 5; | ||
1143 | state->Init_Ctrl[37].val[4] = 0; | ||
1144 | state->Init_Ctrl[37].addr[5] = 59; | ||
1145 | state->Init_Ctrl[37].bit[5] = 6; | ||
1146 | state->Init_Ctrl[37].val[5] = 0; | ||
1147 | state->Init_Ctrl[37].addr[6] = 59; | ||
1148 | state->Init_Ctrl[37].bit[6] = 7; | ||
1149 | state->Init_Ctrl[37].val[6] = 0; | ||
1150 | |||
1151 | state->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ; | ||
1152 | state->Init_Ctrl[38].size = 6 ; | ||
1153 | state->Init_Ctrl[38].addr[0] = 32; | ||
1154 | state->Init_Ctrl[38].bit[0] = 2; | ||
1155 | state->Init_Ctrl[38].val[0] = 0; | ||
1156 | state->Init_Ctrl[38].addr[1] = 32; | ||
1157 | state->Init_Ctrl[38].bit[1] = 3; | ||
1158 | state->Init_Ctrl[38].val[1] = 0; | ||
1159 | state->Init_Ctrl[38].addr[2] = 32; | ||
1160 | state->Init_Ctrl[38].bit[2] = 4; | ||
1161 | state->Init_Ctrl[38].val[2] = 0; | ||
1162 | state->Init_Ctrl[38].addr[3] = 32; | ||
1163 | state->Init_Ctrl[38].bit[3] = 5; | ||
1164 | state->Init_Ctrl[38].val[3] = 0; | ||
1165 | state->Init_Ctrl[38].addr[4] = 32; | ||
1166 | state->Init_Ctrl[38].bit[4] = 6; | ||
1167 | state->Init_Ctrl[38].val[4] = 1; | ||
1168 | state->Init_Ctrl[38].addr[5] = 32; | ||
1169 | state->Init_Ctrl[38].bit[5] = 7; | ||
1170 | state->Init_Ctrl[38].val[5] = 0; | ||
1171 | |||
1172 | state->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ; | ||
1173 | state->Init_Ctrl[39].size = 1 ; | ||
1174 | state->Init_Ctrl[39].addr[0] = 25; | ||
1175 | state->Init_Ctrl[39].bit[0] = 3; | ||
1176 | state->Init_Ctrl[39].val[0] = 1; | ||
1177 | |||
1178 | |||
1179 | state->CH_Ctrl_Num = CHCTRL_NUM ; | ||
1180 | |||
1181 | state->CH_Ctrl[0].Ctrl_Num = DN_POLY ; | ||
1182 | state->CH_Ctrl[0].size = 2 ; | ||
1183 | state->CH_Ctrl[0].addr[0] = 68; | ||
1184 | state->CH_Ctrl[0].bit[0] = 6; | ||
1185 | state->CH_Ctrl[0].val[0] = 1; | ||
1186 | state->CH_Ctrl[0].addr[1] = 68; | ||
1187 | state->CH_Ctrl[0].bit[1] = 7; | ||
1188 | state->CH_Ctrl[0].val[1] = 1; | ||
1189 | |||
1190 | state->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ; | ||
1191 | state->CH_Ctrl[1].size = 2 ; | ||
1192 | state->CH_Ctrl[1].addr[0] = 70; | ||
1193 | state->CH_Ctrl[1].bit[0] = 6; | ||
1194 | state->CH_Ctrl[1].val[0] = 1; | ||
1195 | state->CH_Ctrl[1].addr[1] = 70; | ||
1196 | state->CH_Ctrl[1].bit[1] = 7; | ||
1197 | state->CH_Ctrl[1].val[1] = 0; | ||
1198 | |||
1199 | state->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ; | ||
1200 | state->CH_Ctrl[2].size = 9 ; | ||
1201 | state->CH_Ctrl[2].addr[0] = 69; | ||
1202 | state->CH_Ctrl[2].bit[0] = 5; | ||
1203 | state->CH_Ctrl[2].val[0] = 0; | ||
1204 | state->CH_Ctrl[2].addr[1] = 69; | ||
1205 | state->CH_Ctrl[2].bit[1] = 6; | ||
1206 | state->CH_Ctrl[2].val[1] = 0; | ||
1207 | state->CH_Ctrl[2].addr[2] = 69; | ||
1208 | state->CH_Ctrl[2].bit[2] = 7; | ||
1209 | state->CH_Ctrl[2].val[2] = 0; | ||
1210 | state->CH_Ctrl[2].addr[3] = 68; | ||
1211 | state->CH_Ctrl[2].bit[3] = 0; | ||
1212 | state->CH_Ctrl[2].val[3] = 0; | ||
1213 | state->CH_Ctrl[2].addr[4] = 68; | ||
1214 | state->CH_Ctrl[2].bit[4] = 1; | ||
1215 | state->CH_Ctrl[2].val[4] = 0; | ||
1216 | state->CH_Ctrl[2].addr[5] = 68; | ||
1217 | state->CH_Ctrl[2].bit[5] = 2; | ||
1218 | state->CH_Ctrl[2].val[5] = 0; | ||
1219 | state->CH_Ctrl[2].addr[6] = 68; | ||
1220 | state->CH_Ctrl[2].bit[6] = 3; | ||
1221 | state->CH_Ctrl[2].val[6] = 0; | ||
1222 | state->CH_Ctrl[2].addr[7] = 68; | ||
1223 | state->CH_Ctrl[2].bit[7] = 4; | ||
1224 | state->CH_Ctrl[2].val[7] = 0; | ||
1225 | state->CH_Ctrl[2].addr[8] = 68; | ||
1226 | state->CH_Ctrl[2].bit[8] = 5; | ||
1227 | state->CH_Ctrl[2].val[8] = 0; | ||
1228 | |||
1229 | state->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ; | ||
1230 | state->CH_Ctrl[3].size = 1 ; | ||
1231 | state->CH_Ctrl[3].addr[0] = 70; | ||
1232 | state->CH_Ctrl[3].bit[0] = 5; | ||
1233 | state->CH_Ctrl[3].val[0] = 0; | ||
1234 | |||
1235 | state->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ; | ||
1236 | state->CH_Ctrl[4].size = 3 ; | ||
1237 | state->CH_Ctrl[4].addr[0] = 73; | ||
1238 | state->CH_Ctrl[4].bit[0] = 4; | ||
1239 | state->CH_Ctrl[4].val[0] = 0; | ||
1240 | state->CH_Ctrl[4].addr[1] = 73; | ||
1241 | state->CH_Ctrl[4].bit[1] = 5; | ||
1242 | state->CH_Ctrl[4].val[1] = 1; | ||
1243 | state->CH_Ctrl[4].addr[2] = 73; | ||
1244 | state->CH_Ctrl[4].bit[2] = 6; | ||
1245 | state->CH_Ctrl[4].val[2] = 0; | ||
1246 | |||
1247 | state->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ; | ||
1248 | state->CH_Ctrl[5].size = 4 ; | ||
1249 | state->CH_Ctrl[5].addr[0] = 70; | ||
1250 | state->CH_Ctrl[5].bit[0] = 0; | ||
1251 | state->CH_Ctrl[5].val[0] = 0; | ||
1252 | state->CH_Ctrl[5].addr[1] = 70; | ||
1253 | state->CH_Ctrl[5].bit[1] = 1; | ||
1254 | state->CH_Ctrl[5].val[1] = 0; | ||
1255 | state->CH_Ctrl[5].addr[2] = 70; | ||
1256 | state->CH_Ctrl[5].bit[2] = 2; | ||
1257 | state->CH_Ctrl[5].val[2] = 0; | ||
1258 | state->CH_Ctrl[5].addr[3] = 70; | ||
1259 | state->CH_Ctrl[5].bit[3] = 3; | ||
1260 | state->CH_Ctrl[5].val[3] = 0; | ||
1261 | |||
1262 | state->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ; | ||
1263 | state->CH_Ctrl[6].size = 1 ; | ||
1264 | state->CH_Ctrl[6].addr[0] = 70; | ||
1265 | state->CH_Ctrl[6].bit[0] = 4; | ||
1266 | state->CH_Ctrl[6].val[0] = 1; | ||
1267 | |||
1268 | state->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ; | ||
1269 | state->CH_Ctrl[7].size = 1 ; | ||
1270 | state->CH_Ctrl[7].addr[0] = 111; | ||
1271 | state->CH_Ctrl[7].bit[0] = 4; | ||
1272 | state->CH_Ctrl[7].val[0] = 0; | ||
1273 | |||
1274 | state->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ; | ||
1275 | state->CH_Ctrl[8].size = 1 ; | ||
1276 | state->CH_Ctrl[8].addr[0] = 111; | ||
1277 | state->CH_Ctrl[8].bit[0] = 7; | ||
1278 | state->CH_Ctrl[8].val[0] = 1; | ||
1279 | |||
1280 | state->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ; | ||
1281 | state->CH_Ctrl[9].size = 1 ; | ||
1282 | state->CH_Ctrl[9].addr[0] = 111; | ||
1283 | state->CH_Ctrl[9].bit[0] = 6; | ||
1284 | state->CH_Ctrl[9].val[0] = 1; | ||
1285 | |||
1286 | state->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ; | ||
1287 | state->CH_Ctrl[10].size = 1 ; | ||
1288 | state->CH_Ctrl[10].addr[0] = 111; | ||
1289 | state->CH_Ctrl[10].bit[0] = 5; | ||
1290 | state->CH_Ctrl[10].val[0] = 0; | ||
1291 | |||
1292 | state->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ; | ||
1293 | state->CH_Ctrl[11].size = 2 ; | ||
1294 | state->CH_Ctrl[11].addr[0] = 110; | ||
1295 | state->CH_Ctrl[11].bit[0] = 0; | ||
1296 | state->CH_Ctrl[11].val[0] = 1; | ||
1297 | state->CH_Ctrl[11].addr[1] = 110; | ||
1298 | state->CH_Ctrl[11].bit[1] = 1; | ||
1299 | state->CH_Ctrl[11].val[1] = 0; | ||
1300 | |||
1301 | state->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ; | ||
1302 | state->CH_Ctrl[12].size = 3 ; | ||
1303 | state->CH_Ctrl[12].addr[0] = 69; | ||
1304 | state->CH_Ctrl[12].bit[0] = 2; | ||
1305 | state->CH_Ctrl[12].val[0] = 0; | ||
1306 | state->CH_Ctrl[12].addr[1] = 69; | ||
1307 | state->CH_Ctrl[12].bit[1] = 3; | ||
1308 | state->CH_Ctrl[12].val[1] = 0; | ||
1309 | state->CH_Ctrl[12].addr[2] = 69; | ||
1310 | state->CH_Ctrl[12].bit[2] = 4; | ||
1311 | state->CH_Ctrl[12].val[2] = 0; | ||
1312 | |||
1313 | state->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ; | ||
1314 | state->CH_Ctrl[13].size = 6 ; | ||
1315 | state->CH_Ctrl[13].addr[0] = 110; | ||
1316 | state->CH_Ctrl[13].bit[0] = 2; | ||
1317 | state->CH_Ctrl[13].val[0] = 0; | ||
1318 | state->CH_Ctrl[13].addr[1] = 110; | ||
1319 | state->CH_Ctrl[13].bit[1] = 3; | ||
1320 | state->CH_Ctrl[13].val[1] = 0; | ||
1321 | state->CH_Ctrl[13].addr[2] = 110; | ||
1322 | state->CH_Ctrl[13].bit[2] = 4; | ||
1323 | state->CH_Ctrl[13].val[2] = 0; | ||
1324 | state->CH_Ctrl[13].addr[3] = 110; | ||
1325 | state->CH_Ctrl[13].bit[3] = 5; | ||
1326 | state->CH_Ctrl[13].val[3] = 0; | ||
1327 | state->CH_Ctrl[13].addr[4] = 110; | ||
1328 | state->CH_Ctrl[13].bit[4] = 6; | ||
1329 | state->CH_Ctrl[13].val[4] = 0; | ||
1330 | state->CH_Ctrl[13].addr[5] = 110; | ||
1331 | state->CH_Ctrl[13].bit[5] = 7; | ||
1332 | state->CH_Ctrl[13].val[5] = 1; | ||
1333 | |||
1334 | state->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ; | ||
1335 | state->CH_Ctrl[14].size = 7 ; | ||
1336 | state->CH_Ctrl[14].addr[0] = 14; | ||
1337 | state->CH_Ctrl[14].bit[0] = 0; | ||
1338 | state->CH_Ctrl[14].val[0] = 0; | ||
1339 | state->CH_Ctrl[14].addr[1] = 14; | ||
1340 | state->CH_Ctrl[14].bit[1] = 1; | ||
1341 | state->CH_Ctrl[14].val[1] = 0; | ||
1342 | state->CH_Ctrl[14].addr[2] = 14; | ||
1343 | state->CH_Ctrl[14].bit[2] = 2; | ||
1344 | state->CH_Ctrl[14].val[2] = 0; | ||
1345 | state->CH_Ctrl[14].addr[3] = 14; | ||
1346 | state->CH_Ctrl[14].bit[3] = 3; | ||
1347 | state->CH_Ctrl[14].val[3] = 0; | ||
1348 | state->CH_Ctrl[14].addr[4] = 14; | ||
1349 | state->CH_Ctrl[14].bit[4] = 4; | ||
1350 | state->CH_Ctrl[14].val[4] = 0; | ||
1351 | state->CH_Ctrl[14].addr[5] = 14; | ||
1352 | state->CH_Ctrl[14].bit[5] = 5; | ||
1353 | state->CH_Ctrl[14].val[5] = 0; | ||
1354 | state->CH_Ctrl[14].addr[6] = 14; | ||
1355 | state->CH_Ctrl[14].bit[6] = 6; | ||
1356 | state->CH_Ctrl[14].val[6] = 0; | ||
1357 | |||
1358 | state->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ; | ||
1359 | state->CH_Ctrl[15].size = 18 ; | ||
1360 | state->CH_Ctrl[15].addr[0] = 17; | ||
1361 | state->CH_Ctrl[15].bit[0] = 6; | ||
1362 | state->CH_Ctrl[15].val[0] = 0; | ||
1363 | state->CH_Ctrl[15].addr[1] = 17; | ||
1364 | state->CH_Ctrl[15].bit[1] = 7; | ||
1365 | state->CH_Ctrl[15].val[1] = 0; | ||
1366 | state->CH_Ctrl[15].addr[2] = 16; | ||
1367 | state->CH_Ctrl[15].bit[2] = 0; | ||
1368 | state->CH_Ctrl[15].val[2] = 0; | ||
1369 | state->CH_Ctrl[15].addr[3] = 16; | ||
1370 | state->CH_Ctrl[15].bit[3] = 1; | ||
1371 | state->CH_Ctrl[15].val[3] = 0; | ||
1372 | state->CH_Ctrl[15].addr[4] = 16; | ||
1373 | state->CH_Ctrl[15].bit[4] = 2; | ||
1374 | state->CH_Ctrl[15].val[4] = 0; | ||
1375 | state->CH_Ctrl[15].addr[5] = 16; | ||
1376 | state->CH_Ctrl[15].bit[5] = 3; | ||
1377 | state->CH_Ctrl[15].val[5] = 0; | ||
1378 | state->CH_Ctrl[15].addr[6] = 16; | ||
1379 | state->CH_Ctrl[15].bit[6] = 4; | ||
1380 | state->CH_Ctrl[15].val[6] = 0; | ||
1381 | state->CH_Ctrl[15].addr[7] = 16; | ||
1382 | state->CH_Ctrl[15].bit[7] = 5; | ||
1383 | state->CH_Ctrl[15].val[7] = 0; | ||
1384 | state->CH_Ctrl[15].addr[8] = 16; | ||
1385 | state->CH_Ctrl[15].bit[8] = 6; | ||
1386 | state->CH_Ctrl[15].val[8] = 0; | ||
1387 | state->CH_Ctrl[15].addr[9] = 16; | ||
1388 | state->CH_Ctrl[15].bit[9] = 7; | ||
1389 | state->CH_Ctrl[15].val[9] = 0; | ||
1390 | state->CH_Ctrl[15].addr[10] = 15; | ||
1391 | state->CH_Ctrl[15].bit[10] = 0; | ||
1392 | state->CH_Ctrl[15].val[10] = 0; | ||
1393 | state->CH_Ctrl[15].addr[11] = 15; | ||
1394 | state->CH_Ctrl[15].bit[11] = 1; | ||
1395 | state->CH_Ctrl[15].val[11] = 0; | ||
1396 | state->CH_Ctrl[15].addr[12] = 15; | ||
1397 | state->CH_Ctrl[15].bit[12] = 2; | ||
1398 | state->CH_Ctrl[15].val[12] = 0; | ||
1399 | state->CH_Ctrl[15].addr[13] = 15; | ||
1400 | state->CH_Ctrl[15].bit[13] = 3; | ||
1401 | state->CH_Ctrl[15].val[13] = 0; | ||
1402 | state->CH_Ctrl[15].addr[14] = 15; | ||
1403 | state->CH_Ctrl[15].bit[14] = 4; | ||
1404 | state->CH_Ctrl[15].val[14] = 0; | ||
1405 | state->CH_Ctrl[15].addr[15] = 15; | ||
1406 | state->CH_Ctrl[15].bit[15] = 5; | ||
1407 | state->CH_Ctrl[15].val[15] = 0; | ||
1408 | state->CH_Ctrl[15].addr[16] = 15; | ||
1409 | state->CH_Ctrl[15].bit[16] = 6; | ||
1410 | state->CH_Ctrl[15].val[16] = 1; | ||
1411 | state->CH_Ctrl[15].addr[17] = 15; | ||
1412 | state->CH_Ctrl[15].bit[17] = 7; | ||
1413 | state->CH_Ctrl[15].val[17] = 1; | ||
1414 | |||
1415 | state->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ; | ||
1416 | state->CH_Ctrl[16].size = 5 ; | ||
1417 | state->CH_Ctrl[16].addr[0] = 112; | ||
1418 | state->CH_Ctrl[16].bit[0] = 0; | ||
1419 | state->CH_Ctrl[16].val[0] = 0; | ||
1420 | state->CH_Ctrl[16].addr[1] = 112; | ||
1421 | state->CH_Ctrl[16].bit[1] = 1; | ||
1422 | state->CH_Ctrl[16].val[1] = 0; | ||
1423 | state->CH_Ctrl[16].addr[2] = 112; | ||
1424 | state->CH_Ctrl[16].bit[2] = 2; | ||
1425 | state->CH_Ctrl[16].val[2] = 0; | ||
1426 | state->CH_Ctrl[16].addr[3] = 112; | ||
1427 | state->CH_Ctrl[16].bit[3] = 3; | ||
1428 | state->CH_Ctrl[16].val[3] = 0; | ||
1429 | state->CH_Ctrl[16].addr[4] = 112; | ||
1430 | state->CH_Ctrl[16].bit[4] = 4; | ||
1431 | state->CH_Ctrl[16].val[4] = 1; | ||
1432 | |||
1433 | state->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ; | ||
1434 | state->CH_Ctrl[17].size = 1 ; | ||
1435 | state->CH_Ctrl[17].addr[0] = 14; | ||
1436 | state->CH_Ctrl[17].bit[0] = 7; | ||
1437 | state->CH_Ctrl[17].val[0] = 0; | ||
1438 | |||
1439 | state->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ; | ||
1440 | state->CH_Ctrl[18].size = 4 ; | ||
1441 | state->CH_Ctrl[18].addr[0] = 107; | ||
1442 | state->CH_Ctrl[18].bit[0] = 3; | ||
1443 | state->CH_Ctrl[18].val[0] = 0; | ||
1444 | state->CH_Ctrl[18].addr[1] = 107; | ||
1445 | state->CH_Ctrl[18].bit[1] = 4; | ||
1446 | state->CH_Ctrl[18].val[1] = 0; | ||
1447 | state->CH_Ctrl[18].addr[2] = 107; | ||
1448 | state->CH_Ctrl[18].bit[2] = 5; | ||
1449 | state->CH_Ctrl[18].val[2] = 0; | ||
1450 | state->CH_Ctrl[18].addr[3] = 107; | ||
1451 | state->CH_Ctrl[18].bit[3] = 6; | ||
1452 | state->CH_Ctrl[18].val[3] = 0; | ||
1453 | |||
1454 | state->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ; | ||
1455 | state->CH_Ctrl[19].size = 3 ; | ||
1456 | state->CH_Ctrl[19].addr[0] = 107; | ||
1457 | state->CH_Ctrl[19].bit[0] = 7; | ||
1458 | state->CH_Ctrl[19].val[0] = 1; | ||
1459 | state->CH_Ctrl[19].addr[1] = 106; | ||
1460 | state->CH_Ctrl[19].bit[1] = 0; | ||
1461 | state->CH_Ctrl[19].val[1] = 1; | ||
1462 | state->CH_Ctrl[19].addr[2] = 106; | ||
1463 | state->CH_Ctrl[19].bit[2] = 1; | ||
1464 | state->CH_Ctrl[19].val[2] = 1; | ||
1465 | |||
1466 | state->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ; | ||
1467 | state->CH_Ctrl[20].size = 11 ; | ||
1468 | state->CH_Ctrl[20].addr[0] = 109; | ||
1469 | state->CH_Ctrl[20].bit[0] = 2; | ||
1470 | state->CH_Ctrl[20].val[0] = 0; | ||
1471 | state->CH_Ctrl[20].addr[1] = 109; | ||
1472 | state->CH_Ctrl[20].bit[1] = 3; | ||
1473 | state->CH_Ctrl[20].val[1] = 0; | ||
1474 | state->CH_Ctrl[20].addr[2] = 109; | ||
1475 | state->CH_Ctrl[20].bit[2] = 4; | ||
1476 | state->CH_Ctrl[20].val[2] = 0; | ||
1477 | state->CH_Ctrl[20].addr[3] = 109; | ||
1478 | state->CH_Ctrl[20].bit[3] = 5; | ||
1479 | state->CH_Ctrl[20].val[3] = 0; | ||
1480 | state->CH_Ctrl[20].addr[4] = 109; | ||
1481 | state->CH_Ctrl[20].bit[4] = 6; | ||
1482 | state->CH_Ctrl[20].val[4] = 0; | ||
1483 | state->CH_Ctrl[20].addr[5] = 109; | ||
1484 | state->CH_Ctrl[20].bit[5] = 7; | ||
1485 | state->CH_Ctrl[20].val[5] = 0; | ||
1486 | state->CH_Ctrl[20].addr[6] = 108; | ||
1487 | state->CH_Ctrl[20].bit[6] = 0; | ||
1488 | state->CH_Ctrl[20].val[6] = 0; | ||
1489 | state->CH_Ctrl[20].addr[7] = 108; | ||
1490 | state->CH_Ctrl[20].bit[7] = 1; | ||
1491 | state->CH_Ctrl[20].val[7] = 0; | ||
1492 | state->CH_Ctrl[20].addr[8] = 108; | ||
1493 | state->CH_Ctrl[20].bit[8] = 2; | ||
1494 | state->CH_Ctrl[20].val[8] = 1; | ||
1495 | state->CH_Ctrl[20].addr[9] = 108; | ||
1496 | state->CH_Ctrl[20].bit[9] = 3; | ||
1497 | state->CH_Ctrl[20].val[9] = 1; | ||
1498 | state->CH_Ctrl[20].addr[10] = 108; | ||
1499 | state->CH_Ctrl[20].bit[10] = 4; | ||
1500 | state->CH_Ctrl[20].val[10] = 1; | ||
1501 | |||
1502 | state->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ; | ||
1503 | state->CH_Ctrl[21].size = 6 ; | ||
1504 | state->CH_Ctrl[21].addr[0] = 106; | ||
1505 | state->CH_Ctrl[21].bit[0] = 2; | ||
1506 | state->CH_Ctrl[21].val[0] = 0; | ||
1507 | state->CH_Ctrl[21].addr[1] = 106; | ||
1508 | state->CH_Ctrl[21].bit[1] = 3; | ||
1509 | state->CH_Ctrl[21].val[1] = 0; | ||
1510 | state->CH_Ctrl[21].addr[2] = 106; | ||
1511 | state->CH_Ctrl[21].bit[2] = 4; | ||
1512 | state->CH_Ctrl[21].val[2] = 0; | ||
1513 | state->CH_Ctrl[21].addr[3] = 106; | ||
1514 | state->CH_Ctrl[21].bit[3] = 5; | ||
1515 | state->CH_Ctrl[21].val[3] = 0; | ||
1516 | state->CH_Ctrl[21].addr[4] = 106; | ||
1517 | state->CH_Ctrl[21].bit[4] = 6; | ||
1518 | state->CH_Ctrl[21].val[4] = 0; | ||
1519 | state->CH_Ctrl[21].addr[5] = 106; | ||
1520 | state->CH_Ctrl[21].bit[5] = 7; | ||
1521 | state->CH_Ctrl[21].val[5] = 1; | ||
1522 | |||
1523 | state->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ; | ||
1524 | state->CH_Ctrl[22].size = 1 ; | ||
1525 | state->CH_Ctrl[22].addr[0] = 138; | ||
1526 | state->CH_Ctrl[22].bit[0] = 4; | ||
1527 | state->CH_Ctrl[22].val[0] = 1; | ||
1528 | |||
1529 | state->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ; | ||
1530 | state->CH_Ctrl[23].size = 1 ; | ||
1531 | state->CH_Ctrl[23].addr[0] = 17; | ||
1532 | state->CH_Ctrl[23].bit[0] = 5; | ||
1533 | state->CH_Ctrl[23].val[0] = 0; | ||
1534 | |||
1535 | state->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ; | ||
1536 | state->CH_Ctrl[24].size = 1 ; | ||
1537 | state->CH_Ctrl[24].addr[0] = 111; | ||
1538 | state->CH_Ctrl[24].bit[0] = 3; | ||
1539 | state->CH_Ctrl[24].val[0] = 0; | ||
1540 | |||
1541 | state->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ; | ||
1542 | state->CH_Ctrl[25].size = 1 ; | ||
1543 | state->CH_Ctrl[25].addr[0] = 112; | ||
1544 | state->CH_Ctrl[25].bit[0] = 7; | ||
1545 | state->CH_Ctrl[25].val[0] = 0; | ||
1546 | |||
1547 | state->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ; | ||
1548 | state->CH_Ctrl[26].size = 1 ; | ||
1549 | state->CH_Ctrl[26].addr[0] = 136; | ||
1550 | state->CH_Ctrl[26].bit[0] = 7; | ||
1551 | state->CH_Ctrl[26].val[0] = 0; | ||
1552 | |||
1553 | state->CH_Ctrl[27].Ctrl_Num = GPIO_4B ; | ||
1554 | state->CH_Ctrl[27].size = 1 ; | ||
1555 | state->CH_Ctrl[27].addr[0] = 149; | ||
1556 | state->CH_Ctrl[27].bit[0] = 7; | ||
1557 | state->CH_Ctrl[27].val[0] = 0; | ||
1558 | |||
1559 | state->CH_Ctrl[28].Ctrl_Num = GPIO_3B ; | ||
1560 | state->CH_Ctrl[28].size = 1 ; | ||
1561 | state->CH_Ctrl[28].addr[0] = 149; | ||
1562 | state->CH_Ctrl[28].bit[0] = 6; | ||
1563 | state->CH_Ctrl[28].val[0] = 0; | ||
1564 | |||
1565 | state->CH_Ctrl[29].Ctrl_Num = GPIO_4 ; | ||
1566 | state->CH_Ctrl[29].size = 1 ; | ||
1567 | state->CH_Ctrl[29].addr[0] = 149; | ||
1568 | state->CH_Ctrl[29].bit[0] = 5; | ||
1569 | state->CH_Ctrl[29].val[0] = 1; | ||
1570 | |||
1571 | state->CH_Ctrl[30].Ctrl_Num = GPIO_3 ; | ||
1572 | state->CH_Ctrl[30].size = 1 ; | ||
1573 | state->CH_Ctrl[30].addr[0] = 149; | ||
1574 | state->CH_Ctrl[30].bit[0] = 4; | ||
1575 | state->CH_Ctrl[30].val[0] = 1; | ||
1576 | |||
1577 | state->CH_Ctrl[31].Ctrl_Num = GPIO_1B ; | ||
1578 | state->CH_Ctrl[31].size = 1 ; | ||
1579 | state->CH_Ctrl[31].addr[0] = 149; | ||
1580 | state->CH_Ctrl[31].bit[0] = 3; | ||
1581 | state->CH_Ctrl[31].val[0] = 0; | ||
1582 | |||
1583 | state->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ; | ||
1584 | state->CH_Ctrl[32].size = 1 ; | ||
1585 | state->CH_Ctrl[32].addr[0] = 93; | ||
1586 | state->CH_Ctrl[32].bit[0] = 1; | ||
1587 | state->CH_Ctrl[32].val[0] = 0; | ||
1588 | |||
1589 | state->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ; | ||
1590 | state->CH_Ctrl[33].size = 1 ; | ||
1591 | state->CH_Ctrl[33].addr[0] = 93; | ||
1592 | state->CH_Ctrl[33].bit[0] = 0; | ||
1593 | state->CH_Ctrl[33].val[0] = 0; | ||
1594 | |||
1595 | state->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ; | ||
1596 | state->CH_Ctrl[34].size = 6 ; | ||
1597 | state->CH_Ctrl[34].addr[0] = 92; | ||
1598 | state->CH_Ctrl[34].bit[0] = 2; | ||
1599 | state->CH_Ctrl[34].val[0] = 0; | ||
1600 | state->CH_Ctrl[34].addr[1] = 92; | ||
1601 | state->CH_Ctrl[34].bit[1] = 3; | ||
1602 | state->CH_Ctrl[34].val[1] = 0; | ||
1603 | state->CH_Ctrl[34].addr[2] = 92; | ||
1604 | state->CH_Ctrl[34].bit[2] = 4; | ||
1605 | state->CH_Ctrl[34].val[2] = 0; | ||
1606 | state->CH_Ctrl[34].addr[3] = 92; | ||
1607 | state->CH_Ctrl[34].bit[3] = 5; | ||
1608 | state->CH_Ctrl[34].val[3] = 0; | ||
1609 | state->CH_Ctrl[34].addr[4] = 92; | ||
1610 | state->CH_Ctrl[34].bit[4] = 6; | ||
1611 | state->CH_Ctrl[34].val[4] = 0; | ||
1612 | state->CH_Ctrl[34].addr[5] = 92; | ||
1613 | state->CH_Ctrl[34].bit[5] = 7; | ||
1614 | state->CH_Ctrl[34].val[5] = 0; | ||
1615 | |||
1616 | state->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ; | ||
1617 | state->CH_Ctrl[35].size = 6 ; | ||
1618 | state->CH_Ctrl[35].addr[0] = 93; | ||
1619 | state->CH_Ctrl[35].bit[0] = 2; | ||
1620 | state->CH_Ctrl[35].val[0] = 0; | ||
1621 | state->CH_Ctrl[35].addr[1] = 93; | ||
1622 | state->CH_Ctrl[35].bit[1] = 3; | ||
1623 | state->CH_Ctrl[35].val[1] = 0; | ||
1624 | state->CH_Ctrl[35].addr[2] = 93; | ||
1625 | state->CH_Ctrl[35].bit[2] = 4; | ||
1626 | state->CH_Ctrl[35].val[2] = 0; | ||
1627 | state->CH_Ctrl[35].addr[3] = 93; | ||
1628 | state->CH_Ctrl[35].bit[3] = 5; | ||
1629 | state->CH_Ctrl[35].val[3] = 0; | ||
1630 | state->CH_Ctrl[35].addr[4] = 93; | ||
1631 | state->CH_Ctrl[35].bit[4] = 6; | ||
1632 | state->CH_Ctrl[35].val[4] = 0; | ||
1633 | state->CH_Ctrl[35].addr[5] = 93; | ||
1634 | state->CH_Ctrl[35].bit[5] = 7; | ||
1635 | state->CH_Ctrl[35].val[5] = 0; | ||
1636 | |||
1637 | #ifdef _MXL_PRODUCTION | ||
1638 | state->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ; | ||
1639 | state->CH_Ctrl[36].size = 1 ; | ||
1640 | state->CH_Ctrl[36].addr[0] = 109; | ||
1641 | state->CH_Ctrl[36].bit[0] = 1; | ||
1642 | state->CH_Ctrl[36].val[0] = 1; | ||
1643 | |||
1644 | state->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ; | ||
1645 | state->CH_Ctrl[37].size = 2 ; | ||
1646 | state->CH_Ctrl[37].addr[0] = 112; | ||
1647 | state->CH_Ctrl[37].bit[0] = 5; | ||
1648 | state->CH_Ctrl[37].val[0] = 0; | ||
1649 | state->CH_Ctrl[37].addr[1] = 112; | ||
1650 | state->CH_Ctrl[37].bit[1] = 6; | ||
1651 | state->CH_Ctrl[37].val[1] = 0; | ||
1652 | |||
1653 | state->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ; | ||
1654 | state->CH_Ctrl[38].size = 1 ; | ||
1655 | state->CH_Ctrl[38].addr[0] = 65; | ||
1656 | state->CH_Ctrl[38].bit[0] = 1; | ||
1657 | state->CH_Ctrl[38].val[0] = 0; | ||
1658 | #endif | ||
1659 | |||
1660 | return 0 ; | ||
1661 | } | ||
1662 | |||
1663 | static void InitTunerControls(struct dvb_frontend *fe) | ||
1664 | { | ||
1665 | MXL5005_RegisterInit(fe); | ||
1666 | MXL5005_ControlInit(fe); | ||
1667 | #ifdef _MXL_INTERNAL | ||
1668 | MXL5005_MXLControlInit(fe); | ||
1669 | #endif | ||
1670 | } | ||
1671 | |||
1672 | static u16 MXL5005_TunerConfig(struct dvb_frontend *fe, | ||
1673 | u8 Mode, /* 0: Analog Mode ; 1: Digital Mode */ | ||
1674 | u8 IF_mode, /* for Analog Mode, 0: zero IF; 1: low IF */ | ||
1675 | u32 Bandwidth, /* filter channel bandwidth (6, 7, 8) */ | ||
1676 | u32 IF_out, /* Desired IF Out Frequency */ | ||
1677 | u32 Fxtal, /* XTAL Frequency */ | ||
1678 | u8 AGC_Mode, /* AGC Mode - Dual AGC: 0, Single AGC: 1 */ | ||
1679 | u16 TOP, /* 0: Dual AGC; Value: take over point */ | ||
1680 | u16 IF_OUT_LOAD, /* IF Out Load Resistor (200 / 300 Ohms) */ | ||
1681 | u8 CLOCK_OUT, /* 0: turn off clk out; 1: turn on clock out */ | ||
1682 | u8 DIV_OUT, /* 0: Div-1; 1: Div-4 */ | ||
1683 | u8 CAPSELECT, /* 0: disable On-Chip pulling cap; 1: enable */ | ||
1684 | u8 EN_RSSI, /* 0: disable RSSI; 1: enable RSSI */ | ||
1685 | |||
1686 | /* Modulation Type; */ | ||
1687 | /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */ | ||
1688 | u8 Mod_Type, | ||
1689 | |||
1690 | /* Tracking Filter */ | ||
1691 | /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */ | ||
1692 | u8 TF_Type | ||
1693 | ) | ||
1694 | { | ||
1695 | struct mxl5005s_state *state = fe->tuner_priv; | ||
1696 | u16 status = 0; | ||
1697 | |||
1698 | state->Mode = Mode; | ||
1699 | state->IF_Mode = IF_mode; | ||
1700 | state->Chan_Bandwidth = Bandwidth; | ||
1701 | state->IF_OUT = IF_out; | ||
1702 | state->Fxtal = Fxtal; | ||
1703 | state->AGC_Mode = AGC_Mode; | ||
1704 | state->TOP = TOP; | ||
1705 | state->IF_OUT_LOAD = IF_OUT_LOAD; | ||
1706 | state->CLOCK_OUT = CLOCK_OUT; | ||
1707 | state->DIV_OUT = DIV_OUT; | ||
1708 | state->CAPSELECT = CAPSELECT; | ||
1709 | state->EN_RSSI = EN_RSSI; | ||
1710 | state->Mod_Type = Mod_Type; | ||
1711 | state->TF_Type = TF_Type; | ||
1712 | |||
1713 | /* Initialize all the controls and registers */ | ||
1714 | InitTunerControls(fe); | ||
1715 | |||
1716 | /* Synthesizer LO frequency calculation */ | ||
1717 | MXL_SynthIFLO_Calc(fe); | ||
1718 | |||
1719 | return status; | ||
1720 | } | ||
1721 | |||
1722 | static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe) | ||
1723 | { | ||
1724 | struct mxl5005s_state *state = fe->tuner_priv; | ||
1725 | if (state->Mode == 1) /* Digital Mode */ | ||
1726 | state->IF_LO = state->IF_OUT; | ||
1727 | else /* Analog Mode */ { | ||
1728 | if (state->IF_Mode == 0) /* Analog Zero IF mode */ | ||
1729 | state->IF_LO = state->IF_OUT + 400000; | ||
1730 | else /* Analog Low IF mode */ | ||
1731 | state->IF_LO = state->IF_OUT + state->Chan_Bandwidth/2; | ||
1732 | } | ||
1733 | } | ||
1734 | |||
1735 | static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe) | ||
1736 | { | ||
1737 | struct mxl5005s_state *state = fe->tuner_priv; | ||
1738 | |||
1739 | if (state->Mode == 1) /* Digital Mode */ { | ||
1740 | /* remove 20.48MHz setting for 2.6.10 */ | ||
1741 | state->RF_LO = state->RF_IN; | ||
1742 | /* change for 2.6.6 */ | ||
1743 | state->TG_LO = state->RF_IN - 750000; | ||
1744 | } else /* Analog Mode */ { | ||
1745 | if (state->IF_Mode == 0) /* Analog Zero IF mode */ { | ||
1746 | state->RF_LO = state->RF_IN - 400000; | ||
1747 | state->TG_LO = state->RF_IN - 1750000; | ||
1748 | } else /* Analog Low IF mode */ { | ||
1749 | state->RF_LO = state->RF_IN - state->Chan_Bandwidth/2; | ||
1750 | state->TG_LO = state->RF_IN - | ||
1751 | state->Chan_Bandwidth + 500000; | ||
1752 | } | ||
1753 | } | ||
1754 | } | ||
1755 | |||
1756 | static u16 MXL_OverwriteICDefault(struct dvb_frontend *fe) | ||
1757 | { | ||
1758 | u16 status = 0; | ||
1759 | |||
1760 | status += MXL_ControlWrite(fe, OVERRIDE_1, 1); | ||
1761 | status += MXL_ControlWrite(fe, OVERRIDE_2, 1); | ||
1762 | status += MXL_ControlWrite(fe, OVERRIDE_3, 1); | ||
1763 | status += MXL_ControlWrite(fe, OVERRIDE_4, 1); | ||
1764 | |||
1765 | return status; | ||
1766 | } | ||
1767 | |||
1768 | static u16 MXL_BlockInit(struct dvb_frontend *fe) | ||
1769 | { | ||
1770 | struct mxl5005s_state *state = fe->tuner_priv; | ||
1771 | u16 status = 0; | ||
1772 | |||
1773 | status += MXL_OverwriteICDefault(fe); | ||
1774 | |||
1775 | /* Downconverter Control Dig Ana */ | ||
1776 | status += MXL_ControlWrite(fe, DN_IQTN_AMP_CUT, state->Mode ? 1 : 0); | ||
1777 | |||
1778 | /* Filter Control Dig Ana */ | ||
1779 | status += MXL_ControlWrite(fe, BB_MODE, state->Mode ? 0 : 1); | ||
1780 | status += MXL_ControlWrite(fe, BB_BUF, state->Mode ? 3 : 2); | ||
1781 | status += MXL_ControlWrite(fe, BB_BUF_OA, state->Mode ? 1 : 0); | ||
1782 | status += MXL_ControlWrite(fe, BB_IQSWAP, state->Mode ? 0 : 1); | ||
1783 | status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 0); | ||
1784 | |||
1785 | /* Initialize Low-Pass Filter */ | ||
1786 | if (state->Mode) { /* Digital Mode */ | ||
1787 | switch (state->Chan_Bandwidth) { | ||
1788 | case 8000000: | ||
1789 | status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 0); | ||
1790 | break; | ||
1791 | case 7000000: | ||
1792 | status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 2); | ||
1793 | break; | ||
1794 | case 6000000: | ||
1795 | status += MXL_ControlWrite(fe, | ||
1796 | BB_DLPF_BANDSEL, 3); | ||
1797 | break; | ||
1798 | } | ||
1799 | } else { /* Analog Mode */ | ||
1800 | switch (state->Chan_Bandwidth) { | ||
1801 | case 8000000: /* Low Zero */ | ||
1802 | status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, | ||
1803 | (state->IF_Mode ? 0 : 3)); | ||
1804 | break; | ||
1805 | case 7000000: | ||
1806 | status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, | ||
1807 | (state->IF_Mode ? 1 : 4)); | ||
1808 | break; | ||
1809 | case 6000000: | ||
1810 | status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT, | ||
1811 | (state->IF_Mode ? 2 : 5)); | ||
1812 | break; | ||
1813 | } | ||
1814 | } | ||
1815 | |||
1816 | /* Charge Pump Control Dig Ana */ | ||
1817 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, state->Mode ? 5 : 8); | ||
1818 | status += MXL_ControlWrite(fe, | ||
1819 | RFSYN_EN_CHP_HIGAIN, state->Mode ? 1 : 1); | ||
1820 | status += MXL_ControlWrite(fe, EN_CHP_LIN_B, state->Mode ? 0 : 0); | ||
1821 | |||
1822 | /* AGC TOP Control */ | ||
1823 | if (state->AGC_Mode == 0) /* Dual AGC */ { | ||
1824 | status += MXL_ControlWrite(fe, AGC_IF, 15); | ||
1825 | status += MXL_ControlWrite(fe, AGC_RF, 15); | ||
1826 | } else /* Single AGC Mode Dig Ana */ | ||
1827 | status += MXL_ControlWrite(fe, AGC_RF, state->Mode ? 15 : 12); | ||
1828 | |||
1829 | if (state->TOP == 55) /* TOP == 5.5 */ | ||
1830 | status += MXL_ControlWrite(fe, AGC_IF, 0x0); | ||
1831 | |||
1832 | if (state->TOP == 72) /* TOP == 7.2 */ | ||
1833 | status += MXL_ControlWrite(fe, AGC_IF, 0x1); | ||
1834 | |||
1835 | if (state->TOP == 92) /* TOP == 9.2 */ | ||
1836 | status += MXL_ControlWrite(fe, AGC_IF, 0x2); | ||
1837 | |||
1838 | if (state->TOP == 110) /* TOP == 11.0 */ | ||
1839 | status += MXL_ControlWrite(fe, AGC_IF, 0x3); | ||
1840 | |||
1841 | if (state->TOP == 129) /* TOP == 12.9 */ | ||
1842 | status += MXL_ControlWrite(fe, AGC_IF, 0x4); | ||
1843 | |||
1844 | if (state->TOP == 147) /* TOP == 14.7 */ | ||
1845 | status += MXL_ControlWrite(fe, AGC_IF, 0x5); | ||
1846 | |||
1847 | if (state->TOP == 168) /* TOP == 16.8 */ | ||
1848 | status += MXL_ControlWrite(fe, AGC_IF, 0x6); | ||
1849 | |||
1850 | if (state->TOP == 194) /* TOP == 19.4 */ | ||
1851 | status += MXL_ControlWrite(fe, AGC_IF, 0x7); | ||
1852 | |||
1853 | if (state->TOP == 212) /* TOP == 21.2 */ | ||
1854 | status += MXL_ControlWrite(fe, AGC_IF, 0x9); | ||
1855 | |||
1856 | if (state->TOP == 232) /* TOP == 23.2 */ | ||
1857 | status += MXL_ControlWrite(fe, AGC_IF, 0xA); | ||
1858 | |||
1859 | if (state->TOP == 252) /* TOP == 25.2 */ | ||
1860 | status += MXL_ControlWrite(fe, AGC_IF, 0xB); | ||
1861 | |||
1862 | if (state->TOP == 271) /* TOP == 27.1 */ | ||
1863 | status += MXL_ControlWrite(fe, AGC_IF, 0xC); | ||
1864 | |||
1865 | if (state->TOP == 292) /* TOP == 29.2 */ | ||
1866 | status += MXL_ControlWrite(fe, AGC_IF, 0xD); | ||
1867 | |||
1868 | if (state->TOP == 317) /* TOP == 31.7 */ | ||
1869 | status += MXL_ControlWrite(fe, AGC_IF, 0xE); | ||
1870 | |||
1871 | if (state->TOP == 349) /* TOP == 34.9 */ | ||
1872 | status += MXL_ControlWrite(fe, AGC_IF, 0xF); | ||
1873 | |||
1874 | /* IF Synthesizer Control */ | ||
1875 | status += MXL_IFSynthInit(fe); | ||
1876 | |||
1877 | /* IF UpConverter Control */ | ||
1878 | if (state->IF_OUT_LOAD == 200) { | ||
1879 | status += MXL_ControlWrite(fe, DRV_RES_SEL, 6); | ||
1880 | status += MXL_ControlWrite(fe, I_DRIVER, 2); | ||
1881 | } | ||
1882 | if (state->IF_OUT_LOAD == 300) { | ||
1883 | status += MXL_ControlWrite(fe, DRV_RES_SEL, 4); | ||
1884 | status += MXL_ControlWrite(fe, I_DRIVER, 1); | ||
1885 | } | ||
1886 | |||
1887 | /* Anti-Alias Filtering Control | ||
1888 | * initialise Anti-Aliasing Filter | ||
1889 | */ | ||
1890 | if (state->Mode) { /* Digital Mode */ | ||
1891 | if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 6280000UL) { | ||
1892 | status += MXL_ControlWrite(fe, EN_AAF, 1); | ||
1893 | status += MXL_ControlWrite(fe, EN_3P, 1); | ||
1894 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); | ||
1895 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); | ||
1896 | } | ||
1897 | if ((state->IF_OUT == 36125000UL) || | ||
1898 | (state->IF_OUT == 36150000UL)) { | ||
1899 | status += MXL_ControlWrite(fe, EN_AAF, 1); | ||
1900 | status += MXL_ControlWrite(fe, EN_3P, 1); | ||
1901 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); | ||
1902 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1); | ||
1903 | } | ||
1904 | if (state->IF_OUT > 36150000UL) { | ||
1905 | status += MXL_ControlWrite(fe, EN_AAF, 0); | ||
1906 | status += MXL_ControlWrite(fe, EN_3P, 1); | ||
1907 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); | ||
1908 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1); | ||
1909 | } | ||
1910 | } else { /* Analog Mode */ | ||
1911 | if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 5000000UL) { | ||
1912 | status += MXL_ControlWrite(fe, EN_AAF, 1); | ||
1913 | status += MXL_ControlWrite(fe, EN_3P, 1); | ||
1914 | status += MXL_ControlWrite(fe, EN_AUX_3P, 1); | ||
1915 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); | ||
1916 | } | ||
1917 | if (state->IF_OUT > 5000000UL) { | ||
1918 | status += MXL_ControlWrite(fe, EN_AAF, 0); | ||
1919 | status += MXL_ControlWrite(fe, EN_3P, 0); | ||
1920 | status += MXL_ControlWrite(fe, EN_AUX_3P, 0); | ||
1921 | status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0); | ||
1922 | } | ||
1923 | } | ||
1924 | |||
1925 | /* Demod Clock Out */ | ||
1926 | if (state->CLOCK_OUT) | ||
1927 | status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 1); | ||
1928 | else | ||
1929 | status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 0); | ||
1930 | |||
1931 | if (state->DIV_OUT == 1) | ||
1932 | status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 1); | ||
1933 | if (state->DIV_OUT == 0) | ||
1934 | status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 0); | ||
1935 | |||
1936 | /* Crystal Control */ | ||
1937 | if (state->CAPSELECT) | ||
1938 | status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 1); | ||
1939 | else | ||
1940 | status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 0); | ||
1941 | |||
1942 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL) | ||
1943 | status += MXL_ControlWrite(fe, IF_SEL_DBL, 1); | ||
1944 | if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL) | ||
1945 | status += MXL_ControlWrite(fe, IF_SEL_DBL, 0); | ||
1946 | |||
1947 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL) | ||
1948 | status += MXL_ControlWrite(fe, RFSYN_R_DIV, 3); | ||
1949 | if (state->Fxtal > 22000000UL && state->Fxtal <= 32000000UL) | ||
1950 | status += MXL_ControlWrite(fe, RFSYN_R_DIV, 0); | ||
1951 | |||
1952 | /* Misc Controls */ | ||
1953 | if (state->Mode == 0 && state->IF_Mode == 1) /* Analog LowIF mode */ | ||
1954 | status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 0); | ||
1955 | else | ||
1956 | status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 1); | ||
1957 | |||
1958 | /* status += MXL_ControlRead(fe, IF_DIVVAL, &IF_DIVVAL_Val); */ | ||
1959 | |||
1960 | /* Set TG_R_DIV */ | ||
1961 | status += MXL_ControlWrite(fe, TG_R_DIV, | ||
1962 | MXL_Ceiling(state->Fxtal, 1000000)); | ||
1963 | |||
1964 | /* Apply Default value to BB_INITSTATE_DLPF_TUNE */ | ||
1965 | |||
1966 | /* RSSI Control */ | ||
1967 | if (state->EN_RSSI) { | ||
1968 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
1969 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
1970 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); | ||
1971 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
1972 | |||
1973 | /* RSSI reference point */ | ||
1974 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2); | ||
1975 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 3); | ||
1976 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); | ||
1977 | |||
1978 | /* TOP point */ | ||
1979 | status += MXL_ControlWrite(fe, RFA_FLR, 0); | ||
1980 | status += MXL_ControlWrite(fe, RFA_CEIL, 12); | ||
1981 | } | ||
1982 | |||
1983 | /* Modulation type bit settings | ||
1984 | * Override the control values preset | ||
1985 | */ | ||
1986 | if (state->Mod_Type == MXL_DVBT) /* DVB-T Mode */ { | ||
1987 | state->AGC_Mode = 1; /* Single AGC Mode */ | ||
1988 | |||
1989 | /* Enable RSSI */ | ||
1990 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
1991 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
1992 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); | ||
1993 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
1994 | |||
1995 | /* RSSI reference point */ | ||
1996 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); | ||
1997 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); | ||
1998 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); | ||
1999 | |||
2000 | /* TOP point */ | ||
2001 | status += MXL_ControlWrite(fe, RFA_FLR, 2); | ||
2002 | status += MXL_ControlWrite(fe, RFA_CEIL, 13); | ||
2003 | if (state->IF_OUT <= 6280000UL) /* Low IF */ | ||
2004 | status += MXL_ControlWrite(fe, BB_IQSWAP, 0); | ||
2005 | else /* High IF */ | ||
2006 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); | ||
2007 | |||
2008 | } | ||
2009 | if (state->Mod_Type == MXL_ATSC) /* ATSC Mode */ { | ||
2010 | state->AGC_Mode = 1; /* Single AGC Mode */ | ||
2011 | |||
2012 | /* Enable RSSI */ | ||
2013 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
2014 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
2015 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); | ||
2016 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
2017 | |||
2018 | /* RSSI reference point */ | ||
2019 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2); | ||
2020 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 4); | ||
2021 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1); | ||
2022 | |||
2023 | /* TOP point */ | ||
2024 | status += MXL_ControlWrite(fe, RFA_FLR, 2); | ||
2025 | status += MXL_ControlWrite(fe, RFA_CEIL, 13); | ||
2026 | status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 1); | ||
2027 | /* Low Zero */ | ||
2028 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5); | ||
2029 | |||
2030 | if (state->IF_OUT <= 6280000UL) /* Low IF */ | ||
2031 | status += MXL_ControlWrite(fe, BB_IQSWAP, 0); | ||
2032 | else /* High IF */ | ||
2033 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); | ||
2034 | } | ||
2035 | if (state->Mod_Type == MXL_QAM) /* QAM Mode */ { | ||
2036 | state->Mode = MXL_DIGITAL_MODE; | ||
2037 | |||
2038 | /* state->AGC_Mode = 1; */ /* Single AGC Mode */ | ||
2039 | |||
2040 | /* Disable RSSI */ /* change here for v2.6.5 */ | ||
2041 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
2042 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
2043 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); | ||
2044 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
2045 | |||
2046 | /* RSSI reference point */ | ||
2047 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); | ||
2048 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); | ||
2049 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); | ||
2050 | /* change here for v2.6.5 */ | ||
2051 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); | ||
2052 | |||
2053 | if (state->IF_OUT <= 6280000UL) /* Low IF */ | ||
2054 | status += MXL_ControlWrite(fe, BB_IQSWAP, 0); | ||
2055 | else /* High IF */ | ||
2056 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); | ||
2057 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2); | ||
2058 | |||
2059 | } | ||
2060 | if (state->Mod_Type == MXL_ANALOG_CABLE) { | ||
2061 | /* Analog Cable Mode */ | ||
2062 | /* state->Mode = MXL_DIGITAL_MODE; */ | ||
2063 | |||
2064 | state->AGC_Mode = 1; /* Single AGC Mode */ | ||
2065 | |||
2066 | /* Disable RSSI */ | ||
2067 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
2068 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
2069 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); | ||
2070 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
2071 | /* change for 2.6.3 */ | ||
2072 | status += MXL_ControlWrite(fe, AGC_IF, 1); | ||
2073 | status += MXL_ControlWrite(fe, AGC_RF, 15); | ||
2074 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); | ||
2075 | } | ||
2076 | |||
2077 | if (state->Mod_Type == MXL_ANALOG_OTA) { | ||
2078 | /* Analog OTA Terrestrial mode add for 2.6.7 */ | ||
2079 | /* state->Mode = MXL_ANALOG_MODE; */ | ||
2080 | |||
2081 | /* Enable RSSI */ | ||
2082 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
2083 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
2084 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); | ||
2085 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
2086 | |||
2087 | /* RSSI reference point */ | ||
2088 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); | ||
2089 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); | ||
2090 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); | ||
2091 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); | ||
2092 | status += MXL_ControlWrite(fe, BB_IQSWAP, 1); | ||
2093 | } | ||
2094 | |||
2095 | /* RSSI disable */ | ||
2096 | if (state->EN_RSSI == 0) { | ||
2097 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
2098 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
2099 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); | ||
2100 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
2101 | } | ||
2102 | |||
2103 | return status; | ||
2104 | } | ||
2105 | |||
2106 | static u16 MXL_IFSynthInit(struct dvb_frontend *fe) | ||
2107 | { | ||
2108 | struct mxl5005s_state *state = fe->tuner_priv; | ||
2109 | u16 status = 0 ; | ||
2110 | u32 Fref = 0 ; | ||
2111 | u32 Kdbl, intModVal ; | ||
2112 | u32 fracModVal ; | ||
2113 | Kdbl = 2 ; | ||
2114 | |||
2115 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL) | ||
2116 | Kdbl = 2 ; | ||
2117 | if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL) | ||
2118 | Kdbl = 1 ; | ||
2119 | |||
2120 | /* IF Synthesizer Control */ | ||
2121 | if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF mode */ { | ||
2122 | if (state->IF_LO == 41000000UL) { | ||
2123 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2124 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2125 | Fref = 328000000UL ; | ||
2126 | } | ||
2127 | if (state->IF_LO == 47000000UL) { | ||
2128 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2129 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2130 | Fref = 376000000UL ; | ||
2131 | } | ||
2132 | if (state->IF_LO == 54000000UL) { | ||
2133 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); | ||
2134 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2135 | Fref = 324000000UL ; | ||
2136 | } | ||
2137 | if (state->IF_LO == 60000000UL) { | ||
2138 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); | ||
2139 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2140 | Fref = 360000000UL ; | ||
2141 | } | ||
2142 | if (state->IF_LO == 39250000UL) { | ||
2143 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2144 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2145 | Fref = 314000000UL ; | ||
2146 | } | ||
2147 | if (state->IF_LO == 39650000UL) { | ||
2148 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2149 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2150 | Fref = 317200000UL ; | ||
2151 | } | ||
2152 | if (state->IF_LO == 40150000UL) { | ||
2153 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2154 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2155 | Fref = 321200000UL ; | ||
2156 | } | ||
2157 | if (state->IF_LO == 40650000UL) { | ||
2158 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2159 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2160 | Fref = 325200000UL ; | ||
2161 | } | ||
2162 | } | ||
2163 | |||
2164 | if (state->Mode || (state->Mode == 0 && state->IF_Mode == 0)) { | ||
2165 | if (state->IF_LO == 57000000UL) { | ||
2166 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); | ||
2167 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2168 | Fref = 342000000UL ; | ||
2169 | } | ||
2170 | if (state->IF_LO == 44000000UL) { | ||
2171 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2172 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2173 | Fref = 352000000UL ; | ||
2174 | } | ||
2175 | if (state->IF_LO == 43750000UL) { | ||
2176 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2177 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2178 | Fref = 350000000UL ; | ||
2179 | } | ||
2180 | if (state->IF_LO == 36650000UL) { | ||
2181 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2182 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2183 | Fref = 366500000UL ; | ||
2184 | } | ||
2185 | if (state->IF_LO == 36150000UL) { | ||
2186 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2187 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2188 | Fref = 361500000UL ; | ||
2189 | } | ||
2190 | if (state->IF_LO == 36000000UL) { | ||
2191 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2192 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2193 | Fref = 360000000UL ; | ||
2194 | } | ||
2195 | if (state->IF_LO == 35250000UL) { | ||
2196 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2197 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2198 | Fref = 352500000UL ; | ||
2199 | } | ||
2200 | if (state->IF_LO == 34750000UL) { | ||
2201 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2202 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2203 | Fref = 347500000UL ; | ||
2204 | } | ||
2205 | if (state->IF_LO == 6280000UL) { | ||
2206 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); | ||
2207 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2208 | Fref = 376800000UL ; | ||
2209 | } | ||
2210 | if (state->IF_LO == 5000000UL) { | ||
2211 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); | ||
2212 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2213 | Fref = 360000000UL ; | ||
2214 | } | ||
2215 | if (state->IF_LO == 4500000UL) { | ||
2216 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); | ||
2217 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2218 | Fref = 360000000UL ; | ||
2219 | } | ||
2220 | if (state->IF_LO == 4570000UL) { | ||
2221 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); | ||
2222 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2223 | Fref = 365600000UL ; | ||
2224 | } | ||
2225 | if (state->IF_LO == 4000000UL) { | ||
2226 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05); | ||
2227 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2228 | Fref = 360000000UL ; | ||
2229 | } | ||
2230 | if (state->IF_LO == 57400000UL) { | ||
2231 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10); | ||
2232 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2233 | Fref = 344400000UL ; | ||
2234 | } | ||
2235 | if (state->IF_LO == 44400000UL) { | ||
2236 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2237 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2238 | Fref = 355200000UL ; | ||
2239 | } | ||
2240 | if (state->IF_LO == 44150000UL) { | ||
2241 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08); | ||
2242 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2243 | Fref = 353200000UL ; | ||
2244 | } | ||
2245 | if (state->IF_LO == 37050000UL) { | ||
2246 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2247 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2248 | Fref = 370500000UL ; | ||
2249 | } | ||
2250 | if (state->IF_LO == 36550000UL) { | ||
2251 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2252 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2253 | Fref = 365500000UL ; | ||
2254 | } | ||
2255 | if (state->IF_LO == 36125000UL) { | ||
2256 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04); | ||
2257 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2258 | Fref = 361250000UL ; | ||
2259 | } | ||
2260 | if (state->IF_LO == 6000000UL) { | ||
2261 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); | ||
2262 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2263 | Fref = 360000000UL ; | ||
2264 | } | ||
2265 | if (state->IF_LO == 5400000UL) { | ||
2266 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); | ||
2267 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2268 | Fref = 324000000UL ; | ||
2269 | } | ||
2270 | if (state->IF_LO == 5380000UL) { | ||
2271 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07); | ||
2272 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C); | ||
2273 | Fref = 322800000UL ; | ||
2274 | } | ||
2275 | if (state->IF_LO == 5200000UL) { | ||
2276 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); | ||
2277 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2278 | Fref = 374400000UL ; | ||
2279 | } | ||
2280 | if (state->IF_LO == 4900000UL) { | ||
2281 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09); | ||
2282 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2283 | Fref = 352800000UL ; | ||
2284 | } | ||
2285 | if (state->IF_LO == 4400000UL) { | ||
2286 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06); | ||
2287 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2288 | Fref = 352000000UL ; | ||
2289 | } | ||
2290 | if (state->IF_LO == 4063000UL) /* add for 2.6.8 */ { | ||
2291 | status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05); | ||
2292 | status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08); | ||
2293 | Fref = 365670000UL ; | ||
2294 | } | ||
2295 | } | ||
2296 | /* CHCAL_INT_MOD_IF */ | ||
2297 | /* CHCAL_FRAC_MOD_IF */ | ||
2298 | intModVal = Fref / (state->Fxtal * Kdbl/2); | ||
2299 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_IF, intModVal); | ||
2300 | |||
2301 | fracModVal = (2<<15)*(Fref/1000 - (state->Fxtal/1000 * Kdbl/2) * | ||
2302 | intModVal); | ||
2303 | |||
2304 | fracModVal = fracModVal / ((state->Fxtal * Kdbl/2)/1000); | ||
2305 | status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_IF, fracModVal); | ||
2306 | |||
2307 | return status ; | ||
2308 | } | ||
2309 | |||
2310 | static u32 MXL_GetXtalInt(u32 Xtal_Freq) | ||
2311 | { | ||
2312 | if ((Xtal_Freq % 1000000) == 0) | ||
2313 | return (Xtal_Freq / 10000); | ||
2314 | else | ||
2315 | return (((Xtal_Freq / 1000000) + 1)*100); | ||
2316 | } | ||
2317 | |||
2318 | static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq) | ||
2319 | { | ||
2320 | struct mxl5005s_state *state = fe->tuner_priv; | ||
2321 | u16 status = 0; | ||
2322 | u32 divider_val, E3, E4, E5, E5A; | ||
2323 | u32 Fmax, Fmin, FmaxBin, FminBin; | ||
2324 | u32 Kdbl_RF = 2; | ||
2325 | u32 tg_divval; | ||
2326 | u32 tg_lo; | ||
2327 | u32 Xtal_Int; | ||
2328 | |||
2329 | u32 Fref_TG; | ||
2330 | u32 Fvco; | ||
2331 | |||
2332 | Xtal_Int = MXL_GetXtalInt(state->Fxtal); | ||
2333 | |||
2334 | state->RF_IN = RF_Freq; | ||
2335 | |||
2336 | MXL_SynthRFTGLO_Calc(fe); | ||
2337 | |||
2338 | if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL) | ||
2339 | Kdbl_RF = 2; | ||
2340 | if (state->Fxtal > 22000000 && state->Fxtal <= 32000000) | ||
2341 | Kdbl_RF = 1; | ||
2342 | |||
2343 | /* Downconverter Controls | ||
2344 | * Look-Up Table Implementation for: | ||
2345 | * DN_POLY | ||
2346 | * DN_RFGAIN | ||
2347 | * DN_CAP_RFLPF | ||
2348 | * DN_EN_VHFUHFBAR | ||
2349 | * DN_GAIN_ADJUST | ||
2350 | * Change the boundary reference from RF_IN to RF_LO | ||
2351 | */ | ||
2352 | if (state->RF_LO < 40000000UL) | ||
2353 | return -1; | ||
2354 | |||
2355 | if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) { | ||
2356 | status += MXL_ControlWrite(fe, DN_POLY, 2); | ||
2357 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); | ||
2358 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 423); | ||
2359 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); | ||
2360 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1); | ||
2361 | } | ||
2362 | if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) { | ||
2363 | status += MXL_ControlWrite(fe, DN_POLY, 3); | ||
2364 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); | ||
2365 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 222); | ||
2366 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); | ||
2367 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1); | ||
2368 | } | ||
2369 | if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) { | ||
2370 | status += MXL_ControlWrite(fe, DN_POLY, 3); | ||
2371 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); | ||
2372 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 147); | ||
2373 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); | ||
2374 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2); | ||
2375 | } | ||
2376 | if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) { | ||
2377 | status += MXL_ControlWrite(fe, DN_POLY, 3); | ||
2378 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); | ||
2379 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 9); | ||
2380 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); | ||
2381 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2); | ||
2382 | } | ||
2383 | if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) { | ||
2384 | status += MXL_ControlWrite(fe, DN_POLY, 3); | ||
2385 | status += MXL_ControlWrite(fe, DN_RFGAIN, 3); | ||
2386 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); | ||
2387 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1); | ||
2388 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); | ||
2389 | } | ||
2390 | if (state->RF_LO > 300000000UL && state->RF_LO <= 650000000UL) { | ||
2391 | status += MXL_ControlWrite(fe, DN_POLY, 3); | ||
2392 | status += MXL_ControlWrite(fe, DN_RFGAIN, 1); | ||
2393 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); | ||
2394 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0); | ||
2395 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); | ||
2396 | } | ||
2397 | if (state->RF_LO > 650000000UL && state->RF_LO <= 900000000UL) { | ||
2398 | status += MXL_ControlWrite(fe, DN_POLY, 3); | ||
2399 | status += MXL_ControlWrite(fe, DN_RFGAIN, 2); | ||
2400 | status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0); | ||
2401 | status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0); | ||
2402 | status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3); | ||
2403 | } | ||
2404 | if (state->RF_LO > 900000000UL) | ||
2405 | return -1; | ||
2406 | |||
2407 | /* DN_IQTNBUF_AMP */ | ||
2408 | /* DN_IQTNGNBFBIAS_BST */ | ||
2409 | if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) { | ||
2410 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2411 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2412 | } | ||
2413 | if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) { | ||
2414 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2415 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2416 | } | ||
2417 | if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) { | ||
2418 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2419 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2420 | } | ||
2421 | if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) { | ||
2422 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2423 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2424 | } | ||
2425 | if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) { | ||
2426 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2427 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2428 | } | ||
2429 | if (state->RF_LO > 300000000UL && state->RF_LO <= 400000000UL) { | ||
2430 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2431 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2432 | } | ||
2433 | if (state->RF_LO > 400000000UL && state->RF_LO <= 450000000UL) { | ||
2434 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2435 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2436 | } | ||
2437 | if (state->RF_LO > 450000000UL && state->RF_LO <= 500000000UL) { | ||
2438 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2439 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2440 | } | ||
2441 | if (state->RF_LO > 500000000UL && state->RF_LO <= 550000000UL) { | ||
2442 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2443 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2444 | } | ||
2445 | if (state->RF_LO > 550000000UL && state->RF_LO <= 600000000UL) { | ||
2446 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2447 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2448 | } | ||
2449 | if (state->RF_LO > 600000000UL && state->RF_LO <= 650000000UL) { | ||
2450 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2451 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2452 | } | ||
2453 | if (state->RF_LO > 650000000UL && state->RF_LO <= 700000000UL) { | ||
2454 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2455 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2456 | } | ||
2457 | if (state->RF_LO > 700000000UL && state->RF_LO <= 750000000UL) { | ||
2458 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2459 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2460 | } | ||
2461 | if (state->RF_LO > 750000000UL && state->RF_LO <= 800000000UL) { | ||
2462 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1); | ||
2463 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0); | ||
2464 | } | ||
2465 | if (state->RF_LO > 800000000UL && state->RF_LO <= 850000000UL) { | ||
2466 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10); | ||
2467 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1); | ||
2468 | } | ||
2469 | if (state->RF_LO > 850000000UL && state->RF_LO <= 900000000UL) { | ||
2470 | status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10); | ||
2471 | status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1); | ||
2472 | } | ||
2473 | |||
2474 | /* | ||
2475 | * Set RF Synth and LO Path Control | ||
2476 | * | ||
2477 | * Look-Up table implementation for: | ||
2478 | * RFSYN_EN_OUTMUX | ||
2479 | * RFSYN_SEL_VCO_OUT | ||
2480 | * RFSYN_SEL_VCO_HI | ||
2481 | * RFSYN_SEL_DIVM | ||
2482 | * RFSYN_RF_DIV_BIAS | ||
2483 | * DN_SEL_FREQ | ||
2484 | * | ||
2485 | * Set divider_val, Fmax, Fmix to use in Equations | ||
2486 | */ | ||
2487 | FminBin = 28000000UL ; | ||
2488 | FmaxBin = 42500000UL ; | ||
2489 | if (state->RF_LO >= 40000000UL && state->RF_LO <= FmaxBin) { | ||
2490 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); | ||
2491 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); | ||
2492 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
2493 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2494 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2495 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); | ||
2496 | divider_val = 64 ; | ||
2497 | Fmax = FmaxBin ; | ||
2498 | Fmin = FminBin ; | ||
2499 | } | ||
2500 | FminBin = 42500000UL ; | ||
2501 | FmaxBin = 56000000UL ; | ||
2502 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2503 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); | ||
2504 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); | ||
2505 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
2506 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2507 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2508 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); | ||
2509 | divider_val = 64 ; | ||
2510 | Fmax = FmaxBin ; | ||
2511 | Fmin = FminBin ; | ||
2512 | } | ||
2513 | FminBin = 56000000UL ; | ||
2514 | FmaxBin = 85000000UL ; | ||
2515 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2516 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
2517 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
2518 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
2519 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2520 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2521 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); | ||
2522 | divider_val = 32 ; | ||
2523 | Fmax = FmaxBin ; | ||
2524 | Fmin = FminBin ; | ||
2525 | } | ||
2526 | FminBin = 85000000UL ; | ||
2527 | FmaxBin = 112000000UL ; | ||
2528 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2529 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
2530 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
2531 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
2532 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2533 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2534 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1); | ||
2535 | divider_val = 32 ; | ||
2536 | Fmax = FmaxBin ; | ||
2537 | Fmin = FminBin ; | ||
2538 | } | ||
2539 | FminBin = 112000000UL ; | ||
2540 | FmaxBin = 170000000UL ; | ||
2541 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2542 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
2543 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
2544 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
2545 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2546 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2547 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2); | ||
2548 | divider_val = 16 ; | ||
2549 | Fmax = FmaxBin ; | ||
2550 | Fmin = FminBin ; | ||
2551 | } | ||
2552 | FminBin = 170000000UL ; | ||
2553 | FmaxBin = 225000000UL ; | ||
2554 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2555 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
2556 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
2557 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
2558 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2559 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2560 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2); | ||
2561 | divider_val = 16 ; | ||
2562 | Fmax = FmaxBin ; | ||
2563 | Fmin = FminBin ; | ||
2564 | } | ||
2565 | FminBin = 225000000UL ; | ||
2566 | FmaxBin = 300000000UL ; | ||
2567 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2568 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
2569 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
2570 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
2571 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2572 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2573 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 4); | ||
2574 | divider_val = 8 ; | ||
2575 | Fmax = 340000000UL ; | ||
2576 | Fmin = FminBin ; | ||
2577 | } | ||
2578 | FminBin = 300000000UL ; | ||
2579 | FmaxBin = 340000000UL ; | ||
2580 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2581 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); | ||
2582 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); | ||
2583 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
2584 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2585 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2586 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
2587 | divider_val = 8 ; | ||
2588 | Fmax = FmaxBin ; | ||
2589 | Fmin = 225000000UL ; | ||
2590 | } | ||
2591 | FminBin = 340000000UL ; | ||
2592 | FmaxBin = 450000000UL ; | ||
2593 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2594 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1); | ||
2595 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0); | ||
2596 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
2597 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
2598 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 2); | ||
2599 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
2600 | divider_val = 8 ; | ||
2601 | Fmax = FmaxBin ; | ||
2602 | Fmin = FminBin ; | ||
2603 | } | ||
2604 | FminBin = 450000000UL ; | ||
2605 | FmaxBin = 680000000UL ; | ||
2606 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2607 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
2608 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
2609 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
2610 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1); | ||
2611 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2612 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
2613 | divider_val = 4 ; | ||
2614 | Fmax = FmaxBin ; | ||
2615 | Fmin = FminBin ; | ||
2616 | } | ||
2617 | FminBin = 680000000UL ; | ||
2618 | FmaxBin = 900000000UL ; | ||
2619 | if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) { | ||
2620 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
2621 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
2622 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
2623 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1); | ||
2624 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
2625 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
2626 | divider_val = 4 ; | ||
2627 | Fmax = FmaxBin ; | ||
2628 | Fmin = FminBin ; | ||
2629 | } | ||
2630 | |||
2631 | /* CHCAL_INT_MOD_RF | ||
2632 | * CHCAL_FRAC_MOD_RF | ||
2633 | * RFSYN_LPF_R | ||
2634 | * CHCAL_EN_INT_RF | ||
2635 | */ | ||
2636 | /* Equation E3 RFSYN_VCO_BIAS */ | ||
2637 | E3 = (((Fmax-state->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ; | ||
2638 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, E3); | ||
2639 | |||
2640 | /* Equation E4 CHCAL_INT_MOD_RF */ | ||
2641 | E4 = (state->RF_LO*divider_val/1000)/(2*state->Fxtal*Kdbl_RF/1000); | ||
2642 | MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, E4); | ||
2643 | |||
2644 | /* Equation E5 CHCAL_FRAC_MOD_RF CHCAL_EN_INT_RF */ | ||
2645 | E5 = ((2<<17)*(state->RF_LO/10000*divider_val - | ||
2646 | (E4*(2*state->Fxtal*Kdbl_RF)/10000))) / | ||
2647 | (2*state->Fxtal*Kdbl_RF/10000); | ||
2648 | |||
2649 | status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5); | ||
2650 | |||
2651 | /* Equation E5A RFSYN_LPF_R */ | ||
2652 | E5A = (((Fmax - state->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ; | ||
2653 | status += MXL_ControlWrite(fe, RFSYN_LPF_R, E5A); | ||
2654 | |||
2655 | /* Euqation E5B CHCAL_EN_INIT_RF */ | ||
2656 | status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0)); | ||
2657 | /*if (E5 == 0) | ||
2658 | * status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, 1); | ||
2659 | *else | ||
2660 | * status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5); | ||
2661 | */ | ||
2662 | |||
2663 | /* | ||
2664 | * Set TG Synth | ||
2665 | * | ||
2666 | * Look-Up table implementation for: | ||
2667 | * TG_LO_DIVVAL | ||
2668 | * TG_LO_SELVAL | ||
2669 | * | ||
2670 | * Set divider_val, Fmax, Fmix to use in Equations | ||
2671 | */ | ||
2672 | if (state->TG_LO < 33000000UL) | ||
2673 | return -1; | ||
2674 | |||
2675 | FminBin = 33000000UL ; | ||
2676 | FmaxBin = 50000000UL ; | ||
2677 | if (state->TG_LO >= FminBin && state->TG_LO <= FmaxBin) { | ||
2678 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x6); | ||
2679 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0); | ||
2680 | divider_val = 36 ; | ||
2681 | Fmax = FmaxBin ; | ||
2682 | Fmin = FminBin ; | ||
2683 | } | ||
2684 | FminBin = 50000000UL ; | ||
2685 | FmaxBin = 67000000UL ; | ||
2686 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2687 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x1); | ||
2688 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0); | ||
2689 | divider_val = 24 ; | ||
2690 | Fmax = FmaxBin ; | ||
2691 | Fmin = FminBin ; | ||
2692 | } | ||
2693 | FminBin = 67000000UL ; | ||
2694 | FmaxBin = 100000000UL ; | ||
2695 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2696 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0xC); | ||
2697 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); | ||
2698 | divider_val = 18 ; | ||
2699 | Fmax = FmaxBin ; | ||
2700 | Fmin = FminBin ; | ||
2701 | } | ||
2702 | FminBin = 100000000UL ; | ||
2703 | FmaxBin = 150000000UL ; | ||
2704 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2705 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); | ||
2706 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); | ||
2707 | divider_val = 12 ; | ||
2708 | Fmax = FmaxBin ; | ||
2709 | Fmin = FminBin ; | ||
2710 | } | ||
2711 | FminBin = 150000000UL ; | ||
2712 | FmaxBin = 200000000UL ; | ||
2713 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2714 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); | ||
2715 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2); | ||
2716 | divider_val = 8 ; | ||
2717 | Fmax = FmaxBin ; | ||
2718 | Fmin = FminBin ; | ||
2719 | } | ||
2720 | FminBin = 200000000UL ; | ||
2721 | FmaxBin = 300000000UL ; | ||
2722 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2723 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); | ||
2724 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3); | ||
2725 | divider_val = 6 ; | ||
2726 | Fmax = FmaxBin ; | ||
2727 | Fmin = FminBin ; | ||
2728 | } | ||
2729 | FminBin = 300000000UL ; | ||
2730 | FmaxBin = 400000000UL ; | ||
2731 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2732 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); | ||
2733 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3); | ||
2734 | divider_val = 4 ; | ||
2735 | Fmax = FmaxBin ; | ||
2736 | Fmin = FminBin ; | ||
2737 | } | ||
2738 | FminBin = 400000000UL ; | ||
2739 | FmaxBin = 600000000UL ; | ||
2740 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2741 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8); | ||
2742 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7); | ||
2743 | divider_val = 3 ; | ||
2744 | Fmax = FmaxBin ; | ||
2745 | Fmin = FminBin ; | ||
2746 | } | ||
2747 | FminBin = 600000000UL ; | ||
2748 | FmaxBin = 900000000UL ; | ||
2749 | if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) { | ||
2750 | status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0); | ||
2751 | status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7); | ||
2752 | divider_val = 2 ; | ||
2753 | Fmax = FmaxBin ; | ||
2754 | Fmin = FminBin ; | ||
2755 | } | ||
2756 | |||
2757 | /* TG_DIV_VAL */ | ||
2758 | tg_divval = (state->TG_LO*divider_val/100000) * | ||
2759 | (MXL_Ceiling(state->Fxtal, 1000000) * 100) / | ||
2760 | (state->Fxtal/1000); | ||
2761 | |||
2762 | status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval); | ||
2763 | |||
2764 | if (state->TG_LO > 600000000UL) | ||
2765 | status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval + 1); | ||
2766 | |||
2767 | Fmax = 1800000000UL ; | ||
2768 | Fmin = 1200000000UL ; | ||
2769 | |||
2770 | /* prevent overflow of 32 bit unsigned integer, use | ||
2771 | * following equation. Edit for v2.6.4 | ||
2772 | */ | ||
2773 | /* Fref_TF = Fref_TG * 1000 */ | ||
2774 | Fref_TG = (state->Fxtal/1000) / MXL_Ceiling(state->Fxtal, 1000000); | ||
2775 | |||
2776 | /* Fvco = Fvco/10 */ | ||
2777 | Fvco = (state->TG_LO/10000) * divider_val * Fref_TG; | ||
2778 | |||
2779 | tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8; | ||
2780 | |||
2781 | /* below equation is same as above but much harder to debug. | ||
2782 | * tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) - | ||
2783 | * ((state->TG_LO/10000)*divider_val * | ||
2784 | * (state->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 * | ||
2785 | * Xtal_Int/100) + 8; | ||
2786 | */ | ||
2787 | |||
2788 | status += MXL_ControlWrite(fe, TG_VCO_BIAS , tg_lo); | ||
2789 | |||
2790 | /* add for 2.6.5 Special setting for QAM */ | ||
2791 | if (state->Mod_Type == MXL_QAM) { | ||
2792 | if (state->RF_IN < 680000000) | ||
2793 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); | ||
2794 | else | ||
2795 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2); | ||
2796 | } | ||
2797 | |||
2798 | /* Off Chip Tracking Filter Control */ | ||
2799 | if (state->TF_Type == MXL_TF_OFF) { | ||
2800 | /* Tracking Filter Off State; turn off all the banks */ | ||
2801 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2802 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
2803 | status += MXL_SetGPIO(fe, 3, 1); /* Bank1 Off */ | ||
2804 | status += MXL_SetGPIO(fe, 1, 1); /* Bank2 Off */ | ||
2805 | status += MXL_SetGPIO(fe, 4, 1); /* Bank3 Off */ | ||
2806 | } | ||
2807 | |||
2808 | if (state->TF_Type == MXL_TF_C) /* Tracking Filter type C */ { | ||
2809 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
2810 | status += MXL_ControlWrite(fe, DAC_DIN_A, 0); | ||
2811 | |||
2812 | if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) { | ||
2813 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2814 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
2815 | status += MXL_SetGPIO(fe, 3, 0); | ||
2816 | status += MXL_SetGPIO(fe, 1, 1); | ||
2817 | status += MXL_SetGPIO(fe, 4, 1); | ||
2818 | } | ||
2819 | if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) { | ||
2820 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2821 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
2822 | status += MXL_SetGPIO(fe, 3, 1); | ||
2823 | status += MXL_SetGPIO(fe, 1, 0); | ||
2824 | status += MXL_SetGPIO(fe, 4, 1); | ||
2825 | } | ||
2826 | if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) { | ||
2827 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2828 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
2829 | status += MXL_SetGPIO(fe, 3, 1); | ||
2830 | status += MXL_SetGPIO(fe, 1, 0); | ||
2831 | status += MXL_SetGPIO(fe, 4, 0); | ||
2832 | } | ||
2833 | if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) { | ||
2834 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2835 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
2836 | status += MXL_SetGPIO(fe, 3, 1); | ||
2837 | status += MXL_SetGPIO(fe, 1, 1); | ||
2838 | status += MXL_SetGPIO(fe, 4, 0); | ||
2839 | } | ||
2840 | if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) { | ||
2841 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2842 | status += MXL_ControlWrite(fe, DAC_DIN_B, 29); | ||
2843 | status += MXL_SetGPIO(fe, 3, 1); | ||
2844 | status += MXL_SetGPIO(fe, 1, 1); | ||
2845 | status += MXL_SetGPIO(fe, 4, 0); | ||
2846 | } | ||
2847 | if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) { | ||
2848 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2849 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
2850 | status += MXL_SetGPIO(fe, 3, 1); | ||
2851 | status += MXL_SetGPIO(fe, 1, 1); | ||
2852 | status += MXL_SetGPIO(fe, 4, 0); | ||
2853 | } | ||
2854 | if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) { | ||
2855 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2856 | status += MXL_ControlWrite(fe, DAC_DIN_B, 16); | ||
2857 | status += MXL_SetGPIO(fe, 3, 1); | ||
2858 | status += MXL_SetGPIO(fe, 1, 1); | ||
2859 | status += MXL_SetGPIO(fe, 4, 1); | ||
2860 | } | ||
2861 | if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) { | ||
2862 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2863 | status += MXL_ControlWrite(fe, DAC_DIN_B, 7); | ||
2864 | status += MXL_SetGPIO(fe, 3, 1); | ||
2865 | status += MXL_SetGPIO(fe, 1, 1); | ||
2866 | status += MXL_SetGPIO(fe, 4, 1); | ||
2867 | } | ||
2868 | if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) { | ||
2869 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2870 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
2871 | status += MXL_SetGPIO(fe, 3, 1); | ||
2872 | status += MXL_SetGPIO(fe, 1, 1); | ||
2873 | status += MXL_SetGPIO(fe, 4, 1); | ||
2874 | } | ||
2875 | } | ||
2876 | |||
2877 | if (state->TF_Type == MXL_TF_C_H) { | ||
2878 | |||
2879 | /* Tracking Filter type C-H for Hauppauge only */ | ||
2880 | status += MXL_ControlWrite(fe, DAC_DIN_A, 0); | ||
2881 | |||
2882 | if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) { | ||
2883 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2884 | status += MXL_SetGPIO(fe, 4, 0); | ||
2885 | status += MXL_SetGPIO(fe, 3, 1); | ||
2886 | status += MXL_SetGPIO(fe, 1, 1); | ||
2887 | } | ||
2888 | if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) { | ||
2889 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2890 | status += MXL_SetGPIO(fe, 4, 1); | ||
2891 | status += MXL_SetGPIO(fe, 3, 0); | ||
2892 | status += MXL_SetGPIO(fe, 1, 1); | ||
2893 | } | ||
2894 | if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) { | ||
2895 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2896 | status += MXL_SetGPIO(fe, 4, 1); | ||
2897 | status += MXL_SetGPIO(fe, 3, 0); | ||
2898 | status += MXL_SetGPIO(fe, 1, 0); | ||
2899 | } | ||
2900 | if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) { | ||
2901 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2902 | status += MXL_SetGPIO(fe, 4, 1); | ||
2903 | status += MXL_SetGPIO(fe, 3, 1); | ||
2904 | status += MXL_SetGPIO(fe, 1, 0); | ||
2905 | } | ||
2906 | if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) { | ||
2907 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2908 | status += MXL_SetGPIO(fe, 4, 1); | ||
2909 | status += MXL_SetGPIO(fe, 3, 1); | ||
2910 | status += MXL_SetGPIO(fe, 1, 0); | ||
2911 | } | ||
2912 | if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) { | ||
2913 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2914 | status += MXL_SetGPIO(fe, 4, 1); | ||
2915 | status += MXL_SetGPIO(fe, 3, 1); | ||
2916 | status += MXL_SetGPIO(fe, 1, 0); | ||
2917 | } | ||
2918 | if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) { | ||
2919 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2920 | status += MXL_SetGPIO(fe, 4, 1); | ||
2921 | status += MXL_SetGPIO(fe, 3, 1); | ||
2922 | status += MXL_SetGPIO(fe, 1, 1); | ||
2923 | } | ||
2924 | if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) { | ||
2925 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2926 | status += MXL_SetGPIO(fe, 4, 1); | ||
2927 | status += MXL_SetGPIO(fe, 3, 1); | ||
2928 | status += MXL_SetGPIO(fe, 1, 1); | ||
2929 | } | ||
2930 | if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) { | ||
2931 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
2932 | status += MXL_SetGPIO(fe, 4, 1); | ||
2933 | status += MXL_SetGPIO(fe, 3, 1); | ||
2934 | status += MXL_SetGPIO(fe, 1, 1); | ||
2935 | } | ||
2936 | } | ||
2937 | |||
2938 | if (state->TF_Type == MXL_TF_D) { /* Tracking Filter type D */ | ||
2939 | |||
2940 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
2941 | |||
2942 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { | ||
2943 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
2944 | status += MXL_SetGPIO(fe, 4, 0); | ||
2945 | status += MXL_SetGPIO(fe, 1, 1); | ||
2946 | status += MXL_SetGPIO(fe, 3, 1); | ||
2947 | } | ||
2948 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { | ||
2949 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
2950 | status += MXL_SetGPIO(fe, 4, 0); | ||
2951 | status += MXL_SetGPIO(fe, 1, 0); | ||
2952 | status += MXL_SetGPIO(fe, 3, 1); | ||
2953 | } | ||
2954 | if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) { | ||
2955 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
2956 | status += MXL_SetGPIO(fe, 4, 1); | ||
2957 | status += MXL_SetGPIO(fe, 1, 0); | ||
2958 | status += MXL_SetGPIO(fe, 3, 1); | ||
2959 | } | ||
2960 | if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) { | ||
2961 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
2962 | status += MXL_SetGPIO(fe, 4, 1); | ||
2963 | status += MXL_SetGPIO(fe, 1, 0); | ||
2964 | status += MXL_SetGPIO(fe, 3, 0); | ||
2965 | } | ||
2966 | if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) { | ||
2967 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
2968 | status += MXL_SetGPIO(fe, 4, 1); | ||
2969 | status += MXL_SetGPIO(fe, 1, 1); | ||
2970 | status += MXL_SetGPIO(fe, 3, 0); | ||
2971 | } | ||
2972 | if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { | ||
2973 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
2974 | status += MXL_SetGPIO(fe, 4, 1); | ||
2975 | status += MXL_SetGPIO(fe, 1, 1); | ||
2976 | status += MXL_SetGPIO(fe, 3, 0); | ||
2977 | } | ||
2978 | if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) { | ||
2979 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
2980 | status += MXL_SetGPIO(fe, 4, 1); | ||
2981 | status += MXL_SetGPIO(fe, 1, 1); | ||
2982 | status += MXL_SetGPIO(fe, 3, 1); | ||
2983 | } | ||
2984 | } | ||
2985 | |||
2986 | if (state->TF_Type == MXL_TF_D_L) { | ||
2987 | |||
2988 | /* Tracking Filter type D-L for Lumanate ONLY change 2.6.3 */ | ||
2989 | status += MXL_ControlWrite(fe, DAC_DIN_A, 0); | ||
2990 | |||
2991 | /* if UHF and terrestrial => Turn off Tracking Filter */ | ||
2992 | if (state->RF_IN >= 471000000 && | ||
2993 | (state->RF_IN - 471000000)%6000000 != 0) { | ||
2994 | /* Turn off all the banks */ | ||
2995 | status += MXL_SetGPIO(fe, 3, 1); | ||
2996 | status += MXL_SetGPIO(fe, 1, 1); | ||
2997 | status += MXL_SetGPIO(fe, 4, 1); | ||
2998 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
2999 | status += MXL_ControlWrite(fe, AGC_IF, 10); | ||
3000 | } else { | ||
3001 | /* if VHF or cable => Turn on Tracking Filter */ | ||
3002 | if (state->RF_IN >= 43000000 && | ||
3003 | state->RF_IN < 140000000) { | ||
3004 | |||
3005 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
3006 | status += MXL_SetGPIO(fe, 4, 1); | ||
3007 | status += MXL_SetGPIO(fe, 1, 1); | ||
3008 | status += MXL_SetGPIO(fe, 3, 0); | ||
3009 | } | ||
3010 | if (state->RF_IN >= 140000000 && | ||
3011 | state->RF_IN < 240000000) { | ||
3012 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
3013 | status += MXL_SetGPIO(fe, 4, 1); | ||
3014 | status += MXL_SetGPIO(fe, 1, 0); | ||
3015 | status += MXL_SetGPIO(fe, 3, 0); | ||
3016 | } | ||
3017 | if (state->RF_IN >= 240000000 && | ||
3018 | state->RF_IN < 340000000) { | ||
3019 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
3020 | status += MXL_SetGPIO(fe, 4, 0); | ||
3021 | status += MXL_SetGPIO(fe, 1, 1); | ||
3022 | status += MXL_SetGPIO(fe, 3, 0); | ||
3023 | } | ||
3024 | if (state->RF_IN >= 340000000 && | ||
3025 | state->RF_IN < 430000000) { | ||
3026 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
3027 | status += MXL_SetGPIO(fe, 4, 0); | ||
3028 | status += MXL_SetGPIO(fe, 1, 0); | ||
3029 | status += MXL_SetGPIO(fe, 3, 1); | ||
3030 | } | ||
3031 | if (state->RF_IN >= 430000000 && | ||
3032 | state->RF_IN < 470000000) { | ||
3033 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
3034 | status += MXL_SetGPIO(fe, 4, 1); | ||
3035 | status += MXL_SetGPIO(fe, 1, 0); | ||
3036 | status += MXL_SetGPIO(fe, 3, 1); | ||
3037 | } | ||
3038 | if (state->RF_IN >= 470000000 && | ||
3039 | state->RF_IN < 570000000) { | ||
3040 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
3041 | status += MXL_SetGPIO(fe, 4, 0); | ||
3042 | status += MXL_SetGPIO(fe, 1, 0); | ||
3043 | status += MXL_SetGPIO(fe, 3, 1); | ||
3044 | } | ||
3045 | if (state->RF_IN >= 570000000 && | ||
3046 | state->RF_IN < 620000000) { | ||
3047 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0); | ||
3048 | status += MXL_SetGPIO(fe, 4, 0); | ||
3049 | status += MXL_SetGPIO(fe, 1, 1); | ||
3050 | status += MXL_SetGPIO(fe, 3, 1); | ||
3051 | } | ||
3052 | if (state->RF_IN >= 620000000 && | ||
3053 | state->RF_IN < 760000000) { | ||
3054 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
3055 | status += MXL_SetGPIO(fe, 4, 0); | ||
3056 | status += MXL_SetGPIO(fe, 1, 1); | ||
3057 | status += MXL_SetGPIO(fe, 3, 1); | ||
3058 | } | ||
3059 | if (state->RF_IN >= 760000000 && | ||
3060 | state->RF_IN <= 900000000) { | ||
3061 | status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1); | ||
3062 | status += MXL_SetGPIO(fe, 4, 1); | ||
3063 | status += MXL_SetGPIO(fe, 1, 1); | ||
3064 | status += MXL_SetGPIO(fe, 3, 1); | ||
3065 | } | ||
3066 | } | ||
3067 | } | ||
3068 | |||
3069 | if (state->TF_Type == MXL_TF_E) /* Tracking Filter type E */ { | ||
3070 | |||
3071 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
3072 | |||
3073 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { | ||
3074 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3075 | status += MXL_SetGPIO(fe, 4, 0); | ||
3076 | status += MXL_SetGPIO(fe, 1, 1); | ||
3077 | status += MXL_SetGPIO(fe, 3, 1); | ||
3078 | } | ||
3079 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { | ||
3080 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3081 | status += MXL_SetGPIO(fe, 4, 0); | ||
3082 | status += MXL_SetGPIO(fe, 1, 0); | ||
3083 | status += MXL_SetGPIO(fe, 3, 1); | ||
3084 | } | ||
3085 | if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) { | ||
3086 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3087 | status += MXL_SetGPIO(fe, 4, 1); | ||
3088 | status += MXL_SetGPIO(fe, 1, 0); | ||
3089 | status += MXL_SetGPIO(fe, 3, 1); | ||
3090 | } | ||
3091 | if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) { | ||
3092 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3093 | status += MXL_SetGPIO(fe, 4, 1); | ||
3094 | status += MXL_SetGPIO(fe, 1, 0); | ||
3095 | status += MXL_SetGPIO(fe, 3, 0); | ||
3096 | } | ||
3097 | if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) { | ||
3098 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3099 | status += MXL_SetGPIO(fe, 4, 1); | ||
3100 | status += MXL_SetGPIO(fe, 1, 1); | ||
3101 | status += MXL_SetGPIO(fe, 3, 0); | ||
3102 | } | ||
3103 | if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { | ||
3104 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3105 | status += MXL_SetGPIO(fe, 4, 1); | ||
3106 | status += MXL_SetGPIO(fe, 1, 1); | ||
3107 | status += MXL_SetGPIO(fe, 3, 0); | ||
3108 | } | ||
3109 | if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) { | ||
3110 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3111 | status += MXL_SetGPIO(fe, 4, 1); | ||
3112 | status += MXL_SetGPIO(fe, 1, 1); | ||
3113 | status += MXL_SetGPIO(fe, 3, 1); | ||
3114 | } | ||
3115 | } | ||
3116 | |||
3117 | if (state->TF_Type == MXL_TF_F) { | ||
3118 | |||
3119 | /* Tracking Filter type F */ | ||
3120 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
3121 | |||
3122 | if (state->RF_IN >= 43000000 && state->RF_IN < 160000000) { | ||
3123 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3124 | status += MXL_SetGPIO(fe, 4, 0); | ||
3125 | status += MXL_SetGPIO(fe, 1, 1); | ||
3126 | status += MXL_SetGPIO(fe, 3, 1); | ||
3127 | } | ||
3128 | if (state->RF_IN >= 160000000 && state->RF_IN < 210000000) { | ||
3129 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3130 | status += MXL_SetGPIO(fe, 4, 0); | ||
3131 | status += MXL_SetGPIO(fe, 1, 0); | ||
3132 | status += MXL_SetGPIO(fe, 3, 1); | ||
3133 | } | ||
3134 | if (state->RF_IN >= 210000000 && state->RF_IN < 300000000) { | ||
3135 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3136 | status += MXL_SetGPIO(fe, 4, 1); | ||
3137 | status += MXL_SetGPIO(fe, 1, 0); | ||
3138 | status += MXL_SetGPIO(fe, 3, 1); | ||
3139 | } | ||
3140 | if (state->RF_IN >= 300000000 && state->RF_IN < 390000000) { | ||
3141 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3142 | status += MXL_SetGPIO(fe, 4, 1); | ||
3143 | status += MXL_SetGPIO(fe, 1, 0); | ||
3144 | status += MXL_SetGPIO(fe, 3, 0); | ||
3145 | } | ||
3146 | if (state->RF_IN >= 390000000 && state->RF_IN < 515000000) { | ||
3147 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3148 | status += MXL_SetGPIO(fe, 4, 1); | ||
3149 | status += MXL_SetGPIO(fe, 1, 1); | ||
3150 | status += MXL_SetGPIO(fe, 3, 0); | ||
3151 | } | ||
3152 | if (state->RF_IN >= 515000000 && state->RF_IN < 650000000) { | ||
3153 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3154 | status += MXL_SetGPIO(fe, 4, 1); | ||
3155 | status += MXL_SetGPIO(fe, 1, 1); | ||
3156 | status += MXL_SetGPIO(fe, 3, 0); | ||
3157 | } | ||
3158 | if (state->RF_IN >= 650000000 && state->RF_IN <= 900000000) { | ||
3159 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3160 | status += MXL_SetGPIO(fe, 4, 1); | ||
3161 | status += MXL_SetGPIO(fe, 1, 1); | ||
3162 | status += MXL_SetGPIO(fe, 3, 1); | ||
3163 | } | ||
3164 | } | ||
3165 | |||
3166 | if (state->TF_Type == MXL_TF_E_2) { | ||
3167 | |||
3168 | /* Tracking Filter type E_2 */ | ||
3169 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
3170 | |||
3171 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { | ||
3172 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3173 | status += MXL_SetGPIO(fe, 4, 0); | ||
3174 | status += MXL_SetGPIO(fe, 1, 1); | ||
3175 | status += MXL_SetGPIO(fe, 3, 1); | ||
3176 | } | ||
3177 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { | ||
3178 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3179 | status += MXL_SetGPIO(fe, 4, 0); | ||
3180 | status += MXL_SetGPIO(fe, 1, 0); | ||
3181 | status += MXL_SetGPIO(fe, 3, 1); | ||
3182 | } | ||
3183 | if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) { | ||
3184 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3185 | status += MXL_SetGPIO(fe, 4, 1); | ||
3186 | status += MXL_SetGPIO(fe, 1, 0); | ||
3187 | status += MXL_SetGPIO(fe, 3, 1); | ||
3188 | } | ||
3189 | if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { | ||
3190 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3191 | status += MXL_SetGPIO(fe, 4, 1); | ||
3192 | status += MXL_SetGPIO(fe, 1, 0); | ||
3193 | status += MXL_SetGPIO(fe, 3, 0); | ||
3194 | } | ||
3195 | if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) { | ||
3196 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3197 | status += MXL_SetGPIO(fe, 4, 1); | ||
3198 | status += MXL_SetGPIO(fe, 1, 1); | ||
3199 | status += MXL_SetGPIO(fe, 3, 0); | ||
3200 | } | ||
3201 | if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) { | ||
3202 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3203 | status += MXL_SetGPIO(fe, 4, 1); | ||
3204 | status += MXL_SetGPIO(fe, 1, 1); | ||
3205 | status += MXL_SetGPIO(fe, 3, 0); | ||
3206 | } | ||
3207 | if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) { | ||
3208 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3209 | status += MXL_SetGPIO(fe, 4, 1); | ||
3210 | status += MXL_SetGPIO(fe, 1, 1); | ||
3211 | status += MXL_SetGPIO(fe, 3, 1); | ||
3212 | } | ||
3213 | } | ||
3214 | |||
3215 | if (state->TF_Type == MXL_TF_G) { | ||
3216 | |||
3217 | /* Tracking Filter type G add for v2.6.8 */ | ||
3218 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
3219 | |||
3220 | if (state->RF_IN >= 50000000 && state->RF_IN < 190000000) { | ||
3221 | |||
3222 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3223 | status += MXL_SetGPIO(fe, 4, 0); | ||
3224 | status += MXL_SetGPIO(fe, 1, 1); | ||
3225 | status += MXL_SetGPIO(fe, 3, 1); | ||
3226 | } | ||
3227 | if (state->RF_IN >= 190000000 && state->RF_IN < 280000000) { | ||
3228 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3229 | status += MXL_SetGPIO(fe, 4, 0); | ||
3230 | status += MXL_SetGPIO(fe, 1, 0); | ||
3231 | status += MXL_SetGPIO(fe, 3, 1); | ||
3232 | } | ||
3233 | if (state->RF_IN >= 280000000 && state->RF_IN < 350000000) { | ||
3234 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3235 | status += MXL_SetGPIO(fe, 4, 1); | ||
3236 | status += MXL_SetGPIO(fe, 1, 0); | ||
3237 | status += MXL_SetGPIO(fe, 3, 1); | ||
3238 | } | ||
3239 | if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { | ||
3240 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3241 | status += MXL_SetGPIO(fe, 4, 1); | ||
3242 | status += MXL_SetGPIO(fe, 1, 0); | ||
3243 | status += MXL_SetGPIO(fe, 3, 0); | ||
3244 | } | ||
3245 | if (state->RF_IN >= 400000000 && state->RF_IN < 470000000) { | ||
3246 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3247 | status += MXL_SetGPIO(fe, 4, 1); | ||
3248 | status += MXL_SetGPIO(fe, 1, 0); | ||
3249 | status += MXL_SetGPIO(fe, 3, 1); | ||
3250 | } | ||
3251 | if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) { | ||
3252 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3253 | status += MXL_SetGPIO(fe, 4, 1); | ||
3254 | status += MXL_SetGPIO(fe, 1, 1); | ||
3255 | status += MXL_SetGPIO(fe, 3, 0); | ||
3256 | } | ||
3257 | if (state->RF_IN >= 640000000 && state->RF_IN < 820000000) { | ||
3258 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3259 | status += MXL_SetGPIO(fe, 4, 1); | ||
3260 | status += MXL_SetGPIO(fe, 1, 1); | ||
3261 | status += MXL_SetGPIO(fe, 3, 0); | ||
3262 | } | ||
3263 | if (state->RF_IN >= 820000000 && state->RF_IN <= 900000000) { | ||
3264 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3265 | status += MXL_SetGPIO(fe, 4, 1); | ||
3266 | status += MXL_SetGPIO(fe, 1, 1); | ||
3267 | status += MXL_SetGPIO(fe, 3, 1); | ||
3268 | } | ||
3269 | } | ||
3270 | |||
3271 | if (state->TF_Type == MXL_TF_E_NA) { | ||
3272 | |||
3273 | /* Tracking Filter type E-NA for Empia ONLY change for 2.6.8 */ | ||
3274 | status += MXL_ControlWrite(fe, DAC_DIN_B, 0); | ||
3275 | |||
3276 | /* if UHF and terrestrial=> Turn off Tracking Filter */ | ||
3277 | if (state->RF_IN >= 471000000 && | ||
3278 | (state->RF_IN - 471000000)%6000000 != 0) { | ||
3279 | |||
3280 | /* Turn off all the banks */ | ||
3281 | status += MXL_SetGPIO(fe, 3, 1); | ||
3282 | status += MXL_SetGPIO(fe, 1, 1); | ||
3283 | status += MXL_SetGPIO(fe, 4, 1); | ||
3284 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3285 | |||
3286 | /* 2.6.12 Turn on RSSI */ | ||
3287 | status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1); | ||
3288 | status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1); | ||
3289 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1); | ||
3290 | status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1); | ||
3291 | |||
3292 | /* RSSI reference point */ | ||
3293 | status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5); | ||
3294 | status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3); | ||
3295 | status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2); | ||
3296 | |||
3297 | /* following parameter is from analog OTA mode, | ||
3298 | * can be change to seek better performance */ | ||
3299 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3); | ||
3300 | } else { | ||
3301 | /* if VHF or Cable => Turn on Tracking Filter */ | ||
3302 | |||
3303 | /* 2.6.12 Turn off RSSI */ | ||
3304 | status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0); | ||
3305 | |||
3306 | /* change back from above condition */ | ||
3307 | status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5); | ||
3308 | |||
3309 | |||
3310 | if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) { | ||
3311 | |||
3312 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3313 | status += MXL_SetGPIO(fe, 4, 0); | ||
3314 | status += MXL_SetGPIO(fe, 1, 1); | ||
3315 | status += MXL_SetGPIO(fe, 3, 1); | ||
3316 | } | ||
3317 | if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) { | ||
3318 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3319 | status += MXL_SetGPIO(fe, 4, 0); | ||
3320 | status += MXL_SetGPIO(fe, 1, 0); | ||
3321 | status += MXL_SetGPIO(fe, 3, 1); | ||
3322 | } | ||
3323 | if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) { | ||
3324 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3325 | status += MXL_SetGPIO(fe, 4, 1); | ||
3326 | status += MXL_SetGPIO(fe, 1, 0); | ||
3327 | status += MXL_SetGPIO(fe, 3, 1); | ||
3328 | } | ||
3329 | if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) { | ||
3330 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3331 | status += MXL_SetGPIO(fe, 4, 1); | ||
3332 | status += MXL_SetGPIO(fe, 1, 0); | ||
3333 | status += MXL_SetGPIO(fe, 3, 0); | ||
3334 | } | ||
3335 | if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) { | ||
3336 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0); | ||
3337 | status += MXL_SetGPIO(fe, 4, 1); | ||
3338 | status += MXL_SetGPIO(fe, 1, 1); | ||
3339 | status += MXL_SetGPIO(fe, 3, 0); | ||
3340 | } | ||
3341 | if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) { | ||
3342 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3343 | status += MXL_SetGPIO(fe, 4, 1); | ||
3344 | status += MXL_SetGPIO(fe, 1, 1); | ||
3345 | status += MXL_SetGPIO(fe, 3, 0); | ||
3346 | } | ||
3347 | if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) { | ||
3348 | status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1); | ||
3349 | status += MXL_SetGPIO(fe, 4, 1); | ||
3350 | status += MXL_SetGPIO(fe, 1, 1); | ||
3351 | status += MXL_SetGPIO(fe, 3, 1); | ||
3352 | } | ||
3353 | } | ||
3354 | } | ||
3355 | return status ; | ||
3356 | } | ||
3357 | |||
3358 | static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val) | ||
3359 | { | ||
3360 | u16 status = 0; | ||
3361 | |||
3362 | if (GPIO_Num == 1) | ||
3363 | status += MXL_ControlWrite(fe, GPIO_1B, GPIO_Val ? 0 : 1); | ||
3364 | |||
3365 | /* GPIO2 is not available */ | ||
3366 | |||
3367 | if (GPIO_Num == 3) { | ||
3368 | if (GPIO_Val == 1) { | ||
3369 | status += MXL_ControlWrite(fe, GPIO_3, 0); | ||
3370 | status += MXL_ControlWrite(fe, GPIO_3B, 0); | ||
3371 | } | ||
3372 | if (GPIO_Val == 0) { | ||
3373 | status += MXL_ControlWrite(fe, GPIO_3, 1); | ||
3374 | status += MXL_ControlWrite(fe, GPIO_3B, 1); | ||
3375 | } | ||
3376 | if (GPIO_Val == 3) { /* tri-state */ | ||
3377 | status += MXL_ControlWrite(fe, GPIO_3, 0); | ||
3378 | status += MXL_ControlWrite(fe, GPIO_3B, 1); | ||
3379 | } | ||
3380 | } | ||
3381 | if (GPIO_Num == 4) { | ||
3382 | if (GPIO_Val == 1) { | ||
3383 | status += MXL_ControlWrite(fe, GPIO_4, 0); | ||
3384 | status += MXL_ControlWrite(fe, GPIO_4B, 0); | ||
3385 | } | ||
3386 | if (GPIO_Val == 0) { | ||
3387 | status += MXL_ControlWrite(fe, GPIO_4, 1); | ||
3388 | status += MXL_ControlWrite(fe, GPIO_4B, 1); | ||
3389 | } | ||
3390 | if (GPIO_Val == 3) { /* tri-state */ | ||
3391 | status += MXL_ControlWrite(fe, GPIO_4, 0); | ||
3392 | status += MXL_ControlWrite(fe, GPIO_4B, 1); | ||
3393 | } | ||
3394 | } | ||
3395 | |||
3396 | return status; | ||
3397 | } | ||
3398 | |||
3399 | static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value) | ||
3400 | { | ||
3401 | u16 status = 0; | ||
3402 | |||
3403 | /* Will write ALL Matching Control Name */ | ||
3404 | /* Write Matching INIT Control */ | ||
3405 | status += MXL_ControlWrite_Group(fe, ControlNum, value, 1); | ||
3406 | /* Write Matching CH Control */ | ||
3407 | status += MXL_ControlWrite_Group(fe, ControlNum, value, 2); | ||
3408 | #ifdef _MXL_INTERNAL | ||
3409 | /* Write Matching MXL Control */ | ||
3410 | status += MXL_ControlWrite_Group(fe, ControlNum, value, 3); | ||
3411 | #endif | ||
3412 | return status; | ||
3413 | } | ||
3414 | |||
3415 | static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum, | ||
3416 | u32 value, u16 controlGroup) | ||
3417 | { | ||
3418 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3419 | u16 i, j, k; | ||
3420 | u32 highLimit; | ||
3421 | u32 ctrlVal; | ||
3422 | |||
3423 | if (controlGroup == 1) /* Initial Control */ { | ||
3424 | |||
3425 | for (i = 0; i < state->Init_Ctrl_Num; i++) { | ||
3426 | |||
3427 | if (controlNum == state->Init_Ctrl[i].Ctrl_Num) { | ||
3428 | |||
3429 | highLimit = 1 << state->Init_Ctrl[i].size; | ||
3430 | if (value < highLimit) { | ||
3431 | for (j = 0; j < state->Init_Ctrl[i].size; j++) { | ||
3432 | state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); | ||
3433 | MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]), | ||
3434 | (u8)(state->Init_Ctrl[i].bit[j]), | ||
3435 | (u8)((value>>j) & 0x01)); | ||
3436 | } | ||
3437 | ctrlVal = 0; | ||
3438 | for (k = 0; k < state->Init_Ctrl[i].size; k++) | ||
3439 | ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k); | ||
3440 | } else | ||
3441 | return -1; | ||
3442 | } | ||
3443 | } | ||
3444 | } | ||
3445 | if (controlGroup == 2) /* Chan change Control */ { | ||
3446 | |||
3447 | for (i = 0; i < state->CH_Ctrl_Num; i++) { | ||
3448 | |||
3449 | if (controlNum == state->CH_Ctrl[i].Ctrl_Num) { | ||
3450 | |||
3451 | highLimit = 1 << state->CH_Ctrl[i].size; | ||
3452 | if (value < highLimit) { | ||
3453 | for (j = 0; j < state->CH_Ctrl[i].size; j++) { | ||
3454 | state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); | ||
3455 | MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]), | ||
3456 | (u8)(state->CH_Ctrl[i].bit[j]), | ||
3457 | (u8)((value>>j) & 0x01)); | ||
3458 | } | ||
3459 | ctrlVal = 0; | ||
3460 | for (k = 0; k < state->CH_Ctrl[i].size; k++) | ||
3461 | ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k); | ||
3462 | } else | ||
3463 | return -1; | ||
3464 | } | ||
3465 | } | ||
3466 | } | ||
3467 | #ifdef _MXL_INTERNAL | ||
3468 | if (controlGroup == 3) /* Maxlinear Control */ { | ||
3469 | |||
3470 | for (i = 0; i < state->MXL_Ctrl_Num; i++) { | ||
3471 | |||
3472 | if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) { | ||
3473 | |||
3474 | highLimit = (1 << state->MXL_Ctrl[i].size); | ||
3475 | if (value < highLimit) { | ||
3476 | for (j = 0; j < state->MXL_Ctrl[i].size; j++) { | ||
3477 | state->MXL_Ctrl[i].val[j] = (u8)((value >> j) & 0x01); | ||
3478 | MXL_RegWriteBit(fe, (u8)(state->MXL_Ctrl[i].addr[j]), | ||
3479 | (u8)(state->MXL_Ctrl[i].bit[j]), | ||
3480 | (u8)((value>>j) & 0x01)); | ||
3481 | } | ||
3482 | ctrlVal = 0; | ||
3483 | for (k = 0; k < state->MXL_Ctrl[i].size; k++) | ||
3484 | ctrlVal += state->MXL_Ctrl[i].val[k] * (1 << k); | ||
3485 | } else | ||
3486 | return -1; | ||
3487 | } | ||
3488 | } | ||
3489 | } | ||
3490 | #endif | ||
3491 | return 0 ; /* successful return */ | ||
3492 | } | ||
3493 | |||
3494 | static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal) | ||
3495 | { | ||
3496 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3497 | int i ; | ||
3498 | |||
3499 | for (i = 0; i < 104; i++) { | ||
3500 | if (RegNum == state->TunerRegs[i].Reg_Num) { | ||
3501 | *RegVal = (u8)(state->TunerRegs[i].Reg_Val); | ||
3502 | return 0; | ||
3503 | } | ||
3504 | } | ||
3505 | |||
3506 | return 1; | ||
3507 | } | ||
3508 | |||
3509 | static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value) | ||
3510 | { | ||
3511 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3512 | u32 ctrlVal ; | ||
3513 | u16 i, k ; | ||
3514 | |||
3515 | for (i = 0; i < state->Init_Ctrl_Num ; i++) { | ||
3516 | |||
3517 | if (controlNum == state->Init_Ctrl[i].Ctrl_Num) { | ||
3518 | |||
3519 | ctrlVal = 0; | ||
3520 | for (k = 0; k < state->Init_Ctrl[i].size; k++) | ||
3521 | ctrlVal += state->Init_Ctrl[i].val[k] * (1<<k); | ||
3522 | *value = ctrlVal; | ||
3523 | return 0; | ||
3524 | } | ||
3525 | } | ||
3526 | |||
3527 | for (i = 0; i < state->CH_Ctrl_Num ; i++) { | ||
3528 | |||
3529 | if (controlNum == state->CH_Ctrl[i].Ctrl_Num) { | ||
3530 | |||
3531 | ctrlVal = 0; | ||
3532 | for (k = 0; k < state->CH_Ctrl[i].size; k++) | ||
3533 | ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k); | ||
3534 | *value = ctrlVal; | ||
3535 | return 0; | ||
3536 | |||
3537 | } | ||
3538 | } | ||
3539 | |||
3540 | #ifdef _MXL_INTERNAL | ||
3541 | for (i = 0; i < state->MXL_Ctrl_Num ; i++) { | ||
3542 | |||
3543 | if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) { | ||
3544 | |||
3545 | ctrlVal = 0; | ||
3546 | for (k = 0; k < state->MXL_Ctrl[i].size; k++) | ||
3547 | ctrlVal += state->MXL_Ctrl[i].val[k] * (1<<k); | ||
3548 | *value = ctrlVal; | ||
3549 | return 0; | ||
3550 | |||
3551 | } | ||
3552 | } | ||
3553 | #endif | ||
3554 | return 1; | ||
3555 | } | ||
3556 | |||
3557 | static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit, | ||
3558 | u8 bitVal) | ||
3559 | { | ||
3560 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3561 | int i ; | ||
3562 | |||
3563 | const u8 AND_MAP[8] = { | ||
3564 | 0xFE, 0xFD, 0xFB, 0xF7, | ||
3565 | 0xEF, 0xDF, 0xBF, 0x7F } ; | ||
3566 | |||
3567 | const u8 OR_MAP[8] = { | ||
3568 | 0x01, 0x02, 0x04, 0x08, | ||
3569 | 0x10, 0x20, 0x40, 0x80 } ; | ||
3570 | |||
3571 | for (i = 0; i < state->TunerRegs_Num; i++) { | ||
3572 | if (state->TunerRegs[i].Reg_Num == address) { | ||
3573 | if (bitVal) | ||
3574 | state->TunerRegs[i].Reg_Val |= OR_MAP[bit]; | ||
3575 | else | ||
3576 | state->TunerRegs[i].Reg_Val &= AND_MAP[bit]; | ||
3577 | break ; | ||
3578 | } | ||
3579 | } | ||
3580 | } | ||
3581 | |||
3582 | static u32 MXL_Ceiling(u32 value, u32 resolution) | ||
3583 | { | ||
3584 | return (value/resolution + (value % resolution > 0 ? 1 : 0)); | ||
3585 | } | ||
3586 | |||
3587 | /* Retrieve the Initialzation Registers */ | ||
3588 | static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum, | ||
3589 | u8 *RegVal, int *count) | ||
3590 | { | ||
3591 | u16 status = 0; | ||
3592 | int i ; | ||
3593 | |||
3594 | u8 RegAddr[] = { | ||
3595 | 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73, | ||
3596 | 76, 77, 91, 134, 135, 137, 147, | ||
3597 | 156, 166, 167, 168, 25 }; | ||
3598 | |||
3599 | *count = sizeof(RegAddr) / sizeof(u8); | ||
3600 | |||
3601 | status += MXL_BlockInit(fe); | ||
3602 | |||
3603 | for (i = 0 ; i < *count; i++) { | ||
3604 | RegNum[i] = RegAddr[i]; | ||
3605 | status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); | ||
3606 | } | ||
3607 | |||
3608 | return status; | ||
3609 | } | ||
3610 | |||
3611 | static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal, | ||
3612 | int *count) | ||
3613 | { | ||
3614 | u16 status = 0; | ||
3615 | int i ; | ||
3616 | |||
3617 | /* add 77, 166, 167, 168 register for 2.6.12 */ | ||
3618 | #ifdef _MXL_PRODUCTION | ||
3619 | u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106, | ||
3620 | 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ; | ||
3621 | #else | ||
3622 | u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106, | ||
3623 | 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ; | ||
3624 | /* | ||
3625 | u8 RegAddr[171]; | ||
3626 | for (i = 0; i <= 170; i++) | ||
3627 | RegAddr[i] = i; | ||
3628 | */ | ||
3629 | #endif | ||
3630 | |||
3631 | *count = sizeof(RegAddr) / sizeof(u8); | ||
3632 | |||
3633 | for (i = 0 ; i < *count; i++) { | ||
3634 | RegNum[i] = RegAddr[i]; | ||
3635 | status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); | ||
3636 | } | ||
3637 | |||
3638 | return status; | ||
3639 | } | ||
3640 | |||
3641 | static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum, | ||
3642 | u8 *RegVal, int *count) | ||
3643 | { | ||
3644 | u16 status = 0; | ||
3645 | int i; | ||
3646 | |||
3647 | u8 RegAddr[] = {43, 136}; | ||
3648 | |||
3649 | *count = sizeof(RegAddr) / sizeof(u8); | ||
3650 | |||
3651 | for (i = 0; i < *count; i++) { | ||
3652 | RegNum[i] = RegAddr[i]; | ||
3653 | status += MXL_RegRead(fe, RegNum[i], &RegVal[i]); | ||
3654 | } | ||
3655 | |||
3656 | return status; | ||
3657 | } | ||
3658 | |||
3659 | static u16 MXL_GetMasterControl(u8 *MasterReg, int state) | ||
3660 | { | ||
3661 | if (state == 1) /* Load_Start */ | ||
3662 | *MasterReg = 0xF3; | ||
3663 | if (state == 2) /* Power_Down */ | ||
3664 | *MasterReg = 0x41; | ||
3665 | if (state == 3) /* Synth_Reset */ | ||
3666 | *MasterReg = 0xB1; | ||
3667 | if (state == 4) /* Seq_Off */ | ||
3668 | *MasterReg = 0xF1; | ||
3669 | |||
3670 | return 0; | ||
3671 | } | ||
3672 | |||
3673 | #ifdef _MXL_PRODUCTION | ||
3674 | static u16 MXL_VCORange_Test(struct dvb_frontend *fe, int VCO_Range) | ||
3675 | { | ||
3676 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3677 | u16 status = 0 ; | ||
3678 | |||
3679 | if (VCO_Range == 1) { | ||
3680 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); | ||
3681 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
3682 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
3683 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); | ||
3684 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
3685 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
3686 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
3687 | if (state->Mode == 0 && state->IF_Mode == 1) { | ||
3688 | /* Analog Low IF Mode */ | ||
3689 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
3690 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); | ||
3691 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); | ||
3692 | status += MXL_ControlWrite(fe, | ||
3693 | CHCAL_FRAC_MOD_RF, 180224); | ||
3694 | } | ||
3695 | if (state->Mode == 0 && state->IF_Mode == 0) { | ||
3696 | /* Analog Zero IF Mode */ | ||
3697 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
3698 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); | ||
3699 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); | ||
3700 | status += MXL_ControlWrite(fe, | ||
3701 | CHCAL_FRAC_MOD_RF, 222822); | ||
3702 | } | ||
3703 | if (state->Mode == 1) /* Digital Mode */ { | ||
3704 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
3705 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); | ||
3706 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56); | ||
3707 | status += MXL_ControlWrite(fe, | ||
3708 | CHCAL_FRAC_MOD_RF, 229376); | ||
3709 | } | ||
3710 | } | ||
3711 | |||
3712 | if (VCO_Range == 2) { | ||
3713 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); | ||
3714 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
3715 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
3716 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); | ||
3717 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
3718 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
3719 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
3720 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
3721 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3722 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41); | ||
3723 | if (state->Mode == 0 && state->IF_Mode == 1) { | ||
3724 | /* Analog Low IF Mode */ | ||
3725 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
3726 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3727 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); | ||
3728 | status += MXL_ControlWrite(fe, | ||
3729 | CHCAL_FRAC_MOD_RF, 206438); | ||
3730 | } | ||
3731 | if (state->Mode == 0 && state->IF_Mode == 0) { | ||
3732 | /* Analog Zero IF Mode */ | ||
3733 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
3734 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3735 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); | ||
3736 | status += MXL_ControlWrite(fe, | ||
3737 | CHCAL_FRAC_MOD_RF, 206438); | ||
3738 | } | ||
3739 | if (state->Mode == 1) /* Digital Mode */ { | ||
3740 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1); | ||
3741 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3742 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41); | ||
3743 | status += MXL_ControlWrite(fe, | ||
3744 | CHCAL_FRAC_MOD_RF, 16384); | ||
3745 | } | ||
3746 | } | ||
3747 | |||
3748 | if (VCO_Range == 3) { | ||
3749 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); | ||
3750 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
3751 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
3752 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); | ||
3753 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
3754 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
3755 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
3756 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3757 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); | ||
3758 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); | ||
3759 | if (state->Mode == 0 && state->IF_Mode == 1) { | ||
3760 | /* Analog Low IF Mode */ | ||
3761 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3762 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); | ||
3763 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44); | ||
3764 | status += MXL_ControlWrite(fe, | ||
3765 | CHCAL_FRAC_MOD_RF, 173670); | ||
3766 | } | ||
3767 | if (state->Mode == 0 && state->IF_Mode == 0) { | ||
3768 | /* Analog Zero IF Mode */ | ||
3769 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3770 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); | ||
3771 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44); | ||
3772 | status += MXL_ControlWrite(fe, | ||
3773 | CHCAL_FRAC_MOD_RF, 173670); | ||
3774 | } | ||
3775 | if (state->Mode == 1) /* Digital Mode */ { | ||
3776 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3777 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8); | ||
3778 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42); | ||
3779 | status += MXL_ControlWrite(fe, | ||
3780 | CHCAL_FRAC_MOD_RF, 245760); | ||
3781 | } | ||
3782 | } | ||
3783 | |||
3784 | if (VCO_Range == 4) { | ||
3785 | status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1); | ||
3786 | status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0); | ||
3787 | status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0); | ||
3788 | status += MXL_ControlWrite(fe, RFSYN_DIVM, 1); | ||
3789 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1); | ||
3790 | status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1); | ||
3791 | status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0); | ||
3792 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3793 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3794 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); | ||
3795 | if (state->Mode == 0 && state->IF_Mode == 1) { | ||
3796 | /* Analog Low IF Mode */ | ||
3797 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3798 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3799 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); | ||
3800 | status += MXL_ControlWrite(fe, | ||
3801 | CHCAL_FRAC_MOD_RF, 206438); | ||
3802 | } | ||
3803 | if (state->Mode == 0 && state->IF_Mode == 0) { | ||
3804 | /* Analog Zero IF Mode */ | ||
3805 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3806 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3807 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); | ||
3808 | status += MXL_ControlWrite(fe, | ||
3809 | CHCAL_FRAC_MOD_RF, 206438); | ||
3810 | } | ||
3811 | if (state->Mode == 1) /* Digital Mode */ { | ||
3812 | status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0); | ||
3813 | status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40); | ||
3814 | status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27); | ||
3815 | status += MXL_ControlWrite(fe, | ||
3816 | CHCAL_FRAC_MOD_RF, 212992); | ||
3817 | } | ||
3818 | } | ||
3819 | |||
3820 | return status; | ||
3821 | } | ||
3822 | |||
3823 | static u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis) | ||
3824 | { | ||
3825 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3826 | u16 status = 0; | ||
3827 | |||
3828 | if (Hystersis == 1) | ||
3829 | status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1); | ||
3830 | |||
3831 | return status; | ||
3832 | } | ||
3833 | #endif | ||
3834 | /* End: Reference driver code found in the Realtek driver that | ||
3835 | * is copyright MaxLinear */ | ||
3836 | |||
3837 | /* ---------------------------------------------------------------- | ||
3838 | * Begin: Everything after here is new code to adapt the | ||
3839 | * proprietary Realtek driver into a Linux API tuner. | ||
3840 | * Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | ||
3841 | */ | ||
3842 | static int mxl5005s_reset(struct dvb_frontend *fe) | ||
3843 | { | ||
3844 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3845 | int ret = 0; | ||
3846 | |||
3847 | u8 buf[2] = { 0xff, 0x00 }; | ||
3848 | struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0, | ||
3849 | .buf = buf, .len = 2 }; | ||
3850 | |||
3851 | dprintk(2, "%s()\n", __func__); | ||
3852 | |||
3853 | if (fe->ops.i2c_gate_ctrl) | ||
3854 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
3855 | |||
3856 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { | ||
3857 | printk(KERN_WARNING "mxl5005s I2C reset failed\n"); | ||
3858 | ret = -EREMOTEIO; | ||
3859 | } | ||
3860 | |||
3861 | if (fe->ops.i2c_gate_ctrl) | ||
3862 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
3863 | |||
3864 | return ret; | ||
3865 | } | ||
3866 | |||
3867 | /* Write a single byte to a single reg, latch the value if required by | ||
3868 | * following the transaction with the latch byte. | ||
3869 | */ | ||
3870 | static int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch) | ||
3871 | { | ||
3872 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3873 | u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE }; | ||
3874 | struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0, | ||
3875 | .buf = buf, .len = 3 }; | ||
3876 | |||
3877 | if (latch == 0) | ||
3878 | msg.len = 2; | ||
3879 | |||
3880 | dprintk(2, "%s(0x%x, 0x%x, 0x%x)\n", __func__, reg, val, msg.addr); | ||
3881 | |||
3882 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { | ||
3883 | printk(KERN_WARNING "mxl5005s I2C write failed\n"); | ||
3884 | return -EREMOTEIO; | ||
3885 | } | ||
3886 | return 0; | ||
3887 | } | ||
3888 | |||
3889 | static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable, | ||
3890 | u8 *datatable, u8 len) | ||
3891 | { | ||
3892 | int ret = 0, i; | ||
3893 | |||
3894 | if (fe->ops.i2c_gate_ctrl) | ||
3895 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
3896 | |||
3897 | for (i = 0 ; i < len-1; i++) { | ||
3898 | ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0); | ||
3899 | if (ret < 0) | ||
3900 | break; | ||
3901 | } | ||
3902 | |||
3903 | ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1); | ||
3904 | |||
3905 | if (fe->ops.i2c_gate_ctrl) | ||
3906 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
3907 | |||
3908 | return ret; | ||
3909 | } | ||
3910 | |||
3911 | static int mxl5005s_init(struct dvb_frontend *fe) | ||
3912 | { | ||
3913 | dprintk(1, "%s()\n", __func__); | ||
3914 | return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ); | ||
3915 | } | ||
3916 | |||
3917 | static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type, | ||
3918 | u32 bandwidth) | ||
3919 | { | ||
3920 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3921 | |||
3922 | u8 AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; | ||
3923 | u8 ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX]; | ||
3924 | int TableLen; | ||
3925 | |||
3926 | dprintk(1, "%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth); | ||
3927 | |||
3928 | mxl5005s_reset(fe); | ||
3929 | |||
3930 | /* Tuner initialization stage 0 */ | ||
3931 | MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET); | ||
3932 | AddrTable[0] = MASTER_CONTROL_ADDR; | ||
3933 | ByteTable[0] |= state->config->AgcMasterByte; | ||
3934 | |||
3935 | mxl5005s_writeregs(fe, AddrTable, ByteTable, 1); | ||
3936 | |||
3937 | mxl5005s_AssignTunerMode(fe, mod_type, bandwidth); | ||
3938 | |||
3939 | /* Tuner initialization stage 1 */ | ||
3940 | MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen); | ||
3941 | |||
3942 | mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen); | ||
3943 | |||
3944 | return 0; | ||
3945 | } | ||
3946 | |||
3947 | static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type, | ||
3948 | u32 bandwidth) | ||
3949 | { | ||
3950 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3951 | struct mxl5005s_config *c = state->config; | ||
3952 | |||
3953 | InitTunerControls(fe); | ||
3954 | |||
3955 | /* Set MxL5005S parameters. */ | ||
3956 | MXL5005_TunerConfig( | ||
3957 | fe, | ||
3958 | c->mod_mode, | ||
3959 | c->if_mode, | ||
3960 | bandwidth, | ||
3961 | c->if_freq, | ||
3962 | c->xtal_freq, | ||
3963 | c->agc_mode, | ||
3964 | c->top, | ||
3965 | c->output_load, | ||
3966 | c->clock_out, | ||
3967 | c->div_out, | ||
3968 | c->cap_select, | ||
3969 | c->rssi_enable, | ||
3970 | mod_type, | ||
3971 | c->tracking_filter); | ||
3972 | |||
3973 | return 0; | ||
3974 | } | ||
3975 | |||
3976 | static int mxl5005s_set_params(struct dvb_frontend *fe, | ||
3977 | struct dvb_frontend_parameters *params) | ||
3978 | { | ||
3979 | struct mxl5005s_state *state = fe->tuner_priv; | ||
3980 | u32 req_mode, req_bw = 0; | ||
3981 | int ret; | ||
3982 | |||
3983 | dprintk(1, "%s()\n", __func__); | ||
3984 | |||
3985 | if (fe->ops.info.type == FE_ATSC) { | ||
3986 | switch (params->u.vsb.modulation) { | ||
3987 | case VSB_8: | ||
3988 | req_mode = MXL_ATSC; break; | ||
3989 | default: | ||
3990 | case QAM_64: | ||
3991 | case QAM_256: | ||
3992 | case QAM_AUTO: | ||
3993 | req_mode = MXL_QAM; break; | ||
3994 | } | ||
3995 | } else | ||
3996 | req_mode = MXL_DVBT; | ||
3997 | |||
3998 | /* Change tuner for new modulation type if reqd */ | ||
3999 | if (req_mode != state->current_mode) { | ||
4000 | switch (req_mode) { | ||
4001 | case VSB_8: | ||
4002 | case QAM_64: | ||
4003 | case QAM_256: | ||
4004 | case QAM_AUTO: | ||
4005 | req_bw = MXL5005S_BANDWIDTH_6MHZ; | ||
4006 | break; | ||
4007 | default: | ||
4008 | /* Assume DVB-T */ | ||
4009 | switch (params->u.ofdm.bandwidth) { | ||
4010 | case BANDWIDTH_6_MHZ: | ||
4011 | req_bw = MXL5005S_BANDWIDTH_6MHZ; | ||
4012 | break; | ||
4013 | case BANDWIDTH_7_MHZ: | ||
4014 | req_bw = MXL5005S_BANDWIDTH_7MHZ; | ||
4015 | break; | ||
4016 | case BANDWIDTH_AUTO: | ||
4017 | case BANDWIDTH_8_MHZ: | ||
4018 | req_bw = MXL5005S_BANDWIDTH_8MHZ; | ||
4019 | break; | ||
4020 | } | ||
4021 | } | ||
4022 | |||
4023 | state->current_mode = req_mode; | ||
4024 | ret = mxl5005s_reconfigure(fe, req_mode, req_bw); | ||
4025 | |||
4026 | } else | ||
4027 | ret = 0; | ||
4028 | |||
4029 | if (ret == 0) { | ||
4030 | dprintk(1, "%s() freq=%d\n", __func__, params->frequency); | ||
4031 | ret = mxl5005s_SetRfFreqHz(fe, params->frequency); | ||
4032 | } | ||
4033 | |||
4034 | return ret; | ||
4035 | } | ||
4036 | |||
4037 | static int mxl5005s_get_frequency(struct dvb_frontend *fe, u32 *frequency) | ||
4038 | { | ||
4039 | struct mxl5005s_state *state = fe->tuner_priv; | ||
4040 | dprintk(1, "%s()\n", __func__); | ||
4041 | |||
4042 | *frequency = state->RF_IN; | ||
4043 | |||
4044 | return 0; | ||
4045 | } | ||
4046 | |||
4047 | static int mxl5005s_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | ||
4048 | { | ||
4049 | struct mxl5005s_state *state = fe->tuner_priv; | ||
4050 | dprintk(1, "%s()\n", __func__); | ||
4051 | |||
4052 | *bandwidth = state->Chan_Bandwidth; | ||
4053 | |||
4054 | return 0; | ||
4055 | } | ||
4056 | |||
4057 | static int mxl5005s_release(struct dvb_frontend *fe) | ||
4058 | { | ||
4059 | dprintk(1, "%s()\n", __func__); | ||
4060 | kfree(fe->tuner_priv); | ||
4061 | fe->tuner_priv = NULL; | ||
4062 | return 0; | ||
4063 | } | ||
4064 | |||
4065 | static const struct dvb_tuner_ops mxl5005s_tuner_ops = { | ||
4066 | .info = { | ||
4067 | .name = "MaxLinear MXL5005S", | ||
4068 | .frequency_min = 48000000, | ||
4069 | .frequency_max = 860000000, | ||
4070 | .frequency_step = 50000, | ||
4071 | }, | ||
4072 | |||
4073 | .release = mxl5005s_release, | ||
4074 | .init = mxl5005s_init, | ||
4075 | |||
4076 | .set_params = mxl5005s_set_params, | ||
4077 | .get_frequency = mxl5005s_get_frequency, | ||
4078 | .get_bandwidth = mxl5005s_get_bandwidth, | ||
4079 | }; | ||
4080 | |||
4081 | struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, | ||
4082 | struct i2c_adapter *i2c, | ||
4083 | struct mxl5005s_config *config) | ||
4084 | { | ||
4085 | struct mxl5005s_state *state = NULL; | ||
4086 | dprintk(1, "%s()\n", __func__); | ||
4087 | |||
4088 | state = kzalloc(sizeof(struct mxl5005s_state), GFP_KERNEL); | ||
4089 | if (state == NULL) | ||
4090 | return NULL; | ||
4091 | |||
4092 | state->frontend = fe; | ||
4093 | state->config = config; | ||
4094 | state->i2c = i2c; | ||
4095 | state->current_mode = MXL_QAM; | ||
4096 | |||
4097 | printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n", | ||
4098 | config->i2c_address); | ||
4099 | |||
4100 | memcpy(&fe->ops.tuner_ops, &mxl5005s_tuner_ops, | ||
4101 | sizeof(struct dvb_tuner_ops)); | ||
4102 | |||
4103 | fe->tuner_priv = state; | ||
4104 | return fe; | ||
4105 | } | ||
4106 | EXPORT_SYMBOL(mxl5005s_attach); | ||
4107 | |||
4108 | MODULE_DESCRIPTION("MaxLinear MXL5005S silicon tuner driver"); | ||
4109 | MODULE_AUTHOR("Steven Toth"); | ||
4110 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/common/tuners/mxl5005s.h b/drivers/media/common/tuners/mxl5005s.h new file mode 100644 index 000000000000..396db150bf0c --- /dev/null +++ b/drivers/media/common/tuners/mxl5005s.h | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | MaxLinear MXL5005S VSB/QAM/DVBT tuner driver | ||
3 | |||
4 | Copyright (C) 2008 MaxLinear | ||
5 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | |||
21 | */ | ||
22 | |||
23 | #ifndef __MXL5005S_H | ||
24 | #define __MXL5005S_H | ||
25 | |||
26 | #include <linux/i2c.h> | ||
27 | #include "dvb_frontend.h" | ||
28 | |||
29 | struct mxl5005s_config { | ||
30 | |||
31 | /* 7 bit i2c address */ | ||
32 | u8 i2c_address; | ||
33 | |||
34 | #define IF_FREQ_4570000HZ 4570000 | ||
35 | #define IF_FREQ_4571429HZ 4571429 | ||
36 | #define IF_FREQ_5380000HZ 5380000 | ||
37 | #define IF_FREQ_36000000HZ 36000000 | ||
38 | #define IF_FREQ_36125000HZ 36125000 | ||
39 | #define IF_FREQ_36166667HZ 36166667 | ||
40 | #define IF_FREQ_44000000HZ 44000000 | ||
41 | u32 if_freq; | ||
42 | |||
43 | #define CRYSTAL_FREQ_4000000HZ 4000000 | ||
44 | #define CRYSTAL_FREQ_16000000HZ 16000000 | ||
45 | #define CRYSTAL_FREQ_25000000HZ 25000000 | ||
46 | #define CRYSTAL_FREQ_28800000HZ 28800000 | ||
47 | u32 xtal_freq; | ||
48 | |||
49 | #define MXL_DUAL_AGC 0 | ||
50 | #define MXL_SINGLE_AGC 1 | ||
51 | u8 agc_mode; | ||
52 | |||
53 | #define MXL_TF_DEFAULT 0 | ||
54 | #define MXL_TF_OFF 1 | ||
55 | #define MXL_TF_C 2 | ||
56 | #define MXL_TF_C_H 3 | ||
57 | #define MXL_TF_D 4 | ||
58 | #define MXL_TF_D_L 5 | ||
59 | #define MXL_TF_E 6 | ||
60 | #define MXL_TF_F 7 | ||
61 | #define MXL_TF_E_2 8 | ||
62 | #define MXL_TF_E_NA 9 | ||
63 | #define MXL_TF_G 10 | ||
64 | u8 tracking_filter; | ||
65 | |||
66 | #define MXL_RSSI_DISABLE 0 | ||
67 | #define MXL_RSSI_ENABLE 1 | ||
68 | u8 rssi_enable; | ||
69 | |||
70 | #define MXL_CAP_SEL_DISABLE 0 | ||
71 | #define MXL_CAP_SEL_ENABLE 1 | ||
72 | u8 cap_select; | ||
73 | |||
74 | #define MXL_DIV_OUT_1 0 | ||
75 | #define MXL_DIV_OUT_4 1 | ||
76 | u8 div_out; | ||
77 | |||
78 | #define MXL_CLOCK_OUT_DISABLE 0 | ||
79 | #define MXL_CLOCK_OUT_ENABLE 1 | ||
80 | u8 clock_out; | ||
81 | |||
82 | #define MXL5005S_IF_OUTPUT_LOAD_200_OHM 200 | ||
83 | #define MXL5005S_IF_OUTPUT_LOAD_300_OHM 300 | ||
84 | u32 output_load; | ||
85 | |||
86 | #define MXL5005S_TOP_5P5 55 | ||
87 | #define MXL5005S_TOP_7P2 72 | ||
88 | #define MXL5005S_TOP_9P2 92 | ||
89 | #define MXL5005S_TOP_11P0 110 | ||
90 | #define MXL5005S_TOP_12P9 129 | ||
91 | #define MXL5005S_TOP_14P7 147 | ||
92 | #define MXL5005S_TOP_16P8 168 | ||
93 | #define MXL5005S_TOP_19P4 194 | ||
94 | #define MXL5005S_TOP_21P2 212 | ||
95 | #define MXL5005S_TOP_23P2 232 | ||
96 | #define MXL5005S_TOP_25P2 252 | ||
97 | #define MXL5005S_TOP_27P1 271 | ||
98 | #define MXL5005S_TOP_29P2 292 | ||
99 | #define MXL5005S_TOP_31P7 317 | ||
100 | #define MXL5005S_TOP_34P9 349 | ||
101 | u32 top; | ||
102 | |||
103 | #define MXL_ANALOG_MODE 0 | ||
104 | #define MXL_DIGITAL_MODE 1 | ||
105 | u8 mod_mode; | ||
106 | |||
107 | #define MXL_ZERO_IF 0 | ||
108 | #define MXL_LOW_IF 1 | ||
109 | u8 if_mode; | ||
110 | |||
111 | /* Stuff I don't know what to do with */ | ||
112 | u8 AgcMasterByte; | ||
113 | }; | ||
114 | |||
115 | #if defined(CONFIG_MEDIA_TUNER_MXL5005S) || \ | ||
116 | (defined(CONFIG_MEDIA_TUNER_MXL5005S_MODULE) && defined(MODULE)) | ||
117 | extern struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, | ||
118 | struct i2c_adapter *i2c, | ||
119 | struct mxl5005s_config *config); | ||
120 | #else | ||
121 | static inline struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, | ||
122 | struct i2c_adapter *i2c, | ||
123 | struct mxl5005s_config *config) | ||
124 | { | ||
125 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
126 | return NULL; | ||
127 | } | ||
128 | #endif /* CONFIG_DVB_TUNER_MXL5005S */ | ||
129 | |||
130 | #endif /* __MXL5005S_H */ | ||
131 | |||
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c index e27a7620a32f..42b5f5d4bfe6 100644 --- a/drivers/media/common/tuners/tda18271-common.c +++ b/drivers/media/common/tuners/tda18271-common.c | |||
@@ -227,9 +227,8 @@ int tda18271_charge_pump_source(struct dvb_frontend *fe, | |||
227 | 227 | ||
228 | regs[r_cp] &= ~0x20; | 228 | regs[r_cp] &= ~0x20; |
229 | regs[r_cp] |= ((force & 1) << 5); | 229 | regs[r_cp] |= ((force & 1) << 5); |
230 | tda18271_write_regs(fe, r_cp, 1); | ||
231 | 230 | ||
232 | return 0; | 231 | return tda18271_write_regs(fe, r_cp, 1); |
233 | } | 232 | } |
234 | 233 | ||
235 | int tda18271_init_regs(struct dvb_frontend *fe) | 234 | int tda18271_init_regs(struct dvb_frontend *fe) |
@@ -487,16 +486,15 @@ int tda18271_set_standby_mode(struct dvb_frontend *fe, | |||
487 | struct tda18271_priv *priv = fe->tuner_priv; | 486 | struct tda18271_priv *priv = fe->tuner_priv; |
488 | unsigned char *regs = priv->tda18271_regs; | 487 | unsigned char *regs = priv->tda18271_regs; |
489 | 488 | ||
490 | tda_dbg("sm = %d, sm_lt = %d, sm_xt = %d\n", sm, sm_lt, sm_xt); | 489 | if (tda18271_debug & DBG_ADV) |
490 | tda_dbg("sm = %d, sm_lt = %d, sm_xt = %d\n", sm, sm_lt, sm_xt); | ||
491 | 491 | ||
492 | regs[R_EP3] &= ~0xe0; /* clear sm, sm_lt, sm_xt */ | 492 | regs[R_EP3] &= ~0xe0; /* clear sm, sm_lt, sm_xt */ |
493 | regs[R_EP3] |= sm ? (1 << 7) : 0 | | 493 | regs[R_EP3] |= sm ? (1 << 7) : 0 | |
494 | sm_lt ? (1 << 6) : 0 | | 494 | sm_lt ? (1 << 6) : 0 | |
495 | sm_xt ? (1 << 5) : 0; | 495 | sm_xt ? (1 << 5) : 0; |
496 | 496 | ||
497 | tda18271_write_regs(fe, R_EP3, 1); | 497 | return tda18271_write_regs(fe, R_EP3, 1); |
498 | |||
499 | return 0; | ||
500 | } | 498 | } |
501 | 499 | ||
502 | /*---------------------------------------------------------------------*/ | 500 | /*---------------------------------------------------------------------*/ |
@@ -510,7 +508,7 @@ int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq) | |||
510 | u32 div; | 508 | u32 div; |
511 | 509 | ||
512 | int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d); | 510 | int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d); |
513 | if (ret < 0) | 511 | if (tda_fail(ret)) |
514 | goto fail; | 512 | goto fail; |
515 | 513 | ||
516 | regs[R_MPD] = (0x77 & pd); | 514 | regs[R_MPD] = (0x77 & pd); |
@@ -542,7 +540,7 @@ int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq) | |||
542 | u32 div; | 540 | u32 div; |
543 | 541 | ||
544 | int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d); | 542 | int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d); |
545 | if (ret < 0) | 543 | if (tda_fail(ret)) |
546 | goto fail; | 544 | goto fail; |
547 | 545 | ||
548 | regs[R_CPD] = pd; | 546 | regs[R_CPD] = pd; |
@@ -566,7 +564,7 @@ int tda18271_calc_bp_filter(struct dvb_frontend *fe, u32 *freq) | |||
566 | u8 val; | 564 | u8 val; |
567 | 565 | ||
568 | int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val); | 566 | int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val); |
569 | if (ret < 0) | 567 | if (tda_fail(ret)) |
570 | goto fail; | 568 | goto fail; |
571 | 569 | ||
572 | regs[R_EP1] &= ~0x07; /* clear bp filter bits */ | 570 | regs[R_EP1] &= ~0x07; /* clear bp filter bits */ |
@@ -583,7 +581,7 @@ int tda18271_calc_km(struct dvb_frontend *fe, u32 *freq) | |||
583 | u8 val; | 581 | u8 val; |
584 | 582 | ||
585 | int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val); | 583 | int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val); |
586 | if (ret < 0) | 584 | if (tda_fail(ret)) |
587 | goto fail; | 585 | goto fail; |
588 | 586 | ||
589 | regs[R_EB13] &= ~0x7c; /* clear k & m bits */ | 587 | regs[R_EB13] &= ~0x7c; /* clear k & m bits */ |
@@ -600,7 +598,7 @@ int tda18271_calc_rf_band(struct dvb_frontend *fe, u32 *freq) | |||
600 | u8 val; | 598 | u8 val; |
601 | 599 | ||
602 | int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val); | 600 | int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val); |
603 | if (ret < 0) | 601 | if (tda_fail(ret)) |
604 | goto fail; | 602 | goto fail; |
605 | 603 | ||
606 | regs[R_EP2] &= ~0xe0; /* clear rf band bits */ | 604 | regs[R_EP2] &= ~0xe0; /* clear rf band bits */ |
@@ -617,7 +615,7 @@ int tda18271_calc_gain_taper(struct dvb_frontend *fe, u32 *freq) | |||
617 | u8 val; | 615 | u8 val; |
618 | 616 | ||
619 | int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val); | 617 | int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val); |
620 | if (ret < 0) | 618 | if (tda_fail(ret)) |
621 | goto fail; | 619 | goto fail; |
622 | 620 | ||
623 | regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ | 621 | regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ |
@@ -634,7 +632,7 @@ int tda18271_calc_ir_measure(struct dvb_frontend *fe, u32 *freq) | |||
634 | u8 val; | 632 | u8 val; |
635 | 633 | ||
636 | int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val); | 634 | int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val); |
637 | if (ret < 0) | 635 | if (tda_fail(ret)) |
638 | goto fail; | 636 | goto fail; |
639 | 637 | ||
640 | regs[R_EP5] &= ~0x07; | 638 | regs[R_EP5] &= ~0x07; |
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c index b262100ae897..89c01fb1f859 100644 --- a/drivers/media/common/tuners/tda18271-fe.c +++ b/drivers/media/common/tuners/tda18271-fe.c | |||
@@ -51,6 +51,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
51 | { | 51 | { |
52 | struct tda18271_priv *priv = fe->tuner_priv; | 52 | struct tda18271_priv *priv = fe->tuner_priv; |
53 | unsigned char *regs = priv->tda18271_regs; | 53 | unsigned char *regs = priv->tda18271_regs; |
54 | int ret; | ||
54 | u32 N; | 55 | u32 N; |
55 | 56 | ||
56 | /* update TV broadcast parameters */ | 57 | /* update TV broadcast parameters */ |
@@ -85,7 +86,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
85 | /* update rf top / if top */ | 86 | /* update rf top / if top */ |
86 | regs[R_EB22] = 0x00; | 87 | regs[R_EB22] = 0x00; |
87 | regs[R_EB22] |= map->rfagc_top; | 88 | regs[R_EB22] |= map->rfagc_top; |
88 | tda18271_write_regs(fe, R_EB22, 1); | 89 | ret = tda18271_write_regs(fe, R_EB22, 1); |
90 | if (tda_fail(ret)) | ||
91 | goto fail; | ||
89 | 92 | ||
90 | /* --------------------------------------------------------------- */ | 93 | /* --------------------------------------------------------------- */ |
91 | 94 | ||
@@ -121,7 +124,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
121 | /* agc1 has priority on agc2 */ | 124 | /* agc1 has priority on agc2 */ |
122 | regs[R_EB1] &= ~0x01; | 125 | regs[R_EB1] &= ~0x01; |
123 | 126 | ||
124 | tda18271_write_regs(fe, R_EB1, 1); | 127 | ret = tda18271_write_regs(fe, R_EB1, 1); |
128 | if (tda_fail(ret)) | ||
129 | goto fail; | ||
125 | 130 | ||
126 | /* --------------------------------------------------------------- */ | 131 | /* --------------------------------------------------------------- */ |
127 | 132 | ||
@@ -141,7 +146,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
141 | break; | 146 | break; |
142 | } | 147 | } |
143 | 148 | ||
144 | tda18271_write_regs(fe, R_TM, 7); | 149 | ret = tda18271_write_regs(fe, R_TM, 7); |
150 | if (tda_fail(ret)) | ||
151 | goto fail; | ||
145 | 152 | ||
146 | /* force charge pump source */ | 153 | /* force charge pump source */ |
147 | charge_pump_source(fe, 1); | 154 | charge_pump_source(fe, 1); |
@@ -158,9 +165,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
158 | regs[R_EP3] &= ~0x04; | 165 | regs[R_EP3] &= ~0x04; |
159 | else | 166 | else |
160 | regs[R_EP3] |= 0x04; | 167 | regs[R_EP3] |= 0x04; |
161 | tda18271_write_regs(fe, R_EP3, 1); | 168 | ret = tda18271_write_regs(fe, R_EP3, 1); |
162 | 169 | fail: | |
163 | return 0; | 170 | return ret; |
164 | } | 171 | } |
165 | 172 | ||
166 | static int tda18271_read_thermometer(struct dvb_frontend *fe) | 173 | static int tda18271_read_thermometer(struct dvb_frontend *fe) |
@@ -213,11 +220,13 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, | |||
213 | struct tda18271_priv *priv = fe->tuner_priv; | 220 | struct tda18271_priv *priv = fe->tuner_priv; |
214 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; | 221 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; |
215 | unsigned char *regs = priv->tda18271_regs; | 222 | unsigned char *regs = priv->tda18271_regs; |
216 | int tm_current, rfcal_comp, approx, i; | 223 | int tm_current, rfcal_comp, approx, i, ret; |
217 | u8 dc_over_dt, rf_tab; | 224 | u8 dc_over_dt, rf_tab; |
218 | 225 | ||
219 | /* power up */ | 226 | /* power up */ |
220 | tda18271_set_standby_mode(fe, 0, 0, 0); | 227 | ret = tda18271_set_standby_mode(fe, 0, 0, 0); |
228 | if (tda_fail(ret)) | ||
229 | goto fail; | ||
221 | 230 | ||
222 | /* read die current temperature */ | 231 | /* read die current temperature */ |
223 | tm_current = tda18271_read_thermometer(fe); | 232 | tm_current = tda18271_read_thermometer(fe); |
@@ -228,8 +237,8 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, | |||
228 | rf_tab = regs[R_EB14]; | 237 | rf_tab = regs[R_EB14]; |
229 | 238 | ||
230 | i = tda18271_lookup_rf_band(fe, &freq, NULL); | 239 | i = tda18271_lookup_rf_band(fe, &freq, NULL); |
231 | if (i < 0) | 240 | if (tda_fail(i)) |
232 | return -EINVAL; | 241 | return i; |
233 | 242 | ||
234 | if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { | 243 | if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { |
235 | approx = map[i].rf_a1 * | 244 | approx = map[i].rf_a1 * |
@@ -250,35 +259,42 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, | |||
250 | rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); | 259 | rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); |
251 | 260 | ||
252 | regs[R_EB14] = approx + rfcal_comp; | 261 | regs[R_EB14] = approx + rfcal_comp; |
253 | tda18271_write_regs(fe, R_EB14, 1); | 262 | ret = tda18271_write_regs(fe, R_EB14, 1); |
254 | 263 | fail: | |
255 | return 0; | 264 | return ret; |
256 | } | 265 | } |
257 | 266 | ||
258 | static int tda18271_por(struct dvb_frontend *fe) | 267 | static int tda18271_por(struct dvb_frontend *fe) |
259 | { | 268 | { |
260 | struct tda18271_priv *priv = fe->tuner_priv; | 269 | struct tda18271_priv *priv = fe->tuner_priv; |
261 | unsigned char *regs = priv->tda18271_regs; | 270 | unsigned char *regs = priv->tda18271_regs; |
271 | int ret; | ||
262 | 272 | ||
263 | /* power up detector 1 */ | 273 | /* power up detector 1 */ |
264 | regs[R_EB12] &= ~0x20; | 274 | regs[R_EB12] &= ~0x20; |
265 | tda18271_write_regs(fe, R_EB12, 1); | 275 | ret = tda18271_write_regs(fe, R_EB12, 1); |
276 | if (tda_fail(ret)) | ||
277 | goto fail; | ||
266 | 278 | ||
267 | regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ | 279 | regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ |
268 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ | 280 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
269 | tda18271_write_regs(fe, R_EB18, 1); | 281 | ret = tda18271_write_regs(fe, R_EB18, 1); |
282 | if (tda_fail(ret)) | ||
283 | goto fail; | ||
270 | 284 | ||
271 | regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ | 285 | regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ |
272 | 286 | ||
273 | /* POR mode */ | 287 | /* POR mode */ |
274 | tda18271_set_standby_mode(fe, 1, 0, 0); | 288 | ret = tda18271_set_standby_mode(fe, 1, 0, 0); |
289 | if (tda_fail(ret)) | ||
290 | goto fail; | ||
275 | 291 | ||
276 | /* disable 1.5 MHz low pass filter */ | 292 | /* disable 1.5 MHz low pass filter */ |
277 | regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ | 293 | regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ |
278 | regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ | 294 | regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ |
279 | tda18271_write_regs(fe, R_EB21, 3); | 295 | ret = tda18271_write_regs(fe, R_EB21, 3); |
280 | 296 | fail: | |
281 | return 0; | 297 | return ret; |
282 | } | 298 | } |
283 | 299 | ||
284 | static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) | 300 | static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) |
@@ -389,7 +405,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
389 | { | 405 | { |
390 | struct tda18271_priv *priv = fe->tuner_priv; | 406 | struct tda18271_priv *priv = fe->tuner_priv; |
391 | unsigned char *regs = priv->tda18271_regs; | 407 | unsigned char *regs = priv->tda18271_regs; |
392 | int sgn, bcal, count, wait; | 408 | int sgn, bcal, count, wait, ret; |
393 | u8 cid_target; | 409 | u8 cid_target; |
394 | u16 count_limit; | 410 | u16 count_limit; |
395 | u32 freq; | 411 | u32 freq; |
@@ -421,7 +437,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
421 | tda18271_write_regs(fe, R_EP2, 1); | 437 | tda18271_write_regs(fe, R_EP2, 1); |
422 | 438 | ||
423 | /* read power detection info, stored in EB10 */ | 439 | /* read power detection info, stored in EB10 */ |
424 | tda18271_read_extended(fe); | 440 | ret = tda18271_read_extended(fe); |
441 | if (tda_fail(ret)) | ||
442 | return ret; | ||
425 | 443 | ||
426 | /* algorithm initialization */ | 444 | /* algorithm initialization */ |
427 | sgn = 1; | 445 | sgn = 1; |
@@ -447,7 +465,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
447 | tda18271_write_regs(fe, R_EP2, 1); | 465 | tda18271_write_regs(fe, R_EP2, 1); |
448 | 466 | ||
449 | /* read power detection info, stored in EB10 */ | 467 | /* read power detection info, stored in EB10 */ |
450 | tda18271_read_extended(fe); | 468 | ret = tda18271_read_extended(fe); |
469 | if (tda_fail(ret)) | ||
470 | return ret; | ||
451 | 471 | ||
452 | count += 200; | 472 | count += 200; |
453 | 473 | ||
@@ -478,6 +498,7 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
478 | { | 498 | { |
479 | struct tda18271_priv *priv = fe->tuner_priv; | 499 | struct tda18271_priv *priv = fe->tuner_priv; |
480 | unsigned char *regs = priv->tda18271_regs; | 500 | unsigned char *regs = priv->tda18271_regs; |
501 | int ret; | ||
481 | 502 | ||
482 | /* set standard to digital */ | 503 | /* set standard to digital */ |
483 | regs[R_EP3] &= ~0x1f; /* clear std bits */ | 504 | regs[R_EP3] &= ~0x1f; /* clear std bits */ |
@@ -489,10 +510,14 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
489 | /* update IF output level & IF notch frequency */ | 510 | /* update IF output level & IF notch frequency */ |
490 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ | 511 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
491 | 512 | ||
492 | tda18271_write_regs(fe, R_EP3, 2); | 513 | ret = tda18271_write_regs(fe, R_EP3, 2); |
514 | if (tda_fail(ret)) | ||
515 | goto fail; | ||
493 | 516 | ||
494 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ | 517 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
495 | tda18271_write_regs(fe, R_EB18, 1); | 518 | ret = tda18271_write_regs(fe, R_EB18, 1); |
519 | if (tda_fail(ret)) | ||
520 | goto fail; | ||
496 | 521 | ||
497 | regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ | 522 | regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ |
498 | 523 | ||
@@ -500,9 +525,9 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
500 | regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ | 525 | regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ |
501 | regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ | 526 | regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ |
502 | 527 | ||
503 | tda18271_write_regs(fe, R_EB21, 3); | 528 | ret = tda18271_write_regs(fe, R_EB21, 3); |
504 | 529 | fail: | |
505 | return 0; | 530 | return ret; |
506 | } | 531 | } |
507 | 532 | ||
508 | static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | 533 | static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) |
@@ -521,7 +546,7 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
521 | 546 | ||
522 | i = tda18271_lookup_rf_band(fe, &freq, NULL); | 547 | i = tda18271_lookup_rf_band(fe, &freq, NULL); |
523 | 548 | ||
524 | if (i < 0) | 549 | if (tda_fail(i)) |
525 | return i; | 550 | return i; |
526 | 551 | ||
527 | rf_default[RF1] = 1000 * map[i].rf1_def; | 552 | rf_default[RF1] = 1000 * map[i].rf1_def; |
@@ -535,6 +560,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
535 | 560 | ||
536 | /* look for optimized calibration frequency */ | 561 | /* look for optimized calibration frequency */ |
537 | bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); | 562 | bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); |
563 | if (tda_fail(bcal)) | ||
564 | return bcal; | ||
538 | 565 | ||
539 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); | 566 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); |
540 | prog_tab[rf] = regs[R_EB14]; | 567 | prog_tab[rf] = regs[R_EB14]; |
@@ -575,22 +602,29 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) | |||
575 | { | 602 | { |
576 | struct tda18271_priv *priv = fe->tuner_priv; | 603 | struct tda18271_priv *priv = fe->tuner_priv; |
577 | unsigned int i; | 604 | unsigned int i; |
605 | int ret; | ||
578 | 606 | ||
579 | tda_info("tda18271: performing RF tracking filter calibration\n"); | 607 | tda_info("tda18271: performing RF tracking filter calibration\n"); |
580 | 608 | ||
581 | /* wait for die temperature stabilization */ | 609 | /* wait for die temperature stabilization */ |
582 | msleep(200); | 610 | msleep(200); |
583 | 611 | ||
584 | tda18271_powerscan_init(fe); | 612 | ret = tda18271_powerscan_init(fe); |
613 | if (tda_fail(ret)) | ||
614 | goto fail; | ||
585 | 615 | ||
586 | /* rf band calibration */ | 616 | /* rf band calibration */ |
587 | for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) | 617 | for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) { |
618 | ret = | ||
588 | tda18271_rf_tracking_filters_init(fe, 1000 * | 619 | tda18271_rf_tracking_filters_init(fe, 1000 * |
589 | priv->rf_cal_state[i].rfmax); | 620 | priv->rf_cal_state[i].rfmax); |
621 | if (tda_fail(ret)) | ||
622 | goto fail; | ||
623 | } | ||
590 | 624 | ||
591 | priv->tm_rfcal = tda18271_read_thermometer(fe); | 625 | priv->tm_rfcal = tda18271_read_thermometer(fe); |
592 | 626 | fail: | |
593 | return 0; | 627 | return ret; |
594 | } | 628 | } |
595 | 629 | ||
596 | /* ------------------------------------------------------------------ */ | 630 | /* ------------------------------------------------------------------ */ |
@@ -599,6 +633,7 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) | |||
599 | { | 633 | { |
600 | struct tda18271_priv *priv = fe->tuner_priv; | 634 | struct tda18271_priv *priv = fe->tuner_priv; |
601 | unsigned char *regs = priv->tda18271_regs; | 635 | unsigned char *regs = priv->tda18271_regs; |
636 | int ret; | ||
602 | 637 | ||
603 | /* test RF_CAL_OK to see if we need init */ | 638 | /* test RF_CAL_OK to see if we need init */ |
604 | if ((regs[R_EP1] & 0x10) == 0) | 639 | if ((regs[R_EP1] & 0x10) == 0) |
@@ -607,15 +642,22 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) | |||
607 | if (priv->cal_initialized) | 642 | if (priv->cal_initialized) |
608 | return 0; | 643 | return 0; |
609 | 644 | ||
610 | tda18271_calc_rf_filter_curve(fe); | 645 | ret = tda18271_calc_rf_filter_curve(fe); |
646 | if (tda_fail(ret)) | ||
647 | goto fail; | ||
611 | 648 | ||
612 | tda18271_por(fe); | 649 | ret = tda18271_por(fe); |
650 | if (tda_fail(ret)) | ||
651 | goto fail; | ||
613 | 652 | ||
614 | tda_info("tda18271: RF tracking filter calibration complete\n"); | 653 | tda_info("tda18271: RF tracking filter calibration complete\n"); |
615 | 654 | ||
616 | priv->cal_initialized = true; | 655 | priv->cal_initialized = true; |
617 | 656 | goto end; | |
618 | return 0; | 657 | fail: |
658 | tda_info("tda18271: RF tracking filter calibration failed!\n"); | ||
659 | end: | ||
660 | return ret; | ||
619 | } | 661 | } |
620 | 662 | ||
621 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, | 663 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, |
@@ -623,6 +665,7 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, | |||
623 | { | 665 | { |
624 | struct tda18271_priv *priv = fe->tuner_priv; | 666 | struct tda18271_priv *priv = fe->tuner_priv; |
625 | unsigned char *regs = priv->tda18271_regs; | 667 | unsigned char *regs = priv->tda18271_regs; |
668 | int ret; | ||
626 | u32 N = 0; | 669 | u32 N = 0; |
627 | 670 | ||
628 | /* calculate bp filter */ | 671 | /* calculate bp filter */ |
@@ -671,7 +714,10 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, | |||
671 | 714 | ||
672 | tda18271_calc_main_pll(fe, N); | 715 | tda18271_calc_main_pll(fe, N); |
673 | 716 | ||
674 | tda18271_write_regs(fe, R_EP3, 11); | 717 | ret = tda18271_write_regs(fe, R_EP3, 11); |
718 | if (tda_fail(ret)) | ||
719 | return ret; | ||
720 | |||
675 | msleep(5); /* RF tracking filter calibration initialization */ | 721 | msleep(5); /* RF tracking filter calibration initialization */ |
676 | 722 | ||
677 | /* search for K,M,CO for RF calibration */ | 723 | /* search for K,M,CO for RF calibration */ |
@@ -719,45 +765,56 @@ static int tda18271_ir_cal_init(struct dvb_frontend *fe) | |||
719 | { | 765 | { |
720 | struct tda18271_priv *priv = fe->tuner_priv; | 766 | struct tda18271_priv *priv = fe->tuner_priv; |
721 | unsigned char *regs = priv->tda18271_regs; | 767 | unsigned char *regs = priv->tda18271_regs; |
768 | int ret; | ||
722 | 769 | ||
723 | tda18271_read_regs(fe); | 770 | ret = tda18271_read_regs(fe); |
771 | if (tda_fail(ret)) | ||
772 | goto fail; | ||
724 | 773 | ||
725 | /* test IR_CAL_OK to see if we need init */ | 774 | /* test IR_CAL_OK to see if we need init */ |
726 | if ((regs[R_EP1] & 0x08) == 0) | 775 | if ((regs[R_EP1] & 0x08) == 0) |
727 | tda18271_init_regs(fe); | 776 | ret = tda18271_init_regs(fe); |
728 | 777 | fail: | |
729 | return 0; | 778 | return ret; |
730 | } | 779 | } |
731 | 780 | ||
732 | static int tda18271_init(struct dvb_frontend *fe) | 781 | static int tda18271_init(struct dvb_frontend *fe) |
733 | { | 782 | { |
734 | struct tda18271_priv *priv = fe->tuner_priv; | 783 | struct tda18271_priv *priv = fe->tuner_priv; |
784 | int ret; | ||
735 | 785 | ||
736 | mutex_lock(&priv->lock); | 786 | mutex_lock(&priv->lock); |
737 | 787 | ||
738 | /* power up */ | 788 | /* power up */ |
739 | tda18271_set_standby_mode(fe, 0, 0, 0); | 789 | ret = tda18271_set_standby_mode(fe, 0, 0, 0); |
790 | if (tda_fail(ret)) | ||
791 | goto fail; | ||
740 | 792 | ||
741 | /* initialization */ | 793 | /* initialization */ |
742 | tda18271_ir_cal_init(fe); | 794 | ret = tda18271_ir_cal_init(fe); |
795 | if (tda_fail(ret)) | ||
796 | goto fail; | ||
743 | 797 | ||
744 | if (priv->id == TDA18271HDC2) | 798 | if (priv->id == TDA18271HDC2) |
745 | tda18271c2_rf_cal_init(fe); | 799 | tda18271c2_rf_cal_init(fe); |
746 | 800 | fail: | |
747 | mutex_unlock(&priv->lock); | 801 | mutex_unlock(&priv->lock); |
748 | 802 | ||
749 | return 0; | 803 | return ret; |
750 | } | 804 | } |
751 | 805 | ||
752 | static int tda18271_tune(struct dvb_frontend *fe, | 806 | static int tda18271_tune(struct dvb_frontend *fe, |
753 | struct tda18271_std_map_item *map, u32 freq, u32 bw) | 807 | struct tda18271_std_map_item *map, u32 freq, u32 bw) |
754 | { | 808 | { |
755 | struct tda18271_priv *priv = fe->tuner_priv; | 809 | struct tda18271_priv *priv = fe->tuner_priv; |
810 | int ret; | ||
756 | 811 | ||
757 | tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", | 812 | tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", |
758 | freq, map->if_freq, bw, map->agc_mode, map->std); | 813 | freq, map->if_freq, bw, map->agc_mode, map->std); |
759 | 814 | ||
760 | tda18271_init(fe); | 815 | ret = tda18271_init(fe); |
816 | if (tda_fail(ret)) | ||
817 | goto fail; | ||
761 | 818 | ||
762 | mutex_lock(&priv->lock); | 819 | mutex_lock(&priv->lock); |
763 | 820 | ||
@@ -769,11 +826,11 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
769 | tda18271c2_rf_tracking_filters_correction(fe, freq); | 826 | tda18271c2_rf_tracking_filters_correction(fe, freq); |
770 | break; | 827 | break; |
771 | } | 828 | } |
772 | tda18271_channel_configuration(fe, map, freq, bw); | 829 | ret = tda18271_channel_configuration(fe, map, freq, bw); |
773 | 830 | ||
774 | mutex_unlock(&priv->lock); | 831 | mutex_unlock(&priv->lock); |
775 | 832 | fail: | |
776 | return 0; | 833 | return ret; |
777 | } | 834 | } |
778 | 835 | ||
779 | /* ------------------------------------------------------------------ */ | 836 | /* ------------------------------------------------------------------ */ |
@@ -837,7 +894,7 @@ static int tda18271_set_params(struct dvb_frontend *fe, | |||
837 | 894 | ||
838 | ret = tda18271_tune(fe, map, freq, bw); | 895 | ret = tda18271_tune(fe, map, freq, bw); |
839 | 896 | ||
840 | if (ret < 0) | 897 | if (tda_fail(ret)) |
841 | goto fail; | 898 | goto fail; |
842 | 899 | ||
843 | priv->frequency = freq; | 900 | priv->frequency = freq; |
@@ -893,7 +950,7 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe, | |||
893 | 950 | ||
894 | ret = tda18271_tune(fe, map, freq, 0); | 951 | ret = tda18271_tune(fe, map, freq, 0); |
895 | 952 | ||
896 | if (ret < 0) | 953 | if (tda_fail(ret)) |
897 | goto fail; | 954 | goto fail; |
898 | 955 | ||
899 | priv->frequency = freq; | 956 | priv->frequency = freq; |
@@ -905,16 +962,17 @@ fail: | |||
905 | static int tda18271_sleep(struct dvb_frontend *fe) | 962 | static int tda18271_sleep(struct dvb_frontend *fe) |
906 | { | 963 | { |
907 | struct tda18271_priv *priv = fe->tuner_priv; | 964 | struct tda18271_priv *priv = fe->tuner_priv; |
965 | int ret; | ||
908 | 966 | ||
909 | mutex_lock(&priv->lock); | 967 | mutex_lock(&priv->lock); |
910 | 968 | ||
911 | /* standby mode w/ slave tuner output | 969 | /* standby mode w/ slave tuner output |
912 | * & loop thru & xtal oscillator on */ | 970 | * & loop thru & xtal oscillator on */ |
913 | tda18271_set_standby_mode(fe, 1, 0, 0); | 971 | ret = tda18271_set_standby_mode(fe, 1, 0, 0); |
914 | 972 | ||
915 | mutex_unlock(&priv->lock); | 973 | mutex_unlock(&priv->lock); |
916 | 974 | ||
917 | return 0; | 975 | return ret; |
918 | } | 976 | } |
919 | 977 | ||
920 | static int tda18271_release(struct dvb_frontend *fe) | 978 | static int tda18271_release(struct dvb_frontend *fe) |
@@ -1095,10 +1153,10 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1095 | if (cfg) | 1153 | if (cfg) |
1096 | priv->small_i2c = cfg->small_i2c; | 1154 | priv->small_i2c = cfg->small_i2c; |
1097 | 1155 | ||
1098 | if (tda18271_get_id(fe) < 0) | 1156 | if (tda_fail(tda18271_get_id(fe))) |
1099 | goto fail; | 1157 | goto fail; |
1100 | 1158 | ||
1101 | if (tda18271_assign_map_layout(fe) < 0) | 1159 | if (tda_fail(tda18271_assign_map_layout(fe))) |
1102 | goto fail; | 1160 | goto fail; |
1103 | 1161 | ||
1104 | mutex_lock(&priv->lock); | 1162 | mutex_lock(&priv->lock); |
diff --git a/drivers/media/common/tuners/tda18271-priv.h b/drivers/media/common/tuners/tda18271-priv.h index 2bc5eb368ea2..81a739365f8c 100644 --- a/drivers/media/common/tuners/tda18271-priv.h +++ b/drivers/media/common/tuners/tda18271-priv.h | |||
@@ -153,6 +153,15 @@ extern int tda18271_debug; | |||
153 | #define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) | 153 | #define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) |
154 | #define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg) | 154 | #define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg) |
155 | 155 | ||
156 | #define tda_fail(ret) \ | ||
157 | ({ \ | ||
158 | int __ret; \ | ||
159 | __ret = (ret < 0); \ | ||
160 | if (__ret) \ | ||
161 | tda_printk(KERN_ERR, "error %d on line %d\n", ret, __LINE__);\ | ||
162 | __ret; \ | ||
163 | }) | ||
164 | |||
156 | /*---------------------------------------------------------------------*/ | 165 | /*---------------------------------------------------------------------*/ |
157 | 166 | ||
158 | enum tda18271_map_type { | 167 | enum tda18271_map_type { |
diff --git a/drivers/media/common/tuners/tea5767.c b/drivers/media/common/tuners/tea5767.c index f6e7d7ad8424..1f5646334a8f 100644 --- a/drivers/media/common/tuners/tea5767.c +++ b/drivers/media/common/tuners/tea5767.c | |||
@@ -373,14 +373,14 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr) | |||
373 | 373 | ||
374 | if ((rc = tuner_i2c_xfer_recv(&i2c, buffer, 7))< 5) { | 374 | if ((rc = tuner_i2c_xfer_recv(&i2c, buffer, 7))< 5) { |
375 | printk(KERN_WARNING "It is not a TEA5767. Received %i bytes.\n", rc); | 375 | printk(KERN_WARNING "It is not a TEA5767. Received %i bytes.\n", rc); |
376 | return EINVAL; | 376 | return -EINVAL; |
377 | } | 377 | } |
378 | 378 | ||
379 | /* If all bytes are the same then it's a TV tuner and not a tea5767 */ | 379 | /* If all bytes are the same then it's a TV tuner and not a tea5767 */ |
380 | if (buffer[0] == buffer[1] && buffer[0] == buffer[2] && | 380 | if (buffer[0] == buffer[1] && buffer[0] == buffer[2] && |
381 | buffer[0] == buffer[3] && buffer[0] == buffer[4]) { | 381 | buffer[0] == buffer[3] && buffer[0] == buffer[4]) { |
382 | printk(KERN_WARNING "All bytes are equal. It is not a TEA5767\n"); | 382 | printk(KERN_WARNING "All bytes are equal. It is not a TEA5767\n"); |
383 | return EINVAL; | 383 | return -EINVAL; |
384 | } | 384 | } |
385 | 385 | ||
386 | /* Status bytes: | 386 | /* Status bytes: |
@@ -390,7 +390,7 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr) | |||
390 | */ | 390 | */ |
391 | if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) { | 391 | if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) { |
392 | printk(KERN_WARNING "Chip ID is not zero. It is not a TEA5767\n"); | 392 | printk(KERN_WARNING "Chip ID is not zero. It is not a TEA5767\n"); |
393 | return EINVAL; | 393 | return -EINVAL; |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index 43d35bdb221f..ceae6db901ec 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -212,7 +212,7 @@ static void xc5000_TunerReset(struct dvb_frontend *fe) | |||
212 | dprintk(1, "%s()\n", __func__); | 212 | dprintk(1, "%s()\n", __func__); |
213 | 213 | ||
214 | if (priv->cfg->tuner_callback) { | 214 | if (priv->cfg->tuner_callback) { |
215 | ret = priv->cfg->tuner_callback(priv->cfg->priv, | 215 | ret = priv->cfg->tuner_callback(priv->devptr, |
216 | XC5000_TUNER_RESET, 0); | 216 | XC5000_TUNER_RESET, 0); |
217 | if (ret) | 217 | if (ret) |
218 | printk(KERN_ERR "xc5000: reset failed\n"); | 218 | printk(KERN_ERR "xc5000: reset failed\n"); |
@@ -900,9 +900,9 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = { | |||
900 | .get_status = xc5000_get_status | 900 | .get_status = xc5000_get_status |
901 | }; | 901 | }; |
902 | 902 | ||
903 | struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | 903 | struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, |
904 | struct i2c_adapter *i2c, | 904 | struct i2c_adapter *i2c, |
905 | struct xc5000_config *cfg) | 905 | struct xc5000_config *cfg, void *devptr) |
906 | { | 906 | { |
907 | struct xc5000_priv *priv = NULL; | 907 | struct xc5000_priv *priv = NULL; |
908 | u16 id = 0; | 908 | u16 id = 0; |
@@ -916,6 +916,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | |||
916 | priv->cfg = cfg; | 916 | priv->cfg = cfg; |
917 | priv->bandwidth = BANDWIDTH_6_MHZ; | 917 | priv->bandwidth = BANDWIDTH_6_MHZ; |
918 | priv->i2c = i2c; | 918 | priv->i2c = i2c; |
919 | priv->devptr = devptr; | ||
919 | 920 | ||
920 | /* Check if firmware has been loaded. It is possible that another | 921 | /* Check if firmware has been loaded. It is possible that another |
921 | instance of the driver has loaded the firmware. | 922 | instance of the driver has loaded the firmware. |
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h index 0ee80f9d19b8..c910715addc9 100644 --- a/drivers/media/common/tuners/xc5000.h +++ b/drivers/media/common/tuners/xc5000.h | |||
@@ -31,29 +31,31 @@ struct xc5000_config { | |||
31 | u8 i2c_address; | 31 | u8 i2c_address; |
32 | u32 if_khz; | 32 | u32 if_khz; |
33 | 33 | ||
34 | /* For each bridge framework, when it attaches either analog or digital, | ||
35 | * it has to store a reference back to its _core equivalent structure, | ||
36 | * so that it can service the hardware by steering gpio's etc. | ||
37 | * Each bridge implementation is different so cast priv accordingly. | ||
38 | * The xc5000 driver cares not for this value, other than ensuring | ||
39 | * it's passed back to a bridge during tuner_callback(). | ||
40 | */ | ||
41 | void *priv; | ||
42 | int (*tuner_callback) (void *priv, int command, int arg); | 34 | int (*tuner_callback) (void *priv, int command, int arg); |
43 | }; | 35 | }; |
44 | 36 | ||
45 | /* xc5000 callback command */ | 37 | /* xc5000 callback command */ |
46 | #define XC5000_TUNER_RESET 0 | 38 | #define XC5000_TUNER_RESET 0 |
47 | 39 | ||
40 | /* For each bridge framework, when it attaches either analog or digital, | ||
41 | * it has to store a reference back to its _core equivalent structure, | ||
42 | * so that it can service the hardware by steering gpio's etc. | ||
43 | * Each bridge implementation is different so cast devptr accordingly. | ||
44 | * The xc5000 driver cares not for this value, other than ensuring | ||
45 | * it's passed back to a bridge during tuner_callback(). | ||
46 | */ | ||
47 | |||
48 | #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ | 48 | #if defined(CONFIG_MEDIA_TUNER_XC5000) || \ |
49 | (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) | 49 | (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) |
50 | extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | 50 | extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, |
51 | struct i2c_adapter *i2c, | 51 | struct i2c_adapter *i2c, |
52 | struct xc5000_config *cfg); | 52 | struct xc5000_config *cfg, |
53 | void *devptr); | ||
53 | #else | 54 | #else |
54 | static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | 55 | static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, |
55 | struct i2c_adapter *i2c, | 56 | struct i2c_adapter *i2c, |
56 | struct xc5000_config *cfg) | 57 | struct xc5000_config *cfg, |
58 | void *devptr) | ||
57 | { | 59 | { |
58 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 60 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
59 | return NULL; | 61 | return NULL; |
diff --git a/drivers/media/common/tuners/xc5000_priv.h b/drivers/media/common/tuners/xc5000_priv.h index 13b2d19341da..ecebfe4745ad 100644 --- a/drivers/media/common/tuners/xc5000_priv.h +++ b/drivers/media/common/tuners/xc5000_priv.h | |||
@@ -31,6 +31,8 @@ struct xc5000_priv { | |||
31 | u8 video_standard; | 31 | u8 video_standard; |
32 | u8 rf_mode; | 32 | u8 rf_mode; |
33 | u8 fwloaded; | 33 | u8 fwloaded; |
34 | |||
35 | void *devptr; | ||
34 | }; | 36 | }; |
35 | 37 | ||
36 | #endif | 38 | #endif |
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 7b0ea3bdfafb..f9d087669d5d 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c | |||
@@ -634,7 +634,7 @@ int flexcop_frontend_init(struct flexcop_device *fc) | |||
634 | } | 634 | } |
635 | 635 | ||
636 | /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ | 636 | /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ |
637 | fc->fe = dvb_attach(vp310_mt312_attach, | 637 | fc->fe = dvb_attach(mt312_attach, |
638 | &skystar23_samsung_tbdu18132_config, i2c); | 638 | &skystar23_samsung_tbdu18132_config, i2c); |
639 | if (fc->fe != NULL) { | 639 | if (fc->fe != NULL) { |
640 | ops = &fc->fe->ops; | 640 | ops = &fc->fe->ops; |
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig index d1239b8342f8..7588db1319d0 100644 --- a/drivers/media/dvb/bt8xx/Kconfig +++ b/drivers/media/dvb/bt8xx/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config DVB_BT8XX | 1 | config DVB_BT8XX |
2 | tristate "BT8xx based PCI cards" | 2 | tristate "BT8xx based PCI cards" |
3 | depends on DVB_CORE && PCI && I2C && VIDEO_BT848 | 3 | depends on DVB_CORE && PCI && I2C && VIDEO_BT848 |
4 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select DVB_MT352 if !DVB_FE_CUSTOMISE | 5 | select DVB_MT352 if !DVB_FE_CUSTOMISE |
5 | select DVB_SP887X if !DVB_FE_CUSTOMISE | 6 | select DVB_SP887X if !DVB_FE_CUSTOMISE |
6 | select DVB_NXT6000 if !DVB_FE_CUSTOMISE | 7 | select DVB_NXT6000 if !DVB_FE_CUSTOMISE |
diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig index 3d778c5aba68..c03513b2ccae 100644 --- a/drivers/media/dvb/cinergyT2/Kconfig +++ b/drivers/media/dvb/cinergyT2/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config DVB_CINERGYT2 | 1 | config DVB_CINERGYT2 |
2 | tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver" | 2 | tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver" |
3 | depends on DVB_CORE && USB | 3 | depends on DVB_CORE && USB && INPUT |
4 | help | 4 | help |
5 | Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers | 5 | Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers |
6 | 6 | ||
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 8cbdb0ec67e2..588fbe105c27 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | |||
@@ -910,15 +910,21 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca) | |||
910 | int curdelay = 100000000; | 910 | int curdelay = 100000000; |
911 | int slot; | 911 | int slot; |
912 | 912 | ||
913 | /* Beware of too high polling frequency, because one polling | ||
914 | * call might take several hundred milliseconds until timeout! | ||
915 | */ | ||
913 | for (slot = 0; slot < ca->slot_count; slot++) { | 916 | for (slot = 0; slot < ca->slot_count; slot++) { |
914 | switch (ca->slot_info[slot].slot_state) { | 917 | switch (ca->slot_info[slot].slot_state) { |
915 | default: | 918 | default: |
916 | case DVB_CA_SLOTSTATE_NONE: | 919 | case DVB_CA_SLOTSTATE_NONE: |
920 | delay = HZ * 60; /* 60s */ | ||
921 | if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) | ||
922 | delay = HZ * 5; /* 5s */ | ||
923 | break; | ||
917 | case DVB_CA_SLOTSTATE_INVALID: | 924 | case DVB_CA_SLOTSTATE_INVALID: |
918 | delay = HZ * 60; | 925 | delay = HZ * 60; /* 60s */ |
919 | if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) { | 926 | if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) |
920 | delay = HZ / 10; | 927 | delay = HZ / 10; /* 100ms */ |
921 | } | ||
922 | break; | 928 | break; |
923 | 929 | ||
924 | case DVB_CA_SLOTSTATE_UNINITIALISED: | 930 | case DVB_CA_SLOTSTATE_UNINITIALISED: |
@@ -926,19 +932,17 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca) | |||
926 | case DVB_CA_SLOTSTATE_VALIDATE: | 932 | case DVB_CA_SLOTSTATE_VALIDATE: |
927 | case DVB_CA_SLOTSTATE_WAITFR: | 933 | case DVB_CA_SLOTSTATE_WAITFR: |
928 | case DVB_CA_SLOTSTATE_LINKINIT: | 934 | case DVB_CA_SLOTSTATE_LINKINIT: |
929 | delay = HZ / 10; | 935 | delay = HZ / 10; /* 100ms */ |
930 | break; | 936 | break; |
931 | 937 | ||
932 | case DVB_CA_SLOTSTATE_RUNNING: | 938 | case DVB_CA_SLOTSTATE_RUNNING: |
933 | delay = HZ * 60; | 939 | delay = HZ * 60; /* 60s */ |
934 | if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) { | 940 | if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) |
935 | delay = HZ / 10; | 941 | delay = HZ / 10; /* 100ms */ |
936 | } | ||
937 | if (ca->open) { | 942 | if (ca->open) { |
938 | if ((!ca->slot_info[slot].da_irq_supported) || | 943 | if ((!ca->slot_info[slot].da_irq_supported) || |
939 | (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) { | 944 | (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) |
940 | delay = HZ / 10; | 945 | delay = HZ / 10; /* 100ms */ |
941 | } | ||
942 | } | 946 | } |
943 | break; | 947 | break; |
944 | } | 948 | } |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 4c1cff9feb2e..cf4584e48b6d 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config DVB_USB | 1 | config DVB_USB |
2 | tristate "Support for various USB DVB devices" | 2 | tristate "Support for various USB DVB devices" |
3 | depends on DVB_CORE && USB && I2C | 3 | depends on DVB_CORE && USB && I2C |
4 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select FW_LOADER | 5 | select FW_LOADER |
5 | help | 6 | help |
6 | By enabling this you will be able to choose the various supported | 7 | By enabling this you will be able to choose the various supported |
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index 6d2384605927..c20553c4da1f 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
@@ -30,7 +30,7 @@ config DVB_CX24123 | |||
30 | A DVB-S tuner module. Say Y when you want to support this frontend. | 30 | A DVB-S tuner module. Say Y when you want to support this frontend. |
31 | 31 | ||
32 | config DVB_MT312 | 32 | config DVB_MT312 |
33 | tristate "Zarlink VP310/MT312 based" | 33 | tristate "Zarlink VP310/MT312/ZL10313 based" |
34 | depends on DVB_CORE && I2C | 34 | depends on DVB_CORE && I2C |
35 | default m if DVB_FE_CUSTOMISE | 35 | default m if DVB_FE_CUSTOMISE |
36 | help | 36 | help |
@@ -97,7 +97,7 @@ comment "DVB-T (terrestrial) frontends" | |||
97 | 97 | ||
98 | config DVB_SP8870 | 98 | config DVB_SP8870 |
99 | tristate "Spase sp8870 based" | 99 | tristate "Spase sp8870 based" |
100 | depends on DVB_CORE && I2C | 100 | depends on DVB_CORE && I2C && HOTPLUG |
101 | default m if DVB_FE_CUSTOMISE | 101 | default m if DVB_FE_CUSTOMISE |
102 | select FW_LOADER | 102 | select FW_LOADER |
103 | help | 103 | help |
@@ -110,7 +110,7 @@ config DVB_SP8870 | |||
110 | 110 | ||
111 | config DVB_SP887X | 111 | config DVB_SP887X |
112 | tristate "Spase sp887x based" | 112 | tristate "Spase sp887x based" |
113 | depends on DVB_CORE && I2C | 113 | depends on DVB_CORE && I2C && HOTPLUG |
114 | default m if DVB_FE_CUSTOMISE | 114 | default m if DVB_FE_CUSTOMISE |
115 | select FW_LOADER | 115 | select FW_LOADER |
116 | help | 116 | help |
@@ -144,7 +144,7 @@ config DVB_L64781 | |||
144 | 144 | ||
145 | config DVB_TDA1004X | 145 | config DVB_TDA1004X |
146 | tristate "Philips TDA10045H/TDA10046H based" | 146 | tristate "Philips TDA10045H/TDA10046H based" |
147 | depends on DVB_CORE && I2C | 147 | depends on DVB_CORE && I2C && HOTPLUG |
148 | default m if DVB_FE_CUSTOMISE | 148 | default m if DVB_FE_CUSTOMISE |
149 | select FW_LOADER | 149 | select FW_LOADER |
150 | help | 150 | help |
@@ -211,7 +211,7 @@ config DVB_DIB7000P | |||
211 | 211 | ||
212 | config DVB_TDA10048 | 212 | config DVB_TDA10048 |
213 | tristate "Philips TDA10048HN based" | 213 | tristate "Philips TDA10048HN based" |
214 | depends on DVB_CORE && I2C | 214 | depends on DVB_CORE && I2C && HOTPLUG |
215 | default m if DVB_FE_CUSTOMISE | 215 | default m if DVB_FE_CUSTOMISE |
216 | select FW_LOADER | 216 | select FW_LOADER |
217 | help | 217 | help |
@@ -253,7 +253,7 @@ comment "ATSC (North American/Korean Terrestrial/Cable DTV) frontends" | |||
253 | 253 | ||
254 | config DVB_NXT200X | 254 | config DVB_NXT200X |
255 | tristate "NxtWave Communications NXT2002/NXT2004 based" | 255 | tristate "NxtWave Communications NXT2002/NXT2004 based" |
256 | depends on DVB_CORE && I2C | 256 | depends on DVB_CORE && I2C && HOTPLUG |
257 | default m if DVB_FE_CUSTOMISE | 257 | default m if DVB_FE_CUSTOMISE |
258 | select FW_LOADER | 258 | select FW_LOADER |
259 | help | 259 | help |
@@ -268,7 +268,7 @@ config DVB_NXT200X | |||
268 | 268 | ||
269 | config DVB_OR51211 | 269 | config DVB_OR51211 |
270 | tristate "Oren OR51211 based" | 270 | tristate "Oren OR51211 based" |
271 | depends on DVB_CORE && I2C | 271 | depends on DVB_CORE && I2C && HOTPLUG |
272 | default m if DVB_FE_CUSTOMISE | 272 | default m if DVB_FE_CUSTOMISE |
273 | select FW_LOADER | 273 | select FW_LOADER |
274 | help | 274 | help |
@@ -281,7 +281,7 @@ config DVB_OR51211 | |||
281 | 281 | ||
282 | config DVB_OR51132 | 282 | config DVB_OR51132 |
283 | tristate "Oren OR51132 based" | 283 | tristate "Oren OR51132 based" |
284 | depends on DVB_CORE && I2C | 284 | depends on DVB_CORE && I2C && HOTPLUG |
285 | default m if DVB_FE_CUSTOMISE | 285 | default m if DVB_FE_CUSTOMISE |
286 | select FW_LOADER | 286 | select FW_LOADER |
287 | help | 287 | help |
@@ -297,7 +297,7 @@ config DVB_OR51132 | |||
297 | 297 | ||
298 | config DVB_BCM3510 | 298 | config DVB_BCM3510 |
299 | tristate "Broadcom BCM3510" | 299 | tristate "Broadcom BCM3510" |
300 | depends on DVB_CORE && I2C | 300 | depends on DVB_CORE && I2C && HOTPLUG |
301 | default m if DVB_FE_CUSTOMISE | 301 | default m if DVB_FE_CUSTOMISE |
302 | select FW_LOADER | 302 | select FW_LOADER |
303 | help | 303 | help |
diff --git a/drivers/media/dvb/frontends/itd1000.c b/drivers/media/dvb/frontends/itd1000.c index 04c562ccf990..600dad6b41ea 100644 --- a/drivers/media/dvb/frontends/itd1000.c +++ b/drivers/media/dvb/frontends/itd1000.c | |||
@@ -195,7 +195,7 @@ static void itd1000_set_vco(struct itd1000_state *state, u32 freq_khz) | |||
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | struct { | 198 | static const struct { |
199 | u32 freq; | 199 | u32 freq; |
200 | u8 values[10]; /* RFTR, RFST1 - RFST9 */ | 200 | u8 values[10]; /* RFTR, RFST1 - RFST9 */ |
201 | } itd1000_fre_values[] = { | 201 | } itd1000_fre_values[] = { |
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c index 081ca3398c76..5ac9b15920f8 100644 --- a/drivers/media/dvb/frontends/mt312.c +++ b/drivers/media/dvb/frontends/mt312.c | |||
@@ -737,7 +737,7 @@ static void mt312_release(struct dvb_frontend *fe) | |||
737 | } | 737 | } |
738 | 738 | ||
739 | #define MT312_SYS_CLK 90000000UL /* 90 MHz */ | 739 | #define MT312_SYS_CLK 90000000UL /* 90 MHz */ |
740 | static struct dvb_frontend_ops vp310_mt312_ops = { | 740 | static struct dvb_frontend_ops mt312_ops = { |
741 | 741 | ||
742 | .info = { | 742 | .info = { |
743 | .name = "Zarlink ???? DVB-S", | 743 | .name = "Zarlink ???? DVB-S", |
@@ -776,7 +776,7 @@ static struct dvb_frontend_ops vp310_mt312_ops = { | |||
776 | .set_voltage = mt312_set_voltage, | 776 | .set_voltage = mt312_set_voltage, |
777 | }; | 777 | }; |
778 | 778 | ||
779 | struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, | 779 | struct dvb_frontend *mt312_attach(const struct mt312_config *config, |
780 | struct i2c_adapter *i2c) | 780 | struct i2c_adapter *i2c) |
781 | { | 781 | { |
782 | struct mt312_state *state = NULL; | 782 | struct mt312_state *state = NULL; |
@@ -795,7 +795,7 @@ struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, | |||
795 | goto error; | 795 | goto error; |
796 | 796 | ||
797 | /* create dvb_frontend */ | 797 | /* create dvb_frontend */ |
798 | memcpy(&state->frontend.ops, &vp310_mt312_ops, | 798 | memcpy(&state->frontend.ops, &mt312_ops, |
799 | sizeof(struct dvb_frontend_ops)); | 799 | sizeof(struct dvb_frontend_ops)); |
800 | state->frontend.demodulator_priv = state; | 800 | state->frontend.demodulator_priv = state; |
801 | 801 | ||
@@ -827,12 +827,13 @@ error: | |||
827 | kfree(state); | 827 | kfree(state); |
828 | return NULL; | 828 | return NULL; |
829 | } | 829 | } |
830 | EXPORT_SYMBOL(vp310_mt312_attach); | 830 | EXPORT_SYMBOL(mt312_attach); |
831 | 831 | ||
832 | module_param(debug, int, 0644); | 832 | module_param(debug, int, 0644); |
833 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | 833 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); |
834 | 834 | ||
835 | MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver"); | 835 | MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver"); |
836 | MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); | 836 | MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); |
837 | MODULE_AUTHOR("Matthias Schwarzott <zzam@gentoo.org>"); | ||
837 | MODULE_LICENSE("GPL"); | 838 | MODULE_LICENSE("GPL"); |
838 | 839 | ||
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h index de796eab3911..29e3bb5496b8 100644 --- a/drivers/media/dvb/frontends/mt312.h +++ b/drivers/media/dvb/frontends/mt312.h | |||
@@ -37,10 +37,10 @@ struct mt312_config { | |||
37 | }; | 37 | }; |
38 | 38 | ||
39 | #if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE)) | 39 | #if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE)) |
40 | struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, | 40 | struct dvb_frontend *mt312_attach(const struct mt312_config *config, |
41 | struct i2c_adapter *i2c); | 41 | struct i2c_adapter *i2c); |
42 | #else | 42 | #else |
43 | static inline struct dvb_frontend *vp310_mt312_attach( | 43 | static inline struct dvb_frontend *mt312_attach( |
44 | const struct mt312_config *config, struct i2c_adapter *i2c) | 44 | const struct mt312_config *config, struct i2c_adapter *i2c) |
45 | { | 45 | { |
46 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 46 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig index ae882432dd3d..d4339b1b3b68 100644 --- a/drivers/media/dvb/ttpci/Kconfig +++ b/drivers/media/dvb/ttpci/Kconfig | |||
@@ -5,6 +5,7 @@ config TTPCI_EEPROM | |||
5 | config DVB_AV7110 | 5 | config DVB_AV7110 |
6 | tristate "AV7110 cards" | 6 | tristate "AV7110 cards" |
7 | depends on DVB_CORE && PCI && I2C | 7 | depends on DVB_CORE && PCI && I2C |
8 | depends on HOTPLUG | ||
8 | select FW_LOADER if !DVB_AV7110_FIRMWARE | 9 | select FW_LOADER if !DVB_AV7110_FIRMWARE |
9 | select TTPCI_EEPROM | 10 | select TTPCI_EEPROM |
10 | select VIDEO_SAA7146_VV | 11 | select VIDEO_SAA7146_VV |
@@ -123,6 +124,7 @@ config DVB_BUDGET_AV | |||
123 | depends on DVB_BUDGET_CORE && I2C | 124 | depends on DVB_BUDGET_CORE && I2C |
124 | select VIDEO_SAA7146_VV | 125 | select VIDEO_SAA7146_VV |
125 | depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV | 126 | depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV |
127 | depends on HOTPLUG # dependency of FW_LOADER | ||
126 | select DVB_PLL if !DVB_FE_CUSTOMISE | 128 | select DVB_PLL if !DVB_FE_CUSTOMISE |
127 | select DVB_STV0299 if !DVB_FE_CUSTOMISE | 129 | select DVB_STV0299 if !DVB_FE_CUSTOMISE |
128 | select DVB_TDA1004X if !DVB_FE_CUSTOMISE | 130 | select DVB_TDA1004X if !DVB_FE_CUSTOMISE |
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig index 83611012ef34..0712899e39a4 100644 --- a/drivers/media/dvb/ttusb-dec/Kconfig +++ b/drivers/media/dvb/ttusb-dec/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config DVB_TTUSB_DEC | 1 | config DVB_TTUSB_DEC |
2 | tristate "Technotrend/Hauppauge USB DEC devices" | 2 | tristate "Technotrend/Hauppauge USB DEC devices" |
3 | depends on DVB_CORE && USB | 3 | depends on DVB_CORE && USB |
4 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select FW_LOADER | 5 | select FW_LOADER |
5 | select CRC32 | 6 | select CRC32 |
6 | help | 7 | help |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index fe743aa7f645..89d8d37838a3 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -44,6 +44,10 @@ config VIDEO_TVEEPROM | |||
44 | tristate | 44 | tristate |
45 | depends on I2C | 45 | depends on I2C |
46 | 46 | ||
47 | config VIDEO_TUNER | ||
48 | tristate | ||
49 | depends on MEDIA_TUNER | ||
50 | |||
47 | # | 51 | # |
48 | # Multimedia Video device configuration | 52 | # Multimedia Video device configuration |
49 | # | 53 | # |
@@ -690,7 +694,7 @@ config VIDEO_MXB | |||
690 | tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" | 694 | tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" |
691 | depends on PCI && VIDEO_V4L1 && I2C | 695 | depends on PCI && VIDEO_V4L1 && I2C |
692 | select VIDEO_SAA7146_VV | 696 | select VIDEO_SAA7146_VV |
693 | select MEDIA_TUNER | 697 | select VIDEO_TUNER |
694 | select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO | 698 | select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO |
695 | select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO | 699 | select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO |
696 | select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO | 700 | select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO |
@@ -906,7 +910,7 @@ config SOC_CAMERA | |||
906 | 910 | ||
907 | config SOC_CAMERA_MT9M001 | 911 | config SOC_CAMERA_MT9M001 |
908 | tristate "mt9m001 support" | 912 | tristate "mt9m001 support" |
909 | depends on SOC_CAMERA | 913 | depends on SOC_CAMERA && I2C |
910 | select GPIO_PCA953X if MT9M001_PCA9536_SWITCH | 914 | select GPIO_PCA953X if MT9M001_PCA9536_SWITCH |
911 | help | 915 | help |
912 | This driver supports MT9M001 cameras from Micron, monochrome | 916 | This driver supports MT9M001 cameras from Micron, monochrome |
@@ -921,7 +925,7 @@ config MT9M001_PCA9536_SWITCH | |||
921 | 925 | ||
922 | config SOC_CAMERA_MT9V022 | 926 | config SOC_CAMERA_MT9V022 |
923 | tristate "mt9v022 support" | 927 | tristate "mt9v022 support" |
924 | depends on SOC_CAMERA | 928 | depends on SOC_CAMERA && I2C |
925 | select GPIO_PCA953X if MT9V022_PCA9536_SWITCH | 929 | select GPIO_PCA953X if MT9V022_PCA9536_SWITCH |
926 | help | 930 | help |
927 | This driver supports MT9V022 cameras from Micron | 931 | This driver supports MT9V022 cameras from Micron |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index a352c6e31f0c..dff0d6abe917 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -84,7 +84,7 @@ obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o | |||
84 | obj-$(CONFIG_VIDEO_DPC) += dpc7146.o | 84 | obj-$(CONFIG_VIDEO_DPC) += dpc7146.o |
85 | obj-$(CONFIG_TUNER_3036) += tuner-3036.o | 85 | obj-$(CONFIG_TUNER_3036) += tuner-3036.o |
86 | 86 | ||
87 | obj-$(CONFIG_MEDIA_TUNER) += tuner.o | 87 | obj-$(CONFIG_VIDEO_TUNER) += tuner.o |
88 | 88 | ||
89 | obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o | 89 | obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o |
90 | obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o | 90 | obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o |
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig index cab277fafa63..def10d086373 100644 --- a/drivers/media/video/au0828/Kconfig +++ b/drivers/media/video/au0828/Kconfig | |||
@@ -1,8 +1,9 @@ | |||
1 | 1 | ||
2 | config VIDEO_AU0828 | 2 | config VIDEO_AU0828 |
3 | tristate "Auvitek AU0828 support" | 3 | tristate "Auvitek AU0828 support" |
4 | depends on VIDEO_DEV && I2C && INPUT && DVB_CORE | 4 | depends on VIDEO_DEV && I2C && INPUT && DVB_CORE && USB |
5 | select I2C_ALGOBIT | 5 | select I2C_ALGOBIT |
6 | select VIDEO_TVEEPROM | ||
6 | select DVB_AU8522 if !DVB_FE_CUSTOMIZE | 7 | select DVB_AU8522 if !DVB_FE_CUSTOMIZE |
7 | select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE | 8 | select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE |
8 | ---help--- | 9 | ---help--- |
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c index 1371b4e4b5f1..c86a5f17eca8 100644 --- a/drivers/media/video/au0828/au0828-dvb.c +++ b/drivers/media/video/au0828/au0828-dvb.c | |||
@@ -337,12 +337,10 @@ int au0828_dvb_register(struct au0828_dev *dev) | |||
337 | dvb->frontend = dvb_attach(au8522_attach, | 337 | dvb->frontend = dvb_attach(au8522_attach, |
338 | &hauppauge_hvr950q_config, | 338 | &hauppauge_hvr950q_config, |
339 | &dev->i2c_adap); | 339 | &dev->i2c_adap); |
340 | if (dvb->frontend != NULL) { | 340 | if (dvb->frontend != NULL) |
341 | hauppauge_hvr950q_tunerconfig.priv = dev; | ||
342 | dvb_attach(xc5000_attach, dvb->frontend, | 341 | dvb_attach(xc5000_attach, dvb->frontend, |
343 | &dev->i2c_adap, | 342 | &dev->i2c_adap, |
344 | &hauppauge_hvr950q_tunerconfig); | 343 | &hauppauge_hvr950q_tunerconfig, dev); |
345 | } | ||
346 | break; | 344 | break; |
347 | default: | 345 | default: |
348 | printk(KERN_WARNING "The frontend of your DVB/ATSC card " | 346 | printk(KERN_WARNING "The frontend of your DVB/ATSC card " |
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig index 7431ef6de9f1..24a34fc1f2b3 100644 --- a/drivers/media/video/bt8xx/Kconfig +++ b/drivers/media/video/bt8xx/Kconfig | |||
@@ -1,12 +1,13 @@ | |||
1 | config VIDEO_BT848 | 1 | config VIDEO_BT848 |
2 | tristate "BT848 Video For Linux" | 2 | tristate "BT848 Video For Linux" |
3 | depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT | 3 | depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT |
4 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select I2C_ALGOBIT | 5 | select I2C_ALGOBIT |
5 | select FW_LOADER | 6 | select FW_LOADER |
6 | select VIDEO_BTCX | 7 | select VIDEO_BTCX |
7 | select VIDEOBUF_DMA_SG | 8 | select VIDEOBUF_DMA_SG |
8 | select VIDEO_IR | 9 | select VIDEO_IR |
9 | select MEDIA_TUNER | 10 | select VIDEO_TUNER |
10 | select VIDEO_TVEEPROM | 11 | select VIDEO_TVEEPROM |
11 | select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO | 12 | select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO |
12 | select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO | 13 | select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO |
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig index acc4b47f1d1d..5f942690570c 100644 --- a/drivers/media/video/cx18/Kconfig +++ b/drivers/media/video/cx18/Kconfig | |||
@@ -1,14 +1,17 @@ | |||
1 | config VIDEO_CX18 | 1 | config VIDEO_CX18 |
2 | tristate "Conexant cx23418 MPEG encoder support" | 2 | tristate "Conexant cx23418 MPEG encoder support" |
3 | depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL | 3 | depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL |
4 | depends on INPUT # due to VIDEO_IR | ||
5 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select I2C_ALGOBIT | 6 | select I2C_ALGOBIT |
5 | select FW_LOADER | 7 | select FW_LOADER |
6 | select VIDEO_IR | 8 | select VIDEO_IR |
7 | select MEDIA_TUNER | 9 | select VIDEO_TUNER |
8 | select VIDEO_TVEEPROM | 10 | select VIDEO_TVEEPROM |
9 | select VIDEO_CX2341X | 11 | select VIDEO_CX2341X |
10 | select VIDEO_CS5345 | 12 | select VIDEO_CS5345 |
11 | select DVB_S5H1409 | 13 | select DVB_S5H1409 |
14 | select MEDIA_TUNER_MXL5005S | ||
12 | ---help--- | 15 | ---help--- |
13 | This is a video4linux driver for Conexant cx23418 based | 16 | This is a video4linux driver for Conexant cx23418 based |
14 | PCI combo video recorder devices. | 17 | PCI combo video recorder devices. |
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c index f5e3ba1f5354..553adbf2cd44 100644 --- a/drivers/media/video/cx18/cx18-cards.c +++ b/drivers/media/video/cx18/cx18-cards.c | |||
@@ -47,11 +47,12 @@ static struct cx18_card_tuner_i2c cx18_i2c_std = { | |||
47 | static const struct cx18_card cx18_card_hvr1600_esmt = { | 47 | static const struct cx18_card cx18_card_hvr1600_esmt = { |
48 | .type = CX18_CARD_HVR_1600_ESMT, | 48 | .type = CX18_CARD_HVR_1600_ESMT, |
49 | .name = "Hauppauge HVR-1600", | 49 | .name = "Hauppauge HVR-1600", |
50 | .comment = "DVB & VBI are not yet supported\n", | 50 | .comment = "VBI is not yet supported\n", |
51 | .v4l2_capabilities = CX18_CAP_ENCODER, | 51 | .v4l2_capabilities = CX18_CAP_ENCODER, |
52 | .hw_audio_ctrl = CX18_HW_CX23418, | 52 | .hw_audio_ctrl = CX18_HW_CX23418, |
53 | .hw_muxer = CX18_HW_CS5345, | 53 | .hw_muxer = CX18_HW_CS5345, |
54 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, | 54 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | |
55 | CX18_HW_CS5345 | CX18_HW_DVB, | ||
55 | .video_inputs = { | 56 | .video_inputs = { |
56 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 57 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, |
57 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 58 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, |
@@ -86,11 +87,12 @@ static const struct cx18_card cx18_card_hvr1600_esmt = { | |||
86 | static const struct cx18_card cx18_card_hvr1600_samsung = { | 87 | static const struct cx18_card cx18_card_hvr1600_samsung = { |
87 | .type = CX18_CARD_HVR_1600_SAMSUNG, | 88 | .type = CX18_CARD_HVR_1600_SAMSUNG, |
88 | .name = "Hauppauge HVR-1600 (Preproduction)", | 89 | .name = "Hauppauge HVR-1600 (Preproduction)", |
89 | .comment = "DVB & VBI are not yet supported\n", | 90 | .comment = "VBI is not yet supported\n", |
90 | .v4l2_capabilities = CX18_CAP_ENCODER, | 91 | .v4l2_capabilities = CX18_CAP_ENCODER, |
91 | .hw_audio_ctrl = CX18_HW_CX23418, | 92 | .hw_audio_ctrl = CX18_HW_CX23418, |
92 | .hw_muxer = CX18_HW_CS5345, | 93 | .hw_muxer = CX18_HW_CS5345, |
93 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, | 94 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | |
95 | CX18_HW_CS5345 | CX18_HW_DVB, | ||
94 | .video_inputs = { | 96 | .video_inputs = { |
95 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 97 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, |
96 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 98 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, |
@@ -134,14 +136,15 @@ static const struct cx18_card_pci_info cx18_pci_h900[] = { | |||
134 | static const struct cx18_card cx18_card_h900 = { | 136 | static const struct cx18_card cx18_card_h900 = { |
135 | .type = CX18_CARD_COMPRO_H900, | 137 | .type = CX18_CARD_COMPRO_H900, |
136 | .name = "Compro VideoMate H900", | 138 | .name = "Compro VideoMate H900", |
137 | .comment = "Not yet supported!\n", | 139 | .comment = "DVB & VBI are not yet supported\n", |
138 | .v4l2_capabilities = 0, | 140 | .v4l2_capabilities = CX18_CAP_ENCODER, |
139 | .hw_audio_ctrl = CX18_HW_CX23418, | 141 | .hw_audio_ctrl = CX18_HW_CX23418, |
140 | .hw_all = CX18_HW_TUNER, | 142 | .hw_all = CX18_HW_TUNER, |
141 | .video_inputs = { | 143 | .video_inputs = { |
142 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 144 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 }, |
143 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 145 | { CX18_CARD_INPUT_SVIDEO1, 1, |
144 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, | 146 | CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 }, |
147 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 }, | ||
145 | }, | 148 | }, |
146 | .audio_inputs = { | 149 | .audio_inputs = { |
147 | { CX18_CARD_INPUT_AUD_TUNER, | 150 | { CX18_CARD_INPUT_AUD_TUNER, |
@@ -163,6 +166,7 @@ static const struct cx18_card cx18_card_h900 = { | |||
163 | .tune_lane = 0, | 166 | .tune_lane = 0, |
164 | .initial_emrs = 0, | 167 | .initial_emrs = 0, |
165 | }, | 168 | }, |
169 | .xceive_pin = 15, | ||
166 | .pci_list = cx18_pci_h900, | 170 | .pci_list = cx18_pci_h900, |
167 | .i2c = &cx18_i2c_std, | 171 | .i2c = &cx18_i2c_std, |
168 | }; | 172 | }; |
@@ -200,8 +204,6 @@ static const struct cx18_card cx18_card_mpc718 = { | |||
200 | /* XC3028 tuner */ | 204 | /* XC3028 tuner */ |
201 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, | 205 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, |
202 | }, | 206 | }, |
203 | /* tuner reset */ | ||
204 | .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 }, | ||
205 | .ddr = { | 207 | .ddr = { |
206 | /* Probably Samsung K4D263238G-VC33 memory */ | 208 | /* Probably Samsung K4D263238G-VC33 memory */ |
207 | .chip_config = 0x003, | 209 | .chip_config = 0x003, |
@@ -211,6 +213,7 @@ static const struct cx18_card cx18_card_mpc718 = { | |||
211 | .tune_lane = 0, | 213 | .tune_lane = 0, |
212 | .initial_emrs = 2, | 214 | .initial_emrs = 2, |
213 | }, | 215 | }, |
216 | .xceive_pin = 15, | ||
214 | .pci_list = cx18_pci_mpc718, | 217 | .pci_list = cx18_pci_mpc718, |
215 | .i2c = &cx18_i2c_std, | 218 | .i2c = &cx18_i2c_std, |
216 | }; | 219 | }; |
diff --git a/drivers/media/video/cx18/cx18-cards.h b/drivers/media/video/cx18/cx18-cards.h index bca249bdd337..bccb67f0db16 100644 --- a/drivers/media/video/cx18/cx18-cards.h +++ b/drivers/media/video/cx18/cx18-cards.h | |||
@@ -114,8 +114,8 @@ struct cx18_card_pci_info { | |||
114 | /* The mask is the set of bits used by the operation */ | 114 | /* The mask is the set of bits used by the operation */ |
115 | 115 | ||
116 | struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ | 116 | struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ |
117 | u16 direction; /* DIR setting. Leave to 0 if no init is needed */ | 117 | u32 direction; /* DIR setting. Leave to 0 if no init is needed */ |
118 | u16 initial_value; | 118 | u32 initial_value; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | struct cx18_card_tuner { | 121 | struct cx18_card_tuner { |
@@ -153,6 +153,7 @@ struct cx18_card { | |||
153 | struct cx18_card_audio_input radio_input; | 153 | struct cx18_card_audio_input radio_input; |
154 | 154 | ||
155 | /* GPIO card-specific settings */ | 155 | /* GPIO card-specific settings */ |
156 | u8 xceive_pin; /* XCeive tuner GPIO reset pin */ | ||
156 | struct cx18_gpio_init gpio_init; | 157 | struct cx18_gpio_init gpio_init; |
157 | 158 | ||
158 | struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; | 159 | struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; |
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 3f55d47bc4b9..0dd4e0529970 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c | |||
@@ -164,16 +164,6 @@ MODULE_LICENSE("GPL"); | |||
164 | 164 | ||
165 | MODULE_VERSION(CX18_VERSION); | 165 | MODULE_VERSION(CX18_VERSION); |
166 | 166 | ||
167 | int cx18_waitq(wait_queue_head_t *waitq) | ||
168 | { | ||
169 | DEFINE_WAIT(wait); | ||
170 | |||
171 | prepare_to_wait(waitq, &wait, TASK_INTERRUPTIBLE); | ||
172 | schedule(); | ||
173 | finish_wait(waitq, &wait); | ||
174 | return signal_pending(current) ? -EINTR : 0; | ||
175 | } | ||
176 | |||
177 | /* Generic utility functions */ | 167 | /* Generic utility functions */ |
178 | int cx18_msleep_timeout(unsigned int msecs, int intr) | 168 | int cx18_msleep_timeout(unsigned int msecs, int intr) |
179 | { | 169 | { |
@@ -220,13 +210,13 @@ static void cx18_process_eeprom(struct cx18 *cx) | |||
220 | 210 | ||
221 | /* Many thanks to Steven Toth from Hauppauge for providing the | 211 | /* Many thanks to Steven Toth from Hauppauge for providing the |
222 | model numbers */ | 212 | model numbers */ |
213 | /* Note: the Samsung memory models cannot be reliably determined | ||
214 | from the model number. Use the cardtype module option if you | ||
215 | have one of these preproduction models. */ | ||
223 | switch (tv.model) { | 216 | switch (tv.model) { |
224 | case 74000 ... 74099: | 217 | case 74000 ... 74999: |
225 | cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); | 218 | cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); |
226 | break; | 219 | break; |
227 | case 74700 ... 74799: | ||
228 | cx->card = cx18_get_card(CX18_CARD_HVR_1600_SAMSUNG); | ||
229 | break; | ||
230 | case 0: | 220 | case 0: |
231 | CX18_ERR("Invalid EEPROM\n"); | 221 | CX18_ERR("Invalid EEPROM\n"); |
232 | return; | 222 | return; |
@@ -548,6 +538,7 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *dev, | |||
548 | return 0; | 538 | return 0; |
549 | } | 539 | } |
550 | 540 | ||
541 | #ifdef MODULE | ||
551 | static u32 cx18_request_module(struct cx18 *cx, u32 hw, | 542 | static u32 cx18_request_module(struct cx18 *cx, u32 hw, |
552 | const char *name, u32 id) | 543 | const char *name, u32 id) |
553 | { | 544 | { |
@@ -560,12 +551,14 @@ static u32 cx18_request_module(struct cx18 *cx, u32 hw, | |||
560 | CX18_DEBUG_INFO("Loaded module %s\n", name); | 551 | CX18_DEBUG_INFO("Loaded module %s\n", name); |
561 | return hw; | 552 | return hw; |
562 | } | 553 | } |
554 | #endif | ||
563 | 555 | ||
564 | static void cx18_load_and_init_modules(struct cx18 *cx) | 556 | static void cx18_load_and_init_modules(struct cx18 *cx) |
565 | { | 557 | { |
566 | u32 hw = cx->card->hw_all; | 558 | u32 hw = cx->card->hw_all; |
567 | int i; | 559 | int i; |
568 | 560 | ||
561 | #ifdef MODULE | ||
569 | /* load modules */ | 562 | /* load modules */ |
570 | #ifndef CONFIG_MEDIA_TUNER | 563 | #ifndef CONFIG_MEDIA_TUNER |
571 | hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); | 564 | hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); |
@@ -573,6 +566,7 @@ static void cx18_load_and_init_modules(struct cx18 *cx) | |||
573 | #ifndef CONFIG_VIDEO_CS5345 | 566 | #ifndef CONFIG_VIDEO_CS5345 |
574 | hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); | 567 | hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); |
575 | #endif | 568 | #endif |
569 | #endif | ||
576 | 570 | ||
577 | /* check which i2c devices are actually found */ | 571 | /* check which i2c devices are actually found */ |
578 | for (i = 0; i < 32; i++) { | 572 | for (i = 0; i < 32; i++) { |
@@ -801,7 +795,7 @@ static int __devinit cx18_probe(struct pci_dev *dev, | |||
801 | return 0; | 795 | return 0; |
802 | 796 | ||
803 | free_streams: | 797 | free_streams: |
804 | cx18_streams_cleanup(cx); | 798 | cx18_streams_cleanup(cx, 1); |
805 | free_irq: | 799 | free_irq: |
806 | free_irq(cx->dev->irq, (void *)cx); | 800 | free_irq(cx->dev->irq, (void *)cx); |
807 | free_i2c: | 801 | free_i2c: |
@@ -904,14 +898,13 @@ static void cx18_remove(struct pci_dev *pci_dev) | |||
904 | 898 | ||
905 | cx18_halt_firmware(cx); | 899 | cx18_halt_firmware(cx); |
906 | 900 | ||
907 | cx18_streams_cleanup(cx); | 901 | cx18_streams_cleanup(cx, 1); |
908 | 902 | ||
909 | exit_cx18_i2c(cx); | 903 | exit_cx18_i2c(cx); |
910 | 904 | ||
911 | free_irq(cx->dev->irq, (void *)cx); | 905 | free_irq(cx->dev->irq, (void *)cx); |
912 | 906 | ||
913 | if (cx->dev) | 907 | cx18_iounmap(cx); |
914 | cx18_iounmap(cx); | ||
915 | 908 | ||
916 | release_mem_region(cx->base_addr, CX18_MEM_SIZE); | 909 | release_mem_region(cx->base_addr, CX18_MEM_SIZE); |
917 | 910 | ||
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h index 2ee939193bb7..a2a6c58d12fe 100644 --- a/drivers/media/video/cx18/cx18-driver.h +++ b/drivers/media/video/cx18/cx18-driver.h | |||
@@ -444,9 +444,6 @@ extern spinlock_t cx18_cards_lock; | |||
444 | /* Return non-zero if a signal is pending */ | 444 | /* Return non-zero if a signal is pending */ |
445 | int cx18_msleep_timeout(unsigned int msecs, int intr); | 445 | int cx18_msleep_timeout(unsigned int msecs, int intr); |
446 | 446 | ||
447 | /* Wait on queue, returns -EINTR if interrupted */ | ||
448 | int cx18_waitq(wait_queue_head_t *waitq); | ||
449 | |||
450 | /* Read Hauppauge eeprom */ | 447 | /* Read Hauppauge eeprom */ |
451 | struct tveeprom; /* forward reference */ | 448 | struct tveeprom; /* forward reference */ |
452 | void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv); | 449 | void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv); |
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c index 65efe69d939a..c9744173f969 100644 --- a/drivers/media/video/cx18/cx18-dvb.c +++ b/drivers/media/video/cx18/cx18-dvb.c | |||
@@ -24,25 +24,27 @@ | |||
24 | #include "cx18-streams.h" | 24 | #include "cx18-streams.h" |
25 | #include "cx18-cards.h" | 25 | #include "cx18-cards.h" |
26 | #include "s5h1409.h" | 26 | #include "s5h1409.h" |
27 | 27 | #include "mxl5005s.h" | |
28 | /* Wait until the MXL500X driver is merged */ | ||
29 | #ifdef HAVE_MXL500X | ||
30 | #include "mxl500x.h" | ||
31 | #endif | ||
32 | 28 | ||
33 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 29 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
34 | 30 | ||
35 | #define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000 | 31 | #define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000 |
36 | 32 | ||
37 | #ifdef HAVE_MXL500X | 33 | static struct mxl5005s_config hauppauge_hvr1600_tuner = { |
38 | static struct mxl500x_config hauppauge_hvr1600_tuner = { | 34 | .i2c_address = 0xC6 >> 1, |
39 | .delsys = MXL500x_MODE_ATSC, | 35 | .if_freq = IF_FREQ_5380000HZ, |
40 | .octf = MXL500x_OCTF_CH, | 36 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, |
41 | .xtal_freq = 16000000, | 37 | .agc_mode = MXL_SINGLE_AGC, |
42 | .iflo_freq = 5380000, | 38 | .tracking_filter = MXL_TF_C_H, |
43 | .ref_freq = 322800000, | 39 | .rssi_enable = MXL_RSSI_ENABLE, |
44 | .rssi_ena = MXL_RSSI_ENABLE, | 40 | .cap_select = MXL_CAP_SEL_ENABLE, |
45 | .addr = 0xC6 >> 1, | 41 | .div_out = MXL_DIV_OUT_4, |
42 | .clock_out = MXL_CLOCK_OUT_DISABLE, | ||
43 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, | ||
44 | .top = MXL5005S_TOP_25P2, | ||
45 | .mod_mode = MXL_DIGITAL_MODE, | ||
46 | .if_mode = MXL_ZERO_IF, | ||
47 | .AgcMasterByte = 0x00, | ||
46 | }; | 48 | }; |
47 | 49 | ||
48 | static struct s5h1409_config hauppauge_hvr1600_config = { | 50 | static struct s5h1409_config hauppauge_hvr1600_config = { |
@@ -55,7 +57,6 @@ static struct s5h1409_config hauppauge_hvr1600_config = { | |||
55 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK | 57 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK |
56 | 58 | ||
57 | }; | 59 | }; |
58 | #endif | ||
59 | 60 | ||
60 | static int dvb_register(struct cx18_stream *stream); | 61 | static int dvb_register(struct cx18_stream *stream); |
61 | 62 | ||
@@ -252,21 +253,18 @@ static int dvb_register(struct cx18_stream *stream) | |||
252 | int ret = 0; | 253 | int ret = 0; |
253 | 254 | ||
254 | switch (cx->card->type) { | 255 | switch (cx->card->type) { |
255 | /* Wait until the MXL500X driver is merged */ | ||
256 | #ifdef HAVE_MXL500X | ||
257 | case CX18_CARD_HVR_1600_ESMT: | 256 | case CX18_CARD_HVR_1600_ESMT: |
258 | case CX18_CARD_HVR_1600_SAMSUNG: | 257 | case CX18_CARD_HVR_1600_SAMSUNG: |
259 | dvb->fe = dvb_attach(s5h1409_attach, | 258 | dvb->fe = dvb_attach(s5h1409_attach, |
260 | &hauppauge_hvr1600_config, | 259 | &hauppauge_hvr1600_config, |
261 | &cx->i2c_adap[0]); | 260 | &cx->i2c_adap[0]); |
262 | if (dvb->fe != NULL) { | 261 | if (dvb->fe != NULL) { |
263 | dvb_attach(mxl500x_attach, dvb->fe, | 262 | dvb_attach(mxl5005s_attach, dvb->fe, |
264 | &hauppauge_hvr1600_tuner, | 263 | &cx->i2c_adap[0], |
265 | &cx->i2c_adap[0]); | 264 | &hauppauge_hvr1600_tuner); |
266 | ret = 0; | 265 | ret = 0; |
267 | } | 266 | } |
268 | break; | 267 | break; |
269 | #endif | ||
270 | default: | 268 | default: |
271 | /* No Digital Tv Support */ | 269 | /* No Digital Tv Support */ |
272 | break; | 270 | break; |
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c index 69303065a294..0b3141db174b 100644 --- a/drivers/media/video/cx18/cx18-fileops.c +++ b/drivers/media/video/cx18/cx18-fileops.c | |||
@@ -39,7 +39,7 @@ | |||
39 | associated VBI streams are also automatically claimed. | 39 | associated VBI streams are also automatically claimed. |
40 | Possible error returns: -EBUSY if someone else has claimed | 40 | Possible error returns: -EBUSY if someone else has claimed |
41 | the stream or 0 on success. */ | 41 | the stream or 0 on success. */ |
42 | int cx18_claim_stream(struct cx18_open_id *id, int type) | 42 | static int cx18_claim_stream(struct cx18_open_id *id, int type) |
43 | { | 43 | { |
44 | struct cx18 *cx = id->cx; | 44 | struct cx18 *cx = id->cx; |
45 | struct cx18_stream *s = &cx->streams[type]; | 45 | struct cx18_stream *s = &cx->streams[type]; |
@@ -87,7 +87,7 @@ int cx18_claim_stream(struct cx18_open_id *id, int type) | |||
87 | 87 | ||
88 | /* This function releases a previously claimed stream. It will take into | 88 | /* This function releases a previously claimed stream. It will take into |
89 | account associated VBI streams. */ | 89 | account associated VBI streams. */ |
90 | void cx18_release_stream(struct cx18_stream *s) | 90 | static void cx18_release_stream(struct cx18_stream *s) |
91 | { | 91 | { |
92 | struct cx18 *cx = s->cx; | 92 | struct cx18 *cx = s->cx; |
93 | struct cx18_stream *s_vbi; | 93 | struct cx18_stream *s_vbi; |
@@ -662,6 +662,8 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp) | |||
662 | for (x = 0; cx == NULL && x < cx18_cards_active; x++) { | 662 | for (x = 0; cx == NULL && x < cx18_cards_active; x++) { |
663 | /* find out which stream this open was on */ | 663 | /* find out which stream this open was on */ |
664 | for (y = 0; y < CX18_MAX_STREAMS; y++) { | 664 | for (y = 0; y < CX18_MAX_STREAMS; y++) { |
665 | if (cx18_cards[x] == NULL) | ||
666 | continue; | ||
665 | s = &cx18_cards[x]->streams[y]; | 667 | s = &cx18_cards[x]->streams[y]; |
666 | if (s->v4l2dev && s->v4l2dev->minor == minor) { | 668 | if (s->v4l2dev && s->v4l2dev->minor == minor) { |
667 | cx = cx18_cards[x]; | 669 | cx = cx18_cards[x]; |
diff --git a/drivers/media/video/cx18/cx18-fileops.h b/drivers/media/video/cx18/cx18-fileops.h index 16cdafbd24c5..46da0282fc7d 100644 --- a/drivers/media/video/cx18/cx18-fileops.h +++ b/drivers/media/video/cx18/cx18-fileops.h | |||
@@ -34,12 +34,3 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end); | |||
34 | void cx18_mute(struct cx18 *cx); | 34 | void cx18_mute(struct cx18 *cx); |
35 | void cx18_unmute(struct cx18 *cx); | 35 | void cx18_unmute(struct cx18 *cx); |
36 | 36 | ||
37 | /* Utilities */ | ||
38 | |||
39 | /* Try to claim a stream for the filehandle. Return 0 on success, | ||
40 | -EBUSY if stream already claimed. Once a stream is claimed, it | ||
41 | remains claimed until the associated filehandle is closed. */ | ||
42 | int cx18_claim_stream(struct cx18_open_id *id, int type); | ||
43 | |||
44 | /* Release a previously claimed stream. */ | ||
45 | void cx18_release_stream(struct cx18_stream *s); | ||
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c index 19253e6b8673..bb8bc86086d0 100644 --- a/drivers/media/video/cx18/cx18-gpio.c +++ b/drivers/media/video/cx18/cx18-gpio.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #define CX18_REG_GPIO_OUT2 0xc78104 | 35 | #define CX18_REG_GPIO_OUT2 0xc78104 |
36 | #define CX18_REG_GPIO_DIR2 0xc7810c | 36 | #define CX18_REG_GPIO_DIR2 0xc7810c |
37 | 37 | ||
38 | static u32 gpio_dir; | ||
39 | static u32 gpio_val; | ||
40 | |||
38 | /* | 41 | /* |
39 | * HVR-1600 GPIO pins, courtesy of Hauppauge: | 42 | * HVR-1600 GPIO pins, courtesy of Hauppauge: |
40 | * | 43 | * |
@@ -44,31 +47,53 @@ | |||
44 | * gpio13: cs5345 reset pin | 47 | * gpio13: cs5345 reset pin |
45 | */ | 48 | */ |
46 | 49 | ||
50 | static void gpio_write(struct cx18 *cx) | ||
51 | { | ||
52 | write_reg((gpio_dir & 0xffff) << 16, CX18_REG_GPIO_DIR1); | ||
53 | write_reg(((gpio_dir & 0xffff) << 16) | (gpio_val & 0xffff), | ||
54 | CX18_REG_GPIO_OUT1); | ||
55 | write_reg(gpio_dir & 0xffff0000, CX18_REG_GPIO_DIR2); | ||
56 | write_reg((gpio_dir & 0xffff0000) | ((gpio_val & 0xffff0000) >> 16), | ||
57 | CX18_REG_GPIO_OUT2); | ||
58 | } | ||
59 | |||
47 | void cx18_gpio_init(struct cx18 *cx) | 60 | void cx18_gpio_init(struct cx18 *cx) |
48 | { | 61 | { |
49 | if (cx->card->gpio_init.direction == 0) | 62 | gpio_dir = cx->card->gpio_init.direction; |
63 | gpio_val = cx->card->gpio_init.initial_value; | ||
64 | |||
65 | if (gpio_dir == 0) | ||
50 | return; | 66 | return; |
51 | 67 | ||
52 | CX18_DEBUG_INFO("GPIO initial dir: %08x out: %08x\n", | 68 | gpio_dir |= 1 << cx->card->xceive_pin; |
53 | read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_OUT1)); | 69 | gpio_val |= 1 << cx->card->xceive_pin; |
54 | 70 | ||
55 | /* init output data then direction */ | 71 | CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n", |
56 | write_reg(cx->card->gpio_init.direction << 16, CX18_REG_GPIO_DIR1); | 72 | read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2), |
57 | write_reg(0, CX18_REG_GPIO_DIR2); | 73 | read_reg(CX18_REG_GPIO_OUT1), read_reg(CX18_REG_GPIO_OUT2)); |
58 | write_reg((cx->card->gpio_init.direction << 16) | | 74 | |
59 | cx->card->gpio_init.initial_value, CX18_REG_GPIO_OUT1); | 75 | gpio_write(cx); |
60 | write_reg(0, CX18_REG_GPIO_OUT2); | ||
61 | } | 76 | } |
62 | 77 | ||
63 | /* Xceive tuner reset function */ | 78 | /* Xceive tuner reset function */ |
64 | int cx18_reset_tuner_gpio(void *dev, int cmd, int value) | 79 | int cx18_reset_tuner_gpio(void *dev, int cmd, int value) |
65 | { | 80 | { |
66 | struct i2c_algo_bit_data *algo = dev; | 81 | struct i2c_algo_bit_data *algo = dev; |
67 | struct cx18 *cx = algo->data; | 82 | struct cx18_i2c_algo_callback_data *cb_data = algo->data; |
68 | /* int curdir, curout;*/ | 83 | struct cx18 *cx = cb_data->cx; |
69 | 84 | ||
70 | if (cmd != XC2028_TUNER_RESET) | 85 | if (cmd != XC2028_TUNER_RESET) |
71 | return 0; | 86 | return 0; |
72 | CX18_DEBUG_INFO("Resetting tuner\n"); | 87 | CX18_DEBUG_INFO("Resetting tuner\n"); |
88 | |||
89 | gpio_dir |= 1 << cx->card->xceive_pin; | ||
90 | gpio_val &= ~(1 << cx->card->xceive_pin); | ||
91 | |||
92 | gpio_write(cx); | ||
93 | schedule_timeout_interruptible(msecs_to_jiffies(1)); | ||
94 | |||
95 | gpio_val |= 1 << cx->card->xceive_pin; | ||
96 | gpio_write(cx); | ||
97 | schedule_timeout_interruptible(msecs_to_jiffies(1)); | ||
73 | return 0; | 98 | return 0; |
74 | } | 99 | } |
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c index 18c88d1e4833..4f08a4058d1a 100644 --- a/drivers/media/video/cx18/cx18-i2c.c +++ b/drivers/media/video/cx18/cx18-i2c.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "cx18-cards.h" | 25 | #include "cx18-cards.h" |
26 | #include "cx18-gpio.h" | 26 | #include "cx18-gpio.h" |
27 | #include "cx18-av-core.h" | 27 | #include "cx18-av-core.h" |
28 | #include "cx18-i2c.h" | ||
28 | 29 | ||
29 | #include <media/ir-kbd-i2c.h> | 30 | #include <media/ir-kbd-i2c.h> |
30 | 31 | ||
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c index 65af1bb507ca..6990b77c6200 100644 --- a/drivers/media/video/cx18/cx18-queue.c +++ b/drivers/media/video/cx18/cx18-queue.c | |||
@@ -26,17 +26,6 @@ | |||
26 | #include "cx18-queue.h" | 26 | #include "cx18-queue.h" |
27 | #include "cx18-scb.h" | 27 | #include "cx18-scb.h" |
28 | 28 | ||
29 | int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf, | ||
30 | const char __user *src, int copybytes) | ||
31 | { | ||
32 | if (s->buf_size - buf->bytesused < copybytes) | ||
33 | copybytes = s->buf_size - buf->bytesused; | ||
34 | if (copy_from_user(buf->buf + buf->bytesused, src, copybytes)) | ||
35 | return -EFAULT; | ||
36 | buf->bytesused += copybytes; | ||
37 | return copybytes; | ||
38 | } | ||
39 | |||
40 | void cx18_buf_swap(struct cx18_buffer *buf) | 29 | void cx18_buf_swap(struct cx18_buffer *buf) |
41 | { | 30 | { |
42 | int i; | 31 | int i; |
@@ -159,8 +148,9 @@ static void cx18_queue_move_buf(struct cx18_stream *s, struct cx18_queue *from, | |||
159 | -ENOMEM is returned if the buffers could not be obtained, 0 if all | 148 | -ENOMEM is returned if the buffers could not be obtained, 0 if all |
160 | buffers where obtained from the 'from' list and if non-zero then | 149 | buffers where obtained from the 'from' list and if non-zero then |
161 | the number of stolen buffers is returned. */ | 150 | the number of stolen buffers is returned. */ |
162 | int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, | 151 | static int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, |
163 | struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes) | 152 | struct cx18_queue *steal, struct cx18_queue *to, |
153 | int needed_bytes) | ||
164 | { | 154 | { |
165 | unsigned long flags; | 155 | unsigned long flags; |
166 | int rc = 0; | 156 | int rc = 0; |
@@ -239,12 +229,12 @@ int cx18_stream_alloc(struct cx18_stream *s) | |||
239 | 229 | ||
240 | /* allocate stream buffers. Initially all buffers are in q_free. */ | 230 | /* allocate stream buffers. Initially all buffers are in q_free. */ |
241 | for (i = 0; i < s->buffers; i++) { | 231 | for (i = 0; i < s->buffers; i++) { |
242 | struct cx18_buffer *buf = | 232 | struct cx18_buffer *buf = kzalloc(sizeof(struct cx18_buffer), |
243 | kzalloc(sizeof(struct cx18_buffer), GFP_KERNEL); | 233 | GFP_KERNEL|__GFP_NOWARN); |
244 | 234 | ||
245 | if (buf == NULL) | 235 | if (buf == NULL) |
246 | break; | 236 | break; |
247 | buf->buf = kmalloc(s->buf_size, GFP_KERNEL); | 237 | buf->buf = kmalloc(s->buf_size, GFP_KERNEL|__GFP_NOWARN); |
248 | if (buf->buf == NULL) { | 238 | if (buf->buf == NULL) { |
249 | kfree(buf); | 239 | kfree(buf); |
250 | break; | 240 | break; |
diff --git a/drivers/media/video/cx18/cx18-queue.h b/drivers/media/video/cx18/cx18-queue.h index f86c8a6fa6e7..91423b9863a4 100644 --- a/drivers/media/video/cx18/cx18-queue.h +++ b/drivers/media/video/cx18/cx18-queue.h | |||
@@ -39,8 +39,6 @@ static inline void cx18_buf_sync_for_device(struct cx18_stream *s, | |||
39 | s->buf_size, s->dma); | 39 | s->buf_size, s->dma); |
40 | } | 40 | } |
41 | 41 | ||
42 | int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf, | ||
43 | const char __user *src, int copybytes); | ||
44 | void cx18_buf_swap(struct cx18_buffer *buf); | 42 | void cx18_buf_swap(struct cx18_buffer *buf); |
45 | 43 | ||
46 | /* cx18_queue utility functions */ | 44 | /* cx18_queue utility functions */ |
@@ -48,8 +46,6 @@ void cx18_queue_init(struct cx18_queue *q); | |||
48 | void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, | 46 | void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, |
49 | struct cx18_queue *q); | 47 | struct cx18_queue *q); |
50 | struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); | 48 | struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); |
51 | int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, | ||
52 | struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes); | ||
53 | struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, | 49 | struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, |
54 | u32 bytesused); | 50 | u32 bytesused); |
55 | void cx18_flush_queues(struct cx18_stream *s); | 51 | void cx18_flush_queues(struct cx18_stream *s); |
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index afb141b2027a..4ca9d847f1b1 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c | |||
@@ -218,7 +218,7 @@ int cx18_streams_setup(struct cx18 *cx) | |||
218 | return 0; | 218 | return 0; |
219 | 219 | ||
220 | /* One or more streams could not be initialized. Clean 'em all up. */ | 220 | /* One or more streams could not be initialized. Clean 'em all up. */ |
221 | cx18_streams_cleanup(cx); | 221 | cx18_streams_cleanup(cx, 0); |
222 | return -ENOMEM; | 222 | return -ENOMEM; |
223 | } | 223 | } |
224 | 224 | ||
@@ -296,12 +296,12 @@ int cx18_streams_register(struct cx18 *cx) | |||
296 | return 0; | 296 | return 0; |
297 | 297 | ||
298 | /* One or more streams could not be initialized. Clean 'em all up. */ | 298 | /* One or more streams could not be initialized. Clean 'em all up. */ |
299 | cx18_streams_cleanup(cx); | 299 | cx18_streams_cleanup(cx, 1); |
300 | return -ENOMEM; | 300 | return -ENOMEM; |
301 | } | 301 | } |
302 | 302 | ||
303 | /* Unregister v4l2 devices */ | 303 | /* Unregister v4l2 devices */ |
304 | void cx18_streams_cleanup(struct cx18 *cx) | 304 | void cx18_streams_cleanup(struct cx18 *cx, int unregister) |
305 | { | 305 | { |
306 | struct video_device *vdev; | 306 | struct video_device *vdev; |
307 | int type; | 307 | int type; |
@@ -319,8 +319,11 @@ void cx18_streams_cleanup(struct cx18 *cx) | |||
319 | 319 | ||
320 | cx18_stream_free(&cx->streams[type]); | 320 | cx18_stream_free(&cx->streams[type]); |
321 | 321 | ||
322 | /* Unregister device */ | 322 | /* Unregister or release device */ |
323 | video_unregister_device(vdev); | 323 | if (unregister) |
324 | video_unregister_device(vdev); | ||
325 | else | ||
326 | video_device_release(vdev); | ||
324 | } | 327 | } |
325 | } | 328 | } |
326 | 329 | ||
diff --git a/drivers/media/video/cx18/cx18-streams.h b/drivers/media/video/cx18/cx18-streams.h index 8c7ba7d2fa79..f327e947b24f 100644 --- a/drivers/media/video/cx18/cx18-streams.h +++ b/drivers/media/video/cx18/cx18-streams.h | |||
@@ -24,7 +24,7 @@ | |||
24 | u32 cx18_find_handle(struct cx18 *cx); | 24 | u32 cx18_find_handle(struct cx18 *cx); |
25 | int cx18_streams_setup(struct cx18 *cx); | 25 | int cx18_streams_setup(struct cx18 *cx); |
26 | int cx18_streams_register(struct cx18 *cx); | 26 | int cx18_streams_register(struct cx18 *cx); |
27 | void cx18_streams_cleanup(struct cx18 *cx); | 27 | void cx18_streams_cleanup(struct cx18 *cx, int unregister); |
28 | 28 | ||
29 | /* Capture related */ | 29 | /* Capture related */ |
30 | int cx18_start_v4l2_encode_stream(struct cx18_stream *s); | 30 | int cx18_start_v4l2_encode_stream(struct cx18_stream *s); |
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig index cadf936c3673..7bf14c9a15c7 100644 --- a/drivers/media/video/cx23885/Kconfig +++ b/drivers/media/video/cx23885/Kconfig | |||
@@ -1,18 +1,20 @@ | |||
1 | config VIDEO_CX23885 | 1 | config VIDEO_CX23885 |
2 | tristate "Conexant cx23885 (2388x successor) support" | 2 | tristate "Conexant cx23885 (2388x successor) support" |
3 | depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT | 3 | depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT |
4 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select I2C_ALGOBIT | 5 | select I2C_ALGOBIT |
5 | select FW_LOADER | 6 | select FW_LOADER |
6 | select VIDEO_BTCX | 7 | select VIDEO_BTCX |
7 | select MEDIA_TUNER | 8 | select VIDEO_TUNER |
8 | select VIDEO_TVEEPROM | 9 | select VIDEO_TVEEPROM |
9 | select VIDEO_IR | 10 | select VIDEO_IR |
10 | select VIDEOBUF_DVB | 11 | select VIDEOBUF_DVB |
11 | select VIDEO_CX25840 | 12 | select VIDEO_CX25840 |
13 | select VIDEO_CX2341X | ||
14 | select DVB_DIB7000P if !DVB_FE_CUSTOMISE | ||
12 | select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE | 15 | select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE |
13 | select DVB_S5H1409 if !DVB_FE_CUSTOMISE | 16 | select DVB_S5H1409 if !DVB_FE_CUSTOMISE |
14 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | 17 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE |
15 | select DVB_PLL if !DVB_FE_CUSTOMISE | ||
16 | select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE | 18 | select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE |
17 | select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE | 19 | select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE |
18 | select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE | 20 | select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE |
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c index 6ebf58724a01..20e05f230546 100644 --- a/drivers/media/video/cx23885/cx23885-cards.c +++ b/drivers/media/video/cx23885/cx23885-cards.c | |||
@@ -200,6 +200,10 @@ struct cx23885_subid cx23885_subids[] = { | |||
200 | .card = CX23885_BOARD_HAUPPAUGE_HVR1200, | 200 | .card = CX23885_BOARD_HAUPPAUGE_HVR1200, |
201 | }, { | 201 | }, { |
202 | .subvendor = 0x0070, | 202 | .subvendor = 0x0070, |
203 | .subdevice = 0x71d3, | ||
204 | .card = CX23885_BOARD_HAUPPAUGE_HVR1200, | ||
205 | }, { | ||
206 | .subvendor = 0x0070, | ||
203 | .subdevice = 0x8101, | 207 | .subdevice = 0x8101, |
204 | .card = CX23885_BOARD_HAUPPAUGE_HVR1700, | 208 | .card = CX23885_BOARD_HAUPPAUGE_HVR1700, |
205 | }, { | 209 | }, { |
@@ -245,6 +249,33 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) | |||
245 | /* Make sure we support the board model */ | 249 | /* Make sure we support the board model */ |
246 | switch (tv.model) | 250 | switch (tv.model) |
247 | { | 251 | { |
252 | case 71009: | ||
253 | /* WinTV-HVR1200 (PCIe, Retail, full height) | ||
254 | * DVB-T and basic analog */ | ||
255 | case 71359: | ||
256 | /* WinTV-HVR1200 (PCIe, OEM, half height) | ||
257 | * DVB-T and basic analog */ | ||
258 | case 71439: | ||
259 | /* WinTV-HVR1200 (PCIe, OEM, half height) | ||
260 | * DVB-T and basic analog */ | ||
261 | case 71449: | ||
262 | /* WinTV-HVR1200 (PCIe, OEM, full height) | ||
263 | * DVB-T and basic analog */ | ||
264 | case 71939: | ||
265 | /* WinTV-HVR1200 (PCIe, OEM, half height) | ||
266 | * DVB-T and basic analog */ | ||
267 | case 71949: | ||
268 | /* WinTV-HVR1200 (PCIe, OEM, full height) | ||
269 | * DVB-T and basic analog */ | ||
270 | case 71959: | ||
271 | /* WinTV-HVR1200 (PCIe, OEM, full height) | ||
272 | * DVB-T and basic analog */ | ||
273 | case 71979: | ||
274 | /* WinTV-HVR1200 (PCIe, OEM, half height) | ||
275 | * DVB-T and basic analog */ | ||
276 | case 71999: | ||
277 | /* WinTV-HVR1200 (PCIe, OEM, full height) | ||
278 | * DVB-T and basic analog */ | ||
248 | case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */ | 279 | case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */ |
249 | case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */ | 280 | case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */ |
250 | case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */ | 281 | case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */ |
@@ -263,8 +294,11 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) | |||
263 | case 80019: | 294 | case 80019: |
264 | /* WinTV-HVR1400 (Express Card, Retail, IR, | 295 | /* WinTV-HVR1400 (Express Card, Retail, IR, |
265 | * DVB-T and Basic analog */ | 296 | * DVB-T and Basic analog */ |
297 | case 81509: | ||
298 | /* WinTV-HVR1700 (PCIe, OEM, No IR, half height) | ||
299 | * DVB-T and MPEG2 HW Encoder */ | ||
266 | case 81519: | 300 | case 81519: |
267 | /* WinTV-HVR1700 (PCIe, Retail, No IR, half height, | 301 | /* WinTV-HVR1700 (PCIe, OEM, No IR, full height) |
268 | * DVB-T and MPEG2 HW Encoder */ | 302 | * DVB-T and MPEG2 HW Encoder */ |
269 | break; | 303 | break; |
270 | default: | 304 | default: |
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index f05649727b60..022aa391937a 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include "lgdt330x.h" | 37 | #include "lgdt330x.h" |
38 | #include "xc5000.h" | 38 | #include "xc5000.h" |
39 | #include "tda10048.h" | 39 | #include "tda10048.h" |
40 | #include "dvb-pll.h" | ||
41 | #include "tuner-xc2028.h" | 40 | #include "tuner-xc2028.h" |
42 | #include "tuner-simple.h" | 41 | #include "tuner-simple.h" |
43 | #include "dib7000p.h" | 42 | #include "dib7000p.h" |
@@ -385,12 +384,10 @@ static int dvb_register(struct cx23885_tsport *port) | |||
385 | port->dvb.frontend = dvb_attach(s5h1409_attach, | 384 | port->dvb.frontend = dvb_attach(s5h1409_attach, |
386 | &hauppauge_hvr1500q_config, | 385 | &hauppauge_hvr1500q_config, |
387 | &dev->i2c_bus[0].i2c_adap); | 386 | &dev->i2c_bus[0].i2c_adap); |
388 | if (port->dvb.frontend != NULL) { | 387 | if (port->dvb.frontend != NULL) |
389 | hauppauge_hvr1500q_tunerconfig.priv = i2c_bus; | ||
390 | dvb_attach(xc5000_attach, port->dvb.frontend, | 388 | dvb_attach(xc5000_attach, port->dvb.frontend, |
391 | &i2c_bus->i2c_adap, | 389 | &i2c_bus->i2c_adap, |
392 | &hauppauge_hvr1500q_tunerconfig); | 390 | &hauppauge_hvr1500q_tunerconfig, i2c_bus); |
393 | } | ||
394 | break; | 391 | break; |
395 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 392 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
396 | i2c_bus = &dev->i2c_bus[1]; | 393 | i2c_bus = &dev->i2c_bus[1]; |
diff --git a/drivers/media/video/cx25840/Kconfig b/drivers/media/video/cx25840/Kconfig index 7cf29a03ed63..448f4cd0ce34 100644 --- a/drivers/media/video/cx25840/Kconfig +++ b/drivers/media/video/cx25840/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config VIDEO_CX25840 | 1 | config VIDEO_CX25840 |
2 | tristate "Conexant CX2584x audio/video decoders" | 2 | tristate "Conexant CX2584x audio/video decoders" |
3 | depends on VIDEO_V4L2 && I2C && EXPERIMENTAL | 3 | depends on VIDEO_V4L2 && I2C && EXPERIMENTAL |
4 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select FW_LOADER | 5 | select FW_LOADER |
5 | ---help--- | 6 | ---help--- |
6 | Support for the Conexant CX2584x audio/video decoders. | 7 | Support for the Conexant CX2584x audio/video decoders. |
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig index b0d7d6a7a4cc..10e20d8196dc 100644 --- a/drivers/media/video/cx88/Kconfig +++ b/drivers/media/video/cx88/Kconfig | |||
@@ -2,10 +2,9 @@ config VIDEO_CX88 | |||
2 | tristate "Conexant 2388x (bt878 successor) support" | 2 | tristate "Conexant 2388x (bt878 successor) support" |
3 | depends on VIDEO_DEV && PCI && I2C && INPUT | 3 | depends on VIDEO_DEV && PCI && I2C && INPUT |
4 | select I2C_ALGOBIT | 4 | select I2C_ALGOBIT |
5 | select FW_LOADER | ||
6 | select VIDEO_BTCX | 5 | select VIDEO_BTCX |
7 | select VIDEOBUF_DMA_SG | 6 | select VIDEOBUF_DMA_SG |
8 | select MEDIA_TUNER | 7 | select VIDEO_TUNER |
9 | select VIDEO_TVEEPROM | 8 | select VIDEO_TVEEPROM |
10 | select VIDEO_IR | 9 | select VIDEO_IR |
11 | select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO | 10 | select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO |
@@ -34,8 +33,9 @@ config VIDEO_CX88_ALSA | |||
34 | 33 | ||
35 | config VIDEO_CX88_BLACKBIRD | 34 | config VIDEO_CX88_BLACKBIRD |
36 | tristate "Blackbird MPEG encoder support (cx2388x + cx23416)" | 35 | tristate "Blackbird MPEG encoder support (cx2388x + cx23416)" |
37 | depends on VIDEO_CX88 | 36 | depends on VIDEO_CX88 && HOTPLUG |
38 | select VIDEO_CX2341X | 37 | select VIDEO_CX2341X |
38 | select FW_LOADER | ||
39 | ---help--- | 39 | ---help--- |
40 | This adds support for MPEG encoder cards based on the | 40 | This adds support for MPEG encoder cards based on the |
41 | Blackbird reference design, using the Conexant 2388x | 41 | Blackbird reference design, using the Conexant 2388x |
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 1c7fe6862a60..d96173ff1dba 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c | |||
@@ -509,9 +509,6 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | |||
509 | if (!fe) { | 509 | if (!fe) { |
510 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | 510 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", |
511 | dev->core->name); | 511 | dev->core->name); |
512 | dvb_frontend_detach(dev->dvb.frontend); | ||
513 | dvb_unregister_frontend(dev->dvb.frontend); | ||
514 | dev->dvb.frontend = NULL; | ||
515 | return -EINVAL; | 512 | return -EINVAL; |
516 | } | 513 | } |
517 | 514 | ||
@@ -523,20 +520,23 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | |||
523 | 520 | ||
524 | static int dvb_register(struct cx8802_dev *dev) | 521 | static int dvb_register(struct cx8802_dev *dev) |
525 | { | 522 | { |
523 | struct cx88_core *core = dev->core; | ||
524 | |||
526 | /* init struct videobuf_dvb */ | 525 | /* init struct videobuf_dvb */ |
527 | dev->dvb.name = dev->core->name; | 526 | dev->dvb.name = core->name; |
528 | dev->ts_gen_cntrl = 0x0c; | 527 | dev->ts_gen_cntrl = 0x0c; |
529 | 528 | ||
530 | /* init frontend */ | 529 | /* init frontend */ |
531 | switch (dev->core->boardnr) { | 530 | switch (core->boardnr) { |
532 | case CX88_BOARD_HAUPPAUGE_DVB_T1: | 531 | case CX88_BOARD_HAUPPAUGE_DVB_T1: |
533 | dev->dvb.frontend = dvb_attach(cx22702_attach, | 532 | dev->dvb.frontend = dvb_attach(cx22702_attach, |
534 | &connexant_refboard_config, | 533 | &connexant_refboard_config, |
535 | &dev->core->i2c_adap); | 534 | &core->i2c_adap); |
536 | if (dev->dvb.frontend != NULL) { | 535 | if (dev->dvb.frontend != NULL) { |
537 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 536 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
538 | &dev->core->i2c_adap, | 537 | 0x61, &core->i2c_adap, |
539 | DVB_PLL_THOMSON_DTT759X); | 538 | DVB_PLL_THOMSON_DTT759X)) |
539 | goto frontend_detach; | ||
540 | } | 540 | } |
541 | break; | 541 | break; |
542 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: | 542 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: |
@@ -545,11 +545,12 @@ static int dvb_register(struct cx8802_dev *dev) | |||
545 | case CX88_BOARD_WINFAST_DTV1000: | 545 | case CX88_BOARD_WINFAST_DTV1000: |
546 | dev->dvb.frontend = dvb_attach(cx22702_attach, | 546 | dev->dvb.frontend = dvb_attach(cx22702_attach, |
547 | &connexant_refboard_config, | 547 | &connexant_refboard_config, |
548 | &dev->core->i2c_adap); | 548 | &core->i2c_adap); |
549 | if (dev->dvb.frontend != NULL) { | 549 | if (dev->dvb.frontend != NULL) { |
550 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, | 550 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
551 | &dev->core->i2c_adap, | 551 | 0x60, &core->i2c_adap, |
552 | DVB_PLL_THOMSON_DTT7579); | 552 | DVB_PLL_THOMSON_DTT7579)) |
553 | goto frontend_detach; | ||
553 | } | 554 | } |
554 | break; | 555 | break; |
555 | case CX88_BOARD_WINFAST_DTV2000H: | 556 | case CX88_BOARD_WINFAST_DTV2000H: |
@@ -559,29 +560,32 @@ static int dvb_register(struct cx8802_dev *dev) | |||
559 | case CX88_BOARD_HAUPPAUGE_HVR3000: | 560 | case CX88_BOARD_HAUPPAUGE_HVR3000: |
560 | dev->dvb.frontend = dvb_attach(cx22702_attach, | 561 | dev->dvb.frontend = dvb_attach(cx22702_attach, |
561 | &hauppauge_hvr_config, | 562 | &hauppauge_hvr_config, |
562 | &dev->core->i2c_adap); | 563 | &core->i2c_adap); |
563 | if (dev->dvb.frontend != NULL) { | 564 | if (dev->dvb.frontend != NULL) { |
564 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 565 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
565 | &dev->core->i2c_adap, 0x61, | 566 | &core->i2c_adap, 0x61, |
566 | TUNER_PHILIPS_FMD1216ME_MK3); | 567 | TUNER_PHILIPS_FMD1216ME_MK3)) |
568 | goto frontend_detach; | ||
567 | } | 569 | } |
568 | break; | 570 | break; |
569 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: | 571 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: |
570 | dev->dvb.frontend = dvb_attach(mt352_attach, | 572 | dev->dvb.frontend = dvb_attach(mt352_attach, |
571 | &dvico_fusionhdtv, | 573 | &dvico_fusionhdtv, |
572 | &dev->core->i2c_adap); | 574 | &core->i2c_adap); |
573 | if (dev->dvb.frontend != NULL) { | 575 | if (dev->dvb.frontend != NULL) { |
574 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, | 576 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
575 | NULL, DVB_PLL_THOMSON_DTT7579); | 577 | 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) |
578 | goto frontend_detach; | ||
576 | break; | 579 | break; |
577 | } | 580 | } |
578 | /* ZL10353 replaces MT352 on later cards */ | 581 | /* ZL10353 replaces MT352 on later cards */ |
579 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 582 | dev->dvb.frontend = dvb_attach(zl10353_attach, |
580 | &dvico_fusionhdtv_plus_v1_1, | 583 | &dvico_fusionhdtv_plus_v1_1, |
581 | &dev->core->i2c_adap); | 584 | &core->i2c_adap); |
582 | if (dev->dvb.frontend != NULL) { | 585 | if (dev->dvb.frontend != NULL) { |
583 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, | 586 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
584 | NULL, DVB_PLL_THOMSON_DTT7579); | 587 | 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) |
588 | goto frontend_detach; | ||
585 | } | 589 | } |
586 | break; | 590 | break; |
587 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: | 591 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: |
@@ -589,28 +593,31 @@ static int dvb_register(struct cx8802_dev *dev) | |||
589 | * compatible, with a slightly different MT352 AGC gain. */ | 593 | * compatible, with a slightly different MT352 AGC gain. */ |
590 | dev->dvb.frontend = dvb_attach(mt352_attach, | 594 | dev->dvb.frontend = dvb_attach(mt352_attach, |
591 | &dvico_fusionhdtv_dual, | 595 | &dvico_fusionhdtv_dual, |
592 | &dev->core->i2c_adap); | 596 | &core->i2c_adap); |
593 | if (dev->dvb.frontend != NULL) { | 597 | if (dev->dvb.frontend != NULL) { |
594 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 598 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
595 | NULL, DVB_PLL_THOMSON_DTT7579); | 599 | 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) |
600 | goto frontend_detach; | ||
596 | break; | 601 | break; |
597 | } | 602 | } |
598 | /* ZL10353 replaces MT352 on later cards */ | 603 | /* ZL10353 replaces MT352 on later cards */ |
599 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 604 | dev->dvb.frontend = dvb_attach(zl10353_attach, |
600 | &dvico_fusionhdtv_plus_v1_1, | 605 | &dvico_fusionhdtv_plus_v1_1, |
601 | &dev->core->i2c_adap); | 606 | &core->i2c_adap); |
602 | if (dev->dvb.frontend != NULL) { | 607 | if (dev->dvb.frontend != NULL) { |
603 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 608 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
604 | NULL, DVB_PLL_THOMSON_DTT7579); | 609 | 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) |
610 | goto frontend_detach; | ||
605 | } | 611 | } |
606 | break; | 612 | break; |
607 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: | 613 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: |
608 | dev->dvb.frontend = dvb_attach(mt352_attach, | 614 | dev->dvb.frontend = dvb_attach(mt352_attach, |
609 | &dvico_fusionhdtv, | 615 | &dvico_fusionhdtv, |
610 | &dev->core->i2c_adap); | 616 | &core->i2c_adap); |
611 | if (dev->dvb.frontend != NULL) { | 617 | if (dev->dvb.frontend != NULL) { |
612 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 618 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
613 | NULL, DVB_PLL_LG_Z201); | 619 | 0x61, NULL, DVB_PLL_LG_Z201)) |
620 | goto frontend_detach; | ||
614 | } | 621 | } |
615 | break; | 622 | break; |
616 | case CX88_BOARD_KWORLD_DVB_T: | 623 | case CX88_BOARD_KWORLD_DVB_T: |
@@ -618,10 +625,11 @@ static int dvb_register(struct cx8802_dev *dev) | |||
618 | case CX88_BOARD_ADSTECH_DVB_T_PCI: | 625 | case CX88_BOARD_ADSTECH_DVB_T_PCI: |
619 | dev->dvb.frontend = dvb_attach(mt352_attach, | 626 | dev->dvb.frontend = dvb_attach(mt352_attach, |
620 | &dntv_live_dvbt_config, | 627 | &dntv_live_dvbt_config, |
621 | &dev->core->i2c_adap); | 628 | &core->i2c_adap); |
622 | if (dev->dvb.frontend != NULL) { | 629 | if (dev->dvb.frontend != NULL) { |
623 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 630 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, |
624 | NULL, DVB_PLL_UNKNOWN_1); | 631 | 0x61, NULL, DVB_PLL_UNKNOWN_1)) |
632 | goto frontend_detach; | ||
625 | } | 633 | } |
626 | break; | 634 | break; |
627 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: | 635 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: |
@@ -630,32 +638,35 @@ static int dvb_register(struct cx8802_dev *dev) | |||
630 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, | 638 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, |
631 | &dev->vp3054->adap); | 639 | &dev->vp3054->adap); |
632 | if (dev->dvb.frontend != NULL) { | 640 | if (dev->dvb.frontend != NULL) { |
633 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 641 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
634 | &dev->core->i2c_adap, 0x61, | 642 | &core->i2c_adap, 0x61, |
635 | TUNER_PHILIPS_FMD1216ME_MK3); | 643 | TUNER_PHILIPS_FMD1216ME_MK3)) |
644 | goto frontend_detach; | ||
636 | } | 645 | } |
637 | #else | 646 | #else |
638 | printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name); | 647 | printk(KERN_ERR "%s/2: built without vp3054 support\n", |
648 | core->name); | ||
639 | #endif | 649 | #endif |
640 | break; | 650 | break; |
641 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: | 651 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: |
642 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 652 | dev->dvb.frontend = dvb_attach(zl10353_attach, |
643 | &dvico_fusionhdtv_hybrid, | 653 | &dvico_fusionhdtv_hybrid, |
644 | &dev->core->i2c_adap); | 654 | &core->i2c_adap); |
645 | if (dev->dvb.frontend != NULL) { | 655 | if (dev->dvb.frontend != NULL) { |
646 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 656 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
647 | &dev->core->i2c_adap, 0x61, | 657 | &core->i2c_adap, 0x61, |
648 | TUNER_THOMSON_FE6600); | 658 | TUNER_THOMSON_FE6600)) |
659 | goto frontend_detach; | ||
649 | } | 660 | } |
650 | break; | 661 | break; |
651 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | 662 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: |
652 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 663 | dev->dvb.frontend = dvb_attach(zl10353_attach, |
653 | &dvico_fusionhdtv_xc3028, | 664 | &dvico_fusionhdtv_xc3028, |
654 | &dev->core->i2c_adap); | 665 | &core->i2c_adap); |
655 | if (dev->dvb.frontend == NULL) | 666 | if (dev->dvb.frontend == NULL) |
656 | dev->dvb.frontend = dvb_attach(mt352_attach, | 667 | dev->dvb.frontend = dvb_attach(mt352_attach, |
657 | &dvico_fusionhdtv_mt352_xc3028, | 668 | &dvico_fusionhdtv_mt352_xc3028, |
658 | &dev->core->i2c_adap); | 669 | &core->i2c_adap); |
659 | /* | 670 | /* |
660 | * On this board, the demod provides the I2C bus pullup. | 671 | * On this board, the demod provides the I2C bus pullup. |
661 | * We must not permit gate_ctrl to be performed, or | 672 | * We must not permit gate_ctrl to be performed, or |
@@ -668,19 +679,18 @@ static int dvb_register(struct cx8802_dev *dev) | |||
668 | break; | 679 | break; |
669 | case CX88_BOARD_PCHDTV_HD3000: | 680 | case CX88_BOARD_PCHDTV_HD3000: |
670 | dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, | 681 | dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, |
671 | &dev->core->i2c_adap); | 682 | &core->i2c_adap); |
672 | if (dev->dvb.frontend != NULL) { | 683 | if (dev->dvb.frontend != NULL) { |
673 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 684 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
674 | &dev->core->i2c_adap, 0x61, | 685 | &core->i2c_adap, 0x61, |
675 | TUNER_THOMSON_DTT761X); | 686 | TUNER_THOMSON_DTT761X)) |
687 | goto frontend_detach; | ||
676 | } | 688 | } |
677 | break; | 689 | break; |
678 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: | 690 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: |
679 | dev->ts_gen_cntrl = 0x08; | 691 | dev->ts_gen_cntrl = 0x08; |
680 | { | ||
681 | /* Do a hardware reset of chip before using it. */ | ||
682 | struct cx88_core *core = dev->core; | ||
683 | 692 | ||
693 | /* Do a hardware reset of chip before using it. */ | ||
684 | cx_clear(MO_GP0_IO, 1); | 694 | cx_clear(MO_GP0_IO, 1); |
685 | mdelay(100); | 695 | mdelay(100); |
686 | cx_set(MO_GP0_IO, 1); | 696 | cx_set(MO_GP0_IO, 1); |
@@ -690,139 +700,137 @@ static int dvb_register(struct cx8802_dev *dev) | |||
690 | fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; | 700 | fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; |
691 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 701 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, |
692 | &fusionhdtv_3_gold, | 702 | &fusionhdtv_3_gold, |
693 | &dev->core->i2c_adap); | 703 | &core->i2c_adap); |
694 | if (dev->dvb.frontend != NULL) { | 704 | if (dev->dvb.frontend != NULL) { |
695 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 705 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
696 | &dev->core->i2c_adap, 0x61, | 706 | &core->i2c_adap, 0x61, |
697 | TUNER_MICROTUNE_4042FI5); | 707 | TUNER_MICROTUNE_4042FI5)) |
698 | } | 708 | goto frontend_detach; |
699 | } | 709 | } |
700 | break; | 710 | break; |
701 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: | 711 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: |
702 | dev->ts_gen_cntrl = 0x08; | 712 | dev->ts_gen_cntrl = 0x08; |
703 | { | ||
704 | /* Do a hardware reset of chip before using it. */ | ||
705 | struct cx88_core *core = dev->core; | ||
706 | 713 | ||
714 | /* Do a hardware reset of chip before using it. */ | ||
707 | cx_clear(MO_GP0_IO, 1); | 715 | cx_clear(MO_GP0_IO, 1); |
708 | mdelay(100); | 716 | mdelay(100); |
709 | cx_set(MO_GP0_IO, 9); | 717 | cx_set(MO_GP0_IO, 9); |
710 | mdelay(200); | 718 | mdelay(200); |
711 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 719 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, |
712 | &fusionhdtv_3_gold, | 720 | &fusionhdtv_3_gold, |
713 | &dev->core->i2c_adap); | 721 | &core->i2c_adap); |
714 | if (dev->dvb.frontend != NULL) { | 722 | if (dev->dvb.frontend != NULL) { |
715 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 723 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
716 | &dev->core->i2c_adap, 0x61, | 724 | &core->i2c_adap, 0x61, |
717 | TUNER_THOMSON_DTT761X); | 725 | TUNER_THOMSON_DTT761X)) |
718 | } | 726 | goto frontend_detach; |
719 | } | 727 | } |
720 | break; | 728 | break; |
721 | case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: | 729 | case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: |
722 | dev->ts_gen_cntrl = 0x08; | 730 | dev->ts_gen_cntrl = 0x08; |
723 | { | ||
724 | /* Do a hardware reset of chip before using it. */ | ||
725 | struct cx88_core *core = dev->core; | ||
726 | 731 | ||
732 | /* Do a hardware reset of chip before using it. */ | ||
727 | cx_clear(MO_GP0_IO, 1); | 733 | cx_clear(MO_GP0_IO, 1); |
728 | mdelay(100); | 734 | mdelay(100); |
729 | cx_set(MO_GP0_IO, 1); | 735 | cx_set(MO_GP0_IO, 1); |
730 | mdelay(200); | 736 | mdelay(200); |
731 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 737 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, |
732 | &fusionhdtv_5_gold, | 738 | &fusionhdtv_5_gold, |
733 | &dev->core->i2c_adap); | 739 | &core->i2c_adap); |
734 | if (dev->dvb.frontend != NULL) { | 740 | if (dev->dvb.frontend != NULL) { |
735 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 741 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
736 | &dev->core->i2c_adap, 0x61, | 742 | &core->i2c_adap, 0x61, |
737 | TUNER_LG_TDVS_H06XF); | 743 | TUNER_LG_TDVS_H06XF)) |
738 | dvb_attach(tda9887_attach, dev->dvb.frontend, | 744 | goto frontend_detach; |
739 | &dev->core->i2c_adap, 0x43); | 745 | if (!dvb_attach(tda9887_attach, dev->dvb.frontend, |
740 | } | 746 | &core->i2c_adap, 0x43)) |
747 | goto frontend_detach; | ||
741 | } | 748 | } |
742 | break; | 749 | break; |
743 | case CX88_BOARD_PCHDTV_HD5500: | 750 | case CX88_BOARD_PCHDTV_HD5500: |
744 | dev->ts_gen_cntrl = 0x08; | 751 | dev->ts_gen_cntrl = 0x08; |
745 | { | ||
746 | /* Do a hardware reset of chip before using it. */ | ||
747 | struct cx88_core *core = dev->core; | ||
748 | 752 | ||
753 | /* Do a hardware reset of chip before using it. */ | ||
749 | cx_clear(MO_GP0_IO, 1); | 754 | cx_clear(MO_GP0_IO, 1); |
750 | mdelay(100); | 755 | mdelay(100); |
751 | cx_set(MO_GP0_IO, 1); | 756 | cx_set(MO_GP0_IO, 1); |
752 | mdelay(200); | 757 | mdelay(200); |
753 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 758 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, |
754 | &pchdtv_hd5500, | 759 | &pchdtv_hd5500, |
755 | &dev->core->i2c_adap); | 760 | &core->i2c_adap); |
756 | if (dev->dvb.frontend != NULL) { | 761 | if (dev->dvb.frontend != NULL) { |
757 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 762 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
758 | &dev->core->i2c_adap, 0x61, | 763 | &core->i2c_adap, 0x61, |
759 | TUNER_LG_TDVS_H06XF); | 764 | TUNER_LG_TDVS_H06XF)) |
760 | dvb_attach(tda9887_attach, dev->dvb.frontend, | 765 | goto frontend_detach; |
761 | &dev->core->i2c_adap, 0x43); | 766 | if (!dvb_attach(tda9887_attach, dev->dvb.frontend, |
762 | } | 767 | &core->i2c_adap, 0x43)) |
768 | goto frontend_detach; | ||
763 | } | 769 | } |
764 | break; | 770 | break; |
765 | case CX88_BOARD_ATI_HDTVWONDER: | 771 | case CX88_BOARD_ATI_HDTVWONDER: |
766 | dev->dvb.frontend = dvb_attach(nxt200x_attach, | 772 | dev->dvb.frontend = dvb_attach(nxt200x_attach, |
767 | &ati_hdtvwonder, | 773 | &ati_hdtvwonder, |
768 | &dev->core->i2c_adap); | 774 | &core->i2c_adap); |
769 | if (dev->dvb.frontend != NULL) { | 775 | if (dev->dvb.frontend != NULL) { |
770 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 776 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
771 | &dev->core->i2c_adap, 0x61, | 777 | &core->i2c_adap, 0x61, |
772 | TUNER_PHILIPS_TUV1236D); | 778 | TUNER_PHILIPS_TUV1236D)) |
779 | goto frontend_detach; | ||
773 | } | 780 | } |
774 | break; | 781 | break; |
775 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: | 782 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: |
776 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: | 783 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: |
777 | dev->dvb.frontend = dvb_attach(cx24123_attach, | 784 | dev->dvb.frontend = dvb_attach(cx24123_attach, |
778 | &hauppauge_novas_config, | 785 | &hauppauge_novas_config, |
779 | &dev->core->i2c_adap); | 786 | &core->i2c_adap); |
780 | if (dev->dvb.frontend) { | 787 | if (dev->dvb.frontend) { |
781 | dvb_attach(isl6421_attach, dev->dvb.frontend, | 788 | if (!dvb_attach(isl6421_attach, dev->dvb.frontend, |
782 | &dev->core->i2c_adap, 0x08, 0x00, 0x00); | 789 | &core->i2c_adap, 0x08, 0x00, 0x00)) |
790 | goto frontend_detach; | ||
783 | } | 791 | } |
784 | break; | 792 | break; |
785 | case CX88_BOARD_KWORLD_DVBS_100: | 793 | case CX88_BOARD_KWORLD_DVBS_100: |
786 | dev->dvb.frontend = dvb_attach(cx24123_attach, | 794 | dev->dvb.frontend = dvb_attach(cx24123_attach, |
787 | &kworld_dvbs_100_config, | 795 | &kworld_dvbs_100_config, |
788 | &dev->core->i2c_adap); | 796 | &core->i2c_adap); |
789 | if (dev->dvb.frontend) { | 797 | if (dev->dvb.frontend) { |
790 | dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 798 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; |
791 | dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; | 799 | dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; |
792 | } | 800 | } |
793 | break; | 801 | break; |
794 | case CX88_BOARD_GENIATECH_DVBS: | 802 | case CX88_BOARD_GENIATECH_DVBS: |
795 | dev->dvb.frontend = dvb_attach(cx24123_attach, | 803 | dev->dvb.frontend = dvb_attach(cx24123_attach, |
796 | &geniatech_dvbs_config, | 804 | &geniatech_dvbs_config, |
797 | &dev->core->i2c_adap); | 805 | &core->i2c_adap); |
798 | if (dev->dvb.frontend) { | 806 | if (dev->dvb.frontend) { |
799 | dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 807 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; |
800 | dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; | 808 | dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; |
801 | } | 809 | } |
802 | break; | 810 | break; |
803 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: | 811 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: |
804 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | 812 | dev->dvb.frontend = dvb_attach(s5h1409_attach, |
805 | &pinnacle_pctv_hd_800i_config, | 813 | &pinnacle_pctv_hd_800i_config, |
806 | &dev->core->i2c_adap); | 814 | &core->i2c_adap); |
807 | if (dev->dvb.frontend != NULL) { | 815 | if (dev->dvb.frontend != NULL) { |
808 | /* tuner_config.video_dev must point to | 816 | /* tuner_config.video_dev must point to |
809 | * i2c_adap.algo_data | 817 | * i2c_adap.algo_data |
810 | */ | 818 | */ |
811 | pinnacle_pctv_hd_800i_tuner_config.priv = | 819 | if (!dvb_attach(xc5000_attach, dev->dvb.frontend, |
812 | dev->core->i2c_adap.algo_data; | 820 | &core->i2c_adap, |
813 | dvb_attach(xc5000_attach, dev->dvb.frontend, | 821 | &pinnacle_pctv_hd_800i_tuner_config, |
814 | &dev->core->i2c_adap, | 822 | core->i2c_adap.algo_data)) |
815 | &pinnacle_pctv_hd_800i_tuner_config); | 823 | goto frontend_detach; |
816 | } | 824 | } |
817 | break; | 825 | break; |
818 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | 826 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: |
819 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | 827 | dev->dvb.frontend = dvb_attach(s5h1409_attach, |
820 | &dvico_hdtv5_pci_nano_config, | 828 | &dvico_hdtv5_pci_nano_config, |
821 | &dev->core->i2c_adap); | 829 | &core->i2c_adap); |
822 | if (dev->dvb.frontend != NULL) { | 830 | if (dev->dvb.frontend != NULL) { |
823 | struct dvb_frontend *fe; | 831 | struct dvb_frontend *fe; |
824 | struct xc2028_config cfg = { | 832 | struct xc2028_config cfg = { |
825 | .i2c_adap = &dev->core->i2c_adap, | 833 | .i2c_adap = &core->i2c_adap, |
826 | .i2c_addr = 0x61, | 834 | .i2c_addr = 0x61, |
827 | .callback = cx88_pci_nano_callback, | 835 | .callback = cx88_pci_nano_callback, |
828 | }; | 836 | }; |
@@ -841,50 +849,50 @@ static int dvb_register(struct cx8802_dev *dev) | |||
841 | case CX88_BOARD_PINNACLE_HYBRID_PCTV: | 849 | case CX88_BOARD_PINNACLE_HYBRID_PCTV: |
842 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 850 | dev->dvb.frontend = dvb_attach(zl10353_attach, |
843 | &cx88_geniatech_x8000_mt, | 851 | &cx88_geniatech_x8000_mt, |
844 | &dev->core->i2c_adap); | 852 | &core->i2c_adap); |
845 | if (attach_xc3028(0x61, dev) < 0) | 853 | if (attach_xc3028(0x61, dev) < 0) |
846 | return -EINVAL; | 854 | goto frontend_detach; |
847 | break; | 855 | break; |
848 | case CX88_BOARD_GENIATECH_X8000_MT: | 856 | case CX88_BOARD_GENIATECH_X8000_MT: |
849 | dev->ts_gen_cntrl = 0x00; | 857 | dev->ts_gen_cntrl = 0x00; |
850 | 858 | ||
851 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 859 | dev->dvb.frontend = dvb_attach(zl10353_attach, |
852 | &cx88_geniatech_x8000_mt, | 860 | &cx88_geniatech_x8000_mt, |
853 | &dev->core->i2c_adap); | 861 | &core->i2c_adap); |
854 | if (attach_xc3028(0x61, dev) < 0) | 862 | if (attach_xc3028(0x61, dev) < 0) |
855 | return -EINVAL; | 863 | goto frontend_detach; |
856 | break; | 864 | break; |
857 | case CX88_BOARD_KWORLD_ATSC_120: | 865 | case CX88_BOARD_KWORLD_ATSC_120: |
858 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | 866 | dev->dvb.frontend = dvb_attach(s5h1409_attach, |
859 | &kworld_atsc_120_config, | 867 | &kworld_atsc_120_config, |
860 | &dev->core->i2c_adap); | 868 | &core->i2c_adap); |
861 | if (attach_xc3028(0x61, dev) < 0) | 869 | if (attach_xc3028(0x61, dev) < 0) |
862 | return -EINVAL; | 870 | goto frontend_detach; |
863 | break; | 871 | break; |
864 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: | 872 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: |
865 | dev->dvb.frontend = dvb_attach(s5h1411_attach, | 873 | dev->dvb.frontend = dvb_attach(s5h1411_attach, |
866 | &dvico_fusionhdtv7_config, | 874 | &dvico_fusionhdtv7_config, |
867 | &dev->core->i2c_adap); | 875 | &core->i2c_adap); |
868 | if (dev->dvb.frontend != NULL) { | 876 | if (dev->dvb.frontend != NULL) { |
869 | /* tuner_config.video_dev must point to | 877 | /* tuner_config.video_dev must point to |
870 | * i2c_adap.algo_data | 878 | * i2c_adap.algo_data |
871 | */ | 879 | */ |
872 | dvico_fusionhdtv7_tuner_config.priv = | 880 | if (!dvb_attach(xc5000_attach, dev->dvb.frontend, |
873 | dev->core->i2c_adap.algo_data; | 881 | &core->i2c_adap, |
874 | dvb_attach(xc5000_attach, dev->dvb.frontend, | 882 | &dvico_fusionhdtv7_tuner_config, |
875 | &dev->core->i2c_adap, | 883 | core->i2c_adap.algo_data)) |
876 | &dvico_fusionhdtv7_tuner_config); | 884 | goto frontend_detach; |
877 | } | 885 | } |
878 | break; | 886 | break; |
879 | default: | 887 | default: |
880 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", | 888 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", |
881 | dev->core->name); | 889 | core->name); |
882 | break; | 890 | break; |
883 | } | 891 | } |
884 | if (NULL == dev->dvb.frontend) { | 892 | if (NULL == dev->dvb.frontend) { |
885 | printk(KERN_ERR | 893 | printk(KERN_ERR |
886 | "%s/2: frontend initialization failed\n", | 894 | "%s/2: frontend initialization failed\n", |
887 | dev->core->name); | 895 | core->name); |
888 | return -EINVAL; | 896 | return -EINVAL; |
889 | } | 897 | } |
890 | 898 | ||
@@ -892,11 +900,18 @@ static int dvb_register(struct cx8802_dev *dev) | |||
892 | dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; | 900 | dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; |
893 | 901 | ||
894 | /* Put the analog decoder in standby to keep it quiet */ | 902 | /* Put the analog decoder in standby to keep it quiet */ |
895 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); | 903 | cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL); |
896 | 904 | ||
897 | /* register everything */ | 905 | /* register everything */ |
898 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, | 906 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, |
899 | &dev->pci->dev, adapter_nr); | 907 | &dev->pci->dev, adapter_nr); |
908 | |||
909 | frontend_detach: | ||
910 | if (dev->dvb.frontend) { | ||
911 | dvb_frontend_detach(dev->dvb.frontend); | ||
912 | dev->dvb.frontend = NULL; | ||
913 | } | ||
914 | return -EINVAL; | ||
900 | } | 915 | } |
901 | 916 | ||
902 | /* ----------------------------------------------------------- */ | 917 | /* ----------------------------------------------------------- */ |
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig index c7c2896bbd8b..16a5af30e9d1 100644 --- a/drivers/media/video/em28xx/Kconfig +++ b/drivers/media/video/em28xx/Kconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | config VIDEO_EM28XX | 1 | config VIDEO_EM28XX |
2 | tristate "Empia EM28xx USB video capture support" | 2 | tristate "Empia EM28xx USB video capture support" |
3 | depends on VIDEO_DEV && I2C && INPUT | 3 | depends on VIDEO_DEV && I2C && INPUT |
4 | select MEDIA_TUNER | 4 | select VIDEO_TUNER |
5 | select VIDEO_TVEEPROM | 5 | select VIDEO_TVEEPROM |
6 | select VIDEO_IR | 6 | select VIDEO_IR |
7 | select VIDEOBUF_VMALLOC | 7 | select VIDEOBUF_VMALLOC |
@@ -35,7 +35,6 @@ config VIDEO_EM28XX_DVB | |||
35 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | 35 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE |
36 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE | 36 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE |
37 | select VIDEOBUF_DVB | 37 | select VIDEOBUF_DVB |
38 | select FW_LOADER | ||
39 | ---help--- | 38 | ---help--- |
40 | This adds support for DVB cards based on the | 39 | This adds support for DVB cards based on the |
41 | Empiatech em28xx chips. | 40 | Empiatech em28xx chips. |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 50ccf3771204..3e4f3c7e92e7 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -420,7 +420,13 @@ struct usb_device_id em28xx_id_table [] = { | |||
420 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, | 420 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, |
421 | { USB_DEVICE(0x2040, 0x6502), | 421 | { USB_DEVICE(0x2040, 0x6502), |
422 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, | 422 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, |
423 | { USB_DEVICE(0x2040, 0x6513), | 423 | { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */ |
424 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, | ||
425 | { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */ | ||
426 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, | ||
427 | { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */ | ||
428 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, | ||
429 | { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */ | ||
424 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, | 430 | .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, |
425 | { USB_DEVICE(0x0ccd, 0x0042), | 431 | { USB_DEVICE(0x0ccd, 0x0042), |
426 | .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS }, | 432 | .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS }, |
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c index 7df81575b7f2..8cf4983f0039 100644 --- a/drivers/media/video/em28xx/em28xx-dvb.c +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
@@ -251,7 +251,6 @@ static int attach_xc3028(u8 addr, struct em28xx *dev) | |||
251 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | 251 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", |
252 | dev->name); | 252 | dev->name); |
253 | dvb_frontend_detach(dev->dvb->frontend); | 253 | dvb_frontend_detach(dev->dvb->frontend); |
254 | dvb_unregister_frontend(dev->dvb->frontend); | ||
255 | dev->dvb->frontend = NULL; | 254 | dev->dvb->frontend = NULL; |
256 | return -EINVAL; | 255 | return -EINVAL; |
257 | } | 256 | } |
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig index eec115bf9517..5d7ee8fcdd50 100644 --- a/drivers/media/video/ivtv/Kconfig +++ b/drivers/media/video/ivtv/Kconfig | |||
@@ -1,10 +1,12 @@ | |||
1 | config VIDEO_IVTV | 1 | config VIDEO_IVTV |
2 | tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" | 2 | tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" |
3 | depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL | 3 | depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL |
4 | depends on INPUT # due to VIDEO_IR | ||
5 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select I2C_ALGOBIT | 6 | select I2C_ALGOBIT |
5 | select FW_LOADER | 7 | select FW_LOADER |
6 | select VIDEO_IR | 8 | select VIDEO_IR |
7 | select MEDIA_TUNER | 9 | select VIDEO_TUNER |
8 | select VIDEO_TVEEPROM | 10 | select VIDEO_TVEEPROM |
9 | select VIDEO_CX2341X | 11 | select VIDEO_CX2341X |
10 | select VIDEO_CX25840 | 12 | select VIDEO_CX25840 |
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c index 8c02fa661591..c7e449f6397b 100644 --- a/drivers/media/video/ivtv/ivtv-controls.c +++ b/drivers/media/video/ivtv/ivtv-controls.c | |||
@@ -181,12 +181,12 @@ static int ivtv_setup_vbi_fmt(struct ivtv *itv, enum v4l2_mpeg_stream_vbi_fmt fm | |||
181 | return 0; | 181 | return 0; |
182 | } | 182 | } |
183 | /* Need sliced data for mpeg insertion */ | 183 | /* Need sliced data for mpeg insertion */ |
184 | if (get_service_set(itv->vbi.sliced_in) == 0) { | 184 | if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) { |
185 | if (itv->is_60hz) | 185 | if (itv->is_60hz) |
186 | itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; | 186 | itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; |
187 | else | 187 | else |
188 | itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; | 188 | itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; |
189 | expand_service_set(itv->vbi.sliced_in, itv->is_50hz); | 189 | ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz); |
190 | } | 190 | } |
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index ed020f722b05..797e636771da 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -853,6 +853,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev, | |||
853 | return 0; | 853 | return 0; |
854 | } | 854 | } |
855 | 855 | ||
856 | #ifdef MODULE | ||
856 | static u32 ivtv_request_module(struct ivtv *itv, u32 hw, | 857 | static u32 ivtv_request_module(struct ivtv *itv, u32 hw, |
857 | const char *name, u32 id) | 858 | const char *name, u32 id) |
858 | { | 859 | { |
@@ -865,12 +866,14 @@ static u32 ivtv_request_module(struct ivtv *itv, u32 hw, | |||
865 | IVTV_DEBUG_INFO("Loaded module %s\n", name); | 866 | IVTV_DEBUG_INFO("Loaded module %s\n", name); |
866 | return hw; | 867 | return hw; |
867 | } | 868 | } |
869 | #endif | ||
868 | 870 | ||
869 | static void ivtv_load_and_init_modules(struct ivtv *itv) | 871 | static void ivtv_load_and_init_modules(struct ivtv *itv) |
870 | { | 872 | { |
871 | u32 hw = itv->card->hw_all; | 873 | u32 hw = itv->card->hw_all; |
872 | unsigned i; | 874 | unsigned i; |
873 | 875 | ||
876 | #ifdef MODULE | ||
874 | /* load modules */ | 877 | /* load modules */ |
875 | #ifndef CONFIG_MEDIA_TUNER | 878 | #ifndef CONFIG_MEDIA_TUNER |
876 | hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); | 879 | hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); |
@@ -911,6 +914,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
911 | #ifndef CONFIG_VIDEO_M52790 | 914 | #ifndef CONFIG_VIDEO_M52790 |
912 | hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790); | 915 | hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790); |
913 | #endif | 916 | #endif |
917 | #endif | ||
914 | 918 | ||
915 | /* check which i2c devices are actually found */ | 919 | /* check which i2c devices are actually found */ |
916 | for (i = 0; i < 32; i++) { | 920 | for (i = 0; i < 32; i++) { |
@@ -1228,7 +1232,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1228 | return 0; | 1232 | return 0; |
1229 | 1233 | ||
1230 | free_streams: | 1234 | free_streams: |
1231 | ivtv_streams_cleanup(itv); | 1235 | ivtv_streams_cleanup(itv, 1); |
1232 | free_irq: | 1236 | free_irq: |
1233 | free_irq(itv->dev->irq, (void *)itv); | 1237 | free_irq(itv->dev->irq, (void *)itv); |
1234 | free_i2c: | 1238 | free_i2c: |
@@ -1373,7 +1377,7 @@ static void ivtv_remove(struct pci_dev *pci_dev) | |||
1373 | flush_workqueue(itv->irq_work_queues); | 1377 | flush_workqueue(itv->irq_work_queues); |
1374 | destroy_workqueue(itv->irq_work_queues); | 1378 | destroy_workqueue(itv->irq_work_queues); |
1375 | 1379 | ||
1376 | ivtv_streams_cleanup(itv); | 1380 | ivtv_streams_cleanup(itv, 1); |
1377 | ivtv_udma_free(itv); | 1381 | ivtv_udma_free(itv); |
1378 | 1382 | ||
1379 | exit_ivtv_i2c(itv); | 1383 | exit_ivtv_i2c(itv); |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 2b74b0ab1477..f2fa434b677b 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -987,6 +987,8 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp) | |||
987 | /* Find which card this open was on */ | 987 | /* Find which card this open was on */ |
988 | spin_lock(&ivtv_cards_lock); | 988 | spin_lock(&ivtv_cards_lock); |
989 | for (x = 0; itv == NULL && x < ivtv_cards_active; x++) { | 989 | for (x = 0; itv == NULL && x < ivtv_cards_active; x++) { |
990 | if (ivtv_cards[x] == NULL) | ||
991 | continue; | ||
990 | /* find out which stream this open was on */ | 992 | /* find out which stream this open was on */ |
991 | for (y = 0; y < IVTV_MAX_STREAMS; y++) { | 993 | for (y = 0; y < IVTV_MAX_STREAMS; y++) { |
992 | s = &ivtv_cards[x]->streams[y]; | 994 | s = &ivtv_cards[x]->streams[y]; |
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index d508b5d0538c..26cc0f6699fd 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/dvb/audio.h> | 38 | #include <linux/dvb/audio.h> |
39 | #include <linux/i2c-id.h> | 39 | #include <linux/i2c-id.h> |
40 | 40 | ||
41 | u16 service2vbi(int type) | 41 | u16 ivtv_service2vbi(int type) |
42 | { | 42 | { |
43 | switch (type) { | 43 | switch (type) { |
44 | case V4L2_SLICED_TELETEXT_B: | 44 | case V4L2_SLICED_TELETEXT_B: |
@@ -88,7 +88,7 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal) | |||
88 | return 0; | 88 | return 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) | 91 | void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) |
92 | { | 92 | { |
93 | u16 set = fmt->service_set; | 93 | u16 set = fmt->service_set; |
94 | int f, l; | 94 | int f, l; |
@@ -115,7 +115,7 @@ static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) | |||
115 | return set != 0; | 115 | return set != 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | u16 get_service_set(struct v4l2_sliced_vbi_format *fmt) | 118 | u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt) |
119 | { | 119 | { |
120 | int f, l; | 120 | int f, l; |
121 | u16 set = 0; | 121 | u16 set = 0; |
@@ -466,7 +466,7 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm | |||
466 | vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625; | 466 | vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625; |
467 | vbifmt->service_lines[0][16] = V4L2_SLICED_VPS; | 467 | vbifmt->service_lines[0][16] = V4L2_SLICED_VPS; |
468 | } | 468 | } |
469 | vbifmt->service_set = get_service_set(vbifmt); | 469 | vbifmt->service_set = ivtv_get_service_set(vbifmt); |
470 | break; | 470 | break; |
471 | } | 471 | } |
472 | 472 | ||
@@ -481,12 +481,12 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm | |||
481 | if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) { | 481 | if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) { |
482 | vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 : | 482 | vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 : |
483 | V4L2_SLICED_VBI_525; | 483 | V4L2_SLICED_VBI_525; |
484 | expand_service_set(vbifmt, itv->is_50hz); | 484 | ivtv_expand_service_set(vbifmt, itv->is_50hz); |
485 | break; | 485 | break; |
486 | } | 486 | } |
487 | 487 | ||
488 | itv->video_dec_func(itv, VIDIOC_G_FMT, fmt); | 488 | itv->video_dec_func(itv, VIDIOC_G_FMT, fmt); |
489 | vbifmt->service_set = get_service_set(vbifmt); | 489 | vbifmt->service_set = ivtv_get_service_set(vbifmt); |
490 | break; | 490 | break; |
491 | } | 491 | } |
492 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 492 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
@@ -640,9 +640,9 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype, | |||
640 | memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); | 640 | memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); |
641 | 641 | ||
642 | if (vbifmt->service_set) | 642 | if (vbifmt->service_set) |
643 | expand_service_set(vbifmt, itv->is_50hz); | 643 | ivtv_expand_service_set(vbifmt, itv->is_50hz); |
644 | set = check_service_set(vbifmt, itv->is_50hz); | 644 | set = check_service_set(vbifmt, itv->is_50hz); |
645 | vbifmt->service_set = get_service_set(vbifmt); | 645 | vbifmt->service_set = ivtv_get_service_set(vbifmt); |
646 | 646 | ||
647 | if (!set_fmt) | 647 | if (!set_fmt) |
648 | return 0; | 648 | return 0; |
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.h b/drivers/media/video/ivtv/ivtv-ioctl.h index a03351b6853d..4e67f0ed1fc0 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.h +++ b/drivers/media/video/ivtv/ivtv-ioctl.h | |||
@@ -21,9 +21,9 @@ | |||
21 | #ifndef IVTV_IOCTL_H | 21 | #ifndef IVTV_IOCTL_H |
22 | #define IVTV_IOCTL_H | 22 | #define IVTV_IOCTL_H |
23 | 23 | ||
24 | u16 service2vbi(int type); | 24 | u16 ivtv_service2vbi(int type); |
25 | void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); | 25 | void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); |
26 | u16 get_service_set(struct v4l2_sliced_vbi_format *fmt); | 26 | u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt); |
27 | int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 27 | int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, |
28 | unsigned long arg); | 28 | unsigned long arg); |
29 | int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg); | 29 | int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg); |
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c index 3e1deec67a5e..fc8b1eaa333b 100644 --- a/drivers/media/video/ivtv/ivtv-queue.c +++ b/drivers/media/video/ivtv/ivtv-queue.c | |||
@@ -203,14 +203,14 @@ int ivtv_stream_alloc(struct ivtv_stream *s) | |||
203 | s->dma != PCI_DMA_NONE ? "DMA " : "", | 203 | s->dma != PCI_DMA_NONE ? "DMA " : "", |
204 | s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); | 204 | s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); |
205 | 205 | ||
206 | s->sg_pending = kzalloc(SGsize, GFP_KERNEL); | 206 | s->sg_pending = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN); |
207 | if (s->sg_pending == NULL) { | 207 | if (s->sg_pending == NULL) { |
208 | IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name); | 208 | IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name); |
209 | return -ENOMEM; | 209 | return -ENOMEM; |
210 | } | 210 | } |
211 | s->sg_pending_size = 0; | 211 | s->sg_pending_size = 0; |
212 | 212 | ||
213 | s->sg_processing = kzalloc(SGsize, GFP_KERNEL); | 213 | s->sg_processing = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN); |
214 | if (s->sg_processing == NULL) { | 214 | if (s->sg_processing == NULL) { |
215 | IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name); | 215 | IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name); |
216 | kfree(s->sg_pending); | 216 | kfree(s->sg_pending); |
@@ -219,7 +219,8 @@ int ivtv_stream_alloc(struct ivtv_stream *s) | |||
219 | } | 219 | } |
220 | s->sg_processing_size = 0; | 220 | s->sg_processing_size = 0; |
221 | 221 | ||
222 | s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element), GFP_KERNEL); | 222 | s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element), |
223 | GFP_KERNEL|__GFP_NOWARN); | ||
223 | if (s->sg_dma == NULL) { | 224 | if (s->sg_dma == NULL) { |
224 | IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name); | 225 | IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name); |
225 | kfree(s->sg_pending); | 226 | kfree(s->sg_pending); |
@@ -235,11 +236,12 @@ int ivtv_stream_alloc(struct ivtv_stream *s) | |||
235 | 236 | ||
236 | /* allocate stream buffers. Initially all buffers are in q_free. */ | 237 | /* allocate stream buffers. Initially all buffers are in q_free. */ |
237 | for (i = 0; i < s->buffers; i++) { | 238 | for (i = 0; i < s->buffers; i++) { |
238 | struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer), GFP_KERNEL); | 239 | struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer), |
240 | GFP_KERNEL|__GFP_NOWARN); | ||
239 | 241 | ||
240 | if (buf == NULL) | 242 | if (buf == NULL) |
241 | break; | 243 | break; |
242 | buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL); | 244 | buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL|__GFP_NOWARN); |
243 | if (buf->buf == NULL) { | 245 | if (buf->buf == NULL) { |
244 | kfree(buf); | 246 | kfree(buf); |
245 | break; | 247 | break; |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 4ab8d36831ba..c47c2b945147 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -244,7 +244,7 @@ int ivtv_streams_setup(struct ivtv *itv) | |||
244 | return 0; | 244 | return 0; |
245 | 245 | ||
246 | /* One or more streams could not be initialized. Clean 'em all up. */ | 246 | /* One or more streams could not be initialized. Clean 'em all up. */ |
247 | ivtv_streams_cleanup(itv); | 247 | ivtv_streams_cleanup(itv, 0); |
248 | return -ENOMEM; | 248 | return -ENOMEM; |
249 | } | 249 | } |
250 | 250 | ||
@@ -304,12 +304,12 @@ int ivtv_streams_register(struct ivtv *itv) | |||
304 | return 0; | 304 | return 0; |
305 | 305 | ||
306 | /* One or more streams could not be initialized. Clean 'em all up. */ | 306 | /* One or more streams could not be initialized. Clean 'em all up. */ |
307 | ivtv_streams_cleanup(itv); | 307 | ivtv_streams_cleanup(itv, 1); |
308 | return -ENOMEM; | 308 | return -ENOMEM; |
309 | } | 309 | } |
310 | 310 | ||
311 | /* Unregister v4l2 devices */ | 311 | /* Unregister v4l2 devices */ |
312 | void ivtv_streams_cleanup(struct ivtv *itv) | 312 | void ivtv_streams_cleanup(struct ivtv *itv, int unregister) |
313 | { | 313 | { |
314 | int type; | 314 | int type; |
315 | 315 | ||
@@ -322,8 +322,11 @@ void ivtv_streams_cleanup(struct ivtv *itv) | |||
322 | continue; | 322 | continue; |
323 | 323 | ||
324 | ivtv_stream_free(&itv->streams[type]); | 324 | ivtv_stream_free(&itv->streams[type]); |
325 | /* Unregister device */ | 325 | /* Unregister or release device */ |
326 | video_unregister_device(vdev); | 326 | if (unregister) |
327 | video_unregister_device(vdev); | ||
328 | else | ||
329 | video_device_release(vdev); | ||
327 | } | 330 | } |
328 | } | 331 | } |
329 | 332 | ||
diff --git a/drivers/media/video/ivtv/ivtv-streams.h b/drivers/media/video/ivtv/ivtv-streams.h index 3d76a415fbd8..a653a5136417 100644 --- a/drivers/media/video/ivtv/ivtv-streams.h +++ b/drivers/media/video/ivtv/ivtv-streams.h | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | int ivtv_streams_setup(struct ivtv *itv); | 24 | int ivtv_streams_setup(struct ivtv *itv); |
25 | int ivtv_streams_register(struct ivtv *itv); | 25 | int ivtv_streams_register(struct ivtv *itv); |
26 | void ivtv_streams_cleanup(struct ivtv *itv); | 26 | void ivtv_streams_cleanup(struct ivtv *itv, int unregister); |
27 | 27 | ||
28 | /* Capture related */ | 28 | /* Capture related */ |
29 | int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s); | 29 | int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s); |
diff --git a/drivers/media/video/ivtv/ivtv-vbi.c b/drivers/media/video/ivtv/ivtv-vbi.c index c151bcf5519a..71798f0da27f 100644 --- a/drivers/media/video/ivtv/ivtv-vbi.c +++ b/drivers/media/video/ivtv/ivtv-vbi.c | |||
@@ -169,7 +169,8 @@ static void copy_vbi_data(struct ivtv *itv, int lines, u32 pts_stamp) | |||
169 | linemask[0] |= (1 << l); | 169 | linemask[0] |= (1 << l); |
170 | else | 170 | else |
171 | linemask[1] |= (1 << (l - 32)); | 171 | linemask[1] |= (1 << (l - 32)); |
172 | dst[sd + 12 + line * 43] = service2vbi(itv->vbi.sliced_data[i].id); | 172 | dst[sd + 12 + line * 43] = |
173 | ivtv_service2vbi(itv->vbi.sliced_data[i].id); | ||
173 | memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42); | 174 | memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42); |
174 | line++; | 175 | line++; |
175 | } | 176 | } |
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c index 62f70bd5e3cb..a9417f6e4087 100644 --- a/drivers/media/video/ivtv/ivtv-yuv.c +++ b/drivers/media/video/ivtv/ivtv-yuv.c | |||
@@ -908,7 +908,7 @@ static void ivtv_yuv_init(struct ivtv *itv) | |||
908 | } | 908 | } |
909 | 909 | ||
910 | /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ | 910 | /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ |
911 | yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL); | 911 | yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL|__GFP_NOWARN); |
912 | if (yi->blanking_ptr) { | 912 | if (yi->blanking_ptr) { |
913 | yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE); | 913 | yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE); |
914 | } else { | 914 | } else { |
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c index df789f683e63..73be154f7f05 100644 --- a/drivers/media/video/ivtv/ivtvfb.c +++ b/drivers/media/video/ivtv/ivtvfb.c | |||
@@ -948,7 +948,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv) | |||
948 | } | 948 | } |
949 | 949 | ||
950 | /* Allocate the pseudo palette */ | 950 | /* Allocate the pseudo palette */ |
951 | oi->ivtvfb_info.pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); | 951 | oi->ivtvfb_info.pseudo_palette = |
952 | kmalloc(sizeof(u32) * 16, GFP_KERNEL|__GFP_NOWARN); | ||
952 | 953 | ||
953 | if (!oi->ivtvfb_info.pseudo_palette) { | 954 | if (!oi->ivtvfb_info.pseudo_palette) { |
954 | IVTVFB_ERR("abort, unable to alloc pseudo pallete\n"); | 955 | IVTVFB_ERR("abort, unable to alloc pseudo pallete\n"); |
@@ -1056,7 +1057,8 @@ static int ivtvfb_init_card(struct ivtv *itv) | |||
1056 | return -EBUSY; | 1057 | return -EBUSY; |
1057 | } | 1058 | } |
1058 | 1059 | ||
1059 | itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC); | 1060 | itv->osd_info = kzalloc(sizeof(struct osd_info), |
1061 | GFP_ATOMIC|__GFP_NOWARN); | ||
1060 | if (itv->osd_info == NULL) { | 1062 | if (itv->osd_info == NULL) { |
1061 | IVTVFB_ERR("Failed to allocate memory for osd_info\n"); | 1063 | IVTVFB_ERR("Failed to allocate memory for osd_info\n"); |
1062 | return -ENOMEM; | 1064 | return -ENOMEM; |
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index 179e47049a45..ee43499544c1 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
@@ -12,15 +12,12 @@ | |||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/i2c.h> | 13 | #include <linux/i2c.h> |
14 | #include <linux/log2.h> | 14 | #include <linux/log2.h> |
15 | #include <linux/gpio.h> | ||
15 | 16 | ||
16 | #include <media/v4l2-common.h> | 17 | #include <media/v4l2-common.h> |
17 | #include <media/v4l2-chip-ident.h> | 18 | #include <media/v4l2-chip-ident.h> |
18 | #include <media/soc_camera.h> | 19 | #include <media/soc_camera.h> |
19 | 20 | ||
20 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
21 | #include <asm/gpio.h> | ||
22 | #endif | ||
23 | |||
24 | /* mt9m001 i2c address 0x5d | 21 | /* mt9m001 i2c address 0x5d |
25 | * The platform has to define i2c_board_info | 22 | * The platform has to define i2c_board_info |
26 | * and call i2c_register_board_info() */ | 23 | * and call i2c_register_board_info() */ |
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c index d1391ac55096..1658fe590392 100644 --- a/drivers/media/video/mt9v022.c +++ b/drivers/media/video/mt9v022.c | |||
@@ -13,15 +13,12 @@ | |||
13 | #include <linux/i2c.h> | 13 | #include <linux/i2c.h> |
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/log2.h> | 15 | #include <linux/log2.h> |
16 | #include <linux/gpio.h> | ||
16 | 17 | ||
17 | #include <media/v4l2-common.h> | 18 | #include <media/v4l2-common.h> |
18 | #include <media/v4l2-chip-ident.h> | 19 | #include <media/v4l2-chip-ident.h> |
19 | #include <media/soc_camera.h> | 20 | #include <media/soc_camera.h> |
20 | 21 | ||
21 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
22 | #include <asm/gpio.h> | ||
23 | #endif | ||
24 | |||
25 | /* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c | 22 | /* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c |
26 | * The platform has to define i2c_board_info | 23 | * The platform has to define i2c_board_info |
27 | * and call i2c_register_board_info() */ | 24 | * and call i2c_register_board_info() */ |
@@ -91,7 +88,7 @@ static const struct soc_camera_data_format mt9v022_monochrome_formats[] = { | |||
91 | struct mt9v022 { | 88 | struct mt9v022 { |
92 | struct i2c_client *client; | 89 | struct i2c_client *client; |
93 | struct soc_camera_device icd; | 90 | struct soc_camera_device icd; |
94 | int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ | 91 | int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */ |
95 | int switch_gpio; | 92 | int switch_gpio; |
96 | u16 chip_control; | 93 | u16 chip_control; |
97 | unsigned char datawidth; | 94 | unsigned char datawidth; |
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig index 9620c67fae77..4482b2c72ced 100644 --- a/drivers/media/video/pvrusb2/Kconfig +++ b/drivers/media/video/pvrusb2/Kconfig | |||
@@ -1,8 +1,10 @@ | |||
1 | config VIDEO_PVRUSB2 | 1 | config VIDEO_PVRUSB2 |
2 | tristate "Hauppauge WinTV-PVR USB2 support" | 2 | tristate "Hauppauge WinTV-PVR USB2 support" |
3 | depends on VIDEO_V4L2 && I2C | 3 | depends on VIDEO_V4L2 && I2C |
4 | depends on VIDEO_MEDIA # Avoids pvrusb = Y / DVB = M | ||
5 | depends on HOTPLUG # due to FW_LOADER | ||
4 | select FW_LOADER | 6 | select FW_LOADER |
5 | select MEDIA_TUNER | 7 | select VIDEO_TUNER |
6 | select VIDEO_TVEEPROM | 8 | select VIDEO_TVEEPROM |
7 | select VIDEO_CX2341X | 9 | select VIDEO_CX2341X |
8 | select VIDEO_SAA711X | 10 | select VIDEO_SAA711X |
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig index 40e4c3bd2cb9..83f076abce35 100644 --- a/drivers/media/video/saa7134/Kconfig +++ b/drivers/media/video/saa7134/Kconfig | |||
@@ -3,7 +3,7 @@ config VIDEO_SAA7134 | |||
3 | depends on VIDEO_DEV && PCI && I2C && INPUT | 3 | depends on VIDEO_DEV && PCI && I2C && INPUT |
4 | select VIDEOBUF_DMA_SG | 4 | select VIDEOBUF_DMA_SG |
5 | select VIDEO_IR | 5 | select VIDEO_IR |
6 | select MEDIA_TUNER | 6 | select VIDEO_TUNER |
7 | select VIDEO_TVEEPROM | 7 | select VIDEO_TVEEPROM |
8 | select CRC32 | 8 | select CRC32 |
9 | ---help--- | 9 | ---help--- |
@@ -27,6 +27,7 @@ config VIDEO_SAA7134_ALSA | |||
27 | config VIDEO_SAA7134_DVB | 27 | config VIDEO_SAA7134_DVB |
28 | tristate "DVB/ATSC Support for saa7134 based TV cards" | 28 | tristate "DVB/ATSC Support for saa7134 based TV cards" |
29 | depends on VIDEO_SAA7134 && DVB_CORE | 29 | depends on VIDEO_SAA7134 && DVB_CORE |
30 | depends on HOTPLUG # due to FW_LOADER | ||
30 | select VIDEOBUF_DVB | 31 | select VIDEOBUF_DVB |
31 | select FW_LOADER | 32 | select FW_LOADER |
32 | select DVB_PLL if !DVB_FE_CUSTOMISE | 33 | select DVB_PLL if !DVB_FE_CUSTOMISE |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index eec127864fe3..2c19cd0113c8 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -864,7 +864,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
864 | struct saa7134_dev *dev; | 864 | struct saa7134_dev *dev; |
865 | struct saa7134_mpeg_ops *mops; | 865 | struct saa7134_mpeg_ops *mops; |
866 | int err; | 866 | int err; |
867 | int mask; | ||
868 | 867 | ||
869 | if (saa7134_devcount == SAA7134_MAXBOARDS) | 868 | if (saa7134_devcount == SAA7134_MAXBOARDS) |
870 | return -ENOMEM; | 869 | return -ENOMEM; |
@@ -1065,11 +1064,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1065 | if (TUNER_ABSENT != dev->tuner_type) | 1064 | if (TUNER_ABSENT != dev->tuner_type) |
1066 | saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); | 1065 | saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); |
1067 | 1066 | ||
1068 | if (card(dev).gpiomask != 0) { | ||
1069 | mask = card(dev).gpiomask; | ||
1070 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); | ||
1071 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, 0); | ||
1072 | } | ||
1073 | return 0; | 1067 | return 0; |
1074 | 1068 | ||
1075 | fail4: | 1069 | fail4: |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 2d16be2259db..469f93aac008 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -538,19 +538,23 @@ static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe) | |||
538 | return 0; | 538 | return 0; |
539 | } | 539 | } |
540 | 540 | ||
541 | static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *cdec_conf, | 541 | static int configure_tda827x_fe(struct saa7134_dev *dev, |
542 | struct tda827x_config *tuner_conf) | 542 | struct tda1004x_config *cdec_conf, |
543 | struct tda827x_config *tuner_conf) | ||
543 | { | 544 | { |
544 | dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); | 545 | dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); |
545 | if (dev->dvb.frontend) { | 546 | if (dev->dvb.frontend) { |
546 | if (cdec_conf->i2c_gate) | 547 | if (cdec_conf->i2c_gate) |
547 | dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; | 548 | dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; |
548 | if (dvb_attach(tda827x_attach, dev->dvb.frontend, cdec_conf->tuner_address, | 549 | if (dvb_attach(tda827x_attach, dev->dvb.frontend, |
549 | &dev->i2c_adap, tuner_conf) == NULL) { | 550 | cdec_conf->tuner_address, |
550 | wprintk("no tda827x tuner found at addr: %02x\n", | 551 | &dev->i2c_adap, tuner_conf)) |
552 | return 0; | ||
553 | |||
554 | wprintk("no tda827x tuner found at addr: %02x\n", | ||
551 | cdec_conf->tuner_address); | 555 | cdec_conf->tuner_address); |
552 | } | ||
553 | } | 556 | } |
557 | return -EINVAL; | ||
554 | } | 558 | } |
555 | 559 | ||
556 | /* ------------------------------------------------------------------ */ | 560 | /* ------------------------------------------------------------------ */ |
@@ -997,7 +1001,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
997 | break; | 1001 | break; |
998 | case SAA7134_BOARD_FLYDVBTDUO: | 1002 | case SAA7134_BOARD_FLYDVBTDUO: |
999 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: | 1003 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: |
1000 | configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); | 1004 | if (configure_tda827x_fe(dev, &tda827x_lifeview_config, |
1005 | &tda827x_cfg_0) < 0) | ||
1006 | goto dettach_frontend; | ||
1001 | break; | 1007 | break; |
1002 | case SAA7134_BOARD_PHILIPS_EUROPA: | 1008 | case SAA7134_BOARD_PHILIPS_EUROPA: |
1003 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: | 1009 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
@@ -1022,36 +1028,52 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1022 | } | 1028 | } |
1023 | break; | 1029 | break; |
1024 | case SAA7134_BOARD_KWORLD_DVBT_210: | 1030 | case SAA7134_BOARD_KWORLD_DVBT_210: |
1025 | configure_tda827x_fe(dev, &kworld_dvb_t_210_config, &tda827x_cfg_2); | 1031 | if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config, |
1032 | &tda827x_cfg_2) < 0) | ||
1033 | goto dettach_frontend; | ||
1026 | break; | 1034 | break; |
1027 | case SAA7134_BOARD_PHILIPS_TIGER: | 1035 | case SAA7134_BOARD_PHILIPS_TIGER: |
1028 | configure_tda827x_fe(dev, &philips_tiger_config, &tda827x_cfg_0); | 1036 | if (configure_tda827x_fe(dev, &philips_tiger_config, |
1037 | &tda827x_cfg_0) < 0) | ||
1038 | goto dettach_frontend; | ||
1029 | break; | 1039 | break; |
1030 | case SAA7134_BOARD_PINNACLE_PCTV_310i: | 1040 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
1031 | configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, &tda827x_cfg_1); | 1041 | if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, |
1042 | &tda827x_cfg_1) < 0) | ||
1043 | goto dettach_frontend; | ||
1032 | break; | 1044 | break; |
1033 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: | 1045 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
1034 | configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, &tda827x_cfg_1); | 1046 | if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, |
1047 | &tda827x_cfg_1) < 0) | ||
1048 | goto dettach_frontend; | ||
1035 | break; | 1049 | break; |
1036 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: | 1050 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
1037 | configure_tda827x_fe(dev, &asus_p7131_dual_config, &tda827x_cfg_0); | 1051 | if (configure_tda827x_fe(dev, &asus_p7131_dual_config, |
1052 | &tda827x_cfg_0) < 0) | ||
1053 | goto dettach_frontend; | ||
1038 | break; | 1054 | break; |
1039 | case SAA7134_BOARD_FLYDVBT_LR301: | 1055 | case SAA7134_BOARD_FLYDVBT_LR301: |
1040 | configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); | 1056 | if (configure_tda827x_fe(dev, &tda827x_lifeview_config, |
1057 | &tda827x_cfg_0) < 0) | ||
1058 | goto dettach_frontend; | ||
1041 | break; | 1059 | break; |
1042 | case SAA7134_BOARD_FLYDVB_TRIO: | 1060 | case SAA7134_BOARD_FLYDVB_TRIO: |
1043 | if(! use_frontend) { /* terrestrial */ | 1061 | if (!use_frontend) { /* terrestrial */ |
1044 | configure_tda827x_fe(dev, &lifeview_trio_config, &tda827x_cfg_0); | 1062 | if (configure_tda827x_fe(dev, &lifeview_trio_config, |
1063 | &tda827x_cfg_0) < 0) | ||
1064 | goto dettach_frontend; | ||
1045 | } else { /* satellite */ | 1065 | } else { /* satellite */ |
1046 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); | 1066 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); |
1047 | if (dev->dvb.frontend) { | 1067 | if (dev->dvb.frontend) { |
1048 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, | 1068 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, |
1049 | &dev->i2c_adap, 0) == NULL) { | 1069 | &dev->i2c_adap, 0) == NULL) { |
1050 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); | 1070 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); |
1071 | goto dettach_frontend; | ||
1051 | } | 1072 | } |
1052 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, | 1073 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, |
1053 | 0x08, 0, 0) == NULL) { | 1074 | 0x08, 0, 0) == NULL) { |
1054 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); | 1075 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); |
1076 | goto dettach_frontend; | ||
1055 | } | 1077 | } |
1056 | } | 1078 | } |
1057 | } | 1079 | } |
@@ -1067,15 +1089,20 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1067 | &ads_duo_cfg) == NULL) { | 1089 | &ads_duo_cfg) == NULL) { |
1068 | wprintk("no tda827x tuner found at addr: %02x\n", | 1090 | wprintk("no tda827x tuner found at addr: %02x\n", |
1069 | ads_tech_duo_config.tuner_address); | 1091 | ads_tech_duo_config.tuner_address); |
1092 | goto dettach_frontend; | ||
1070 | } | 1093 | } |
1071 | } | 1094 | } |
1072 | break; | 1095 | break; |
1073 | case SAA7134_BOARD_TEVION_DVBT_220RF: | 1096 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
1074 | configure_tda827x_fe(dev, &tevion_dvbt220rf_config, &tda827x_cfg_0); | 1097 | if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config, |
1098 | &tda827x_cfg_0) < 0) | ||
1099 | goto dettach_frontend; | ||
1075 | break; | 1100 | break; |
1076 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: | 1101 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: |
1077 | if (!use_frontend) { /* terrestrial */ | 1102 | if (!use_frontend) { /* terrestrial */ |
1078 | configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); | 1103 | if (configure_tda827x_fe(dev, &md8800_dvbt_config, |
1104 | &tda827x_cfg_0) < 0) | ||
1105 | goto dettach_frontend; | ||
1079 | } else { /* satellite */ | 1106 | } else { /* satellite */ |
1080 | dev->dvb.frontend = dvb_attach(tda10086_attach, | 1107 | dev->dvb.frontend = dvb_attach(tda10086_attach, |
1081 | &flydvbs, &dev->i2c_adap); | 1108 | &flydvbs, &dev->i2c_adap); |
@@ -1086,16 +1113,20 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1086 | struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; | 1113 | struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; |
1087 | 1114 | ||
1088 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, | 1115 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, |
1089 | 0x60, &dev->i2c_adap, 0) == NULL) | 1116 | 0x60, &dev->i2c_adap, 0) == NULL) { |
1090 | wprintk("%s: Medion Quadro, no tda826x " | 1117 | wprintk("%s: Medion Quadro, no tda826x " |
1091 | "found !\n", __func__); | 1118 | "found !\n", __func__); |
1119 | goto dettach_frontend; | ||
1120 | } | ||
1092 | if (dev_id != 0x08) { | 1121 | if (dev_id != 0x08) { |
1093 | /* we need to open the i2c gate (we know it exists) */ | 1122 | /* we need to open the i2c gate (we know it exists) */ |
1094 | fe->ops.i2c_gate_ctrl(fe, 1); | 1123 | fe->ops.i2c_gate_ctrl(fe, 1); |
1095 | if (dvb_attach(isl6405_attach, fe, | 1124 | if (dvb_attach(isl6405_attach, fe, |
1096 | &dev->i2c_adap, 0x08, 0, 0) == NULL) | 1125 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
1097 | wprintk("%s: Medion Quadro, no ISL6405 " | 1126 | wprintk("%s: Medion Quadro, no ISL6405 " |
1098 | "found !\n", __func__); | 1127 | "found !\n", __func__); |
1128 | goto dettach_frontend; | ||
1129 | } | ||
1099 | if (dev_id == 0x07) { | 1130 | if (dev_id == 0x07) { |
1100 | /* fire up the 2nd section of the LNB supply since | 1131 | /* fire up the 2nd section of the LNB supply since |
1101 | we can't do this from the other section */ | 1132 | we can't do this from the other section */ |
@@ -1117,19 +1148,17 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1117 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: | 1148 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: |
1118 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, | 1149 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, |
1119 | &dev->i2c_adap); | 1150 | &dev->i2c_adap); |
1120 | if (dev->dvb.frontend) { | 1151 | if (dev->dvb.frontend) |
1121 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 1152 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
1122 | NULL, DVB_PLL_TDHU2); | 1153 | NULL, DVB_PLL_TDHU2); |
1123 | } | ||
1124 | break; | 1154 | break; |
1125 | case SAA7134_BOARD_KWORLD_ATSC110: | 1155 | case SAA7134_BOARD_KWORLD_ATSC110: |
1126 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, | 1156 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, |
1127 | &dev->i2c_adap); | 1157 | &dev->i2c_adap); |
1128 | if (dev->dvb.frontend) { | 1158 | if (dev->dvb.frontend) |
1129 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 1159 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
1130 | &dev->i2c_adap, 0x61, | 1160 | &dev->i2c_adap, 0x61, |
1131 | TUNER_PHILIPS_TUV1236D); | 1161 | TUNER_PHILIPS_TUV1236D); |
1132 | } | ||
1133 | break; | 1162 | break; |
1134 | case SAA7134_BOARD_FLYDVBS_LR300: | 1163 | case SAA7134_BOARD_FLYDVBS_LR300: |
1135 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, | 1164 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, |
@@ -1138,10 +1167,12 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1138 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, | 1167 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, |
1139 | &dev->i2c_adap, 0) == NULL) { | 1168 | &dev->i2c_adap, 0) == NULL) { |
1140 | wprintk("%s: No tda826x found!\n", __func__); | 1169 | wprintk("%s: No tda826x found!\n", __func__); |
1170 | goto dettach_frontend; | ||
1141 | } | 1171 | } |
1142 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, | 1172 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, |
1143 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { | 1173 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
1144 | wprintk("%s: No ISL6421 found!\n", __func__); | 1174 | wprintk("%s: No ISL6421 found!\n", __func__); |
1175 | goto dettach_frontend; | ||
1145 | } | 1176 | } |
1146 | } | 1177 | } |
1147 | break; | 1178 | break; |
@@ -1168,43 +1199,65 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1168 | } | 1199 | } |
1169 | break; | 1200 | break; |
1170 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: | 1201 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: |
1171 | configure_tda827x_fe(dev, &cinergy_ht_config, &tda827x_cfg_0); | 1202 | if (configure_tda827x_fe(dev, &cinergy_ht_config, |
1203 | &tda827x_cfg_0) < 0) | ||
1204 | goto dettach_frontend; | ||
1172 | break; | 1205 | break; |
1173 | case SAA7134_BOARD_CINERGY_HT_PCI: | 1206 | case SAA7134_BOARD_CINERGY_HT_PCI: |
1174 | configure_tda827x_fe(dev, &cinergy_ht_pci_config, &tda827x_cfg_0); | 1207 | if (configure_tda827x_fe(dev, &cinergy_ht_pci_config, |
1208 | &tda827x_cfg_0) < 0) | ||
1209 | goto dettach_frontend; | ||
1175 | break; | 1210 | break; |
1176 | case SAA7134_BOARD_PHILIPS_TIGER_S: | 1211 | case SAA7134_BOARD_PHILIPS_TIGER_S: |
1177 | configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); | 1212 | if (configure_tda827x_fe(dev, &philips_tiger_s_config, |
1213 | &tda827x_cfg_2) < 0) | ||
1214 | goto dettach_frontend; | ||
1178 | break; | 1215 | break; |
1179 | case SAA7134_BOARD_ASUS_P7131_4871: | 1216 | case SAA7134_BOARD_ASUS_P7131_4871: |
1180 | configure_tda827x_fe(dev, &asus_p7131_4871_config, &tda827x_cfg_2); | 1217 | if (configure_tda827x_fe(dev, &asus_p7131_4871_config, |
1218 | &tda827x_cfg_2) < 0) | ||
1219 | goto dettach_frontend; | ||
1181 | break; | 1220 | break; |
1182 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: | 1221 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
1183 | configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, &tda827x_cfg_2); | 1222 | if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, |
1223 | &tda827x_cfg_2) < 0) | ||
1224 | goto dettach_frontend; | ||
1184 | break; | 1225 | break; |
1185 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: | 1226 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: |
1186 | configure_tda827x_fe(dev, &avermedia_super_007_config, &tda827x_cfg_0); | 1227 | if (configure_tda827x_fe(dev, &avermedia_super_007_config, |
1228 | &tda827x_cfg_0) < 0) | ||
1229 | goto dettach_frontend; | ||
1187 | break; | 1230 | break; |
1188 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: | 1231 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: |
1189 | configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, &tda827x_cfg_2_sw42); | 1232 | if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, |
1233 | &tda827x_cfg_2_sw42) < 0) | ||
1234 | goto dettach_frontend; | ||
1190 | break; | 1235 | break; |
1191 | case SAA7134_BOARD_PHILIPS_SNAKE: | 1236 | case SAA7134_BOARD_PHILIPS_SNAKE: |
1192 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, | 1237 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, |
1193 | &dev->i2c_adap); | 1238 | &dev->i2c_adap); |
1194 | if (dev->dvb.frontend) { | 1239 | if (dev->dvb.frontend) { |
1195 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, | 1240 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, |
1196 | &dev->i2c_adap, 0) == NULL) | 1241 | &dev->i2c_adap, 0) == NULL) { |
1197 | wprintk("%s: No tda826x found!\n", __func__); | 1242 | wprintk("%s: No tda826x found!\n", __func__); |
1243 | goto dettach_frontend; | ||
1244 | } | ||
1198 | if (dvb_attach(lnbp21_attach, dev->dvb.frontend, | 1245 | if (dvb_attach(lnbp21_attach, dev->dvb.frontend, |
1199 | &dev->i2c_adap, 0, 0) == NULL) | 1246 | &dev->i2c_adap, 0, 0) == NULL) { |
1200 | wprintk("%s: No lnbp21 found!\n", __func__); | 1247 | wprintk("%s: No lnbp21 found!\n", __func__); |
1248 | goto dettach_frontend; | ||
1249 | } | ||
1201 | } | 1250 | } |
1202 | break; | 1251 | break; |
1203 | case SAA7134_BOARD_CREATIX_CTX953: | 1252 | case SAA7134_BOARD_CREATIX_CTX953: |
1204 | configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); | 1253 | if (configure_tda827x_fe(dev, &md8800_dvbt_config, |
1254 | &tda827x_cfg_0) < 0) | ||
1255 | goto dettach_frontend; | ||
1205 | break; | 1256 | break; |
1206 | case SAA7134_BOARD_MSI_TVANYWHERE_AD11: | 1257 | case SAA7134_BOARD_MSI_TVANYWHERE_AD11: |
1207 | configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); | 1258 | if (configure_tda827x_fe(dev, &philips_tiger_s_config, |
1259 | &tda827x_cfg_2) < 0) | ||
1260 | goto dettach_frontend; | ||
1208 | break; | 1261 | break; |
1209 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | 1262 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
1210 | dev->dvb.frontend = dvb_attach(mt352_attach, | 1263 | dev->dvb.frontend = dvb_attach(mt352_attach, |
@@ -1218,16 +1271,20 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1218 | if (dev->dvb.frontend) { | 1271 | if (dev->dvb.frontend) { |
1219 | struct dvb_frontend *fe; | 1272 | struct dvb_frontend *fe; |
1220 | if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, | 1273 | if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, |
1221 | &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) | 1274 | &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { |
1222 | wprintk("%s: MD7134 DVB-S, no SD1878 " | 1275 | wprintk("%s: MD7134 DVB-S, no SD1878 " |
1223 | "found !\n", __func__); | 1276 | "found !\n", __func__); |
1277 | goto dettach_frontend; | ||
1278 | } | ||
1224 | /* we need to open the i2c gate (we know it exists) */ | 1279 | /* we need to open the i2c gate (we know it exists) */ |
1225 | fe = dev->dvb.frontend; | 1280 | fe = dev->dvb.frontend; |
1226 | fe->ops.i2c_gate_ctrl(fe, 1); | 1281 | fe->ops.i2c_gate_ctrl(fe, 1); |
1227 | if (dvb_attach(isl6405_attach, fe, | 1282 | if (dvb_attach(isl6405_attach, fe, |
1228 | &dev->i2c_adap, 0x08, 0, 0) == NULL) | 1283 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
1229 | wprintk("%s: MD7134 DVB-S, no ISL6405 " | 1284 | wprintk("%s: MD7134 DVB-S, no ISL6405 " |
1230 | "found !\n", __func__); | 1285 | "found !\n", __func__); |
1286 | goto dettach_frontend; | ||
1287 | } | ||
1231 | fe->ops.i2c_gate_ctrl(fe, 0); | 1288 | fe->ops.i2c_gate_ctrl(fe, 0); |
1232 | dev->original_set_voltage = fe->ops.set_voltage; | 1289 | dev->original_set_voltage = fe->ops.set_voltage; |
1233 | fe->ops.set_voltage = md8800_set_voltage; | 1290 | fe->ops.set_voltage = md8800_set_voltage; |
@@ -1254,10 +1311,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1254 | if (!fe) { | 1311 | if (!fe) { |
1255 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | 1312 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", |
1256 | dev->name); | 1313 | dev->name); |
1257 | dvb_frontend_detach(dev->dvb.frontend); | 1314 | goto dettach_frontend; |
1258 | dvb_unregister_frontend(dev->dvb.frontend); | ||
1259 | dev->dvb.frontend = NULL; | ||
1260 | return -1; | ||
1261 | } | 1315 | } |
1262 | } | 1316 | } |
1263 | 1317 | ||
@@ -1282,6 +1336,12 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1282 | dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); | 1336 | dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); |
1283 | } | 1337 | } |
1284 | return ret; | 1338 | return ret; |
1339 | |||
1340 | dettach_frontend: | ||
1341 | dvb_frontend_detach(dev->dvb.frontend); | ||
1342 | dev->dvb.frontend = NULL; | ||
1343 | |||
1344 | return -1; | ||
1285 | } | 1345 | } |
1286 | 1346 | ||
1287 | static int dvb_fini(struct saa7134_dev *dev) | 1347 | static int dvb_fini(struct saa7134_dev *dev) |
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index 9276ed997388..b12c60cf5a09 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/kref.h> | 30 | #include <linux/kref.h> |
31 | 31 | ||
32 | #include <linux/usb.h> | 32 | #include <linux/usb.h> |
33 | #include <linux/mm.h> | ||
33 | #include <linux/vmalloc.h> | 34 | #include <linux/vmalloc.h> |
34 | #include <linux/videodev2.h> | 35 | #include <linux/videodev2.h> |
35 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
@@ -245,6 +246,8 @@ static int stk_initialise(struct stk_camera *dev) | |||
245 | return -1; | 246 | return -1; |
246 | } | 247 | } |
247 | 248 | ||
249 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
250 | |||
248 | /* sysfs functions */ | 251 | /* sysfs functions */ |
249 | /*FIXME cleanup this */ | 252 | /*FIXME cleanup this */ |
250 | 253 | ||
@@ -350,6 +353,10 @@ static void stk_remove_sysfs_files(struct video_device *vdev) | |||
350 | video_device_remove_file(vdev, &dev_attr_vflip); | 353 | video_device_remove_file(vdev, &dev_attr_vflip); |
351 | } | 354 | } |
352 | 355 | ||
356 | #else | ||
357 | #define stk_create_sysfs_files(a) | ||
358 | #define stk_remove_sysfs_files(a) | ||
359 | #endif | ||
353 | 360 | ||
354 | /* *********************************************** */ | 361 | /* *********************************************** */ |
355 | /* | 362 | /* |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 6bf104ea051d..5a75788b92ae 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -40,11 +40,11 @@ | |||
40 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ | 40 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ |
41 | if (__a) { \ | 41 | if (__a) { \ |
42 | __r = (int) __a(ARGS); \ | 42 | __r = (int) __a(ARGS); \ |
43 | symbol_put(FUNCTION); \ | ||
43 | } else { \ | 44 | } else { \ |
44 | printk(KERN_ERR "TUNER: Unable to find " \ | 45 | printk(KERN_ERR "TUNER: Unable to find " \ |
45 | "symbol "#FUNCTION"()\n"); \ | 46 | "symbol "#FUNCTION"()\n"); \ |
46 | } \ | 47 | } \ |
47 | symbol_put(FUNCTION); \ | ||
48 | __r; \ | 48 | __r; \ |
49 | }) | 49 | }) |
50 | 50 | ||
@@ -340,16 +340,6 @@ static void tuner_i2c_address_check(struct tuner *t) | |||
340 | tuner_warn("====================== WARNING! ======================\n"); | 340 | tuner_warn("====================== WARNING! ======================\n"); |
341 | } | 341 | } |
342 | 342 | ||
343 | static void attach_tda829x(struct tuner *t) | ||
344 | { | ||
345 | struct tda829x_config cfg = { | ||
346 | .lna_cfg = t->config, | ||
347 | .tuner_callback = t->tuner_callback, | ||
348 | }; | ||
349 | dvb_attach(tda829x_attach, | ||
350 | &t->fe, t->i2c->adapter, t->i2c->addr, &cfg); | ||
351 | } | ||
352 | |||
353 | static struct xc5000_config xc5000_cfg; | 343 | static struct xc5000_config xc5000_cfg; |
354 | 344 | ||
355 | static void set_type(struct i2c_client *c, unsigned int type, | 345 | static void set_type(struct i2c_client *c, unsigned int type, |
@@ -385,12 +375,19 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
385 | 375 | ||
386 | switch (t->type) { | 376 | switch (t->type) { |
387 | case TUNER_MT2032: | 377 | case TUNER_MT2032: |
388 | dvb_attach(microtune_attach, | 378 | if (!dvb_attach(microtune_attach, |
389 | &t->fe, t->i2c->adapter, t->i2c->addr); | 379 | &t->fe, t->i2c->adapter, t->i2c->addr)) |
380 | goto attach_failed; | ||
390 | break; | 381 | break; |
391 | case TUNER_PHILIPS_TDA8290: | 382 | case TUNER_PHILIPS_TDA8290: |
392 | { | 383 | { |
393 | attach_tda829x(t); | 384 | struct tda829x_config cfg = { |
385 | .lna_cfg = t->config, | ||
386 | .tuner_callback = t->tuner_callback, | ||
387 | }; | ||
388 | if (!dvb_attach(tda829x_attach, &t->fe, t->i2c->adapter, | ||
389 | t->i2c->addr, &cfg)) | ||
390 | goto attach_failed; | ||
394 | break; | 391 | break; |
395 | } | 392 | } |
396 | case TUNER_TEA5767: | 393 | case TUNER_TEA5767: |
@@ -441,8 +438,9 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
441 | break; | 438 | break; |
442 | } | 439 | } |
443 | case TUNER_TDA9887: | 440 | case TUNER_TDA9887: |
444 | dvb_attach(tda9887_attach, | 441 | if (!dvb_attach(tda9887_attach, |
445 | &t->fe, t->i2c->adapter, t->i2c->addr); | 442 | &t->fe, t->i2c->adapter, t->i2c->addr)) |
443 | goto attach_failed; | ||
446 | break; | 444 | break; |
447 | case TUNER_XC5000: | 445 | case TUNER_XC5000: |
448 | { | 446 | { |
@@ -450,10 +448,10 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
450 | 448 | ||
451 | xc5000_cfg.i2c_address = t->i2c->addr; | 449 | xc5000_cfg.i2c_address = t->i2c->addr; |
452 | xc5000_cfg.if_khz = 5380; | 450 | xc5000_cfg.if_khz = 5380; |
453 | xc5000_cfg.priv = c->adapter->algo_data; | ||
454 | xc5000_cfg.tuner_callback = t->tuner_callback; | 451 | xc5000_cfg.tuner_callback = t->tuner_callback; |
455 | if (!dvb_attach(xc5000_attach, | 452 | if (!dvb_attach(xc5000_attach, |
456 | &t->fe, t->i2c->adapter, &xc5000_cfg)) | 453 | &t->fe, t->i2c->adapter, &xc5000_cfg, |
454 | c->adapter->algo_data)) | ||
457 | goto attach_failed; | 455 | goto attach_failed; |
458 | 456 | ||
459 | xc_tuner_ops = &t->fe.ops.tuner_ops; | 457 | xc_tuner_ops = &t->fe.ops.tuner_ops; |
@@ -1167,7 +1165,7 @@ static int tuner_probe(struct i2c_client *client, | |||
1167 | /* If chip is not tda8290, don't register. | 1165 | /* If chip is not tda8290, don't register. |
1168 | since it can be tda9887*/ | 1166 | since it can be tda9887*/ |
1169 | if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, | 1167 | if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, |
1170 | t->i2c->addr) == 0) { | 1168 | t->i2c->addr) >= 0) { |
1171 | tuner_dbg("tda829x detected\n"); | 1169 | tuner_dbg("tda829x detected\n"); |
1172 | } else { | 1170 | } else { |
1173 | /* Default is being tda9887 */ | 1171 | /* Default is being tda9887 */ |
@@ -1181,7 +1179,7 @@ static int tuner_probe(struct i2c_client *client, | |||
1181 | case 0x60: | 1179 | case 0x60: |
1182 | if (tuner_symbol_probe(tea5767_autodetection, | 1180 | if (tuner_symbol_probe(tea5767_autodetection, |
1183 | t->i2c->adapter, t->i2c->addr) | 1181 | t->i2c->adapter, t->i2c->addr) |
1184 | != EINVAL) { | 1182 | >= 0) { |
1185 | t->type = TUNER_TEA5767; | 1183 | t->type = TUNER_TEA5767; |
1186 | t->mode_mask = T_RADIO; | 1184 | t->mode_mask = T_RADIO; |
1187 | t->mode = T_STANDBY; | 1185 | t->mode = T_STANDBY; |
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 3cf8a8e801e5..9da0e1807ffb 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c | |||
@@ -319,10 +319,12 @@ audioIC[] = | |||
319 | {AUDIO_CHIP_INTERNAL, "CX25843"}, | 319 | {AUDIO_CHIP_INTERNAL, "CX25843"}, |
320 | {AUDIO_CHIP_INTERNAL, "CX23418"}, | 320 | {AUDIO_CHIP_INTERNAL, "CX23418"}, |
321 | {AUDIO_CHIP_INTERNAL, "CX23885"}, | 321 | {AUDIO_CHIP_INTERNAL, "CX23885"}, |
322 | /* 40-42 */ | 322 | /* 40-44 */ |
323 | {AUDIO_CHIP_INTERNAL, "CX23888"}, | 323 | {AUDIO_CHIP_INTERNAL, "CX23888"}, |
324 | {AUDIO_CHIP_INTERNAL, "SAA7131"}, | 324 | {AUDIO_CHIP_INTERNAL, "SAA7131"}, |
325 | {AUDIO_CHIP_INTERNAL, "CX23887"}, | 325 | {AUDIO_CHIP_INTERNAL, "CX23887"}, |
326 | {AUDIO_CHIP_INTERNAL, "SAA7164"}, | ||
327 | {AUDIO_CHIP_INTERNAL, "AU8522"}, | ||
326 | }; | 328 | }; |
327 | 329 | ||
328 | /* This list is supplied by Hauppauge. Thanks! */ | 330 | /* This list is supplied by Hauppauge. Thanks! */ |
@@ -341,8 +343,10 @@ static const char *decoderIC[] = { | |||
341 | "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", | 343 | "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", |
342 | /* 30-34 */ | 344 | /* 30-34 */ |
343 | "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", | 345 | "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", |
344 | /* 35-37 */ | 346 | /* 35-39 */ |
345 | "SAA7131", "CX25837", "CX23887" | 347 | "SAA7131", "CX25837", "CX23887", "CX23885A", "CX23887A", |
348 | /* 40-42 */ | ||
349 | "SAA7164", "CX23885B", "AU8522" | ||
346 | }; | 350 | }; |
347 | 351 | ||
348 | static int hasRadioTuner(int tunerType) | 352 | static int hasRadioTuner(int tunerType) |
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig index 74e1d3075a20..fc24ef05b3f3 100644 --- a/drivers/media/video/usbvision/Kconfig +++ b/drivers/media/video/usbvision/Kconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | config VIDEO_USBVISION | 1 | config VIDEO_USBVISION |
2 | tristate "USB video devices based on Nogatech NT1003/1004/1005" | 2 | tristate "USB video devices based on Nogatech NT1003/1004/1005" |
3 | depends on I2C && VIDEO_V4L2 | 3 | depends on I2C && VIDEO_V4L2 |
4 | select MEDIA_TUNER | 4 | select VIDEO_TUNER |
5 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO | 5 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO |
6 | ---help--- | 6 | ---help--- |
7 | There are more than 50 different USB video devices based on | 7 | There are more than 50 different USB video devices based on |
diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h index 5515234be86a..03a87a307e32 100644 --- a/drivers/misc/sgi-xp/xp.h +++ b/drivers/misc/sgi-xp/xp.h | |||
@@ -157,215 +157,136 @@ struct xpc_msg { | |||
157 | /* | 157 | /* |
158 | * Define the return values and values passed to user's callout functions. | 158 | * Define the return values and values passed to user's callout functions. |
159 | * (It is important to add new value codes at the end just preceding | 159 | * (It is important to add new value codes at the end just preceding |
160 | * xpcUnknownReason, which must have the highest numerical value.) | 160 | * xpUnknownReason, which must have the highest numerical value.) |
161 | */ | 161 | */ |
162 | enum xpc_retval { | 162 | enum xp_retval { |
163 | xpcSuccess = 0, | 163 | xpSuccess = 0, |
164 | 164 | ||
165 | xpcNotConnected, /* 1: channel is not connected */ | 165 | xpNotConnected, /* 1: channel is not connected */ |
166 | xpcConnected, /* 2: channel connected (opened) */ | 166 | xpConnected, /* 2: channel connected (opened) */ |
167 | xpcRETIRED1, /* 3: (formerly xpcDisconnected) */ | 167 | xpRETIRED1, /* 3: (formerly xpDisconnected) */ |
168 | 168 | ||
169 | xpcMsgReceived, /* 4: message received */ | 169 | xpMsgReceived, /* 4: message received */ |
170 | xpcMsgDelivered, /* 5: message delivered and acknowledged */ | 170 | xpMsgDelivered, /* 5: message delivered and acknowledged */ |
171 | 171 | ||
172 | xpcRETIRED2, /* 6: (formerly xpcTransferFailed) */ | 172 | xpRETIRED2, /* 6: (formerly xpTransferFailed) */ |
173 | 173 | ||
174 | xpcNoWait, /* 7: operation would require wait */ | 174 | xpNoWait, /* 7: operation would require wait */ |
175 | xpcRetry, /* 8: retry operation */ | 175 | xpRetry, /* 8: retry operation */ |
176 | xpcTimeout, /* 9: timeout in xpc_allocate_msg_wait() */ | 176 | xpTimeout, /* 9: timeout in xpc_allocate_msg_wait() */ |
177 | xpcInterrupted, /* 10: interrupted wait */ | 177 | xpInterrupted, /* 10: interrupted wait */ |
178 | 178 | ||
179 | xpcUnequalMsgSizes, /* 11: message size disparity between sides */ | 179 | xpUnequalMsgSizes, /* 11: message size disparity between sides */ |
180 | xpcInvalidAddress, /* 12: invalid address */ | 180 | xpInvalidAddress, /* 12: invalid address */ |
181 | 181 | ||
182 | xpcNoMemory, /* 13: no memory available for XPC structures */ | 182 | xpNoMemory, /* 13: no memory available for XPC structures */ |
183 | xpcLackOfResources, /* 14: insufficient resources for operation */ | 183 | xpLackOfResources, /* 14: insufficient resources for operation */ |
184 | xpcUnregistered, /* 15: channel is not registered */ | 184 | xpUnregistered, /* 15: channel is not registered */ |
185 | xpcAlreadyRegistered, /* 16: channel is already registered */ | 185 | xpAlreadyRegistered, /* 16: channel is already registered */ |
186 | 186 | ||
187 | xpcPartitionDown, /* 17: remote partition is down */ | 187 | xpPartitionDown, /* 17: remote partition is down */ |
188 | xpcNotLoaded, /* 18: XPC module is not loaded */ | 188 | xpNotLoaded, /* 18: XPC module is not loaded */ |
189 | xpcUnloading, /* 19: this side is unloading XPC module */ | 189 | xpUnloading, /* 19: this side is unloading XPC module */ |
190 | 190 | ||
191 | xpcBadMagic, /* 20: XPC MAGIC string not found */ | 191 | xpBadMagic, /* 20: XPC MAGIC string not found */ |
192 | 192 | ||
193 | xpcReactivating, /* 21: remote partition was reactivated */ | 193 | xpReactivating, /* 21: remote partition was reactivated */ |
194 | 194 | ||
195 | xpcUnregistering, /* 22: this side is unregistering channel */ | 195 | xpUnregistering, /* 22: this side is unregistering channel */ |
196 | xpcOtherUnregistering, /* 23: other side is unregistering channel */ | 196 | xpOtherUnregistering, /* 23: other side is unregistering channel */ |
197 | 197 | ||
198 | xpcCloneKThread, /* 24: cloning kernel thread */ | 198 | xpCloneKThread, /* 24: cloning kernel thread */ |
199 | xpcCloneKThreadFailed, /* 25: cloning kernel thread failed */ | 199 | xpCloneKThreadFailed, /* 25: cloning kernel thread failed */ |
200 | 200 | ||
201 | xpcNoHeartbeat, /* 26: remote partition has no heartbeat */ | 201 | xpNoHeartbeat, /* 26: remote partition has no heartbeat */ |
202 | 202 | ||
203 | xpcPioReadError, /* 27: PIO read error */ | 203 | xpPioReadError, /* 27: PIO read error */ |
204 | xpcPhysAddrRegFailed, /* 28: registration of phys addr range failed */ | 204 | xpPhysAddrRegFailed, /* 28: registration of phys addr range failed */ |
205 | 205 | ||
206 | xpcBteDirectoryError, /* 29: maps to BTEFAIL_DIR */ | 206 | xpRETIRED3, /* 29: (formerly xpBteDirectoryError) */ |
207 | xpcBtePoisonError, /* 30: maps to BTEFAIL_POISON */ | 207 | xpRETIRED4, /* 30: (formerly xpBtePoisonError) */ |
208 | xpcBteWriteError, /* 31: maps to BTEFAIL_WERR */ | 208 | xpRETIRED5, /* 31: (formerly xpBteWriteError) */ |
209 | xpcBteAccessError, /* 32: maps to BTEFAIL_ACCESS */ | 209 | xpRETIRED6, /* 32: (formerly xpBteAccessError) */ |
210 | xpcBtePWriteError, /* 33: maps to BTEFAIL_PWERR */ | 210 | xpRETIRED7, /* 33: (formerly xpBtePWriteError) */ |
211 | xpcBtePReadError, /* 34: maps to BTEFAIL_PRERR */ | 211 | xpRETIRED8, /* 34: (formerly xpBtePReadError) */ |
212 | xpcBteTimeOutError, /* 35: maps to BTEFAIL_TOUT */ | 212 | xpRETIRED9, /* 35: (formerly xpBteTimeOutError) */ |
213 | xpcBteXtalkError, /* 36: maps to BTEFAIL_XTERR */ | 213 | xpRETIRED10, /* 36: (formerly xpBteXtalkError) */ |
214 | xpcBteNotAvailable, /* 37: maps to BTEFAIL_NOTAVAIL */ | 214 | xpRETIRED11, /* 37: (formerly xpBteNotAvailable) */ |
215 | xpcBteUnmappedError, /* 38: unmapped BTEFAIL_ error */ | 215 | xpRETIRED12, /* 38: (formerly xpBteUnmappedError) */ |
216 | 216 | ||
217 | xpcBadVersion, /* 39: bad version number */ | 217 | xpBadVersion, /* 39: bad version number */ |
218 | xpcVarsNotSet, /* 40: the XPC variables are not set up */ | 218 | xpVarsNotSet, /* 40: the XPC variables are not set up */ |
219 | xpcNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */ | 219 | xpNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */ |
220 | xpcInvalidPartid, /* 42: invalid partition ID */ | 220 | xpInvalidPartid, /* 42: invalid partition ID */ |
221 | xpcLocalPartid, /* 43: local partition ID */ | 221 | xpLocalPartid, /* 43: local partition ID */ |
222 | 222 | ||
223 | xpcOtherGoingDown, /* 44: other side going down, reason unknown */ | 223 | xpOtherGoingDown, /* 44: other side going down, reason unknown */ |
224 | xpcSystemGoingDown, /* 45: system is going down, reason unknown */ | 224 | xpSystemGoingDown, /* 45: system is going down, reason unknown */ |
225 | xpcSystemHalt, /* 46: system is being halted */ | 225 | xpSystemHalt, /* 46: system is being halted */ |
226 | xpcSystemReboot, /* 47: system is being rebooted */ | 226 | xpSystemReboot, /* 47: system is being rebooted */ |
227 | xpcSystemPoweroff, /* 48: system is being powered off */ | 227 | xpSystemPoweroff, /* 48: system is being powered off */ |
228 | 228 | ||
229 | xpcDisconnecting, /* 49: channel disconnecting (closing) */ | 229 | xpDisconnecting, /* 49: channel disconnecting (closing) */ |
230 | 230 | ||
231 | xpcOpenCloseError, /* 50: channel open/close protocol error */ | 231 | xpOpenCloseError, /* 50: channel open/close protocol error */ |
232 | 232 | ||
233 | xpcDisconnected, /* 51: channel disconnected (closed) */ | 233 | xpDisconnected, /* 51: channel disconnected (closed) */ |
234 | 234 | ||
235 | xpcBteSh2Start, /* 52: BTE CRB timeout */ | 235 | xpBteCopyError, /* 52: bte_copy() returned error */ |
236 | 236 | ||
237 | /* 53: 0x1 BTE Error Response Short */ | 237 | xpUnknownReason /* 53: unknown reason - must be last in enum */ |
238 | xpcBteSh2RspShort = xpcBteSh2Start + BTEFAIL_SH2_RESP_SHORT, | ||
239 | |||
240 | /* 54: 0x2 BTE Error Response Long */ | ||
241 | xpcBteSh2RspLong = xpcBteSh2Start + BTEFAIL_SH2_RESP_LONG, | ||
242 | |||
243 | /* 56: 0x4 BTE Error Response DSB */ | ||
244 | xpcBteSh2RspDSB = xpcBteSh2Start + BTEFAIL_SH2_RESP_DSP, | ||
245 | |||
246 | /* 60: 0x8 BTE Error Response Access */ | ||
247 | xpcBteSh2RspAccess = xpcBteSh2Start + BTEFAIL_SH2_RESP_ACCESS, | ||
248 | |||
249 | /* 68: 0x10 BTE Error CRB timeout */ | ||
250 | xpcBteSh2CRBTO = xpcBteSh2Start + BTEFAIL_SH2_CRB_TO, | ||
251 | |||
252 | /* 84: 0x20 BTE Error NACK limit */ | ||
253 | xpcBteSh2NACKLimit = xpcBteSh2Start + BTEFAIL_SH2_NACK_LIMIT, | ||
254 | |||
255 | /* 115: BTE end */ | ||
256 | xpcBteSh2End = xpcBteSh2Start + BTEFAIL_SH2_ALL, | ||
257 | |||
258 | xpcUnknownReason /* 116: unknown reason - must be last in enum */ | ||
259 | }; | 238 | }; |
260 | 239 | ||
261 | /* | 240 | /* |
262 | * Define the callout function types used by XPC to update the user on | 241 | * Define the callout function type used by XPC to update the user on |
263 | * connection activity and state changes (via the user function registered by | 242 | * connection activity and state changes via the user function registered |
264 | * xpc_connect()) and to notify them of messages received and delivered (via | 243 | * by xpc_connect(). |
265 | * the user function registered by xpc_send_notify()). | ||
266 | * | ||
267 | * The two function types are xpc_channel_func and xpc_notify_func and | ||
268 | * both share the following arguments, with the exception of "data", which | ||
269 | * only xpc_channel_func has. | ||
270 | * | 244 | * |
271 | * Arguments: | 245 | * Arguments: |
272 | * | 246 | * |
273 | * reason - reason code. (See following table.) | 247 | * reason - reason code. |
274 | * partid - partition ID associated with condition. | 248 | * partid - partition ID associated with condition. |
275 | * ch_number - channel # associated with condition. | 249 | * ch_number - channel # associated with condition. |
276 | * data - pointer to optional data. (See following table.) | 250 | * data - pointer to optional data. |
277 | * key - pointer to optional user-defined value provided as the "key" | 251 | * key - pointer to optional user-defined value provided as the "key" |
278 | * argument to xpc_connect() or xpc_send_notify(). | 252 | * argument to xpc_connect(). |
279 | * | 253 | * |
280 | * In the following table the "Optional Data" column applies to callouts made | 254 | * A reason code of xpConnected indicates that a connection has been |
281 | * to functions registered by xpc_connect(). A "NA" in that column indicates | 255 | * established to the specified partition on the specified channel. The data |
282 | * that this reason code can be passed to functions registered by | 256 | * argument indicates the max number of entries allowed in the message queue. |
283 | * xpc_send_notify() (i.e. they don't have data arguments). | ||
284 | * | 257 | * |
285 | * Also, the first three reason codes in the following table indicate | 258 | * A reason code of xpMsgReceived indicates that a XPC message arrived from |
286 | * success, whereas the others indicate failure. When a failure reason code | 259 | * the specified partition on the specified channel. The data argument |
287 | * is received, one can assume that the channel is not connected. | 260 | * specifies the address of the message's payload. The user must call |
261 | * xpc_received() when finished with the payload. | ||
288 | * | 262 | * |
289 | * | 263 | * All other reason codes indicate failure. The data argmument is NULL. |
290 | * Reason Code | Cause | Optional Data | 264 | * When a failure reason code is received, one can assume that the channel |
291 | * =====================+================================+===================== | 265 | * is not connected. |
292 | * xpcConnected | connection has been established| max #of entries | ||
293 | * | to the specified partition on | allowed in message | ||
294 | * | the specified channel | queue | ||
295 | * ---------------------+--------------------------------+--------------------- | ||
296 | * xpcMsgReceived | an XPC message arrived from | address of payload | ||
297 | * | the specified partition on the | | ||
298 | * | specified channel | [the user must call | ||
299 | * | | xpc_received() when | ||
300 | * | | finished with the | ||
301 | * | | payload] | ||
302 | * ---------------------+--------------------------------+--------------------- | ||
303 | * xpcMsgDelivered | notification that the message | NA | ||
304 | * | was delivered to the intended | | ||
305 | * | recipient and that they have | | ||
306 | * | acknowledged its receipt by | | ||
307 | * | calling xpc_received() | | ||
308 | * =====================+================================+===================== | ||
309 | * xpcUnequalMsgSizes | can't connect to the specified | NULL | ||
310 | * | partition on the specified | | ||
311 | * | channel because of mismatched | | ||
312 | * | message sizes | | ||
313 | * ---------------------+--------------------------------+--------------------- | ||
314 | * xpcNoMemory | insufficient memory avaiable | NULL | ||
315 | * | to allocate message queue | | ||
316 | * ---------------------+--------------------------------+--------------------- | ||
317 | * xpcLackOfResources | lack of resources to create | NULL | ||
318 | * | the necessary kthreads to | | ||
319 | * | support the channel | | ||
320 | * ---------------------+--------------------------------+--------------------- | ||
321 | * xpcUnregistering | this side's user has | NULL or NA | ||
322 | * | unregistered by calling | | ||
323 | * | xpc_disconnect() | | ||
324 | * ---------------------+--------------------------------+--------------------- | ||
325 | * xpcOtherUnregistering| the other side's user has | NULL or NA | ||
326 | * | unregistered by calling | | ||
327 | * | xpc_disconnect() | | ||
328 | * ---------------------+--------------------------------+--------------------- | ||
329 | * xpcNoHeartbeat | the other side's XPC is no | NULL or NA | ||
330 | * | longer heartbeating | | ||
331 | * | | | ||
332 | * ---------------------+--------------------------------+--------------------- | ||
333 | * xpcUnloading | this side's XPC module is | NULL or NA | ||
334 | * | being unloaded | | ||
335 | * | | | ||
336 | * ---------------------+--------------------------------+--------------------- | ||
337 | * xpcOtherUnloading | the other side's XPC module is | NULL or NA | ||
338 | * | is being unloaded | | ||
339 | * | | | ||
340 | * ---------------------+--------------------------------+--------------------- | ||
341 | * xpcPioReadError | xp_nofault_PIOR() returned an | NULL or NA | ||
342 | * | error while sending an IPI | | ||
343 | * | | | ||
344 | * ---------------------+--------------------------------+--------------------- | ||
345 | * xpcInvalidAddress | the address either received or | NULL or NA | ||
346 | * | sent by the specified partition| | ||
347 | * | is invalid | | ||
348 | * ---------------------+--------------------------------+--------------------- | ||
349 | * xpcBteNotAvailable | attempt to pull data from the | NULL or NA | ||
350 | * xpcBtePoisonError | specified partition over the | | ||
351 | * xpcBteWriteError | specified channel via a | | ||
352 | * xpcBteAccessError | bte_copy() failed | | ||
353 | * xpcBteTimeOutError | | | ||
354 | * xpcBteXtalkError | | | ||
355 | * xpcBteDirectoryError | | | ||
356 | * xpcBteGenericError | | | ||
357 | * xpcBteUnmappedError | | | ||
358 | * ---------------------+--------------------------------+--------------------- | ||
359 | * xpcUnknownReason | the specified channel to the | NULL or NA | ||
360 | * | specified partition was | | ||
361 | * | unavailable for unknown reasons| | ||
362 | * =====================+================================+===================== | ||
363 | */ | 266 | */ |
364 | 267 | typedef void (*xpc_channel_func) (enum xp_retval reason, short partid, | |
365 | typedef void (*xpc_channel_func) (enum xpc_retval reason, partid_t partid, | ||
366 | int ch_number, void *data, void *key); | 268 | int ch_number, void *data, void *key); |
367 | 269 | ||
368 | typedef void (*xpc_notify_func) (enum xpc_retval reason, partid_t partid, | 270 | /* |
271 | * Define the callout function type used by XPC to notify the user of | ||
272 | * messages received and delivered via the user function registered by | ||
273 | * xpc_send_notify(). | ||
274 | * | ||
275 | * Arguments: | ||
276 | * | ||
277 | * reason - reason code. | ||
278 | * partid - partition ID associated with condition. | ||
279 | * ch_number - channel # associated with condition. | ||
280 | * key - pointer to optional user-defined value provided as the "key" | ||
281 | * argument to xpc_send_notify(). | ||
282 | * | ||
283 | * A reason code of xpMsgDelivered indicates that the message was delivered | ||
284 | * to the intended recipient and that they have acknowledged its receipt by | ||
285 | * calling xpc_received(). | ||
286 | * | ||
287 | * All other reason codes indicate failure. | ||
288 | */ | ||
289 | typedef void (*xpc_notify_func) (enum xp_retval reason, short partid, | ||
369 | int ch_number, void *key); | 290 | int ch_number, void *key); |
370 | 291 | ||
371 | /* | 292 | /* |
@@ -401,57 +322,57 @@ struct xpc_registration { | |||
401 | struct xpc_interface { | 322 | struct xpc_interface { |
402 | void (*connect) (int); | 323 | void (*connect) (int); |
403 | void (*disconnect) (int); | 324 | void (*disconnect) (int); |
404 | enum xpc_retval (*allocate) (partid_t, int, u32, void **); | 325 | enum xp_retval (*allocate) (short, int, u32, void **); |
405 | enum xpc_retval (*send) (partid_t, int, void *); | 326 | enum xp_retval (*send) (short, int, void *); |
406 | enum xpc_retval (*send_notify) (partid_t, int, void *, | 327 | enum xp_retval (*send_notify) (short, int, void *, |
407 | xpc_notify_func, void *); | 328 | xpc_notify_func, void *); |
408 | void (*received) (partid_t, int, void *); | 329 | void (*received) (short, int, void *); |
409 | enum xpc_retval (*partid_to_nasids) (partid_t, void *); | 330 | enum xp_retval (*partid_to_nasids) (short, void *); |
410 | }; | 331 | }; |
411 | 332 | ||
412 | extern struct xpc_interface xpc_interface; | 333 | extern struct xpc_interface xpc_interface; |
413 | 334 | ||
414 | extern void xpc_set_interface(void (*)(int), | 335 | extern void xpc_set_interface(void (*)(int), |
415 | void (*)(int), | 336 | void (*)(int), |
416 | enum xpc_retval (*)(partid_t, int, u32, void **), | 337 | enum xp_retval (*)(short, int, u32, void **), |
417 | enum xpc_retval (*)(partid_t, int, void *), | 338 | enum xp_retval (*)(short, int, void *), |
418 | enum xpc_retval (*)(partid_t, int, void *, | 339 | enum xp_retval (*)(short, int, void *, |
419 | xpc_notify_func, void *), | 340 | xpc_notify_func, void *), |
420 | void (*)(partid_t, int, void *), | 341 | void (*)(short, int, void *), |
421 | enum xpc_retval (*)(partid_t, void *)); | 342 | enum xp_retval (*)(short, void *)); |
422 | extern void xpc_clear_interface(void); | 343 | extern void xpc_clear_interface(void); |
423 | 344 | ||
424 | extern enum xpc_retval xpc_connect(int, xpc_channel_func, void *, u16, | 345 | extern enum xp_retval xpc_connect(int, xpc_channel_func, void *, u16, |
425 | u16, u32, u32); | 346 | u16, u32, u32); |
426 | extern void xpc_disconnect(int); | 347 | extern void xpc_disconnect(int); |
427 | 348 | ||
428 | static inline enum xpc_retval | 349 | static inline enum xp_retval |
429 | xpc_allocate(partid_t partid, int ch_number, u32 flags, void **payload) | 350 | xpc_allocate(short partid, int ch_number, u32 flags, void **payload) |
430 | { | 351 | { |
431 | return xpc_interface.allocate(partid, ch_number, flags, payload); | 352 | return xpc_interface.allocate(partid, ch_number, flags, payload); |
432 | } | 353 | } |
433 | 354 | ||
434 | static inline enum xpc_retval | 355 | static inline enum xp_retval |
435 | xpc_send(partid_t partid, int ch_number, void *payload) | 356 | xpc_send(short partid, int ch_number, void *payload) |
436 | { | 357 | { |
437 | return xpc_interface.send(partid, ch_number, payload); | 358 | return xpc_interface.send(partid, ch_number, payload); |
438 | } | 359 | } |
439 | 360 | ||
440 | static inline enum xpc_retval | 361 | static inline enum xp_retval |
441 | xpc_send_notify(partid_t partid, int ch_number, void *payload, | 362 | xpc_send_notify(short partid, int ch_number, void *payload, |
442 | xpc_notify_func func, void *key) | 363 | xpc_notify_func func, void *key) |
443 | { | 364 | { |
444 | return xpc_interface.send_notify(partid, ch_number, payload, func, key); | 365 | return xpc_interface.send_notify(partid, ch_number, payload, func, key); |
445 | } | 366 | } |
446 | 367 | ||
447 | static inline void | 368 | static inline void |
448 | xpc_received(partid_t partid, int ch_number, void *payload) | 369 | xpc_received(short partid, int ch_number, void *payload) |
449 | { | 370 | { |
450 | return xpc_interface.received(partid, ch_number, payload); | 371 | return xpc_interface.received(partid, ch_number, payload); |
451 | } | 372 | } |
452 | 373 | ||
453 | static inline enum xpc_retval | 374 | static inline enum xp_retval |
454 | xpc_partid_to_nasids(partid_t partid, void *nasids) | 375 | xpc_partid_to_nasids(short partid, void *nasids) |
455 | { | 376 | { |
456 | return xpc_interface.partid_to_nasids(partid, nasids); | 377 | return xpc_interface.partid_to_nasids(partid, nasids); |
457 | } | 378 | } |
diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c index 1fbf99bae963..196480b691a1 100644 --- a/drivers/misc/sgi-xp/xp_main.c +++ b/drivers/misc/sgi-xp/xp_main.c | |||
@@ -42,21 +42,21 @@ EXPORT_SYMBOL_GPL(xpc_registrations); | |||
42 | /* | 42 | /* |
43 | * Initialize the XPC interface to indicate that XPC isn't loaded. | 43 | * Initialize the XPC interface to indicate that XPC isn't loaded. |
44 | */ | 44 | */ |
45 | static enum xpc_retval | 45 | static enum xp_retval |
46 | xpc_notloaded(void) | 46 | xpc_notloaded(void) |
47 | { | 47 | { |
48 | return xpcNotLoaded; | 48 | return xpNotLoaded; |
49 | } | 49 | } |
50 | 50 | ||
51 | struct xpc_interface xpc_interface = { | 51 | struct xpc_interface xpc_interface = { |
52 | (void (*)(int))xpc_notloaded, | 52 | (void (*)(int))xpc_notloaded, |
53 | (void (*)(int))xpc_notloaded, | 53 | (void (*)(int))xpc_notloaded, |
54 | (enum xpc_retval(*)(partid_t, int, u32, void **))xpc_notloaded, | 54 | (enum xp_retval(*)(short, int, u32, void **))xpc_notloaded, |
55 | (enum xpc_retval(*)(partid_t, int, void *))xpc_notloaded, | 55 | (enum xp_retval(*)(short, int, void *))xpc_notloaded, |
56 | (enum xpc_retval(*)(partid_t, int, void *, xpc_notify_func, void *)) | 56 | (enum xp_retval(*)(short, int, void *, xpc_notify_func, void *)) |
57 | xpc_notloaded, | 57 | xpc_notloaded, |
58 | (void (*)(partid_t, int, void *))xpc_notloaded, | 58 | (void (*)(short, int, void *))xpc_notloaded, |
59 | (enum xpc_retval(*)(partid_t, void *))xpc_notloaded | 59 | (enum xp_retval(*)(short, void *))xpc_notloaded |
60 | }; | 60 | }; |
61 | EXPORT_SYMBOL_GPL(xpc_interface); | 61 | EXPORT_SYMBOL_GPL(xpc_interface); |
62 | 62 | ||
@@ -66,12 +66,12 @@ EXPORT_SYMBOL_GPL(xpc_interface); | |||
66 | void | 66 | void |
67 | xpc_set_interface(void (*connect) (int), | 67 | xpc_set_interface(void (*connect) (int), |
68 | void (*disconnect) (int), | 68 | void (*disconnect) (int), |
69 | enum xpc_retval (*allocate) (partid_t, int, u32, void **), | 69 | enum xp_retval (*allocate) (short, int, u32, void **), |
70 | enum xpc_retval (*send) (partid_t, int, void *), | 70 | enum xp_retval (*send) (short, int, void *), |
71 | enum xpc_retval (*send_notify) (partid_t, int, void *, | 71 | enum xp_retval (*send_notify) (short, int, void *, |
72 | xpc_notify_func, void *), | 72 | xpc_notify_func, void *), |
73 | void (*received) (partid_t, int, void *), | 73 | void (*received) (short, int, void *), |
74 | enum xpc_retval (*partid_to_nasids) (partid_t, void *)) | 74 | enum xp_retval (*partid_to_nasids) (short, void *)) |
75 | { | 75 | { |
76 | xpc_interface.connect = connect; | 76 | xpc_interface.connect = connect; |
77 | xpc_interface.disconnect = disconnect; | 77 | xpc_interface.disconnect = disconnect; |
@@ -91,16 +91,16 @@ xpc_clear_interface(void) | |||
91 | { | 91 | { |
92 | xpc_interface.connect = (void (*)(int))xpc_notloaded; | 92 | xpc_interface.connect = (void (*)(int))xpc_notloaded; |
93 | xpc_interface.disconnect = (void (*)(int))xpc_notloaded; | 93 | xpc_interface.disconnect = (void (*)(int))xpc_notloaded; |
94 | xpc_interface.allocate = (enum xpc_retval(*)(partid_t, int, u32, | 94 | xpc_interface.allocate = (enum xp_retval(*)(short, int, u32, |
95 | void **))xpc_notloaded; | 95 | void **))xpc_notloaded; |
96 | xpc_interface.send = (enum xpc_retval(*)(partid_t, int, void *)) | 96 | xpc_interface.send = (enum xp_retval(*)(short, int, void *)) |
97 | xpc_notloaded; | 97 | xpc_notloaded; |
98 | xpc_interface.send_notify = (enum xpc_retval(*)(partid_t, int, void *, | 98 | xpc_interface.send_notify = (enum xp_retval(*)(short, int, void *, |
99 | xpc_notify_func, | 99 | xpc_notify_func, |
100 | void *))xpc_notloaded; | 100 | void *))xpc_notloaded; |
101 | xpc_interface.received = (void (*)(partid_t, int, void *)) | 101 | xpc_interface.received = (void (*)(short, int, void *)) |
102 | xpc_notloaded; | 102 | xpc_notloaded; |
103 | xpc_interface.partid_to_nasids = (enum xpc_retval(*)(partid_t, void *)) | 103 | xpc_interface.partid_to_nasids = (enum xp_retval(*)(short, void *)) |
104 | xpc_notloaded; | 104 | xpc_notloaded; |
105 | } | 105 | } |
106 | EXPORT_SYMBOL_GPL(xpc_clear_interface); | 106 | EXPORT_SYMBOL_GPL(xpc_clear_interface); |
@@ -123,13 +123,13 @@ EXPORT_SYMBOL_GPL(xpc_clear_interface); | |||
123 | * nentries - max #of XPC message entries a message queue can contain. | 123 | * nentries - max #of XPC message entries a message queue can contain. |
124 | * The actual number, which is determined when a connection | 124 | * The actual number, which is determined when a connection |
125 | * is established and may be less then requested, will be | 125 | * is established and may be less then requested, will be |
126 | * passed to the user via the xpcConnected callout. | 126 | * passed to the user via the xpConnected callout. |
127 | * assigned_limit - max number of kthreads allowed to be processing | 127 | * assigned_limit - max number of kthreads allowed to be processing |
128 | * messages (per connection) at any given instant. | 128 | * messages (per connection) at any given instant. |
129 | * idle_limit - max number of kthreads allowed to be idle at any given | 129 | * idle_limit - max number of kthreads allowed to be idle at any given |
130 | * instant. | 130 | * instant. |
131 | */ | 131 | */ |
132 | enum xpc_retval | 132 | enum xp_retval |
133 | xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, | 133 | xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, |
134 | u16 nentries, u32 assigned_limit, u32 idle_limit) | 134 | u16 nentries, u32 assigned_limit, u32 idle_limit) |
135 | { | 135 | { |
@@ -143,12 +143,12 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, | |||
143 | registration = &xpc_registrations[ch_number]; | 143 | registration = &xpc_registrations[ch_number]; |
144 | 144 | ||
145 | if (mutex_lock_interruptible(®istration->mutex) != 0) | 145 | if (mutex_lock_interruptible(®istration->mutex) != 0) |
146 | return xpcInterrupted; | 146 | return xpInterrupted; |
147 | 147 | ||
148 | /* if XPC_CHANNEL_REGISTERED(ch_number) */ | 148 | /* if XPC_CHANNEL_REGISTERED(ch_number) */ |
149 | if (registration->func != NULL) { | 149 | if (registration->func != NULL) { |
150 | mutex_unlock(®istration->mutex); | 150 | mutex_unlock(®istration->mutex); |
151 | return xpcAlreadyRegistered; | 151 | return xpAlreadyRegistered; |
152 | } | 152 | } |
153 | 153 | ||
154 | /* register the channel for connection */ | 154 | /* register the channel for connection */ |
@@ -163,7 +163,7 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, | |||
163 | 163 | ||
164 | xpc_interface.connect(ch_number); | 164 | xpc_interface.connect(ch_number); |
165 | 165 | ||
166 | return xpcSuccess; | 166 | return xpSuccess; |
167 | } | 167 | } |
168 | EXPORT_SYMBOL_GPL(xpc_connect); | 168 | EXPORT_SYMBOL_GPL(xpc_connect); |
169 | 169 | ||
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h index 9eb6d4a3269c..11ac267ed68f 100644 --- a/drivers/misc/sgi-xp/xpc.h +++ b/drivers/misc/sgi-xp/xpc.h | |||
@@ -172,13 +172,13 @@ struct xpc_vars { | |||
172 | (_version >= _XPC_VERSION(3, 1)) | 172 | (_version >= _XPC_VERSION(3, 1)) |
173 | 173 | ||
174 | static inline int | 174 | static inline int |
175 | xpc_hb_allowed(partid_t partid, struct xpc_vars *vars) | 175 | xpc_hb_allowed(short partid, struct xpc_vars *vars) |
176 | { | 176 | { |
177 | return ((vars->heartbeating_to_mask & (1UL << partid)) != 0); | 177 | return ((vars->heartbeating_to_mask & (1UL << partid)) != 0); |
178 | } | 178 | } |
179 | 179 | ||
180 | static inline void | 180 | static inline void |
181 | xpc_allow_hb(partid_t partid, struct xpc_vars *vars) | 181 | xpc_allow_hb(short partid, struct xpc_vars *vars) |
182 | { | 182 | { |
183 | u64 old_mask, new_mask; | 183 | u64 old_mask, new_mask; |
184 | 184 | ||
@@ -190,7 +190,7 @@ xpc_allow_hb(partid_t partid, struct xpc_vars *vars) | |||
190 | } | 190 | } |
191 | 191 | ||
192 | static inline void | 192 | static inline void |
193 | xpc_disallow_hb(partid_t partid, struct xpc_vars *vars) | 193 | xpc_disallow_hb(short partid, struct xpc_vars *vars) |
194 | { | 194 | { |
195 | u64 old_mask, new_mask; | 195 | u64 old_mask, new_mask; |
196 | 196 | ||
@@ -408,11 +408,11 @@ struct xpc_notify { | |||
408 | * messages. | 408 | * messages. |
409 | */ | 409 | */ |
410 | struct xpc_channel { | 410 | struct xpc_channel { |
411 | partid_t partid; /* ID of remote partition connected */ | 411 | short partid; /* ID of remote partition connected */ |
412 | spinlock_t lock; /* lock for updating this structure */ | 412 | spinlock_t lock; /* lock for updating this structure */ |
413 | u32 flags; /* general flags */ | 413 | u32 flags; /* general flags */ |
414 | 414 | ||
415 | enum xpc_retval reason; /* reason why channel is disconnect'g */ | 415 | enum xp_retval reason; /* reason why channel is disconnect'g */ |
416 | int reason_line; /* line# disconnect initiated from */ | 416 | int reason_line; /* line# disconnect initiated from */ |
417 | 417 | ||
418 | u16 number; /* channel # */ | 418 | u16 number; /* channel # */ |
@@ -522,7 +522,7 @@ struct xpc_partition { | |||
522 | spinlock_t act_lock; /* protect updating of act_state */ | 522 | spinlock_t act_lock; /* protect updating of act_state */ |
523 | u8 act_state; /* from XPC HB viewpoint */ | 523 | u8 act_state; /* from XPC HB viewpoint */ |
524 | u8 remote_vars_version; /* version# of partition's vars */ | 524 | u8 remote_vars_version; /* version# of partition's vars */ |
525 | enum xpc_retval reason; /* reason partition is deactivating */ | 525 | enum xp_retval reason; /* reason partition is deactivating */ |
526 | int reason_line; /* line# deactivation initiated from */ | 526 | int reason_line; /* line# deactivation initiated from */ |
527 | int reactivate_nasid; /* nasid in partition to reactivate */ | 527 | int reactivate_nasid; /* nasid in partition to reactivate */ |
528 | 528 | ||
@@ -615,7 +615,7 @@ struct xpc_partition { | |||
615 | /* interval in seconds to print 'waiting disengagement' messages */ | 615 | /* interval in seconds to print 'waiting disengagement' messages */ |
616 | #define XPC_DISENGAGE_PRINTMSG_INTERVAL 10 | 616 | #define XPC_DISENGAGE_PRINTMSG_INTERVAL 10 |
617 | 617 | ||
618 | #define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0])) | 618 | #define XPC_PARTID(_p) ((short)((_p) - &xpc_partitions[0])) |
619 | 619 | ||
620 | /* found in xp_main.c */ | 620 | /* found in xp_main.c */ |
621 | extern struct xpc_registration xpc_registrations[]; | 621 | extern struct xpc_registration xpc_registrations[]; |
@@ -646,31 +646,31 @@ extern void xpc_allow_IPI_ops(void); | |||
646 | extern void xpc_restrict_IPI_ops(void); | 646 | extern void xpc_restrict_IPI_ops(void); |
647 | extern int xpc_identify_act_IRQ_sender(void); | 647 | extern int xpc_identify_act_IRQ_sender(void); |
648 | extern int xpc_partition_disengaged(struct xpc_partition *); | 648 | extern int xpc_partition_disengaged(struct xpc_partition *); |
649 | extern enum xpc_retval xpc_mark_partition_active(struct xpc_partition *); | 649 | extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *); |
650 | extern void xpc_mark_partition_inactive(struct xpc_partition *); | 650 | extern void xpc_mark_partition_inactive(struct xpc_partition *); |
651 | extern void xpc_discovery(void); | 651 | extern void xpc_discovery(void); |
652 | extern void xpc_check_remote_hb(void); | 652 | extern void xpc_check_remote_hb(void); |
653 | extern void xpc_deactivate_partition(const int, struct xpc_partition *, | 653 | extern void xpc_deactivate_partition(const int, struct xpc_partition *, |
654 | enum xpc_retval); | 654 | enum xp_retval); |
655 | extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *); | 655 | extern enum xp_retval xpc_initiate_partid_to_nasids(short, void *); |
656 | 656 | ||
657 | /* found in xpc_channel.c */ | 657 | /* found in xpc_channel.c */ |
658 | extern void xpc_initiate_connect(int); | 658 | extern void xpc_initiate_connect(int); |
659 | extern void xpc_initiate_disconnect(int); | 659 | extern void xpc_initiate_disconnect(int); |
660 | extern enum xpc_retval xpc_initiate_allocate(partid_t, int, u32, void **); | 660 | extern enum xp_retval xpc_initiate_allocate(short, int, u32, void **); |
661 | extern enum xpc_retval xpc_initiate_send(partid_t, int, void *); | 661 | extern enum xp_retval xpc_initiate_send(short, int, void *); |
662 | extern enum xpc_retval xpc_initiate_send_notify(partid_t, int, void *, | 662 | extern enum xp_retval xpc_initiate_send_notify(short, int, void *, |
663 | xpc_notify_func, void *); | 663 | xpc_notify_func, void *); |
664 | extern void xpc_initiate_received(partid_t, int, void *); | 664 | extern void xpc_initiate_received(short, int, void *); |
665 | extern enum xpc_retval xpc_setup_infrastructure(struct xpc_partition *); | 665 | extern enum xp_retval xpc_setup_infrastructure(struct xpc_partition *); |
666 | extern enum xpc_retval xpc_pull_remote_vars_part(struct xpc_partition *); | 666 | extern enum xp_retval xpc_pull_remote_vars_part(struct xpc_partition *); |
667 | extern void xpc_process_channel_activity(struct xpc_partition *); | 667 | extern void xpc_process_channel_activity(struct xpc_partition *); |
668 | extern void xpc_connected_callout(struct xpc_channel *); | 668 | extern void xpc_connected_callout(struct xpc_channel *); |
669 | extern void xpc_deliver_msg(struct xpc_channel *); | 669 | extern void xpc_deliver_msg(struct xpc_channel *); |
670 | extern void xpc_disconnect_channel(const int, struct xpc_channel *, | 670 | extern void xpc_disconnect_channel(const int, struct xpc_channel *, |
671 | enum xpc_retval, unsigned long *); | 671 | enum xp_retval, unsigned long *); |
672 | extern void xpc_disconnect_callout(struct xpc_channel *, enum xpc_retval); | 672 | extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval); |
673 | extern void xpc_partition_going_down(struct xpc_partition *, enum xpc_retval); | 673 | extern void xpc_partition_going_down(struct xpc_partition *, enum xp_retval); |
674 | extern void xpc_teardown_infrastructure(struct xpc_partition *); | 674 | extern void xpc_teardown_infrastructure(struct xpc_partition *); |
675 | 675 | ||
676 | static inline void | 676 | static inline void |
@@ -901,7 +901,7 @@ xpc_IPI_receive(AMO_t *amo) | |||
901 | return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR); | 901 | return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR); |
902 | } | 902 | } |
903 | 903 | ||
904 | static inline enum xpc_retval | 904 | static inline enum xp_retval |
905 | xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector) | 905 | xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector) |
906 | { | 906 | { |
907 | int ret = 0; | 907 | int ret = 0; |
@@ -923,7 +923,7 @@ xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector) | |||
923 | 923 | ||
924 | local_irq_restore(irq_flags); | 924 | local_irq_restore(irq_flags); |
925 | 925 | ||
926 | return ((ret == 0) ? xpcSuccess : xpcPioReadError); | 926 | return ((ret == 0) ? xpSuccess : xpPioReadError); |
927 | } | 927 | } |
928 | 928 | ||
929 | /* | 929 | /* |
@@ -992,7 +992,7 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string, | |||
992 | unsigned long *irq_flags) | 992 | unsigned long *irq_flags) |
993 | { | 993 | { |
994 | struct xpc_partition *part = &xpc_partitions[ch->partid]; | 994 | struct xpc_partition *part = &xpc_partitions[ch->partid]; |
995 | enum xpc_retval ret; | 995 | enum xp_retval ret; |
996 | 996 | ||
997 | if (likely(part->act_state != XPC_P_DEACTIVATING)) { | 997 | if (likely(part->act_state != XPC_P_DEACTIVATING)) { |
998 | ret = xpc_IPI_send(part->remote_IPI_amo_va, | 998 | ret = xpc_IPI_send(part->remote_IPI_amo_va, |
@@ -1001,7 +1001,7 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string, | |||
1001 | part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY); | 1001 | part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY); |
1002 | dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n", | 1002 | dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n", |
1003 | ipi_flag_string, ch->partid, ch->number, ret); | 1003 | ipi_flag_string, ch->partid, ch->number, ret); |
1004 | if (unlikely(ret != xpcSuccess)) { | 1004 | if (unlikely(ret != xpSuccess)) { |
1005 | if (irq_flags != NULL) | 1005 | if (irq_flags != NULL) |
1006 | spin_unlock_irqrestore(&ch->lock, *irq_flags); | 1006 | spin_unlock_irqrestore(&ch->lock, *irq_flags); |
1007 | XPC_DEACTIVATE_PARTITION(part, ret); | 1007 | XPC_DEACTIVATE_PARTITION(part, ret); |
@@ -1123,41 +1123,10 @@ xpc_IPI_init(int index) | |||
1123 | return amo; | 1123 | return amo; |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | static inline enum xpc_retval | 1126 | static inline enum xp_retval |
1127 | xpc_map_bte_errors(bte_result_t error) | 1127 | xpc_map_bte_errors(bte_result_t error) |
1128 | { | 1128 | { |
1129 | if (error == BTE_SUCCESS) | 1129 | return ((error == BTE_SUCCESS) ? xpSuccess : xpBteCopyError); |
1130 | return xpcSuccess; | ||
1131 | |||
1132 | if (is_shub2()) { | ||
1133 | if (BTE_VALID_SH2_ERROR(error)) | ||
1134 | return xpcBteSh2Start + error; | ||
1135 | return xpcBteUnmappedError; | ||
1136 | } | ||
1137 | switch (error) { | ||
1138 | case BTE_SUCCESS: | ||
1139 | return xpcSuccess; | ||
1140 | case BTEFAIL_DIR: | ||
1141 | return xpcBteDirectoryError; | ||
1142 | case BTEFAIL_POISON: | ||
1143 | return xpcBtePoisonError; | ||
1144 | case BTEFAIL_WERR: | ||
1145 | return xpcBteWriteError; | ||
1146 | case BTEFAIL_ACCESS: | ||
1147 | return xpcBteAccessError; | ||
1148 | case BTEFAIL_PWERR: | ||
1149 | return xpcBtePWriteError; | ||
1150 | case BTEFAIL_PRERR: | ||
1151 | return xpcBtePReadError; | ||
1152 | case BTEFAIL_TOUT: | ||
1153 | return xpcBteTimeOutError; | ||
1154 | case BTEFAIL_XTERR: | ||
1155 | return xpcBteXtalkError; | ||
1156 | case BTEFAIL_NOTAVAIL: | ||
1157 | return xpcBteNotAvailable; | ||
1158 | default: | ||
1159 | return xpcBteUnmappedError; | ||
1160 | } | ||
1161 | } | 1130 | } |
1162 | 1131 | ||
1163 | /* | 1132 | /* |
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c index bfcb9ea968e9..9c90c2d55c08 100644 --- a/drivers/misc/sgi-xp/xpc_channel.c +++ b/drivers/misc/sgi-xp/xpc_channel.c | |||
@@ -53,7 +53,7 @@ xpc_kzalloc_cacheline_aligned(size_t size, gfp_t flags, void **base) | |||
53 | * Set up the initial values for the XPartition Communication channels. | 53 | * Set up the initial values for the XPartition Communication channels. |
54 | */ | 54 | */ |
55 | static void | 55 | static void |
56 | xpc_initialize_channels(struct xpc_partition *part, partid_t partid) | 56 | xpc_initialize_channels(struct xpc_partition *part, short partid) |
57 | { | 57 | { |
58 | int ch_number; | 58 | int ch_number; |
59 | struct xpc_channel *ch; | 59 | struct xpc_channel *ch; |
@@ -90,12 +90,12 @@ xpc_initialize_channels(struct xpc_partition *part, partid_t partid) | |||
90 | * Setup the infrastructure necessary to support XPartition Communication | 90 | * Setup the infrastructure necessary to support XPartition Communication |
91 | * between the specified remote partition and the local one. | 91 | * between the specified remote partition and the local one. |
92 | */ | 92 | */ |
93 | enum xpc_retval | 93 | enum xp_retval |
94 | xpc_setup_infrastructure(struct xpc_partition *part) | 94 | xpc_setup_infrastructure(struct xpc_partition *part) |
95 | { | 95 | { |
96 | int ret, cpuid; | 96 | int ret, cpuid; |
97 | struct timer_list *timer; | 97 | struct timer_list *timer; |
98 | partid_t partid = XPC_PARTID(part); | 98 | short partid = XPC_PARTID(part); |
99 | 99 | ||
100 | /* | 100 | /* |
101 | * Zero out MOST of the entry for this partition. Only the fields | 101 | * Zero out MOST of the entry for this partition. Only the fields |
@@ -114,7 +114,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
114 | GFP_KERNEL); | 114 | GFP_KERNEL); |
115 | if (part->channels == NULL) { | 115 | if (part->channels == NULL) { |
116 | dev_err(xpc_chan, "can't get memory for channels\n"); | 116 | dev_err(xpc_chan, "can't get memory for channels\n"); |
117 | return xpcNoMemory; | 117 | return xpNoMemory; |
118 | } | 118 | } |
119 | 119 | ||
120 | part->nchannels = XPC_NCHANNELS; | 120 | part->nchannels = XPC_NCHANNELS; |
@@ -129,7 +129,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
129 | part->channels = NULL; | 129 | part->channels = NULL; |
130 | dev_err(xpc_chan, "can't get memory for local get/put " | 130 | dev_err(xpc_chan, "can't get memory for local get/put " |
131 | "values\n"); | 131 | "values\n"); |
132 | return xpcNoMemory; | 132 | return xpNoMemory; |
133 | } | 133 | } |
134 | 134 | ||
135 | part->remote_GPs = xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE, | 135 | part->remote_GPs = xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE, |
@@ -143,7 +143,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
143 | part->local_GPs = NULL; | 143 | part->local_GPs = NULL; |
144 | kfree(part->channels); | 144 | kfree(part->channels); |
145 | part->channels = NULL; | 145 | part->channels = NULL; |
146 | return xpcNoMemory; | 146 | return xpNoMemory; |
147 | } | 147 | } |
148 | 148 | ||
149 | /* allocate all the required open and close args */ | 149 | /* allocate all the required open and close args */ |
@@ -159,7 +159,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
159 | part->local_GPs = NULL; | 159 | part->local_GPs = NULL; |
160 | kfree(part->channels); | 160 | kfree(part->channels); |
161 | part->channels = NULL; | 161 | part->channels = NULL; |
162 | return xpcNoMemory; | 162 | return xpNoMemory; |
163 | } | 163 | } |
164 | 164 | ||
165 | part->remote_openclose_args = | 165 | part->remote_openclose_args = |
@@ -175,7 +175,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
175 | part->local_GPs = NULL; | 175 | part->local_GPs = NULL; |
176 | kfree(part->channels); | 176 | kfree(part->channels); |
177 | part->channels = NULL; | 177 | part->channels = NULL; |
178 | return xpcNoMemory; | 178 | return xpNoMemory; |
179 | } | 179 | } |
180 | 180 | ||
181 | xpc_initialize_channels(part, partid); | 181 | xpc_initialize_channels(part, partid); |
@@ -209,7 +209,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
209 | part->local_GPs = NULL; | 209 | part->local_GPs = NULL; |
210 | kfree(part->channels); | 210 | kfree(part->channels); |
211 | part->channels = NULL; | 211 | part->channels = NULL; |
212 | return xpcLackOfResources; | 212 | return xpLackOfResources; |
213 | } | 213 | } |
214 | 214 | ||
215 | /* Setup a timer to check for dropped IPIs */ | 215 | /* Setup a timer to check for dropped IPIs */ |
@@ -243,7 +243,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
243 | xpc_vars_part[partid].nchannels = part->nchannels; | 243 | xpc_vars_part[partid].nchannels = part->nchannels; |
244 | xpc_vars_part[partid].magic = XPC_VP_MAGIC1; | 244 | xpc_vars_part[partid].magic = XPC_VP_MAGIC1; |
245 | 245 | ||
246 | return xpcSuccess; | 246 | return xpSuccess; |
247 | } | 247 | } |
248 | 248 | ||
249 | /* | 249 | /* |
@@ -254,7 +254,7 @@ xpc_setup_infrastructure(struct xpc_partition *part) | |||
254 | * dst must be a cacheline aligned virtual address on this partition. | 254 | * dst must be a cacheline aligned virtual address on this partition. |
255 | * cnt must be an cacheline sized | 255 | * cnt must be an cacheline sized |
256 | */ | 256 | */ |
257 | static enum xpc_retval | 257 | static enum xp_retval |
258 | xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst, | 258 | xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst, |
259 | const void *src, size_t cnt) | 259 | const void *src, size_t cnt) |
260 | { | 260 | { |
@@ -270,7 +270,7 @@ xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst, | |||
270 | bte_ret = xp_bte_copy((u64)src, (u64)dst, (u64)cnt, | 270 | bte_ret = xp_bte_copy((u64)src, (u64)dst, (u64)cnt, |
271 | (BTE_NORMAL | BTE_WACQUIRE), NULL); | 271 | (BTE_NORMAL | BTE_WACQUIRE), NULL); |
272 | if (bte_ret == BTE_SUCCESS) | 272 | if (bte_ret == BTE_SUCCESS) |
273 | return xpcSuccess; | 273 | return xpSuccess; |
274 | 274 | ||
275 | dev_dbg(xpc_chan, "xp_bte_copy() from partition %d failed, ret=%d\n", | 275 | dev_dbg(xpc_chan, "xp_bte_copy() from partition %d failed, ret=%d\n", |
276 | XPC_PARTID(part), bte_ret); | 276 | XPC_PARTID(part), bte_ret); |
@@ -282,7 +282,7 @@ xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst, | |||
282 | * Pull the remote per partition specific variables from the specified | 282 | * Pull the remote per partition specific variables from the specified |
283 | * partition. | 283 | * partition. |
284 | */ | 284 | */ |
285 | enum xpc_retval | 285 | enum xp_retval |
286 | xpc_pull_remote_vars_part(struct xpc_partition *part) | 286 | xpc_pull_remote_vars_part(struct xpc_partition *part) |
287 | { | 287 | { |
288 | u8 buffer[L1_CACHE_BYTES * 2]; | 288 | u8 buffer[L1_CACHE_BYTES * 2]; |
@@ -290,8 +290,8 @@ xpc_pull_remote_vars_part(struct xpc_partition *part) | |||
290 | (struct xpc_vars_part *)L1_CACHE_ALIGN((u64)buffer); | 290 | (struct xpc_vars_part *)L1_CACHE_ALIGN((u64)buffer); |
291 | struct xpc_vars_part *pulled_entry; | 291 | struct xpc_vars_part *pulled_entry; |
292 | u64 remote_entry_cacheline_pa, remote_entry_pa; | 292 | u64 remote_entry_cacheline_pa, remote_entry_pa; |
293 | partid_t partid = XPC_PARTID(part); | 293 | short partid = XPC_PARTID(part); |
294 | enum xpc_retval ret; | 294 | enum xp_retval ret; |
295 | 295 | ||
296 | /* pull the cacheline that contains the variables we're interested in */ | 296 | /* pull the cacheline that contains the variables we're interested in */ |
297 | 297 | ||
@@ -311,7 +311,7 @@ xpc_pull_remote_vars_part(struct xpc_partition *part) | |||
311 | ret = xpc_pull_remote_cachelines(part, pulled_entry_cacheline, | 311 | ret = xpc_pull_remote_cachelines(part, pulled_entry_cacheline, |
312 | (void *)remote_entry_cacheline_pa, | 312 | (void *)remote_entry_cacheline_pa, |
313 | L1_CACHE_BYTES); | 313 | L1_CACHE_BYTES); |
314 | if (ret != xpcSuccess) { | 314 | if (ret != xpSuccess) { |
315 | dev_dbg(xpc_chan, "failed to pull XPC vars_part from " | 315 | dev_dbg(xpc_chan, "failed to pull XPC vars_part from " |
316 | "partition %d, ret=%d\n", partid, ret); | 316 | "partition %d, ret=%d\n", partid, ret); |
317 | return ret; | 317 | return ret; |
@@ -326,11 +326,11 @@ xpc_pull_remote_vars_part(struct xpc_partition *part) | |||
326 | dev_dbg(xpc_chan, "partition %d's XPC vars_part for " | 326 | dev_dbg(xpc_chan, "partition %d's XPC vars_part for " |
327 | "partition %d has bad magic value (=0x%lx)\n", | 327 | "partition %d has bad magic value (=0x%lx)\n", |
328 | partid, sn_partition_id, pulled_entry->magic); | 328 | partid, sn_partition_id, pulled_entry->magic); |
329 | return xpcBadMagic; | 329 | return xpBadMagic; |
330 | } | 330 | } |
331 | 331 | ||
332 | /* they've not been initialized yet */ | 332 | /* they've not been initialized yet */ |
333 | return xpcRetry; | 333 | return xpRetry; |
334 | } | 334 | } |
335 | 335 | ||
336 | if (xpc_vars_part[partid].magic == XPC_VP_MAGIC1) { | 336 | if (xpc_vars_part[partid].magic == XPC_VP_MAGIC1) { |
@@ -344,7 +344,7 @@ xpc_pull_remote_vars_part(struct xpc_partition *part) | |||
344 | dev_err(xpc_chan, "partition %d's XPC vars_part for " | 344 | dev_err(xpc_chan, "partition %d's XPC vars_part for " |
345 | "partition %d are not valid\n", partid, | 345 | "partition %d are not valid\n", partid, |
346 | sn_partition_id); | 346 | sn_partition_id); |
347 | return xpcInvalidAddress; | 347 | return xpInvalidAddress; |
348 | } | 348 | } |
349 | 349 | ||
350 | /* the variables we imported look to be valid */ | 350 | /* the variables we imported look to be valid */ |
@@ -366,9 +366,9 @@ xpc_pull_remote_vars_part(struct xpc_partition *part) | |||
366 | } | 366 | } |
367 | 367 | ||
368 | if (pulled_entry->magic == XPC_VP_MAGIC1) | 368 | if (pulled_entry->magic == XPC_VP_MAGIC1) |
369 | return xpcRetry; | 369 | return xpRetry; |
370 | 370 | ||
371 | return xpcSuccess; | 371 | return xpSuccess; |
372 | } | 372 | } |
373 | 373 | ||
374 | /* | 374 | /* |
@@ -379,7 +379,7 @@ xpc_get_IPI_flags(struct xpc_partition *part) | |||
379 | { | 379 | { |
380 | unsigned long irq_flags; | 380 | unsigned long irq_flags; |
381 | u64 IPI_amo; | 381 | u64 IPI_amo; |
382 | enum xpc_retval ret; | 382 | enum xp_retval ret; |
383 | 383 | ||
384 | /* | 384 | /* |
385 | * See if there are any IPI flags to be handled. | 385 | * See if there are any IPI flags to be handled. |
@@ -398,7 +398,7 @@ xpc_get_IPI_flags(struct xpc_partition *part) | |||
398 | (void *)part-> | 398 | (void *)part-> |
399 | remote_openclose_args_pa, | 399 | remote_openclose_args_pa, |
400 | XPC_OPENCLOSE_ARGS_SIZE); | 400 | XPC_OPENCLOSE_ARGS_SIZE); |
401 | if (ret != xpcSuccess) { | 401 | if (ret != xpSuccess) { |
402 | XPC_DEACTIVATE_PARTITION(part, ret); | 402 | XPC_DEACTIVATE_PARTITION(part, ret); |
403 | 403 | ||
404 | dev_dbg(xpc_chan, "failed to pull openclose args from " | 404 | dev_dbg(xpc_chan, "failed to pull openclose args from " |
@@ -414,7 +414,7 @@ xpc_get_IPI_flags(struct xpc_partition *part) | |||
414 | ret = xpc_pull_remote_cachelines(part, part->remote_GPs, | 414 | ret = xpc_pull_remote_cachelines(part, part->remote_GPs, |
415 | (void *)part->remote_GPs_pa, | 415 | (void *)part->remote_GPs_pa, |
416 | XPC_GP_SIZE); | 416 | XPC_GP_SIZE); |
417 | if (ret != xpcSuccess) { | 417 | if (ret != xpSuccess) { |
418 | XPC_DEACTIVATE_PARTITION(part, ret); | 418 | XPC_DEACTIVATE_PARTITION(part, ret); |
419 | 419 | ||
420 | dev_dbg(xpc_chan, "failed to pull GPs from partition " | 420 | dev_dbg(xpc_chan, "failed to pull GPs from partition " |
@@ -431,7 +431,7 @@ xpc_get_IPI_flags(struct xpc_partition *part) | |||
431 | /* | 431 | /* |
432 | * Allocate the local message queue and the notify queue. | 432 | * Allocate the local message queue and the notify queue. |
433 | */ | 433 | */ |
434 | static enum xpc_retval | 434 | static enum xp_retval |
435 | xpc_allocate_local_msgqueue(struct xpc_channel *ch) | 435 | xpc_allocate_local_msgqueue(struct xpc_channel *ch) |
436 | { | 436 | { |
437 | unsigned long irq_flags; | 437 | unsigned long irq_flags; |
@@ -464,18 +464,18 @@ xpc_allocate_local_msgqueue(struct xpc_channel *ch) | |||
464 | ch->local_nentries = nentries; | 464 | ch->local_nentries = nentries; |
465 | } | 465 | } |
466 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 466 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
467 | return xpcSuccess; | 467 | return xpSuccess; |
468 | } | 468 | } |
469 | 469 | ||
470 | dev_dbg(xpc_chan, "can't get memory for local message queue and notify " | 470 | dev_dbg(xpc_chan, "can't get memory for local message queue and notify " |
471 | "queue, partid=%d, channel=%d\n", ch->partid, ch->number); | 471 | "queue, partid=%d, channel=%d\n", ch->partid, ch->number); |
472 | return xpcNoMemory; | 472 | return xpNoMemory; |
473 | } | 473 | } |
474 | 474 | ||
475 | /* | 475 | /* |
476 | * Allocate the cached remote message queue. | 476 | * Allocate the cached remote message queue. |
477 | */ | 477 | */ |
478 | static enum xpc_retval | 478 | static enum xp_retval |
479 | xpc_allocate_remote_msgqueue(struct xpc_channel *ch) | 479 | xpc_allocate_remote_msgqueue(struct xpc_channel *ch) |
480 | { | 480 | { |
481 | unsigned long irq_flags; | 481 | unsigned long irq_flags; |
@@ -502,12 +502,12 @@ xpc_allocate_remote_msgqueue(struct xpc_channel *ch) | |||
502 | ch->remote_nentries = nentries; | 502 | ch->remote_nentries = nentries; |
503 | } | 503 | } |
504 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 504 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
505 | return xpcSuccess; | 505 | return xpSuccess; |
506 | } | 506 | } |
507 | 507 | ||
508 | dev_dbg(xpc_chan, "can't get memory for cached remote message queue, " | 508 | dev_dbg(xpc_chan, "can't get memory for cached remote message queue, " |
509 | "partid=%d, channel=%d\n", ch->partid, ch->number); | 509 | "partid=%d, channel=%d\n", ch->partid, ch->number); |
510 | return xpcNoMemory; | 510 | return xpNoMemory; |
511 | } | 511 | } |
512 | 512 | ||
513 | /* | 513 | /* |
@@ -515,20 +515,20 @@ xpc_allocate_remote_msgqueue(struct xpc_channel *ch) | |||
515 | * | 515 | * |
516 | * Note: Assumes all of the channel sizes are filled in. | 516 | * Note: Assumes all of the channel sizes are filled in. |
517 | */ | 517 | */ |
518 | static enum xpc_retval | 518 | static enum xp_retval |
519 | xpc_allocate_msgqueues(struct xpc_channel *ch) | 519 | xpc_allocate_msgqueues(struct xpc_channel *ch) |
520 | { | 520 | { |
521 | unsigned long irq_flags; | 521 | unsigned long irq_flags; |
522 | enum xpc_retval ret; | 522 | enum xp_retval ret; |
523 | 523 | ||
524 | DBUG_ON(ch->flags & XPC_C_SETUP); | 524 | DBUG_ON(ch->flags & XPC_C_SETUP); |
525 | 525 | ||
526 | ret = xpc_allocate_local_msgqueue(ch); | 526 | ret = xpc_allocate_local_msgqueue(ch); |
527 | if (ret != xpcSuccess) | 527 | if (ret != xpSuccess) |
528 | return ret; | 528 | return ret; |
529 | 529 | ||
530 | ret = xpc_allocate_remote_msgqueue(ch); | 530 | ret = xpc_allocate_remote_msgqueue(ch); |
531 | if (ret != xpcSuccess) { | 531 | if (ret != xpSuccess) { |
532 | kfree(ch->local_msgqueue_base); | 532 | kfree(ch->local_msgqueue_base); |
533 | ch->local_msgqueue = NULL; | 533 | ch->local_msgqueue = NULL; |
534 | kfree(ch->notify_queue); | 534 | kfree(ch->notify_queue); |
@@ -540,7 +540,7 @@ xpc_allocate_msgqueues(struct xpc_channel *ch) | |||
540 | ch->flags |= XPC_C_SETUP; | 540 | ch->flags |= XPC_C_SETUP; |
541 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 541 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
542 | 542 | ||
543 | return xpcSuccess; | 543 | return xpSuccess; |
544 | } | 544 | } |
545 | 545 | ||
546 | /* | 546 | /* |
@@ -552,7 +552,7 @@ xpc_allocate_msgqueues(struct xpc_channel *ch) | |||
552 | static void | 552 | static void |
553 | xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags) | 553 | xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags) |
554 | { | 554 | { |
555 | enum xpc_retval ret; | 555 | enum xp_retval ret; |
556 | 556 | ||
557 | DBUG_ON(!spin_is_locked(&ch->lock)); | 557 | DBUG_ON(!spin_is_locked(&ch->lock)); |
558 | 558 | ||
@@ -568,7 +568,7 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags) | |||
568 | ret = xpc_allocate_msgqueues(ch); | 568 | ret = xpc_allocate_msgqueues(ch); |
569 | spin_lock_irqsave(&ch->lock, *irq_flags); | 569 | spin_lock_irqsave(&ch->lock, *irq_flags); |
570 | 570 | ||
571 | if (ret != xpcSuccess) | 571 | if (ret != xpSuccess) |
572 | XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags); | 572 | XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags); |
573 | 573 | ||
574 | if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) | 574 | if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) |
@@ -603,7 +603,7 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags) | |||
603 | * Notify those who wanted to be notified upon delivery of their message. | 603 | * Notify those who wanted to be notified upon delivery of their message. |
604 | */ | 604 | */ |
605 | static void | 605 | static void |
606 | xpc_notify_senders(struct xpc_channel *ch, enum xpc_retval reason, s64 put) | 606 | xpc_notify_senders(struct xpc_channel *ch, enum xp_retval reason, s64 put) |
607 | { | 607 | { |
608 | struct xpc_notify *notify; | 608 | struct xpc_notify *notify; |
609 | u8 notify_type; | 609 | u8 notify_type; |
@@ -748,7 +748,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags) | |||
748 | 748 | ||
749 | if (ch->flags & XPC_C_DISCONNECTINGCALLOUT_MADE) { | 749 | if (ch->flags & XPC_C_DISCONNECTINGCALLOUT_MADE) { |
750 | spin_unlock_irqrestore(&ch->lock, *irq_flags); | 750 | spin_unlock_irqrestore(&ch->lock, *irq_flags); |
751 | xpc_disconnect_callout(ch, xpcDisconnected); | 751 | xpc_disconnect_callout(ch, xpDisconnected); |
752 | spin_lock_irqsave(&ch->lock, *irq_flags); | 752 | spin_lock_irqsave(&ch->lock, *irq_flags); |
753 | } | 753 | } |
754 | 754 | ||
@@ -791,7 +791,7 @@ xpc_process_openclose_IPI(struct xpc_partition *part, int ch_number, | |||
791 | struct xpc_openclose_args *args = | 791 | struct xpc_openclose_args *args = |
792 | &part->remote_openclose_args[ch_number]; | 792 | &part->remote_openclose_args[ch_number]; |
793 | struct xpc_channel *ch = &part->channels[ch_number]; | 793 | struct xpc_channel *ch = &part->channels[ch_number]; |
794 | enum xpc_retval reason; | 794 | enum xp_retval reason; |
795 | 795 | ||
796 | spin_lock_irqsave(&ch->lock, irq_flags); | 796 | spin_lock_irqsave(&ch->lock, irq_flags); |
797 | 797 | ||
@@ -871,10 +871,10 @@ again: | |||
871 | 871 | ||
872 | if (!(ch->flags & XPC_C_DISCONNECTING)) { | 872 | if (!(ch->flags & XPC_C_DISCONNECTING)) { |
873 | reason = args->reason; | 873 | reason = args->reason; |
874 | if (reason <= xpcSuccess || reason > xpcUnknownReason) | 874 | if (reason <= xpSuccess || reason > xpUnknownReason) |
875 | reason = xpcUnknownReason; | 875 | reason = xpUnknownReason; |
876 | else if (reason == xpcUnregistering) | 876 | else if (reason == xpUnregistering) |
877 | reason = xpcOtherUnregistering; | 877 | reason = xpOtherUnregistering; |
878 | 878 | ||
879 | XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags); | 879 | XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags); |
880 | 880 | ||
@@ -961,7 +961,7 @@ again: | |||
961 | 961 | ||
962 | if (ch->flags & XPC_C_OPENREQUEST) { | 962 | if (ch->flags & XPC_C_OPENREQUEST) { |
963 | if (args->msg_size != ch->msg_size) { | 963 | if (args->msg_size != ch->msg_size) { |
964 | XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes, | 964 | XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes, |
965 | &irq_flags); | 965 | &irq_flags); |
966 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 966 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
967 | return; | 967 | return; |
@@ -991,7 +991,7 @@ again: | |||
991 | return; | 991 | return; |
992 | } | 992 | } |
993 | if (!(ch->flags & XPC_C_OPENREQUEST)) { | 993 | if (!(ch->flags & XPC_C_OPENREQUEST)) { |
994 | XPC_DISCONNECT_CHANNEL(ch, xpcOpenCloseError, | 994 | XPC_DISCONNECT_CHANNEL(ch, xpOpenCloseError, |
995 | &irq_flags); | 995 | &irq_flags); |
996 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 996 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
997 | return; | 997 | return; |
@@ -1042,18 +1042,18 @@ again: | |||
1042 | /* | 1042 | /* |
1043 | * Attempt to establish a channel connection to a remote partition. | 1043 | * Attempt to establish a channel connection to a remote partition. |
1044 | */ | 1044 | */ |
1045 | static enum xpc_retval | 1045 | static enum xp_retval |
1046 | xpc_connect_channel(struct xpc_channel *ch) | 1046 | xpc_connect_channel(struct xpc_channel *ch) |
1047 | { | 1047 | { |
1048 | unsigned long irq_flags; | 1048 | unsigned long irq_flags; |
1049 | struct xpc_registration *registration = &xpc_registrations[ch->number]; | 1049 | struct xpc_registration *registration = &xpc_registrations[ch->number]; |
1050 | 1050 | ||
1051 | if (mutex_trylock(®istration->mutex) == 0) | 1051 | if (mutex_trylock(®istration->mutex) == 0) |
1052 | return xpcRetry; | 1052 | return xpRetry; |
1053 | 1053 | ||
1054 | if (!XPC_CHANNEL_REGISTERED(ch->number)) { | 1054 | if (!XPC_CHANNEL_REGISTERED(ch->number)) { |
1055 | mutex_unlock(®istration->mutex); | 1055 | mutex_unlock(®istration->mutex); |
1056 | return xpcUnregistered; | 1056 | return xpUnregistered; |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | spin_lock_irqsave(&ch->lock, irq_flags); | 1059 | spin_lock_irqsave(&ch->lock, irq_flags); |
@@ -1095,10 +1095,10 @@ xpc_connect_channel(struct xpc_channel *ch) | |||
1095 | * the channel lock as needed. | 1095 | * the channel lock as needed. |
1096 | */ | 1096 | */ |
1097 | mutex_unlock(®istration->mutex); | 1097 | mutex_unlock(®istration->mutex); |
1098 | XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes, | 1098 | XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes, |
1099 | &irq_flags); | 1099 | &irq_flags); |
1100 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 1100 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
1101 | return xpcUnequalMsgSizes; | 1101 | return xpUnequalMsgSizes; |
1102 | } | 1102 | } |
1103 | } else { | 1103 | } else { |
1104 | ch->msg_size = registration->msg_size; | 1104 | ch->msg_size = registration->msg_size; |
@@ -1120,7 +1120,7 @@ xpc_connect_channel(struct xpc_channel *ch) | |||
1120 | 1120 | ||
1121 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 1121 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
1122 | 1122 | ||
1123 | return xpcSuccess; | 1123 | return xpSuccess; |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | /* | 1126 | /* |
@@ -1203,7 +1203,7 @@ xpc_process_msg_IPI(struct xpc_partition *part, int ch_number) | |||
1203 | * Notify senders that messages sent have been | 1203 | * Notify senders that messages sent have been |
1204 | * received and delivered by the other side. | 1204 | * received and delivered by the other side. |
1205 | */ | 1205 | */ |
1206 | xpc_notify_senders(ch, xpcMsgDelivered, | 1206 | xpc_notify_senders(ch, xpMsgDelivered, |
1207 | ch->remote_GP.get); | 1207 | ch->remote_GP.get); |
1208 | } | 1208 | } |
1209 | 1209 | ||
@@ -1335,7 +1335,7 @@ xpc_process_channel_activity(struct xpc_partition *part) | |||
1335 | * at the same time. | 1335 | * at the same time. |
1336 | */ | 1336 | */ |
1337 | void | 1337 | void |
1338 | xpc_partition_going_down(struct xpc_partition *part, enum xpc_retval reason) | 1338 | xpc_partition_going_down(struct xpc_partition *part, enum xp_retval reason) |
1339 | { | 1339 | { |
1340 | unsigned long irq_flags; | 1340 | unsigned long irq_flags; |
1341 | int ch_number; | 1341 | int ch_number; |
@@ -1375,7 +1375,7 @@ xpc_partition_going_down(struct xpc_partition *part, enum xpc_retval reason) | |||
1375 | void | 1375 | void |
1376 | xpc_teardown_infrastructure(struct xpc_partition *part) | 1376 | xpc_teardown_infrastructure(struct xpc_partition *part) |
1377 | { | 1377 | { |
1378 | partid_t partid = XPC_PARTID(part); | 1378 | short partid = XPC_PARTID(part); |
1379 | 1379 | ||
1380 | /* | 1380 | /* |
1381 | * We start off by making this partition inaccessible to local | 1381 | * We start off by making this partition inaccessible to local |
@@ -1428,7 +1428,7 @@ xpc_teardown_infrastructure(struct xpc_partition *part) | |||
1428 | void | 1428 | void |
1429 | xpc_initiate_connect(int ch_number) | 1429 | xpc_initiate_connect(int ch_number) |
1430 | { | 1430 | { |
1431 | partid_t partid; | 1431 | short partid; |
1432 | struct xpc_partition *part; | 1432 | struct xpc_partition *part; |
1433 | struct xpc_channel *ch; | 1433 | struct xpc_channel *ch; |
1434 | 1434 | ||
@@ -1456,13 +1456,13 @@ xpc_connected_callout(struct xpc_channel *ch) | |||
1456 | /* let the registerer know that a connection has been established */ | 1456 | /* let the registerer know that a connection has been established */ |
1457 | 1457 | ||
1458 | if (ch->func != NULL) { | 1458 | if (ch->func != NULL) { |
1459 | dev_dbg(xpc_chan, "ch->func() called, reason=xpcConnected, " | 1459 | dev_dbg(xpc_chan, "ch->func() called, reason=xpConnected, " |
1460 | "partid=%d, channel=%d\n", ch->partid, ch->number); | 1460 | "partid=%d, channel=%d\n", ch->partid, ch->number); |
1461 | 1461 | ||
1462 | ch->func(xpcConnected, ch->partid, ch->number, | 1462 | ch->func(xpConnected, ch->partid, ch->number, |
1463 | (void *)(u64)ch->local_nentries, ch->key); | 1463 | (void *)(u64)ch->local_nentries, ch->key); |
1464 | 1464 | ||
1465 | dev_dbg(xpc_chan, "ch->func() returned, reason=xpcConnected, " | 1465 | dev_dbg(xpc_chan, "ch->func() returned, reason=xpConnected, " |
1466 | "partid=%d, channel=%d\n", ch->partid, ch->number); | 1466 | "partid=%d, channel=%d\n", ch->partid, ch->number); |
1467 | } | 1467 | } |
1468 | } | 1468 | } |
@@ -1484,7 +1484,7 @@ void | |||
1484 | xpc_initiate_disconnect(int ch_number) | 1484 | xpc_initiate_disconnect(int ch_number) |
1485 | { | 1485 | { |
1486 | unsigned long irq_flags; | 1486 | unsigned long irq_flags; |
1487 | partid_t partid; | 1487 | short partid; |
1488 | struct xpc_partition *part; | 1488 | struct xpc_partition *part; |
1489 | struct xpc_channel *ch; | 1489 | struct xpc_channel *ch; |
1490 | 1490 | ||
@@ -1503,7 +1503,7 @@ xpc_initiate_disconnect(int ch_number) | |||
1503 | if (!(ch->flags & XPC_C_DISCONNECTED)) { | 1503 | if (!(ch->flags & XPC_C_DISCONNECTED)) { |
1504 | ch->flags |= XPC_C_WDISCONNECT; | 1504 | ch->flags |= XPC_C_WDISCONNECT; |
1505 | 1505 | ||
1506 | XPC_DISCONNECT_CHANNEL(ch, xpcUnregistering, | 1506 | XPC_DISCONNECT_CHANNEL(ch, xpUnregistering, |
1507 | &irq_flags); | 1507 | &irq_flags); |
1508 | } | 1508 | } |
1509 | 1509 | ||
@@ -1528,7 +1528,7 @@ xpc_initiate_disconnect(int ch_number) | |||
1528 | */ | 1528 | */ |
1529 | void | 1529 | void |
1530 | xpc_disconnect_channel(const int line, struct xpc_channel *ch, | 1530 | xpc_disconnect_channel(const int line, struct xpc_channel *ch, |
1531 | enum xpc_retval reason, unsigned long *irq_flags) | 1531 | enum xp_retval reason, unsigned long *irq_flags) |
1532 | { | 1532 | { |
1533 | u32 channel_was_connected = (ch->flags & XPC_C_CONNECTED); | 1533 | u32 channel_was_connected = (ch->flags & XPC_C_CONNECTED); |
1534 | 1534 | ||
@@ -1563,7 +1563,7 @@ xpc_disconnect_channel(const int line, struct xpc_channel *ch, | |||
1563 | 1563 | ||
1564 | } else if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && | 1564 | } else if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && |
1565 | !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { | 1565 | !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { |
1566 | /* start a kthread that will do the xpcDisconnecting callout */ | 1566 | /* start a kthread that will do the xpDisconnecting callout */ |
1567 | xpc_create_kthreads(ch, 1, 1); | 1567 | xpc_create_kthreads(ch, 1, 1); |
1568 | } | 1568 | } |
1569 | 1569 | ||
@@ -1575,7 +1575,7 @@ xpc_disconnect_channel(const int line, struct xpc_channel *ch, | |||
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | void | 1577 | void |
1578 | xpc_disconnect_callout(struct xpc_channel *ch, enum xpc_retval reason) | 1578 | xpc_disconnect_callout(struct xpc_channel *ch, enum xp_retval reason) |
1579 | { | 1579 | { |
1580 | /* | 1580 | /* |
1581 | * Let the channel's registerer know that the channel is being | 1581 | * Let the channel's registerer know that the channel is being |
@@ -1598,13 +1598,13 @@ xpc_disconnect_callout(struct xpc_channel *ch, enum xpc_retval reason) | |||
1598 | * Wait for a message entry to become available for the specified channel, | 1598 | * Wait for a message entry to become available for the specified channel, |
1599 | * but don't wait any longer than 1 jiffy. | 1599 | * but don't wait any longer than 1 jiffy. |
1600 | */ | 1600 | */ |
1601 | static enum xpc_retval | 1601 | static enum xp_retval |
1602 | xpc_allocate_msg_wait(struct xpc_channel *ch) | 1602 | xpc_allocate_msg_wait(struct xpc_channel *ch) |
1603 | { | 1603 | { |
1604 | enum xpc_retval ret; | 1604 | enum xp_retval ret; |
1605 | 1605 | ||
1606 | if (ch->flags & XPC_C_DISCONNECTING) { | 1606 | if (ch->flags & XPC_C_DISCONNECTING) { |
1607 | DBUG_ON(ch->reason == xpcInterrupted); | 1607 | DBUG_ON(ch->reason == xpInterrupted); |
1608 | return ch->reason; | 1608 | return ch->reason; |
1609 | } | 1609 | } |
1610 | 1610 | ||
@@ -1614,11 +1614,11 @@ xpc_allocate_msg_wait(struct xpc_channel *ch) | |||
1614 | 1614 | ||
1615 | if (ch->flags & XPC_C_DISCONNECTING) { | 1615 | if (ch->flags & XPC_C_DISCONNECTING) { |
1616 | ret = ch->reason; | 1616 | ret = ch->reason; |
1617 | DBUG_ON(ch->reason == xpcInterrupted); | 1617 | DBUG_ON(ch->reason == xpInterrupted); |
1618 | } else if (ret == 0) { | 1618 | } else if (ret == 0) { |
1619 | ret = xpcTimeout; | 1619 | ret = xpTimeout; |
1620 | } else { | 1620 | } else { |
1621 | ret = xpcInterrupted; | 1621 | ret = xpInterrupted; |
1622 | } | 1622 | } |
1623 | 1623 | ||
1624 | return ret; | 1624 | return ret; |
@@ -1628,12 +1628,12 @@ xpc_allocate_msg_wait(struct xpc_channel *ch) | |||
1628 | * Allocate an entry for a message from the message queue associated with the | 1628 | * Allocate an entry for a message from the message queue associated with the |
1629 | * specified channel. | 1629 | * specified channel. |
1630 | */ | 1630 | */ |
1631 | static enum xpc_retval | 1631 | static enum xp_retval |
1632 | xpc_allocate_msg(struct xpc_channel *ch, u32 flags, | 1632 | xpc_allocate_msg(struct xpc_channel *ch, u32 flags, |
1633 | struct xpc_msg **address_of_msg) | 1633 | struct xpc_msg **address_of_msg) |
1634 | { | 1634 | { |
1635 | struct xpc_msg *msg; | 1635 | struct xpc_msg *msg; |
1636 | enum xpc_retval ret; | 1636 | enum xp_retval ret; |
1637 | s64 put; | 1637 | s64 put; |
1638 | 1638 | ||
1639 | /* this reference will be dropped in xpc_send_msg() */ | 1639 | /* this reference will be dropped in xpc_send_msg() */ |
@@ -1645,7 +1645,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags, | |||
1645 | } | 1645 | } |
1646 | if (!(ch->flags & XPC_C_CONNECTED)) { | 1646 | if (!(ch->flags & XPC_C_CONNECTED)) { |
1647 | xpc_msgqueue_deref(ch); | 1647 | xpc_msgqueue_deref(ch); |
1648 | return xpcNotConnected; | 1648 | return xpNotConnected; |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | /* | 1651 | /* |
@@ -1653,7 +1653,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags, | |||
1653 | * If none are available, we'll make sure that we grab the latest | 1653 | * If none are available, we'll make sure that we grab the latest |
1654 | * GP values. | 1654 | * GP values. |
1655 | */ | 1655 | */ |
1656 | ret = xpcTimeout; | 1656 | ret = xpTimeout; |
1657 | 1657 | ||
1658 | while (1) { | 1658 | while (1) { |
1659 | 1659 | ||
@@ -1683,16 +1683,16 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags, | |||
1683 | * that will cause the IPI handler to fetch the latest | 1683 | * that will cause the IPI handler to fetch the latest |
1684 | * GP values as if an IPI was sent by the other side. | 1684 | * GP values as if an IPI was sent by the other side. |
1685 | */ | 1685 | */ |
1686 | if (ret == xpcTimeout) | 1686 | if (ret == xpTimeout) |
1687 | xpc_IPI_send_local_msgrequest(ch); | 1687 | xpc_IPI_send_local_msgrequest(ch); |
1688 | 1688 | ||
1689 | if (flags & XPC_NOWAIT) { | 1689 | if (flags & XPC_NOWAIT) { |
1690 | xpc_msgqueue_deref(ch); | 1690 | xpc_msgqueue_deref(ch); |
1691 | return xpcNoWait; | 1691 | return xpNoWait; |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | ret = xpc_allocate_msg_wait(ch); | 1694 | ret = xpc_allocate_msg_wait(ch); |
1695 | if (ret != xpcInterrupted && ret != xpcTimeout) { | 1695 | if (ret != xpInterrupted && ret != xpTimeout) { |
1696 | xpc_msgqueue_deref(ch); | 1696 | xpc_msgqueue_deref(ch); |
1697 | return ret; | 1697 | return ret; |
1698 | } | 1698 | } |
@@ -1711,7 +1711,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags, | |||
1711 | 1711 | ||
1712 | *address_of_msg = msg; | 1712 | *address_of_msg = msg; |
1713 | 1713 | ||
1714 | return xpcSuccess; | 1714 | return xpSuccess; |
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | /* | 1717 | /* |
@@ -1727,11 +1727,11 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags, | |||
1727 | * payload - address of the allocated payload area pointer (filled in on | 1727 | * payload - address of the allocated payload area pointer (filled in on |
1728 | * return) in which the user-defined message is constructed. | 1728 | * return) in which the user-defined message is constructed. |
1729 | */ | 1729 | */ |
1730 | enum xpc_retval | 1730 | enum xp_retval |
1731 | xpc_initiate_allocate(partid_t partid, int ch_number, u32 flags, void **payload) | 1731 | xpc_initiate_allocate(short partid, int ch_number, u32 flags, void **payload) |
1732 | { | 1732 | { |
1733 | struct xpc_partition *part = &xpc_partitions[partid]; | 1733 | struct xpc_partition *part = &xpc_partitions[partid]; |
1734 | enum xpc_retval ret = xpcUnknownReason; | 1734 | enum xp_retval ret = xpUnknownReason; |
1735 | struct xpc_msg *msg = NULL; | 1735 | struct xpc_msg *msg = NULL; |
1736 | 1736 | ||
1737 | DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); | 1737 | DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); |
@@ -1814,11 +1814,11 @@ xpc_send_msgs(struct xpc_channel *ch, s64 initial_put) | |||
1814 | * local message queue's Put value and sends an IPI to the partition the | 1814 | * local message queue's Put value and sends an IPI to the partition the |
1815 | * message is being sent to. | 1815 | * message is being sent to. |
1816 | */ | 1816 | */ |
1817 | static enum xpc_retval | 1817 | static enum xp_retval |
1818 | xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type, | 1818 | xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type, |
1819 | xpc_notify_func func, void *key) | 1819 | xpc_notify_func func, void *key) |
1820 | { | 1820 | { |
1821 | enum xpc_retval ret = xpcSuccess; | 1821 | enum xp_retval ret = xpSuccess; |
1822 | struct xpc_notify *notify = notify; | 1822 | struct xpc_notify *notify = notify; |
1823 | s64 put, msg_number = msg->number; | 1823 | s64 put, msg_number = msg->number; |
1824 | 1824 | ||
@@ -1908,12 +1908,12 @@ xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type, | |||
1908 | * payload - pointer to the payload area allocated via | 1908 | * payload - pointer to the payload area allocated via |
1909 | * xpc_initiate_allocate(). | 1909 | * xpc_initiate_allocate(). |
1910 | */ | 1910 | */ |
1911 | enum xpc_retval | 1911 | enum xp_retval |
1912 | xpc_initiate_send(partid_t partid, int ch_number, void *payload) | 1912 | xpc_initiate_send(short partid, int ch_number, void *payload) |
1913 | { | 1913 | { |
1914 | struct xpc_partition *part = &xpc_partitions[partid]; | 1914 | struct xpc_partition *part = &xpc_partitions[partid]; |
1915 | struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); | 1915 | struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); |
1916 | enum xpc_retval ret; | 1916 | enum xp_retval ret; |
1917 | 1917 | ||
1918 | dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, | 1918 | dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, |
1919 | partid, ch_number); | 1919 | partid, ch_number); |
@@ -1957,13 +1957,13 @@ xpc_initiate_send(partid_t partid, int ch_number, void *payload) | |||
1957 | * receipt. THIS FUNCTION MUST BE NON-BLOCKING. | 1957 | * receipt. THIS FUNCTION MUST BE NON-BLOCKING. |
1958 | * key - user-defined key to be passed to the function when it's called. | 1958 | * key - user-defined key to be passed to the function when it's called. |
1959 | */ | 1959 | */ |
1960 | enum xpc_retval | 1960 | enum xp_retval |
1961 | xpc_initiate_send_notify(partid_t partid, int ch_number, void *payload, | 1961 | xpc_initiate_send_notify(short partid, int ch_number, void *payload, |
1962 | xpc_notify_func func, void *key) | 1962 | xpc_notify_func func, void *key) |
1963 | { | 1963 | { |
1964 | struct xpc_partition *part = &xpc_partitions[partid]; | 1964 | struct xpc_partition *part = &xpc_partitions[partid]; |
1965 | struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); | 1965 | struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); |
1966 | enum xpc_retval ret; | 1966 | enum xp_retval ret; |
1967 | 1967 | ||
1968 | dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, | 1968 | dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, |
1969 | partid, ch_number); | 1969 | partid, ch_number); |
@@ -1985,7 +1985,7 @@ xpc_pull_remote_msg(struct xpc_channel *ch, s64 get) | |||
1985 | struct xpc_msg *remote_msg, *msg; | 1985 | struct xpc_msg *remote_msg, *msg; |
1986 | u32 msg_index, nmsgs; | 1986 | u32 msg_index, nmsgs; |
1987 | u64 msg_offset; | 1987 | u64 msg_offset; |
1988 | enum xpc_retval ret; | 1988 | enum xp_retval ret; |
1989 | 1989 | ||
1990 | if (mutex_lock_interruptible(&ch->msg_to_pull_mutex) != 0) { | 1990 | if (mutex_lock_interruptible(&ch->msg_to_pull_mutex) != 0) { |
1991 | /* we were interrupted by a signal */ | 1991 | /* we were interrupted by a signal */ |
@@ -2012,7 +2012,7 @@ xpc_pull_remote_msg(struct xpc_channel *ch, s64 get) | |||
2012 | 2012 | ||
2013 | ret = xpc_pull_remote_cachelines(part, msg, remote_msg, | 2013 | ret = xpc_pull_remote_cachelines(part, msg, remote_msg, |
2014 | nmsgs * ch->msg_size); | 2014 | nmsgs * ch->msg_size); |
2015 | if (ret != xpcSuccess) { | 2015 | if (ret != xpSuccess) { |
2016 | 2016 | ||
2017 | dev_dbg(xpc_chan, "failed to pull %d msgs starting with" | 2017 | dev_dbg(xpc_chan, "failed to pull %d msgs starting with" |
2018 | " msg %ld from partition %d, channel=%d, " | 2018 | " msg %ld from partition %d, channel=%d, " |
@@ -2112,7 +2112,7 @@ xpc_deliver_msg(struct xpc_channel *ch) | |||
2112 | ch->number); | 2112 | ch->number); |
2113 | 2113 | ||
2114 | /* deliver the message to its intended recipient */ | 2114 | /* deliver the message to its intended recipient */ |
2115 | ch->func(xpcMsgReceived, ch->partid, ch->number, | 2115 | ch->func(xpMsgReceived, ch->partid, ch->number, |
2116 | &msg->payload, ch->key); | 2116 | &msg->payload, ch->key); |
2117 | 2117 | ||
2118 | dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, " | 2118 | dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, " |
@@ -2203,7 +2203,7 @@ xpc_acknowledge_msgs(struct xpc_channel *ch, s64 initial_get, u8 msg_flags) | |||
2203 | * xpc_initiate_allocate(). | 2203 | * xpc_initiate_allocate(). |
2204 | */ | 2204 | */ |
2205 | void | 2205 | void |
2206 | xpc_initiate_received(partid_t partid, int ch_number, void *payload) | 2206 | xpc_initiate_received(short partid, int ch_number, void *payload) |
2207 | { | 2207 | { |
2208 | struct xpc_partition *part = &xpc_partitions[partid]; | 2208 | struct xpc_partition *part = &xpc_partitions[partid]; |
2209 | struct xpc_channel *ch; | 2209 | struct xpc_channel *ch; |
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index f673ba90eb0e..08256ed0d9a6 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c | |||
@@ -315,13 +315,13 @@ xpc_initiate_discovery(void *ignore) | |||
315 | * the XPC per partition variables from the remote partition and waiting for | 315 | * the XPC per partition variables from the remote partition and waiting for |
316 | * the remote partition to pull ours. | 316 | * the remote partition to pull ours. |
317 | */ | 317 | */ |
318 | static enum xpc_retval | 318 | static enum xp_retval |
319 | xpc_make_first_contact(struct xpc_partition *part) | 319 | xpc_make_first_contact(struct xpc_partition *part) |
320 | { | 320 | { |
321 | enum xpc_retval ret; | 321 | enum xp_retval ret; |
322 | 322 | ||
323 | while ((ret = xpc_pull_remote_vars_part(part)) != xpcSuccess) { | 323 | while ((ret = xpc_pull_remote_vars_part(part)) != xpSuccess) { |
324 | if (ret != xpcRetry) { | 324 | if (ret != xpRetry) { |
325 | XPC_DEACTIVATE_PARTITION(part, ret); | 325 | XPC_DEACTIVATE_PARTITION(part, ret); |
326 | return ret; | 326 | return ret; |
327 | } | 327 | } |
@@ -406,7 +406,7 @@ xpc_partition_up(struct xpc_partition *part) | |||
406 | 406 | ||
407 | dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part)); | 407 | dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part)); |
408 | 408 | ||
409 | if (xpc_setup_infrastructure(part) != xpcSuccess) | 409 | if (xpc_setup_infrastructure(part) != xpSuccess) |
410 | return; | 410 | return; |
411 | 411 | ||
412 | /* | 412 | /* |
@@ -418,7 +418,7 @@ xpc_partition_up(struct xpc_partition *part) | |||
418 | 418 | ||
419 | (void)xpc_part_ref(part); /* this will always succeed */ | 419 | (void)xpc_part_ref(part); /* this will always succeed */ |
420 | 420 | ||
421 | if (xpc_make_first_contact(part) == xpcSuccess) | 421 | if (xpc_make_first_contact(part) == xpSuccess) |
422 | xpc_channel_mgr(part); | 422 | xpc_channel_mgr(part); |
423 | 423 | ||
424 | xpc_part_deref(part); | 424 | xpc_part_deref(part); |
@@ -429,7 +429,7 @@ xpc_partition_up(struct xpc_partition *part) | |||
429 | static int | 429 | static int |
430 | xpc_activating(void *__partid) | 430 | xpc_activating(void *__partid) |
431 | { | 431 | { |
432 | partid_t partid = (u64)__partid; | 432 | short partid = (u64)__partid; |
433 | struct xpc_partition *part = &xpc_partitions[partid]; | 433 | struct xpc_partition *part = &xpc_partitions[partid]; |
434 | unsigned long irq_flags; | 434 | unsigned long irq_flags; |
435 | 435 | ||
@@ -470,7 +470,7 @@ xpc_activating(void *__partid) | |||
470 | 470 | ||
471 | spin_lock_irqsave(&part->act_lock, irq_flags); | 471 | spin_lock_irqsave(&part->act_lock, irq_flags); |
472 | part->act_state = XPC_P_INACTIVE; | 472 | part->act_state = XPC_P_INACTIVE; |
473 | XPC_SET_REASON(part, xpcPhysAddrRegFailed, __LINE__); | 473 | XPC_SET_REASON(part, xpPhysAddrRegFailed, __LINE__); |
474 | spin_unlock_irqrestore(&part->act_lock, irq_flags); | 474 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
475 | part->remote_rp_pa = 0; | 475 | part->remote_rp_pa = 0; |
476 | return 0; | 476 | return 0; |
@@ -488,7 +488,7 @@ xpc_activating(void *__partid) | |||
488 | xpc_disallow_hb(partid, xpc_vars); | 488 | xpc_disallow_hb(partid, xpc_vars); |
489 | xpc_mark_partition_inactive(part); | 489 | xpc_mark_partition_inactive(part); |
490 | 490 | ||
491 | if (part->reason == xpcReactivating) { | 491 | if (part->reason == xpReactivating) { |
492 | /* interrupting ourselves results in activating partition */ | 492 | /* interrupting ourselves results in activating partition */ |
493 | xpc_IPI_send_reactivate(part); | 493 | xpc_IPI_send_reactivate(part); |
494 | } | 494 | } |
@@ -499,7 +499,7 @@ xpc_activating(void *__partid) | |||
499 | void | 499 | void |
500 | xpc_activate_partition(struct xpc_partition *part) | 500 | xpc_activate_partition(struct xpc_partition *part) |
501 | { | 501 | { |
502 | partid_t partid = XPC_PARTID(part); | 502 | short partid = XPC_PARTID(part); |
503 | unsigned long irq_flags; | 503 | unsigned long irq_flags; |
504 | struct task_struct *kthread; | 504 | struct task_struct *kthread; |
505 | 505 | ||
@@ -508,7 +508,7 @@ xpc_activate_partition(struct xpc_partition *part) | |||
508 | DBUG_ON(part->act_state != XPC_P_INACTIVE); | 508 | DBUG_ON(part->act_state != XPC_P_INACTIVE); |
509 | 509 | ||
510 | part->act_state = XPC_P_ACTIVATION_REQ; | 510 | part->act_state = XPC_P_ACTIVATION_REQ; |
511 | XPC_SET_REASON(part, xpcCloneKThread, __LINE__); | 511 | XPC_SET_REASON(part, xpCloneKThread, __LINE__); |
512 | 512 | ||
513 | spin_unlock_irqrestore(&part->act_lock, irq_flags); | 513 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
514 | 514 | ||
@@ -517,7 +517,7 @@ xpc_activate_partition(struct xpc_partition *part) | |||
517 | if (IS_ERR(kthread)) { | 517 | if (IS_ERR(kthread)) { |
518 | spin_lock_irqsave(&part->act_lock, irq_flags); | 518 | spin_lock_irqsave(&part->act_lock, irq_flags); |
519 | part->act_state = XPC_P_INACTIVE; | 519 | part->act_state = XPC_P_INACTIVE; |
520 | XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__); | 520 | XPC_SET_REASON(part, xpCloneKThreadFailed, __LINE__); |
521 | spin_unlock_irqrestore(&part->act_lock, irq_flags); | 521 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
522 | } | 522 | } |
523 | } | 523 | } |
@@ -541,7 +541,7 @@ xpc_activate_partition(struct xpc_partition *part) | |||
541 | irqreturn_t | 541 | irqreturn_t |
542 | xpc_notify_IRQ_handler(int irq, void *dev_id) | 542 | xpc_notify_IRQ_handler(int irq, void *dev_id) |
543 | { | 543 | { |
544 | partid_t partid = (partid_t) (u64)dev_id; | 544 | short partid = (short)(u64)dev_id; |
545 | struct xpc_partition *part = &xpc_partitions[partid]; | 545 | struct xpc_partition *part = &xpc_partitions[partid]; |
546 | 546 | ||
547 | DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); | 547 | DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); |
@@ -643,7 +643,7 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch) | |||
643 | static int | 643 | static int |
644 | xpc_kthread_start(void *args) | 644 | xpc_kthread_start(void *args) |
645 | { | 645 | { |
646 | partid_t partid = XPC_UNPACK_ARG1(args); | 646 | short partid = XPC_UNPACK_ARG1(args); |
647 | u16 ch_number = XPC_UNPACK_ARG2(args); | 647 | u16 ch_number = XPC_UNPACK_ARG2(args); |
648 | struct xpc_partition *part = &xpc_partitions[partid]; | 648 | struct xpc_partition *part = &xpc_partitions[partid]; |
649 | struct xpc_channel *ch; | 649 | struct xpc_channel *ch; |
@@ -696,7 +696,7 @@ xpc_kthread_start(void *args) | |||
696 | ch->flags |= XPC_C_DISCONNECTINGCALLOUT; | 696 | ch->flags |= XPC_C_DISCONNECTINGCALLOUT; |
697 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 697 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
698 | 698 | ||
699 | xpc_disconnect_callout(ch, xpcDisconnecting); | 699 | xpc_disconnect_callout(ch, xpDisconnecting); |
700 | 700 | ||
701 | spin_lock_irqsave(&ch->lock, irq_flags); | 701 | spin_lock_irqsave(&ch->lock, irq_flags); |
702 | ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; | 702 | ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; |
@@ -776,7 +776,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed, | |||
776 | * then we'll deadlock if all other kthreads assigned | 776 | * then we'll deadlock if all other kthreads assigned |
777 | * to this channel are blocked in the channel's | 777 | * to this channel are blocked in the channel's |
778 | * registerer, because the only thing that will unblock | 778 | * registerer, because the only thing that will unblock |
779 | * them is the xpcDisconnecting callout that this | 779 | * them is the xpDisconnecting callout that this |
780 | * failed kthread_run() would have made. | 780 | * failed kthread_run() would have made. |
781 | */ | 781 | */ |
782 | 782 | ||
@@ -796,7 +796,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed, | |||
796 | * to function. | 796 | * to function. |
797 | */ | 797 | */ |
798 | spin_lock_irqsave(&ch->lock, irq_flags); | 798 | spin_lock_irqsave(&ch->lock, irq_flags); |
799 | XPC_DISCONNECT_CHANNEL(ch, xpcLackOfResources, | 799 | XPC_DISCONNECT_CHANNEL(ch, xpLackOfResources, |
800 | &irq_flags); | 800 | &irq_flags); |
801 | spin_unlock_irqrestore(&ch->lock, irq_flags); | 801 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
802 | } | 802 | } |
@@ -809,7 +809,7 @@ void | |||
809 | xpc_disconnect_wait(int ch_number) | 809 | xpc_disconnect_wait(int ch_number) |
810 | { | 810 | { |
811 | unsigned long irq_flags; | 811 | unsigned long irq_flags; |
812 | partid_t partid; | 812 | short partid; |
813 | struct xpc_partition *part; | 813 | struct xpc_partition *part; |
814 | struct xpc_channel *ch; | 814 | struct xpc_channel *ch; |
815 | int wakeup_channel_mgr; | 815 | int wakeup_channel_mgr; |
@@ -857,9 +857,9 @@ xpc_disconnect_wait(int ch_number) | |||
857 | } | 857 | } |
858 | 858 | ||
859 | static void | 859 | static void |
860 | xpc_do_exit(enum xpc_retval reason) | 860 | xpc_do_exit(enum xp_retval reason) |
861 | { | 861 | { |
862 | partid_t partid; | 862 | short partid; |
863 | int active_part_count, printed_waiting_msg = 0; | 863 | int active_part_count, printed_waiting_msg = 0; |
864 | struct xpc_partition *part; | 864 | struct xpc_partition *part; |
865 | unsigned long printmsg_time, disengage_request_timeout = 0; | 865 | unsigned long printmsg_time, disengage_request_timeout = 0; |
@@ -955,7 +955,7 @@ xpc_do_exit(enum xpc_retval reason) | |||
955 | del_timer_sync(&xpc_hb_timer); | 955 | del_timer_sync(&xpc_hb_timer); |
956 | DBUG_ON(xpc_vars->heartbeating_to_mask != 0); | 956 | DBUG_ON(xpc_vars->heartbeating_to_mask != 0); |
957 | 957 | ||
958 | if (reason == xpcUnloading) { | 958 | if (reason == xpUnloading) { |
959 | /* take ourselves off of the reboot_notifier_list */ | 959 | /* take ourselves off of the reboot_notifier_list */ |
960 | (void)unregister_reboot_notifier(&xpc_reboot_notifier); | 960 | (void)unregister_reboot_notifier(&xpc_reboot_notifier); |
961 | 961 | ||
@@ -981,20 +981,20 @@ xpc_do_exit(enum xpc_retval reason) | |||
981 | static int | 981 | static int |
982 | xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused) | 982 | xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused) |
983 | { | 983 | { |
984 | enum xpc_retval reason; | 984 | enum xp_retval reason; |
985 | 985 | ||
986 | switch (event) { | 986 | switch (event) { |
987 | case SYS_RESTART: | 987 | case SYS_RESTART: |
988 | reason = xpcSystemReboot; | 988 | reason = xpSystemReboot; |
989 | break; | 989 | break; |
990 | case SYS_HALT: | 990 | case SYS_HALT: |
991 | reason = xpcSystemHalt; | 991 | reason = xpSystemHalt; |
992 | break; | 992 | break; |
993 | case SYS_POWER_OFF: | 993 | case SYS_POWER_OFF: |
994 | reason = xpcSystemPoweroff; | 994 | reason = xpSystemPoweroff; |
995 | break; | 995 | break; |
996 | default: | 996 | default: |
997 | reason = xpcSystemGoingDown; | 997 | reason = xpSystemGoingDown; |
998 | } | 998 | } |
999 | 999 | ||
1000 | xpc_do_exit(reason); | 1000 | xpc_do_exit(reason); |
@@ -1008,7 +1008,7 @@ static void | |||
1008 | xpc_die_disengage(void) | 1008 | xpc_die_disengage(void) |
1009 | { | 1009 | { |
1010 | struct xpc_partition *part; | 1010 | struct xpc_partition *part; |
1011 | partid_t partid; | 1011 | short partid; |
1012 | unsigned long engaged; | 1012 | unsigned long engaged; |
1013 | long time, printmsg_time, disengage_request_timeout; | 1013 | long time, printmsg_time, disengage_request_timeout; |
1014 | 1014 | ||
@@ -1124,7 +1124,7 @@ int __init | |||
1124 | xpc_init(void) | 1124 | xpc_init(void) |
1125 | { | 1125 | { |
1126 | int ret; | 1126 | int ret; |
1127 | partid_t partid; | 1127 | short partid; |
1128 | struct xpc_partition *part; | 1128 | struct xpc_partition *part; |
1129 | struct task_struct *kthread; | 1129 | struct task_struct *kthread; |
1130 | size_t buf_size; | 1130 | size_t buf_size; |
@@ -1279,7 +1279,7 @@ xpc_init(void) | |||
1279 | /* mark this new thread as a non-starter */ | 1279 | /* mark this new thread as a non-starter */ |
1280 | complete(&xpc_discovery_exited); | 1280 | complete(&xpc_discovery_exited); |
1281 | 1281 | ||
1282 | xpc_do_exit(xpcUnloading); | 1282 | xpc_do_exit(xpUnloading); |
1283 | return -EBUSY; | 1283 | return -EBUSY; |
1284 | } | 1284 | } |
1285 | 1285 | ||
@@ -1297,7 +1297,7 @@ module_init(xpc_init); | |||
1297 | void __exit | 1297 | void __exit |
1298 | xpc_exit(void) | 1298 | xpc_exit(void) |
1299 | { | 1299 | { |
1300 | xpc_do_exit(xpcUnloading); | 1300 | xpc_do_exit(xpUnloading); |
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | module_exit(xpc_exit); | 1303 | module_exit(xpc_exit); |
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c index acd3fd4285d7..7dd4b5812c42 100644 --- a/drivers/misc/sgi-xp/xpc_partition.c +++ b/drivers/misc/sgi-xp/xpc_partition.c | |||
@@ -403,7 +403,7 @@ xpc_check_remote_hb(void) | |||
403 | { | 403 | { |
404 | struct xpc_vars *remote_vars; | 404 | struct xpc_vars *remote_vars; |
405 | struct xpc_partition *part; | 405 | struct xpc_partition *part; |
406 | partid_t partid; | 406 | short partid; |
407 | bte_result_t bres; | 407 | bte_result_t bres; |
408 | 408 | ||
409 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; | 409 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; |
@@ -444,7 +444,7 @@ xpc_check_remote_hb(void) | |||
444 | (remote_vars->heartbeat_offline == 0)) || | 444 | (remote_vars->heartbeat_offline == 0)) || |
445 | !xpc_hb_allowed(sn_partition_id, remote_vars)) { | 445 | !xpc_hb_allowed(sn_partition_id, remote_vars)) { |
446 | 446 | ||
447 | XPC_DEACTIVATE_PARTITION(part, xpcNoHeartbeat); | 447 | XPC_DEACTIVATE_PARTITION(part, xpNoHeartbeat); |
448 | continue; | 448 | continue; |
449 | } | 449 | } |
450 | 450 | ||
@@ -459,7 +459,7 @@ xpc_check_remote_hb(void) | |||
459 | * is large enough to contain a copy of their reserved page header and | 459 | * is large enough to contain a copy of their reserved page header and |
460 | * part_nasids mask. | 460 | * part_nasids mask. |
461 | */ | 461 | */ |
462 | static enum xpc_retval | 462 | static enum xp_retval |
463 | xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | 463 | xpc_get_remote_rp(int nasid, u64 *discovered_nasids, |
464 | struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) | 464 | struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) |
465 | { | 465 | { |
@@ -469,7 +469,7 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | |||
469 | 469 | ||
470 | *remote_rp_pa = xpc_get_rsvd_page_pa(nasid); | 470 | *remote_rp_pa = xpc_get_rsvd_page_pa(nasid); |
471 | if (*remote_rp_pa == 0) | 471 | if (*remote_rp_pa == 0) |
472 | return xpcNoRsvdPageAddr; | 472 | return xpNoRsvdPageAddr; |
473 | 473 | ||
474 | /* pull over the reserved page header and part_nasids mask */ | 474 | /* pull over the reserved page header and part_nasids mask */ |
475 | bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp, | 475 | bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp, |
@@ -489,18 +489,18 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | |||
489 | 489 | ||
490 | if (remote_rp->partid < 1 || | 490 | if (remote_rp->partid < 1 || |
491 | remote_rp->partid > (XP_MAX_PARTITIONS - 1)) { | 491 | remote_rp->partid > (XP_MAX_PARTITIONS - 1)) { |
492 | return xpcInvalidPartid; | 492 | return xpInvalidPartid; |
493 | } | 493 | } |
494 | 494 | ||
495 | if (remote_rp->partid == sn_partition_id) | 495 | if (remote_rp->partid == sn_partition_id) |
496 | return xpcLocalPartid; | 496 | return xpLocalPartid; |
497 | 497 | ||
498 | if (XPC_VERSION_MAJOR(remote_rp->version) != | 498 | if (XPC_VERSION_MAJOR(remote_rp->version) != |
499 | XPC_VERSION_MAJOR(XPC_RP_VERSION)) { | 499 | XPC_VERSION_MAJOR(XPC_RP_VERSION)) { |
500 | return xpcBadVersion; | 500 | return xpBadVersion; |
501 | } | 501 | } |
502 | 502 | ||
503 | return xpcSuccess; | 503 | return xpSuccess; |
504 | } | 504 | } |
505 | 505 | ||
506 | /* | 506 | /* |
@@ -509,13 +509,13 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids, | |||
509 | * remote_vars points to a buffer that is cacheline aligned for BTE copies and | 509 | * remote_vars points to a buffer that is cacheline aligned for BTE copies and |
510 | * assumed to be of size XPC_RP_VARS_SIZE. | 510 | * assumed to be of size XPC_RP_VARS_SIZE. |
511 | */ | 511 | */ |
512 | static enum xpc_retval | 512 | static enum xp_retval |
513 | xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars) | 513 | xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars) |
514 | { | 514 | { |
515 | int bres; | 515 | int bres; |
516 | 516 | ||
517 | if (remote_vars_pa == 0) | 517 | if (remote_vars_pa == 0) |
518 | return xpcVarsNotSet; | 518 | return xpVarsNotSet; |
519 | 519 | ||
520 | /* pull over the cross partition variables */ | 520 | /* pull over the cross partition variables */ |
521 | bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE, | 521 | bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE, |
@@ -525,10 +525,10 @@ xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars) | |||
525 | 525 | ||
526 | if (XPC_VERSION_MAJOR(remote_vars->version) != | 526 | if (XPC_VERSION_MAJOR(remote_vars->version) != |
527 | XPC_VERSION_MAJOR(XPC_V_VERSION)) { | 527 | XPC_VERSION_MAJOR(XPC_V_VERSION)) { |
528 | return xpcBadVersion; | 528 | return xpBadVersion; |
529 | } | 529 | } |
530 | 530 | ||
531 | return xpcSuccess; | 531 | return xpSuccess; |
532 | } | 532 | } |
533 | 533 | ||
534 | /* | 534 | /* |
@@ -604,16 +604,16 @@ xpc_identify_act_IRQ_req(int nasid) | |||
604 | int reactivate = 0; | 604 | int reactivate = 0; |
605 | int stamp_diff; | 605 | int stamp_diff; |
606 | struct timespec remote_rp_stamp = { 0, 0 }; | 606 | struct timespec remote_rp_stamp = { 0, 0 }; |
607 | partid_t partid; | 607 | short partid; |
608 | struct xpc_partition *part; | 608 | struct xpc_partition *part; |
609 | enum xpc_retval ret; | 609 | enum xp_retval ret; |
610 | 610 | ||
611 | /* pull over the reserved page structure */ | 611 | /* pull over the reserved page structure */ |
612 | 612 | ||
613 | remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer; | 613 | remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer; |
614 | 614 | ||
615 | ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa); | 615 | ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa); |
616 | if (ret != xpcSuccess) { | 616 | if (ret != xpSuccess) { |
617 | dev_warn(xpc_part, "unable to get reserved page from nasid %d, " | 617 | dev_warn(xpc_part, "unable to get reserved page from nasid %d, " |
618 | "which sent interrupt, reason=%d\n", nasid, ret); | 618 | "which sent interrupt, reason=%d\n", nasid, ret); |
619 | return; | 619 | return; |
@@ -632,7 +632,7 @@ xpc_identify_act_IRQ_req(int nasid) | |||
632 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; | 632 | remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; |
633 | 633 | ||
634 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); | 634 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); |
635 | if (ret != xpcSuccess) { | 635 | if (ret != xpSuccess) { |
636 | 636 | ||
637 | dev_warn(xpc_part, "unable to get XPC variables from nasid %d, " | 637 | dev_warn(xpc_part, "unable to get XPC variables from nasid %d, " |
638 | "which sent interrupt, reason=%d\n", nasid, ret); | 638 | "which sent interrupt, reason=%d\n", nasid, ret); |
@@ -699,7 +699,7 @@ xpc_identify_act_IRQ_req(int nasid) | |||
699 | &remote_rp_stamp, remote_rp_pa, | 699 | &remote_rp_stamp, remote_rp_pa, |
700 | remote_vars_pa, remote_vars); | 700 | remote_vars_pa, remote_vars); |
701 | part->reactivate_nasid = nasid; | 701 | part->reactivate_nasid = nasid; |
702 | XPC_DEACTIVATE_PARTITION(part, xpcReactivating); | 702 | XPC_DEACTIVATE_PARTITION(part, xpReactivating); |
703 | return; | 703 | return; |
704 | } | 704 | } |
705 | 705 | ||
@@ -754,11 +754,11 @@ xpc_identify_act_IRQ_req(int nasid) | |||
754 | 754 | ||
755 | if (reactivate) { | 755 | if (reactivate) { |
756 | part->reactivate_nasid = nasid; | 756 | part->reactivate_nasid = nasid; |
757 | XPC_DEACTIVATE_PARTITION(part, xpcReactivating); | 757 | XPC_DEACTIVATE_PARTITION(part, xpReactivating); |
758 | 758 | ||
759 | } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) && | 759 | } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) && |
760 | xpc_partition_disengage_requested(1UL << partid)) { | 760 | xpc_partition_disengage_requested(1UL << partid)) { |
761 | XPC_DEACTIVATE_PARTITION(part, xpcOtherGoingDown); | 761 | XPC_DEACTIVATE_PARTITION(part, xpOtherGoingDown); |
762 | } | 762 | } |
763 | } | 763 | } |
764 | 764 | ||
@@ -825,7 +825,7 @@ xpc_identify_act_IRQ_sender(void) | |||
825 | int | 825 | int |
826 | xpc_partition_disengaged(struct xpc_partition *part) | 826 | xpc_partition_disengaged(struct xpc_partition *part) |
827 | { | 827 | { |
828 | partid_t partid = XPC_PARTID(part); | 828 | short partid = XPC_PARTID(part); |
829 | int disengaged; | 829 | int disengaged; |
830 | 830 | ||
831 | disengaged = (xpc_partition_engaged(1UL << partid) == 0); | 831 | disengaged = (xpc_partition_engaged(1UL << partid) == 0); |
@@ -870,20 +870,20 @@ xpc_partition_disengaged(struct xpc_partition *part) | |||
870 | /* | 870 | /* |
871 | * Mark specified partition as active. | 871 | * Mark specified partition as active. |
872 | */ | 872 | */ |
873 | enum xpc_retval | 873 | enum xp_retval |
874 | xpc_mark_partition_active(struct xpc_partition *part) | 874 | xpc_mark_partition_active(struct xpc_partition *part) |
875 | { | 875 | { |
876 | unsigned long irq_flags; | 876 | unsigned long irq_flags; |
877 | enum xpc_retval ret; | 877 | enum xp_retval ret; |
878 | 878 | ||
879 | dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part)); | 879 | dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part)); |
880 | 880 | ||
881 | spin_lock_irqsave(&part->act_lock, irq_flags); | 881 | spin_lock_irqsave(&part->act_lock, irq_flags); |
882 | if (part->act_state == XPC_P_ACTIVATING) { | 882 | if (part->act_state == XPC_P_ACTIVATING) { |
883 | part->act_state = XPC_P_ACTIVE; | 883 | part->act_state = XPC_P_ACTIVE; |
884 | ret = xpcSuccess; | 884 | ret = xpSuccess; |
885 | } else { | 885 | } else { |
886 | DBUG_ON(part->reason == xpcSuccess); | 886 | DBUG_ON(part->reason == xpSuccess); |
887 | ret = part->reason; | 887 | ret = part->reason; |
888 | } | 888 | } |
889 | spin_unlock_irqrestore(&part->act_lock, irq_flags); | 889 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
@@ -896,7 +896,7 @@ xpc_mark_partition_active(struct xpc_partition *part) | |||
896 | */ | 896 | */ |
897 | void | 897 | void |
898 | xpc_deactivate_partition(const int line, struct xpc_partition *part, | 898 | xpc_deactivate_partition(const int line, struct xpc_partition *part, |
899 | enum xpc_retval reason) | 899 | enum xp_retval reason) |
900 | { | 900 | { |
901 | unsigned long irq_flags; | 901 | unsigned long irq_flags; |
902 | 902 | ||
@@ -905,15 +905,15 @@ xpc_deactivate_partition(const int line, struct xpc_partition *part, | |||
905 | if (part->act_state == XPC_P_INACTIVE) { | 905 | if (part->act_state == XPC_P_INACTIVE) { |
906 | XPC_SET_REASON(part, reason, line); | 906 | XPC_SET_REASON(part, reason, line); |
907 | spin_unlock_irqrestore(&part->act_lock, irq_flags); | 907 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
908 | if (reason == xpcReactivating) { | 908 | if (reason == xpReactivating) { |
909 | /* we interrupt ourselves to reactivate partition */ | 909 | /* we interrupt ourselves to reactivate partition */ |
910 | xpc_IPI_send_reactivate(part); | 910 | xpc_IPI_send_reactivate(part); |
911 | } | 911 | } |
912 | return; | 912 | return; |
913 | } | 913 | } |
914 | if (part->act_state == XPC_P_DEACTIVATING) { | 914 | if (part->act_state == XPC_P_DEACTIVATING) { |
915 | if ((part->reason == xpcUnloading && reason != xpcUnloading) || | 915 | if ((part->reason == xpUnloading && reason != xpUnloading) || |
916 | reason == xpcReactivating) { | 916 | reason == xpReactivating) { |
917 | XPC_SET_REASON(part, reason, line); | 917 | XPC_SET_REASON(part, reason, line); |
918 | } | 918 | } |
919 | spin_unlock_irqrestore(&part->act_lock, irq_flags); | 919 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
@@ -982,10 +982,10 @@ xpc_discovery(void) | |||
982 | int max_regions; | 982 | int max_regions; |
983 | int nasid; | 983 | int nasid; |
984 | struct xpc_rsvd_page *rp; | 984 | struct xpc_rsvd_page *rp; |
985 | partid_t partid; | 985 | short partid; |
986 | struct xpc_partition *part; | 986 | struct xpc_partition *part; |
987 | u64 *discovered_nasids; | 987 | u64 *discovered_nasids; |
988 | enum xpc_retval ret; | 988 | enum xp_retval ret; |
989 | 989 | ||
990 | remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + | 990 | remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + |
991 | xp_nasid_mask_bytes, | 991 | xp_nasid_mask_bytes, |
@@ -1063,12 +1063,12 @@ xpc_discovery(void) | |||
1063 | 1063 | ||
1064 | ret = xpc_get_remote_rp(nasid, discovered_nasids, | 1064 | ret = xpc_get_remote_rp(nasid, discovered_nasids, |
1065 | remote_rp, &remote_rp_pa); | 1065 | remote_rp, &remote_rp_pa); |
1066 | if (ret != xpcSuccess) { | 1066 | if (ret != xpSuccess) { |
1067 | dev_dbg(xpc_part, "unable to get reserved page " | 1067 | dev_dbg(xpc_part, "unable to get reserved page " |
1068 | "from nasid %d, reason=%d\n", nasid, | 1068 | "from nasid %d, reason=%d\n", nasid, |
1069 | ret); | 1069 | ret); |
1070 | 1070 | ||
1071 | if (ret == xpcLocalPartid) | 1071 | if (ret == xpLocalPartid) |
1072 | break; | 1072 | break; |
1073 | 1073 | ||
1074 | continue; | 1074 | continue; |
@@ -1082,7 +1082,7 @@ xpc_discovery(void) | |||
1082 | /* pull over the cross partition variables */ | 1082 | /* pull over the cross partition variables */ |
1083 | 1083 | ||
1084 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); | 1084 | ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); |
1085 | if (ret != xpcSuccess) { | 1085 | if (ret != xpSuccess) { |
1086 | dev_dbg(xpc_part, "unable to get XPC variables " | 1086 | dev_dbg(xpc_part, "unable to get XPC variables " |
1087 | "from nasid %d, reason=%d\n", nasid, | 1087 | "from nasid %d, reason=%d\n", nasid, |
1088 | ret); | 1088 | ret); |
@@ -1116,7 +1116,7 @@ xpc_discovery(void) | |||
1116 | "register xp_addr region 0x%016lx\n", | 1116 | "register xp_addr region 0x%016lx\n", |
1117 | partid, remote_vars->amos_page_pa); | 1117 | partid, remote_vars->amos_page_pa); |
1118 | 1118 | ||
1119 | XPC_SET_REASON(part, xpcPhysAddrRegFailed, | 1119 | XPC_SET_REASON(part, xpPhysAddrRegFailed, |
1120 | __LINE__); | 1120 | __LINE__); |
1121 | break; | 1121 | break; |
1122 | } | 1122 | } |
@@ -1151,8 +1151,8 @@ xpc_discovery(void) | |||
1151 | * Given a partid, get the nasids owned by that partition from the | 1151 | * Given a partid, get the nasids owned by that partition from the |
1152 | * remote partition's reserved page. | 1152 | * remote partition's reserved page. |
1153 | */ | 1153 | */ |
1154 | enum xpc_retval | 1154 | enum xp_retval |
1155 | xpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask) | 1155 | xpc_initiate_partid_to_nasids(short partid, void *nasid_mask) |
1156 | { | 1156 | { |
1157 | struct xpc_partition *part; | 1157 | struct xpc_partition *part; |
1158 | u64 part_nasid_pa; | 1158 | u64 part_nasid_pa; |
@@ -1160,7 +1160,7 @@ xpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask) | |||
1160 | 1160 | ||
1161 | part = &xpc_partitions[partid]; | 1161 | part = &xpc_partitions[partid]; |
1162 | if (part->remote_rp_pa == 0) | 1162 | if (part->remote_rp_pa == 0) |
1163 | return xpcPartitionDown; | 1163 | return xpPartitionDown; |
1164 | 1164 | ||
1165 | memset(nasid_mask, 0, XP_NASID_MASK_BYTES); | 1165 | memset(nasid_mask, 0, XP_NASID_MASK_BYTES); |
1166 | 1166 | ||
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c index a9543c65814d..822dc8e8d7f0 100644 --- a/drivers/misc/sgi-xp/xpnet.c +++ b/drivers/misc/sgi-xp/xpnet.c | |||
@@ -166,7 +166,7 @@ struct device *xpnet = &xpnet_dbg_subname; | |||
166 | * Packet was recevied by XPC and forwarded to us. | 166 | * Packet was recevied by XPC and forwarded to us. |
167 | */ | 167 | */ |
168 | static void | 168 | static void |
169 | xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg) | 169 | xpnet_receive(short partid, int channel, struct xpnet_message *msg) |
170 | { | 170 | { |
171 | struct sk_buff *skb; | 171 | struct sk_buff *skb; |
172 | bte_result_t bret; | 172 | bte_result_t bret; |
@@ -282,7 +282,7 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg) | |||
282 | * state or message reception on a connection. | 282 | * state or message reception on a connection. |
283 | */ | 283 | */ |
284 | static void | 284 | static void |
285 | xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel, | 285 | xpnet_connection_activity(enum xp_retval reason, short partid, int channel, |
286 | void *data, void *key) | 286 | void *data, void *key) |
287 | { | 287 | { |
288 | long bp; | 288 | long bp; |
@@ -291,13 +291,13 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel, | |||
291 | DBUG_ON(channel != XPC_NET_CHANNEL); | 291 | DBUG_ON(channel != XPC_NET_CHANNEL); |
292 | 292 | ||
293 | switch (reason) { | 293 | switch (reason) { |
294 | case xpcMsgReceived: /* message received */ | 294 | case xpMsgReceived: /* message received */ |
295 | DBUG_ON(data == NULL); | 295 | DBUG_ON(data == NULL); |
296 | 296 | ||
297 | xpnet_receive(partid, channel, (struct xpnet_message *)data); | 297 | xpnet_receive(partid, channel, (struct xpnet_message *)data); |
298 | break; | 298 | break; |
299 | 299 | ||
300 | case xpcConnected: /* connection completed to a partition */ | 300 | case xpConnected: /* connection completed to a partition */ |
301 | spin_lock_bh(&xpnet_broadcast_lock); | 301 | spin_lock_bh(&xpnet_broadcast_lock); |
302 | xpnet_broadcast_partitions |= 1UL << (partid - 1); | 302 | xpnet_broadcast_partitions |= 1UL << (partid - 1); |
303 | bp = xpnet_broadcast_partitions; | 303 | bp = xpnet_broadcast_partitions; |
@@ -330,7 +330,7 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel, | |||
330 | static int | 330 | static int |
331 | xpnet_dev_open(struct net_device *dev) | 331 | xpnet_dev_open(struct net_device *dev) |
332 | { | 332 | { |
333 | enum xpc_retval ret; | 333 | enum xp_retval ret; |
334 | 334 | ||
335 | dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, " | 335 | dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, " |
336 | "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity, | 336 | "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity, |
@@ -340,7 +340,7 @@ xpnet_dev_open(struct net_device *dev) | |||
340 | ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL, | 340 | ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL, |
341 | XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, | 341 | XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, |
342 | XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS); | 342 | XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS); |
343 | if (ret != xpcSuccess) { | 343 | if (ret != xpSuccess) { |
344 | dev_err(xpnet, "ifconfig up of %s failed on XPC connect, " | 344 | dev_err(xpnet, "ifconfig up of %s failed on XPC connect, " |
345 | "ret=%d\n", dev->name, ret); | 345 | "ret=%d\n", dev->name, ret); |
346 | 346 | ||
@@ -407,7 +407,7 @@ xpnet_dev_get_stats(struct net_device *dev) | |||
407 | * release the skb and then release our pending message structure. | 407 | * release the skb and then release our pending message structure. |
408 | */ | 408 | */ |
409 | static void | 409 | static void |
410 | xpnet_send_completed(enum xpc_retval reason, partid_t partid, int channel, | 410 | xpnet_send_completed(enum xp_retval reason, short partid, int channel, |
411 | void *__qm) | 411 | void *__qm) |
412 | { | 412 | { |
413 | struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm; | 413 | struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm; |
@@ -439,12 +439,12 @@ static int | |||
439 | xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | 439 | xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
440 | { | 440 | { |
441 | struct xpnet_pending_msg *queued_msg; | 441 | struct xpnet_pending_msg *queued_msg; |
442 | enum xpc_retval ret; | 442 | enum xp_retval ret; |
443 | struct xpnet_message *msg; | 443 | struct xpnet_message *msg; |
444 | u64 start_addr, end_addr; | 444 | u64 start_addr, end_addr; |
445 | long dp; | 445 | long dp; |
446 | u8 second_mac_octet; | 446 | u8 second_mac_octet; |
447 | partid_t dest_partid; | 447 | short dest_partid; |
448 | struct xpnet_dev_private *priv; | 448 | struct xpnet_dev_private *priv; |
449 | u16 embedded_bytes; | 449 | u16 embedded_bytes; |
450 | 450 | ||
@@ -528,7 +528,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
528 | 528 | ||
529 | ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL, | 529 | ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL, |
530 | XPC_NOWAIT, (void **)&msg); | 530 | XPC_NOWAIT, (void **)&msg); |
531 | if (unlikely(ret != xpcSuccess)) | 531 | if (unlikely(ret != xpSuccess)) |
532 | continue; | 532 | continue; |
533 | 533 | ||
534 | msg->embedded_bytes = embedded_bytes; | 534 | msg->embedded_bytes = embedded_bytes; |
@@ -557,7 +557,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
557 | 557 | ||
558 | ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg, | 558 | ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg, |
559 | xpnet_send_completed, queued_msg); | 559 | xpnet_send_completed, queued_msg); |
560 | if (unlikely(ret != xpcSuccess)) { | 560 | if (unlikely(ret != xpSuccess)) { |
561 | atomic_dec(&queued_msg->use_count); | 561 | atomic_dec(&queued_msg->use_count); |
562 | continue; | 562 | continue; |
563 | } | 563 | } |
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 7fb02e177a3d..299118de8933 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -187,7 +187,7 @@ struct sdhci_host { | |||
187 | struct mmc_request *mrq; /* Current request */ | 187 | struct mmc_request *mrq; /* Current request */ |
188 | struct mmc_command *cmd; /* Current command */ | 188 | struct mmc_command *cmd; /* Current command */ |
189 | struct mmc_data *data; /* Current data request */ | 189 | struct mmc_data *data; /* Current data request */ |
190 | int data_early:1; /* Data finished before cmd */ | 190 | unsigned int data_early:1; /* Data finished before cmd */ |
191 | 191 | ||
192 | struct scatterlist *cur_sg; /* We're working on this */ | 192 | struct scatterlist *cur_sg; /* We're working on this */ |
193 | int num_sg; /* Entries left */ | 193 | int num_sg; /* Entries left */ |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index d27f54a2df77..9f6cc8a56073 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2426,7 +2426,7 @@ config CHELSIO_T3 | |||
2426 | 2426 | ||
2427 | config EHEA | 2427 | config EHEA |
2428 | tristate "eHEA Ethernet support" | 2428 | tristate "eHEA Ethernet support" |
2429 | depends on IBMEBUS && INET && SPARSEMEM | 2429 | depends on IBMEBUS && INET && SPARSEMEM && MEMORY_HOTPLUG |
2430 | select INET_LRO | 2430 | select INET_LRO |
2431 | ---help--- | 2431 | ---help--- |
2432 | This driver supports the IBM pSeries eHEA ethernet adapter. | 2432 | This driver supports the IBM pSeries eHEA ethernet adapter. |
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c index 0afe522b8f7b..9c2394d49428 100644 --- a/drivers/net/atlx/atl1.c +++ b/drivers/net/atlx/atl1.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. | 2 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. |
3 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> | 3 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> |
4 | * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> | 4 | * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com> |
5 | * | 5 | * |
6 | * Derived from Intel e1000 driver | 6 | * Derived from Intel e1000 driver |
7 | * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. | 7 | * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. |
@@ -36,7 +36,6 @@ | |||
36 | * A very incomplete list of things that need to be dealt with: | 36 | * A very incomplete list of things that need to be dealt with: |
37 | * | 37 | * |
38 | * TODO: | 38 | * TODO: |
39 | * Wake on LAN. | ||
40 | * Add more ethtool functions. | 39 | * Add more ethtool functions. |
41 | * Fix abstruse irq enable/disable condition described here: | 40 | * Fix abstruse irq enable/disable condition described here: |
42 | * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2 | 41 | * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2 |
@@ -638,21 +637,18 @@ static s32 atl1_phy_leave_power_saving(struct atl1_hw *hw) | |||
638 | } | 637 | } |
639 | 638 | ||
640 | /* | 639 | /* |
641 | *TODO: do something or get rid of this | 640 | * Force the PHY into power saving mode using vendor magic. |
642 | */ | 641 | */ |
643 | #ifdef CONFIG_PM | 642 | #ifdef CONFIG_PM |
644 | static s32 atl1_phy_enter_power_saving(struct atl1_hw *hw) | 643 | static void atl1_phy_enter_power_saving(struct atl1_hw *hw) |
645 | { | 644 | { |
646 | /* s32 ret_val; | 645 | atl1_write_phy_reg(hw, MII_DBG_ADDR, 0); |
647 | * u16 phy_data; | 646 | atl1_write_phy_reg(hw, MII_DBG_DATA, 0x124E); |
648 | */ | 647 | atl1_write_phy_reg(hw, MII_DBG_ADDR, 2); |
648 | atl1_write_phy_reg(hw, MII_DBG_DATA, 0x3000); | ||
649 | atl1_write_phy_reg(hw, MII_DBG_ADDR, 3); | ||
650 | atl1_write_phy_reg(hw, MII_DBG_DATA, 0); | ||
649 | 651 | ||
650 | /* | ||
651 | ret_val = atl1_write_phy_reg(hw, ...); | ||
652 | ret_val = atl1_write_phy_reg(hw, ...); | ||
653 | .... | ||
654 | */ | ||
655 | return 0; | ||
656 | } | 652 | } |
657 | #endif | 653 | #endif |
658 | 654 | ||
@@ -2784,64 +2780,93 @@ static int atl1_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2784 | struct atl1_hw *hw = &adapter->hw; | 2780 | struct atl1_hw *hw = &adapter->hw; |
2785 | u32 ctrl = 0; | 2781 | u32 ctrl = 0; |
2786 | u32 wufc = adapter->wol; | 2782 | u32 wufc = adapter->wol; |
2783 | u32 val; | ||
2784 | int retval; | ||
2785 | u16 speed; | ||
2786 | u16 duplex; | ||
2787 | 2787 | ||
2788 | netif_device_detach(netdev); | 2788 | netif_device_detach(netdev); |
2789 | if (netif_running(netdev)) | 2789 | if (netif_running(netdev)) |
2790 | atl1_down(adapter); | 2790 | atl1_down(adapter); |
2791 | 2791 | ||
2792 | retval = pci_save_state(pdev); | ||
2793 | if (retval) | ||
2794 | return retval; | ||
2795 | |||
2792 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); | 2796 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); |
2793 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); | 2797 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); |
2794 | if (ctrl & BMSR_LSTATUS) | 2798 | val = ctrl & BMSR_LSTATUS; |
2799 | if (val) | ||
2795 | wufc &= ~ATLX_WUFC_LNKC; | 2800 | wufc &= ~ATLX_WUFC_LNKC; |
2796 | 2801 | ||
2797 | /* reduce speed to 10/100M */ | 2802 | if (val && wufc) { |
2798 | if (wufc) { | 2803 | val = atl1_get_speed_and_duplex(hw, &speed, &duplex); |
2799 | atl1_phy_enter_power_saving(hw); | 2804 | if (val) { |
2800 | /* if resume, let driver to re- setup link */ | 2805 | if (netif_msg_ifdown(adapter)) |
2801 | hw->phy_configured = false; | 2806 | dev_printk(KERN_DEBUG, &pdev->dev, |
2802 | atl1_set_mac_addr(hw); | 2807 | "error getting speed/duplex\n"); |
2803 | atlx_set_multi(netdev); | 2808 | goto disable_wol; |
2809 | } | ||
2804 | 2810 | ||
2805 | ctrl = 0; | 2811 | ctrl = 0; |
2806 | /* turn on magic packet wol */ | ||
2807 | if (wufc & ATLX_WUFC_MAG) | ||
2808 | ctrl = WOL_MAGIC_EN | WOL_MAGIC_PME_EN; | ||
2809 | 2812 | ||
2810 | /* turn on Link change WOL */ | 2813 | /* enable magic packet WOL */ |
2811 | if (wufc & ATLX_WUFC_LNKC) | 2814 | if (wufc & ATLX_WUFC_MAG) |
2812 | ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN); | 2815 | ctrl |= (WOL_MAGIC_EN | WOL_MAGIC_PME_EN); |
2813 | iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL); | 2816 | iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL); |
2814 | 2817 | ioread32(hw->hw_addr + REG_WOL_CTRL); | |
2815 | /* turn on all-multi mode if wake on multicast is enabled */ | 2818 | |
2816 | ctrl = ioread32(hw->hw_addr + REG_MAC_CTRL); | 2819 | /* configure the mac */ |
2817 | ctrl &= ~MAC_CTRL_DBG; | 2820 | ctrl = MAC_CTRL_RX_EN; |
2818 | ctrl &= ~MAC_CTRL_PROMIS_EN; | 2821 | ctrl |= ((u32)((speed == SPEED_1000) ? MAC_CTRL_SPEED_1000 : |
2819 | if (wufc & ATLX_WUFC_MC) | 2822 | MAC_CTRL_SPEED_10_100) << MAC_CTRL_SPEED_SHIFT); |
2820 | ctrl |= MAC_CTRL_MC_ALL_EN; | 2823 | if (duplex == FULL_DUPLEX) |
2821 | else | 2824 | ctrl |= MAC_CTRL_DUPLX; |
2822 | ctrl &= ~MAC_CTRL_MC_ALL_EN; | 2825 | ctrl |= (((u32)adapter->hw.preamble_len & |
2823 | 2826 | MAC_CTRL_PRMLEN_MASK) << MAC_CTRL_PRMLEN_SHIFT); | |
2824 | /* turn on broadcast mode if wake on-BC is enabled */ | 2827 | if (adapter->vlgrp) |
2825 | if (wufc & ATLX_WUFC_BC) | 2828 | ctrl |= MAC_CTRL_RMV_VLAN; |
2829 | if (wufc & ATLX_WUFC_MAG) | ||
2826 | ctrl |= MAC_CTRL_BC_EN; | 2830 | ctrl |= MAC_CTRL_BC_EN; |
2827 | else | ||
2828 | ctrl &= ~MAC_CTRL_BC_EN; | ||
2829 | |||
2830 | /* enable RX */ | ||
2831 | ctrl |= MAC_CTRL_RX_EN; | ||
2832 | iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL); | 2831 | iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL); |
2833 | pci_enable_wake(pdev, PCI_D3hot, 1); | 2832 | ioread32(hw->hw_addr + REG_MAC_CTRL); |
2834 | pci_enable_wake(pdev, PCI_D3cold, 1); | 2833 | |
2835 | } else { | 2834 | /* poke the PHY */ |
2836 | iowrite32(0, hw->hw_addr + REG_WOL_CTRL); | 2835 | ctrl = ioread32(hw->hw_addr + REG_PCIE_PHYMISC); |
2837 | pci_enable_wake(pdev, PCI_D3hot, 0); | 2836 | ctrl |= PCIE_PHYMISC_FORCE_RCV_DET; |
2838 | pci_enable_wake(pdev, PCI_D3cold, 0); | 2837 | iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC); |
2838 | ioread32(hw->hw_addr + REG_PCIE_PHYMISC); | ||
2839 | |||
2840 | pci_enable_wake(pdev, pci_choose_state(pdev, state), 1); | ||
2841 | goto exit; | ||
2839 | } | 2842 | } |
2840 | 2843 | ||
2841 | pci_save_state(pdev); | 2844 | if (!val && wufc) { |
2845 | ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN); | ||
2846 | iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL); | ||
2847 | ioread32(hw->hw_addr + REG_WOL_CTRL); | ||
2848 | iowrite32(0, hw->hw_addr + REG_MAC_CTRL); | ||
2849 | ioread32(hw->hw_addr + REG_MAC_CTRL); | ||
2850 | hw->phy_configured = false; | ||
2851 | pci_enable_wake(pdev, pci_choose_state(pdev, state), 1); | ||
2852 | goto exit; | ||
2853 | } | ||
2854 | |||
2855 | disable_wol: | ||
2856 | iowrite32(0, hw->hw_addr + REG_WOL_CTRL); | ||
2857 | ioread32(hw->hw_addr + REG_WOL_CTRL); | ||
2858 | ctrl = ioread32(hw->hw_addr + REG_PCIE_PHYMISC); | ||
2859 | ctrl |= PCIE_PHYMISC_FORCE_RCV_DET; | ||
2860 | iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC); | ||
2861 | ioread32(hw->hw_addr + REG_PCIE_PHYMISC); | ||
2862 | atl1_phy_enter_power_saving(hw); | ||
2863 | hw->phy_configured = false; | ||
2864 | pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); | ||
2865 | exit: | ||
2866 | if (netif_running(netdev)) | ||
2867 | pci_disable_msi(adapter->pdev); | ||
2842 | pci_disable_device(pdev); | 2868 | pci_disable_device(pdev); |
2843 | 2869 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | |
2844 | pci_set_power_state(pdev, PCI_D3hot); | ||
2845 | 2870 | ||
2846 | return 0; | 2871 | return 0; |
2847 | } | 2872 | } |
@@ -2855,20 +2880,26 @@ static int atl1_resume(struct pci_dev *pdev) | |||
2855 | pci_set_power_state(pdev, PCI_D0); | 2880 | pci_set_power_state(pdev, PCI_D0); |
2856 | pci_restore_state(pdev); | 2881 | pci_restore_state(pdev); |
2857 | 2882 | ||
2858 | /* FIXME: check and handle */ | ||
2859 | err = pci_enable_device(pdev); | 2883 | err = pci_enable_device(pdev); |
2884 | if (err) { | ||
2885 | if (netif_msg_ifup(adapter)) | ||
2886 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
2887 | "error enabling pci device\n"); | ||
2888 | return err; | ||
2889 | } | ||
2890 | |||
2891 | pci_set_master(pdev); | ||
2892 | iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL); | ||
2860 | pci_enable_wake(pdev, PCI_D3hot, 0); | 2893 | pci_enable_wake(pdev, PCI_D3hot, 0); |
2861 | pci_enable_wake(pdev, PCI_D3cold, 0); | 2894 | pci_enable_wake(pdev, PCI_D3cold, 0); |
2862 | 2895 | ||
2863 | iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL); | 2896 | atl1_reset_hw(&adapter->hw); |
2864 | atl1_reset(adapter); | 2897 | adapter->cmb.cmb->int_stats = 0; |
2865 | 2898 | ||
2866 | if (netif_running(netdev)) | 2899 | if (netif_running(netdev)) |
2867 | atl1_up(adapter); | 2900 | atl1_up(adapter); |
2868 | netif_device_attach(netdev); | 2901 | netif_device_attach(netdev); |
2869 | 2902 | ||
2870 | atl1_via_workaround(adapter); | ||
2871 | |||
2872 | return 0; | 2903 | return 0; |
2873 | } | 2904 | } |
2874 | #else | 2905 | #else |
@@ -2876,6 +2907,13 @@ static int atl1_resume(struct pci_dev *pdev) | |||
2876 | #define atl1_resume NULL | 2907 | #define atl1_resume NULL |
2877 | #endif | 2908 | #endif |
2878 | 2909 | ||
2910 | static void atl1_shutdown(struct pci_dev *pdev) | ||
2911 | { | ||
2912 | #ifdef CONFIG_PM | ||
2913 | atl1_suspend(pdev, PMSG_SUSPEND); | ||
2914 | #endif | ||
2915 | } | ||
2916 | |||
2879 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2917 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2880 | static void atl1_poll_controller(struct net_device *netdev) | 2918 | static void atl1_poll_controller(struct net_device *netdev) |
2881 | { | 2919 | { |
@@ -3122,7 +3160,8 @@ static struct pci_driver atl1_driver = { | |||
3122 | .probe = atl1_probe, | 3160 | .probe = atl1_probe, |
3123 | .remove = __devexit_p(atl1_remove), | 3161 | .remove = __devexit_p(atl1_remove), |
3124 | .suspend = atl1_suspend, | 3162 | .suspend = atl1_suspend, |
3125 | .resume = atl1_resume | 3163 | .resume = atl1_resume, |
3164 | .shutdown = atl1_shutdown | ||
3126 | }; | 3165 | }; |
3127 | 3166 | ||
3128 | /* | 3167 | /* |
diff --git a/drivers/net/atlx/atl1.h b/drivers/net/atlx/atl1.h index 51893d66eae1..a5015b14a429 100644 --- a/drivers/net/atlx/atl1.h +++ b/drivers/net/atlx/atl1.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. | 2 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. |
3 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> | 3 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> |
4 | * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> | 4 | * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com> |
5 | * | 5 | * |
6 | * Derived from Intel e1000 driver | 6 | * Derived from Intel e1000 driver |
7 | * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. | 7 | * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. |
diff --git a/drivers/net/atlx/atlx.c b/drivers/net/atlx/atlx.c index f06b854e2501..b3e7fcf0f6e7 100644 --- a/drivers/net/atlx/atlx.c +++ b/drivers/net/atlx/atlx.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * | 2 | * |
3 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. | 3 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. |
4 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> | 4 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> |
5 | * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> | 5 | * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com> |
6 | * Copyright(c) 2007 Atheros Corporation. All rights reserved. | 6 | * Copyright(c) 2007 Atheros Corporation. All rights reserved. |
7 | * | 7 | * |
8 | * Derived from Intel e1000 driver | 8 | * Derived from Intel e1000 driver |
diff --git a/drivers/net/atlx/atlx.h b/drivers/net/atlx/atlx.h index 3be7c09734d4..297a03da6b7f 100644 --- a/drivers/net/atlx/atlx.h +++ b/drivers/net/atlx/atlx.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * | 2 | * |
3 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. | 3 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. |
4 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> | 4 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> |
5 | * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> | 5 | * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com> |
6 | * Copyright(c) 2007 Atheros Corporation. All rights reserved. | 6 | * Copyright(c) 2007 Atheros Corporation. All rights reserved. |
7 | * | 7 | * |
8 | * Derived from Intel e1000 driver | 8 | * Derived from Intel e1000 driver |
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | 31 | ||
32 | #define ATLX_DRIVER_VERSION "2.1.1" | 32 | #define ATLX_DRIVER_VERSION "2.1.3" |
33 | MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \ | 33 | MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \ |
34 | Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>"); | 34 | Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>"); |
35 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
@@ -460,6 +460,9 @@ MODULE_VERSION(ATLX_DRIVER_VERSION); | |||
460 | #define MII_ATLX_PSSR_100MBS 0x4000 /* 01=100Mbs */ | 460 | #define MII_ATLX_PSSR_100MBS 0x4000 /* 01=100Mbs */ |
461 | #define MII_ATLX_PSSR_1000MBS 0x8000 /* 10=1000Mbs */ | 461 | #define MII_ATLX_PSSR_1000MBS 0x8000 /* 10=1000Mbs */ |
462 | 462 | ||
463 | #define MII_DBG_ADDR 0x1D | ||
464 | #define MII_DBG_DATA 0x1E | ||
465 | |||
463 | /* PCI Command Register Bit Definitions */ | 466 | /* PCI Command Register Bit Definitions */ |
464 | #define PCI_REG_COMMAND 0x04 /* PCI Command Register */ | 467 | #define PCI_REG_COMMAND 0x04 /* PCI Command Register */ |
465 | #define CMD_IO_SPACE 0x0001 | 468 | #define CMD_IO_SPACE 0x0001 |
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h index 4fdb13f8447b..acebe431d068 100644 --- a/drivers/net/cxgb3/adapter.h +++ b/drivers/net/cxgb3/adapter.h | |||
@@ -71,6 +71,7 @@ enum { /* adapter flags */ | |||
71 | USING_MSIX = (1 << 2), | 71 | USING_MSIX = (1 << 2), |
72 | QUEUES_BOUND = (1 << 3), | 72 | QUEUES_BOUND = (1 << 3), |
73 | TP_PARITY_INIT = (1 << 4), | 73 | TP_PARITY_INIT = (1 << 4), |
74 | NAPI_INIT = (1 << 5), | ||
74 | }; | 75 | }; |
75 | 76 | ||
76 | struct fl_pg_chunk { | 77 | struct fl_pg_chunk { |
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h index 91ee7277b813..579bee42a5cb 100644 --- a/drivers/net/cxgb3/common.h +++ b/drivers/net/cxgb3/common.h | |||
@@ -698,6 +698,7 @@ void mac_prep(struct cmac *mac, struct adapter *adapter, int index); | |||
698 | void early_hw_init(struct adapter *adapter, const struct adapter_info *ai); | 698 | void early_hw_init(struct adapter *adapter, const struct adapter_info *ai); |
699 | int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, | 699 | int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, |
700 | int reset); | 700 | int reset); |
701 | int t3_replay_prep_adapter(struct adapter *adapter); | ||
701 | void t3_led_ready(struct adapter *adapter); | 702 | void t3_led_ready(struct adapter *adapter); |
702 | void t3_fatal_err(struct adapter *adapter); | 703 | void t3_fatal_err(struct adapter *adapter); |
703 | void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on); | 704 | void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on); |
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index ce949d5fae39..3a3127216791 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -421,6 +421,13 @@ static void init_napi(struct adapter *adap) | |||
421 | netif_napi_add(qs->netdev, &qs->napi, qs->napi.poll, | 421 | netif_napi_add(qs->netdev, &qs->napi, qs->napi.poll, |
422 | 64); | 422 | 64); |
423 | } | 423 | } |
424 | |||
425 | /* | ||
426 | * netif_napi_add() can be called only once per napi_struct because it | ||
427 | * adds each new napi_struct to a list. Be careful not to call it a | ||
428 | * second time, e.g., during EEH recovery, by making a note of it. | ||
429 | */ | ||
430 | adap->flags |= NAPI_INIT; | ||
424 | } | 431 | } |
425 | 432 | ||
426 | /* | 433 | /* |
@@ -896,7 +903,8 @@ static int cxgb_up(struct adapter *adap) | |||
896 | goto out; | 903 | goto out; |
897 | 904 | ||
898 | setup_rss(adap); | 905 | setup_rss(adap); |
899 | init_napi(adap); | 906 | if (!(adap->flags & NAPI_INIT)) |
907 | init_napi(adap); | ||
900 | adap->flags |= FULL_INIT_DONE; | 908 | adap->flags |= FULL_INIT_DONE; |
901 | } | 909 | } |
902 | 910 | ||
@@ -999,7 +1007,7 @@ static int offload_open(struct net_device *dev) | |||
999 | return 0; | 1007 | return 0; |
1000 | 1008 | ||
1001 | if (!adap_up && (err = cxgb_up(adapter)) < 0) | 1009 | if (!adap_up && (err = cxgb_up(adapter)) < 0) |
1002 | return err; | 1010 | goto out; |
1003 | 1011 | ||
1004 | t3_tp_set_offload_mode(adapter, 1); | 1012 | t3_tp_set_offload_mode(adapter, 1); |
1005 | tdev->lldev = adapter->port[0]; | 1013 | tdev->lldev = adapter->port[0]; |
@@ -1061,10 +1069,8 @@ static int cxgb_open(struct net_device *dev) | |||
1061 | int other_ports = adapter->open_device_map & PORT_MASK; | 1069 | int other_ports = adapter->open_device_map & PORT_MASK; |
1062 | int err; | 1070 | int err; |
1063 | 1071 | ||
1064 | if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) { | 1072 | if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) |
1065 | quiesce_rx(adapter); | ||
1066 | return err; | 1073 | return err; |
1067 | } | ||
1068 | 1074 | ||
1069 | set_bit(pi->port_id, &adapter->open_device_map); | 1075 | set_bit(pi->port_id, &adapter->open_device_map); |
1070 | if (is_offload(adapter) && !ofld_disable) { | 1076 | if (is_offload(adapter) && !ofld_disable) { |
@@ -2424,14 +2430,11 @@ static pci_ers_result_t t3_io_error_detected(struct pci_dev *pdev, | |||
2424 | test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) | 2430 | test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) |
2425 | offload_close(&adapter->tdev); | 2431 | offload_close(&adapter->tdev); |
2426 | 2432 | ||
2427 | /* Free sge resources */ | ||
2428 | t3_free_sge_resources(adapter); | ||
2429 | |||
2430 | adapter->flags &= ~FULL_INIT_DONE; | 2433 | adapter->flags &= ~FULL_INIT_DONE; |
2431 | 2434 | ||
2432 | pci_disable_device(pdev); | 2435 | pci_disable_device(pdev); |
2433 | 2436 | ||
2434 | /* Request a slot slot reset. */ | 2437 | /* Request a slot reset. */ |
2435 | return PCI_ERS_RESULT_NEED_RESET; | 2438 | return PCI_ERS_RESULT_NEED_RESET; |
2436 | } | 2439 | } |
2437 | 2440 | ||
@@ -2448,13 +2451,20 @@ static pci_ers_result_t t3_io_slot_reset(struct pci_dev *pdev) | |||
2448 | if (pci_enable_device(pdev)) { | 2451 | if (pci_enable_device(pdev)) { |
2449 | dev_err(&pdev->dev, | 2452 | dev_err(&pdev->dev, |
2450 | "Cannot re-enable PCI device after reset.\n"); | 2453 | "Cannot re-enable PCI device after reset.\n"); |
2451 | return PCI_ERS_RESULT_DISCONNECT; | 2454 | goto err; |
2452 | } | 2455 | } |
2453 | pci_set_master(pdev); | 2456 | pci_set_master(pdev); |
2457 | pci_restore_state(pdev); | ||
2454 | 2458 | ||
2455 | t3_prep_adapter(adapter, adapter->params.info, 1); | 2459 | /* Free sge resources */ |
2460 | t3_free_sge_resources(adapter); | ||
2461 | |||
2462 | if (t3_replay_prep_adapter(adapter)) | ||
2463 | goto err; | ||
2456 | 2464 | ||
2457 | return PCI_ERS_RESULT_RECOVERED; | 2465 | return PCI_ERS_RESULT_RECOVERED; |
2466 | err: | ||
2467 | return PCI_ERS_RESULT_DISCONNECT; | ||
2458 | } | 2468 | } |
2459 | 2469 | ||
2460 | /** | 2470 | /** |
@@ -2483,13 +2493,6 @@ static void t3_io_resume(struct pci_dev *pdev) | |||
2483 | netif_device_attach(netdev); | 2493 | netif_device_attach(netdev); |
2484 | } | 2494 | } |
2485 | } | 2495 | } |
2486 | |||
2487 | if (is_offload(adapter)) { | ||
2488 | __set_bit(OFFLOAD_DEVMAP_BIT, &adapter->registered_device_map); | ||
2489 | if (offload_open(adapter->port[0])) | ||
2490 | printk(KERN_WARNING | ||
2491 | "Could not bring back offload capabilities\n"); | ||
2492 | } | ||
2493 | } | 2496 | } |
2494 | 2497 | ||
2495 | static struct pci_error_handlers t3_err_handler = { | 2498 | static struct pci_error_handlers t3_err_handler = { |
@@ -2608,6 +2611,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2608 | } | 2611 | } |
2609 | 2612 | ||
2610 | pci_set_master(pdev); | 2613 | pci_set_master(pdev); |
2614 | pci_save_state(pdev); | ||
2611 | 2615 | ||
2612 | mmio_start = pci_resource_start(pdev, 0); | 2616 | mmio_start = pci_resource_start(pdev, 0); |
2613 | mmio_len = pci_resource_len(pdev, 0); | 2617 | mmio_len = pci_resource_len(pdev, 0); |
diff --git a/drivers/net/cxgb3/regs.h b/drivers/net/cxgb3/regs.h index 02dbbb300929..567178879345 100644 --- a/drivers/net/cxgb3/regs.h +++ b/drivers/net/cxgb3/regs.h | |||
@@ -444,6 +444,14 @@ | |||
444 | 444 | ||
445 | #define A_PCIE_CFG 0x88 | 445 | #define A_PCIE_CFG 0x88 |
446 | 446 | ||
447 | #define S_ENABLELINKDWNDRST 21 | ||
448 | #define V_ENABLELINKDWNDRST(x) ((x) << S_ENABLELINKDWNDRST) | ||
449 | #define F_ENABLELINKDWNDRST V_ENABLELINKDWNDRST(1U) | ||
450 | |||
451 | #define S_ENABLELINKDOWNRST 20 | ||
452 | #define V_ENABLELINKDOWNRST(x) ((x) << S_ENABLELINKDOWNRST) | ||
453 | #define F_ENABLELINKDOWNRST V_ENABLELINKDOWNRST(1U) | ||
454 | |||
447 | #define S_PCIE_CLIDECEN 16 | 455 | #define S_PCIE_CLIDECEN 16 |
448 | #define V_PCIE_CLIDECEN(x) ((x) << S_PCIE_CLIDECEN) | 456 | #define V_PCIE_CLIDECEN(x) ((x) << S_PCIE_CLIDECEN) |
449 | #define F_PCIE_CLIDECEN V_PCIE_CLIDECEN(1U) | 457 | #define F_PCIE_CLIDECEN V_PCIE_CLIDECEN(1U) |
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c index 98a6bbd11d4c..796eb305cdc3 100644 --- a/drivers/net/cxgb3/sge.c +++ b/drivers/net/cxgb3/sge.c | |||
@@ -539,6 +539,31 @@ static void *alloc_ring(struct pci_dev *pdev, size_t nelem, size_t elem_size, | |||
539 | } | 539 | } |
540 | 540 | ||
541 | /** | 541 | /** |
542 | * t3_reset_qset - reset a sge qset | ||
543 | * @q: the queue set | ||
544 | * | ||
545 | * Reset the qset structure. | ||
546 | * the NAPI structure is preserved in the event of | ||
547 | * the qset's reincarnation, for example during EEH recovery. | ||
548 | */ | ||
549 | static void t3_reset_qset(struct sge_qset *q) | ||
550 | { | ||
551 | if (q->adap && | ||
552 | !(q->adap->flags & NAPI_INIT)) { | ||
553 | memset(q, 0, sizeof(*q)); | ||
554 | return; | ||
555 | } | ||
556 | |||
557 | q->adap = NULL; | ||
558 | memset(&q->rspq, 0, sizeof(q->rspq)); | ||
559 | memset(q->fl, 0, sizeof(struct sge_fl) * SGE_RXQ_PER_SET); | ||
560 | memset(q->txq, 0, sizeof(struct sge_txq) * SGE_TXQ_PER_SET); | ||
561 | q->txq_stopped = 0; | ||
562 | memset(&q->tx_reclaim_timer, 0, sizeof(q->tx_reclaim_timer)); | ||
563 | } | ||
564 | |||
565 | |||
566 | /** | ||
542 | * free_qset - free the resources of an SGE queue set | 567 | * free_qset - free the resources of an SGE queue set |
543 | * @adapter: the adapter owning the queue set | 568 | * @adapter: the adapter owning the queue set |
544 | * @q: the queue set | 569 | * @q: the queue set |
@@ -594,7 +619,7 @@ static void t3_free_qset(struct adapter *adapter, struct sge_qset *q) | |||
594 | q->rspq.desc, q->rspq.phys_addr); | 619 | q->rspq.desc, q->rspq.phys_addr); |
595 | } | 620 | } |
596 | 621 | ||
597 | memset(q, 0, sizeof(*q)); | 622 | t3_reset_qset(q); |
598 | } | 623 | } |
599 | 624 | ||
600 | /** | 625 | /** |
@@ -1365,7 +1390,7 @@ static void restart_ctrlq(unsigned long data) | |||
1365 | */ | 1390 | */ |
1366 | int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb) | 1391 | int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb) |
1367 | { | 1392 | { |
1368 | int ret; | 1393 | int ret; |
1369 | local_bh_disable(); | 1394 | local_bh_disable(); |
1370 | ret = ctrl_xmit(adap, &adap->sge.qs[0].txq[TXQ_CTRL], skb); | 1395 | ret = ctrl_xmit(adap, &adap->sge.qs[0].txq[TXQ_CTRL], skb); |
1371 | local_bh_enable(); | 1396 | local_bh_enable(); |
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c index a99496a431c4..d405a932c73a 100644 --- a/drivers/net/cxgb3/t3_hw.c +++ b/drivers/net/cxgb3/t3_hw.c | |||
@@ -3264,6 +3264,7 @@ static void config_pcie(struct adapter *adap) | |||
3264 | 3264 | ||
3265 | t3_write_reg(adap, A_PCIE_PEX_ERR, 0xffffffff); | 3265 | t3_write_reg(adap, A_PCIE_PEX_ERR, 0xffffffff); |
3266 | t3_set_reg_field(adap, A_PCIE_CFG, 0, | 3266 | t3_set_reg_field(adap, A_PCIE_CFG, 0, |
3267 | F_ENABLELINKDWNDRST | F_ENABLELINKDOWNRST | | ||
3267 | F_PCIE_DMASTOPEN | F_PCIE_CLIDECEN); | 3268 | F_PCIE_DMASTOPEN | F_PCIE_CLIDECEN); |
3268 | } | 3269 | } |
3269 | 3270 | ||
@@ -3655,3 +3656,30 @@ void t3_led_ready(struct adapter *adapter) | |||
3655 | t3_set_reg_field(adapter, A_T3DBG_GPIO_EN, F_GPIO0_OUT_VAL, | 3656 | t3_set_reg_field(adapter, A_T3DBG_GPIO_EN, F_GPIO0_OUT_VAL, |
3656 | F_GPIO0_OUT_VAL); | 3657 | F_GPIO0_OUT_VAL); |
3657 | } | 3658 | } |
3659 | |||
3660 | int t3_replay_prep_adapter(struct adapter *adapter) | ||
3661 | { | ||
3662 | const struct adapter_info *ai = adapter->params.info; | ||
3663 | unsigned int i, j = 0; | ||
3664 | int ret; | ||
3665 | |||
3666 | early_hw_init(adapter, ai); | ||
3667 | ret = init_parity(adapter); | ||
3668 | if (ret) | ||
3669 | return ret; | ||
3670 | |||
3671 | for_each_port(adapter, i) { | ||
3672 | struct port_info *p = adap2pinfo(adapter, i); | ||
3673 | while (!adapter->params.vpd.port_type[j]) | ||
3674 | ++j; | ||
3675 | |||
3676 | p->port_type->phy_prep(&p->phy, adapter, ai->phy_base_addr + j, | ||
3677 | ai->mdio_ops); | ||
3678 | |||
3679 | p->phy.ops->power_down(&p->phy, 1); | ||
3680 | ++j; | ||
3681 | } | ||
3682 | |||
3683 | return 0; | ||
3684 | } | ||
3685 | |||
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index e6fe2614ea6d..d45bcd2660af 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c | |||
@@ -117,6 +117,9 @@ typedef struct board_info { | |||
117 | 117 | ||
118 | struct mutex addr_lock; /* phy and eeprom access lock */ | 118 | struct mutex addr_lock; /* phy and eeprom access lock */ |
119 | 119 | ||
120 | struct delayed_work phy_poll; | ||
121 | struct net_device *ndev; | ||
122 | |||
120 | spinlock_t lock; | 123 | spinlock_t lock; |
121 | 124 | ||
122 | struct mii_if_info mii; | 125 | struct mii_if_info mii; |
@@ -297,6 +300,10 @@ static void dm9000_set_io(struct board_info *db, int byte_width) | |||
297 | } | 300 | } |
298 | } | 301 | } |
299 | 302 | ||
303 | static void dm9000_schedule_poll(board_info_t *db) | ||
304 | { | ||
305 | schedule_delayed_work(&db->phy_poll, HZ * 2); | ||
306 | } | ||
300 | 307 | ||
301 | /* Our watchdog timed out. Called by the networking layer */ | 308 | /* Our watchdog timed out. Called by the networking layer */ |
302 | static void dm9000_timeout(struct net_device *dev) | 309 | static void dm9000_timeout(struct net_device *dev) |
@@ -465,6 +472,17 @@ static const struct ethtool_ops dm9000_ethtool_ops = { | |||
465 | .set_eeprom = dm9000_set_eeprom, | 472 | .set_eeprom = dm9000_set_eeprom, |
466 | }; | 473 | }; |
467 | 474 | ||
475 | static void | ||
476 | dm9000_poll_work(struct work_struct *w) | ||
477 | { | ||
478 | struct delayed_work *dw = container_of(w, struct delayed_work, work); | ||
479 | board_info_t *db = container_of(dw, board_info_t, phy_poll); | ||
480 | |||
481 | mii_check_media(&db->mii, netif_msg_link(db), 0); | ||
482 | |||
483 | if (netif_running(db->ndev)) | ||
484 | dm9000_schedule_poll(db); | ||
485 | } | ||
468 | 486 | ||
469 | /* dm9000_release_board | 487 | /* dm9000_release_board |
470 | * | 488 | * |
@@ -503,7 +521,7 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db) | |||
503 | /* | 521 | /* |
504 | * Search DM9000 board, allocate space and register it | 522 | * Search DM9000 board, allocate space and register it |
505 | */ | 523 | */ |
506 | static int | 524 | static int __devinit |
507 | dm9000_probe(struct platform_device *pdev) | 525 | dm9000_probe(struct platform_device *pdev) |
508 | { | 526 | { |
509 | struct dm9000_plat_data *pdata = pdev->dev.platform_data; | 527 | struct dm9000_plat_data *pdata = pdev->dev.platform_data; |
@@ -525,17 +543,21 @@ dm9000_probe(struct platform_device *pdev) | |||
525 | 543 | ||
526 | SET_NETDEV_DEV(ndev, &pdev->dev); | 544 | SET_NETDEV_DEV(ndev, &pdev->dev); |
527 | 545 | ||
528 | dev_dbg(&pdev->dev, "dm9000_probe()"); | 546 | dev_dbg(&pdev->dev, "dm9000_probe()\n"); |
529 | 547 | ||
530 | /* setup board info structure */ | 548 | /* setup board info structure */ |
531 | db = (struct board_info *) ndev->priv; | 549 | db = (struct board_info *) ndev->priv; |
532 | memset(db, 0, sizeof (*db)); | 550 | memset(db, 0, sizeof (*db)); |
533 | 551 | ||
534 | db->dev = &pdev->dev; | 552 | db->dev = &pdev->dev; |
553 | db->ndev = ndev; | ||
535 | 554 | ||
536 | spin_lock_init(&db->lock); | 555 | spin_lock_init(&db->lock); |
537 | mutex_init(&db->addr_lock); | 556 | mutex_init(&db->addr_lock); |
538 | 557 | ||
558 | INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work); | ||
559 | |||
560 | |||
539 | if (pdev->num_resources < 2) { | 561 | if (pdev->num_resources < 2) { |
540 | ret = -ENODEV; | 562 | ret = -ENODEV; |
541 | goto out; | 563 | goto out; |
@@ -761,6 +783,8 @@ dm9000_open(struct net_device *dev) | |||
761 | 783 | ||
762 | mii_check_media(&db->mii, netif_msg_link(db), 1); | 784 | mii_check_media(&db->mii, netif_msg_link(db), 1); |
763 | netif_start_queue(dev); | 785 | netif_start_queue(dev); |
786 | |||
787 | dm9000_schedule_poll(db); | ||
764 | 788 | ||
765 | return 0; | 789 | return 0; |
766 | } | 790 | } |
@@ -879,6 +903,8 @@ dm9000_stop(struct net_device *ndev) | |||
879 | if (netif_msg_ifdown(db)) | 903 | if (netif_msg_ifdown(db)) |
880 | dev_dbg(db->dev, "shutting down %s\n", ndev->name); | 904 | dev_dbg(db->dev, "shutting down %s\n", ndev->name); |
881 | 905 | ||
906 | cancel_delayed_work(&db->phy_poll); | ||
907 | |||
882 | netif_stop_queue(ndev); | 908 | netif_stop_queue(ndev); |
883 | netif_carrier_off(ndev); | 909 | netif_carrier_off(ndev); |
884 | 910 | ||
@@ -1288,6 +1314,8 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg) | |||
1288 | spin_unlock_irqrestore(&db->lock,flags); | 1314 | spin_unlock_irqrestore(&db->lock,flags); |
1289 | 1315 | ||
1290 | mutex_unlock(&db->addr_lock); | 1316 | mutex_unlock(&db->addr_lock); |
1317 | |||
1318 | dm9000_dbg(db, 5, "phy_read[%02x] -> %04x\n", reg, ret); | ||
1291 | return ret; | 1319 | return ret; |
1292 | } | 1320 | } |
1293 | 1321 | ||
@@ -1301,6 +1329,7 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) | |||
1301 | unsigned long flags; | 1329 | unsigned long flags; |
1302 | unsigned long reg_save; | 1330 | unsigned long reg_save; |
1303 | 1331 | ||
1332 | dm9000_dbg(db, 5, "phy_write[%02x] = %04x\n", reg, value); | ||
1304 | mutex_lock(&db->addr_lock); | 1333 | mutex_lock(&db->addr_lock); |
1305 | 1334 | ||
1306 | spin_lock_irqsave(&db->lock,flags); | 1335 | spin_lock_irqsave(&db->lock,flags); |
@@ -1372,7 +1401,7 @@ dm9000_drv_resume(struct platform_device *dev) | |||
1372 | return 0; | 1401 | return 0; |
1373 | } | 1402 | } |
1374 | 1403 | ||
1375 | static int | 1404 | static int __devexit |
1376 | dm9000_drv_remove(struct platform_device *pdev) | 1405 | dm9000_drv_remove(struct platform_device *pdev) |
1377 | { | 1406 | { |
1378 | struct net_device *ndev = platform_get_drvdata(pdev); | 1407 | struct net_device *ndev = platform_get_drvdata(pdev); |
@@ -1393,7 +1422,7 @@ static struct platform_driver dm9000_driver = { | |||
1393 | .owner = THIS_MODULE, | 1422 | .owner = THIS_MODULE, |
1394 | }, | 1423 | }, |
1395 | .probe = dm9000_probe, | 1424 | .probe = dm9000_probe, |
1396 | .remove = dm9000_drv_remove, | 1425 | .remove = __devexit_p(dm9000_drv_remove), |
1397 | .suspend = dm9000_drv_suspend, | 1426 | .suspend = dm9000_drv_suspend, |
1398 | .resume = dm9000_drv_resume, | 1427 | .resume = dm9000_drv_resume, |
1399 | }; | 1428 | }; |
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h index f5dacceab95b..fe872fbd671e 100644 --- a/drivers/net/ehea/ehea.h +++ b/drivers/net/ehea/ehea.h | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | 41 | ||
42 | #define DRV_NAME "ehea" | 42 | #define DRV_NAME "ehea" |
43 | #define DRV_VERSION "EHEA_0090" | 43 | #define DRV_VERSION "EHEA_0091" |
44 | 44 | ||
45 | /* eHEA capability flags */ | 45 | /* eHEA capability flags */ |
46 | #define DLPAR_PORT_ADD_REM 1 | 46 | #define DLPAR_PORT_ADD_REM 1 |
@@ -118,6 +118,13 @@ | |||
118 | #define EHEA_MR_ACC_CTRL 0x00800000 | 118 | #define EHEA_MR_ACC_CTRL 0x00800000 |
119 | 119 | ||
120 | #define EHEA_BUSMAP_START 0x8000000000000000ULL | 120 | #define EHEA_BUSMAP_START 0x8000000000000000ULL |
121 | #define EHEA_INVAL_ADDR 0xFFFFFFFFFFFFFFFFULL | ||
122 | #define EHEA_DIR_INDEX_SHIFT 13 /* 8k Entries in 64k block */ | ||
123 | #define EHEA_TOP_INDEX_SHIFT (EHEA_DIR_INDEX_SHIFT * 2) | ||
124 | #define EHEA_MAP_ENTRIES (1 << EHEA_DIR_INDEX_SHIFT) | ||
125 | #define EHEA_MAP_SIZE (0x10000) /* currently fixed map size */ | ||
126 | #define EHEA_INDEX_MASK (EHEA_MAP_ENTRIES - 1) | ||
127 | |||
121 | 128 | ||
122 | #define EHEA_WATCH_DOG_TIMEOUT 10*HZ | 129 | #define EHEA_WATCH_DOG_TIMEOUT 10*HZ |
123 | 130 | ||
@@ -192,10 +199,20 @@ struct h_epas { | |||
192 | set to 0 if unused */ | 199 | set to 0 if unused */ |
193 | }; | 200 | }; |
194 | 201 | ||
195 | struct ehea_busmap { | 202 | /* |
196 | unsigned int entries; /* total number of entries */ | 203 | * Memory map data structures |
197 | unsigned int valid_sections; /* number of valid sections */ | 204 | */ |
198 | u64 *vaddr; | 205 | struct ehea_dir_bmap |
206 | { | ||
207 | u64 ent[EHEA_MAP_ENTRIES]; | ||
208 | }; | ||
209 | struct ehea_top_bmap | ||
210 | { | ||
211 | struct ehea_dir_bmap *dir[EHEA_MAP_ENTRIES]; | ||
212 | }; | ||
213 | struct ehea_bmap | ||
214 | { | ||
215 | struct ehea_top_bmap *top[EHEA_MAP_ENTRIES]; | ||
199 | }; | 216 | }; |
200 | 217 | ||
201 | struct ehea_qp; | 218 | struct ehea_qp; |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index f9bc21c74b59..d1b6d4e7495d 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/if_ether.h> | 35 | #include <linux/if_ether.h> |
36 | #include <linux/notifier.h> | 36 | #include <linux/notifier.h> |
37 | #include <linux/reboot.h> | 37 | #include <linux/reboot.h> |
38 | #include <linux/memory.h> | ||
38 | #include <asm/kexec.h> | 39 | #include <asm/kexec.h> |
39 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
40 | 41 | ||
@@ -3503,6 +3504,24 @@ void ehea_crash_handler(void) | |||
3503 | 0, H_DEREG_BCMC); | 3504 | 0, H_DEREG_BCMC); |
3504 | } | 3505 | } |
3505 | 3506 | ||
3507 | static int ehea_mem_notifier(struct notifier_block *nb, | ||
3508 | unsigned long action, void *data) | ||
3509 | { | ||
3510 | switch (action) { | ||
3511 | case MEM_OFFLINE: | ||
3512 | ehea_info("memory has been removed"); | ||
3513 | ehea_rereg_mrs(NULL); | ||
3514 | break; | ||
3515 | default: | ||
3516 | break; | ||
3517 | } | ||
3518 | return NOTIFY_OK; | ||
3519 | } | ||
3520 | |||
3521 | static struct notifier_block ehea_mem_nb = { | ||
3522 | .notifier_call = ehea_mem_notifier, | ||
3523 | }; | ||
3524 | |||
3506 | static int ehea_reboot_notifier(struct notifier_block *nb, | 3525 | static int ehea_reboot_notifier(struct notifier_block *nb, |
3507 | unsigned long action, void *unused) | 3526 | unsigned long action, void *unused) |
3508 | { | 3527 | { |
@@ -3581,6 +3600,10 @@ int __init ehea_module_init(void) | |||
3581 | if (ret) | 3600 | if (ret) |
3582 | ehea_info("failed registering reboot notifier"); | 3601 | ehea_info("failed registering reboot notifier"); |
3583 | 3602 | ||
3603 | ret = register_memory_notifier(&ehea_mem_nb); | ||
3604 | if (ret) | ||
3605 | ehea_info("failed registering memory remove notifier"); | ||
3606 | |||
3584 | ret = crash_shutdown_register(&ehea_crash_handler); | 3607 | ret = crash_shutdown_register(&ehea_crash_handler); |
3585 | if (ret) | 3608 | if (ret) |
3586 | ehea_info("failed registering crash handler"); | 3609 | ehea_info("failed registering crash handler"); |
@@ -3604,6 +3627,7 @@ int __init ehea_module_init(void) | |||
3604 | out3: | 3627 | out3: |
3605 | ibmebus_unregister_driver(&ehea_driver); | 3628 | ibmebus_unregister_driver(&ehea_driver); |
3606 | out2: | 3629 | out2: |
3630 | unregister_memory_notifier(&ehea_mem_nb); | ||
3607 | unregister_reboot_notifier(&ehea_reboot_nb); | 3631 | unregister_reboot_notifier(&ehea_reboot_nb); |
3608 | crash_shutdown_unregister(&ehea_crash_handler); | 3632 | crash_shutdown_unregister(&ehea_crash_handler); |
3609 | out: | 3633 | out: |
@@ -3621,6 +3645,7 @@ static void __exit ehea_module_exit(void) | |||
3621 | ret = crash_shutdown_unregister(&ehea_crash_handler); | 3645 | ret = crash_shutdown_unregister(&ehea_crash_handler); |
3622 | if (ret) | 3646 | if (ret) |
3623 | ehea_info("failed unregistering crash handler"); | 3647 | ehea_info("failed unregistering crash handler"); |
3648 | unregister_memory_notifier(&ehea_mem_nb); | ||
3624 | kfree(ehea_fw_handles.arr); | 3649 | kfree(ehea_fw_handles.arr); |
3625 | kfree(ehea_bcmc_regs.arr); | 3650 | kfree(ehea_bcmc_regs.arr); |
3626 | ehea_destroy_busmap(); | 3651 | ehea_destroy_busmap(); |
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c index d522e905f460..140f05baafd8 100644 --- a/drivers/net/ehea/ehea_qmr.c +++ b/drivers/net/ehea/ehea_qmr.c | |||
@@ -31,8 +31,8 @@ | |||
31 | #include "ehea_phyp.h" | 31 | #include "ehea_phyp.h" |
32 | #include "ehea_qmr.h" | 32 | #include "ehea_qmr.h" |
33 | 33 | ||
34 | struct ehea_bmap *ehea_bmap = NULL; | ||
34 | 35 | ||
35 | struct ehea_busmap ehea_bmap = { 0, 0, NULL }; | ||
36 | 36 | ||
37 | 37 | ||
38 | static void *hw_qpageit_get_inc(struct hw_queue *queue) | 38 | static void *hw_qpageit_get_inc(struct hw_queue *queue) |
@@ -559,125 +559,253 @@ int ehea_destroy_qp(struct ehea_qp *qp) | |||
559 | return 0; | 559 | return 0; |
560 | } | 560 | } |
561 | 561 | ||
562 | int ehea_create_busmap(void) | 562 | static inline int ehea_calc_index(unsigned long i, unsigned long s) |
563 | { | 563 | { |
564 | u64 vaddr = EHEA_BUSMAP_START; | 564 | return (i >> s) & EHEA_INDEX_MASK; |
565 | unsigned long high_section_index = 0; | 565 | } |
566 | int i; | ||
567 | 566 | ||
568 | /* | 567 | static inline int ehea_init_top_bmap(struct ehea_top_bmap *ehea_top_bmap, |
569 | * Sections are not in ascending order -> Loop over all sections and | 568 | int dir) |
570 | * find the highest PFN to compute the required map size. | 569 | { |
571 | */ | 570 | if(!ehea_top_bmap->dir[dir]) { |
572 | ehea_bmap.valid_sections = 0; | 571 | ehea_top_bmap->dir[dir] = |
572 | kzalloc(sizeof(struct ehea_dir_bmap), GFP_KERNEL); | ||
573 | if (!ehea_top_bmap->dir[dir]) | ||
574 | return -ENOMEM; | ||
575 | } | ||
576 | return 0; | ||
577 | } | ||
573 | 578 | ||
574 | for (i = 0; i < NR_MEM_SECTIONS; i++) | 579 | static inline int ehea_init_bmap(struct ehea_bmap *ehea_bmap, int top, int dir) |
575 | if (valid_section_nr(i)) | 580 | { |
576 | high_section_index = i; | 581 | if(!ehea_bmap->top[top]) { |
582 | ehea_bmap->top[top] = | ||
583 | kzalloc(sizeof(struct ehea_top_bmap), GFP_KERNEL); | ||
584 | if (!ehea_bmap->top[top]) | ||
585 | return -ENOMEM; | ||
586 | } | ||
587 | return ehea_init_top_bmap(ehea_bmap->top[top], dir); | ||
588 | } | ||
577 | 589 | ||
578 | ehea_bmap.entries = high_section_index + 1; | 590 | static int ehea_create_busmap_callback(unsigned long pfn, |
579 | ehea_bmap.vaddr = vmalloc(ehea_bmap.entries * sizeof(*ehea_bmap.vaddr)); | 591 | unsigned long nr_pages, void *arg) |
592 | { | ||
593 | unsigned long i, mr_len, start_section, end_section; | ||
594 | start_section = (pfn * PAGE_SIZE) / EHEA_SECTSIZE; | ||
595 | end_section = start_section + ((nr_pages * PAGE_SIZE) / EHEA_SECTSIZE); | ||
596 | mr_len = *(unsigned long *)arg; | ||
580 | 597 | ||
581 | if (!ehea_bmap.vaddr) | 598 | ehea_bmap = kzalloc(sizeof(struct ehea_bmap), GFP_KERNEL); |
599 | if (!ehea_bmap) | ||
582 | return -ENOMEM; | 600 | return -ENOMEM; |
583 | 601 | ||
584 | for (i = 0 ; i < ehea_bmap.entries; i++) { | 602 | for (i = start_section; i < end_section; i++) { |
585 | unsigned long pfn = section_nr_to_pfn(i); | 603 | int ret; |
604 | int top, dir, idx; | ||
605 | u64 vaddr; | ||
606 | |||
607 | top = ehea_calc_index(i, EHEA_TOP_INDEX_SHIFT); | ||
608 | dir = ehea_calc_index(i, EHEA_DIR_INDEX_SHIFT); | ||
609 | |||
610 | ret = ehea_init_bmap(ehea_bmap, top, dir); | ||
611 | if(ret) | ||
612 | return ret; | ||
586 | 613 | ||
587 | if (pfn_valid(pfn)) { | 614 | idx = i & EHEA_INDEX_MASK; |
588 | ehea_bmap.vaddr[i] = vaddr; | 615 | vaddr = EHEA_BUSMAP_START + mr_len + i * EHEA_SECTSIZE; |
589 | vaddr += EHEA_SECTSIZE; | 616 | |
590 | ehea_bmap.valid_sections++; | 617 | ehea_bmap->top[top]->dir[dir]->ent[idx] = vaddr; |
591 | } else | ||
592 | ehea_bmap.vaddr[i] = 0; | ||
593 | } | 618 | } |
594 | 619 | ||
620 | mr_len += nr_pages * PAGE_SIZE; | ||
621 | *(unsigned long *)arg = mr_len; | ||
622 | |||
595 | return 0; | 623 | return 0; |
596 | } | 624 | } |
597 | 625 | ||
626 | static unsigned long ehea_mr_len; | ||
627 | |||
628 | static DEFINE_MUTEX(ehea_busmap_mutex); | ||
629 | |||
630 | int ehea_create_busmap(void) | ||
631 | { | ||
632 | int ret; | ||
633 | mutex_lock(&ehea_busmap_mutex); | ||
634 | ehea_mr_len = 0; | ||
635 | ret = walk_memory_resource(0, 1ULL << MAX_PHYSMEM_BITS, &ehea_mr_len, | ||
636 | ehea_create_busmap_callback); | ||
637 | mutex_unlock(&ehea_busmap_mutex); | ||
638 | return ret; | ||
639 | } | ||
640 | |||
598 | void ehea_destroy_busmap(void) | 641 | void ehea_destroy_busmap(void) |
599 | { | 642 | { |
600 | vfree(ehea_bmap.vaddr); | 643 | int top, dir; |
644 | mutex_lock(&ehea_busmap_mutex); | ||
645 | if (!ehea_bmap) | ||
646 | goto out_destroy; | ||
647 | |||
648 | for (top = 0; top < EHEA_MAP_ENTRIES; top++) { | ||
649 | if (!ehea_bmap->top[top]) | ||
650 | continue; | ||
651 | |||
652 | for (dir = 0; dir < EHEA_MAP_ENTRIES; dir++) { | ||
653 | if (!ehea_bmap->top[top]->dir[dir]) | ||
654 | continue; | ||
655 | |||
656 | kfree(ehea_bmap->top[top]->dir[dir]); | ||
657 | } | ||
658 | |||
659 | kfree(ehea_bmap->top[top]); | ||
660 | } | ||
661 | |||
662 | kfree(ehea_bmap); | ||
663 | ehea_bmap = NULL; | ||
664 | out_destroy: | ||
665 | mutex_unlock(&ehea_busmap_mutex); | ||
601 | } | 666 | } |
602 | 667 | ||
603 | u64 ehea_map_vaddr(void *caddr) | 668 | u64 ehea_map_vaddr(void *caddr) |
604 | { | 669 | { |
605 | u64 mapped_addr; | 670 | int top, dir, idx; |
606 | unsigned long index = __pa(caddr) >> SECTION_SIZE_BITS; | 671 | unsigned long index, offset; |
607 | 672 | ||
608 | if (likely(index < ehea_bmap.entries)) { | 673 | if (!ehea_bmap) |
609 | mapped_addr = ehea_bmap.vaddr[index]; | 674 | return EHEA_INVAL_ADDR; |
610 | if (likely(mapped_addr)) | 675 | |
611 | mapped_addr |= (((unsigned long)caddr) | 676 | index = virt_to_abs(caddr) >> SECTION_SIZE_BITS; |
612 | & (EHEA_SECTSIZE - 1)); | 677 | top = (index >> EHEA_TOP_INDEX_SHIFT) & EHEA_INDEX_MASK; |
613 | else | 678 | if (!ehea_bmap->top[top]) |
614 | mapped_addr = -1; | 679 | return EHEA_INVAL_ADDR; |
615 | } else | 680 | |
616 | mapped_addr = -1; | 681 | dir = (index >> EHEA_DIR_INDEX_SHIFT) & EHEA_INDEX_MASK; |
617 | 682 | if (!ehea_bmap->top[top]->dir[dir]) | |
618 | if (unlikely(mapped_addr == -1)) | 683 | return EHEA_INVAL_ADDR; |
619 | if (!test_and_set_bit(__EHEA_STOP_XFER, &ehea_driver_flags)) | 684 | |
620 | schedule_work(&ehea_rereg_mr_task); | 685 | idx = index & EHEA_INDEX_MASK; |
621 | 686 | if (!ehea_bmap->top[top]->dir[dir]->ent[idx]) | |
622 | return mapped_addr; | 687 | return EHEA_INVAL_ADDR; |
688 | |||
689 | offset = (unsigned long)caddr & (EHEA_SECTSIZE - 1); | ||
690 | return ehea_bmap->top[top]->dir[dir]->ent[idx] | offset; | ||
691 | } | ||
692 | |||
693 | static inline void *ehea_calc_sectbase(int top, int dir, int idx) | ||
694 | { | ||
695 | unsigned long ret = idx; | ||
696 | ret |= dir << EHEA_DIR_INDEX_SHIFT; | ||
697 | ret |= top << EHEA_TOP_INDEX_SHIFT; | ||
698 | return abs_to_virt(ret << SECTION_SIZE_BITS); | ||
699 | } | ||
700 | |||
701 | static u64 ehea_reg_mr_section(int top, int dir, int idx, u64 *pt, | ||
702 | struct ehea_adapter *adapter, | ||
703 | struct ehea_mr *mr) | ||
704 | { | ||
705 | void *pg; | ||
706 | u64 j, m, hret; | ||
707 | unsigned long k = 0; | ||
708 | u64 pt_abs = virt_to_abs(pt); | ||
709 | |||
710 | void *sectbase = ehea_calc_sectbase(top, dir, idx); | ||
711 | |||
712 | for (j = 0; j < (EHEA_PAGES_PER_SECTION / EHEA_MAX_RPAGE); j++) { | ||
713 | |||
714 | for (m = 0; m < EHEA_MAX_RPAGE; m++) { | ||
715 | pg = sectbase + ((k++) * EHEA_PAGESIZE); | ||
716 | pt[m] = virt_to_abs(pg); | ||
717 | } | ||
718 | hret = ehea_h_register_rpage_mr(adapter->handle, mr->handle, 0, | ||
719 | 0, pt_abs, EHEA_MAX_RPAGE); | ||
720 | |||
721 | if ((hret != H_SUCCESS) | ||
722 | && (hret != H_PAGE_REGISTERED)) { | ||
723 | ehea_h_free_resource(adapter->handle, mr->handle, | ||
724 | FORCE_FREE); | ||
725 | ehea_error("register_rpage_mr failed"); | ||
726 | return hret; | ||
727 | } | ||
728 | } | ||
729 | return hret; | ||
730 | } | ||
731 | |||
732 | static u64 ehea_reg_mr_sections(int top, int dir, u64 *pt, | ||
733 | struct ehea_adapter *adapter, | ||
734 | struct ehea_mr *mr) | ||
735 | { | ||
736 | u64 hret = H_SUCCESS; | ||
737 | int idx; | ||
738 | |||
739 | for (idx = 0; idx < EHEA_MAP_ENTRIES; idx++) { | ||
740 | if (!ehea_bmap->top[top]->dir[dir]->ent[idx]) | ||
741 | continue; | ||
742 | |||
743 | hret = ehea_reg_mr_section(top, dir, idx, pt, adapter, mr); | ||
744 | if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED)) | ||
745 | return hret; | ||
746 | } | ||
747 | return hret; | ||
748 | } | ||
749 | |||
750 | static u64 ehea_reg_mr_dir_sections(int top, u64 *pt, | ||
751 | struct ehea_adapter *adapter, | ||
752 | struct ehea_mr *mr) | ||
753 | { | ||
754 | u64 hret = H_SUCCESS; | ||
755 | int dir; | ||
756 | |||
757 | for (dir = 0; dir < EHEA_MAP_ENTRIES; dir++) { | ||
758 | if (!ehea_bmap->top[top]->dir[dir]) | ||
759 | continue; | ||
760 | |||
761 | hret = ehea_reg_mr_sections(top, dir, pt, adapter, mr); | ||
762 | if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED)) | ||
763 | return hret; | ||
764 | } | ||
765 | return hret; | ||
623 | } | 766 | } |
624 | 767 | ||
625 | int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) | 768 | int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) |
626 | { | 769 | { |
627 | int ret; | 770 | int ret; |
628 | u64 *pt; | 771 | u64 *pt; |
629 | void *pg; | 772 | u64 hret; |
630 | u64 hret, pt_abs, i, j, m, mr_len; | ||
631 | u32 acc_ctrl = EHEA_MR_ACC_CTRL; | 773 | u32 acc_ctrl = EHEA_MR_ACC_CTRL; |
632 | 774 | ||
633 | mr_len = ehea_bmap.valid_sections * EHEA_SECTSIZE; | 775 | unsigned long top; |
634 | 776 | ||
635 | pt = kzalloc(PAGE_SIZE, GFP_KERNEL); | 777 | pt = kzalloc(PAGE_SIZE, GFP_KERNEL); |
636 | if (!pt) { | 778 | if (!pt) { |
637 | ehea_error("no mem"); | 779 | ehea_error("no mem"); |
638 | ret = -ENOMEM; | 780 | ret = -ENOMEM; |
639 | goto out; | 781 | goto out; |
640 | } | 782 | } |
641 | pt_abs = virt_to_abs(pt); | ||
642 | 783 | ||
643 | hret = ehea_h_alloc_resource_mr(adapter->handle, | 784 | hret = ehea_h_alloc_resource_mr(adapter->handle, EHEA_BUSMAP_START, |
644 | EHEA_BUSMAP_START, mr_len, | 785 | ehea_mr_len, acc_ctrl, adapter->pd, |
645 | acc_ctrl, adapter->pd, | ||
646 | &mr->handle, &mr->lkey); | 786 | &mr->handle, &mr->lkey); |
787 | |||
647 | if (hret != H_SUCCESS) { | 788 | if (hret != H_SUCCESS) { |
648 | ehea_error("alloc_resource_mr failed"); | 789 | ehea_error("alloc_resource_mr failed"); |
649 | ret = -EIO; | 790 | ret = -EIO; |
650 | goto out; | 791 | goto out; |
651 | } | 792 | } |
652 | 793 | ||
653 | for (i = 0 ; i < ehea_bmap.entries; i++) | 794 | if (!ehea_bmap) { |
654 | if (ehea_bmap.vaddr[i]) { | 795 | ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE); |
655 | void *sectbase = __va(i << SECTION_SIZE_BITS); | 796 | ehea_error("no busmap available"); |
656 | unsigned long k = 0; | 797 | ret = -EIO; |
657 | 798 | goto out; | |
658 | for (j = 0; j < (EHEA_PAGES_PER_SECTION / | 799 | } |
659 | EHEA_MAX_RPAGE); j++) { | 800 | |
660 | 801 | for (top = 0; top < EHEA_MAP_ENTRIES; top++) { | |
661 | for (m = 0; m < EHEA_MAX_RPAGE; m++) { | 802 | if (!ehea_bmap->top[top]) |
662 | pg = sectbase + ((k++) * EHEA_PAGESIZE); | 803 | continue; |
663 | pt[m] = virt_to_abs(pg); | 804 | |
664 | } | 805 | hret = ehea_reg_mr_dir_sections(top, pt, adapter, mr); |
665 | 806 | if((hret != H_PAGE_REGISTERED) && (hret != H_SUCCESS)) | |
666 | hret = ehea_h_register_rpage_mr(adapter->handle, | 807 | break; |
667 | mr->handle, | 808 | } |
668 | 0, 0, pt_abs, | ||
669 | EHEA_MAX_RPAGE); | ||
670 | if ((hret != H_SUCCESS) | ||
671 | && (hret != H_PAGE_REGISTERED)) { | ||
672 | ehea_h_free_resource(adapter->handle, | ||
673 | mr->handle, | ||
674 | FORCE_FREE); | ||
675 | ehea_error("register_rpage_mr failed"); | ||
676 | ret = -EIO; | ||
677 | goto out; | ||
678 | } | ||
679 | } | ||
680 | } | ||
681 | 809 | ||
682 | if (hret != H_SUCCESS) { | 810 | if (hret != H_SUCCESS) { |
683 | ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE); | 811 | ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE); |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 6f22f068d6ee..25bdd0832df5 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -635,6 +635,8 @@ static void free_skb_resources(struct gfar_private *priv) | |||
635 | dev_kfree_skb_any(priv->tx_skbuff[i]); | 635 | dev_kfree_skb_any(priv->tx_skbuff[i]); |
636 | priv->tx_skbuff[i] = NULL; | 636 | priv->tx_skbuff[i] = NULL; |
637 | } | 637 | } |
638 | |||
639 | txbdp++; | ||
638 | } | 640 | } |
639 | 641 | ||
640 | kfree(priv->tx_skbuff); | 642 | kfree(priv->tx_skbuff); |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index ef63c8d2bd7e..c91b12ea26ad 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -144,11 +144,13 @@ struct myri10ge_tx_buf { | |||
144 | char *req_bytes; | 144 | char *req_bytes; |
145 | struct myri10ge_tx_buffer_state *info; | 145 | struct myri10ge_tx_buffer_state *info; |
146 | int mask; /* number of transmit slots -1 */ | 146 | int mask; /* number of transmit slots -1 */ |
147 | int boundary; /* boundary transmits cannot cross */ | ||
148 | int req ____cacheline_aligned; /* transmit slots submitted */ | 147 | int req ____cacheline_aligned; /* transmit slots submitted */ |
149 | int pkt_start; /* packets started */ | 148 | int pkt_start; /* packets started */ |
149 | int stop_queue; | ||
150 | int linearized; | ||
150 | int done ____cacheline_aligned; /* transmit slots completed */ | 151 | int done ____cacheline_aligned; /* transmit slots completed */ |
151 | int pkt_done; /* packets completed */ | 152 | int pkt_done; /* packets completed */ |
153 | int wake_queue; | ||
152 | }; | 154 | }; |
153 | 155 | ||
154 | struct myri10ge_rx_done { | 156 | struct myri10ge_rx_done { |
@@ -160,29 +162,50 @@ struct myri10ge_rx_done { | |||
160 | struct net_lro_desc lro_desc[MYRI10GE_MAX_LRO_DESCRIPTORS]; | 162 | struct net_lro_desc lro_desc[MYRI10GE_MAX_LRO_DESCRIPTORS]; |
161 | }; | 163 | }; |
162 | 164 | ||
163 | struct myri10ge_priv { | 165 | struct myri10ge_slice_netstats { |
164 | int running; /* running? */ | 166 | unsigned long rx_packets; |
165 | int csum_flag; /* rx_csums? */ | 167 | unsigned long tx_packets; |
168 | unsigned long rx_bytes; | ||
169 | unsigned long tx_bytes; | ||
170 | unsigned long rx_dropped; | ||
171 | unsigned long tx_dropped; | ||
172 | }; | ||
173 | |||
174 | struct myri10ge_slice_state { | ||
166 | struct myri10ge_tx_buf tx; /* transmit ring */ | 175 | struct myri10ge_tx_buf tx; /* transmit ring */ |
167 | struct myri10ge_rx_buf rx_small; | 176 | struct myri10ge_rx_buf rx_small; |
168 | struct myri10ge_rx_buf rx_big; | 177 | struct myri10ge_rx_buf rx_big; |
169 | struct myri10ge_rx_done rx_done; | 178 | struct myri10ge_rx_done rx_done; |
179 | struct net_device *dev; | ||
180 | struct napi_struct napi; | ||
181 | struct myri10ge_priv *mgp; | ||
182 | struct myri10ge_slice_netstats stats; | ||
183 | __be32 __iomem *irq_claim; | ||
184 | struct mcp_irq_data *fw_stats; | ||
185 | dma_addr_t fw_stats_bus; | ||
186 | int watchdog_tx_done; | ||
187 | int watchdog_tx_req; | ||
188 | }; | ||
189 | |||
190 | struct myri10ge_priv { | ||
191 | struct myri10ge_slice_state ss; | ||
192 | int tx_boundary; /* boundary transmits cannot cross */ | ||
193 | int running; /* running? */ | ||
194 | int csum_flag; /* rx_csums? */ | ||
170 | int small_bytes; | 195 | int small_bytes; |
171 | int big_bytes; | 196 | int big_bytes; |
197 | int max_intr_slots; | ||
172 | struct net_device *dev; | 198 | struct net_device *dev; |
173 | struct napi_struct napi; | ||
174 | struct net_device_stats stats; | 199 | struct net_device_stats stats; |
200 | spinlock_t stats_lock; | ||
175 | u8 __iomem *sram; | 201 | u8 __iomem *sram; |
176 | int sram_size; | 202 | int sram_size; |
177 | unsigned long board_span; | 203 | unsigned long board_span; |
178 | unsigned long iomem_base; | 204 | unsigned long iomem_base; |
179 | __be32 __iomem *irq_claim; | ||
180 | __be32 __iomem *irq_deassert; | 205 | __be32 __iomem *irq_deassert; |
181 | char *mac_addr_string; | 206 | char *mac_addr_string; |
182 | struct mcp_cmd_response *cmd; | 207 | struct mcp_cmd_response *cmd; |
183 | dma_addr_t cmd_bus; | 208 | dma_addr_t cmd_bus; |
184 | struct mcp_irq_data *fw_stats; | ||
185 | dma_addr_t fw_stats_bus; | ||
186 | struct pci_dev *pdev; | 209 | struct pci_dev *pdev; |
187 | int msi_enabled; | 210 | int msi_enabled; |
188 | u32 link_state; | 211 | u32 link_state; |
@@ -191,20 +214,16 @@ struct myri10ge_priv { | |||
191 | __be32 __iomem *intr_coal_delay_ptr; | 214 | __be32 __iomem *intr_coal_delay_ptr; |
192 | int mtrr; | 215 | int mtrr; |
193 | int wc_enabled; | 216 | int wc_enabled; |
194 | int wake_queue; | ||
195 | int stop_queue; | ||
196 | int down_cnt; | 217 | int down_cnt; |
197 | wait_queue_head_t down_wq; | 218 | wait_queue_head_t down_wq; |
198 | struct work_struct watchdog_work; | 219 | struct work_struct watchdog_work; |
199 | struct timer_list watchdog_timer; | 220 | struct timer_list watchdog_timer; |
200 | int watchdog_tx_done; | ||
201 | int watchdog_tx_req; | ||
202 | int watchdog_pause; | ||
203 | int watchdog_resets; | 221 | int watchdog_resets; |
204 | int tx_linearized; | 222 | int watchdog_pause; |
205 | int pause; | 223 | int pause; |
206 | char *fw_name; | 224 | char *fw_name; |
207 | char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE]; | 225 | char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE]; |
226 | char *product_code_string; | ||
208 | char fw_version[128]; | 227 | char fw_version[128]; |
209 | int fw_ver_major; | 228 | int fw_ver_major; |
210 | int fw_ver_minor; | 229 | int fw_ver_minor; |
@@ -228,58 +247,54 @@ static char *myri10ge_fw_aligned = "myri10ge_eth_z8e.dat"; | |||
228 | 247 | ||
229 | static char *myri10ge_fw_name = NULL; | 248 | static char *myri10ge_fw_name = NULL; |
230 | module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR); | 249 | module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR); |
231 | MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name\n"); | 250 | MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name"); |
232 | 251 | ||
233 | static int myri10ge_ecrc_enable = 1; | 252 | static int myri10ge_ecrc_enable = 1; |
234 | module_param(myri10ge_ecrc_enable, int, S_IRUGO); | 253 | module_param(myri10ge_ecrc_enable, int, S_IRUGO); |
235 | MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E\n"); | 254 | MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E"); |
236 | |||
237 | static int myri10ge_max_intr_slots = 1024; | ||
238 | module_param(myri10ge_max_intr_slots, int, S_IRUGO); | ||
239 | MODULE_PARM_DESC(myri10ge_max_intr_slots, "Interrupt queue slots\n"); | ||
240 | 255 | ||
241 | static int myri10ge_small_bytes = -1; /* -1 == auto */ | 256 | static int myri10ge_small_bytes = -1; /* -1 == auto */ |
242 | module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR); | 257 | module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR); |
243 | MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets\n"); | 258 | MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets"); |
244 | 259 | ||
245 | static int myri10ge_msi = 1; /* enable msi by default */ | 260 | static int myri10ge_msi = 1; /* enable msi by default */ |
246 | module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR); | 261 | module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR); |
247 | MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts\n"); | 262 | MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts"); |
248 | 263 | ||
249 | static int myri10ge_intr_coal_delay = 75; | 264 | static int myri10ge_intr_coal_delay = 75; |
250 | module_param(myri10ge_intr_coal_delay, int, S_IRUGO); | 265 | module_param(myri10ge_intr_coal_delay, int, S_IRUGO); |
251 | MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay\n"); | 266 | MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay"); |
252 | 267 | ||
253 | static int myri10ge_flow_control = 1; | 268 | static int myri10ge_flow_control = 1; |
254 | module_param(myri10ge_flow_control, int, S_IRUGO); | 269 | module_param(myri10ge_flow_control, int, S_IRUGO); |
255 | MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter\n"); | 270 | MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter"); |
256 | 271 | ||
257 | static int myri10ge_deassert_wait = 1; | 272 | static int myri10ge_deassert_wait = 1; |
258 | module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR); | 273 | module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR); |
259 | MODULE_PARM_DESC(myri10ge_deassert_wait, | 274 | MODULE_PARM_DESC(myri10ge_deassert_wait, |
260 | "Wait when deasserting legacy interrupts\n"); | 275 | "Wait when deasserting legacy interrupts"); |
261 | 276 | ||
262 | static int myri10ge_force_firmware = 0; | 277 | static int myri10ge_force_firmware = 0; |
263 | module_param(myri10ge_force_firmware, int, S_IRUGO); | 278 | module_param(myri10ge_force_firmware, int, S_IRUGO); |
264 | MODULE_PARM_DESC(myri10ge_force_firmware, | 279 | MODULE_PARM_DESC(myri10ge_force_firmware, |
265 | "Force firmware to assume aligned completions\n"); | 280 | "Force firmware to assume aligned completions"); |
266 | 281 | ||
267 | static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN; | 282 | static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN; |
268 | module_param(myri10ge_initial_mtu, int, S_IRUGO); | 283 | module_param(myri10ge_initial_mtu, int, S_IRUGO); |
269 | MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU\n"); | 284 | MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU"); |
270 | 285 | ||
271 | static int myri10ge_napi_weight = 64; | 286 | static int myri10ge_napi_weight = 64; |
272 | module_param(myri10ge_napi_weight, int, S_IRUGO); | 287 | module_param(myri10ge_napi_weight, int, S_IRUGO); |
273 | MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight\n"); | 288 | MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight"); |
274 | 289 | ||
275 | static int myri10ge_watchdog_timeout = 1; | 290 | static int myri10ge_watchdog_timeout = 1; |
276 | module_param(myri10ge_watchdog_timeout, int, S_IRUGO); | 291 | module_param(myri10ge_watchdog_timeout, int, S_IRUGO); |
277 | MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout\n"); | 292 | MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout"); |
278 | 293 | ||
279 | static int myri10ge_max_irq_loops = 1048576; | 294 | static int myri10ge_max_irq_loops = 1048576; |
280 | module_param(myri10ge_max_irq_loops, int, S_IRUGO); | 295 | module_param(myri10ge_max_irq_loops, int, S_IRUGO); |
281 | MODULE_PARM_DESC(myri10ge_max_irq_loops, | 296 | MODULE_PARM_DESC(myri10ge_max_irq_loops, |
282 | "Set stuck legacy IRQ detection threshold\n"); | 297 | "Set stuck legacy IRQ detection threshold"); |
283 | 298 | ||
284 | #define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK | 299 | #define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK |
285 | 300 | ||
@@ -289,21 +304,22 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)"); | |||
289 | 304 | ||
290 | static int myri10ge_lro = 1; | 305 | static int myri10ge_lro = 1; |
291 | module_param(myri10ge_lro, int, S_IRUGO); | 306 | module_param(myri10ge_lro, int, S_IRUGO); |
292 | MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload\n"); | 307 | MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload"); |
293 | 308 | ||
294 | static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS; | 309 | static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS; |
295 | module_param(myri10ge_lro_max_pkts, int, S_IRUGO); | 310 | module_param(myri10ge_lro_max_pkts, int, S_IRUGO); |
296 | MODULE_PARM_DESC(myri10ge_lro, "Number of LRO packets to be aggregated\n"); | 311 | MODULE_PARM_DESC(myri10ge_lro_max_pkts, |
312 | "Number of LRO packets to be aggregated"); | ||
297 | 313 | ||
298 | static int myri10ge_fill_thresh = 256; | 314 | static int myri10ge_fill_thresh = 256; |
299 | module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR); | 315 | module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR); |
300 | MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed\n"); | 316 | MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed"); |
301 | 317 | ||
302 | static int myri10ge_reset_recover = 1; | 318 | static int myri10ge_reset_recover = 1; |
303 | 319 | ||
304 | static int myri10ge_wcfifo = 0; | 320 | static int myri10ge_wcfifo = 0; |
305 | module_param(myri10ge_wcfifo, int, S_IRUGO); | 321 | module_param(myri10ge_wcfifo, int, S_IRUGO); |
306 | MODULE_PARM_DESC(myri10ge_wcfifo, "Enable WC Fifo when WC is enabled\n"); | 322 | MODULE_PARM_DESC(myri10ge_wcfifo, "Enable WC Fifo when WC is enabled"); |
307 | 323 | ||
308 | #define MYRI10GE_FW_OFFSET 1024*1024 | 324 | #define MYRI10GE_FW_OFFSET 1024*1024 |
309 | #define MYRI10GE_HIGHPART_TO_U32(X) \ | 325 | #define MYRI10GE_HIGHPART_TO_U32(X) \ |
@@ -359,8 +375,10 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, | |||
359 | for (sleep_total = 0; | 375 | for (sleep_total = 0; |
360 | sleep_total < 1000 | 376 | sleep_total < 1000 |
361 | && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); | 377 | && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); |
362 | sleep_total += 10) | 378 | sleep_total += 10) { |
363 | udelay(10); | 379 | udelay(10); |
380 | mb(); | ||
381 | } | ||
364 | } else { | 382 | } else { |
365 | /* use msleep for most command */ | 383 | /* use msleep for most command */ |
366 | for (sleep_total = 0; | 384 | for (sleep_total = 0; |
@@ -420,6 +438,10 @@ static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp) | |||
420 | ptr += 1; | 438 | ptr += 1; |
421 | } | 439 | } |
422 | } | 440 | } |
441 | if (memcmp(ptr, "PC=", 3) == 0) { | ||
442 | ptr += 3; | ||
443 | mgp->product_code_string = ptr; | ||
444 | } | ||
423 | if (memcmp((const void *)ptr, "SN=", 3) == 0) { | 445 | if (memcmp((const void *)ptr, "SN=", 3) == 0) { |
424 | ptr += 3; | 446 | ptr += 3; |
425 | mgp->serial_number = simple_strtoul(ptr, &ptr, 10); | 447 | mgp->serial_number = simple_strtoul(ptr, &ptr, 10); |
@@ -442,7 +464,7 @@ abort: | |||
442 | static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) | 464 | static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) |
443 | { | 465 | { |
444 | char __iomem *submit; | 466 | char __iomem *submit; |
445 | __be32 buf[16]; | 467 | __be32 buf[16] __attribute__ ((__aligned__(8))); |
446 | u32 dma_low, dma_high; | 468 | u32 dma_low, dma_high; |
447 | int i; | 469 | int i; |
448 | 470 | ||
@@ -609,13 +631,38 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp) | |||
609 | return status; | 631 | return status; |
610 | } | 632 | } |
611 | 633 | ||
634 | int myri10ge_get_firmware_capabilities(struct myri10ge_priv *mgp) | ||
635 | { | ||
636 | struct myri10ge_cmd cmd; | ||
637 | int status; | ||
638 | |||
639 | /* probe for IPv6 TSO support */ | ||
640 | mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO; | ||
641 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, | ||
642 | &cmd, 0); | ||
643 | if (status == 0) { | ||
644 | mgp->max_tso6 = cmd.data0; | ||
645 | mgp->features |= NETIF_F_TSO6; | ||
646 | } | ||
647 | |||
648 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); | ||
649 | if (status != 0) { | ||
650 | dev_err(&mgp->pdev->dev, | ||
651 | "failed MXGEFW_CMD_GET_RX_RING_SIZE\n"); | ||
652 | return -ENXIO; | ||
653 | } | ||
654 | |||
655 | mgp->max_intr_slots = 2 * (cmd.data0 / sizeof(struct mcp_dma_addr)); | ||
656 | |||
657 | return 0; | ||
658 | } | ||
659 | |||
612 | static int myri10ge_load_firmware(struct myri10ge_priv *mgp) | 660 | static int myri10ge_load_firmware(struct myri10ge_priv *mgp) |
613 | { | 661 | { |
614 | char __iomem *submit; | 662 | char __iomem *submit; |
615 | __be32 buf[16]; | 663 | __be32 buf[16] __attribute__ ((__aligned__(8))); |
616 | u32 dma_low, dma_high, size; | 664 | u32 dma_low, dma_high, size; |
617 | int status, i; | 665 | int status, i; |
618 | struct myri10ge_cmd cmd; | ||
619 | 666 | ||
620 | size = 0; | 667 | size = 0; |
621 | status = myri10ge_load_hotplug_firmware(mgp, &size); | 668 | status = myri10ge_load_hotplug_firmware(mgp, &size); |
@@ -635,7 +682,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp) | |||
635 | } | 682 | } |
636 | dev_info(&mgp->pdev->dev, | 683 | dev_info(&mgp->pdev->dev, |
637 | "Successfully adopted running firmware\n"); | 684 | "Successfully adopted running firmware\n"); |
638 | if (mgp->tx.boundary == 4096) { | 685 | if (mgp->tx_boundary == 4096) { |
639 | dev_warn(&mgp->pdev->dev, | 686 | dev_warn(&mgp->pdev->dev, |
640 | "Using firmware currently running on NIC" | 687 | "Using firmware currently running on NIC" |
641 | ". For optimal\n"); | 688 | ". For optimal\n"); |
@@ -646,7 +693,9 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp) | |||
646 | } | 693 | } |
647 | 694 | ||
648 | mgp->fw_name = "adopted"; | 695 | mgp->fw_name = "adopted"; |
649 | mgp->tx.boundary = 2048; | 696 | mgp->tx_boundary = 2048; |
697 | myri10ge_dummy_rdma(mgp, 1); | ||
698 | status = myri10ge_get_firmware_capabilities(mgp); | ||
650 | return status; | 699 | return status; |
651 | } | 700 | } |
652 | 701 | ||
@@ -681,26 +730,18 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp) | |||
681 | msleep(1); | 730 | msleep(1); |
682 | mb(); | 731 | mb(); |
683 | i = 0; | 732 | i = 0; |
684 | while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20) { | 733 | while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 9) { |
685 | msleep(1); | 734 | msleep(1 << i); |
686 | i++; | 735 | i++; |
687 | } | 736 | } |
688 | if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) { | 737 | if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) { |
689 | dev_err(&mgp->pdev->dev, "handoff failed\n"); | 738 | dev_err(&mgp->pdev->dev, "handoff failed\n"); |
690 | return -ENXIO; | 739 | return -ENXIO; |
691 | } | 740 | } |
692 | dev_info(&mgp->pdev->dev, "handoff confirmed\n"); | ||
693 | myri10ge_dummy_rdma(mgp, 1); | 741 | myri10ge_dummy_rdma(mgp, 1); |
742 | status = myri10ge_get_firmware_capabilities(mgp); | ||
694 | 743 | ||
695 | /* probe for IPv6 TSO support */ | 744 | return status; |
696 | mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO; | ||
697 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, | ||
698 | &cmd, 0); | ||
699 | if (status == 0) { | ||
700 | mgp->max_tso6 = cmd.data0; | ||
701 | mgp->features |= NETIF_F_TSO6; | ||
702 | } | ||
703 | return 0; | ||
704 | } | 745 | } |
705 | 746 | ||
706 | static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr) | 747 | static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr) |
@@ -772,7 +813,7 @@ static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type) | |||
772 | * transfers took to complete. | 813 | * transfers took to complete. |
773 | */ | 814 | */ |
774 | 815 | ||
775 | len = mgp->tx.boundary; | 816 | len = mgp->tx_boundary; |
776 | 817 | ||
777 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus); | 818 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus); |
778 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus); | 819 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus); |
@@ -834,17 +875,17 @@ static int myri10ge_reset(struct myri10ge_priv *mgp) | |||
834 | 875 | ||
835 | /* Now exchange information about interrupts */ | 876 | /* Now exchange information about interrupts */ |
836 | 877 | ||
837 | bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); | 878 | bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry); |
838 | memset(mgp->rx_done.entry, 0, bytes); | 879 | memset(mgp->ss.rx_done.entry, 0, bytes); |
839 | cmd.data0 = (u32) bytes; | 880 | cmd.data0 = (u32) bytes; |
840 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); | 881 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); |
841 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus); | 882 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->ss.rx_done.bus); |
842 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus); | 883 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->ss.rx_done.bus); |
843 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0); | 884 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0); |
844 | 885 | ||
845 | status |= | 886 | status |= |
846 | myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); | 887 | myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); |
847 | mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0); | 888 | mgp->ss.irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0); |
848 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, | 889 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, |
849 | &cmd, 0); | 890 | &cmd, 0); |
850 | mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); | 891 | mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); |
@@ -858,17 +899,17 @@ static int myri10ge_reset(struct myri10ge_priv *mgp) | |||
858 | } | 899 | } |
859 | put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); | 900 | put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); |
860 | 901 | ||
861 | memset(mgp->rx_done.entry, 0, bytes); | 902 | memset(mgp->ss.rx_done.entry, 0, bytes); |
862 | 903 | ||
863 | /* reset mcp/driver shared state back to 0 */ | 904 | /* reset mcp/driver shared state back to 0 */ |
864 | mgp->tx.req = 0; | 905 | mgp->ss.tx.req = 0; |
865 | mgp->tx.done = 0; | 906 | mgp->ss.tx.done = 0; |
866 | mgp->tx.pkt_start = 0; | 907 | mgp->ss.tx.pkt_start = 0; |
867 | mgp->tx.pkt_done = 0; | 908 | mgp->ss.tx.pkt_done = 0; |
868 | mgp->rx_big.cnt = 0; | 909 | mgp->ss.rx_big.cnt = 0; |
869 | mgp->rx_small.cnt = 0; | 910 | mgp->ss.rx_small.cnt = 0; |
870 | mgp->rx_done.idx = 0; | 911 | mgp->ss.rx_done.idx = 0; |
871 | mgp->rx_done.cnt = 0; | 912 | mgp->ss.rx_done.cnt = 0; |
872 | mgp->link_changes = 0; | 913 | mgp->link_changes = 0; |
873 | status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr); | 914 | status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr); |
874 | myri10ge_change_pause(mgp, mgp->pause); | 915 | myri10ge_change_pause(mgp, mgp->pause); |
@@ -1020,9 +1061,10 @@ myri10ge_unmap_rx_page(struct pci_dev *pdev, | |||
1020 | * page into an skb */ | 1061 | * page into an skb */ |
1021 | 1062 | ||
1022 | static inline int | 1063 | static inline int |
1023 | myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, | 1064 | myri10ge_rx_done(struct myri10ge_slice_state *ss, struct myri10ge_rx_buf *rx, |
1024 | int bytes, int len, __wsum csum) | 1065 | int bytes, int len, __wsum csum) |
1025 | { | 1066 | { |
1067 | struct myri10ge_priv *mgp = ss->mgp; | ||
1026 | struct sk_buff *skb; | 1068 | struct sk_buff *skb; |
1027 | struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME]; | 1069 | struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME]; |
1028 | int i, idx, hlen, remainder; | 1070 | int i, idx, hlen, remainder; |
@@ -1052,11 +1094,10 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, | |||
1052 | rx_frags[0].page_offset += MXGEFW_PAD; | 1094 | rx_frags[0].page_offset += MXGEFW_PAD; |
1053 | rx_frags[0].size -= MXGEFW_PAD; | 1095 | rx_frags[0].size -= MXGEFW_PAD; |
1054 | len -= MXGEFW_PAD; | 1096 | len -= MXGEFW_PAD; |
1055 | lro_receive_frags(&mgp->rx_done.lro_mgr, rx_frags, | 1097 | lro_receive_frags(&ss->rx_done.lro_mgr, rx_frags, |
1056 | len, len, | 1098 | len, len, |
1057 | /* opaque, will come back in get_frag_header */ | 1099 | /* opaque, will come back in get_frag_header */ |
1058 | (void *)(__force unsigned long)csum, | 1100 | (void *)(__force unsigned long)csum, csum); |
1059 | csum); | ||
1060 | return 1; | 1101 | return 1; |
1061 | } | 1102 | } |
1062 | 1103 | ||
@@ -1096,10 +1137,11 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, | |||
1096 | return 1; | 1137 | return 1; |
1097 | } | 1138 | } |
1098 | 1139 | ||
1099 | static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index) | 1140 | static inline void |
1141 | myri10ge_tx_done(struct myri10ge_slice_state *ss, int mcp_index) | ||
1100 | { | 1142 | { |
1101 | struct pci_dev *pdev = mgp->pdev; | 1143 | struct pci_dev *pdev = ss->mgp->pdev; |
1102 | struct myri10ge_tx_buf *tx = &mgp->tx; | 1144 | struct myri10ge_tx_buf *tx = &ss->tx; |
1103 | struct sk_buff *skb; | 1145 | struct sk_buff *skb; |
1104 | int idx, len; | 1146 | int idx, len; |
1105 | 1147 | ||
@@ -1117,8 +1159,8 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index) | |||
1117 | len = pci_unmap_len(&tx->info[idx], len); | 1159 | len = pci_unmap_len(&tx->info[idx], len); |
1118 | pci_unmap_len_set(&tx->info[idx], len, 0); | 1160 | pci_unmap_len_set(&tx->info[idx], len, 0); |
1119 | if (skb) { | 1161 | if (skb) { |
1120 | mgp->stats.tx_bytes += skb->len; | 1162 | ss->stats.tx_bytes += skb->len; |
1121 | mgp->stats.tx_packets++; | 1163 | ss->stats.tx_packets++; |
1122 | dev_kfree_skb_irq(skb); | 1164 | dev_kfree_skb_irq(skb); |
1123 | if (len) | 1165 | if (len) |
1124 | pci_unmap_single(pdev, | 1166 | pci_unmap_single(pdev, |
@@ -1134,16 +1176,18 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index) | |||
1134 | } | 1176 | } |
1135 | } | 1177 | } |
1136 | /* start the queue if we've stopped it */ | 1178 | /* start the queue if we've stopped it */ |
1137 | if (netif_queue_stopped(mgp->dev) | 1179 | if (netif_queue_stopped(ss->dev) |
1138 | && tx->req - tx->done < (tx->mask >> 1)) { | 1180 | && tx->req - tx->done < (tx->mask >> 1)) { |
1139 | mgp->wake_queue++; | 1181 | tx->wake_queue++; |
1140 | netif_wake_queue(mgp->dev); | 1182 | netif_wake_queue(ss->dev); |
1141 | } | 1183 | } |
1142 | } | 1184 | } |
1143 | 1185 | ||
1144 | static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget) | 1186 | static inline int |
1187 | myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget) | ||
1145 | { | 1188 | { |
1146 | struct myri10ge_rx_done *rx_done = &mgp->rx_done; | 1189 | struct myri10ge_rx_done *rx_done = &ss->rx_done; |
1190 | struct myri10ge_priv *mgp = ss->mgp; | ||
1147 | unsigned long rx_bytes = 0; | 1191 | unsigned long rx_bytes = 0; |
1148 | unsigned long rx_packets = 0; | 1192 | unsigned long rx_packets = 0; |
1149 | unsigned long rx_ok; | 1193 | unsigned long rx_ok; |
@@ -1159,40 +1203,40 @@ static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget) | |||
1159 | rx_done->entry[idx].length = 0; | 1203 | rx_done->entry[idx].length = 0; |
1160 | checksum = csum_unfold(rx_done->entry[idx].checksum); | 1204 | checksum = csum_unfold(rx_done->entry[idx].checksum); |
1161 | if (length <= mgp->small_bytes) | 1205 | if (length <= mgp->small_bytes) |
1162 | rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small, | 1206 | rx_ok = myri10ge_rx_done(ss, &ss->rx_small, |
1163 | mgp->small_bytes, | 1207 | mgp->small_bytes, |
1164 | length, checksum); | 1208 | length, checksum); |
1165 | else | 1209 | else |
1166 | rx_ok = myri10ge_rx_done(mgp, &mgp->rx_big, | 1210 | rx_ok = myri10ge_rx_done(ss, &ss->rx_big, |
1167 | mgp->big_bytes, | 1211 | mgp->big_bytes, |
1168 | length, checksum); | 1212 | length, checksum); |
1169 | rx_packets += rx_ok; | 1213 | rx_packets += rx_ok; |
1170 | rx_bytes += rx_ok * (unsigned long)length; | 1214 | rx_bytes += rx_ok * (unsigned long)length; |
1171 | cnt++; | 1215 | cnt++; |
1172 | idx = cnt & (myri10ge_max_intr_slots - 1); | 1216 | idx = cnt & (mgp->max_intr_slots - 1); |
1173 | work_done++; | 1217 | work_done++; |
1174 | } | 1218 | } |
1175 | rx_done->idx = idx; | 1219 | rx_done->idx = idx; |
1176 | rx_done->cnt = cnt; | 1220 | rx_done->cnt = cnt; |
1177 | mgp->stats.rx_packets += rx_packets; | 1221 | ss->stats.rx_packets += rx_packets; |
1178 | mgp->stats.rx_bytes += rx_bytes; | 1222 | ss->stats.rx_bytes += rx_bytes; |
1179 | 1223 | ||
1180 | if (myri10ge_lro) | 1224 | if (myri10ge_lro) |
1181 | lro_flush_all(&rx_done->lro_mgr); | 1225 | lro_flush_all(&rx_done->lro_mgr); |
1182 | 1226 | ||
1183 | /* restock receive rings if needed */ | 1227 | /* restock receive rings if needed */ |
1184 | if (mgp->rx_small.fill_cnt - mgp->rx_small.cnt < myri10ge_fill_thresh) | 1228 | if (ss->rx_small.fill_cnt - ss->rx_small.cnt < myri10ge_fill_thresh) |
1185 | myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, | 1229 | myri10ge_alloc_rx_pages(mgp, &ss->rx_small, |
1186 | mgp->small_bytes + MXGEFW_PAD, 0); | 1230 | mgp->small_bytes + MXGEFW_PAD, 0); |
1187 | if (mgp->rx_big.fill_cnt - mgp->rx_big.cnt < myri10ge_fill_thresh) | 1231 | if (ss->rx_big.fill_cnt - ss->rx_big.cnt < myri10ge_fill_thresh) |
1188 | myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 0); | 1232 | myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); |
1189 | 1233 | ||
1190 | return work_done; | 1234 | return work_done; |
1191 | } | 1235 | } |
1192 | 1236 | ||
1193 | static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) | 1237 | static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) |
1194 | { | 1238 | { |
1195 | struct mcp_irq_data *stats = mgp->fw_stats; | 1239 | struct mcp_irq_data *stats = mgp->ss.fw_stats; |
1196 | 1240 | ||
1197 | if (unlikely(stats->stats_updated)) { | 1241 | if (unlikely(stats->stats_updated)) { |
1198 | unsigned link_up = ntohl(stats->link_up); | 1242 | unsigned link_up = ntohl(stats->link_up); |
@@ -1219,9 +1263,9 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) | |||
1219 | } | 1263 | } |
1220 | } | 1264 | } |
1221 | if (mgp->rdma_tags_available != | 1265 | if (mgp->rdma_tags_available != |
1222 | ntohl(mgp->fw_stats->rdma_tags_available)) { | 1266 | ntohl(stats->rdma_tags_available)) { |
1223 | mgp->rdma_tags_available = | 1267 | mgp->rdma_tags_available = |
1224 | ntohl(mgp->fw_stats->rdma_tags_available); | 1268 | ntohl(stats->rdma_tags_available); |
1225 | printk(KERN_WARNING "myri10ge: %s: RDMA timed out! " | 1269 | printk(KERN_WARNING "myri10ge: %s: RDMA timed out! " |
1226 | "%d tags left\n", mgp->dev->name, | 1270 | "%d tags left\n", mgp->dev->name, |
1227 | mgp->rdma_tags_available); | 1271 | mgp->rdma_tags_available); |
@@ -1234,26 +1278,27 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) | |||
1234 | 1278 | ||
1235 | static int myri10ge_poll(struct napi_struct *napi, int budget) | 1279 | static int myri10ge_poll(struct napi_struct *napi, int budget) |
1236 | { | 1280 | { |
1237 | struct myri10ge_priv *mgp = | 1281 | struct myri10ge_slice_state *ss = |
1238 | container_of(napi, struct myri10ge_priv, napi); | 1282 | container_of(napi, struct myri10ge_slice_state, napi); |
1239 | struct net_device *netdev = mgp->dev; | 1283 | struct net_device *netdev = ss->mgp->dev; |
1240 | int work_done; | 1284 | int work_done; |
1241 | 1285 | ||
1242 | /* process as many rx events as NAPI will allow */ | 1286 | /* process as many rx events as NAPI will allow */ |
1243 | work_done = myri10ge_clean_rx_done(mgp, budget); | 1287 | work_done = myri10ge_clean_rx_done(ss, budget); |
1244 | 1288 | ||
1245 | if (work_done < budget) { | 1289 | if (work_done < budget) { |
1246 | netif_rx_complete(netdev, napi); | 1290 | netif_rx_complete(netdev, napi); |
1247 | put_be32(htonl(3), mgp->irq_claim); | 1291 | put_be32(htonl(3), ss->irq_claim); |
1248 | } | 1292 | } |
1249 | return work_done; | 1293 | return work_done; |
1250 | } | 1294 | } |
1251 | 1295 | ||
1252 | static irqreturn_t myri10ge_intr(int irq, void *arg) | 1296 | static irqreturn_t myri10ge_intr(int irq, void *arg) |
1253 | { | 1297 | { |
1254 | struct myri10ge_priv *mgp = arg; | 1298 | struct myri10ge_slice_state *ss = arg; |
1255 | struct mcp_irq_data *stats = mgp->fw_stats; | 1299 | struct myri10ge_priv *mgp = ss->mgp; |
1256 | struct myri10ge_tx_buf *tx = &mgp->tx; | 1300 | struct mcp_irq_data *stats = ss->fw_stats; |
1301 | struct myri10ge_tx_buf *tx = &ss->tx; | ||
1257 | u32 send_done_count; | 1302 | u32 send_done_count; |
1258 | int i; | 1303 | int i; |
1259 | 1304 | ||
@@ -1264,7 +1309,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg) | |||
1264 | /* low bit indicates receives are present, so schedule | 1309 | /* low bit indicates receives are present, so schedule |
1265 | * napi poll handler */ | 1310 | * napi poll handler */ |
1266 | if (stats->valid & 1) | 1311 | if (stats->valid & 1) |
1267 | netif_rx_schedule(mgp->dev, &mgp->napi); | 1312 | netif_rx_schedule(ss->dev, &ss->napi); |
1268 | 1313 | ||
1269 | if (!mgp->msi_enabled) { | 1314 | if (!mgp->msi_enabled) { |
1270 | put_be32(0, mgp->irq_deassert); | 1315 | put_be32(0, mgp->irq_deassert); |
@@ -1281,7 +1326,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg) | |||
1281 | /* check for transmit completes and receives */ | 1326 | /* check for transmit completes and receives */ |
1282 | send_done_count = ntohl(stats->send_done_count); | 1327 | send_done_count = ntohl(stats->send_done_count); |
1283 | if (send_done_count != tx->pkt_done) | 1328 | if (send_done_count != tx->pkt_done) |
1284 | myri10ge_tx_done(mgp, (int)send_done_count); | 1329 | myri10ge_tx_done(ss, (int)send_done_count); |
1285 | if (unlikely(i > myri10ge_max_irq_loops)) { | 1330 | if (unlikely(i > myri10ge_max_irq_loops)) { |
1286 | printk(KERN_WARNING "myri10ge: %s: irq stuck?\n", | 1331 | printk(KERN_WARNING "myri10ge: %s: irq stuck?\n", |
1287 | mgp->dev->name); | 1332 | mgp->dev->name); |
@@ -1296,16 +1341,46 @@ static irqreturn_t myri10ge_intr(int irq, void *arg) | |||
1296 | 1341 | ||
1297 | myri10ge_check_statblock(mgp); | 1342 | myri10ge_check_statblock(mgp); |
1298 | 1343 | ||
1299 | put_be32(htonl(3), mgp->irq_claim + 1); | 1344 | put_be32(htonl(3), ss->irq_claim + 1); |
1300 | return (IRQ_HANDLED); | 1345 | return (IRQ_HANDLED); |
1301 | } | 1346 | } |
1302 | 1347 | ||
1303 | static int | 1348 | static int |
1304 | myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) | 1349 | myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) |
1305 | { | 1350 | { |
1351 | struct myri10ge_priv *mgp = netdev_priv(netdev); | ||
1352 | char *ptr; | ||
1353 | int i; | ||
1354 | |||
1306 | cmd->autoneg = AUTONEG_DISABLE; | 1355 | cmd->autoneg = AUTONEG_DISABLE; |
1307 | cmd->speed = SPEED_10000; | 1356 | cmd->speed = SPEED_10000; |
1308 | cmd->duplex = DUPLEX_FULL; | 1357 | cmd->duplex = DUPLEX_FULL; |
1358 | |||
1359 | /* | ||
1360 | * parse the product code to deterimine the interface type | ||
1361 | * (CX4, XFP, Quad Ribbon Fiber) by looking at the character | ||
1362 | * after the 3rd dash in the driver's cached copy of the | ||
1363 | * EEPROM's product code string. | ||
1364 | */ | ||
1365 | ptr = mgp->product_code_string; | ||
1366 | if (ptr == NULL) { | ||
1367 | printk(KERN_ERR "myri10ge: %s: Missing product code\n", | ||
1368 | netdev->name); | ||
1369 | return 0; | ||
1370 | } | ||
1371 | for (i = 0; i < 3; i++, ptr++) { | ||
1372 | ptr = strchr(ptr, '-'); | ||
1373 | if (ptr == NULL) { | ||
1374 | printk(KERN_ERR "myri10ge: %s: Invalid product " | ||
1375 | "code %s\n", netdev->name, | ||
1376 | mgp->product_code_string); | ||
1377 | return 0; | ||
1378 | } | ||
1379 | } | ||
1380 | if (*ptr == 'R' || *ptr == 'Q') { | ||
1381 | /* We've found either an XFP or quad ribbon fiber */ | ||
1382 | cmd->port = PORT_FIBRE; | ||
1383 | } | ||
1309 | return 0; | 1384 | return 0; |
1310 | } | 1385 | } |
1311 | 1386 | ||
@@ -1324,6 +1399,7 @@ static int | |||
1324 | myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal) | 1399 | myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal) |
1325 | { | 1400 | { |
1326 | struct myri10ge_priv *mgp = netdev_priv(netdev); | 1401 | struct myri10ge_priv *mgp = netdev_priv(netdev); |
1402 | |||
1327 | coal->rx_coalesce_usecs = mgp->intr_coal_delay; | 1403 | coal->rx_coalesce_usecs = mgp->intr_coal_delay; |
1328 | return 0; | 1404 | return 0; |
1329 | } | 1405 | } |
@@ -1370,10 +1446,10 @@ myri10ge_get_ringparam(struct net_device *netdev, | |||
1370 | { | 1446 | { |
1371 | struct myri10ge_priv *mgp = netdev_priv(netdev); | 1447 | struct myri10ge_priv *mgp = netdev_priv(netdev); |
1372 | 1448 | ||
1373 | ring->rx_mini_max_pending = mgp->rx_small.mask + 1; | 1449 | ring->rx_mini_max_pending = mgp->ss.rx_small.mask + 1; |
1374 | ring->rx_max_pending = mgp->rx_big.mask + 1; | 1450 | ring->rx_max_pending = mgp->ss.rx_big.mask + 1; |
1375 | ring->rx_jumbo_max_pending = 0; | 1451 | ring->rx_jumbo_max_pending = 0; |
1376 | ring->tx_max_pending = mgp->rx_small.mask + 1; | 1452 | ring->tx_max_pending = mgp->ss.rx_small.mask + 1; |
1377 | ring->rx_mini_pending = ring->rx_mini_max_pending; | 1453 | ring->rx_mini_pending = ring->rx_mini_max_pending; |
1378 | ring->rx_pending = ring->rx_max_pending; | 1454 | ring->rx_pending = ring->rx_max_pending; |
1379 | ring->rx_jumbo_pending = ring->rx_jumbo_max_pending; | 1455 | ring->rx_jumbo_pending = ring->rx_jumbo_max_pending; |
@@ -1383,6 +1459,7 @@ myri10ge_get_ringparam(struct net_device *netdev, | |||
1383 | static u32 myri10ge_get_rx_csum(struct net_device *netdev) | 1459 | static u32 myri10ge_get_rx_csum(struct net_device *netdev) |
1384 | { | 1460 | { |
1385 | struct myri10ge_priv *mgp = netdev_priv(netdev); | 1461 | struct myri10ge_priv *mgp = netdev_priv(netdev); |
1462 | |||
1386 | if (mgp->csum_flag) | 1463 | if (mgp->csum_flag) |
1387 | return 1; | 1464 | return 1; |
1388 | else | 1465 | else |
@@ -1392,6 +1469,7 @@ static u32 myri10ge_get_rx_csum(struct net_device *netdev) | |||
1392 | static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled) | 1469 | static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled) |
1393 | { | 1470 | { |
1394 | struct myri10ge_priv *mgp = netdev_priv(netdev); | 1471 | struct myri10ge_priv *mgp = netdev_priv(netdev); |
1472 | |||
1395 | if (csum_enabled) | 1473 | if (csum_enabled) |
1396 | mgp->csum_flag = MXGEFW_FLAGS_CKSUM; | 1474 | mgp->csum_flag = MXGEFW_FLAGS_CKSUM; |
1397 | else | 1475 | else |
@@ -1411,7 +1489,7 @@ static int myri10ge_set_tso(struct net_device *netdev, u32 tso_enabled) | |||
1411 | return 0; | 1489 | return 0; |
1412 | } | 1490 | } |
1413 | 1491 | ||
1414 | static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = { | 1492 | static const char myri10ge_gstrings_main_stats[][ETH_GSTRING_LEN] = { |
1415 | "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", | 1493 | "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", |
1416 | "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions", | 1494 | "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions", |
1417 | "rx_length_errors", "rx_over_errors", "rx_crc_errors", | 1495 | "rx_length_errors", "rx_over_errors", "rx_crc_errors", |
@@ -1421,28 +1499,39 @@ static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = { | |||
1421 | /* device-specific stats */ | 1499 | /* device-specific stats */ |
1422 | "tx_boundary", "WC", "irq", "MSI", | 1500 | "tx_boundary", "WC", "irq", "MSI", |
1423 | "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs", | 1501 | "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs", |
1424 | "serial_number", "tx_pkt_start", "tx_pkt_done", | 1502 | "serial_number", "watchdog_resets", |
1425 | "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt", | ||
1426 | "wake_queue", "stop_queue", "watchdog_resets", "tx_linearized", | ||
1427 | "link_changes", "link_up", "dropped_link_overflow", | 1503 | "link_changes", "link_up", "dropped_link_overflow", |
1428 | "dropped_link_error_or_filtered", | 1504 | "dropped_link_error_or_filtered", |
1429 | "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32", | 1505 | "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32", |
1430 | "dropped_unicast_filtered", "dropped_multicast_filtered", | 1506 | "dropped_unicast_filtered", "dropped_multicast_filtered", |
1431 | "dropped_runt", "dropped_overrun", "dropped_no_small_buffer", | 1507 | "dropped_runt", "dropped_overrun", "dropped_no_small_buffer", |
1432 | "dropped_no_big_buffer", "LRO aggregated", "LRO flushed", | 1508 | "dropped_no_big_buffer" |
1509 | }; | ||
1510 | |||
1511 | static const char myri10ge_gstrings_slice_stats[][ETH_GSTRING_LEN] = { | ||
1512 | "----------- slice ---------", | ||
1513 | "tx_pkt_start", "tx_pkt_done", "tx_req", "tx_done", | ||
1514 | "rx_small_cnt", "rx_big_cnt", | ||
1515 | "wake_queue", "stop_queue", "tx_linearized", "LRO aggregated", | ||
1516 | "LRO flushed", | ||
1433 | "LRO avg aggr", "LRO no_desc" | 1517 | "LRO avg aggr", "LRO no_desc" |
1434 | }; | 1518 | }; |
1435 | 1519 | ||
1436 | #define MYRI10GE_NET_STATS_LEN 21 | 1520 | #define MYRI10GE_NET_STATS_LEN 21 |
1437 | #define MYRI10GE_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_stats) | 1521 | #define MYRI10GE_MAIN_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_main_stats) |
1522 | #define MYRI10GE_SLICE_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_slice_stats) | ||
1438 | 1523 | ||
1439 | static void | 1524 | static void |
1440 | myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data) | 1525 | myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data) |
1441 | { | 1526 | { |
1442 | switch (stringset) { | 1527 | switch (stringset) { |
1443 | case ETH_SS_STATS: | 1528 | case ETH_SS_STATS: |
1444 | memcpy(data, *myri10ge_gstrings_stats, | 1529 | memcpy(data, *myri10ge_gstrings_main_stats, |
1445 | sizeof(myri10ge_gstrings_stats)); | 1530 | sizeof(myri10ge_gstrings_main_stats)); |
1531 | data += sizeof(myri10ge_gstrings_main_stats); | ||
1532 | memcpy(data, *myri10ge_gstrings_slice_stats, | ||
1533 | sizeof(myri10ge_gstrings_slice_stats)); | ||
1534 | data += sizeof(myri10ge_gstrings_slice_stats); | ||
1446 | break; | 1535 | break; |
1447 | } | 1536 | } |
1448 | } | 1537 | } |
@@ -1451,7 +1540,7 @@ static int myri10ge_get_sset_count(struct net_device *netdev, int sset) | |||
1451 | { | 1540 | { |
1452 | switch (sset) { | 1541 | switch (sset) { |
1453 | case ETH_SS_STATS: | 1542 | case ETH_SS_STATS: |
1454 | return MYRI10GE_STATS_LEN; | 1543 | return MYRI10GE_MAIN_STATS_LEN + MYRI10GE_SLICE_STATS_LEN; |
1455 | default: | 1544 | default: |
1456 | return -EOPNOTSUPP; | 1545 | return -EOPNOTSUPP; |
1457 | } | 1546 | } |
@@ -1462,12 +1551,13 @@ myri10ge_get_ethtool_stats(struct net_device *netdev, | |||
1462 | struct ethtool_stats *stats, u64 * data) | 1551 | struct ethtool_stats *stats, u64 * data) |
1463 | { | 1552 | { |
1464 | struct myri10ge_priv *mgp = netdev_priv(netdev); | 1553 | struct myri10ge_priv *mgp = netdev_priv(netdev); |
1554 | struct myri10ge_slice_state *ss; | ||
1465 | int i; | 1555 | int i; |
1466 | 1556 | ||
1467 | for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++) | 1557 | for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++) |
1468 | data[i] = ((unsigned long *)&mgp->stats)[i]; | 1558 | data[i] = ((unsigned long *)&mgp->stats)[i]; |
1469 | 1559 | ||
1470 | data[i++] = (unsigned int)mgp->tx.boundary; | 1560 | data[i++] = (unsigned int)mgp->tx_boundary; |
1471 | data[i++] = (unsigned int)mgp->wc_enabled; | 1561 | data[i++] = (unsigned int)mgp->wc_enabled; |
1472 | data[i++] = (unsigned int)mgp->pdev->irq; | 1562 | data[i++] = (unsigned int)mgp->pdev->irq; |
1473 | data[i++] = (unsigned int)mgp->msi_enabled; | 1563 | data[i++] = (unsigned int)mgp->msi_enabled; |
@@ -1475,40 +1565,44 @@ myri10ge_get_ethtool_stats(struct net_device *netdev, | |||
1475 | data[i++] = (unsigned int)mgp->write_dma; | 1565 | data[i++] = (unsigned int)mgp->write_dma; |
1476 | data[i++] = (unsigned int)mgp->read_write_dma; | 1566 | data[i++] = (unsigned int)mgp->read_write_dma; |
1477 | data[i++] = (unsigned int)mgp->serial_number; | 1567 | data[i++] = (unsigned int)mgp->serial_number; |
1478 | data[i++] = (unsigned int)mgp->tx.pkt_start; | ||
1479 | data[i++] = (unsigned int)mgp->tx.pkt_done; | ||
1480 | data[i++] = (unsigned int)mgp->tx.req; | ||
1481 | data[i++] = (unsigned int)mgp->tx.done; | ||
1482 | data[i++] = (unsigned int)mgp->rx_small.cnt; | ||
1483 | data[i++] = (unsigned int)mgp->rx_big.cnt; | ||
1484 | data[i++] = (unsigned int)mgp->wake_queue; | ||
1485 | data[i++] = (unsigned int)mgp->stop_queue; | ||
1486 | data[i++] = (unsigned int)mgp->watchdog_resets; | 1568 | data[i++] = (unsigned int)mgp->watchdog_resets; |
1487 | data[i++] = (unsigned int)mgp->tx_linearized; | ||
1488 | data[i++] = (unsigned int)mgp->link_changes; | 1569 | data[i++] = (unsigned int)mgp->link_changes; |
1489 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up); | 1570 | |
1490 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow); | 1571 | /* firmware stats are useful only in the first slice */ |
1491 | data[i++] = | 1572 | ss = &mgp->ss; |
1492 | (unsigned int)ntohl(mgp->fw_stats->dropped_link_error_or_filtered); | 1573 | data[i++] = (unsigned int)ntohl(ss->fw_stats->link_up); |
1493 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_pause); | 1574 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_link_overflow); |
1494 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_bad_phy); | ||
1495 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_bad_crc32); | ||
1496 | data[i++] = | 1575 | data[i++] = |
1497 | (unsigned int)ntohl(mgp->fw_stats->dropped_unicast_filtered); | 1576 | (unsigned int)ntohl(ss->fw_stats->dropped_link_error_or_filtered); |
1577 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_pause); | ||
1578 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_phy); | ||
1579 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_crc32); | ||
1580 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_unicast_filtered); | ||
1498 | data[i++] = | 1581 | data[i++] = |
1499 | (unsigned int)ntohl(mgp->fw_stats->dropped_multicast_filtered); | 1582 | (unsigned int)ntohl(ss->fw_stats->dropped_multicast_filtered); |
1500 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_runt); | 1583 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_runt); |
1501 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_overrun); | 1584 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_overrun); |
1502 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_small_buffer); | 1585 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_small_buffer); |
1503 | data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_big_buffer); | 1586 | data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_big_buffer); |
1504 | data[i++] = mgp->rx_done.lro_mgr.stats.aggregated; | 1587 | |
1505 | data[i++] = mgp->rx_done.lro_mgr.stats.flushed; | 1588 | data[i++] = 0; |
1506 | if (mgp->rx_done.lro_mgr.stats.flushed) | 1589 | data[i++] = (unsigned int)ss->tx.pkt_start; |
1507 | data[i++] = mgp->rx_done.lro_mgr.stats.aggregated / | 1590 | data[i++] = (unsigned int)ss->tx.pkt_done; |
1508 | mgp->rx_done.lro_mgr.stats.flushed; | 1591 | data[i++] = (unsigned int)ss->tx.req; |
1592 | data[i++] = (unsigned int)ss->tx.done; | ||
1593 | data[i++] = (unsigned int)ss->rx_small.cnt; | ||
1594 | data[i++] = (unsigned int)ss->rx_big.cnt; | ||
1595 | data[i++] = (unsigned int)ss->tx.wake_queue; | ||
1596 | data[i++] = (unsigned int)ss->tx.stop_queue; | ||
1597 | data[i++] = (unsigned int)ss->tx.linearized; | ||
1598 | data[i++] = ss->rx_done.lro_mgr.stats.aggregated; | ||
1599 | data[i++] = ss->rx_done.lro_mgr.stats.flushed; | ||
1600 | if (ss->rx_done.lro_mgr.stats.flushed) | ||
1601 | data[i++] = ss->rx_done.lro_mgr.stats.aggregated / | ||
1602 | ss->rx_done.lro_mgr.stats.flushed; | ||
1509 | else | 1603 | else |
1510 | data[i++] = 0; | 1604 | data[i++] = 0; |
1511 | data[i++] = mgp->rx_done.lro_mgr.stats.no_desc; | 1605 | data[i++] = ss->rx_done.lro_mgr.stats.no_desc; |
1512 | } | 1606 | } |
1513 | 1607 | ||
1514 | static void myri10ge_set_msglevel(struct net_device *netdev, u32 value) | 1608 | static void myri10ge_set_msglevel(struct net_device *netdev, u32 value) |
@@ -1544,19 +1638,17 @@ static const struct ethtool_ops myri10ge_ethtool_ops = { | |||
1544 | .get_msglevel = myri10ge_get_msglevel | 1638 | .get_msglevel = myri10ge_get_msglevel |
1545 | }; | 1639 | }; |
1546 | 1640 | ||
1547 | static int myri10ge_allocate_rings(struct net_device *dev) | 1641 | static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss) |
1548 | { | 1642 | { |
1549 | struct myri10ge_priv *mgp; | 1643 | struct myri10ge_priv *mgp = ss->mgp; |
1550 | struct myri10ge_cmd cmd; | 1644 | struct myri10ge_cmd cmd; |
1645 | struct net_device *dev = mgp->dev; | ||
1551 | int tx_ring_size, rx_ring_size; | 1646 | int tx_ring_size, rx_ring_size; |
1552 | int tx_ring_entries, rx_ring_entries; | 1647 | int tx_ring_entries, rx_ring_entries; |
1553 | int i, status; | 1648 | int i, status; |
1554 | size_t bytes; | 1649 | size_t bytes; |
1555 | 1650 | ||
1556 | mgp = netdev_priv(dev); | ||
1557 | |||
1558 | /* get ring sizes */ | 1651 | /* get ring sizes */ |
1559 | |||
1560 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0); | 1652 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0); |
1561 | tx_ring_size = cmd.data0; | 1653 | tx_ring_size = cmd.data0; |
1562 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); | 1654 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); |
@@ -1566,144 +1658,142 @@ static int myri10ge_allocate_rings(struct net_device *dev) | |||
1566 | 1658 | ||
1567 | tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send); | 1659 | tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send); |
1568 | rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr); | 1660 | rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr); |
1569 | mgp->tx.mask = tx_ring_entries - 1; | 1661 | ss->tx.mask = tx_ring_entries - 1; |
1570 | mgp->rx_small.mask = mgp->rx_big.mask = rx_ring_entries - 1; | 1662 | ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1; |
1571 | 1663 | ||
1572 | status = -ENOMEM; | 1664 | status = -ENOMEM; |
1573 | 1665 | ||
1574 | /* allocate the host shadow rings */ | 1666 | /* allocate the host shadow rings */ |
1575 | 1667 | ||
1576 | bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4) | 1668 | bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4) |
1577 | * sizeof(*mgp->tx.req_list); | 1669 | * sizeof(*ss->tx.req_list); |
1578 | mgp->tx.req_bytes = kzalloc(bytes, GFP_KERNEL); | 1670 | ss->tx.req_bytes = kzalloc(bytes, GFP_KERNEL); |
1579 | if (mgp->tx.req_bytes == NULL) | 1671 | if (ss->tx.req_bytes == NULL) |
1580 | goto abort_with_nothing; | 1672 | goto abort_with_nothing; |
1581 | 1673 | ||
1582 | /* ensure req_list entries are aligned to 8 bytes */ | 1674 | /* ensure req_list entries are aligned to 8 bytes */ |
1583 | mgp->tx.req_list = (struct mcp_kreq_ether_send *) | 1675 | ss->tx.req_list = (struct mcp_kreq_ether_send *) |
1584 | ALIGN((unsigned long)mgp->tx.req_bytes, 8); | 1676 | ALIGN((unsigned long)ss->tx.req_bytes, 8); |
1585 | 1677 | ||
1586 | bytes = rx_ring_entries * sizeof(*mgp->rx_small.shadow); | 1678 | bytes = rx_ring_entries * sizeof(*ss->rx_small.shadow); |
1587 | mgp->rx_small.shadow = kzalloc(bytes, GFP_KERNEL); | 1679 | ss->rx_small.shadow = kzalloc(bytes, GFP_KERNEL); |
1588 | if (mgp->rx_small.shadow == NULL) | 1680 | if (ss->rx_small.shadow == NULL) |
1589 | goto abort_with_tx_req_bytes; | 1681 | goto abort_with_tx_req_bytes; |
1590 | 1682 | ||
1591 | bytes = rx_ring_entries * sizeof(*mgp->rx_big.shadow); | 1683 | bytes = rx_ring_entries * sizeof(*ss->rx_big.shadow); |
1592 | mgp->rx_big.shadow = kzalloc(bytes, GFP_KERNEL); | 1684 | ss->rx_big.shadow = kzalloc(bytes, GFP_KERNEL); |
1593 | if (mgp->rx_big.shadow == NULL) | 1685 | if (ss->rx_big.shadow == NULL) |
1594 | goto abort_with_rx_small_shadow; | 1686 | goto abort_with_rx_small_shadow; |
1595 | 1687 | ||
1596 | /* allocate the host info rings */ | 1688 | /* allocate the host info rings */ |
1597 | 1689 | ||
1598 | bytes = tx_ring_entries * sizeof(*mgp->tx.info); | 1690 | bytes = tx_ring_entries * sizeof(*ss->tx.info); |
1599 | mgp->tx.info = kzalloc(bytes, GFP_KERNEL); | 1691 | ss->tx.info = kzalloc(bytes, GFP_KERNEL); |
1600 | if (mgp->tx.info == NULL) | 1692 | if (ss->tx.info == NULL) |
1601 | goto abort_with_rx_big_shadow; | 1693 | goto abort_with_rx_big_shadow; |
1602 | 1694 | ||
1603 | bytes = rx_ring_entries * sizeof(*mgp->rx_small.info); | 1695 | bytes = rx_ring_entries * sizeof(*ss->rx_small.info); |
1604 | mgp->rx_small.info = kzalloc(bytes, GFP_KERNEL); | 1696 | ss->rx_small.info = kzalloc(bytes, GFP_KERNEL); |
1605 | if (mgp->rx_small.info == NULL) | 1697 | if (ss->rx_small.info == NULL) |
1606 | goto abort_with_tx_info; | 1698 | goto abort_with_tx_info; |
1607 | 1699 | ||
1608 | bytes = rx_ring_entries * sizeof(*mgp->rx_big.info); | 1700 | bytes = rx_ring_entries * sizeof(*ss->rx_big.info); |
1609 | mgp->rx_big.info = kzalloc(bytes, GFP_KERNEL); | 1701 | ss->rx_big.info = kzalloc(bytes, GFP_KERNEL); |
1610 | if (mgp->rx_big.info == NULL) | 1702 | if (ss->rx_big.info == NULL) |
1611 | goto abort_with_rx_small_info; | 1703 | goto abort_with_rx_small_info; |
1612 | 1704 | ||
1613 | /* Fill the receive rings */ | 1705 | /* Fill the receive rings */ |
1614 | mgp->rx_big.cnt = 0; | 1706 | ss->rx_big.cnt = 0; |
1615 | mgp->rx_small.cnt = 0; | 1707 | ss->rx_small.cnt = 0; |
1616 | mgp->rx_big.fill_cnt = 0; | 1708 | ss->rx_big.fill_cnt = 0; |
1617 | mgp->rx_small.fill_cnt = 0; | 1709 | ss->rx_small.fill_cnt = 0; |
1618 | mgp->rx_small.page_offset = MYRI10GE_ALLOC_SIZE; | 1710 | ss->rx_small.page_offset = MYRI10GE_ALLOC_SIZE; |
1619 | mgp->rx_big.page_offset = MYRI10GE_ALLOC_SIZE; | 1711 | ss->rx_big.page_offset = MYRI10GE_ALLOC_SIZE; |
1620 | mgp->rx_small.watchdog_needed = 0; | 1712 | ss->rx_small.watchdog_needed = 0; |
1621 | mgp->rx_big.watchdog_needed = 0; | 1713 | ss->rx_big.watchdog_needed = 0; |
1622 | myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, | 1714 | myri10ge_alloc_rx_pages(mgp, &ss->rx_small, |
1623 | mgp->small_bytes + MXGEFW_PAD, 0); | 1715 | mgp->small_bytes + MXGEFW_PAD, 0); |
1624 | 1716 | ||
1625 | if (mgp->rx_small.fill_cnt < mgp->rx_small.mask + 1) { | 1717 | if (ss->rx_small.fill_cnt < ss->rx_small.mask + 1) { |
1626 | printk(KERN_ERR "myri10ge: %s: alloced only %d small bufs\n", | 1718 | printk(KERN_ERR "myri10ge: %s: alloced only %d small bufs\n", |
1627 | dev->name, mgp->rx_small.fill_cnt); | 1719 | dev->name, ss->rx_small.fill_cnt); |
1628 | goto abort_with_rx_small_ring; | 1720 | goto abort_with_rx_small_ring; |
1629 | } | 1721 | } |
1630 | 1722 | ||
1631 | myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 0); | 1723 | myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); |
1632 | if (mgp->rx_big.fill_cnt < mgp->rx_big.mask + 1) { | 1724 | if (ss->rx_big.fill_cnt < ss->rx_big.mask + 1) { |
1633 | printk(KERN_ERR "myri10ge: %s: alloced only %d big bufs\n", | 1725 | printk(KERN_ERR "myri10ge: %s: alloced only %d big bufs\n", |
1634 | dev->name, mgp->rx_big.fill_cnt); | 1726 | dev->name, ss->rx_big.fill_cnt); |
1635 | goto abort_with_rx_big_ring; | 1727 | goto abort_with_rx_big_ring; |
1636 | } | 1728 | } |
1637 | 1729 | ||
1638 | return 0; | 1730 | return 0; |
1639 | 1731 | ||
1640 | abort_with_rx_big_ring: | 1732 | abort_with_rx_big_ring: |
1641 | for (i = mgp->rx_big.cnt; i < mgp->rx_big.fill_cnt; i++) { | 1733 | for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) { |
1642 | int idx = i & mgp->rx_big.mask; | 1734 | int idx = i & ss->rx_big.mask; |
1643 | myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_big.info[idx], | 1735 | myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx], |
1644 | mgp->big_bytes); | 1736 | mgp->big_bytes); |
1645 | put_page(mgp->rx_big.info[idx].page); | 1737 | put_page(ss->rx_big.info[idx].page); |
1646 | } | 1738 | } |
1647 | 1739 | ||
1648 | abort_with_rx_small_ring: | 1740 | abort_with_rx_small_ring: |
1649 | for (i = mgp->rx_small.cnt; i < mgp->rx_small.fill_cnt; i++) { | 1741 | for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) { |
1650 | int idx = i & mgp->rx_small.mask; | 1742 | int idx = i & ss->rx_small.mask; |
1651 | myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_small.info[idx], | 1743 | myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx], |
1652 | mgp->small_bytes + MXGEFW_PAD); | 1744 | mgp->small_bytes + MXGEFW_PAD); |
1653 | put_page(mgp->rx_small.info[idx].page); | 1745 | put_page(ss->rx_small.info[idx].page); |
1654 | } | 1746 | } |
1655 | 1747 | ||
1656 | kfree(mgp->rx_big.info); | 1748 | kfree(ss->rx_big.info); |
1657 | 1749 | ||
1658 | abort_with_rx_small_info: | 1750 | abort_with_rx_small_info: |
1659 | kfree(mgp->rx_small.info); | 1751 | kfree(ss->rx_small.info); |
1660 | 1752 | ||
1661 | abort_with_tx_info: | 1753 | abort_with_tx_info: |
1662 | kfree(mgp->tx.info); | 1754 | kfree(ss->tx.info); |
1663 | 1755 | ||
1664 | abort_with_rx_big_shadow: | 1756 | abort_with_rx_big_shadow: |
1665 | kfree(mgp->rx_big.shadow); | 1757 | kfree(ss->rx_big.shadow); |
1666 | 1758 | ||
1667 | abort_with_rx_small_shadow: | 1759 | abort_with_rx_small_shadow: |
1668 | kfree(mgp->rx_small.shadow); | 1760 | kfree(ss->rx_small.shadow); |
1669 | 1761 | ||
1670 | abort_with_tx_req_bytes: | 1762 | abort_with_tx_req_bytes: |
1671 | kfree(mgp->tx.req_bytes); | 1763 | kfree(ss->tx.req_bytes); |
1672 | mgp->tx.req_bytes = NULL; | 1764 | ss->tx.req_bytes = NULL; |
1673 | mgp->tx.req_list = NULL; | 1765 | ss->tx.req_list = NULL; |
1674 | 1766 | ||
1675 | abort_with_nothing: | 1767 | abort_with_nothing: |
1676 | return status; | 1768 | return status; |
1677 | } | 1769 | } |
1678 | 1770 | ||
1679 | static void myri10ge_free_rings(struct net_device *dev) | 1771 | static void myri10ge_free_rings(struct myri10ge_slice_state *ss) |
1680 | { | 1772 | { |
1681 | struct myri10ge_priv *mgp; | 1773 | struct myri10ge_priv *mgp = ss->mgp; |
1682 | struct sk_buff *skb; | 1774 | struct sk_buff *skb; |
1683 | struct myri10ge_tx_buf *tx; | 1775 | struct myri10ge_tx_buf *tx; |
1684 | int i, len, idx; | 1776 | int i, len, idx; |
1685 | 1777 | ||
1686 | mgp = netdev_priv(dev); | 1778 | for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) { |
1687 | 1779 | idx = i & ss->rx_big.mask; | |
1688 | for (i = mgp->rx_big.cnt; i < mgp->rx_big.fill_cnt; i++) { | 1780 | if (i == ss->rx_big.fill_cnt - 1) |
1689 | idx = i & mgp->rx_big.mask; | 1781 | ss->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE; |
1690 | if (i == mgp->rx_big.fill_cnt - 1) | 1782 | myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx], |
1691 | mgp->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE; | ||
1692 | myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_big.info[idx], | ||
1693 | mgp->big_bytes); | 1783 | mgp->big_bytes); |
1694 | put_page(mgp->rx_big.info[idx].page); | 1784 | put_page(ss->rx_big.info[idx].page); |
1695 | } | 1785 | } |
1696 | 1786 | ||
1697 | for (i = mgp->rx_small.cnt; i < mgp->rx_small.fill_cnt; i++) { | 1787 | for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) { |
1698 | idx = i & mgp->rx_small.mask; | 1788 | idx = i & ss->rx_small.mask; |
1699 | if (i == mgp->rx_small.fill_cnt - 1) | 1789 | if (i == ss->rx_small.fill_cnt - 1) |
1700 | mgp->rx_small.info[idx].page_offset = | 1790 | ss->rx_small.info[idx].page_offset = |
1701 | MYRI10GE_ALLOC_SIZE; | 1791 | MYRI10GE_ALLOC_SIZE; |
1702 | myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_small.info[idx], | 1792 | myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx], |
1703 | mgp->small_bytes + MXGEFW_PAD); | 1793 | mgp->small_bytes + MXGEFW_PAD); |
1704 | put_page(mgp->rx_small.info[idx].page); | 1794 | put_page(ss->rx_small.info[idx].page); |
1705 | } | 1795 | } |
1706 | tx = &mgp->tx; | 1796 | tx = &ss->tx; |
1707 | while (tx->done != tx->req) { | 1797 | while (tx->done != tx->req) { |
1708 | idx = tx->done & tx->mask; | 1798 | idx = tx->done & tx->mask; |
1709 | skb = tx->info[idx].skb; | 1799 | skb = tx->info[idx].skb; |
@@ -1714,7 +1804,7 @@ static void myri10ge_free_rings(struct net_device *dev) | |||
1714 | len = pci_unmap_len(&tx->info[idx], len); | 1804 | len = pci_unmap_len(&tx->info[idx], len); |
1715 | pci_unmap_len_set(&tx->info[idx], len, 0); | 1805 | pci_unmap_len_set(&tx->info[idx], len, 0); |
1716 | if (skb) { | 1806 | if (skb) { |
1717 | mgp->stats.tx_dropped++; | 1807 | ss->stats.tx_dropped++; |
1718 | dev_kfree_skb_any(skb); | 1808 | dev_kfree_skb_any(skb); |
1719 | if (len) | 1809 | if (len) |
1720 | pci_unmap_single(mgp->pdev, | 1810 | pci_unmap_single(mgp->pdev, |
@@ -1729,19 +1819,19 @@ static void myri10ge_free_rings(struct net_device *dev) | |||
1729 | PCI_DMA_TODEVICE); | 1819 | PCI_DMA_TODEVICE); |
1730 | } | 1820 | } |
1731 | } | 1821 | } |
1732 | kfree(mgp->rx_big.info); | 1822 | kfree(ss->rx_big.info); |
1733 | 1823 | ||
1734 | kfree(mgp->rx_small.info); | 1824 | kfree(ss->rx_small.info); |
1735 | 1825 | ||
1736 | kfree(mgp->tx.info); | 1826 | kfree(ss->tx.info); |
1737 | 1827 | ||
1738 | kfree(mgp->rx_big.shadow); | 1828 | kfree(ss->rx_big.shadow); |
1739 | 1829 | ||
1740 | kfree(mgp->rx_small.shadow); | 1830 | kfree(ss->rx_small.shadow); |
1741 | 1831 | ||
1742 | kfree(mgp->tx.req_bytes); | 1832 | kfree(ss->tx.req_bytes); |
1743 | mgp->tx.req_bytes = NULL; | 1833 | ss->tx.req_bytes = NULL; |
1744 | mgp->tx.req_list = NULL; | 1834 | ss->tx.req_list = NULL; |
1745 | } | 1835 | } |
1746 | 1836 | ||
1747 | static int myri10ge_request_irq(struct myri10ge_priv *mgp) | 1837 | static int myri10ge_request_irq(struct myri10ge_priv *mgp) |
@@ -1840,13 +1930,11 @@ myri10ge_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr, | |||
1840 | 1930 | ||
1841 | static int myri10ge_open(struct net_device *dev) | 1931 | static int myri10ge_open(struct net_device *dev) |
1842 | { | 1932 | { |
1843 | struct myri10ge_priv *mgp; | 1933 | struct myri10ge_priv *mgp = netdev_priv(dev); |
1844 | struct myri10ge_cmd cmd; | 1934 | struct myri10ge_cmd cmd; |
1845 | struct net_lro_mgr *lro_mgr; | 1935 | struct net_lro_mgr *lro_mgr; |
1846 | int status, big_pow2; | 1936 | int status, big_pow2; |
1847 | 1937 | ||
1848 | mgp = netdev_priv(dev); | ||
1849 | |||
1850 | if (mgp->running != MYRI10GE_ETH_STOPPED) | 1938 | if (mgp->running != MYRI10GE_ETH_STOPPED) |
1851 | return -EBUSY; | 1939 | return -EBUSY; |
1852 | 1940 | ||
@@ -1883,16 +1971,16 @@ static int myri10ge_open(struct net_device *dev) | |||
1883 | /* get the lanai pointers to the send and receive rings */ | 1971 | /* get the lanai pointers to the send and receive rings */ |
1884 | 1972 | ||
1885 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0); | 1973 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0); |
1886 | mgp->tx.lanai = | 1974 | mgp->ss.tx.lanai = |
1887 | (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0); | 1975 | (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0); |
1888 | 1976 | ||
1889 | status |= | 1977 | status |= |
1890 | myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0); | 1978 | myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0); |
1891 | mgp->rx_small.lanai = | 1979 | mgp->ss.rx_small.lanai = |
1892 | (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); | 1980 | (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); |
1893 | 1981 | ||
1894 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0); | 1982 | status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0); |
1895 | mgp->rx_big.lanai = | 1983 | mgp->ss.rx_big.lanai = |
1896 | (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); | 1984 | (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); |
1897 | 1985 | ||
1898 | if (status != 0) { | 1986 | if (status != 0) { |
@@ -1904,15 +1992,15 @@ static int myri10ge_open(struct net_device *dev) | |||
1904 | } | 1992 | } |
1905 | 1993 | ||
1906 | if (myri10ge_wcfifo && mgp->wc_enabled) { | 1994 | if (myri10ge_wcfifo && mgp->wc_enabled) { |
1907 | mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4; | 1995 | mgp->ss.tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4; |
1908 | mgp->rx_small.wc_fifo = | 1996 | mgp->ss.rx_small.wc_fifo = |
1909 | (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL; | 1997 | (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL; |
1910 | mgp->rx_big.wc_fifo = | 1998 | mgp->ss.rx_big.wc_fifo = |
1911 | (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG; | 1999 | (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG; |
1912 | } else { | 2000 | } else { |
1913 | mgp->tx.wc_fifo = NULL; | 2001 | mgp->ss.tx.wc_fifo = NULL; |
1914 | mgp->rx_small.wc_fifo = NULL; | 2002 | mgp->ss.rx_small.wc_fifo = NULL; |
1915 | mgp->rx_big.wc_fifo = NULL; | 2003 | mgp->ss.rx_big.wc_fifo = NULL; |
1916 | } | 2004 | } |
1917 | 2005 | ||
1918 | /* Firmware needs the big buff size as a power of 2. Lie and | 2006 | /* Firmware needs the big buff size as a power of 2. Lie and |
@@ -1929,7 +2017,7 @@ static int myri10ge_open(struct net_device *dev) | |||
1929 | mgp->big_bytes = big_pow2; | 2017 | mgp->big_bytes = big_pow2; |
1930 | } | 2018 | } |
1931 | 2019 | ||
1932 | status = myri10ge_allocate_rings(dev); | 2020 | status = myri10ge_allocate_rings(&mgp->ss); |
1933 | if (status != 0) | 2021 | if (status != 0) |
1934 | goto abort_with_irq; | 2022 | goto abort_with_irq; |
1935 | 2023 | ||
@@ -1948,12 +2036,12 @@ static int myri10ge_open(struct net_device *dev) | |||
1948 | goto abort_with_rings; | 2036 | goto abort_with_rings; |
1949 | } | 2037 | } |
1950 | 2038 | ||
1951 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->fw_stats_bus); | 2039 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->ss.fw_stats_bus); |
1952 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->fw_stats_bus); | 2040 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->ss.fw_stats_bus); |
1953 | cmd.data2 = sizeof(struct mcp_irq_data); | 2041 | cmd.data2 = sizeof(struct mcp_irq_data); |
1954 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0); | 2042 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0); |
1955 | if (status == -ENOSYS) { | 2043 | if (status == -ENOSYS) { |
1956 | dma_addr_t bus = mgp->fw_stats_bus; | 2044 | dma_addr_t bus = mgp->ss.fw_stats_bus; |
1957 | bus += offsetof(struct mcp_irq_data, send_done_count); | 2045 | bus += offsetof(struct mcp_irq_data, send_done_count); |
1958 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus); | 2046 | cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus); |
1959 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus); | 2047 | cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus); |
@@ -1974,20 +2062,20 @@ static int myri10ge_open(struct net_device *dev) | |||
1974 | mgp->link_state = ~0U; | 2062 | mgp->link_state = ~0U; |
1975 | mgp->rdma_tags_available = 15; | 2063 | mgp->rdma_tags_available = 15; |
1976 | 2064 | ||
1977 | lro_mgr = &mgp->rx_done.lro_mgr; | 2065 | lro_mgr = &mgp->ss.rx_done.lro_mgr; |
1978 | lro_mgr->dev = dev; | 2066 | lro_mgr->dev = dev; |
1979 | lro_mgr->features = LRO_F_NAPI; | 2067 | lro_mgr->features = LRO_F_NAPI; |
1980 | lro_mgr->ip_summed = CHECKSUM_COMPLETE; | 2068 | lro_mgr->ip_summed = CHECKSUM_COMPLETE; |
1981 | lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY; | 2069 | lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY; |
1982 | lro_mgr->max_desc = MYRI10GE_MAX_LRO_DESCRIPTORS; | 2070 | lro_mgr->max_desc = MYRI10GE_MAX_LRO_DESCRIPTORS; |
1983 | lro_mgr->lro_arr = mgp->rx_done.lro_desc; | 2071 | lro_mgr->lro_arr = mgp->ss.rx_done.lro_desc; |
1984 | lro_mgr->get_frag_header = myri10ge_get_frag_header; | 2072 | lro_mgr->get_frag_header = myri10ge_get_frag_header; |
1985 | lro_mgr->max_aggr = myri10ge_lro_max_pkts; | 2073 | lro_mgr->max_aggr = myri10ge_lro_max_pkts; |
1986 | lro_mgr->frag_align_pad = 2; | 2074 | lro_mgr->frag_align_pad = 2; |
1987 | if (lro_mgr->max_aggr > MAX_SKB_FRAGS) | 2075 | if (lro_mgr->max_aggr > MAX_SKB_FRAGS) |
1988 | lro_mgr->max_aggr = MAX_SKB_FRAGS; | 2076 | lro_mgr->max_aggr = MAX_SKB_FRAGS; |
1989 | 2077 | ||
1990 | napi_enable(&mgp->napi); /* must happen prior to any irq */ | 2078 | napi_enable(&mgp->ss.napi); /* must happen prior to any irq */ |
1991 | 2079 | ||
1992 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0); | 2080 | status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0); |
1993 | if (status) { | 2081 | if (status) { |
@@ -1996,8 +2084,8 @@ static int myri10ge_open(struct net_device *dev) | |||
1996 | goto abort_with_rings; | 2084 | goto abort_with_rings; |
1997 | } | 2085 | } |
1998 | 2086 | ||
1999 | mgp->wake_queue = 0; | 2087 | mgp->ss.tx.wake_queue = 0; |
2000 | mgp->stop_queue = 0; | 2088 | mgp->ss.tx.stop_queue = 0; |
2001 | mgp->running = MYRI10GE_ETH_RUNNING; | 2089 | mgp->running = MYRI10GE_ETH_RUNNING; |
2002 | mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ; | 2090 | mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ; |
2003 | add_timer(&mgp->watchdog_timer); | 2091 | add_timer(&mgp->watchdog_timer); |
@@ -2005,7 +2093,7 @@ static int myri10ge_open(struct net_device *dev) | |||
2005 | return 0; | 2093 | return 0; |
2006 | 2094 | ||
2007 | abort_with_rings: | 2095 | abort_with_rings: |
2008 | myri10ge_free_rings(dev); | 2096 | myri10ge_free_rings(&mgp->ss); |
2009 | 2097 | ||
2010 | abort_with_irq: | 2098 | abort_with_irq: |
2011 | myri10ge_free_irq(mgp); | 2099 | myri10ge_free_irq(mgp); |
@@ -2017,21 +2105,19 @@ abort_with_nothing: | |||
2017 | 2105 | ||
2018 | static int myri10ge_close(struct net_device *dev) | 2106 | static int myri10ge_close(struct net_device *dev) |
2019 | { | 2107 | { |
2020 | struct myri10ge_priv *mgp; | 2108 | struct myri10ge_priv *mgp = netdev_priv(dev); |
2021 | struct myri10ge_cmd cmd; | 2109 | struct myri10ge_cmd cmd; |
2022 | int status, old_down_cnt; | 2110 | int status, old_down_cnt; |
2023 | 2111 | ||
2024 | mgp = netdev_priv(dev); | ||
2025 | |||
2026 | if (mgp->running != MYRI10GE_ETH_RUNNING) | 2112 | if (mgp->running != MYRI10GE_ETH_RUNNING) |
2027 | return 0; | 2113 | return 0; |
2028 | 2114 | ||
2029 | if (mgp->tx.req_bytes == NULL) | 2115 | if (mgp->ss.tx.req_bytes == NULL) |
2030 | return 0; | 2116 | return 0; |
2031 | 2117 | ||
2032 | del_timer_sync(&mgp->watchdog_timer); | 2118 | del_timer_sync(&mgp->watchdog_timer); |
2033 | mgp->running = MYRI10GE_ETH_STOPPING; | 2119 | mgp->running = MYRI10GE_ETH_STOPPING; |
2034 | napi_disable(&mgp->napi); | 2120 | napi_disable(&mgp->ss.napi); |
2035 | netif_carrier_off(dev); | 2121 | netif_carrier_off(dev); |
2036 | netif_stop_queue(dev); | 2122 | netif_stop_queue(dev); |
2037 | old_down_cnt = mgp->down_cnt; | 2123 | old_down_cnt = mgp->down_cnt; |
@@ -2047,7 +2133,7 @@ static int myri10ge_close(struct net_device *dev) | |||
2047 | 2133 | ||
2048 | netif_tx_disable(dev); | 2134 | netif_tx_disable(dev); |
2049 | myri10ge_free_irq(mgp); | 2135 | myri10ge_free_irq(mgp); |
2050 | myri10ge_free_rings(dev); | 2136 | myri10ge_free_rings(&mgp->ss); |
2051 | 2137 | ||
2052 | mgp->running = MYRI10GE_ETH_STOPPED; | 2138 | mgp->running = MYRI10GE_ETH_STOPPED; |
2053 | return 0; | 2139 | return 0; |
@@ -2143,7 +2229,7 @@ myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx, | |||
2143 | 2229 | ||
2144 | /* | 2230 | /* |
2145 | * Transmit a packet. We need to split the packet so that a single | 2231 | * Transmit a packet. We need to split the packet so that a single |
2146 | * segment does not cross myri10ge->tx.boundary, so this makes segment | 2232 | * segment does not cross myri10ge->tx_boundary, so this makes segment |
2147 | * counting tricky. So rather than try to count segments up front, we | 2233 | * counting tricky. So rather than try to count segments up front, we |
2148 | * just give up if there are too few segments to hold a reasonably | 2234 | * just give up if there are too few segments to hold a reasonably |
2149 | * fragmented packet currently available. If we run | 2235 | * fragmented packet currently available. If we run |
@@ -2154,8 +2240,9 @@ myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx, | |||
2154 | static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev) | 2240 | static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev) |
2155 | { | 2241 | { |
2156 | struct myri10ge_priv *mgp = netdev_priv(dev); | 2242 | struct myri10ge_priv *mgp = netdev_priv(dev); |
2243 | struct myri10ge_slice_state *ss; | ||
2157 | struct mcp_kreq_ether_send *req; | 2244 | struct mcp_kreq_ether_send *req; |
2158 | struct myri10ge_tx_buf *tx = &mgp->tx; | 2245 | struct myri10ge_tx_buf *tx; |
2159 | struct skb_frag_struct *frag; | 2246 | struct skb_frag_struct *frag; |
2160 | dma_addr_t bus; | 2247 | dma_addr_t bus; |
2161 | u32 low; | 2248 | u32 low; |
@@ -2166,6 +2253,9 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2166 | int cum_len, seglen, boundary, rdma_count; | 2253 | int cum_len, seglen, boundary, rdma_count; |
2167 | u8 flags, odd_flag; | 2254 | u8 flags, odd_flag; |
2168 | 2255 | ||
2256 | /* always transmit through slot 0 */ | ||
2257 | ss = &mgp->ss; | ||
2258 | tx = &ss->tx; | ||
2169 | again: | 2259 | again: |
2170 | req = tx->req_list; | 2260 | req = tx->req_list; |
2171 | avail = tx->mask - 1 - (tx->req - tx->done); | 2261 | avail = tx->mask - 1 - (tx->req - tx->done); |
@@ -2180,7 +2270,7 @@ again: | |||
2180 | 2270 | ||
2181 | if ((unlikely(avail < max_segments))) { | 2271 | if ((unlikely(avail < max_segments))) { |
2182 | /* we are out of transmit resources */ | 2272 | /* we are out of transmit resources */ |
2183 | mgp->stop_queue++; | 2273 | tx->stop_queue++; |
2184 | netif_stop_queue(dev); | 2274 | netif_stop_queue(dev); |
2185 | return 1; | 2275 | return 1; |
2186 | } | 2276 | } |
@@ -2242,7 +2332,7 @@ again: | |||
2242 | if (skb_padto(skb, ETH_ZLEN)) { | 2332 | if (skb_padto(skb, ETH_ZLEN)) { |
2243 | /* The packet is gone, so we must | 2333 | /* The packet is gone, so we must |
2244 | * return 0 */ | 2334 | * return 0 */ |
2245 | mgp->stats.tx_dropped += 1; | 2335 | ss->stats.tx_dropped += 1; |
2246 | return 0; | 2336 | return 0; |
2247 | } | 2337 | } |
2248 | /* adjust the len to account for the zero pad | 2338 | /* adjust the len to account for the zero pad |
@@ -2284,7 +2374,7 @@ again: | |||
2284 | 2374 | ||
2285 | while (1) { | 2375 | while (1) { |
2286 | /* Break the SKB or Fragment up into pieces which | 2376 | /* Break the SKB or Fragment up into pieces which |
2287 | * do not cross mgp->tx.boundary */ | 2377 | * do not cross mgp->tx_boundary */ |
2288 | low = MYRI10GE_LOWPART_TO_U32(bus); | 2378 | low = MYRI10GE_LOWPART_TO_U32(bus); |
2289 | high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus)); | 2379 | high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus)); |
2290 | while (len) { | 2380 | while (len) { |
@@ -2294,7 +2384,8 @@ again: | |||
2294 | if (unlikely(count == max_segments)) | 2384 | if (unlikely(count == max_segments)) |
2295 | goto abort_linearize; | 2385 | goto abort_linearize; |
2296 | 2386 | ||
2297 | boundary = (low + tx->boundary) & ~(tx->boundary - 1); | 2387 | boundary = |
2388 | (low + mgp->tx_boundary) & ~(mgp->tx_boundary - 1); | ||
2298 | seglen = boundary - low; | 2389 | seglen = boundary - low; |
2299 | if (seglen > len) | 2390 | if (seglen > len) |
2300 | seglen = len; | 2391 | seglen = len; |
@@ -2378,7 +2469,7 @@ again: | |||
2378 | myri10ge_submit_req_wc(tx, tx->req_list, count); | 2469 | myri10ge_submit_req_wc(tx, tx->req_list, count); |
2379 | tx->pkt_start++; | 2470 | tx->pkt_start++; |
2380 | if ((avail - count) < MXGEFW_MAX_SEND_DESC) { | 2471 | if ((avail - count) < MXGEFW_MAX_SEND_DESC) { |
2381 | mgp->stop_queue++; | 2472 | tx->stop_queue++; |
2382 | netif_stop_queue(dev); | 2473 | netif_stop_queue(dev); |
2383 | } | 2474 | } |
2384 | dev->trans_start = jiffies; | 2475 | dev->trans_start = jiffies; |
@@ -2420,12 +2511,12 @@ abort_linearize: | |||
2420 | if (skb_linearize(skb)) | 2511 | if (skb_linearize(skb)) |
2421 | goto drop; | 2512 | goto drop; |
2422 | 2513 | ||
2423 | mgp->tx_linearized++; | 2514 | tx->linearized++; |
2424 | goto again; | 2515 | goto again; |
2425 | 2516 | ||
2426 | drop: | 2517 | drop: |
2427 | dev_kfree_skb_any(skb); | 2518 | dev_kfree_skb_any(skb); |
2428 | mgp->stats.tx_dropped += 1; | 2519 | ss->stats.tx_dropped += 1; |
2429 | return 0; | 2520 | return 0; |
2430 | 2521 | ||
2431 | } | 2522 | } |
@@ -2433,7 +2524,7 @@ drop: | |||
2433 | static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev) | 2524 | static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev) |
2434 | { | 2525 | { |
2435 | struct sk_buff *segs, *curr; | 2526 | struct sk_buff *segs, *curr; |
2436 | struct myri10ge_priv *mgp = dev->priv; | 2527 | struct myri10ge_priv *mgp = netdev_priv(dev); |
2437 | int status; | 2528 | int status; |
2438 | 2529 | ||
2439 | segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6); | 2530 | segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6); |
@@ -2473,14 +2564,13 @@ static struct net_device_stats *myri10ge_get_stats(struct net_device *dev) | |||
2473 | 2564 | ||
2474 | static void myri10ge_set_multicast_list(struct net_device *dev) | 2565 | static void myri10ge_set_multicast_list(struct net_device *dev) |
2475 | { | 2566 | { |
2567 | struct myri10ge_priv *mgp = netdev_priv(dev); | ||
2476 | struct myri10ge_cmd cmd; | 2568 | struct myri10ge_cmd cmd; |
2477 | struct myri10ge_priv *mgp; | ||
2478 | struct dev_mc_list *mc_list; | 2569 | struct dev_mc_list *mc_list; |
2479 | __be32 data[2] = { 0, 0 }; | 2570 | __be32 data[2] = { 0, 0 }; |
2480 | int err; | 2571 | int err; |
2481 | DECLARE_MAC_BUF(mac); | 2572 | DECLARE_MAC_BUF(mac); |
2482 | 2573 | ||
2483 | mgp = netdev_priv(dev); | ||
2484 | /* can be called from atomic contexts, | 2574 | /* can be called from atomic contexts, |
2485 | * pass 1 to force atomicity in myri10ge_send_cmd() */ | 2575 | * pass 1 to force atomicity in myri10ge_send_cmd() */ |
2486 | myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1); | 2576 | myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1); |
@@ -2616,13 +2706,14 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) | |||
2616 | ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; | 2706 | ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; |
2617 | if (ext_type != PCI_EXP_TYPE_ROOT_PORT) { | 2707 | if (ext_type != PCI_EXP_TYPE_ROOT_PORT) { |
2618 | if (myri10ge_ecrc_enable > 1) { | 2708 | if (myri10ge_ecrc_enable > 1) { |
2619 | struct pci_dev *old_bridge = bridge; | 2709 | struct pci_dev *prev_bridge, *old_bridge = bridge; |
2620 | 2710 | ||
2621 | /* Walk the hierarchy up to the root port | 2711 | /* Walk the hierarchy up to the root port |
2622 | * where ECRC has to be enabled */ | 2712 | * where ECRC has to be enabled */ |
2623 | do { | 2713 | do { |
2714 | prev_bridge = bridge; | ||
2624 | bridge = bridge->bus->self; | 2715 | bridge = bridge->bus->self; |
2625 | if (!bridge) { | 2716 | if (!bridge || prev_bridge == bridge) { |
2626 | dev_err(dev, | 2717 | dev_err(dev, |
2627 | "Failed to find root port" | 2718 | "Failed to find root port" |
2628 | " to force ECRC\n"); | 2719 | " to force ECRC\n"); |
@@ -2681,9 +2772,9 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) | |||
2681 | * already been enabled, then it must use a firmware image which works | 2772 | * already been enabled, then it must use a firmware image which works |
2682 | * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it | 2773 | * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it |
2683 | * should also ensure that it never gives the device a Read-DMA which is | 2774 | * should also ensure that it never gives the device a Read-DMA which is |
2684 | * larger than 2KB by setting the tx.boundary to 2KB. If ECRC is | 2775 | * larger than 2KB by setting the tx_boundary to 2KB. If ECRC is |
2685 | * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat) | 2776 | * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat) |
2686 | * firmware image, and set tx.boundary to 4KB. | 2777 | * firmware image, and set tx_boundary to 4KB. |
2687 | */ | 2778 | */ |
2688 | 2779 | ||
2689 | static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) | 2780 | static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) |
@@ -2692,7 +2783,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) | |||
2692 | struct device *dev = &pdev->dev; | 2783 | struct device *dev = &pdev->dev; |
2693 | int status; | 2784 | int status; |
2694 | 2785 | ||
2695 | mgp->tx.boundary = 4096; | 2786 | mgp->tx_boundary = 4096; |
2696 | /* | 2787 | /* |
2697 | * Verify the max read request size was set to 4KB | 2788 | * Verify the max read request size was set to 4KB |
2698 | * before trying the test with 4KB. | 2789 | * before trying the test with 4KB. |
@@ -2704,7 +2795,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) | |||
2704 | } | 2795 | } |
2705 | if (status != 4096) { | 2796 | if (status != 4096) { |
2706 | dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status); | 2797 | dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status); |
2707 | mgp->tx.boundary = 2048; | 2798 | mgp->tx_boundary = 2048; |
2708 | } | 2799 | } |
2709 | /* | 2800 | /* |
2710 | * load the optimized firmware (which assumes aligned PCIe | 2801 | * load the optimized firmware (which assumes aligned PCIe |
@@ -2737,7 +2828,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) | |||
2737 | "Please install up to date fw\n"); | 2828 | "Please install up to date fw\n"); |
2738 | abort: | 2829 | abort: |
2739 | /* fall back to using the unaligned firmware */ | 2830 | /* fall back to using the unaligned firmware */ |
2740 | mgp->tx.boundary = 2048; | 2831 | mgp->tx_boundary = 2048; |
2741 | mgp->fw_name = myri10ge_fw_unaligned; | 2832 | mgp->fw_name = myri10ge_fw_unaligned; |
2742 | 2833 | ||
2743 | } | 2834 | } |
@@ -2758,7 +2849,7 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp) | |||
2758 | if (link_width < 8) { | 2849 | if (link_width < 8) { |
2759 | dev_info(&mgp->pdev->dev, "PCIE x%d Link\n", | 2850 | dev_info(&mgp->pdev->dev, "PCIE x%d Link\n", |
2760 | link_width); | 2851 | link_width); |
2761 | mgp->tx.boundary = 4096; | 2852 | mgp->tx_boundary = 4096; |
2762 | mgp->fw_name = myri10ge_fw_aligned; | 2853 | mgp->fw_name = myri10ge_fw_aligned; |
2763 | } else { | 2854 | } else { |
2764 | myri10ge_firmware_probe(mgp); | 2855 | myri10ge_firmware_probe(mgp); |
@@ -2767,12 +2858,12 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp) | |||
2767 | if (myri10ge_force_firmware == 1) { | 2858 | if (myri10ge_force_firmware == 1) { |
2768 | dev_info(&mgp->pdev->dev, | 2859 | dev_info(&mgp->pdev->dev, |
2769 | "Assuming aligned completions (forced)\n"); | 2860 | "Assuming aligned completions (forced)\n"); |
2770 | mgp->tx.boundary = 4096; | 2861 | mgp->tx_boundary = 4096; |
2771 | mgp->fw_name = myri10ge_fw_aligned; | 2862 | mgp->fw_name = myri10ge_fw_aligned; |
2772 | } else { | 2863 | } else { |
2773 | dev_info(&mgp->pdev->dev, | 2864 | dev_info(&mgp->pdev->dev, |
2774 | "Assuming unaligned completions (forced)\n"); | 2865 | "Assuming unaligned completions (forced)\n"); |
2775 | mgp->tx.boundary = 2048; | 2866 | mgp->tx_boundary = 2048; |
2776 | mgp->fw_name = myri10ge_fw_unaligned; | 2867 | mgp->fw_name = myri10ge_fw_unaligned; |
2777 | } | 2868 | } |
2778 | } | 2869 | } |
@@ -2889,6 +2980,7 @@ static void myri10ge_watchdog(struct work_struct *work) | |||
2889 | { | 2980 | { |
2890 | struct myri10ge_priv *mgp = | 2981 | struct myri10ge_priv *mgp = |
2891 | container_of(work, struct myri10ge_priv, watchdog_work); | 2982 | container_of(work, struct myri10ge_priv, watchdog_work); |
2983 | struct myri10ge_tx_buf *tx; | ||
2892 | u32 reboot; | 2984 | u32 reboot; |
2893 | int status; | 2985 | int status; |
2894 | u16 cmd, vendor; | 2986 | u16 cmd, vendor; |
@@ -2938,15 +3030,16 @@ static void myri10ge_watchdog(struct work_struct *work) | |||
2938 | 3030 | ||
2939 | printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n", | 3031 | printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n", |
2940 | mgp->dev->name); | 3032 | mgp->dev->name); |
3033 | tx = &mgp->ss.tx; | ||
2941 | printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", | 3034 | printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", |
2942 | mgp->dev->name, mgp->tx.req, mgp->tx.done, | 3035 | mgp->dev->name, tx->req, tx->done, |
2943 | mgp->tx.pkt_start, mgp->tx.pkt_done, | 3036 | tx->pkt_start, tx->pkt_done, |
2944 | (int)ntohl(mgp->fw_stats->send_done_count)); | 3037 | (int)ntohl(mgp->ss.fw_stats->send_done_count)); |
2945 | msleep(2000); | 3038 | msleep(2000); |
2946 | printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", | 3039 | printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", |
2947 | mgp->dev->name, mgp->tx.req, mgp->tx.done, | 3040 | mgp->dev->name, tx->req, tx->done, |
2948 | mgp->tx.pkt_start, mgp->tx.pkt_done, | 3041 | tx->pkt_start, tx->pkt_done, |
2949 | (int)ntohl(mgp->fw_stats->send_done_count)); | 3042 | (int)ntohl(mgp->ss.fw_stats->send_done_count)); |
2950 | } | 3043 | } |
2951 | rtnl_lock(); | 3044 | rtnl_lock(); |
2952 | myri10ge_close(mgp->dev); | 3045 | myri10ge_close(mgp->dev); |
@@ -2969,28 +3062,31 @@ static void myri10ge_watchdog(struct work_struct *work) | |||
2969 | static void myri10ge_watchdog_timer(unsigned long arg) | 3062 | static void myri10ge_watchdog_timer(unsigned long arg) |
2970 | { | 3063 | { |
2971 | struct myri10ge_priv *mgp; | 3064 | struct myri10ge_priv *mgp; |
3065 | struct myri10ge_slice_state *ss; | ||
2972 | u32 rx_pause_cnt; | 3066 | u32 rx_pause_cnt; |
2973 | 3067 | ||
2974 | mgp = (struct myri10ge_priv *)arg; | 3068 | mgp = (struct myri10ge_priv *)arg; |
2975 | 3069 | ||
2976 | if (mgp->rx_small.watchdog_needed) { | 3070 | rx_pause_cnt = ntohl(mgp->ss.fw_stats->dropped_pause); |
2977 | myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, | 3071 | |
3072 | ss = &mgp->ss; | ||
3073 | if (ss->rx_small.watchdog_needed) { | ||
3074 | myri10ge_alloc_rx_pages(mgp, &ss->rx_small, | ||
2978 | mgp->small_bytes + MXGEFW_PAD, 1); | 3075 | mgp->small_bytes + MXGEFW_PAD, 1); |
2979 | if (mgp->rx_small.fill_cnt - mgp->rx_small.cnt >= | 3076 | if (ss->rx_small.fill_cnt - ss->rx_small.cnt >= |
2980 | myri10ge_fill_thresh) | 3077 | myri10ge_fill_thresh) |
2981 | mgp->rx_small.watchdog_needed = 0; | 3078 | ss->rx_small.watchdog_needed = 0; |
2982 | } | 3079 | } |
2983 | if (mgp->rx_big.watchdog_needed) { | 3080 | if (ss->rx_big.watchdog_needed) { |
2984 | myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 1); | 3081 | myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 1); |
2985 | if (mgp->rx_big.fill_cnt - mgp->rx_big.cnt >= | 3082 | if (ss->rx_big.fill_cnt - ss->rx_big.cnt >= |
2986 | myri10ge_fill_thresh) | 3083 | myri10ge_fill_thresh) |
2987 | mgp->rx_big.watchdog_needed = 0; | 3084 | ss->rx_big.watchdog_needed = 0; |
2988 | } | 3085 | } |
2989 | rx_pause_cnt = ntohl(mgp->fw_stats->dropped_pause); | ||
2990 | 3086 | ||
2991 | if (mgp->tx.req != mgp->tx.done && | 3087 | if (ss->tx.req != ss->tx.done && |
2992 | mgp->tx.done == mgp->watchdog_tx_done && | 3088 | ss->tx.done == ss->watchdog_tx_done && |
2993 | mgp->watchdog_tx_req != mgp->watchdog_tx_done) { | 3089 | ss->watchdog_tx_req != ss->watchdog_tx_done) { |
2994 | /* nic seems like it might be stuck.. */ | 3090 | /* nic seems like it might be stuck.. */ |
2995 | if (rx_pause_cnt != mgp->watchdog_pause) { | 3091 | if (rx_pause_cnt != mgp->watchdog_pause) { |
2996 | if (net_ratelimit()) | 3092 | if (net_ratelimit()) |
@@ -3005,8 +3101,8 @@ static void myri10ge_watchdog_timer(unsigned long arg) | |||
3005 | /* rearm timer */ | 3101 | /* rearm timer */ |
3006 | mod_timer(&mgp->watchdog_timer, | 3102 | mod_timer(&mgp->watchdog_timer, |
3007 | jiffies + myri10ge_watchdog_timeout * HZ); | 3103 | jiffies + myri10ge_watchdog_timeout * HZ); |
3008 | mgp->watchdog_tx_done = mgp->tx.done; | 3104 | ss->watchdog_tx_done = ss->tx.done; |
3009 | mgp->watchdog_tx_req = mgp->tx.req; | 3105 | ss->watchdog_tx_req = ss->tx.req; |
3010 | mgp->watchdog_pause = rx_pause_cnt; | 3106 | mgp->watchdog_pause = rx_pause_cnt; |
3011 | } | 3107 | } |
3012 | 3108 | ||
@@ -3030,7 +3126,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3030 | 3126 | ||
3031 | mgp = netdev_priv(netdev); | 3127 | mgp = netdev_priv(netdev); |
3032 | mgp->dev = netdev; | 3128 | mgp->dev = netdev; |
3033 | netif_napi_add(netdev, &mgp->napi, myri10ge_poll, myri10ge_napi_weight); | 3129 | netif_napi_add(netdev, &mgp->ss.napi, myri10ge_poll, myri10ge_napi_weight); |
3034 | mgp->pdev = pdev; | 3130 | mgp->pdev = pdev; |
3035 | mgp->csum_flag = MXGEFW_FLAGS_CKSUM; | 3131 | mgp->csum_flag = MXGEFW_FLAGS_CKSUM; |
3036 | mgp->pause = myri10ge_flow_control; | 3132 | mgp->pause = myri10ge_flow_control; |
@@ -3076,9 +3172,9 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3076 | if (mgp->cmd == NULL) | 3172 | if (mgp->cmd == NULL) |
3077 | goto abort_with_netdev; | 3173 | goto abort_with_netdev; |
3078 | 3174 | ||
3079 | mgp->fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->fw_stats), | 3175 | mgp->ss.fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats), |
3080 | &mgp->fw_stats_bus, GFP_KERNEL); | 3176 | &mgp->ss.fw_stats_bus, GFP_KERNEL); |
3081 | if (mgp->fw_stats == NULL) | 3177 | if (mgp->ss.fw_stats == NULL) |
3082 | goto abort_with_cmd; | 3178 | goto abort_with_cmd; |
3083 | 3179 | ||
3084 | mgp->board_span = pci_resource_len(pdev, 0); | 3180 | mgp->board_span = pci_resource_len(pdev, 0); |
@@ -3118,12 +3214,12 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3118 | netdev->dev_addr[i] = mgp->mac_addr[i]; | 3214 | netdev->dev_addr[i] = mgp->mac_addr[i]; |
3119 | 3215 | ||
3120 | /* allocate rx done ring */ | 3216 | /* allocate rx done ring */ |
3121 | bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); | 3217 | bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry); |
3122 | mgp->rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes, | 3218 | mgp->ss.rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes, |
3123 | &mgp->rx_done.bus, GFP_KERNEL); | 3219 | &mgp->ss.rx_done.bus, GFP_KERNEL); |
3124 | if (mgp->rx_done.entry == NULL) | 3220 | if (mgp->ss.rx_done.entry == NULL) |
3125 | goto abort_with_ioremap; | 3221 | goto abort_with_ioremap; |
3126 | memset(mgp->rx_done.entry, 0, bytes); | 3222 | memset(mgp->ss.rx_done.entry, 0, bytes); |
3127 | 3223 | ||
3128 | myri10ge_select_firmware(mgp); | 3224 | myri10ge_select_firmware(mgp); |
3129 | 3225 | ||
@@ -3183,7 +3279,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3183 | } | 3279 | } |
3184 | dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n", | 3280 | dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n", |
3185 | (mgp->msi_enabled ? "MSI" : "xPIC"), | 3281 | (mgp->msi_enabled ? "MSI" : "xPIC"), |
3186 | netdev->irq, mgp->tx.boundary, mgp->fw_name, | 3282 | netdev->irq, mgp->tx_boundary, mgp->fw_name, |
3187 | (mgp->wc_enabled ? "Enabled" : "Disabled")); | 3283 | (mgp->wc_enabled ? "Enabled" : "Disabled")); |
3188 | 3284 | ||
3189 | return 0; | 3285 | return 0; |
@@ -3195,9 +3291,9 @@ abort_with_firmware: | |||
3195 | myri10ge_dummy_rdma(mgp, 0); | 3291 | myri10ge_dummy_rdma(mgp, 0); |
3196 | 3292 | ||
3197 | abort_with_rx_done: | 3293 | abort_with_rx_done: |
3198 | bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); | 3294 | bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry); |
3199 | dma_free_coherent(&pdev->dev, bytes, | 3295 | dma_free_coherent(&pdev->dev, bytes, |
3200 | mgp->rx_done.entry, mgp->rx_done.bus); | 3296 | mgp->ss.rx_done.entry, mgp->ss.rx_done.bus); |
3201 | 3297 | ||
3202 | abort_with_ioremap: | 3298 | abort_with_ioremap: |
3203 | iounmap(mgp->sram); | 3299 | iounmap(mgp->sram); |
@@ -3207,8 +3303,8 @@ abort_with_wc: | |||
3207 | if (mgp->mtrr >= 0) | 3303 | if (mgp->mtrr >= 0) |
3208 | mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); | 3304 | mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); |
3209 | #endif | 3305 | #endif |
3210 | dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats), | 3306 | dma_free_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats), |
3211 | mgp->fw_stats, mgp->fw_stats_bus); | 3307 | mgp->ss.fw_stats, mgp->ss.fw_stats_bus); |
3212 | 3308 | ||
3213 | abort_with_cmd: | 3309 | abort_with_cmd: |
3214 | dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), | 3310 | dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), |
@@ -3246,9 +3342,9 @@ static void myri10ge_remove(struct pci_dev *pdev) | |||
3246 | /* avoid a memory leak */ | 3342 | /* avoid a memory leak */ |
3247 | pci_restore_state(pdev); | 3343 | pci_restore_state(pdev); |
3248 | 3344 | ||
3249 | bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); | 3345 | bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry); |
3250 | dma_free_coherent(&pdev->dev, bytes, | 3346 | dma_free_coherent(&pdev->dev, bytes, |
3251 | mgp->rx_done.entry, mgp->rx_done.bus); | 3347 | mgp->ss.rx_done.entry, mgp->ss.rx_done.bus); |
3252 | 3348 | ||
3253 | iounmap(mgp->sram); | 3349 | iounmap(mgp->sram); |
3254 | 3350 | ||
@@ -3256,8 +3352,8 @@ static void myri10ge_remove(struct pci_dev *pdev) | |||
3256 | if (mgp->mtrr >= 0) | 3352 | if (mgp->mtrr >= 0) |
3257 | mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); | 3353 | mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); |
3258 | #endif | 3354 | #endif |
3259 | dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats), | 3355 | dma_free_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats), |
3260 | mgp->fw_stats, mgp->fw_stats_bus); | 3356 | mgp->ss.fw_stats, mgp->ss.fw_stats_bus); |
3261 | 3357 | ||
3262 | dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), | 3358 | dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), |
3263 | mgp->cmd, mgp->cmd_bus); | 3359 | mgp->cmd, mgp->cmd_bus); |
diff --git a/drivers/net/myri10ge/myri10ge_mcp.h b/drivers/net/myri10ge/myri10ge_mcp.h index 58e57178c563..fdbeeee07372 100644 --- a/drivers/net/myri10ge/myri10ge_mcp.h +++ b/drivers/net/myri10ge/myri10ge_mcp.h | |||
@@ -10,7 +10,7 @@ struct mcp_dma_addr { | |||
10 | __be32 low; | 10 | __be32 low; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | /* 4 Bytes. 8 Bytes for NDIS drivers. */ | 13 | /* 4 Bytes */ |
14 | struct mcp_slot { | 14 | struct mcp_slot { |
15 | __sum16 checksum; | 15 | __sum16 checksum; |
16 | __be16 length; | 16 | __be16 length; |
@@ -144,6 +144,7 @@ enum myri10ge_mcp_cmd_type { | |||
144 | * a power of 2 number of entries. */ | 144 | * a power of 2 number of entries. */ |
145 | 145 | ||
146 | MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */ | 146 | MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */ |
147 | #define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK (1 << 31) | ||
147 | 148 | ||
148 | /* command to bring ethernet interface up. Above parameters | 149 | /* command to bring ethernet interface up. Above parameters |
149 | * (plus mtu & mac address) must have been exchanged prior | 150 | * (plus mtu & mac address) must have been exchanged prior |
@@ -221,10 +222,14 @@ enum myri10ge_mcp_cmd_type { | |||
221 | MXGEFW_CMD_GET_MAX_RSS_QUEUES, | 222 | MXGEFW_CMD_GET_MAX_RSS_QUEUES, |
222 | MXGEFW_CMD_ENABLE_RSS_QUEUES, | 223 | MXGEFW_CMD_ENABLE_RSS_QUEUES, |
223 | /* data0 = number of slices n (0, 1, ..., n-1) to enable | 224 | /* data0 = number of slices n (0, 1, ..., n-1) to enable |
224 | * data1 = interrupt mode. 0=share one INTx/MSI, 1=use one MSI-X per queue. | 225 | * data1 = interrupt mode. |
226 | * 0=share one INTx/MSI, 1=use one MSI-X per queue. | ||
225 | * If all queues share one interrupt, the driver must have set | 227 | * If all queues share one interrupt, the driver must have set |
226 | * RSS_SHARED_INTERRUPT_DMA before enabling queues. | 228 | * RSS_SHARED_INTERRUPT_DMA before enabling queues. |
227 | */ | 229 | */ |
230 | #define MXGEFW_SLICE_INTR_MODE_SHARED 0 | ||
231 | #define MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE 1 | ||
232 | |||
228 | MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET, | 233 | MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET, |
229 | MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA, | 234 | MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA, |
230 | /* data0, data1 = bus address lsw, msw */ | 235 | /* data0, data1 = bus address lsw, msw */ |
@@ -241,10 +246,14 @@ enum myri10ge_mcp_cmd_type { | |||
241 | * 0: disable rss. nic does not distribute receive packets. | 246 | * 0: disable rss. nic does not distribute receive packets. |
242 | * 1: enable rss. nic distributes receive packets among queues. | 247 | * 1: enable rss. nic distributes receive packets among queues. |
243 | * data1 = hash type | 248 | * data1 = hash type |
244 | * 1: IPV4 | 249 | * 1: IPV4 (required by RSS) |
245 | * 2: TCP_IPV4 | 250 | * 2: TCP_IPV4 (required by RSS) |
246 | * 3: IPV4 | TCP_IPV4 | 251 | * 3: IPV4 | TCP_IPV4 (required by RSS) |
252 | * 4: source port | ||
247 | */ | 253 | */ |
254 | #define MXGEFW_RSS_HASH_TYPE_IPV4 0x1 | ||
255 | #define MXGEFW_RSS_HASH_TYPE_TCP_IPV4 0x2 | ||
256 | #define MXGEFW_RSS_HASH_TYPE_SRC_PORT 0x4 | ||
248 | 257 | ||
249 | MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, | 258 | MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, |
250 | /* Return data = the max. size of the entire headers of a IPv6 TSO packet. | 259 | /* Return data = the max. size of the entire headers of a IPv6 TSO packet. |
@@ -260,6 +269,8 @@ enum myri10ge_mcp_cmd_type { | |||
260 | * 0: Linux/FreeBSD style (NIC default) | 269 | * 0: Linux/FreeBSD style (NIC default) |
261 | * 1: NDIS/NetBSD style | 270 | * 1: NDIS/NetBSD style |
262 | */ | 271 | */ |
272 | #define MXGEFW_TSO_MODE_LINUX 0 | ||
273 | #define MXGEFW_TSO_MODE_NDIS 1 | ||
263 | 274 | ||
264 | MXGEFW_CMD_MDIO_READ, | 275 | MXGEFW_CMD_MDIO_READ, |
265 | /* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */ | 276 | /* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */ |
@@ -286,6 +297,38 @@ enum myri10ge_mcp_cmd_type { | |||
286 | /* Return data = NIC memory offset of mcp_vpump_public_global */ | 297 | /* Return data = NIC memory offset of mcp_vpump_public_global */ |
287 | MXGEFW_CMD_RESET_VPUMP, | 298 | MXGEFW_CMD_RESET_VPUMP, |
288 | /* Resets the VPUMP state */ | 299 | /* Resets the VPUMP state */ |
300 | |||
301 | MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE, | ||
302 | /* data0 = mcp_slot type to use. | ||
303 | * 0 = the default 4B mcp_slot | ||
304 | * 1 = 8B mcp_slot_8 | ||
305 | */ | ||
306 | #define MXGEFW_RSS_MCP_SLOT_TYPE_MIN 0 | ||
307 | #define MXGEFW_RSS_MCP_SLOT_TYPE_WITH_HASH 1 | ||
308 | |||
309 | MXGEFW_CMD_SET_THROTTLE_FACTOR, | ||
310 | /* set the throttle factor for ethp_z8e | ||
311 | * data0 = throttle_factor | ||
312 | * throttle_factor = 256 * pcie-raw-speed / tx_speed | ||
313 | * tx_speed = 256 * pcie-raw-speed / throttle_factor | ||
314 | * | ||
315 | * For PCI-E x8: pcie-raw-speed == 16Gb/s | ||
316 | * For PCI-E x4: pcie-raw-speed == 8Gb/s | ||
317 | * | ||
318 | * ex1: throttle_factor == 0x1a0 (416), tx_speed == 1.23GB/s == 9.846 Gb/s | ||
319 | * ex2: throttle_factor == 0x200 (512), tx_speed == 1.0GB/s == 8 Gb/s | ||
320 | * | ||
321 | * with tx_boundary == 2048, max-throttle-factor == 8191 => min-speed == 500Mb/s | ||
322 | * with tx_boundary == 4096, max-throttle-factor == 4095 => min-speed == 1Gb/s | ||
323 | */ | ||
324 | |||
325 | MXGEFW_CMD_VPUMP_UP, | ||
326 | /* Allocates VPump Connection, Send Request and Zero copy buffer address tables */ | ||
327 | MXGEFW_CMD_GET_VPUMP_CLK, | ||
328 | /* Get the lanai clock */ | ||
329 | |||
330 | MXGEFW_CMD_GET_DCA_OFFSET, | ||
331 | /* offset of dca control for WDMAs */ | ||
289 | }; | 332 | }; |
290 | 333 | ||
291 | enum myri10ge_mcp_cmd_status { | 334 | enum myri10ge_mcp_cmd_status { |
@@ -302,7 +345,8 @@ enum myri10ge_mcp_cmd_status { | |||
302 | MXGEFW_CMD_ERROR_UNALIGNED, | 345 | MXGEFW_CMD_ERROR_UNALIGNED, |
303 | MXGEFW_CMD_ERROR_NO_MDIO, | 346 | MXGEFW_CMD_ERROR_NO_MDIO, |
304 | MXGEFW_CMD_ERROR_XFP_FAILURE, | 347 | MXGEFW_CMD_ERROR_XFP_FAILURE, |
305 | MXGEFW_CMD_ERROR_XFP_ABSENT | 348 | MXGEFW_CMD_ERROR_XFP_ABSENT, |
349 | MXGEFW_CMD_ERROR_BAD_PCIE_LINK | ||
306 | }; | 350 | }; |
307 | 351 | ||
308 | #define MXGEFW_OLD_IRQ_DATA_LEN 40 | 352 | #define MXGEFW_OLD_IRQ_DATA_LEN 40 |
diff --git a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h index 16a810dd6d51..07d65c2cbb24 100644 --- a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h +++ b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h | |||
@@ -1,30 +1,6 @@ | |||
1 | #ifndef __MYRI10GE_MCP_GEN_HEADER_H__ | 1 | #ifndef __MYRI10GE_MCP_GEN_HEADER_H__ |
2 | #define __MYRI10GE_MCP_GEN_HEADER_H__ | 2 | #define __MYRI10GE_MCP_GEN_HEADER_H__ |
3 | 3 | ||
4 | /* this file define a standard header used as a first entry point to | ||
5 | * exchange information between firmware/driver and driver. The | ||
6 | * header structure can be anywhere in the mcp. It will usually be in | ||
7 | * the .data section, because some fields needs to be initialized at | ||
8 | * compile time. | ||
9 | * The 32bit word at offset MX_HEADER_PTR_OFFSET in the mcp must | ||
10 | * contains the location of the header. | ||
11 | * | ||
12 | * Typically a MCP will start with the following: | ||
13 | * .text | ||
14 | * .space 52 ! to help catch MEMORY_INT errors | ||
15 | * bt start ! jump to real code | ||
16 | * nop | ||
17 | * .long _gen_mcp_header | ||
18 | * | ||
19 | * The source will have a definition like: | ||
20 | * | ||
21 | * mcp_gen_header_t gen_mcp_header = { | ||
22 | * .header_length = sizeof(mcp_gen_header_t), | ||
23 | * .mcp_type = MCP_TYPE_XXX, | ||
24 | * .version = "something $Id: mcp_gen_header.h,v 1.2 2006/05/13 10:04:35 bgoglin Exp $", | ||
25 | * .mcp_globals = (unsigned)&Globals | ||
26 | * }; | ||
27 | */ | ||
28 | 4 | ||
29 | #define MCP_HEADER_PTR_OFFSET 0x3c | 5 | #define MCP_HEADER_PTR_OFFSET 0x3c |
30 | 6 | ||
@@ -32,13 +8,14 @@ | |||
32 | #define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */ | 8 | #define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */ |
33 | #define MCP_TYPE_ETH 0x45544820 /* "ETH " */ | 9 | #define MCP_TYPE_ETH 0x45544820 /* "ETH " */ |
34 | #define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */ | 10 | #define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */ |
11 | #define MCP_TYPE_DFLT 0x20202020 /* " " */ | ||
35 | 12 | ||
36 | struct mcp_gen_header { | 13 | struct mcp_gen_header { |
37 | /* the first 4 fields are filled at compile time */ | 14 | /* the first 4 fields are filled at compile time */ |
38 | unsigned header_length; | 15 | unsigned header_length; |
39 | __be32 mcp_type; | 16 | __be32 mcp_type; |
40 | char version[128]; | 17 | char version[128]; |
41 | unsigned mcp_globals; /* pointer to mcp-type specific structure */ | 18 | unsigned mcp_private; /* pointer to mcp-type specific structure */ |
42 | 19 | ||
43 | /* filled by the MCP at run-time */ | 20 | /* filled by the MCP at run-time */ |
44 | unsigned sram_size; | 21 | unsigned sram_size; |
@@ -53,6 +30,18 @@ struct mcp_gen_header { | |||
53 | * | 30 | * |
54 | * Never remove any field. Keep everything naturally align. | 31 | * Never remove any field. Keep everything naturally align. |
55 | */ | 32 | */ |
33 | |||
34 | /* Specifies if the running mcp is mcp0, 1, or 2. */ | ||
35 | unsigned char mcp_index; | ||
36 | unsigned char disable_rabbit; | ||
37 | unsigned char unaligned_tlp; | ||
38 | unsigned char pad1; | ||
39 | unsigned counters_addr; | ||
40 | unsigned copy_block_info; /* for small mcps loaded with "lload -d" */ | ||
41 | unsigned short handoff_id_major; /* must be equal */ | ||
42 | unsigned short handoff_id_caps; /* bitfield: new mcp must have superset */ | ||
43 | unsigned msix_table_addr; /* start address of msix table in firmware */ | ||
44 | /* 8 */ | ||
56 | }; | 45 | }; |
57 | 46 | ||
58 | #endif /* __MYRI10GE_MCP_GEN_HEADER_H__ */ | 47 | #endif /* __MYRI10GE_MCP_GEN_HEADER_H__ */ |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index 57cfd72ffdf7..918f802fe089 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -865,7 +865,6 @@ static int link_status_1g_serdes(struct niu *np, int *link_up_p) | |||
865 | return 0; | 865 | return 0; |
866 | } | 866 | } |
867 | 867 | ||
868 | |||
869 | static int link_status_10g_serdes(struct niu *np, int *link_up_p) | 868 | static int link_status_10g_serdes(struct niu *np, int *link_up_p) |
870 | { | 869 | { |
871 | unsigned long flags; | 870 | unsigned long flags; |
@@ -900,7 +899,6 @@ static int link_status_10g_serdes(struct niu *np, int *link_up_p) | |||
900 | return 0; | 899 | return 0; |
901 | } | 900 | } |
902 | 901 | ||
903 | |||
904 | static int link_status_1g_rgmii(struct niu *np, int *link_up_p) | 902 | static int link_status_1g_rgmii(struct niu *np, int *link_up_p) |
905 | { | 903 | { |
906 | struct niu_link_config *lp = &np->link_config; | 904 | struct niu_link_config *lp = &np->link_config; |
@@ -957,7 +955,6 @@ out: | |||
957 | return err; | 955 | return err; |
958 | } | 956 | } |
959 | 957 | ||
960 | |||
961 | static int bcm8704_reset(struct niu *np) | 958 | static int bcm8704_reset(struct niu *np) |
962 | { | 959 | { |
963 | int err, limit; | 960 | int err, limit; |
@@ -1357,8 +1354,6 @@ static int mii_reset(struct niu *np) | |||
1357 | return 0; | 1354 | return 0; |
1358 | } | 1355 | } |
1359 | 1356 | ||
1360 | |||
1361 | |||
1362 | static int xcvr_init_1g_rgmii(struct niu *np) | 1357 | static int xcvr_init_1g_rgmii(struct niu *np) |
1363 | { | 1358 | { |
1364 | int err; | 1359 | int err; |
@@ -1419,7 +1414,6 @@ static int xcvr_init_1g_rgmii(struct niu *np) | |||
1419 | return 0; | 1414 | return 0; |
1420 | } | 1415 | } |
1421 | 1416 | ||
1422 | |||
1423 | static int mii_init_common(struct niu *np) | 1417 | static int mii_init_common(struct niu *np) |
1424 | { | 1418 | { |
1425 | struct niu_link_config *lp = &np->link_config; | 1419 | struct niu_link_config *lp = &np->link_config; |
@@ -7008,31 +7002,20 @@ static int __devinit niu_phy_type_prop_decode(struct niu *np, | |||
7008 | return 0; | 7002 | return 0; |
7009 | } | 7003 | } |
7010 | 7004 | ||
7011 | /* niu board models have a trailing dash version incremented | ||
7012 | * with HW rev change. Need to ingnore the dash version while | ||
7013 | * checking for match | ||
7014 | * | ||
7015 | * for example, for the 10G card the current vpd.board_model | ||
7016 | * is 501-5283-04, of which -04 is the dash version and have | ||
7017 | * to be ignored | ||
7018 | */ | ||
7019 | static int niu_board_model_match(struct niu *np, const char *model) | ||
7020 | { | ||
7021 | return !strncmp(np->vpd.board_model, model, strlen(model)); | ||
7022 | } | ||
7023 | |||
7024 | static int niu_pci_vpd_get_nports(struct niu *np) | 7005 | static int niu_pci_vpd_get_nports(struct niu *np) |
7025 | { | 7006 | { |
7026 | int ports = 0; | 7007 | int ports = 0; |
7027 | 7008 | ||
7028 | if ((niu_board_model_match(np, NIU_QGC_LP_BM_STR)) || | 7009 | if ((!strcmp(np->vpd.model, NIU_QGC_LP_MDL_STR)) || |
7029 | (niu_board_model_match(np, NIU_QGC_PEM_BM_STR)) || | 7010 | (!strcmp(np->vpd.model, NIU_QGC_PEM_MDL_STR)) || |
7030 | (niu_board_model_match(np, NIU_ALONSO_BM_STR))) { | 7011 | (!strcmp(np->vpd.model, NIU_MARAMBA_MDL_STR)) || |
7012 | (!strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) || | ||
7013 | (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR))) { | ||
7031 | ports = 4; | 7014 | ports = 4; |
7032 | } else if ((niu_board_model_match(np, NIU_2XGF_LP_BM_STR)) || | 7015 | } else if ((!strcmp(np->vpd.model, NIU_2XGF_LP_MDL_STR)) || |
7033 | (niu_board_model_match(np, NIU_2XGF_PEM_BM_STR)) || | 7016 | (!strcmp(np->vpd.model, NIU_2XGF_PEM_MDL_STR)) || |
7034 | (niu_board_model_match(np, NIU_FOXXY_BM_STR)) || | 7017 | (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) || |
7035 | (niu_board_model_match(np, NIU_2XGF_MRVL_BM_STR))) { | 7018 | (!strcmp(np->vpd.model, NIU_2XGF_MRVL_MDL_STR))) { |
7036 | ports = 2; | 7019 | ports = 2; |
7037 | } | 7020 | } |
7038 | 7021 | ||
@@ -7053,8 +7036,8 @@ static void __devinit niu_pci_vpd_validate(struct niu *np) | |||
7053 | return; | 7036 | return; |
7054 | } | 7037 | } |
7055 | 7038 | ||
7056 | if (!strcmp(np->vpd.model, "SUNW,CP3220") || | 7039 | if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) || |
7057 | !strcmp(np->vpd.model, "SUNW,CP3260")) { | 7040 | !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) { |
7058 | np->flags |= NIU_FLAGS_10G; | 7041 | np->flags |= NIU_FLAGS_10G; |
7059 | np->flags &= ~NIU_FLAGS_FIBER; | 7042 | np->flags &= ~NIU_FLAGS_FIBER; |
7060 | np->flags |= NIU_FLAGS_XCVR_SERDES; | 7043 | np->flags |= NIU_FLAGS_XCVR_SERDES; |
@@ -7065,7 +7048,7 @@ static void __devinit niu_pci_vpd_validate(struct niu *np) | |||
7065 | } | 7048 | } |
7066 | if (np->flags & NIU_FLAGS_10G) | 7049 | if (np->flags & NIU_FLAGS_10G) |
7067 | np->mac_xcvr = MAC_XCVR_XPCS; | 7050 | np->mac_xcvr = MAC_XCVR_XPCS; |
7068 | } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { | 7051 | } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) { |
7069 | np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER | | 7052 | np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER | |
7070 | NIU_FLAGS_HOTPLUG_PHY); | 7053 | NIU_FLAGS_HOTPLUG_PHY); |
7071 | } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) { | 7054 | } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) { |
@@ -7541,8 +7524,8 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent) | |||
7541 | u32 val; | 7524 | u32 val; |
7542 | int err; | 7525 | int err; |
7543 | 7526 | ||
7544 | if (!strcmp(np->vpd.model, "SUNW,CP3220") || | 7527 | if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) || |
7545 | !strcmp(np->vpd.model, "SUNW,CP3260")) { | 7528 | !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) { |
7546 | num_10g = 0; | 7529 | num_10g = 0; |
7547 | num_1g = 2; | 7530 | num_1g = 2; |
7548 | parent->plat_type = PLAT_TYPE_ATCA_CP3220; | 7531 | parent->plat_type = PLAT_TYPE_ATCA_CP3220; |
@@ -7551,7 +7534,7 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent) | |||
7551 | phy_encode(PORT_TYPE_1G, 1) | | 7534 | phy_encode(PORT_TYPE_1G, 1) | |
7552 | phy_encode(PORT_TYPE_1G, 2) | | 7535 | phy_encode(PORT_TYPE_1G, 2) | |
7553 | phy_encode(PORT_TYPE_1G, 3)); | 7536 | phy_encode(PORT_TYPE_1G, 3)); |
7554 | } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { | 7537 | } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) { |
7555 | num_10g = 2; | 7538 | num_10g = 2; |
7556 | num_1g = 0; | 7539 | num_1g = 0; |
7557 | parent->num_ports = 2; | 7540 | parent->num_ports = 2; |
@@ -7946,6 +7929,7 @@ static int __devinit niu_get_of_props(struct niu *np) | |||
7946 | struct device_node *dp; | 7929 | struct device_node *dp; |
7947 | const char *phy_type; | 7930 | const char *phy_type; |
7948 | const u8 *mac_addr; | 7931 | const u8 *mac_addr; |
7932 | const char *model; | ||
7949 | int prop_len; | 7933 | int prop_len; |
7950 | 7934 | ||
7951 | if (np->parent->plat_type == PLAT_TYPE_NIU) | 7935 | if (np->parent->plat_type == PLAT_TYPE_NIU) |
@@ -8000,6 +7984,11 @@ static int __devinit niu_get_of_props(struct niu *np) | |||
8000 | 7984 | ||
8001 | memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len); | 7985 | memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len); |
8002 | 7986 | ||
7987 | model = of_get_property(dp, "model", &prop_len); | ||
7988 | |||
7989 | if (model) | ||
7990 | strcpy(np->vpd.model, model); | ||
7991 | |||
8003 | return 0; | 7992 | return 0; |
8004 | #else | 7993 | #else |
8005 | return -EINVAL; | 7994 | return -EINVAL; |
diff --git a/drivers/net/niu.h b/drivers/net/niu.h index 97ffbe137bcb..12fd570b9423 100644 --- a/drivers/net/niu.h +++ b/drivers/net/niu.h | |||
@@ -2946,6 +2946,15 @@ struct rx_ring_info { | |||
2946 | #define NIU_ALONSO_BM_STR "373-0202" | 2946 | #define NIU_ALONSO_BM_STR "373-0202" |
2947 | #define NIU_FOXXY_BM_STR "501-7961" | 2947 | #define NIU_FOXXY_BM_STR "501-7961" |
2948 | #define NIU_2XGF_MRVL_BM_STR "SK-6E82" | 2948 | #define NIU_2XGF_MRVL_BM_STR "SK-6E82" |
2949 | #define NIU_QGC_LP_MDL_STR "SUNW,pcie-qgc" | ||
2950 | #define NIU_2XGF_LP_MDL_STR "SUNW,pcie-2xgf" | ||
2951 | #define NIU_QGC_PEM_MDL_STR "SUNW,pcie-qgc-pem" | ||
2952 | #define NIU_2XGF_PEM_MDL_STR "SUNW,pcie-2xgf-pem" | ||
2953 | #define NIU_ALONSO_MDL_STR "SUNW,CP3220" | ||
2954 | #define NIU_KIMI_MDL_STR "SUNW,CP3260" | ||
2955 | #define NIU_MARAMBA_MDL_STR "SUNW,pcie-neptune" | ||
2956 | #define NIU_FOXXY_MDL_STR "SUNW,pcie-rfem" | ||
2957 | #define NIU_2XGF_MRVL_MDL_STR "SysKonnect,pcie-2xgf" | ||
2949 | 2958 | ||
2950 | #define NIU_VPD_MIN_MAJOR 3 | 2959 | #define NIU_VPD_MIN_MAJOR 3 |
2951 | #define NIU_VPD_MIN_MINOR 4 | 2960 | #define NIU_VPD_MIN_MINOR 4 |
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index d3207c0da895..1f4ca2b54a73 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -2458,6 +2458,7 @@ ppp_create_interface(int unit, int *retp) | |||
2458 | 2458 | ||
2459 | out3: | 2459 | out3: |
2460 | atomic_dec(&ppp_unit_count); | 2460 | atomic_dec(&ppp_unit_count); |
2461 | unregister_netdev(dev); | ||
2461 | out2: | 2462 | out2: |
2462 | mutex_unlock(&all_ppp_mutex); | 2463 | mutex_unlock(&all_ppp_mutex); |
2463 | free_netdev(dev); | 2464 | free_netdev(dev); |
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c index 244d7830c92a..79359919335b 100644 --- a/drivers/net/pppol2tp.c +++ b/drivers/net/pppol2tp.c | |||
@@ -1621,9 +1621,16 @@ out_no_ppp: | |||
1621 | end: | 1621 | end: |
1622 | release_sock(sk); | 1622 | release_sock(sk); |
1623 | 1623 | ||
1624 | if (error != 0) | 1624 | if (error != 0) { |
1625 | PRINTK(session ? session->debug : -1, PPPOL2TP_MSG_CONTROL, KERN_WARNING, | 1625 | if (session) |
1626 | "%s: connect failed: %d\n", session->name, error); | 1626 | PRINTK(session->debug, |
1627 | PPPOL2TP_MSG_CONTROL, KERN_WARNING, | ||
1628 | "%s: connect failed: %d\n", | ||
1629 | session->name, error); | ||
1630 | else | ||
1631 | PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_WARNING, | ||
1632 | "connect failed: %d\n", error); | ||
1633 | } | ||
1627 | 1634 | ||
1628 | return error; | 1635 | return error; |
1629 | } | 1636 | } |
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c index 0d32123085e9..1dae1f2ed813 100644 --- a/drivers/net/ps3_gelic_wireless.c +++ b/drivers/net/ps3_gelic_wireless.c | |||
@@ -2474,6 +2474,8 @@ static void gelic_wl_free(struct gelic_wl_info *wl) | |||
2474 | 2474 | ||
2475 | pr_debug("%s: <-\n", __func__); | 2475 | pr_debug("%s: <-\n", __func__); |
2476 | 2476 | ||
2477 | free_page((unsigned long)wl->buf); | ||
2478 | |||
2477 | pr_debug("%s: destroy queues\n", __func__); | 2479 | pr_debug("%s: destroy queues\n", __func__); |
2478 | destroy_workqueue(wl->eurus_cmd_queue); | 2480 | destroy_workqueue(wl->eurus_cmd_queue); |
2479 | destroy_workqueue(wl->event_queue); | 2481 | destroy_workqueue(wl->event_queue); |
diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile index 0f023447eafd..1d2daeec7ac1 100644 --- a/drivers/net/sfc/Makefile +++ b/drivers/net/sfc/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \ | 1 | sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \ |
2 | i2c-direct.o ethtool.o xfp_phy.o mdio_10g.o \ | 2 | i2c-direct.o selftest.o ethtool.o xfp_phy.o \ |
3 | tenxpress.o boards.o sfe4001.o | 3 | mdio_10g.o tenxpress.o boards.o sfe4001.o |
4 | 4 | ||
5 | obj-$(CONFIG_SFC) += sfc.o | 5 | obj-$(CONFIG_SFC) += sfc.o |
diff --git a/drivers/net/sfc/boards.h b/drivers/net/sfc/boards.h index f56341d428e1..695764dc2e64 100644 --- a/drivers/net/sfc/boards.h +++ b/drivers/net/sfc/boards.h | |||
@@ -22,5 +22,7 @@ enum efx_board_type { | |||
22 | extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info); | 22 | extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info); |
23 | extern int sfe4001_poweron(struct efx_nic *efx); | 23 | extern int sfe4001_poweron(struct efx_nic *efx); |
24 | extern void sfe4001_poweroff(struct efx_nic *efx); | 24 | extern void sfe4001_poweroff(struct efx_nic *efx); |
25 | /* Are we putting the PHY into flash config mode */ | ||
26 | extern unsigned int sfe4001_phy_flash_cfg; | ||
25 | 27 | ||
26 | #endif | 28 | #endif |
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index 59edcf793c19..418f2e53a95b 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -1873,6 +1873,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type, | |||
1873 | tx_queue->queue = i; | 1873 | tx_queue->queue = i; |
1874 | tx_queue->buffer = NULL; | 1874 | tx_queue->buffer = NULL; |
1875 | tx_queue->channel = &efx->channel[0]; /* for safety */ | 1875 | tx_queue->channel = &efx->channel[0]; /* for safety */ |
1876 | tx_queue->tso_headers_free = NULL; | ||
1876 | } | 1877 | } |
1877 | for (i = 0; i < EFX_MAX_RX_QUEUES; i++) { | 1878 | for (i = 0; i < EFX_MAX_RX_QUEUES; i++) { |
1878 | rx_queue = &efx->rx_queue[i]; | 1879 | rx_queue = &efx->rx_queue[i]; |
@@ -2071,7 +2072,8 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, | |||
2071 | net_dev = alloc_etherdev(sizeof(*efx)); | 2072 | net_dev = alloc_etherdev(sizeof(*efx)); |
2072 | if (!net_dev) | 2073 | if (!net_dev) |
2073 | return -ENOMEM; | 2074 | return -ENOMEM; |
2074 | net_dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA; | 2075 | net_dev->features |= (NETIF_F_IP_CSUM | NETIF_F_SG | |
2076 | NETIF_F_HIGHDMA | NETIF_F_TSO); | ||
2075 | if (lro) | 2077 | if (lro) |
2076 | net_dev->features |= NETIF_F_LRO; | 2078 | net_dev->features |= NETIF_F_LRO; |
2077 | efx = net_dev->priv; | 2079 | efx = net_dev->priv; |
diff --git a/drivers/net/sfc/enum.h b/drivers/net/sfc/enum.h index 43663a4619da..c53290d08e2b 100644 --- a/drivers/net/sfc/enum.h +++ b/drivers/net/sfc/enum.h | |||
@@ -10,6 +10,55 @@ | |||
10 | #ifndef EFX_ENUM_H | 10 | #ifndef EFX_ENUM_H |
11 | #define EFX_ENUM_H | 11 | #define EFX_ENUM_H |
12 | 12 | ||
13 | /** | ||
14 | * enum efx_loopback_mode - loopback modes | ||
15 | * @LOOPBACK_NONE: no loopback | ||
16 | * @LOOPBACK_XGMII: loopback within MAC at XGMII level | ||
17 | * @LOOPBACK_XGXS: loopback within MAC at XGXS level | ||
18 | * @LOOPBACK_XAUI: loopback within MAC at XAUI level | ||
19 | * @LOOPBACK_PHYXS: loopback within PHY at PHYXS level | ||
20 | * @LOOPBACK_PCS: loopback within PHY at PCS level | ||
21 | * @LOOPBACK_PMAPMD: loopback within PHY at PMAPMD level | ||
22 | * @LOOPBACK_NETWORK: reflecting loopback (even further than furthest!) | ||
23 | */ | ||
24 | /* Please keep in order and up-to-date w.r.t the following two #defines */ | ||
25 | enum efx_loopback_mode { | ||
26 | LOOPBACK_NONE = 0, | ||
27 | LOOPBACK_MAC = 1, | ||
28 | LOOPBACK_XGMII = 2, | ||
29 | LOOPBACK_XGXS = 3, | ||
30 | LOOPBACK_XAUI = 4, | ||
31 | LOOPBACK_PHY = 5, | ||
32 | LOOPBACK_PHYXS = 6, | ||
33 | LOOPBACK_PCS = 7, | ||
34 | LOOPBACK_PMAPMD = 8, | ||
35 | LOOPBACK_NETWORK = 9, | ||
36 | LOOPBACK_MAX | ||
37 | }; | ||
38 | |||
39 | #define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD | ||
40 | |||
41 | extern const char *efx_loopback_mode_names[]; | ||
42 | #define LOOPBACK_MODE_NAME(mode) \ | ||
43 | STRING_TABLE_LOOKUP(mode, efx_loopback_mode) | ||
44 | #define LOOPBACK_MODE(efx) \ | ||
45 | LOOPBACK_MODE_NAME(efx->loopback_mode) | ||
46 | |||
47 | /* These loopbacks occur within the controller */ | ||
48 | #define LOOPBACKS_10G_INTERNAL ((1 << LOOPBACK_XGMII)| \ | ||
49 | (1 << LOOPBACK_XGXS) | \ | ||
50 | (1 << LOOPBACK_XAUI)) | ||
51 | |||
52 | #define LOOPBACK_MASK(_efx) \ | ||
53 | (1 << (_efx)->loopback_mode) | ||
54 | |||
55 | #define LOOPBACK_INTERNAL(_efx) \ | ||
56 | ((LOOPBACKS_10G_INTERNAL & LOOPBACK_MASK(_efx)) ? 1 : 0) | ||
57 | |||
58 | #define LOOPBACK_OUT_OF(_from, _to, _mask) \ | ||
59 | (((LOOPBACK_MASK(_from) & (_mask)) && \ | ||
60 | ((LOOPBACK_MASK(_to) & (_mask)) == 0)) ? 1 : 0) | ||
61 | |||
13 | /*****************************************************************************/ | 62 | /*****************************************************************************/ |
14 | 63 | ||
15 | /** | 64 | /** |
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c index ad541badbd98..e2c75d101610 100644 --- a/drivers/net/sfc/ethtool.c +++ b/drivers/net/sfc/ethtool.c | |||
@@ -12,12 +12,26 @@ | |||
12 | #include <linux/ethtool.h> | 12 | #include <linux/ethtool.h> |
13 | #include <linux/rtnetlink.h> | 13 | #include <linux/rtnetlink.h> |
14 | #include "net_driver.h" | 14 | #include "net_driver.h" |
15 | #include "selftest.h" | ||
15 | #include "efx.h" | 16 | #include "efx.h" |
16 | #include "ethtool.h" | 17 | #include "ethtool.h" |
17 | #include "falcon.h" | 18 | #include "falcon.h" |
18 | #include "gmii.h" | 19 | #include "gmii.h" |
19 | #include "mac.h" | 20 | #include "mac.h" |
20 | 21 | ||
22 | const char *efx_loopback_mode_names[] = { | ||
23 | [LOOPBACK_NONE] = "NONE", | ||
24 | [LOOPBACK_MAC] = "MAC", | ||
25 | [LOOPBACK_XGMII] = "XGMII", | ||
26 | [LOOPBACK_XGXS] = "XGXS", | ||
27 | [LOOPBACK_XAUI] = "XAUI", | ||
28 | [LOOPBACK_PHY] = "PHY", | ||
29 | [LOOPBACK_PHYXS] = "PHY(XS)", | ||
30 | [LOOPBACK_PCS] = "PHY(PCS)", | ||
31 | [LOOPBACK_PMAPMD] = "PHY(PMAPMD)", | ||
32 | [LOOPBACK_NETWORK] = "NETWORK", | ||
33 | }; | ||
34 | |||
21 | static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable); | 35 | static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable); |
22 | 36 | ||
23 | struct ethtool_string { | 37 | struct ethtool_string { |
@@ -217,23 +231,179 @@ static void efx_ethtool_get_drvinfo(struct net_device *net_dev, | |||
217 | strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); | 231 | strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); |
218 | } | 232 | } |
219 | 233 | ||
234 | /** | ||
235 | * efx_fill_test - fill in an individual self-test entry | ||
236 | * @test_index: Index of the test | ||
237 | * @strings: Ethtool strings, or %NULL | ||
238 | * @data: Ethtool test results, or %NULL | ||
239 | * @test: Pointer to test result (used only if data != %NULL) | ||
240 | * @unit_format: Unit name format (e.g. "channel\%d") | ||
241 | * @unit_id: Unit id (e.g. 0 for "channel0") | ||
242 | * @test_format: Test name format (e.g. "loopback.\%s.tx.sent") | ||
243 | * @test_id: Test id (e.g. "PHY" for "loopback.PHY.tx_sent") | ||
244 | * | ||
245 | * Fill in an individual self-test entry. | ||
246 | */ | ||
247 | static void efx_fill_test(unsigned int test_index, | ||
248 | struct ethtool_string *strings, u64 *data, | ||
249 | int *test, const char *unit_format, int unit_id, | ||
250 | const char *test_format, const char *test_id) | ||
251 | { | ||
252 | struct ethtool_string unit_str, test_str; | ||
253 | |||
254 | /* Fill data value, if applicable */ | ||
255 | if (data) | ||
256 | data[test_index] = *test; | ||
257 | |||
258 | /* Fill string, if applicable */ | ||
259 | if (strings) { | ||
260 | snprintf(unit_str.name, sizeof(unit_str.name), | ||
261 | unit_format, unit_id); | ||
262 | snprintf(test_str.name, sizeof(test_str.name), | ||
263 | test_format, test_id); | ||
264 | snprintf(strings[test_index].name, | ||
265 | sizeof(strings[test_index].name), | ||
266 | "%-9s%-17s", unit_str.name, test_str.name); | ||
267 | } | ||
268 | } | ||
269 | |||
270 | #define EFX_PORT_NAME "port%d", 0 | ||
271 | #define EFX_CHANNEL_NAME(_channel) "channel%d", _channel->channel | ||
272 | #define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue | ||
273 | #define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue | ||
274 | #define EFX_LOOPBACK_NAME(_mode, _counter) \ | ||
275 | "loopback.%s." _counter, LOOPBACK_MODE_NAME(mode) | ||
276 | |||
277 | /** | ||
278 | * efx_fill_loopback_test - fill in a block of loopback self-test entries | ||
279 | * @efx: Efx NIC | ||
280 | * @lb_tests: Efx loopback self-test results structure | ||
281 | * @mode: Loopback test mode | ||
282 | * @test_index: Starting index of the test | ||
283 | * @strings: Ethtool strings, or %NULL | ||
284 | * @data: Ethtool test results, or %NULL | ||
285 | */ | ||
286 | static int efx_fill_loopback_test(struct efx_nic *efx, | ||
287 | struct efx_loopback_self_tests *lb_tests, | ||
288 | enum efx_loopback_mode mode, | ||
289 | unsigned int test_index, | ||
290 | struct ethtool_string *strings, u64 *data) | ||
291 | { | ||
292 | struct efx_tx_queue *tx_queue; | ||
293 | |||
294 | efx_for_each_tx_queue(tx_queue, efx) { | ||
295 | efx_fill_test(test_index++, strings, data, | ||
296 | &lb_tests->tx_sent[tx_queue->queue], | ||
297 | EFX_TX_QUEUE_NAME(tx_queue), | ||
298 | EFX_LOOPBACK_NAME(mode, "tx_sent")); | ||
299 | efx_fill_test(test_index++, strings, data, | ||
300 | &lb_tests->tx_done[tx_queue->queue], | ||
301 | EFX_TX_QUEUE_NAME(tx_queue), | ||
302 | EFX_LOOPBACK_NAME(mode, "tx_done")); | ||
303 | } | ||
304 | efx_fill_test(test_index++, strings, data, | ||
305 | &lb_tests->rx_good, | ||
306 | EFX_PORT_NAME, | ||
307 | EFX_LOOPBACK_NAME(mode, "rx_good")); | ||
308 | efx_fill_test(test_index++, strings, data, | ||
309 | &lb_tests->rx_bad, | ||
310 | EFX_PORT_NAME, | ||
311 | EFX_LOOPBACK_NAME(mode, "rx_bad")); | ||
312 | |||
313 | return test_index; | ||
314 | } | ||
315 | |||
316 | /** | ||
317 | * efx_ethtool_fill_self_tests - get self-test details | ||
318 | * @efx: Efx NIC | ||
319 | * @tests: Efx self-test results structure, or %NULL | ||
320 | * @strings: Ethtool strings, or %NULL | ||
321 | * @data: Ethtool test results, or %NULL | ||
322 | */ | ||
323 | static int efx_ethtool_fill_self_tests(struct efx_nic *efx, | ||
324 | struct efx_self_tests *tests, | ||
325 | struct ethtool_string *strings, | ||
326 | u64 *data) | ||
327 | { | ||
328 | struct efx_channel *channel; | ||
329 | unsigned int n = 0; | ||
330 | enum efx_loopback_mode mode; | ||
331 | |||
332 | /* Interrupt */ | ||
333 | efx_fill_test(n++, strings, data, &tests->interrupt, | ||
334 | "core", 0, "interrupt", NULL); | ||
335 | |||
336 | /* Event queues */ | ||
337 | efx_for_each_channel(channel, efx) { | ||
338 | efx_fill_test(n++, strings, data, | ||
339 | &tests->eventq_dma[channel->channel], | ||
340 | EFX_CHANNEL_NAME(channel), | ||
341 | "eventq.dma", NULL); | ||
342 | efx_fill_test(n++, strings, data, | ||
343 | &tests->eventq_int[channel->channel], | ||
344 | EFX_CHANNEL_NAME(channel), | ||
345 | "eventq.int", NULL); | ||
346 | efx_fill_test(n++, strings, data, | ||
347 | &tests->eventq_poll[channel->channel], | ||
348 | EFX_CHANNEL_NAME(channel), | ||
349 | "eventq.poll", NULL); | ||
350 | } | ||
351 | |||
352 | /* PHY presence */ | ||
353 | efx_fill_test(n++, strings, data, &tests->phy_ok, | ||
354 | EFX_PORT_NAME, "phy_ok", NULL); | ||
355 | |||
356 | /* Loopback tests */ | ||
357 | efx_fill_test(n++, strings, data, &tests->loopback_speed, | ||
358 | EFX_PORT_NAME, "loopback.speed", NULL); | ||
359 | efx_fill_test(n++, strings, data, &tests->loopback_full_duplex, | ||
360 | EFX_PORT_NAME, "loopback.full_duplex", NULL); | ||
361 | for (mode = LOOPBACK_NONE; mode < LOOPBACK_TEST_MAX; mode++) { | ||
362 | if (!(efx->loopback_modes & (1 << mode))) | ||
363 | continue; | ||
364 | n = efx_fill_loopback_test(efx, | ||
365 | &tests->loopback[mode], mode, n, | ||
366 | strings, data); | ||
367 | } | ||
368 | |||
369 | return n; | ||
370 | } | ||
371 | |||
220 | static int efx_ethtool_get_stats_count(struct net_device *net_dev) | 372 | static int efx_ethtool_get_stats_count(struct net_device *net_dev) |
221 | { | 373 | { |
222 | return EFX_ETHTOOL_NUM_STATS; | 374 | return EFX_ETHTOOL_NUM_STATS; |
223 | } | 375 | } |
224 | 376 | ||
377 | static int efx_ethtool_self_test_count(struct net_device *net_dev) | ||
378 | { | ||
379 | struct efx_nic *efx = net_dev->priv; | ||
380 | |||
381 | return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL); | ||
382 | } | ||
383 | |||
225 | static void efx_ethtool_get_strings(struct net_device *net_dev, | 384 | static void efx_ethtool_get_strings(struct net_device *net_dev, |
226 | u32 string_set, u8 *strings) | 385 | u32 string_set, u8 *strings) |
227 | { | 386 | { |
387 | struct efx_nic *efx = net_dev->priv; | ||
228 | struct ethtool_string *ethtool_strings = | 388 | struct ethtool_string *ethtool_strings = |
229 | (struct ethtool_string *)strings; | 389 | (struct ethtool_string *)strings; |
230 | int i; | 390 | int i; |
231 | 391 | ||
232 | if (string_set == ETH_SS_STATS) | 392 | switch (string_set) { |
393 | case ETH_SS_STATS: | ||
233 | for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) | 394 | for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) |
234 | strncpy(ethtool_strings[i].name, | 395 | strncpy(ethtool_strings[i].name, |
235 | efx_ethtool_stats[i].name, | 396 | efx_ethtool_stats[i].name, |
236 | sizeof(ethtool_strings[i].name)); | 397 | sizeof(ethtool_strings[i].name)); |
398 | break; | ||
399 | case ETH_SS_TEST: | ||
400 | efx_ethtool_fill_self_tests(efx, NULL, | ||
401 | ethtool_strings, NULL); | ||
402 | break; | ||
403 | default: | ||
404 | /* No other string sets */ | ||
405 | break; | ||
406 | } | ||
237 | } | 407 | } |
238 | 408 | ||
239 | static void efx_ethtool_get_stats(struct net_device *net_dev, | 409 | static void efx_ethtool_get_stats(struct net_device *net_dev, |
@@ -272,6 +442,22 @@ static void efx_ethtool_get_stats(struct net_device *net_dev, | |||
272 | } | 442 | } |
273 | } | 443 | } |
274 | 444 | ||
445 | static int efx_ethtool_set_tso(struct net_device *net_dev, u32 enable) | ||
446 | { | ||
447 | int rc; | ||
448 | |||
449 | /* Our TSO requires TX checksumming, so force TX checksumming | ||
450 | * on when TSO is enabled. | ||
451 | */ | ||
452 | if (enable) { | ||
453 | rc = efx_ethtool_set_tx_csum(net_dev, 1); | ||
454 | if (rc) | ||
455 | return rc; | ||
456 | } | ||
457 | |||
458 | return ethtool_op_set_tso(net_dev, enable); | ||
459 | } | ||
460 | |||
275 | static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable) | 461 | static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable) |
276 | { | 462 | { |
277 | struct efx_nic *efx = net_dev->priv; | 463 | struct efx_nic *efx = net_dev->priv; |
@@ -283,6 +469,15 @@ static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable) | |||
283 | 469 | ||
284 | efx_flush_queues(efx); | 470 | efx_flush_queues(efx); |
285 | 471 | ||
472 | /* Our TSO requires TX checksumming, so disable TSO when | ||
473 | * checksumming is disabled | ||
474 | */ | ||
475 | if (!enable) { | ||
476 | rc = efx_ethtool_set_tso(net_dev, 0); | ||
477 | if (rc) | ||
478 | return rc; | ||
479 | } | ||
480 | |||
286 | return 0; | 481 | return 0; |
287 | } | 482 | } |
288 | 483 | ||
@@ -305,6 +500,64 @@ static u32 efx_ethtool_get_rx_csum(struct net_device *net_dev) | |||
305 | return efx->rx_checksum_enabled; | 500 | return efx->rx_checksum_enabled; |
306 | } | 501 | } |
307 | 502 | ||
503 | static void efx_ethtool_self_test(struct net_device *net_dev, | ||
504 | struct ethtool_test *test, u64 *data) | ||
505 | { | ||
506 | struct efx_nic *efx = net_dev->priv; | ||
507 | struct efx_self_tests efx_tests; | ||
508 | int offline, already_up; | ||
509 | int rc; | ||
510 | |||
511 | ASSERT_RTNL(); | ||
512 | if (efx->state != STATE_RUNNING) { | ||
513 | rc = -EIO; | ||
514 | goto fail1; | ||
515 | } | ||
516 | |||
517 | /* We need rx buffers and interrupts. */ | ||
518 | already_up = (efx->net_dev->flags & IFF_UP); | ||
519 | if (!already_up) { | ||
520 | rc = dev_open(efx->net_dev); | ||
521 | if (rc) { | ||
522 | EFX_ERR(efx, "failed opening device.\n"); | ||
523 | goto fail2; | ||
524 | } | ||
525 | } | ||
526 | |||
527 | memset(&efx_tests, 0, sizeof(efx_tests)); | ||
528 | offline = (test->flags & ETH_TEST_FL_OFFLINE); | ||
529 | |||
530 | /* Perform online self tests first */ | ||
531 | rc = efx_online_test(efx, &efx_tests); | ||
532 | if (rc) | ||
533 | goto out; | ||
534 | |||
535 | /* Perform offline tests only if online tests passed */ | ||
536 | if (offline) { | ||
537 | /* Stop the kernel from sending packets during the test. */ | ||
538 | efx_stop_queue(efx); | ||
539 | rc = efx_flush_queues(efx); | ||
540 | if (!rc) | ||
541 | rc = efx_offline_test(efx, &efx_tests, | ||
542 | efx->loopback_modes); | ||
543 | efx_wake_queue(efx); | ||
544 | } | ||
545 | |||
546 | out: | ||
547 | if (!already_up) | ||
548 | dev_close(efx->net_dev); | ||
549 | |||
550 | EFX_LOG(efx, "%s all %sline self-tests\n", | ||
551 | rc == 0 ? "passed" : "failed", offline ? "off" : "on"); | ||
552 | |||
553 | fail2: | ||
554 | fail1: | ||
555 | /* Fill ethtool results structures */ | ||
556 | efx_ethtool_fill_self_tests(efx, &efx_tests, NULL, data); | ||
557 | if (rc) | ||
558 | test->flags |= ETH_TEST_FL_FAILED; | ||
559 | } | ||
560 | |||
308 | /* Restart autonegotiation */ | 561 | /* Restart autonegotiation */ |
309 | static int efx_ethtool_nway_reset(struct net_device *net_dev) | 562 | static int efx_ethtool_nway_reset(struct net_device *net_dev) |
310 | { | 563 | { |
@@ -451,8 +704,12 @@ struct ethtool_ops efx_ethtool_ops = { | |||
451 | .set_tx_csum = efx_ethtool_set_tx_csum, | 704 | .set_tx_csum = efx_ethtool_set_tx_csum, |
452 | .get_sg = ethtool_op_get_sg, | 705 | .get_sg = ethtool_op_get_sg, |
453 | .set_sg = ethtool_op_set_sg, | 706 | .set_sg = ethtool_op_set_sg, |
707 | .get_tso = ethtool_op_get_tso, | ||
708 | .set_tso = efx_ethtool_set_tso, | ||
454 | .get_flags = ethtool_op_get_flags, | 709 | .get_flags = ethtool_op_get_flags, |
455 | .set_flags = ethtool_op_set_flags, | 710 | .set_flags = ethtool_op_set_flags, |
711 | .self_test_count = efx_ethtool_self_test_count, | ||
712 | .self_test = efx_ethtool_self_test, | ||
456 | .get_strings = efx_ethtool_get_strings, | 713 | .get_strings = efx_ethtool_get_strings, |
457 | .phys_id = efx_ethtool_phys_id, | 714 | .phys_id = efx_ethtool_phys_id, |
458 | .get_stats_count = efx_ethtool_get_stats_count, | 715 | .get_stats_count = efx_ethtool_get_stats_count, |
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index 46db549ce580..b57cc68058c0 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -1129,6 +1129,7 @@ static void falcon_handle_driver_event(struct efx_channel *channel, | |||
1129 | case RX_RECOVERY_EV_DECODE: | 1129 | case RX_RECOVERY_EV_DECODE: |
1130 | EFX_ERR(efx, "channel %d seen DRIVER RX_RESET event. " | 1130 | EFX_ERR(efx, "channel %d seen DRIVER RX_RESET event. " |
1131 | "Resetting.\n", channel->channel); | 1131 | "Resetting.\n", channel->channel); |
1132 | atomic_inc(&efx->rx_reset); | ||
1132 | efx_schedule_reset(efx, | 1133 | efx_schedule_reset(efx, |
1133 | EFX_WORKAROUND_6555(efx) ? | 1134 | EFX_WORKAROUND_6555(efx) ? |
1134 | RESET_TYPE_RX_RECOVERY : | 1135 | RESET_TYPE_RX_RECOVERY : |
@@ -1731,7 +1732,8 @@ void falcon_drain_tx_fifo(struct efx_nic *efx) | |||
1731 | efx_oword_t temp; | 1732 | efx_oword_t temp; |
1732 | int count; | 1733 | int count; |
1733 | 1734 | ||
1734 | if (FALCON_REV(efx) < FALCON_REV_B0) | 1735 | if ((FALCON_REV(efx) < FALCON_REV_B0) || |
1736 | (efx->loopback_mode != LOOPBACK_NONE)) | ||
1735 | return; | 1737 | return; |
1736 | 1738 | ||
1737 | falcon_read(efx, &temp, MAC0_CTRL_REG_KER); | 1739 | falcon_read(efx, &temp, MAC0_CTRL_REG_KER); |
@@ -2091,6 +2093,8 @@ static int falcon_probe_phy(struct efx_nic *efx) | |||
2091 | efx->phy_type); | 2093 | efx->phy_type); |
2092 | return -1; | 2094 | return -1; |
2093 | } | 2095 | } |
2096 | |||
2097 | efx->loopback_modes = LOOPBACKS_10G_INTERNAL | efx->phy_op->loopbacks; | ||
2094 | return 0; | 2098 | return 0; |
2095 | } | 2099 | } |
2096 | 2100 | ||
@@ -2468,14 +2472,12 @@ int falcon_probe_nic(struct efx_nic *efx) | |||
2468 | fail5: | 2472 | fail5: |
2469 | falcon_free_buffer(efx, &efx->irq_status); | 2473 | falcon_free_buffer(efx, &efx->irq_status); |
2470 | fail4: | 2474 | fail4: |
2471 | /* fall-thru */ | ||
2472 | fail3: | 2475 | fail3: |
2473 | if (nic_data->pci_dev2) { | 2476 | if (nic_data->pci_dev2) { |
2474 | pci_dev_put(nic_data->pci_dev2); | 2477 | pci_dev_put(nic_data->pci_dev2); |
2475 | nic_data->pci_dev2 = NULL; | 2478 | nic_data->pci_dev2 = NULL; |
2476 | } | 2479 | } |
2477 | fail2: | 2480 | fail2: |
2478 | /* fall-thru */ | ||
2479 | fail1: | 2481 | fail1: |
2480 | kfree(efx->nic_data); | 2482 | kfree(efx->nic_data); |
2481 | return rc; | 2483 | return rc; |
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h index 0485a63eaff6..06e2d68fc3d1 100644 --- a/drivers/net/sfc/falcon_hwdefs.h +++ b/drivers/net/sfc/falcon_hwdefs.h | |||
@@ -636,6 +636,14 @@ | |||
636 | #define XX_HIDRVA_WIDTH 1 | 636 | #define XX_HIDRVA_WIDTH 1 |
637 | #define XX_LODRVA_LBN 8 | 637 | #define XX_LODRVA_LBN 8 |
638 | #define XX_LODRVA_WIDTH 1 | 638 | #define XX_LODRVA_WIDTH 1 |
639 | #define XX_LPBKD_LBN 3 | ||
640 | #define XX_LPBKD_WIDTH 1 | ||
641 | #define XX_LPBKC_LBN 2 | ||
642 | #define XX_LPBKC_WIDTH 1 | ||
643 | #define XX_LPBKB_LBN 1 | ||
644 | #define XX_LPBKB_WIDTH 1 | ||
645 | #define XX_LPBKA_LBN 0 | ||
646 | #define XX_LPBKA_WIDTH 1 | ||
639 | 647 | ||
640 | #define XX_TXDRV_CTL_REG_MAC 0x12 | 648 | #define XX_TXDRV_CTL_REG_MAC 0x12 |
641 | #define XX_DEQD_LBN 28 | 649 | #define XX_DEQD_LBN 28 |
@@ -656,8 +664,14 @@ | |||
656 | #define XX_DTXA_WIDTH 4 | 664 | #define XX_DTXA_WIDTH 4 |
657 | 665 | ||
658 | /* XAUI XGXS core status register */ | 666 | /* XAUI XGXS core status register */ |
659 | #define XX_FORCE_SIG_DECODE_FORCED 0xff | ||
660 | #define XX_CORE_STAT_REG_MAC 0x16 | 667 | #define XX_CORE_STAT_REG_MAC 0x16 |
668 | #define XX_FORCE_SIG_LBN 24 | ||
669 | #define XX_FORCE_SIG_WIDTH 8 | ||
670 | #define XX_FORCE_SIG_DECODE_FORCED 0xff | ||
671 | #define XX_XGXS_LB_EN_LBN 23 | ||
672 | #define XX_XGXS_LB_EN_WIDTH 1 | ||
673 | #define XX_XGMII_LB_EN_LBN 22 | ||
674 | #define XX_XGMII_LB_EN_WIDTH 1 | ||
661 | #define XX_ALIGN_DONE_LBN 20 | 675 | #define XX_ALIGN_DONE_LBN 20 |
662 | #define XX_ALIGN_DONE_WIDTH 1 | 676 | #define XX_ALIGN_DONE_WIDTH 1 |
663 | #define XX_SYNC_STAT_LBN 16 | 677 | #define XX_SYNC_STAT_LBN 16 |
diff --git a/drivers/net/sfc/falcon_xmac.c b/drivers/net/sfc/falcon_xmac.c index aa7521b24a5d..a74b7931a3c4 100644 --- a/drivers/net/sfc/falcon_xmac.c +++ b/drivers/net/sfc/falcon_xmac.c | |||
@@ -32,7 +32,7 @@ | |||
32 | (FALCON_XMAC_REGBANK + ((mac_reg) * FALCON_XMAC_REG_SIZE)) | 32 | (FALCON_XMAC_REGBANK + ((mac_reg) * FALCON_XMAC_REG_SIZE)) |
33 | 33 | ||
34 | void falcon_xmac_writel(struct efx_nic *efx, | 34 | void falcon_xmac_writel(struct efx_nic *efx, |
35 | efx_dword_t *value, unsigned int mac_reg) | 35 | efx_dword_t *value, unsigned int mac_reg) |
36 | { | 36 | { |
37 | efx_oword_t temp; | 37 | efx_oword_t temp; |
38 | 38 | ||
@@ -69,6 +69,10 @@ static int falcon_reset_xmac(struct efx_nic *efx) | |||
69 | udelay(10); | 69 | udelay(10); |
70 | } | 70 | } |
71 | 71 | ||
72 | /* This often fails when DSP is disabled, ignore it */ | ||
73 | if (sfe4001_phy_flash_cfg != 0) | ||
74 | return 0; | ||
75 | |||
72 | EFX_ERR(efx, "timed out waiting for XMAC core reset\n"); | 76 | EFX_ERR(efx, "timed out waiting for XMAC core reset\n"); |
73 | return -ETIMEDOUT; | 77 | return -ETIMEDOUT; |
74 | } | 78 | } |
@@ -223,7 +227,7 @@ static int falcon_xgmii_status(struct efx_nic *efx) | |||
223 | /* The ISR latches, so clear it and re-read */ | 227 | /* The ISR latches, so clear it and re-read */ |
224 | falcon_xmac_readl(efx, ®, XM_MGT_INT_REG_MAC_B0); | 228 | falcon_xmac_readl(efx, ®, XM_MGT_INT_REG_MAC_B0); |
225 | falcon_xmac_readl(efx, ®, XM_MGT_INT_REG_MAC_B0); | 229 | falcon_xmac_readl(efx, ®, XM_MGT_INT_REG_MAC_B0); |
226 | 230 | ||
227 | if (EFX_DWORD_FIELD(reg, XM_LCLFLT) || | 231 | if (EFX_DWORD_FIELD(reg, XM_LCLFLT) || |
228 | EFX_DWORD_FIELD(reg, XM_RMTFLT)) { | 232 | EFX_DWORD_FIELD(reg, XM_RMTFLT)) { |
229 | EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg)); | 233 | EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg)); |
@@ -237,7 +241,7 @@ static void falcon_mask_status_intr(struct efx_nic *efx, int enable) | |||
237 | { | 241 | { |
238 | efx_dword_t reg; | 242 | efx_dword_t reg; |
239 | 243 | ||
240 | if (FALCON_REV(efx) < FALCON_REV_B0) | 244 | if ((FALCON_REV(efx) < FALCON_REV_B0) || LOOPBACK_INTERNAL(efx)) |
241 | return; | 245 | return; |
242 | 246 | ||
243 | /* Flush the ISR */ | 247 | /* Flush the ISR */ |
@@ -284,6 +288,9 @@ int falcon_xaui_link_ok(struct efx_nic *efx) | |||
284 | efx_dword_t reg; | 288 | efx_dword_t reg; |
285 | int align_done, sync_status, link_ok = 0; | 289 | int align_done, sync_status, link_ok = 0; |
286 | 290 | ||
291 | if (LOOPBACK_INTERNAL(efx)) | ||
292 | return 1; | ||
293 | |||
287 | /* Read link status */ | 294 | /* Read link status */ |
288 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); | 295 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); |
289 | 296 | ||
@@ -374,6 +381,61 @@ static void falcon_reconfigure_xmac_core(struct efx_nic *efx) | |||
374 | falcon_xmac_writel(efx, ®, XM_ADR_HI_REG_MAC); | 381 | falcon_xmac_writel(efx, ®, XM_ADR_HI_REG_MAC); |
375 | } | 382 | } |
376 | 383 | ||
384 | static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) | ||
385 | { | ||
386 | efx_dword_t reg; | ||
387 | int xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS) ? 1 : 0; | ||
388 | int xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI) ? 1 : 0; | ||
389 | int xgmii_loopback = | ||
390 | (efx->loopback_mode == LOOPBACK_XGMII) ? 1 : 0; | ||
391 | |||
392 | /* XGXS block is flaky and will need to be reset if moving | ||
393 | * into our out of XGMII, XGXS or XAUI loopbacks. */ | ||
394 | if (EFX_WORKAROUND_5147(efx)) { | ||
395 | int old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback; | ||
396 | int reset_xgxs; | ||
397 | |||
398 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); | ||
399 | old_xgxs_loopback = EFX_DWORD_FIELD(reg, XX_XGXS_LB_EN); | ||
400 | old_xgmii_loopback = EFX_DWORD_FIELD(reg, XX_XGMII_LB_EN); | ||
401 | |||
402 | falcon_xmac_readl(efx, ®, XX_SD_CTL_REG_MAC); | ||
403 | old_xaui_loopback = EFX_DWORD_FIELD(reg, XX_LPBKA); | ||
404 | |||
405 | /* The PHY driver may have turned XAUI off */ | ||
406 | reset_xgxs = ((xgxs_loopback != old_xgxs_loopback) || | ||
407 | (xaui_loopback != old_xaui_loopback) || | ||
408 | (xgmii_loopback != old_xgmii_loopback)); | ||
409 | if (reset_xgxs) { | ||
410 | falcon_xmac_readl(efx, ®, XX_PWR_RST_REG_MAC); | ||
411 | EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSTX_EN, 1); | ||
412 | EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSRX_EN, 1); | ||
413 | falcon_xmac_writel(efx, ®, XX_PWR_RST_REG_MAC); | ||
414 | udelay(1); | ||
415 | EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSTX_EN, 0); | ||
416 | EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSRX_EN, 0); | ||
417 | falcon_xmac_writel(efx, ®, XX_PWR_RST_REG_MAC); | ||
418 | udelay(1); | ||
419 | } | ||
420 | } | ||
421 | |||
422 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); | ||
423 | EFX_SET_DWORD_FIELD(reg, XX_FORCE_SIG, | ||
424 | (xgxs_loopback || xaui_loopback) ? | ||
425 | XX_FORCE_SIG_DECODE_FORCED : 0); | ||
426 | EFX_SET_DWORD_FIELD(reg, XX_XGXS_LB_EN, xgxs_loopback); | ||
427 | EFX_SET_DWORD_FIELD(reg, XX_XGMII_LB_EN, xgmii_loopback); | ||
428 | falcon_xmac_writel(efx, ®, XX_CORE_STAT_REG_MAC); | ||
429 | |||
430 | falcon_xmac_readl(efx, ®, XX_SD_CTL_REG_MAC); | ||
431 | EFX_SET_DWORD_FIELD(reg, XX_LPBKD, xaui_loopback); | ||
432 | EFX_SET_DWORD_FIELD(reg, XX_LPBKC, xaui_loopback); | ||
433 | EFX_SET_DWORD_FIELD(reg, XX_LPBKB, xaui_loopback); | ||
434 | EFX_SET_DWORD_FIELD(reg, XX_LPBKA, xaui_loopback); | ||
435 | falcon_xmac_writel(efx, ®, XX_SD_CTL_REG_MAC); | ||
436 | } | ||
437 | |||
438 | |||
377 | /* Try and bring the Falcon side of the Falcon-Phy XAUI link fails | 439 | /* Try and bring the Falcon side of the Falcon-Phy XAUI link fails |
378 | * to come back up. Bash it until it comes back up */ | 440 | * to come back up. Bash it until it comes back up */ |
379 | static int falcon_check_xaui_link_up(struct efx_nic *efx) | 441 | static int falcon_check_xaui_link_up(struct efx_nic *efx) |
@@ -382,7 +444,8 @@ static int falcon_check_xaui_link_up(struct efx_nic *efx) | |||
382 | tries = EFX_WORKAROUND_5147(efx) ? 5 : 1; | 444 | tries = EFX_WORKAROUND_5147(efx) ? 5 : 1; |
383 | max_tries = tries; | 445 | max_tries = tries; |
384 | 446 | ||
385 | if (efx->phy_type == PHY_TYPE_NONE) | 447 | if ((efx->loopback_mode == LOOPBACK_NETWORK) || |
448 | (efx->phy_type == PHY_TYPE_NONE)) | ||
386 | return 0; | 449 | return 0; |
387 | 450 | ||
388 | while (tries) { | 451 | while (tries) { |
@@ -408,8 +471,13 @@ void falcon_reconfigure_xmac(struct efx_nic *efx) | |||
408 | falcon_mask_status_intr(efx, 0); | 471 | falcon_mask_status_intr(efx, 0); |
409 | 472 | ||
410 | falcon_deconfigure_mac_wrapper(efx); | 473 | falcon_deconfigure_mac_wrapper(efx); |
474 | |||
475 | efx->tx_disabled = LOOPBACK_INTERNAL(efx); | ||
411 | efx->phy_op->reconfigure(efx); | 476 | efx->phy_op->reconfigure(efx); |
477 | |||
478 | falcon_reconfigure_xgxs_core(efx); | ||
412 | falcon_reconfigure_xmac_core(efx); | 479 | falcon_reconfigure_xmac_core(efx); |
480 | |||
413 | falcon_reconfigure_mac_wrapper(efx); | 481 | falcon_reconfigure_mac_wrapper(efx); |
414 | 482 | ||
415 | /* Ensure XAUI link is up */ | 483 | /* Ensure XAUI link is up */ |
@@ -491,13 +559,15 @@ void falcon_update_stats_xmac(struct efx_nic *efx) | |||
491 | (mac_stats->rx_bytes - mac_stats->rx_good_bytes); | 559 | (mac_stats->rx_bytes - mac_stats->rx_good_bytes); |
492 | } | 560 | } |
493 | 561 | ||
494 | #define EFX_XAUI_RETRAIN_MAX 8 | ||
495 | |||
496 | int falcon_check_xmac(struct efx_nic *efx) | 562 | int falcon_check_xmac(struct efx_nic *efx) |
497 | { | 563 | { |
498 | unsigned xaui_link_ok; | 564 | unsigned xaui_link_ok; |
499 | int rc; | 565 | int rc; |
500 | 566 | ||
567 | if ((efx->loopback_mode == LOOPBACK_NETWORK) || | ||
568 | (efx->phy_type == PHY_TYPE_NONE)) | ||
569 | return 0; | ||
570 | |||
501 | falcon_mask_status_intr(efx, 0); | 571 | falcon_mask_status_intr(efx, 0); |
502 | xaui_link_ok = falcon_xaui_link_ok(efx); | 572 | xaui_link_ok = falcon_xaui_link_ok(efx); |
503 | 573 | ||
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c index dc06bb0aa575..c4f540e93b79 100644 --- a/drivers/net/sfc/mdio_10g.c +++ b/drivers/net/sfc/mdio_10g.c | |||
@@ -44,6 +44,9 @@ static int mdio_clause45_check_mmd(struct efx_nic *efx, int mmd, | |||
44 | int status; | 44 | int status; |
45 | int phy_id = efx->mii.phy_id; | 45 | int phy_id = efx->mii.phy_id; |
46 | 46 | ||
47 | if (LOOPBACK_INTERNAL(efx)) | ||
48 | return 0; | ||
49 | |||
47 | /* Read MMD STATUS2 to check it is responding. */ | 50 | /* Read MMD STATUS2 to check it is responding. */ |
48 | status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT2); | 51 | status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT2); |
49 | if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) & | 52 | if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) & |
@@ -164,6 +167,22 @@ int mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask) | |||
164 | int mmd = 0; | 167 | int mmd = 0; |
165 | int good; | 168 | int good; |
166 | 169 | ||
170 | /* If the port is in loopback, then we should only consider a subset | ||
171 | * of mmd's */ | ||
172 | if (LOOPBACK_INTERNAL(efx)) | ||
173 | return 1; | ||
174 | else if (efx->loopback_mode == LOOPBACK_NETWORK) | ||
175 | return 0; | ||
176 | else if (efx->loopback_mode == LOOPBACK_PHYXS) | ||
177 | mmd_mask &= ~(MDIO_MMDREG_DEVS0_PHYXS | | ||
178 | MDIO_MMDREG_DEVS0_PCS | | ||
179 | MDIO_MMDREG_DEVS0_PMAPMD); | ||
180 | else if (efx->loopback_mode == LOOPBACK_PCS) | ||
181 | mmd_mask &= ~(MDIO_MMDREG_DEVS0_PCS | | ||
182 | MDIO_MMDREG_DEVS0_PMAPMD); | ||
183 | else if (efx->loopback_mode == LOOPBACK_PMAPMD) | ||
184 | mmd_mask &= ~MDIO_MMDREG_DEVS0_PMAPMD; | ||
185 | |||
167 | while (mmd_mask) { | 186 | while (mmd_mask) { |
168 | if (mmd_mask & 1) { | 187 | if (mmd_mask & 1) { |
169 | /* Double reads because link state is latched, and a | 188 | /* Double reads because link state is latched, and a |
@@ -182,6 +201,65 @@ int mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask) | |||
182 | return ok; | 201 | return ok; |
183 | } | 202 | } |
184 | 203 | ||
204 | void mdio_clause45_transmit_disable(struct efx_nic *efx) | ||
205 | { | ||
206 | int phy_id = efx->mii.phy_id; | ||
207 | int ctrl1, ctrl2; | ||
208 | |||
209 | ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, | ||
210 | MDIO_MMDREG_TXDIS); | ||
211 | if (efx->tx_disabled) | ||
212 | ctrl2 |= (1 << MDIO_MMDREG_TXDIS_GLOBAL_LBN); | ||
213 | else | ||
214 | ctrl1 &= ~(1 << MDIO_MMDREG_TXDIS_GLOBAL_LBN); | ||
215 | if (ctrl1 != ctrl2) | ||
216 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, | ||
217 | MDIO_MMDREG_TXDIS, ctrl2); | ||
218 | } | ||
219 | |||
220 | void mdio_clause45_phy_reconfigure(struct efx_nic *efx) | ||
221 | { | ||
222 | int phy_id = efx->mii.phy_id; | ||
223 | int ctrl1, ctrl2; | ||
224 | |||
225 | /* Handle (with debouncing) PMA/PMD loopback */ | ||
226 | ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, | ||
227 | MDIO_MMDREG_CTRL1); | ||
228 | |||
229 | if (efx->loopback_mode == LOOPBACK_PMAPMD) | ||
230 | ctrl2 |= (1 << MDIO_PMAPMD_CTRL1_LBACK_LBN); | ||
231 | else | ||
232 | ctrl2 &= ~(1 << MDIO_PMAPMD_CTRL1_LBACK_LBN); | ||
233 | |||
234 | if (ctrl1 != ctrl2) | ||
235 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, | ||
236 | MDIO_MMDREG_CTRL1, ctrl2); | ||
237 | |||
238 | /* Handle (with debouncing) PCS loopback */ | ||
239 | ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS, | ||
240 | MDIO_MMDREG_CTRL1); | ||
241 | if (efx->loopback_mode == LOOPBACK_PCS) | ||
242 | ctrl2 |= (1 << MDIO_MMDREG_CTRL1_LBACK_LBN); | ||
243 | else | ||
244 | ctrl2 &= ~(1 << MDIO_MMDREG_CTRL1_LBACK_LBN); | ||
245 | |||
246 | if (ctrl1 != ctrl2) | ||
247 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PCS, | ||
248 | MDIO_MMDREG_CTRL1, ctrl2); | ||
249 | |||
250 | /* Handle (with debouncing) PHYXS network loopback */ | ||
251 | ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS, | ||
252 | MDIO_MMDREG_CTRL1); | ||
253 | if (efx->loopback_mode == LOOPBACK_NETWORK) | ||
254 | ctrl2 |= (1 << MDIO_MMDREG_CTRL1_LBACK_LBN); | ||
255 | else | ||
256 | ctrl2 &= ~(1 << MDIO_MMDREG_CTRL1_LBACK_LBN); | ||
257 | |||
258 | if (ctrl1 != ctrl2) | ||
259 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PHYXS, | ||
260 | MDIO_MMDREG_CTRL1, ctrl2); | ||
261 | } | ||
262 | |||
185 | /** | 263 | /** |
186 | * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO. | 264 | * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO. |
187 | * @efx: Efx NIC | 265 | * @efx: Efx NIC |
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h index 2214b6d820a7..cb99f3f4491c 100644 --- a/drivers/net/sfc/mdio_10g.h +++ b/drivers/net/sfc/mdio_10g.h | |||
@@ -44,11 +44,16 @@ | |||
44 | #define MDIO_MMDREG_DEVS1 (6) | 44 | #define MDIO_MMDREG_DEVS1 (6) |
45 | #define MDIO_MMDREG_CTRL2 (7) | 45 | #define MDIO_MMDREG_CTRL2 (7) |
46 | #define MDIO_MMDREG_STAT2 (8) | 46 | #define MDIO_MMDREG_STAT2 (8) |
47 | #define MDIO_MMDREG_TXDIS (9) | ||
47 | 48 | ||
48 | /* Bits in MMDREG_CTRL1 */ | 49 | /* Bits in MMDREG_CTRL1 */ |
49 | /* Reset */ | 50 | /* Reset */ |
50 | #define MDIO_MMDREG_CTRL1_RESET_LBN (15) | 51 | #define MDIO_MMDREG_CTRL1_RESET_LBN (15) |
51 | #define MDIO_MMDREG_CTRL1_RESET_WIDTH (1) | 52 | #define MDIO_MMDREG_CTRL1_RESET_WIDTH (1) |
53 | /* Loopback */ | ||
54 | /* Loopback bit for WIS, PCS, PHYSX and DTEXS */ | ||
55 | #define MDIO_MMDREG_CTRL1_LBACK_LBN (14) | ||
56 | #define MDIO_MMDREG_CTRL1_LBACK_WIDTH (1) | ||
52 | 57 | ||
53 | /* Bits in MMDREG_STAT1 */ | 58 | /* Bits in MMDREG_STAT1 */ |
54 | #define MDIO_MMDREG_STAT1_FAULT_LBN (7) | 59 | #define MDIO_MMDREG_STAT1_FAULT_LBN (7) |
@@ -56,6 +61,9 @@ | |||
56 | /* Link state */ | 61 | /* Link state */ |
57 | #define MDIO_MMDREG_STAT1_LINK_LBN (2) | 62 | #define MDIO_MMDREG_STAT1_LINK_LBN (2) |
58 | #define MDIO_MMDREG_STAT1_LINK_WIDTH (1) | 63 | #define MDIO_MMDREG_STAT1_LINK_WIDTH (1) |
64 | /* Low power ability */ | ||
65 | #define MDIO_MMDREG_STAT1_LPABLE_LBN (1) | ||
66 | #define MDIO_MMDREG_STAT1_LPABLE_WIDTH (1) | ||
59 | 67 | ||
60 | /* Bits in ID reg */ | 68 | /* Bits in ID reg */ |
61 | #define MDIO_ID_REV(_id32) (_id32 & 0xf) | 69 | #define MDIO_ID_REV(_id32) (_id32 & 0xf) |
@@ -76,6 +84,14 @@ | |||
76 | #define MDIO_MMDREG_STAT2_PRESENT_LBN (14) | 84 | #define MDIO_MMDREG_STAT2_PRESENT_LBN (14) |
77 | #define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2) | 85 | #define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2) |
78 | 86 | ||
87 | /* Bits in MMDREG_TXDIS */ | ||
88 | #define MDIO_MMDREG_TXDIS_GLOBAL_LBN (0) | ||
89 | #define MDIO_MMDREG_TXDIS_GLOBAL_WIDTH (1) | ||
90 | |||
91 | /* MMD-specific bits, ordered by MMD, then register */ | ||
92 | #define MDIO_PMAPMD_CTRL1_LBACK_LBN (0) | ||
93 | #define MDIO_PMAPMD_CTRL1_LBACK_WIDTH (1) | ||
94 | |||
79 | /* PMA type (4 bits) */ | 95 | /* PMA type (4 bits) */ |
80 | #define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0) | 96 | #define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0) |
81 | #define MDIO_PMAPMD_CTRL2_10G_EW (0x1) | 97 | #define MDIO_PMAPMD_CTRL2_10G_EW (0x1) |
@@ -95,7 +111,7 @@ | |||
95 | #define MDIO_PMAPMD_CTRL2_10_BT (0xf) | 111 | #define MDIO_PMAPMD_CTRL2_10_BT (0xf) |
96 | #define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf) | 112 | #define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf) |
97 | 113 | ||
98 | /* /\* PHY XGXS lane state *\/ */ | 114 | /* PHY XGXS lane state */ |
99 | #define MDIO_PHYXS_LANE_STATE (0x18) | 115 | #define MDIO_PHYXS_LANE_STATE (0x18) |
100 | #define MDIO_PHYXS_LANE_ALIGNED_LBN (12) | 116 | #define MDIO_PHYXS_LANE_ALIGNED_LBN (12) |
101 | 117 | ||
@@ -217,6 +233,12 @@ int mdio_clause45_check_mmds(struct efx_nic *efx, | |||
217 | extern int mdio_clause45_links_ok(struct efx_nic *efx, | 233 | extern int mdio_clause45_links_ok(struct efx_nic *efx, |
218 | unsigned int mmd_mask); | 234 | unsigned int mmd_mask); |
219 | 235 | ||
236 | /* Generic transmit disable support though PMAPMD */ | ||
237 | extern void mdio_clause45_transmit_disable(struct efx_nic *efx); | ||
238 | |||
239 | /* Generic part of reconfigure: set/clear loopback bits */ | ||
240 | extern void mdio_clause45_phy_reconfigure(struct efx_nic *efx); | ||
241 | |||
220 | /* Read (some of) the PHY settings over MDIO */ | 242 | /* Read (some of) the PHY settings over MDIO */ |
221 | extern void mdio_clause45_get_settings(struct efx_nic *efx, | 243 | extern void mdio_clause45_get_settings(struct efx_nic *efx, |
222 | struct ethtool_cmd *ecmd); | 244 | struct ethtool_cmd *ecmd); |
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h index c505482c2520..59f261b4171f 100644 --- a/drivers/net/sfc/net_driver.h +++ b/drivers/net/sfc/net_driver.h | |||
@@ -134,6 +134,8 @@ struct efx_special_buffer { | |||
134 | * Set only on the final fragment of a packet; %NULL for all other | 134 | * Set only on the final fragment of a packet; %NULL for all other |
135 | * fragments. When this fragment completes, then we can free this | 135 | * fragments. When this fragment completes, then we can free this |
136 | * skb. | 136 | * skb. |
137 | * @tsoh: The associated TSO header structure, or %NULL if this | ||
138 | * buffer is not a TSO header. | ||
137 | * @dma_addr: DMA address of the fragment. | 139 | * @dma_addr: DMA address of the fragment. |
138 | * @len: Length of this fragment. | 140 | * @len: Length of this fragment. |
139 | * This field is zero when the queue slot is empty. | 141 | * This field is zero when the queue slot is empty. |
@@ -144,6 +146,7 @@ struct efx_special_buffer { | |||
144 | */ | 146 | */ |
145 | struct efx_tx_buffer { | 147 | struct efx_tx_buffer { |
146 | const struct sk_buff *skb; | 148 | const struct sk_buff *skb; |
149 | struct efx_tso_header *tsoh; | ||
147 | dma_addr_t dma_addr; | 150 | dma_addr_t dma_addr; |
148 | unsigned short len; | 151 | unsigned short len; |
149 | unsigned char continuation; | 152 | unsigned char continuation; |
@@ -187,6 +190,13 @@ struct efx_tx_buffer { | |||
187 | * variable indicates that the queue is full. This is to | 190 | * variable indicates that the queue is full. This is to |
188 | * avoid cache-line ping-pong between the xmit path and the | 191 | * avoid cache-line ping-pong between the xmit path and the |
189 | * completion path. | 192 | * completion path. |
193 | * @tso_headers_free: A list of TSO headers allocated for this TX queue | ||
194 | * that are not in use, and so available for new TSO sends. The list | ||
195 | * is protected by the TX queue lock. | ||
196 | * @tso_bursts: Number of times TSO xmit invoked by kernel | ||
197 | * @tso_long_headers: Number of packets with headers too long for standard | ||
198 | * blocks | ||
199 | * @tso_packets: Number of packets via the TSO xmit path | ||
190 | */ | 200 | */ |
191 | struct efx_tx_queue { | 201 | struct efx_tx_queue { |
192 | /* Members which don't change on the fast path */ | 202 | /* Members which don't change on the fast path */ |
@@ -206,6 +216,10 @@ struct efx_tx_queue { | |||
206 | unsigned int insert_count ____cacheline_aligned_in_smp; | 216 | unsigned int insert_count ____cacheline_aligned_in_smp; |
207 | unsigned int write_count; | 217 | unsigned int write_count; |
208 | unsigned int old_read_count; | 218 | unsigned int old_read_count; |
219 | struct efx_tso_header *tso_headers_free; | ||
220 | unsigned int tso_bursts; | ||
221 | unsigned int tso_long_headers; | ||
222 | unsigned int tso_packets; | ||
209 | }; | 223 | }; |
210 | 224 | ||
211 | /** | 225 | /** |
@@ -434,6 +448,9 @@ struct efx_board { | |||
434 | struct efx_blinker blinker; | 448 | struct efx_blinker blinker; |
435 | }; | 449 | }; |
436 | 450 | ||
451 | #define STRING_TABLE_LOOKUP(val, member) \ | ||
452 | member ## _names[val] | ||
453 | |||
437 | enum efx_int_mode { | 454 | enum efx_int_mode { |
438 | /* Be careful if altering to correct macro below */ | 455 | /* Be careful if altering to correct macro below */ |
439 | EFX_INT_MODE_MSIX = 0, | 456 | EFX_INT_MODE_MSIX = 0, |
@@ -506,6 +523,7 @@ enum efx_fc_type { | |||
506 | * @check_hw: Check hardware | 523 | * @check_hw: Check hardware |
507 | * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset) | 524 | * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset) |
508 | * @mmds: MMD presence mask | 525 | * @mmds: MMD presence mask |
526 | * @loopbacks: Supported loopback modes mask | ||
509 | */ | 527 | */ |
510 | struct efx_phy_operations { | 528 | struct efx_phy_operations { |
511 | int (*init) (struct efx_nic *efx); | 529 | int (*init) (struct efx_nic *efx); |
@@ -515,6 +533,7 @@ struct efx_phy_operations { | |||
515 | int (*check_hw) (struct efx_nic *efx); | 533 | int (*check_hw) (struct efx_nic *efx); |
516 | void (*reset_xaui) (struct efx_nic *efx); | 534 | void (*reset_xaui) (struct efx_nic *efx); |
517 | int mmds; | 535 | int mmds; |
536 | unsigned loopbacks; | ||
518 | }; | 537 | }; |
519 | 538 | ||
520 | /* | 539 | /* |
@@ -653,7 +672,6 @@ union efx_multicast_hash { | |||
653 | * @phy_op: PHY interface | 672 | * @phy_op: PHY interface |
654 | * @phy_data: PHY private data (including PHY-specific stats) | 673 | * @phy_data: PHY private data (including PHY-specific stats) |
655 | * @mii: PHY interface | 674 | * @mii: PHY interface |
656 | * @phy_powered: PHY power state | ||
657 | * @tx_disabled: PHY transmitter turned off | 675 | * @tx_disabled: PHY transmitter turned off |
658 | * @link_up: Link status | 676 | * @link_up: Link status |
659 | * @link_options: Link options (MII/GMII format) | 677 | * @link_options: Link options (MII/GMII format) |
@@ -662,6 +680,9 @@ union efx_multicast_hash { | |||
662 | * @multicast_hash: Multicast hash table | 680 | * @multicast_hash: Multicast hash table |
663 | * @flow_control: Flow control flags - separate RX/TX so can't use link_options | 681 | * @flow_control: Flow control flags - separate RX/TX so can't use link_options |
664 | * @reconfigure_work: work item for dealing with PHY events | 682 | * @reconfigure_work: work item for dealing with PHY events |
683 | * @loopback_mode: Loopback status | ||
684 | * @loopback_modes: Supported loopback mode bitmask | ||
685 | * @loopback_selftest: Offline self-test private state | ||
665 | * | 686 | * |
666 | * The @priv field of the corresponding &struct net_device points to | 687 | * The @priv field of the corresponding &struct net_device points to |
667 | * this. | 688 | * this. |
@@ -721,6 +742,7 @@ struct efx_nic { | |||
721 | struct efx_phy_operations *phy_op; | 742 | struct efx_phy_operations *phy_op; |
722 | void *phy_data; | 743 | void *phy_data; |
723 | struct mii_if_info mii; | 744 | struct mii_if_info mii; |
745 | unsigned tx_disabled; | ||
724 | 746 | ||
725 | int link_up; | 747 | int link_up; |
726 | unsigned int link_options; | 748 | unsigned int link_options; |
@@ -732,6 +754,10 @@ struct efx_nic { | |||
732 | struct work_struct reconfigure_work; | 754 | struct work_struct reconfigure_work; |
733 | 755 | ||
734 | atomic_t rx_reset; | 756 | atomic_t rx_reset; |
757 | enum efx_loopback_mode loopback_mode; | ||
758 | unsigned int loopback_modes; | ||
759 | |||
760 | void *loopback_selftest; | ||
735 | }; | 761 | }; |
736 | 762 | ||
737 | /** | 763 | /** |
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c index 551299b462ae..670622373ddf 100644 --- a/drivers/net/sfc/rx.c +++ b/drivers/net/sfc/rx.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "rx.h" | 19 | #include "rx.h" |
20 | #include "efx.h" | 20 | #include "efx.h" |
21 | #include "falcon.h" | 21 | #include "falcon.h" |
22 | #include "selftest.h" | ||
22 | #include "workarounds.h" | 23 | #include "workarounds.h" |
23 | 24 | ||
24 | /* Number of RX descriptors pushed at once. */ | 25 | /* Number of RX descriptors pushed at once. */ |
@@ -683,6 +684,15 @@ void __efx_rx_packet(struct efx_channel *channel, | |||
683 | struct sk_buff *skb; | 684 | struct sk_buff *skb; |
684 | int lro = efx->net_dev->features & NETIF_F_LRO; | 685 | int lro = efx->net_dev->features & NETIF_F_LRO; |
685 | 686 | ||
687 | /* If we're in loopback test, then pass the packet directly to the | ||
688 | * loopback layer, and free the rx_buf here | ||
689 | */ | ||
690 | if (unlikely(efx->loopback_selftest)) { | ||
691 | efx_loopback_rx_packet(efx, rx_buf->data, rx_buf->len); | ||
692 | efx_free_rx_buffer(efx, rx_buf); | ||
693 | goto done; | ||
694 | } | ||
695 | |||
686 | if (rx_buf->skb) { | 696 | if (rx_buf->skb) { |
687 | prefetch(skb_shinfo(rx_buf->skb)); | 697 | prefetch(skb_shinfo(rx_buf->skb)); |
688 | 698 | ||
@@ -736,7 +746,6 @@ void __efx_rx_packet(struct efx_channel *channel, | |||
736 | /* Update allocation strategy method */ | 746 | /* Update allocation strategy method */ |
737 | channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; | 747 | channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; |
738 | 748 | ||
739 | /* fall-thru */ | ||
740 | done: | 749 | done: |
741 | efx->net_dev->last_rx = jiffies; | 750 | efx->net_dev->last_rx = jiffies; |
742 | } | 751 | } |
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c new file mode 100644 index 000000000000..cbda15946e8f --- /dev/null +++ b/drivers/net/sfc/selftest.c | |||
@@ -0,0 +1,717 @@ | |||
1 | /**************************************************************************** | ||
2 | * Driver for Solarflare Solarstorm network controllers and boards | ||
3 | * Copyright 2005-2006 Fen Systems Ltd. | ||
4 | * Copyright 2006-2008 Solarflare Communications Inc. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published | ||
8 | * by the Free Software Foundation, incorporated herein by reference. | ||
9 | */ | ||
10 | |||
11 | #include <linux/netdevice.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/delay.h> | ||
14 | #include <linux/kernel_stat.h> | ||
15 | #include <linux/pci.h> | ||
16 | #include <linux/ethtool.h> | ||
17 | #include <linux/ip.h> | ||
18 | #include <linux/in.h> | ||
19 | #include <linux/udp.h> | ||
20 | #include <linux/rtnetlink.h> | ||
21 | #include <asm/io.h> | ||
22 | #include "net_driver.h" | ||
23 | #include "ethtool.h" | ||
24 | #include "efx.h" | ||
25 | #include "falcon.h" | ||
26 | #include "selftest.h" | ||
27 | #include "boards.h" | ||
28 | #include "workarounds.h" | ||
29 | #include "mac.h" | ||
30 | |||
31 | /* | ||
32 | * Loopback test packet structure | ||
33 | * | ||
34 | * The self-test should stress every RSS vector, and unfortunately | ||
35 | * Falcon only performs RSS on TCP/UDP packets. | ||
36 | */ | ||
37 | struct efx_loopback_payload { | ||
38 | struct ethhdr header; | ||
39 | struct iphdr ip; | ||
40 | struct udphdr udp; | ||
41 | __be16 iteration; | ||
42 | const char msg[64]; | ||
43 | } __attribute__ ((packed)); | ||
44 | |||
45 | /* Loopback test source MAC address */ | ||
46 | static const unsigned char payload_source[ETH_ALEN] = { | ||
47 | 0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b, | ||
48 | }; | ||
49 | |||
50 | static const char *payload_msg = | ||
51 | "Hello world! This is an Efx loopback test in progress!"; | ||
52 | |||
53 | /** | ||
54 | * efx_selftest_state - persistent state during a selftest | ||
55 | * @flush: Drop all packets in efx_loopback_rx_packet | ||
56 | * @packet_count: Number of packets being used in this test | ||
57 | * @skbs: An array of skbs transmitted | ||
58 | * @rx_good: RX good packet count | ||
59 | * @rx_bad: RX bad packet count | ||
60 | * @payload: Payload used in tests | ||
61 | */ | ||
62 | struct efx_selftest_state { | ||
63 | int flush; | ||
64 | int packet_count; | ||
65 | struct sk_buff **skbs; | ||
66 | atomic_t rx_good; | ||
67 | atomic_t rx_bad; | ||
68 | struct efx_loopback_payload payload; | ||
69 | }; | ||
70 | |||
71 | /************************************************************************** | ||
72 | * | ||
73 | * Configurable values | ||
74 | * | ||
75 | **************************************************************************/ | ||
76 | |||
77 | /* Level of loopback testing | ||
78 | * | ||
79 | * The maximum packet burst length is 16**(n-1), i.e. | ||
80 | * | ||
81 | * - Level 0 : no packets | ||
82 | * - Level 1 : 1 packet | ||
83 | * - Level 2 : 17 packets (1 * 1 packet, 1 * 16 packets) | ||
84 | * - Level 3 : 273 packets (1 * 1 packet, 1 * 16 packet, 1 * 256 packets) | ||
85 | * | ||
86 | */ | ||
87 | static unsigned int loopback_test_level = 3; | ||
88 | |||
89 | /************************************************************************** | ||
90 | * | ||
91 | * Interrupt and event queue testing | ||
92 | * | ||
93 | **************************************************************************/ | ||
94 | |||
95 | /* Test generation and receipt of interrupts */ | ||
96 | static int efx_test_interrupts(struct efx_nic *efx, | ||
97 | struct efx_self_tests *tests) | ||
98 | { | ||
99 | struct efx_channel *channel; | ||
100 | |||
101 | EFX_LOG(efx, "testing interrupts\n"); | ||
102 | tests->interrupt = -1; | ||
103 | |||
104 | /* Reset interrupt flag */ | ||
105 | efx->last_irq_cpu = -1; | ||
106 | smp_wmb(); | ||
107 | |||
108 | /* ACK each interrupting event queue. Receiving an interrupt due to | ||
109 | * traffic before a test event is raised is considered a pass */ | ||
110 | efx_for_each_channel_with_interrupt(channel, efx) { | ||
111 | if (channel->work_pending) | ||
112 | efx_process_channel_now(channel); | ||
113 | if (efx->last_irq_cpu >= 0) | ||
114 | goto success; | ||
115 | } | ||
116 | |||
117 | falcon_generate_interrupt(efx); | ||
118 | |||
119 | /* Wait for arrival of test interrupt. */ | ||
120 | EFX_LOG(efx, "waiting for test interrupt\n"); | ||
121 | schedule_timeout_uninterruptible(HZ / 10); | ||
122 | if (efx->last_irq_cpu >= 0) | ||
123 | goto success; | ||
124 | |||
125 | EFX_ERR(efx, "timed out waiting for interrupt\n"); | ||
126 | return -ETIMEDOUT; | ||
127 | |||
128 | success: | ||
129 | EFX_LOG(efx, "test interrupt (mode %d) seen on CPU%d\n", | ||
130 | efx->interrupt_mode, efx->last_irq_cpu); | ||
131 | tests->interrupt = 1; | ||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | /* Test generation and receipt of non-interrupting events */ | ||
136 | static int efx_test_eventq(struct efx_channel *channel, | ||
137 | struct efx_self_tests *tests) | ||
138 | { | ||
139 | unsigned int magic; | ||
140 | |||
141 | /* Channel specific code, limited to 20 bits */ | ||
142 | magic = (0x00010150 + channel->channel); | ||
143 | EFX_LOG(channel->efx, "channel %d testing event queue with code %x\n", | ||
144 | channel->channel, magic); | ||
145 | |||
146 | tests->eventq_dma[channel->channel] = -1; | ||
147 | tests->eventq_int[channel->channel] = 1; /* fake pass */ | ||
148 | tests->eventq_poll[channel->channel] = 1; /* fake pass */ | ||
149 | |||
150 | /* Reset flag and zero magic word */ | ||
151 | channel->efx->last_irq_cpu = -1; | ||
152 | channel->eventq_magic = 0; | ||
153 | smp_wmb(); | ||
154 | |||
155 | falcon_generate_test_event(channel, magic); | ||
156 | udelay(1); | ||
157 | |||
158 | efx_process_channel_now(channel); | ||
159 | if (channel->eventq_magic != magic) { | ||
160 | EFX_ERR(channel->efx, "channel %d failed to see test event\n", | ||
161 | channel->channel); | ||
162 | return -ETIMEDOUT; | ||
163 | } else { | ||
164 | tests->eventq_dma[channel->channel] = 1; | ||
165 | } | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | /* Test generation and receipt of interrupting events */ | ||
171 | static int efx_test_eventq_irq(struct efx_channel *channel, | ||
172 | struct efx_self_tests *tests) | ||
173 | { | ||
174 | unsigned int magic, count; | ||
175 | |||
176 | /* Channel specific code, limited to 20 bits */ | ||
177 | magic = (0x00010150 + channel->channel); | ||
178 | EFX_LOG(channel->efx, "channel %d testing event queue with code %x\n", | ||
179 | channel->channel, magic); | ||
180 | |||
181 | tests->eventq_dma[channel->channel] = -1; | ||
182 | tests->eventq_int[channel->channel] = -1; | ||
183 | tests->eventq_poll[channel->channel] = -1; | ||
184 | |||
185 | /* Reset flag and zero magic word */ | ||
186 | channel->efx->last_irq_cpu = -1; | ||
187 | channel->eventq_magic = 0; | ||
188 | smp_wmb(); | ||
189 | |||
190 | falcon_generate_test_event(channel, magic); | ||
191 | |||
192 | /* Wait for arrival of interrupt */ | ||
193 | count = 0; | ||
194 | do { | ||
195 | schedule_timeout_uninterruptible(HZ / 100); | ||
196 | |||
197 | if (channel->work_pending) | ||
198 | efx_process_channel_now(channel); | ||
199 | |||
200 | if (channel->eventq_magic == magic) | ||
201 | goto eventq_ok; | ||
202 | } while (++count < 2); | ||
203 | |||
204 | EFX_ERR(channel->efx, "channel %d timed out waiting for event queue\n", | ||
205 | channel->channel); | ||
206 | |||
207 | /* See if interrupt arrived */ | ||
208 | if (channel->efx->last_irq_cpu >= 0) { | ||
209 | EFX_ERR(channel->efx, "channel %d saw interrupt on CPU%d " | ||
210 | "during event queue test\n", channel->channel, | ||
211 | raw_smp_processor_id()); | ||
212 | tests->eventq_int[channel->channel] = 1; | ||
213 | } | ||
214 | |||
215 | /* Check to see if event was received even if interrupt wasn't */ | ||
216 | efx_process_channel_now(channel); | ||
217 | if (channel->eventq_magic == magic) { | ||
218 | EFX_ERR(channel->efx, "channel %d event was generated, but " | ||
219 | "failed to trigger an interrupt\n", channel->channel); | ||
220 | tests->eventq_dma[channel->channel] = 1; | ||
221 | } | ||
222 | |||
223 | return -ETIMEDOUT; | ||
224 | eventq_ok: | ||
225 | EFX_LOG(channel->efx, "channel %d event queue passed\n", | ||
226 | channel->channel); | ||
227 | tests->eventq_dma[channel->channel] = 1; | ||
228 | tests->eventq_int[channel->channel] = 1; | ||
229 | tests->eventq_poll[channel->channel] = 1; | ||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | /************************************************************************** | ||
234 | * | ||
235 | * PHY testing | ||
236 | * | ||
237 | **************************************************************************/ | ||
238 | |||
239 | /* Check PHY presence by reading the PHY ID registers */ | ||
240 | static int efx_test_phy(struct efx_nic *efx, | ||
241 | struct efx_self_tests *tests) | ||
242 | { | ||
243 | u16 physid1, physid2; | ||
244 | struct mii_if_info *mii = &efx->mii; | ||
245 | struct net_device *net_dev = efx->net_dev; | ||
246 | |||
247 | if (efx->phy_type == PHY_TYPE_NONE) | ||
248 | return 0; | ||
249 | |||
250 | EFX_LOG(efx, "testing PHY presence\n"); | ||
251 | tests->phy_ok = -1; | ||
252 | |||
253 | physid1 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID1); | ||
254 | physid2 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID2); | ||
255 | |||
256 | if ((physid1 != 0x0000) && (physid1 != 0xffff) && | ||
257 | (physid2 != 0x0000) && (physid2 != 0xffff)) { | ||
258 | EFX_LOG(efx, "found MII PHY %d ID 0x%x:%x\n", | ||
259 | mii->phy_id, physid1, physid2); | ||
260 | tests->phy_ok = 1; | ||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | EFX_ERR(efx, "no MII PHY present with ID %d\n", mii->phy_id); | ||
265 | return -ENODEV; | ||
266 | } | ||
267 | |||
268 | /************************************************************************** | ||
269 | * | ||
270 | * Loopback testing | ||
271 | * NB Only one loopback test can be executing concurrently. | ||
272 | * | ||
273 | **************************************************************************/ | ||
274 | |||
275 | /* Loopback test RX callback | ||
276 | * This is called for each received packet during loopback testing. | ||
277 | */ | ||
278 | void efx_loopback_rx_packet(struct efx_nic *efx, | ||
279 | const char *buf_ptr, int pkt_len) | ||
280 | { | ||
281 | struct efx_selftest_state *state = efx->loopback_selftest; | ||
282 | struct efx_loopback_payload *received; | ||
283 | struct efx_loopback_payload *payload; | ||
284 | |||
285 | BUG_ON(!buf_ptr); | ||
286 | |||
287 | /* If we are just flushing, then drop the packet */ | ||
288 | if ((state == NULL) || state->flush) | ||
289 | return; | ||
290 | |||
291 | payload = &state->payload; | ||
292 | |||
293 | received = (struct efx_loopback_payload *)(char *) buf_ptr; | ||
294 | received->ip.saddr = payload->ip.saddr; | ||
295 | received->ip.check = payload->ip.check; | ||
296 | |||
297 | /* Check that header exists */ | ||
298 | if (pkt_len < sizeof(received->header)) { | ||
299 | EFX_ERR(efx, "saw runt RX packet (length %d) in %s loopback " | ||
300 | "test\n", pkt_len, LOOPBACK_MODE(efx)); | ||
301 | goto err; | ||
302 | } | ||
303 | |||
304 | /* Check that the ethernet header exists */ | ||
305 | if (memcmp(&received->header, &payload->header, ETH_HLEN) != 0) { | ||
306 | EFX_ERR(efx, "saw non-loopback RX packet in %s loopback test\n", | ||
307 | LOOPBACK_MODE(efx)); | ||
308 | goto err; | ||
309 | } | ||
310 | |||
311 | /* Check packet length */ | ||
312 | if (pkt_len != sizeof(*payload)) { | ||
313 | EFX_ERR(efx, "saw incorrect RX packet length %d (wanted %d) in " | ||
314 | "%s loopback test\n", pkt_len, (int)sizeof(*payload), | ||
315 | LOOPBACK_MODE(efx)); | ||
316 | goto err; | ||
317 | } | ||
318 | |||
319 | /* Check that IP header matches */ | ||
320 | if (memcmp(&received->ip, &payload->ip, sizeof(payload->ip)) != 0) { | ||
321 | EFX_ERR(efx, "saw corrupted IP header in %s loopback test\n", | ||
322 | LOOPBACK_MODE(efx)); | ||
323 | goto err; | ||
324 | } | ||
325 | |||
326 | /* Check that msg and padding matches */ | ||
327 | if (memcmp(&received->msg, &payload->msg, sizeof(received->msg)) != 0) { | ||
328 | EFX_ERR(efx, "saw corrupted RX packet in %s loopback test\n", | ||
329 | LOOPBACK_MODE(efx)); | ||
330 | goto err; | ||
331 | } | ||
332 | |||
333 | /* Check that iteration matches */ | ||
334 | if (received->iteration != payload->iteration) { | ||
335 | EFX_ERR(efx, "saw RX packet from iteration %d (wanted %d) in " | ||
336 | "%s loopback test\n", ntohs(received->iteration), | ||
337 | ntohs(payload->iteration), LOOPBACK_MODE(efx)); | ||
338 | goto err; | ||
339 | } | ||
340 | |||
341 | /* Increase correct RX count */ | ||
342 | EFX_TRACE(efx, "got loopback RX in %s loopback test\n", | ||
343 | LOOPBACK_MODE(efx)); | ||
344 | |||
345 | atomic_inc(&state->rx_good); | ||
346 | return; | ||
347 | |||
348 | err: | ||
349 | #ifdef EFX_ENABLE_DEBUG | ||
350 | if (atomic_read(&state->rx_bad) == 0) { | ||
351 | EFX_ERR(efx, "received packet:\n"); | ||
352 | print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, | ||
353 | buf_ptr, pkt_len, 0); | ||
354 | EFX_ERR(efx, "expected packet:\n"); | ||
355 | print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, | ||
356 | &state->payload, sizeof(state->payload), 0); | ||
357 | } | ||
358 | #endif | ||
359 | atomic_inc(&state->rx_bad); | ||
360 | } | ||
361 | |||
362 | /* Initialise an efx_selftest_state for a new iteration */ | ||
363 | static void efx_iterate_state(struct efx_nic *efx) | ||
364 | { | ||
365 | struct efx_selftest_state *state = efx->loopback_selftest; | ||
366 | struct net_device *net_dev = efx->net_dev; | ||
367 | struct efx_loopback_payload *payload = &state->payload; | ||
368 | |||
369 | /* Initialise the layerII header */ | ||
370 | memcpy(&payload->header.h_dest, net_dev->dev_addr, ETH_ALEN); | ||
371 | memcpy(&payload->header.h_source, &payload_source, ETH_ALEN); | ||
372 | payload->header.h_proto = htons(ETH_P_IP); | ||
373 | |||
374 | /* saddr set later and used as incrementing count */ | ||
375 | payload->ip.daddr = htonl(INADDR_LOOPBACK); | ||
376 | payload->ip.ihl = 5; | ||
377 | payload->ip.check = htons(0xdead); | ||
378 | payload->ip.tot_len = htons(sizeof(*payload) - sizeof(struct ethhdr)); | ||
379 | payload->ip.version = IPVERSION; | ||
380 | payload->ip.protocol = IPPROTO_UDP; | ||
381 | |||
382 | /* Initialise udp header */ | ||
383 | payload->udp.source = 0; | ||
384 | payload->udp.len = htons(sizeof(*payload) - sizeof(struct ethhdr) - | ||
385 | sizeof(struct iphdr)); | ||
386 | payload->udp.check = 0; /* checksum ignored */ | ||
387 | |||
388 | /* Fill out payload */ | ||
389 | payload->iteration = htons(ntohs(payload->iteration) + 1); | ||
390 | memcpy(&payload->msg, payload_msg, sizeof(payload_msg)); | ||
391 | |||
392 | /* Fill out remaining state members */ | ||
393 | atomic_set(&state->rx_good, 0); | ||
394 | atomic_set(&state->rx_bad, 0); | ||
395 | smp_wmb(); | ||
396 | } | ||
397 | |||
398 | static int efx_tx_loopback(struct efx_tx_queue *tx_queue) | ||
399 | { | ||
400 | struct efx_nic *efx = tx_queue->efx; | ||
401 | struct efx_selftest_state *state = efx->loopback_selftest; | ||
402 | struct efx_loopback_payload *payload; | ||
403 | struct sk_buff *skb; | ||
404 | int i, rc; | ||
405 | |||
406 | /* Transmit N copies of buffer */ | ||
407 | for (i = 0; i < state->packet_count; i++) { | ||
408 | /* Allocate an skb, holding an extra reference for | ||
409 | * transmit completion counting */ | ||
410 | skb = alloc_skb(sizeof(state->payload), GFP_KERNEL); | ||
411 | if (!skb) | ||
412 | return -ENOMEM; | ||
413 | state->skbs[i] = skb; | ||
414 | skb_get(skb); | ||
415 | |||
416 | /* Copy the payload in, incrementing the source address to | ||
417 | * exercise the rss vectors */ | ||
418 | payload = ((struct efx_loopback_payload *) | ||
419 | skb_put(skb, sizeof(state->payload))); | ||
420 | memcpy(payload, &state->payload, sizeof(state->payload)); | ||
421 | payload->ip.saddr = htonl(INADDR_LOOPBACK | (i << 2)); | ||
422 | |||
423 | /* Ensure everything we've written is visible to the | ||
424 | * interrupt handler. */ | ||
425 | smp_wmb(); | ||
426 | |||
427 | if (NET_DEV_REGISTERED(efx)) | ||
428 | netif_tx_lock_bh(efx->net_dev); | ||
429 | rc = efx_xmit(efx, tx_queue, skb); | ||
430 | if (NET_DEV_REGISTERED(efx)) | ||
431 | netif_tx_unlock_bh(efx->net_dev); | ||
432 | |||
433 | if (rc != NETDEV_TX_OK) { | ||
434 | EFX_ERR(efx, "TX queue %d could not transmit packet %d " | ||
435 | "of %d in %s loopback test\n", tx_queue->queue, | ||
436 | i + 1, state->packet_count, LOOPBACK_MODE(efx)); | ||
437 | |||
438 | /* Defer cleaning up the other skbs for the caller */ | ||
439 | kfree_skb(skb); | ||
440 | return -EPIPE; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | return 0; | ||
445 | } | ||
446 | |||
447 | static int efx_rx_loopback(struct efx_tx_queue *tx_queue, | ||
448 | struct efx_loopback_self_tests *lb_tests) | ||
449 | { | ||
450 | struct efx_nic *efx = tx_queue->efx; | ||
451 | struct efx_selftest_state *state = efx->loopback_selftest; | ||
452 | struct sk_buff *skb; | ||
453 | int tx_done = 0, rx_good, rx_bad; | ||
454 | int i, rc = 0; | ||
455 | |||
456 | if (NET_DEV_REGISTERED(efx)) | ||
457 | netif_tx_lock_bh(efx->net_dev); | ||
458 | |||
459 | /* Count the number of tx completions, and decrement the refcnt. Any | ||
460 | * skbs not already completed will be free'd when the queue is flushed */ | ||
461 | for (i=0; i < state->packet_count; i++) { | ||
462 | skb = state->skbs[i]; | ||
463 | if (skb && !skb_shared(skb)) | ||
464 | ++tx_done; | ||
465 | dev_kfree_skb_any(skb); | ||
466 | } | ||
467 | |||
468 | if (NET_DEV_REGISTERED(efx)) | ||
469 | netif_tx_unlock_bh(efx->net_dev); | ||
470 | |||
471 | /* Check TX completion and received packet counts */ | ||
472 | rx_good = atomic_read(&state->rx_good); | ||
473 | rx_bad = atomic_read(&state->rx_bad); | ||
474 | if (tx_done != state->packet_count) { | ||
475 | /* Don't free the skbs; they will be picked up on TX | ||
476 | * overflow or channel teardown. | ||
477 | */ | ||
478 | EFX_ERR(efx, "TX queue %d saw only %d out of an expected %d " | ||
479 | "TX completion events in %s loopback test\n", | ||
480 | tx_queue->queue, tx_done, state->packet_count, | ||
481 | LOOPBACK_MODE(efx)); | ||
482 | rc = -ETIMEDOUT; | ||
483 | /* Allow to fall through so we see the RX errors as well */ | ||
484 | } | ||
485 | |||
486 | /* We may always be up to a flush away from our desired packet total */ | ||
487 | if (rx_good != state->packet_count) { | ||
488 | EFX_LOG(efx, "TX queue %d saw only %d out of an expected %d " | ||
489 | "received packets in %s loopback test\n", | ||
490 | tx_queue->queue, rx_good, state->packet_count, | ||
491 | LOOPBACK_MODE(efx)); | ||
492 | rc = -ETIMEDOUT; | ||
493 | /* Fall through */ | ||
494 | } | ||
495 | |||
496 | /* Update loopback test structure */ | ||
497 | lb_tests->tx_sent[tx_queue->queue] += state->packet_count; | ||
498 | lb_tests->tx_done[tx_queue->queue] += tx_done; | ||
499 | lb_tests->rx_good += rx_good; | ||
500 | lb_tests->rx_bad += rx_bad; | ||
501 | |||
502 | return rc; | ||
503 | } | ||
504 | |||
505 | static int | ||
506 | efx_test_loopback(struct efx_tx_queue *tx_queue, | ||
507 | struct efx_loopback_self_tests *lb_tests) | ||
508 | { | ||
509 | struct efx_nic *efx = tx_queue->efx; | ||
510 | struct efx_selftest_state *state = efx->loopback_selftest; | ||
511 | struct efx_channel *channel; | ||
512 | int i, rc = 0; | ||
513 | |||
514 | for (i = 0; i < loopback_test_level; i++) { | ||
515 | /* Determine how many packets to send */ | ||
516 | state->packet_count = (efx->type->txd_ring_mask + 1) / 3; | ||
517 | state->packet_count = min(1 << (i << 2), state->packet_count); | ||
518 | state->skbs = kzalloc(sizeof(state->skbs[0]) * | ||
519 | state->packet_count, GFP_KERNEL); | ||
520 | state->flush = 0; | ||
521 | |||
522 | EFX_LOG(efx, "TX queue %d testing %s loopback with %d " | ||
523 | "packets\n", tx_queue->queue, LOOPBACK_MODE(efx), | ||
524 | state->packet_count); | ||
525 | |||
526 | efx_iterate_state(efx); | ||
527 | rc = efx_tx_loopback(tx_queue); | ||
528 | |||
529 | /* NAPI polling is not enabled, so process channels synchronously */ | ||
530 | schedule_timeout_uninterruptible(HZ / 50); | ||
531 | efx_for_each_channel_with_interrupt(channel, efx) { | ||
532 | if (channel->work_pending) | ||
533 | efx_process_channel_now(channel); | ||
534 | } | ||
535 | |||
536 | rc |= efx_rx_loopback(tx_queue, lb_tests); | ||
537 | kfree(state->skbs); | ||
538 | |||
539 | if (rc) { | ||
540 | /* Wait a while to ensure there are no packets | ||
541 | * floating around after a failure. */ | ||
542 | schedule_timeout_uninterruptible(HZ / 10); | ||
543 | return rc; | ||
544 | } | ||
545 | } | ||
546 | |||
547 | EFX_LOG(efx, "TX queue %d passed %s loopback test with a burst length " | ||
548 | "of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx), | ||
549 | state->packet_count); | ||
550 | |||
551 | return rc; | ||
552 | } | ||
553 | |||
554 | static int efx_test_loopbacks(struct efx_nic *efx, | ||
555 | struct efx_self_tests *tests, | ||
556 | unsigned int loopback_modes) | ||
557 | { | ||
558 | struct efx_selftest_state *state = efx->loopback_selftest; | ||
559 | struct ethtool_cmd ecmd, ecmd_loopback; | ||
560 | struct efx_tx_queue *tx_queue; | ||
561 | enum efx_loopback_mode old_mode, mode; | ||
562 | int count, rc = 0, link_up; | ||
563 | |||
564 | rc = efx_ethtool_get_settings(efx->net_dev, &ecmd); | ||
565 | if (rc) { | ||
566 | EFX_ERR(efx, "could not get GMII settings\n"); | ||
567 | return rc; | ||
568 | } | ||
569 | old_mode = efx->loopback_mode; | ||
570 | |||
571 | /* Disable autonegotiation for the purposes of loopback */ | ||
572 | memcpy(&ecmd_loopback, &ecmd, sizeof(ecmd_loopback)); | ||
573 | if (ecmd_loopback.autoneg == AUTONEG_ENABLE) { | ||
574 | ecmd_loopback.autoneg = AUTONEG_DISABLE; | ||
575 | ecmd_loopback.duplex = DUPLEX_FULL; | ||
576 | ecmd_loopback.speed = SPEED_10000; | ||
577 | } | ||
578 | |||
579 | rc = efx_ethtool_set_settings(efx->net_dev, &ecmd_loopback); | ||
580 | if (rc) { | ||
581 | EFX_ERR(efx, "could not disable autonegotiation\n"); | ||
582 | goto out; | ||
583 | } | ||
584 | tests->loopback_speed = ecmd_loopback.speed; | ||
585 | tests->loopback_full_duplex = ecmd_loopback.duplex; | ||
586 | |||
587 | /* Test all supported loopback modes */ | ||
588 | for (mode = LOOPBACK_NONE; mode < LOOPBACK_TEST_MAX; mode++) { | ||
589 | if (!(loopback_modes & (1 << mode))) | ||
590 | continue; | ||
591 | |||
592 | /* Move the port into the specified loopback mode. */ | ||
593 | state->flush = 1; | ||
594 | efx->loopback_mode = mode; | ||
595 | efx_reconfigure_port(efx); | ||
596 | |||
597 | /* Wait for the PHY to signal the link is up */ | ||
598 | count = 0; | ||
599 | do { | ||
600 | struct efx_channel *channel = &efx->channel[0]; | ||
601 | |||
602 | falcon_check_xmac(efx); | ||
603 | schedule_timeout_uninterruptible(HZ / 10); | ||
604 | if (channel->work_pending) | ||
605 | efx_process_channel_now(channel); | ||
606 | /* Wait for PHY events to be processed */ | ||
607 | flush_workqueue(efx->workqueue); | ||
608 | rmb(); | ||
609 | |||
610 | /* efx->link_up can be 1 even if the XAUI link is down, | ||
611 | * (bug5762). Usually, it's not worth bothering with the | ||
612 | * difference, but for selftests, we need that extra | ||
613 | * guarantee that the link is really, really, up. | ||
614 | */ | ||
615 | link_up = efx->link_up; | ||
616 | if (!falcon_xaui_link_ok(efx)) | ||
617 | link_up = 0; | ||
618 | |||
619 | } while ((++count < 20) && !link_up); | ||
620 | |||
621 | /* The link should now be up. If it isn't, there is no point | ||
622 | * in attempting a loopback test */ | ||
623 | if (!link_up) { | ||
624 | EFX_ERR(efx, "loopback %s never came up\n", | ||
625 | LOOPBACK_MODE(efx)); | ||
626 | rc = -EIO; | ||
627 | goto out; | ||
628 | } | ||
629 | |||
630 | EFX_LOG(efx, "link came up in %s loopback in %d iterations\n", | ||
631 | LOOPBACK_MODE(efx), count); | ||
632 | |||
633 | /* Test every TX queue */ | ||
634 | efx_for_each_tx_queue(tx_queue, efx) { | ||
635 | rc |= efx_test_loopback(tx_queue, | ||
636 | &tests->loopback[mode]); | ||
637 | if (rc) | ||
638 | goto out; | ||
639 | } | ||
640 | } | ||
641 | |||
642 | out: | ||
643 | /* Take out of loopback and restore PHY settings */ | ||
644 | state->flush = 1; | ||
645 | efx->loopback_mode = old_mode; | ||
646 | efx_ethtool_set_settings(efx->net_dev, &ecmd); | ||
647 | |||
648 | return rc; | ||
649 | } | ||
650 | |||
651 | /************************************************************************** | ||
652 | * | ||
653 | * Entry points | ||
654 | * | ||
655 | *************************************************************************/ | ||
656 | |||
657 | /* Online (i.e. non-disruptive) testing | ||
658 | * This checks interrupt generation, event delivery and PHY presence. */ | ||
659 | int efx_online_test(struct efx_nic *efx, struct efx_self_tests *tests) | ||
660 | { | ||
661 | struct efx_channel *channel; | ||
662 | int rc = 0; | ||
663 | |||
664 | EFX_LOG(efx, "performing online self-tests\n"); | ||
665 | |||
666 | rc |= efx_test_interrupts(efx, tests); | ||
667 | efx_for_each_channel(channel, efx) { | ||
668 | if (channel->has_interrupt) | ||
669 | rc |= efx_test_eventq_irq(channel, tests); | ||
670 | else | ||
671 | rc |= efx_test_eventq(channel, tests); | ||
672 | } | ||
673 | rc |= efx_test_phy(efx, tests); | ||
674 | |||
675 | if (rc) | ||
676 | EFX_ERR(efx, "failed online self-tests\n"); | ||
677 | |||
678 | return rc; | ||
679 | } | ||
680 | |||
681 | /* Offline (i.e. disruptive) testing | ||
682 | * This checks MAC and PHY loopback on the specified port. */ | ||
683 | int efx_offline_test(struct efx_nic *efx, | ||
684 | struct efx_self_tests *tests, unsigned int loopback_modes) | ||
685 | { | ||
686 | struct efx_selftest_state *state; | ||
687 | int rc = 0; | ||
688 | |||
689 | EFX_LOG(efx, "performing offline self-tests\n"); | ||
690 | |||
691 | /* Create a selftest_state structure to hold state for the test */ | ||
692 | state = kzalloc(sizeof(*state), GFP_KERNEL); | ||
693 | if (state == NULL) { | ||
694 | rc = -ENOMEM; | ||
695 | goto out; | ||
696 | } | ||
697 | |||
698 | /* Set the port loopback_selftest member. From this point on | ||
699 | * all received packets will be dropped. Mark the state as | ||
700 | * "flushing" so all inflight packets are dropped */ | ||
701 | BUG_ON(efx->loopback_selftest); | ||
702 | state->flush = 1; | ||
703 | efx->loopback_selftest = (void *)state; | ||
704 | |||
705 | rc = efx_test_loopbacks(efx, tests, loopback_modes); | ||
706 | |||
707 | efx->loopback_selftest = NULL; | ||
708 | wmb(); | ||
709 | kfree(state); | ||
710 | |||
711 | out: | ||
712 | if (rc) | ||
713 | EFX_ERR(efx, "failed offline self-tests\n"); | ||
714 | |||
715 | return rc; | ||
716 | } | ||
717 | |||
diff --git a/drivers/net/sfc/selftest.h b/drivers/net/sfc/selftest.h new file mode 100644 index 000000000000..f6999c2b622d --- /dev/null +++ b/drivers/net/sfc/selftest.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /**************************************************************************** | ||
2 | * Driver for Solarflare Solarstorm network controllers and boards | ||
3 | * Copyright 2005-2006 Fen Systems Ltd. | ||
4 | * Copyright 2006-2008 Solarflare Communications Inc. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published | ||
8 | * by the Free Software Foundation, incorporated herein by reference. | ||
9 | */ | ||
10 | |||
11 | #ifndef EFX_SELFTEST_H | ||
12 | #define EFX_SELFTEST_H | ||
13 | |||
14 | #include "net_driver.h" | ||
15 | |||
16 | /* | ||
17 | * Self tests | ||
18 | */ | ||
19 | |||
20 | struct efx_loopback_self_tests { | ||
21 | int tx_sent[EFX_MAX_TX_QUEUES]; | ||
22 | int tx_done[EFX_MAX_TX_QUEUES]; | ||
23 | int rx_good; | ||
24 | int rx_bad; | ||
25 | }; | ||
26 | |||
27 | /* Efx self test results | ||
28 | * For fields which are not counters, 1 indicates success and -1 | ||
29 | * indicates failure. | ||
30 | */ | ||
31 | struct efx_self_tests { | ||
32 | int interrupt; | ||
33 | int eventq_dma[EFX_MAX_CHANNELS]; | ||
34 | int eventq_int[EFX_MAX_CHANNELS]; | ||
35 | int eventq_poll[EFX_MAX_CHANNELS]; | ||
36 | int phy_ok; | ||
37 | int loopback_speed; | ||
38 | int loopback_full_duplex; | ||
39 | struct efx_loopback_self_tests loopback[LOOPBACK_TEST_MAX]; | ||
40 | }; | ||
41 | |||
42 | extern void efx_loopback_rx_packet(struct efx_nic *efx, | ||
43 | const char *buf_ptr, int pkt_len); | ||
44 | extern int efx_online_test(struct efx_nic *efx, | ||
45 | struct efx_self_tests *tests); | ||
46 | extern int efx_offline_test(struct efx_nic *efx, | ||
47 | struct efx_self_tests *tests, | ||
48 | unsigned int loopback_modes); | ||
49 | |||
50 | #endif /* EFX_SELFTEST_H */ | ||
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c index 11fa9fb8f48b..725d1a539c49 100644 --- a/drivers/net/sfc/sfe4001.c +++ b/drivers/net/sfc/sfe4001.c | |||
@@ -130,6 +130,15 @@ void sfe4001_poweroff(struct efx_nic *efx) | |||
130 | (void) efx_i2c_read(i2c, MAX6647, RSL, &in, 1); | 130 | (void) efx_i2c_read(i2c, MAX6647, RSL, &in, 1); |
131 | } | 131 | } |
132 | 132 | ||
133 | /* The P0_EN_3V3X line on SFE4001 boards (from A2 onward) is connected | ||
134 | * to the FLASH_CFG_1 input on the DSP. We must keep it high at power- | ||
135 | * up to allow writing the flash (done through MDIO from userland). | ||
136 | */ | ||
137 | unsigned int sfe4001_phy_flash_cfg; | ||
138 | module_param_named(phy_flash_cfg, sfe4001_phy_flash_cfg, uint, 0444); | ||
139 | MODULE_PARM_DESC(phy_flash_cfg, | ||
140 | "Force PHY to enter flash configuration mode"); | ||
141 | |||
133 | /* This board uses an I2C expander to provider power to the PHY, which needs to | 142 | /* This board uses an I2C expander to provider power to the PHY, which needs to |
134 | * be turned on before the PHY can be used. | 143 | * be turned on before the PHY can be used. |
135 | * Context: Process context, rtnl lock held | 144 | * Context: Process context, rtnl lock held |
@@ -203,6 +212,8 @@ int sfe4001_poweron(struct efx_nic *efx) | |||
203 | out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) | | 212 | out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) | |
204 | (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) | | 213 | (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) | |
205 | (1 << P0_X_TRST_LBN)); | 214 | (1 << P0_X_TRST_LBN)); |
215 | if (sfe4001_phy_flash_cfg) | ||
216 | out |= 1 << P0_EN_3V3X_LBN; | ||
206 | 217 | ||
207 | rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1); | 218 | rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1); |
208 | if (rc) | 219 | if (rc) |
@@ -226,6 +237,9 @@ int sfe4001_poweron(struct efx_nic *efx) | |||
226 | if (in & (1 << P1_AFE_PWD_LBN)) | 237 | if (in & (1 << P1_AFE_PWD_LBN)) |
227 | goto done; | 238 | goto done; |
228 | 239 | ||
240 | /* DSP doesn't look powered in flash config mode */ | ||
241 | if (sfe4001_phy_flash_cfg) | ||
242 | goto done; | ||
229 | } while (++count < 20); | 243 | } while (++count < 20); |
230 | 244 | ||
231 | EFX_INFO(efx, "timed out waiting for power\n"); | 245 | EFX_INFO(efx, "timed out waiting for power\n"); |
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c index a2e9f79e47b1..b1cd6deec01f 100644 --- a/drivers/net/sfc/tenxpress.c +++ b/drivers/net/sfc/tenxpress.c | |||
@@ -24,6 +24,11 @@ | |||
24 | MDIO_MMDREG_DEVS0_PCS | \ | 24 | MDIO_MMDREG_DEVS0_PCS | \ |
25 | MDIO_MMDREG_DEVS0_PHYXS) | 25 | MDIO_MMDREG_DEVS0_PHYXS) |
26 | 26 | ||
27 | #define TENXPRESS_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \ | ||
28 | (1 << LOOPBACK_PCS) | \ | ||
29 | (1 << LOOPBACK_PMAPMD) | \ | ||
30 | (1 << LOOPBACK_NETWORK)) | ||
31 | |||
27 | /* We complain if we fail to see the link partner as 10G capable this many | 32 | /* We complain if we fail to see the link partner as 10G capable this many |
28 | * times in a row (must be > 1 as sampling the autoneg. registers is racy) | 33 | * times in a row (must be > 1 as sampling the autoneg. registers is racy) |
29 | */ | 34 | */ |
@@ -72,6 +77,10 @@ | |||
72 | #define PMA_PMD_BIST_RXD_LBN (1) | 77 | #define PMA_PMD_BIST_RXD_LBN (1) |
73 | #define PMA_PMD_BIST_AFE_LBN (0) | 78 | #define PMA_PMD_BIST_AFE_LBN (0) |
74 | 79 | ||
80 | /* Special Software reset register */ | ||
81 | #define PMA_PMD_EXT_CTRL_REG 49152 | ||
82 | #define PMA_PMD_EXT_SSR_LBN 15 | ||
83 | |||
75 | #define BIST_MAX_DELAY (1000) | 84 | #define BIST_MAX_DELAY (1000) |
76 | #define BIST_POLL_DELAY (10) | 85 | #define BIST_POLL_DELAY (10) |
77 | 86 | ||
@@ -86,6 +95,11 @@ | |||
86 | #define PCS_TEST_SELECT_REG 0xd807 /* PRM 10.5.8 */ | 95 | #define PCS_TEST_SELECT_REG 0xd807 /* PRM 10.5.8 */ |
87 | #define CLK312_EN_LBN 3 | 96 | #define CLK312_EN_LBN 3 |
88 | 97 | ||
98 | /* PHYXS registers */ | ||
99 | #define PHYXS_TEST1 (49162) | ||
100 | #define LOOPBACK_NEAR_LBN (8) | ||
101 | #define LOOPBACK_NEAR_WIDTH (1) | ||
102 | |||
89 | /* Boot status register */ | 103 | /* Boot status register */ |
90 | #define PCS_BOOT_STATUS_REG (0xd000) | 104 | #define PCS_BOOT_STATUS_REG (0xd000) |
91 | #define PCS_BOOT_FATAL_ERR_LBN (0) | 105 | #define PCS_BOOT_FATAL_ERR_LBN (0) |
@@ -106,7 +120,9 @@ MODULE_PARM_DESC(crc_error_reset_threshold, | |||
106 | 120 | ||
107 | struct tenxpress_phy_data { | 121 | struct tenxpress_phy_data { |
108 | enum tenxpress_state state; | 122 | enum tenxpress_state state; |
123 | enum efx_loopback_mode loopback_mode; | ||
109 | atomic_t bad_crc_count; | 124 | atomic_t bad_crc_count; |
125 | int tx_disabled; | ||
110 | int bad_lp_tries; | 126 | int bad_lp_tries; |
111 | }; | 127 | }; |
112 | 128 | ||
@@ -199,10 +215,12 @@ static int tenxpress_phy_init(struct efx_nic *efx) | |||
199 | 215 | ||
200 | tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL); | 216 | tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL); |
201 | 217 | ||
202 | rc = mdio_clause45_wait_reset_mmds(efx, | 218 | if (!sfe4001_phy_flash_cfg) { |
203 | TENXPRESS_REQUIRED_DEVS); | 219 | rc = mdio_clause45_wait_reset_mmds(efx, |
204 | if (rc < 0) | 220 | TENXPRESS_REQUIRED_DEVS); |
205 | goto fail; | 221 | if (rc < 0) |
222 | goto fail; | ||
223 | } | ||
206 | 224 | ||
207 | rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0); | 225 | rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0); |
208 | if (rc < 0) | 226 | if (rc < 0) |
@@ -225,6 +243,35 @@ static int tenxpress_phy_init(struct efx_nic *efx) | |||
225 | return rc; | 243 | return rc; |
226 | } | 244 | } |
227 | 245 | ||
246 | static int tenxpress_special_reset(struct efx_nic *efx) | ||
247 | { | ||
248 | int rc, reg; | ||
249 | |||
250 | EFX_TRACE(efx, "%s\n", __func__); | ||
251 | |||
252 | /* Initiate reset */ | ||
253 | reg = mdio_clause45_read(efx, efx->mii.phy_id, | ||
254 | MDIO_MMD_PMAPMD, PMA_PMD_EXT_CTRL_REG); | ||
255 | reg |= (1 << PMA_PMD_EXT_SSR_LBN); | ||
256 | mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD, | ||
257 | PMA_PMD_EXT_CTRL_REG, reg); | ||
258 | |||
259 | msleep(200); | ||
260 | |||
261 | /* Wait for the blocks to come out of reset */ | ||
262 | rc = mdio_clause45_wait_reset_mmds(efx, | ||
263 | TENXPRESS_REQUIRED_DEVS); | ||
264 | if (rc < 0) | ||
265 | return rc; | ||
266 | |||
267 | /* Try and reconfigure the device */ | ||
268 | rc = tenxpress_init(efx); | ||
269 | if (rc < 0) | ||
270 | return rc; | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
228 | static void tenxpress_set_bad_lp(struct efx_nic *efx, int bad_lp) | 275 | static void tenxpress_set_bad_lp(struct efx_nic *efx, int bad_lp) |
229 | { | 276 | { |
230 | struct tenxpress_phy_data *pd = efx->phy_data; | 277 | struct tenxpress_phy_data *pd = efx->phy_data; |
@@ -299,11 +346,46 @@ static int tenxpress_link_ok(struct efx_nic *efx, int check_lp) | |||
299 | return ok; | 346 | return ok; |
300 | } | 347 | } |
301 | 348 | ||
349 | static void tenxpress_phyxs_loopback(struct efx_nic *efx) | ||
350 | { | ||
351 | int phy_id = efx->mii.phy_id; | ||
352 | int ctrl1, ctrl2; | ||
353 | |||
354 | ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS, | ||
355 | PHYXS_TEST1); | ||
356 | if (efx->loopback_mode == LOOPBACK_PHYXS) | ||
357 | ctrl2 |= (1 << LOOPBACK_NEAR_LBN); | ||
358 | else | ||
359 | ctrl2 &= ~(1 << LOOPBACK_NEAR_LBN); | ||
360 | if (ctrl1 != ctrl2) | ||
361 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PHYXS, | ||
362 | PHYXS_TEST1, ctrl2); | ||
363 | } | ||
364 | |||
302 | static void tenxpress_phy_reconfigure(struct efx_nic *efx) | 365 | static void tenxpress_phy_reconfigure(struct efx_nic *efx) |
303 | { | 366 | { |
367 | struct tenxpress_phy_data *phy_data = efx->phy_data; | ||
368 | int loop_change = LOOPBACK_OUT_OF(phy_data, efx, | ||
369 | TENXPRESS_LOOPBACKS); | ||
370 | |||
304 | if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL)) | 371 | if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL)) |
305 | return; | 372 | return; |
306 | 373 | ||
374 | /* When coming out of transmit disable, coming out of low power | ||
375 | * mode, or moving out of any PHY internal loopback mode, | ||
376 | * perform a special software reset */ | ||
377 | if ((phy_data->tx_disabled && !efx->tx_disabled) || | ||
378 | loop_change) { | ||
379 | (void) tenxpress_special_reset(efx); | ||
380 | falcon_reset_xaui(efx); | ||
381 | } | ||
382 | |||
383 | mdio_clause45_transmit_disable(efx); | ||
384 | mdio_clause45_phy_reconfigure(efx); | ||
385 | tenxpress_phyxs_loopback(efx); | ||
386 | |||
387 | phy_data->tx_disabled = efx->tx_disabled; | ||
388 | phy_data->loopback_mode = efx->loopback_mode; | ||
307 | efx->link_up = tenxpress_link_ok(efx, 0); | 389 | efx->link_up = tenxpress_link_ok(efx, 0); |
308 | efx->link_options = GM_LPA_10000FULL; | 390 | efx->link_options = GM_LPA_10000FULL; |
309 | } | 391 | } |
@@ -431,4 +513,5 @@ struct efx_phy_operations falcon_tenxpress_phy_ops = { | |||
431 | .clear_interrupt = tenxpress_phy_clear_interrupt, | 513 | .clear_interrupt = tenxpress_phy_clear_interrupt, |
432 | .reset_xaui = tenxpress_reset_xaui, | 514 | .reset_xaui = tenxpress_reset_xaui, |
433 | .mmds = TENXPRESS_REQUIRED_DEVS, | 515 | .mmds = TENXPRESS_REQUIRED_DEVS, |
516 | .loopbacks = TENXPRESS_LOOPBACKS, | ||
434 | }; | 517 | }; |
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c index fbb866b2185e..9b436f5b4888 100644 --- a/drivers/net/sfc/tx.c +++ b/drivers/net/sfc/tx.c | |||
@@ -82,6 +82,46 @@ static inline void efx_dequeue_buffer(struct efx_tx_queue *tx_queue, | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | /** | ||
86 | * struct efx_tso_header - a DMA mapped buffer for packet headers | ||
87 | * @next: Linked list of free ones. | ||
88 | * The list is protected by the TX queue lock. | ||
89 | * @dma_unmap_len: Length to unmap for an oversize buffer, or 0. | ||
90 | * @dma_addr: The DMA address of the header below. | ||
91 | * | ||
92 | * This controls the memory used for a TSO header. Use TSOH_DATA() | ||
93 | * to find the packet header data. Use TSOH_SIZE() to calculate the | ||
94 | * total size required for a given packet header length. TSO headers | ||
95 | * in the free list are exactly %TSOH_STD_SIZE bytes in size. | ||
96 | */ | ||
97 | struct efx_tso_header { | ||
98 | union { | ||
99 | struct efx_tso_header *next; | ||
100 | size_t unmap_len; | ||
101 | }; | ||
102 | dma_addr_t dma_addr; | ||
103 | }; | ||
104 | |||
105 | static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue, | ||
106 | const struct sk_buff *skb); | ||
107 | static void efx_fini_tso(struct efx_tx_queue *tx_queue); | ||
108 | static void efx_tsoh_heap_free(struct efx_tx_queue *tx_queue, | ||
109 | struct efx_tso_header *tsoh); | ||
110 | |||
111 | static inline void efx_tsoh_free(struct efx_tx_queue *tx_queue, | ||
112 | struct efx_tx_buffer *buffer) | ||
113 | { | ||
114 | if (buffer->tsoh) { | ||
115 | if (likely(!buffer->tsoh->unmap_len)) { | ||
116 | buffer->tsoh->next = tx_queue->tso_headers_free; | ||
117 | tx_queue->tso_headers_free = buffer->tsoh; | ||
118 | } else { | ||
119 | efx_tsoh_heap_free(tx_queue, buffer->tsoh); | ||
120 | } | ||
121 | buffer->tsoh = NULL; | ||
122 | } | ||
123 | } | ||
124 | |||
85 | 125 | ||
86 | /* | 126 | /* |
87 | * Add a socket buffer to a TX queue | 127 | * Add a socket buffer to a TX queue |
@@ -114,6 +154,9 @@ static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue, | |||
114 | 154 | ||
115 | EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count); | 155 | EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count); |
116 | 156 | ||
157 | if (skb_shinfo((struct sk_buff *)skb)->gso_size) | ||
158 | return efx_enqueue_skb_tso(tx_queue, skb); | ||
159 | |||
117 | /* Get size of the initial fragment */ | 160 | /* Get size of the initial fragment */ |
118 | len = skb_headlen(skb); | 161 | len = skb_headlen(skb); |
119 | 162 | ||
@@ -166,6 +209,8 @@ static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue, | |||
166 | insert_ptr = (tx_queue->insert_count & | 209 | insert_ptr = (tx_queue->insert_count & |
167 | efx->type->txd_ring_mask); | 210 | efx->type->txd_ring_mask); |
168 | buffer = &tx_queue->buffer[insert_ptr]; | 211 | buffer = &tx_queue->buffer[insert_ptr]; |
212 | efx_tsoh_free(tx_queue, buffer); | ||
213 | EFX_BUG_ON_PARANOID(buffer->tsoh); | ||
169 | EFX_BUG_ON_PARANOID(buffer->skb); | 214 | EFX_BUG_ON_PARANOID(buffer->skb); |
170 | EFX_BUG_ON_PARANOID(buffer->len); | 215 | EFX_BUG_ON_PARANOID(buffer->len); |
171 | EFX_BUG_ON_PARANOID(buffer->continuation != 1); | 216 | EFX_BUG_ON_PARANOID(buffer->continuation != 1); |
@@ -432,6 +477,9 @@ void efx_fini_tx_queue(struct efx_tx_queue *tx_queue) | |||
432 | 477 | ||
433 | efx_release_tx_buffers(tx_queue); | 478 | efx_release_tx_buffers(tx_queue); |
434 | 479 | ||
480 | /* Free up TSO header cache */ | ||
481 | efx_fini_tso(tx_queue); | ||
482 | |||
435 | /* Release queue's stop on port, if any */ | 483 | /* Release queue's stop on port, if any */ |
436 | if (tx_queue->stopped) { | 484 | if (tx_queue->stopped) { |
437 | tx_queue->stopped = 0; | 485 | tx_queue->stopped = 0; |
@@ -450,3 +498,619 @@ void efx_remove_tx_queue(struct efx_tx_queue *tx_queue) | |||
450 | } | 498 | } |
451 | 499 | ||
452 | 500 | ||
501 | /* Efx TCP segmentation acceleration. | ||
502 | * | ||
503 | * Why? Because by doing it here in the driver we can go significantly | ||
504 | * faster than the GSO. | ||
505 | * | ||
506 | * Requires TX checksum offload support. | ||
507 | */ | ||
508 | |||
509 | /* Number of bytes inserted at the start of a TSO header buffer, | ||
510 | * similar to NET_IP_ALIGN. | ||
511 | */ | ||
512 | #if defined(__i386__) || defined(__x86_64__) | ||
513 | #define TSOH_OFFSET 0 | ||
514 | #else | ||
515 | #define TSOH_OFFSET NET_IP_ALIGN | ||
516 | #endif | ||
517 | |||
518 | #define TSOH_BUFFER(tsoh) ((u8 *)(tsoh + 1) + TSOH_OFFSET) | ||
519 | |||
520 | /* Total size of struct efx_tso_header, buffer and padding */ | ||
521 | #define TSOH_SIZE(hdr_len) \ | ||
522 | (sizeof(struct efx_tso_header) + TSOH_OFFSET + hdr_len) | ||
523 | |||
524 | /* Size of blocks on free list. Larger blocks must be allocated from | ||
525 | * the heap. | ||
526 | */ | ||
527 | #define TSOH_STD_SIZE 128 | ||
528 | |||
529 | #define PTR_DIFF(p1, p2) ((u8 *)(p1) - (u8 *)(p2)) | ||
530 | #define ETH_HDR_LEN(skb) (skb_network_header(skb) - (skb)->data) | ||
531 | #define SKB_TCP_OFF(skb) PTR_DIFF(tcp_hdr(skb), (skb)->data) | ||
532 | #define SKB_IPV4_OFF(skb) PTR_DIFF(ip_hdr(skb), (skb)->data) | ||
533 | |||
534 | /** | ||
535 | * struct tso_state - TSO state for an SKB | ||
536 | * @remaining_len: Bytes of data we've yet to segment | ||
537 | * @seqnum: Current sequence number | ||
538 | * @packet_space: Remaining space in current packet | ||
539 | * @ifc: Input fragment cursor. | ||
540 | * Where we are in the current fragment of the incoming SKB. These | ||
541 | * values get updated in place when we split a fragment over | ||
542 | * multiple packets. | ||
543 | * @p: Parameters. | ||
544 | * These values are set once at the start of the TSO send and do | ||
545 | * not get changed as the routine progresses. | ||
546 | * | ||
547 | * The state used during segmentation. It is put into this data structure | ||
548 | * just to make it easy to pass into inline functions. | ||
549 | */ | ||
550 | struct tso_state { | ||
551 | unsigned remaining_len; | ||
552 | unsigned seqnum; | ||
553 | unsigned packet_space; | ||
554 | |||
555 | struct { | ||
556 | /* DMA address of current position */ | ||
557 | dma_addr_t dma_addr; | ||
558 | /* Remaining length */ | ||
559 | unsigned int len; | ||
560 | /* DMA address and length of the whole fragment */ | ||
561 | unsigned int unmap_len; | ||
562 | dma_addr_t unmap_addr; | ||
563 | struct page *page; | ||
564 | unsigned page_off; | ||
565 | } ifc; | ||
566 | |||
567 | struct { | ||
568 | /* The number of bytes of header */ | ||
569 | unsigned int header_length; | ||
570 | |||
571 | /* The number of bytes to put in each outgoing segment. */ | ||
572 | int full_packet_size; | ||
573 | |||
574 | /* Current IPv4 ID, host endian. */ | ||
575 | unsigned ipv4_id; | ||
576 | } p; | ||
577 | }; | ||
578 | |||
579 | |||
580 | /* | ||
581 | * Verify that our various assumptions about sk_buffs and the conditions | ||
582 | * under which TSO will be attempted hold true. | ||
583 | */ | ||
584 | static inline void efx_tso_check_safe(const struct sk_buff *skb) | ||
585 | { | ||
586 | EFX_BUG_ON_PARANOID(skb->protocol != htons(ETH_P_IP)); | ||
587 | EFX_BUG_ON_PARANOID(((struct ethhdr *)skb->data)->h_proto != | ||
588 | skb->protocol); | ||
589 | EFX_BUG_ON_PARANOID(ip_hdr(skb)->protocol != IPPROTO_TCP); | ||
590 | EFX_BUG_ON_PARANOID((PTR_DIFF(tcp_hdr(skb), skb->data) | ||
591 | + (tcp_hdr(skb)->doff << 2u)) > | ||
592 | skb_headlen(skb)); | ||
593 | } | ||
594 | |||
595 | |||
596 | /* | ||
597 | * Allocate a page worth of efx_tso_header structures, and string them | ||
598 | * into the tx_queue->tso_headers_free linked list. Return 0 or -ENOMEM. | ||
599 | */ | ||
600 | static int efx_tsoh_block_alloc(struct efx_tx_queue *tx_queue) | ||
601 | { | ||
602 | |||
603 | struct pci_dev *pci_dev = tx_queue->efx->pci_dev; | ||
604 | struct efx_tso_header *tsoh; | ||
605 | dma_addr_t dma_addr; | ||
606 | u8 *base_kva, *kva; | ||
607 | |||
608 | base_kva = pci_alloc_consistent(pci_dev, PAGE_SIZE, &dma_addr); | ||
609 | if (base_kva == NULL) { | ||
610 | EFX_ERR(tx_queue->efx, "Unable to allocate page for TSO" | ||
611 | " headers\n"); | ||
612 | return -ENOMEM; | ||
613 | } | ||
614 | |||
615 | /* pci_alloc_consistent() allocates pages. */ | ||
616 | EFX_BUG_ON_PARANOID(dma_addr & (PAGE_SIZE - 1u)); | ||
617 | |||
618 | for (kva = base_kva; kva < base_kva + PAGE_SIZE; kva += TSOH_STD_SIZE) { | ||
619 | tsoh = (struct efx_tso_header *)kva; | ||
620 | tsoh->dma_addr = dma_addr + (TSOH_BUFFER(tsoh) - base_kva); | ||
621 | tsoh->next = tx_queue->tso_headers_free; | ||
622 | tx_queue->tso_headers_free = tsoh; | ||
623 | } | ||
624 | |||
625 | return 0; | ||
626 | } | ||
627 | |||
628 | |||
629 | /* Free up a TSO header, and all others in the same page. */ | ||
630 | static void efx_tsoh_block_free(struct efx_tx_queue *tx_queue, | ||
631 | struct efx_tso_header *tsoh, | ||
632 | struct pci_dev *pci_dev) | ||
633 | { | ||
634 | struct efx_tso_header **p; | ||
635 | unsigned long base_kva; | ||
636 | dma_addr_t base_dma; | ||
637 | |||
638 | base_kva = (unsigned long)tsoh & PAGE_MASK; | ||
639 | base_dma = tsoh->dma_addr & PAGE_MASK; | ||
640 | |||
641 | p = &tx_queue->tso_headers_free; | ||
642 | while (*p != NULL) | ||
643 | if (((unsigned long)*p & PAGE_MASK) == base_kva) | ||
644 | *p = (*p)->next; | ||
645 | else | ||
646 | p = &(*p)->next; | ||
647 | |||
648 | pci_free_consistent(pci_dev, PAGE_SIZE, (void *)base_kva, base_dma); | ||
649 | } | ||
650 | |||
651 | static struct efx_tso_header * | ||
652 | efx_tsoh_heap_alloc(struct efx_tx_queue *tx_queue, size_t header_len) | ||
653 | { | ||
654 | struct efx_tso_header *tsoh; | ||
655 | |||
656 | tsoh = kmalloc(TSOH_SIZE(header_len), GFP_ATOMIC | GFP_DMA); | ||
657 | if (unlikely(!tsoh)) | ||
658 | return NULL; | ||
659 | |||
660 | tsoh->dma_addr = pci_map_single(tx_queue->efx->pci_dev, | ||
661 | TSOH_BUFFER(tsoh), header_len, | ||
662 | PCI_DMA_TODEVICE); | ||
663 | if (unlikely(pci_dma_mapping_error(tsoh->dma_addr))) { | ||
664 | kfree(tsoh); | ||
665 | return NULL; | ||
666 | } | ||
667 | |||
668 | tsoh->unmap_len = header_len; | ||
669 | return tsoh; | ||
670 | } | ||
671 | |||
672 | static void | ||
673 | efx_tsoh_heap_free(struct efx_tx_queue *tx_queue, struct efx_tso_header *tsoh) | ||
674 | { | ||
675 | pci_unmap_single(tx_queue->efx->pci_dev, | ||
676 | tsoh->dma_addr, tsoh->unmap_len, | ||
677 | PCI_DMA_TODEVICE); | ||
678 | kfree(tsoh); | ||
679 | } | ||
680 | |||
681 | /** | ||
682 | * efx_tx_queue_insert - push descriptors onto the TX queue | ||
683 | * @tx_queue: Efx TX queue | ||
684 | * @dma_addr: DMA address of fragment | ||
685 | * @len: Length of fragment | ||
686 | * @skb: Only non-null for end of last segment | ||
687 | * @end_of_packet: True if last fragment in a packet | ||
688 | * @unmap_addr: DMA address of fragment for unmapping | ||
689 | * @unmap_len: Only set this in last segment of a fragment | ||
690 | * | ||
691 | * Push descriptors onto the TX queue. Return 0 on success or 1 if | ||
692 | * @tx_queue full. | ||
693 | */ | ||
694 | static int efx_tx_queue_insert(struct efx_tx_queue *tx_queue, | ||
695 | dma_addr_t dma_addr, unsigned len, | ||
696 | const struct sk_buff *skb, int end_of_packet, | ||
697 | dma_addr_t unmap_addr, unsigned unmap_len) | ||
698 | { | ||
699 | struct efx_tx_buffer *buffer; | ||
700 | struct efx_nic *efx = tx_queue->efx; | ||
701 | unsigned dma_len, fill_level, insert_ptr, misalign; | ||
702 | int q_space; | ||
703 | |||
704 | EFX_BUG_ON_PARANOID(len <= 0); | ||
705 | |||
706 | fill_level = tx_queue->insert_count - tx_queue->old_read_count; | ||
707 | /* -1 as there is no way to represent all descriptors used */ | ||
708 | q_space = efx->type->txd_ring_mask - 1 - fill_level; | ||
709 | |||
710 | while (1) { | ||
711 | if (unlikely(q_space-- <= 0)) { | ||
712 | /* It might be that completions have happened | ||
713 | * since the xmit path last checked. Update | ||
714 | * the xmit path's copy of read_count. | ||
715 | */ | ||
716 | ++tx_queue->stopped; | ||
717 | /* This memory barrier protects the change of | ||
718 | * stopped from the access of read_count. */ | ||
719 | smp_mb(); | ||
720 | tx_queue->old_read_count = | ||
721 | *(volatile unsigned *)&tx_queue->read_count; | ||
722 | fill_level = (tx_queue->insert_count | ||
723 | - tx_queue->old_read_count); | ||
724 | q_space = efx->type->txd_ring_mask - 1 - fill_level; | ||
725 | if (unlikely(q_space-- <= 0)) | ||
726 | return 1; | ||
727 | smp_mb(); | ||
728 | --tx_queue->stopped; | ||
729 | } | ||
730 | |||
731 | insert_ptr = tx_queue->insert_count & efx->type->txd_ring_mask; | ||
732 | buffer = &tx_queue->buffer[insert_ptr]; | ||
733 | ++tx_queue->insert_count; | ||
734 | |||
735 | EFX_BUG_ON_PARANOID(tx_queue->insert_count - | ||
736 | tx_queue->read_count > | ||
737 | efx->type->txd_ring_mask); | ||
738 | |||
739 | efx_tsoh_free(tx_queue, buffer); | ||
740 | EFX_BUG_ON_PARANOID(buffer->len); | ||
741 | EFX_BUG_ON_PARANOID(buffer->unmap_len); | ||
742 | EFX_BUG_ON_PARANOID(buffer->skb); | ||
743 | EFX_BUG_ON_PARANOID(buffer->continuation != 1); | ||
744 | EFX_BUG_ON_PARANOID(buffer->tsoh); | ||
745 | |||
746 | buffer->dma_addr = dma_addr; | ||
747 | |||
748 | /* Ensure we do not cross a boundary unsupported by H/W */ | ||
749 | dma_len = (~dma_addr & efx->type->tx_dma_mask) + 1; | ||
750 | |||
751 | misalign = (unsigned)dma_addr & efx->type->bug5391_mask; | ||
752 | if (misalign && dma_len + misalign > 512) | ||
753 | dma_len = 512 - misalign; | ||
754 | |||
755 | /* If there is enough space to send then do so */ | ||
756 | if (dma_len >= len) | ||
757 | break; | ||
758 | |||
759 | buffer->len = dma_len; /* Don't set the other members */ | ||
760 | dma_addr += dma_len; | ||
761 | len -= dma_len; | ||
762 | } | ||
763 | |||
764 | EFX_BUG_ON_PARANOID(!len); | ||
765 | buffer->len = len; | ||
766 | buffer->skb = skb; | ||
767 | buffer->continuation = !end_of_packet; | ||
768 | buffer->unmap_addr = unmap_addr; | ||
769 | buffer->unmap_len = unmap_len; | ||
770 | return 0; | ||
771 | } | ||
772 | |||
773 | |||
774 | /* | ||
775 | * Put a TSO header into the TX queue. | ||
776 | * | ||
777 | * This is special-cased because we know that it is small enough to fit in | ||
778 | * a single fragment, and we know it doesn't cross a page boundary. It | ||
779 | * also allows us to not worry about end-of-packet etc. | ||
780 | */ | ||
781 | static inline void efx_tso_put_header(struct efx_tx_queue *tx_queue, | ||
782 | struct efx_tso_header *tsoh, unsigned len) | ||
783 | { | ||
784 | struct efx_tx_buffer *buffer; | ||
785 | |||
786 | buffer = &tx_queue->buffer[tx_queue->insert_count & | ||
787 | tx_queue->efx->type->txd_ring_mask]; | ||
788 | efx_tsoh_free(tx_queue, buffer); | ||
789 | EFX_BUG_ON_PARANOID(buffer->len); | ||
790 | EFX_BUG_ON_PARANOID(buffer->unmap_len); | ||
791 | EFX_BUG_ON_PARANOID(buffer->skb); | ||
792 | EFX_BUG_ON_PARANOID(buffer->continuation != 1); | ||
793 | EFX_BUG_ON_PARANOID(buffer->tsoh); | ||
794 | buffer->len = len; | ||
795 | buffer->dma_addr = tsoh->dma_addr; | ||
796 | buffer->tsoh = tsoh; | ||
797 | |||
798 | ++tx_queue->insert_count; | ||
799 | } | ||
800 | |||
801 | |||
802 | /* Remove descriptors put into a tx_queue. */ | ||
803 | static void efx_enqueue_unwind(struct efx_tx_queue *tx_queue) | ||
804 | { | ||
805 | struct efx_tx_buffer *buffer; | ||
806 | |||
807 | /* Work backwards until we hit the original insert pointer value */ | ||
808 | while (tx_queue->insert_count != tx_queue->write_count) { | ||
809 | --tx_queue->insert_count; | ||
810 | buffer = &tx_queue->buffer[tx_queue->insert_count & | ||
811 | tx_queue->efx->type->txd_ring_mask]; | ||
812 | efx_tsoh_free(tx_queue, buffer); | ||
813 | EFX_BUG_ON_PARANOID(buffer->skb); | ||
814 | buffer->len = 0; | ||
815 | buffer->continuation = 1; | ||
816 | if (buffer->unmap_len) { | ||
817 | pci_unmap_page(tx_queue->efx->pci_dev, | ||
818 | buffer->unmap_addr, | ||
819 | buffer->unmap_len, PCI_DMA_TODEVICE); | ||
820 | buffer->unmap_len = 0; | ||
821 | } | ||
822 | } | ||
823 | } | ||
824 | |||
825 | |||
826 | /* Parse the SKB header and initialise state. */ | ||
827 | static inline void tso_start(struct tso_state *st, const struct sk_buff *skb) | ||
828 | { | ||
829 | /* All ethernet/IP/TCP headers combined size is TCP header size | ||
830 | * plus offset of TCP header relative to start of packet. | ||
831 | */ | ||
832 | st->p.header_length = ((tcp_hdr(skb)->doff << 2u) | ||
833 | + PTR_DIFF(tcp_hdr(skb), skb->data)); | ||
834 | st->p.full_packet_size = (st->p.header_length | ||
835 | + skb_shinfo(skb)->gso_size); | ||
836 | |||
837 | st->p.ipv4_id = ntohs(ip_hdr(skb)->id); | ||
838 | st->seqnum = ntohl(tcp_hdr(skb)->seq); | ||
839 | |||
840 | EFX_BUG_ON_PARANOID(tcp_hdr(skb)->urg); | ||
841 | EFX_BUG_ON_PARANOID(tcp_hdr(skb)->syn); | ||
842 | EFX_BUG_ON_PARANOID(tcp_hdr(skb)->rst); | ||
843 | |||
844 | st->packet_space = st->p.full_packet_size; | ||
845 | st->remaining_len = skb->len - st->p.header_length; | ||
846 | } | ||
847 | |||
848 | |||
849 | /** | ||
850 | * tso_get_fragment - record fragment details and map for DMA | ||
851 | * @st: TSO state | ||
852 | * @efx: Efx NIC | ||
853 | * @data: Pointer to fragment data | ||
854 | * @len: Length of fragment | ||
855 | * | ||
856 | * Record fragment details and map for DMA. Return 0 on success, or | ||
857 | * -%ENOMEM if DMA mapping fails. | ||
858 | */ | ||
859 | static inline int tso_get_fragment(struct tso_state *st, struct efx_nic *efx, | ||
860 | int len, struct page *page, int page_off) | ||
861 | { | ||
862 | |||
863 | st->ifc.unmap_addr = pci_map_page(efx->pci_dev, page, page_off, | ||
864 | len, PCI_DMA_TODEVICE); | ||
865 | if (likely(!pci_dma_mapping_error(st->ifc.unmap_addr))) { | ||
866 | st->ifc.unmap_len = len; | ||
867 | st->ifc.len = len; | ||
868 | st->ifc.dma_addr = st->ifc.unmap_addr; | ||
869 | st->ifc.page = page; | ||
870 | st->ifc.page_off = page_off; | ||
871 | return 0; | ||
872 | } | ||
873 | return -ENOMEM; | ||
874 | } | ||
875 | |||
876 | |||
877 | /** | ||
878 | * tso_fill_packet_with_fragment - form descriptors for the current fragment | ||
879 | * @tx_queue: Efx TX queue | ||
880 | * @skb: Socket buffer | ||
881 | * @st: TSO state | ||
882 | * | ||
883 | * Form descriptors for the current fragment, until we reach the end | ||
884 | * of fragment or end-of-packet. Return 0 on success, 1 if not enough | ||
885 | * space in @tx_queue. | ||
886 | */ | ||
887 | static inline int tso_fill_packet_with_fragment(struct efx_tx_queue *tx_queue, | ||
888 | const struct sk_buff *skb, | ||
889 | struct tso_state *st) | ||
890 | { | ||
891 | |||
892 | int n, end_of_packet, rc; | ||
893 | |||
894 | if (st->ifc.len == 0) | ||
895 | return 0; | ||
896 | if (st->packet_space == 0) | ||
897 | return 0; | ||
898 | |||
899 | EFX_BUG_ON_PARANOID(st->ifc.len <= 0); | ||
900 | EFX_BUG_ON_PARANOID(st->packet_space <= 0); | ||
901 | |||
902 | n = min(st->ifc.len, st->packet_space); | ||
903 | |||
904 | st->packet_space -= n; | ||
905 | st->remaining_len -= n; | ||
906 | st->ifc.len -= n; | ||
907 | st->ifc.page_off += n; | ||
908 | end_of_packet = st->remaining_len == 0 || st->packet_space == 0; | ||
909 | |||
910 | rc = efx_tx_queue_insert(tx_queue, st->ifc.dma_addr, n, | ||
911 | st->remaining_len ? NULL : skb, | ||
912 | end_of_packet, st->ifc.unmap_addr, | ||
913 | st->ifc.len ? 0 : st->ifc.unmap_len); | ||
914 | |||
915 | st->ifc.dma_addr += n; | ||
916 | |||
917 | return rc; | ||
918 | } | ||
919 | |||
920 | |||
921 | /** | ||
922 | * tso_start_new_packet - generate a new header and prepare for the new packet | ||
923 | * @tx_queue: Efx TX queue | ||
924 | * @skb: Socket buffer | ||
925 | * @st: TSO state | ||
926 | * | ||
927 | * Generate a new header and prepare for the new packet. Return 0 on | ||
928 | * success, or -1 if failed to alloc header. | ||
929 | */ | ||
930 | static inline int tso_start_new_packet(struct efx_tx_queue *tx_queue, | ||
931 | const struct sk_buff *skb, | ||
932 | struct tso_state *st) | ||
933 | { | ||
934 | struct efx_tso_header *tsoh; | ||
935 | struct iphdr *tsoh_iph; | ||
936 | struct tcphdr *tsoh_th; | ||
937 | unsigned ip_length; | ||
938 | u8 *header; | ||
939 | |||
940 | /* Allocate a DMA-mapped header buffer. */ | ||
941 | if (likely(TSOH_SIZE(st->p.header_length) <= TSOH_STD_SIZE)) { | ||
942 | if (tx_queue->tso_headers_free == NULL) | ||
943 | if (efx_tsoh_block_alloc(tx_queue)) | ||
944 | return -1; | ||
945 | EFX_BUG_ON_PARANOID(!tx_queue->tso_headers_free); | ||
946 | tsoh = tx_queue->tso_headers_free; | ||
947 | tx_queue->tso_headers_free = tsoh->next; | ||
948 | tsoh->unmap_len = 0; | ||
949 | } else { | ||
950 | tx_queue->tso_long_headers++; | ||
951 | tsoh = efx_tsoh_heap_alloc(tx_queue, st->p.header_length); | ||
952 | if (unlikely(!tsoh)) | ||
953 | return -1; | ||
954 | } | ||
955 | |||
956 | header = TSOH_BUFFER(tsoh); | ||
957 | tsoh_th = (struct tcphdr *)(header + SKB_TCP_OFF(skb)); | ||
958 | tsoh_iph = (struct iphdr *)(header + SKB_IPV4_OFF(skb)); | ||
959 | |||
960 | /* Copy and update the headers. */ | ||
961 | memcpy(header, skb->data, st->p.header_length); | ||
962 | |||
963 | tsoh_th->seq = htonl(st->seqnum); | ||
964 | st->seqnum += skb_shinfo(skb)->gso_size; | ||
965 | if (st->remaining_len > skb_shinfo(skb)->gso_size) { | ||
966 | /* This packet will not finish the TSO burst. */ | ||
967 | ip_length = st->p.full_packet_size - ETH_HDR_LEN(skb); | ||
968 | tsoh_th->fin = 0; | ||
969 | tsoh_th->psh = 0; | ||
970 | } else { | ||
971 | /* This packet will be the last in the TSO burst. */ | ||
972 | ip_length = (st->p.header_length - ETH_HDR_LEN(skb) | ||
973 | + st->remaining_len); | ||
974 | tsoh_th->fin = tcp_hdr(skb)->fin; | ||
975 | tsoh_th->psh = tcp_hdr(skb)->psh; | ||
976 | } | ||
977 | tsoh_iph->tot_len = htons(ip_length); | ||
978 | |||
979 | /* Linux leaves suitable gaps in the IP ID space for us to fill. */ | ||
980 | tsoh_iph->id = htons(st->p.ipv4_id); | ||
981 | st->p.ipv4_id++; | ||
982 | |||
983 | st->packet_space = skb_shinfo(skb)->gso_size; | ||
984 | ++tx_queue->tso_packets; | ||
985 | |||
986 | /* Form a descriptor for this header. */ | ||
987 | efx_tso_put_header(tx_queue, tsoh, st->p.header_length); | ||
988 | |||
989 | return 0; | ||
990 | } | ||
991 | |||
992 | |||
993 | /** | ||
994 | * efx_enqueue_skb_tso - segment and transmit a TSO socket buffer | ||
995 | * @tx_queue: Efx TX queue | ||
996 | * @skb: Socket buffer | ||
997 | * | ||
998 | * Context: You must hold netif_tx_lock() to call this function. | ||
999 | * | ||
1000 | * Add socket buffer @skb to @tx_queue, doing TSO or return != 0 if | ||
1001 | * @skb was not enqueued. In all cases @skb is consumed. Return | ||
1002 | * %NETDEV_TX_OK or %NETDEV_TX_BUSY. | ||
1003 | */ | ||
1004 | static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue, | ||
1005 | const struct sk_buff *skb) | ||
1006 | { | ||
1007 | int frag_i, rc, rc2 = NETDEV_TX_OK; | ||
1008 | struct tso_state state; | ||
1009 | skb_frag_t *f; | ||
1010 | |||
1011 | /* Verify TSO is safe - these checks should never fail. */ | ||
1012 | efx_tso_check_safe(skb); | ||
1013 | |||
1014 | EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count); | ||
1015 | |||
1016 | tso_start(&state, skb); | ||
1017 | |||
1018 | /* Assume that skb header area contains exactly the headers, and | ||
1019 | * all payload is in the frag list. | ||
1020 | */ | ||
1021 | if (skb_headlen(skb) == state.p.header_length) { | ||
1022 | /* Grab the first payload fragment. */ | ||
1023 | EFX_BUG_ON_PARANOID(skb_shinfo(skb)->nr_frags < 1); | ||
1024 | frag_i = 0; | ||
1025 | f = &skb_shinfo(skb)->frags[frag_i]; | ||
1026 | rc = tso_get_fragment(&state, tx_queue->efx, | ||
1027 | f->size, f->page, f->page_offset); | ||
1028 | if (rc) | ||
1029 | goto mem_err; | ||
1030 | } else { | ||
1031 | /* It may look like this code fragment assumes that the | ||
1032 | * skb->data portion does not cross a page boundary, but | ||
1033 | * that is not the case. It is guaranteed to be direct | ||
1034 | * mapped memory, and therefore is physically contiguous, | ||
1035 | * and so DMA will work fine. kmap_atomic() on this region | ||
1036 | * will just return the direct mapping, so that will work | ||
1037 | * too. | ||
1038 | */ | ||
1039 | int page_off = (unsigned long)skb->data & (PAGE_SIZE - 1); | ||
1040 | int hl = state.p.header_length; | ||
1041 | rc = tso_get_fragment(&state, tx_queue->efx, | ||
1042 | skb_headlen(skb) - hl, | ||
1043 | virt_to_page(skb->data), page_off + hl); | ||
1044 | if (rc) | ||
1045 | goto mem_err; | ||
1046 | frag_i = -1; | ||
1047 | } | ||
1048 | |||
1049 | if (tso_start_new_packet(tx_queue, skb, &state) < 0) | ||
1050 | goto mem_err; | ||
1051 | |||
1052 | while (1) { | ||
1053 | rc = tso_fill_packet_with_fragment(tx_queue, skb, &state); | ||
1054 | if (unlikely(rc)) | ||
1055 | goto stop; | ||
1056 | |||
1057 | /* Move onto the next fragment? */ | ||
1058 | if (state.ifc.len == 0) { | ||
1059 | if (++frag_i >= skb_shinfo(skb)->nr_frags) | ||
1060 | /* End of payload reached. */ | ||
1061 | break; | ||
1062 | f = &skb_shinfo(skb)->frags[frag_i]; | ||
1063 | rc = tso_get_fragment(&state, tx_queue->efx, | ||
1064 | f->size, f->page, f->page_offset); | ||
1065 | if (rc) | ||
1066 | goto mem_err; | ||
1067 | } | ||
1068 | |||
1069 | /* Start at new packet? */ | ||
1070 | if (state.packet_space == 0 && | ||
1071 | tso_start_new_packet(tx_queue, skb, &state) < 0) | ||
1072 | goto mem_err; | ||
1073 | } | ||
1074 | |||
1075 | /* Pass off to hardware */ | ||
1076 | falcon_push_buffers(tx_queue); | ||
1077 | |||
1078 | tx_queue->tso_bursts++; | ||
1079 | return NETDEV_TX_OK; | ||
1080 | |||
1081 | mem_err: | ||
1082 | EFX_ERR(tx_queue->efx, "Out of memory for TSO headers, or PCI mapping" | ||
1083 | " error\n"); | ||
1084 | dev_kfree_skb_any((struct sk_buff *)skb); | ||
1085 | goto unwind; | ||
1086 | |||
1087 | stop: | ||
1088 | rc2 = NETDEV_TX_BUSY; | ||
1089 | |||
1090 | /* Stop the queue if it wasn't stopped before. */ | ||
1091 | if (tx_queue->stopped == 1) | ||
1092 | efx_stop_queue(tx_queue->efx); | ||
1093 | |||
1094 | unwind: | ||
1095 | efx_enqueue_unwind(tx_queue); | ||
1096 | return rc2; | ||
1097 | } | ||
1098 | |||
1099 | |||
1100 | /* | ||
1101 | * Free up all TSO datastructures associated with tx_queue. This | ||
1102 | * routine should be called only once the tx_queue is both empty and | ||
1103 | * will no longer be used. | ||
1104 | */ | ||
1105 | static void efx_fini_tso(struct efx_tx_queue *tx_queue) | ||
1106 | { | ||
1107 | unsigned i; | ||
1108 | |||
1109 | if (tx_queue->buffer) | ||
1110 | for (i = 0; i <= tx_queue->efx->type->txd_ring_mask; ++i) | ||
1111 | efx_tsoh_free(tx_queue, &tx_queue->buffer[i]); | ||
1112 | |||
1113 | while (tx_queue->tso_headers_free != NULL) | ||
1114 | efx_tsoh_block_free(tx_queue, tx_queue->tso_headers_free, | ||
1115 | tx_queue->efx->pci_dev); | ||
1116 | } | ||
diff --git a/drivers/net/sfc/xfp_phy.c b/drivers/net/sfc/xfp_phy.c index 66dd5bf1eaa9..3b9f9ddbc372 100644 --- a/drivers/net/sfc/xfp_phy.c +++ b/drivers/net/sfc/xfp_phy.c | |||
@@ -24,6 +24,10 @@ | |||
24 | MDIO_MMDREG_DEVS0_PMAPMD | \ | 24 | MDIO_MMDREG_DEVS0_PMAPMD | \ |
25 | MDIO_MMDREG_DEVS0_PHYXS) | 25 | MDIO_MMDREG_DEVS0_PHYXS) |
26 | 26 | ||
27 | #define XFP_LOOPBACKS ((1 << LOOPBACK_PCS) | \ | ||
28 | (1 << LOOPBACK_PMAPMD) | \ | ||
29 | (1 << LOOPBACK_NETWORK)) | ||
30 | |||
27 | /****************************************************************************/ | 31 | /****************************************************************************/ |
28 | /* Quake-specific MDIO registers */ | 32 | /* Quake-specific MDIO registers */ |
29 | #define MDIO_QUAKE_LED0_REG (0xD006) | 33 | #define MDIO_QUAKE_LED0_REG (0xD006) |
@@ -35,6 +39,10 @@ void xfp_set_led(struct efx_nic *p, int led, int mode) | |||
35 | mode); | 39 | mode); |
36 | } | 40 | } |
37 | 41 | ||
42 | struct xfp_phy_data { | ||
43 | int tx_disabled; | ||
44 | }; | ||
45 | |||
38 | #define XFP_MAX_RESET_TIME 500 | 46 | #define XFP_MAX_RESET_TIME 500 |
39 | #define XFP_RESET_WAIT 10 | 47 | #define XFP_RESET_WAIT 10 |
40 | 48 | ||
@@ -72,18 +80,31 @@ static int xfp_reset_phy(struct efx_nic *efx) | |||
72 | 80 | ||
73 | static int xfp_phy_init(struct efx_nic *efx) | 81 | static int xfp_phy_init(struct efx_nic *efx) |
74 | { | 82 | { |
83 | struct xfp_phy_data *phy_data; | ||
75 | u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS); | 84 | u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS); |
76 | int rc; | 85 | int rc; |
77 | 86 | ||
87 | phy_data = kzalloc(sizeof(struct xfp_phy_data), GFP_KERNEL); | ||
88 | efx->phy_data = (void *) phy_data; | ||
89 | |||
78 | EFX_INFO(efx, "XFP: PHY ID reg %x (OUI %x model %x revision" | 90 | EFX_INFO(efx, "XFP: PHY ID reg %x (OUI %x model %x revision" |
79 | " %x)\n", devid, MDIO_ID_OUI(devid), MDIO_ID_MODEL(devid), | 91 | " %x)\n", devid, MDIO_ID_OUI(devid), MDIO_ID_MODEL(devid), |
80 | MDIO_ID_REV(devid)); | 92 | MDIO_ID_REV(devid)); |
81 | 93 | ||
94 | phy_data->tx_disabled = efx->tx_disabled; | ||
95 | |||
82 | rc = xfp_reset_phy(efx); | 96 | rc = xfp_reset_phy(efx); |
83 | 97 | ||
84 | EFX_INFO(efx, "XFP: PHY init %s.\n", | 98 | EFX_INFO(efx, "XFP: PHY init %s.\n", |
85 | rc ? "failed" : "successful"); | 99 | rc ? "failed" : "successful"); |
100 | if (rc < 0) | ||
101 | goto fail; | ||
86 | 102 | ||
103 | return 0; | ||
104 | |||
105 | fail: | ||
106 | kfree(efx->phy_data); | ||
107 | efx->phy_data = NULL; | ||
87 | return rc; | 108 | return rc; |
88 | } | 109 | } |
89 | 110 | ||
@@ -110,6 +131,16 @@ static int xfp_phy_check_hw(struct efx_nic *efx) | |||
110 | 131 | ||
111 | static void xfp_phy_reconfigure(struct efx_nic *efx) | 132 | static void xfp_phy_reconfigure(struct efx_nic *efx) |
112 | { | 133 | { |
134 | struct xfp_phy_data *phy_data = efx->phy_data; | ||
135 | |||
136 | /* Reset the PHY when moving from tx off to tx on */ | ||
137 | if (phy_data->tx_disabled && !efx->tx_disabled) | ||
138 | xfp_reset_phy(efx); | ||
139 | |||
140 | mdio_clause45_transmit_disable(efx); | ||
141 | mdio_clause45_phy_reconfigure(efx); | ||
142 | |||
143 | phy_data->tx_disabled = efx->tx_disabled; | ||
113 | efx->link_up = xfp_link_ok(efx); | 144 | efx->link_up = xfp_link_ok(efx); |
114 | efx->link_options = GM_LPA_10000FULL; | 145 | efx->link_options = GM_LPA_10000FULL; |
115 | } | 146 | } |
@@ -119,6 +150,10 @@ static void xfp_phy_fini(struct efx_nic *efx) | |||
119 | { | 150 | { |
120 | /* Clobber the LED if it was blinking */ | 151 | /* Clobber the LED if it was blinking */ |
121 | efx->board_info.blink(efx, 0); | 152 | efx->board_info.blink(efx, 0); |
153 | |||
154 | /* Free the context block */ | ||
155 | kfree(efx->phy_data); | ||
156 | efx->phy_data = NULL; | ||
122 | } | 157 | } |
123 | 158 | ||
124 | struct efx_phy_operations falcon_xfp_phy_ops = { | 159 | struct efx_phy_operations falcon_xfp_phy_ops = { |
@@ -129,4 +164,5 @@ struct efx_phy_operations falcon_xfp_phy_ops = { | |||
129 | .clear_interrupt = xfp_phy_clear_interrupt, | 164 | .clear_interrupt = xfp_phy_clear_interrupt, |
130 | .reset_xaui = efx_port_dummy_op_void, | 165 | .reset_xaui = efx_port_dummy_op_void, |
131 | .mmds = XFP_REQUIRED_DEVS, | 166 | .mmds = XFP_REQUIRED_DEVS, |
167 | .loopbacks = XFP_LOOPBACKS, | ||
132 | }; | 168 | }; |
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 7bb3ba9bcbd8..c0a5eea20007 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h | |||
@@ -1966,13 +1966,13 @@ struct sky2_status_le { | |||
1966 | struct tx_ring_info { | 1966 | struct tx_ring_info { |
1967 | struct sk_buff *skb; | 1967 | struct sk_buff *skb; |
1968 | DECLARE_PCI_UNMAP_ADDR(mapaddr); | 1968 | DECLARE_PCI_UNMAP_ADDR(mapaddr); |
1969 | DECLARE_PCI_UNMAP_ADDR(maplen); | 1969 | DECLARE_PCI_UNMAP_LEN(maplen); |
1970 | }; | 1970 | }; |
1971 | 1971 | ||
1972 | struct rx_ring_info { | 1972 | struct rx_ring_info { |
1973 | struct sk_buff *skb; | 1973 | struct sk_buff *skb; |
1974 | dma_addr_t data_addr; | 1974 | dma_addr_t data_addr; |
1975 | DECLARE_PCI_UNMAP_ADDR(data_size); | 1975 | DECLARE_PCI_UNMAP_LEN(data_size); |
1976 | dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT]; | 1976 | dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT]; |
1977 | }; | 1977 | }; |
1978 | 1978 | ||
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index 8005dd16fb4e..d5140aed7b79 100644 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig | |||
@@ -150,11 +150,9 @@ config HDLC_FR | |||
150 | 150 | ||
151 | config HDLC_PPP | 151 | config HDLC_PPP |
152 | tristate "Synchronous Point-to-Point Protocol (PPP) support" | 152 | tristate "Synchronous Point-to-Point Protocol (PPP) support" |
153 | depends on HDLC && BROKEN | 153 | depends on HDLC |
154 | help | 154 | help |
155 | Generic HDLC driver supporting PPP over WAN connections. | 155 | Generic HDLC driver supporting PPP over WAN connections. |
156 | This module is currently broken and will cause a kernel panic | ||
157 | when a device configured in PPP mode is activated. | ||
158 | 156 | ||
159 | It will be replaced by new PPP implementation in Linux 2.6.26. | 157 | It will be replaced by new PPP implementation in Linux 2.6.26. |
160 | 158 | ||
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 45ddfc9763cc..b0fce1387eaf 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c | |||
@@ -629,7 +629,7 @@ static void sppp_channel_init(struct channel_data *chan) | |||
629 | d->base_addr = chan->cosa->datareg; | 629 | d->base_addr = chan->cosa->datareg; |
630 | d->irq = chan->cosa->irq; | 630 | d->irq = chan->cosa->irq; |
631 | d->dma = chan->cosa->dma; | 631 | d->dma = chan->cosa->dma; |
632 | d->priv = chan; | 632 | d->ml_priv = chan; |
633 | sppp_attach(&chan->pppdev); | 633 | sppp_attach(&chan->pppdev); |
634 | if (register_netdev(d)) { | 634 | if (register_netdev(d)) { |
635 | printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); | 635 | printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); |
@@ -650,7 +650,7 @@ static void sppp_channel_delete(struct channel_data *chan) | |||
650 | 650 | ||
651 | static int cosa_sppp_open(struct net_device *d) | 651 | static int cosa_sppp_open(struct net_device *d) |
652 | { | 652 | { |
653 | struct channel_data *chan = d->priv; | 653 | struct channel_data *chan = d->ml_priv; |
654 | int err; | 654 | int err; |
655 | unsigned long flags; | 655 | unsigned long flags; |
656 | 656 | ||
@@ -690,7 +690,7 @@ static int cosa_sppp_open(struct net_device *d) | |||
690 | 690 | ||
691 | static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev) | 691 | static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev) |
692 | { | 692 | { |
693 | struct channel_data *chan = dev->priv; | 693 | struct channel_data *chan = dev->ml_priv; |
694 | 694 | ||
695 | netif_stop_queue(dev); | 695 | netif_stop_queue(dev); |
696 | 696 | ||
@@ -701,7 +701,7 @@ static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev) | |||
701 | 701 | ||
702 | static void cosa_sppp_timeout(struct net_device *dev) | 702 | static void cosa_sppp_timeout(struct net_device *dev) |
703 | { | 703 | { |
704 | struct channel_data *chan = dev->priv; | 704 | struct channel_data *chan = dev->ml_priv; |
705 | 705 | ||
706 | if (test_bit(RXBIT, &chan->cosa->rxtx)) { | 706 | if (test_bit(RXBIT, &chan->cosa->rxtx)) { |
707 | chan->stats.rx_errors++; | 707 | chan->stats.rx_errors++; |
@@ -720,7 +720,7 @@ static void cosa_sppp_timeout(struct net_device *dev) | |||
720 | 720 | ||
721 | static int cosa_sppp_close(struct net_device *d) | 721 | static int cosa_sppp_close(struct net_device *d) |
722 | { | 722 | { |
723 | struct channel_data *chan = d->priv; | 723 | struct channel_data *chan = d->ml_priv; |
724 | unsigned long flags; | 724 | unsigned long flags; |
725 | 725 | ||
726 | netif_stop_queue(d); | 726 | netif_stop_queue(d); |
@@ -800,7 +800,7 @@ static int sppp_tx_done(struct channel_data *chan, int size) | |||
800 | 800 | ||
801 | static struct net_device_stats *cosa_net_stats(struct net_device *dev) | 801 | static struct net_device_stats *cosa_net_stats(struct net_device *dev) |
802 | { | 802 | { |
803 | struct channel_data *chan = dev->priv; | 803 | struct channel_data *chan = dev->ml_priv; |
804 | return &chan->stats; | 804 | return &chan->stats; |
805 | } | 805 | } |
806 | 806 | ||
@@ -1217,7 +1217,7 @@ static int cosa_sppp_ioctl(struct net_device *dev, struct ifreq *ifr, | |||
1217 | int cmd) | 1217 | int cmd) |
1218 | { | 1218 | { |
1219 | int rv; | 1219 | int rv; |
1220 | struct channel_data *chan = dev->priv; | 1220 | struct channel_data *chan = dev->ml_priv; |
1221 | rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data); | 1221 | rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data); |
1222 | if (rv == -ENOIOCTLCMD) { | 1222 | if (rv == -ENOIOCTLCMD) { |
1223 | return sppp_do_ioctl(dev, ifr, cmd); | 1223 | return sppp_do_ioctl(dev, ifr, cmd); |
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c index 10396d9686f4..00308337928e 100644 --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c | |||
@@ -45,7 +45,7 @@ static int ppp_open(struct net_device *dev) | |||
45 | int (*old_ioctl)(struct net_device *, struct ifreq *, int); | 45 | int (*old_ioctl)(struct net_device *, struct ifreq *, int); |
46 | int result; | 46 | int result; |
47 | 47 | ||
48 | dev->priv = &state(hdlc)->syncppp_ptr; | 48 | dev->ml_priv = &state(hdlc)->syncppp_ptr; |
49 | state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev; | 49 | state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev; |
50 | state(hdlc)->pppdev.dev = dev; | 50 | state(hdlc)->pppdev.dev = dev; |
51 | 51 | ||
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c index 83dbc924fcb5..f3065d3473fd 100644 --- a/drivers/net/wan/hostess_sv11.c +++ b/drivers/net/wan/hostess_sv11.c | |||
@@ -75,7 +75,7 @@ static void hostess_input(struct z8530_channel *c, struct sk_buff *skb) | |||
75 | 75 | ||
76 | static int hostess_open(struct net_device *d) | 76 | static int hostess_open(struct net_device *d) |
77 | { | 77 | { |
78 | struct sv11_device *sv11=d->priv; | 78 | struct sv11_device *sv11=d->ml_priv; |
79 | int err = -1; | 79 | int err = -1; |
80 | 80 | ||
81 | /* | 81 | /* |
@@ -128,7 +128,7 @@ static int hostess_open(struct net_device *d) | |||
128 | 128 | ||
129 | static int hostess_close(struct net_device *d) | 129 | static int hostess_close(struct net_device *d) |
130 | { | 130 | { |
131 | struct sv11_device *sv11=d->priv; | 131 | struct sv11_device *sv11=d->ml_priv; |
132 | /* | 132 | /* |
133 | * Discard new frames | 133 | * Discard new frames |
134 | */ | 134 | */ |
@@ -159,14 +159,14 @@ static int hostess_close(struct net_device *d) | |||
159 | 159 | ||
160 | static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd) | 160 | static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd) |
161 | { | 161 | { |
162 | /* struct sv11_device *sv11=d->priv; | 162 | /* struct sv11_device *sv11=d->ml_priv; |
163 | z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */ | 163 | z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */ |
164 | return sppp_do_ioctl(d, ifr,cmd); | 164 | return sppp_do_ioctl(d, ifr,cmd); |
165 | } | 165 | } |
166 | 166 | ||
167 | static struct net_device_stats *hostess_get_stats(struct net_device *d) | 167 | static struct net_device_stats *hostess_get_stats(struct net_device *d) |
168 | { | 168 | { |
169 | struct sv11_device *sv11=d->priv; | 169 | struct sv11_device *sv11=d->ml_priv; |
170 | if(sv11) | 170 | if(sv11) |
171 | return z8530_get_stats(&sv11->sync.chanA); | 171 | return z8530_get_stats(&sv11->sync.chanA); |
172 | else | 172 | else |
@@ -179,7 +179,7 @@ static struct net_device_stats *hostess_get_stats(struct net_device *d) | |||
179 | 179 | ||
180 | static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d) | 180 | static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d) |
181 | { | 181 | { |
182 | struct sv11_device *sv11=d->priv; | 182 | struct sv11_device *sv11=d->ml_priv; |
183 | return z8530_queue_xmit(&sv11->sync.chanA, skb); | 183 | return z8530_queue_xmit(&sv11->sync.chanA, skb); |
184 | } | 184 | } |
185 | 185 | ||
@@ -325,6 +325,7 @@ static struct sv11_device *sv11_init(int iobase, int irq) | |||
325 | /* | 325 | /* |
326 | * Initialise the PPP components | 326 | * Initialise the PPP components |
327 | */ | 327 | */ |
328 | d->ml_priv = sv; | ||
328 | sppp_attach(&sv->netdev); | 329 | sppp_attach(&sv->netdev); |
329 | 330 | ||
330 | /* | 331 | /* |
@@ -333,7 +334,6 @@ static struct sv11_device *sv11_init(int iobase, int irq) | |||
333 | 334 | ||
334 | d->base_addr = iobase; | 335 | d->base_addr = iobase; |
335 | d->irq = irq; | 336 | d->irq = irq; |
336 | d->priv = sv; | ||
337 | 337 | ||
338 | if(register_netdev(d)) | 338 | if(register_netdev(d)) |
339 | { | 339 | { |
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 6635ecef36e5..62133cee446a 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c | |||
@@ -891,6 +891,7 @@ static int __devinit lmc_init_one(struct pci_dev *pdev, | |||
891 | 891 | ||
892 | /* Initialize the sppp layer */ | 892 | /* Initialize the sppp layer */ |
893 | /* An ioctl can cause a subsequent detach for raw frame interface */ | 893 | /* An ioctl can cause a subsequent detach for raw frame interface */ |
894 | dev->ml_priv = sc; | ||
894 | sc->if_type = LMC_PPP; | 895 | sc->if_type = LMC_PPP; |
895 | sc->check = 0xBEAFCAFE; | 896 | sc->check = 0xBEAFCAFE; |
896 | dev->base_addr = pci_resource_start(pdev, 0); | 897 | dev->base_addr = pci_resource_start(pdev, 0); |
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c index 11276bf3149f..44a89df1b8bf 100644 --- a/drivers/net/wan/sealevel.c +++ b/drivers/net/wan/sealevel.c | |||
@@ -241,6 +241,7 @@ static inline struct slvl_device *slvl_alloc(int iobase, int irq) | |||
241 | return NULL; | 241 | return NULL; |
242 | 242 | ||
243 | sv = d->priv; | 243 | sv = d->priv; |
244 | d->ml_priv = sv; | ||
244 | sv->if_ptr = &sv->pppdev; | 245 | sv->if_ptr = &sv->pppdev; |
245 | sv->pppdev.dev = d; | 246 | sv->pppdev.dev = d; |
246 | d->base_addr = iobase; | 247 | d->base_addr = iobase; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index d3406830c8e3..62a3d8f8563e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -666,7 +666,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv, | |||
666 | rx_status.flag = 0; | 666 | rx_status.flag = 0; |
667 | rx_status.mactime = le64_to_cpu(rx_end->timestamp); | 667 | rx_status.mactime = le64_to_cpu(rx_end->timestamp); |
668 | rx_status.freq = | 668 | rx_status.freq = |
669 | ieee80211_frequency_to_channel(le16_to_cpu(rx_hdr->channel)); | 669 | ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel)); |
670 | rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? | 670 | rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? |
671 | IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; | 671 | IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; |
672 | 672 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c index b608e1ca8b40..c9847b1a67f7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c | |||
@@ -163,8 +163,8 @@ struct iwl4965_lq_sta { | |||
163 | struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; | 163 | struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; |
164 | #endif | 164 | #endif |
165 | struct iwl4965_rate dbg_fixed; | 165 | struct iwl4965_rate dbg_fixed; |
166 | struct iwl_priv *drv; | ||
167 | #endif | 166 | #endif |
167 | struct iwl_priv *drv; | ||
168 | }; | 168 | }; |
169 | 169 | ||
170 | static void rs_rate_scale_perform(struct iwl_priv *priv, | 170 | static void rs_rate_scale_perform(struct iwl_priv *priv, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 17f629fb96ff..bf19eb8aafd0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -3978,7 +3978,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
3978 | 3978 | ||
3979 | rx_status.mactime = le64_to_cpu(rx_start->timestamp); | 3979 | rx_status.mactime = le64_to_cpu(rx_start->timestamp); |
3980 | rx_status.freq = | 3980 | rx_status.freq = |
3981 | ieee80211_frequency_to_channel(le16_to_cpu(rx_start->channel)); | 3981 | ieee80211_channel_to_frequency(le16_to_cpu(rx_start->channel)); |
3982 | rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? | 3982 | rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? |
3983 | IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; | 3983 | IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; |
3984 | rx_status.rate_idx = | 3984 | rx_status.rate_idx = |
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c index 04c2638d75ad..9196825ed1b5 100644 --- a/drivers/net/wireless/prism54/islpci_dev.c +++ b/drivers/net/wireless/prism54/islpci_dev.c | |||
@@ -388,8 +388,15 @@ islpci_open(struct net_device *ndev) | |||
388 | 388 | ||
389 | netif_start_queue(ndev); | 389 | netif_start_queue(ndev); |
390 | 390 | ||
391 | /* Turn off carrier unless we know we have associated */ | 391 | /* Turn off carrier if in STA or Ad-hoc mode. It will be turned on |
392 | netif_carrier_off(ndev); | 392 | * once the firmware receives a trap of being associated |
393 | * (GEN_OID_LINKSTATE). In other modes (AP or WDS or monitor) we | ||
394 | * should just leave the carrier on as its expected the firmware | ||
395 | * won't send us a trigger. */ | ||
396 | if (priv->iw_mode == IW_MODE_INFRA || priv->iw_mode == IW_MODE_ADHOC) | ||
397 | netif_carrier_off(ndev); | ||
398 | else | ||
399 | netif_carrier_on(ndev); | ||
393 | 400 | ||
394 | return 0; | 401 | return 0; |
395 | } | 402 | } |
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 8d8657fb64dd..b22c02737185 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -1032,8 +1032,10 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev) | |||
1032 | * Initialize the device. | 1032 | * Initialize the device. |
1033 | */ | 1033 | */ |
1034 | status = rt2x00dev->ops->lib->initialize(rt2x00dev); | 1034 | status = rt2x00dev->ops->lib->initialize(rt2x00dev); |
1035 | if (status) | 1035 | if (status) { |
1036 | goto exit; | 1036 | rt2x00queue_uninitialize(rt2x00dev); |
1037 | return status; | ||
1038 | } | ||
1037 | 1039 | ||
1038 | __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags); | 1040 | __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags); |
1039 | 1041 | ||
@@ -1043,11 +1045,6 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev) | |||
1043 | rt2x00rfkill_register(rt2x00dev); | 1045 | rt2x00rfkill_register(rt2x00dev); |
1044 | 1046 | ||
1045 | return 0; | 1047 | return 0; |
1046 | |||
1047 | exit: | ||
1048 | rt2x00lib_uninitialize(rt2x00dev); | ||
1049 | |||
1050 | return status; | ||
1051 | } | 1048 | } |
1052 | 1049 | ||
1053 | int rt2x00lib_start(struct rt2x00_dev *rt2x00dev) | 1050 | int rt2x00lib_start(struct rt2x00_dev *rt2x00dev) |
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c index 7867ec64bd2c..971af2546b59 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.c +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c | |||
@@ -314,13 +314,14 @@ int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) | |||
314 | if (status) { | 314 | if (status) { |
315 | ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n", | 315 | ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n", |
316 | pci_dev->irq, status); | 316 | pci_dev->irq, status); |
317 | return status; | 317 | goto exit; |
318 | } | 318 | } |
319 | 319 | ||
320 | return 0; | 320 | return 0; |
321 | 321 | ||
322 | exit: | 322 | exit: |
323 | rt2x00pci_uninitialize(rt2x00dev); | 323 | queue_for_each(rt2x00dev, queue) |
324 | rt2x00pci_free_queue_dma(rt2x00dev, queue); | ||
324 | 325 | ||
325 | return status; | 326 | return status; |
326 | } | 327 | } |
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index ae12dcdd3c24..14bc7b281659 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -2366,6 +2366,7 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2366 | { | 2366 | { |
2367 | struct rt2x00_dev *rt2x00dev = hw->priv; | 2367 | struct rt2x00_dev *rt2x00dev = hw->priv; |
2368 | struct rt2x00_intf *intf = vif_to_intf(control->vif); | 2368 | struct rt2x00_intf *intf = vif_to_intf(control->vif); |
2369 | struct queue_entry_priv_pci_tx *priv_tx; | ||
2369 | struct skb_frame_desc *skbdesc; | 2370 | struct skb_frame_desc *skbdesc; |
2370 | unsigned int beacon_base; | 2371 | unsigned int beacon_base; |
2371 | u32 reg; | 2372 | u32 reg; |
@@ -2373,21 +2374,8 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2373 | if (unlikely(!intf->beacon)) | 2374 | if (unlikely(!intf->beacon)) |
2374 | return -ENOBUFS; | 2375 | return -ENOBUFS; |
2375 | 2376 | ||
2376 | /* | 2377 | priv_tx = intf->beacon->priv_data; |
2377 | * We need to append the descriptor in front of the | 2378 | memset(priv_tx->desc, 0, intf->beacon->queue->desc_size); |
2378 | * beacon frame. | ||
2379 | */ | ||
2380 | if (skb_headroom(skb) < intf->beacon->queue->desc_size) { | ||
2381 | if (pskb_expand_head(skb, intf->beacon->queue->desc_size, | ||
2382 | 0, GFP_ATOMIC)) | ||
2383 | return -ENOMEM; | ||
2384 | } | ||
2385 | |||
2386 | /* | ||
2387 | * Add the descriptor in front of the skb. | ||
2388 | */ | ||
2389 | skb_push(skb, intf->beacon->queue->desc_size); | ||
2390 | memset(skb->data, 0, intf->beacon->queue->desc_size); | ||
2391 | 2379 | ||
2392 | /* | 2380 | /* |
2393 | * Fill in skb descriptor | 2381 | * Fill in skb descriptor |
@@ -2395,9 +2383,9 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2395 | skbdesc = get_skb_frame_desc(skb); | 2383 | skbdesc = get_skb_frame_desc(skb); |
2396 | memset(skbdesc, 0, sizeof(*skbdesc)); | 2384 | memset(skbdesc, 0, sizeof(*skbdesc)); |
2397 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; | 2385 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; |
2398 | skbdesc->data = skb->data + intf->beacon->queue->desc_size; | 2386 | skbdesc->data = skb->data; |
2399 | skbdesc->data_len = skb->len - intf->beacon->queue->desc_size; | 2387 | skbdesc->data_len = skb->len; |
2400 | skbdesc->desc = skb->data; | 2388 | skbdesc->desc = priv_tx->desc; |
2401 | skbdesc->desc_len = intf->beacon->queue->desc_size; | 2389 | skbdesc->desc_len = intf->beacon->queue->desc_size; |
2402 | skbdesc->entry = intf->beacon; | 2390 | skbdesc->entry = intf->beacon; |
2403 | 2391 | ||
@@ -2425,7 +2413,10 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2425 | */ | 2413 | */ |
2426 | beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); | 2414 | beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); |
2427 | rt2x00pci_register_multiwrite(rt2x00dev, beacon_base, | 2415 | rt2x00pci_register_multiwrite(rt2x00dev, beacon_base, |
2428 | skb->data, skb->len); | 2416 | skbdesc->desc, skbdesc->desc_len); |
2417 | rt2x00pci_register_multiwrite(rt2x00dev, | ||
2418 | beacon_base + skbdesc->desc_len, | ||
2419 | skbdesc->data, skbdesc->data_len); | ||
2429 | rt61pci_kick_tx_queue(rt2x00dev, control->queue); | 2420 | rt61pci_kick_tx_queue(rt2x00dev, control->queue); |
2430 | 2421 | ||
2431 | return 0; | 2422 | return 0; |
@@ -2490,7 +2481,7 @@ static const struct data_queue_desc rt61pci_queue_tx = { | |||
2490 | 2481 | ||
2491 | static const struct data_queue_desc rt61pci_queue_bcn = { | 2482 | static const struct data_queue_desc rt61pci_queue_bcn = { |
2492 | .entry_num = 4 * BEACON_ENTRIES, | 2483 | .entry_num = 4 * BEACON_ENTRIES, |
2493 | .data_size = MGMT_FRAME_SIZE, | 2484 | .data_size = 0, /* No DMA required for beacons */ |
2494 | .desc_size = TXINFO_SIZE, | 2485 | .desc_size = TXINFO_SIZE, |
2495 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 2486 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), |
2496 | }; | 2487 | }; |
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c index 03384a43186b..49ae97003952 100644 --- a/drivers/net/wireless/wavelan.c +++ b/drivers/net/wireless/wavelan.c | |||
@@ -908,9 +908,9 @@ static void wv_psa_show(psa_t * p) | |||
908 | p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5], | 908 | p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5], |
909 | p->psa_call_code[6], p->psa_call_code[7]); | 909 | p->psa_call_code[6], p->psa_call_code[7]); |
910 | #ifdef DEBUG_SHOW_UNUSED | 910 | #ifdef DEBUG_SHOW_UNUSED |
911 | printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n", | 911 | printk(KERN_DEBUG "psa_reserved[]: %02X:%02X\n", |
912 | p->psa_reserved[0], | 912 | p->psa_reserved[0], |
913 | p->psa_reserved[1], p->psa_reserved[2], p->psa_reserved[3]); | 913 | p->psa_reserved[1]); |
914 | #endif /* DEBUG_SHOW_UNUSED */ | 914 | #endif /* DEBUG_SHOW_UNUSED */ |
915 | printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); | 915 | printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); |
916 | printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); | 916 | printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index baf74015751c..b584c0ecc62d 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -1074,11 +1074,9 @@ wv_psa_show(psa_t * p) | |||
1074 | p->psa_call_code[6], | 1074 | p->psa_call_code[6], |
1075 | p->psa_call_code[7]); | 1075 | p->psa_call_code[7]); |
1076 | #ifdef DEBUG_SHOW_UNUSED | 1076 | #ifdef DEBUG_SHOW_UNUSED |
1077 | printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n", | 1077 | printk(KERN_DEBUG "psa_reserved[]: %02X:%02X\n", |
1078 | p->psa_reserved[0], | 1078 | p->psa_reserved[0], |
1079 | p->psa_reserved[1], | 1079 | p->psa_reserved[1]); |
1080 | p->psa_reserved[2], | ||
1081 | p->psa_reserved[3]); | ||
1082 | #endif /* DEBUG_SHOW_UNUSED */ | 1080 | #endif /* DEBUG_SHOW_UNUSED */ |
1083 | printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); | 1081 | printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); |
1084 | printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); | 1082 | printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); |
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index 5316074f39f0..12e24f04dddf 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c | |||
@@ -889,9 +889,13 @@ static void tx_urb_complete(struct urb *urb) | |||
889 | } | 889 | } |
890 | free_urb: | 890 | free_urb: |
891 | skb = (struct sk_buff *)urb->context; | 891 | skb = (struct sk_buff *)urb->context; |
892 | zd_mac_tx_to_dev(skb, urb->status); | 892 | /* |
893 | * grab 'usb' pointer before handing off the skb (since | ||
894 | * it might be freed by zd_mac_tx_to_dev or mac80211) | ||
895 | */ | ||
893 | cb = (struct zd_tx_skb_control_block *)skb->cb; | 896 | cb = (struct zd_tx_skb_control_block *)skb->cb; |
894 | usb = &zd_hw_mac(cb->hw)->chip.usb; | 897 | usb = &zd_hw_mac(cb->hw)->chip.usb; |
898 | zd_mac_tx_to_dev(skb, urb->status); | ||
895 | free_tx_urb(usb, urb); | 899 | free_tx_urb(usb, urb); |
896 | tx_dec_submitted_urbs(usb); | 900 | tx_dec_submitted_urbs(usb); |
897 | return; | 901 | return; |
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 1fd8bb765702..66c0fd21894b 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -49,7 +49,7 @@ | |||
49 | 49 | ||
50 | #define DEFAULT_DOMAIN_ADDRESS_WIDTH 48 | 50 | #define DEFAULT_DOMAIN_ADDRESS_WIDTH 48 |
51 | 51 | ||
52 | #define DMAR_OPERATION_TIMEOUT (HZ*60) /* 1m */ | 52 | #define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) /* 10sec */ |
53 | 53 | ||
54 | #define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) | 54 | #define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) |
55 | 55 | ||
@@ -490,12 +490,12 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu) | |||
490 | 490 | ||
491 | #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ | 491 | #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ |
492 | {\ | 492 | {\ |
493 | unsigned long start_time = jiffies;\ | 493 | cycles_t start_time = get_cycles();\ |
494 | while (1) {\ | 494 | while (1) {\ |
495 | sts = op (iommu->reg + offset);\ | 495 | sts = op (iommu->reg + offset);\ |
496 | if (cond)\ | 496 | if (cond)\ |
497 | break;\ | 497 | break;\ |
498 | if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT))\ | 498 | if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\ |
499 | panic("DMAR hardware is malfunctioning\n");\ | 499 | panic("DMAR hardware is malfunctioning\n");\ |
500 | cpu_relax();\ | 500 | cpu_relax();\ |
501 | }\ | 501 | }\ |
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 72f7476930c8..9d6fc8e6285d 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -19,8 +19,31 @@ | |||
19 | #include <linux/pci-acpi.h> | 19 | #include <linux/pci-acpi.h> |
20 | #include "pci.h" | 20 | #include "pci.h" |
21 | 21 | ||
22 | static u32 ctrlset_buf[3] = {0, 0, 0}; | 22 | struct acpi_osc_data { |
23 | static u32 global_ctrlsets = 0; | 23 | acpi_handle handle; |
24 | u32 ctrlset_buf[3]; | ||
25 | u32 global_ctrlsets; | ||
26 | struct list_head sibiling; | ||
27 | }; | ||
28 | static LIST_HEAD(acpi_osc_data_list); | ||
29 | |||
30 | static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle) | ||
31 | { | ||
32 | struct acpi_osc_data *data; | ||
33 | |||
34 | list_for_each_entry(data, &acpi_osc_data_list, sibiling) { | ||
35 | if (data->handle == handle) | ||
36 | return data; | ||
37 | } | ||
38 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
39 | if (!data) | ||
40 | return NULL; | ||
41 | INIT_LIST_HEAD(&data->sibiling); | ||
42 | data->handle = handle; | ||
43 | list_add_tail(&data->sibiling, &acpi_osc_data_list); | ||
44 | return data; | ||
45 | } | ||
46 | |||
24 | static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; | 47 | static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; |
25 | 48 | ||
26 | static acpi_status | 49 | static acpi_status |
@@ -37,8 +60,27 @@ acpi_query_osc ( | |||
37 | union acpi_object *out_obj; | 60 | union acpi_object *out_obj; |
38 | u32 osc_dw0; | 61 | u32 osc_dw0; |
39 | acpi_status *ret_status = (acpi_status *)retval; | 62 | acpi_status *ret_status = (acpi_status *)retval; |
63 | struct acpi_osc_data *osc_data; | ||
64 | u32 flags = (unsigned long)context, temp; | ||
65 | acpi_handle tmp; | ||
66 | |||
67 | status = acpi_get_handle(handle, "_OSC", &tmp); | ||
68 | if (ACPI_FAILURE(status)) | ||
69 | return status; | ||
70 | |||
71 | osc_data = acpi_get_osc_data(handle); | ||
72 | if (!osc_data) { | ||
73 | printk(KERN_ERR "acpi osc data array is full\n"); | ||
74 | return AE_ERROR; | ||
75 | } | ||
76 | |||
77 | osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS); | ||
78 | |||
79 | /* do _OSC query for all possible controls */ | ||
80 | temp = osc_data->ctrlset_buf[OSC_CONTROL_TYPE]; | ||
81 | osc_data->ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; | ||
82 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; | ||
40 | 83 | ||
41 | |||
42 | /* Setting up input parameters */ | 84 | /* Setting up input parameters */ |
43 | input.count = 4; | 85 | input.count = 4; |
44 | input.pointer = in_params; | 86 | input.pointer = in_params; |
@@ -51,13 +93,11 @@ acpi_query_osc ( | |||
51 | in_params[2].integer.value = 3; | 93 | in_params[2].integer.value = 3; |
52 | in_params[3].type = ACPI_TYPE_BUFFER; | 94 | in_params[3].type = ACPI_TYPE_BUFFER; |
53 | in_params[3].buffer.length = 12; | 95 | in_params[3].buffer.length = 12; |
54 | in_params[3].buffer.pointer = (u8 *)context; | 96 | in_params[3].buffer.pointer = (u8 *)osc_data->ctrlset_buf; |
55 | 97 | ||
56 | status = acpi_evaluate_object(handle, "_OSC", &input, &output); | 98 | status = acpi_evaluate_object(handle, "_OSC", &input, &output); |
57 | if (ACPI_FAILURE (status)) { | 99 | if (ACPI_FAILURE(status)) |
58 | *ret_status = status; | 100 | goto out_nofree; |
59 | return status; | ||
60 | } | ||
61 | out_obj = output.pointer; | 101 | out_obj = output.pointer; |
62 | 102 | ||
63 | if (out_obj->type != ACPI_TYPE_BUFFER) { | 103 | if (out_obj->type != ACPI_TYPE_BUFFER) { |
@@ -76,7 +116,8 @@ acpi_query_osc ( | |||
76 | printk(KERN_DEBUG "_OSC invalid revision\n"); | 116 | printk(KERN_DEBUG "_OSC invalid revision\n"); |
77 | if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { | 117 | if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { |
78 | /* Update Global Control Set */ | 118 | /* Update Global Control Set */ |
79 | global_ctrlsets = *((u32 *)(out_obj->buffer.pointer+8)); | 119 | osc_data->global_ctrlsets = |
120 | *((u32 *)(out_obj->buffer.pointer + 8)); | ||
80 | status = AE_OK; | 121 | status = AE_OK; |
81 | goto query_osc_out; | 122 | goto query_osc_out; |
82 | } | 123 | } |
@@ -85,12 +126,21 @@ acpi_query_osc ( | |||
85 | } | 126 | } |
86 | 127 | ||
87 | /* Update Global Control Set */ | 128 | /* Update Global Control Set */ |
88 | global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8)); | 129 | osc_data->global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8)); |
89 | status = AE_OK; | 130 | status = AE_OK; |
90 | 131 | ||
91 | query_osc_out: | 132 | query_osc_out: |
92 | kfree(output.pointer); | 133 | kfree(output.pointer); |
134 | out_nofree: | ||
93 | *ret_status = status; | 135 | *ret_status = status; |
136 | |||
137 | osc_data->ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE; | ||
138 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = temp; | ||
139 | if (ACPI_FAILURE(status)) { | ||
140 | /* no osc support at all */ | ||
141 | osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] = 0; | ||
142 | } | ||
143 | |||
94 | return status; | 144 | return status; |
95 | } | 145 | } |
96 | 146 | ||
@@ -165,28 +215,15 @@ run_osc_out: | |||
165 | **/ | 215 | **/ |
166 | acpi_status __pci_osc_support_set(u32 flags, const char *hid) | 216 | acpi_status __pci_osc_support_set(u32 flags, const char *hid) |
167 | { | 217 | { |
168 | u32 temp; | 218 | acpi_status retval = AE_NOT_FOUND; |
169 | acpi_status retval; | ||
170 | 219 | ||
171 | if (!(flags & OSC_SUPPORT_MASKS)) { | 220 | if (!(flags & OSC_SUPPORT_MASKS)) { |
172 | return AE_TYPE; | 221 | return AE_TYPE; |
173 | } | 222 | } |
174 | ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS); | ||
175 | |||
176 | /* do _OSC query for all possible controls */ | ||
177 | temp = ctrlset_buf[OSC_CONTROL_TYPE]; | ||
178 | ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; | ||
179 | ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; | ||
180 | acpi_get_devices(hid, | 223 | acpi_get_devices(hid, |
181 | acpi_query_osc, | 224 | acpi_query_osc, |
182 | ctrlset_buf, | 225 | (void *)(unsigned long)flags, |
183 | (void **) &retval ); | 226 | (void **) &retval ); |
184 | ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE; | ||
185 | ctrlset_buf[OSC_CONTROL_TYPE] = temp; | ||
186 | if (ACPI_FAILURE(retval)) { | ||
187 | /* no osc support at all */ | ||
188 | ctrlset_buf[OSC_SUPPORT_TYPE] = 0; | ||
189 | } | ||
190 | return AE_OK; | 227 | return AE_OK; |
191 | } | 228 | } |
192 | 229 | ||
@@ -201,19 +238,31 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) | |||
201 | { | 238 | { |
202 | acpi_status status; | 239 | acpi_status status; |
203 | u32 ctrlset; | 240 | u32 ctrlset; |
241 | acpi_handle tmp; | ||
242 | struct acpi_osc_data *osc_data; | ||
243 | |||
244 | status = acpi_get_handle(handle, "_OSC", &tmp); | ||
245 | if (ACPI_FAILURE(status)) | ||
246 | return status; | ||
247 | |||
248 | osc_data = acpi_get_osc_data(handle); | ||
249 | if (!osc_data) { | ||
250 | printk(KERN_ERR "acpi osc data array is full\n"); | ||
251 | return AE_ERROR; | ||
252 | } | ||
204 | 253 | ||
205 | ctrlset = (flags & OSC_CONTROL_MASKS); | 254 | ctrlset = (flags & OSC_CONTROL_MASKS); |
206 | if (!ctrlset) { | 255 | if (!ctrlset) { |
207 | return AE_TYPE; | 256 | return AE_TYPE; |
208 | } | 257 | } |
209 | if (ctrlset_buf[OSC_SUPPORT_TYPE] && | 258 | if (osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] && |
210 | ((global_ctrlsets & ctrlset) != ctrlset)) { | 259 | ((osc_data->global_ctrlsets & ctrlset) != ctrlset)) { |
211 | return AE_SUPPORT; | 260 | return AE_SUPPORT; |
212 | } | 261 | } |
213 | ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset; | 262 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset; |
214 | status = acpi_run_osc(handle, ctrlset_buf); | 263 | status = acpi_run_osc(handle, osc_data->ctrlset_buf); |
215 | if (ACPI_FAILURE (status)) { | 264 | if (ACPI_FAILURE (status)) { |
216 | ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset; | 265 | osc_data->ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset; |
217 | } | 266 | } |
218 | 267 | ||
219 | return status; | 268 | return status; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index afd914ebe215..f2d9c770f51a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -1826,6 +1826,7 @@ static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev) | |||
1826 | } | 1826 | } |
1827 | } | 1827 | } |
1828 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk); | 1828 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk); |
1829 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk); | ||
1829 | 1830 | ||
1830 | static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) | 1831 | static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) |
1831 | { | 1832 | { |
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 5d9301de1778..5695a79f3a52 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -424,7 +424,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
424 | start = simple_strtoul(buf, &buf, 0); | 424 | start = simple_strtoul(buf, &buf, 0); |
425 | pnp_res = pnp_add_irq_resource(dev, start, 0); | 425 | pnp_res = pnp_add_irq_resource(dev, start, 0); |
426 | if (pnp_res) | 426 | if (pnp_res) |
427 | nirq++; | 427 | pnp_res->index = nirq++; |
428 | continue; | 428 | continue; |
429 | } | 429 | } |
430 | if (!strnicmp(buf, "dma", 3)) { | 430 | if (!strnicmp(buf, "dma", 3)) { |
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index ba795a4db1e9..9f996ec881ce 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c | |||
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(rtc_year_days); | |||
51 | */ | 51 | */ |
52 | void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) | 52 | void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) |
53 | { | 53 | { |
54 | register int days, month, year; | 54 | unsigned int days, month, year; |
55 | 55 | ||
56 | days = time / 86400; | 56 | days = time / 86400; |
57 | time -= days * 86400; | 57 | time -= days * 86400; |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 316bfaa80872..a3e0880b38fb 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/kernel.h> | ||
18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
19 | #include <linux/string.h> | 20 | #include <linux/string.h> |
20 | #include <linux/i2c.h> | 21 | #include <linux/i2c.h> |
@@ -803,6 +804,7 @@ static int m41t80_probe(struct i2c_client *client, | |||
803 | 804 | ||
804 | #ifdef CONFIG_RTC_DRV_M41T80_WDT | 805 | #ifdef CONFIG_RTC_DRV_M41T80_WDT |
805 | if (clientdata->features & M41T80_FEATURE_HT) { | 806 | if (clientdata->features & M41T80_FEATURE_HT) { |
807 | save_client = client; | ||
806 | rc = misc_register(&wdt_dev); | 808 | rc = misc_register(&wdt_dev); |
807 | if (rc) | 809 | if (rc) |
808 | goto exit; | 810 | goto exit; |
@@ -811,7 +813,6 @@ static int m41t80_probe(struct i2c_client *client, | |||
811 | misc_deregister(&wdt_dev); | 813 | misc_deregister(&wdt_dev); |
812 | goto exit; | 814 | goto exit; |
813 | } | 815 | } |
814 | save_client = client; | ||
815 | } | 816 | } |
816 | #endif | 817 | #endif |
817 | return 0; | 818 | return 0; |
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index f5215fd4b73d..1dca1775f4b1 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c | |||
@@ -3830,7 +3830,7 @@ static int __init aha152x_init(void) | |||
3830 | iounmap(p); | 3830 | iounmap(p); |
3831 | } | 3831 | } |
3832 | if (!ok && setup_count == 0) | 3832 | if (!ok && setup_count == 0) |
3833 | return 0; | 3833 | return -ENODEV; |
3834 | 3834 | ||
3835 | printk(KERN_INFO "aha152x: BIOS test: passed, "); | 3835 | printk(KERN_INFO "aha152x: BIOS test: passed, "); |
3836 | #else | 3836 | #else |
@@ -3909,14 +3909,14 @@ static int __init aha152x_init(void) | |||
3909 | #endif | 3909 | #endif |
3910 | } | 3910 | } |
3911 | 3911 | ||
3912 | return 1; | 3912 | return 0; |
3913 | } | 3913 | } |
3914 | 3914 | ||
3915 | static void __exit aha152x_exit(void) | 3915 | static void __exit aha152x_exit(void) |
3916 | { | 3916 | { |
3917 | struct aha152x_hostdata *hd; | 3917 | struct aha152x_hostdata *hd, *tmp; |
3918 | 3918 | ||
3919 | list_for_each_entry(hd, &aha152x_host_list, host_list) { | 3919 | list_for_each_entry_safe(hd, tmp, &aha152x_host_list, host_list) { |
3920 | struct Scsi_Host *shost = container_of((void *)hd, struct Scsi_Host, hostdata); | 3920 | struct Scsi_Host *shost = container_of((void *)hd, struct Scsi_Host, hostdata); |
3921 | 3921 | ||
3922 | aha152x_release(shost); | 3922 | aha152x_release(shost); |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 8e2e964af668..46771d4c81bd 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -550,7 +550,6 @@ static int __init gdth_search_isa(ulong32 bios_adr) | |||
550 | #endif /* CONFIG_ISA */ | 550 | #endif /* CONFIG_ISA */ |
551 | 551 | ||
552 | #ifdef CONFIG_PCI | 552 | #ifdef CONFIG_PCI |
553 | static bool gdth_pci_registered; | ||
554 | 553 | ||
555 | static bool gdth_search_vortex(ushort device) | 554 | static bool gdth_search_vortex(ushort device) |
556 | { | 555 | { |
@@ -3724,6 +3723,8 @@ static void gdth_log_event(gdth_evt_data *dvr, char *buffer) | |||
3724 | } | 3723 | } |
3725 | 3724 | ||
3726 | #ifdef GDTH_STATISTICS | 3725 | #ifdef GDTH_STATISTICS |
3726 | static unchar gdth_timer_running; | ||
3727 | |||
3727 | static void gdth_timeout(ulong data) | 3728 | static void gdth_timeout(ulong data) |
3728 | { | 3729 | { |
3729 | ulong32 i; | 3730 | ulong32 i; |
@@ -3731,7 +3732,10 @@ static void gdth_timeout(ulong data) | |||
3731 | gdth_ha_str *ha; | 3732 | gdth_ha_str *ha; |
3732 | ulong flags; | 3733 | ulong flags; |
3733 | 3734 | ||
3734 | BUG_ON(list_empty(&gdth_instances)); | 3735 | if(unlikely(list_empty(&gdth_instances))) { |
3736 | gdth_timer_running = 0; | ||
3737 | return; | ||
3738 | } | ||
3735 | 3739 | ||
3736 | ha = list_first_entry(&gdth_instances, gdth_ha_str, list); | 3740 | ha = list_first_entry(&gdth_instances, gdth_ha_str, list); |
3737 | spin_lock_irqsave(&ha->smp_lock, flags); | 3741 | spin_lock_irqsave(&ha->smp_lock, flags); |
@@ -3751,6 +3755,22 @@ static void gdth_timeout(ulong data) | |||
3751 | add_timer(&gdth_timer); | 3755 | add_timer(&gdth_timer); |
3752 | spin_unlock_irqrestore(&ha->smp_lock, flags); | 3756 | spin_unlock_irqrestore(&ha->smp_lock, flags); |
3753 | } | 3757 | } |
3758 | |||
3759 | static void gdth_timer_init(void) | ||
3760 | { | ||
3761 | if (gdth_timer_running) | ||
3762 | return; | ||
3763 | gdth_timer_running = 1; | ||
3764 | TRACE2(("gdth_detect(): Initializing timer !\n")); | ||
3765 | gdth_timer.expires = jiffies + HZ; | ||
3766 | gdth_timer.data = 0L; | ||
3767 | gdth_timer.function = gdth_timeout; | ||
3768 | add_timer(&gdth_timer); | ||
3769 | } | ||
3770 | #else | ||
3771 | static inline void gdth_timer_init(void) | ||
3772 | { | ||
3773 | } | ||
3754 | #endif | 3774 | #endif |
3755 | 3775 | ||
3756 | static void __init internal_setup(char *str,int *ints) | 3776 | static void __init internal_setup(char *str,int *ints) |
@@ -4735,6 +4755,7 @@ static int __init gdth_isa_probe_one(ulong32 isa_bios) | |||
4735 | if (error) | 4755 | if (error) |
4736 | goto out_free_coal_stat; | 4756 | goto out_free_coal_stat; |
4737 | list_add_tail(&ha->list, &gdth_instances); | 4757 | list_add_tail(&ha->list, &gdth_instances); |
4758 | gdth_timer_init(); | ||
4738 | 4759 | ||
4739 | scsi_scan_host(shp); | 4760 | scsi_scan_host(shp); |
4740 | 4761 | ||
@@ -4865,6 +4886,7 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot) | |||
4865 | if (error) | 4886 | if (error) |
4866 | goto out_free_coal_stat; | 4887 | goto out_free_coal_stat; |
4867 | list_add_tail(&ha->list, &gdth_instances); | 4888 | list_add_tail(&ha->list, &gdth_instances); |
4889 | gdth_timer_init(); | ||
4868 | 4890 | ||
4869 | scsi_scan_host(shp); | 4891 | scsi_scan_host(shp); |
4870 | 4892 | ||
@@ -5011,6 +5033,7 @@ static int gdth_pci_probe_one(gdth_pci_str *pcistr, | |||
5011 | list_add_tail(&ha->list, &gdth_instances); | 5033 | list_add_tail(&ha->list, &gdth_instances); |
5012 | 5034 | ||
5013 | pci_set_drvdata(ha->pdev, ha); | 5035 | pci_set_drvdata(ha->pdev, ha); |
5036 | gdth_timer_init(); | ||
5014 | 5037 | ||
5015 | scsi_scan_host(shp); | 5038 | scsi_scan_host(shp); |
5016 | 5039 | ||
@@ -5110,6 +5133,7 @@ static int __init gdth_init(void) | |||
5110 | /* initializations */ | 5133 | /* initializations */ |
5111 | gdth_polling = TRUE; | 5134 | gdth_polling = TRUE; |
5112 | gdth_clear_events(); | 5135 | gdth_clear_events(); |
5136 | init_timer(&gdth_timer); | ||
5113 | 5137 | ||
5114 | /* As default we do not probe for EISA or ISA controllers */ | 5138 | /* As default we do not probe for EISA or ISA controllers */ |
5115 | if (probe_eisa_isa) { | 5139 | if (probe_eisa_isa) { |
@@ -5132,23 +5156,17 @@ static int __init gdth_init(void) | |||
5132 | 5156 | ||
5133 | #ifdef CONFIG_PCI | 5157 | #ifdef CONFIG_PCI |
5134 | /* scanning for PCI controllers */ | 5158 | /* scanning for PCI controllers */ |
5135 | if (pci_register_driver(&gdth_pci_driver) == 0) | 5159 | if (pci_register_driver(&gdth_pci_driver)) { |
5136 | gdth_pci_registered = true; | 5160 | gdth_ha_str *ha; |
5161 | |||
5162 | list_for_each_entry(ha, &gdth_instances, list) | ||
5163 | gdth_remove_one(ha); | ||
5164 | return -ENODEV; | ||
5165 | } | ||
5137 | #endif /* CONFIG_PCI */ | 5166 | #endif /* CONFIG_PCI */ |
5138 | 5167 | ||
5139 | TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); | 5168 | TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); |
5140 | 5169 | ||
5141 | if (list_empty(&gdth_instances)) | ||
5142 | return -ENODEV; | ||
5143 | |||
5144 | #ifdef GDTH_STATISTICS | ||
5145 | TRACE2(("gdth_detect(): Initializing timer !\n")); | ||
5146 | init_timer(&gdth_timer); | ||
5147 | gdth_timer.expires = jiffies + HZ; | ||
5148 | gdth_timer.data = 0L; | ||
5149 | gdth_timer.function = gdth_timeout; | ||
5150 | add_timer(&gdth_timer); | ||
5151 | #endif | ||
5152 | major = register_chrdev(0,"gdth", &gdth_fops); | 5170 | major = register_chrdev(0,"gdth", &gdth_fops); |
5153 | register_reboot_notifier(&gdth_notifier); | 5171 | register_reboot_notifier(&gdth_notifier); |
5154 | gdth_polling = FALSE; | 5172 | gdth_polling = FALSE; |
@@ -5167,8 +5185,7 @@ static void __exit gdth_exit(void) | |||
5167 | #endif | 5185 | #endif |
5168 | 5186 | ||
5169 | #ifdef CONFIG_PCI | 5187 | #ifdef CONFIG_PCI |
5170 | if (gdth_pci_registered) | 5188 | pci_unregister_driver(&gdth_pci_driver); |
5171 | pci_unregister_driver(&gdth_pci_driver); | ||
5172 | #endif | 5189 | #endif |
5173 | 5190 | ||
5174 | list_for_each_entry(ha, &gdth_instances, list) | 5191 | list_for_each_entry(ha, &gdth_instances, list) |
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 010c1b9b178c..b43bf1d60dac 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -730,7 +730,9 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
730 | if (iscsi_recv_pdu(conn->cls_conn, hdr, data, | 730 | if (iscsi_recv_pdu(conn->cls_conn, hdr, data, |
731 | datalen)) | 731 | datalen)) |
732 | rc = ISCSI_ERR_CONN_FAILED; | 732 | rc = ISCSI_ERR_CONN_FAILED; |
733 | } | 733 | } else |
734 | mod_timer(&conn->transport_timer, | ||
735 | jiffies + conn->recv_timeout); | ||
734 | iscsi_free_mgmt_task(conn, mtask); | 736 | iscsi_free_mgmt_task(conn, mtask); |
735 | break; | 737 | break; |
736 | default: | 738 | default: |
@@ -1453,19 +1455,20 @@ static void iscsi_check_transport_timeouts(unsigned long data) | |||
1453 | { | 1455 | { |
1454 | struct iscsi_conn *conn = (struct iscsi_conn *)data; | 1456 | struct iscsi_conn *conn = (struct iscsi_conn *)data; |
1455 | struct iscsi_session *session = conn->session; | 1457 | struct iscsi_session *session = conn->session; |
1456 | unsigned long timeout, next_timeout = 0, last_recv; | 1458 | unsigned long recv_timeout, next_timeout = 0, last_recv; |
1457 | 1459 | ||
1458 | spin_lock(&session->lock); | 1460 | spin_lock(&session->lock); |
1459 | if (session->state != ISCSI_STATE_LOGGED_IN) | 1461 | if (session->state != ISCSI_STATE_LOGGED_IN) |
1460 | goto done; | 1462 | goto done; |
1461 | 1463 | ||
1462 | timeout = conn->recv_timeout; | 1464 | recv_timeout = conn->recv_timeout; |
1463 | if (!timeout) | 1465 | if (!recv_timeout) |
1464 | goto done; | 1466 | goto done; |
1465 | 1467 | ||
1466 | timeout *= HZ; | 1468 | recv_timeout *= HZ; |
1467 | last_recv = conn->last_recv; | 1469 | last_recv = conn->last_recv; |
1468 | if (time_before_eq(last_recv + timeout + (conn->ping_timeout * HZ), | 1470 | if (conn->ping_mtask && |
1471 | time_before_eq(conn->last_ping + (conn->ping_timeout * HZ), | ||
1469 | jiffies)) { | 1472 | jiffies)) { |
1470 | iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " | 1473 | iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " |
1471 | "expired, last rx %lu, last ping %lu, " | 1474 | "expired, last rx %lu, last ping %lu, " |
@@ -1476,15 +1479,13 @@ static void iscsi_check_transport_timeouts(unsigned long data) | |||
1476 | return; | 1479 | return; |
1477 | } | 1480 | } |
1478 | 1481 | ||
1479 | if (time_before_eq(last_recv + timeout, jiffies)) { | 1482 | if (time_before_eq(last_recv + recv_timeout, jiffies)) { |
1480 | if (time_before_eq(conn->last_ping, last_recv)) { | 1483 | /* send a ping to try to provoke some traffic */ |
1481 | /* send a ping to try to provoke some traffic */ | 1484 | debug_scsi("Sending nopout as ping on conn %p\n", conn); |
1482 | debug_scsi("Sending nopout as ping on conn %p\n", conn); | 1485 | iscsi_send_nopout(conn, NULL); |
1483 | iscsi_send_nopout(conn, NULL); | 1486 | next_timeout = conn->last_ping + (conn->ping_timeout * HZ); |
1484 | } | ||
1485 | next_timeout = last_recv + timeout + (conn->ping_timeout * HZ); | ||
1486 | } else | 1487 | } else |
1487 | next_timeout = last_recv + timeout; | 1488 | next_timeout = last_recv + recv_timeout; |
1488 | 1489 | ||
1489 | debug_scsi("Setting next tmo %lu\n", next_timeout); | 1490 | debug_scsi("Setting next tmo %lu\n", next_timeout); |
1490 | mod_timer(&conn->transport_timer, next_timeout); | 1491 | mod_timer(&conn->transport_timer, next_timeout); |
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index fa060932d2b4..51e2f299dbbb 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c | |||
@@ -2007,7 +2007,7 @@ qla1280_set_defaults(struct scsi_qla_host *ha) | |||
2007 | nv->bus[bus].config_2.req_ack_active_negation = 1; | 2007 | nv->bus[bus].config_2.req_ack_active_negation = 1; |
2008 | nv->bus[bus].config_2.data_line_active_negation = 1; | 2008 | nv->bus[bus].config_2.data_line_active_negation = 1; |
2009 | nv->bus[bus].selection_timeout = 250; | 2009 | nv->bus[bus].selection_timeout = 250; |
2010 | nv->bus[bus].max_queue_depth = 256; | 2010 | nv->bus[bus].max_queue_depth = 32; |
2011 | 2011 | ||
2012 | if (IS_ISP1040(ha)) { | 2012 | if (IS_ISP1040(ha)) { |
2013 | nv->bus[bus].bus_reset_delay = 3; | 2013 | nv->bus[bus].bus_reset_delay = 3; |
@@ -2051,7 +2051,7 @@ qla1280_config_target(struct scsi_qla_host *ha, int bus, int target) | |||
2051 | status = qla1280_mailbox_command(ha, 0x0f, mb); | 2051 | status = qla1280_mailbox_command(ha, 0x0f, mb); |
2052 | 2052 | ||
2053 | /* Save Tag queuing enable flag. */ | 2053 | /* Save Tag queuing enable flag. */ |
2054 | flag = (BIT_0 << target) & mb[0]; | 2054 | flag = (BIT_0 << target); |
2055 | if (nv->bus[bus].target[target].parameter.tag_queuing) | 2055 | if (nv->bus[bus].target[target].parameter.tag_queuing) |
2056 | ha->bus_settings[bus].qtag_enables |= flag; | 2056 | ha->bus_settings[bus].qtag_enables |= flag; |
2057 | 2057 | ||
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index fae9e8f3d092..66ec5d8808de 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -126,7 +126,6 @@ config SPI_MPC52xx_PSC | |||
126 | config SPI_MPC83xx | 126 | config SPI_MPC83xx |
127 | tristate "Freescale MPC83xx/QUICC Engine SPI controller" | 127 | tristate "Freescale MPC83xx/QUICC Engine SPI controller" |
128 | depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL | 128 | depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL |
129 | select SPI_BITBANG | ||
130 | help | 129 | help |
131 | This enables using the Freescale MPC83xx and QUICC Engine SPI | 130 | This enables using the Freescale MPC83xx and QUICC Engine SPI |
132 | controllers in master mode. | 131 | controllers in master mode. |
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index 654bb58be630..0c452c46ab07 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c | |||
@@ -1567,7 +1567,7 @@ static int pxa2xx_spi_resume(struct platform_device *pdev) | |||
1567 | int status = 0; | 1567 | int status = 0; |
1568 | 1568 | ||
1569 | /* Enable the SSP clock */ | 1569 | /* Enable the SSP clock */ |
1570 | clk_disable(ssp->clk); | 1570 | clk_enable(ssp->clk); |
1571 | 1571 | ||
1572 | /* Start the queue running */ | 1572 | /* Start the queue running */ |
1573 | status = start_queue(drv_data); | 1573 | status = start_queue(drv_data); |
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index 189f706b9e4b..6832da6f7109 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c | |||
@@ -49,6 +49,7 @@ struct mpc83xx_spi_reg { | |||
49 | #define SPMODE_LEN(x) ((x) << 20) | 49 | #define SPMODE_LEN(x) ((x) << 20) |
50 | #define SPMODE_PM(x) ((x) << 16) | 50 | #define SPMODE_PM(x) ((x) << 16) |
51 | #define SPMODE_OP (1 << 14) | 51 | #define SPMODE_OP (1 << 14) |
52 | #define SPMODE_CG(x) ((x) << 7) | ||
52 | 53 | ||
53 | /* | 54 | /* |
54 | * Default for SPI Mode: | 55 | * Default for SPI Mode: |
@@ -67,10 +68,6 @@ struct mpc83xx_spi_reg { | |||
67 | 68 | ||
68 | /* SPI Controller driver's private data. */ | 69 | /* SPI Controller driver's private data. */ |
69 | struct mpc83xx_spi { | 70 | struct mpc83xx_spi { |
70 | /* bitbang has to be first */ | ||
71 | struct spi_bitbang bitbang; | ||
72 | struct completion done; | ||
73 | |||
74 | struct mpc83xx_spi_reg __iomem *base; | 71 | struct mpc83xx_spi_reg __iomem *base; |
75 | 72 | ||
76 | /* rx & tx bufs from the spi_transfer */ | 73 | /* rx & tx bufs from the spi_transfer */ |
@@ -82,7 +79,7 @@ struct mpc83xx_spi { | |||
82 | u32(*get_tx) (struct mpc83xx_spi *); | 79 | u32(*get_tx) (struct mpc83xx_spi *); |
83 | 80 | ||
84 | unsigned int count; | 81 | unsigned int count; |
85 | u32 irq; | 82 | int irq; |
86 | 83 | ||
87 | unsigned nsecs; /* (clock cycle time)/2 */ | 84 | unsigned nsecs; /* (clock cycle time)/2 */ |
88 | 85 | ||
@@ -94,6 +91,25 @@ struct mpc83xx_spi { | |||
94 | 91 | ||
95 | void (*activate_cs) (u8 cs, u8 polarity); | 92 | void (*activate_cs) (u8 cs, u8 polarity); |
96 | void (*deactivate_cs) (u8 cs, u8 polarity); | 93 | void (*deactivate_cs) (u8 cs, u8 polarity); |
94 | |||
95 | u8 busy; | ||
96 | |||
97 | struct workqueue_struct *workqueue; | ||
98 | struct work_struct work; | ||
99 | |||
100 | struct list_head queue; | ||
101 | spinlock_t lock; | ||
102 | |||
103 | struct completion done; | ||
104 | }; | ||
105 | |||
106 | struct spi_mpc83xx_cs { | ||
107 | /* functions to deal with different sized buffers */ | ||
108 | void (*get_rx) (u32 rx_data, struct mpc83xx_spi *); | ||
109 | u32 (*get_tx) (struct mpc83xx_spi *); | ||
110 | u32 rx_shift; /* RX data reg shift when in qe mode */ | ||
111 | u32 tx_shift; /* TX data reg shift when in qe mode */ | ||
112 | u32 hw_mode; /* Holds HW mode register settings */ | ||
97 | }; | 113 | }; |
98 | 114 | ||
99 | static inline void mpc83xx_spi_write_reg(__be32 __iomem * reg, u32 val) | 115 | static inline void mpc83xx_spi_write_reg(__be32 __iomem * reg, u32 val) |
@@ -137,6 +153,7 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value) | |||
137 | { | 153 | { |
138 | struct mpc83xx_spi *mpc83xx_spi; | 154 | struct mpc83xx_spi *mpc83xx_spi; |
139 | u8 pol = spi->mode & SPI_CS_HIGH ? 1 : 0; | 155 | u8 pol = spi->mode & SPI_CS_HIGH ? 1 : 0; |
156 | struct spi_mpc83xx_cs *cs = spi->controller_state; | ||
140 | 157 | ||
141 | mpc83xx_spi = spi_master_get_devdata(spi->master); | 158 | mpc83xx_spi = spi_master_get_devdata(spi->master); |
142 | 159 | ||
@@ -147,50 +164,26 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value) | |||
147 | 164 | ||
148 | if (value == BITBANG_CS_ACTIVE) { | 165 | if (value == BITBANG_CS_ACTIVE) { |
149 | u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | 166 | u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); |
150 | u32 len = spi->bits_per_word; | ||
151 | u8 pm; | ||
152 | 167 | ||
153 | if (len == 32) | 168 | mpc83xx_spi->rx_shift = cs->rx_shift; |
154 | len = 0; | 169 | mpc83xx_spi->tx_shift = cs->tx_shift; |
155 | else | 170 | mpc83xx_spi->get_rx = cs->get_rx; |
156 | len = len - 1; | 171 | mpc83xx_spi->get_tx = cs->get_tx; |
157 | 172 | ||
158 | /* mask out bits we are going to set */ | 173 | if (cs->hw_mode != regval) { |
159 | regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH | 174 | unsigned long flags; |
160 | | SPMODE_LEN(0xF) | SPMODE_DIV16 | 175 | void *tmp_ptr = &mpc83xx_spi->base->mode; |
161 | | SPMODE_PM(0xF) | SPMODE_REV | SPMODE_LOOP); | 176 | |
162 | 177 | regval = cs->hw_mode; | |
163 | if (spi->mode & SPI_CPHA) | 178 | /* Turn off IRQs locally to minimize time that |
164 | regval |= SPMODE_CP_BEGIN_EDGECLK; | 179 | * SPI is disabled |
165 | if (spi->mode & SPI_CPOL) | 180 | */ |
166 | regval |= SPMODE_CI_INACTIVEHIGH; | 181 | local_irq_save(flags); |
167 | if (!(spi->mode & SPI_LSB_FIRST)) | 182 | /* Turn off SPI unit prior changing mode */ |
168 | regval |= SPMODE_REV; | 183 | mpc83xx_spi_write_reg(tmp_ptr, regval & ~SPMODE_ENABLE); |
169 | if (spi->mode & SPI_LOOP) | 184 | mpc83xx_spi_write_reg(tmp_ptr, regval); |
170 | regval |= SPMODE_LOOP; | 185 | local_irq_restore(flags); |
171 | |||
172 | regval |= SPMODE_LEN(len); | ||
173 | |||
174 | if ((mpc83xx_spi->spibrg / spi->max_speed_hz) >= 64) { | ||
175 | pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 64) - 1; | ||
176 | if (pm > 0x0f) { | ||
177 | dev_err(&spi->dev, "Requested speed is too " | ||
178 | "low: %d Hz. Will use %d Hz instead.\n", | ||
179 | spi->max_speed_hz, | ||
180 | mpc83xx_spi->spibrg / 1024); | ||
181 | pm = 0x0f; | ||
182 | } | ||
183 | regval |= SPMODE_PM(pm) | SPMODE_DIV16; | ||
184 | } else { | ||
185 | pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 4); | ||
186 | if (pm) | ||
187 | pm--; | ||
188 | regval |= SPMODE_PM(pm); | ||
189 | } | 186 | } |
190 | |||
191 | /* Turn off SPI unit prior changing mode */ | ||
192 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0); | ||
193 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); | ||
194 | if (mpc83xx_spi->activate_cs) | 187 | if (mpc83xx_spi->activate_cs) |
195 | mpc83xx_spi->activate_cs(spi->chip_select, pol); | 188 | mpc83xx_spi->activate_cs(spi->chip_select, pol); |
196 | } | 189 | } |
@@ -201,8 +194,9 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
201 | { | 194 | { |
202 | struct mpc83xx_spi *mpc83xx_spi; | 195 | struct mpc83xx_spi *mpc83xx_spi; |
203 | u32 regval; | 196 | u32 regval; |
204 | u8 bits_per_word; | 197 | u8 bits_per_word, pm; |
205 | u32 hz; | 198 | u32 hz; |
199 | struct spi_mpc83xx_cs *cs = spi->controller_state; | ||
206 | 200 | ||
207 | mpc83xx_spi = spi_master_get_devdata(spi->master); | 201 | mpc83xx_spi = spi_master_get_devdata(spi->master); |
208 | 202 | ||
@@ -223,61 +217,191 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
223 | || ((bits_per_word > 16) && (bits_per_word != 32))) | 217 | || ((bits_per_word > 16) && (bits_per_word != 32))) |
224 | return -EINVAL; | 218 | return -EINVAL; |
225 | 219 | ||
226 | mpc83xx_spi->rx_shift = 0; | 220 | if (!hz) |
227 | mpc83xx_spi->tx_shift = 0; | 221 | hz = spi->max_speed_hz; |
222 | |||
223 | cs->rx_shift = 0; | ||
224 | cs->tx_shift = 0; | ||
228 | if (bits_per_word <= 8) { | 225 | if (bits_per_word <= 8) { |
229 | mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u8; | 226 | cs->get_rx = mpc83xx_spi_rx_buf_u8; |
230 | mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u8; | 227 | cs->get_tx = mpc83xx_spi_tx_buf_u8; |
231 | if (mpc83xx_spi->qe_mode) { | 228 | if (mpc83xx_spi->qe_mode) { |
232 | mpc83xx_spi->rx_shift = 16; | 229 | cs->rx_shift = 16; |
233 | mpc83xx_spi->tx_shift = 24; | 230 | cs->tx_shift = 24; |
234 | } | 231 | } |
235 | } else if (bits_per_word <= 16) { | 232 | } else if (bits_per_word <= 16) { |
236 | mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u16; | 233 | cs->get_rx = mpc83xx_spi_rx_buf_u16; |
237 | mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u16; | 234 | cs->get_tx = mpc83xx_spi_tx_buf_u16; |
238 | if (mpc83xx_spi->qe_mode) { | 235 | if (mpc83xx_spi->qe_mode) { |
239 | mpc83xx_spi->rx_shift = 16; | 236 | cs->rx_shift = 16; |
240 | mpc83xx_spi->tx_shift = 16; | 237 | cs->tx_shift = 16; |
241 | } | 238 | } |
242 | } else if (bits_per_word <= 32) { | 239 | } else if (bits_per_word <= 32) { |
243 | mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u32; | 240 | cs->get_rx = mpc83xx_spi_rx_buf_u32; |
244 | mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u32; | 241 | cs->get_tx = mpc83xx_spi_tx_buf_u32; |
245 | } else | 242 | } else |
246 | return -EINVAL; | 243 | return -EINVAL; |
247 | 244 | ||
248 | if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) { | 245 | if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) { |
249 | mpc83xx_spi->tx_shift = 0; | 246 | cs->tx_shift = 0; |
250 | if (bits_per_word <= 8) | 247 | if (bits_per_word <= 8) |
251 | mpc83xx_spi->rx_shift = 8; | 248 | cs->rx_shift = 8; |
252 | else | 249 | else |
253 | mpc83xx_spi->rx_shift = 0; | 250 | cs->rx_shift = 0; |
254 | } | 251 | } |
255 | 252 | ||
256 | /* nsecs = (clock period)/2 */ | 253 | mpc83xx_spi->rx_shift = cs->rx_shift; |
257 | if (!hz) | 254 | mpc83xx_spi->tx_shift = cs->tx_shift; |
258 | hz = spi->max_speed_hz; | 255 | mpc83xx_spi->get_rx = cs->get_rx; |
259 | mpc83xx_spi->nsecs = (1000000000 / 2) / hz; | 256 | mpc83xx_spi->get_tx = cs->get_tx; |
260 | if (mpc83xx_spi->nsecs > MAX_UDELAY_MS * 1000) | ||
261 | return -EINVAL; | ||
262 | 257 | ||
263 | if (bits_per_word == 32) | 258 | if (bits_per_word == 32) |
264 | bits_per_word = 0; | 259 | bits_per_word = 0; |
265 | else | 260 | else |
266 | bits_per_word = bits_per_word - 1; | 261 | bits_per_word = bits_per_word - 1; |
267 | 262 | ||
268 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | ||
269 | |||
270 | /* mask out bits we are going to set */ | 263 | /* mask out bits we are going to set */ |
271 | regval &= ~(SPMODE_LEN(0xF) | SPMODE_REV); | 264 | cs->hw_mode &= ~(SPMODE_LEN(0xF) | SPMODE_DIV16 |
272 | regval |= SPMODE_LEN(bits_per_word); | 265 | | SPMODE_PM(0xF)); |
273 | if (!(spi->mode & SPI_LSB_FIRST)) | 266 | |
274 | regval |= SPMODE_REV; | 267 | cs->hw_mode |= SPMODE_LEN(bits_per_word); |
268 | |||
269 | if ((mpc83xx_spi->spibrg / hz) >= 64) { | ||
270 | pm = mpc83xx_spi->spibrg / (hz * 64) - 1; | ||
271 | if (pm > 0x0f) { | ||
272 | dev_err(&spi->dev, "Requested speed is too " | ||
273 | "low: %d Hz. Will use %d Hz instead.\n", | ||
274 | hz, mpc83xx_spi->spibrg / 1024); | ||
275 | pm = 0x0f; | ||
276 | } | ||
277 | cs->hw_mode |= SPMODE_PM(pm) | SPMODE_DIV16; | ||
278 | } else { | ||
279 | pm = mpc83xx_spi->spibrg / (hz * 4); | ||
280 | if (pm) | ||
281 | pm--; | ||
282 | cs->hw_mode |= SPMODE_PM(pm); | ||
283 | } | ||
284 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | ||
285 | if (cs->hw_mode != regval) { | ||
286 | unsigned long flags; | ||
287 | void *tmp_ptr = &mpc83xx_spi->base->mode; | ||
288 | |||
289 | regval = cs->hw_mode; | ||
290 | /* Turn off IRQs locally to minimize time | ||
291 | * that SPI is disabled | ||
292 | */ | ||
293 | local_irq_save(flags); | ||
294 | /* Turn off SPI unit prior changing mode */ | ||
295 | mpc83xx_spi_write_reg(tmp_ptr, regval & ~SPMODE_ENABLE); | ||
296 | mpc83xx_spi_write_reg(tmp_ptr, regval); | ||
297 | local_irq_restore(flags); | ||
298 | } | ||
299 | return 0; | ||
300 | } | ||
275 | 301 | ||
276 | /* Turn off SPI unit prior changing mode */ | 302 | static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t) |
277 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0); | 303 | { |
278 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); | 304 | struct mpc83xx_spi *mpc83xx_spi; |
305 | u32 word, len, bits_per_word; | ||
279 | 306 | ||
280 | return 0; | 307 | mpc83xx_spi = spi_master_get_devdata(spi->master); |
308 | |||
309 | mpc83xx_spi->tx = t->tx_buf; | ||
310 | mpc83xx_spi->rx = t->rx_buf; | ||
311 | bits_per_word = spi->bits_per_word; | ||
312 | if (t->bits_per_word) | ||
313 | bits_per_word = t->bits_per_word; | ||
314 | len = t->len; | ||
315 | if (bits_per_word > 8) | ||
316 | len /= 2; | ||
317 | if (bits_per_word > 16) | ||
318 | len /= 2; | ||
319 | mpc83xx_spi->count = len; | ||
320 | INIT_COMPLETION(mpc83xx_spi->done); | ||
321 | |||
322 | /* enable rx ints */ | ||
323 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, SPIM_NE); | ||
324 | |||
325 | /* transmit word */ | ||
326 | word = mpc83xx_spi->get_tx(mpc83xx_spi); | ||
327 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit, word); | ||
328 | |||
329 | wait_for_completion(&mpc83xx_spi->done); | ||
330 | |||
331 | /* disable rx ints */ | ||
332 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0); | ||
333 | |||
334 | return mpc83xx_spi->count; | ||
335 | } | ||
336 | |||
337 | static void mpc83xx_spi_work(struct work_struct *work) | ||
338 | { | ||
339 | struct mpc83xx_spi *mpc83xx_spi = | ||
340 | container_of(work, struct mpc83xx_spi, work); | ||
341 | |||
342 | spin_lock_irq(&mpc83xx_spi->lock); | ||
343 | mpc83xx_spi->busy = 1; | ||
344 | while (!list_empty(&mpc83xx_spi->queue)) { | ||
345 | struct spi_message *m; | ||
346 | struct spi_device *spi; | ||
347 | struct spi_transfer *t = NULL; | ||
348 | unsigned cs_change; | ||
349 | int status, nsecs = 50; | ||
350 | |||
351 | m = container_of(mpc83xx_spi->queue.next, | ||
352 | struct spi_message, queue); | ||
353 | list_del_init(&m->queue); | ||
354 | spin_unlock_irq(&mpc83xx_spi->lock); | ||
355 | |||
356 | spi = m->spi; | ||
357 | cs_change = 1; | ||
358 | status = 0; | ||
359 | list_for_each_entry(t, &m->transfers, transfer_list) { | ||
360 | if (t->bits_per_word || t->speed_hz) { | ||
361 | /* Don't allow changes if CS is active */ | ||
362 | status = -EINVAL; | ||
363 | |||
364 | if (cs_change) | ||
365 | status = mpc83xx_spi_setup_transfer(spi, t); | ||
366 | if (status < 0) | ||
367 | break; | ||
368 | } | ||
369 | |||
370 | if (cs_change) | ||
371 | mpc83xx_spi_chipselect(spi, BITBANG_CS_ACTIVE); | ||
372 | cs_change = t->cs_change; | ||
373 | if (t->len) | ||
374 | status = mpc83xx_spi_bufs(spi, t); | ||
375 | if (status) { | ||
376 | status = -EMSGSIZE; | ||
377 | break; | ||
378 | } | ||
379 | m->actual_length += t->len; | ||
380 | |||
381 | if (t->delay_usecs) | ||
382 | udelay(t->delay_usecs); | ||
383 | |||
384 | if (cs_change) { | ||
385 | ndelay(nsecs); | ||
386 | mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE); | ||
387 | ndelay(nsecs); | ||
388 | } | ||
389 | } | ||
390 | |||
391 | m->status = status; | ||
392 | m->complete(m->context); | ||
393 | |||
394 | if (status || !cs_change) { | ||
395 | ndelay(nsecs); | ||
396 | mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE); | ||
397 | } | ||
398 | |||
399 | mpc83xx_spi_setup_transfer(spi, NULL); | ||
400 | |||
401 | spin_lock_irq(&mpc83xx_spi->lock); | ||
402 | } | ||
403 | mpc83xx_spi->busy = 0; | ||
404 | spin_unlock_irq(&mpc83xx_spi->lock); | ||
281 | } | 405 | } |
282 | 406 | ||
283 | /* the spi->mode bits understood by this driver: */ | 407 | /* the spi->mode bits understood by this driver: */ |
@@ -286,9 +410,10 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
286 | 410 | ||
287 | static int mpc83xx_spi_setup(struct spi_device *spi) | 411 | static int mpc83xx_spi_setup(struct spi_device *spi) |
288 | { | 412 | { |
289 | struct spi_bitbang *bitbang; | ||
290 | struct mpc83xx_spi *mpc83xx_spi; | 413 | struct mpc83xx_spi *mpc83xx_spi; |
291 | int retval; | 414 | int retval; |
415 | u32 hw_mode; | ||
416 | struct spi_mpc83xx_cs *cs = spi->controller_state; | ||
292 | 417 | ||
293 | if (spi->mode & ~MODEBITS) { | 418 | if (spi->mode & ~MODEBITS) { |
294 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", | 419 | dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", |
@@ -299,63 +424,56 @@ static int mpc83xx_spi_setup(struct spi_device *spi) | |||
299 | if (!spi->max_speed_hz) | 424 | if (!spi->max_speed_hz) |
300 | return -EINVAL; | 425 | return -EINVAL; |
301 | 426 | ||
302 | bitbang = spi_master_get_devdata(spi->master); | 427 | if (!cs) { |
428 | cs = kzalloc(sizeof *cs, GFP_KERNEL); | ||
429 | if (!cs) | ||
430 | return -ENOMEM; | ||
431 | spi->controller_state = cs; | ||
432 | } | ||
303 | mpc83xx_spi = spi_master_get_devdata(spi->master); | 433 | mpc83xx_spi = spi_master_get_devdata(spi->master); |
304 | 434 | ||
305 | if (!spi->bits_per_word) | 435 | if (!spi->bits_per_word) |
306 | spi->bits_per_word = 8; | 436 | spi->bits_per_word = 8; |
307 | 437 | ||
438 | hw_mode = cs->hw_mode; /* Save orginal settings */ | ||
439 | cs->hw_mode = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | ||
440 | /* mask out bits we are going to set */ | ||
441 | cs->hw_mode &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH | ||
442 | | SPMODE_REV | SPMODE_LOOP); | ||
443 | |||
444 | if (spi->mode & SPI_CPHA) | ||
445 | cs->hw_mode |= SPMODE_CP_BEGIN_EDGECLK; | ||
446 | if (spi->mode & SPI_CPOL) | ||
447 | cs->hw_mode |= SPMODE_CI_INACTIVEHIGH; | ||
448 | if (!(spi->mode & SPI_LSB_FIRST)) | ||
449 | cs->hw_mode |= SPMODE_REV; | ||
450 | if (spi->mode & SPI_LOOP) | ||
451 | cs->hw_mode |= SPMODE_LOOP; | ||
452 | |||
308 | retval = mpc83xx_spi_setup_transfer(spi, NULL); | 453 | retval = mpc83xx_spi_setup_transfer(spi, NULL); |
309 | if (retval < 0) | 454 | if (retval < 0) { |
455 | cs->hw_mode = hw_mode; /* Restore settings */ | ||
310 | return retval; | 456 | return retval; |
457 | } | ||
311 | 458 | ||
312 | dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec\n", | 459 | dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u Hz\n", |
313 | __func__, spi->mode & (SPI_CPOL | SPI_CPHA), | 460 | __func__, spi->mode & (SPI_CPOL | SPI_CPHA), |
314 | spi->bits_per_word, 2 * mpc83xx_spi->nsecs); | 461 | spi->bits_per_word, spi->max_speed_hz); |
315 | 462 | #if 0 /* Don't think this is needed */ | |
316 | /* NOTE we _need_ to call chipselect() early, ideally with adapter | 463 | /* NOTE we _need_ to call chipselect() early, ideally with adapter |
317 | * setup, unless the hardware defaults cooperate to avoid confusion | 464 | * setup, unless the hardware defaults cooperate to avoid confusion |
318 | * between normal (active low) and inverted chipselects. | 465 | * between normal (active low) and inverted chipselects. |
319 | */ | 466 | */ |
320 | 467 | ||
321 | /* deselect chip (low or high) */ | 468 | /* deselect chip (low or high) */ |
322 | spin_lock(&bitbang->lock); | 469 | spin_lock(&mpc83xx_spi->lock); |
323 | if (!bitbang->busy) { | 470 | if (!mpc83xx_spi->busy) |
324 | bitbang->chipselect(spi, BITBANG_CS_INACTIVE); | 471 | mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE); |
325 | ndelay(mpc83xx_spi->nsecs); | 472 | spin_unlock(&mpc83xx_spi->lock); |
326 | } | 473 | #endif |
327 | spin_unlock(&bitbang->lock); | ||
328 | |||
329 | return 0; | 474 | return 0; |
330 | } | 475 | } |
331 | 476 | ||
332 | static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t) | ||
333 | { | ||
334 | struct mpc83xx_spi *mpc83xx_spi; | ||
335 | u32 word; | ||
336 | |||
337 | mpc83xx_spi = spi_master_get_devdata(spi->master); | ||
338 | |||
339 | mpc83xx_spi->tx = t->tx_buf; | ||
340 | mpc83xx_spi->rx = t->rx_buf; | ||
341 | mpc83xx_spi->count = t->len; | ||
342 | INIT_COMPLETION(mpc83xx_spi->done); | ||
343 | |||
344 | /* enable rx ints */ | ||
345 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, SPIM_NE); | ||
346 | |||
347 | /* transmit word */ | ||
348 | word = mpc83xx_spi->get_tx(mpc83xx_spi); | ||
349 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit, word); | ||
350 | |||
351 | wait_for_completion(&mpc83xx_spi->done); | ||
352 | |||
353 | /* disable rx ints */ | ||
354 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0); | ||
355 | |||
356 | return t->len - mpc83xx_spi->count; | ||
357 | } | ||
358 | |||
359 | irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data) | 477 | irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data) |
360 | { | 478 | { |
361 | struct mpc83xx_spi *mpc83xx_spi = context_data; | 479 | struct mpc83xx_spi *mpc83xx_spi = context_data; |
@@ -395,6 +513,28 @@ irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data) | |||
395 | 513 | ||
396 | return ret; | 514 | return ret; |
397 | } | 515 | } |
516 | static int mpc83xx_spi_transfer(struct spi_device *spi, | ||
517 | struct spi_message *m) | ||
518 | { | ||
519 | struct mpc83xx_spi *mpc83xx_spi = spi_master_get_devdata(spi->master); | ||
520 | unsigned long flags; | ||
521 | |||
522 | m->actual_length = 0; | ||
523 | m->status = -EINPROGRESS; | ||
524 | |||
525 | spin_lock_irqsave(&mpc83xx_spi->lock, flags); | ||
526 | list_add_tail(&m->queue, &mpc83xx_spi->queue); | ||
527 | queue_work(mpc83xx_spi->workqueue, &mpc83xx_spi->work); | ||
528 | spin_unlock_irqrestore(&mpc83xx_spi->lock, flags); | ||
529 | |||
530 | return 0; | ||
531 | } | ||
532 | |||
533 | |||
534 | static void mpc83xx_spi_cleanup(struct spi_device *spi) | ||
535 | { | ||
536 | kfree(spi->controller_state); | ||
537 | } | ||
398 | 538 | ||
399 | static int __init mpc83xx_spi_probe(struct platform_device *dev) | 539 | static int __init mpc83xx_spi_probe(struct platform_device *dev) |
400 | { | 540 | { |
@@ -426,11 +566,11 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev) | |||
426 | ret = -ENODEV; | 566 | ret = -ENODEV; |
427 | goto free_master; | 567 | goto free_master; |
428 | } | 568 | } |
569 | master->setup = mpc83xx_spi_setup; | ||
570 | master->transfer = mpc83xx_spi_transfer; | ||
571 | master->cleanup = mpc83xx_spi_cleanup; | ||
572 | |||
429 | mpc83xx_spi = spi_master_get_devdata(master); | 573 | mpc83xx_spi = spi_master_get_devdata(master); |
430 | mpc83xx_spi->bitbang.master = spi_master_get(master); | ||
431 | mpc83xx_spi->bitbang.chipselect = mpc83xx_spi_chipselect; | ||
432 | mpc83xx_spi->bitbang.setup_transfer = mpc83xx_spi_setup_transfer; | ||
433 | mpc83xx_spi->bitbang.txrx_bufs = mpc83xx_spi_bufs; | ||
434 | mpc83xx_spi->activate_cs = pdata->activate_cs; | 574 | mpc83xx_spi->activate_cs = pdata->activate_cs; |
435 | mpc83xx_spi->deactivate_cs = pdata->deactivate_cs; | 575 | mpc83xx_spi->deactivate_cs = pdata->deactivate_cs; |
436 | mpc83xx_spi->qe_mode = pdata->qe_mode; | 576 | mpc83xx_spi->qe_mode = pdata->qe_mode; |
@@ -445,7 +585,6 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev) | |||
445 | mpc83xx_spi->tx_shift = 24; | 585 | mpc83xx_spi->tx_shift = 24; |
446 | } | 586 | } |
447 | 587 | ||
448 | mpc83xx_spi->bitbang.master->setup = mpc83xx_spi_setup; | ||
449 | init_completion(&mpc83xx_spi->done); | 588 | init_completion(&mpc83xx_spi->done); |
450 | 589 | ||
451 | mpc83xx_spi->base = ioremap(r->start, r->end - r->start + 1); | 590 | mpc83xx_spi->base = ioremap(r->start, r->end - r->start + 1); |
@@ -483,11 +622,21 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev) | |||
483 | regval |= SPMODE_OP; | 622 | regval |= SPMODE_OP; |
484 | 623 | ||
485 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); | 624 | mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); |
625 | spin_lock_init(&mpc83xx_spi->lock); | ||
626 | init_completion(&mpc83xx_spi->done); | ||
627 | INIT_WORK(&mpc83xx_spi->work, mpc83xx_spi_work); | ||
628 | INIT_LIST_HEAD(&mpc83xx_spi->queue); | ||
486 | 629 | ||
487 | ret = spi_bitbang_start(&mpc83xx_spi->bitbang); | 630 | mpc83xx_spi->workqueue = create_singlethread_workqueue( |
488 | 631 | master->dev.parent->bus_id); | |
489 | if (ret != 0) | 632 | if (mpc83xx_spi->workqueue == NULL) { |
633 | ret = -EBUSY; | ||
490 | goto free_irq; | 634 | goto free_irq; |
635 | } | ||
636 | |||
637 | ret = spi_register_master(master); | ||
638 | if (ret < 0) | ||
639 | goto unreg_master; | ||
491 | 640 | ||
492 | printk(KERN_INFO | 641 | printk(KERN_INFO |
493 | "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n", | 642 | "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n", |
@@ -495,6 +644,8 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev) | |||
495 | 644 | ||
496 | return ret; | 645 | return ret; |
497 | 646 | ||
647 | unreg_master: | ||
648 | destroy_workqueue(mpc83xx_spi->workqueue); | ||
498 | free_irq: | 649 | free_irq: |
499 | free_irq(mpc83xx_spi->irq, mpc83xx_spi); | 650 | free_irq(mpc83xx_spi->irq, mpc83xx_spi); |
500 | unmap_io: | 651 | unmap_io: |
@@ -515,10 +666,12 @@ static int __exit mpc83xx_spi_remove(struct platform_device *dev) | |||
515 | master = platform_get_drvdata(dev); | 666 | master = platform_get_drvdata(dev); |
516 | mpc83xx_spi = spi_master_get_devdata(master); | 667 | mpc83xx_spi = spi_master_get_devdata(master); |
517 | 668 | ||
518 | spi_bitbang_stop(&mpc83xx_spi->bitbang); | 669 | flush_workqueue(mpc83xx_spi->workqueue); |
670 | destroy_workqueue(mpc83xx_spi->workqueue); | ||
671 | spi_unregister_master(master); | ||
672 | |||
519 | free_irq(mpc83xx_spi->irq, mpc83xx_spi); | 673 | free_irq(mpc83xx_spi->irq, mpc83xx_spi); |
520 | iounmap(mpc83xx_spi->base); | 674 | iounmap(mpc83xx_spi->base); |
521 | spi_master_put(mpc83xx_spi->bitbang.master); | ||
522 | 675 | ||
523 | return 0; | 676 | return 0; |
524 | } | 677 | } |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index cefe7f2c6f75..63c34043b4d9 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -1248,6 +1248,9 @@ static struct usb_device_id acm_ids[] = { | |||
1248 | { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ | 1248 | { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ |
1249 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ | 1249 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ |
1250 | }, | 1250 | }, |
1251 | { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */ | ||
1252 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ | ||
1253 | }, | ||
1251 | 1254 | ||
1252 | /* control interfaces with various AT-command sets */ | 1255 | /* control interfaces with various AT-command sets */ |
1253 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, | 1256 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, |
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 99e5a68a3f12..fae55a31e26d 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c | |||
@@ -156,6 +156,10 @@ static struct attribute *ep_dev_attrs[] = { | |||
156 | static struct attribute_group ep_dev_attr_grp = { | 156 | static struct attribute_group ep_dev_attr_grp = { |
157 | .attrs = ep_dev_attrs, | 157 | .attrs = ep_dev_attrs, |
158 | }; | 158 | }; |
159 | static struct attribute_group *ep_dev_groups[] = { | ||
160 | &ep_dev_attr_grp, | ||
161 | NULL | ||
162 | }; | ||
159 | 163 | ||
160 | static int usb_endpoint_major_init(void) | 164 | static int usb_endpoint_major_init(void) |
161 | { | 165 | { |
@@ -298,6 +302,7 @@ int usb_create_ep_files(struct device *parent, | |||
298 | 302 | ||
299 | ep_dev->desc = &endpoint->desc; | 303 | ep_dev->desc = &endpoint->desc; |
300 | ep_dev->udev = udev; | 304 | ep_dev->udev = udev; |
305 | ep_dev->dev.groups = ep_dev_groups; | ||
301 | ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); | 306 | ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); |
302 | ep_dev->dev.class = ep_class->class; | 307 | ep_dev->dev.class = ep_class->class; |
303 | ep_dev->dev.parent = parent; | 308 | ep_dev->dev.parent = parent; |
@@ -309,9 +314,6 @@ int usb_create_ep_files(struct device *parent, | |||
309 | retval = device_register(&ep_dev->dev); | 314 | retval = device_register(&ep_dev->dev); |
310 | if (retval) | 315 | if (retval) |
311 | goto error_chrdev; | 316 | goto error_chrdev; |
312 | retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); | ||
313 | if (retval) | ||
314 | goto error_group; | ||
315 | 317 | ||
316 | /* create the symlink to the old-style "ep_XX" directory */ | 318 | /* create the symlink to the old-style "ep_XX" directory */ |
317 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); | 319 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); |
@@ -322,8 +324,6 @@ int usb_create_ep_files(struct device *parent, | |||
322 | return retval; | 324 | return retval; |
323 | 325 | ||
324 | error_link: | 326 | error_link: |
325 | sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); | ||
326 | error_group: | ||
327 | device_unregister(&ep_dev->dev); | 327 | device_unregister(&ep_dev->dev); |
328 | destroy_endpoint_class(); | 328 | destroy_endpoint_class(); |
329 | return retval; | 329 | return retval; |
@@ -348,7 +348,6 @@ void usb_remove_ep_files(struct usb_host_endpoint *endpoint) | |||
348 | 348 | ||
349 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); | 349 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); |
350 | sysfs_remove_link(&ep_dev->dev.parent->kobj, name); | 350 | sysfs_remove_link(&ep_dev->dev.parent->kobj, name); |
351 | sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); | ||
352 | device_unregister(&ep_dev->dev); | 351 | device_unregister(&ep_dev->dev); |
353 | endpoint->ep_dev = NULL; | 352 | endpoint->ep_dev = NULL; |
354 | destroy_endpoint_class(); | 353 | destroy_endpoint_class(); |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 3e69266e1f4d..fe47d145255a 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -1607,6 +1607,7 @@ free_interfaces: | |||
1607 | intf->dev.driver = NULL; | 1607 | intf->dev.driver = NULL; |
1608 | intf->dev.bus = &usb_bus_type; | 1608 | intf->dev.bus = &usb_bus_type; |
1609 | intf->dev.type = &usb_if_device_type; | 1609 | intf->dev.type = &usb_if_device_type; |
1610 | intf->dev.groups = usb_interface_groups; | ||
1610 | intf->dev.dma_mask = dev->dev.dma_mask; | 1611 | intf->dev.dma_mask = dev->dev.dma_mask; |
1611 | device_initialize(&intf->dev); | 1612 | device_initialize(&intf->dev); |
1612 | mark_quiesced(intf); | 1613 | mark_quiesced(intf); |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 5b20a60de8ba..c783cb111847 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -538,6 +538,46 @@ static struct attribute_group dev_attr_grp = { | |||
538 | .attrs = dev_attrs, | 538 | .attrs = dev_attrs, |
539 | }; | 539 | }; |
540 | 540 | ||
541 | /* When modifying this list, be sure to modify dev_string_attrs_are_visible() | ||
542 | * accordingly. | ||
543 | */ | ||
544 | static struct attribute *dev_string_attrs[] = { | ||
545 | &dev_attr_manufacturer.attr, | ||
546 | &dev_attr_product.attr, | ||
547 | &dev_attr_serial.attr, | ||
548 | NULL | ||
549 | }; | ||
550 | |||
551 | static mode_t dev_string_attrs_are_visible(struct kobject *kobj, | ||
552 | struct attribute *a, int n) | ||
553 | { | ||
554 | struct usb_device *udev = to_usb_device( | ||
555 | container_of(kobj, struct device, kobj)); | ||
556 | |||
557 | if (a == &dev_attr_manufacturer.attr) { | ||
558 | if (udev->manufacturer == NULL) | ||
559 | return 0; | ||
560 | } else if (a == &dev_attr_product.attr) { | ||
561 | if (udev->product == NULL) | ||
562 | return 0; | ||
563 | } else if (a == &dev_attr_serial.attr) { | ||
564 | if (udev->serial == NULL) | ||
565 | return 0; | ||
566 | } | ||
567 | return a->mode; | ||
568 | } | ||
569 | |||
570 | static struct attribute_group dev_string_attr_grp = { | ||
571 | .attrs = dev_string_attrs, | ||
572 | .is_visible = dev_string_attrs_are_visible, | ||
573 | }; | ||
574 | |||
575 | struct attribute_group *usb_device_groups[] = { | ||
576 | &dev_attr_grp, | ||
577 | &dev_string_attr_grp, | ||
578 | NULL | ||
579 | }; | ||
580 | |||
541 | /* Binary descriptors */ | 581 | /* Binary descriptors */ |
542 | 582 | ||
543 | static ssize_t | 583 | static ssize_t |
@@ -591,10 +631,9 @@ int usb_create_sysfs_dev_files(struct usb_device *udev) | |||
591 | struct device *dev = &udev->dev; | 631 | struct device *dev = &udev->dev; |
592 | int retval; | 632 | int retval; |
593 | 633 | ||
594 | retval = sysfs_create_group(&dev->kobj, &dev_attr_grp); | 634 | /* Unforunately these attributes cannot be created before |
595 | if (retval) | 635 | * the uevent is broadcast. |
596 | return retval; | 636 | */ |
597 | |||
598 | retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); | 637 | retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); |
599 | if (retval) | 638 | if (retval) |
600 | goto error; | 639 | goto error; |
@@ -607,21 +646,6 @@ int usb_create_sysfs_dev_files(struct usb_device *udev) | |||
607 | if (retval) | 646 | if (retval) |
608 | goto error; | 647 | goto error; |
609 | 648 | ||
610 | if (udev->manufacturer) { | ||
611 | retval = device_create_file(dev, &dev_attr_manufacturer); | ||
612 | if (retval) | ||
613 | goto error; | ||
614 | } | ||
615 | if (udev->product) { | ||
616 | retval = device_create_file(dev, &dev_attr_product); | ||
617 | if (retval) | ||
618 | goto error; | ||
619 | } | ||
620 | if (udev->serial) { | ||
621 | retval = device_create_file(dev, &dev_attr_serial); | ||
622 | if (retval) | ||
623 | goto error; | ||
624 | } | ||
625 | retval = usb_create_ep_files(dev, &udev->ep0, udev); | 649 | retval = usb_create_ep_files(dev, &udev->ep0, udev); |
626 | if (retval) | 650 | if (retval) |
627 | goto error; | 651 | goto error; |
@@ -636,13 +660,9 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev) | |||
636 | struct device *dev = &udev->dev; | 660 | struct device *dev = &udev->dev; |
637 | 661 | ||
638 | usb_remove_ep_files(&udev->ep0); | 662 | usb_remove_ep_files(&udev->ep0); |
639 | device_remove_file(dev, &dev_attr_manufacturer); | ||
640 | device_remove_file(dev, &dev_attr_product); | ||
641 | device_remove_file(dev, &dev_attr_serial); | ||
642 | remove_power_attributes(dev); | 663 | remove_power_attributes(dev); |
643 | remove_persist_attributes(dev); | 664 | remove_persist_attributes(dev); |
644 | device_remove_bin_file(dev, &dev_bin_attr_descriptors); | 665 | device_remove_bin_file(dev, &dev_bin_attr_descriptors); |
645 | sysfs_remove_group(&dev->kobj, &dev_attr_grp); | ||
646 | } | 666 | } |
647 | 667 | ||
648 | /* Interface Accociation Descriptor fields */ | 668 | /* Interface Accociation Descriptor fields */ |
@@ -688,17 +708,15 @@ static ssize_t show_interface_string(struct device *dev, | |||
688 | struct device_attribute *attr, char *buf) | 708 | struct device_attribute *attr, char *buf) |
689 | { | 709 | { |
690 | struct usb_interface *intf; | 710 | struct usb_interface *intf; |
691 | struct usb_device *udev; | 711 | char *string; |
692 | int len; | ||
693 | 712 | ||
694 | intf = to_usb_interface(dev); | 713 | intf = to_usb_interface(dev); |
695 | udev = interface_to_usbdev(intf); | 714 | string = intf->cur_altsetting->string; |
696 | len = snprintf(buf, 256, "%s", intf->cur_altsetting->string); | 715 | barrier(); /* The altsetting might change! */ |
697 | if (len < 0) | 716 | |
717 | if (!string) | ||
698 | return 0; | 718 | return 0; |
699 | buf[len] = '\n'; | 719 | return sprintf(buf, "%s\n", string); |
700 | buf[len+1] = 0; | ||
701 | return len+1; | ||
702 | } | 720 | } |
703 | static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); | 721 | static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); |
704 | 722 | ||
@@ -727,18 +745,6 @@ static ssize_t show_modalias(struct device *dev, | |||
727 | } | 745 | } |
728 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 746 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
729 | 747 | ||
730 | static struct attribute *intf_assoc_attrs[] = { | ||
731 | &dev_attr_iad_bFirstInterface.attr, | ||
732 | &dev_attr_iad_bInterfaceCount.attr, | ||
733 | &dev_attr_iad_bFunctionClass.attr, | ||
734 | &dev_attr_iad_bFunctionSubClass.attr, | ||
735 | &dev_attr_iad_bFunctionProtocol.attr, | ||
736 | NULL, | ||
737 | }; | ||
738 | static struct attribute_group intf_assoc_attr_grp = { | ||
739 | .attrs = intf_assoc_attrs, | ||
740 | }; | ||
741 | |||
742 | static struct attribute *intf_attrs[] = { | 748 | static struct attribute *intf_attrs[] = { |
743 | &dev_attr_bInterfaceNumber.attr, | 749 | &dev_attr_bInterfaceNumber.attr, |
744 | &dev_attr_bAlternateSetting.attr, | 750 | &dev_attr_bAlternateSetting.attr, |
@@ -753,6 +759,37 @@ static struct attribute_group intf_attr_grp = { | |||
753 | .attrs = intf_attrs, | 759 | .attrs = intf_attrs, |
754 | }; | 760 | }; |
755 | 761 | ||
762 | static struct attribute *intf_assoc_attrs[] = { | ||
763 | &dev_attr_iad_bFirstInterface.attr, | ||
764 | &dev_attr_iad_bInterfaceCount.attr, | ||
765 | &dev_attr_iad_bFunctionClass.attr, | ||
766 | &dev_attr_iad_bFunctionSubClass.attr, | ||
767 | &dev_attr_iad_bFunctionProtocol.attr, | ||
768 | NULL, | ||
769 | }; | ||
770 | |||
771 | static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj, | ||
772 | struct attribute *a, int n) | ||
773 | { | ||
774 | struct usb_interface *intf = to_usb_interface( | ||
775 | container_of(kobj, struct device, kobj)); | ||
776 | |||
777 | if (intf->intf_assoc == NULL) | ||
778 | return 0; | ||
779 | return a->mode; | ||
780 | } | ||
781 | |||
782 | static struct attribute_group intf_assoc_attr_grp = { | ||
783 | .attrs = intf_assoc_attrs, | ||
784 | .is_visible = intf_assoc_attrs_are_visible, | ||
785 | }; | ||
786 | |||
787 | struct attribute_group *usb_interface_groups[] = { | ||
788 | &intf_attr_grp, | ||
789 | &intf_assoc_attr_grp, | ||
790 | NULL | ||
791 | }; | ||
792 | |||
756 | static inline void usb_create_intf_ep_files(struct usb_interface *intf, | 793 | static inline void usb_create_intf_ep_files(struct usb_interface *intf, |
757 | struct usb_device *udev) | 794 | struct usb_device *udev) |
758 | { | 795 | { |
@@ -777,23 +814,21 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf) | |||
777 | 814 | ||
778 | int usb_create_sysfs_intf_files(struct usb_interface *intf) | 815 | int usb_create_sysfs_intf_files(struct usb_interface *intf) |
779 | { | 816 | { |
780 | struct device *dev = &intf->dev; | ||
781 | struct usb_device *udev = interface_to_usbdev(intf); | 817 | struct usb_device *udev = interface_to_usbdev(intf); |
782 | struct usb_host_interface *alt = intf->cur_altsetting; | 818 | struct usb_host_interface *alt = intf->cur_altsetting; |
783 | int retval; | 819 | int retval; |
784 | 820 | ||
785 | if (intf->sysfs_files_created) | 821 | if (intf->sysfs_files_created) |
786 | return 0; | 822 | return 0; |
787 | retval = sysfs_create_group(&dev->kobj, &intf_attr_grp); | ||
788 | if (retval) | ||
789 | return retval; | ||
790 | 823 | ||
824 | /* The interface string may be present in some altsettings | ||
825 | * and missing in others. Hence its attribute cannot be created | ||
826 | * before the uevent is broadcast. | ||
827 | */ | ||
791 | if (alt->string == NULL) | 828 | if (alt->string == NULL) |
792 | alt->string = usb_cache_string(udev, alt->desc.iInterface); | 829 | alt->string = usb_cache_string(udev, alt->desc.iInterface); |
793 | if (alt->string) | 830 | if (alt->string) |
794 | retval = device_create_file(dev, &dev_attr_interface); | 831 | retval = device_create_file(&intf->dev, &dev_attr_interface); |
795 | if (intf->intf_assoc) | ||
796 | retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp); | ||
797 | usb_create_intf_ep_files(intf, udev); | 832 | usb_create_intf_ep_files(intf, udev); |
798 | intf->sysfs_files_created = 1; | 833 | intf->sysfs_files_created = 1; |
799 | return 0; | 834 | return 0; |
@@ -807,7 +842,5 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf) | |||
807 | return; | 842 | return; |
808 | usb_remove_intf_ep_files(intf); | 843 | usb_remove_intf_ep_files(intf); |
809 | device_remove_file(dev, &dev_attr_interface); | 844 | device_remove_file(dev, &dev_attr_interface); |
810 | sysfs_remove_group(&dev->kobj, &intf_attr_grp); | ||
811 | sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp); | ||
812 | intf->sysfs_files_created = 0; | 845 | intf->sysfs_files_created = 0; |
813 | } | 846 | } |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 1f0db51190cc..325774375837 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -291,6 +291,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, | |||
291 | device_initialize(&dev->dev); | 291 | device_initialize(&dev->dev); |
292 | dev->dev.bus = &usb_bus_type; | 292 | dev->dev.bus = &usb_bus_type; |
293 | dev->dev.type = &usb_device_type; | 293 | dev->dev.type = &usb_device_type; |
294 | dev->dev.groups = usb_device_groups; | ||
294 | dev->dev.dma_mask = bus->controller->dma_mask; | 295 | dev->dev.dma_mask = bus->controller->dma_mask; |
295 | set_dev_node(&dev->dev, dev_to_node(bus->controller)); | 296 | set_dev_node(&dev->dev, dev_to_node(bus->controller)); |
296 | dev->state = USB_STATE_ATTACHED; | 297 | dev->state = USB_STATE_ATTACHED; |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 1bf8ccb9c58d..1a8bc21c335e 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -130,6 +130,10 @@ static inline int is_active(const struct usb_interface *f) | |||
130 | /* for labeling diagnostics */ | 130 | /* for labeling diagnostics */ |
131 | extern const char *usbcore_name; | 131 | extern const char *usbcore_name; |
132 | 132 | ||
133 | /* sysfs stuff */ | ||
134 | extern struct attribute_group *usb_device_groups[]; | ||
135 | extern struct attribute_group *usb_interface_groups[]; | ||
136 | |||
133 | /* usbfs stuff */ | 137 | /* usbfs stuff */ |
134 | extern struct mutex usbfs_mutex; | 138 | extern struct mutex usbfs_mutex; |
135 | extern struct usb_driver usbfs_driver; | 139 | extern struct usb_driver usbfs_driver; |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index ce337cb5d137..f261d2a9a5f0 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -3251,7 +3251,7 @@ static int udc_pci_probe( | |||
3251 | /* pci setup */ | 3251 | /* pci setup */ |
3252 | if (pci_enable_device(pdev) < 0) { | 3252 | if (pci_enable_device(pdev) < 0) { |
3253 | kfree(dev); | 3253 | kfree(dev); |
3254 | dev = 0; | 3254 | dev = NULL; |
3255 | retval = -ENODEV; | 3255 | retval = -ENODEV; |
3256 | goto finished; | 3256 | goto finished; |
3257 | } | 3257 | } |
@@ -3264,7 +3264,7 @@ static int udc_pci_probe( | |||
3264 | if (!request_mem_region(resource, len, name)) { | 3264 | if (!request_mem_region(resource, len, name)) { |
3265 | dev_dbg(&pdev->dev, "pci device used already\n"); | 3265 | dev_dbg(&pdev->dev, "pci device used already\n"); |
3266 | kfree(dev); | 3266 | kfree(dev); |
3267 | dev = 0; | 3267 | dev = NULL; |
3268 | retval = -EBUSY; | 3268 | retval = -EBUSY; |
3269 | goto finished; | 3269 | goto finished; |
3270 | } | 3270 | } |
@@ -3274,7 +3274,7 @@ static int udc_pci_probe( | |||
3274 | if (dev->virt_addr == NULL) { | 3274 | if (dev->virt_addr == NULL) { |
3275 | dev_dbg(&pdev->dev, "start address cannot be mapped\n"); | 3275 | dev_dbg(&pdev->dev, "start address cannot be mapped\n"); |
3276 | kfree(dev); | 3276 | kfree(dev); |
3277 | dev = 0; | 3277 | dev = NULL; |
3278 | retval = -EFAULT; | 3278 | retval = -EFAULT; |
3279 | goto finished; | 3279 | goto finished; |
3280 | } | 3280 | } |
@@ -3282,7 +3282,7 @@ static int udc_pci_probe( | |||
3282 | if (!pdev->irq) { | 3282 | if (!pdev->irq) { |
3283 | dev_err(&dev->pdev->dev, "irq not set\n"); | 3283 | dev_err(&dev->pdev->dev, "irq not set\n"); |
3284 | kfree(dev); | 3284 | kfree(dev); |
3285 | dev = 0; | 3285 | dev = NULL; |
3286 | retval = -ENODEV; | 3286 | retval = -ENODEV; |
3287 | goto finished; | 3287 | goto finished; |
3288 | } | 3288 | } |
@@ -3290,7 +3290,7 @@ static int udc_pci_probe( | |||
3290 | if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { | 3290 | if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { |
3291 | dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); | 3291 | dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); |
3292 | kfree(dev); | 3292 | kfree(dev); |
3293 | dev = 0; | 3293 | dev = NULL; |
3294 | retval = -EBUSY; | 3294 | retval = -EBUSY; |
3295 | goto finished; | 3295 | goto finished; |
3296 | } | 3296 | } |
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index e756023362c2..07e5a0b5dcda 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -649,7 +649,13 @@ static int usba_ep_disable(struct usb_ep *_ep) | |||
649 | 649 | ||
650 | if (!ep->desc) { | 650 | if (!ep->desc) { |
651 | spin_unlock_irqrestore(&udc->lock, flags); | 651 | spin_unlock_irqrestore(&udc->lock, flags); |
652 | DBG(DBG_ERR, "ep_disable: %s not enabled\n", ep->ep.name); | 652 | /* REVISIT because this driver disables endpoints in |
653 | * reset_all_endpoints() before calling disconnect(), | ||
654 | * most gadget drivers would trigger this non-error ... | ||
655 | */ | ||
656 | if (udc->gadget.speed != USB_SPEED_UNKNOWN) | ||
657 | DBG(DBG_ERR, "ep_disable: %s not enabled\n", | ||
658 | ep->ep.name); | ||
653 | return -EINVAL; | 659 | return -EINVAL; |
654 | } | 660 | } |
655 | ep->desc = NULL; | 661 | ep->desc = NULL; |
@@ -1032,8 +1038,6 @@ static struct usba_udc the_udc = { | |||
1032 | .release = nop_release, | 1038 | .release = nop_release, |
1033 | }, | 1039 | }, |
1034 | }, | 1040 | }, |
1035 | |||
1036 | .lock = SPIN_LOCK_UNLOCKED, | ||
1037 | }; | 1041 | }; |
1038 | 1042 | ||
1039 | /* | 1043 | /* |
@@ -1052,6 +1056,12 @@ static void reset_all_endpoints(struct usba_udc *udc) | |||
1052 | request_complete(ep, req, -ECONNRESET); | 1056 | request_complete(ep, req, -ECONNRESET); |
1053 | } | 1057 | } |
1054 | 1058 | ||
1059 | /* NOTE: normally, the next call to the gadget driver is in | ||
1060 | * charge of disabling endpoints... usually disconnect(). | ||
1061 | * The exception would be entering a high speed test mode. | ||
1062 | * | ||
1063 | * FIXME remove this code ... and retest thoroughly. | ||
1064 | */ | ||
1055 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { | 1065 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { |
1056 | if (ep->desc) { | 1066 | if (ep->desc) { |
1057 | spin_unlock(&udc->lock); | 1067 | spin_unlock(&udc->lock); |
@@ -1219,7 +1229,7 @@ static inline bool feature_is_ep_halt(struct usb_ctrlrequest *crq) | |||
1219 | static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, | 1229 | static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, |
1220 | struct usb_ctrlrequest *crq) | 1230 | struct usb_ctrlrequest *crq) |
1221 | { | 1231 | { |
1222 | int retval = 0;; | 1232 | int retval = 0; |
1223 | 1233 | ||
1224 | switch (crq->bRequest) { | 1234 | switch (crq->bRequest) { |
1225 | case USB_REQ_GET_STATUS: { | 1235 | case USB_REQ_GET_STATUS: { |
@@ -1693,6 +1703,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) | |||
1693 | usba_writel(udc, INT_CLR, USBA_END_OF_RESET); | 1703 | usba_writel(udc, INT_CLR, USBA_END_OF_RESET); |
1694 | reset_all_endpoints(udc); | 1704 | reset_all_endpoints(udc); |
1695 | 1705 | ||
1706 | if (udc->gadget.speed != USB_SPEED_UNKNOWN | ||
1707 | && udc->driver->disconnect) { | ||
1708 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1709 | spin_unlock(&udc->lock); | ||
1710 | udc->driver->disconnect(&udc->gadget); | ||
1711 | spin_lock(&udc->lock); | ||
1712 | } | ||
1713 | |||
1696 | if (status & USBA_HIGH_SPEED) { | 1714 | if (status & USBA_HIGH_SPEED) { |
1697 | DBG(DBG_BUS, "High-speed bus reset detected\n"); | 1715 | DBG(DBG_BUS, "High-speed bus reset detected\n"); |
1698 | udc->gadget.speed = USB_SPEED_HIGH; | 1716 | udc->gadget.speed = USB_SPEED_HIGH; |
@@ -1716,9 +1734,13 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) | |||
1716 | | USBA_DET_SUSPEND | 1734 | | USBA_DET_SUSPEND |
1717 | | USBA_END_OF_RESUME)); | 1735 | | USBA_END_OF_RESUME)); |
1718 | 1736 | ||
1737 | /* | ||
1738 | * Unclear why we hit this irregularly, e.g. in usbtest, | ||
1739 | * but it's clearly harmless... | ||
1740 | */ | ||
1719 | if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED)) | 1741 | if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED)) |
1720 | dev_warn(&udc->pdev->dev, | 1742 | dev_dbg(&udc->pdev->dev, |
1721 | "WARNING: EP0 configuration is invalid!\n"); | 1743 | "ODD: EP0 configuration is invalid!\n"); |
1722 | } | 1744 | } |
1723 | 1745 | ||
1724 | spin_unlock(&udc->lock); | 1746 | spin_unlock(&udc->lock); |
@@ -1751,9 +1773,11 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) | |||
1751 | reset_all_endpoints(udc); | 1773 | reset_all_endpoints(udc); |
1752 | toggle_bias(0); | 1774 | toggle_bias(0); |
1753 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); | 1775 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); |
1754 | spin_unlock(&udc->lock); | 1776 | if (udc->driver->disconnect) { |
1755 | udc->driver->disconnect(&udc->gadget); | 1777 | spin_unlock(&udc->lock); |
1756 | spin_lock(&udc->lock); | 1778 | udc->driver->disconnect(&udc->gadget); |
1779 | spin_lock(&udc->lock); | ||
1780 | } | ||
1757 | } | 1781 | } |
1758 | udc->vbus_prev = vbus; | 1782 | udc->vbus_prev = vbus; |
1759 | } | 1783 | } |
@@ -1825,7 +1849,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1825 | 1849 | ||
1826 | if (!udc->pdev) | 1850 | if (!udc->pdev) |
1827 | return -ENODEV; | 1851 | return -ENODEV; |
1828 | if (driver != udc->driver) | 1852 | if (driver != udc->driver || !driver->unbind) |
1829 | return -EINVAL; | 1853 | return -EINVAL; |
1830 | 1854 | ||
1831 | if (udc->vbus_pin != -1) | 1855 | if (udc->vbus_pin != -1) |
@@ -1840,6 +1864,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1840 | toggle_bias(0); | 1864 | toggle_bias(0); |
1841 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); | 1865 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); |
1842 | 1866 | ||
1867 | if (udc->driver->disconnect) | ||
1868 | udc->driver->disconnect(&udc->gadget); | ||
1869 | |||
1843 | driver->unbind(&udc->gadget); | 1870 | driver->unbind(&udc->gadget); |
1844 | udc->gadget.dev.driver = NULL; | 1871 | udc->gadget.dev.driver = NULL; |
1845 | udc->driver = NULL; | 1872 | udc->driver = NULL; |
@@ -1879,6 +1906,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1879 | goto err_get_hclk; | 1906 | goto err_get_hclk; |
1880 | } | 1907 | } |
1881 | 1908 | ||
1909 | spin_lock_init(&udc->lock); | ||
1882 | udc->pdev = pdev; | 1910 | udc->pdev = pdev; |
1883 | udc->pclk = pclk; | 1911 | udc->pclk = pclk; |
1884 | udc->hclk = hclk; | 1912 | udc->hclk = hclk; |
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 75eba202f737..499b7a23f351 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -1546,7 +1546,6 @@ static __init void udc_init_data(struct pxa_udc *dev) | |||
1546 | INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); | 1546 | INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); |
1547 | dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; | 1547 | dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; |
1548 | ep0_idle(dev); | 1548 | ep0_idle(dev); |
1549 | strcpy(dev->dev->bus_id, ""); | ||
1550 | 1549 | ||
1551 | /* PXA endpoints init */ | 1550 | /* PXA endpoints init */ |
1552 | for (i = 0; i < NR_PXA_ENDPOINTS; i++) { | 1551 | for (i = 0; i < NR_PXA_ENDPOINTS; i++) { |
@@ -1746,13 +1745,10 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc, | |||
1746 | ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i); | 1745 | ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i); |
1747 | } | 1746 | } |
1748 | 1747 | ||
1749 | le16_to_cpus(&u.r.wValue); | ||
1750 | le16_to_cpus(&u.r.wIndex); | ||
1751 | le16_to_cpus(&u.r.wLength); | ||
1752 | |||
1753 | ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n", | 1748 | ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n", |
1754 | u.r.bRequestType, u.r.bRequest, | 1749 | u.r.bRequestType, u.r.bRequest, |
1755 | u.r.wValue, u.r.wIndex, u.r.wLength); | 1750 | le16_to_cpu(u.r.wValue), le16_to_cpu(u.r.wIndex), |
1751 | le16_to_cpu(u.r.wLength)); | ||
1756 | if (unlikely(have_extrabytes)) | 1752 | if (unlikely(have_extrabytes)) |
1757 | goto stall; | 1753 | goto stall; |
1758 | 1754 | ||
@@ -2296,7 +2292,8 @@ static void pxa_udc_shutdown(struct platform_device *_dev) | |||
2296 | { | 2292 | { |
2297 | struct pxa_udc *udc = platform_get_drvdata(_dev); | 2293 | struct pxa_udc *udc = platform_get_drvdata(_dev); |
2298 | 2294 | ||
2299 | udc_disable(udc); | 2295 | if (udc_readl(udc, UDCCR) & UDCCR_UDE) |
2296 | udc_disable(udc); | ||
2300 | } | 2297 | } |
2301 | 2298 | ||
2302 | #ifdef CONFIG_PM | 2299 | #ifdef CONFIG_PM |
@@ -2361,9 +2358,8 @@ static int pxa_udc_resume(struct platform_device *_dev) | |||
2361 | * Upon exit from sleep mode and before clearing OTGPH, | 2358 | * Upon exit from sleep mode and before clearing OTGPH, |
2362 | * Software must configure the USB OTG pad, UDC, and UHC | 2359 | * Software must configure the USB OTG pad, UDC, and UHC |
2363 | * to the state they were in before entering sleep mode. | 2360 | * to the state they were in before entering sleep mode. |
2364 | * | ||
2365 | * Should be : PSSR |= PSSR_OTGPH; | ||
2366 | */ | 2361 | */ |
2362 | PSSR |= PSSR_OTGPH; | ||
2367 | 2363 | ||
2368 | return 0; | 2364 | return 0; |
2369 | } | 2365 | } |
@@ -2387,6 +2383,9 @@ static struct platform_driver udc_driver = { | |||
2387 | 2383 | ||
2388 | static int __init udc_init(void) | 2384 | static int __init udc_init(void) |
2389 | { | 2385 | { |
2386 | if (!cpu_is_pxa27x()) | ||
2387 | return -ENODEV; | ||
2388 | |||
2390 | printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); | 2389 | printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); |
2391 | return platform_driver_probe(&udc_driver, pxa_udc_probe); | 2390 | return platform_driver_probe(&udc_driver, pxa_udc_probe); |
2392 | } | 2391 | } |
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h index 1d1b7936ee11..97453db924ff 100644 --- a/drivers/usb/gadget/pxa27x_udc.h +++ b/drivers/usb/gadget/pxa27x_udc.h | |||
@@ -484,4 +484,12 @@ static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget) | |||
484 | #define ep_warn(ep, fmt, arg...) \ | 484 | #define ep_warn(ep, fmt, arg...) \ |
485 | dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg) | 485 | dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg) |
486 | 486 | ||
487 | /* | ||
488 | * Cannot include pxa-regs.h, as register names are similar. | ||
489 | * So PSSR is redefined here. This should be removed once UDC registers will | ||
490 | * be gone from pxa-regs.h. | ||
491 | */ | ||
492 | #define PSSR __REG(0x40F00004) /* Power Manager Sleep Status */ | ||
493 | #define PSSR_OTGPH (1 << 6) /* OTG Peripheral Hold */ | ||
494 | |||
487 | #endif /* __LINUX_USB_GADGET_PXA27X_H */ | 495 | #endif /* __LINUX_USB_GADGET_PXA27X_H */ |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 54cdd6f94034..fa019fa73334 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * This software is distributed under the terms of the GNU General | 14 | * This software is distributed under the terms of the GNU General |
15 | * Public License ("GPL") as published by the Free Software Foundation, | 15 | * Public License ("GPL") as published by the Free Software Foundation, |
16 | * either version 2 of that License or (at your option) any later version. | 16 | * either version 2 of that License or (at your option) any later version. |
17 | * | ||
18 | */ | 17 | */ |
19 | 18 | ||
20 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -33,7 +32,7 @@ | |||
33 | /* Defines */ | 32 | /* Defines */ |
34 | 33 | ||
35 | #define GS_VERSION_STR "v2.2" | 34 | #define GS_VERSION_STR "v2.2" |
36 | #define GS_VERSION_NUM 0x0202 | 35 | #define GS_VERSION_NUM 0x2200 |
37 | 36 | ||
38 | #define GS_LONG_NAME "Gadget Serial" | 37 | #define GS_LONG_NAME "Gadget Serial" |
39 | #define GS_SHORT_NAME "g_serial" | 38 | #define GS_SHORT_NAME "g_serial" |
@@ -41,7 +40,11 @@ | |||
41 | #define GS_MAJOR 127 | 40 | #define GS_MAJOR 127 |
42 | #define GS_MINOR_START 0 | 41 | #define GS_MINOR_START 0 |
43 | 42 | ||
44 | #define GS_NUM_PORTS 16 | 43 | /* REVISIT only one port is supported for now; |
44 | * see gs_{send,recv}_packet() ... no multiplexing, | ||
45 | * and no support for multiple ACM devices. | ||
46 | */ | ||
47 | #define GS_NUM_PORTS 1 | ||
45 | 48 | ||
46 | #define GS_NUM_CONFIGS 1 | 49 | #define GS_NUM_CONFIGS 1 |
47 | #define GS_NO_CONFIG_ID 0 | 50 | #define GS_NO_CONFIG_ID 0 |
@@ -65,6 +68,9 @@ | |||
65 | 68 | ||
66 | #define GS_DEFAULT_USE_ACM 0 | 69 | #define GS_DEFAULT_USE_ACM 0 |
67 | 70 | ||
71 | /* 9600-8-N-1 ... matches init_termios.c_cflag and defaults | ||
72 | * expected by "usbser.sys" on MS-Windows. | ||
73 | */ | ||
68 | #define GS_DEFAULT_DTE_RATE 9600 | 74 | #define GS_DEFAULT_DTE_RATE 9600 |
69 | #define GS_DEFAULT_DATA_BITS 8 | 75 | #define GS_DEFAULT_DATA_BITS 8 |
70 | #define GS_DEFAULT_PARITY USB_CDC_NO_PARITY | 76 | #define GS_DEFAULT_PARITY USB_CDC_NO_PARITY |
@@ -107,10 +113,6 @@ static int debug = 1; | |||
107 | #define GS_NOTIFY_MAXPACKET 8 | 113 | #define GS_NOTIFY_MAXPACKET 8 |
108 | 114 | ||
109 | 115 | ||
110 | /* Structures */ | ||
111 | |||
112 | struct gs_dev; | ||
113 | |||
114 | /* circular buffer */ | 116 | /* circular buffer */ |
115 | struct gs_buf { | 117 | struct gs_buf { |
116 | unsigned int buf_size; | 118 | unsigned int buf_size; |
@@ -119,12 +121,6 @@ struct gs_buf { | |||
119 | char *buf_put; | 121 | char *buf_put; |
120 | }; | 122 | }; |
121 | 123 | ||
122 | /* list of requests */ | ||
123 | struct gs_req_entry { | ||
124 | struct list_head re_entry; | ||
125 | struct usb_request *re_req; | ||
126 | }; | ||
127 | |||
128 | /* the port structure holds info for each port, one for each minor number */ | 124 | /* the port structure holds info for each port, one for each minor number */ |
129 | struct gs_port { | 125 | struct gs_port { |
130 | struct gs_dev *port_dev; /* pointer to device struct */ | 126 | struct gs_dev *port_dev; /* pointer to device struct */ |
@@ -164,26 +160,7 @@ struct gs_dev { | |||
164 | 160 | ||
165 | /* Functions */ | 161 | /* Functions */ |
166 | 162 | ||
167 | /* module */ | 163 | /* tty driver internals */ |
168 | static int __init gs_module_init(void); | ||
169 | static void __exit gs_module_exit(void); | ||
170 | |||
171 | /* tty driver */ | ||
172 | static int gs_open(struct tty_struct *tty, struct file *file); | ||
173 | static void gs_close(struct tty_struct *tty, struct file *file); | ||
174 | static int gs_write(struct tty_struct *tty, | ||
175 | const unsigned char *buf, int count); | ||
176 | static int gs_put_char(struct tty_struct *tty, unsigned char ch); | ||
177 | static void gs_flush_chars(struct tty_struct *tty); | ||
178 | static int gs_write_room(struct tty_struct *tty); | ||
179 | static int gs_chars_in_buffer(struct tty_struct *tty); | ||
180 | static void gs_throttle(struct tty_struct * tty); | ||
181 | static void gs_unthrottle(struct tty_struct * tty); | ||
182 | static void gs_break(struct tty_struct *tty, int break_state); | ||
183 | static int gs_ioctl(struct tty_struct *tty, struct file *file, | ||
184 | unsigned int cmd, unsigned long arg); | ||
185 | static void gs_set_termios(struct tty_struct *tty, struct ktermios *old); | ||
186 | |||
187 | static int gs_send(struct gs_dev *dev); | 164 | static int gs_send(struct gs_dev *dev); |
188 | static int gs_send_packet(struct gs_dev *dev, char *packet, | 165 | static int gs_send_packet(struct gs_dev *dev, char *packet, |
189 | unsigned int size); | 166 | unsigned int size); |
@@ -192,19 +169,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet, | |||
192 | static void gs_read_complete(struct usb_ep *ep, struct usb_request *req); | 169 | static void gs_read_complete(struct usb_ep *ep, struct usb_request *req); |
193 | static void gs_write_complete(struct usb_ep *ep, struct usb_request *req); | 170 | static void gs_write_complete(struct usb_ep *ep, struct usb_request *req); |
194 | 171 | ||
195 | /* gadget driver */ | 172 | /* gadget driver internals */ |
196 | static int gs_bind(struct usb_gadget *gadget); | ||
197 | static void gs_unbind(struct usb_gadget *gadget); | ||
198 | static int gs_setup(struct usb_gadget *gadget, | ||
199 | const struct usb_ctrlrequest *ctrl); | ||
200 | static int gs_setup_standard(struct usb_gadget *gadget, | ||
201 | const struct usb_ctrlrequest *ctrl); | ||
202 | static int gs_setup_class(struct usb_gadget *gadget, | ||
203 | const struct usb_ctrlrequest *ctrl); | ||
204 | static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req); | ||
205 | static void gs_setup_complete_set_line_coding(struct usb_ep *ep, | ||
206 | struct usb_request *req); | ||
207 | static void gs_disconnect(struct usb_gadget *gadget); | ||
208 | static int gs_set_config(struct gs_dev *dev, unsigned config); | 173 | static int gs_set_config(struct gs_dev *dev, unsigned config); |
209 | static void gs_reset_config(struct gs_dev *dev); | 174 | static void gs_reset_config(struct gs_dev *dev); |
210 | static int gs_build_config_buf(u8 *buf, struct usb_gadget *g, | 175 | static int gs_build_config_buf(u8 *buf, struct usb_gadget *g, |
@@ -214,10 +179,6 @@ static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, | |||
214 | gfp_t kmalloc_flags); | 179 | gfp_t kmalloc_flags); |
215 | static void gs_free_req(struct usb_ep *ep, struct usb_request *req); | 180 | static void gs_free_req(struct usb_ep *ep, struct usb_request *req); |
216 | 181 | ||
217 | static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len, | ||
218 | gfp_t kmalloc_flags); | ||
219 | static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req); | ||
220 | |||
221 | static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); | 182 | static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); |
222 | static void gs_free_ports(struct gs_dev *dev); | 183 | static void gs_free_ports(struct gs_dev *dev); |
223 | 184 | ||
@@ -232,62 +193,15 @@ static unsigned int gs_buf_put(struct gs_buf *gb, const char *buf, | |||
232 | static unsigned int gs_buf_get(struct gs_buf *gb, char *buf, | 193 | static unsigned int gs_buf_get(struct gs_buf *gb, char *buf, |
233 | unsigned int count); | 194 | unsigned int count); |
234 | 195 | ||
235 | /* external functions */ | ||
236 | extern int net2280_set_fifo_mode(struct usb_gadget *gadget, int mode); | ||
237 | |||
238 | 196 | ||
239 | /* Globals */ | 197 | /* Globals */ |
240 | 198 | ||
241 | static struct gs_dev *gs_device; | 199 | static struct gs_dev *gs_device; |
242 | 200 | ||
243 | static const char *EP_IN_NAME; | ||
244 | static const char *EP_OUT_NAME; | ||
245 | static const char *EP_NOTIFY_NAME; | ||
246 | |||
247 | static struct mutex gs_open_close_lock[GS_NUM_PORTS]; | 201 | static struct mutex gs_open_close_lock[GS_NUM_PORTS]; |
248 | 202 | ||
249 | static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE; | ||
250 | static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE; | ||
251 | |||
252 | static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE; | ||
253 | |||
254 | static unsigned int use_acm = GS_DEFAULT_USE_ACM; | ||
255 | |||
256 | |||
257 | /* tty driver struct */ | ||
258 | static const struct tty_operations gs_tty_ops = { | ||
259 | .open = gs_open, | ||
260 | .close = gs_close, | ||
261 | .write = gs_write, | ||
262 | .put_char = gs_put_char, | ||
263 | .flush_chars = gs_flush_chars, | ||
264 | .write_room = gs_write_room, | ||
265 | .ioctl = gs_ioctl, | ||
266 | .set_termios = gs_set_termios, | ||
267 | .throttle = gs_throttle, | ||
268 | .unthrottle = gs_unthrottle, | ||
269 | .break_ctl = gs_break, | ||
270 | .chars_in_buffer = gs_chars_in_buffer, | ||
271 | }; | ||
272 | static struct tty_driver *gs_tty_driver; | ||
273 | |||
274 | /* gadget driver struct */ | ||
275 | static struct usb_gadget_driver gs_gadget_driver = { | ||
276 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
277 | .speed = USB_SPEED_HIGH, | ||
278 | #else | ||
279 | .speed = USB_SPEED_FULL, | ||
280 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ | ||
281 | .function = GS_LONG_NAME, | ||
282 | .bind = gs_bind, | ||
283 | .unbind = gs_unbind, | ||
284 | .setup = gs_setup, | ||
285 | .disconnect = gs_disconnect, | ||
286 | .driver = { | ||
287 | .name = GS_SHORT_NAME, | ||
288 | }, | ||
289 | }; | ||
290 | 203 | ||
204 | /*-------------------------------------------------------------------------*/ | ||
291 | 205 | ||
292 | /* USB descriptors */ | 206 | /* USB descriptors */ |
293 | 207 | ||
@@ -304,7 +218,6 @@ static char manufacturer[50]; | |||
304 | static struct usb_string gs_strings[] = { | 218 | static struct usb_string gs_strings[] = { |
305 | { GS_MANUFACTURER_STR_ID, manufacturer }, | 219 | { GS_MANUFACTURER_STR_ID, manufacturer }, |
306 | { GS_PRODUCT_STR_ID, GS_LONG_NAME }, | 220 | { GS_PRODUCT_STR_ID, GS_LONG_NAME }, |
307 | { GS_SERIAL_STR_ID, "0" }, | ||
308 | { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" }, | 221 | { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" }, |
309 | { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" }, | 222 | { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" }, |
310 | { GS_CONTROL_STR_ID, "Gadget Serial Control" }, | 223 | { GS_CONTROL_STR_ID, "Gadget Serial Control" }, |
@@ -327,7 +240,6 @@ static struct usb_device_descriptor gs_device_desc = { | |||
327 | .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID), | 240 | .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID), |
328 | .iManufacturer = GS_MANUFACTURER_STR_ID, | 241 | .iManufacturer = GS_MANUFACTURER_STR_ID, |
329 | .iProduct = GS_PRODUCT_STR_ID, | 242 | .iProduct = GS_PRODUCT_STR_ID, |
330 | .iSerialNumber = GS_SERIAL_STR_ID, | ||
331 | .bNumConfigurations = GS_NUM_CONFIGS, | 243 | .bNumConfigurations = GS_NUM_CONFIGS, |
332 | }; | 244 | }; |
333 | 245 | ||
@@ -364,7 +276,7 @@ static const struct usb_interface_descriptor gs_bulk_interface_desc = { | |||
364 | .bDescriptorType = USB_DT_INTERFACE, | 276 | .bDescriptorType = USB_DT_INTERFACE, |
365 | .bInterfaceNumber = GS_BULK_INTERFACE_ID, | 277 | .bInterfaceNumber = GS_BULK_INTERFACE_ID, |
366 | .bNumEndpoints = 2, | 278 | .bNumEndpoints = 2, |
367 | .bInterfaceClass = USB_CLASS_CDC_DATA, | 279 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, |
368 | .bInterfaceSubClass = 0, | 280 | .bInterfaceSubClass = 0, |
369 | .bInterfaceProtocol = 0, | 281 | .bInterfaceProtocol = 0, |
370 | .iInterface = GS_DATA_STR_ID, | 282 | .iInterface = GS_DATA_STR_ID, |
@@ -521,6 +433,8 @@ static const struct usb_descriptor_header *gs_acm_highspeed_function[] = { | |||
521 | }; | 433 | }; |
522 | 434 | ||
523 | 435 | ||
436 | /*-------------------------------------------------------------------------*/ | ||
437 | |||
524 | /* Module */ | 438 | /* Module */ |
525 | MODULE_DESCRIPTION(GS_LONG_NAME); | 439 | MODULE_DESCRIPTION(GS_LONG_NAME); |
526 | MODULE_AUTHOR("Al Borchers"); | 440 | MODULE_AUTHOR("Al Borchers"); |
@@ -531,84 +445,23 @@ module_param(debug, int, S_IRUGO|S_IWUSR); | |||
531 | MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on"); | 445 | MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on"); |
532 | #endif | 446 | #endif |
533 | 447 | ||
448 | static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE; | ||
534 | module_param(read_q_size, uint, S_IRUGO); | 449 | module_param(read_q_size, uint, S_IRUGO); |
535 | MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32"); | 450 | MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32"); |
536 | 451 | ||
452 | static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE; | ||
537 | module_param(write_q_size, uint, S_IRUGO); | 453 | module_param(write_q_size, uint, S_IRUGO); |
538 | MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32"); | 454 | MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32"); |
539 | 455 | ||
456 | static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE; | ||
540 | module_param(write_buf_size, uint, S_IRUGO); | 457 | module_param(write_buf_size, uint, S_IRUGO); |
541 | MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192"); | 458 | MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192"); |
542 | 459 | ||
460 | static unsigned int use_acm = GS_DEFAULT_USE_ACM; | ||
543 | module_param(use_acm, uint, S_IRUGO); | 461 | module_param(use_acm, uint, S_IRUGO); |
544 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no"); | 462 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no"); |
545 | 463 | ||
546 | module_init(gs_module_init); | 464 | /*-------------------------------------------------------------------------*/ |
547 | module_exit(gs_module_exit); | ||
548 | |||
549 | /* | ||
550 | * gs_module_init | ||
551 | * | ||
552 | * Register as a USB gadget driver and a tty driver. | ||
553 | */ | ||
554 | static int __init gs_module_init(void) | ||
555 | { | ||
556 | int i; | ||
557 | int retval; | ||
558 | |||
559 | retval = usb_gadget_register_driver(&gs_gadget_driver); | ||
560 | if (retval) { | ||
561 | pr_err("gs_module_init: cannot register gadget driver, " | ||
562 | "ret=%d\n", retval); | ||
563 | return retval; | ||
564 | } | ||
565 | |||
566 | gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS); | ||
567 | if (!gs_tty_driver) | ||
568 | return -ENOMEM; | ||
569 | gs_tty_driver->owner = THIS_MODULE; | ||
570 | gs_tty_driver->driver_name = GS_SHORT_NAME; | ||
571 | gs_tty_driver->name = "ttygs"; | ||
572 | gs_tty_driver->major = GS_MAJOR; | ||
573 | gs_tty_driver->minor_start = GS_MINOR_START; | ||
574 | gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; | ||
575 | gs_tty_driver->subtype = SERIAL_TYPE_NORMAL; | ||
576 | gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | ||
577 | gs_tty_driver->init_termios = tty_std_termios; | ||
578 | gs_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | ||
579 | tty_set_operations(gs_tty_driver, &gs_tty_ops); | ||
580 | |||
581 | for (i=0; i < GS_NUM_PORTS; i++) | ||
582 | mutex_init(&gs_open_close_lock[i]); | ||
583 | |||
584 | retval = tty_register_driver(gs_tty_driver); | ||
585 | if (retval) { | ||
586 | usb_gadget_unregister_driver(&gs_gadget_driver); | ||
587 | put_tty_driver(gs_tty_driver); | ||
588 | pr_err("gs_module_init: cannot register tty driver, " | ||
589 | "ret=%d\n", retval); | ||
590 | return retval; | ||
591 | } | ||
592 | |||
593 | pr_info("gs_module_init: %s %s loaded\n", | ||
594 | GS_LONG_NAME, GS_VERSION_STR); | ||
595 | return 0; | ||
596 | } | ||
597 | |||
598 | /* | ||
599 | * gs_module_exit | ||
600 | * | ||
601 | * Unregister as a tty driver and a USB gadget driver. | ||
602 | */ | ||
603 | static void __exit gs_module_exit(void) | ||
604 | { | ||
605 | tty_unregister_driver(gs_tty_driver); | ||
606 | put_tty_driver(gs_tty_driver); | ||
607 | usb_gadget_unregister_driver(&gs_gadget_driver); | ||
608 | |||
609 | pr_info("gs_module_exit: %s %s unloaded\n", | ||
610 | GS_LONG_NAME, GS_VERSION_STR); | ||
611 | } | ||
612 | 465 | ||
613 | /* TTY Driver */ | 466 | /* TTY Driver */ |
614 | 467 | ||
@@ -753,15 +606,15 @@ exit_unlock_dev: | |||
753 | * gs_close | 606 | * gs_close |
754 | */ | 607 | */ |
755 | 608 | ||
756 | #define GS_WRITE_FINISHED_EVENT_SAFELY(p) \ | 609 | static int gs_write_finished_event_safely(struct gs_port *p) |
757 | ({ \ | 610 | { |
758 | int cond; \ | 611 | int cond; |
759 | \ | 612 | |
760 | spin_lock_irq(&(p)->port_lock); \ | 613 | spin_lock_irq(&(p)->port_lock); |
761 | cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); \ | 614 | cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); |
762 | spin_unlock_irq(&(p)->port_lock); \ | 615 | spin_unlock_irq(&(p)->port_lock); |
763 | cond; \ | 616 | return cond; |
764 | }) | 617 | } |
765 | 618 | ||
766 | static void gs_close(struct tty_struct *tty, struct file *file) | 619 | static void gs_close(struct tty_struct *tty, struct file *file) |
767 | { | 620 | { |
@@ -807,7 +660,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) | |||
807 | if (gs_buf_data_avail(port->port_write_buf) > 0) { | 660 | if (gs_buf_data_avail(port->port_write_buf) > 0) { |
808 | spin_unlock_irq(&port->port_lock); | 661 | spin_unlock_irq(&port->port_lock); |
809 | wait_event_interruptible_timeout(port->port_write_wait, | 662 | wait_event_interruptible_timeout(port->port_write_wait, |
810 | GS_WRITE_FINISHED_EVENT_SAFELY(port), | 663 | gs_write_finished_event_safely(port), |
811 | GS_CLOSE_TIMEOUT * HZ); | 664 | GS_CLOSE_TIMEOUT * HZ); |
812 | spin_lock_irq(&port->port_lock); | 665 | spin_lock_irq(&port->port_lock); |
813 | } | 666 | } |
@@ -1065,6 +918,23 @@ static void gs_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
1065 | { | 918 | { |
1066 | } | 919 | } |
1067 | 920 | ||
921 | static const struct tty_operations gs_tty_ops = { | ||
922 | .open = gs_open, | ||
923 | .close = gs_close, | ||
924 | .write = gs_write, | ||
925 | .put_char = gs_put_char, | ||
926 | .flush_chars = gs_flush_chars, | ||
927 | .write_room = gs_write_room, | ||
928 | .ioctl = gs_ioctl, | ||
929 | .set_termios = gs_set_termios, | ||
930 | .throttle = gs_throttle, | ||
931 | .unthrottle = gs_unthrottle, | ||
932 | .break_ctl = gs_break, | ||
933 | .chars_in_buffer = gs_chars_in_buffer, | ||
934 | }; | ||
935 | |||
936 | /*-------------------------------------------------------------------------*/ | ||
937 | |||
1068 | /* | 938 | /* |
1069 | * gs_send | 939 | * gs_send |
1070 | * | 940 | * |
@@ -1080,7 +950,6 @@ static int gs_send(struct gs_dev *dev) | |||
1080 | unsigned long flags; | 950 | unsigned long flags; |
1081 | struct usb_ep *ep; | 951 | struct usb_ep *ep; |
1082 | struct usb_request *req; | 952 | struct usb_request *req; |
1083 | struct gs_req_entry *req_entry; | ||
1084 | 953 | ||
1085 | if (dev == NULL) { | 954 | if (dev == NULL) { |
1086 | pr_err("gs_send: NULL device pointer\n"); | 955 | pr_err("gs_send: NULL device pointer\n"); |
@@ -1093,10 +962,8 @@ static int gs_send(struct gs_dev *dev) | |||
1093 | 962 | ||
1094 | while(!list_empty(&dev->dev_req_list)) { | 963 | while(!list_empty(&dev->dev_req_list)) { |
1095 | 964 | ||
1096 | req_entry = list_entry(dev->dev_req_list.next, | 965 | req = list_entry(dev->dev_req_list.next, |
1097 | struct gs_req_entry, re_entry); | 966 | struct usb_request, list); |
1098 | |||
1099 | req = req_entry->re_req; | ||
1100 | 967 | ||
1101 | len = gs_send_packet(dev, req->buf, ep->maxpacket); | 968 | len = gs_send_packet(dev, req->buf, ep->maxpacket); |
1102 | 969 | ||
@@ -1106,7 +973,7 @@ static int gs_send(struct gs_dev *dev) | |||
1106 | *((unsigned char *)req->buf), | 973 | *((unsigned char *)req->buf), |
1107 | *((unsigned char *)req->buf+1), | 974 | *((unsigned char *)req->buf+1), |
1108 | *((unsigned char *)req->buf+2)); | 975 | *((unsigned char *)req->buf+2)); |
1109 | list_del(&req_entry->re_entry); | 976 | list_del(&req->list); |
1110 | req->length = len; | 977 | req->length = len; |
1111 | spin_unlock_irqrestore(&dev->dev_lock, flags); | 978 | spin_unlock_irqrestore(&dev->dev_lock, flags); |
1112 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { | 979 | if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { |
@@ -1289,7 +1156,6 @@ requeue: | |||
1289 | static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) | 1156 | static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) |
1290 | { | 1157 | { |
1291 | struct gs_dev *dev = ep->driver_data; | 1158 | struct gs_dev *dev = ep->driver_data; |
1292 | struct gs_req_entry *gs_req = req->context; | ||
1293 | 1159 | ||
1294 | if (dev == NULL) { | 1160 | if (dev == NULL) { |
1295 | pr_err("gs_write_complete: NULL device pointer\n"); | 1161 | pr_err("gs_write_complete: NULL device pointer\n"); |
@@ -1300,13 +1166,8 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) | |||
1300 | case 0: | 1166 | case 0: |
1301 | /* normal completion */ | 1167 | /* normal completion */ |
1302 | requeue: | 1168 | requeue: |
1303 | if (gs_req == NULL) { | ||
1304 | pr_err("gs_write_complete: NULL request pointer\n"); | ||
1305 | return; | ||
1306 | } | ||
1307 | |||
1308 | spin_lock(&dev->dev_lock); | 1169 | spin_lock(&dev->dev_lock); |
1309 | list_add(&gs_req->re_entry, &dev->dev_req_list); | 1170 | list_add(&req->list, &dev->dev_req_list); |
1310 | spin_unlock(&dev->dev_lock); | 1171 | spin_unlock(&dev->dev_lock); |
1311 | 1172 | ||
1312 | gs_send(dev); | 1173 | gs_send(dev); |
@@ -1328,9 +1189,39 @@ requeue: | |||
1328 | } | 1189 | } |
1329 | } | 1190 | } |
1330 | 1191 | ||
1192 | /*-------------------------------------------------------------------------*/ | ||
1193 | |||
1331 | /* Gadget Driver */ | 1194 | /* Gadget Driver */ |
1332 | 1195 | ||
1333 | /* | 1196 | /* |
1197 | * gs_unbind | ||
1198 | * | ||
1199 | * Called on module unload. Frees the control request and device | ||
1200 | * structure. | ||
1201 | */ | ||
1202 | static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget) | ||
1203 | { | ||
1204 | struct gs_dev *dev = get_gadget_data(gadget); | ||
1205 | |||
1206 | gs_device = NULL; | ||
1207 | |||
1208 | /* read/write requests already freed, only control request remains */ | ||
1209 | if (dev != NULL) { | ||
1210 | if (dev->dev_ctrl_req != NULL) { | ||
1211 | gs_free_req(gadget->ep0, dev->dev_ctrl_req); | ||
1212 | dev->dev_ctrl_req = NULL; | ||
1213 | } | ||
1214 | gs_reset_config(dev); | ||
1215 | gs_free_ports(dev); | ||
1216 | kfree(dev); | ||
1217 | set_gadget_data(gadget, NULL); | ||
1218 | } | ||
1219 | |||
1220 | pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME, | ||
1221 | GS_VERSION_STR); | ||
1222 | } | ||
1223 | |||
1224 | /* | ||
1334 | * gs_bind | 1225 | * gs_bind |
1335 | * | 1226 | * |
1336 | * Called on module load. Allocates and initializes the device | 1227 | * Called on module load. Allocates and initializes the device |
@@ -1362,19 +1253,23 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1362 | __constant_cpu_to_le16(GS_VERSION_NUM|0x0099); | 1253 | __constant_cpu_to_le16(GS_VERSION_NUM|0x0099); |
1363 | } | 1254 | } |
1364 | 1255 | ||
1256 | dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL); | ||
1257 | if (dev == NULL) | ||
1258 | return -ENOMEM; | ||
1259 | |||
1365 | usb_ep_autoconfig_reset(gadget); | 1260 | usb_ep_autoconfig_reset(gadget); |
1366 | 1261 | ||
1367 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc); | 1262 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc); |
1368 | if (!ep) | 1263 | if (!ep) |
1369 | goto autoconf_fail; | 1264 | goto autoconf_fail; |
1370 | EP_IN_NAME = ep->name; | 1265 | dev->dev_in_ep = ep; |
1371 | ep->driver_data = ep; /* claim the endpoint */ | 1266 | ep->driver_data = dev; /* claim the endpoint */ |
1372 | 1267 | ||
1373 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc); | 1268 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc); |
1374 | if (!ep) | 1269 | if (!ep) |
1375 | goto autoconf_fail; | 1270 | goto autoconf_fail; |
1376 | EP_OUT_NAME = ep->name; | 1271 | dev->dev_out_ep = ep; |
1377 | ep->driver_data = ep; /* claim the endpoint */ | 1272 | ep->driver_data = dev; /* claim the endpoint */ |
1378 | 1273 | ||
1379 | if (use_acm) { | 1274 | if (use_acm) { |
1380 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); | 1275 | ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); |
@@ -1384,8 +1279,8 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1384 | } | 1279 | } |
1385 | gs_device_desc.idProduct = __constant_cpu_to_le16( | 1280 | gs_device_desc.idProduct = __constant_cpu_to_le16( |
1386 | GS_CDC_PRODUCT_ID), | 1281 | GS_CDC_PRODUCT_ID), |
1387 | EP_NOTIFY_NAME = ep->name; | 1282 | dev->dev_notify_ep = ep; |
1388 | ep->driver_data = ep; /* claim the endpoint */ | 1283 | ep->driver_data = dev; /* claim the endpoint */ |
1389 | } | 1284 | } |
1390 | 1285 | ||
1391 | gs_device_desc.bDeviceClass = use_acm | 1286 | gs_device_desc.bDeviceClass = use_acm |
@@ -1415,9 +1310,7 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1415 | gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 1310 | gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
1416 | } | 1311 | } |
1417 | 1312 | ||
1418 | gs_device = dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL); | 1313 | gs_device = dev; |
1419 | if (dev == NULL) | ||
1420 | return -ENOMEM; | ||
1421 | 1314 | ||
1422 | snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", | 1315 | snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", |
1423 | init_utsname()->sysname, init_utsname()->release, | 1316 | init_utsname()->sysname, init_utsname()->release, |
@@ -1441,8 +1334,6 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1441 | gs_unbind(gadget); | 1334 | gs_unbind(gadget); |
1442 | return -ENOMEM; | 1335 | return -ENOMEM; |
1443 | } | 1336 | } |
1444 | dev->dev_ctrl_req->complete = gs_setup_complete; | ||
1445 | |||
1446 | gadget->ep0->driver_data = dev; | 1337 | gadget->ep0->driver_data = dev; |
1447 | 1338 | ||
1448 | pr_info("gs_bind: %s %s bound\n", | 1339 | pr_info("gs_bind: %s %s bound\n", |
@@ -1451,99 +1342,11 @@ static int __init gs_bind(struct usb_gadget *gadget) | |||
1451 | return 0; | 1342 | return 0; |
1452 | 1343 | ||
1453 | autoconf_fail: | 1344 | autoconf_fail: |
1345 | kfree(dev); | ||
1454 | pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); | 1346 | pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); |
1455 | return -ENODEV; | 1347 | return -ENODEV; |
1456 | } | 1348 | } |
1457 | 1349 | ||
1458 | /* | ||
1459 | * gs_unbind | ||
1460 | * | ||
1461 | * Called on module unload. Frees the control request and device | ||
1462 | * structure. | ||
1463 | */ | ||
1464 | static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget) | ||
1465 | { | ||
1466 | struct gs_dev *dev = get_gadget_data(gadget); | ||
1467 | |||
1468 | gs_device = NULL; | ||
1469 | |||
1470 | /* read/write requests already freed, only control request remains */ | ||
1471 | if (dev != NULL) { | ||
1472 | if (dev->dev_ctrl_req != NULL) { | ||
1473 | gs_free_req(gadget->ep0, dev->dev_ctrl_req); | ||
1474 | dev->dev_ctrl_req = NULL; | ||
1475 | } | ||
1476 | gs_free_ports(dev); | ||
1477 | if (dev->dev_notify_ep) | ||
1478 | usb_ep_disable(dev->dev_notify_ep); | ||
1479 | if (dev->dev_in_ep) | ||
1480 | usb_ep_disable(dev->dev_in_ep); | ||
1481 | if (dev->dev_out_ep) | ||
1482 | usb_ep_disable(dev->dev_out_ep); | ||
1483 | kfree(dev); | ||
1484 | set_gadget_data(gadget, NULL); | ||
1485 | } | ||
1486 | |||
1487 | pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME, | ||
1488 | GS_VERSION_STR); | ||
1489 | } | ||
1490 | |||
1491 | /* | ||
1492 | * gs_setup | ||
1493 | * | ||
1494 | * Implements all the control endpoint functionality that's not | ||
1495 | * handled in hardware or the hardware driver. | ||
1496 | * | ||
1497 | * Returns the size of the data sent to the host, or a negative | ||
1498 | * error number. | ||
1499 | */ | ||
1500 | static int gs_setup(struct usb_gadget *gadget, | ||
1501 | const struct usb_ctrlrequest *ctrl) | ||
1502 | { | ||
1503 | int ret = -EOPNOTSUPP; | ||
1504 | struct gs_dev *dev = get_gadget_data(gadget); | ||
1505 | struct usb_request *req = dev->dev_ctrl_req; | ||
1506 | u16 wIndex = le16_to_cpu(ctrl->wIndex); | ||
1507 | u16 wValue = le16_to_cpu(ctrl->wValue); | ||
1508 | u16 wLength = le16_to_cpu(ctrl->wLength); | ||
1509 | |||
1510 | req->complete = gs_setup_complete; | ||
1511 | |||
1512 | switch (ctrl->bRequestType & USB_TYPE_MASK) { | ||
1513 | case USB_TYPE_STANDARD: | ||
1514 | ret = gs_setup_standard(gadget,ctrl); | ||
1515 | break; | ||
1516 | |||
1517 | case USB_TYPE_CLASS: | ||
1518 | ret = gs_setup_class(gadget,ctrl); | ||
1519 | break; | ||
1520 | |||
1521 | default: | ||
1522 | pr_err("gs_setup: unknown request, type=%02x, request=%02x, " | ||
1523 | "value=%04x, index=%04x, length=%d\n", | ||
1524 | ctrl->bRequestType, ctrl->bRequest, | ||
1525 | wValue, wIndex, wLength); | ||
1526 | break; | ||
1527 | } | ||
1528 | |||
1529 | /* respond with data transfer before status phase? */ | ||
1530 | if (ret >= 0) { | ||
1531 | req->length = ret; | ||
1532 | req->zero = ret < wLength | ||
1533 | && (ret % gadget->ep0->maxpacket) == 0; | ||
1534 | ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); | ||
1535 | if (ret < 0) { | ||
1536 | pr_err("gs_setup: cannot queue response, ret=%d\n", | ||
1537 | ret); | ||
1538 | req->status = 0; | ||
1539 | gs_setup_complete(gadget->ep0, req); | ||
1540 | } | ||
1541 | } | ||
1542 | |||
1543 | /* device either stalls (ret < 0) or reports success */ | ||
1544 | return ret; | ||
1545 | } | ||
1546 | |||
1547 | static int gs_setup_standard(struct usb_gadget *gadget, | 1350 | static int gs_setup_standard(struct usb_gadget *gadget, |
1548 | const struct usb_ctrlrequest *ctrl) | 1351 | const struct usb_ctrlrequest *ctrl) |
1549 | { | 1352 | { |
@@ -1673,6 +1476,42 @@ set_interface_done: | |||
1673 | return ret; | 1476 | return ret; |
1674 | } | 1477 | } |
1675 | 1478 | ||
1479 | static void gs_setup_complete_set_line_coding(struct usb_ep *ep, | ||
1480 | struct usb_request *req) | ||
1481 | { | ||
1482 | struct gs_dev *dev = ep->driver_data; | ||
1483 | struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ | ||
1484 | |||
1485 | switch (req->status) { | ||
1486 | case 0: | ||
1487 | /* normal completion */ | ||
1488 | if (req->actual != sizeof(port->port_line_coding)) | ||
1489 | usb_ep_set_halt(ep); | ||
1490 | else if (port) { | ||
1491 | struct usb_cdc_line_coding *value = req->buf; | ||
1492 | |||
1493 | /* REVISIT: we currently just remember this data. | ||
1494 | * If we change that, (a) validate it first, then | ||
1495 | * (b) update whatever hardware needs updating. | ||
1496 | */ | ||
1497 | spin_lock(&port->port_lock); | ||
1498 | port->port_line_coding = *value; | ||
1499 | spin_unlock(&port->port_lock); | ||
1500 | } | ||
1501 | break; | ||
1502 | |||
1503 | case -ESHUTDOWN: | ||
1504 | /* disconnect */ | ||
1505 | gs_free_req(ep, req); | ||
1506 | break; | ||
1507 | |||
1508 | default: | ||
1509 | /* unexpected */ | ||
1510 | break; | ||
1511 | } | ||
1512 | return; | ||
1513 | } | ||
1514 | |||
1676 | static int gs_setup_class(struct usb_gadget *gadget, | 1515 | static int gs_setup_class(struct usb_gadget *gadget, |
1677 | const struct usb_ctrlrequest *ctrl) | 1516 | const struct usb_ctrlrequest *ctrl) |
1678 | { | 1517 | { |
@@ -1734,52 +1573,72 @@ static int gs_setup_class(struct usb_gadget *gadget, | |||
1734 | return ret; | 1573 | return ret; |
1735 | } | 1574 | } |
1736 | 1575 | ||
1737 | static void gs_setup_complete_set_line_coding(struct usb_ep *ep, | 1576 | /* |
1738 | struct usb_request *req) | 1577 | * gs_setup_complete |
1578 | */ | ||
1579 | static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) | ||
1739 | { | 1580 | { |
1740 | struct gs_dev *dev = ep->driver_data; | 1581 | if (req->status || req->actual != req->length) { |
1741 | struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ | 1582 | pr_err("gs_setup_complete: status error, status=%d, " |
1583 | "actual=%d, length=%d\n", | ||
1584 | req->status, req->actual, req->length); | ||
1585 | } | ||
1586 | } | ||
1742 | 1587 | ||
1743 | switch (req->status) { | 1588 | /* |
1744 | case 0: | 1589 | * gs_setup |
1745 | /* normal completion */ | 1590 | * |
1746 | if (req->actual != sizeof(port->port_line_coding)) | 1591 | * Implements all the control endpoint functionality that's not |
1747 | usb_ep_set_halt(ep); | 1592 | * handled in hardware or the hardware driver. |
1748 | else if (port) { | 1593 | * |
1749 | struct usb_cdc_line_coding *value = req->buf; | 1594 | * Returns the size of the data sent to the host, or a negative |
1595 | * error number. | ||
1596 | */ | ||
1597 | static int gs_setup(struct usb_gadget *gadget, | ||
1598 | const struct usb_ctrlrequest *ctrl) | ||
1599 | { | ||
1600 | int ret = -EOPNOTSUPP; | ||
1601 | struct gs_dev *dev = get_gadget_data(gadget); | ||
1602 | struct usb_request *req = dev->dev_ctrl_req; | ||
1603 | u16 wIndex = le16_to_cpu(ctrl->wIndex); | ||
1604 | u16 wValue = le16_to_cpu(ctrl->wValue); | ||
1605 | u16 wLength = le16_to_cpu(ctrl->wLength); | ||
1750 | 1606 | ||
1751 | /* REVISIT: we currently just remember this data. | 1607 | req->complete = gs_setup_complete; |
1752 | * If we change that, (a) validate it first, then | 1608 | |
1753 | * (b) update whatever hardware needs updating. | 1609 | switch (ctrl->bRequestType & USB_TYPE_MASK) { |
1754 | */ | 1610 | case USB_TYPE_STANDARD: |
1755 | spin_lock(&port->port_lock); | 1611 | ret = gs_setup_standard(gadget, ctrl); |
1756 | port->port_line_coding = *value; | ||
1757 | spin_unlock(&port->port_lock); | ||
1758 | } | ||
1759 | break; | 1612 | break; |
1760 | 1613 | ||
1761 | case -ESHUTDOWN: | 1614 | case USB_TYPE_CLASS: |
1762 | /* disconnect */ | 1615 | ret = gs_setup_class(gadget, ctrl); |
1763 | gs_free_req(ep, req); | ||
1764 | break; | 1616 | break; |
1765 | 1617 | ||
1766 | default: | 1618 | default: |
1767 | /* unexpected */ | 1619 | pr_err("gs_setup: unknown request, type=%02x, request=%02x, " |
1620 | "value=%04x, index=%04x, length=%d\n", | ||
1621 | ctrl->bRequestType, ctrl->bRequest, | ||
1622 | wValue, wIndex, wLength); | ||
1768 | break; | 1623 | break; |
1769 | } | 1624 | } |
1770 | return; | ||
1771 | } | ||
1772 | 1625 | ||
1773 | /* | 1626 | /* respond with data transfer before status phase? */ |
1774 | * gs_setup_complete | 1627 | if (ret >= 0) { |
1775 | */ | 1628 | req->length = ret; |
1776 | static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) | 1629 | req->zero = ret < wLength |
1777 | { | 1630 | && (ret % gadget->ep0->maxpacket) == 0; |
1778 | if (req->status || req->actual != req->length) { | 1631 | ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); |
1779 | pr_err("gs_setup_complete: status error, status=%d, " | 1632 | if (ret < 0) { |
1780 | "actual=%d, length=%d\n", | 1633 | pr_err("gs_setup: cannot queue response, ret=%d\n", |
1781 | req->status, req->actual, req->length); | 1634 | ret); |
1635 | req->status = 0; | ||
1636 | gs_setup_complete(gadget->ep0, req); | ||
1637 | } | ||
1782 | } | 1638 | } |
1639 | |||
1640 | /* device either stalls (ret < 0) or reports success */ | ||
1641 | return ret; | ||
1783 | } | 1642 | } |
1784 | 1643 | ||
1785 | /* | 1644 | /* |
@@ -1811,6 +1670,23 @@ static void gs_disconnect(struct usb_gadget *gadget) | |||
1811 | pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); | 1670 | pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); |
1812 | } | 1671 | } |
1813 | 1672 | ||
1673 | static struct usb_gadget_driver gs_gadget_driver = { | ||
1674 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
1675 | .speed = USB_SPEED_HIGH, | ||
1676 | #else | ||
1677 | .speed = USB_SPEED_FULL, | ||
1678 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ | ||
1679 | .function = GS_LONG_NAME, | ||
1680 | .bind = gs_bind, | ||
1681 | .unbind = gs_unbind, | ||
1682 | .setup = gs_setup, | ||
1683 | .disconnect = gs_disconnect, | ||
1684 | .driver = { | ||
1685 | .name = GS_SHORT_NAME, | ||
1686 | .owner = THIS_MODULE, | ||
1687 | }, | ||
1688 | }; | ||
1689 | |||
1814 | /* | 1690 | /* |
1815 | * gs_set_config | 1691 | * gs_set_config |
1816 | * | 1692 | * |
@@ -1826,9 +1702,8 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1826 | int ret = 0; | 1702 | int ret = 0; |
1827 | struct usb_gadget *gadget = dev->dev_gadget; | 1703 | struct usb_gadget *gadget = dev->dev_gadget; |
1828 | struct usb_ep *ep; | 1704 | struct usb_ep *ep; |
1829 | struct usb_endpoint_descriptor *ep_desc; | 1705 | struct usb_endpoint_descriptor *out, *in, *notify; |
1830 | struct usb_request *req; | 1706 | struct usb_request *req; |
1831 | struct gs_req_entry *req_entry; | ||
1832 | 1707 | ||
1833 | if (dev == NULL) { | 1708 | if (dev == NULL) { |
1834 | pr_err("gs_set_config: NULL device pointer\n"); | 1709 | pr_err("gs_set_config: NULL device pointer\n"); |
@@ -1846,86 +1721,62 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1846 | case GS_BULK_CONFIG_ID: | 1721 | case GS_BULK_CONFIG_ID: |
1847 | if (use_acm) | 1722 | if (use_acm) |
1848 | return -EINVAL; | 1723 | return -EINVAL; |
1849 | /* device specific optimizations */ | ||
1850 | if (gadget_is_net2280(gadget)) | ||
1851 | net2280_set_fifo_mode(gadget, 1); | ||
1852 | break; | 1724 | break; |
1853 | case GS_ACM_CONFIG_ID: | 1725 | case GS_ACM_CONFIG_ID: |
1854 | if (!use_acm) | 1726 | if (!use_acm) |
1855 | return -EINVAL; | 1727 | return -EINVAL; |
1856 | /* device specific optimizations */ | ||
1857 | if (gadget_is_net2280(gadget)) | ||
1858 | net2280_set_fifo_mode(gadget, 1); | ||
1859 | break; | 1728 | break; |
1860 | default: | 1729 | default: |
1861 | return -EINVAL; | 1730 | return -EINVAL; |
1862 | } | 1731 | } |
1863 | 1732 | ||
1864 | dev->dev_config = config; | 1733 | in = choose_ep_desc(gadget, |
1865 | 1734 | &gs_highspeed_in_desc, | |
1866 | gadget_for_each_ep(ep, gadget) { | 1735 | &gs_fullspeed_in_desc); |
1867 | 1736 | out = choose_ep_desc(gadget, | |
1868 | if (EP_NOTIFY_NAME | 1737 | &gs_highspeed_out_desc, |
1869 | && strcmp(ep->name, EP_NOTIFY_NAME) == 0) { | 1738 | &gs_fullspeed_out_desc); |
1870 | ep_desc = choose_ep_desc(gadget, | 1739 | notify = dev->dev_notify_ep |
1740 | ? choose_ep_desc(gadget, | ||
1871 | &gs_highspeed_notify_desc, | 1741 | &gs_highspeed_notify_desc, |
1872 | &gs_fullspeed_notify_desc); | 1742 | &gs_fullspeed_notify_desc) |
1873 | ret = usb_ep_enable(ep,ep_desc); | 1743 | : NULL; |
1874 | if (ret == 0) { | ||
1875 | ep->driver_data = dev; | ||
1876 | dev->dev_notify_ep = ep; | ||
1877 | dev->dev_notify_ep_desc = ep_desc; | ||
1878 | } else { | ||
1879 | pr_err("gs_set_config: cannot enable NOTIFY " | ||
1880 | "endpoint %s, ret=%d\n", | ||
1881 | ep->name, ret); | ||
1882 | goto exit_reset_config; | ||
1883 | } | ||
1884 | } | ||
1885 | |||
1886 | else if (strcmp(ep->name, EP_IN_NAME) == 0) { | ||
1887 | ep_desc = choose_ep_desc(gadget, | ||
1888 | &gs_highspeed_in_desc, | ||
1889 | &gs_fullspeed_in_desc); | ||
1890 | ret = usb_ep_enable(ep,ep_desc); | ||
1891 | if (ret == 0) { | ||
1892 | ep->driver_data = dev; | ||
1893 | dev->dev_in_ep = ep; | ||
1894 | dev->dev_in_ep_desc = ep_desc; | ||
1895 | } else { | ||
1896 | pr_err("gs_set_config: cannot enable IN " | ||
1897 | "endpoint %s, ret=%d\n", | ||
1898 | ep->name, ret); | ||
1899 | goto exit_reset_config; | ||
1900 | } | ||
1901 | } | ||
1902 | 1744 | ||
1903 | else if (strcmp(ep->name, EP_OUT_NAME) == 0) { | 1745 | ret = usb_ep_enable(dev->dev_in_ep, in); |
1904 | ep_desc = choose_ep_desc(gadget, | 1746 | if (ret == 0) { |
1905 | &gs_highspeed_out_desc, | 1747 | dev->dev_in_ep_desc = in; |
1906 | &gs_fullspeed_out_desc); | 1748 | } else { |
1907 | ret = usb_ep_enable(ep,ep_desc); | 1749 | pr_debug("%s: cannot enable %s %s, ret=%d\n", |
1908 | if (ret == 0) { | 1750 | __func__, "IN", dev->dev_in_ep->name, ret); |
1909 | ep->driver_data = dev; | 1751 | return ret; |
1910 | dev->dev_out_ep = ep; | 1752 | } |
1911 | dev->dev_out_ep_desc = ep_desc; | ||
1912 | } else { | ||
1913 | pr_err("gs_set_config: cannot enable OUT " | ||
1914 | "endpoint %s, ret=%d\n", | ||
1915 | ep->name, ret); | ||
1916 | goto exit_reset_config; | ||
1917 | } | ||
1918 | } | ||
1919 | 1753 | ||
1754 | ret = usb_ep_enable(dev->dev_out_ep, out); | ||
1755 | if (ret == 0) { | ||
1756 | dev->dev_out_ep_desc = out; | ||
1757 | } else { | ||
1758 | pr_debug("%s: cannot enable %s %s, ret=%d\n", | ||
1759 | __func__, "OUT", dev->dev_out_ep->name, ret); | ||
1760 | fail0: | ||
1761 | usb_ep_disable(dev->dev_in_ep); | ||
1762 | return ret; | ||
1920 | } | 1763 | } |
1921 | 1764 | ||
1922 | if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL | 1765 | if (notify) { |
1923 | || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { | 1766 | ret = usb_ep_enable(dev->dev_notify_ep, notify); |
1924 | pr_err("gs_set_config: cannot find endpoints\n"); | 1767 | if (ret == 0) { |
1925 | ret = -ENODEV; | 1768 | dev->dev_notify_ep_desc = notify; |
1926 | goto exit_reset_config; | 1769 | } else { |
1770 | pr_debug("%s: cannot enable %s %s, ret=%d\n", | ||
1771 | __func__, "NOTIFY", | ||
1772 | dev->dev_notify_ep->name, ret); | ||
1773 | usb_ep_disable(dev->dev_out_ep); | ||
1774 | goto fail0; | ||
1775 | } | ||
1927 | } | 1776 | } |
1928 | 1777 | ||
1778 | dev->dev_config = config; | ||
1779 | |||
1929 | /* allocate and queue read requests */ | 1780 | /* allocate and queue read requests */ |
1930 | ep = dev->dev_out_ep; | 1781 | ep = dev->dev_out_ep; |
1931 | for (i=0; i<read_q_size && ret == 0; i++) { | 1782 | for (i=0; i<read_q_size && ret == 0; i++) { |
@@ -1946,9 +1797,10 @@ static int gs_set_config(struct gs_dev *dev, unsigned config) | |||
1946 | /* allocate write requests, and put on free list */ | 1797 | /* allocate write requests, and put on free list */ |
1947 | ep = dev->dev_in_ep; | 1798 | ep = dev->dev_in_ep; |
1948 | for (i=0; i<write_q_size; i++) { | 1799 | for (i=0; i<write_q_size; i++) { |
1949 | if ((req_entry=gs_alloc_req_entry(ep, ep->maxpacket, GFP_ATOMIC))) { | 1800 | req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC); |
1950 | req_entry->re_req->complete = gs_write_complete; | 1801 | if (req) { |
1951 | list_add(&req_entry->re_entry, &dev->dev_req_list); | 1802 | req->complete = gs_write_complete; |
1803 | list_add(&req->list, &dev->dev_req_list); | ||
1952 | } else { | 1804 | } else { |
1953 | pr_err("gs_set_config: cannot allocate " | 1805 | pr_err("gs_set_config: cannot allocate " |
1954 | "write requests\n"); | 1806 | "write requests\n"); |
@@ -1986,7 +1838,7 @@ exit_reset_config: | |||
1986 | */ | 1838 | */ |
1987 | static void gs_reset_config(struct gs_dev *dev) | 1839 | static void gs_reset_config(struct gs_dev *dev) |
1988 | { | 1840 | { |
1989 | struct gs_req_entry *req_entry; | 1841 | struct usb_request *req; |
1990 | 1842 | ||
1991 | if (dev == NULL) { | 1843 | if (dev == NULL) { |
1992 | pr_err("gs_reset_config: NULL device pointer\n"); | 1844 | pr_err("gs_reset_config: NULL device pointer\n"); |
@@ -2000,26 +1852,18 @@ static void gs_reset_config(struct gs_dev *dev) | |||
2000 | 1852 | ||
2001 | /* free write requests on the free list */ | 1853 | /* free write requests on the free list */ |
2002 | while(!list_empty(&dev->dev_req_list)) { | 1854 | while(!list_empty(&dev->dev_req_list)) { |
2003 | req_entry = list_entry(dev->dev_req_list.next, | 1855 | req = list_entry(dev->dev_req_list.next, |
2004 | struct gs_req_entry, re_entry); | 1856 | struct usb_request, list); |
2005 | list_del(&req_entry->re_entry); | 1857 | list_del(&req->list); |
2006 | gs_free_req_entry(dev->dev_in_ep, req_entry); | 1858 | gs_free_req(dev->dev_in_ep, req); |
2007 | } | 1859 | } |
2008 | 1860 | ||
2009 | /* disable endpoints, forcing completion of pending i/o; */ | 1861 | /* disable endpoints, forcing completion of pending i/o; */ |
2010 | /* completion handlers free their requests in this case */ | 1862 | /* completion handlers free their requests in this case */ |
2011 | if (dev->dev_notify_ep) { | 1863 | if (dev->dev_notify_ep) |
2012 | usb_ep_disable(dev->dev_notify_ep); | 1864 | usb_ep_disable(dev->dev_notify_ep); |
2013 | dev->dev_notify_ep = NULL; | 1865 | usb_ep_disable(dev->dev_in_ep); |
2014 | } | 1866 | usb_ep_disable(dev->dev_out_ep); |
2015 | if (dev->dev_in_ep) { | ||
2016 | usb_ep_disable(dev->dev_in_ep); | ||
2017 | dev->dev_in_ep = NULL; | ||
2018 | } | ||
2019 | if (dev->dev_out_ep) { | ||
2020 | usb_ep_disable(dev->dev_out_ep); | ||
2021 | dev->dev_out_ep = NULL; | ||
2022 | } | ||
2023 | } | 1867 | } |
2024 | 1868 | ||
2025 | /* | 1869 | /* |
@@ -2113,46 +1957,6 @@ static void gs_free_req(struct usb_ep *ep, struct usb_request *req) | |||
2113 | } | 1957 | } |
2114 | 1958 | ||
2115 | /* | 1959 | /* |
2116 | * gs_alloc_req_entry | ||
2117 | * | ||
2118 | * Allocates a request and its buffer, using the given | ||
2119 | * endpoint, buffer len, and kmalloc flags. | ||
2120 | */ | ||
2121 | static struct gs_req_entry * | ||
2122 | gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags) | ||
2123 | { | ||
2124 | struct gs_req_entry *req; | ||
2125 | |||
2126 | req = kmalloc(sizeof(struct gs_req_entry), kmalloc_flags); | ||
2127 | if (req == NULL) | ||
2128 | return NULL; | ||
2129 | |||
2130 | req->re_req = gs_alloc_req(ep, len, kmalloc_flags); | ||
2131 | if (req->re_req == NULL) { | ||
2132 | kfree(req); | ||
2133 | return NULL; | ||
2134 | } | ||
2135 | |||
2136 | req->re_req->context = req; | ||
2137 | |||
2138 | return req; | ||
2139 | } | ||
2140 | |||
2141 | /* | ||
2142 | * gs_free_req_entry | ||
2143 | * | ||
2144 | * Frees a request and its buffer. | ||
2145 | */ | ||
2146 | static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req) | ||
2147 | { | ||
2148 | if (ep != NULL && req != NULL) { | ||
2149 | if (req->re_req != NULL) | ||
2150 | gs_free_req(ep, req->re_req); | ||
2151 | kfree(req); | ||
2152 | } | ||
2153 | } | ||
2154 | |||
2155 | /* | ||
2156 | * gs_alloc_ports | 1960 | * gs_alloc_ports |
2157 | * | 1961 | * |
2158 | * Allocate all ports and set the gs_dev struct to point to them. | 1962 | * Allocate all ports and set the gs_dev struct to point to them. |
@@ -2233,6 +2037,8 @@ static void gs_free_ports(struct gs_dev *dev) | |||
2233 | } | 2037 | } |
2234 | } | 2038 | } |
2235 | 2039 | ||
2040 | /*-------------------------------------------------------------------------*/ | ||
2041 | |||
2236 | /* Circular Buffer */ | 2042 | /* Circular Buffer */ |
2237 | 2043 | ||
2238 | /* | 2044 | /* |
@@ -2393,3 +2199,77 @@ gs_buf_get(struct gs_buf *gb, char *buf, unsigned int count) | |||
2393 | 2199 | ||
2394 | return count; | 2200 | return count; |
2395 | } | 2201 | } |
2202 | |||
2203 | /*-------------------------------------------------------------------------*/ | ||
2204 | |||
2205 | static struct tty_driver *gs_tty_driver; | ||
2206 | |||
2207 | /* | ||
2208 | * gs_module_init | ||
2209 | * | ||
2210 | * Register as a USB gadget driver and a tty driver. | ||
2211 | */ | ||
2212 | static int __init gs_module_init(void) | ||
2213 | { | ||
2214 | int i; | ||
2215 | int retval; | ||
2216 | |||
2217 | retval = usb_gadget_register_driver(&gs_gadget_driver); | ||
2218 | if (retval) { | ||
2219 | pr_err("gs_module_init: cannot register gadget driver, " | ||
2220 | "ret=%d\n", retval); | ||
2221 | return retval; | ||
2222 | } | ||
2223 | |||
2224 | gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS); | ||
2225 | if (!gs_tty_driver) | ||
2226 | return -ENOMEM; | ||
2227 | gs_tty_driver->owner = THIS_MODULE; | ||
2228 | gs_tty_driver->driver_name = GS_SHORT_NAME; | ||
2229 | gs_tty_driver->name = "ttygs"; | ||
2230 | gs_tty_driver->major = GS_MAJOR; | ||
2231 | gs_tty_driver->minor_start = GS_MINOR_START; | ||
2232 | gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; | ||
2233 | gs_tty_driver->subtype = SERIAL_TYPE_NORMAL; | ||
2234 | gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | ||
2235 | gs_tty_driver->init_termios = tty_std_termios; | ||
2236 | /* must match GS_DEFAULT_DTE_RATE and friends */ | ||
2237 | gs_tty_driver->init_termios.c_cflag = | ||
2238 | B9600 | CS8 | CREAD | HUPCL | CLOCAL; | ||
2239 | gs_tty_driver->init_termios.c_ispeed = GS_DEFAULT_DTE_RATE; | ||
2240 | gs_tty_driver->init_termios.c_ospeed = GS_DEFAULT_DTE_RATE; | ||
2241 | tty_set_operations(gs_tty_driver, &gs_tty_ops); | ||
2242 | |||
2243 | for (i = 0; i < GS_NUM_PORTS; i++) | ||
2244 | mutex_init(&gs_open_close_lock[i]); | ||
2245 | |||
2246 | retval = tty_register_driver(gs_tty_driver); | ||
2247 | if (retval) { | ||
2248 | usb_gadget_unregister_driver(&gs_gadget_driver); | ||
2249 | put_tty_driver(gs_tty_driver); | ||
2250 | pr_err("gs_module_init: cannot register tty driver, " | ||
2251 | "ret=%d\n", retval); | ||
2252 | return retval; | ||
2253 | } | ||
2254 | |||
2255 | pr_info("gs_module_init: %s %s loaded\n", | ||
2256 | GS_LONG_NAME, GS_VERSION_STR); | ||
2257 | return 0; | ||
2258 | } | ||
2259 | module_init(gs_module_init); | ||
2260 | |||
2261 | /* | ||
2262 | * gs_module_exit | ||
2263 | * | ||
2264 | * Unregister as a tty driver and a USB gadget driver. | ||
2265 | */ | ||
2266 | static void __exit gs_module_exit(void) | ||
2267 | { | ||
2268 | tty_unregister_driver(gs_tty_driver); | ||
2269 | put_tty_driver(gs_tty_driver); | ||
2270 | usb_gadget_unregister_driver(&gs_gadget_driver); | ||
2271 | |||
2272 | pr_info("gs_module_exit: %s %s unloaded\n", | ||
2273 | GS_LONG_NAME, GS_VERSION_STR); | ||
2274 | } | ||
2275 | module_exit(gs_module_exit); | ||
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index 4ba96c1e060c..c9cec8738261 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -988,7 +988,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd) | |||
988 | * This did not trigger for a long time now. | 988 | * This did not trigger for a long time now. |
989 | */ | 989 | */ |
990 | printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " | 990 | printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " |
991 | "%d of %d done: %08x cur: %08x\n", qtd, | 991 | "%d of %zu done: %08x cur: %08x\n", qtd, |
992 | urb, qh, PTD_XFERRED_LENGTH(dw3), | 992 | urb, qh, PTD_XFERRED_LENGTH(dw3), |
993 | qtd->length, done_map, | 993 | qtd->length, done_map, |
994 | (1 << queue_entry)); | 994 | (1 << queue_entry)); |
@@ -1088,7 +1088,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd) | |||
1088 | } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { | 1088 | } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { |
1089 | /* short BULK received */ | 1089 | /* short BULK received */ |
1090 | 1090 | ||
1091 | printk(KERN_ERR "short bulk, %d instead %d\n", length, | 1091 | printk(KERN_ERR "short bulk, %d instead %zu\n", length, |
1092 | qtd->length); | 1092 | qtd->length); |
1093 | if (urb->transfer_flags & URB_SHORT_NOT_OK) { | 1093 | if (urb->transfer_flags & URB_SHORT_NOT_OK) { |
1094 | urb->status = -EREMOTEIO; | 1094 | urb->status = -EREMOTEIO; |
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index 73fb2a38f1e4..440bf94f0d4c 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c | |||
@@ -256,7 +256,7 @@ static struct pci_driver isp1761_pci_driver = { | |||
256 | 256 | ||
257 | static int __init isp1760_init(void) | 257 | static int __init isp1760_init(void) |
258 | { | 258 | { |
259 | int ret; | 259 | int ret = -ENODEV; |
260 | 260 | ||
261 | init_kmem_once(); | 261 | init_kmem_once(); |
262 | 262 | ||
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index 77204f001b9a..e899a77dfb83 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c | |||
@@ -90,7 +90,7 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev) | |||
90 | struct device *dev = &pdev->dev; | 90 | struct device *dev = &pdev->dev; |
91 | struct resource *res, *mem; | 91 | struct resource *res, *mem; |
92 | int retval, irq; | 92 | int retval, irq; |
93 | struct usb_hcd *hcd = 0; | 93 | struct usb_hcd *hcd = NULL; |
94 | 94 | ||
95 | irq = retval = platform_get_irq(pdev, 0); | 95 | irq = retval = platform_get_irq(pdev, 0); |
96 | if (retval < 0) | 96 | if (retval < 0) |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 7aafd53fbcab..189a9db03509 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -63,9 +63,6 @@ | |||
63 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 | 63 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 |
64 | #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 | 64 | #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 |
65 | 65 | ||
66 | #define USB_VENDOR_ID_MICROCHIP 0x04d8 | ||
67 | #define USB_DEVICE_ID_PICDEM 0x000c | ||
68 | |||
69 | #ifdef CONFIG_USB_DYNAMIC_MINORS | 66 | #ifdef CONFIG_USB_DYNAMIC_MINORS |
70 | #define USB_LD_MINOR_BASE 0 | 67 | #define USB_LD_MINOR_BASE 0 |
71 | #else | 68 | #else |
@@ -92,7 +89,6 @@ static struct usb_device_id ld_usb_table [] = { | |||
92 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, | 89 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, |
93 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, | 90 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, |
94 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, | 91 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, |
95 | { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) }, | ||
96 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, | 92 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, |
97 | { } /* Terminating entry */ | 93 | { } /* Terminating entry */ |
98 | }; | 94 | }; |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 742be3c35947..054dedd28127 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -856,6 +856,11 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
856 | struct urb *u; | 856 | struct urb *u; |
857 | struct usb_ctrlrequest req; | 857 | struct usb_ctrlrequest req; |
858 | struct subcase *reqp; | 858 | struct subcase *reqp; |
859 | |||
860 | /* sign of this variable means: | ||
861 | * -: tested code must return this (negative) error code | ||
862 | * +: tested code may return this (negative too) error code | ||
863 | */ | ||
859 | int expected = 0; | 864 | int expected = 0; |
860 | 865 | ||
861 | /* requests here are mostly expected to succeed on any | 866 | /* requests here are mostly expected to succeed on any |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 2cffec85ee7e..9ba64ccc1359 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -447,6 +447,15 @@ config USB_SERIAL_MOS7840 | |||
447 | To compile this driver as a module, choose M here: the | 447 | To compile this driver as a module, choose M here: the |
448 | module will be called mos7840. If unsure, choose N. | 448 | module will be called mos7840. If unsure, choose N. |
449 | 449 | ||
450 | config USB_SERIAL_MOTOROLA | ||
451 | tristate "USB Motorola Phone modem driver" | ||
452 | ---help--- | ||
453 | Say Y here if you want to use a Motorola phone with a USB | ||
454 | connector as a modem link. | ||
455 | |||
456 | To compile this driver as a module, choose M here: the | ||
457 | module will be called moto_modem. If unsure, choose N. | ||
458 | |||
450 | config USB_SERIAL_NAVMAN | 459 | config USB_SERIAL_NAVMAN |
451 | tristate "USB Navman GPS device" | 460 | tristate "USB Navman GPS device" |
452 | help | 461 | help |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 756859510d8c..17a762ab6769 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o | |||
39 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o | 39 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o |
40 | obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o | 40 | obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o |
41 | obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o | 41 | obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o |
42 | obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o | ||
42 | obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o | 43 | obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o |
43 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o | 44 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o |
44 | obj-$(CONFIG_USB_SERIAL_OPTION) += option.o | 45 | obj-$(CONFIG_USB_SERIAL_OPTION) += option.o |
diff --git a/drivers/usb/serial/moto_modem.c b/drivers/usb/serial/moto_modem.c new file mode 100644 index 000000000000..2e8e05462ef7 --- /dev/null +++ b/drivers/usb/serial/moto_modem.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Motorola USB Phone driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * {sigh} | ||
11 | * Mororola should be using the CDC ACM USB spec, but instead | ||
12 | * they try to just "do their own thing"... This driver should handle a | ||
13 | * few phones in which a basic "dumb serial connection" is needed to be | ||
14 | * able to get a connection through to them. | ||
15 | */ | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/tty.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/usb.h> | ||
22 | #include <linux/usb/serial.h> | ||
23 | |||
24 | static struct usb_device_id id_table [] = { | ||
25 | { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */ | ||
26 | { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */ | ||
27 | { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */ | ||
28 | { }, | ||
29 | }; | ||
30 | MODULE_DEVICE_TABLE(usb, id_table); | ||
31 | |||
32 | static struct usb_driver moto_driver = { | ||
33 | .name = "moto-modem", | ||
34 | .probe = usb_serial_probe, | ||
35 | .disconnect = usb_serial_disconnect, | ||
36 | .id_table = id_table, | ||
37 | .no_dynamic_id = 1, | ||
38 | }; | ||
39 | |||
40 | static struct usb_serial_driver moto_device = { | ||
41 | .driver = { | ||
42 | .owner = THIS_MODULE, | ||
43 | .name = "moto-modem", | ||
44 | }, | ||
45 | .id_table = id_table, | ||
46 | .num_ports = 1, | ||
47 | }; | ||
48 | |||
49 | static int __init moto_init(void) | ||
50 | { | ||
51 | int retval; | ||
52 | |||
53 | retval = usb_serial_register(&moto_device); | ||
54 | if (retval) | ||
55 | return retval; | ||
56 | retval = usb_register(&moto_driver); | ||
57 | if (retval) | ||
58 | usb_serial_deregister(&moto_device); | ||
59 | return retval; | ||
60 | } | ||
61 | |||
62 | static void __exit moto_exit(void) | ||
63 | { | ||
64 | usb_deregister(&moto_driver); | ||
65 | usb_serial_deregister(&moto_device); | ||
66 | } | ||
67 | |||
68 | module_init(moto_init); | ||
69 | module_exit(moto_exit); | ||
70 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index e4be2d442b1e..e7e016e60333 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -154,8 +154,6 @@ static int option_send_setup(struct usb_serial_port *port); | |||
154 | #define NOVATELWIRELESS_PRODUCT_MC727 0x4100 | 154 | #define NOVATELWIRELESS_PRODUCT_MC727 0x4100 |
155 | #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 | 155 | #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 |
156 | 156 | ||
157 | #define NOVATELWIRELESS_PRODUCT_U727 0x5010 | ||
158 | |||
159 | /* FUTURE NOVATEL PRODUCTS */ | 157 | /* FUTURE NOVATEL PRODUCTS */ |
160 | #define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 | 158 | #define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 |
161 | #define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 | 159 | #define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 |
@@ -184,6 +182,9 @@ static int option_send_setup(struct usb_serial_port *port); | |||
184 | #define AXESSTEL_VENDOR_ID 0x1726 | 182 | #define AXESSTEL_VENDOR_ID 0x1726 |
185 | #define AXESSTEL_PRODUCT_MV110H 0x1000 | 183 | #define AXESSTEL_PRODUCT_MV110H 0x1000 |
186 | 184 | ||
185 | #define ONDA_VENDOR_ID 0x19d2 | ||
186 | #define ONDA_PRODUCT_ET502HS 0x0002 | ||
187 | |||
187 | #define BANDRICH_VENDOR_ID 0x1A8D | 188 | #define BANDRICH_VENDOR_ID 0x1A8D |
188 | #define BANDRICH_PRODUCT_C100_1 0x1002 | 189 | #define BANDRICH_PRODUCT_C100_1 0x1002 |
189 | #define BANDRICH_PRODUCT_C100_2 0x1003 | 190 | #define BANDRICH_PRODUCT_C100_2 0x1003 |
@@ -269,7 +270,6 @@ static struct usb_device_id option_ids[] = { | |||
269 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ | 270 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ |
270 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ | 271 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ |
271 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ | 272 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ |
272 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel U727 */ | ||
273 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ | 273 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ |
274 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ | 274 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ |
275 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ | 275 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ |
@@ -293,14 +293,17 @@ static struct usb_device_id option_ids[] = { | |||
293 | { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ | 293 | { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ |
294 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ | 294 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ |
295 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ | 295 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ |
296 | { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ | ||
296 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, | 297 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, |
297 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, | 298 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
298 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, | 299 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, |
300 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, | ||
299 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 301 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, |
300 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 302 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, |
301 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, | 303 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, |
302 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ | 304 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ |
303 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ | 305 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ |
306 | { USB_DEVICE(0x19d2, 0x0001) }, /* Telstra NextG CDMA */ | ||
304 | { } /* Terminating entry */ | 307 | { } /* Terminating entry */ |
305 | }; | 308 | }; |
306 | MODULE_DEVICE_TABLE(usb, option_ids); | 309 | MODULE_DEVICE_TABLE(usb, option_ids); |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index a0ed889230aa..1b09578cbb10 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -401,6 +401,14 @@ UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100, | |||
401 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 401 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
402 | US_FL_IGNORE_RESIDUE ), | 402 | US_FL_IGNORE_RESIDUE ), |
403 | 403 | ||
404 | #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB | ||
405 | UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, | ||
406 | "Cypress", | ||
407 | "Cypress AT2LP", | ||
408 | US_SC_CYP_ATACB, US_PR_BULK, NULL, | ||
409 | 0), | ||
410 | #endif | ||
411 | |||
404 | /* Reported by Simon Levitt <simon@whattf.com> | 412 | /* Reported by Simon Levitt <simon@whattf.com> |
405 | * This entry needs Sub and Proto fields */ | 413 | * This entry needs Sub and Proto fields */ |
406 | UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, | 414 | UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, |
@@ -539,17 +547,6 @@ UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200, | |||
539 | "CD-RW Device", | 547 | "CD-RW Device", |
540 | US_SC_8020, US_PR_CB, NULL, 0), | 548 | US_SC_8020, US_PR_CB, NULL, 0), |
541 | 549 | ||
542 | /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. | ||
543 | * Device uses standards-violating 32-byte Bulk Command Block Wrappers and | ||
544 | * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. | ||
545 | */ | ||
546 | |||
547 | UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100, | ||
548 | "Kobian Mercury", | ||
549 | "Binocam DCB-132", | ||
550 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
551 | US_FL_BULK32), | ||
552 | |||
553 | #ifdef CONFIG_USB_STORAGE_USBAT | 550 | #ifdef CONFIG_USB_STORAGE_USBAT |
554 | UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, | 551 | UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, |
555 | "Shuttle/SCM", | 552 | "Shuttle/SCM", |
@@ -565,6 +562,16 @@ UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220, | |||
565 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 562 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
566 | US_FL_MAX_SECTORS_64), | 563 | US_FL_MAX_SECTORS_64), |
567 | 564 | ||
565 | /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. | ||
566 | * Device uses standards-violating 32-byte Bulk Command Block Wrappers and | ||
567 | * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. | ||
568 | */ | ||
569 | UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100, | ||
570 | "Kobian Mercury", | ||
571 | "Binocam DCB-132", | ||
572 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
573 | US_FL_BULK32), | ||
574 | |||
568 | /* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ | 575 | /* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ |
569 | UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, | 576 | UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, |
570 | "Belkin", | 577 | "Belkin", |
@@ -1304,6 +1311,16 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101, | |||
1304 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1311 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1305 | US_FL_IGNORE_DEVICE ), | 1312 | US_FL_IGNORE_DEVICE ), |
1306 | 1313 | ||
1314 | /* Reported by F. Aben <f.aben@option.com> | ||
1315 | * This device (wrongly) has a vendor-specific device descriptor. | ||
1316 | * The entry is needed so usb-storage can bind to it's mass-storage | ||
1317 | * interface as an interface driver */ | ||
1318 | UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000, | ||
1319 | "Option", | ||
1320 | "GI 0401 SD-Card", | ||
1321 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1322 | 0 ), | ||
1323 | |||
1307 | #ifdef CONFIG_USB_STORAGE_ISD200 | 1324 | #ifdef CONFIG_USB_STORAGE_ISD200 |
1308 | UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, | 1325 | UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, |
1309 | "ATI", | 1326 | "ATI", |
@@ -1361,13 +1378,6 @@ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, | |||
1361 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1378 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1362 | US_FL_FIX_INQUIRY), | 1379 | US_FL_FIX_INQUIRY), |
1363 | 1380 | ||
1364 | /* Reported by Rohan Hart <rohan.hart17@gmail.com> */ | ||
1365 | UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010, | ||
1366 | "INTOVA", | ||
1367 | "Pixtreme", | ||
1368 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1369 | US_FL_FIX_CAPACITY ), | ||
1370 | |||
1371 | /* | 1381 | /* |
1372 | * Entry for Jenoptik JD 5200z3 | 1382 | * Entry for Jenoptik JD 5200z3 |
1373 | * | 1383 | * |
@@ -1684,6 +1694,16 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201, | |||
1684 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1694 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1685 | US_FL_IGNORE_RESIDUE ), | 1695 | US_FL_IGNORE_RESIDUE ), |
1686 | 1696 | ||
1697 | /* Reported by Mauro Andreolini <andreoli@weblab.ing.unimo.it> | ||
1698 | * This entry is needed to bypass the ZeroCD mechanism | ||
1699 | * and to properly load as a modem device. | ||
1700 | */ | ||
1701 | UNUSUAL_DEV( 0x19d2, 0x2000, 0x0000, 0x0000, | ||
1702 | "Onda ET502HS", | ||
1703 | "USB MMC Storage", | ||
1704 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1705 | US_FL_IGNORE_DEVICE), | ||
1706 | |||
1687 | /* patch submitted by Davide Perini <perini.davide@dpsoftware.org> | 1707 | /* patch submitted by Davide Perini <perini.davide@dpsoftware.org> |
1688 | * and Renato Perini <rperini@email.it> | 1708 | * and Renato Perini <rperini@email.it> |
1689 | */ | 1709 | */ |
@@ -1721,6 +1741,13 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999, | |||
1721 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1741 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1722 | US_FL_GO_SLOW ), | 1742 | US_FL_GO_SLOW ), |
1723 | 1743 | ||
1744 | /* Reported by Rohan Hart <rohan.hart17@gmail.com> */ | ||
1745 | UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010, | ||
1746 | "INTOVA", | ||
1747 | "Pixtreme", | ||
1748 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1749 | US_FL_FIX_CAPACITY ), | ||
1750 | |||
1724 | /* | 1751 | /* |
1725 | * David Härdeman <david@2gen.com> | 1752 | * David Härdeman <david@2gen.com> |
1726 | * The key makes the SCSI stack print confusing (but harmless) messages | 1753 | * The key makes the SCSI stack print confusing (but harmless) messages |
@@ -1745,14 +1772,6 @@ UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001, | |||
1745 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1772 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1746 | US_FL_CAPACITY_HEURISTICS), | 1773 | US_FL_CAPACITY_HEURISTICS), |
1747 | 1774 | ||
1748 | #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB | ||
1749 | UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, | ||
1750 | "Cypress", | ||
1751 | "Cypress AT2LP", | ||
1752 | US_SC_CYP_ATACB, US_PR_BULK, NULL, | ||
1753 | 0), | ||
1754 | #endif | ||
1755 | |||
1756 | /* Control/Bulk transport for all SubClass values */ | 1775 | /* Control/Bulk transport for all SubClass values */ |
1757 | USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), | 1776 | USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), |
1758 | USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), | 1777 | USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index bb1dadaa4a23..2cdaf1ff8315 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -171,7 +171,6 @@ config FB_SYS_FOPS | |||
171 | config FB_DEFERRED_IO | 171 | config FB_DEFERRED_IO |
172 | bool | 172 | bool |
173 | depends on FB | 173 | depends on FB |
174 | default y | ||
175 | 174 | ||
176 | config FB_METRONOME | 175 | config FB_METRONOME |
177 | tristate | 176 | tristate |
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 8ffdf3578768..b004036d4087 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -441,14 +441,15 @@ static int atmel_lcdfb_set_par(struct fb_info *info) | |||
441 | 441 | ||
442 | value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock)); | 442 | value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock)); |
443 | 443 | ||
444 | value = (value / 2) - 1; | 444 | if (value < 2) { |
445 | dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n", value); | ||
446 | |||
447 | if (value <= 0) { | ||
448 | dev_notice(info->device, "Bypassing pixel clock divider\n"); | 445 | dev_notice(info->device, "Bypassing pixel clock divider\n"); |
449 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS); | 446 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS); |
450 | } else { | 447 | } else { |
451 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET); | 448 | value = (value / 2) - 1; |
449 | dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n", | ||
450 | value); | ||
451 | lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, | ||
452 | value << ATMEL_LCDC_CLKVAL_OFFSET); | ||
452 | info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1))); | 453 | info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1))); |
453 | dev_dbg(info->device, " updated pixclk: %lu KHz\n", | 454 | dev_dbg(info->device, " updated pixclk: %lu KHz\n", |
454 | PICOS2KHZ(info->var.pixclock)); | 455 | PICOS2KHZ(info->var.pixclock)); |
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index ad31983b43eb..5fa8b76673cb 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c | |||
@@ -1853,6 +1853,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, | |||
1853 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | 1853 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; |
1854 | struct display *p = &fb_display[vc->vc_num]; | 1854 | struct display *p = &fb_display[vc->vc_num]; |
1855 | int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; | 1855 | int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; |
1856 | unsigned short saved_ec; | ||
1857 | int ret; | ||
1856 | 1858 | ||
1857 | if (fbcon_is_inactive(vc, info)) | 1859 | if (fbcon_is_inactive(vc, info)) |
1858 | return -EINVAL; | 1860 | return -EINVAL; |
@@ -1865,6 +1867,11 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, | |||
1865 | * whole screen (prevents flicker). | 1867 | * whole screen (prevents flicker). |
1866 | */ | 1868 | */ |
1867 | 1869 | ||
1870 | saved_ec = vc->vc_video_erase_char; | ||
1871 | vc->vc_video_erase_char = vc->vc_scrl_erase_char; | ||
1872 | |||
1873 | ret = 0; | ||
1874 | |||
1868 | switch (dir) { | 1875 | switch (dir) { |
1869 | case SM_UP: | 1876 | case SM_UP: |
1870 | if (count > vc->vc_rows) /* Maximum realistic size */ | 1877 | if (count > vc->vc_rows) /* Maximum realistic size */ |
@@ -1883,7 +1890,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, | |||
1883 | (b - count)), | 1890 | (b - count)), |
1884 | vc->vc_scrl_erase_char, | 1891 | vc->vc_scrl_erase_char, |
1885 | vc->vc_size_row * count); | 1892 | vc->vc_size_row * count); |
1886 | return 1; | 1893 | ret = 1; |
1887 | break; | 1894 | break; |
1888 | 1895 | ||
1889 | case SCROLL_WRAP_MOVE: | 1896 | case SCROLL_WRAP_MOVE: |
@@ -1955,7 +1962,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, | |||
1955 | (b - count)), | 1962 | (b - count)), |
1956 | vc->vc_scrl_erase_char, | 1963 | vc->vc_scrl_erase_char, |
1957 | vc->vc_size_row * count); | 1964 | vc->vc_size_row * count); |
1958 | return 1; | 1965 | ret = 1; |
1966 | break; | ||
1959 | } | 1967 | } |
1960 | break; | 1968 | break; |
1961 | 1969 | ||
@@ -1974,7 +1982,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, | |||
1974 | t), | 1982 | t), |
1975 | vc->vc_scrl_erase_char, | 1983 | vc->vc_scrl_erase_char, |
1976 | vc->vc_size_row * count); | 1984 | vc->vc_size_row * count); |
1977 | return 1; | 1985 | ret = 1; |
1978 | break; | 1986 | break; |
1979 | 1987 | ||
1980 | case SCROLL_WRAP_MOVE: | 1988 | case SCROLL_WRAP_MOVE: |
@@ -2044,10 +2052,13 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, | |||
2044 | t), | 2052 | t), |
2045 | vc->vc_scrl_erase_char, | 2053 | vc->vc_scrl_erase_char, |
2046 | vc->vc_size_row * count); | 2054 | vc->vc_size_row * count); |
2047 | return 1; | 2055 | ret = 1; |
2056 | break; | ||
2048 | } | 2057 | } |
2058 | break; | ||
2049 | } | 2059 | } |
2050 | return 0; | 2060 | vc->vc_video_erase_char = saved_ec; |
2061 | return ret; | ||
2051 | } | 2062 | } |
2052 | 2063 | ||
2053 | 2064 | ||
@@ -2507,6 +2518,9 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, | |||
2507 | c = vc->vc_video_erase_char; | 2518 | c = vc->vc_video_erase_char; |
2508 | vc->vc_video_erase_char = | 2519 | vc->vc_video_erase_char = |
2509 | ((c & 0xfe00) >> 1) | (c & 0xff); | 2520 | ((c & 0xfe00) >> 1) | (c & 0xff); |
2521 | c = vc->vc_def_color; | ||
2522 | vc->vc_scrl_erase_char = | ||
2523 | ((c & 0xFE00) >> 1) | (c & 0xFF); | ||
2510 | vc->vc_attr >>= 1; | 2524 | vc->vc_attr >>= 1; |
2511 | } | 2525 | } |
2512 | } else if (!vc->vc_hi_font_mask && cnt == 512) { | 2526 | } else if (!vc->vc_hi_font_mask && cnt == 512) { |
@@ -2537,9 +2551,14 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, | |||
2537 | if (vc->vc_can_do_color) { | 2551 | if (vc->vc_can_do_color) { |
2538 | vc->vc_video_erase_char = | 2552 | vc->vc_video_erase_char = |
2539 | ((c & 0xff00) << 1) | (c & 0xff); | 2553 | ((c & 0xff00) << 1) | (c & 0xff); |
2554 | c = vc->vc_def_color; | ||
2555 | vc->vc_scrl_erase_char = | ||
2556 | ((c & 0xFF00) << 1) | (c & 0xFF); | ||
2540 | vc->vc_attr <<= 1; | 2557 | vc->vc_attr <<= 1; |
2541 | } else | 2558 | } else { |
2542 | vc->vc_video_erase_char = c & ~0x100; | 2559 | vc->vc_video_erase_char = c & ~0x100; |
2560 | vc->vc_scrl_erase_char = c & ~0x100; | ||
2561 | } | ||
2543 | } | 2562 | } |
2544 | 2563 | ||
2545 | } | 2564 | } |
diff --git a/drivers/video/pnx4008/pnxrgbfb.c b/drivers/video/pnx4008/pnxrgbfb.c index 685761a0732c..4db6b48a8715 100644 --- a/drivers/video/pnx4008/pnxrgbfb.c +++ b/drivers/video/pnx4008/pnxrgbfb.c | |||
@@ -100,7 +100,6 @@ static int rgbfb_remove(struct platform_device *pdev) | |||
100 | fb_dealloc_cmap(&info->cmap); | 100 | fb_dealloc_cmap(&info->cmap); |
101 | framebuffer_release(info); | 101 | framebuffer_release(info); |
102 | platform_set_drvdata(pdev, NULL); | 102 | platform_set_drvdata(pdev, NULL); |
103 | kfree(info); | ||
104 | } | 103 | } |
105 | 104 | ||
106 | pnx4008_free_dum_channel(channel_owned, pdev->id); | 105 | pnx4008_free_dum_channel(channel_owned, pdev->id); |
@@ -168,23 +167,21 @@ static int __devinit rgbfb_probe(struct platform_device *pdev) | |||
168 | 167 | ||
169 | ret = fb_alloc_cmap(&info->cmap, 256, 0); | 168 | ret = fb_alloc_cmap(&info->cmap, 256, 0); |
170 | if (ret < 0) | 169 | if (ret < 0) |
171 | goto err2; | 170 | goto err1; |
172 | 171 | ||
173 | ret = register_framebuffer(info); | 172 | ret = register_framebuffer(info); |
174 | if (ret < 0) | 173 | if (ret < 0) |
175 | goto err3; | 174 | goto err2; |
176 | platform_set_drvdata(pdev, info); | 175 | platform_set_drvdata(pdev, info); |
177 | 176 | ||
178 | return 0; | 177 | return 0; |
179 | 178 | ||
180 | err3: | ||
181 | fb_dealloc_cmap(&info->cmap); | ||
182 | err2: | 179 | err2: |
183 | framebuffer_release(info); | 180 | fb_dealloc_cmap(&info->cmap); |
184 | err1: | 181 | err1: |
185 | pnx4008_free_dum_channel(channel_owned, pdev->id); | 182 | pnx4008_free_dum_channel(channel_owned, pdev->id); |
186 | err0: | 183 | err0: |
187 | kfree(info); | 184 | framebuffer_release(info); |
188 | err: | 185 | err: |
189 | return ret; | 186 | return ret; |
190 | } | 187 | } |
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c index bd54cd0de39a..beefab2992c0 100644 --- a/drivers/video/tridentfb.c +++ b/drivers/video/tridentfb.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #define VERSION "0.7.8-NEWAPI" | 27 | #define VERSION "0.7.8-NEWAPI" |
28 | 28 | ||
29 | struct tridentfb_par { | 29 | struct tridentfb_par { |
30 | int vclk; /* in MHz */ | ||
31 | void __iomem *io_virt; /* iospace virtual memory address */ | 30 | void __iomem *io_virt; /* iospace virtual memory address */ |
32 | }; | 31 | }; |
33 | 32 | ||
@@ -669,27 +668,26 @@ static void set_screen_start(int base) | |||
669 | (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17)); | 668 | (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17)); |
670 | } | 669 | } |
671 | 670 | ||
672 | /* Use 20.12 fixed-point for NTSC value and frequency calculation */ | ||
673 | #define calc_freq(n, m, k) ( ((unsigned long)0xE517 * (n + 8) / ((m + 2) * (1 << k))) >> 12 ) | ||
674 | |||
675 | /* Set dotclock frequency */ | 671 | /* Set dotclock frequency */ |
676 | static void set_vclk(int freq) | 672 | static void set_vclk(unsigned long freq) |
677 | { | 673 | { |
678 | int m, n, k; | 674 | int m, n, k; |
679 | int f, fi, d, di; | 675 | unsigned long f, fi, d, di; |
680 | unsigned char lo = 0, hi = 0; | 676 | unsigned char lo = 0, hi = 0; |
681 | 677 | ||
682 | d = 20; | 678 | d = 20000; |
683 | for (k = 2; k >= 0; k--) | 679 | for (k = 2; k >= 0; k--) |
684 | for (m = 0; m < 63; m++) | 680 | for (m = 0; m < 63; m++) |
685 | for (n = 0; n < 128; n++) { | 681 | for (n = 0; n < 128; n++) { |
686 | fi = calc_freq(n, m, k); | 682 | fi = ((14318l * (n + 8)) / (m + 2)) >> k; |
687 | if ((di = abs(fi - freq)) < d) { | 683 | if ((di = abs(fi - freq)) < d) { |
688 | d = di; | 684 | d = di; |
689 | f = fi; | 685 | f = fi; |
690 | lo = n; | 686 | lo = n; |
691 | hi = (k << 6) | m; | 687 | hi = (k << 6) | m; |
692 | } | 688 | } |
689 | if (fi > freq) | ||
690 | break; | ||
693 | } | 691 | } |
694 | if (chip3D) { | 692 | if (chip3D) { |
695 | write3C4(ClockHigh, hi); | 693 | write3C4(ClockHigh, hi); |
@@ -888,6 +886,8 @@ static int tridentfb_set_par(struct fb_info *info) | |||
888 | struct fb_var_screeninfo *var = &info->var; | 886 | struct fb_var_screeninfo *var = &info->var; |
889 | int bpp = var->bits_per_pixel; | 887 | int bpp = var->bits_per_pixel; |
890 | unsigned char tmp; | 888 | unsigned char tmp; |
889 | unsigned long vclk; | ||
890 | |||
891 | debug("enter\n"); | 891 | debug("enter\n"); |
892 | hdispend = var->xres / 8 - 1; | 892 | hdispend = var->xres / 8 - 1; |
893 | hsyncstart = (var->xres + var->right_margin) / 8; | 893 | hsyncstart = (var->xres + var->right_margin) / 8; |
@@ -905,7 +905,6 @@ static int tridentfb_set_par(struct fb_info *info) | |||
905 | vblankstart = var->yres; | 905 | vblankstart = var->yres; |
906 | vblankend = vtotal + 2; | 906 | vblankend = vtotal + 2; |
907 | 907 | ||
908 | enable_mmio(); | ||
909 | crtc_unlock(); | 908 | crtc_unlock(); |
910 | write3CE(CyberControl, 8); | 909 | write3CE(CyberControl, 8); |
911 | 910 | ||
@@ -1015,11 +1014,11 @@ static int tridentfb_set_par(struct fb_info *info) | |||
1015 | write3X4(Performance, 0x92); | 1014 | write3X4(Performance, 0x92); |
1016 | write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */ | 1015 | write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */ |
1017 | 1016 | ||
1018 | /* convert from picoseconds to MHz */ | 1017 | /* convert from picoseconds to kHz */ |
1019 | par->vclk = 1000000 / info->var.pixclock; | 1018 | vclk = PICOS2KHZ(info->var.pixclock); |
1020 | if (bpp == 32) | 1019 | if (bpp == 32) |
1021 | par->vclk *= 2; | 1020 | vclk *= 2; |
1022 | set_vclk(par->vclk); | 1021 | set_vclk(vclk); |
1023 | 1022 | ||
1024 | write3C4(0, 3); | 1023 | write3C4(0, 3); |
1025 | write3C4(1, 1); /* set char clock 8 dots wide */ | 1024 | write3C4(1, 1); /* set char clock 8 dots wide */ |
diff --git a/fs/dquot.c b/fs/dquot.c index dfba1623cccb..5ac77da19959 100644 --- a/fs/dquot.c +++ b/fs/dquot.c | |||
@@ -1491,6 +1491,16 @@ int vfs_quota_off(struct super_block *sb, int type, int remount) | |||
1491 | 1491 | ||
1492 | /* We need to serialize quota_off() for device */ | 1492 | /* We need to serialize quota_off() for device */ |
1493 | mutex_lock(&dqopt->dqonoff_mutex); | 1493 | mutex_lock(&dqopt->dqonoff_mutex); |
1494 | |||
1495 | /* | ||
1496 | * Skip everything if there's nothing to do. We have to do this because | ||
1497 | * sometimes we are called when fill_super() failed and calling | ||
1498 | * sync_fs() in such cases does no good. | ||
1499 | */ | ||
1500 | if (!sb_any_quota_enabled(sb) && !sb_any_quota_suspended(sb)) { | ||
1501 | mutex_unlock(&dqopt->dqonoff_mutex); | ||
1502 | return 0; | ||
1503 | } | ||
1494 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1504 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1495 | toputinode[cnt] = NULL; | 1505 | toputinode[cnt] = NULL; |
1496 | if (type != -1 && cnt != type) | 1506 | if (type != -1 && cnt != type) |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 0a1397335a8e..c92cc1c00aae 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -37,17 +37,11 @@ static struct dentry *lock_parent(struct dentry *dentry) | |||
37 | { | 37 | { |
38 | struct dentry *dir; | 38 | struct dentry *dir; |
39 | 39 | ||
40 | dir = dget(dentry->d_parent); | 40 | dir = dget_parent(dentry); |
41 | mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT); | 41 | mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT); |
42 | return dir; | 42 | return dir; |
43 | } | 43 | } |
44 | 44 | ||
45 | static void unlock_parent(struct dentry *dentry) | ||
46 | { | ||
47 | mutex_unlock(&(dentry->d_parent->d_inode->i_mutex)); | ||
48 | dput(dentry->d_parent); | ||
49 | } | ||
50 | |||
51 | static void unlock_dir(struct dentry *dir) | 45 | static void unlock_dir(struct dentry *dir) |
52 | { | 46 | { |
53 | mutex_unlock(&dir->d_inode->i_mutex); | 47 | mutex_unlock(&dir->d_inode->i_mutex); |
@@ -426,8 +420,9 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry) | |||
426 | int rc = 0; | 420 | int rc = 0; |
427 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); | 421 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); |
428 | struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir); | 422 | struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir); |
423 | struct dentry *lower_dir_dentry; | ||
429 | 424 | ||
430 | lock_parent(lower_dentry); | 425 | lower_dir_dentry = lock_parent(lower_dentry); |
431 | rc = vfs_unlink(lower_dir_inode, lower_dentry); | 426 | rc = vfs_unlink(lower_dir_inode, lower_dentry); |
432 | if (rc) { | 427 | if (rc) { |
433 | printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc); | 428 | printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc); |
@@ -439,7 +434,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry) | |||
439 | dentry->d_inode->i_ctime = dir->i_ctime; | 434 | dentry->d_inode->i_ctime = dir->i_ctime; |
440 | d_drop(dentry); | 435 | d_drop(dentry); |
441 | out_unlock: | 436 | out_unlock: |
442 | unlock_parent(lower_dentry); | 437 | unlock_dir(lower_dir_dentry); |
443 | return rc; | 438 | return rc; |
444 | } | 439 | } |
445 | 440 | ||
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c index 788995efd1d3..6560da1a58ce 100644 --- a/fs/ecryptfs/miscdev.c +++ b/fs/ecryptfs/miscdev.c | |||
@@ -257,12 +257,14 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count, | |||
257 | mutex_lock(&daemon->mux); | 257 | mutex_lock(&daemon->mux); |
258 | if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { | 258 | if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { |
259 | rc = 0; | 259 | rc = 0; |
260 | mutex_unlock(&ecryptfs_daemon_hash_mux); | ||
260 | printk(KERN_WARNING "%s: Attempt to read from zombified " | 261 | printk(KERN_WARNING "%s: Attempt to read from zombified " |
261 | "daemon\n", __func__); | 262 | "daemon\n", __func__); |
262 | goto out_unlock_daemon; | 263 | goto out_unlock_daemon; |
263 | } | 264 | } |
264 | if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) { | 265 | if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) { |
265 | rc = 0; | 266 | rc = 0; |
267 | mutex_unlock(&ecryptfs_daemon_hash_mux); | ||
266 | goto out_unlock_daemon; | 268 | goto out_unlock_daemon; |
267 | } | 269 | } |
268 | /* This daemon will not go away so long as this flag is set */ | 270 | /* This daemon will not go away so long as this flag is set */ |
@@ -736,7 +736,7 @@ static int exec_mmap(struct mm_struct *mm) | |||
736 | tsk->active_mm = mm; | 736 | tsk->active_mm = mm; |
737 | activate_mm(active_mm, mm); | 737 | activate_mm(active_mm, mm); |
738 | task_unlock(tsk); | 738 | task_unlock(tsk); |
739 | mm_update_next_owner(mm); | 739 | mm_update_next_owner(old_mm); |
740 | arch_pick_mmap_layout(mm); | 740 | arch_pick_mmap_layout(mm); |
741 | if (old_mm) { | 741 | if (old_mm) { |
742 | up_read(&old_mm->mmap_sem); | 742 | up_read(&old_mm->mmap_sem); |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index fbec2ef93797..b128bdc0f55c 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2639,8 +2639,7 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb) | |||
2639 | struct proc_dir_entry *proc; | 2639 | struct proc_dir_entry *proc; |
2640 | char devname[64]; | 2640 | char devname[64]; |
2641 | 2641 | ||
2642 | snprintf(devname, sizeof(devname) - 1, "%s", | 2642 | bdevname(sb->s_bdev, devname); |
2643 | bdevname(sb->s_bdev, devname)); | ||
2644 | sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); | 2643 | sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); |
2645 | 2644 | ||
2646 | MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); | 2645 | MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); |
@@ -2674,8 +2673,7 @@ static int ext4_mb_destroy_per_dev_proc(struct super_block *sb) | |||
2674 | if (sbi->s_mb_proc == NULL) | 2673 | if (sbi->s_mb_proc == NULL) |
2675 | return -EINVAL; | 2674 | return -EINVAL; |
2676 | 2675 | ||
2677 | snprintf(devname, sizeof(devname) - 1, "%s", | 2676 | bdevname(sb->s_bdev, devname); |
2678 | bdevname(sb->s_bdev, devname)); | ||
2679 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); | 2677 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); |
2680 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); | 2678 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); |
2681 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); | 2679 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f28cf8b46f80..8092f0d9fd1f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -804,6 +804,8 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req, | |||
804 | if (offset == PAGE_CACHE_SIZE) | 804 | if (offset == PAGE_CACHE_SIZE) |
805 | offset = 0; | 805 | offset = 0; |
806 | 806 | ||
807 | if (!fc->big_writes) | ||
808 | break; | ||
807 | } while (iov_iter_count(ii) && count < fc->max_write && | 809 | } while (iov_iter_count(ii) && count < fc->max_write && |
808 | req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0); | 810 | req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0); |
809 | 811 | ||
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index dadffa21a206..bae948657c4f 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -404,6 +404,9 @@ struct fuse_conn { | |||
404 | /** Is bmap not implemented by fs? */ | 404 | /** Is bmap not implemented by fs? */ |
405 | unsigned no_bmap : 1; | 405 | unsigned no_bmap : 1; |
406 | 406 | ||
407 | /** Do multi-page cached writes */ | ||
408 | unsigned big_writes : 1; | ||
409 | |||
407 | /** The number of requests waiting for completion */ | 410 | /** The number of requests waiting for completion */ |
408 | atomic_t num_waiting; | 411 | atomic_t num_waiting; |
409 | 412 | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 79b615873838..fb77e0962132 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -576,6 +576,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
576 | fc->no_lock = 1; | 576 | fc->no_lock = 1; |
577 | if (arg->flags & FUSE_ATOMIC_O_TRUNC) | 577 | if (arg->flags & FUSE_ATOMIC_O_TRUNC) |
578 | fc->atomic_o_trunc = 1; | 578 | fc->atomic_o_trunc = 1; |
579 | if (arg->flags & FUSE_BIG_WRITES) | ||
580 | fc->big_writes = 1; | ||
579 | } else { | 581 | } else { |
580 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; | 582 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; |
581 | fc->no_lock = 1; | 583 | fc->no_lock = 1; |
@@ -599,7 +601,8 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req) | |||
599 | arg->major = FUSE_KERNEL_VERSION; | 601 | arg->major = FUSE_KERNEL_VERSION; |
600 | arg->minor = FUSE_KERNEL_MINOR_VERSION; | 602 | arg->minor = FUSE_KERNEL_MINOR_VERSION; |
601 | arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; | 603 | arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; |
602 | arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC; | 604 | arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | |
605 | FUSE_BIG_WRITES; | ||
603 | req->in.h.opcode = FUSE_INIT; | 606 | req->in.h.opcode = FUSE_INIT; |
604 | req->in.numargs = 1; | 607 | req->in.numargs = 1; |
605 | req->in.args[0].size = sizeof(*arg); | 608 | req->in.args[0].size = sizeof(*arg); |
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index d53b2af91c25..67e1c8b467c4 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -65,6 +65,8 @@ static int hfsplus_releasepage(struct page *page, gfp_t mask) | |||
65 | BUG(); | 65 | BUG(); |
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | if (!tree) | ||
69 | return 0; | ||
68 | if (tree->node_size >= PAGE_CACHE_SIZE) { | 70 | if (tree->node_size >= PAGE_CACHE_SIZE) { |
69 | nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT); | 71 | nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT); |
70 | spin_lock(&tree->hash_lock); | 72 | spin_lock(&tree->hash_lock); |
diff --git a/fs/hppfs/Makefile b/fs/hppfs/Makefile index 6890433f7595..8a1f50344368 100644 --- a/fs/hppfs/Makefile +++ b/fs/hppfs/Makefile | |||
@@ -1,9 +1,9 @@ | |||
1 | # | 1 | # |
2 | # Copyright (C) 2002, 2003 Jeff Dike (jdike@karaya.com) | 2 | # Copyright (C) 2002 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
5 | 5 | ||
6 | hppfs-objs := hppfs_kern.o | 6 | hppfs-objs := hppfs.o |
7 | 7 | ||
8 | obj-y = | 8 | obj-y = |
9 | obj-$(CONFIG_HPPFS) += hppfs.o | 9 | obj-$(CONFIG_HPPFS) += $(hppfs-objs) |
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs.c index 8601d8ef3b55..65077aa90f0a 100644 --- a/fs/hppfs/hppfs_kern.c +++ b/fs/hppfs/hppfs.c | |||
@@ -33,7 +33,7 @@ struct hppfs_private { | |||
33 | }; | 33 | }; |
34 | 34 | ||
35 | struct hppfs_inode_info { | 35 | struct hppfs_inode_info { |
36 | struct dentry *proc_dentry; | 36 | struct dentry *proc_dentry; |
37 | struct inode vfs_inode; | 37 | struct inode vfs_inode; |
38 | }; | 38 | }; |
39 | 39 | ||
@@ -52,7 +52,7 @@ static int is_pid(struct dentry *dentry) | |||
52 | int i; | 52 | int i; |
53 | 53 | ||
54 | sb = dentry->d_sb; | 54 | sb = dentry->d_sb; |
55 | if ((sb->s_op != &hppfs_sbops) || (dentry->d_parent != sb->s_root)) | 55 | if (dentry->d_parent != sb->s_root) |
56 | return 0; | 56 | return 0; |
57 | 57 | ||
58 | for (i = 0; i < dentry->d_name.len; i++) { | 58 | for (i = 0; i < dentry->d_name.len; i++) { |
@@ -136,7 +136,7 @@ static int file_removed(struct dentry *dentry, const char *file) | |||
136 | } | 136 | } |
137 | 137 | ||
138 | static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, | 138 | static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, |
139 | struct nameidata *nd) | 139 | struct nameidata *nd) |
140 | { | 140 | { |
141 | struct dentry *proc_dentry, *new, *parent; | 141 | struct dentry *proc_dentry, *new, *parent; |
142 | struct inode *inode; | 142 | struct inode *inode; |
@@ -254,6 +254,8 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count, | |||
254 | int err; | 254 | int err; |
255 | 255 | ||
256 | if (hppfs->contents != NULL) { | 256 | if (hppfs->contents != NULL) { |
257 | int rem; | ||
258 | |||
257 | if (*ppos >= hppfs->len) | 259 | if (*ppos >= hppfs->len) |
258 | return 0; | 260 | return 0; |
259 | 261 | ||
@@ -267,8 +269,10 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count, | |||
267 | 269 | ||
268 | if (off + count > hppfs->len) | 270 | if (off + count > hppfs->len) |
269 | count = hppfs->len - off; | 271 | count = hppfs->len - off; |
270 | copy_to_user(buf, &data->contents[off], count); | 272 | rem = copy_to_user(buf, &data->contents[off], count); |
271 | *ppos += count; | 273 | *ppos += count - rem; |
274 | if (rem > 0) | ||
275 | return -EFAULT; | ||
272 | } else if (hppfs->host_fd != -1) { | 276 | } else if (hppfs->host_fd != -1) { |
273 | err = os_seek_file(hppfs->host_fd, *ppos); | 277 | err = os_seek_file(hppfs->host_fd, *ppos); |
274 | if (err) { | 278 | if (err) { |
@@ -285,21 +289,15 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count, | |||
285 | return count; | 289 | return count; |
286 | } | 290 | } |
287 | 291 | ||
288 | static ssize_t hppfs_write(struct file *file, const char __user *buf, size_t len, | 292 | static ssize_t hppfs_write(struct file *file, const char __user *buf, |
289 | loff_t *ppos) | 293 | size_t len, loff_t *ppos) |
290 | { | 294 | { |
291 | struct hppfs_private *data = file->private_data; | 295 | struct hppfs_private *data = file->private_data; |
292 | struct file *proc_file = data->proc_file; | 296 | struct file *proc_file = data->proc_file; |
293 | ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); | 297 | ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); |
294 | int err; | ||
295 | 298 | ||
296 | write = proc_file->f_path.dentry->d_inode->i_fop->write; | 299 | write = proc_file->f_path.dentry->d_inode->i_fop->write; |
297 | 300 | return (*write)(proc_file, buf, len, ppos); | |
298 | proc_file->f_pos = file->f_pos; | ||
299 | err = (*write)(proc_file, buf, len, &proc_file->f_pos); | ||
300 | file->f_pos = proc_file->f_pos; | ||
301 | |||
302 | return err; | ||
303 | } | 301 | } |
304 | 302 | ||
305 | static int open_host_sock(char *host_file, int *filter_out) | 303 | static int open_host_sock(char *host_file, int *filter_out) |
@@ -357,7 +355,7 @@ static struct hppfs_data *hppfs_get_data(int fd, int filter, | |||
357 | 355 | ||
358 | if (filter) { | 356 | if (filter) { |
359 | while ((n = read_proc(proc_file, data->contents, | 357 | while ((n = read_proc(proc_file, data->contents, |
360 | sizeof(data->contents), NULL, 0)) > 0) | 358 | sizeof(data->contents), NULL, 0)) > 0) |
361 | os_write_file(fd, data->contents, n); | 359 | os_write_file(fd, data->contents, n); |
362 | err = os_shutdown_socket(fd, 0, 1); | 360 | err = os_shutdown_socket(fd, 0, 1); |
363 | if (err) { | 361 | if (err) { |
@@ -429,8 +427,8 @@ static int file_mode(int fmode) | |||
429 | static int hppfs_open(struct inode *inode, struct file *file) | 427 | static int hppfs_open(struct inode *inode, struct file *file) |
430 | { | 428 | { |
431 | struct hppfs_private *data; | 429 | struct hppfs_private *data; |
432 | struct dentry *proc_dentry; | ||
433 | struct vfsmount *proc_mnt; | 430 | struct vfsmount *proc_mnt; |
431 | struct dentry *proc_dentry; | ||
434 | char *host_file; | 432 | char *host_file; |
435 | int err, fd, type, filter; | 433 | int err, fd, type, filter; |
436 | 434 | ||
@@ -492,8 +490,8 @@ static int hppfs_open(struct inode *inode, struct file *file) | |||
492 | static int hppfs_dir_open(struct inode *inode, struct file *file) | 490 | static int hppfs_dir_open(struct inode *inode, struct file *file) |
493 | { | 491 | { |
494 | struct hppfs_private *data; | 492 | struct hppfs_private *data; |
495 | struct dentry *proc_dentry; | ||
496 | struct vfsmount *proc_mnt; | 493 | struct vfsmount *proc_mnt; |
494 | struct dentry *proc_dentry; | ||
497 | int err; | 495 | int err; |
498 | 496 | ||
499 | err = -ENOMEM; | 497 | err = -ENOMEM; |
@@ -620,6 +618,9 @@ static struct inode *hppfs_alloc_inode(struct super_block *sb) | |||
620 | 618 | ||
621 | void hppfs_delete_inode(struct inode *ino) | 619 | void hppfs_delete_inode(struct inode *ino) |
622 | { | 620 | { |
621 | dput(HPPFS_I(ino)->proc_dentry); | ||
622 | mntput(ino->i_sb->s_fs_info); | ||
623 | |||
623 | clear_inode(ino); | 624 | clear_inode(ino); |
624 | } | 625 | } |
625 | 626 | ||
@@ -628,69 +629,46 @@ static void hppfs_destroy_inode(struct inode *inode) | |||
628 | kfree(HPPFS_I(inode)); | 629 | kfree(HPPFS_I(inode)); |
629 | } | 630 | } |
630 | 631 | ||
631 | static void hppfs_put_super(struct super_block *sb) | ||
632 | { | ||
633 | mntput(sb->s_fs_info); | ||
634 | } | ||
635 | |||
636 | static const struct super_operations hppfs_sbops = { | 632 | static const struct super_operations hppfs_sbops = { |
637 | .alloc_inode = hppfs_alloc_inode, | 633 | .alloc_inode = hppfs_alloc_inode, |
638 | .destroy_inode = hppfs_destroy_inode, | 634 | .destroy_inode = hppfs_destroy_inode, |
639 | .delete_inode = hppfs_delete_inode, | 635 | .delete_inode = hppfs_delete_inode, |
640 | .statfs = hppfs_statfs, | 636 | .statfs = hppfs_statfs, |
641 | .put_super = hppfs_put_super, | ||
642 | }; | 637 | }; |
643 | 638 | ||
644 | static int hppfs_readlink(struct dentry *dentry, char __user *buffer, | 639 | static int hppfs_readlink(struct dentry *dentry, char __user *buffer, |
645 | int buflen) | 640 | int buflen) |
646 | { | 641 | { |
647 | struct file *proc_file; | ||
648 | struct dentry *proc_dentry; | 642 | struct dentry *proc_dentry; |
649 | struct vfsmount *proc_mnt; | ||
650 | int ret; | ||
651 | 643 | ||
652 | proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; | 644 | proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; |
653 | proc_mnt = dentry->d_sb->s_fs_info; | 645 | return proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer, |
654 | 646 | buflen); | |
655 | proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt), O_RDONLY); | ||
656 | if (IS_ERR(proc_file)) | ||
657 | return PTR_ERR(proc_file); | ||
658 | |||
659 | ret = proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer, buflen); | ||
660 | |||
661 | fput(proc_file); | ||
662 | |||
663 | return ret; | ||
664 | } | 647 | } |
665 | 648 | ||
666 | static void* hppfs_follow_link(struct dentry *dentry, struct nameidata *nd) | 649 | static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd) |
667 | { | 650 | { |
668 | struct file *proc_file; | ||
669 | struct dentry *proc_dentry; | 651 | struct dentry *proc_dentry; |
670 | struct vfsmount *proc_mnt; | ||
671 | void *ret; | ||
672 | 652 | ||
673 | proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; | 653 | proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; |
674 | proc_mnt = dentry->d_sb->s_fs_info; | ||
675 | |||
676 | proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt), O_RDONLY); | ||
677 | if (IS_ERR(proc_file)) | ||
678 | return proc_file; | ||
679 | |||
680 | ret = proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd); | ||
681 | 654 | ||
682 | fput(proc_file); | 655 | return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd); |
656 | } | ||
683 | 657 | ||
684 | return ret; | 658 | int hppfs_permission(struct inode *inode, int mask, struct nameidata *nd) |
659 | { | ||
660 | return generic_permission(inode, mask, NULL); | ||
685 | } | 661 | } |
686 | 662 | ||
687 | static const struct inode_operations hppfs_dir_iops = { | 663 | static const struct inode_operations hppfs_dir_iops = { |
688 | .lookup = hppfs_lookup, | 664 | .lookup = hppfs_lookup, |
665 | .permission = hppfs_permission, | ||
689 | }; | 666 | }; |
690 | 667 | ||
691 | static const struct inode_operations hppfs_link_iops = { | 668 | static const struct inode_operations hppfs_link_iops = { |
692 | .readlink = hppfs_readlink, | 669 | .readlink = hppfs_readlink, |
693 | .follow_link = hppfs_follow_link, | 670 | .follow_link = hppfs_follow_link, |
671 | .permission = hppfs_permission, | ||
694 | }; | 672 | }; |
695 | 673 | ||
696 | static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) | 674 | static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) |
@@ -712,7 +690,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) | |||
712 | inode->i_fop = &hppfs_file_fops; | 690 | inode->i_fop = &hppfs_file_fops; |
713 | } | 691 | } |
714 | 692 | ||
715 | HPPFS_I(inode)->proc_dentry = dentry; | 693 | HPPFS_I(inode)->proc_dentry = dget(dentry); |
716 | 694 | ||
717 | inode->i_uid = proc_ino->i_uid; | 695 | inode->i_uid = proc_ino->i_uid; |
718 | inode->i_gid = proc_ino->i_gid; | 696 | inode->i_gid = proc_ino->i_gid; |
@@ -725,7 +703,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) | |||
725 | inode->i_size = proc_ino->i_size; | 703 | inode->i_size = proc_ino->i_size; |
726 | inode->i_blocks = proc_ino->i_blocks; | 704 | inode->i_blocks = proc_ino->i_blocks; |
727 | 705 | ||
728 | return 0; | 706 | return inode; |
729 | } | 707 | } |
730 | 708 | ||
731 | static int hppfs_fill_super(struct super_block *sb, void *d, int silent) | 709 | static int hppfs_fill_super(struct super_block *sb, void *d, int silent) |
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 53632e3e8457..2e24567c4a79 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -901,7 +901,7 @@ static void jbd2_stats_proc_init(journal_t *journal) | |||
901 | { | 901 | { |
902 | char name[BDEVNAME_SIZE]; | 902 | char name[BDEVNAME_SIZE]; |
903 | 903 | ||
904 | snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); | 904 | bdevname(journal->j_dev, name); |
905 | journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats); | 905 | journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats); |
906 | if (journal->j_proc_entry) { | 906 | if (journal->j_proc_entry) { |
907 | proc_create_data("history", S_IRUGO, journal->j_proc_entry, | 907 | proc_create_data("history", S_IRUGO, journal->j_proc_entry, |
@@ -915,7 +915,7 @@ static void jbd2_stats_proc_exit(journal_t *journal) | |||
915 | { | 915 | { |
916 | char name[BDEVNAME_SIZE]; | 916 | char name[BDEVNAME_SIZE]; |
917 | 917 | ||
918 | snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); | 918 | bdevname(journal->j_dev, name); |
919 | remove_proc_entry("info", journal->j_proc_entry); | 919 | remove_proc_entry("info", journal->j_proc_entry); |
920 | remove_proc_entry("history", journal->j_proc_entry); | 920 | remove_proc_entry("history", journal->j_proc_entry); |
921 | remove_proc_entry(name, proc_jbd2_stats); | 921 | remove_proc_entry(name, proc_jbd2_stats); |
diff --git a/fs/proc/array.c b/fs/proc/array.c index dca997a93bff..9e3b8c33c24b 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -298,6 +298,7 @@ static inline void task_cap(struct seq_file *m, struct task_struct *p) | |||
298 | render_cap_t(m, "CapInh:\t", &p->cap_inheritable); | 298 | render_cap_t(m, "CapInh:\t", &p->cap_inheritable); |
299 | render_cap_t(m, "CapPrm:\t", &p->cap_permitted); | 299 | render_cap_t(m, "CapPrm:\t", &p->cap_permitted); |
300 | render_cap_t(m, "CapEff:\t", &p->cap_effective); | 300 | render_cap_t(m, "CapEff:\t", &p->cap_effective); |
301 | render_cap_t(m, "CapBnd:\t", &p->cap_bset); | ||
301 | } | 302 | } |
302 | 303 | ||
303 | static inline void task_context_switch_counts(struct seq_file *m, | 304 | static inline void task_context_switch_counts(struct seq_file *m, |
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 244a1aaa940e..11c035168ea6 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h | |||
@@ -107,7 +107,6 @@ extern struct inode * ufs_new_inode (struct inode *, int); | |||
107 | 107 | ||
108 | /* inode.c */ | 108 | /* inode.c */ |
109 | extern struct inode *ufs_iget(struct super_block *, unsigned long); | 109 | extern struct inode *ufs_iget(struct super_block *, unsigned long); |
110 | extern void ufs_put_inode (struct inode *); | ||
111 | extern int ufs_write_inode (struct inode *, int); | 110 | extern int ufs_write_inode (struct inode *, int); |
112 | extern int ufs_sync_inode (struct inode *); | 111 | extern int ufs_sync_inode (struct inode *); |
113 | extern void ufs_delete_inode (struct inode *); | 112 | extern void ufs_delete_inode (struct inode *); |
diff --git a/include/asm-alpha/barrier.h b/include/asm-alpha/barrier.h index 384dc08d6f53..ac78eba909bc 100644 --- a/include/asm-alpha/barrier.h +++ b/include/asm-alpha/barrier.h | |||
@@ -24,7 +24,7 @@ __asm__ __volatile__("mb": : :"memory") | |||
24 | #define smp_mb() barrier() | 24 | #define smp_mb() barrier() |
25 | #define smp_rmb() barrier() | 25 | #define smp_rmb() barrier() |
26 | #define smp_wmb() barrier() | 26 | #define smp_wmb() barrier() |
27 | #define smp_read_barrier_depends() barrier() | 27 | #define smp_read_barrier_depends() do { } while (0) |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #define set_mb(var, value) \ | 30 | #define set_mb(var, value) \ |
diff --git a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h index 05ce5fba43e3..3f0c59f6d8aa 100644 --- a/include/asm-alpha/pgtable.h +++ b/include/asm-alpha/pgtable.h | |||
@@ -287,17 +287,34 @@ extern inline pte_t pte_mkspecial(pte_t pte) { return pte; } | |||
287 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) | 287 | #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) |
288 | #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) | 288 | #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) |
289 | 289 | ||
290 | /* | ||
291 | * The smp_read_barrier_depends() in the following functions are required to | ||
292 | * order the load of *dir (the pointer in the top level page table) with any | ||
293 | * subsequent load of the returned pmd_t *ret (ret is data dependent on *dir). | ||
294 | * | ||
295 | * If this ordering is not enforced, the CPU might load an older value of | ||
296 | * *ret, which may be uninitialized data. See mm/memory.c:__pte_alloc for | ||
297 | * more details. | ||
298 | * | ||
299 | * Note that we never change the mm->pgd pointer after the task is running, so | ||
300 | * pgd_offset does not require such a barrier. | ||
301 | */ | ||
302 | |||
290 | /* Find an entry in the second-level page table.. */ | 303 | /* Find an entry in the second-level page table.. */ |
291 | extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address) | 304 | extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address) |
292 | { | 305 | { |
293 | return (pmd_t *) pgd_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1)); | 306 | pmd_t *ret = (pmd_t *) pgd_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1)); |
307 | smp_read_barrier_depends(); /* see above */ | ||
308 | return ret; | ||
294 | } | 309 | } |
295 | 310 | ||
296 | /* Find an entry in the third-level page table.. */ | 311 | /* Find an entry in the third-level page table.. */ |
297 | extern inline pte_t * pte_offset_kernel(pmd_t * dir, unsigned long address) | 312 | extern inline pte_t * pte_offset_kernel(pmd_t * dir, unsigned long address) |
298 | { | 313 | { |
299 | return (pte_t *) pmd_page_vaddr(*dir) | 314 | pte_t *ret = (pte_t *) pmd_page_vaddr(*dir) |
300 | + ((address >> PAGE_SHIFT) & (PTRS_PER_PAGE - 1)); | 315 | + ((address >> PAGE_SHIFT) & (PTRS_PER_PAGE - 1)); |
316 | smp_read_barrier_depends(); /* see above */ | ||
317 | return ret; | ||
301 | } | 318 | } |
302 | 319 | ||
303 | #define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr)) | 320 | #define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr)) |
diff --git a/include/asm-frv/system.h b/include/asm-frv/system.h index cb307f8a6b48..d3a12a9079f7 100644 --- a/include/asm-frv/system.h +++ b/include/asm-frv/system.h | |||
@@ -179,7 +179,7 @@ do { \ | |||
179 | #define mb() asm volatile ("membar" : : :"memory") | 179 | #define mb() asm volatile ("membar" : : :"memory") |
180 | #define rmb() asm volatile ("membar" : : :"memory") | 180 | #define rmb() asm volatile ("membar" : : :"memory") |
181 | #define wmb() asm volatile ("membar" : : :"memory") | 181 | #define wmb() asm volatile ("membar" : : :"memory") |
182 | #define read_barrier_depends() barrier() | 182 | #define read_barrier_depends() do { } while (0) |
183 | 183 | ||
184 | #ifdef CONFIG_SMP | 184 | #ifdef CONFIG_SMP |
185 | #define smp_mb() mb() | 185 | #define smp_mb() mb() |
diff --git a/include/asm-um/irq.h b/include/asm-um/irq.h index de389a477cdd..4a2037f8204b 100644 --- a/include/asm-um/irq.h +++ b/include/asm-um/irq.h | |||
@@ -15,8 +15,9 @@ | |||
15 | #define SIGIO_WRITE_IRQ 11 | 15 | #define SIGIO_WRITE_IRQ 11 |
16 | #define TELNETD_IRQ 12 | 16 | #define TELNETD_IRQ 12 |
17 | #define XTERM_IRQ 13 | 17 | #define XTERM_IRQ 13 |
18 | #define RANDOM_IRQ 14 | ||
18 | 19 | ||
19 | #define LAST_IRQ XTERM_IRQ | 20 | #define LAST_IRQ RANDOM_IRQ |
20 | #define NR_IRQS (LAST_IRQ + 1) | 21 | #define NR_IRQS (LAST_IRQ + 1) |
21 | 22 | ||
22 | #endif | 23 | #endif |
diff --git a/include/asm-um/keyboard.h b/include/asm-um/keyboard.h deleted file mode 100644 index ee2e2303d0e4..000000000000 --- a/include/asm-um/keyboard.h +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #ifndef __UM_KEYBOARD_H | ||
2 | #define __UM_KEYBOARD_H | ||
3 | |||
4 | #include "asm/arch/keyboard.h" | ||
5 | |||
6 | #endif | ||
diff --git a/include/asm-um/page.h b/include/asm-um/page.h index 381f96b1c825..916e1a61999f 100644 --- a/include/asm-um/page.h +++ b/include/asm-um/page.h | |||
@@ -7,16 +7,20 @@ | |||
7 | #ifndef __UM_PAGE_H | 7 | #ifndef __UM_PAGE_H |
8 | #define __UM_PAGE_H | 8 | #define __UM_PAGE_H |
9 | 9 | ||
10 | struct page; | 10 | #include <linux/const.h> |
11 | |||
12 | #include <linux/types.h> | ||
13 | #include <asm/vm-flags.h> | ||
14 | 11 | ||
15 | /* PAGE_SHIFT determines the page size */ | 12 | /* PAGE_SHIFT determines the page size */ |
16 | #define PAGE_SHIFT 12 | 13 | #define PAGE_SHIFT 12 |
17 | #define PAGE_SIZE (1UL << PAGE_SHIFT) | 14 | #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) |
18 | #define PAGE_MASK (~(PAGE_SIZE-1)) | 15 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
19 | 16 | ||
17 | #ifndef __ASSEMBLY__ | ||
18 | |||
19 | struct page; | ||
20 | |||
21 | #include <linux/types.h> | ||
22 | #include <asm/vm-flags.h> | ||
23 | |||
20 | /* | 24 | /* |
21 | * These are used to make use of C type-checking.. | 25 | * These are used to make use of C type-checking.. |
22 | */ | 26 | */ |
@@ -120,4 +124,5 @@ extern struct page *arch_validate(struct page *page, gfp_t mask, int order); | |||
120 | #include <asm-generic/memory_model.h> | 124 | #include <asm-generic/memory_model.h> |
121 | #include <asm-generic/page.h> | 125 | #include <asm-generic/page.h> |
122 | 126 | ||
123 | #endif | 127 | #endif /* __ASSEMBLY__ */ |
128 | #endif /* __UM_PAGE_H */ | ||
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 43b406def35f..1abfe664c444 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -110,7 +110,6 @@ extern int __bitmap_weight(const unsigned long *bitmap, int bits); | |||
110 | 110 | ||
111 | extern int bitmap_scnprintf(char *buf, unsigned int len, | 111 | extern int bitmap_scnprintf(char *buf, unsigned int len, |
112 | const unsigned long *src, int nbits); | 112 | const unsigned long *src, int nbits); |
113 | extern int bitmap_scnprintf_len(unsigned int len); | ||
114 | extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, | 113 | extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, |
115 | unsigned long *dst, int nbits); | 114 | unsigned long *dst, int nbits); |
116 | extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, | 115 | extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, |
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 9650806fe2ea..5df3db58fcc6 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -289,13 +289,6 @@ static inline int __cpumask_scnprintf(char *buf, int len, | |||
289 | return bitmap_scnprintf(buf, len, srcp->bits, nbits); | 289 | return bitmap_scnprintf(buf, len, srcp->bits, nbits); |
290 | } | 290 | } |
291 | 291 | ||
292 | #define cpumask_scnprintf_len(len) \ | ||
293 | __cpumask_scnprintf_len((len)) | ||
294 | static inline int __cpumask_scnprintf_len(int len) | ||
295 | { | ||
296 | return bitmap_scnprintf_len(len); | ||
297 | } | ||
298 | |||
299 | #define cpumask_parse_user(ubuf, ulen, dst) \ | 292 | #define cpumask_parse_user(ubuf, ulen, dst) \ |
300 | __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS) | 293 | __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS) |
301 | static inline int __cpumask_parse_user(const char __user *buf, int len, | 294 | static inline int __cpumask_parse_user(const char __user *buf, int len, |
diff --git a/include/linux/device.h b/include/linux/device.h index 8c23e3dfe3ac..15e9fa3ad3af 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -183,7 +183,6 @@ struct class { | |||
183 | struct module *owner; | 183 | struct module *owner; |
184 | 184 | ||
185 | struct kset subsys; | 185 | struct kset subsys; |
186 | struct list_head children; | ||
187 | struct list_head devices; | 186 | struct list_head devices; |
188 | struct list_head interfaces; | 187 | struct list_head interfaces; |
189 | struct kset class_dirs; | 188 | struct kset class_dirs; |
diff --git a/include/linux/fuse.h b/include/linux/fuse.h index 5c86f1196c3a..d48282197696 100644 --- a/include/linux/fuse.h +++ b/include/linux/fuse.h | |||
@@ -109,6 +109,7 @@ struct fuse_file_lock { | |||
109 | #define FUSE_POSIX_LOCKS (1 << 1) | 109 | #define FUSE_POSIX_LOCKS (1 << 1) |
110 | #define FUSE_FILE_OPS (1 << 2) | 110 | #define FUSE_FILE_OPS (1 << 2) |
111 | #define FUSE_ATOMIC_O_TRUNC (1 << 3) | 111 | #define FUSE_ATOMIC_O_TRUNC (1 << 3) |
112 | #define FUSE_BIG_WRITES (1 << 5) | ||
112 | 113 | ||
113 | /** | 114 | /** |
114 | * Release flags | 115 | * Release flags |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index e9874e7fcdf9..ae7aec3cabee 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -525,7 +525,7 @@ struct unixware_disklabel { | |||
525 | #define ADDPART_FLAG_RAID 1 | 525 | #define ADDPART_FLAG_RAID 1 |
526 | #define ADDPART_FLAG_WHOLEDISK 2 | 526 | #define ADDPART_FLAG_WHOLEDISK 2 |
527 | 527 | ||
528 | extern dev_t blk_lookup_devt(const char *name); | 528 | extern dev_t blk_lookup_devt(const char *name, int part); |
529 | extern char *disk_name (struct gendisk *hd, int part, char *buf); | 529 | extern char *disk_name (struct gendisk *hd, int part, char *buf); |
530 | 530 | ||
531 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | 531 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
@@ -553,7 +553,7 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index) | |||
553 | 553 | ||
554 | static inline void printk_all_partitions(void) { } | 554 | static inline void printk_all_partitions(void) { } |
555 | 555 | ||
556 | static inline dev_t blk_lookup_devt(const char *name) | 556 | static inline dev_t blk_lookup_devt(const char *name, int part) |
557 | { | 557 | { |
558 | dev_t devt = MKDEV(0, 0); | 558 | dev_t devt = MKDEV(0, 0); |
559 | return devt; | 559 | return devt; |
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index eb7c16cc9559..02a27ae78539 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h | |||
@@ -226,8 +226,17 @@ struct mm_struct { | |||
226 | rwlock_t ioctx_list_lock; /* aio lock */ | 226 | rwlock_t ioctx_list_lock; /* aio lock */ |
227 | struct kioctx *ioctx_list; | 227 | struct kioctx *ioctx_list; |
228 | #ifdef CONFIG_MM_OWNER | 228 | #ifdef CONFIG_MM_OWNER |
229 | struct task_struct *owner; /* The thread group leader that */ | 229 | /* |
230 | /* owns the mm_struct. */ | 230 | * "owner" points to a task that is regarded as the canonical |
231 | * user/owner of this mm. All of the following must be true in | ||
232 | * order for it to be changed: | ||
233 | * | ||
234 | * current == mm->owner | ||
235 | * current->mm != mm | ||
236 | * new_owner->mm == mm | ||
237 | * new_owner->alloc_lock is held | ||
238 | */ | ||
239 | struct task_struct *owner; | ||
231 | #endif | 240 | #endif |
232 | 241 | ||
233 | #ifdef CONFIG_PROC_FS | 242 | #ifdef CONFIG_PROC_FS |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7c1d4466583b..b11e6e19e96c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -93,14 +93,16 @@ struct wireless_dev; | |||
93 | * used. | 93 | * used. |
94 | */ | 94 | */ |
95 | 95 | ||
96 | #if !defined(CONFIG_AX25) && !defined(CONFIG_AX25_MODULE) && !defined(CONFIG_TR) | 96 | #if defined(CONFIG_WLAN_80211) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) |
97 | #define LL_MAX_HEADER 32 | 97 | # if defined(CONFIG_MAC80211_MESH) |
98 | # define LL_MAX_HEADER 128 | ||
99 | # else | ||
100 | # define LL_MAX_HEADER 96 | ||
101 | # endif | ||
102 | #elif defined(CONFIG_TR) | ||
103 | # define LL_MAX_HEADER 48 | ||
98 | #else | 104 | #else |
99 | #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) | 105 | # define LL_MAX_HEADER 32 |
100 | #define LL_MAX_HEADER 96 | ||
101 | #else | ||
102 | #define LL_MAX_HEADER 48 | ||
103 | #endif | ||
104 | #endif | 106 | #endif |
105 | 107 | ||
106 | #if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \ | 108 | #if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \ |
@@ -244,11 +246,16 @@ struct hh_cache | |||
244 | * | 246 | * |
245 | * We could use other alignment values, but we must maintain the | 247 | * We could use other alignment values, but we must maintain the |
246 | * relationship HH alignment <= LL alignment. | 248 | * relationship HH alignment <= LL alignment. |
249 | * | ||
250 | * LL_ALLOCATED_SPACE also takes into account the tailroom the device | ||
251 | * may need. | ||
247 | */ | 252 | */ |
248 | #define LL_RESERVED_SPACE(dev) \ | 253 | #define LL_RESERVED_SPACE(dev) \ |
249 | (((dev)->hard_header_len&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) | 254 | ((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) |
250 | #define LL_RESERVED_SPACE_EXTRA(dev,extra) \ | 255 | #define LL_RESERVED_SPACE_EXTRA(dev,extra) \ |
251 | ((((dev)->hard_header_len+extra)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) | 256 | ((((dev)->hard_header_len+(dev)->needed_headroom+(extra))&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) |
257 | #define LL_ALLOCATED_SPACE(dev) \ | ||
258 | ((((dev)->hard_header_len+(dev)->needed_headroom+(dev)->needed_tailroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) | ||
252 | 259 | ||
253 | struct header_ops { | 260 | struct header_ops { |
254 | int (*create) (struct sk_buff *skb, struct net_device *dev, | 261 | int (*create) (struct sk_buff *skb, struct net_device *dev, |
@@ -567,6 +574,13 @@ struct net_device | |||
567 | unsigned short type; /* interface hardware type */ | 574 | unsigned short type; /* interface hardware type */ |
568 | unsigned short hard_header_len; /* hardware hdr length */ | 575 | unsigned short hard_header_len; /* hardware hdr length */ |
569 | 576 | ||
577 | /* extra head- and tailroom the hardware may need, but not in all cases | ||
578 | * can this be guaranteed, especially tailroom. Some cases also use | ||
579 | * LL_MAX_HEADER instead to allocate the skb. | ||
580 | */ | ||
581 | unsigned short needed_headroom; | ||
582 | unsigned short needed_tailroom; | ||
583 | |||
570 | struct net_device *master; /* Pointer to master device of a group, | 584 | struct net_device *master; /* Pointer to master device of a group, |
571 | * which this device is member of. | 585 | * which this device is member of. |
572 | */ | 586 | */ |
@@ -715,6 +729,9 @@ struct net_device | |||
715 | struct net *nd_net; | 729 | struct net *nd_net; |
716 | #endif | 730 | #endif |
717 | 731 | ||
732 | /* mid-layer private */ | ||
733 | void *ml_priv; | ||
734 | |||
718 | /* bridge stuff */ | 735 | /* bridge stuff */ |
719 | struct net_bridge_port *br_port; | 736 | struct net_bridge_port *br_port; |
720 | /* macvlan */ | 737 | /* macvlan */ |
diff --git a/include/linux/usb/association.h b/include/linux/usb/association.h new file mode 100644 index 000000000000..07c5e3cf5898 --- /dev/null +++ b/include/linux/usb/association.h | |||
@@ -0,0 +1,150 @@ | |||
1 | /* | ||
2 | * Wireless USB - Cable Based Association | ||
3 | * | ||
4 | * Copyright (C) 2006 Intel Corporation | ||
5 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License version | ||
9 | * 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | #ifndef __LINUX_USB_ASSOCIATION_H | ||
13 | #define __LINUX_USB_ASSOCIATION_H | ||
14 | |||
15 | |||
16 | /* | ||
17 | * Association attributes | ||
18 | * | ||
19 | * Association Models Supplement to WUSB 1.0 T[3-1] | ||
20 | * | ||
21 | * Each field in the structures has it's ID, it's length and then the | ||
22 | * value. This is the actual definition of the field's ID and its | ||
23 | * length. | ||
24 | */ | ||
25 | struct wusb_am_attr { | ||
26 | __u8 id; | ||
27 | __u8 len; | ||
28 | }; | ||
29 | |||
30 | /* Different fields defined by the spec */ | ||
31 | #define WUSB_AR_AssociationTypeId { .id = 0x0000, .len = 2 } | ||
32 | #define WUSB_AR_AssociationSubTypeId { .id = 0x0001, .len = 2 } | ||
33 | #define WUSB_AR_Length { .id = 0x0002, .len = 4 } | ||
34 | #define WUSB_AR_AssociationStatus { .id = 0x0004, .len = 4 } | ||
35 | #define WUSB_AR_LangID { .id = 0x0008, .len = 2 } | ||
36 | #define WUSB_AR_DeviceFriendlyName { .id = 0x000b, .len = 64 } /* max */ | ||
37 | #define WUSB_AR_HostFriendlyName { .id = 0x000c, .len = 64 } /* max */ | ||
38 | #define WUSB_AR_CHID { .id = 0x1000, .len = 16 } | ||
39 | #define WUSB_AR_CDID { .id = 0x1001, .len = 16 } | ||
40 | #define WUSB_AR_ConnectionContext { .id = 0x1002, .len = 48 } | ||
41 | #define WUSB_AR_BandGroups { .id = 0x1004, .len = 2 } | ||
42 | |||
43 | /* CBAF Control Requests (AMS1.0[T4-1] */ | ||
44 | enum { | ||
45 | CBAF_REQ_GET_ASSOCIATION_INFORMATION = 0x01, | ||
46 | CBAF_REQ_GET_ASSOCIATION_REQUEST, | ||
47 | CBAF_REQ_SET_ASSOCIATION_RESPONSE | ||
48 | }; | ||
49 | |||
50 | /* | ||
51 | * CBAF USB-interface defitions | ||
52 | * | ||
53 | * No altsettings, one optional interrupt endpoint. | ||
54 | */ | ||
55 | enum { | ||
56 | CBAF_IFACECLASS = 0xef, | ||
57 | CBAF_IFACESUBCLASS = 0x03, | ||
58 | CBAF_IFACEPROTOCOL = 0x01, | ||
59 | }; | ||
60 | |||
61 | /* Association Information (AMS1.0[T4-3]) */ | ||
62 | struct wusb_cbaf_assoc_info { | ||
63 | __le16 Length; | ||
64 | __u8 NumAssociationRequests; | ||
65 | __le16 Flags; | ||
66 | __u8 AssociationRequestsArray[]; | ||
67 | } __attribute__((packed)); | ||
68 | |||
69 | /* Association Request (AMS1.0[T4-4]) */ | ||
70 | struct wusb_cbaf_assoc_request { | ||
71 | __u8 AssociationDataIndex; | ||
72 | __u8 Reserved; | ||
73 | __le16 AssociationTypeId; | ||
74 | __le16 AssociationSubTypeId; | ||
75 | __le32 AssociationTypeInfoSize; | ||
76 | } __attribute__((packed)); | ||
77 | |||
78 | enum { | ||
79 | AR_TYPE_WUSB = 0x0001, | ||
80 | AR_TYPE_WUSB_RETRIEVE_HOST_INFO = 0x0000, | ||
81 | AR_TYPE_WUSB_ASSOCIATE = 0x0001, | ||
82 | }; | ||
83 | |||
84 | /* Association Attribute header (AMS1.0[3.8]) */ | ||
85 | struct wusb_cbaf_attr_hdr { | ||
86 | __le16 id; | ||
87 | __le16 len; | ||
88 | } __attribute__((packed)); | ||
89 | |||
90 | /* Host Info (AMS1.0[T4-7]) (yeah, more headers and fields...) */ | ||
91 | struct wusb_cbaf_host_info { | ||
92 | struct wusb_cbaf_attr_hdr AssociationTypeId_hdr; | ||
93 | __le16 AssociationTypeId; | ||
94 | struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr; | ||
95 | __le16 AssociationSubTypeId; | ||
96 | struct wusb_cbaf_attr_hdr CHID_hdr; | ||
97 | struct wusb_ckhdid CHID; | ||
98 | struct wusb_cbaf_attr_hdr LangID_hdr; | ||
99 | __le16 LangID; | ||
100 | struct wusb_cbaf_attr_hdr HostFriendlyName_hdr; | ||
101 | __u8 HostFriendlyName[]; | ||
102 | } __attribute__((packed)); | ||
103 | |||
104 | /* Device Info (AMS1.0[T4-8]) | ||
105 | * | ||
106 | * I still don't get this tag'n'header stuff for each goddamn | ||
107 | * field... | ||
108 | */ | ||
109 | struct wusb_cbaf_device_info { | ||
110 | struct wusb_cbaf_attr_hdr Length_hdr; | ||
111 | __le32 Length; | ||
112 | struct wusb_cbaf_attr_hdr CDID_hdr; | ||
113 | struct wusb_ckhdid CDID; | ||
114 | struct wusb_cbaf_attr_hdr BandGroups_hdr; | ||
115 | __le16 BandGroups; | ||
116 | struct wusb_cbaf_attr_hdr LangID_hdr; | ||
117 | __le16 LangID; | ||
118 | struct wusb_cbaf_attr_hdr DeviceFriendlyName_hdr; | ||
119 | __u8 DeviceFriendlyName[]; | ||
120 | } __attribute__((packed)); | ||
121 | |||
122 | /* Connection Context; CC_DATA - Success case (AMS1.0[T4-9]) */ | ||
123 | struct wusb_cbaf_cc_data { | ||
124 | struct wusb_cbaf_attr_hdr AssociationTypeId_hdr; | ||
125 | __le16 AssociationTypeId; | ||
126 | struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr; | ||
127 | __le16 AssociationSubTypeId; | ||
128 | struct wusb_cbaf_attr_hdr Length_hdr; | ||
129 | __le32 Length; | ||
130 | struct wusb_cbaf_attr_hdr ConnectionContext_hdr; | ||
131 | struct wusb_ckhdid CHID; | ||
132 | struct wusb_ckhdid CDID; | ||
133 | struct wusb_ckhdid CK; | ||
134 | struct wusb_cbaf_attr_hdr BandGroups_hdr; | ||
135 | __le16 BandGroups; | ||
136 | } __attribute__((packed)); | ||
137 | |||
138 | /* CC_DATA - Failure case (AMS1.0[T4-10]) */ | ||
139 | struct wusb_cbaf_cc_data_fail { | ||
140 | struct wusb_cbaf_attr_hdr AssociationTypeId_hdr; | ||
141 | __le16 AssociationTypeId; | ||
142 | struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr; | ||
143 | __le16 AssociationSubTypeId; | ||
144 | struct wusb_cbaf_attr_hdr Length_hdr; | ||
145 | __le16 Length; | ||
146 | struct wusb_cbaf_attr_hdr AssociationStatus_hdr; | ||
147 | __u32 AssociationStatus; | ||
148 | } __attribute__((packed)); | ||
149 | |||
150 | #endif /* __LINUX_USB_ASSOCIATION_H */ | ||
diff --git a/include/net/irda/discovery.h b/include/net/irda/discovery.h index e4efad1f9eff..0ce93398720d 100644 --- a/include/net/irda/discovery.h +++ b/include/net/irda/discovery.h | |||
@@ -57,9 +57,6 @@ typedef union { | |||
57 | __u8 byte[2]; | 57 | __u8 byte[2]; |
58 | } __u16_host_order; | 58 | } __u16_host_order; |
59 | 59 | ||
60 | /* Same purpose, different application */ | ||
61 | #define u16ho(array) (* ((__u16 *) array)) | ||
62 | |||
63 | /* Types of discovery */ | 60 | /* Types of discovery */ |
64 | typedef enum { | 61 | typedef enum { |
65 | DISCOVERY_LOG, /* What's in our discovery log */ | 62 | DISCOVERY_LOG, /* What's in our discovery log */ |
diff --git a/include/net/syncppp.h b/include/net/syncppp.h index 877efa434700..e43f4070d892 100644 --- a/include/net/syncppp.h +++ b/include/net/syncppp.h | |||
@@ -59,7 +59,7 @@ struct ppp_device | |||
59 | 59 | ||
60 | static inline struct sppp *sppp_of(struct net_device *dev) | 60 | static inline struct sppp *sppp_of(struct net_device *dev) |
61 | { | 61 | { |
62 | struct ppp_device **ppp = dev->priv; | 62 | struct ppp_device **ppp = dev->ml_priv; |
63 | BUG_ON((*ppp)->dev != dev); | 63 | BUG_ON((*ppp)->dev != dev); |
64 | return &(*ppp)->sppp; | 64 | return &(*ppp)->sppp; |
65 | } | 65 | } |
diff --git a/include/sound/soc.h b/include/sound/soc.h index e6ea6f750941..d3c8c033dff8 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -238,7 +238,7 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, | |||
238 | struct snd_ctl_elem_info *uinfo); | 238 | struct snd_ctl_elem_info *uinfo); |
239 | int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, | 239 | int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, |
240 | struct snd_ctl_elem_info *uinfo); | 240 | struct snd_ctl_elem_info *uinfo); |
241 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono | 241 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info |
242 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, | 242 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, |
243 | struct snd_ctl_elem_value *ucontrol); | 243 | struct snd_ctl_elem_value *ucontrol); |
244 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, | 244 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, |
diff --git a/init/do_mounts.c b/init/do_mounts.c index 3885e70e7759..660c1e50c91b 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c | |||
@@ -76,6 +76,7 @@ dev_t name_to_dev_t(char *name) | |||
76 | char s[32]; | 76 | char s[32]; |
77 | char *p; | 77 | char *p; |
78 | dev_t res = 0; | 78 | dev_t res = 0; |
79 | int part; | ||
79 | 80 | ||
80 | if (strncmp(name, "/dev/", 5) != 0) { | 81 | if (strncmp(name, "/dev/", 5) != 0) { |
81 | unsigned maj, min; | 82 | unsigned maj, min; |
@@ -106,7 +107,31 @@ dev_t name_to_dev_t(char *name) | |||
106 | for (p = s; *p; p++) | 107 | for (p = s; *p; p++) |
107 | if (*p == '/') | 108 | if (*p == '/') |
108 | *p = '!'; | 109 | *p = '!'; |
109 | res = blk_lookup_devt(s); | 110 | res = blk_lookup_devt(s, 0); |
111 | if (res) | ||
112 | goto done; | ||
113 | |||
114 | /* | ||
115 | * try non-existant, but valid partition, which may only exist | ||
116 | * after revalidating the disk, like partitioned md devices | ||
117 | */ | ||
118 | while (p > s && isdigit(p[-1])) | ||
119 | p--; | ||
120 | if (p == s || !*p || *p == '0') | ||
121 | goto fail; | ||
122 | |||
123 | /* try disk name without <part number> */ | ||
124 | part = simple_strtoul(p, NULL, 10); | ||
125 | *p = '\0'; | ||
126 | res = blk_lookup_devt(s, part); | ||
127 | if (res) | ||
128 | goto done; | ||
129 | |||
130 | /* try disk name without p<part number> */ | ||
131 | if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p') | ||
132 | goto fail; | ||
133 | p[-1] = '\0'; | ||
134 | res = blk_lookup_devt(s, part); | ||
110 | if (res) | 135 | if (res) |
111 | goto done; | 136 | goto done; |
112 | 137 | ||
diff --git a/init/main.c b/init/main.c index ddada7acf363..f406fefa626c 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -702,7 +702,6 @@ static void __init do_initcalls(void) | |||
702 | 702 | ||
703 | for (call = __initcall_start; call < __initcall_end; call++) { | 703 | for (call = __initcall_start; call < __initcall_end; call++) { |
704 | ktime_t t0, t1, delta; | 704 | ktime_t t0, t1, delta; |
705 | char *msg = NULL; | ||
706 | char msgbuf[40]; | 705 | char msgbuf[40]; |
707 | int result; | 706 | int result; |
708 | 707 | ||
@@ -724,22 +723,23 @@ static void __init do_initcalls(void) | |||
724 | (unsigned long long) delta.tv64 >> 20); | 723 | (unsigned long long) delta.tv64 >> 20); |
725 | } | 724 | } |
726 | 725 | ||
727 | if (result && result != -ENODEV && initcall_debug) { | 726 | msgbuf[0] = 0; |
728 | sprintf(msgbuf, "error code %d", result); | 727 | |
729 | msg = msgbuf; | 728 | if (result && result != -ENODEV && initcall_debug) |
730 | } | 729 | sprintf(msgbuf, "error code %d ", result); |
730 | |||
731 | if (preempt_count() != count) { | 731 | if (preempt_count() != count) { |
732 | msg = "preemption imbalance"; | 732 | strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf)); |
733 | preempt_count() = count; | 733 | preempt_count() = count; |
734 | } | 734 | } |
735 | if (irqs_disabled()) { | 735 | if (irqs_disabled()) { |
736 | msg = "disabled interrupts"; | 736 | strncat(msgbuf, "disabled interrupts ", sizeof(msgbuf)); |
737 | local_irq_enable(); | 737 | local_irq_enable(); |
738 | } | 738 | } |
739 | if (msg) { | 739 | if (msgbuf[0]) { |
740 | print_fn_descriptor_symbol(KERN_WARNING "initcall %s()", | 740 | print_fn_descriptor_symbol(KERN_WARNING "initcall %s()", |
741 | (unsigned long) *call); | 741 | (unsigned long) *call); |
742 | printk(" returned with %s\n", msg); | 742 | printk(" returned with %s\n", msgbuf); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
diff --git a/lib/bitmap.c b/lib/bitmap.c index c4cb48f77f0c..482df94ea21e 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -316,22 +316,6 @@ int bitmap_scnprintf(char *buf, unsigned int buflen, | |||
316 | EXPORT_SYMBOL(bitmap_scnprintf); | 316 | EXPORT_SYMBOL(bitmap_scnprintf); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | * bitmap_scnprintf_len - return buffer length needed to convert | ||
320 | * bitmap to an ASCII hex string. | ||
321 | * @len: number of bits to be converted | ||
322 | */ | ||
323 | int bitmap_scnprintf_len(unsigned int len) | ||
324 | { | ||
325 | /* we need 9 chars per word for 32 bit words (8 hexdigits + sep/null) */ | ||
326 | int bitslen = ALIGN(len, CHUNKSZ); | ||
327 | int wordlen = CHUNKSZ / 4; | ||
328 | int buflen = (bitslen / wordlen) * (wordlen + 1) * sizeof(char); | ||
329 | |||
330 | return buflen; | ||
331 | } | ||
332 | EXPORT_SYMBOL(bitmap_scnprintf_len); | ||
333 | |||
334 | /** | ||
335 | * __bitmap_parse - convert an ASCII hex string into a bitmap. | 319 | * __bitmap_parse - convert an ASCII hex string into a bitmap. |
336 | * @buf: pointer to buffer containing string. | 320 | * @buf: pointer to buffer containing string. |
337 | * @buflen: buffer size in bytes. If string is smaller than this | 321 | * @buflen: buffer size in bytes. If string is smaller than this |
diff --git a/mm/memory.c b/mm/memory.c index 48c122d42ed7..fb5608a120ed 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -311,6 +311,21 @@ int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address) | |||
311 | if (!new) | 311 | if (!new) |
312 | return -ENOMEM; | 312 | return -ENOMEM; |
313 | 313 | ||
314 | /* | ||
315 | * Ensure all pte setup (eg. pte page lock and page clearing) are | ||
316 | * visible before the pte is made visible to other CPUs by being | ||
317 | * put into page tables. | ||
318 | * | ||
319 | * The other side of the story is the pointer chasing in the page | ||
320 | * table walking code (when walking the page table without locking; | ||
321 | * ie. most of the time). Fortunately, these data accesses consist | ||
322 | * of a chain of data-dependent loads, meaning most CPUs (alpha | ||
323 | * being the notable exception) will already guarantee loads are | ||
324 | * seen in-order. See the alpha page table accessors for the | ||
325 | * smp_read_barrier_depends() barriers in page table walking code. | ||
326 | */ | ||
327 | smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */ | ||
328 | |||
314 | spin_lock(&mm->page_table_lock); | 329 | spin_lock(&mm->page_table_lock); |
315 | if (!pmd_present(*pmd)) { /* Has another populated it ? */ | 330 | if (!pmd_present(*pmd)) { /* Has another populated it ? */ |
316 | mm->nr_ptes++; | 331 | mm->nr_ptes++; |
@@ -329,6 +344,8 @@ int __pte_alloc_kernel(pmd_t *pmd, unsigned long address) | |||
329 | if (!new) | 344 | if (!new) |
330 | return -ENOMEM; | 345 | return -ENOMEM; |
331 | 346 | ||
347 | smp_wmb(); /* See comment in __pte_alloc */ | ||
348 | |||
332 | spin_lock(&init_mm.page_table_lock); | 349 | spin_lock(&init_mm.page_table_lock); |
333 | if (!pmd_present(*pmd)) { /* Has another populated it ? */ | 350 | if (!pmd_present(*pmd)) { /* Has another populated it ? */ |
334 | pmd_populate_kernel(&init_mm, pmd, new); | 351 | pmd_populate_kernel(&init_mm, pmd, new); |
@@ -2619,6 +2636,8 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address) | |||
2619 | if (!new) | 2636 | if (!new) |
2620 | return -ENOMEM; | 2637 | return -ENOMEM; |
2621 | 2638 | ||
2639 | smp_wmb(); /* See comment in __pte_alloc */ | ||
2640 | |||
2622 | spin_lock(&mm->page_table_lock); | 2641 | spin_lock(&mm->page_table_lock); |
2623 | if (pgd_present(*pgd)) /* Another has populated it */ | 2642 | if (pgd_present(*pgd)) /* Another has populated it */ |
2624 | pud_free(mm, new); | 2643 | pud_free(mm, new); |
@@ -2640,6 +2659,8 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) | |||
2640 | if (!new) | 2659 | if (!new) |
2641 | return -ENOMEM; | 2660 | return -ENOMEM; |
2642 | 2661 | ||
2662 | smp_wmb(); /* See comment in __pte_alloc */ | ||
2663 | |||
2643 | spin_lock(&mm->page_table_lock); | 2664 | spin_lock(&mm->page_table_lock); |
2644 | #ifndef __ARCH_HAS_4LEVEL_HACK | 2665 | #ifndef __ARCH_HAS_4LEVEL_HACK |
2645 | if (pud_present(*pud)) /* Another has populated it */ | 2666 | if (pud_present(*pud)) /* Another has populated it */ |
diff --git a/mm/pdflush.c b/mm/pdflush.c index 1c96cfc9e040..9d834aa4b979 100644 --- a/mm/pdflush.c +++ b/mm/pdflush.c | |||
@@ -207,7 +207,6 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0) | |||
207 | 207 | ||
208 | spin_lock_irqsave(&pdflush_lock, flags); | 208 | spin_lock_irqsave(&pdflush_lock, flags); |
209 | if (list_empty(&pdflush_list)) { | 209 | if (list_empty(&pdflush_list)) { |
210 | spin_unlock_irqrestore(&pdflush_lock, flags); | ||
211 | ret = -1; | 210 | ret = -1; |
212 | } else { | 211 | } else { |
213 | struct pdflush_work *pdf; | 212 | struct pdflush_work *pdf; |
@@ -219,8 +218,9 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0) | |||
219 | pdf->fn = fn; | 218 | pdf->fn = fn; |
220 | pdf->arg0 = arg0; | 219 | pdf->arg0 = arg0; |
221 | wake_up_process(pdf->who); | 220 | wake_up_process(pdf->who); |
222 | spin_unlock_irqrestore(&pdflush_lock, flags); | ||
223 | } | 221 | } |
222 | spin_unlock_irqrestore(&pdflush_lock, flags); | ||
223 | |||
224 | return ret; | 224 | return ret; |
225 | } | 225 | } |
226 | 226 | ||
diff --git a/mm/vmstat.c b/mm/vmstat.c index 1a32130b958c..db9eabb2c5b3 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -41,7 +41,9 @@ static void sum_vm_events(unsigned long *ret, cpumask_t *cpumask) | |||
41 | */ | 41 | */ |
42 | void all_vm_events(unsigned long *ret) | 42 | void all_vm_events(unsigned long *ret) |
43 | { | 43 | { |
44 | get_online_cpus(); | ||
44 | sum_vm_events(ret, &cpu_online_map); | 45 | sum_vm_events(ret, &cpu_online_map); |
46 | put_online_cpus(); | ||
45 | } | 47 | } |
46 | EXPORT_SYMBOL_GPL(all_vm_events); | 48 | EXPORT_SYMBOL_GPL(all_vm_events); |
47 | 49 | ||
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index b04d643fc3c7..8fb134da0346 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -419,7 +419,7 @@ static void arp_reply(struct sk_buff *skb) | |||
419 | return; | 419 | return; |
420 | 420 | ||
421 | size = arp_hdr_len(skb->dev); | 421 | size = arp_hdr_len(skb->dev); |
422 | send_skb = find_skb(np, size + LL_RESERVED_SPACE(np->dev), | 422 | send_skb = find_skb(np, size + LL_ALLOCATED_SPACE(np->dev), |
423 | LL_RESERVED_SPACE(np->dev)); | 423 | LL_RESERVED_SPACE(np->dev)); |
424 | 424 | ||
425 | if (!send_skb) | 425 | if (!send_skb) |
diff --git a/net/core/sock.c b/net/core/sock.c index fa76f04fa9c6..88094cb09c06 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -270,7 +270,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
270 | int err = 0; | 270 | int err = 0; |
271 | int skb_len; | 271 | int skb_len; |
272 | 272 | ||
273 | /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces | 273 | /* Cast sk->rcvbuf to unsigned... It's pointless, but reduces |
274 | number of warnings when compiling with -W --ANK | 274 | number of warnings when compiling with -W --ANK |
275 | */ | 275 | */ |
276 | if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= | 276 | if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= |
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 68d154480043..7c9bb13b1539 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -340,7 +340,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
340 | 340 | ||
341 | dev_hold(dev); | 341 | dev_hold(dev); |
342 | 342 | ||
343 | skb = sock_alloc_send_skb(sk, len+LL_RESERVED_SPACE(dev), | 343 | skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev), |
344 | msg->msg_flags & MSG_DONTWAIT, &err); | 344 | msg->msg_flags & MSG_DONTWAIT, &err); |
345 | if (skb==NULL) | 345 | if (skb==NULL) |
346 | goto out_unlock; | 346 | goto out_unlock; |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 68b72a7a1806..418862f1bf22 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -570,7 +570,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, | |||
570 | * Allocate a buffer | 570 | * Allocate a buffer |
571 | */ | 571 | */ |
572 | 572 | ||
573 | skb = alloc_skb(arp_hdr_len(dev) + LL_RESERVED_SPACE(dev), GFP_ATOMIC); | 573 | skb = alloc_skb(arp_hdr_len(dev) + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
574 | if (skb == NULL) | 574 | if (skb == NULL) |
575 | return NULL; | 575 | return NULL; |
576 | 576 | ||
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index 05afb576d935..2c0e4572cc90 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c | |||
@@ -338,7 +338,7 @@ static int cipso_v4_cache_check(const unsigned char *key, | |||
338 | return -ENOENT; | 338 | return -ENOENT; |
339 | 339 | ||
340 | hash = cipso_v4_map_cache_hash(key, key_len); | 340 | hash = cipso_v4_map_cache_hash(key, key_len); |
341 | bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1); | 341 | bkt = hash & (CIPSO_V4_CACHE_BUCKETS - 1); |
342 | spin_lock_bh(&cipso_v4_cache[bkt].lock); | 342 | spin_lock_bh(&cipso_v4_cache[bkt].lock); |
343 | list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) { | 343 | list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) { |
344 | if (entry->hash == hash && | 344 | if (entry->hash == hash && |
@@ -417,7 +417,7 @@ int cipso_v4_cache_add(const struct sk_buff *skb, | |||
417 | atomic_inc(&secattr->cache->refcount); | 417 | atomic_inc(&secattr->cache->refcount); |
418 | entry->lsm_data = secattr->cache; | 418 | entry->lsm_data = secattr->cache; |
419 | 419 | ||
420 | bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETBITS - 1); | 420 | bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETS - 1); |
421 | spin_lock_bh(&cipso_v4_cache[bkt].lock); | 421 | spin_lock_bh(&cipso_v4_cache[bkt].lock); |
422 | if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) { | 422 | if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) { |
423 | list_add(&entry->list, &cipso_v4_cache[bkt].list); | 423 | list_add(&entry->list, &cipso_v4_cache[bkt].list); |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 6250f4239b61..2769dc4a4c84 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -292,7 +292,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) | |||
292 | struct iphdr *pip; | 292 | struct iphdr *pip; |
293 | struct igmpv3_report *pig; | 293 | struct igmpv3_report *pig; |
294 | 294 | ||
295 | skb = alloc_skb(size + LL_RESERVED_SPACE(dev), GFP_ATOMIC); | 295 | skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
296 | if (skb == NULL) | 296 | if (skb == NULL) |
297 | return NULL; | 297 | return NULL; |
298 | 298 | ||
@@ -653,7 +653,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, | |||
653 | return -1; | 653 | return -1; |
654 | } | 654 | } |
655 | 655 | ||
656 | skb=alloc_skb(IGMP_SIZE+LL_RESERVED_SPACE(dev), GFP_ATOMIC); | 656 | skb=alloc_skb(IGMP_SIZE+LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
657 | if (skb == NULL) { | 657 | if (skb == NULL) { |
658 | ip_rt_put(rt); | 658 | ip_rt_put(rt); |
659 | return -1; | 659 | return -1; |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 89dee4346f60..ed45037ce9be 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -710,14 +710,14 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d | |||
710 | struct net_device *dev = d->dev; | 710 | struct net_device *dev = d->dev; |
711 | struct sk_buff *skb; | 711 | struct sk_buff *skb; |
712 | struct bootp_pkt *b; | 712 | struct bootp_pkt *b; |
713 | int hh_len = LL_RESERVED_SPACE(dev); | ||
714 | struct iphdr *h; | 713 | struct iphdr *h; |
715 | 714 | ||
716 | /* Allocate packet */ | 715 | /* Allocate packet */ |
717 | skb = alloc_skb(sizeof(struct bootp_pkt) + hh_len + 15, GFP_KERNEL); | 716 | skb = alloc_skb(sizeof(struct bootp_pkt) + LL_ALLOCATED_SPACE(dev) + 15, |
717 | GFP_KERNEL); | ||
718 | if (!skb) | 718 | if (!skb) |
719 | return; | 719 | return; |
720 | skb_reserve(skb, hh_len); | 720 | skb_reserve(skb, LL_RESERVED_SPACE(dev)); |
721 | b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt)); | 721 | b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt)); |
722 | memset(b, 0, sizeof(struct bootp_pkt)); | 722 | memset(b, 0, sizeof(struct bootp_pkt)); |
723 | 723 | ||
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 11d7f753a820..fead049daf43 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -322,7 +322,6 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, | |||
322 | unsigned int flags) | 322 | unsigned int flags) |
323 | { | 323 | { |
324 | struct inet_sock *inet = inet_sk(sk); | 324 | struct inet_sock *inet = inet_sk(sk); |
325 | int hh_len; | ||
326 | struct iphdr *iph; | 325 | struct iphdr *iph; |
327 | struct sk_buff *skb; | 326 | struct sk_buff *skb; |
328 | unsigned int iphlen; | 327 | unsigned int iphlen; |
@@ -336,13 +335,12 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, | |||
336 | if (flags&MSG_PROBE) | 335 | if (flags&MSG_PROBE) |
337 | goto out; | 336 | goto out; |
338 | 337 | ||
339 | hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); | 338 | skb = sock_alloc_send_skb(sk, |
340 | 339 | length + LL_ALLOCATED_SPACE(rt->u.dst.dev) + 15, | |
341 | skb = sock_alloc_send_skb(sk, length+hh_len+15, | 340 | flags & MSG_DONTWAIT, &err); |
342 | flags&MSG_DONTWAIT, &err); | ||
343 | if (skb == NULL) | 341 | if (skb == NULL) |
344 | goto error; | 342 | goto error; |
345 | skb_reserve(skb, hh_len); | 343 | skb_reserve(skb, LL_RESERVED_SPACE(rt->u.dst.dev)); |
346 | 344 | ||
347 | skb->priority = sk->sk_priority; | 345 | skb->priority = sk->sk_priority; |
348 | skb->mark = sk->sk_mark; | 346 | skb->mark = sk->sk_mark; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 26c936930e92..b54d9d37b636 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1842,9 +1842,16 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1842 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; | 1842 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; |
1843 | } | 1843 | } |
1844 | 1844 | ||
1845 | /* Don't lost mark skbs that were fwd transmitted after RTO */ | 1845 | /* Marking forward transmissions that were made after RTO lost |
1846 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED) && | 1846 | * can cause unnecessary retransmissions in some scenarios, |
1847 | !after(TCP_SKB_CB(skb)->end_seq, tp->frto_highmark)) { | 1847 | * SACK blocks will mitigate that in some but not in all cases. |
1848 | * We used to not mark them but it was causing break-ups with | ||
1849 | * receivers that do only in-order receival. | ||
1850 | * | ||
1851 | * TODO: we could detect presence of such receiver and select | ||
1852 | * different behavior per flow. | ||
1853 | */ | ||
1854 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) { | ||
1848 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; | 1855 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; |
1849 | tp->lost_out += tcp_skb_pcount(skb); | 1856 | tp->lost_out += tcp_skb_pcount(skb); |
1850 | } | 1857 | } |
@@ -1860,7 +1867,7 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag) | |||
1860 | tp->reordering = min_t(unsigned int, tp->reordering, | 1867 | tp->reordering = min_t(unsigned int, tp->reordering, |
1861 | sysctl_tcp_reordering); | 1868 | sysctl_tcp_reordering); |
1862 | tcp_set_ca_state(sk, TCP_CA_Loss); | 1869 | tcp_set_ca_state(sk, TCP_CA_Loss); |
1863 | tp->high_seq = tp->frto_highmark; | 1870 | tp->high_seq = tp->snd_nxt; |
1864 | TCP_ECN_queue_cwr(tp); | 1871 | TCP_ECN_queue_cwr(tp); |
1865 | 1872 | ||
1866 | tcp_clear_retrans_hints_partial(tp); | 1873 | tcp_clear_retrans_hints_partial(tp); |
@@ -2482,7 +2489,7 @@ static void tcp_try_to_open(struct sock *sk, int flag) | |||
2482 | 2489 | ||
2483 | tcp_verify_left_out(tp); | 2490 | tcp_verify_left_out(tp); |
2484 | 2491 | ||
2485 | if (tp->retrans_out == 0) | 2492 | if (!tp->frto_counter && tp->retrans_out == 0) |
2486 | tp->retrans_stamp = 0; | 2493 | tp->retrans_stamp = 0; |
2487 | 2494 | ||
2488 | if (flag & FLAG_ECE) | 2495 | if (flag & FLAG_ECE) |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 0af2e055f883..48cdce9c696c 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -780,7 +780,7 @@ slow_path: | |||
780 | * Allocate buffer. | 780 | * Allocate buffer. |
781 | */ | 781 | */ |
782 | 782 | ||
783 | if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_RESERVED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) { | 783 | if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_ALLOCATED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) { |
784 | NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n"); | 784 | NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n"); |
785 | IP6_INC_STATS(ip6_dst_idev(skb->dst), | 785 | IP6_INC_STATS(ip6_dst_idev(skb->dst), |
786 | IPSTATS_MIB_FRAGFAILS); | 786 | IPSTATS_MIB_FRAGFAILS); |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 54f91efdae58..fd632dd7f98d 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -1411,7 +1411,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size) | |||
1411 | IPV6_TLV_PADN, 0 }; | 1411 | IPV6_TLV_PADN, 0 }; |
1412 | 1412 | ||
1413 | /* we assume size > sizeof(ra) here */ | 1413 | /* we assume size > sizeof(ra) here */ |
1414 | skb = sock_alloc_send_skb(sk, size + LL_RESERVED_SPACE(dev), 1, &err); | 1414 | skb = sock_alloc_send_skb(sk, size + LL_ALLOCATED_SPACE(dev), 1, &err); |
1415 | 1415 | ||
1416 | if (!skb) | 1416 | if (!skb) |
1417 | return NULL; | 1417 | return NULL; |
@@ -1790,7 +1790,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) | |||
1790 | payload_len = len + sizeof(ra); | 1790 | payload_len = len + sizeof(ra); |
1791 | full_len = sizeof(struct ipv6hdr) + payload_len; | 1791 | full_len = sizeof(struct ipv6hdr) + payload_len; |
1792 | 1792 | ||
1793 | skb = sock_alloc_send_skb(sk, LL_RESERVED_SPACE(dev) + full_len, 1, &err); | 1793 | skb = sock_alloc_send_skb(sk, LL_ALLOCATED_SPACE(dev) + full_len, 1, &err); |
1794 | 1794 | ||
1795 | if (skb == NULL) { | 1795 | if (skb == NULL) { |
1796 | rcu_read_lock(); | 1796 | rcu_read_lock(); |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 2c74885f8355..a55fc05b8125 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -479,7 +479,7 @@ static void __ndisc_send(struct net_device *dev, | |||
479 | 479 | ||
480 | skb = sock_alloc_send_skb(sk, | 480 | skb = sock_alloc_send_skb(sk, |
481 | (MAX_HEADER + sizeof(struct ipv6hdr) + | 481 | (MAX_HEADER + sizeof(struct ipv6hdr) + |
482 | len + LL_RESERVED_SPACE(dev)), | 482 | len + LL_ALLOCATED_SPACE(dev)), |
483 | 1, &err); | 483 | 1, &err); |
484 | if (!skb) { | 484 | if (!skb) { |
485 | ND_PRINTK0(KERN_ERR | 485 | ND_PRINTK0(KERN_ERR |
@@ -1521,7 +1521,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, | |||
1521 | 1521 | ||
1522 | buff = sock_alloc_send_skb(sk, | 1522 | buff = sock_alloc_send_skb(sk, |
1523 | (MAX_HEADER + sizeof(struct ipv6hdr) + | 1523 | (MAX_HEADER + sizeof(struct ipv6hdr) + |
1524 | len + LL_RESERVED_SPACE(dev)), | 1524 | len + LL_ALLOCATED_SPACE(dev)), |
1525 | 1, &err); | 1525 | 1, &err); |
1526 | if (buff == NULL) { | 1526 | if (buff == NULL) { |
1527 | ND_PRINTK0(KERN_ERR | 1527 | ND_PRINTK0(KERN_ERR |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 396f0ea11090..232e0dc45bf5 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -609,7 +609,6 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, | |||
609 | struct ipv6_pinfo *np = inet6_sk(sk); | 609 | struct ipv6_pinfo *np = inet6_sk(sk); |
610 | struct ipv6hdr *iph; | 610 | struct ipv6hdr *iph; |
611 | struct sk_buff *skb; | 611 | struct sk_buff *skb; |
612 | unsigned int hh_len; | ||
613 | int err; | 612 | int err; |
614 | 613 | ||
615 | if (length > rt->u.dst.dev->mtu) { | 614 | if (length > rt->u.dst.dev->mtu) { |
@@ -619,13 +618,12 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, | |||
619 | if (flags&MSG_PROBE) | 618 | if (flags&MSG_PROBE) |
620 | goto out; | 619 | goto out; |
621 | 620 | ||
622 | hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); | 621 | skb = sock_alloc_send_skb(sk, |
623 | 622 | length + LL_ALLOCATED_SPACE(rt->u.dst.dev) + 15, | |
624 | skb = sock_alloc_send_skb(sk, length+hh_len+15, | 623 | flags & MSG_DONTWAIT, &err); |
625 | flags&MSG_DONTWAIT, &err); | ||
626 | if (skb == NULL) | 624 | if (skb == NULL) |
627 | goto error; | 625 | goto error; |
628 | skb_reserve(skb, hh_len); | 626 | skb_reserve(skb, LL_RESERVED_SPACE(rt->u.dst.dev)); |
629 | 627 | ||
630 | skb->priority = sk->sk_priority; | 628 | skb->priority = sk->sk_priority; |
631 | skb->mark = sk->sk_mark; | 629 | skb->mark = sk->sk_mark; |
diff --git a/net/irda/discovery.c b/net/irda/discovery.c index bfacef8b76f4..a6f99b5a1499 100644 --- a/net/irda/discovery.c +++ b/net/irda/discovery.c | |||
@@ -40,6 +40,8 @@ | |||
40 | 40 | ||
41 | #include <net/irda/discovery.h> | 41 | #include <net/irda/discovery.h> |
42 | 42 | ||
43 | #include <asm/unaligned.h> | ||
44 | |||
43 | /* | 45 | /* |
44 | * Function irlmp_add_discovery (cachelog, discovery) | 46 | * Function irlmp_add_discovery (cachelog, discovery) |
45 | * | 47 | * |
@@ -87,7 +89,7 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new) | |||
87 | */ | 89 | */ |
88 | hashbin_remove_this(cachelog, (irda_queue_t *) node); | 90 | hashbin_remove_this(cachelog, (irda_queue_t *) node); |
89 | /* Check if hints bits are unchanged */ | 91 | /* Check if hints bits are unchanged */ |
90 | if(u16ho(node->data.hints) == u16ho(new->data.hints)) | 92 | if (get_unaligned((__u16 *)node->data.hints) == get_unaligned((__u16 *)new->data.hints)) |
91 | /* Set time of first discovery for this node */ | 93 | /* Set time of first discovery for this node */ |
92 | new->firststamp = node->firststamp; | 94 | new->firststamp = node->firststamp; |
93 | kfree(node); | 95 | kfree(node); |
@@ -281,9 +283,9 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn, | |||
281 | /* Mask out the ones we don't want : | 283 | /* Mask out the ones we don't want : |
282 | * We want to match the discovery mask, and to get only | 284 | * We want to match the discovery mask, and to get only |
283 | * the most recent one (unless we want old ones) */ | 285 | * the most recent one (unless we want old ones) */ |
284 | if ((u16ho(discovery->data.hints) & mask) && | 286 | if ((get_unaligned((__u16 *)discovery->data.hints) & mask) && |
285 | ((old_entries) || | 287 | ((old_entries) || |
286 | ((jiffies - discovery->firststamp) < j_timeout)) ) { | 288 | ((jiffies - discovery->firststamp) < j_timeout))) { |
287 | /* Create buffer as needed. | 289 | /* Create buffer as needed. |
288 | * As this function get called a lot and most time | 290 | * As this function get called a lot and most time |
289 | * we don't have anything to put in the log (we are | 291 | * we don't have anything to put in the log (we are |
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c index 1f81f8e7c61d..7bf5b913828b 100644 --- a/net/irda/irlmp.c +++ b/net/irda/irlmp.c | |||
@@ -1062,7 +1062,8 @@ void irlmp_discovery_expiry(discinfo_t *expiries, int number) | |||
1062 | for(i = 0; i < number; i++) { | 1062 | for(i = 0; i < number; i++) { |
1063 | /* Check if we should notify client */ | 1063 | /* Check if we should notify client */ |
1064 | if ((client->expir_callback) && | 1064 | if ((client->expir_callback) && |
1065 | (client->hint_mask.word & u16ho(expiries[i].hints) | 1065 | (client->hint_mask.word & |
1066 | get_unaligned((__u16 *)expiries[i].hints) | ||
1066 | & 0x7f7f) ) | 1067 | & 0x7f7f) ) |
1067 | client->expir_callback(&(expiries[i]), | 1068 | client->expir_callback(&(expiries[i]), |
1068 | EXPIRY_TIMEOUT, | 1069 | EXPIRY_TIMEOUT, |
@@ -1086,7 +1087,7 @@ discovery_t *irlmp_get_discovery_response(void) | |||
1086 | 1087 | ||
1087 | IRDA_ASSERT(irlmp != NULL, return NULL;); | 1088 | IRDA_ASSERT(irlmp != NULL, return NULL;); |
1088 | 1089 | ||
1089 | u16ho(irlmp->discovery_rsp.data.hints) = irlmp->hints.word; | 1090 | put_unaligned(irlmp->hints.word, (__u16 *)irlmp->discovery_rsp.data.hints); |
1090 | 1091 | ||
1091 | /* | 1092 | /* |
1092 | * Set character set for device name (we use ASCII), and | 1093 | * Set character set for device name (we use ASCII), and |
diff --git a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c index 75497e55927d..a3ec0026cdb2 100644 --- a/net/irda/irnet/irnet_irda.c +++ b/net/irda/irnet/irnet_irda.c | |||
@@ -1673,7 +1673,7 @@ irnet_discovery_indication(discinfo_t * discovery, | |||
1673 | /* Notify the control channel */ | 1673 | /* Notify the control channel */ |
1674 | irnet_post_event(NULL, IRNET_DISCOVER, | 1674 | irnet_post_event(NULL, IRNET_DISCOVER, |
1675 | discovery->saddr, discovery->daddr, discovery->info, | 1675 | discovery->saddr, discovery->daddr, discovery->info, |
1676 | u16ho(discovery->hints)); | 1676 | get_unaligned((__u16 *)discovery->hints)); |
1677 | 1677 | ||
1678 | DEXIT(IRDA_OCB_TRACE, "\n"); | 1678 | DEXIT(IRDA_OCB_TRACE, "\n"); |
1679 | } | 1679 | } |
@@ -1704,7 +1704,7 @@ irnet_expiry_indication(discinfo_t * expiry, | |||
1704 | /* Notify the control channel */ | 1704 | /* Notify the control channel */ |
1705 | irnet_post_event(NULL, IRNET_EXPIRE, | 1705 | irnet_post_event(NULL, IRNET_EXPIRE, |
1706 | expiry->saddr, expiry->daddr, expiry->info, | 1706 | expiry->saddr, expiry->daddr, expiry->info, |
1707 | u16ho(expiry->hints)); | 1707 | get_unaligned((__u16 *)expiry->hints)); |
1708 | 1708 | ||
1709 | DEXIT(IRDA_OCB_TRACE, "\n"); | 1709 | DEXIT(IRDA_OCB_TRACE, "\n"); |
1710 | } | 1710 | } |
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c index 879e7210458a..19efc3a6a932 100644 --- a/net/mac80211/debugfs_key.c +++ b/net/mac80211/debugfs_key.c | |||
@@ -255,14 +255,23 @@ void ieee80211_debugfs_key_remove(struct ieee80211_key *key) | |||
255 | void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) | 255 | void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) |
256 | { | 256 | { |
257 | char buf[50]; | 257 | char buf[50]; |
258 | struct ieee80211_key *key; | ||
258 | 259 | ||
259 | if (!sdata->debugfsdir) | 260 | if (!sdata->debugfsdir) |
260 | return; | 261 | return; |
261 | 262 | ||
262 | sprintf(buf, "../keys/%d", sdata->default_key->debugfs.cnt); | 263 | /* this is running under the key lock */ |
263 | sdata->debugfs.default_key = | 264 | |
264 | debugfs_create_symlink("default_key", sdata->debugfsdir, buf); | 265 | key = sdata->default_key; |
266 | if (key) { | ||
267 | sprintf(buf, "../keys/%d", key->debugfs.cnt); | ||
268 | sdata->debugfs.default_key = | ||
269 | debugfs_create_symlink("default_key", | ||
270 | sdata->debugfsdir, buf); | ||
271 | } else | ||
272 | ieee80211_debugfs_key_remove_default(sdata); | ||
265 | } | 273 | } |
274 | |||
266 | void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) | 275 | void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) |
267 | { | 276 | { |
268 | if (!sdata) | 277 | if (!sdata) |
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 80954a512185..06e88a5a036d 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -54,6 +54,15 @@ int ieee80211_if_add(struct net_device *dev, const char *name, | |||
54 | if (!ndev) | 54 | if (!ndev) |
55 | return -ENOMEM; | 55 | return -ENOMEM; |
56 | 56 | ||
57 | ndev->needed_headroom = local->tx_headroom + | ||
58 | 4*6 /* four MAC addresses */ | ||
59 | + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */ | ||
60 | + 6 /* mesh */ | ||
61 | + 8 /* rfc1042/bridge tunnel */ | ||
62 | - ETH_HLEN /* ethernet hard_header_len */ | ||
63 | + IEEE80211_ENCRYPT_HEADROOM; | ||
64 | ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM; | ||
65 | |||
57 | ret = dev_alloc_name(ndev, ndev->name); | 66 | ret = dev_alloc_name(ndev, ndev->name); |
58 | if (ret < 0) | 67 | if (ret < 0) |
59 | goto fail; | 68 | goto fail; |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index f76bc26ae4d2..697ef67f96b6 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -397,7 +397,7 @@ int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, | |||
397 | put_unaligned(cpu_to_le32(sdata->u.sta.mesh_seqnum), &meshhdr->seqnum); | 397 | put_unaligned(cpu_to_le32(sdata->u.sta.mesh_seqnum), &meshhdr->seqnum); |
398 | sdata->u.sta.mesh_seqnum++; | 398 | sdata->u.sta.mesh_seqnum++; |
399 | 399 | ||
400 | return 5; | 400 | return 6; |
401 | } | 401 | } |
402 | 402 | ||
403 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) | 403 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) |
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 3df809222d1c..af0cd1e3e213 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -120,7 +120,7 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
120 | *pos++ = WLAN_EID_PREP; | 120 | *pos++ = WLAN_EID_PREP; |
121 | break; | 121 | break; |
122 | default: | 122 | default: |
123 | kfree(skb); | 123 | kfree_skb(skb); |
124 | return -ENOTSUPP; | 124 | return -ENOTSUPP; |
125 | break; | 125 | break; |
126 | } | 126 | } |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 5845dc21ce85..99c2d360888e 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -158,19 +158,25 @@ int mesh_path_add(u8 *dst, struct net_device *dev) | |||
158 | if (atomic_add_unless(&sdata->u.sta.mpaths, 1, MESH_MAX_MPATHS) == 0) | 158 | if (atomic_add_unless(&sdata->u.sta.mpaths, 1, MESH_MAX_MPATHS) == 0) |
159 | return -ENOSPC; | 159 | return -ENOSPC; |
160 | 160 | ||
161 | read_lock(&pathtbl_resize_lock); | ||
162 | |||
163 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL); | 161 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL); |
164 | if (!new_mpath) { | 162 | if (!new_mpath) { |
165 | atomic_dec(&sdata->u.sta.mpaths); | 163 | atomic_dec(&sdata->u.sta.mpaths); |
166 | err = -ENOMEM; | 164 | err = -ENOMEM; |
167 | goto endadd2; | 165 | goto endadd2; |
168 | } | 166 | } |
167 | new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL); | ||
168 | if (!new_node) { | ||
169 | kfree(new_mpath); | ||
170 | atomic_dec(&sdata->u.sta.mpaths); | ||
171 | err = -ENOMEM; | ||
172 | goto endadd2; | ||
173 | } | ||
174 | |||
175 | read_lock(&pathtbl_resize_lock); | ||
169 | memcpy(new_mpath->dst, dst, ETH_ALEN); | 176 | memcpy(new_mpath->dst, dst, ETH_ALEN); |
170 | new_mpath->dev = dev; | 177 | new_mpath->dev = dev; |
171 | new_mpath->flags = 0; | 178 | new_mpath->flags = 0; |
172 | skb_queue_head_init(&new_mpath->frame_queue); | 179 | skb_queue_head_init(&new_mpath->frame_queue); |
173 | new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL); | ||
174 | new_node->mpath = new_mpath; | 180 | new_node->mpath = new_mpath; |
175 | new_mpath->timer.data = (unsigned long) new_mpath; | 181 | new_mpath->timer.data = (unsigned long) new_mpath; |
176 | new_mpath->timer.function = mesh_path_timer; | 182 | new_mpath->timer.function = mesh_path_timer; |
@@ -202,7 +208,6 @@ int mesh_path_add(u8 *dst, struct net_device *dev) | |||
202 | 208 | ||
203 | endadd: | 209 | endadd: |
204 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); | 210 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); |
205 | endadd2: | ||
206 | read_unlock(&pathtbl_resize_lock); | 211 | read_unlock(&pathtbl_resize_lock); |
207 | if (!err && grow) { | 212 | if (!err && grow) { |
208 | struct mesh_table *oldtbl, *newtbl; | 213 | struct mesh_table *oldtbl, *newtbl; |
@@ -215,10 +220,12 @@ endadd2: | |||
215 | return -ENOMEM; | 220 | return -ENOMEM; |
216 | } | 221 | } |
217 | rcu_assign_pointer(mesh_paths, newtbl); | 222 | rcu_assign_pointer(mesh_paths, newtbl); |
223 | write_unlock(&pathtbl_resize_lock); | ||
224 | |||
218 | synchronize_rcu(); | 225 | synchronize_rcu(); |
219 | mesh_table_free(oldtbl, false); | 226 | mesh_table_free(oldtbl, false); |
220 | write_unlock(&pathtbl_resize_lock); | ||
221 | } | 227 | } |
228 | endadd2: | ||
222 | return err; | 229 | return err; |
223 | } | 230 | } |
224 | 231 | ||
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index a5e5c31c23ab..4adba09e80ca 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -665,6 +665,26 @@ static void ieee80211_authenticate(struct net_device *dev, | |||
665 | mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); | 665 | mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); |
666 | } | 666 | } |
667 | 667 | ||
668 | static int ieee80211_compatible_rates(struct ieee80211_sta_bss *bss, | ||
669 | struct ieee80211_supported_band *sband, | ||
670 | u64 *rates) | ||
671 | { | ||
672 | int i, j, count; | ||
673 | *rates = 0; | ||
674 | count = 0; | ||
675 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
676 | int rate = (bss->supp_rates[i] & 0x7F) * 5; | ||
677 | |||
678 | for (j = 0; j < sband->n_bitrates; j++) | ||
679 | if (sband->bitrates[j].bitrate == rate) { | ||
680 | *rates |= BIT(j); | ||
681 | count++; | ||
682 | break; | ||
683 | } | ||
684 | } | ||
685 | |||
686 | return count; | ||
687 | } | ||
668 | 688 | ||
669 | static void ieee80211_send_assoc(struct net_device *dev, | 689 | static void ieee80211_send_assoc(struct net_device *dev, |
670 | struct ieee80211_if_sta *ifsta) | 690 | struct ieee80211_if_sta *ifsta) |
@@ -673,11 +693,12 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
673 | struct sk_buff *skb; | 693 | struct sk_buff *skb; |
674 | struct ieee80211_mgmt *mgmt; | 694 | struct ieee80211_mgmt *mgmt; |
675 | u8 *pos, *ies; | 695 | u8 *pos, *ies; |
676 | int i, len; | 696 | int i, len, count, rates_len, supp_rates_len; |
677 | u16 capab; | 697 | u16 capab; |
678 | struct ieee80211_sta_bss *bss; | 698 | struct ieee80211_sta_bss *bss; |
679 | int wmm = 0; | 699 | int wmm = 0; |
680 | struct ieee80211_supported_band *sband; | 700 | struct ieee80211_supported_band *sband; |
701 | u64 rates = 0; | ||
681 | 702 | ||
682 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | 703 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
683 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + | 704 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + |
@@ -740,24 +761,39 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
740 | *pos++ = ifsta->ssid_len; | 761 | *pos++ = ifsta->ssid_len; |
741 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | 762 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); |
742 | 763 | ||
764 | /* all supported rates should be added here but some APs | ||
765 | * (e.g. D-Link DAP 1353 in b-only mode) don't like that | ||
766 | * Therefore only add rates the AP supports */ | ||
767 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); | ||
768 | supp_rates_len = rates_len; | ||
769 | if (supp_rates_len > 8) | ||
770 | supp_rates_len = 8; | ||
771 | |||
743 | len = sband->n_bitrates; | 772 | len = sband->n_bitrates; |
744 | if (len > 8) | 773 | pos = skb_put(skb, supp_rates_len + 2); |
745 | len = 8; | ||
746 | pos = skb_put(skb, len + 2); | ||
747 | *pos++ = WLAN_EID_SUPP_RATES; | 774 | *pos++ = WLAN_EID_SUPP_RATES; |
748 | *pos++ = len; | 775 | *pos++ = supp_rates_len; |
749 | for (i = 0; i < len; i++) { | ||
750 | int rate = sband->bitrates[i].bitrate; | ||
751 | *pos++ = (u8) (rate / 5); | ||
752 | } | ||
753 | 776 | ||
754 | if (sband->n_bitrates > len) { | 777 | count = 0; |
755 | pos = skb_put(skb, sband->n_bitrates - len + 2); | 778 | for (i = 0; i < sband->n_bitrates; i++) { |
756 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 779 | if (BIT(i) & rates) { |
757 | *pos++ = sband->n_bitrates - len; | ||
758 | for (i = len; i < sband->n_bitrates; i++) { | ||
759 | int rate = sband->bitrates[i].bitrate; | 780 | int rate = sband->bitrates[i].bitrate; |
760 | *pos++ = (u8) (rate / 5); | 781 | *pos++ = (u8) (rate / 5); |
782 | if (++count == 8) | ||
783 | break; | ||
784 | } | ||
785 | } | ||
786 | |||
787 | if (count == 8) { | ||
788 | pos = skb_put(skb, rates_len - count + 2); | ||
789 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
790 | *pos++ = rates_len - count; | ||
791 | |||
792 | for (i++; i < sband->n_bitrates; i++) { | ||
793 | if (BIT(i) & rates) { | ||
794 | int rate = sband->bitrates[i].bitrate; | ||
795 | *pos++ = (u8) (rate / 5); | ||
796 | } | ||
761 | } | 797 | } |
762 | } | 798 | } |
763 | 799 | ||
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 02f436a86061..1958bfb361c6 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1305,11 +1305,11 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1305 | if (is_multicast_ether_addr(skb->data)) { | 1305 | if (is_multicast_ether_addr(skb->data)) { |
1306 | if (*mesh_ttl > 0) { | 1306 | if (*mesh_ttl > 0) { |
1307 | xmit_skb = skb_copy(skb, GFP_ATOMIC); | 1307 | xmit_skb = skb_copy(skb, GFP_ATOMIC); |
1308 | if (!xmit_skb && net_ratelimit()) | 1308 | if (xmit_skb) |
1309 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1310 | else if (net_ratelimit()) | ||
1309 | printk(KERN_DEBUG "%s: failed to clone " | 1311 | printk(KERN_DEBUG "%s: failed to clone " |
1310 | "multicast frame\n", dev->name); | 1312 | "multicast frame\n", dev->name); |
1311 | else | ||
1312 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1313 | } else | 1313 | } else |
1314 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, | 1314 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, |
1315 | dropped_frames_ttl); | 1315 | dropped_frames_ttl); |
@@ -1395,7 +1395,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1395 | padding = ((4 - subframe_len) & 0x3); | 1395 | padding = ((4 - subframe_len) & 0x3); |
1396 | /* the last MSDU has no padding */ | 1396 | /* the last MSDU has no padding */ |
1397 | if (subframe_len > remaining) { | 1397 | if (subframe_len > remaining) { |
1398 | printk(KERN_DEBUG "%s: wrong buffer size", dev->name); | 1398 | printk(KERN_DEBUG "%s: wrong buffer size\n", dev->name); |
1399 | return RX_DROP_UNUSABLE; | 1399 | return RX_DROP_UNUSABLE; |
1400 | } | 1400 | } |
1401 | 1401 | ||
@@ -1418,7 +1418,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1418 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + | 1418 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + |
1419 | padding); | 1419 | padding); |
1420 | if (!eth) { | 1420 | if (!eth) { |
1421 | printk(KERN_DEBUG "%s: wrong buffer size ", | 1421 | printk(KERN_DEBUG "%s: wrong buffer size\n", |
1422 | dev->name); | 1422 | dev->name); |
1423 | dev_kfree_skb(frame); | 1423 | dev_kfree_skb(frame); |
1424 | return RX_DROP_UNUSABLE; | 1424 | return RX_DROP_UNUSABLE; |
@@ -1952,7 +1952,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1952 | if (!skb_new) { | 1952 | if (!skb_new) { |
1953 | if (net_ratelimit()) | 1953 | if (net_ratelimit()) |
1954 | printk(KERN_DEBUG "%s: failed to copy " | 1954 | printk(KERN_DEBUG "%s: failed to copy " |
1955 | "multicast frame for %s", | 1955 | "multicast frame for %s\n", |
1956 | wiphy_name(local->hw.wiphy), | 1956 | wiphy_name(local->hw.wiphy), |
1957 | prev->dev->name); | 1957 | prev->dev->name); |
1958 | continue; | 1958 | continue; |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f35eaea98e73..1d7dd54aacef 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -1562,13 +1562,13 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1562 | * be cloned. This could happen, e.g., with Linux bridge code passing | 1562 | * be cloned. This could happen, e.g., with Linux bridge code passing |
1563 | * us broadcast frames. */ | 1563 | * us broadcast frames. */ |
1564 | 1564 | ||
1565 | if (head_need > 0 || skb_cloned(skb)) { | 1565 | if (head_need > 0 || skb_header_cloned(skb)) { |
1566 | #if 0 | 1566 | #if 0 |
1567 | printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " | 1567 | printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " |
1568 | "of headroom\n", dev->name, head_need); | 1568 | "of headroom\n", dev->name, head_need); |
1569 | #endif | 1569 | #endif |
1570 | 1570 | ||
1571 | if (skb_cloned(skb)) | 1571 | if (skb_header_cloned(skb)) |
1572 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); | 1572 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); |
1573 | else | 1573 | else |
1574 | I802_DEBUG_INC(local->tx_expand_skb_head); | 1574 | I802_DEBUG_INC(local->tx_expand_skb_head); |
@@ -1898,6 +1898,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1898 | control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; | 1898 | control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; |
1899 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; | 1899 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; |
1900 | control->flags |= IEEE80211_TXCTL_NO_ACK; | 1900 | control->flags |= IEEE80211_TXCTL_NO_ACK; |
1901 | control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | ||
1901 | control->retry_limit = 1; | 1902 | control->retry_limit = 1; |
1902 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; | 1903 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; |
1903 | } | 1904 | } |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index cc9f715c7bfc..24a465c4df09 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -153,15 +153,15 @@ int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) | |||
153 | /* 7.1.3.5a.2 */ | 153 | /* 7.1.3.5a.2 */ |
154 | switch (ae) { | 154 | switch (ae) { |
155 | case 0: | 155 | case 0: |
156 | return 5; | 156 | return 6; |
157 | case 1: | 157 | case 1: |
158 | return 11; | 158 | return 12; |
159 | case 2: | 159 | case 2: |
160 | return 17; | 160 | return 18; |
161 | case 3: | 161 | case 3: |
162 | return 23; | 162 | return 24; |
163 | default: | 163 | default: |
164 | return 5; | 164 | return 6; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index 64faa3dc488f..dc1598b86004 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c | |||
@@ -394,7 +394,8 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt) | |||
394 | qd->handle); | 394 | qd->handle); |
395 | if (!q->queues[i]) { | 395 | if (!q->queues[i]) { |
396 | q->queues[i] = &noop_qdisc; | 396 | q->queues[i] = &noop_qdisc; |
397 | printk(KERN_ERR "%s child qdisc %i creation failed", dev->name, i); | 397 | printk(KERN_ERR "%s child qdisc %i creation failed\n", |
398 | dev->name, i); | ||
398 | } | 399 | } |
399 | } | 400 | } |
400 | 401 | ||
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 16774ecd1c4e..0edefcfc5949 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -472,6 +472,9 @@ static int ctnetlink_conntrack_event(struct notifier_block *this, | |||
472 | goto nla_put_failure; | 472 | goto nla_put_failure; |
473 | nla_nest_end(skb, nest_parms); | 473 | nla_nest_end(skb, nest_parms); |
474 | 474 | ||
475 | if (ctnetlink_dump_id(skb, ct) < 0) | ||
476 | goto nla_put_failure; | ||
477 | |||
475 | if (events & IPCT_DESTROY) { | 478 | if (events & IPCT_DESTROY) { |
476 | if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || | 479 | if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || |
477 | ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) | 480 | ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) |
diff --git a/net/netfilter/xt_iprange.c b/net/netfilter/xt_iprange.c index 500528d60cd7..c63e9333c755 100644 --- a/net/netfilter/xt_iprange.c +++ b/net/netfilter/xt_iprange.c | |||
@@ -179,3 +179,5 @@ module_exit(iprange_mt_exit); | |||
179 | MODULE_LICENSE("GPL"); | 179 | MODULE_LICENSE("GPL"); |
180 | MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>, Jan Engelhardt <jengelh@computergmbh.de>"); | 180 | MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>, Jan Engelhardt <jengelh@computergmbh.de>"); |
181 | MODULE_DESCRIPTION("Xtables: arbitrary IPv4 range matching"); | 181 | MODULE_DESCRIPTION("Xtables: arbitrary IPv4 range matching"); |
182 | MODULE_ALIAS("ipt_iprange"); | ||
183 | MODULE_ALIAS("ip6t_iprange"); | ||
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 25070240d4ae..2cee87da4441 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -743,7 +743,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
743 | if (len > dev->mtu+reserve) | 743 | if (len > dev->mtu+reserve) |
744 | goto out_unlock; | 744 | goto out_unlock; |
745 | 745 | ||
746 | skb = sock_alloc_send_skb(sk, len + LL_RESERVED_SPACE(dev), | 746 | skb = sock_alloc_send_skb(sk, len + LL_ALLOCATED_SPACE(dev), |
747 | msg->msg_flags & MSG_DONTWAIT, &err); | 747 | msg->msg_flags & MSG_DONTWAIT, &err); |
748 | if (skb==NULL) | 748 | if (skb==NULL) |
749 | goto out_unlock; | 749 | goto out_unlock; |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 81b606424e12..bbc7107c86cf 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -2418,7 +2418,8 @@ static int sctp_process_param(struct sctp_association *asoc, | |||
2418 | break; | 2418 | break; |
2419 | 2419 | ||
2420 | case SCTP_PARAM_IPV6_ADDRESS: | 2420 | case SCTP_PARAM_IPV6_ADDRESS: |
2421 | asoc->peer.ipv6_address = 1; | 2421 | if (PF_INET6 == asoc->base.sk->sk_family) |
2422 | asoc->peer.ipv6_address = 1; | ||
2422 | break; | 2423 | break; |
2423 | 2424 | ||
2424 | case SCTP_PARAM_HOST_NAME_ADDRESS: | 2425 | case SCTP_PARAM_HOST_NAME_ADDRESS: |
@@ -2829,6 +2830,19 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, | |||
2829 | addr_param = (union sctp_addr_param *) | 2830 | addr_param = (union sctp_addr_param *) |
2830 | ((void *)asconf_param + sizeof(sctp_addip_param_t)); | 2831 | ((void *)asconf_param + sizeof(sctp_addip_param_t)); |
2831 | 2832 | ||
2833 | switch (addr_param->v4.param_hdr.type) { | ||
2834 | case SCTP_PARAM_IPV6_ADDRESS: | ||
2835 | if (!asoc->peer.ipv6_address) | ||
2836 | return SCTP_ERROR_INV_PARAM; | ||
2837 | break; | ||
2838 | case SCTP_PARAM_IPV4_ADDRESS: | ||
2839 | if (!asoc->peer.ipv4_address) | ||
2840 | return SCTP_ERROR_INV_PARAM; | ||
2841 | break; | ||
2842 | default: | ||
2843 | return SCTP_ERROR_INV_PARAM; | ||
2844 | } | ||
2845 | |||
2832 | af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type)); | 2846 | af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type)); |
2833 | if (unlikely(!af)) | 2847 | if (unlikely(!af)) |
2834 | return SCTP_ERROR_INV_PARAM; | 2848 | return SCTP_ERROR_INV_PARAM; |
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 09cd9c0c2d80..3f964db908a7 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c | |||
@@ -25,11 +25,11 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb) | |||
25 | struct dst_entry *dst = skb->dst; | 25 | struct dst_entry *dst = skb->dst; |
26 | int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev) | 26 | int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev) |
27 | - skb_headroom(skb); | 27 | - skb_headroom(skb); |
28 | int ntail = dst->dev->needed_tailroom - skb_tailroom(skb); | ||
28 | 29 | ||
29 | if (nhead > 0) | 30 | if (nhead > 0 || ntail > 0) |
30 | return pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); | 31 | return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC); |
31 | 32 | ||
32 | /* Check tail too... */ | ||
33 | return 0; | 33 | return 0; |
34 | } | 34 | } |
35 | 35 | ||
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 630684f4a0bc..09b1661b8a3a 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -539,8 +539,8 @@ static const char *intercon[][3] = { | |||
539 | {"HPRCOM", NULL, "Right HP Com"}, | 539 | {"HPRCOM", NULL, "Right HP Com"}, |
540 | 540 | ||
541 | /* Mono Output */ | 541 | /* Mono Output */ |
542 | {"MONOLOUT", NULL, "Mono Out"}, | 542 | {"MONO_LOUT", NULL, "Mono Out"}, |
543 | {"MONOLOUT", NULL, "Mono Out"}, | 543 | {"MONO_LOUT", NULL, "Mono Out"}, |
544 | 544 | ||
545 | /* Left Input */ | 545 | /* Left Input */ |
546 | {"Left Line1L Mux", "single-ended", "LINE1L"}, | 546 | {"Left Line1L Mux", "single-ended", "LINE1L"}, |
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index b2a11b0d2e4c..f588545698f3 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
@@ -416,7 +416,7 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd) | |||
416 | * to put data into its FIFO. Without it, ALSA starts | 416 | * to put data into its FIFO. Without it, ALSA starts |
417 | * to complain about overruns. | 417 | * to complain about overruns. |
418 | */ | 418 | */ |
419 | msleep(1); | 419 | mdelay(1); |
420 | } | 420 | } |
421 | break; | 421 | break; |
422 | 422 | ||
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 83b1eb4e40f3..6533563a6011 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c | |||
@@ -188,8 +188,8 @@ static const char *audio_map[][3] = { | |||
188 | static const char *spk_function[] = {"Off", "On"}; | 188 | static const char *spk_function[] = {"Off", "On"}; |
189 | static const char *jack_function[] = {"Off", "Headphone"}; | 189 | static const char *jack_function[] = {"Off", "Headphone"}; |
190 | static const struct soc_enum n810_enum[] = { | 190 | static const struct soc_enum n810_enum[] = { |
191 | SOC_ENUM_SINGLE_EXT(2, spk_function), | 191 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), |
192 | SOC_ENUM_SINGLE_EXT(3, jack_function), | 192 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(jack_function), jack_function), |
193 | }; | 193 | }; |
194 | 194 | ||
195 | static const struct snd_kcontrol_new aic33_n810_controls[] = { | 195 | static const struct snd_kcontrol_new aic33_n810_controls[] = { |
diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c index 478369bb38c3..b343818dbb96 100644 --- a/sound/synth/emux/emux_synth.c +++ b/sound/synth/emux/emux_synth.c | |||
@@ -341,8 +341,12 @@ snd_emux_control(void *p, int type, struct snd_midi_channel *chan) | |||
341 | case MIDI_CTL_SOFT_PEDAL: | 341 | case MIDI_CTL_SOFT_PEDAL: |
342 | #ifdef SNDRV_EMUX_USE_RAW_EFFECT | 342 | #ifdef SNDRV_EMUX_USE_RAW_EFFECT |
343 | /* FIXME: this is an emulation */ | 343 | /* FIXME: this is an emulation */ |
344 | snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, -160, | 344 | if (chan->control[type] >= 64) |
345 | snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, -160, | ||
345 | EMUX_FX_FLAG_ADD); | 346 | EMUX_FX_FLAG_ADD); |
347 | else | ||
348 | snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, 0, | ||
349 | EMUX_FX_FLAG_OFF); | ||
346 | #endif | 350 | #endif |
347 | break; | 351 | break; |
348 | 352 | ||