diff options
385 files changed, 11806 insertions, 2508 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX index edef85ce1195..2a39aeba1464 100644 --- a/Documentation/00-INDEX +++ b/Documentation/00-INDEX | |||
@@ -42,14 +42,8 @@ IRQ.txt | |||
42 | - description of what an IRQ is. | 42 | - description of what an IRQ is. |
43 | ManagementStyle | 43 | ManagementStyle |
44 | - how to (attempt to) manage kernel hackers. | 44 | - how to (attempt to) manage kernel hackers. |
45 | MSI-HOWTO.txt | ||
46 | - the Message Signaled Interrupts (MSI) Driver Guide HOWTO and FAQ. | ||
47 | RCU/ | 45 | RCU/ |
48 | - directory with info on RCU (read-copy update). | 46 | - directory with info on RCU (read-copy update). |
49 | README.DAC960 | ||
50 | - info on Mylex DAC960/DAC1100 PCI RAID Controller Driver for Linux. | ||
51 | README.cycladesZ | ||
52 | - info on Cyclades-Z firmware loading. | ||
53 | SAK.txt | 47 | SAK.txt |
54 | - info on Secure Attention Keys. | 48 | - info on Secure Attention Keys. |
55 | SM501.txt | 49 | SM501.txt |
@@ -86,20 +80,16 @@ blackfin/ | |||
86 | - directory with documentation for the Blackfin arch. | 80 | - directory with documentation for the Blackfin arch. |
87 | block/ | 81 | block/ |
88 | - info on the Block I/O (BIO) layer. | 82 | - info on the Block I/O (BIO) layer. |
83 | blockdev/ | ||
84 | - info on block devices & drivers | ||
89 | cachetlb.txt | 85 | cachetlb.txt |
90 | - describes the cache/TLB flushing interfaces Linux uses. | 86 | - describes the cache/TLB flushing interfaces Linux uses. |
91 | cciss.txt | ||
92 | - info, major/minor #'s for Compaq's SMART Array Controllers. | ||
93 | cdrom/ | 87 | cdrom/ |
94 | - directory with information on the CD-ROM drivers that Linux has. | 88 | - directory with information on the CD-ROM drivers that Linux has. |
95 | computone.txt | ||
96 | - info on Computone Intelliport II/Plus Multiport Serial Driver. | ||
97 | connector/ | 89 | connector/ |
98 | - docs on the netlink based userspace<->kernel space communication mod. | 90 | - docs on the netlink based userspace<->kernel space communication mod. |
99 | console/ | 91 | console/ |
100 | - documentation on Linux console drivers. | 92 | - documentation on Linux console drivers. |
101 | cpqarray.txt | ||
102 | - info on using Compaq's SMART2 Intelligent Disk Array Controllers. | ||
103 | cpu-freq/ | 93 | cpu-freq/ |
104 | - info on CPU frequency and voltage scaling. | 94 | - info on CPU frequency and voltage scaling. |
105 | cpu-hotplug.txt | 95 | cpu-hotplug.txt |
@@ -126,8 +116,6 @@ device-mapper/ | |||
126 | - directory with info on Device Mapper. | 116 | - directory with info on Device Mapper. |
127 | devices.txt | 117 | devices.txt |
128 | - plain ASCII listing of all the nodes in /dev/ with major minor #'s. | 118 | - plain ASCII listing of all the nodes in /dev/ with major minor #'s. |
129 | digiepca.txt | ||
130 | - info on Digi Intl. {PC,PCI,EISA}Xx and Xem series cards. | ||
131 | dontdiff | 119 | dontdiff |
132 | - file containing a list of files that should never be diff'ed. | 120 | - file containing a list of files that should never be diff'ed. |
133 | driver-model/ | 121 | driver-model/ |
@@ -152,14 +140,10 @@ filesystems/ | |||
152 | - info on the vfs and the various filesystems that Linux supports. | 140 | - info on the vfs and the various filesystems that Linux supports. |
153 | firmware_class/ | 141 | firmware_class/ |
154 | - request_firmware() hotplug interface info. | 142 | - request_firmware() hotplug interface info. |
155 | floppy.txt | ||
156 | - notes and driver options for the floppy disk driver. | ||
157 | frv/ | 143 | frv/ |
158 | - Fujitsu FR-V Linux documentation. | 144 | - Fujitsu FR-V Linux documentation. |
159 | gpio.txt | 145 | gpio.txt |
160 | - overview of GPIO (General Purpose Input/Output) access conventions. | 146 | - overview of GPIO (General Purpose Input/Output) access conventions. |
161 | hayes-esp.txt | ||
162 | - info on using the Hayes ESP serial driver. | ||
163 | highuid.txt | 147 | highuid.txt |
164 | - notes on the change from 16 bit to 32 bit user/group IDs. | 148 | - notes on the change from 16 bit to 32 bit user/group IDs. |
165 | timers/ | 149 | timers/ |
@@ -186,8 +170,6 @@ io_ordering.txt | |||
186 | - info on ordering I/O writes to memory-mapped addresses. | 170 | - info on ordering I/O writes to memory-mapped addresses. |
187 | ioctl/ | 171 | ioctl/ |
188 | - directory with documents describing various IOCTL calls. | 172 | - directory with documents describing various IOCTL calls. |
189 | ioctl-number.txt | ||
190 | - how to implement and register device/driver ioctl calls. | ||
191 | iostats.txt | 173 | iostats.txt |
192 | - info on I/O statistics Linux kernel provides. | 174 | - info on I/O statistics Linux kernel provides. |
193 | irqflags-tracing.txt | 175 | irqflags-tracing.txt |
@@ -250,14 +232,10 @@ mips/ | |||
250 | - directory with info about Linux on MIPS architecture. | 232 | - directory with info about Linux on MIPS architecture. |
251 | mono.txt | 233 | mono.txt |
252 | - how to execute Mono-based .NET binaries with the help of BINFMT_MISC. | 234 | - how to execute Mono-based .NET binaries with the help of BINFMT_MISC. |
253 | moxa-smartio | ||
254 | - file with info on installing/using Moxa multiport serial driver. | ||
255 | mutex-design.txt | 235 | mutex-design.txt |
256 | - info on the generic mutex subsystem. | 236 | - info on the generic mutex subsystem. |
257 | namespaces/ | 237 | namespaces/ |
258 | - directory with various information about namespaces | 238 | - directory with various information about namespaces |
259 | nbd.txt | ||
260 | - info on a TCP implementation of a network block device. | ||
261 | netlabel/ | 239 | netlabel/ |
262 | - directory with information on the NetLabel subsystem. | 240 | - directory with information on the NetLabel subsystem. |
263 | networking/ | 241 | networking/ |
@@ -270,8 +248,6 @@ numastat.txt | |||
270 | - info on how to read Numa policy hit/miss statistics in sysfs. | 248 | - info on how to read Numa policy hit/miss statistics in sysfs. |
271 | oops-tracing.txt | 249 | oops-tracing.txt |
272 | - how to decode those nasty internal kernel error dump messages. | 250 | - how to decode those nasty internal kernel error dump messages. |
273 | paride.txt | ||
274 | - information about the parallel port IDE subsystem. | ||
275 | parisc/ | 251 | parisc/ |
276 | - directory with info on using Linux on PA-RISC architecture. | 252 | - directory with info on using Linux on PA-RISC architecture. |
277 | parport.txt | 253 | parport.txt |
@@ -290,20 +266,16 @@ powerpc/ | |||
290 | - directory with info on using Linux with the PowerPC. | 266 | - directory with info on using Linux with the PowerPC. |
291 | preempt-locking.txt | 267 | preempt-locking.txt |
292 | - info on locking under a preemptive kernel. | 268 | - info on locking under a preemptive kernel. |
269 | printk-formats.txt | ||
270 | - how to get printk format specifiers right | ||
293 | prio_tree.txt | 271 | prio_tree.txt |
294 | - info on radix-priority-search-tree use for indexing vmas. | 272 | - info on radix-priority-search-tree use for indexing vmas. |
295 | ramdisk.txt | ||
296 | - short guide on how to set up and use the RAM disk. | ||
297 | rbtree.txt | 273 | rbtree.txt |
298 | - info on what red-black trees are and what they are for. | 274 | - info on what red-black trees are and what they are for. |
299 | riscom8.txt | ||
300 | - notes on using the RISCom/8 multi-port serial driver. | ||
301 | robust-futex-ABI.txt | 275 | robust-futex-ABI.txt |
302 | - documentation of the robust futex ABI. | 276 | - documentation of the robust futex ABI. |
303 | robust-futexes.txt | 277 | robust-futexes.txt |
304 | - a description of what robust futexes are. | 278 | - a description of what robust futexes are. |
305 | rocket.txt | ||
306 | - info on the Comtrol RocketPort multiport serial driver. | ||
307 | rt-mutex-design.txt | 279 | rt-mutex-design.txt |
308 | - description of the RealTime mutex implementation design. | 280 | - description of the RealTime mutex implementation design. |
309 | rt-mutex.txt | 281 | rt-mutex.txt |
@@ -332,8 +304,6 @@ sparc/ | |||
332 | - directory with info on using Linux on Sparc architecture. | 304 | - directory with info on using Linux on Sparc architecture. |
333 | sparse.txt | 305 | sparse.txt |
334 | - info on how to obtain and use the sparse tool for typechecking. | 306 | - info on how to obtain and use the sparse tool for typechecking. |
335 | specialix.txt | ||
336 | - info on hardware/driver for specialix IO8+ multiport serial card. | ||
337 | spi/ | 307 | spi/ |
338 | - overview of Linux kernel Serial Peripheral Interface (SPI) support. | 308 | - overview of Linux kernel Serial Peripheral Interface (SPI) support. |
339 | spinlocks.txt | 309 | spinlocks.txt |
@@ -342,14 +312,10 @@ stable_api_nonsense.txt | |||
342 | - info on why the kernel does not have a stable in-kernel api or abi. | 312 | - info on why the kernel does not have a stable in-kernel api or abi. |
343 | stable_kernel_rules.txt | 313 | stable_kernel_rules.txt |
344 | - rules and procedures for the -stable kernel releases. | 314 | - rules and procedures for the -stable kernel releases. |
345 | stallion.txt | ||
346 | - info on using the Stallion multiport serial driver. | ||
347 | svga.txt | 315 | svga.txt |
348 | - short guide on selecting video modes at boot via VGA BIOS. | 316 | - short guide on selecting video modes at boot via VGA BIOS. |
349 | sysfs-rules.txt | 317 | sysfs-rules.txt |
350 | - How not to use sysfs. | 318 | - How not to use sysfs. |
351 | sx.txt | ||
352 | - info on the Specialix SX/SI multiport serial driver. | ||
353 | sysctl/ | 319 | sysctl/ |
354 | - directory with info on the /proc/sys/* files. | 320 | - directory with info on the /proc/sys/* files. |
355 | sysrq.txt | 321 | sysrq.txt |
@@ -358,8 +324,6 @@ telephony/ | |||
358 | - directory with info on telephony (e.g. voice over IP) support. | 324 | - directory with info on telephony (e.g. voice over IP) support. |
359 | time_interpolators.txt | 325 | time_interpolators.txt |
360 | - info on time interpolators. | 326 | - info on time interpolators. |
361 | tty.txt | ||
362 | - guide to the locking policies of the tty layer. | ||
363 | uml/ | 327 | uml/ |
364 | - directory with information about User Mode Linux. | 328 | - directory with information about User Mode Linux. |
365 | unicode.txt | 329 | unicode.txt |
diff --git a/Documentation/ABI/testing/sysfs-c2port b/Documentation/ABI/testing/sysfs-c2port new file mode 100644 index 000000000000..716cffc457e9 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-c2port | |||
@@ -0,0 +1,88 @@ | |||
1 | What: /sys/class/c2port/ | ||
2 | Date: October 2008 | ||
3 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
4 | Description: | ||
5 | The /sys/class/c2port/ directory will contain files and | ||
6 | directories that will provide a unified interface to | ||
7 | the C2 port interface. | ||
8 | |||
9 | What: /sys/class/c2port/c2portX | ||
10 | Date: October 2008 | ||
11 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
12 | Description: | ||
13 | The /sys/class/c2port/c2portX/ directory is related to X-th | ||
14 | C2 port into the system. Each directory will contain files to | ||
15 | manage and control its C2 port. | ||
16 | |||
17 | What: /sys/class/c2port/c2portX/access | ||
18 | Date: October 2008 | ||
19 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
20 | Description: | ||
21 | The /sys/class/c2port/c2portX/access file enable the access | ||
22 | to the C2 port from the system. No commands can be sent | ||
23 | till this entry is set to 0. | ||
24 | |||
25 | What: /sys/class/c2port/c2portX/dev_id | ||
26 | Date: October 2008 | ||
27 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
28 | Description: | ||
29 | The /sys/class/c2port/c2portX/dev_id file show the device ID | ||
30 | of the connected micro. | ||
31 | |||
32 | What: /sys/class/c2port/c2portX/flash_access | ||
33 | Date: October 2008 | ||
34 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
35 | Description: | ||
36 | The /sys/class/c2port/c2portX/flash_access file enable the | ||
37 | access to the on-board flash of the connected micro. | ||
38 | No commands can be sent till this entry is set to 0. | ||
39 | |||
40 | What: /sys/class/c2port/c2portX/flash_block_size | ||
41 | Date: October 2008 | ||
42 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
43 | Description: | ||
44 | The /sys/class/c2port/c2portX/flash_block_size file show | ||
45 | the on-board flash block size of the connected micro. | ||
46 | |||
47 | What: /sys/class/c2port/c2portX/flash_blocks_num | ||
48 | Date: October 2008 | ||
49 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
50 | Description: | ||
51 | The /sys/class/c2port/c2portX/flash_blocks_num file show | ||
52 | the on-board flash blocks number of the connected micro. | ||
53 | |||
54 | What: /sys/class/c2port/c2portX/flash_data | ||
55 | Date: October 2008 | ||
56 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
57 | Description: | ||
58 | The /sys/class/c2port/c2portX/flash_data file export | ||
59 | the content of the on-board flash of the connected micro. | ||
60 | |||
61 | What: /sys/class/c2port/c2portX/flash_erase | ||
62 | Date: October 2008 | ||
63 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
64 | Description: | ||
65 | The /sys/class/c2port/c2portX/flash_erase file execute | ||
66 | the "erase" command on the on-board flash of the connected | ||
67 | micro. | ||
68 | |||
69 | What: /sys/class/c2port/c2portX/flash_erase | ||
70 | Date: October 2008 | ||
71 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
72 | Description: | ||
73 | The /sys/class/c2port/c2portX/flash_erase file show the | ||
74 | on-board flash size of the connected micro. | ||
75 | |||
76 | What: /sys/class/c2port/c2portX/reset | ||
77 | Date: October 2008 | ||
78 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
79 | Description: | ||
80 | The /sys/class/c2port/c2portX/reset file execute a "reset" | ||
81 | command on the connected micro. | ||
82 | |||
83 | What: /sys/class/c2port/c2portX/rev_id | ||
84 | Date: October 2008 | ||
85 | Contact: Rodolfo Giometti <giometti@linux.it> | ||
86 | Description: | ||
87 | The /sys/class/c2port/c2portX/rev_id file show the revision ID | ||
88 | of the connected micro. | ||
diff --git a/Documentation/ABI/testing/sysfs-firmware-acpi b/Documentation/ABI/testing/sysfs-firmware-acpi index f27be7d1a49f..e8ffc70ffe12 100644 --- a/Documentation/ABI/testing/sysfs-firmware-acpi +++ b/Documentation/ABI/testing/sysfs-firmware-acpi | |||
@@ -89,7 +89,7 @@ Description: | |||
89 | 89 | ||
90 | error - an interrupt that can't be accounted for above. | 90 | error - an interrupt that can't be accounted for above. |
91 | 91 | ||
92 | invalid: it's either a wakeup GPE or a GPE/Fixed Event that | 92 | invalid: it's either a GPE or a Fixed Event that |
93 | doesn't have an event handler. | 93 | doesn't have an event handler. |
94 | 94 | ||
95 | disable: the GPE/Fixed Event is valid but disabled. | 95 | disable: the GPE/Fixed Event is valid but disabled. |
@@ -117,30 +117,30 @@ Description: | |||
117 | and other user space applications so that the machine won't shutdown | 117 | and other user space applications so that the machine won't shutdown |
118 | when pressing the power button. | 118 | when pressing the power button. |
119 | # cat ff_pwr_btn | 119 | # cat ff_pwr_btn |
120 | 0 | 120 | 0 enabled |
121 | # press the power button for 3 times; | 121 | # press the power button for 3 times; |
122 | # cat ff_pwr_btn | 122 | # cat ff_pwr_btn |
123 | 3 | 123 | 3 enabled |
124 | # echo disable > ff_pwr_btn | 124 | # echo disable > ff_pwr_btn |
125 | # cat ff_pwr_btn | 125 | # cat ff_pwr_btn |
126 | disable | 126 | 3 disabled |
127 | # press the power button for 3 times; | 127 | # press the power button for 3 times; |
128 | # cat ff_pwr_btn | 128 | # cat ff_pwr_btn |
129 | disable | 129 | 3 disabled |
130 | # echo enable > ff_pwr_btn | 130 | # echo enable > ff_pwr_btn |
131 | # cat ff_pwr_btn | 131 | # cat ff_pwr_btn |
132 | 4 | 132 | 4 enabled |
133 | /* | 133 | /* |
134 | * this is because the status bit is set even if the enable bit is cleared, | 134 | * this is because the status bit is set even if the enable bit is cleared, |
135 | * and it triggers an ACPI fixed event when the enable bit is set again | 135 | * and it triggers an ACPI fixed event when the enable bit is set again |
136 | */ | 136 | */ |
137 | # press the power button for 3 times; | 137 | # press the power button for 3 times; |
138 | # cat ff_pwr_btn | 138 | # cat ff_pwr_btn |
139 | 7 | 139 | 7 enabled |
140 | # echo disable > ff_pwr_btn | 140 | # echo disable > ff_pwr_btn |
141 | # press the power button for 3 times; | 141 | # press the power button for 3 times; |
142 | # echo clear > ff_pwr_btn /* clear the status bit */ | 142 | # echo clear > ff_pwr_btn /* clear the status bit */ |
143 | # echo disable > ff_pwr_btn | 143 | # echo disable > ff_pwr_btn |
144 | # cat ff_pwr_btn | 144 | # cat ff_pwr_btn |
145 | 7 | 145 | 7 enabled |
146 | 146 | ||
diff --git a/Documentation/PCI/00-INDEX b/Documentation/PCI/00-INDEX index 49f43946c6b6..812b17fe3ed0 100644 --- a/Documentation/PCI/00-INDEX +++ b/Documentation/PCI/00-INDEX | |||
@@ -1,5 +1,7 @@ | |||
1 | 00-INDEX | 1 | 00-INDEX |
2 | - this file | 2 | - this file |
3 | MSI-HOWTO.txt | ||
4 | - the Message Signaled Interrupts (MSI) Driver Guide HOWTO and FAQ. | ||
3 | PCI-DMA-mapping.txt | 5 | PCI-DMA-mapping.txt |
4 | - info for PCI drivers using DMA portably across all platforms | 6 | - info for PCI drivers using DMA portably across all platforms |
5 | PCIEBUS-HOWTO.txt | 7 | PCIEBUS-HOWTO.txt |
diff --git a/Documentation/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt index 256defd7e174..256defd7e174 100644 --- a/Documentation/MSI-HOWTO.txt +++ b/Documentation/PCI/MSI-HOWTO.txt | |||
diff --git a/Documentation/acpi/debug.txt b/Documentation/acpi/debug.txt new file mode 100644 index 000000000000..65bf47c46b6d --- /dev/null +++ b/Documentation/acpi/debug.txt | |||
@@ -0,0 +1,148 @@ | |||
1 | ACPI Debug Output | ||
2 | |||
3 | |||
4 | The ACPI CA, the Linux ACPI core, and some ACPI drivers can generate debug | ||
5 | output. This document describes how to use this facility. | ||
6 | |||
7 | Compile-time configuration | ||
8 | -------------------------- | ||
9 | |||
10 | ACPI debug output is globally enabled by CONFIG_ACPI_DEBUG. If this config | ||
11 | option is turned off, the debug messages are not even built into the | ||
12 | kernel. | ||
13 | |||
14 | Boot- and run-time configuration | ||
15 | -------------------------------- | ||
16 | |||
17 | When CONFIG_ACPI_DEBUG=y, you can select the component and level of messages | ||
18 | you're interested in. At boot-time, use the acpi.debug_layer and | ||
19 | acpi.debug_level kernel command line options. After boot, you can use the | ||
20 | debug_layer and debug_level files in /sys/module/acpi/parameters/ to control | ||
21 | the debug messages. | ||
22 | |||
23 | debug_layer (component) | ||
24 | ----------------------- | ||
25 | |||
26 | The "debug_layer" is a mask that selects components of interest, e.g., a | ||
27 | specific driver or part of the ACPI interpreter. To build the debug_layer | ||
28 | bitmask, look for the "#define _COMPONENT" in an ACPI source file. | ||
29 | |||
30 | You can set the debug_layer mask at boot-time using the acpi.debug_layer | ||
31 | command line argument, and you can change it after boot by writing values | ||
32 | to /sys/module/acpi/parameters/debug_layer. | ||
33 | |||
34 | The possible components are defined in include/acpi/acoutput.h and | ||
35 | include/acpi/acpi_drivers.h. Reading /sys/module/acpi/parameters/debug_layer | ||
36 | shows the supported mask values, currently these: | ||
37 | |||
38 | ACPI_UTILITIES 0x00000001 | ||
39 | ACPI_HARDWARE 0x00000002 | ||
40 | ACPI_EVENTS 0x00000004 | ||
41 | ACPI_TABLES 0x00000008 | ||
42 | ACPI_NAMESPACE 0x00000010 | ||
43 | ACPI_PARSER 0x00000020 | ||
44 | ACPI_DISPATCHER 0x00000040 | ||
45 | ACPI_EXECUTER 0x00000080 | ||
46 | ACPI_RESOURCES 0x00000100 | ||
47 | ACPI_CA_DEBUGGER 0x00000200 | ||
48 | ACPI_OS_SERVICES 0x00000400 | ||
49 | ACPI_CA_DISASSEMBLER 0x00000800 | ||
50 | ACPI_COMPILER 0x00001000 | ||
51 | ACPI_TOOLS 0x00002000 | ||
52 | ACPI_BUS_COMPONENT 0x00010000 | ||
53 | ACPI_AC_COMPONENT 0x00020000 | ||
54 | ACPI_BATTERY_COMPONENT 0x00040000 | ||
55 | ACPI_BUTTON_COMPONENT 0x00080000 | ||
56 | ACPI_SBS_COMPONENT 0x00100000 | ||
57 | ACPI_FAN_COMPONENT 0x00200000 | ||
58 | ACPI_PCI_COMPONENT 0x00400000 | ||
59 | ACPI_POWER_COMPONENT 0x00800000 | ||
60 | ACPI_CONTAINER_COMPONENT 0x01000000 | ||
61 | ACPI_SYSTEM_COMPONENT 0x02000000 | ||
62 | ACPI_THERMAL_COMPONENT 0x04000000 | ||
63 | ACPI_MEMORY_DEVICE_COMPONENT 0x08000000 | ||
64 | ACPI_VIDEO_COMPONENT 0x10000000 | ||
65 | ACPI_PROCESSOR_COMPONENT 0x20000000 | ||
66 | |||
67 | debug_level | ||
68 | ----------- | ||
69 | |||
70 | The "debug_level" is a mask that selects different types of messages, e.g., | ||
71 | those related to initialization, method execution, informational messages, etc. | ||
72 | To build debug_level, look at the level specified in an ACPI_DEBUG_PRINT() | ||
73 | statement. | ||
74 | |||
75 | The ACPI interpreter uses several different levels, but the Linux | ||
76 | ACPI core and ACPI drivers generally only use ACPI_LV_INFO. | ||
77 | |||
78 | You can set the debug_level mask at boot-time using the acpi.debug_level | ||
79 | command line argument, and you can change it after boot by writing values | ||
80 | to /sys/module/acpi/parameters/debug_level. | ||
81 | |||
82 | The possible levels are defined in include/acpi/acoutput.h. Reading | ||
83 | /sys/module/acpi/parameters/debug_level shows the supported mask values, | ||
84 | currently these: | ||
85 | |||
86 | ACPI_LV_INIT 0x00000001 | ||
87 | ACPI_LV_DEBUG_OBJECT 0x00000002 | ||
88 | ACPI_LV_INFO 0x00000004 | ||
89 | ACPI_LV_INIT_NAMES 0x00000020 | ||
90 | ACPI_LV_PARSE 0x00000040 | ||
91 | ACPI_LV_LOAD 0x00000080 | ||
92 | ACPI_LV_DISPATCH 0x00000100 | ||
93 | ACPI_LV_EXEC 0x00000200 | ||
94 | ACPI_LV_NAMES 0x00000400 | ||
95 | ACPI_LV_OPREGION 0x00000800 | ||
96 | ACPI_LV_BFIELD 0x00001000 | ||
97 | ACPI_LV_TABLES 0x00002000 | ||
98 | ACPI_LV_VALUES 0x00004000 | ||
99 | ACPI_LV_OBJECTS 0x00008000 | ||
100 | ACPI_LV_RESOURCES 0x00010000 | ||
101 | ACPI_LV_USER_REQUESTS 0x00020000 | ||
102 | ACPI_LV_PACKAGE 0x00040000 | ||
103 | ACPI_LV_ALLOCATIONS 0x00100000 | ||
104 | ACPI_LV_FUNCTIONS 0x00200000 | ||
105 | ACPI_LV_OPTIMIZATIONS 0x00400000 | ||
106 | ACPI_LV_MUTEX 0x01000000 | ||
107 | ACPI_LV_THREADS 0x02000000 | ||
108 | ACPI_LV_IO 0x04000000 | ||
109 | ACPI_LV_INTERRUPTS 0x08000000 | ||
110 | ACPI_LV_AML_DISASSEMBLE 0x10000000 | ||
111 | ACPI_LV_VERBOSE_INFO 0x20000000 | ||
112 | ACPI_LV_FULL_TABLES 0x40000000 | ||
113 | ACPI_LV_EVENTS 0x80000000 | ||
114 | |||
115 | Examples | ||
116 | -------- | ||
117 | |||
118 | For example, drivers/acpi/bus.c contains this: | ||
119 | |||
120 | #define _COMPONENT ACPI_BUS_COMPONENT | ||
121 | ... | ||
122 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n")); | ||
123 | |||
124 | To turn on this message, set the ACPI_BUS_COMPONENT bit in acpi.debug_layer | ||
125 | and the ACPI_LV_INFO bit in acpi.debug_level. (The ACPI_DEBUG_PRINT | ||
126 | statement uses ACPI_DB_INFO, which is macro based on the ACPI_LV_INFO | ||
127 | definition.) | ||
128 | |||
129 | Enable all AML "Debug" output (stores to the Debug object while interpreting | ||
130 | AML) during boot: | ||
131 | |||
132 | acpi.debug_layer=0xffffffff acpi.debug_level=0x2 | ||
133 | |||
134 | Enable PCI and PCI interrupt routing debug messages: | ||
135 | |||
136 | acpi.debug_layer=0x400000 acpi.debug_level=0x4 | ||
137 | |||
138 | Enable all ACPI hardware-related messages: | ||
139 | |||
140 | acpi.debug_layer=0x2 acpi.debug_level=0xffffffff | ||
141 | |||
142 | Enable all ACPI_DB_INFO messages after boot: | ||
143 | |||
144 | # echo 0x4 > /sys/module/acpi/parameters/debug_level | ||
145 | |||
146 | Show all valid component values: | ||
147 | |||
148 | # cat /sys/module/acpi/parameters/debug_layer | ||
diff --git a/Documentation/blockdev/00-INDEX b/Documentation/blockdev/00-INDEX new file mode 100644 index 000000000000..86f054c47013 --- /dev/null +++ b/Documentation/blockdev/00-INDEX | |||
@@ -0,0 +1,16 @@ | |||
1 | 00-INDEX | ||
2 | - this file | ||
3 | README.DAC960 | ||
4 | - info on Mylex DAC960/DAC1100 PCI RAID Controller Driver for Linux. | ||
5 | cciss.txt | ||
6 | - info, major/minor #'s for Compaq's SMART Array Controllers. | ||
7 | cpqarray.txt | ||
8 | - info on using Compaq's SMART2 Intelligent Disk Array Controllers. | ||
9 | floppy.txt | ||
10 | - notes and driver options for the floppy disk driver. | ||
11 | nbd.txt | ||
12 | - info on a TCP implementation of a network block device. | ||
13 | paride.txt | ||
14 | - information about the parallel port IDE subsystem. | ||
15 | ramdisk.txt | ||
16 | - short guide on how to set up and use the RAM disk. | ||
diff --git a/Documentation/README.DAC960 b/Documentation/blockdev/README.DAC960 index 0e8f618ab534..0e8f618ab534 100644 --- a/Documentation/README.DAC960 +++ b/Documentation/blockdev/README.DAC960 | |||
diff --git a/Documentation/cciss.txt b/Documentation/blockdev/cciss.txt index 89698e8df7d4..89698e8df7d4 100644 --- a/Documentation/cciss.txt +++ b/Documentation/blockdev/cciss.txt | |||
diff --git a/Documentation/cpqarray.txt b/Documentation/blockdev/cpqarray.txt index c7154e20ef5e..c7154e20ef5e 100644 --- a/Documentation/cpqarray.txt +++ b/Documentation/blockdev/cpqarray.txt | |||
diff --git a/Documentation/floppy.txt b/Documentation/blockdev/floppy.txt index 6ccab88705cb..6ccab88705cb 100644 --- a/Documentation/floppy.txt +++ b/Documentation/blockdev/floppy.txt | |||
diff --git a/Documentation/nbd.txt b/Documentation/blockdev/nbd.txt index aeb93ffe6416..aeb93ffe6416 100644 --- a/Documentation/nbd.txt +++ b/Documentation/blockdev/nbd.txt | |||
diff --git a/Documentation/paride.txt b/Documentation/blockdev/paride.txt index e4312676bdda..e4312676bdda 100644 --- a/Documentation/paride.txt +++ b/Documentation/blockdev/paride.txt | |||
diff --git a/Documentation/ramdisk.txt b/Documentation/blockdev/ramdisk.txt index 6c820baa19a6..6c820baa19a6 100644 --- a/Documentation/ramdisk.txt +++ b/Documentation/blockdev/ramdisk.txt | |||
diff --git a/Documentation/c2port.txt b/Documentation/c2port.txt new file mode 100644 index 000000000000..d9bf93ea4398 --- /dev/null +++ b/Documentation/c2port.txt | |||
@@ -0,0 +1,90 @@ | |||
1 | C2 port support | ||
2 | --------------- | ||
3 | |||
4 | (C) Copyright 2007 Rodolfo Giometti <giometti@enneenne.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 as published by | ||
8 | the Free Software Foundation; either version 2 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | |||
17 | |||
18 | Overview | ||
19 | -------- | ||
20 | |||
21 | This driver implements the support for Linux of Silicon Labs (Silabs) | ||
22 | C2 Interface used for in-system programming of micro controllers. | ||
23 | |||
24 | By using this driver you can reprogram the in-system flash without EC2 | ||
25 | or EC3 debug adapter. This solution is also useful in those systems | ||
26 | where the micro controller is connected via special GPIOs pins. | ||
27 | |||
28 | References | ||
29 | ---------- | ||
30 | |||
31 | The C2 Interface main references are at (http://www.silabs.com) | ||
32 | Silicon Laboratories site], see: | ||
33 | |||
34 | - AN127: FLASH Programming via the C2 Interface at | ||
35 | http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Small_Form_Factor/en/an127.pdf, and | ||
36 | |||
37 | - C2 Specification at | ||
38 | http://www.silabs.com/public/documents/tpub_doc/spec/Microcontrollers/en/C2spec.pdf, | ||
39 | |||
40 | however it implements a two wire serial communication protocol (bit | ||
41 | banging) designed to enable in-system programming, debugging, and | ||
42 | boundary-scan testing on low pin-count Silicon Labs devices. Currently | ||
43 | this code supports only flash programming but extensions are easy to | ||
44 | add. | ||
45 | |||
46 | Using the driver | ||
47 | ---------------- | ||
48 | |||
49 | Once the driver is loaded you can use sysfs support to get C2port's | ||
50 | info or read/write in-system flash. | ||
51 | |||
52 | # ls /sys/class/c2port/c2port0/ | ||
53 | access flash_block_size flash_erase rev_id | ||
54 | dev_id flash_blocks_num flash_size subsystem/ | ||
55 | flash_access flash_data reset uevent | ||
56 | |||
57 | Initially the C2port access is disabled since you hardware may have | ||
58 | such lines multiplexed with other devices so, to get access to the | ||
59 | C2port, you need the command: | ||
60 | |||
61 | # echo 1 > /sys/class/c2port/c2port0/access | ||
62 | |||
63 | after that you should read the device ID and revision ID of the | ||
64 | connected micro controller: | ||
65 | |||
66 | # cat /sys/class/c2port/c2port0/dev_id | ||
67 | 8 | ||
68 | # cat /sys/class/c2port/c2port0/rev_id | ||
69 | 1 | ||
70 | |||
71 | However, for security reasons, the in-system flash access in not | ||
72 | enabled yet, to do so you need the command: | ||
73 | |||
74 | # echo 1 > /sys/class/c2port/c2port0/flash_access | ||
75 | |||
76 | After that you can read the whole flash: | ||
77 | |||
78 | # cat /sys/class/c2port/c2port0/flash_data > image | ||
79 | |||
80 | erase it: | ||
81 | |||
82 | # echo 1 > /sys/class/c2port/c2port0/flash_erase | ||
83 | |||
84 | and write it: | ||
85 | |||
86 | # cat image > /sys/class/c2port/c2port0/flash_data | ||
87 | |||
88 | after writing you have to reset the device to execute the new code: | ||
89 | |||
90 | # echo 1 > /sys/class/c2port/c2port0/reset | ||
diff --git a/Documentation/cgroups/freezer-subsystem.txt b/Documentation/cgroups/freezer-subsystem.txt index c50ab58b72eb..41f37fea1276 100644 --- a/Documentation/cgroups/freezer-subsystem.txt +++ b/Documentation/cgroups/freezer-subsystem.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | The cgroup freezer is useful to batch job management system which start | 1 | The cgroup freezer is useful to batch job management system which start |
2 | and stop sets of tasks in order to schedule the resources of a machine | 2 | and stop sets of tasks in order to schedule the resources of a machine |
3 | according to the desires of a system administrator. This sort of program | 3 | according to the desires of a system administrator. This sort of program |
4 | is often used on HPC clusters to schedule access to the cluster as a | 4 | is often used on HPC clusters to schedule access to the cluster as a |
@@ -6,7 +6,7 @@ whole. The cgroup freezer uses cgroups to describe the set of tasks to | |||
6 | be started/stopped by the batch job management system. It also provides | 6 | be started/stopped by the batch job management system. It also provides |
7 | a means to start and stop the tasks composing the job. | 7 | a means to start and stop the tasks composing the job. |
8 | 8 | ||
9 | The cgroup freezer will also be useful for checkpointing running groups | 9 | The cgroup freezer will also be useful for checkpointing running groups |
10 | of tasks. The freezer allows the checkpoint code to obtain a consistent | 10 | of tasks. The freezer allows the checkpoint code to obtain a consistent |
11 | image of the tasks by attempting to force the tasks in a cgroup into a | 11 | image of the tasks by attempting to force the tasks in a cgroup into a |
12 | quiescent state. Once the tasks are quiescent another task can | 12 | quiescent state. Once the tasks are quiescent another task can |
@@ -16,7 +16,7 @@ recoverable error occur. This also allows the checkpointed tasks to be | |||
16 | migrated between nodes in a cluster by copying the gathered information | 16 | migrated between nodes in a cluster by copying the gathered information |
17 | to another node and restarting the tasks there. | 17 | to another node and restarting the tasks there. |
18 | 18 | ||
19 | Sequences of SIGSTOP and SIGCONT are not always sufficient for stopping | 19 | Sequences of SIGSTOP and SIGCONT are not always sufficient for stopping |
20 | and resuming tasks in userspace. Both of these signals are observable | 20 | and resuming tasks in userspace. Both of these signals are observable |
21 | from within the tasks we wish to freeze. While SIGSTOP cannot be caught, | 21 | from within the tasks we wish to freeze. While SIGSTOP cannot be caught, |
22 | blocked, or ignored it can be seen by waiting or ptracing parent tasks. | 22 | blocked, or ignored it can be seen by waiting or ptracing parent tasks. |
@@ -37,26 +37,29 @@ demonstrate this problem using nested bash shells: | |||
37 | 37 | ||
38 | <at this point 16990 exits and causes 16644 to exit too> | 38 | <at this point 16990 exits and causes 16644 to exit too> |
39 | 39 | ||
40 | This happens because bash can observe both signals and choose how it | 40 | This happens because bash can observe both signals and choose how it |
41 | responds to them. | 41 | responds to them. |
42 | 42 | ||
43 | Another example of a program which catches and responds to these | 43 | Another example of a program which catches and responds to these |
44 | signals is gdb. In fact any program designed to use ptrace is likely to | 44 | signals is gdb. In fact any program designed to use ptrace is likely to |
45 | have a problem with this method of stopping and resuming tasks. | 45 | have a problem with this method of stopping and resuming tasks. |
46 | 46 | ||
47 | In contrast, the cgroup freezer uses the kernel freezer code to | 47 | In contrast, the cgroup freezer uses the kernel freezer code to |
48 | prevent the freeze/unfreeze cycle from becoming visible to the tasks | 48 | prevent the freeze/unfreeze cycle from becoming visible to the tasks |
49 | being frozen. This allows the bash example above and gdb to run as | 49 | being frozen. This allows the bash example above and gdb to run as |
50 | expected. | 50 | expected. |
51 | 51 | ||
52 | The freezer subsystem in the container filesystem defines a file named | 52 | The freezer subsystem in the container filesystem defines a file named |
53 | freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the | 53 | freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the |
54 | cgroup. Subsequently writing "THAWED" will unfreeze the tasks in the cgroup. | 54 | cgroup. Subsequently writing "THAWED" will unfreeze the tasks in the cgroup. |
55 | Reading will return the current state. | 55 | Reading will return the current state. |
56 | 56 | ||
57 | Note freezer.state doesn't exist in root cgroup, which means root cgroup | ||
58 | is non-freezable. | ||
59 | |||
57 | * Examples of usage : | 60 | * Examples of usage : |
58 | 61 | ||
59 | # mkdir /containers/freezer | 62 | # mkdir /containers |
60 | # mount -t cgroup -ofreezer freezer /containers | 63 | # mount -t cgroup -ofreezer freezer /containers |
61 | # mkdir /containers/0 | 64 | # mkdir /containers/0 |
62 | # echo $some_pid > /containers/0/tasks | 65 | # echo $some_pid > /containers/0/tasks |
@@ -94,6 +97,6 @@ things happens: | |||
94 | the freezer.state file | 97 | the freezer.state file |
95 | 2) Userspace retries the freezing operation by writing "FROZEN" to | 98 | 2) Userspace retries the freezing operation by writing "FROZEN" to |
96 | the freezer.state file (writing "FREEZING" is not legal | 99 | the freezer.state file (writing "FREEZING" is not legal |
97 | and returns EIO) | 100 | and returns EINVAL) |
98 | 3) The tasks that blocked the cgroup from entering the "FROZEN" | 101 | 3) The tasks that blocked the cgroup from entering the "FROZEN" |
99 | state disappear from the cgroup's set of tasks. | 102 | state disappear from the cgroup's set of tasks. |
diff --git a/Documentation/filesystems/xip.txt b/Documentation/filesystems/xip.txt index 3cc4010521a0..0466ee569278 100644 --- a/Documentation/filesystems/xip.txt +++ b/Documentation/filesystems/xip.txt | |||
@@ -39,10 +39,11 @@ The block device operation is optional, these block devices support it as of | |||
39 | today: | 39 | today: |
40 | - dcssblk: s390 dcss block device driver | 40 | - dcssblk: s390 dcss block device driver |
41 | 41 | ||
42 | An address space operation named get_xip_page is used to retrieve reference | 42 | An address space operation named get_xip_mem is used to retrieve references |
43 | to a struct page. To address the target page, a reference to an address_space, | 43 | to a page frame number and a kernel address. To obtain these values a reference |
44 | and a sector number is provided. A 3rd argument indicates whether the | 44 | to an address_space is provided. This function assigns values to the kmem and |
45 | function should allocate blocks if needed. | 45 | pfn parameters. The third argument indicates whether the function should allocate |
46 | blocks if needed. | ||
46 | 47 | ||
47 | This address space operation is mutually exclusive with readpage&writepage that | 48 | This address space operation is mutually exclusive with readpage&writepage that |
48 | do page cache read/write operations. | 49 | do page cache read/write operations. |
diff --git a/Documentation/hwmon/adt7462 b/Documentation/hwmon/adt7462 new file mode 100644 index 000000000000..ec660b328275 --- /dev/null +++ b/Documentation/hwmon/adt7462 | |||
@@ -0,0 +1,67 @@ | |||
1 | Kernel driver adt7462 | ||
2 | ====================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Analog Devices ADT7462 | ||
6 | Prefix: 'adt7462' | ||
7 | Addresses scanned: I2C 0x58, 0x5C | ||
8 | Datasheet: Publicly available at the Analog Devices website | ||
9 | |||
10 | Author: Darrick J. Wong | ||
11 | |||
12 | Description | ||
13 | ----------- | ||
14 | |||
15 | This driver implements support for the Analog Devices ADT7462 chip family. | ||
16 | |||
17 | This chip is a bit of a beast. It has 8 counters for measuring fan speed. It | ||
18 | can also measure 13 voltages or 4 temperatures, or various combinations of the | ||
19 | two. See the chip documentation for more details about the exact set of | ||
20 | configurations. This driver does not allow one to configure the chip; that is | ||
21 | left to the system designer. | ||
22 | |||
23 | A sophisticated control system for the PWM outputs is designed into the ADT7462 | ||
24 | that allows fan speed to be adjusted automatically based on any of the three | ||
25 | temperature sensors. Each PWM output is individually adjustable and | ||
26 | programmable. Once configured, the ADT7462 will adjust the PWM outputs in | ||
27 | response to the measured temperatures without further host intervention. This | ||
28 | feature can also be disabled for manual control of the PWM's. | ||
29 | |||
30 | Each of the measured inputs (voltage, temperature, fan speed) has | ||
31 | corresponding high/low limit values. The ADT7462 will signal an ALARM if | ||
32 | any measured value exceeds either limit. | ||
33 | |||
34 | The ADT7462 samples all inputs continuously. The driver will not read | ||
35 | the registers more often than once every other second. Further, | ||
36 | configuration data is only read once per minute. | ||
37 | |||
38 | Special Features | ||
39 | ---------------- | ||
40 | |||
41 | The ADT7462 have a 10-bit ADC and can therefore measure temperatures | ||
42 | with 0.25 degC resolution. | ||
43 | |||
44 | The Analog Devices datasheet is very detailed and describes a procedure for | ||
45 | determining an optimal configuration for the automatic PWM control. | ||
46 | |||
47 | The driver will report sensor labels when it is able to determine that | ||
48 | information from the configuration registers. | ||
49 | |||
50 | Configuration Notes | ||
51 | ------------------- | ||
52 | |||
53 | Besides standard interfaces driver adds the following: | ||
54 | |||
55 | * PWM Control | ||
56 | |||
57 | * pwm#_auto_point1_pwm and temp#_auto_point1_temp and | ||
58 | * pwm#_auto_point2_pwm and temp#_auto_point2_temp - | ||
59 | |||
60 | point1: Set the pwm speed at a lower temperature bound. | ||
61 | point2: Set the pwm speed at a higher temperature bound. | ||
62 | |||
63 | The ADT7462 will scale the pwm between the lower and higher pwm speed when | ||
64 | the temperature is between the two temperature boundaries. PWM values range | ||
65 | from 0 (off) to 255 (full speed). Fan speed will be set to maximum when the | ||
66 | temperature sensor associated with the PWM control exceeds temp#_max. | ||
67 | |||
diff --git a/Documentation/hwmon/lis3lv02d b/Documentation/hwmon/lis3lv02d new file mode 100644 index 000000000000..65dfb0c0fd67 --- /dev/null +++ b/Documentation/hwmon/lis3lv02d | |||
@@ -0,0 +1,49 @@ | |||
1 | Kernel driver lis3lv02d | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | |||
6 | * STMicroelectronics LIS3LV02DL and LIS3LV02DQ | ||
7 | |||
8 | Author: | ||
9 | Yan Burman <burman.yan@gmail.com> | ||
10 | Eric Piel <eric.piel@tremplin-utc.net> | ||
11 | |||
12 | |||
13 | Description | ||
14 | ----------- | ||
15 | |||
16 | This driver provides support for the accelerometer found in various HP laptops | ||
17 | sporting the feature officially called "HP Mobile Data Protection System 3D" or | ||
18 | "HP 3D DriveGuard". It detect automatically laptops with this sensor. Known models | ||
19 | (for now the HP 2133, nc6420, nc2510, nc8510, nc84x0, nw9440 and nx9420) will | ||
20 | have their axis automatically oriented on standard way (eg: you can directly | ||
21 | play neverball). The accelerometer data is readable via | ||
22 | /sys/devices/platform/lis3lv02d. | ||
23 | |||
24 | Sysfs attributes under /sys/devices/platform/lis3lv02d/: | ||
25 | position - 3D position that the accelerometer reports. Format: "(x,y,z)" | ||
26 | calibrate - read: values (x, y, z) that are used as the base for input class device operation. | ||
27 | write: forces the base to be recalibrated with the current position. | ||
28 | rate - reports the sampling rate of the accelerometer device in HZ | ||
29 | |||
30 | This driver also provides an absolute input class device, allowing | ||
31 | the laptop to act as a pinball machine-esque joystick. | ||
32 | |||
33 | Axes orientation | ||
34 | ---------------- | ||
35 | |||
36 | For better compatibility between the various laptops. The values reported by | ||
37 | the accelerometer are converted into a "standard" organisation of the axes | ||
38 | (aka "can play neverball out of the box"): | ||
39 | * When the laptop is horizontal the position reported is about 0 for X and Y | ||
40 | and a positive value for Z | ||
41 | * If the left side is elevated, X increases (becomes positive) | ||
42 | * If the front side (where the touchpad is) is elevated, Y decreases (becomes negative) | ||
43 | * If the laptop is put upside-down, Z becomes negative | ||
44 | |||
45 | If your laptop model is not recognized (cf "dmesg"), you can send an email to the | ||
46 | authors to add it to the database. When reporting a new laptop, please include | ||
47 | the output of "dmidecode" plus the value of /sys/devices/platform/lis3lv02d/position | ||
48 | in these four cases. | ||
49 | |||
diff --git a/Documentation/ics932s401 b/Documentation/ics932s401 new file mode 100644 index 000000000000..07a739f406d8 --- /dev/null +++ b/Documentation/ics932s401 | |||
@@ -0,0 +1,31 @@ | |||
1 | Kernel driver ics932s401 | ||
2 | ====================== | ||
3 | |||
4 | Supported chips: | ||
5 | * IDT ICS932S401 | ||
6 | Prefix: 'ics932s401' | ||
7 | Addresses scanned: I2C 0x69 | ||
8 | Datasheet: Publically available at the IDT website | ||
9 | |||
10 | Author: Darrick J. Wong | ||
11 | |||
12 | Description | ||
13 | ----------- | ||
14 | |||
15 | This driver implements support for the IDT ICS932S401 chip family. | ||
16 | |||
17 | This chip has 4 clock outputs--a base clock for the CPU (which is likely | ||
18 | multiplied to get the real CPU clock), a system clock, a PCI clock, a USB | ||
19 | clock, and a reference clock. The driver reports selected and actual | ||
20 | frequency. If spread spectrum mode is enabled, the driver also reports by what | ||
21 | percent the clock signal is being spread, which should be between 0 and -0.5%. | ||
22 | All frequencies are reported in KHz. | ||
23 | |||
24 | The ICS932S401 monitors all inputs continuously. The driver will not read | ||
25 | the registers more often than once every other second. | ||
26 | |||
27 | Special Features | ||
28 | ---------------- | ||
29 | |||
30 | The clocks could be reprogrammed to increase system speed. I will not help you | ||
31 | do this, as you risk damaging your system! | ||
diff --git a/Documentation/ioctl/00-INDEX b/Documentation/ioctl/00-INDEX new file mode 100644 index 000000000000..d2fe4d4729ef --- /dev/null +++ b/Documentation/ioctl/00-INDEX | |||
@@ -0,0 +1,10 @@ | |||
1 | 00-INDEX | ||
2 | - this file | ||
3 | cdrom.txt | ||
4 | - summary of CDROM ioctl calls | ||
5 | hdio.txt | ||
6 | - summary of HDIO_ ioctl calls | ||
7 | ioctl-decoding.txt | ||
8 | - how to decode the bits of an IOCTL code | ||
9 | ioctl-number.txt | ||
10 | - how to implement and register device/driver ioctl calls | ||
diff --git a/Documentation/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index b880ce5dbd33..b880ce5dbd33 100644 --- a/Documentation/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt | |||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 196fd1c62a2f..cf2ac2961fc2 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -198,59 +198,42 @@ and is between 256 and 4096 characters. It is defined in the file | |||
198 | that require a timer override, but don't have | 198 | that require a timer override, but don't have |
199 | HPET | 199 | HPET |
200 | 200 | ||
201 | acpi.debug_layer= [HW,ACPI] | 201 | acpi_backlight= [HW,ACPI] |
202 | acpi_backlight=vendor | ||
203 | acpi_backlight=video | ||
204 | If set to vendor, prefer vendor specific driver | ||
205 | (e.g. thinkpad_acpi, sony_acpi, etc.) instead | ||
206 | of the ACPI video.ko driver. | ||
207 | |||
208 | acpi_display_output= [HW,ACPI] | ||
209 | acpi_display_output=vendor | ||
210 | acpi_display_output=video | ||
211 | See above. | ||
212 | |||
213 | acpi.debug_layer= [HW,ACPI,ACPI_DEBUG] | ||
214 | acpi.debug_level= [HW,ACPI,ACPI_DEBUG] | ||
202 | Format: <int> | 215 | Format: <int> |
203 | Each bit of the <int> indicates an ACPI debug layer, | 216 | CONFIG_ACPI_DEBUG must be enabled to produce any ACPI |
204 | 1: enable, 0: disable. It is useful for boot time | 217 | debug output. Bits in debug_layer correspond to a |
205 | debugging. After system has booted up, it can be set | 218 | _COMPONENT in an ACPI source file, e.g., |
206 | via /sys/module/acpi/parameters/debug_layer. | 219 | #define _COMPONENT ACPI_PCI_COMPONENT |
207 | CONFIG_ACPI_DEBUG must be enabled for this to produce any output. | 220 | Bits in debug_level correspond to a level in |
208 | Available bits (add the numbers together) to enable debug output | 221 | ACPI_DEBUG_PRINT statements, e.g., |
209 | for specific parts of the ACPI subsystem: | 222 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, ... |
210 | 0x01 utilities 0x02 hardware 0x04 events 0x08 tables | 223 | See Documentation/acpi/debug.txt for more information |
211 | 0x10 namespace 0x20 parser 0x40 dispatcher | 224 | about debug layers and levels. |
212 | 0x80 executer 0x100 resources 0x200 acpica debugger | 225 | |
213 | 0x400 os services 0x800 acpica disassembler. | 226 | Enable AML "Debug" output, i.e., stores to the Debug |
214 | The number can be in decimal or prefixed with 0x in hex. | 227 | object while interpreting AML: |
215 | Warning: Many of these options can produce a lot of | 228 | acpi.debug_layer=0xffffffff acpi.debug_level=0x2 |
216 | output and make your system unusable. Be very careful. | 229 | Enable PCI/PCI interrupt routing info messages: |
217 | 230 | acpi.debug_layer=0x400000 acpi.debug_level=0x4 | |
218 | acpi.debug_level= [HW,ACPI] | 231 | Enable all messages related to ACPI hardware: |
219 | Format: <int> | 232 | acpi.debug_layer=0x2 acpi.debug_level=0xffffffff |
220 | Each bit of the <int> indicates an ACPI debug level, | 233 | |
221 | which corresponds to the level in an ACPI_DEBUG_PRINT | 234 | Some values produce so much output that the system is |
222 | statement. After system has booted up, this mask | 235 | unusable. The "log_buf_len" parameter may be useful |
223 | can be set via /sys/module/acpi/parameters/debug_level. | 236 | if you need to capture more output. |
224 | |||
225 | CONFIG_ACPI_DEBUG must be enabled for this to produce | ||
226 | any output. The number can be in decimal or prefixed | ||
227 | with 0x in hex. Some of these options produce so much | ||
228 | output that the system is unusable. | ||
229 | |||
230 | The following global components are defined by the | ||
231 | ACPI CA: | ||
232 | 0x01 error | ||
233 | 0x02 warn | ||
234 | 0x04 init | ||
235 | 0x08 debug object | ||
236 | 0x10 info | ||
237 | 0x20 init names | ||
238 | 0x40 parse | ||
239 | 0x80 load | ||
240 | 0x100 dispatch | ||
241 | 0x200 execute | ||
242 | 0x400 names | ||
243 | 0x800 operation region | ||
244 | 0x1000 bfield | ||
245 | 0x2000 tables | ||
246 | 0x4000 values | ||
247 | 0x8000 objects | ||
248 | 0x10000 resources | ||
249 | 0x20000 user requests | ||
250 | 0x40000 package | ||
251 | The number can be in decimal or prefixed with 0x in hex. | ||
252 | Warning: Many of these options can produce a lot of | ||
253 | output and make your system unusable. Be very careful. | ||
254 | 237 | ||
255 | acpi.power_nocheck= [HW,ACPI] | 238 | acpi.power_nocheck= [HW,ACPI] |
256 | Format: 1/0 enable/disable the check of power state. | 239 | Format: 1/0 enable/disable the check of power state. |
@@ -646,7 +629,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
646 | 629 | ||
647 | digiepca= [HW,SERIAL] | 630 | digiepca= [HW,SERIAL] |
648 | See drivers/char/README.epca and | 631 | See drivers/char/README.epca and |
649 | Documentation/digiepca.txt. | 632 | Documentation/serial/digiepca.txt. |
650 | 633 | ||
651 | disable_mtrr_cleanup [X86] | 634 | disable_mtrr_cleanup [X86] |
652 | enable_mtrr_cleanup [X86] | 635 | enable_mtrr_cleanup [X86] |
@@ -757,7 +740,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
757 | See header of drivers/scsi/fdomain.c. | 740 | See header of drivers/scsi/fdomain.c. |
758 | 741 | ||
759 | floppy= [HW] | 742 | floppy= [HW] |
760 | See Documentation/floppy.txt. | 743 | See Documentation/blockdev/floppy.txt. |
761 | 744 | ||
762 | force_pal_cache_flush | 745 | force_pal_cache_flush |
763 | [IA-64] Avoid check_sal_cache_flush which may hang on | 746 | [IA-64] Avoid check_sal_cache_flush which may hang on |
@@ -1126,7 +1109,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1126 | the same attribute, the last one is used. | 1109 | the same attribute, the last one is used. |
1127 | 1110 | ||
1128 | load_ramdisk= [RAM] List of ramdisks to load from floppy | 1111 | load_ramdisk= [RAM] List of ramdisks to load from floppy |
1129 | See Documentation/ramdisk.txt. | 1112 | See Documentation/blockdev/ramdisk.txt. |
1130 | 1113 | ||
1131 | lockd.nlm_grace_period=P [NFS] Assign grace period. | 1114 | lockd.nlm_grace_period=P [NFS] Assign grace period. |
1132 | Format: <integer> | 1115 | Format: <integer> |
@@ -1621,7 +1604,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1621 | 1604 | ||
1622 | pcd. [PARIDE] | 1605 | pcd. [PARIDE] |
1623 | See header of drivers/block/paride/pcd.c. | 1606 | See header of drivers/block/paride/pcd.c. |
1624 | See also Documentation/paride.txt. | 1607 | See also Documentation/blockdev/paride.txt. |
1625 | 1608 | ||
1626 | pci=option[,option...] [PCI] various PCI subsystem options: | 1609 | pci=option[,option...] [PCI] various PCI subsystem options: |
1627 | off [X86] don't probe for the PCI bus | 1610 | off [X86] don't probe for the PCI bus |
@@ -1722,7 +1705,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1722 | pcmv= [HW,PCMCIA] BadgePAD 4 | 1705 | pcmv= [HW,PCMCIA] BadgePAD 4 |
1723 | 1706 | ||
1724 | pd. [PARIDE] | 1707 | pd. [PARIDE] |
1725 | See Documentation/paride.txt. | 1708 | See Documentation/blockdev/paride.txt. |
1726 | 1709 | ||
1727 | pdcchassis= [PARISC,HW] Disable/Enable PDC Chassis Status codes at | 1710 | pdcchassis= [PARISC,HW] Disable/Enable PDC Chassis Status codes at |
1728 | boot time. | 1711 | boot time. |
@@ -1730,10 +1713,10 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1730 | See arch/parisc/kernel/pdc_chassis.c | 1713 | See arch/parisc/kernel/pdc_chassis.c |
1731 | 1714 | ||
1732 | pf. [PARIDE] | 1715 | pf. [PARIDE] |
1733 | See Documentation/paride.txt. | 1716 | See Documentation/blockdev/paride.txt. |
1734 | 1717 | ||
1735 | pg. [PARIDE] | 1718 | pg. [PARIDE] |
1736 | See Documentation/paride.txt. | 1719 | See Documentation/blockdev/paride.txt. |
1737 | 1720 | ||
1738 | pirq= [SMP,APIC] Manual mp-table setup | 1721 | pirq= [SMP,APIC] Manual mp-table setup |
1739 | See Documentation/x86/i386/IO-APIC.txt. | 1722 | See Documentation/x86/i386/IO-APIC.txt. |
@@ -1803,7 +1786,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1803 | 1786 | ||
1804 | prompt_ramdisk= [RAM] List of RAM disks to prompt for floppy disk | 1787 | prompt_ramdisk= [RAM] List of RAM disks to prompt for floppy disk |
1805 | before loading. | 1788 | before loading. |
1806 | See Documentation/ramdisk.txt. | 1789 | See Documentation/blockdev/ramdisk.txt. |
1807 | 1790 | ||
1808 | psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to | 1791 | psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to |
1809 | probe for; one of (bare|imps|exps|lifebook|any). | 1792 | probe for; one of (bare|imps|exps|lifebook|any). |
@@ -1823,7 +1806,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1823 | <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq> | 1806 | <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq> |
1824 | 1807 | ||
1825 | pt. [PARIDE] | 1808 | pt. [PARIDE] |
1826 | See Documentation/paride.txt. | 1809 | See Documentation/blockdev/paride.txt. |
1827 | 1810 | ||
1828 | pty.legacy_count= | 1811 | pty.legacy_count= |
1829 | [KNL] Number of legacy pty's. Overwrites compiled-in | 1812 | [KNL] Number of legacy pty's. Overwrites compiled-in |
@@ -1837,10 +1820,10 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1837 | See Documentation/md.txt. | 1820 | See Documentation/md.txt. |
1838 | 1821 | ||
1839 | ramdisk_blocksize= [RAM] | 1822 | ramdisk_blocksize= [RAM] |
1840 | See Documentation/ramdisk.txt. | 1823 | See Documentation/blockdev/ramdisk.txt. |
1841 | 1824 | ||
1842 | ramdisk_size= [RAM] Sizes of RAM disks in kilobytes | 1825 | ramdisk_size= [RAM] Sizes of RAM disks in kilobytes |
1843 | See Documentation/ramdisk.txt. | 1826 | See Documentation/blockdev/ramdisk.txt. |
1844 | 1827 | ||
1845 | rcupdate.blimit= [KNL,BOOT] | 1828 | rcupdate.blimit= [KNL,BOOT] |
1846 | Set maximum number of finished RCU callbacks to process | 1829 | Set maximum number of finished RCU callbacks to process |
@@ -2172,7 +2155,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
2172 | See Documentation/sonypi.txt | 2155 | See Documentation/sonypi.txt |
2173 | 2156 | ||
2174 | specialix= [HW,SERIAL] Specialix multi-serial port adapter | 2157 | specialix= [HW,SERIAL] Specialix multi-serial port adapter |
2175 | See Documentation/specialix.txt. | 2158 | See Documentation/serial/specialix.txt. |
2176 | 2159 | ||
2177 | spia_io_base= [HW,MTD] | 2160 | spia_io_base= [HW,MTD] |
2178 | spia_fio_base= | 2161 | spia_fio_base= |
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt new file mode 100644 index 000000000000..1b5a5ddbc3ef --- /dev/null +++ b/Documentation/printk-formats.txt | |||
@@ -0,0 +1,35 @@ | |||
1 | If variable is of Type, use printk format specifier: | ||
2 | --------------------------------------------------------- | ||
3 | int %d or %x | ||
4 | unsigned int %u or %x | ||
5 | long %ld or %lx | ||
6 | unsigned long %lu or %lx | ||
7 | long long %lld or %llx | ||
8 | unsigned long long %llu or %llx | ||
9 | size_t %zu or %zx | ||
10 | ssize_t %zd or %zx | ||
11 | |||
12 | Raw pointer value SHOULD be printed with %p. | ||
13 | |||
14 | u64 SHOULD be printed with %llu/%llx, (unsigned long long): | ||
15 | |||
16 | printk("%llu", (unsigned long long)u64_var); | ||
17 | |||
18 | s64 SHOULD be printed with %lld/%llx, (long long): | ||
19 | |||
20 | printk("%lld", (long long)s64_var); | ||
21 | |||
22 | If <type> is dependent on a config option for its size (e.g., sector_t, | ||
23 | blkcnt_t, phys_addr_t, resource_size_t) or is architecture-dependent | ||
24 | for its size (e.g., tcflag_t), use a format specifier of its largest | ||
25 | possible type and explicitly cast to it. Example: | ||
26 | |||
27 | printk("test: sector number/total blocks: %llu/%llu\n", | ||
28 | (unsigned long long)sector, (unsigned long long)blockcount); | ||
29 | |||
30 | Reminder: sizeof() result is of type size_t. | ||
31 | |||
32 | Thank you for your cooperation and attention. | ||
33 | |||
34 | |||
35 | By Randy Dunlap <rdunlap@xenotime.net> | ||
diff --git a/Documentation/serial/00-INDEX b/Documentation/serial/00-INDEX new file mode 100644 index 000000000000..07dcdb0d2a36 --- /dev/null +++ b/Documentation/serial/00-INDEX | |||
@@ -0,0 +1,24 @@ | |||
1 | 00-INDEX | ||
2 | - this file. | ||
3 | README.cycladesZ | ||
4 | - info on Cyclades-Z firmware loading. | ||
5 | computone.txt | ||
6 | - info on Computone Intelliport II/Plus Multiport Serial Driver. | ||
7 | digiepca.txt | ||
8 | - info on Digi Intl. {PC,PCI,EISA}Xx and Xem series cards. | ||
9 | hayes-esp.txt | ||
10 | - info on using the Hayes ESP serial driver. | ||
11 | moxa-smartio | ||
12 | - file with info on installing/using Moxa multiport serial driver. | ||
13 | riscom8.txt | ||
14 | - notes on using the RISCom/8 multi-port serial driver. | ||
15 | rocket.txt | ||
16 | - info on the Comtrol RocketPort multiport serial driver. | ||
17 | specialix.txt | ||
18 | - info on hardware/driver for specialix IO8+ multiport serial card. | ||
19 | stallion.txt | ||
20 | - info on using the Stallion multiport serial driver. | ||
21 | sx.txt | ||
22 | - info on the Specialix SX/SI multiport serial driver. | ||
23 | tty.txt | ||
24 | - guide to the locking policies of the tty layer. | ||
diff --git a/Documentation/README.cycladesZ b/Documentation/serial/README.cycladesZ index 024a69443cc2..024a69443cc2 100644 --- a/Documentation/README.cycladesZ +++ b/Documentation/serial/README.cycladesZ | |||
diff --git a/Documentation/computone.txt b/Documentation/serial/computone.txt index 5e2a0c76bfa0..c57ea4781e5d 100644 --- a/Documentation/computone.txt +++ b/Documentation/serial/computone.txt | |||
@@ -247,7 +247,7 @@ shar archive to make it easier to extract the script from the documentation. | |||
247 | To create the ip2mkdev shell script change to a convenient directory (/tmp | 247 | To create the ip2mkdev shell script change to a convenient directory (/tmp |
248 | works just fine) and run the following command: | 248 | works just fine) and run the following command: |
249 | 249 | ||
250 | unshar Documentation/computone.txt | 250 | unshar Documentation/serial/computone.txt |
251 | (This file) | 251 | (This file) |
252 | 252 | ||
253 | You should now have a file ip2mkdev in your current working directory with | 253 | You should now have a file ip2mkdev in your current working directory with |
diff --git a/Documentation/digiepca.txt b/Documentation/serial/digiepca.txt index f2560e22f2c9..f2560e22f2c9 100644 --- a/Documentation/digiepca.txt +++ b/Documentation/serial/digiepca.txt | |||
diff --git a/Documentation/hayes-esp.txt b/Documentation/serial/hayes-esp.txt index 09b5d5856758..09b5d5856758 100644 --- a/Documentation/hayes-esp.txt +++ b/Documentation/serial/hayes-esp.txt | |||
diff --git a/Documentation/moxa-smartio b/Documentation/serial/moxa-smartio index 5337e80a5b96..5337e80a5b96 100644 --- a/Documentation/moxa-smartio +++ b/Documentation/serial/moxa-smartio | |||
diff --git a/Documentation/riscom8.txt b/Documentation/serial/riscom8.txt index 14f61fdad7ca..14f61fdad7ca 100644 --- a/Documentation/riscom8.txt +++ b/Documentation/serial/riscom8.txt | |||
diff --git a/Documentation/rocket.txt b/Documentation/serial/rocket.txt index 1d8582990435..1d8582990435 100644 --- a/Documentation/rocket.txt +++ b/Documentation/serial/rocket.txt | |||
diff --git a/Documentation/specialix.txt b/Documentation/serial/specialix.txt index 6eb6f3a3331c..6eb6f3a3331c 100644 --- a/Documentation/specialix.txt +++ b/Documentation/serial/specialix.txt | |||
diff --git a/Documentation/stallion.txt b/Documentation/serial/stallion.txt index 5c4902d9a5be..5c4902d9a5be 100644 --- a/Documentation/stallion.txt +++ b/Documentation/serial/stallion.txt | |||
diff --git a/Documentation/sx.txt b/Documentation/serial/sx.txt index cb4efa0fb5cc..cb4efa0fb5cc 100644 --- a/Documentation/sx.txt +++ b/Documentation/serial/sx.txt | |||
diff --git a/Documentation/tty.txt b/Documentation/serial/tty.txt index 8e65c4498c52..8e65c4498c52 100644 --- a/Documentation/tty.txt +++ b/Documentation/serial/tty.txt | |||
diff --git a/Documentation/w1/masters/omap-hdq b/Documentation/w1/masters/omap-hdq new file mode 100644 index 000000000000..ca722e09b6a1 --- /dev/null +++ b/Documentation/w1/masters/omap-hdq | |||
@@ -0,0 +1,46 @@ | |||
1 | Kernel driver for omap HDQ/1-wire module. | ||
2 | ======================================== | ||
3 | |||
4 | Supported chips: | ||
5 | ================ | ||
6 | HDQ/1-wire controller on the TI OMAP 2430/3430 platforms. | ||
7 | |||
8 | A useful link about HDQ basics: | ||
9 | =============================== | ||
10 | http://focus.ti.com/lit/an/slua408/slua408.pdf | ||
11 | |||
12 | Description: | ||
13 | ============ | ||
14 | The HDQ/1-Wire module of TI OMAP2430/3430 platforms implement the hardware | ||
15 | protocol of the master functions of the Benchmark HDQ and the Dallas | ||
16 | Semiconductor 1-Wire protocols. These protocols use a single wire for | ||
17 | communication between the master (HDQ/1-Wire controller) and the slave | ||
18 | (HDQ/1-Wire external compliant device). | ||
19 | |||
20 | A typical application of the HDQ/1-Wire module is the communication with battery | ||
21 | monitor (gas gauge) integrated circuits. | ||
22 | |||
23 | The controller supports operation in both HDQ and 1-wire mode. The essential | ||
24 | difference between the HDQ and 1-wire mode is how the slave device responds to | ||
25 | initialization pulse.In HDQ mode, the firmware does not require the host to | ||
26 | create an initialization pulse to the slave.However, the slave can be reset by | ||
27 | using an initialization pulse (also referred to as a break pulse).The slave | ||
28 | does not respond with a presence pulse as it does in the 1-Wire protocol. | ||
29 | |||
30 | Remarks: | ||
31 | ======== | ||
32 | The driver (drivers/w1/masters/omap_hdq.c) supports the HDQ mode of the | ||
33 | controller. In this mode, as we can not read the ID which obeys the W1 | ||
34 | spec(family:id:crc), a module parameter can be passed to the driver which will | ||
35 | be used to calculate the CRC and pass back an appropriate slave ID to the W1 | ||
36 | core. | ||
37 | |||
38 | By default the master driver and the BQ slave i/f | ||
39 | driver(drivers/w1/slaves/w1_bq27000.c) sets the ID to 1. | ||
40 | Please note to load both the modules with a different ID if required, but note | ||
41 | that the ID used should be same for both master and slave driver loading. | ||
42 | |||
43 | e.g: | ||
44 | insmod omap_hdq.ko W1_ID=2 | ||
45 | inamod w1_bq27000.ko F_ID=2 | ||
46 | |||
diff --git a/MAINTAINERS b/MAINTAINERS index 53e78c83cc7a..627e4c89328e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2216,6 +2216,13 @@ M: adaplas@gmail.com | |||
2216 | L: linux-fbdev-devel@lists.sourceforge.net (moderated for non-subscribers) | 2216 | L: linux-fbdev-devel@lists.sourceforge.net (moderated for non-subscribers) |
2217 | S: Maintained | 2217 | S: Maintained |
2218 | 2218 | ||
2219 | INTEL MENLOW THERMAL DRIVER | ||
2220 | P: Sujith Thomas | ||
2221 | M: sujith.thomas@intel.com | ||
2222 | L: linux-acpi@vger.kernel.org | ||
2223 | W: http://www.lesswatts.org/projects/acpi/ | ||
2224 | S: Supported | ||
2225 | |||
2219 | INTEL IA32 MICROCODE UPDATE SUPPORT | 2226 | INTEL IA32 MICROCODE UPDATE SUPPORT |
2220 | P: Tigran Aivazian | 2227 | P: Tigran Aivazian |
2221 | M: tigran@aivazian.fsnet.co.uk | 2228 | M: tigran@aivazian.fsnet.co.uk |
@@ -2696,6 +2703,11 @@ P: Arnaldo Carvalho de Melo | |||
2696 | M: acme@ghostprotocols.net | 2703 | M: acme@ghostprotocols.net |
2697 | S: Maintained | 2704 | S: Maintained |
2698 | 2705 | ||
2706 | LIS3LV02D ACCELEROMETER DRIVER | ||
2707 | P: Eric Piel | ||
2708 | M: eric.piel@tremplin-utc.net | ||
2709 | S: Maintained | ||
2710 | |||
2699 | LM83 HARDWARE MONITOR DRIVER | 2711 | LM83 HARDWARE MONITOR DRIVER |
2700 | P: Jean Delvare | 2712 | P: Jean Delvare |
2701 | M: khali@linux-fr.org | 2713 | M: khali@linux-fr.org |
@@ -3377,7 +3389,9 @@ S: Maintained | |||
3377 | 3389 | ||
3378 | PNP SUPPORT | 3390 | PNP SUPPORT |
3379 | P: Adam Belay | 3391 | P: Adam Belay |
3380 | M: ambx1@neo.rr.com | 3392 | M: abelay@mit.edu |
3393 | P: Bjorn Helgaas | ||
3394 | M: bjorn.helgaas@hp.com | ||
3381 | S: Maintained | 3395 | S: Maintained |
3382 | 3396 | ||
3383 | PNXxxxx I2C DRIVER | 3397 | PNXxxxx I2C DRIVER |
@@ -3914,8 +3928,6 @@ M: bootc@bootc.net | |||
3914 | S: Maintained | 3928 | S: Maintained |
3915 | 3929 | ||
3916 | SOFTWARE RAID (Multiple Disks) SUPPORT | 3930 | SOFTWARE RAID (Multiple Disks) SUPPORT |
3917 | P: Ingo Molnar | ||
3918 | M: mingo@redhat.com | ||
3919 | P: Neil Brown | 3931 | P: Neil Brown |
3920 | M: neilb@suse.de | 3932 | M: neilb@suse.de |
3921 | L: linux-raid@vger.kernel.org | 3933 | L: linux-raid@vger.kernel.org |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 2 | 1 | VERSION = 2 |
2 | PATCHLEVEL = 6 | 2 | PATCHLEVEL = 6 |
3 | SUBLEVEL = 28 | 3 | SUBLEVEL = 28 |
4 | EXTRAVERSION = -rc4 | 4 | EXTRAVERSION = -rc5 |
5 | NAME = Killer Bat of Doom | 5 | NAME = Killer Bat of Doom |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 1cb8602dd9d5..4ed149cbb32a 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -256,8 +256,17 @@ int dmabounce_sync_for_cpu(struct device *, dma_addr_t, unsigned long, | |||
256 | int dmabounce_sync_for_device(struct device *, dma_addr_t, unsigned long, | 256 | int dmabounce_sync_for_device(struct device *, dma_addr_t, unsigned long, |
257 | size_t, enum dma_data_direction); | 257 | size_t, enum dma_data_direction); |
258 | #else | 258 | #else |
259 | #define dmabounce_sync_for_cpu(dev,dma,off,sz,dir) (1) | 259 | static inline int dmabounce_sync_for_cpu(struct device *d, dma_addr_t addr, |
260 | #define dmabounce_sync_for_device(dev,dma,off,sz,dir) (1) | 260 | unsigned long offset, size_t size, enum dma_data_direction dir) |
261 | { | ||
262 | return 1; | ||
263 | } | ||
264 | |||
265 | static inline int dmabounce_sync_for_device(struct device *d, dma_addr_t addr, | ||
266 | unsigned long offset, size_t size, enum dma_data_direction dir) | ||
267 | { | ||
268 | return 1; | ||
269 | } | ||
261 | 270 | ||
262 | 271 | ||
263 | /** | 272 | /** |
diff --git a/arch/arm/include/asm/hardware/iop3xx-adma.h b/arch/arm/include/asm/hardware/iop3xx-adma.h index 87bff09633aa..83e6ba338e2c 100644 --- a/arch/arm/include/asm/hardware/iop3xx-adma.h +++ b/arch/arm/include/asm/hardware/iop3xx-adma.h | |||
@@ -730,7 +730,8 @@ static inline void iop_desc_set_next_desc(struct iop_adma_desc_slot *desc, | |||
730 | { | 730 | { |
731 | /* hw_desc->next_desc is the same location for all channels */ | 731 | /* hw_desc->next_desc is the same location for all channels */ |
732 | union iop3xx_desc hw_desc = { .ptr = desc->hw_desc, }; | 732 | union iop3xx_desc hw_desc = { .ptr = desc->hw_desc, }; |
733 | BUG_ON(hw_desc.dma->next_desc); | 733 | |
734 | iop_paranoia(hw_desc.dma->next_desc); | ||
734 | hw_desc.dma->next_desc = next_desc_addr; | 735 | hw_desc.dma->next_desc = next_desc_addr; |
735 | } | 736 | } |
736 | 737 | ||
@@ -760,7 +761,7 @@ static inline int iop_desc_get_zero_result(struct iop_adma_desc_slot *desc) | |||
760 | struct iop3xx_desc_aau *hw_desc = desc->hw_desc; | 761 | struct iop3xx_desc_aau *hw_desc = desc->hw_desc; |
761 | struct iop3xx_aau_desc_ctrl desc_ctrl = hw_desc->desc_ctrl_field; | 762 | struct iop3xx_aau_desc_ctrl desc_ctrl = hw_desc->desc_ctrl_field; |
762 | 763 | ||
763 | BUG_ON(!(desc_ctrl.tx_complete && desc_ctrl.zero_result_en)); | 764 | iop_paranoia(!(desc_ctrl.tx_complete && desc_ctrl.zero_result_en)); |
764 | return desc_ctrl.zero_result_err; | 765 | return desc_ctrl.zero_result_err; |
765 | } | 766 | } |
766 | 767 | ||
diff --git a/arch/arm/include/asm/hardware/iop_adma.h b/arch/arm/include/asm/hardware/iop_adma.h index cb7e3611bcba..385c6e8cbbd2 100644 --- a/arch/arm/include/asm/hardware/iop_adma.h +++ b/arch/arm/include/asm/hardware/iop_adma.h | |||
@@ -23,6 +23,12 @@ | |||
23 | 23 | ||
24 | #define IOP_ADMA_SLOT_SIZE 32 | 24 | #define IOP_ADMA_SLOT_SIZE 32 |
25 | #define IOP_ADMA_THRESHOLD 4 | 25 | #define IOP_ADMA_THRESHOLD 4 |
26 | #ifdef DEBUG | ||
27 | #define IOP_PARANOIA 1 | ||
28 | #else | ||
29 | #define IOP_PARANOIA 0 | ||
30 | #endif | ||
31 | #define iop_paranoia(x) BUG_ON(IOP_PARANOIA && (x)) | ||
26 | 32 | ||
27 | /** | 33 | /** |
28 | * struct iop_adma_device - internal representation of an ADMA device | 34 | * struct iop_adma_device - internal representation of an ADMA device |
diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h index cb1139ac1943..39d949b63e80 100644 --- a/arch/arm/include/asm/mach/map.h +++ b/arch/arm/include/asm/mach/map.h | |||
@@ -19,12 +19,13 @@ struct map_desc { | |||
19 | }; | 19 | }; |
20 | 20 | ||
21 | /* types 0-3 are defined in asm/io.h */ | 21 | /* types 0-3 are defined in asm/io.h */ |
22 | #define MT_CACHECLEAN 4 | 22 | #define MT_UNCACHED 4 |
23 | #define MT_MINICLEAN 5 | 23 | #define MT_CACHECLEAN 5 |
24 | #define MT_LOW_VECTORS 6 | 24 | #define MT_MINICLEAN 6 |
25 | #define MT_HIGH_VECTORS 7 | 25 | #define MT_LOW_VECTORS 7 |
26 | #define MT_MEMORY 8 | 26 | #define MT_HIGH_VECTORS 8 |
27 | #define MT_ROM 9 | 27 | #define MT_MEMORY 9 |
28 | #define MT_ROM 10 | ||
28 | 29 | ||
29 | #ifdef CONFIG_MMU | 30 | #ifdef CONFIG_MMU |
30 | extern void iotable_init(struct map_desc *, int); | 31 | extern void iotable_init(struct map_desc *, int); |
diff --git a/arch/arm/mach-clps711x/include/mach/hardware.h b/arch/arm/mach-clps711x/include/mach/hardware.h index 4c3e101b96c9..b3ebe9e4871f 100644 --- a/arch/arm/mach-clps711x/include/mach/hardware.h +++ b/arch/arm/mach-clps711x/include/mach/hardware.h | |||
@@ -94,20 +94,6 @@ | |||
94 | #include <asm/hardware/ep7212.h> | 94 | #include <asm/hardware/ep7212.h> |
95 | #include <asm/hardware/cs89712.h> | 95 | #include <asm/hardware/cs89712.h> |
96 | 96 | ||
97 | /* dynamic ioremap() areas */ | ||
98 | #define FLASH_START 0x00000000 | ||
99 | #define FLASH_SIZE 0x800000 | ||
100 | #define FLASH_WIDTH 4 | ||
101 | |||
102 | #define SRAM_START 0x60000000 | ||
103 | #define SRAM_SIZE 0xc000 | ||
104 | #define SRAM_WIDTH 4 | ||
105 | |||
106 | #define BOOTROM_START 0x70000000 | ||
107 | #define BOOTROM_SIZE 0x80 | ||
108 | #define BOOTROM_WIDTH 4 | ||
109 | |||
110 | |||
111 | /* static cdb89712_map_io() areas */ | 97 | /* static cdb89712_map_io() areas */ |
112 | #define REGISTER_START 0x80000000 | 98 | #define REGISTER_START 0x80000000 |
113 | #define REGISTER_SIZE 0x4000 | 99 | #define REGISTER_SIZE 0x4000 |
@@ -198,14 +184,6 @@ | |||
198 | #define CEIVA_FLASH_SIZE 0x100000 | 184 | #define CEIVA_FLASH_SIZE 0x100000 |
199 | #define CEIVA_FLASH_WIDTH 2 | 185 | #define CEIVA_FLASH_WIDTH 2 |
200 | 186 | ||
201 | #define SRAM_START 0x60000000 | ||
202 | #define SRAM_SIZE 0xc000 | ||
203 | #define SRAM_WIDTH 4 | ||
204 | |||
205 | #define BOOTROM_START 0x70000000 | ||
206 | #define BOOTROM_SIZE 0x80 | ||
207 | #define BOOTROM_WIDTH 4 | ||
208 | |||
209 | /* | 187 | /* |
210 | * SED1355 LCD controller | 188 | * SED1355 LCD controller |
211 | */ | 189 | */ |
diff --git a/arch/arm/mach-clps7500/core.c b/arch/arm/mach-clps7500/core.c index c3a33b8a5aac..7e247c04d41c 100644 --- a/arch/arm/mach-clps7500/core.c +++ b/arch/arm/mach-clps7500/core.c | |||
@@ -275,9 +275,9 @@ static struct map_desc cl7500_io_desc[] __initdata = { | |||
275 | .length = ISA_SIZE, | 275 | .length = ISA_SIZE, |
276 | .type = MT_DEVICE | 276 | .type = MT_DEVICE |
277 | }, { /* Flash */ | 277 | }, { /* Flash */ |
278 | .virtual = FLASH_BASE, | 278 | .virtual = CLPS7500_FLASH_BASE, |
279 | .pfn = __phys_to_pfn(FLASH_START), | 279 | .pfn = __phys_to_pfn(CLPS7500_FLASH_START), |
280 | .length = FLASH_SIZE, | 280 | .length = CLPS7500_FLASH_SIZE, |
281 | .type = MT_DEVICE | 281 | .type = MT_DEVICE |
282 | }, { /* LED */ | 282 | }, { /* LED */ |
283 | .virtual = LED_BASE, | 283 | .virtual = LED_BASE, |
diff --git a/arch/arm/mach-clps7500/include/mach/hardware.h b/arch/arm/mach-clps7500/include/mach/hardware.h index d66578a3371c..a6ad1d44badf 100644 --- a/arch/arm/mach-clps7500/include/mach/hardware.h +++ b/arch/arm/mach-clps7500/include/mach/hardware.h | |||
@@ -39,9 +39,9 @@ | |||
39 | #define ISA_SIZE 0x00010000 | 39 | #define ISA_SIZE 0x00010000 |
40 | #define ISA_BASE 0xe1000000 | 40 | #define ISA_BASE 0xe1000000 |
41 | 41 | ||
42 | #define FLASH_START 0x01000000 /* XXX */ | 42 | #define CLPS7500_FLASH_START 0x01000000 /* XXX */ |
43 | #define FLASH_SIZE 0x01000000 | 43 | #define CLPS7500_FLASH_SIZE 0x01000000 |
44 | #define FLASH_BASE 0xe2000000 | 44 | #define CLPS7500_FLASH_BASE 0xe2000000 |
45 | 45 | ||
46 | #define LED_START 0x0302B000 | 46 | #define LED_START 0x0302B000 |
47 | #define LED_SIZE 0x00001000 | 47 | #define LED_SIZE 0x00001000 |
diff --git a/arch/arm/mach-h720x/include/mach/boards.h b/arch/arm/mach-h720x/include/mach/boards.h index 079b279e1242..38b8e0d61fbf 100644 --- a/arch/arm/mach-h720x/include/mach/boards.h +++ b/arch/arm/mach-h720x/include/mach/boards.h | |||
@@ -19,9 +19,9 @@ | |||
19 | #ifdef CONFIG_ARCH_H7202 | 19 | #ifdef CONFIG_ARCH_H7202 |
20 | 20 | ||
21 | /* FLASH */ | 21 | /* FLASH */ |
22 | #define FLASH_VIRT 0xd0000000 | 22 | #define H720X_FLASH_VIRT 0xd0000000 |
23 | #define FLASH_PHYS 0x00000000 | 23 | #define H720X_FLASH_PHYS 0x00000000 |
24 | #define FLASH_SIZE 0x02000000 | 24 | #define H720X_FLASH_SIZE 0x02000000 |
25 | 25 | ||
26 | /* onboard LAN controller */ | 26 | /* onboard LAN controller */ |
27 | # define ETH0_PHYS 0x08000000 | 27 | # define ETH0_PHYS 0x08000000 |
diff --git a/arch/arm/mach-integrator/include/mach/platform.h b/arch/arm/mach-integrator/include/mach/platform.h index 028b87839c0f..e00a2624f269 100644 --- a/arch/arm/mach-integrator/include/mach/platform.h +++ b/arch/arm/mach-integrator/include/mach/platform.h | |||
@@ -408,27 +408,10 @@ | |||
408 | #define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE | 408 | #define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE |
409 | 409 | ||
410 | /* | 410 | /* |
411 | * Application Flash | ||
412 | * | ||
413 | */ | ||
414 | #define FLASH_BASE INTEGRATOR_FLASH_BASE | ||
415 | #define FLASH_SIZE INTEGRATOR_FLASH_SIZE | ||
416 | #define FLASH_END (FLASH_BASE + FLASH_SIZE - 1) | ||
417 | #define FLASH_BLOCK_SIZE SZ_128K | ||
418 | |||
419 | /* | ||
420 | * Boot Flash | ||
421 | * | ||
422 | */ | ||
423 | #define EPROM_BASE INTEGRATOR_BOOT_ROM_HI | ||
424 | #define EPROM_SIZE INTEGRATOR_BOOT_ROM_SIZE | ||
425 | #define EPROM_END (EPROM_BASE + EPROM_SIZE - 1) | ||
426 | |||
427 | /* | ||
428 | * Clean base - dummy | 411 | * Clean base - dummy |
429 | * | 412 | * |
430 | */ | 413 | */ |
431 | #define CLEAN_BASE EPROM_BASE | 414 | #define CLEAN_BASE INTEGRATOR_BOOT_ROM_HI |
432 | 415 | ||
433 | /* | 416 | /* |
434 | * Timer definitions | 417 | * Timer definitions |
diff --git a/arch/arm/mach-iop13xx/include/mach/adma.h b/arch/arm/mach-iop13xx/include/mach/adma.h index 60019c8e6465..5722e86f2174 100644 --- a/arch/arm/mach-iop13xx/include/mach/adma.h +++ b/arch/arm/mach-iop13xx/include/mach/adma.h | |||
@@ -404,7 +404,8 @@ static inline void iop_desc_set_next_desc(struct iop_adma_desc_slot *desc, | |||
404 | u32 next_desc_addr) | 404 | u32 next_desc_addr) |
405 | { | 405 | { |
406 | struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; | 406 | struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; |
407 | BUG_ON(hw_desc->next_desc); | 407 | |
408 | iop_paranoia(hw_desc->next_desc); | ||
408 | hw_desc->next_desc = next_desc_addr; | 409 | hw_desc->next_desc = next_desc_addr; |
409 | } | 410 | } |
410 | 411 | ||
diff --git a/arch/arm/mach-realview/clock.c b/arch/arm/mach-realview/clock.c index 3e706c57833a..3347c4236a60 100644 --- a/arch/arm/mach-realview/clock.c +++ b/arch/arm/mach-realview/clock.c | |||
@@ -104,7 +104,7 @@ static struct clk uart_clk = { | |||
104 | 104 | ||
105 | static struct clk mmci_clk = { | 105 | static struct clk mmci_clk = { |
106 | .name = "MCLK", | 106 | .name = "MCLK", |
107 | .rate = 33000000, | 107 | .rate = 24000000, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | int clk_register(struct clk *clk) | 110 | int clk_register(struct clk *clk) |
diff --git a/arch/arm/mach-realview/include/mach/platform.h b/arch/arm/mach-realview/include/mach/platform.h index 4034b54950c2..793a3a332712 100644 --- a/arch/arm/mach-realview/include/mach/platform.h +++ b/arch/arm/mach-realview/include/mach/platform.h | |||
@@ -239,27 +239,10 @@ | |||
239 | #define REALVIEW_DECODE_OFFSET 0xC /* Fitted logic modules */ | 239 | #define REALVIEW_DECODE_OFFSET 0xC /* Fitted logic modules */ |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * Application Flash | ||
243 | * | ||
244 | */ | ||
245 | #define FLASH_BASE REALVIEW_FLASH_BASE | ||
246 | #define FLASH_SIZE REALVIEW_FLASH_SIZE | ||
247 | #define FLASH_END (FLASH_BASE + FLASH_SIZE - 1) | ||
248 | #define FLASH_BLOCK_SIZE SZ_128K | ||
249 | |||
250 | /* | ||
251 | * Boot Flash | ||
252 | * | ||
253 | */ | ||
254 | #define EPROM_BASE REALVIEW_BOOT_ROM_HI | ||
255 | #define EPROM_SIZE REALVIEW_BOOT_ROM_SIZE | ||
256 | #define EPROM_END (EPROM_BASE + EPROM_SIZE - 1) | ||
257 | |||
258 | /* | ||
259 | * Clean base - dummy | 242 | * Clean base - dummy |
260 | * | 243 | * |
261 | */ | 244 | */ |
262 | #define CLEAN_BASE EPROM_BASE | 245 | #define CLEAN_BASE REALVIEW_BOOT_ROM_HI |
263 | 246 | ||
264 | /* | 247 | /* |
265 | * System controller bit assignment | 248 | * System controller bit assignment |
diff --git a/arch/arm/mach-versatile/clock.c b/arch/arm/mach-versatile/clock.c index 9336508ec0b2..58937f1fb38c 100644 --- a/arch/arm/mach-versatile/clock.c +++ b/arch/arm/mach-versatile/clock.c | |||
@@ -105,7 +105,7 @@ static struct clk uart_clk = { | |||
105 | 105 | ||
106 | static struct clk mmci_clk = { | 106 | static struct clk mmci_clk = { |
107 | .name = "MCLK", | 107 | .name = "MCLK", |
108 | .rate = 33000000, | 108 | .rate = 24000000, |
109 | }; | 109 | }; |
110 | 110 | ||
111 | int clk_register(struct clk *clk) | 111 | int clk_register(struct clk *clk) |
diff --git a/arch/arm/mach-versatile/include/mach/platform.h b/arch/arm/mach-versatile/include/mach/platform.h index 27cbe6a3f220..f91ba930ca8a 100644 --- a/arch/arm/mach-versatile/include/mach/platform.h +++ b/arch/arm/mach-versatile/include/mach/platform.h | |||
@@ -436,28 +436,12 @@ | |||
436 | #define SIC_INTMASK_PCI1 (1 << SIC_INT_PCI1) | 436 | #define SIC_INTMASK_PCI1 (1 << SIC_INT_PCI1) |
437 | #define SIC_INTMASK_PCI2 (1 << SIC_INT_PCI2) | 437 | #define SIC_INTMASK_PCI2 (1 << SIC_INT_PCI2) |
438 | #define SIC_INTMASK_PCI3 (1 << SIC_INT_PCI3) | 438 | #define SIC_INTMASK_PCI3 (1 << SIC_INT_PCI3) |
439 | /* | ||
440 | * Application Flash | ||
441 | * | ||
442 | */ | ||
443 | #define FLASH_BASE VERSATILE_FLASH_BASE | ||
444 | #define FLASH_SIZE VERSATILE_FLASH_SIZE | ||
445 | #define FLASH_END (FLASH_BASE + FLASH_SIZE - 1) | ||
446 | #define FLASH_BLOCK_SIZE SZ_128K | ||
447 | |||
448 | /* | ||
449 | * Boot Flash | ||
450 | * | ||
451 | */ | ||
452 | #define EPROM_BASE VERSATILE_BOOT_ROM_HI | ||
453 | #define EPROM_SIZE VERSATILE_BOOT_ROM_SIZE | ||
454 | #define EPROM_END (EPROM_BASE + EPROM_SIZE - 1) | ||
455 | 439 | ||
456 | /* | 440 | /* |
457 | * Clean base - dummy | 441 | * Clean base - dummy |
458 | * | 442 | * |
459 | */ | 443 | */ |
460 | #define CLEAN_BASE EPROM_BASE | 444 | #define CLEAN_BASE VERSATILE_BOOT_ROM_HI |
461 | 445 | ||
462 | /* | 446 | /* |
463 | * System controller bit assignment | 447 | * System controller bit assignment |
diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c index 13cdae8b0d44..80cd207cbaea 100644 --- a/arch/arm/mm/cache-feroceon-l2.c +++ b/arch/arm/mm/cache-feroceon-l2.c | |||
@@ -150,7 +150,7 @@ static void feroceon_l2_inv_range(unsigned long start, unsigned long end) | |||
150 | /* | 150 | /* |
151 | * Clean and invalidate partial last cache line. | 151 | * Clean and invalidate partial last cache line. |
152 | */ | 152 | */ |
153 | if (end & (CACHE_LINE_SIZE - 1)) { | 153 | if (start < end && end & (CACHE_LINE_SIZE - 1)) { |
154 | l2_clean_inv_pa(end & ~(CACHE_LINE_SIZE - 1)); | 154 | l2_clean_inv_pa(end & ~(CACHE_LINE_SIZE - 1)); |
155 | end &= ~(CACHE_LINE_SIZE - 1); | 155 | end &= ~(CACHE_LINE_SIZE - 1); |
156 | } | 156 | } |
@@ -158,7 +158,7 @@ static void feroceon_l2_inv_range(unsigned long start, unsigned long end) | |||
158 | /* | 158 | /* |
159 | * Invalidate all full cache lines between 'start' and 'end'. | 159 | * Invalidate all full cache lines between 'start' and 'end'. |
160 | */ | 160 | */ |
161 | while (start != end) { | 161 | while (start < end) { |
162 | unsigned long range_end = calc_range_end(start, end); | 162 | unsigned long range_end = calc_range_end(start, end); |
163 | l2_inv_pa_range(start, range_end - CACHE_LINE_SIZE); | 163 | l2_inv_pa_range(start, range_end - CACHE_LINE_SIZE); |
164 | start = range_end; | 164 | start = range_end; |
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index e63db11f16a8..7f36c825718d 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
@@ -208,6 +208,12 @@ static struct mem_type mem_types[] = { | |||
208 | .prot_sect = PROT_SECT_DEVICE, | 208 | .prot_sect = PROT_SECT_DEVICE, |
209 | .domain = DOMAIN_IO, | 209 | .domain = DOMAIN_IO, |
210 | }, | 210 | }, |
211 | [MT_UNCACHED] = { | ||
212 | .prot_pte = PROT_PTE_DEVICE, | ||
213 | .prot_l1 = PMD_TYPE_TABLE, | ||
214 | .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN, | ||
215 | .domain = DOMAIN_IO, | ||
216 | }, | ||
211 | [MT_CACHECLEAN] = { | 217 | [MT_CACHECLEAN] = { |
212 | .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN, | 218 | .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN, |
213 | .domain = DOMAIN_KERNEL, | 219 | .domain = DOMAIN_KERNEL, |
diff --git a/arch/arm/plat-iop/setup.c b/arch/arm/plat-iop/setup.c index 4689db638e95..9e573e78176a 100644 --- a/arch/arm/plat-iop/setup.c +++ b/arch/arm/plat-iop/setup.c | |||
@@ -16,14 +16,15 @@ | |||
16 | #include <asm/hardware/iop3xx.h> | 16 | #include <asm/hardware/iop3xx.h> |
17 | 17 | ||
18 | /* | 18 | /* |
19 | * Standard IO mapping for all IOP3xx based systems | 19 | * Standard IO mapping for all IOP3xx based systems. Note that |
20 | * the IOP3xx OCCDR must be mapped uncached and unbuffered. | ||
20 | */ | 21 | */ |
21 | static struct map_desc iop3xx_std_desc[] __initdata = { | 22 | static struct map_desc iop3xx_std_desc[] __initdata = { |
22 | { /* mem mapped registers */ | 23 | { /* mem mapped registers */ |
23 | .virtual = IOP3XX_PERIPHERAL_VIRT_BASE, | 24 | .virtual = IOP3XX_PERIPHERAL_VIRT_BASE, |
24 | .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE), | 25 | .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE), |
25 | .length = IOP3XX_PERIPHERAL_SIZE, | 26 | .length = IOP3XX_PERIPHERAL_SIZE, |
26 | .type = MT_DEVICE, | 27 | .type = MT_UNCACHED, |
27 | }, { /* PCI IO space */ | 28 | }, { /* PCI IO space */ |
28 | .virtual = IOP3XX_PCI_LOWER_IO_VA, | 29 | .virtual = IOP3XX_PCI_LOWER_IO_VA, |
29 | .pfn = __phys_to_pfn(IOP3XX_PCI_LOWER_IO_PA), | 30 | .pfn = __phys_to_pfn(IOP3XX_PCI_LOWER_IO_PA), |
diff --git a/arch/blackfin/include/asm/bfin-global.h b/arch/blackfin/include/asm/bfin-global.h index 56dcb0a2d244..77295666c34b 100644 --- a/arch/blackfin/include/asm/bfin-global.h +++ b/arch/blackfin/include/asm/bfin-global.h | |||
@@ -101,7 +101,7 @@ extern u16 _bfin_swrst; /* shadow for Software Reset Register (SWRST) */ | |||
101 | extern unsigned long _ramstart, _ramend, _rambase; | 101 | extern unsigned long _ramstart, _ramend, _rambase; |
102 | extern unsigned long memory_start, memory_end, physical_mem_end; | 102 | extern unsigned long memory_start, memory_end, physical_mem_end; |
103 | extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[], | 103 | extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[], |
104 | _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _ebss_b_l1[], | 104 | _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _sbss_b_l1[], _ebss_b_l1[], |
105 | _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[], | 105 | _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[], |
106 | _ebss_l2[], _l2_lma_start[]; | 106 | _ebss_l2[], _l2_lma_start[]; |
107 | 107 | ||
diff --git a/arch/blackfin/include/asm/dma-mapping.h b/arch/blackfin/include/asm/dma-mapping.h index ede748d67efd..d7d9148e433c 100644 --- a/arch/blackfin/include/asm/dma-mapping.h +++ b/arch/blackfin/include/asm/dma-mapping.h | |||
@@ -15,7 +15,11 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr, | |||
15 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | 15 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) |
16 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | 16 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) |
17 | 17 | ||
18 | #define dma_mapping_error | 18 | static inline |
19 | int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | ||
20 | { | ||
21 | return 0; | ||
22 | } | ||
19 | 23 | ||
20 | /* | 24 | /* |
21 | * Map a single buffer of the indicated size for DMA in streaming mode. | 25 | * Map a single buffer of the indicated size for DMA in streaming mode. |
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index 6e08f425bb44..5c0800adb4dd 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c | |||
@@ -218,7 +218,7 @@ inline int check_gpio(unsigned gpio) | |||
218 | if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15 | 218 | if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15 |
219 | || gpio == GPIO_PH14 || gpio == GPIO_PH15 | 219 | || gpio == GPIO_PH14 || gpio == GPIO_PH15 |
220 | || gpio == GPIO_PJ14 || gpio == GPIO_PJ15 | 220 | || gpio == GPIO_PJ14 || gpio == GPIO_PJ15 |
221 | || gpio > MAX_BLACKFIN_GPIOS) | 221 | || gpio >= MAX_BLACKFIN_GPIOS) |
222 | return -EINVAL; | 222 | return -EINVAL; |
223 | return 0; | 223 | return 0; |
224 | } | 224 | } |
diff --git a/arch/blackfin/kernel/cplb-nompu/cplbinit.c b/arch/blackfin/kernel/cplb-nompu/cplbinit.c index 512f8c92ead5..2debc900e246 100644 --- a/arch/blackfin/kernel/cplb-nompu/cplbinit.c +++ b/arch/blackfin/kernel/cplb-nompu/cplbinit.c | |||
@@ -188,10 +188,11 @@ static struct cplb_desc cplb_data[] = { | |||
188 | 188 | ||
189 | static u16 __init lock_kernel_check(u32 start, u32 end) | 189 | static u16 __init lock_kernel_check(u32 start, u32 end) |
190 | { | 190 | { |
191 | if ((end <= (u32) _end && end >= (u32)_stext) || | 191 | if (start >= (u32)_end || end <= (u32)_stext) |
192 | (start <= (u32) _end && start >= (u32)_stext)) | 192 | return 0; |
193 | return IN_KERNEL; | 193 | |
194 | return 0; | 194 | /* This cplb block overlapped with kernel area. */ |
195 | return IN_KERNEL; | ||
195 | } | 196 | } |
196 | 197 | ||
197 | static unsigned short __init | 198 | static unsigned short __init |
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c index 77800dd83e57..0c3ea118b657 100644 --- a/arch/blackfin/kernel/process.c +++ b/arch/blackfin/kernel/process.c | |||
@@ -351,10 +351,15 @@ int _access_ok(unsigned long addr, unsigned long size) | |||
351 | return 1; | 351 | return 1; |
352 | #endif | 352 | #endif |
353 | #if L1_DATA_B_LENGTH != 0 | 353 | #if L1_DATA_B_LENGTH != 0 |
354 | if (addr >= L1_DATA_B_START | 354 | if (addr >= L1_DATA_B_START + (_ebss_b_l1 - _sdata_b_l1) |
355 | && addr + size <= L1_DATA_B_START + L1_DATA_B_LENGTH) | 355 | && addr + size <= L1_DATA_B_START + L1_DATA_B_LENGTH) |
356 | return 1; | 356 | return 1; |
357 | #endif | 357 | #endif |
358 | #if L2_LENGTH != 0 | ||
359 | if (addr >= L2_START + (_ebss_l2 - _stext_l2) | ||
360 | && addr + size <= L2_START + L2_LENGTH) | ||
361 | return 1; | ||
362 | #endif | ||
358 | return 0; | 363 | return 0; |
359 | } | 364 | } |
360 | EXPORT_SYMBOL(_access_ok); | 365 | EXPORT_SYMBOL(_access_ok); |
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c index 7f35d1046cd8..71a9a8c53cea 100644 --- a/arch/blackfin/kernel/setup.c +++ b/arch/blackfin/kernel/setup.c | |||
@@ -119,23 +119,23 @@ void __init bfin_relocate_l1_mem(void) | |||
119 | /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */ | 119 | /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */ |
120 | dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length); | 120 | dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length); |
121 | 121 | ||
122 | l1_data_a_length = _ebss_l1 - _sdata_l1; | 122 | l1_data_a_length = _sbss_l1 - _sdata_l1; |
123 | if (l1_data_a_length > L1_DATA_A_LENGTH) | 123 | if (l1_data_a_length > L1_DATA_A_LENGTH) |
124 | panic("L1 Data SRAM Bank A Overflow\n"); | 124 | panic("L1 Data SRAM Bank A Overflow\n"); |
125 | 125 | ||
126 | /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */ | 126 | /* Copy _sdata_l1 to _sbss_l1 to L1 data bank A SRAM */ |
127 | dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length); | 127 | dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length); |
128 | 128 | ||
129 | l1_data_b_length = _ebss_b_l1 - _sdata_b_l1; | 129 | l1_data_b_length = _sbss_b_l1 - _sdata_b_l1; |
130 | if (l1_data_b_length > L1_DATA_B_LENGTH) | 130 | if (l1_data_b_length > L1_DATA_B_LENGTH) |
131 | panic("L1 Data SRAM Bank B Overflow\n"); | 131 | panic("L1 Data SRAM Bank B Overflow\n"); |
132 | 132 | ||
133 | /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */ | 133 | /* Copy _sdata_b_l1 to _sbss_b_l1 to L1 data bank B SRAM */ |
134 | dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length + | 134 | dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length + |
135 | l1_data_a_length, l1_data_b_length); | 135 | l1_data_a_length, l1_data_b_length); |
136 | 136 | ||
137 | if (L2_LENGTH != 0) { | 137 | if (L2_LENGTH != 0) { |
138 | l2_length = _ebss_l2 - _stext_l2; | 138 | l2_length = _sbss_l2 - _stext_l2; |
139 | if (l2_length > L2_LENGTH) | 139 | if (l2_length > L2_LENGTH) |
140 | panic("L2 SRAM Overflow\n"); | 140 | panic("L2 SRAM Overflow\n"); |
141 | 141 | ||
@@ -827,7 +827,7 @@ void __init setup_arch(char **cmdline_p) | |||
827 | printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n", | 827 | printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n", |
828 | bfin_compiled_revid(), bfin_revid()); | 828 | bfin_compiled_revid(), bfin_revid()); |
829 | } | 829 | } |
830 | if (bfin_revid() <= CONFIG_BF_REV_MIN || bfin_revid() > CONFIG_BF_REV_MAX) | 830 | if (bfin_revid() < CONFIG_BF_REV_MIN || bfin_revid() > CONFIG_BF_REV_MAX) |
831 | printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n", | 831 | printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n", |
832 | CPU, bfin_revid()); | 832 | CPU, bfin_revid()); |
833 | } | 833 | } |
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c index 1aa2c788e228..bef025b07443 100644 --- a/arch/blackfin/kernel/traps.c +++ b/arch/blackfin/kernel/traps.c | |||
@@ -59,7 +59,7 @@ | |||
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | 61 | ||
62 | #ifdef CONFIG_VERBOSE_DEBUG | 62 | #ifdef CONFIG_DEBUG_VERBOSE |
63 | #define verbose_printk(fmt, arg...) \ | 63 | #define verbose_printk(fmt, arg...) \ |
64 | printk(fmt, ##arg) | 64 | printk(fmt, ##arg) |
65 | #else | 65 | #else |
@@ -147,9 +147,12 @@ static void decode_address(char *buf, unsigned long address) | |||
147 | char *name = p->comm; | 147 | char *name = p->comm; |
148 | struct file *file = vma->vm_file; | 148 | struct file *file = vma->vm_file; |
149 | 149 | ||
150 | if (file) | 150 | if (file) { |
151 | name = d_path(&file->f_path, _tmpbuf, | 151 | char *d_name = d_path(&file->f_path, _tmpbuf, |
152 | sizeof(_tmpbuf)); | 152 | sizeof(_tmpbuf)); |
153 | if (!IS_ERR(d_name)) | ||
154 | name = d_name; | ||
155 | } | ||
153 | 156 | ||
154 | /* FLAT does not have its text aligned to the start of | 157 | /* FLAT does not have its text aligned to the start of |
155 | * the map while FDPIC ELF does ... | 158 | * the map while FDPIC ELF does ... |
@@ -571,7 +574,7 @@ asmlinkage void trap_c(struct pt_regs *fp) | |||
571 | #endif | 574 | #endif |
572 | panic("Kernel exception"); | 575 | panic("Kernel exception"); |
573 | } else { | 576 | } else { |
574 | #ifdef CONFIG_VERBOSE_DEBUG | 577 | #ifdef CONFIG_DEBUG_VERBOSE |
575 | unsigned long *stack; | 578 | unsigned long *stack; |
576 | /* Dump the user space stack */ | 579 | /* Dump the user space stack */ |
577 | stack = (unsigned long *)rdusp(); | 580 | stack = (unsigned long *)rdusp(); |
diff --git a/arch/blackfin/mach-common/cache.S b/arch/blackfin/mach-common/cache.S index db532181fbde..a028e9450419 100644 --- a/arch/blackfin/mach-common/cache.S +++ b/arch/blackfin/mach-common/cache.S | |||
@@ -25,9 +25,13 @@ | |||
25 | */ | 25 | */ |
26 | .macro do_flush flushins:req optflushins optnopins label | 26 | .macro do_flush flushins:req optflushins optnopins label |
27 | 27 | ||
28 | R2 = -L1_CACHE_BYTES; | ||
29 | |||
30 | /* start = (start & -L1_CACHE_BYTES) */ | ||
31 | R0 = R0 & R2; | ||
32 | |||
28 | /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */ | 33 | /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */ |
29 | R1 += -1; | 34 | R1 += -1; |
30 | R2 = -L1_CACHE_BYTES; | ||
31 | R1 = R1 & R2; | 35 | R1 = R1 & R2; |
32 | R1 += L1_CACHE_BYTES; | 36 | R1 += L1_CACHE_BYTES; |
33 | 37 | ||
@@ -63,7 +67,7 @@ ENDPROC(_blackfin_icache_flush_range) | |||
63 | 67 | ||
64 | /* Flush all cache lines assocoiated with this area of memory. */ | 68 | /* Flush all cache lines assocoiated with this area of memory. */ |
65 | ENTRY(_blackfin_icache_dcache_flush_range) | 69 | ENTRY(_blackfin_icache_dcache_flush_range) |
66 | do_flush IFLUSH, FLUSH | 70 | do_flush FLUSH, IFLUSH |
67 | ENDPROC(_blackfin_icache_dcache_flush_range) | 71 | ENDPROC(_blackfin_icache_dcache_flush_range) |
68 | 72 | ||
69 | /* Throw away all D-cached data in specified region without any obligation to | 73 | /* Throw away all D-cached data in specified region without any obligation to |
diff --git a/arch/blackfin/mach-common/cpufreq.c b/arch/blackfin/mach-common/cpufreq.c index c22c47b60127..dda5443b37ed 100644 --- a/arch/blackfin/mach-common/cpufreq.c +++ b/arch/blackfin/mach-common/cpufreq.c | |||
@@ -72,13 +72,13 @@ unsigned int __bfin_cycles_mod; | |||
72 | 72 | ||
73 | /**************************************************************************/ | 73 | /**************************************************************************/ |
74 | 74 | ||
75 | static unsigned int bfin_getfreq(unsigned int cpu) | 75 | static unsigned int bfin_getfreq_khz(unsigned int cpu) |
76 | { | 76 | { |
77 | /* The driver only support single cpu */ | 77 | /* The driver only support single cpu */ |
78 | if (cpu != 0) | 78 | if (cpu != 0) |
79 | return -1; | 79 | return -1; |
80 | 80 | ||
81 | return get_cclk(); | 81 | return get_cclk() / 1000; |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
@@ -96,7 +96,7 @@ static int bfin_target(struct cpufreq_policy *policy, | |||
96 | 96 | ||
97 | cclk_hz = bfin_freq_table[index].frequency; | 97 | cclk_hz = bfin_freq_table[index].frequency; |
98 | 98 | ||
99 | freqs.old = bfin_getfreq(0); | 99 | freqs.old = bfin_getfreq_khz(0); |
100 | freqs.new = cclk_hz; | 100 | freqs.new = cclk_hz; |
101 | freqs.cpu = 0; | 101 | freqs.cpu = 0; |
102 | 102 | ||
@@ -137,8 +137,8 @@ static int __init __bfin_cpu_init(struct cpufreq_policy *policy) | |||
137 | if (policy->cpu != 0) | 137 | if (policy->cpu != 0) |
138 | return -EINVAL; | 138 | return -EINVAL; |
139 | 139 | ||
140 | cclk = get_cclk(); | 140 | cclk = get_cclk() / 1000; |
141 | sclk = get_sclk(); | 141 | sclk = get_sclk() / 1000; |
142 | 142 | ||
143 | #if ANOMALY_05000273 || (!defined(CONFIG_BF54x) && defined(CONFIG_BFIN_DCACHE)) | 143 | #if ANOMALY_05000273 || (!defined(CONFIG_BF54x) && defined(CONFIG_BFIN_DCACHE)) |
144 | min_cclk = sclk * 2; | 144 | min_cclk = sclk * 2; |
@@ -152,7 +152,7 @@ static int __init __bfin_cpu_init(struct cpufreq_policy *policy) | |||
152 | dpm_state_table[index].csel = csel << 4; /* Shift now into PLL_DIV bitpos */ | 152 | dpm_state_table[index].csel = csel << 4; /* Shift now into PLL_DIV bitpos */ |
153 | dpm_state_table[index].tscale = (TIME_SCALE / (1 << csel)) - 1; | 153 | dpm_state_table[index].tscale = (TIME_SCALE / (1 << csel)) - 1; |
154 | 154 | ||
155 | pr_debug("cpufreq: freq:%d csel:%d tscale:%d\n", | 155 | pr_debug("cpufreq: freq:%d csel:0x%x tscale:%d\n", |
156 | bfin_freq_table[index].frequency, | 156 | bfin_freq_table[index].frequency, |
157 | dpm_state_table[index].csel, | 157 | dpm_state_table[index].csel, |
158 | dpm_state_table[index].tscale); | 158 | dpm_state_table[index].tscale); |
@@ -173,7 +173,7 @@ static struct freq_attr *bfin_freq_attr[] = { | |||
173 | static struct cpufreq_driver bfin_driver = { | 173 | static struct cpufreq_driver bfin_driver = { |
174 | .verify = bfin_verify_speed, | 174 | .verify = bfin_verify_speed, |
175 | .target = bfin_target, | 175 | .target = bfin_target, |
176 | .get = bfin_getfreq, | 176 | .get = bfin_getfreq_khz, |
177 | .init = __bfin_cpu_init, | 177 | .init = __bfin_cpu_init, |
178 | .name = "bfin cpufreq", | 178 | .name = "bfin cpufreq", |
179 | .owner = THIS_MODULE, | 179 | .owner = THIS_MODULE, |
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S index c13fa8da28c7..bde6dc4e2614 100644 --- a/arch/blackfin/mach-common/entry.S +++ b/arch/blackfin/mach-common/entry.S | |||
@@ -277,7 +277,7 @@ ENTRY(_bfin_return_from_exception) | |||
277 | p5.h = hi(ILAT); | 277 | p5.h = hi(ILAT); |
278 | r6 = [p5]; | 278 | r6 = [p5]; |
279 | r7 = 0x20; /* Did I just cause anther HW error? */ | 279 | r7 = 0x20; /* Did I just cause anther HW error? */ |
280 | r7 = r7 & r1; | 280 | r6 = r7 & r6; |
281 | CC = R7 == R6; | 281 | CC = R7 == R6; |
282 | if CC JUMP _double_fault; | 282 | if CC JUMP _double_fault; |
283 | #endif | 283 | #endif |
diff --git a/arch/blackfin/mm/sram-alloc.c b/arch/blackfin/mm/sram-alloc.c index 0f1ca6930c16..cc6f336e7313 100644 --- a/arch/blackfin/mm/sram-alloc.c +++ b/arch/blackfin/mm/sram-alloc.c | |||
@@ -183,10 +183,10 @@ static void __init l2_sram_init(void) | |||
183 | return; | 183 | return; |
184 | } | 184 | } |
185 | 185 | ||
186 | free_l2_sram_head.next->paddr = (void *)L2_START + | 186 | free_l2_sram_head.next->paddr = |
187 | (_etext_l2 - _stext_l2) + (_edata_l2 - _sdata_l2); | 187 | (void *)L2_START + (_ebss_l2 - _stext_l2); |
188 | free_l2_sram_head.next->size = L2_LENGTH - | 188 | free_l2_sram_head.next->size = |
189 | (_etext_l2 - _stext_l2) + (_edata_l2 - _sdata_l2); | 189 | L2_LENGTH - (_ebss_l2 - _stext_l2); |
190 | free_l2_sram_head.next->pid = 0; | 190 | free_l2_sram_head.next->pid = 0; |
191 | free_l2_sram_head.next->next = NULL; | 191 | free_l2_sram_head.next->next = NULL; |
192 | 192 | ||
diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig index 8e99fed6b3fd..f833a0b4188d 100644 --- a/arch/ia64/kvm/Kconfig +++ b/arch/ia64/kvm/Kconfig | |||
@@ -20,6 +20,8 @@ if VIRTUALIZATION | |||
20 | config KVM | 20 | config KVM |
21 | tristate "Kernel-based Virtual Machine (KVM) support" | 21 | tristate "Kernel-based Virtual Machine (KVM) support" |
22 | depends on HAVE_KVM && EXPERIMENTAL | 22 | depends on HAVE_KVM && EXPERIMENTAL |
23 | # for device assignment: | ||
24 | depends on PCI | ||
23 | select PREEMPT_NOTIFIERS | 25 | select PREEMPT_NOTIFIERS |
24 | select ANON_INODES | 26 | select ANON_INODES |
25 | ---help--- | 27 | ---help--- |
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 3caac477de9e..af1464f7a6ad 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
@@ -673,16 +673,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
673 | 673 | ||
674 | vcpu_load(vcpu); | 674 | vcpu_load(vcpu); |
675 | 675 | ||
676 | if (vcpu->sigset_active) | ||
677 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); | ||
678 | |||
676 | if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { | 679 | if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { |
677 | kvm_vcpu_block(vcpu); | 680 | kvm_vcpu_block(vcpu); |
678 | clear_bit(KVM_REQ_UNHALT, &vcpu->requests); | 681 | clear_bit(KVM_REQ_UNHALT, &vcpu->requests); |
679 | vcpu_put(vcpu); | 682 | r = -EAGAIN; |
680 | return -EAGAIN; | 683 | goto out; |
681 | } | 684 | } |
682 | 685 | ||
683 | if (vcpu->sigset_active) | ||
684 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); | ||
685 | |||
686 | if (vcpu->mmio_needed) { | 686 | if (vcpu->mmio_needed) { |
687 | memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); | 687 | memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); |
688 | kvm_set_mmio_data(vcpu); | 688 | kvm_set_mmio_data(vcpu); |
@@ -690,7 +690,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
690 | vcpu->mmio_needed = 0; | 690 | vcpu->mmio_needed = 0; |
691 | } | 691 | } |
692 | r = __vcpu_run(vcpu, kvm_run); | 692 | r = __vcpu_run(vcpu, kvm_run); |
693 | 693 | out: | |
694 | if (vcpu->sigset_active) | 694 | if (vcpu->sigset_active) |
695 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | 695 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); |
696 | 696 | ||
diff --git a/arch/ia64/kvm/vcpu.h b/arch/ia64/kvm/vcpu.h index 341e3fee280c..e9b2a4e121c0 100644 --- a/arch/ia64/kvm/vcpu.h +++ b/arch/ia64/kvm/vcpu.h | |||
@@ -384,6 +384,10 @@ static inline u64 __gpfn_is_io(u64 gpfn) | |||
384 | #define MODE_IND(psr) \ | 384 | #define MODE_IND(psr) \ |
385 | (((psr).it << 2) + ((psr).dt << 1) + (psr).rt) | 385 | (((psr).it << 2) + ((psr).dt << 1) + (psr).rt) |
386 | 386 | ||
387 | #ifndef CONFIG_SMP | ||
388 | #define _vmm_raw_spin_lock(x) do {}while(0) | ||
389 | #define _vmm_raw_spin_unlock(x) do {}while(0) | ||
390 | #else | ||
387 | #define _vmm_raw_spin_lock(x) \ | 391 | #define _vmm_raw_spin_lock(x) \ |
388 | do { \ | 392 | do { \ |
389 | __u32 *ia64_spinlock_ptr = (__u32 *) (x); \ | 393 | __u32 *ia64_spinlock_ptr = (__u32 *) (x); \ |
@@ -403,6 +407,7 @@ static inline u64 __gpfn_is_io(u64 gpfn) | |||
403 | do { barrier(); \ | 407 | do { barrier(); \ |
404 | ((spinlock_t *)x)->raw_lock.lock = 0; } \ | 408 | ((spinlock_t *)x)->raw_lock.lock = 0; } \ |
405 | while (0) | 409 | while (0) |
410 | #endif | ||
406 | 411 | ||
407 | void vmm_spin_lock(spinlock_t *lock); | 412 | void vmm_spin_lock(spinlock_t *lock); |
408 | void vmm_spin_unlock(spinlock_t *lock); | 413 | void vmm_spin_unlock(spinlock_t *lock); |
diff --git a/arch/m68k/kernel/ints.c b/arch/m68k/kernel/ints.c index 7e8a0d394e61..761ee0440c99 100644 --- a/arch/m68k/kernel/ints.c +++ b/arch/m68k/kernel/ints.c | |||
@@ -133,7 +133,7 @@ void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt, | |||
133 | { | 133 | { |
134 | int i; | 134 | int i; |
135 | 135 | ||
136 | BUG_ON(IRQ_USER + cnt >= NR_IRQS); | 136 | BUG_ON(IRQ_USER + cnt > NR_IRQS); |
137 | m68k_first_user_vec = vec; | 137 | m68k_first_user_vec = vec; |
138 | for (i = 0; i < cnt; i++) | 138 | for (i = 0; i < cnt; i++) |
139 | irq_controller[IRQ_USER + i] = &user_irq_controller; | 139 | irq_controller[IRQ_USER + i] = &user_irq_controller; |
diff --git a/arch/mn10300/Kconfig.debug b/arch/mn10300/Kconfig.debug index 524e33819f32..ff80e86b9bd2 100644 --- a/arch/mn10300/Kconfig.debug +++ b/arch/mn10300/Kconfig.debug | |||
@@ -15,6 +15,15 @@ config DEBUG_DECOMPRESS_KERNEL | |||
15 | decompressing Linux seeing "Uncompressing Linux... " and | 15 | decompressing Linux seeing "Uncompressing Linux... " and |
16 | "Ok, booting the kernel.\n" on console. | 16 | "Ok, booting the kernel.\n" on console. |
17 | 17 | ||
18 | config TEST_MISALIGNMENT_HANDLER | ||
19 | bool "Run tests on the misalignment handler" | ||
20 | depends on DEBUG_KERNEL | ||
21 | default n | ||
22 | help | ||
23 | If you say Y here the kernel will execute a list of misaligned memory | ||
24 | accesses to make sure the misalignment handler deals them with | ||
25 | correctly. If it does not, the kernel will throw a BUG. | ||
26 | |||
18 | config KPROBES | 27 | config KPROBES |
19 | bool "Kprobes" | 28 | bool "Kprobes" |
20 | depends on DEBUG_KERNEL | 29 | depends on DEBUG_KERNEL |
diff --git a/arch/mn10300/mm/misalignment.c b/arch/mn10300/mm/misalignment.c index 32aa89dc3848..94c4a4358065 100644 --- a/arch/mn10300/mm/misalignment.c +++ b/arch/mn10300/mm/misalignment.c | |||
@@ -37,26 +37,22 @@ | |||
37 | #include <asm/asm-offsets.h> | 37 | #include <asm/asm-offsets.h> |
38 | 38 | ||
39 | #if 0 | 39 | #if 0 |
40 | #define kdebug(FMT, ...) printk(KERN_DEBUG FMT, ##__VA_ARGS__) | 40 | #define kdebug(FMT, ...) printk(KERN_DEBUG "MISALIGN: "FMT"\n", ##__VA_ARGS__) |
41 | #else | 41 | #else |
42 | #define kdebug(FMT, ...) do {} while (0) | 42 | #define kdebug(FMT, ...) do {} while (0) |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | static int misalignment_addr(unsigned long *registers, unsigned params, | 45 | static int misalignment_addr(unsigned long *registers, unsigned long sp, |
46 | unsigned opcode, unsigned disp, | 46 | unsigned params, unsigned opcode, |
47 | void **_address, unsigned long **_postinc); | 47 | unsigned long disp, |
48 | void **_address, unsigned long **_postinc, | ||
49 | unsigned long *_inc); | ||
48 | 50 | ||
49 | static int misalignment_reg(unsigned long *registers, unsigned params, | 51 | static int misalignment_reg(unsigned long *registers, unsigned params, |
50 | unsigned opcode, unsigned disp, | 52 | unsigned opcode, unsigned long disp, |
51 | unsigned long **_register); | 53 | unsigned long **_register); |
52 | 54 | ||
53 | static inline unsigned int_log2(unsigned x) | 55 | static void misalignment_MOV_Lcc(struct pt_regs *regs, uint32_t opcode); |
54 | { | ||
55 | unsigned y; | ||
56 | asm("bsch %1,%0" : "=r"(y) : "r"(x), "0"(0)); | ||
57 | return y; | ||
58 | } | ||
59 | #define log2(x) int_log2(x) | ||
60 | 56 | ||
61 | static const unsigned Dreg_index[] = { | 57 | static const unsigned Dreg_index[] = { |
62 | REG_D0 >> 2, REG_D1 >> 2, REG_D2 >> 2, REG_D3 >> 2 | 58 | REG_D0 >> 2, REG_D1 >> 2, REG_D2 >> 2, REG_D3 >> 2 |
@@ -86,9 +82,10 @@ enum format_id { | |||
86 | FMT_D7, | 82 | FMT_D7, |
87 | FMT_D8, | 83 | FMT_D8, |
88 | FMT_D9, | 84 | FMT_D9, |
85 | FMT_D10, | ||
89 | }; | 86 | }; |
90 | 87 | ||
91 | struct { | 88 | static const struct { |
92 | u_int8_t opsz, dispsz; | 89 | u_int8_t opsz, dispsz; |
93 | } format_tbl[16] = { | 90 | } format_tbl[16] = { |
94 | [FMT_S0] = { 8, 0 }, | 91 | [FMT_S0] = { 8, 0 }, |
@@ -103,6 +100,7 @@ struct { | |||
103 | [FMT_D7] = { 24, 8 }, | 100 | [FMT_D7] = { 24, 8 }, |
104 | [FMT_D8] = { 24, 24 }, | 101 | [FMT_D8] = { 24, 24 }, |
105 | [FMT_D9] = { 24, 32 }, | 102 | [FMT_D9] = { 24, 32 }, |
103 | [FMT_D10] = { 32, 0 }, | ||
106 | }; | 104 | }; |
107 | 105 | ||
108 | enum value_id { | 106 | enum value_id { |
@@ -128,9 +126,14 @@ enum value_id { | |||
128 | SD24, /* 24-bit signed displacement */ | 126 | SD24, /* 24-bit signed displacement */ |
129 | SIMM4_2, /* 4-bit signed displacement in opcode bits 4-7 */ | 127 | SIMM4_2, /* 4-bit signed displacement in opcode bits 4-7 */ |
130 | SIMM8, /* 8-bit signed immediate */ | 128 | SIMM8, /* 8-bit signed immediate */ |
129 | IMM8, /* 8-bit unsigned immediate */ | ||
130 | IMM16, /* 16-bit unsigned immediate */ | ||
131 | IMM24, /* 24-bit unsigned immediate */ | 131 | IMM24, /* 24-bit unsigned immediate */ |
132 | IMM32, /* 32-bit unsigned immediate */ | 132 | IMM32, /* 32-bit unsigned immediate */ |
133 | IMM32_HIGH8, /* 32-bit unsigned immediate, high 8-bits in opcode */ | 133 | IMM32_HIGH8, /* 32-bit unsigned immediate, LSB in opcode */ |
134 | |||
135 | IMM32_MEM, /* 32-bit unsigned displacement */ | ||
136 | IMM32_HIGH8_MEM, /* 32-bit unsigned displacement, LSB in opcode */ | ||
134 | 137 | ||
135 | DN0 = DM0, | 138 | DN0 = DM0, |
136 | DN1 = DM1, | 139 | DN1 = DM1, |
@@ -149,7 +152,7 @@ enum value_id { | |||
149 | }; | 152 | }; |
150 | 153 | ||
151 | struct mn10300_opcode { | 154 | struct mn10300_opcode { |
152 | const char *name; | 155 | const char name[8]; |
153 | u_int32_t opcode; | 156 | u_int32_t opcode; |
154 | u_int32_t opmask; | 157 | u_int32_t opmask; |
155 | unsigned exclusion; | 158 | unsigned exclusion; |
@@ -185,6 +188,10 @@ struct mn10300_opcode { | |||
185 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 188 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
186 | */ | 189 | */ |
187 | static const struct mn10300_opcode mn10300_opcodes[] = { | 190 | static const struct mn10300_opcode mn10300_opcodes[] = { |
191 | { "mov", 0x4200, 0xf300, 0, FMT_S1, 0, {DM1, MEM2(IMM8, SP)}}, | ||
192 | { "mov", 0x4300, 0xf300, 0, FMT_S1, 0, {AM1, MEM2(IMM8, SP)}}, | ||
193 | { "mov", 0x5800, 0xfc00, 0, FMT_S1, 0, {MEM2(IMM8, SP), DN0}}, | ||
194 | { "mov", 0x5c00, 0xfc00, 0, FMT_S1, 0, {MEM2(IMM8, SP), AN0}}, | ||
188 | { "mov", 0x60, 0xf0, 0, FMT_S0, 0, {DM1, MEM(AN0)}}, | 195 | { "mov", 0x60, 0xf0, 0, FMT_S0, 0, {DM1, MEM(AN0)}}, |
189 | { "mov", 0x70, 0xf0, 0, FMT_S0, 0, {MEM(AM0), DN1}}, | 196 | { "mov", 0x70, 0xf0, 0, FMT_S0, 0, {MEM(AM0), DN1}}, |
190 | { "mov", 0xf000, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), AN1}}, | 197 | { "mov", 0xf000, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), AN1}}, |
@@ -197,8 +204,6 @@ static const struct mn10300_opcode mn10300_opcodes[] = { | |||
197 | { "mov", 0xf81000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}}, | 204 | { "mov", 0xf81000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}}, |
198 | { "mov", 0xf82000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8,AM0), AN1}}, | 205 | { "mov", 0xf82000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8,AM0), AN1}}, |
199 | { "mov", 0xf83000, 0xfff000, 0, FMT_D1, 0, {AM1, MEM2(SD8, AN0)}}, | 206 | { "mov", 0xf83000, 0xfff000, 0, FMT_D1, 0, {AM1, MEM2(SD8, AN0)}}, |
200 | { "mov", 0xf8f000, 0xfffc00, 0, FMT_D1, AM33, {MEM2(SD8, AM0), SP}}, | ||
201 | { "mov", 0xf8f400, 0xfffc00, 0, FMT_D1, AM33, {SP, MEM2(SD8, AN0)}}, | ||
202 | { "mov", 0xf90a00, 0xffff00, 0, FMT_D6, AM33, {MEM(RM0), RN2}}, | 207 | { "mov", 0xf90a00, 0xffff00, 0, FMT_D6, AM33, {MEM(RM0), RN2}}, |
203 | { "mov", 0xf91a00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEM(RN0)}}, | 208 | { "mov", 0xf91a00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEM(RN0)}}, |
204 | { "mov", 0xf96a00, 0xffff00, 0x12, FMT_D6, AM33, {MEMINC(RM0), RN2}}, | 209 | { "mov", 0xf96a00, 0xffff00, 0x12, FMT_D6, AM33, {MEMINC(RM0), RN2}}, |
@@ -207,24 +212,46 @@ static const struct mn10300_opcode mn10300_opcodes[] = { | |||
207 | { "mov", 0xfa100000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}}, | 212 | { "mov", 0xfa100000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}}, |
208 | { "mov", 0xfa200000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), AN1}}, | 213 | { "mov", 0xfa200000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), AN1}}, |
209 | { "mov", 0xfa300000, 0xfff00000, 0, FMT_D2, 0, {AM1, MEM2(SD16, AN0)}}, | 214 | { "mov", 0xfa300000, 0xfff00000, 0, FMT_D2, 0, {AM1, MEM2(SD16, AN0)}}, |
215 | { "mov", 0xfa900000, 0xfff30000, 0, FMT_D2, 0, {AM1, MEM2(IMM16, SP)}}, | ||
216 | { "mov", 0xfa910000, 0xfff30000, 0, FMT_D2, 0, {DM1, MEM2(IMM16, SP)}}, | ||
217 | { "mov", 0xfab00000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), AN0}}, | ||
218 | { "mov", 0xfab40000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), DN0}}, | ||
210 | { "mov", 0xfb0a0000, 0xffff0000, 0, FMT_D7, AM33, {MEM2(SD8, RM0), RN2}}, | 219 | { "mov", 0xfb0a0000, 0xffff0000, 0, FMT_D7, AM33, {MEM2(SD8, RM0), RN2}}, |
211 | { "mov", 0xfb1a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEM2(SD8, RN0)}}, | 220 | { "mov", 0xfb1a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEM2(SD8, RN0)}}, |
212 | { "mov", 0xfb6a0000, 0xffff0000, 0x22, FMT_D7, AM33, {MEMINC2 (RM0, SIMM8), RN2}}, | 221 | { "mov", 0xfb6a0000, 0xffff0000, 0x22, FMT_D7, AM33, {MEMINC2 (RM0, SIMM8), RN2}}, |
213 | { "mov", 0xfb7a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEMINC2 (RN0, SIMM8)}}, | 222 | { "mov", 0xfb7a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEMINC2 (RN0, SIMM8)}}, |
223 | { "mov", 0xfb8a0000, 0xffff0f00, 0, FMT_D7, AM33, {MEM2(IMM8, SP), RN2}}, | ||
214 | { "mov", 0xfb8e0000, 0xffff000f, 0, FMT_D7, AM33, {MEM2(RI, RM0), RD2}}, | 224 | { "mov", 0xfb8e0000, 0xffff000f, 0, FMT_D7, AM33, {MEM2(RI, RM0), RD2}}, |
225 | { "mov", 0xfb9a0000, 0xffff0f00, 0, FMT_D7, AM33, {RM2, MEM2(IMM8, SP)}}, | ||
215 | { "mov", 0xfb9e0000, 0xffff000f, 0, FMT_D7, AM33, {RD2, MEM2(RI, RN0)}}, | 226 | { "mov", 0xfb9e0000, 0xffff000f, 0, FMT_D7, AM33, {RD2, MEM2(RI, RN0)}}, |
216 | { "mov", 0xfc000000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}}, | 227 | { "mov", 0xfc000000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}}, |
217 | { "mov", 0xfc100000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}}, | 228 | { "mov", 0xfc100000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}}, |
218 | { "mov", 0xfc200000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), AN1}}, | 229 | { "mov", 0xfc200000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), AN1}}, |
219 | { "mov", 0xfc300000, 0xfff00000, 0, FMT_D4, 0, {AM1, MEM2(IMM32,AN0)}}, | 230 | { "mov", 0xfc300000, 0xfff00000, 0, FMT_D4, 0, {AM1, MEM2(IMM32,AN0)}}, |
231 | { "mov", 0xfc800000, 0xfff30000, 0, FMT_D4, 0, {AM1, MEM(IMM32_MEM)}}, | ||
232 | { "mov", 0xfc810000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM(IMM32_MEM)}}, | ||
233 | { "mov", 0xfc900000, 0xfff30000, 0, FMT_D4, 0, {AM1, MEM2(IMM32, SP)}}, | ||
234 | { "mov", 0xfc910000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM2(IMM32, SP)}}, | ||
235 | { "mov", 0xfca00000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), AN0}}, | ||
236 | { "mov", 0xfca40000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), DN0}}, | ||
237 | { "mov", 0xfcb00000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), AN0}}, | ||
238 | { "mov", 0xfcb40000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), DN0}}, | ||
220 | { "mov", 0xfd0a0000, 0xffff0000, 0, FMT_D8, AM33, {MEM2(SD24, RM0), RN2}}, | 239 | { "mov", 0xfd0a0000, 0xffff0000, 0, FMT_D8, AM33, {MEM2(SD24, RM0), RN2}}, |
221 | { "mov", 0xfd1a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEM2(SD24, RN0)}}, | 240 | { "mov", 0xfd1a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEM2(SD24, RN0)}}, |
222 | { "mov", 0xfd6a0000, 0xffff0000, 0x22, FMT_D8, AM33, {MEMINC2 (RM0, IMM24), RN2}}, | 241 | { "mov", 0xfd6a0000, 0xffff0000, 0x22, FMT_D8, AM33, {MEMINC2 (RM0, IMM24), RN2}}, |
223 | { "mov", 0xfd7a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEMINC2 (RN0, IMM24)}}, | 242 | { "mov", 0xfd7a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEMINC2 (RN0, IMM24)}}, |
243 | { "mov", 0xfd8a0000, 0xffff0f00, 0, FMT_D8, AM33, {MEM2(IMM24, SP), RN2}}, | ||
244 | { "mov", 0xfd9a0000, 0xffff0f00, 0, FMT_D8, AM33, {RM2, MEM2(IMM24, SP)}}, | ||
224 | { "mov", 0xfe0a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}}, | 245 | { "mov", 0xfe0a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}}, |
246 | { "mov", 0xfe0a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}}, | ||
247 | { "mov", 0xfe0e0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM(IMM32_HIGH8_MEM), RN2}}, | ||
248 | { "mov", 0xfe1a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}}, | ||
225 | { "mov", 0xfe1a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}}, | 249 | { "mov", 0xfe1a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}}, |
250 | { "mov", 0xfe1e0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM(IMM32_HIGH8_MEM)}}, | ||
226 | { "mov", 0xfe6a0000, 0xffff0000, 0x22, FMT_D9, AM33, {MEMINC2 (RM0, IMM32_HIGH8), RN2}}, | 251 | { "mov", 0xfe6a0000, 0xffff0000, 0x22, FMT_D9, AM33, {MEMINC2 (RM0, IMM32_HIGH8), RN2}}, |
227 | { "mov", 0xfe7a0000, 0xffff0000, 0, FMT_D9, AM33, {RN2, MEMINC2 (RM0, IMM32_HIGH8)}}, | 252 | { "mov", 0xfe7a0000, 0xffff0000, 0, FMT_D9, AM33, {RN2, MEMINC2 (RM0, IMM32_HIGH8)}}, |
253 | { "mov", 0xfe8a0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8, SP), RN2}}, | ||
254 | { "mov", 0xfe9a0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, SP)}}, | ||
228 | 255 | ||
229 | { "movhu", 0xf060, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), DN1}}, | 256 | { "movhu", 0xf060, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), DN1}}, |
230 | { "movhu", 0xf070, 0xfff0, 0, FMT_D0, 0, {DM1, MEM(AN0)}}, | 257 | { "movhu", 0xf070, 0xfff0, 0, FMT_D0, 0, {DM1, MEM(AN0)}}, |
@@ -232,29 +259,58 @@ static const struct mn10300_opcode mn10300_opcodes[] = { | |||
232 | { "movhu", 0xf4c0, 0xffc0, 0, FMT_D0, 0, {DM2, MEM2(DI, AN0)}}, | 259 | { "movhu", 0xf4c0, 0xffc0, 0, FMT_D0, 0, {DM2, MEM2(DI, AN0)}}, |
233 | { "movhu", 0xf86000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8, AM0), DN1}}, | 260 | { "movhu", 0xf86000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8, AM0), DN1}}, |
234 | { "movhu", 0xf87000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}}, | 261 | { "movhu", 0xf87000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}}, |
262 | { "movhu", 0xf89300, 0xfff300, 0, FMT_D1, 0, {DM1, MEM2(IMM8, SP)}}, | ||
263 | { "movhu", 0xf8bc00, 0xfffc00, 0, FMT_D1, 0, {MEM2(IMM8, SP), DN0}}, | ||
235 | { "movhu", 0xf94a00, 0xffff00, 0, FMT_D6, AM33, {MEM(RM0), RN2}}, | 264 | { "movhu", 0xf94a00, 0xffff00, 0, FMT_D6, AM33, {MEM(RM0), RN2}}, |
236 | { "movhu", 0xf95a00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEM(RN0)}}, | 265 | { "movhu", 0xf95a00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEM(RN0)}}, |
237 | { "movhu", 0xf9ea00, 0xffff00, 0x12, FMT_D6, AM33, {MEMINC(RM0), RN2}}, | 266 | { "movhu", 0xf9ea00, 0xffff00, 0x12, FMT_D6, AM33, {MEMINC(RM0), RN2}}, |
238 | { "movhu", 0xf9fa00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEMINC(RN0)}}, | 267 | { "movhu", 0xf9fa00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEMINC(RN0)}}, |
239 | { "movhu", 0xfa600000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), DN1}}, | 268 | { "movhu", 0xfa600000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), DN1}}, |
240 | { "movhu", 0xfa700000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}}, | 269 | { "movhu", 0xfa700000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}}, |
270 | { "movhu", 0xfa930000, 0xfff30000, 0, FMT_D2, 0, {DM1, MEM2(IMM16, SP)}}, | ||
271 | { "movhu", 0xfabc0000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), DN0}}, | ||
241 | { "movhu", 0xfb4a0000, 0xffff0000, 0, FMT_D7, AM33, {MEM2(SD8, RM0), RN2}}, | 272 | { "movhu", 0xfb4a0000, 0xffff0000, 0, FMT_D7, AM33, {MEM2(SD8, RM0), RN2}}, |
242 | { "movhu", 0xfb5a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEM2(SD8, RN0)}}, | 273 | { "movhu", 0xfb5a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEM2(SD8, RN0)}}, |
274 | { "movhu", 0xfbca0000, 0xffff0f00, 0, FMT_D7, AM33, {MEM2(IMM8, SP), RN2}}, | ||
243 | { "movhu", 0xfbce0000, 0xffff000f, 0, FMT_D7, AM33, {MEM2(RI, RM0), RD2}}, | 275 | { "movhu", 0xfbce0000, 0xffff000f, 0, FMT_D7, AM33, {MEM2(RI, RM0), RD2}}, |
276 | { "movhu", 0xfbda0000, 0xffff0f00, 0, FMT_D7, AM33, {RM2, MEM2(IMM8, SP)}}, | ||
244 | { "movhu", 0xfbde0000, 0xffff000f, 0, FMT_D7, AM33, {RD2, MEM2(RI, RN0)}}, | 277 | { "movhu", 0xfbde0000, 0xffff000f, 0, FMT_D7, AM33, {RD2, MEM2(RI, RN0)}}, |
245 | { "movhu", 0xfbea0000, 0xffff0000, 0x22, FMT_D7, AM33, {MEMINC2 (RM0, SIMM8), RN2}}, | 278 | { "movhu", 0xfbea0000, 0xffff0000, 0x22, FMT_D7, AM33, {MEMINC2 (RM0, SIMM8), RN2}}, |
246 | { "movhu", 0xfbfa0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEMINC2 (RN0, SIMM8)}}, | 279 | { "movhu", 0xfbfa0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEMINC2 (RN0, SIMM8)}}, |
247 | { "movhu", 0xfc600000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}}, | 280 | { "movhu", 0xfc600000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}}, |
248 | { "movhu", 0xfc700000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}}, | 281 | { "movhu", 0xfc700000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}}, |
282 | { "movhu", 0xfc830000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM(IMM32_MEM)}}, | ||
283 | { "movhu", 0xfc930000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM2(IMM32, SP)}}, | ||
284 | { "movhu", 0xfcac0000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), DN0}}, | ||
285 | { "movhu", 0xfcbc0000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), DN0}}, | ||
249 | { "movhu", 0xfd4a0000, 0xffff0000, 0, FMT_D8, AM33, {MEM2(SD24, RM0), RN2}}, | 286 | { "movhu", 0xfd4a0000, 0xffff0000, 0, FMT_D8, AM33, {MEM2(SD24, RM0), RN2}}, |
250 | { "movhu", 0xfd5a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEM2(SD24, RN0)}}, | 287 | { "movhu", 0xfd5a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEM2(SD24, RN0)}}, |
288 | { "movhu", 0xfdca0000, 0xffff0f00, 0, FMT_D8, AM33, {MEM2(IMM24, SP), RN2}}, | ||
289 | { "movhu", 0xfdda0000, 0xffff0f00, 0, FMT_D8, AM33, {RM2, MEM2(IMM24, SP)}}, | ||
251 | { "movhu", 0xfdea0000, 0xffff0000, 0x22, FMT_D8, AM33, {MEMINC2 (RM0, IMM24), RN2}}, | 290 | { "movhu", 0xfdea0000, 0xffff0000, 0x22, FMT_D8, AM33, {MEMINC2 (RM0, IMM24), RN2}}, |
252 | { "movhu", 0xfdfa0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEMINC2 (RN0, IMM24)}}, | 291 | { "movhu", 0xfdfa0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEMINC2 (RN0, IMM24)}}, |
253 | { "movhu", 0xfe4a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}}, | 292 | { "movhu", 0xfe4a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}}, |
293 | { "movhu", 0xfe4e0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM(IMM32_HIGH8_MEM), RN2}}, | ||
254 | { "movhu", 0xfe5a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}}, | 294 | { "movhu", 0xfe5a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}}, |
295 | { "movhu", 0xfe5e0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM(IMM32_HIGH8_MEM)}}, | ||
296 | { "movhu", 0xfeca0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8, SP), RN2}}, | ||
297 | { "movhu", 0xfeda0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, SP)}}, | ||
255 | { "movhu", 0xfeea0000, 0xffff0000, 0x22, FMT_D9, AM33, {MEMINC2 (RM0, IMM32_HIGH8), RN2}}, | 298 | { "movhu", 0xfeea0000, 0xffff0000, 0x22, FMT_D9, AM33, {MEMINC2 (RM0, IMM32_HIGH8), RN2}}, |
256 | { "movhu", 0xfefa0000, 0xffff0000, 0, FMT_D9, AM33, {RN2, MEMINC2 (RM0, IMM32_HIGH8)}}, | 299 | { "movhu", 0xfefa0000, 0xffff0000, 0, FMT_D9, AM33, {RN2, MEMINC2 (RM0, IMM32_HIGH8)}}, |
257 | { 0, 0, 0, 0, 0, 0, {0}}, | 300 | |
301 | { "mov_llt", 0xf7e00000, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
302 | { "mov_lgt", 0xf7e00001, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
303 | { "mov_lge", 0xf7e00002, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
304 | { "mov_lle", 0xf7e00003, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
305 | { "mov_lcs", 0xf7e00004, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
306 | { "mov_lhi", 0xf7e00005, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
307 | { "mov_lcc", 0xf7e00006, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
308 | { "mov_lls", 0xf7e00007, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
309 | { "mov_leq", 0xf7e00008, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
310 | { "mov_lne", 0xf7e00009, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
311 | { "mov_lra", 0xf7e0000a, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}}, | ||
312 | |||
313 | { "", 0, 0, 0, 0, 0, {0}}, | ||
258 | }; | 314 | }; |
259 | 315 | ||
260 | /* | 316 | /* |
@@ -265,18 +321,21 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code) | |||
265 | const struct exception_table_entry *fixup; | 321 | const struct exception_table_entry *fixup; |
266 | const struct mn10300_opcode *pop; | 322 | const struct mn10300_opcode *pop; |
267 | unsigned long *registers = (unsigned long *) regs; | 323 | unsigned long *registers = (unsigned long *) regs; |
268 | unsigned long data, *store, *postinc; | 324 | unsigned long data, *store, *postinc, disp, inc, sp; |
269 | mm_segment_t seg; | 325 | mm_segment_t seg; |
270 | siginfo_t info; | 326 | siginfo_t info; |
271 | uint32_t opcode, disp, noc, xo, xm; | 327 | uint32_t opcode, noc, xo, xm; |
272 | uint8_t *pc, byte; | 328 | uint8_t *pc, byte, datasz; |
273 | void *address; | 329 | void *address; |
274 | unsigned tmp, npop; | 330 | unsigned tmp, npop, dispsz, loop; |
331 | |||
332 | /* we don't fix up userspace misalignment faults */ | ||
333 | if (user_mode(regs)) | ||
334 | goto bus_error; | ||
275 | 335 | ||
276 | kdebug("MISALIGN at %lx\n", regs->pc); | 336 | sp = (unsigned long) regs + sizeof(*regs); |
277 | 337 | ||
278 | if (in_interrupt()) | 338 | kdebug("==>misalignment({pc=%lx,sp=%lx})", regs->pc, sp); |
279 | die("Misalignment trap in interrupt context", regs, code); | ||
280 | 339 | ||
281 | if (regs->epsw & EPSW_IE) | 340 | if (regs->epsw & EPSW_IE) |
282 | asm volatile("or %0,epsw" : : "i"(EPSW_IE)); | 341 | asm volatile("or %0,epsw" : : "i"(EPSW_IE)); |
@@ -294,8 +353,8 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code) | |||
294 | opcode = byte; | 353 | opcode = byte; |
295 | noc = 8; | 354 | noc = 8; |
296 | 355 | ||
297 | for (pop = mn10300_opcodes; pop->name; pop++) { | 356 | for (pop = mn10300_opcodes; pop->name[0]; pop++) { |
298 | npop = log2(pop->opcode | pop->opmask); | 357 | npop = ilog2(pop->opcode | pop->opmask); |
299 | if (npop <= 0 || npop > 31) | 358 | if (npop <= 0 || npop > 31) |
300 | continue; | 359 | continue; |
301 | npop = (npop + 8) & ~7; | 360 | npop = (npop + 8) & ~7; |
@@ -328,15 +387,15 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code) | |||
328 | } | 387 | } |
329 | 388 | ||
330 | /* didn't manage to find a fixup */ | 389 | /* didn't manage to find a fixup */ |
331 | if (!user_mode(regs)) | 390 | printk(KERN_CRIT "MISALIGN: %lx: unsupported instruction %x\n", |
332 | printk(KERN_CRIT "MISALIGN: %lx: unsupported instruction %x\n", | 391 | regs->pc, opcode); |
333 | regs->pc, opcode); | ||
334 | 392 | ||
335 | failed: | 393 | failed: |
336 | set_fs(seg); | 394 | set_fs(seg); |
337 | if (die_if_no_fixup("misalignment error", regs, code)) | 395 | if (die_if_no_fixup("misalignment error", regs, code)) |
338 | return; | 396 | return; |
339 | 397 | ||
398 | bus_error: | ||
340 | info.si_signo = SIGBUS; | 399 | info.si_signo = SIGBUS; |
341 | info.si_errno = 0; | 400 | info.si_errno = 0; |
342 | info.si_code = BUS_ADRALN; | 401 | info.si_code = BUS_ADRALN; |
@@ -346,31 +405,27 @@ failed: | |||
346 | 405 | ||
347 | /* error reading opcodes */ | 406 | /* error reading opcodes */ |
348 | fetch_error: | 407 | fetch_error: |
349 | if (!user_mode(regs)) | 408 | printk(KERN_CRIT |
350 | printk(KERN_CRIT | 409 | "MISALIGN: %p: fault whilst reading instruction data\n", |
351 | "MISALIGN: %p: fault whilst reading instruction data\n", | 410 | pc); |
352 | pc); | ||
353 | goto failed; | 411 | goto failed; |
354 | 412 | ||
355 | bad_addr_mode: | 413 | bad_addr_mode: |
356 | if (!user_mode(regs)) | 414 | printk(KERN_CRIT |
357 | printk(KERN_CRIT | 415 | "MISALIGN: %lx: unsupported addressing mode %x\n", |
358 | "MISALIGN: %lx: unsupported addressing mode %x\n", | 416 | regs->pc, opcode); |
359 | regs->pc, opcode); | ||
360 | goto failed; | 417 | goto failed; |
361 | 418 | ||
362 | bad_reg_mode: | 419 | bad_reg_mode: |
363 | if (!user_mode(regs)) | 420 | printk(KERN_CRIT |
364 | printk(KERN_CRIT | 421 | "MISALIGN: %lx: unsupported register mode %x\n", |
365 | "MISALIGN: %lx: unsupported register mode %x\n", | 422 | regs->pc, opcode); |
366 | regs->pc, opcode); | ||
367 | goto failed; | 423 | goto failed; |
368 | 424 | ||
369 | unsupported_instruction: | 425 | unsupported_instruction: |
370 | if (!user_mode(regs)) | 426 | printk(KERN_CRIT |
371 | printk(KERN_CRIT | 427 | "MISALIGN: %lx: unsupported instruction %x (%s)\n", |
372 | "MISALIGN: %lx: unsupported instruction %x (%s)\n", | 428 | regs->pc, opcode, pop->name); |
373 | regs->pc, opcode, pop->name); | ||
374 | goto failed; | 429 | goto failed; |
375 | 430 | ||
376 | transfer_failed: | 431 | transfer_failed: |
@@ -391,7 +446,7 @@ transfer_failed: | |||
391 | 446 | ||
392 | /* we matched the opcode */ | 447 | /* we matched the opcode */ |
393 | found_opcode: | 448 | found_opcode: |
394 | kdebug("MISALIGN: %lx: %x==%x { %x, %x }\n", | 449 | kdebug("%lx: %x==%x { %x, %x }", |
395 | regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]); | 450 | regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]); |
396 | 451 | ||
397 | tmp = format_tbl[pop->format].opsz; | 452 | tmp = format_tbl[pop->format].opsz; |
@@ -406,106 +461,108 @@ found_opcode: | |||
406 | 461 | ||
407 | /* grab the extra displacement (note it's LSB first) */ | 462 | /* grab the extra displacement (note it's LSB first) */ |
408 | disp = 0; | 463 | disp = 0; |
409 | tmp = format_tbl[pop->format].dispsz >> 3; | 464 | dispsz = format_tbl[pop->format].dispsz; |
410 | while (tmp > 0) { | 465 | for (loop = 0; loop < dispsz; loop += 8) { |
411 | tmp--; | ||
412 | disp <<= 8; | ||
413 | |||
414 | pc++; | 466 | pc++; |
415 | if (__get_user(byte, pc) != 0) | 467 | if (__get_user(byte, pc) != 0) |
416 | goto fetch_error; | 468 | goto fetch_error; |
417 | disp |= byte; | 469 | disp |= byte << loop; |
470 | kdebug("{%p} disp[%02x]=%02x", pc, loop, byte); | ||
418 | } | 471 | } |
419 | 472 | ||
473 | kdebug("disp=%lx", disp); | ||
474 | |||
420 | set_fs(KERNEL_XDS); | 475 | set_fs(KERNEL_XDS); |
421 | if (fixup || regs->epsw & EPSW_nSL) | 476 | if (fixup) |
422 | set_fs(seg); | 477 | set_fs(seg); |
423 | 478 | ||
424 | tmp = (pop->params[0] ^ pop->params[1]) & 0x80000000; | 479 | tmp = (pop->params[0] ^ pop->params[1]) & 0x80000000; |
425 | if (!tmp) { | 480 | if (!tmp) { |
426 | if (!user_mode(regs)) | 481 | printk(KERN_CRIT |
427 | printk(KERN_CRIT | 482 | "MISALIGN: %lx: insn not move to/from memory %x\n", |
428 | "MISALIGN: %lx:" | 483 | regs->pc, opcode); |
429 | " insn not move to/from memory %x\n", | ||
430 | regs->pc, opcode); | ||
431 | goto failed; | 484 | goto failed; |
432 | } | 485 | } |
433 | 486 | ||
487 | /* determine the data transfer size of the move */ | ||
488 | if (pop->name[3] == 0 || /* "mov" */ | ||
489 | pop->name[4] == 'l') /* mov_lcc */ | ||
490 | inc = datasz = 4; | ||
491 | else if (pop->name[3] == 'h') /* movhu */ | ||
492 | inc = datasz = 2; | ||
493 | else | ||
494 | goto unsupported_instruction; | ||
495 | |||
434 | if (pop->params[0] & 0x80000000) { | 496 | if (pop->params[0] & 0x80000000) { |
435 | /* move memory to register */ | 497 | /* move memory to register */ |
436 | if (!misalignment_addr(registers, pop->params[0], opcode, disp, | 498 | if (!misalignment_addr(registers, sp, |
437 | &address, &postinc)) | 499 | pop->params[0], opcode, disp, |
500 | &address, &postinc, &inc)) | ||
438 | goto bad_addr_mode; | 501 | goto bad_addr_mode; |
439 | 502 | ||
440 | if (!misalignment_reg(registers, pop->params[1], opcode, disp, | 503 | if (!misalignment_reg(registers, pop->params[1], opcode, disp, |
441 | &store)) | 504 | &store)) |
442 | goto bad_reg_mode; | 505 | goto bad_reg_mode; |
443 | 506 | ||
444 | if (strcmp(pop->name, "mov") == 0) { | 507 | kdebug("mov%u (%p),DARn", datasz, address); |
445 | kdebug("FIXUP: mov (%p),DARn\n", address); | 508 | if (copy_from_user(&data, (void *) address, datasz) != 0) |
446 | if (copy_from_user(&data, (void *) address, 4) != 0) | 509 | goto transfer_failed; |
447 | goto transfer_failed; | 510 | if (pop->params[0] & 0x1000000) { |
448 | if (pop->params[0] & 0x1000000) | 511 | kdebug("inc=%lx", inc); |
449 | *postinc += 4; | 512 | *postinc += inc; |
450 | } else if (strcmp(pop->name, "movhu") == 0) { | ||
451 | kdebug("FIXUP: movhu (%p),DARn\n", address); | ||
452 | data = 0; | ||
453 | if (copy_from_user(&data, (void *) address, 2) != 0) | ||
454 | goto transfer_failed; | ||
455 | if (pop->params[0] & 0x1000000) | ||
456 | *postinc += 2; | ||
457 | } else { | ||
458 | goto unsupported_instruction; | ||
459 | } | 513 | } |
460 | 514 | ||
461 | *store = data; | 515 | *store = data; |
516 | kdebug("loaded %lx", data); | ||
462 | } else { | 517 | } else { |
463 | /* move register to memory */ | 518 | /* move register to memory */ |
464 | if (!misalignment_reg(registers, pop->params[0], opcode, disp, | 519 | if (!misalignment_reg(registers, pop->params[0], opcode, disp, |
465 | &store)) | 520 | &store)) |
466 | goto bad_reg_mode; | 521 | goto bad_reg_mode; |
467 | 522 | ||
468 | if (!misalignment_addr(registers, pop->params[1], opcode, disp, | 523 | if (!misalignment_addr(registers, sp, |
469 | &address, &postinc)) | 524 | pop->params[1], opcode, disp, |
525 | &address, &postinc, &inc)) | ||
470 | goto bad_addr_mode; | 526 | goto bad_addr_mode; |
471 | 527 | ||
472 | data = *store; | 528 | data = *store; |
473 | 529 | ||
474 | if (strcmp(pop->name, "mov") == 0) { | 530 | kdebug("mov%u %lx,(%p)", datasz, data, address); |
475 | kdebug("FIXUP: mov %lx,(%p)\n", data, address); | 531 | if (copy_to_user((void *) address, &data, datasz) != 0) |
476 | if (copy_to_user((void *) address, &data, 4) != 0) | 532 | goto transfer_failed; |
477 | goto transfer_failed; | 533 | if (pop->params[1] & 0x1000000) |
478 | if (pop->params[1] & 0x1000000) | 534 | *postinc += inc; |
479 | *postinc += 4; | ||
480 | } else if (strcmp(pop->name, "movhu") == 0) { | ||
481 | kdebug("FIXUP: movhu %hx,(%p)\n", | ||
482 | (uint16_t) data, address); | ||
483 | if (copy_to_user((void *) address, &data, 2) != 0) | ||
484 | goto transfer_failed; | ||
485 | if (pop->params[1] & 0x1000000) | ||
486 | *postinc += 2; | ||
487 | } else { | ||
488 | goto unsupported_instruction; | ||
489 | } | ||
490 | } | 535 | } |
491 | 536 | ||
492 | tmp = format_tbl[pop->format].opsz + format_tbl[pop->format].dispsz; | 537 | tmp = format_tbl[pop->format].opsz + format_tbl[pop->format].dispsz; |
493 | regs->pc += tmp >> 3; | 538 | regs->pc += tmp >> 3; |
494 | 539 | ||
540 | /* handle MOV_Lcc, which are currently the only FMT_D10 insns that | ||
541 | * access memory */ | ||
542 | if (pop->format == FMT_D10) | ||
543 | misalignment_MOV_Lcc(regs, opcode); | ||
544 | |||
495 | set_fs(seg); | 545 | set_fs(seg); |
496 | return; | ||
497 | } | 546 | } |
498 | 547 | ||
499 | /* | 548 | /* |
500 | * determine the address that was being accessed | 549 | * determine the address that was being accessed |
501 | */ | 550 | */ |
502 | static int misalignment_addr(unsigned long *registers, unsigned params, | 551 | static int misalignment_addr(unsigned long *registers, unsigned long sp, |
503 | unsigned opcode, unsigned disp, | 552 | unsigned params, unsigned opcode, |
504 | void **_address, unsigned long **_postinc) | 553 | unsigned long disp, |
554 | void **_address, unsigned long **_postinc, | ||
555 | unsigned long *_inc) | ||
505 | { | 556 | { |
506 | unsigned long *postinc = NULL, address = 0, tmp; | 557 | unsigned long *postinc = NULL, address = 0, tmp; |
507 | 558 | ||
508 | params &= 0x7fffffff; | 559 | if (!(params & 0x1000000)) { |
560 | kdebug("noinc"); | ||
561 | *_inc = 0; | ||
562 | _inc = NULL; | ||
563 | } | ||
564 | |||
565 | params &= 0x00ffffff; | ||
509 | 566 | ||
510 | do { | 567 | do { |
511 | switch (params & 0xff) { | 568 | switch (params & 0xff) { |
@@ -514,11 +571,11 @@ static int misalignment_addr(unsigned long *registers, unsigned params, | |||
514 | address += *postinc; | 571 | address += *postinc; |
515 | break; | 572 | break; |
516 | case DM1: | 573 | case DM1: |
517 | postinc = ®isters[Dreg_index[opcode >> 2 & 0x0c]]; | 574 | postinc = ®isters[Dreg_index[opcode >> 2 & 0x03]]; |
518 | address += *postinc; | 575 | address += *postinc; |
519 | break; | 576 | break; |
520 | case DM2: | 577 | case DM2: |
521 | postinc = ®isters[Dreg_index[opcode >> 4 & 0x30]]; | 578 | postinc = ®isters[Dreg_index[opcode >> 4 & 0x03]]; |
522 | address += *postinc; | 579 | address += *postinc; |
523 | break; | 580 | break; |
524 | case AM0: | 581 | case AM0: |
@@ -526,11 +583,11 @@ static int misalignment_addr(unsigned long *registers, unsigned params, | |||
526 | address += *postinc; | 583 | address += *postinc; |
527 | break; | 584 | break; |
528 | case AM1: | 585 | case AM1: |
529 | postinc = ®isters[Areg_index[opcode >> 2 & 0x0c]]; | 586 | postinc = ®isters[Areg_index[opcode >> 2 & 0x03]]; |
530 | address += *postinc; | 587 | address += *postinc; |
531 | break; | 588 | break; |
532 | case AM2: | 589 | case AM2: |
533 | postinc = ®isters[Areg_index[opcode >> 4 & 0x30]]; | 590 | postinc = ®isters[Areg_index[opcode >> 4 & 0x03]]; |
534 | address += *postinc; | 591 | address += *postinc; |
535 | break; | 592 | break; |
536 | case RM0: | 593 | case RM0: |
@@ -561,33 +618,53 @@ static int misalignment_addr(unsigned long *registers, unsigned params, | |||
561 | postinc = ®isters[Rreg_index[disp >> 4 & 0x0f]]; | 618 | postinc = ®isters[Rreg_index[disp >> 4 & 0x0f]]; |
562 | address += *postinc; | 619 | address += *postinc; |
563 | break; | 620 | break; |
621 | case SP: | ||
622 | address += sp; | ||
623 | break; | ||
564 | 624 | ||
625 | /* displacements are either to be added to the address | ||
626 | * before use, or, in the case of post-inc addressing, | ||
627 | * to be added into the base register after use */ | ||
565 | case SD8: | 628 | case SD8: |
566 | case SIMM8: | 629 | case SIMM8: |
567 | address += (int32_t) (int8_t) (disp & 0xff); | 630 | disp = (long) (int8_t) (disp & 0xff); |
568 | break; | 631 | goto displace_or_inc; |
569 | case SD16: | 632 | case SD16: |
570 | address += (int32_t) (int16_t) (disp & 0xffff); | 633 | disp = (long) (int16_t) (disp & 0xffff); |
571 | break; | 634 | goto displace_or_inc; |
572 | case SD24: | 635 | case SD24: |
573 | tmp = disp << 8; | 636 | tmp = disp << 8; |
574 | asm("asr 8,%0" : "=r"(tmp) : "0"(tmp)); | 637 | asm("asr 8,%0" : "=r"(tmp) : "0"(tmp)); |
575 | address += tmp; | 638 | disp = (long) tmp; |
576 | break; | 639 | goto displace_or_inc; |
577 | case SIMM4_2: | 640 | case SIMM4_2: |
578 | tmp = opcode >> 4 & 0x0f; | 641 | tmp = opcode >> 4 & 0x0f; |
579 | tmp <<= 28; | 642 | tmp <<= 28; |
580 | asm("asr 28,%0" : "=r"(tmp) : "0"(tmp)); | 643 | asm("asr 28,%0" : "=r"(tmp) : "0"(tmp)); |
581 | address += tmp; | 644 | disp = (long) tmp; |
582 | break; | 645 | goto displace_or_inc; |
646 | case IMM8: | ||
647 | disp &= 0x000000ff; | ||
648 | goto displace_or_inc; | ||
649 | case IMM16: | ||
650 | disp &= 0x0000ffff; | ||
651 | goto displace_or_inc; | ||
583 | case IMM24: | 652 | case IMM24: |
584 | address += disp & 0x00ffffff; | 653 | disp &= 0x00ffffff; |
585 | break; | 654 | goto displace_or_inc; |
586 | case IMM32: | 655 | case IMM32: |
656 | case IMM32_MEM: | ||
587 | case IMM32_HIGH8: | 657 | case IMM32_HIGH8: |
588 | address += disp; | 658 | case IMM32_HIGH8_MEM: |
659 | displace_or_inc: | ||
660 | kdebug("%s %lx", _inc ? "incr" : "disp", disp); | ||
661 | if (!_inc) | ||
662 | address += disp; | ||
663 | else | ||
664 | *_inc = disp; | ||
589 | break; | 665 | break; |
590 | default: | 666 | default: |
667 | BUG(); | ||
591 | return 0; | 668 | return 0; |
592 | } | 669 | } |
593 | } while ((params >>= 8)); | 670 | } while ((params >>= 8)); |
@@ -601,7 +678,7 @@ static int misalignment_addr(unsigned long *registers, unsigned params, | |||
601 | * determine the register that is acting as source/dest | 678 | * determine the register that is acting as source/dest |
602 | */ | 679 | */ |
603 | static int misalignment_reg(unsigned long *registers, unsigned params, | 680 | static int misalignment_reg(unsigned long *registers, unsigned params, |
604 | unsigned opcode, unsigned disp, | 681 | unsigned opcode, unsigned long disp, |
605 | unsigned long **_register) | 682 | unsigned long **_register) |
606 | { | 683 | { |
607 | params &= 0x7fffffff; | 684 | params &= 0x7fffffff; |
@@ -654,8 +731,239 @@ static int misalignment_reg(unsigned long *registers, unsigned params, | |||
654 | break; | 731 | break; |
655 | 732 | ||
656 | default: | 733 | default: |
734 | BUG(); | ||
657 | return 0; | 735 | return 0; |
658 | } | 736 | } |
659 | 737 | ||
660 | return 1; | 738 | return 1; |
661 | } | 739 | } |
740 | |||
741 | /* | ||
742 | * handle the conditional loop part of the move-and-loop instructions | ||
743 | */ | ||
744 | static void misalignment_MOV_Lcc(struct pt_regs *regs, uint32_t opcode) | ||
745 | { | ||
746 | unsigned long epsw = regs->epsw; | ||
747 | unsigned long NxorV; | ||
748 | |||
749 | kdebug("MOV_Lcc %x [flags=%lx]", opcode, epsw & 0xf); | ||
750 | |||
751 | /* calculate N^V and shift onto the same bit position as Z */ | ||
752 | NxorV = ((epsw >> 3) ^ epsw >> 1) & 1; | ||
753 | |||
754 | switch (opcode & 0xf) { | ||
755 | case 0x0: /* MOV_LLT: N^V */ | ||
756 | if (NxorV) | ||
757 | goto take_the_loop; | ||
758 | return; | ||
759 | case 0x1: /* MOV_LGT: ~(Z or (N^V))*/ | ||
760 | if (!((epsw & EPSW_FLAG_Z) | NxorV)) | ||
761 | goto take_the_loop; | ||
762 | return; | ||
763 | case 0x2: /* MOV_LGE: ~(N^V) */ | ||
764 | if (!NxorV) | ||
765 | goto take_the_loop; | ||
766 | return; | ||
767 | case 0x3: /* MOV_LLE: Z or (N^V) */ | ||
768 | if ((epsw & EPSW_FLAG_Z) | NxorV) | ||
769 | goto take_the_loop; | ||
770 | return; | ||
771 | |||
772 | case 0x4: /* MOV_LCS: C */ | ||
773 | if (epsw & EPSW_FLAG_C) | ||
774 | goto take_the_loop; | ||
775 | return; | ||
776 | case 0x5: /* MOV_LHI: ~(C or Z) */ | ||
777 | if (!(epsw & (EPSW_FLAG_C | EPSW_FLAG_Z))) | ||
778 | goto take_the_loop; | ||
779 | return; | ||
780 | case 0x6: /* MOV_LCC: ~C */ | ||
781 | if (!(epsw & EPSW_FLAG_C)) | ||
782 | goto take_the_loop; | ||
783 | return; | ||
784 | case 0x7: /* MOV_LLS: C or Z */ | ||
785 | if (epsw & (EPSW_FLAG_C | EPSW_FLAG_Z)) | ||
786 | goto take_the_loop; | ||
787 | return; | ||
788 | |||
789 | case 0x8: /* MOV_LEQ: Z */ | ||
790 | if (epsw & EPSW_FLAG_Z) | ||
791 | goto take_the_loop; | ||
792 | return; | ||
793 | case 0x9: /* MOV_LNE: ~Z */ | ||
794 | if (!(epsw & EPSW_FLAG_Z)) | ||
795 | goto take_the_loop; | ||
796 | return; | ||
797 | case 0xa: /* MOV_LRA: always */ | ||
798 | goto take_the_loop; | ||
799 | |||
800 | default: | ||
801 | BUG(); | ||
802 | } | ||
803 | |||
804 | take_the_loop: | ||
805 | /* wind the PC back to just after the SETLB insn */ | ||
806 | kdebug("loop LAR=%lx", regs->lar); | ||
807 | regs->pc = regs->lar - 4; | ||
808 | } | ||
809 | |||
810 | /* | ||
811 | * misalignment handler tests | ||
812 | */ | ||
813 | #ifdef CONFIG_TEST_MISALIGNMENT_HANDLER | ||
814 | static u8 __initdata testbuf[512] __attribute__((aligned(16))) = { | ||
815 | [257] = 0x11, | ||
816 | [258] = 0x22, | ||
817 | [259] = 0x33, | ||
818 | [260] = 0x44, | ||
819 | }; | ||
820 | |||
821 | #define ASSERTCMP(X, OP, Y) \ | ||
822 | do { \ | ||
823 | if (unlikely(!((X) OP (Y)))) { \ | ||
824 | printk(KERN_ERR "\n"); \ | ||
825 | printk(KERN_ERR "MISALIGN: Assertion failed at line %u\n", \ | ||
826 | __LINE__); \ | ||
827 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ | ||
828 | (unsigned long)(X), (unsigned long)(Y)); \ | ||
829 | BUG(); \ | ||
830 | } \ | ||
831 | } while(0) | ||
832 | |||
833 | static int __init test_misalignment(void) | ||
834 | { | ||
835 | register void *r asm("e0"); | ||
836 | register u32 y asm("e1"); | ||
837 | void *p = testbuf, *q; | ||
838 | u32 tmp, tmp2, x; | ||
839 | |||
840 | printk(KERN_NOTICE "==>test_misalignment() [testbuf=%p]\n", p); | ||
841 | p++; | ||
842 | |||
843 | printk(KERN_NOTICE "___ MOV (Am),Dn ___\n"); | ||
844 | q = p + 256; | ||
845 | asm volatile("mov (%0),%1" : "+a"(q), "=d"(x)); | ||
846 | ASSERTCMP(q, ==, p + 256); | ||
847 | ASSERTCMP(x, ==, 0x44332211); | ||
848 | |||
849 | printk(KERN_NOTICE "___ MOV (256,Am),Dn ___\n"); | ||
850 | q = p; | ||
851 | asm volatile("mov (256,%0),%1" : "+a"(q), "=d"(x)); | ||
852 | ASSERTCMP(q, ==, p); | ||
853 | ASSERTCMP(x, ==, 0x44332211); | ||
854 | |||
855 | printk(KERN_NOTICE "___ MOV (Di,Am),Dn ___\n"); | ||
856 | tmp = 256; | ||
857 | q = p; | ||
858 | asm volatile("mov (%2,%0),%1" : "+a"(q), "=d"(x), "+d"(tmp)); | ||
859 | ASSERTCMP(q, ==, p); | ||
860 | ASSERTCMP(x, ==, 0x44332211); | ||
861 | ASSERTCMP(tmp, ==, 256); | ||
862 | |||
863 | printk(KERN_NOTICE "___ MOV (256,Rm),Rn ___\n"); | ||
864 | r = p; | ||
865 | asm volatile("mov (256,%0),%1" : "+r"(r), "=r"(y)); | ||
866 | ASSERTCMP(r, ==, p); | ||
867 | ASSERTCMP(y, ==, 0x44332211); | ||
868 | |||
869 | printk(KERN_NOTICE "___ MOV (Rm+),Rn ___\n"); | ||
870 | r = p + 256; | ||
871 | asm volatile("mov (%0+),%1" : "+r"(r), "=r"(y)); | ||
872 | ASSERTCMP(r, ==, p + 256 + 4); | ||
873 | ASSERTCMP(y, ==, 0x44332211); | ||
874 | |||
875 | printk(KERN_NOTICE "___ MOV (Rm+,8),Rn ___\n"); | ||
876 | r = p + 256; | ||
877 | asm volatile("mov (%0+,8),%1" : "+r"(r), "=r"(y)); | ||
878 | ASSERTCMP(r, ==, p + 256 + 8); | ||
879 | ASSERTCMP(y, ==, 0x44332211); | ||
880 | |||
881 | printk(KERN_NOTICE "___ MOV (7,SP),Rn ___\n"); | ||
882 | asm volatile( | ||
883 | "add -16,sp \n" | ||
884 | "mov +0x11,%0 \n" | ||
885 | "movbu %0,(7,sp) \n" | ||
886 | "mov +0x22,%0 \n" | ||
887 | "movbu %0,(8,sp) \n" | ||
888 | "mov +0x33,%0 \n" | ||
889 | "movbu %0,(9,sp) \n" | ||
890 | "mov +0x44,%0 \n" | ||
891 | "movbu %0,(10,sp) \n" | ||
892 | "mov (7,sp),%1 \n" | ||
893 | "add +16,sp \n" | ||
894 | : "+a"(q), "=d"(x)); | ||
895 | ASSERTCMP(x, ==, 0x44332211); | ||
896 | |||
897 | printk(KERN_NOTICE "___ MOV (259,SP),Rn ___\n"); | ||
898 | asm volatile( | ||
899 | "add -264,sp \n" | ||
900 | "mov +0x11,%0 \n" | ||
901 | "movbu %0,(259,sp) \n" | ||
902 | "mov +0x22,%0 \n" | ||
903 | "movbu %0,(260,sp) \n" | ||
904 | "mov +0x33,%0 \n" | ||
905 | "movbu %0,(261,sp) \n" | ||
906 | "mov +0x55,%0 \n" | ||
907 | "movbu %0,(262,sp) \n" | ||
908 | "mov (259,sp),%1 \n" | ||
909 | "add +264,sp \n" | ||
910 | : "+d"(tmp), "=d"(x)); | ||
911 | ASSERTCMP(x, ==, 0x55332211); | ||
912 | |||
913 | printk(KERN_NOTICE "___ MOV (260,SP),Rn ___\n"); | ||
914 | asm volatile( | ||
915 | "add -264,sp \n" | ||
916 | "mov +0x11,%0 \n" | ||
917 | "movbu %0,(260,sp) \n" | ||
918 | "mov +0x22,%0 \n" | ||
919 | "movbu %0,(261,sp) \n" | ||
920 | "mov +0x33,%0 \n" | ||
921 | "movbu %0,(262,sp) \n" | ||
922 | "mov +0x55,%0 \n" | ||
923 | "movbu %0,(263,sp) \n" | ||
924 | "mov (260,sp),%1 \n" | ||
925 | "add +264,sp \n" | ||
926 | : "+d"(tmp), "=d"(x)); | ||
927 | ASSERTCMP(x, ==, 0x55332211); | ||
928 | |||
929 | |||
930 | printk(KERN_NOTICE "___ MOV_LNE ___\n"); | ||
931 | tmp = 1; | ||
932 | tmp2 = 2; | ||
933 | q = p + 256; | ||
934 | asm volatile( | ||
935 | "setlb \n" | ||
936 | "mov %2,%3 \n" | ||
937 | "mov %1,%2 \n" | ||
938 | "cmp +0,%1 \n" | ||
939 | "mov_lne (%0+,4),%1" | ||
940 | : "+r"(q), "+d"(tmp), "+d"(tmp2), "=d"(x) | ||
941 | : | ||
942 | : "cc"); | ||
943 | ASSERTCMP(q, ==, p + 256 + 12); | ||
944 | ASSERTCMP(x, ==, 0x44332211); | ||
945 | |||
946 | printk(KERN_NOTICE "___ MOV in SETLB ___\n"); | ||
947 | tmp = 1; | ||
948 | tmp2 = 2; | ||
949 | q = p + 256; | ||
950 | asm volatile( | ||
951 | "setlb \n" | ||
952 | "mov %1,%3 \n" | ||
953 | "mov (%0+),%1 \n" | ||
954 | "cmp +0,%1 \n" | ||
955 | "lne " | ||
956 | : "+a"(q), "+d"(tmp), "+d"(tmp2), "=d"(x) | ||
957 | : | ||
958 | : "cc"); | ||
959 | |||
960 | ASSERTCMP(q, ==, p + 256 + 8); | ||
961 | ASSERTCMP(x, ==, 0x44332211); | ||
962 | |||
963 | printk(KERN_NOTICE "<==test_misalignment()\n"); | ||
964 | return 0; | ||
965 | } | ||
966 | |||
967 | arch_initcall(test_misalignment); | ||
968 | |||
969 | #endif /* CONFIG_TEST_MISALIGNMENT_HANDLER */ | ||
diff --git a/arch/parisc/include/asm/smp.h b/arch/parisc/include/asm/smp.h index 398cdbaf4e54..409e698f4361 100644 --- a/arch/parisc/include/asm/smp.h +++ b/arch/parisc/include/asm/smp.h | |||
@@ -44,8 +44,6 @@ extern void arch_send_call_function_ipi(cpumask_t mask); | |||
44 | 44 | ||
45 | #define PROC_CHANGE_PENALTY 15 /* Schedule penalty */ | 45 | #define PROC_CHANGE_PENALTY 15 /* Schedule penalty */ |
46 | 46 | ||
47 | extern unsigned long cpu_present_mask; | ||
48 | |||
49 | #define raw_smp_processor_id() (current_thread_info()->cpu) | 47 | #define raw_smp_processor_id() (current_thread_info()->cpu) |
50 | 48 | ||
51 | #else /* CONFIG_SMP */ | 49 | #else /* CONFIG_SMP */ |
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index ed500ef799b7..08844fc24a2e 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S | |||
@@ -61,22 +61,25 @@ STACK_SIZE = 1 << STACK_SHIFT | |||
61 | 61 | ||
62 | #ifdef CONFIG_TRACE_IRQFLAGS | 62 | #ifdef CONFIG_TRACE_IRQFLAGS |
63 | .macro TRACE_IRQS_ON | 63 | .macro TRACE_IRQS_ON |
64 | l %r1,BASED(.Ltrace_irq_on) | 64 | basr %r2,%r0 |
65 | l %r1,BASED(.Ltrace_irq_on_caller) | ||
65 | basr %r14,%r1 | 66 | basr %r14,%r1 |
66 | .endm | 67 | .endm |
67 | 68 | ||
68 | .macro TRACE_IRQS_OFF | 69 | .macro TRACE_IRQS_OFF |
69 | l %r1,BASED(.Ltrace_irq_off) | 70 | basr %r2,%r0 |
71 | l %r1,BASED(.Ltrace_irq_off_caller) | ||
70 | basr %r14,%r1 | 72 | basr %r14,%r1 |
71 | .endm | 73 | .endm |
72 | 74 | ||
73 | .macro TRACE_IRQS_CHECK | 75 | .macro TRACE_IRQS_CHECK |
76 | basr %r2,%r0 | ||
74 | tm SP_PSW(%r15),0x03 # irqs enabled? | 77 | tm SP_PSW(%r15),0x03 # irqs enabled? |
75 | jz 0f | 78 | jz 0f |
76 | l %r1,BASED(.Ltrace_irq_on) | 79 | l %r1,BASED(.Ltrace_irq_on_caller) |
77 | basr %r14,%r1 | 80 | basr %r14,%r1 |
78 | j 1f | 81 | j 1f |
79 | 0: l %r1,BASED(.Ltrace_irq_off) | 82 | 0: l %r1,BASED(.Ltrace_irq_off_caller) |
80 | basr %r14,%r1 | 83 | basr %r14,%r1 |
81 | 1: | 84 | 1: |
82 | .endm | 85 | .endm |
@@ -1113,9 +1116,12 @@ cleanup_io_leave_insn: | |||
1113 | .Lschedtail: .long schedule_tail | 1116 | .Lschedtail: .long schedule_tail |
1114 | .Lsysc_table: .long sys_call_table | 1117 | .Lsysc_table: .long sys_call_table |
1115 | #ifdef CONFIG_TRACE_IRQFLAGS | 1118 | #ifdef CONFIG_TRACE_IRQFLAGS |
1116 | .Ltrace_irq_on: .long trace_hardirqs_on | 1119 | .Ltrace_irq_on_caller: |
1117 | .Ltrace_irq_off: | 1120 | .long trace_hardirqs_on_caller |
1118 | .long trace_hardirqs_off | 1121 | .Ltrace_irq_off_caller: |
1122 | .long trace_hardirqs_off_caller | ||
1123 | #endif | ||
1124 | #ifdef CONFIG_LOCKDEP | ||
1119 | .Llockdep_sys_exit: | 1125 | .Llockdep_sys_exit: |
1120 | .long lockdep_sys_exit | 1126 | .long lockdep_sys_exit |
1121 | #endif | 1127 | #endif |
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S index d7ce150453f2..41aca06682aa 100644 --- a/arch/s390/kernel/entry64.S +++ b/arch/s390/kernel/entry64.S | |||
@@ -61,19 +61,22 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \ | |||
61 | 61 | ||
62 | #ifdef CONFIG_TRACE_IRQFLAGS | 62 | #ifdef CONFIG_TRACE_IRQFLAGS |
63 | .macro TRACE_IRQS_ON | 63 | .macro TRACE_IRQS_ON |
64 | brasl %r14,trace_hardirqs_on | 64 | basr %r2,%r0 |
65 | brasl %r14,trace_hardirqs_on_caller | ||
65 | .endm | 66 | .endm |
66 | 67 | ||
67 | .macro TRACE_IRQS_OFF | 68 | .macro TRACE_IRQS_OFF |
68 | brasl %r14,trace_hardirqs_off | 69 | basr %r2,%r0 |
70 | brasl %r14,trace_hardirqs_off_caller | ||
69 | .endm | 71 | .endm |
70 | 72 | ||
71 | .macro TRACE_IRQS_CHECK | 73 | .macro TRACE_IRQS_CHECK |
74 | basr %r2,%r0 | ||
72 | tm SP_PSW(%r15),0x03 # irqs enabled? | 75 | tm SP_PSW(%r15),0x03 # irqs enabled? |
73 | jz 0f | 76 | jz 0f |
74 | brasl %r14,trace_hardirqs_on | 77 | brasl %r14,trace_hardirqs_on_caller |
75 | j 1f | 78 | j 1f |
76 | 0: brasl %r14,trace_hardirqs_off | 79 | 0: brasl %r14,trace_hardirqs_off_caller |
77 | 1: | 80 | 1: |
78 | .endm | 81 | .endm |
79 | #else | 82 | #else |
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 3e2c05cb6a87..04f8c67a6101 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c | |||
@@ -136,9 +136,12 @@ static void default_idle(void) | |||
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | trace_hardirqs_on(); | 138 | trace_hardirqs_on(); |
139 | /* Don't trace preempt off for idle. */ | ||
140 | stop_critical_timings(); | ||
139 | /* Wait for external, I/O or machine check interrupt. */ | 141 | /* Wait for external, I/O or machine check interrupt. */ |
140 | __load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT | | 142 | __load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT | |
141 | PSW_MASK_IO | PSW_MASK_EXT); | 143 | PSW_MASK_IO | PSW_MASK_EXT); |
144 | start_critical_timings(); | ||
142 | } | 145 | } |
143 | 146 | ||
144 | void cpu_idle(void) | 147 | void cpu_idle(void) |
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 62122bad1e33..400b040df7fa 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
@@ -604,13 +604,13 @@ setup_memory(void) | |||
604 | if (memory_chunk[i].type != CHUNK_READ_WRITE) | 604 | if (memory_chunk[i].type != CHUNK_READ_WRITE) |
605 | continue; | 605 | continue; |
606 | start_chunk = PFN_DOWN(memory_chunk[i].addr); | 606 | start_chunk = PFN_DOWN(memory_chunk[i].addr); |
607 | end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size) - 1; | 607 | end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size); |
608 | end_chunk = min(end_chunk, end_pfn); | 608 | end_chunk = min(end_chunk, end_pfn); |
609 | if (start_chunk >= end_chunk) | 609 | if (start_chunk >= end_chunk) |
610 | continue; | 610 | continue; |
611 | add_active_range(0, start_chunk, end_chunk); | 611 | add_active_range(0, start_chunk, end_chunk); |
612 | pfn = max(start_chunk, start_pfn); | 612 | pfn = max(start_chunk, start_pfn); |
613 | for (; pfn <= end_chunk; pfn++) | 613 | for (; pfn < end_chunk; pfn++) |
614 | page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY); | 614 | page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY); |
615 | } | 615 | } |
616 | 616 | ||
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c index 5fdb799062b7..4fe952e557ac 100644 --- a/arch/s390/kernel/sys_s390.c +++ b/arch/s390/kernel/sys_s390.c | |||
@@ -198,7 +198,7 @@ asmlinkage long s390x_newuname(struct new_utsname __user *name) | |||
198 | { | 198 | { |
199 | int ret = sys_newuname(name); | 199 | int ret = sys_newuname(name); |
200 | 200 | ||
201 | if (current->personality == PER_LINUX32 && !ret) { | 201 | if (personality(current->personality) == PER_LINUX32 && !ret) { |
202 | ret = copy_to_user(name->machine, "s390\0\0\0\0", 8); | 202 | ret = copy_to_user(name->machine, "s390\0\0\0\0", 8); |
203 | if (ret) ret = -EFAULT; | 203 | if (ret) ret = -EFAULT; |
204 | } | 204 | } |
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c index 632b13e10053..a947899dcba1 100644 --- a/arch/s390/kernel/topology.c +++ b/arch/s390/kernel/topology.c | |||
@@ -65,18 +65,21 @@ static int machine_has_topology_irq; | |||
65 | static struct timer_list topology_timer; | 65 | static struct timer_list topology_timer; |
66 | static void set_topology_timer(void); | 66 | static void set_topology_timer(void); |
67 | static DECLARE_WORK(topology_work, topology_work_fn); | 67 | static DECLARE_WORK(topology_work, topology_work_fn); |
68 | /* topology_lock protects the core linked list */ | ||
69 | static DEFINE_SPINLOCK(topology_lock); | ||
68 | 70 | ||
69 | cpumask_t cpu_core_map[NR_CPUS]; | 71 | cpumask_t cpu_core_map[NR_CPUS]; |
70 | 72 | ||
71 | cpumask_t cpu_coregroup_map(unsigned int cpu) | 73 | cpumask_t cpu_coregroup_map(unsigned int cpu) |
72 | { | 74 | { |
73 | struct core_info *core = &core_info; | 75 | struct core_info *core = &core_info; |
76 | unsigned long flags; | ||
74 | cpumask_t mask; | 77 | cpumask_t mask; |
75 | 78 | ||
76 | cpus_clear(mask); | 79 | cpus_clear(mask); |
77 | if (!machine_has_topology) | 80 | if (!machine_has_topology) |
78 | return cpu_present_map; | 81 | return cpu_present_map; |
79 | mutex_lock(&smp_cpu_state_mutex); | 82 | spin_lock_irqsave(&topology_lock, flags); |
80 | while (core) { | 83 | while (core) { |
81 | if (cpu_isset(cpu, core->mask)) { | 84 | if (cpu_isset(cpu, core->mask)) { |
82 | mask = core->mask; | 85 | mask = core->mask; |
@@ -84,7 +87,7 @@ cpumask_t cpu_coregroup_map(unsigned int cpu) | |||
84 | } | 87 | } |
85 | core = core->next; | 88 | core = core->next; |
86 | } | 89 | } |
87 | mutex_unlock(&smp_cpu_state_mutex); | 90 | spin_unlock_irqrestore(&topology_lock, flags); |
88 | if (cpus_empty(mask)) | 91 | if (cpus_empty(mask)) |
89 | mask = cpumask_of_cpu(cpu); | 92 | mask = cpumask_of_cpu(cpu); |
90 | return mask; | 93 | return mask; |
@@ -133,7 +136,7 @@ static void tl_to_cores(struct tl_info *info) | |||
133 | union tl_entry *tle, *end; | 136 | union tl_entry *tle, *end; |
134 | struct core_info *core = &core_info; | 137 | struct core_info *core = &core_info; |
135 | 138 | ||
136 | mutex_lock(&smp_cpu_state_mutex); | 139 | spin_lock_irq(&topology_lock); |
137 | clear_cores(); | 140 | clear_cores(); |
138 | tle = info->tle; | 141 | tle = info->tle; |
139 | end = (union tl_entry *)((unsigned long)info + info->length); | 142 | end = (union tl_entry *)((unsigned long)info + info->length); |
@@ -157,7 +160,7 @@ static void tl_to_cores(struct tl_info *info) | |||
157 | } | 160 | } |
158 | tle = next_tle(tle); | 161 | tle = next_tle(tle); |
159 | } | 162 | } |
160 | mutex_unlock(&smp_cpu_state_mutex); | 163 | spin_unlock_irq(&topology_lock); |
161 | } | 164 | } |
162 | 165 | ||
163 | static void topology_update_polarization_simple(void) | 166 | static void topology_update_polarization_simple(void) |
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index 436c28539577..65eaae34e753 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h | |||
@@ -293,6 +293,10 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags) | |||
293 | */ | 293 | */ |
294 | #define xlate_dev_kmem_ptr(p) p | 294 | #define xlate_dev_kmem_ptr(p) p |
295 | 295 | ||
296 | #define ARCH_HAS_VALID_PHYS_ADDR_RANGE | ||
297 | int valid_phys_addr_range(unsigned long addr, size_t size); | ||
298 | int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); | ||
299 | |||
296 | #endif /* __KERNEL__ */ | 300 | #endif /* __KERNEL__ */ |
297 | 301 | ||
298 | #endif /* __ASM_SH_IO_H */ | 302 | #endif /* __ASM_SH_IO_H */ |
diff --git a/arch/sh/include/asm/pgtable.h b/arch/sh/include/asm/pgtable.h index 52220d70a096..b517ae08b9c0 100644 --- a/arch/sh/include/asm/pgtable.h +++ b/arch/sh/include/asm/pgtable.h | |||
@@ -148,6 +148,12 @@ extern void paging_init(void); | |||
148 | extern void page_table_range_init(unsigned long start, unsigned long end, | 148 | extern void page_table_range_init(unsigned long start, unsigned long end, |
149 | pgd_t *pgd); | 149 | pgd_t *pgd); |
150 | 150 | ||
151 | #if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_CPU_SH4) && defined(CONFIG_MMU) | ||
152 | extern void kmap_coherent_init(void); | ||
153 | #else | ||
154 | #define kmap_coherent_init() do { } while (0) | ||
155 | #endif | ||
156 | |||
151 | #include <asm-generic/pgtable.h> | 157 | #include <asm-generic/pgtable.h> |
152 | 158 | ||
153 | #endif /* __ASM_SH_PGTABLE_H */ | 159 | #endif /* __ASM_SH_PGTABLE_H */ |
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c index a7412cede534..6d9e6972cfc9 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c | |||
@@ -119,17 +119,17 @@ static struct plat_sci_port sci_platform_data[] = { | |||
119 | },{ | 119 | },{ |
120 | .mapbase = 0xa4e30000, | 120 | .mapbase = 0xa4e30000, |
121 | .flags = UPF_BOOT_AUTOCONF, | 121 | .flags = UPF_BOOT_AUTOCONF, |
122 | .type = PORT_SCI, | 122 | .type = PORT_SCIFA, |
123 | .irqs = { 56, 56, 56, 56 }, | 123 | .irqs = { 56, 56, 56, 56 }, |
124 | },{ | 124 | },{ |
125 | .mapbase = 0xa4e40000, | 125 | .mapbase = 0xa4e40000, |
126 | .flags = UPF_BOOT_AUTOCONF, | 126 | .flags = UPF_BOOT_AUTOCONF, |
127 | .type = PORT_SCI, | 127 | .type = PORT_SCIFA, |
128 | .irqs = { 88, 88, 88, 88 }, | 128 | .irqs = { 88, 88, 88, 88 }, |
129 | },{ | 129 | },{ |
130 | .mapbase = 0xa4e50000, | 130 | .mapbase = 0xa4e50000, |
131 | .flags = UPF_BOOT_AUTOCONF, | 131 | .flags = UPF_BOOT_AUTOCONF, |
132 | .type = PORT_SCI, | 132 | .type = PORT_SCIFA, |
133 | .irqs = { 109, 109, 109, 109 }, | 133 | .irqs = { 109, 109, 109, 109 }, |
134 | }, { | 134 | }, { |
135 | .flags = 0, | 135 | .flags = 0, |
diff --git a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c index 6b7d166694e2..a952dcf9999d 100644 --- a/arch/sh/kernel/early_printk.c +++ b/arch/sh/kernel/early_printk.c | |||
@@ -75,6 +75,7 @@ static struct console bios_console = { | |||
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | static struct uart_port scif_port = { | 77 | static struct uart_port scif_port = { |
78 | .type = PORT_SCIF, | ||
78 | .mapbase = CONFIG_EARLY_SCIF_CONSOLE_PORT, | 79 | .mapbase = CONFIG_EARLY_SCIF_CONSOLE_PORT, |
79 | .membase = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT, | 80 | .membase = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT, |
80 | }; | 81 | }; |
@@ -84,9 +85,9 @@ static void scif_sercon_putc(int c) | |||
84 | while (((sci_in(&scif_port, SCFDR) & EPK_FIFO_BITS) >= EPK_FIFO_SIZE)) | 85 | while (((sci_in(&scif_port, SCFDR) & EPK_FIFO_BITS) >= EPK_FIFO_SIZE)) |
85 | ; | 86 | ; |
86 | 87 | ||
87 | sci_out(&scif_port, SCxTDR, c); | ||
88 | sci_in(&scif_port, SCxSR); | 88 | sci_in(&scif_port, SCxSR); |
89 | sci_out(&scif_port, SCxSR, 0xf3 & ~(0x20 | 0x40)); | 89 | sci_out(&scif_port, SCxSR, 0xf3 & ~(0x20 | 0x40)); |
90 | sci_out(&scif_port, SCxTDR, c); | ||
90 | 91 | ||
91 | while ((sci_in(&scif_port, SCxSR) & 0x40) == 0) | 92 | while ((sci_in(&scif_port, SCxSR) & 0x40) == 0) |
92 | ; | 93 | ; |
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c index aaaf90d06b85..3c61ddd4d43e 100644 --- a/arch/sh/kernel/timers/timer-tmu.c +++ b/arch/sh/kernel/timers/timer-tmu.c | |||
@@ -120,7 +120,7 @@ static void tmu_set_mode(enum clock_event_mode mode, | |||
120 | { | 120 | { |
121 | switch (mode) { | 121 | switch (mode) { |
122 | case CLOCK_EVT_MODE_PERIODIC: | 122 | case CLOCK_EVT_MODE_PERIODIC: |
123 | ctrl_outl(ctrl_inl(TMU0_TCNT), TMU0_TCOR); | 123 | ctrl_outl(tmu_latest_interval[TMU0], TMU0_TCOR); |
124 | break; | 124 | break; |
125 | case CLOCK_EVT_MODE_ONESHOT: | 125 | case CLOCK_EVT_MODE_ONESHOT: |
126 | ctrl_outl(0, TMU0_TCOR); | 126 | ctrl_outl(0, TMU0_TCOR); |
diff --git a/arch/sh/lib/copy_page.S b/arch/sh/lib/copy_page.S index 5d12e657be34..43de7e8e4e17 100644 --- a/arch/sh/lib/copy_page.S +++ b/arch/sh/lib/copy_page.S | |||
@@ -80,6 +80,11 @@ ENTRY(copy_page) | |||
80 | .section __ex_table, "a"; \ | 80 | .section __ex_table, "a"; \ |
81 | .long 9999b, 6000f ; \ | 81 | .long 9999b, 6000f ; \ |
82 | .previous | 82 | .previous |
83 | #define EX_NO_POP(...) \ | ||
84 | 9999: __VA_ARGS__ ; \ | ||
85 | .section __ex_table, "a"; \ | ||
86 | .long 9999b, 6005f ; \ | ||
87 | .previous | ||
83 | ENTRY(__copy_user) | 88 | ENTRY(__copy_user) |
84 | ! Check if small number of bytes | 89 | ! Check if small number of bytes |
85 | mov #11,r0 | 90 | mov #11,r0 |
@@ -139,9 +144,9 @@ EX( mov.b r1,@r4 ) | |||
139 | bt 1f | 144 | bt 1f |
140 | 145 | ||
141 | 2: | 146 | 2: |
142 | EX( mov.b @r5+,r0 ) | 147 | EX_NO_POP( mov.b @r5+,r0 ) |
143 | dt r6 | 148 | dt r6 |
144 | EX( mov.b r0,@r4 ) | 149 | EX_NO_POP( mov.b r0,@r4 ) |
145 | bf/s 2b | 150 | bf/s 2b |
146 | add #1,r4 | 151 | add #1,r4 |
147 | 152 | ||
@@ -150,7 +155,7 @@ EX( mov.b r0,@r4 ) | |||
150 | 155 | ||
151 | # Exception handler: | 156 | # Exception handler: |
152 | .section .fixup, "ax" | 157 | .section .fixup, "ax" |
153 | 6000: | 158 | 6005: |
154 | mov.l 8000f,r1 | 159 | mov.l 8000f,r1 |
155 | mov r3,r0 | 160 | mov r3,r0 |
156 | jmp @r1 | 161 | jmp @r1 |
diff --git a/arch/sh/mm/Makefile_32 b/arch/sh/mm/Makefile_32 index 70e0906023cc..f066e76da204 100644 --- a/arch/sh/mm/Makefile_32 +++ b/arch/sh/mm/Makefile_32 | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the Linux SuperH-specific parts of the memory manager. | 2 | # Makefile for the Linux SuperH-specific parts of the memory manager. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := init.o extable_32.o consistent.o | 5 | obj-y := init.o extable_32.o consistent.o mmap.o |
6 | 6 | ||
7 | ifndef CONFIG_CACHE_OFF | 7 | ifndef CONFIG_CACHE_OFF |
8 | cache-$(CONFIG_CPU_SH2) := cache-sh2.o | 8 | cache-$(CONFIG_CPU_SH2) := cache-sh2.o |
diff --git a/arch/sh/mm/Makefile_64 b/arch/sh/mm/Makefile_64 index 0d92a8a3ac9a..9481d0f54efd 100644 --- a/arch/sh/mm/Makefile_64 +++ b/arch/sh/mm/Makefile_64 | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the Linux SuperH-specific parts of the memory manager. | 2 | # Makefile for the Linux SuperH-specific parts of the memory manager. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := init.o consistent.o | 5 | obj-y := init.o consistent.o mmap.o |
6 | 6 | ||
7 | mmu-y := tlb-nommu.o pg-nommu.o extable_32.o | 7 | mmu-y := tlb-nommu.o pg-nommu.o extable_32.o |
8 | mmu-$(CONFIG_MMU) := fault_64.o ioremap_64.o tlbflush_64.o tlb-sh5.o \ | 8 | mmu-$(CONFIG_MMU) := fault_64.o ioremap_64.o tlbflush_64.o tlb-sh5.o \ |
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 4abf00031dae..6cbef8caeb56 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c | |||
@@ -137,6 +137,7 @@ void __init page_table_range_init(unsigned long start, unsigned long end, | |||
137 | void __init paging_init(void) | 137 | void __init paging_init(void) |
138 | { | 138 | { |
139 | unsigned long max_zone_pfns[MAX_NR_ZONES]; | 139 | unsigned long max_zone_pfns[MAX_NR_ZONES]; |
140 | unsigned long vaddr; | ||
140 | int nid; | 141 | int nid; |
141 | 142 | ||
142 | /* We don't need to map the kernel through the TLB, as | 143 | /* We don't need to map the kernel through the TLB, as |
@@ -148,10 +149,15 @@ void __init paging_init(void) | |||
148 | * check for a null value. */ | 149 | * check for a null value. */ |
149 | set_TTB(swapper_pg_dir); | 150 | set_TTB(swapper_pg_dir); |
150 | 151 | ||
151 | /* Populate the relevant portions of swapper_pg_dir so that | 152 | /* |
153 | * Populate the relevant portions of swapper_pg_dir so that | ||
152 | * we can use the fixmap entries without calling kmalloc. | 154 | * we can use the fixmap entries without calling kmalloc. |
153 | * pte's will be filled in by __set_fixmap(). */ | 155 | * pte's will be filled in by __set_fixmap(). |
154 | page_table_range_init(FIXADDR_START, FIXADDR_TOP, swapper_pg_dir); | 156 | */ |
157 | vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; | ||
158 | page_table_range_init(vaddr, 0, swapper_pg_dir); | ||
159 | |||
160 | kmap_coherent_init(); | ||
155 | 161 | ||
156 | memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); | 162 | memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); |
157 | 163 | ||
diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c new file mode 100644 index 000000000000..8837d511710a --- /dev/null +++ b/arch/sh/mm/mmap.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * arch/sh/mm/mmap.c | ||
3 | * | ||
4 | * Copyright (C) 2008 Paul Mundt | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #include <linux/io.h> | ||
11 | #include <linux/mm.h> | ||
12 | #include <asm/page.h> | ||
13 | |||
14 | /* | ||
15 | * You really shouldn't be using read() or write() on /dev/mem. This | ||
16 | * might go away in the future. | ||
17 | */ | ||
18 | int valid_phys_addr_range(unsigned long addr, size_t count) | ||
19 | { | ||
20 | if (addr < __MEMORY_START) | ||
21 | return 0; | ||
22 | if (addr + count > __pa(high_memory)) | ||
23 | return 0; | ||
24 | |||
25 | return 1; | ||
26 | } | ||
27 | |||
28 | int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) | ||
29 | { | ||
30 | return 1; | ||
31 | } | ||
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c index 38870e0fc182..2fe14da1f839 100644 --- a/arch/sh/mm/pg-sh4.c +++ b/arch/sh/mm/pg-sh4.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * Released under the terms of the GNU GPL v2.0. | 7 | * Released under the terms of the GNU GPL v2.0. |
8 | */ | 8 | */ |
9 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
10 | #include <linux/init.h> | ||
10 | #include <linux/mutex.h> | 11 | #include <linux/mutex.h> |
11 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
12 | #include <linux/highmem.h> | 13 | #include <linux/highmem.h> |
@@ -16,6 +17,20 @@ | |||
16 | 17 | ||
17 | #define CACHE_ALIAS (current_cpu_data.dcache.alias_mask) | 18 | #define CACHE_ALIAS (current_cpu_data.dcache.alias_mask) |
18 | 19 | ||
20 | #define kmap_get_fixmap_pte(vaddr) \ | ||
21 | pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr)) | ||
22 | |||
23 | static pte_t *kmap_coherent_pte; | ||
24 | |||
25 | void __init kmap_coherent_init(void) | ||
26 | { | ||
27 | unsigned long vaddr; | ||
28 | |||
29 | /* cache the first coherent kmap pte */ | ||
30 | vaddr = __fix_to_virt(FIX_CMAP_BEGIN); | ||
31 | kmap_coherent_pte = kmap_get_fixmap_pte(vaddr); | ||
32 | } | ||
33 | |||
19 | static inline void *kmap_coherent(struct page *page, unsigned long addr) | 34 | static inline void *kmap_coherent(struct page *page, unsigned long addr) |
20 | { | 35 | { |
21 | enum fixed_addresses idx; | 36 | enum fixed_addresses idx; |
@@ -34,6 +49,8 @@ static inline void *kmap_coherent(struct page *page, unsigned long addr) | |||
34 | 49 | ||
35 | update_mmu_cache(NULL, vaddr, pte); | 50 | update_mmu_cache(NULL, vaddr, pte); |
36 | 51 | ||
52 | set_pte(kmap_coherent_pte - (FIX_CMAP_END - idx), pte); | ||
53 | |||
37 | return (void *)vaddr; | 54 | return (void *)vaddr; |
38 | } | 55 | } |
39 | 56 | ||
diff --git a/arch/sparc/include/asm/termbits.h b/arch/sparc/include/asm/termbits.h index d6ca3e2754f5..d72dfed1f9d7 100644 --- a/arch/sparc/include/asm/termbits.h +++ b/arch/sparc/include/asm/termbits.h | |||
@@ -29,10 +29,11 @@ struct termios { | |||
29 | tcflag_t c_cflag; /* control mode flags */ | 29 | tcflag_t c_cflag; /* control mode flags */ |
30 | tcflag_t c_lflag; /* local mode flags */ | 30 | tcflag_t c_lflag; /* local mode flags */ |
31 | cc_t c_line; /* line discipline */ | 31 | cc_t c_line; /* line discipline */ |
32 | #ifndef __KERNEL__ | ||
32 | cc_t c_cc[NCCS]; /* control characters */ | 33 | cc_t c_cc[NCCS]; /* control characters */ |
33 | #ifdef __KERNEL__ | 34 | #else |
35 | cc_t c_cc[NCCS+2]; /* kernel needs 2 more to hold vmin/vtime */ | ||
34 | #define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t)) | 36 | #define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t)) |
35 | cc_t _x_cc[2]; /* We need them to hold vmin/vtime */ | ||
36 | #endif | 37 | #endif |
37 | }; | 38 | }; |
38 | 39 | ||
@@ -42,8 +43,7 @@ struct termios2 { | |||
42 | tcflag_t c_cflag; /* control mode flags */ | 43 | tcflag_t c_cflag; /* control mode flags */ |
43 | tcflag_t c_lflag; /* local mode flags */ | 44 | tcflag_t c_lflag; /* local mode flags */ |
44 | cc_t c_line; /* line discipline */ | 45 | cc_t c_line; /* line discipline */ |
45 | cc_t c_cc[NCCS]; /* control characters */ | 46 | cc_t c_cc[NCCS+2]; /* control characters */ |
46 | cc_t _x_cc[2]; /* padding to match ktermios */ | ||
47 | speed_t c_ispeed; /* input speed */ | 47 | speed_t c_ispeed; /* input speed */ |
48 | speed_t c_ospeed; /* output speed */ | 48 | speed_t c_ospeed; /* output speed */ |
49 | }; | 49 | }; |
@@ -54,8 +54,7 @@ struct ktermios { | |||
54 | tcflag_t c_cflag; /* control mode flags */ | 54 | tcflag_t c_cflag; /* control mode flags */ |
55 | tcflag_t c_lflag; /* local mode flags */ | 55 | tcflag_t c_lflag; /* local mode flags */ |
56 | cc_t c_line; /* line discipline */ | 56 | cc_t c_line; /* line discipline */ |
57 | cc_t c_cc[NCCS]; /* control characters */ | 57 | cc_t c_cc[NCCS+2]; /* control characters */ |
58 | cc_t _x_cc[2]; /* We need them to hold vmin/vtime */ | ||
59 | speed_t c_ispeed; /* input speed */ | 58 | speed_t c_ispeed; /* input speed */ |
60 | speed_t c_ospeed; /* output speed */ | 59 | speed_t c_ospeed; /* output speed */ |
61 | }; | 60 | }; |
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c index 0837bd52e28f..0a83bd737654 100644 --- a/arch/sparc/kernel/of_device.c +++ b/arch/sparc/kernel/of_device.c | |||
@@ -563,9 +563,9 @@ build_resources: | |||
563 | op->dev.parent = parent; | 563 | op->dev.parent = parent; |
564 | op->dev.bus = &of_platform_bus_type; | 564 | op->dev.bus = &of_platform_bus_type; |
565 | if (!parent) | 565 | if (!parent) |
566 | strcpy(op->dev.bus_id, "root"); | 566 | dev_set_name(&op->dev, "root"); |
567 | else | 567 | else |
568 | sprintf(op->dev.bus_id, "%08x", dp->node); | 568 | dev_set_name(&op->dev, "%08x", dp->node); |
569 | 569 | ||
570 | if (of_device_register(op)) { | 570 | if (of_device_register(op)) { |
571 | printk("%s: Could not register of device.\n", | 571 | printk("%s: Could not register of device.\n", |
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 8d676d8ecde9..9830681446ad 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h | |||
@@ -113,7 +113,6 @@ static inline void acpi_disable_pci(void) | |||
113 | acpi_pci_disabled = 1; | 113 | acpi_pci_disabled = 1; |
114 | acpi_noirq_set(); | 114 | acpi_noirq_set(); |
115 | } | 115 | } |
116 | extern int acpi_irq_balance_set(char *str); | ||
117 | 116 | ||
118 | /* routines for saving/restoring kernel state */ | 117 | /* routines for saving/restoring kernel state */ |
119 | extern int acpi_save_state_mem(void); | 118 | extern int acpi_save_state_mem(void); |
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h index e4a552d44465..0b500c5b6446 100644 --- a/arch/x86/include/asm/iommu.h +++ b/arch/x86/include/asm/iommu.h | |||
@@ -6,7 +6,6 @@ extern void no_iommu_init(void); | |||
6 | extern struct dma_mapping_ops nommu_dma_ops; | 6 | extern struct dma_mapping_ops nommu_dma_ops; |
7 | extern int force_iommu, no_iommu; | 7 | extern int force_iommu, no_iommu; |
8 | extern int iommu_detected; | 8 | extern int iommu_detected; |
9 | extern int dmar_disabled; | ||
10 | 9 | ||
11 | extern unsigned long iommu_nr_pages(unsigned long addr, unsigned long len); | 10 | extern unsigned long iommu_nr_pages(unsigned long addr, unsigned long len); |
12 | 11 | ||
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 8c1f76abae9e..4c51a2f8fd31 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -1343,7 +1343,6 @@ static void __init acpi_process_madt(void) | |||
1343 | error = acpi_parse_madt_ioapic_entries(); | 1343 | error = acpi_parse_madt_ioapic_entries(); |
1344 | if (!error) { | 1344 | if (!error) { |
1345 | acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; | 1345 | acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; |
1346 | acpi_irq_balance_set(NULL); | ||
1347 | acpi_ioapic = 1; | 1346 | acpi_ioapic = 1; |
1348 | 1347 | ||
1349 | smp_found_config = 1; | 1348 | smp_found_config = 1; |
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c index 3ce029ffaa55..1b894b72c0f5 100644 --- a/arch/x86/kernel/early-quirks.c +++ b/arch/x86/kernel/early-quirks.c | |||
@@ -188,20 +188,6 @@ static void __init ati_bugs_contd(int num, int slot, int func) | |||
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | #ifdef CONFIG_DMAR | ||
192 | static void __init intel_g33_dmar(int num, int slot, int func) | ||
193 | { | ||
194 | struct acpi_table_header *dmar_tbl; | ||
195 | acpi_status status; | ||
196 | |||
197 | status = acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_tbl); | ||
198 | if (ACPI_SUCCESS(status)) { | ||
199 | printk(KERN_INFO "BIOS BUG: DMAR advertised on Intel G31/G33 chipset -- ignoring\n"); | ||
200 | dmar_disabled = 1; | ||
201 | } | ||
202 | } | ||
203 | #endif | ||
204 | |||
205 | #define QFLAG_APPLY_ONCE 0x1 | 191 | #define QFLAG_APPLY_ONCE 0x1 |
206 | #define QFLAG_APPLIED 0x2 | 192 | #define QFLAG_APPLIED 0x2 |
207 | #define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED) | 193 | #define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED) |
@@ -225,10 +211,6 @@ static struct chipset early_qrk[] __initdata = { | |||
225 | PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs }, | 211 | PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs }, |
226 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, | 212 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, |
227 | PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd }, | 213 | PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd }, |
228 | #ifdef CONFIG_DMAR | ||
229 | { PCI_VENDOR_ID_INTEL, 0x29c0, | ||
230 | PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, intel_g33_dmar }, | ||
231 | #endif | ||
232 | {} | 214 | {} |
233 | }; | 215 | }; |
234 | 216 | ||
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 774ac4991568..1c9cc431ea4f 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c | |||
@@ -128,7 +128,7 @@ static int kvm_register_clock(char *txt) | |||
128 | } | 128 | } |
129 | 129 | ||
130 | #ifdef CONFIG_X86_LOCAL_APIC | 130 | #ifdef CONFIG_X86_LOCAL_APIC |
131 | static void kvm_setup_secondary_clock(void) | 131 | static void __devinit kvm_setup_secondary_clock(void) |
132 | { | 132 | { |
133 | /* | 133 | /* |
134 | * Now that the first cpu already had this clocksource initialized, | 134 | * Now that the first cpu already had this clocksource initialized, |
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index ce3251ce5504..b81125f0bdee 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig | |||
@@ -20,6 +20,8 @@ if VIRTUALIZATION | |||
20 | config KVM | 20 | config KVM |
21 | tristate "Kernel-based Virtual Machine (KVM) support" | 21 | tristate "Kernel-based Virtual Machine (KVM) support" |
22 | depends on HAVE_KVM | 22 | depends on HAVE_KVM |
23 | # for device assignment: | ||
24 | depends on PCI | ||
23 | select PREEMPT_NOTIFIERS | 25 | select PREEMPT_NOTIFIERS |
24 | select MMU_NOTIFIER | 26 | select MMU_NOTIFIER |
25 | select ANON_INODES | 27 | select ANON_INODES |
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 8772dc946823..59ebd37ad79e 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -548,8 +548,10 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm) | |||
548 | mutex_lock(&kvm->lock); | 548 | mutex_lock(&kvm->lock); |
549 | pit->irq_source_id = kvm_request_irq_source_id(kvm); | 549 | pit->irq_source_id = kvm_request_irq_source_id(kvm); |
550 | mutex_unlock(&kvm->lock); | 550 | mutex_unlock(&kvm->lock); |
551 | if (pit->irq_source_id < 0) | 551 | if (pit->irq_source_id < 0) { |
552 | kfree(pit); | ||
552 | return NULL; | 553 | return NULL; |
554 | } | ||
553 | 555 | ||
554 | mutex_init(&pit->pit_state.lock); | 556 | mutex_init(&pit->pit_state.lock); |
555 | mutex_lock(&pit->pit_state.lock); | 557 | mutex_lock(&pit->pit_state.lock); |
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 2a5e64881d9b..f1983d9477cd 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -314,7 +314,7 @@ static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu) | |||
314 | if (r) | 314 | if (r) |
315 | goto out; | 315 | goto out; |
316 | r = mmu_topup_memory_cache(&vcpu->arch.mmu_rmap_desc_cache, | 316 | r = mmu_topup_memory_cache(&vcpu->arch.mmu_rmap_desc_cache, |
317 | rmap_desc_cache, 1); | 317 | rmap_desc_cache, 4); |
318 | if (r) | 318 | if (r) |
319 | goto out; | 319 | goto out; |
320 | r = mmu_topup_memory_cache_page(&vcpu->arch.mmu_page_cache, 8); | 320 | r = mmu_topup_memory_cache_page(&vcpu->arch.mmu_page_cache, 8); |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 2643b430d83a..d06b4dc0e2ea 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -3564,7 +3564,8 @@ static int __init vmx_init(void) | |||
3564 | bypass_guest_pf = 0; | 3564 | bypass_guest_pf = 0; |
3565 | kvm_mmu_set_base_ptes(VMX_EPT_READABLE_MASK | | 3565 | kvm_mmu_set_base_ptes(VMX_EPT_READABLE_MASK | |
3566 | VMX_EPT_WRITABLE_MASK | | 3566 | VMX_EPT_WRITABLE_MASK | |
3567 | VMX_EPT_DEFAULT_MT << VMX_EPT_MT_EPTE_SHIFT); | 3567 | VMX_EPT_DEFAULT_MT << VMX_EPT_MT_EPTE_SHIFT | |
3568 | VMX_EPT_IGMT_BIT); | ||
3568 | kvm_mmu_set_mask_ptes(0ull, 0ull, 0ull, 0ull, | 3569 | kvm_mmu_set_mask_ptes(0ull, 0ull, 0ull, 0ull, |
3569 | VMX_EPT_EXECUTABLE_MASK); | 3570 | VMX_EPT_EXECUTABLE_MASK); |
3570 | kvm_enable_tdp(); | 3571 | kvm_enable_tdp(); |
diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h index 3e010d21fdd7..ec5edc339da6 100644 --- a/arch/x86/kvm/vmx.h +++ b/arch/x86/kvm/vmx.h | |||
@@ -352,6 +352,7 @@ enum vmcs_field { | |||
352 | #define VMX_EPT_READABLE_MASK 0x1ull | 352 | #define VMX_EPT_READABLE_MASK 0x1ull |
353 | #define VMX_EPT_WRITABLE_MASK 0x2ull | 353 | #define VMX_EPT_WRITABLE_MASK 0x2ull |
354 | #define VMX_EPT_EXECUTABLE_MASK 0x4ull | 354 | #define VMX_EPT_EXECUTABLE_MASK 0x4ull |
355 | #define VMX_EPT_IGMT_BIT (1ull << 6) | ||
355 | 356 | ||
356 | #define VMX_EPT_IDENTITY_PAGETABLE_ADDR 0xfffbc000ul | 357 | #define VMX_EPT_IDENTITY_PAGETABLE_ADDR 0xfffbc000ul |
357 | 358 | ||
diff --git a/block/blk-map.c b/block/blk-map.c index 4849fa36161e..0f4b4b881811 100644 --- a/block/blk-map.c +++ b/block/blk-map.c | |||
@@ -217,6 +217,12 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, | |||
217 | return PTR_ERR(bio); | 217 | return PTR_ERR(bio); |
218 | 218 | ||
219 | if (bio->bi_size != len) { | 219 | if (bio->bi_size != len) { |
220 | /* | ||
221 | * Grab an extra reference to this bio, as bio_unmap_user() | ||
222 | * expects to be able to drop it twice as it happens on the | ||
223 | * normal IO completion path | ||
224 | */ | ||
225 | bio_get(bio); | ||
220 | bio_endio(bio, 0); | 226 | bio_endio(bio, 0); |
221 | bio_unmap_user(bio); | 227 | bio_unmap_user(bio); |
222 | return -EINVAL; | 228 | return -EINVAL; |
diff --git a/block/genhd.c b/block/genhd.c index 4e5e7493f676..27549e470da5 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -768,6 +768,8 @@ static int __init genhd_device_init(void) | |||
768 | bdev_map = kobj_map_init(base_probe, &block_class_lock); | 768 | bdev_map = kobj_map_init(base_probe, &block_class_lock); |
769 | blk_dev_init(); | 769 | blk_dev_init(); |
770 | 770 | ||
771 | register_blkdev(BLOCK_EXT_MAJOR, "blkext"); | ||
772 | |||
771 | #ifndef CONFIG_SYSFS_DEPRECATED | 773 | #ifndef CONFIG_SYSFS_DEPRECATED |
772 | /* create top-level block dir */ | 774 | /* create top-level block dir */ |
773 | block_depr = kobject_create_and_add("block", NULL); | 775 | block_depr = kobject_create_and_add("block", NULL); |
diff --git a/block/ioctl.c b/block/ioctl.c index c832d639b6e2..d03985b04d67 100644 --- a/block/ioctl.c +++ b/block/ioctl.c | |||
@@ -18,7 +18,6 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user | |||
18 | struct disk_part_iter piter; | 18 | struct disk_part_iter piter; |
19 | long long start, length; | 19 | long long start, length; |
20 | int partno; | 20 | int partno; |
21 | int err; | ||
22 | 21 | ||
23 | if (!capable(CAP_SYS_ADMIN)) | 22 | if (!capable(CAP_SYS_ADMIN)) |
24 | return -EACCES; | 23 | return -EACCES; |
@@ -61,10 +60,10 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user | |||
61 | disk_part_iter_exit(&piter); | 60 | disk_part_iter_exit(&piter); |
62 | 61 | ||
63 | /* all seems OK */ | 62 | /* all seems OK */ |
64 | err = add_partition(disk, partno, start, length, | 63 | part = add_partition(disk, partno, start, length, |
65 | ADDPART_FLAG_NONE); | 64 | ADDPART_FLAG_NONE); |
66 | mutex_unlock(&bdev->bd_mutex); | 65 | mutex_unlock(&bdev->bd_mutex); |
67 | return err; | 66 | return IS_ERR(part) ? PTR_ERR(part) : 0; |
68 | case BLKPG_DEL_PARTITION: | 67 | case BLKPG_DEL_PARTITION: |
69 | part = disk_get_part(disk, partno); | 68 | part = disk_get_part(disk, partno); |
70 | if (!part) | 69 | if (!part) |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index f4f632917509..b0243fd55ac0 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -312,9 +312,13 @@ config ACPI_DEBUG | |||
312 | bool "Debug Statements" | 312 | bool "Debug Statements" |
313 | default n | 313 | default n |
314 | help | 314 | help |
315 | The ACPI driver can optionally report errors with a great deal | 315 | The ACPI subsystem can produce debug output. Saying Y enables this |
316 | of verbosity. Saying Y enables these statements. This will increase | 316 | output and increases the kernel size by around 50K. |
317 | your kernel size by around 50K. | 317 | |
318 | Use the acpi.debug_layer and acpi.debug_level kernel command-line | ||
319 | parameters documented in Documentation/acpi/debug.txt and | ||
320 | Documentation/kernel-parameters.txt to control the type and | ||
321 | amount of debug output. | ||
318 | 322 | ||
319 | config ACPI_DEBUG_FUNC_TRACE | 323 | config ACPI_DEBUG_FUNC_TRACE |
320 | bool "Additionally enable ACPI function tracing" | 324 | bool "Additionally enable ACPI function tracing" |
@@ -324,14 +328,6 @@ config ACPI_DEBUG_FUNC_TRACE | |||
324 | ACPI Debug Statements slow down ACPI processing. Function trace | 328 | ACPI Debug Statements slow down ACPI processing. Function trace |
325 | is about half of the penalty and is rarely useful. | 329 | is about half of the penalty and is rarely useful. |
326 | 330 | ||
327 | config ACPI_EC | ||
328 | bool | ||
329 | default y | ||
330 | help | ||
331 | This driver is required on some systems for the proper operation of | ||
332 | the battery and thermal drivers. If you are compiling for a | ||
333 | mobile system, say Y. | ||
334 | |||
335 | config ACPI_PCI_SLOT | 331 | config ACPI_PCI_SLOT |
336 | tristate "PCI slot detection driver" | 332 | tristate "PCI slot detection driver" |
337 | default n | 333 | default n |
@@ -341,10 +337,6 @@ config ACPI_PCI_SLOT | |||
341 | help you correlate PCI bus addresses with the physical geography | 337 | help you correlate PCI bus addresses with the physical geography |
342 | of your slots. If you are unsure, say N. | 338 | of your slots. If you are unsure, say N. |
343 | 339 | ||
344 | config ACPI_POWER | ||
345 | bool | ||
346 | default y | ||
347 | |||
348 | config ACPI_SYSTEM | 340 | config ACPI_SYSTEM |
349 | bool | 341 | bool |
350 | default y | 342 | default y |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index d91c027ece8f..3c0c93300f12 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -39,19 +39,23 @@ obj-y += sleep/ | |||
39 | obj-y += bus.o glue.o | 39 | obj-y += bus.o glue.o |
40 | obj-y += scan.o | 40 | obj-y += scan.o |
41 | # Keep EC driver first. Initialization of others depend on it. | 41 | # Keep EC driver first. Initialization of others depend on it. |
42 | obj-$(CONFIG_ACPI_EC) += ec.o | 42 | obj-y += ec.o |
43 | obj-$(CONFIG_ACPI_AC) += ac.o | 43 | obj-$(CONFIG_ACPI_AC) += ac.o |
44 | obj-$(CONFIG_ACPI_BATTERY) += battery.o | 44 | obj-$(CONFIG_ACPI_BATTERY) += battery.o |
45 | obj-$(CONFIG_ACPI_BUTTON) += button.o | 45 | obj-$(CONFIG_ACPI_BUTTON) += button.o |
46 | obj-$(CONFIG_ACPI_FAN) += fan.o | 46 | obj-$(CONFIG_ACPI_FAN) += fan.o |
47 | obj-$(CONFIG_ACPI_DOCK) += dock.o | 47 | obj-$(CONFIG_ACPI_DOCK) += dock.o |
48 | obj-$(CONFIG_ACPI_VIDEO) += video.o | 48 | obj-$(CONFIG_ACPI_VIDEO) += video.o |
49 | ifdef CONFIG_ACPI_VIDEO | ||
50 | obj-y += video_detect.o | ||
51 | endif | ||
52 | |||
49 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 53 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
50 | obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o | 54 | obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o |
51 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o | 55 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o |
52 | obj-$(CONFIG_ACPI_CONTAINER) += container.o | 56 | obj-$(CONFIG_ACPI_CONTAINER) += container.o |
53 | obj-$(CONFIG_ACPI_THERMAL) += thermal.o | 57 | obj-$(CONFIG_ACPI_THERMAL) += thermal.o |
54 | obj-$(CONFIG_ACPI_POWER) += power.o | 58 | obj-y += power.o |
55 | obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o | 59 | obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o |
56 | obj-$(CONFIG_ACPI_DEBUG) += debug.o | 60 | obj-$(CONFIG_ACPI_DEBUG) += debug.o |
57 | obj-$(CONFIG_ACPI_NUMA) += numa.o | 61 | obj-$(CONFIG_ACPI_NUMA) += numa.o |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index d72a1b6c8a94..9b917dac7732 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <acpi/acpi_bus.h> | 37 | #include <acpi/acpi_bus.h> |
38 | #include <acpi/acpi_drivers.h> | 38 | #include <acpi/acpi_drivers.h> |
39 | 39 | ||
40 | #define ACPI_AC_COMPONENT 0x00020000 | ||
41 | #define ACPI_AC_CLASS "ac_adapter" | 40 | #define ACPI_AC_CLASS "ac_adapter" |
42 | #define ACPI_AC_DEVICE_NAME "AC Adapter" | 41 | #define ACPI_AC_DEVICE_NAME "AC Adapter" |
43 | #define ACPI_AC_FILE_STATE "state" | 42 | #define ACPI_AC_FILE_STATE "state" |
@@ -242,7 +241,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | |||
242 | acpi_ac_get_state(ac); | 241 | acpi_ac_get_state(ac); |
243 | acpi_bus_generate_proc_event(device, event, (u32) ac->state); | 242 | acpi_bus_generate_proc_event(device, event, (u32) ac->state); |
244 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 243 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
245 | device->dev.bus_id, event, | 244 | dev_name(&device->dev), event, |
246 | (u32) ac->state); | 245 | (u32) ac->state); |
247 | #ifdef CONFIG_ACPI_SYSFS_POWER | 246 | #ifdef CONFIG_ACPI_SYSFS_POWER |
248 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); | 247 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 71d21c51c45f..63a17b55b39b 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/memory_hotplug.h> | 32 | #include <linux/memory_hotplug.h> |
33 | #include <acpi/acpi_drivers.h> | 33 | #include <acpi/acpi_drivers.h> |
34 | 34 | ||
35 | #define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL | ||
36 | #define ACPI_MEMORY_DEVICE_CLASS "memory" | 35 | #define ACPI_MEMORY_DEVICE_CLASS "memory" |
37 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" | 36 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" |
38 | #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" | 37 | #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index b2133e89ad9a..1423b0c0cd2e 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF | 47 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF |
48 | 48 | ||
49 | #define ACPI_BATTERY_COMPONENT 0x00040000 | ||
50 | #define ACPI_BATTERY_CLASS "battery" | 49 | #define ACPI_BATTERY_CLASS "battery" |
51 | #define ACPI_BATTERY_DEVICE_NAME "Battery" | 50 | #define ACPI_BATTERY_DEVICE_NAME "Battery" |
52 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 | 51 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 |
@@ -782,7 +781,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | |||
782 | acpi_bus_generate_proc_event(device, event, | 781 | acpi_bus_generate_proc_event(device, event, |
783 | acpi_battery_present(battery)); | 782 | acpi_battery_present(battery)); |
784 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 783 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
785 | device->dev.bus_id, event, | 784 | dev_name(&device->dev), event, |
786 | acpi_battery_present(battery)); | 785 | acpi_battery_present(battery)); |
787 | #ifdef CONFIG_ACPI_SYSFS_POWER | 786 | #ifdef CONFIG_ACPI_SYSFS_POWER |
788 | /* acpi_batter_update could remove power_supply object */ | 787 | /* acpi_batter_update could remove power_supply object */ |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index c797c6473f31..7edf6d913c13 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -688,6 +688,14 @@ void __init acpi_early_init(void) | |||
688 | if (acpi_disabled) | 688 | if (acpi_disabled) |
689 | return; | 689 | return; |
690 | 690 | ||
691 | /* | ||
692 | * ACPI CA initializes acpi_dbg_level to non-zero, which means | ||
693 | * we get debug output merely by turning on CONFIG_ACPI_DEBUG. | ||
694 | * Turn it off so we don't get output unless the user specifies | ||
695 | * acpi.debug_level. | ||
696 | */ | ||
697 | acpi_dbg_level = 0; | ||
698 | |||
691 | printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); | 699 | printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); |
692 | 700 | ||
693 | /* enable workarounds, unless strict ACPI spec. compliance */ | 701 | /* enable workarounds, unless strict ACPI spec. compliance */ |
@@ -774,7 +782,7 @@ static int __init acpi_bus_init(void) | |||
774 | "Unable to initialize ACPI OS objects\n"); | 782 | "Unable to initialize ACPI OS objects\n"); |
775 | goto error1; | 783 | goto error1; |
776 | } | 784 | } |
777 | #ifdef CONFIG_ACPI_EC | 785 | |
778 | /* | 786 | /* |
779 | * ACPI 2.0 requires the EC driver to be loaded and work before | 787 | * ACPI 2.0 requires the EC driver to be loaded and work before |
780 | * the EC device is found in the namespace (i.e. before acpi_initialize_objects() | 788 | * the EC device is found in the namespace (i.e. before acpi_initialize_objects() |
@@ -785,7 +793,6 @@ static int __init acpi_bus_init(void) | |||
785 | */ | 793 | */ |
786 | status = acpi_ec_ecdt_probe(); | 794 | status = acpi_ec_ecdt_probe(); |
787 | /* Ignore result. Not having an ECDT is not fatal. */ | 795 | /* Ignore result. Not having an ECDT is not fatal. */ |
788 | #endif | ||
789 | 796 | ||
790 | status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); | 797 | status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); |
791 | if (ACPI_FAILURE(status)) { | 798 | if (ACPI_FAILURE(status)) { |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index cb046c3fc3f2..171fd914f435 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <acpi/acpi_bus.h> | 33 | #include <acpi/acpi_bus.h> |
34 | #include <acpi/acpi_drivers.h> | 34 | #include <acpi/acpi_drivers.h> |
35 | 35 | ||
36 | #define ACPI_BUTTON_COMPONENT 0x00080000 | ||
37 | #define ACPI_BUTTON_CLASS "button" | 36 | #define ACPI_BUTTON_CLASS "button" |
38 | #define ACPI_BUTTON_FILE_INFO "info" | 37 | #define ACPI_BUTTON_FILE_INFO "info" |
39 | #define ACPI_BUTTON_FILE_STATE "state" | 38 | #define ACPI_BUTTON_FILE_STATE "state" |
@@ -479,7 +478,7 @@ static int acpi_button_add(struct acpi_device *device) | |||
479 | device->wakeup.gpe_number, | 478 | device->wakeup.gpe_number, |
480 | ACPI_GPE_TYPE_WAKE_RUN); | 479 | ACPI_GPE_TYPE_WAKE_RUN); |
481 | acpi_enable_gpe(device->wakeup.gpe_device, | 480 | acpi_enable_gpe(device->wakeup.gpe_device, |
482 | device->wakeup.gpe_number, ACPI_NOT_ISR); | 481 | device->wakeup.gpe_number); |
483 | device->wakeup.state.enabled = 1; | 482 | device->wakeup.state.enabled = 1; |
484 | } | 483 | } |
485 | 484 | ||
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c index 4441e84b28a9..307963bd1043 100644 --- a/drivers/acpi/cm_sbs.c +++ b/drivers/acpi/cm_sbs.c | |||
@@ -34,7 +34,6 @@ | |||
34 | ACPI_MODULE_NAME("cm_sbs"); | 34 | ACPI_MODULE_NAME("cm_sbs"); |
35 | #define ACPI_AC_CLASS "ac_adapter" | 35 | #define ACPI_AC_CLASS "ac_adapter" |
36 | #define ACPI_BATTERY_CLASS "battery" | 36 | #define ACPI_BATTERY_CLASS "battery" |
37 | #define ACPI_SBS_COMPONENT 0x00080000 | ||
38 | #define _COMPONENT ACPI_SBS_COMPONENT | 37 | #define _COMPONENT ACPI_SBS_COMPONENT |
39 | static struct proc_dir_entry *acpi_ac_dir; | 38 | static struct proc_dir_entry *acpi_ac_dir; |
40 | static struct proc_dir_entry *acpi_battery_dir; | 39 | static struct proc_dir_entry *acpi_battery_dir; |
@@ -105,9 +104,3 @@ void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param) | |||
105 | return; | 104 | return; |
106 | } | 105 | } |
107 | EXPORT_SYMBOL(acpi_unlock_battery_dir); | 106 | EXPORT_SYMBOL(acpi_unlock_battery_dir); |
108 | |||
109 | static int __init acpi_cm_sbs_init(void) | ||
110 | { | ||
111 | return 0; | ||
112 | } | ||
113 | subsys_initcall(acpi_cm_sbs_init); | ||
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 134818b265a9..17020c12623c 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #define INSTALL_NOTIFY_HANDLER 1 | 41 | #define INSTALL_NOTIFY_HANDLER 1 |
42 | #define UNINSTALL_NOTIFY_HANDLER 2 | 42 | #define UNINSTALL_NOTIFY_HANDLER 2 |
43 | 43 | ||
44 | #define ACPI_CONTAINER_COMPONENT 0x01000000 | ||
45 | #define _COMPONENT ACPI_CONTAINER_COMPONENT | 44 | #define _COMPONENT ACPI_CONTAINER_COMPONENT |
46 | ACPI_MODULE_NAME("container"); | 45 | ACPI_MODULE_NAME("container"); |
47 | 46 | ||
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index abf36b4b1d1d..c48396892008 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c | |||
@@ -44,6 +44,21 @@ static const struct acpi_dlayer acpi_debug_layers[] = { | |||
44 | ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER), | 44 | ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER), |
45 | ACPI_DEBUG_INIT(ACPI_COMPILER), | 45 | ACPI_DEBUG_INIT(ACPI_COMPILER), |
46 | ACPI_DEBUG_INIT(ACPI_TOOLS), | 46 | ACPI_DEBUG_INIT(ACPI_TOOLS), |
47 | |||
48 | ACPI_DEBUG_INIT(ACPI_BUS_COMPONENT), | ||
49 | ACPI_DEBUG_INIT(ACPI_AC_COMPONENT), | ||
50 | ACPI_DEBUG_INIT(ACPI_BATTERY_COMPONENT), | ||
51 | ACPI_DEBUG_INIT(ACPI_BUTTON_COMPONENT), | ||
52 | ACPI_DEBUG_INIT(ACPI_SBS_COMPONENT), | ||
53 | ACPI_DEBUG_INIT(ACPI_FAN_COMPONENT), | ||
54 | ACPI_DEBUG_INIT(ACPI_PCI_COMPONENT), | ||
55 | ACPI_DEBUG_INIT(ACPI_POWER_COMPONENT), | ||
56 | ACPI_DEBUG_INIT(ACPI_CONTAINER_COMPONENT), | ||
57 | ACPI_DEBUG_INIT(ACPI_SYSTEM_COMPONENT), | ||
58 | ACPI_DEBUG_INIT(ACPI_THERMAL_COMPONENT), | ||
59 | ACPI_DEBUG_INIT(ACPI_MEMORY_DEVICE_COMPONENT), | ||
60 | ACPI_DEBUG_INIT(ACPI_VIDEO_COMPONENT), | ||
61 | ACPI_DEBUG_INIT(ACPI_PROCESSOR_COMPONENT), | ||
47 | }; | 62 | }; |
48 | 63 | ||
49 | static const struct acpi_dlevel acpi_debug_levels[] = { | 64 | static const struct acpi_dlevel acpi_debug_levels[] = { |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index ef42316f89f5..cf41f9fc24a7 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -70,7 +70,7 @@ enum ec_command { | |||
70 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | 70 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ |
71 | #define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */ | 71 | #define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */ |
72 | 72 | ||
73 | #define ACPI_EC_STORM_THRESHOLD 20 /* number of false interrupts | 73 | #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts |
74 | per one transaction */ | 74 | per one transaction */ |
75 | 75 | ||
76 | enum { | 76 | enum { |
@@ -100,8 +100,11 @@ struct transaction { | |||
100 | u8 *rdata; | 100 | u8 *rdata; |
101 | unsigned short irq_count; | 101 | unsigned short irq_count; |
102 | u8 command; | 102 | u8 command; |
103 | u8 wi; | ||
104 | u8 ri; | ||
103 | u8 wlen; | 105 | u8 wlen; |
104 | u8 rlen; | 106 | u8 rlen; |
107 | bool done; | ||
105 | }; | 108 | }; |
106 | 109 | ||
107 | static struct acpi_ec { | 110 | static struct acpi_ec { |
@@ -178,34 +181,45 @@ static int ec_transaction_done(struct acpi_ec *ec) | |||
178 | unsigned long flags; | 181 | unsigned long flags; |
179 | int ret = 0; | 182 | int ret = 0; |
180 | spin_lock_irqsave(&ec->curr_lock, flags); | 183 | spin_lock_irqsave(&ec->curr_lock, flags); |
181 | if (!ec->curr || (!ec->curr->wlen && !ec->curr->rlen)) | 184 | if (!ec->curr || ec->curr->done) |
182 | ret = 1; | 185 | ret = 1; |
183 | spin_unlock_irqrestore(&ec->curr_lock, flags); | 186 | spin_unlock_irqrestore(&ec->curr_lock, flags); |
184 | return ret; | 187 | return ret; |
185 | } | 188 | } |
186 | 189 | ||
190 | static void start_transaction(struct acpi_ec *ec) | ||
191 | { | ||
192 | ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0; | ||
193 | ec->curr->done = false; | ||
194 | acpi_ec_write_cmd(ec, ec->curr->command); | ||
195 | } | ||
196 | |||
187 | static void gpe_transaction(struct acpi_ec *ec, u8 status) | 197 | static void gpe_transaction(struct acpi_ec *ec, u8 status) |
188 | { | 198 | { |
189 | unsigned long flags; | 199 | unsigned long flags; |
190 | spin_lock_irqsave(&ec->curr_lock, flags); | 200 | spin_lock_irqsave(&ec->curr_lock, flags); |
191 | if (!ec->curr) | 201 | if (!ec->curr) |
192 | goto unlock; | 202 | goto unlock; |
193 | if (ec->curr->wlen > 0) { | 203 | if (ec->curr->wlen > ec->curr->wi) { |
194 | if ((status & ACPI_EC_FLAG_IBF) == 0) { | 204 | if ((status & ACPI_EC_FLAG_IBF) == 0) |
195 | acpi_ec_write_data(ec, *(ec->curr->wdata++)); | 205 | acpi_ec_write_data(ec, |
196 | --ec->curr->wlen; | 206 | ec->curr->wdata[ec->curr->wi++]); |
197 | } else | 207 | else |
198 | /* false interrupt, state didn't change */ | 208 | goto err; |
199 | ++ec->curr->irq_count; | 209 | } else if (ec->curr->rlen > ec->curr->ri) { |
200 | |||
201 | } else if (ec->curr->rlen > 0) { | ||
202 | if ((status & ACPI_EC_FLAG_OBF) == 1) { | 210 | if ((status & ACPI_EC_FLAG_OBF) == 1) { |
203 | *(ec->curr->rdata++) = acpi_ec_read_data(ec); | 211 | ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec); |
204 | --ec->curr->rlen; | 212 | if (ec->curr->rlen == ec->curr->ri) |
213 | ec->curr->done = true; | ||
205 | } else | 214 | } else |
206 | /* false interrupt, state didn't change */ | 215 | goto err; |
207 | ++ec->curr->irq_count; | 216 | } else if (ec->curr->wlen == ec->curr->wi && |
208 | } | 217 | (status & ACPI_EC_FLAG_IBF) == 0) |
218 | ec->curr->done = true; | ||
219 | goto unlock; | ||
220 | err: | ||
221 | /* false interrupt, state didn't change */ | ||
222 | ++ec->curr->irq_count; | ||
209 | unlock: | 223 | unlock: |
210 | spin_unlock_irqrestore(&ec->curr_lock, flags); | 224 | spin_unlock_irqrestore(&ec->curr_lock, flags); |
211 | } | 225 | } |
@@ -215,6 +229,15 @@ static int acpi_ec_wait(struct acpi_ec *ec) | |||
215 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), | 229 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), |
216 | msecs_to_jiffies(ACPI_EC_DELAY))) | 230 | msecs_to_jiffies(ACPI_EC_DELAY))) |
217 | return 0; | 231 | return 0; |
232 | /* try restart command if we get any false interrupts */ | ||
233 | if (ec->curr->irq_count && | ||
234 | (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { | ||
235 | pr_debug(PREFIX "controller reset, restart transaction\n"); | ||
236 | start_transaction(ec); | ||
237 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), | ||
238 | msecs_to_jiffies(ACPI_EC_DELAY))) | ||
239 | return 0; | ||
240 | } | ||
218 | /* missing GPEs, switch back to poll mode */ | 241 | /* missing GPEs, switch back to poll mode */ |
219 | if (printk_ratelimit()) | 242 | if (printk_ratelimit()) |
220 | pr_info(PREFIX "missing confirmations, " | 243 | pr_info(PREFIX "missing confirmations, " |
@@ -239,10 +262,10 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state) | |||
239 | static int ec_poll(struct acpi_ec *ec) | 262 | static int ec_poll(struct acpi_ec *ec) |
240 | { | 263 | { |
241 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); | 264 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); |
242 | msleep(1); | 265 | udelay(ACPI_EC_UDELAY); |
243 | while (time_before(jiffies, delay)) { | 266 | while (time_before(jiffies, delay)) { |
244 | gpe_transaction(ec, acpi_ec_read_status(ec)); | 267 | gpe_transaction(ec, acpi_ec_read_status(ec)); |
245 | msleep(1); | 268 | udelay(ACPI_EC_UDELAY); |
246 | if (ec_transaction_done(ec)) | 269 | if (ec_transaction_done(ec)) |
247 | return 0; | 270 | return 0; |
248 | } | 271 | } |
@@ -259,14 +282,13 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
259 | /* disable GPE during transaction if storm is detected */ | 282 | /* disable GPE during transaction if storm is detected */ |
260 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { | 283 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { |
261 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 284 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
262 | acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 285 | acpi_disable_gpe(NULL, ec->gpe); |
263 | } | 286 | } |
264 | /* start transaction */ | 287 | /* start transaction */ |
265 | spin_lock_irqsave(&ec->curr_lock, tmp); | 288 | spin_lock_irqsave(&ec->curr_lock, tmp); |
266 | /* following two actions should be kept atomic */ | 289 | /* following two actions should be kept atomic */ |
267 | t->irq_count = 0; | ||
268 | ec->curr = t; | 290 | ec->curr = t; |
269 | acpi_ec_write_cmd(ec, ec->curr->command); | 291 | start_transaction(ec); |
270 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) | 292 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) |
271 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); | 293 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
272 | spin_unlock_irqrestore(&ec->curr_lock, tmp); | 294 | spin_unlock_irqrestore(&ec->curr_lock, tmp); |
@@ -283,10 +305,11 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
283 | /* check if we received SCI during transaction */ | 305 | /* check if we received SCI during transaction */ |
284 | ec_check_sci(ec, acpi_ec_read_status(ec)); | 306 | ec_check_sci(ec, acpi_ec_read_status(ec)); |
285 | /* it is safe to enable GPE outside of transaction */ | 307 | /* it is safe to enable GPE outside of transaction */ |
286 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 308 | acpi_enable_gpe(NULL, ec->gpe); |
287 | } else if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && | 309 | } else if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && |
288 | t->irq_count > ACPI_EC_STORM_THRESHOLD) { | 310 | t->irq_count > ACPI_EC_STORM_THRESHOLD) { |
289 | pr_debug(PREFIX "GPE storm detected\n"); | 311 | pr_info(PREFIX "GPE storm detected, " |
312 | "transactions will use polling mode\n"); | ||
290 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); | 313 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); |
291 | } | 314 | } |
292 | return ret; | 315 | return ret; |
@@ -558,17 +581,26 @@ static u32 acpi_ec_gpe_handler(void *data) | |||
558 | pr_debug(PREFIX "~~~> interrupt\n"); | 581 | pr_debug(PREFIX "~~~> interrupt\n"); |
559 | status = acpi_ec_read_status(ec); | 582 | status = acpi_ec_read_status(ec); |
560 | 583 | ||
561 | gpe_transaction(ec, status); | 584 | if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) { |
562 | if (ec_transaction_done(ec) && (status & ACPI_EC_FLAG_IBF) == 0) | 585 | gpe_transaction(ec, status); |
563 | wake_up(&ec->wait); | 586 | if (ec_transaction_done(ec) && |
587 | (status & ACPI_EC_FLAG_IBF) == 0) | ||
588 | wake_up(&ec->wait); | ||
589 | } | ||
564 | 590 | ||
565 | ec_check_sci(ec, status); | 591 | ec_check_sci(ec, status); |
566 | if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && | 592 | if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) && |
567 | !test_bit(EC_FLAGS_NO_GPE, &ec->flags)) { | 593 | !test_bit(EC_FLAGS_NO_GPE, &ec->flags)) { |
568 | /* this is non-query, must be confirmation */ | 594 | /* this is non-query, must be confirmation */ |
569 | if (printk_ratelimit()) | 595 | if (!test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { |
570 | pr_info(PREFIX "non-query interrupt received," | 596 | if (printk_ratelimit()) |
597 | pr_info(PREFIX "non-query interrupt received," | ||
598 | " switching to interrupt mode\n"); | ||
599 | } else { | ||
600 | /* hush, STORM switches the mode every transaction */ | ||
601 | pr_debug(PREFIX "non-query interrupt received," | ||
571 | " switching to interrupt mode\n"); | 602 | " switching to interrupt mode\n"); |
603 | } | ||
572 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 604 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
573 | } | 605 | } |
574 | return ACPI_INTERRUPT_HANDLED; | 606 | return ACPI_INTERRUPT_HANDLED; |
@@ -736,7 +768,7 @@ static acpi_status | |||
736 | ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | 768 | ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) |
737 | { | 769 | { |
738 | acpi_status status; | 770 | acpi_status status; |
739 | unsigned long long tmp; | 771 | unsigned long long tmp = 0; |
740 | 772 | ||
741 | struct acpi_ec *ec = context; | 773 | struct acpi_ec *ec = context; |
742 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 774 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
@@ -751,6 +783,7 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | |||
751 | return status; | 783 | return status; |
752 | ec->gpe = tmp; | 784 | ec->gpe = tmp; |
753 | /* Use the global lock for all EC transactions? */ | 785 | /* Use the global lock for all EC transactions? */ |
786 | tmp = 0; | ||
754 | acpi_evaluate_integer(handle, "_GLK", NULL, &tmp); | 787 | acpi_evaluate_integer(handle, "_GLK", NULL, &tmp); |
755 | ec->global_lock = tmp; | 788 | ec->global_lock = tmp; |
756 | ec->handle = handle; | 789 | ec->handle = handle; |
@@ -868,7 +901,7 @@ static int ec_install_handlers(struct acpi_ec *ec) | |||
868 | if (ACPI_FAILURE(status)) | 901 | if (ACPI_FAILURE(status)) |
869 | return -ENODEV; | 902 | return -ENODEV; |
870 | acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); | 903 | acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); |
871 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 904 | acpi_enable_gpe(NULL, ec->gpe); |
872 | status = acpi_install_address_space_handler(ec->handle, | 905 | status = acpi_install_address_space_handler(ec->handle, |
873 | ACPI_ADR_SPACE_EC, | 906 | ACPI_ADR_SPACE_EC, |
874 | &acpi_ec_space_handler, | 907 | &acpi_ec_space_handler, |
@@ -1007,7 +1040,7 @@ static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state) | |||
1007 | /* Stop using GPE */ | 1040 | /* Stop using GPE */ |
1008 | set_bit(EC_FLAGS_NO_GPE, &ec->flags); | 1041 | set_bit(EC_FLAGS_NO_GPE, &ec->flags); |
1009 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 1042 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
1010 | acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 1043 | acpi_disable_gpe(NULL, ec->gpe); |
1011 | return 0; | 1044 | return 0; |
1012 | } | 1045 | } |
1013 | 1046 | ||
@@ -1016,7 +1049,7 @@ static int acpi_ec_resume(struct acpi_device *device) | |||
1016 | struct acpi_ec *ec = acpi_driver_data(device); | 1049 | struct acpi_ec *ec = acpi_driver_data(device); |
1017 | /* Enable use of GPE back */ | 1050 | /* Enable use of GPE back */ |
1018 | clear_bit(EC_FLAGS_NO_GPE, &ec->flags); | 1051 | clear_bit(EC_FLAGS_NO_GPE, &ec->flags); |
1019 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | 1052 | acpi_enable_gpe(NULL, ec->gpe); |
1020 | return 0; | 1053 | return 0; |
1021 | } | 1054 | } |
1022 | 1055 | ||
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index c5e53aae86f7..f45c74fe745e 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c | |||
@@ -289,8 +289,6 @@ acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
289 | */ | 289 | */ |
290 | status = acpi_hw_low_disable_gpe(gpe_event_info); | 290 | status = acpi_hw_low_disable_gpe(gpe_event_info); |
291 | return_ACPI_STATUS(status); | 291 | return_ACPI_STATUS(status); |
292 | |||
293 | return_ACPI_STATUS(AE_OK); | ||
294 | } | 292 | } |
295 | 293 | ||
296 | /******************************************************************************* | 294 | /******************************************************************************* |
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index 73bfd6bf962f..41554f736b68 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c | |||
@@ -248,21 +248,15 @@ ACPI_EXPORT_SYMBOL(acpi_set_gpe_type) | |||
248 | * DESCRIPTION: Enable an ACPI event (general purpose) | 248 | * DESCRIPTION: Enable an ACPI event (general purpose) |
249 | * | 249 | * |
250 | ******************************************************************************/ | 250 | ******************************************************************************/ |
251 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | 251 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) |
252 | { | 252 | { |
253 | acpi_status status = AE_OK; | 253 | acpi_status status = AE_OK; |
254 | acpi_cpu_flags flags; | ||
254 | struct acpi_gpe_event_info *gpe_event_info; | 255 | struct acpi_gpe_event_info *gpe_event_info; |
255 | 256 | ||
256 | ACPI_FUNCTION_TRACE(acpi_enable_gpe); | 257 | ACPI_FUNCTION_TRACE(acpi_enable_gpe); |
257 | 258 | ||
258 | /* Use semaphore lock if not executing at interrupt level */ | 259 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
259 | |||
260 | if (flags & ACPI_NOT_ISR) { | ||
261 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
262 | if (ACPI_FAILURE(status)) { | ||
263 | return_ACPI_STATUS(status); | ||
264 | } | ||
265 | } | ||
266 | 260 | ||
267 | /* Ensure that we have a valid GPE number */ | 261 | /* Ensure that we have a valid GPE number */ |
268 | 262 | ||
@@ -277,9 +271,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | |||
277 | status = acpi_ev_enable_gpe(gpe_event_info, TRUE); | 271 | status = acpi_ev_enable_gpe(gpe_event_info, TRUE); |
278 | 272 | ||
279 | unlock_and_exit: | 273 | unlock_and_exit: |
280 | if (flags & ACPI_NOT_ISR) { | 274 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
281 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
282 | } | ||
283 | return_ACPI_STATUS(status); | 275 | return_ACPI_STATUS(status); |
284 | } | 276 | } |
285 | 277 | ||
@@ -299,22 +291,15 @@ ACPI_EXPORT_SYMBOL(acpi_enable_gpe) | |||
299 | * DESCRIPTION: Disable an ACPI event (general purpose) | 291 | * DESCRIPTION: Disable an ACPI event (general purpose) |
300 | * | 292 | * |
301 | ******************************************************************************/ | 293 | ******************************************************************************/ |
302 | acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | 294 | acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number) |
303 | { | 295 | { |
304 | acpi_status status = AE_OK; | 296 | acpi_status status = AE_OK; |
297 | acpi_cpu_flags flags; | ||
305 | struct acpi_gpe_event_info *gpe_event_info; | 298 | struct acpi_gpe_event_info *gpe_event_info; |
306 | 299 | ||
307 | ACPI_FUNCTION_TRACE(acpi_disable_gpe); | 300 | ACPI_FUNCTION_TRACE(acpi_disable_gpe); |
308 | 301 | ||
309 | /* Use semaphore lock if not executing at interrupt level */ | 302 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
310 | |||
311 | if (flags & ACPI_NOT_ISR) { | ||
312 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
313 | if (ACPI_FAILURE(status)) { | ||
314 | return_ACPI_STATUS(status); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | /* Ensure that we have a valid GPE number */ | 303 | /* Ensure that we have a valid GPE number */ |
319 | 304 | ||
320 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 305 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); |
@@ -325,10 +310,8 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) | |||
325 | 310 | ||
326 | status = acpi_ev_disable_gpe(gpe_event_info); | 311 | status = acpi_ev_disable_gpe(gpe_event_info); |
327 | 312 | ||
328 | unlock_and_exit: | 313 | unlock_and_exit: |
329 | if (flags & ACPI_NOT_ISR) { | 314 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
330 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
331 | } | ||
332 | return_ACPI_STATUS(status); | 315 | return_ACPI_STATUS(status); |
333 | } | 316 | } |
334 | 317 | ||
@@ -521,6 +504,9 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) | |||
521 | if (value) | 504 | if (value) |
522 | *event_status |= ACPI_EVENT_FLAG_SET; | 505 | *event_status |= ACPI_EVENT_FLAG_SET; |
523 | 506 | ||
507 | if (acpi_gbl_fixed_event_handlers[event].handler) | ||
508 | *event_status |= ACPI_EVENT_FLAG_HANDLE; | ||
509 | |||
524 | return_ACPI_STATUS(status); | 510 | return_ACPI_STATUS(status); |
525 | } | 511 | } |
526 | 512 | ||
@@ -571,6 +557,9 @@ acpi_get_gpe_status(acpi_handle gpe_device, | |||
571 | 557 | ||
572 | status = acpi_hw_get_gpe_status(gpe_event_info, event_status); | 558 | status = acpi_hw_get_gpe_status(gpe_event_info, event_status); |
573 | 559 | ||
560 | if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) | ||
561 | *event_status |= ACPI_EVENT_FLAG_HANDLE; | ||
562 | |||
574 | unlock_and_exit: | 563 | unlock_and_exit: |
575 | if (flags & ACPI_NOT_ISR) { | 564 | if (flags & ACPI_NOT_ISR) { |
576 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 565 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 60d54d1f6b19..eaaee1660bdf 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <acpi/acpi_bus.h> | 34 | #include <acpi/acpi_bus.h> |
35 | #include <acpi/acpi_drivers.h> | 35 | #include <acpi/acpi_drivers.h> |
36 | 36 | ||
37 | #define ACPI_FAN_COMPONENT 0x00200000 | ||
38 | #define ACPI_FAN_CLASS "fan" | 37 | #define ACPI_FAN_CLASS "fan" |
39 | #define ACPI_FAN_FILE_STATE "state" | 38 | #define ACPI_FAN_FILE_STATE "state" |
40 | 39 | ||
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 24649ada08df..adec3d15810a 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -140,6 +140,46 @@ struct device *acpi_get_physical_device(acpi_handle handle) | |||
140 | 140 | ||
141 | EXPORT_SYMBOL(acpi_get_physical_device); | 141 | EXPORT_SYMBOL(acpi_get_physical_device); |
142 | 142 | ||
143 | /* ToDo: When a PCI bridge is found, return the PCI device behind the bridge | ||
144 | * This should work in general, but did not on a Lenovo T61 for the | ||
145 | * graphics card. But this must be fixed when the PCI device is | ||
146 | * bound and the kernel device struct is attached to the acpi device | ||
147 | * Note: A success call will increase reference count by one | ||
148 | * Do call put_device(dev) on the returned device then | ||
149 | */ | ||
150 | struct device *acpi_get_physical_pci_device(acpi_handle handle) | ||
151 | { | ||
152 | struct device *dev; | ||
153 | long long device_id; | ||
154 | acpi_status status; | ||
155 | |||
156 | status = | ||
157 | acpi_evaluate_integer(handle, "_ADR", NULL, &device_id); | ||
158 | |||
159 | if (ACPI_FAILURE(status)) | ||
160 | return NULL; | ||
161 | |||
162 | /* We need to attempt to determine whether the _ADR refers to a | ||
163 | PCI device or not. There's no terribly good way to do this, | ||
164 | so the best we can hope for is to assume that there'll never | ||
165 | be a device in the host bridge */ | ||
166 | if (device_id >= 0x10000) { | ||
167 | /* It looks like a PCI device. Does it exist? */ | ||
168 | dev = acpi_get_physical_device(handle); | ||
169 | } else { | ||
170 | /* It doesn't look like a PCI device. Does its parent | ||
171 | exist? */ | ||
172 | acpi_handle phandle; | ||
173 | if (acpi_get_parent(handle, &phandle)) | ||
174 | return NULL; | ||
175 | dev = acpi_get_physical_device(phandle); | ||
176 | } | ||
177 | if (!dev) | ||
178 | return NULL; | ||
179 | return dev; | ||
180 | } | ||
181 | EXPORT_SYMBOL(acpi_get_physical_pci_device); | ||
182 | |||
143 | static int acpi_bind_one(struct device *dev, acpi_handle handle) | 183 | static int acpi_bind_one(struct device *dev, acpi_handle handle) |
144 | { | 184 | { |
145 | struct acpi_device *acpi_dev; | 185 | struct acpi_device *acpi_dev; |
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index fcfdef7b4fdd..e52ad91ce2dc 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -531,7 +531,7 @@ int __init acpi_irq_penalty_init(void) | |||
531 | return 0; | 531 | return 0; |
532 | } | 532 | } |
533 | 533 | ||
534 | static int acpi_irq_balance; /* 0: static, 1: balance */ | 534 | static int acpi_irq_balance = -1; /* 0: static, 1: balance */ |
535 | 535 | ||
536 | static int acpi_pci_link_allocate(struct acpi_pci_link *link) | 536 | static int acpi_pci_link_allocate(struct acpi_pci_link *link) |
537 | { | 537 | { |
@@ -950,10 +950,17 @@ device_initcall(irqrouter_init_sysfs); | |||
950 | 950 | ||
951 | static int __init acpi_pci_link_init(void) | 951 | static int __init acpi_pci_link_init(void) |
952 | { | 952 | { |
953 | |||
954 | if (acpi_noirq) | 953 | if (acpi_noirq) |
955 | return 0; | 954 | return 0; |
956 | 955 | ||
956 | if (acpi_irq_balance == -1) { | ||
957 | /* no command line switch: enable balancing in IOAPIC mode */ | ||
958 | if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) | ||
959 | acpi_irq_balance = 1; | ||
960 | else | ||
961 | acpi_irq_balance = 0; | ||
962 | } | ||
963 | |||
957 | acpi_link.count = 0; | 964 | acpi_link.count = 0; |
958 | INIT_LIST_HEAD(&acpi_link.entries); | 965 | INIT_LIST_HEAD(&acpi_link.entries); |
959 | 966 | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 1b8f67d21d53..642554b1b60c 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -376,15 +376,9 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type) | |||
376 | 376 | ||
377 | static int __init acpi_pci_root_init(void) | 377 | static int __init acpi_pci_root_init(void) |
378 | { | 378 | { |
379 | |||
380 | if (acpi_pci_disabled) | 379 | if (acpi_pci_disabled) |
381 | return 0; | 380 | return 0; |
382 | 381 | ||
383 | /* DEBUG: | ||
384 | acpi_dbg_layer = ACPI_PCI_COMPONENT; | ||
385 | acpi_dbg_level = 0xFFFFFFFF; | ||
386 | */ | ||
387 | |||
388 | if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) | 382 | if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) |
389 | return -ENODEV; | 383 | return -ENODEV; |
390 | 384 | ||
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index a1718e56103b..bb7d50dd2818 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -44,9 +44,8 @@ | |||
44 | #include <acpi/acpi_bus.h> | 44 | #include <acpi/acpi_bus.h> |
45 | #include <acpi/acpi_drivers.h> | 45 | #include <acpi/acpi_drivers.h> |
46 | 46 | ||
47 | #define _COMPONENT ACPI_POWER_COMPONENT | 47 | #define _COMPONENT ACPI_POWER_COMPONENT |
48 | ACPI_MODULE_NAME("power"); | 48 | ACPI_MODULE_NAME("power"); |
49 | #define ACPI_POWER_COMPONENT 0x00800000 | ||
50 | #define ACPI_POWER_CLASS "power_resource" | 49 | #define ACPI_POWER_CLASS "power_resource" |
51 | #define ACPI_POWER_DEVICE_NAME "Power Resource" | 50 | #define ACPI_POWER_DEVICE_NAME "Power Resource" |
52 | #define ACPI_POWER_FILE_INFO "info" | 51 | #define ACPI_POWER_FILE_INFO "info" |
@@ -153,7 +152,8 @@ static int acpi_power_get_state(acpi_handle handle, int *state) | |||
153 | ACPI_POWER_RESOURCE_STATE_OFF; | 152 | ACPI_POWER_RESOURCE_STATE_OFF; |
154 | 153 | ||
155 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", | 154 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", |
156 | acpi_ut_get_node_name(handle), state ? "on" : "off")); | 155 | acpi_ut_get_node_name(handle), |
156 | *state ? "on" : "off")); | ||
157 | 157 | ||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
@@ -516,11 +516,6 @@ int acpi_power_transition(struct acpi_device *device, int state) | |||
516 | cl = &device->power.states[device->power.state].resources; | 516 | cl = &device->power.states[device->power.state].resources; |
517 | tl = &device->power.states[state].resources; | 517 | tl = &device->power.states[state].resources; |
518 | 518 | ||
519 | if (!cl->count && !tl->count) { | ||
520 | result = -ENODEV; | ||
521 | goto end; | ||
522 | } | ||
523 | |||
524 | /* TBD: Resources must be ordered. */ | 519 | /* TBD: Resources must be ordered. */ |
525 | 520 | ||
526 | /* | 521 | /* |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 24a362f8034c..34948362f41d 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <acpi/acpi_drivers.h> | 59 | #include <acpi/acpi_drivers.h> |
60 | #include <acpi/processor.h> | 60 | #include <acpi/processor.h> |
61 | 61 | ||
62 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
63 | #define ACPI_PROCESSOR_CLASS "processor" | 62 | #define ACPI_PROCESSOR_CLASS "processor" |
64 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" | 63 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" |
65 | #define ACPI_PROCESSOR_FILE_INFO "info" | 64 | #define ACPI_PROCESSOR_FILE_INFO "info" |
@@ -89,6 +88,7 @@ static int acpi_processor_handle_eject(struct acpi_processor *pr); | |||
89 | 88 | ||
90 | 89 | ||
91 | static const struct acpi_device_id processor_device_ids[] = { | 90 | static const struct acpi_device_id processor_device_ids[] = { |
91 | {ACPI_PROCESSOR_OBJECT_HID, 0}, | ||
92 | {ACPI_PROCESSOR_HID, 0}, | 92 | {ACPI_PROCESSOR_HID, 0}, |
93 | {"", 0}, | 93 | {"", 0}, |
94 | }; | 94 | }; |
@@ -409,7 +409,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device) | |||
409 | /* Use the acpiid in MADT to map cpus in case of SMP */ | 409 | /* Use the acpiid in MADT to map cpus in case of SMP */ |
410 | 410 | ||
411 | #ifndef CONFIG_SMP | 411 | #ifndef CONFIG_SMP |
412 | static int get_cpu_id(acpi_handle handle, u32 acpi_id) {return -1;} | 412 | static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) { return -1; } |
413 | #else | 413 | #else |
414 | 414 | ||
415 | static struct acpi_table_madt *madt; | 415 | static struct acpi_table_madt *madt; |
@@ -428,27 +428,35 @@ static int map_lapic_id(struct acpi_subtable_header *entry, | |||
428 | } | 428 | } |
429 | 429 | ||
430 | static int map_lsapic_id(struct acpi_subtable_header *entry, | 430 | static int map_lsapic_id(struct acpi_subtable_header *entry, |
431 | u32 acpi_id, int *apic_id) | 431 | int device_declaration, u32 acpi_id, int *apic_id) |
432 | { | 432 | { |
433 | struct acpi_madt_local_sapic *lsapic = | 433 | struct acpi_madt_local_sapic *lsapic = |
434 | (struct acpi_madt_local_sapic *)entry; | 434 | (struct acpi_madt_local_sapic *)entry; |
435 | u32 tmp = (lsapic->id << 8) | lsapic->eid; | ||
436 | |||
435 | /* Only check enabled APICs*/ | 437 | /* Only check enabled APICs*/ |
436 | if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { | 438 | if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) |
437 | /* First check against id */ | 439 | return 0; |
438 | if (lsapic->processor_id == acpi_id) { | 440 | |
439 | *apic_id = (lsapic->id << 8) | lsapic->eid; | 441 | /* Device statement declaration type */ |
440 | return 1; | 442 | if (device_declaration) { |
441 | /* Check against optional uid */ | 443 | if (entry->length < 16) |
442 | } else if (entry->length >= 16 && | 444 | printk(KERN_ERR PREFIX |
443 | lsapic->uid == acpi_id) { | 445 | "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n", |
444 | *apic_id = lsapic->uid; | 446 | tmp); |
445 | return 1; | 447 | else if (lsapic->uid == acpi_id) |
446 | } | 448 | goto found; |
447 | } | 449 | /* Processor statement declaration type */ |
450 | } else if (lsapic->processor_id == acpi_id) | ||
451 | goto found; | ||
452 | |||
448 | return 0; | 453 | return 0; |
454 | found: | ||
455 | *apic_id = tmp; | ||
456 | return 1; | ||
449 | } | 457 | } |
450 | 458 | ||
451 | static int map_madt_entry(u32 acpi_id) | 459 | static int map_madt_entry(int type, u32 acpi_id) |
452 | { | 460 | { |
453 | unsigned long madt_end, entry; | 461 | unsigned long madt_end, entry; |
454 | int apic_id = -1; | 462 | int apic_id = -1; |
@@ -469,7 +477,7 @@ static int map_madt_entry(u32 acpi_id) | |||
469 | if (map_lapic_id(header, acpi_id, &apic_id)) | 477 | if (map_lapic_id(header, acpi_id, &apic_id)) |
470 | break; | 478 | break; |
471 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { | 479 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { |
472 | if (map_lsapic_id(header, acpi_id, &apic_id)) | 480 | if (map_lsapic_id(header, type, acpi_id, &apic_id)) |
473 | break; | 481 | break; |
474 | } | 482 | } |
475 | entry += header->length; | 483 | entry += header->length; |
@@ -477,7 +485,7 @@ static int map_madt_entry(u32 acpi_id) | |||
477 | return apic_id; | 485 | return apic_id; |
478 | } | 486 | } |
479 | 487 | ||
480 | static int map_mat_entry(acpi_handle handle, u32 acpi_id) | 488 | static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) |
481 | { | 489 | { |
482 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 490 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
483 | union acpi_object *obj; | 491 | union acpi_object *obj; |
@@ -500,7 +508,7 @@ static int map_mat_entry(acpi_handle handle, u32 acpi_id) | |||
500 | if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { | 508 | if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { |
501 | map_lapic_id(header, acpi_id, &apic_id); | 509 | map_lapic_id(header, acpi_id, &apic_id); |
502 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { | 510 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { |
503 | map_lsapic_id(header, acpi_id, &apic_id); | 511 | map_lsapic_id(header, type, acpi_id, &apic_id); |
504 | } | 512 | } |
505 | 513 | ||
506 | exit: | 514 | exit: |
@@ -509,14 +517,14 @@ exit: | |||
509 | return apic_id; | 517 | return apic_id; |
510 | } | 518 | } |
511 | 519 | ||
512 | static int get_cpu_id(acpi_handle handle, u32 acpi_id) | 520 | static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) |
513 | { | 521 | { |
514 | int i; | 522 | int i; |
515 | int apic_id = -1; | 523 | int apic_id = -1; |
516 | 524 | ||
517 | apic_id = map_mat_entry(handle, acpi_id); | 525 | apic_id = map_mat_entry(handle, type, acpi_id); |
518 | if (apic_id == -1) | 526 | if (apic_id == -1) |
519 | apic_id = map_madt_entry(acpi_id); | 527 | apic_id = map_madt_entry(type, acpi_id); |
520 | if (apic_id == -1) | 528 | if (apic_id == -1) |
521 | return apic_id; | 529 | return apic_id; |
522 | 530 | ||
@@ -532,15 +540,16 @@ static int get_cpu_id(acpi_handle handle, u32 acpi_id) | |||
532 | Driver Interface | 540 | Driver Interface |
533 | -------------------------------------------------------------------------- */ | 541 | -------------------------------------------------------------------------- */ |
534 | 542 | ||
535 | static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) | 543 | static int acpi_processor_get_info(struct acpi_device *device) |
536 | { | 544 | { |
537 | acpi_status status = 0; | 545 | acpi_status status = 0; |
538 | union acpi_object object = { 0 }; | 546 | union acpi_object object = { 0 }; |
539 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | 547 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; |
540 | int cpu_index; | 548 | struct acpi_processor *pr; |
549 | int cpu_index, device_declaration = 0; | ||
541 | static int cpu0_initialized; | 550 | static int cpu0_initialized; |
542 | 551 | ||
543 | 552 | pr = acpi_driver_data(device); | |
544 | if (!pr) | 553 | if (!pr) |
545 | return -EINVAL; | 554 | return -EINVAL; |
546 | 555 | ||
@@ -561,22 +570,23 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) | |||
561 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 570 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
562 | "No bus mastering arbitration control\n")); | 571 | "No bus mastering arbitration control\n")); |
563 | 572 | ||
564 | /* Check if it is a Device with HID and UID */ | 573 | if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_HID)) { |
565 | if (has_uid) { | 574 | /* |
575 | * Declared with "Device" statement; match _UID. | ||
576 | * Note that we don't handle string _UIDs yet. | ||
577 | */ | ||
566 | unsigned long long value; | 578 | unsigned long long value; |
567 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, | 579 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, |
568 | NULL, &value); | 580 | NULL, &value); |
569 | if (ACPI_FAILURE(status)) { | 581 | if (ACPI_FAILURE(status)) { |
570 | printk(KERN_ERR PREFIX "Evaluating processor _UID\n"); | 582 | printk(KERN_ERR PREFIX |
583 | "Evaluating processor _UID [%#x]\n", status); | ||
571 | return -ENODEV; | 584 | return -ENODEV; |
572 | } | 585 | } |
586 | device_declaration = 1; | ||
573 | pr->acpi_id = value; | 587 | pr->acpi_id = value; |
574 | } else { | 588 | } else { |
575 | /* | 589 | /* Declared with "Processor" statement; match ProcessorID */ |
576 | * Evalute the processor object. Note that it is common on SMP to | ||
577 | * have the first (boot) processor with a valid PBLK address while | ||
578 | * all others have a NULL address. | ||
579 | */ | ||
580 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); | 590 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); |
581 | if (ACPI_FAILURE(status)) { | 591 | if (ACPI_FAILURE(status)) { |
582 | printk(KERN_ERR PREFIX "Evaluating processor object\n"); | 592 | printk(KERN_ERR PREFIX "Evaluating processor object\n"); |
@@ -584,12 +594,13 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) | |||
584 | } | 594 | } |
585 | 595 | ||
586 | /* | 596 | /* |
587 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. | 597 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. |
588 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c | 598 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in |
589 | */ | 599 | * arch/xxx/acpi.c |
600 | */ | ||
590 | pr->acpi_id = object.processor.proc_id; | 601 | pr->acpi_id = object.processor.proc_id; |
591 | } | 602 | } |
592 | cpu_index = get_cpu_id(pr->handle, pr->acpi_id); | 603 | cpu_index = get_cpu_id(pr->handle, device_declaration, pr->acpi_id); |
593 | 604 | ||
594 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | 605 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ |
595 | if (!cpu0_initialized && (cpu_index == -1) && | 606 | if (!cpu0_initialized && (cpu_index == -1) && |
@@ -661,7 +672,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) | |||
661 | 672 | ||
662 | pr = acpi_driver_data(device); | 673 | pr = acpi_driver_data(device); |
663 | 674 | ||
664 | result = acpi_processor_get_info(pr, device->flags.unique_id); | 675 | result = acpi_processor_get_info(device); |
665 | if (result) { | 676 | if (result) { |
666 | /* Processor is physically not present */ | 677 | /* Processor is physically not present */ |
667 | return 0; | 678 | return 0; |
@@ -761,20 +772,20 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) | |||
761 | acpi_bus_generate_proc_event(device, event, | 772 | acpi_bus_generate_proc_event(device, event, |
762 | pr->performance_platform_limit); | 773 | pr->performance_platform_limit); |
763 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 774 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
764 | device->dev.bus_id, event, | 775 | dev_name(&device->dev), event, |
765 | pr->performance_platform_limit); | 776 | pr->performance_platform_limit); |
766 | break; | 777 | break; |
767 | case ACPI_PROCESSOR_NOTIFY_POWER: | 778 | case ACPI_PROCESSOR_NOTIFY_POWER: |
768 | acpi_processor_cst_has_changed(pr); | 779 | acpi_processor_cst_has_changed(pr); |
769 | acpi_bus_generate_proc_event(device, event, 0); | 780 | acpi_bus_generate_proc_event(device, event, 0); |
770 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 781 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
771 | device->dev.bus_id, event, 0); | 782 | dev_name(&device->dev), event, 0); |
772 | break; | 783 | break; |
773 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: | 784 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: |
774 | acpi_processor_tstate_has_changed(pr); | 785 | acpi_processor_tstate_has_changed(pr); |
775 | acpi_bus_generate_proc_event(device, event, 0); | 786 | acpi_bus_generate_proc_event(device, event, 0); |
776 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 787 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
777 | device->dev.bus_id, event, 0); | 788 | dev_name(&device->dev), event, 0); |
778 | default: | 789 | default: |
779 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 790 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
780 | "Unsupported event [0x%x]\n", event)); | 791 | "Unsupported event [0x%x]\n", event)); |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 81b40ed5379e..5f8d746a9b81 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <acpi/processor.h> | 59 | #include <acpi/processor.h> |
60 | #include <asm/processor.h> | 60 | #include <asm/processor.h> |
61 | 61 | ||
62 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
63 | #define ACPI_PROCESSOR_CLASS "processor" | 62 | #define ACPI_PROCESSOR_CLASS "processor" |
64 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 63 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
65 | ACPI_MODULE_NAME("processor_idle"); | 64 | ACPI_MODULE_NAME("processor_idle"); |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index dbcf260ea93f..0d7b772bef50 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -44,9 +44,9 @@ | |||
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include <acpi/acpi_bus.h> | 46 | #include <acpi/acpi_bus.h> |
47 | #include <acpi/acpi_drivers.h> | ||
47 | #include <acpi/processor.h> | 48 | #include <acpi/processor.h> |
48 | 49 | ||
49 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
50 | #define ACPI_PROCESSOR_CLASS "processor" | 50 | #define ACPI_PROCESSOR_CLASS "processor" |
51 | #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" | 51 | #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" |
52 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 52 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index ef34b18f95ca..b1eb376fae45 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <acpi/processor.h> | 40 | #include <acpi/processor.h> |
41 | #include <acpi/acpi_drivers.h> | 41 | #include <acpi/acpi_drivers.h> |
42 | 42 | ||
43 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
44 | #define ACPI_PROCESSOR_CLASS "processor" | 43 | #define ACPI_PROCESSOR_CLASS "processor" |
45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 44 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
46 | ACPI_MODULE_NAME("processor_thermal"); | 45 | ACPI_MODULE_NAME("processor_thermal"); |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 3da2df93d924..a0c38c94a8a0 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -38,9 +38,9 @@ | |||
38 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
39 | 39 | ||
40 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
41 | #include <acpi/acpi_drivers.h> | ||
41 | #include <acpi/processor.h> | 42 | #include <acpi/processor.h> |
42 | 43 | ||
43 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | ||
44 | #define ACPI_PROCESSOR_CLASS "processor" | 44 | #define ACPI_PROCESSOR_CLASS "processor" |
45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
46 | ACPI_MODULE_NAME("processor_throttling"); | 46 | ACPI_MODULE_NAME("processor_throttling"); |
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c index 755baf2ca70a..a6b662c00b67 100644 --- a/drivers/acpi/reboot.c +++ b/drivers/acpi/reboot.c | |||
@@ -15,28 +15,9 @@ void acpi_reboot(void) | |||
15 | 15 | ||
16 | rr = &acpi_gbl_FADT.reset_register; | 16 | rr = &acpi_gbl_FADT.reset_register; |
17 | 17 | ||
18 | /* | 18 | /* Is the reset register supported? */ |
19 | * Is the ACPI reset register supported? | 19 | if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || |
20 | * | 20 | rr->bit_width != 8 || rr->bit_offset != 0) |
21 | * According to ACPI 3.0, FADT.flags.RESET_REG_SUP indicates | ||
22 | * whether the ACPI reset mechanism is supported. | ||
23 | * | ||
24 | * However, some boxes have this bit clear, yet a valid | ||
25 | * ACPI_RESET_REG & RESET_VALUE, and ACPI reboot is the only | ||
26 | * mechanism that works for them after S3. | ||
27 | * | ||
28 | * This suggests that other operating systems may not be checking | ||
29 | * the RESET_REG_SUP bit, and are using other means to decide | ||
30 | * whether to use the ACPI reboot mechanism or not. | ||
31 | * | ||
32 | * So when acpi reboot is requested, | ||
33 | * only the reset_register is checked. If the following | ||
34 | * conditions are met, it indicates that the reset register is supported. | ||
35 | * a. reset_register is not zero | ||
36 | * b. the access width is eight | ||
37 | * c. the bit_offset is zero | ||
38 | */ | ||
39 | if (!(rr->address) || rr->bit_width != 8 || rr->bit_offset != 0) | ||
40 | return; | 21 | return; |
41 | 22 | ||
42 | reset_value = acpi_gbl_FADT.reset_value; | 23 | reset_value = acpi_gbl_FADT.reset_value; |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a9dda8e0f9f9..bd5253ee5c85 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -109,8 +109,7 @@ static int acpi_bus_hot_remove_device(void *context) | |||
109 | return 0; | 109 | return 0; |
110 | 110 | ||
111 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 111 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
112 | "Hot-removing device %s...\n", device->dev.bus_id)); | 112 | "Hot-removing device %s...\n", dev_name(&device->dev))); |
113 | |||
114 | 113 | ||
115 | if (acpi_bus_trim(device, 1)) { | 114 | if (acpi_bus_trim(device, 1)) { |
116 | printk(KERN_ERR PREFIX | 115 | printk(KERN_ERR PREFIX |
@@ -460,7 +459,7 @@ static int acpi_device_register(struct acpi_device *device, | |||
460 | acpi_device_bus_id->instance_no = 0; | 459 | acpi_device_bus_id->instance_no = 0; |
461 | list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); | 460 | list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); |
462 | } | 461 | } |
463 | sprintf(device->dev.bus_id, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); | 462 | dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); |
464 | 463 | ||
465 | if (device->parent) { | 464 | if (device->parent) { |
466 | list_add_tail(&device->node, &device->parent->children); | 465 | list_add_tail(&device->node, &device->parent->children); |
@@ -484,7 +483,8 @@ static int acpi_device_register(struct acpi_device *device, | |||
484 | 483 | ||
485 | result = acpi_device_setup_files(device); | 484 | result = acpi_device_setup_files(device); |
486 | if(result) | 485 | if(result) |
487 | printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", device->dev.bus_id); | 486 | printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", |
487 | dev_name(&device->dev)); | ||
488 | 488 | ||
489 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; | 489 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; |
490 | return 0; | 490 | return 0; |
@@ -919,36 +919,6 @@ static void acpi_device_get_busid(struct acpi_device *device, | |||
919 | } | 919 | } |
920 | } | 920 | } |
921 | 921 | ||
922 | static int | ||
923 | acpi_video_bus_match(struct acpi_device *device) | ||
924 | { | ||
925 | acpi_handle h_dummy; | ||
926 | |||
927 | if (!device) | ||
928 | return -EINVAL; | ||
929 | |||
930 | /* Since there is no HID, CID for ACPI Video drivers, we have | ||
931 | * to check well known required nodes for each feature we support. | ||
932 | */ | ||
933 | |||
934 | /* Does this device able to support video switching ? */ | ||
935 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) && | ||
936 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy))) | ||
937 | return 0; | ||
938 | |||
939 | /* Does this device able to retrieve a video ROM ? */ | ||
940 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy))) | ||
941 | return 0; | ||
942 | |||
943 | /* Does this device able to configure which video head to be POSTed ? */ | ||
944 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) && | ||
945 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) && | ||
946 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy))) | ||
947 | return 0; | ||
948 | |||
949 | return -ENODEV; | ||
950 | } | ||
951 | |||
952 | /* | 922 | /* |
953 | * acpi_bay_match - see if a device is an ejectable driver bay | 923 | * acpi_bay_match - see if a device is an ejectable driver bay |
954 | * | 924 | * |
@@ -1031,7 +1001,7 @@ static void acpi_device_set_id(struct acpi_device *device, | |||
1031 | will get autoloaded and the device might still match | 1001 | will get autoloaded and the device might still match |
1032 | against another driver. | 1002 | against another driver. |
1033 | */ | 1003 | */ |
1034 | if (ACPI_SUCCESS(acpi_video_bus_match(device))) | 1004 | if (acpi_is_video_device(device)) |
1035 | cid_add = ACPI_VIDEO_HID; | 1005 | cid_add = ACPI_VIDEO_HID; |
1036 | else if (ACPI_SUCCESS(acpi_bay_match(device))) | 1006 | else if (ACPI_SUCCESS(acpi_bay_match(device))) |
1037 | cid_add = ACPI_BAY_HID; | 1007 | cid_add = ACPI_BAY_HID; |
@@ -1043,7 +1013,7 @@ static void acpi_device_set_id(struct acpi_device *device, | |||
1043 | hid = ACPI_POWER_HID; | 1013 | hid = ACPI_POWER_HID; |
1044 | break; | 1014 | break; |
1045 | case ACPI_BUS_TYPE_PROCESSOR: | 1015 | case ACPI_BUS_TYPE_PROCESSOR: |
1046 | hid = ACPI_PROCESSOR_HID; | 1016 | hid = ACPI_PROCESSOR_OBJECT_HID; |
1047 | break; | 1017 | break; |
1048 | case ACPI_BUS_TYPE_SYSTEM: | 1018 | case ACPI_BUS_TYPE_SYSTEM: |
1049 | hid = ACPI_SYSTEM_HID; | 1019 | hid = ACPI_SYSTEM_HID; |
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 631ee2ee2ca0..4dbc2271acf5 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -367,7 +367,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) | |||
367 | if (ldev) | 367 | if (ldev) |
368 | seq_printf(seq, "%s:%s", | 368 | seq_printf(seq, "%s:%s", |
369 | ldev->bus ? ldev->bus->name : "no-bus", | 369 | ldev->bus ? ldev->bus->name : "no-bus", |
370 | ldev->bus_id); | 370 | dev_name(ldev)); |
371 | seq_printf(seq, "\n"); | 371 | seq_printf(seq, "\n"); |
372 | put_device(ldev); | 372 | put_device(ldev); |
373 | 373 | ||
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c index 38655eb132dc..dea4c23df764 100644 --- a/drivers/acpi/sleep/wakeup.c +++ b/drivers/acpi/sleep/wakeup.c | |||
@@ -88,7 +88,7 @@ void acpi_enable_wakeup_device(u8 sleep_state) | |||
88 | spin_unlock(&acpi_device_lock); | 88 | spin_unlock(&acpi_device_lock); |
89 | if (!dev->wakeup.flags.run_wake) | 89 | if (!dev->wakeup.flags.run_wake) |
90 | acpi_enable_gpe(dev->wakeup.gpe_device, | 90 | acpi_enable_gpe(dev->wakeup.gpe_device, |
91 | dev->wakeup.gpe_number, ACPI_ISR); | 91 | dev->wakeup.gpe_number); |
92 | spin_lock(&acpi_device_lock); | 92 | spin_lock(&acpi_device_lock); |
93 | } | 93 | } |
94 | spin_unlock(&acpi_device_lock); | 94 | spin_unlock(&acpi_device_lock); |
@@ -122,7 +122,7 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
122 | ACPI_GPE_TYPE_WAKE_RUN); | 122 | ACPI_GPE_TYPE_WAKE_RUN); |
123 | /* Re-enable it, since set_gpe_type will disable it */ | 123 | /* Re-enable it, since set_gpe_type will disable it */ |
124 | acpi_enable_gpe(dev->wakeup.gpe_device, | 124 | acpi_enable_gpe(dev->wakeup.gpe_device, |
125 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 125 | dev->wakeup.gpe_number); |
126 | spin_lock(&acpi_device_lock); | 126 | spin_lock(&acpi_device_lock); |
127 | } | 127 | } |
128 | continue; | 128 | continue; |
@@ -133,7 +133,7 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
133 | /* Never disable run-wake GPE */ | 133 | /* Never disable run-wake GPE */ |
134 | if (!dev->wakeup.flags.run_wake) { | 134 | if (!dev->wakeup.flags.run_wake) { |
135 | acpi_disable_gpe(dev->wakeup.gpe_device, | 135 | acpi_disable_gpe(dev->wakeup.gpe_device, |
136 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 136 | dev->wakeup.gpe_number); |
137 | acpi_clear_gpe(dev->wakeup.gpe_device, | 137 | acpi_clear_gpe(dev->wakeup.gpe_device, |
138 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 138 | dev->wakeup.gpe_number, ACPI_NOT_ISR); |
139 | } | 139 | } |
@@ -162,7 +162,7 @@ static int __init acpi_wakeup_device_init(void) | |||
162 | dev->wakeup.gpe_number, | 162 | dev->wakeup.gpe_number, |
163 | ACPI_GPE_TYPE_WAKE_RUN); | 163 | ACPI_GPE_TYPE_WAKE_RUN); |
164 | acpi_enable_gpe(dev->wakeup.gpe_device, | 164 | acpi_enable_gpe(dev->wakeup.gpe_device, |
165 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 165 | dev->wakeup.gpe_number); |
166 | dev->wakeup.state.enabled = 1; | 166 | dev->wakeup.state.enabled = 1; |
167 | spin_lock(&acpi_device_lock); | 167 | spin_lock(&acpi_device_lock); |
168 | } | 168 | } |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 1d74171b7940..6e4107f82403 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -78,9 +78,15 @@ static ssize_t acpi_table_show(struct kobject *kobj, | |||
78 | container_of(bin_attr, struct acpi_table_attr, attr); | 78 | container_of(bin_attr, struct acpi_table_attr, attr); |
79 | struct acpi_table_header *table_header = NULL; | 79 | struct acpi_table_header *table_header = NULL; |
80 | acpi_status status; | 80 | acpi_status status; |
81 | char name[ACPI_NAME_SIZE]; | ||
82 | |||
83 | if (strncmp(table_attr->name, "NULL", 4)) | ||
84 | memcpy(name, table_attr->name, ACPI_NAME_SIZE); | ||
85 | else | ||
86 | memcpy(name, "\0\0\0\0", 4); | ||
81 | 87 | ||
82 | status = | 88 | status = |
83 | acpi_get_table(table_attr->name, table_attr->instance, | 89 | acpi_get_table(name, table_attr->instance, |
84 | &table_header); | 90 | &table_header); |
85 | if (ACPI_FAILURE(status)) | 91 | if (ACPI_FAILURE(status)) |
86 | return -ENODEV; | 92 | return -ENODEV; |
@@ -95,21 +101,24 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr, | |||
95 | struct acpi_table_header *header = NULL; | 101 | struct acpi_table_header *header = NULL; |
96 | struct acpi_table_attr *attr = NULL; | 102 | struct acpi_table_attr *attr = NULL; |
97 | 103 | ||
98 | memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE); | 104 | if (table_header->signature[0] != '\0') |
105 | memcpy(table_attr->name, table_header->signature, | ||
106 | ACPI_NAME_SIZE); | ||
107 | else | ||
108 | memcpy(table_attr->name, "NULL", 4); | ||
99 | 109 | ||
100 | list_for_each_entry(attr, &acpi_table_attr_list, node) { | 110 | list_for_each_entry(attr, &acpi_table_attr_list, node) { |
101 | if (!memcmp(table_header->signature, attr->name, | 111 | if (!memcmp(table_attr->name, attr->name, ACPI_NAME_SIZE)) |
102 | ACPI_NAME_SIZE)) | ||
103 | if (table_attr->instance < attr->instance) | 112 | if (table_attr->instance < attr->instance) |
104 | table_attr->instance = attr->instance; | 113 | table_attr->instance = attr->instance; |
105 | } | 114 | } |
106 | table_attr->instance++; | 115 | table_attr->instance++; |
107 | 116 | ||
108 | if (table_attr->instance > 1 || (table_attr->instance == 1 && | 117 | if (table_attr->instance > 1 || (table_attr->instance == 1 && |
109 | !acpi_get_table(table_header-> | 118 | !acpi_get_table |
110 | signature, 2, | 119 | (table_header->signature, 2, &header))) |
111 | &header))) | 120 | sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", |
112 | sprintf(table_attr->name + 4, "%d", table_attr->instance); | 121 | table_attr->instance); |
113 | 122 | ||
114 | table_attr->attr.size = 0; | 123 | table_attr->attr.size = 0; |
115 | table_attr->attr.read = acpi_table_show; | 124 | table_attr->attr.read = acpi_table_show; |
@@ -167,7 +176,6 @@ static int acpi_system_sysfs_init(void) | |||
167 | #define COUNT_ERROR 2 /* other */ | 176 | #define COUNT_ERROR 2 /* other */ |
168 | #define NUM_COUNTERS_EXTRA 3 | 177 | #define NUM_COUNTERS_EXTRA 3 |
169 | 178 | ||
170 | #define ACPI_EVENT_VALID 0x01 | ||
171 | struct event_counter { | 179 | struct event_counter { |
172 | u32 count; | 180 | u32 count; |
173 | u32 flags; | 181 | u32 flags; |
@@ -312,12 +320,6 @@ static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle) | |||
312 | } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS)) | 320 | } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS)) |
313 | result = acpi_get_event_status(index - num_gpes, status); | 321 | result = acpi_get_event_status(index - num_gpes, status); |
314 | 322 | ||
315 | /* | ||
316 | * sleep/power button GPE/Fixed Event is enabled after acpi_system_init, | ||
317 | * check the status at runtime and mark it as valid once it's enabled | ||
318 | */ | ||
319 | if (!result && (*status & ACPI_EVENT_FLAG_ENABLED)) | ||
320 | all_counters[index].flags |= ACPI_EVENT_VALID; | ||
321 | end: | 323 | end: |
322 | return result; | 324 | return result; |
323 | } | 325 | } |
@@ -346,12 +348,14 @@ static ssize_t counter_show(struct kobject *kobj, | |||
346 | if (result) | 348 | if (result) |
347 | goto end; | 349 | goto end; |
348 | 350 | ||
349 | if (!(all_counters[index].flags & ACPI_EVENT_VALID)) | 351 | if (!(status & ACPI_EVENT_FLAG_HANDLE)) |
350 | size += sprintf(buf + size, " invalid"); | 352 | size += sprintf(buf + size, " invalid"); |
351 | else if (status & ACPI_EVENT_FLAG_ENABLED) | 353 | else if (status & ACPI_EVENT_FLAG_ENABLED) |
352 | size += sprintf(buf + size, " enable"); | 354 | size += sprintf(buf + size, " enabled"); |
355 | else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED) | ||
356 | size += sprintf(buf + size, " wake_enabled"); | ||
353 | else | 357 | else |
354 | size += sprintf(buf + size, " disable"); | 358 | size += sprintf(buf + size, " disabled"); |
355 | 359 | ||
356 | end: | 360 | end: |
357 | size += sprintf(buf + size, "\n"); | 361 | size += sprintf(buf + size, "\n"); |
@@ -385,7 +389,7 @@ static ssize_t counter_set(struct kobject *kobj, | |||
385 | if (result) | 389 | if (result) |
386 | goto end; | 390 | goto end; |
387 | 391 | ||
388 | if (!(all_counters[index].flags & ACPI_EVENT_VALID)) { | 392 | if (!(status & ACPI_EVENT_FLAG_HANDLE)) { |
389 | printk(KERN_WARNING PREFIX | 393 | printk(KERN_WARNING PREFIX |
390 | "Can not change Invalid GPE/Fixed Event status\n"); | 394 | "Can not change Invalid GPE/Fixed Event status\n"); |
391 | return -EINVAL; | 395 | return -EINVAL; |
@@ -394,10 +398,10 @@ static ssize_t counter_set(struct kobject *kobj, | |||
394 | if (index < num_gpes) { | 398 | if (index < num_gpes) { |
395 | if (!strcmp(buf, "disable\n") && | 399 | if (!strcmp(buf, "disable\n") && |
396 | (status & ACPI_EVENT_FLAG_ENABLED)) | 400 | (status & ACPI_EVENT_FLAG_ENABLED)) |
397 | result = acpi_disable_gpe(handle, index, ACPI_NOT_ISR); | 401 | result = acpi_disable_gpe(handle, index); |
398 | else if (!strcmp(buf, "enable\n") && | 402 | else if (!strcmp(buf, "enable\n") && |
399 | !(status & ACPI_EVENT_FLAG_ENABLED)) | 403 | !(status & ACPI_EVENT_FLAG_ENABLED)) |
400 | result = acpi_enable_gpe(handle, index, ACPI_NOT_ISR); | 404 | result = acpi_enable_gpe(handle, index); |
401 | else if (!strcmp(buf, "clear\n") && | 405 | else if (!strcmp(buf, "clear\n") && |
402 | (status & ACPI_EVENT_FLAG_SET)) | 406 | (status & ACPI_EVENT_FLAG_SET)) |
403 | result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR); | 407 | result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR); |
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/tables/tbfadt.c index 2c7885e7ffba..2817158fb6a1 100644 --- a/drivers/acpi/tables/tbfadt.c +++ b/drivers/acpi/tables/tbfadt.c | |||
@@ -304,7 +304,7 @@ static void acpi_tb_convert_fadt(void) | |||
304 | * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at | 304 | * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at |
305 | * offset 45, 55, 95, and the word located at offset 109, 110. | 305 | * offset 45, 55, 95, and the word located at offset 109, 110. |
306 | */ | 306 | */ |
307 | if (acpi_gbl_FADT.header.revision < 3) { | 307 | if (acpi_gbl_FADT.header.revision < FADT2_REVISION_ID) { |
308 | acpi_gbl_FADT.preferred_profile = 0; | 308 | acpi_gbl_FADT.preferred_profile = 0; |
309 | acpi_gbl_FADT.pstate_control = 0; | 309 | acpi_gbl_FADT.pstate_control = 0; |
310 | acpi_gbl_FADT.cst_control = 0; | 310 | acpi_gbl_FADT.cst_control = 0; |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index ad6cae938f0b..073ff09218a9 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include <acpi/acpi_bus.h> | 47 | #include <acpi/acpi_bus.h> |
48 | #include <acpi/acpi_drivers.h> | 48 | #include <acpi/acpi_drivers.h> |
49 | 49 | ||
50 | #define ACPI_THERMAL_COMPONENT 0x04000000 | ||
51 | #define ACPI_THERMAL_CLASS "thermal_zone" | 50 | #define ACPI_THERMAL_CLASS "thermal_zone" |
52 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" | 51 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" |
53 | #define ACPI_THERMAL_FILE_STATE "state" | 52 | #define ACPI_THERMAL_FILE_STATE "state" |
@@ -576,7 +575,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) | |||
576 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, | 575 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, |
577 | tz->trips.critical.flags.enabled); | 576 | tz->trips.critical.flags.enabled); |
578 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, | 577 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, |
579 | tz->device->dev.bus_id, | 578 | dev_name(&tz->device->dev), |
580 | ACPI_THERMAL_NOTIFY_CRITICAL, | 579 | ACPI_THERMAL_NOTIFY_CRITICAL, |
581 | tz->trips.critical.flags.enabled); | 580 | tz->trips.critical.flags.enabled); |
582 | 581 | ||
@@ -605,7 +604,7 @@ static int acpi_thermal_hot(struct acpi_thermal *tz) | |||
605 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, | 604 | acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, |
606 | tz->trips.hot.flags.enabled); | 605 | tz->trips.hot.flags.enabled); |
607 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, | 606 | acpi_bus_generate_netlink_event(tz->device->pnp.device_class, |
608 | tz->device->dev.bus_id, | 607 | dev_name(&tz->device->dev), |
609 | ACPI_THERMAL_NOTIFY_HOT, | 608 | ACPI_THERMAL_NOTIFY_HOT, |
610 | tz->trips.hot.flags.enabled); | 609 | tz->trips.hot.flags.enabled); |
611 | 610 | ||
@@ -1592,14 +1591,14 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) | |||
1592 | acpi_thermal_check(tz); | 1591 | acpi_thermal_check(tz); |
1593 | acpi_bus_generate_proc_event(device, event, 0); | 1592 | acpi_bus_generate_proc_event(device, event, 0); |
1594 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 1593 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
1595 | device->dev.bus_id, event, 0); | 1594 | dev_name(&device->dev), event, 0); |
1596 | break; | 1595 | break; |
1597 | case ACPI_THERMAL_NOTIFY_DEVICES: | 1596 | case ACPI_THERMAL_NOTIFY_DEVICES: |
1598 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); | 1597 | acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); |
1599 | acpi_thermal_check(tz); | 1598 | acpi_thermal_check(tz); |
1600 | acpi_bus_generate_proc_event(device, event, 0); | 1599 | acpi_bus_generate_proc_event(device, event, 0); |
1601 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 1600 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
1602 | device->dev.bus_id, event, 0); | 1601 | dev_name(&device->dev), event, 0); |
1603 | break; | 1602 | break; |
1604 | default: | 1603 | default: |
1605 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 1604 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index a29b0ccac65a..baa441929720 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <acpi/acpi_bus.h> | 41 | #include <acpi/acpi_bus.h> |
42 | #include <acpi/acpi_drivers.h> | 42 | #include <acpi/acpi_drivers.h> |
43 | 43 | ||
44 | #define ACPI_VIDEO_COMPONENT 0x08000000 | ||
45 | #define ACPI_VIDEO_CLASS "video" | 44 | #define ACPI_VIDEO_CLASS "video" |
46 | #define ACPI_VIDEO_BUS_NAME "Video Bus" | 45 | #define ACPI_VIDEO_BUS_NAME "Video Bus" |
47 | #define ACPI_VIDEO_DEVICE_NAME "Video Device" | 46 | #define ACPI_VIDEO_DEVICE_NAME "Video Device" |
@@ -739,7 +738,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
739 | device->cap._DSS = 1; | 738 | device->cap._DSS = 1; |
740 | } | 739 | } |
741 | 740 | ||
742 | max_level = acpi_video_init_brightness(device); | 741 | if (acpi_video_backlight_support()) |
742 | max_level = acpi_video_init_brightness(device); | ||
743 | 743 | ||
744 | if (device->cap._BCL && device->cap._BCM && max_level > 0) { | 744 | if (device->cap._BCL && device->cap._BCM && max_level > 0) { |
745 | int result; | 745 | int result; |
@@ -785,18 +785,21 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
785 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | 785 | printk(KERN_ERR PREFIX "Create sysfs link\n"); |
786 | 786 | ||
787 | } | 787 | } |
788 | if (device->cap._DCS && device->cap._DSS){ | 788 | |
789 | static int count = 0; | 789 | if (acpi_video_display_switch_support()) { |
790 | char *name; | 790 | |
791 | name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); | 791 | if (device->cap._DCS && device->cap._DSS) { |
792 | if (!name) | 792 | static int count; |
793 | return; | 793 | char *name; |
794 | sprintf(name, "acpi_video%d", count++); | 794 | name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); |
795 | device->output_dev = video_output_register(name, | 795 | if (!name) |
796 | NULL, device, &acpi_output_properties); | 796 | return; |
797 | kfree(name); | 797 | sprintf(name, "acpi_video%d", count++); |
798 | device->output_dev = video_output_register(name, | ||
799 | NULL, device, &acpi_output_properties); | ||
800 | kfree(name); | ||
801 | } | ||
798 | } | 802 | } |
799 | return; | ||
800 | } | 803 | } |
801 | 804 | ||
802 | /* | 805 | /* |
@@ -842,11 +845,16 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video) | |||
842 | static int acpi_video_bus_check(struct acpi_video_bus *video) | 845 | static int acpi_video_bus_check(struct acpi_video_bus *video) |
843 | { | 846 | { |
844 | acpi_status status = -ENOENT; | 847 | acpi_status status = -ENOENT; |
845 | 848 | struct device *dev; | |
846 | 849 | ||
847 | if (!video) | 850 | if (!video) |
848 | return -EINVAL; | 851 | return -EINVAL; |
849 | 852 | ||
853 | dev = acpi_get_physical_pci_device(video->device->handle); | ||
854 | if (!dev) | ||
855 | return -ENODEV; | ||
856 | put_device(dev); | ||
857 | |||
850 | /* Since there is no HID, CID and so on for VGA driver, we have | 858 | /* Since there is no HID, CID and so on for VGA driver, we have |
851 | * to check well known required nodes. | 859 | * to check well known required nodes. |
852 | */ | 860 | */ |
@@ -2094,12 +2102,6 @@ static int __init acpi_video_init(void) | |||
2094 | { | 2102 | { |
2095 | int result = 0; | 2103 | int result = 0; |
2096 | 2104 | ||
2097 | |||
2098 | /* | ||
2099 | acpi_dbg_level = 0xFFFFFFFF; | ||
2100 | acpi_dbg_layer = 0x08000000; | ||
2101 | */ | ||
2102 | |||
2103 | acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); | 2105 | acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); |
2104 | if (!acpi_video_dir) | 2106 | if (!acpi_video_dir) |
2105 | return -ENODEV; | 2107 | return -ENODEV; |
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c new file mode 100644 index 000000000000..f022eb6f5637 --- /dev/null +++ b/drivers/acpi/video_detect.c | |||
@@ -0,0 +1,267 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 SuSE Linux Products GmbH | ||
3 | * Thomas Renninger <trenn@suse.de> | ||
4 | * | ||
5 | * May be copied or modified under the terms of the GNU General Public License | ||
6 | * | ||
7 | * video_detect.c: | ||
8 | * Provides acpi_is_video_device() for early scanning of ACPI devices in scan.c | ||
9 | * There a Linux specific (Spec does not provide a HID for video devices) is | ||
10 | * assinged | ||
11 | * | ||
12 | * After PCI devices are glued with ACPI devices | ||
13 | * acpi_get_physical_pci_device() can be called to identify ACPI graphics | ||
14 | * devices for which a real graphics card is plugged in | ||
15 | * | ||
16 | * Now acpi_video_get_capabilities() can be called to check which | ||
17 | * capabilities the graphics cards plugged in support. The check for general | ||
18 | * video capabilities will be triggered by the first caller of | ||
19 | * acpi_video_get_capabilities(NULL); which will happen when the first | ||
20 | * backlight (or display output) switching supporting driver calls: | ||
21 | * acpi_video_backlight_support(); | ||
22 | * | ||
23 | * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B) | ||
24 | * are available, video.ko should be used to handle the device. | ||
25 | * | ||
26 | * Otherwise vendor specific drivers like thinkpad_acpi, asus_acpi, | ||
27 | * sony_acpi,... can take care about backlight brightness and display output | ||
28 | * switching. | ||
29 | * | ||
30 | * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) | ||
31 | * this file will not be compiled, acpi_video_get_capabilities() and | ||
32 | * acpi_video_backlight_support() will always return 0 and vendor specific | ||
33 | * drivers always can handle backlight. | ||
34 | * | ||
35 | */ | ||
36 | |||
37 | #include <linux/acpi.h> | ||
38 | #include <linux/dmi.h> | ||
39 | |||
40 | ACPI_MODULE_NAME("video"); | ||
41 | #define _COMPONENT ACPI_VIDEO_COMPONENT | ||
42 | |||
43 | static long acpi_video_support; | ||
44 | static bool acpi_video_caps_checked; | ||
45 | |||
46 | static acpi_status | ||
47 | acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, | ||
48 | void **retyurn_value) | ||
49 | { | ||
50 | long *cap = context; | ||
51 | acpi_handle h_dummy; | ||
52 | |||
53 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_BCM", &h_dummy)) && | ||
54 | ACPI_SUCCESS(acpi_get_handle(handle, "_BCL", &h_dummy))) { | ||
55 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight " | ||
56 | "support\n")); | ||
57 | *cap |= ACPI_VIDEO_BACKLIGHT; | ||
58 | /* We have backlight support, no need to scan further */ | ||
59 | return AE_CTRL_TERMINATE; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | /* Returns true if the device is a video device which can be handled by | ||
65 | * video.ko. | ||
66 | * The device will get a Linux specific CID added in scan.c to | ||
67 | * identify the device as an ACPI graphics device | ||
68 | * Be aware that the graphics device may not be physically present | ||
69 | * Use acpi_video_get_capabilities() to detect general ACPI video | ||
70 | * capabilities of present cards | ||
71 | */ | ||
72 | long acpi_is_video_device(struct acpi_device *device) | ||
73 | { | ||
74 | acpi_handle h_dummy; | ||
75 | long video_caps = 0; | ||
76 | |||
77 | if (!device) | ||
78 | return 0; | ||
79 | |||
80 | /* Does this device able to support video switching ? */ | ||
81 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) && | ||
82 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy))) | ||
83 | video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; | ||
84 | |||
85 | /* Does this device able to retrieve a video ROM ? */ | ||
86 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy))) | ||
87 | video_caps |= ACPI_VIDEO_ROM_AVAILABLE; | ||
88 | |||
89 | /* Does this device able to configure which video head to be POSTed ? */ | ||
90 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) && | ||
91 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) && | ||
92 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy))) | ||
93 | video_caps |= ACPI_VIDEO_DEVICE_POSTING; | ||
94 | |||
95 | /* Only check for backlight functionality if one of the above hit. */ | ||
96 | if (video_caps) | ||
97 | acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle, | ||
98 | ACPI_UINT32_MAX, acpi_backlight_cap_match, | ||
99 | &video_caps, NULL); | ||
100 | |||
101 | return video_caps; | ||
102 | } | ||
103 | EXPORT_SYMBOL(acpi_is_video_device); | ||
104 | |||
105 | static acpi_status | ||
106 | find_video(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
107 | { | ||
108 | long *cap = context; | ||
109 | struct device *dev; | ||
110 | struct acpi_device *acpi_dev; | ||
111 | |||
112 | const struct acpi_device_id video_ids[] = { | ||
113 | {ACPI_VIDEO_HID, 0}, | ||
114 | {"", 0}, | ||
115 | }; | ||
116 | if (acpi_bus_get_device(handle, &acpi_dev)) | ||
117 | return AE_OK; | ||
118 | |||
119 | if (!acpi_match_device_ids(acpi_dev, video_ids)) { | ||
120 | dev = acpi_get_physical_pci_device(handle); | ||
121 | if (!dev) | ||
122 | return AE_OK; | ||
123 | put_device(dev); | ||
124 | *cap |= acpi_is_video_device(acpi_dev); | ||
125 | } | ||
126 | return AE_OK; | ||
127 | } | ||
128 | |||
129 | /* | ||
130 | * Returns the video capabilities of a specific ACPI graphics device | ||
131 | * | ||
132 | * if NULL is passed as argument all ACPI devices are enumerated and | ||
133 | * all graphics capabilities of physically present devices are | ||
134 | * summerized and returned. This is cached and done only once. | ||
135 | */ | ||
136 | long acpi_video_get_capabilities(acpi_handle graphics_handle) | ||
137 | { | ||
138 | long caps = 0; | ||
139 | struct acpi_device *tmp_dev; | ||
140 | acpi_status status; | ||
141 | |||
142 | if (acpi_video_caps_checked && graphics_handle == NULL) | ||
143 | return acpi_video_support; | ||
144 | |||
145 | if (!graphics_handle) { | ||
146 | /* Only do the global walk through all graphics devices once */ | ||
147 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
148 | ACPI_UINT32_MAX, find_video, | ||
149 | &caps, NULL); | ||
150 | /* There might be boot param flags set already... */ | ||
151 | acpi_video_support |= caps; | ||
152 | acpi_video_caps_checked = 1; | ||
153 | /* Add blacklists here. Be careful to use the right *DMI* bits | ||
154 | * to still be able to override logic via boot params, e.g.: | ||
155 | * | ||
156 | * if (dmi_name_in_vendors("XY")) { | ||
157 | * acpi_video_support |= | ||
158 | * ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR; | ||
159 | * acpi_video_support |= | ||
160 | * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR; | ||
161 | *} | ||
162 | */ | ||
163 | } else { | ||
164 | status = acpi_bus_get_device(graphics_handle, &tmp_dev); | ||
165 | if (ACPI_FAILURE(status)) { | ||
166 | ACPI_EXCEPTION((AE_INFO, status, "Invalid device")); | ||
167 | return 0; | ||
168 | } | ||
169 | acpi_walk_namespace(ACPI_TYPE_DEVICE, graphics_handle, | ||
170 | ACPI_UINT32_MAX, find_video, | ||
171 | &caps, NULL); | ||
172 | } | ||
173 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "We have 0x%lX video support %s %s\n", | ||
174 | graphics_handle ? caps : acpi_video_support, | ||
175 | graphics_handle ? "on device " : "in general", | ||
176 | graphics_handle ? acpi_device_bid(tmp_dev) : "")); | ||
177 | return caps; | ||
178 | } | ||
179 | EXPORT_SYMBOL(acpi_video_get_capabilities); | ||
180 | |||
181 | /* Returns true if video.ko can do backlight switching */ | ||
182 | int acpi_video_backlight_support(void) | ||
183 | { | ||
184 | /* | ||
185 | * We must check whether the ACPI graphics device is physically plugged | ||
186 | * in. Therefore this must be called after binding PCI and ACPI devices | ||
187 | */ | ||
188 | if (!acpi_video_caps_checked) | ||
189 | acpi_video_get_capabilities(NULL); | ||
190 | |||
191 | /* First check for boot param -> highest prio */ | ||
192 | if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR) | ||
193 | return 0; | ||
194 | else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO) | ||
195 | return 1; | ||
196 | |||
197 | /* Then check for DMI blacklist -> second highest prio */ | ||
198 | if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VENDOR) | ||
199 | return 0; | ||
200 | else if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_DMI_VIDEO) | ||
201 | return 1; | ||
202 | |||
203 | /* Then go the default way */ | ||
204 | return acpi_video_support & ACPI_VIDEO_BACKLIGHT; | ||
205 | } | ||
206 | EXPORT_SYMBOL(acpi_video_backlight_support); | ||
207 | |||
208 | /* | ||
209 | * Returns true if video.ko can do display output switching. | ||
210 | * This does not work well/at all with binary graphics drivers | ||
211 | * which disable system io ranges and do it on their own. | ||
212 | */ | ||
213 | int acpi_video_display_switch_support(void) | ||
214 | { | ||
215 | if (!acpi_video_caps_checked) | ||
216 | acpi_video_get_capabilities(NULL); | ||
217 | |||
218 | if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR) | ||
219 | return 0; | ||
220 | else if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO) | ||
221 | return 1; | ||
222 | |||
223 | if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR) | ||
224 | return 0; | ||
225 | else if (acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO) | ||
226 | return 1; | ||
227 | |||
228 | return acpi_video_support & ACPI_VIDEO_OUTPUT_SWITCHING; | ||
229 | } | ||
230 | EXPORT_SYMBOL(acpi_video_display_switch_support); | ||
231 | |||
232 | /* | ||
233 | * Use acpi_display_output=vendor/video or acpi_backlight=vendor/video | ||
234 | * To force that backlight or display output switching is processed by vendor | ||
235 | * specific acpi drivers or video.ko driver. | ||
236 | */ | ||
237 | int __init acpi_backlight(char *str) | ||
238 | { | ||
239 | if (str == NULL || *str == '\0') | ||
240 | return 1; | ||
241 | else { | ||
242 | if (!strcmp("vendor", str)) | ||
243 | acpi_video_support |= | ||
244 | ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR; | ||
245 | if (!strcmp("video", str)) | ||
246 | acpi_video_support |= | ||
247 | ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO; | ||
248 | } | ||
249 | return 1; | ||
250 | } | ||
251 | __setup("acpi_backlight=", acpi_backlight); | ||
252 | |||
253 | int __init acpi_display_output(char *str) | ||
254 | { | ||
255 | if (str == NULL || *str == '\0') | ||
256 | return 1; | ||
257 | else { | ||
258 | if (!strcmp("vendor", str)) | ||
259 | acpi_video_support |= | ||
260 | ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR; | ||
261 | if (!strcmp("video", str)) | ||
262 | acpi_video_support |= | ||
263 | ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO; | ||
264 | } | ||
265 | return 1; | ||
266 | } | ||
267 | __setup("acpi_display_output=", acpi_display_output); | ||
diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c index 47cd7baf9b1b..8a8b377712c9 100644 --- a/drivers/acpi/wmi.c +++ b/drivers/acpi/wmi.c | |||
@@ -660,7 +660,7 @@ static void acpi_wmi_notify(acpi_handle handle, u32 event, void *data) | |||
660 | wblock->handler(event, wblock->handler_data); | 660 | wblock->handler(event, wblock->handler_data); |
661 | 661 | ||
662 | acpi_bus_generate_netlink_event( | 662 | acpi_bus_generate_netlink_event( |
663 | device->pnp.device_class, device->dev.bus_id, | 663 | device->pnp.device_class, dev_name(&device->dev), |
664 | event, 0); | 664 | event, 0); |
665 | break; | 665 | break; |
666 | } | 666 | } |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 4b4739486327..9033d164c4ec 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -1227,10 +1227,19 @@ fsm_start: | |||
1227 | /* ATA PIO protocol */ | 1227 | /* ATA PIO protocol */ |
1228 | if (unlikely((status & ATA_DRQ) == 0)) { | 1228 | if (unlikely((status & ATA_DRQ) == 0)) { |
1229 | /* handle BSY=0, DRQ=0 as error */ | 1229 | /* handle BSY=0, DRQ=0 as error */ |
1230 | if (likely(status & (ATA_ERR | ATA_DF))) | 1230 | if (likely(status & (ATA_ERR | ATA_DF))) { |
1231 | /* device stops HSM for abort/error */ | 1231 | /* device stops HSM for abort/error */ |
1232 | qc->err_mask |= AC_ERR_DEV; | 1232 | qc->err_mask |= AC_ERR_DEV; |
1233 | else { | 1233 | |
1234 | /* If diagnostic failed and this is | ||
1235 | * IDENTIFY, it's likely a phantom | ||
1236 | * device. Mark hint. | ||
1237 | */ | ||
1238 | if (qc->dev->horkage & | ||
1239 | ATA_HORKAGE_DIAGNOSTIC) | ||
1240 | qc->err_mask |= | ||
1241 | AC_ERR_NODEV_HINT; | ||
1242 | } else { | ||
1234 | /* HSM violation. Let EH handle this. | 1243 | /* HSM violation. Let EH handle this. |
1235 | * Phantom devices also trigger this | 1244 | * Phantom devices also trigger this |
1236 | * condition. Mark hint. | 1245 | * condition. Mark hint. |
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 61ad8d639ba3..0344a8a8321d 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig | |||
@@ -21,7 +21,8 @@ config BLK_DEV_FD | |||
21 | ---help--- | 21 | ---help--- |
22 | If you want to use the floppy disk drive(s) of your PC under Linux, | 22 | If you want to use the floppy disk drive(s) of your PC under Linux, |
23 | say Y. Information about this driver, especially important for IBM | 23 | say Y. Information about this driver, especially important for IBM |
24 | Thinkpad users, is contained in <file:Documentation/floppy.txt>. | 24 | Thinkpad users, is contained in |
25 | <file:Documentation/blockdev/floppy.txt>. | ||
25 | That file also contains the location of the Floppy driver FAQ as | 26 | That file also contains the location of the Floppy driver FAQ as |
26 | well as location of the fdutils package used to configure additional | 27 | well as location of the fdutils package used to configure additional |
27 | parameters of the driver at run time. | 28 | parameters of the driver at run time. |
@@ -76,7 +77,7 @@ config PARIDE | |||
76 | your computer's parallel port. Most of them are actually IDE devices | 77 | your computer's parallel port. Most of them are actually IDE devices |
77 | using a parallel port IDE adapter. This option enables the PARIDE | 78 | using a parallel port IDE adapter. This option enables the PARIDE |
78 | subsystem which contains drivers for many of these external drives. | 79 | subsystem which contains drivers for many of these external drives. |
79 | Read <file:Documentation/paride.txt> for more information. | 80 | Read <file:Documentation/blockdev/paride.txt> for more information. |
80 | 81 | ||
81 | If you have said Y to the "Parallel-port support" configuration | 82 | If you have said Y to the "Parallel-port support" configuration |
82 | option, you may share a single port between your printer and other | 83 | option, you may share a single port between your printer and other |
@@ -114,9 +115,9 @@ config BLK_CPQ_DA | |||
114 | help | 115 | help |
115 | This is the driver for Compaq Smart Array controllers. Everyone | 116 | This is the driver for Compaq Smart Array controllers. Everyone |
116 | using these boards should say Y here. See the file | 117 | using these boards should say Y here. See the file |
117 | <file:Documentation/cpqarray.txt> for the current list of boards | 118 | <file:Documentation/blockdev/cpqarray.txt> for the current list of |
118 | supported by this driver, and for further information on the use of | 119 | boards supported by this driver, and for further information on the |
119 | this driver. | 120 | use of this driver. |
120 | 121 | ||
121 | config BLK_CPQ_CISS_DA | 122 | config BLK_CPQ_CISS_DA |
122 | tristate "Compaq Smart Array 5xxx support" | 123 | tristate "Compaq Smart Array 5xxx support" |
@@ -124,7 +125,7 @@ config BLK_CPQ_CISS_DA | |||
124 | help | 125 | help |
125 | This is the driver for Compaq Smart Array 5xxx controllers. | 126 | This is the driver for Compaq Smart Array 5xxx controllers. |
126 | Everyone using these boards should say Y here. | 127 | Everyone using these boards should say Y here. |
127 | See <file:Documentation/cciss.txt> for the current list of | 128 | See <file:Documentation/blockdev/cciss.txt> for the current list of |
128 | boards supported by this driver, and for further information | 129 | boards supported by this driver, and for further information |
129 | on the use of this driver. | 130 | on the use of this driver. |
130 | 131 | ||
@@ -135,7 +136,7 @@ config CISS_SCSI_TAPE | |||
135 | help | 136 | help |
136 | When enabled (Y), this option allows SCSI tape drives and SCSI medium | 137 | When enabled (Y), this option allows SCSI tape drives and SCSI medium |
137 | changers (tape robots) to be accessed via a Compaq 5xxx array | 138 | changers (tape robots) to be accessed via a Compaq 5xxx array |
138 | controller. (See <file:Documentation/cciss.txt> for more details.) | 139 | controller. (See <file:Documentation/blockdev/cciss.txt> for more details.) |
139 | 140 | ||
140 | "SCSI support" and "SCSI tape support" must also be enabled for this | 141 | "SCSI support" and "SCSI tape support" must also be enabled for this |
141 | option to work. | 142 | option to work. |
@@ -149,8 +150,8 @@ config BLK_DEV_DAC960 | |||
149 | help | 150 | help |
150 | This driver adds support for the Mylex DAC960, AcceleRAID, and | 151 | This driver adds support for the Mylex DAC960, AcceleRAID, and |
151 | eXtremeRAID PCI RAID controllers. See the file | 152 | eXtremeRAID PCI RAID controllers. See the file |
152 | <file:Documentation/README.DAC960> for further information about | 153 | <file:Documentation/blockdev/README.DAC960> for further information |
153 | this driver. | 154 | about this driver. |
154 | 155 | ||
155 | To compile this driver as a module, choose M here: the | 156 | To compile this driver as a module, choose M here: the |
156 | module will be called DAC960. | 157 | module will be called DAC960. |
@@ -278,9 +279,9 @@ config BLK_DEV_NBD | |||
278 | userland (making server and client physically the same computer, | 279 | userland (making server and client physically the same computer, |
279 | communicating using the loopback network device). | 280 | communicating using the loopback network device). |
280 | 281 | ||
281 | Read <file:Documentation/nbd.txt> for more information, especially | 282 | Read <file:Documentation/blockdev/nbd.txt> for more information, |
282 | about where to find the server code, which runs in user space and | 283 | especially about where to find the server code, which runs in user |
283 | does not need special kernel support. | 284 | space and does not need special kernel support. |
284 | 285 | ||
285 | Note that this has nothing to do with the network file systems NFS | 286 | Note that this has nothing to do with the network file systems NFS |
286 | or Coda; you can say N here even if you intend to use NFS or Coda. | 287 | or Coda; you can say N here even if you intend to use NFS or Coda. |
@@ -321,8 +322,8 @@ config BLK_DEV_RAM | |||
321 | store a copy of a minimal root file system off of a floppy into RAM | 322 | store a copy of a minimal root file system off of a floppy into RAM |
322 | during the initial install of Linux. | 323 | during the initial install of Linux. |
323 | 324 | ||
324 | Note that the kernel command line option "ramdisk=XX" is now | 325 | Note that the kernel command line option "ramdisk=XX" is now obsolete. |
325 | obsolete. For details, read <file:Documentation/ramdisk.txt>. | 326 | For details, read <file:Documentation/blockdev/ramdisk.txt>. |
326 | 327 | ||
327 | To compile this driver as a module, choose M here: the | 328 | To compile this driver as a module, choose M here: the |
328 | module will be called rd. | 329 | module will be called rd. |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 14db747a636e..cf29cc4e6ab7 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -4124,7 +4124,7 @@ static int __init floppy_setup(char *str) | |||
4124 | printk("\n"); | 4124 | printk("\n"); |
4125 | } else | 4125 | } else |
4126 | DPRINT("botched floppy option\n"); | 4126 | DPRINT("botched floppy option\n"); |
4127 | DPRINT("Read Documentation/floppy.txt\n"); | 4127 | DPRINT("Read Documentation/blockdev/floppy.txt\n"); |
4128 | return 0; | 4128 | return 0; |
4129 | } | 4129 | } |
4130 | 4130 | ||
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index fccac18d3111..048d71d244d7 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -1546,8 +1546,6 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) | |||
1546 | 1546 | ||
1547 | /* | 1547 | /* |
1548 | * Reset management | 1548 | * Reset management |
1549 | * XXX Move usb_reset_device to khubd. Hogging kevent is not a good thing. | ||
1550 | * XXX Make usb_sync_reset asynchronous. | ||
1551 | */ | 1549 | */ |
1552 | 1550 | ||
1553 | static void ub_reset_enter(struct ub_dev *sc, int try) | 1551 | static void ub_reset_enter(struct ub_dev *sc, int try) |
@@ -1633,6 +1631,22 @@ static void ub_reset_task(struct work_struct *work) | |||
1633 | } | 1631 | } |
1634 | 1632 | ||
1635 | /* | 1633 | /* |
1634 | * XXX Reset brackets are too much hassle to implement, so just stub them | ||
1635 | * in order to prevent forced unbinding (which deadlocks solid when our | ||
1636 | * ->disconnect method waits for the reset to complete and this kills keventd). | ||
1637 | * | ||
1638 | * XXX Tell Alan to move usb_unlock_device inside of usb_reset_device, | ||
1639 | * or else the post_reset is invoked, and restats I/O on a locked device. | ||
1640 | */ | ||
1641 | static int ub_pre_reset(struct usb_interface *iface) { | ||
1642 | return 0; | ||
1643 | } | ||
1644 | |||
1645 | static int ub_post_reset(struct usb_interface *iface) { | ||
1646 | return 0; | ||
1647 | } | ||
1648 | |||
1649 | /* | ||
1636 | * This is called from a process context. | 1650 | * This is called from a process context. |
1637 | */ | 1651 | */ |
1638 | static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) | 1652 | static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) |
@@ -2446,6 +2460,8 @@ static struct usb_driver ub_driver = { | |||
2446 | .probe = ub_probe, | 2460 | .probe = ub_probe, |
2447 | .disconnect = ub_disconnect, | 2461 | .disconnect = ub_disconnect, |
2448 | .id_table = ub_usb_ids, | 2462 | .id_table = ub_usb_ids, |
2463 | .pre_reset = ub_pre_reset, | ||
2464 | .post_reset = ub_post_reset, | ||
2449 | }; | 2465 | }; |
2450 | 2466 | ||
2451 | static int __init ub_init(void) | 2467 | static int __init ub_init(void) |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index b220c686089d..2d19f0cc47f2 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -338,12 +338,18 @@ wait: | |||
338 | static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) | 338 | static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) |
339 | { | 339 | { |
340 | struct request_queue *rq; | 340 | struct request_queue *rq; |
341 | elevator_t *old_e; | ||
341 | 342 | ||
342 | rq = blk_init_queue(do_blkif_request, &blkif_io_lock); | 343 | rq = blk_init_queue(do_blkif_request, &blkif_io_lock); |
343 | if (rq == NULL) | 344 | if (rq == NULL) |
344 | return -1; | 345 | return -1; |
345 | 346 | ||
346 | elevator_init(rq, "noop"); | 347 | old_e = rq->elevator; |
348 | if (IS_ERR_VALUE(elevator_init(rq, "noop"))) | ||
349 | printk(KERN_WARNING | ||
350 | "blkfront: Switch elevator failed, use default\n"); | ||
351 | else | ||
352 | elevator_exit(old_e); | ||
347 | 353 | ||
348 | /* Hard sector size and max sectors impersonate the equiv. hardware. */ | 354 | /* Hard sector size and max sectors impersonate the equiv. hardware. */ |
349 | blk_queue_hardsect_size(rq, sector_size); | 355 | blk_queue_hardsect_size(rq, sector_size); |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 43b35d0369d6..43d6ba83a191 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -124,7 +124,7 @@ config COMPUTONE | |||
124 | which give you many serial ports. You would need something like this | 124 | which give you many serial ports. You would need something like this |
125 | to connect more than two modems to your Linux box, for instance in | 125 | to connect more than two modems to your Linux box, for instance in |
126 | order to become a dial-in server. If you have a card like that, say | 126 | order to become a dial-in server. If you have a card like that, say |
127 | Y here and read <file:Documentation/computone.txt>. | 127 | Y here and read <file:Documentation/serial/computone.txt>. |
128 | 128 | ||
129 | To compile this driver as module, choose M here: the | 129 | To compile this driver as module, choose M here: the |
130 | module will be called ip2. | 130 | module will be called ip2. |
@@ -136,7 +136,7 @@ config ROCKETPORT | |||
136 | This driver supports Comtrol RocketPort and RocketModem PCI boards. | 136 | This driver supports Comtrol RocketPort and RocketModem PCI boards. |
137 | These boards provide 2, 4, 8, 16, or 32 high-speed serial ports or | 137 | These boards provide 2, 4, 8, 16, or 32 high-speed serial ports or |
138 | modems. For information about the RocketPort/RocketModem boards | 138 | modems. For information about the RocketPort/RocketModem boards |
139 | and this driver read <file:Documentation/rocket.txt>. | 139 | and this driver read <file:Documentation/serial/rocket.txt>. |
140 | 140 | ||
141 | To compile this driver as a module, choose M here: the | 141 | To compile this driver as a module, choose M here: the |
142 | module will be called rocket. | 142 | module will be called rocket. |
@@ -154,7 +154,7 @@ config CYCLADES | |||
154 | your Linux box, for instance in order to become a dial-in server. | 154 | your Linux box, for instance in order to become a dial-in server. |
155 | 155 | ||
156 | For information about the Cyclades-Z card, read | 156 | For information about the Cyclades-Z card, read |
157 | <file:Documentation/README.cycladesZ>. | 157 | <file:Documentation/serial/README.cycladesZ>. |
158 | 158 | ||
159 | To compile this driver as a module, choose M here: the | 159 | To compile this driver as a module, choose M here: the |
160 | module will be called cyclades. | 160 | module will be called cyclades. |
@@ -183,7 +183,7 @@ config DIGIEPCA | |||
183 | box, for instance in order to become a dial-in server. This driver | 183 | box, for instance in order to become a dial-in server. This driver |
184 | supports the original PC (ISA) boards as well as PCI, and EISA. If | 184 | supports the original PC (ISA) boards as well as PCI, and EISA. If |
185 | you have a card like this, say Y here and read the file | 185 | you have a card like this, say Y here and read the file |
186 | <file:Documentation/digiepca.txt>. | 186 | <file:Documentation/serial/digiepca.txt>. |
187 | 187 | ||
188 | To compile this driver as a module, choose M here: the | 188 | To compile this driver as a module, choose M here: the |
189 | module will be called epca. | 189 | module will be called epca. |
@@ -289,7 +289,7 @@ config RISCOM8 | |||
289 | which gives you many serial ports. You would need something like | 289 | which gives you many serial ports. You would need something like |
290 | this to connect more than two modems to your Linux box, for instance | 290 | this to connect more than two modems to your Linux box, for instance |
291 | in order to become a dial-in server. If you have a card like that, | 291 | in order to become a dial-in server. If you have a card like that, |
292 | say Y here and read the file <file:Documentation/riscom8.txt>. | 292 | say Y here and read the file <file:Documentation/serial/riscom8.txt>. |
293 | 293 | ||
294 | Also it's possible to say M here and compile this driver as kernel | 294 | Also it's possible to say M here and compile this driver as kernel |
295 | loadable module; the module will be called riscom8. | 295 | loadable module; the module will be called riscom8. |
@@ -304,8 +304,8 @@ config SPECIALIX | |||
304 | your Linux box, for instance in order to become a dial-in server. | 304 | your Linux box, for instance in order to become a dial-in server. |
305 | 305 | ||
306 | If you have a card like that, say Y here and read the file | 306 | If you have a card like that, say Y here and read the file |
307 | <file:Documentation/specialix.txt>. Also it's possible to say M here | 307 | <file:Documentation/serial/specialix.txt>. Also it's possible to say |
308 | and compile this driver as kernel loadable module which will be | 308 | M here and compile this driver as kernel loadable module which will be |
309 | called specialix. | 309 | called specialix. |
310 | 310 | ||
311 | config SX | 311 | config SX |
@@ -313,7 +313,7 @@ config SX | |||
313 | depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) | 313 | depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) |
314 | help | 314 | help |
315 | This is a driver for the SX and SI multiport serial cards. | 315 | This is a driver for the SX and SI multiport serial cards. |
316 | Please read the file <file:Documentation/sx.txt> for details. | 316 | Please read the file <file:Documentation/serial/sx.txt> for details. |
317 | 317 | ||
318 | This driver can only be built as a module ( = code which can be | 318 | This driver can only be built as a module ( = code which can be |
319 | inserted in and removed from the running kernel whenever you want). | 319 | inserted in and removed from the running kernel whenever you want). |
@@ -344,8 +344,8 @@ config STALDRV | |||
344 | like this to connect more than two modems to your Linux box, for | 344 | like this to connect more than two modems to your Linux box, for |
345 | instance in order to become a dial-in server. If you say Y here, | 345 | instance in order to become a dial-in server. If you say Y here, |
346 | you will be asked for your specific card model in the next | 346 | you will be asked for your specific card model in the next |
347 | questions. Make sure to read <file:Documentation/stallion.txt> in | 347 | questions. Make sure to read <file:Documentation/serial/stallion.txt> |
348 | this case. If you have never heard about all this, it's safe to | 348 | in this case. If you have never heard about all this, it's safe to |
349 | say N. | 349 | say N. |
350 | 350 | ||
351 | config STALLION | 351 | config STALLION |
@@ -354,7 +354,7 @@ config STALLION | |||
354 | help | 354 | help |
355 | If you have an EasyIO or EasyConnection 8/32 multiport Stallion | 355 | If you have an EasyIO or EasyConnection 8/32 multiport Stallion |
356 | card, then this is for you; say Y. Make sure to read | 356 | card, then this is for you; say Y. Make sure to read |
357 | <file:Documentation/stallion.txt>. | 357 | <file:Documentation/serial/stallion.txt>. |
358 | 358 | ||
359 | To compile this driver as a module, choose M here: the | 359 | To compile this driver as a module, choose M here: the |
360 | module will be called stallion. | 360 | module will be called stallion. |
@@ -365,7 +365,7 @@ config ISTALLION | |||
365 | help | 365 | help |
366 | If you have an EasyConnection 8/64, ONboard, Brumby or Stallion | 366 | If you have an EasyConnection 8/64, ONboard, Brumby or Stallion |
367 | serial multiport card, say Y here. Make sure to read | 367 | serial multiport card, say Y here. Make sure to read |
368 | <file:Documentation/stallion.txt>. | 368 | <file:Documentation/serial/stallion.txt>. |
369 | 369 | ||
370 | To compile this driver as a module, choose M here: the | 370 | To compile this driver as a module, choose M here: the |
371 | module will be called istallion. | 371 | module will be called istallion. |
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 8a59aaa21be5..7a88dfd4427b 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -422,9 +422,11 @@ struct ipmi_smi { | |||
422 | /** | 422 | /** |
423 | * The driver model view of the IPMI messaging driver. | 423 | * The driver model view of the IPMI messaging driver. |
424 | */ | 424 | */ |
425 | static struct device_driver ipmidriver = { | 425 | static struct platform_driver ipmidriver = { |
426 | .name = "ipmi", | 426 | .driver = { |
427 | .bus = &platform_bus_type | 427 | .name = "ipmi", |
428 | .bus = &platform_bus_type | ||
429 | } | ||
428 | }; | 430 | }; |
429 | static DEFINE_MUTEX(ipmidriver_mutex); | 431 | static DEFINE_MUTEX(ipmidriver_mutex); |
430 | 432 | ||
@@ -2384,9 +2386,9 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum, | |||
2384 | * representing the interfaced BMC already | 2386 | * representing the interfaced BMC already |
2385 | */ | 2387 | */ |
2386 | if (bmc->guid_set) | 2388 | if (bmc->guid_set) |
2387 | old_bmc = ipmi_find_bmc_guid(&ipmidriver, bmc->guid); | 2389 | old_bmc = ipmi_find_bmc_guid(&ipmidriver.driver, bmc->guid); |
2388 | else | 2390 | else |
2389 | old_bmc = ipmi_find_bmc_prod_dev_id(&ipmidriver, | 2391 | old_bmc = ipmi_find_bmc_prod_dev_id(&ipmidriver.driver, |
2390 | bmc->id.product_id, | 2392 | bmc->id.product_id, |
2391 | bmc->id.device_id); | 2393 | bmc->id.device_id); |
2392 | 2394 | ||
@@ -2416,7 +2418,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum, | |||
2416 | snprintf(name, sizeof(name), | 2418 | snprintf(name, sizeof(name), |
2417 | "ipmi_bmc.%4.4x", bmc->id.product_id); | 2419 | "ipmi_bmc.%4.4x", bmc->id.product_id); |
2418 | 2420 | ||
2419 | while (ipmi_find_bmc_prod_dev_id(&ipmidriver, | 2421 | while (ipmi_find_bmc_prod_dev_id(&ipmidriver.driver, |
2420 | bmc->id.product_id, | 2422 | bmc->id.product_id, |
2421 | bmc->id.device_id)) { | 2423 | bmc->id.device_id)) { |
2422 | if (!warn_printed) { | 2424 | if (!warn_printed) { |
@@ -2446,7 +2448,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum, | |||
2446 | " Unable to allocate platform device\n"); | 2448 | " Unable to allocate platform device\n"); |
2447 | return -ENOMEM; | 2449 | return -ENOMEM; |
2448 | } | 2450 | } |
2449 | bmc->dev->dev.driver = &ipmidriver; | 2451 | bmc->dev->dev.driver = &ipmidriver.driver; |
2450 | dev_set_drvdata(&bmc->dev->dev, bmc); | 2452 | dev_set_drvdata(&bmc->dev->dev, bmc); |
2451 | kref_init(&bmc->refcount); | 2453 | kref_init(&bmc->refcount); |
2452 | 2454 | ||
@@ -4247,7 +4249,7 @@ static int ipmi_init_msghandler(void) | |||
4247 | if (initialized) | 4249 | if (initialized) |
4248 | return 0; | 4250 | return 0; |
4249 | 4251 | ||
4250 | rv = driver_register(&ipmidriver); | 4252 | rv = driver_register(&ipmidriver.driver); |
4251 | if (rv) { | 4253 | if (rv) { |
4252 | printk(KERN_ERR PFX "Could not register IPMI driver\n"); | 4254 | printk(KERN_ERR PFX "Could not register IPMI driver\n"); |
4253 | return rv; | 4255 | return rv; |
@@ -4308,7 +4310,7 @@ static __exit void cleanup_ipmi(void) | |||
4308 | remove_proc_entry(proc_ipmi_root->name, NULL); | 4310 | remove_proc_entry(proc_ipmi_root->name, NULL); |
4309 | #endif /* CONFIG_PROC_FS */ | 4311 | #endif /* CONFIG_PROC_FS */ |
4310 | 4312 | ||
4311 | driver_unregister(&ipmidriver); | 4313 | driver_unregister(&ipmidriver.driver); |
4312 | 4314 | ||
4313 | initialized = 0; | 4315 | initialized = 0; |
4314 | 4316 | ||
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 3123bf57ad91..3000135f2ead 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -114,9 +114,11 @@ static char *si_to_str[] = { "kcs", "smic", "bt" }; | |||
114 | 114 | ||
115 | #define DEVICE_NAME "ipmi_si" | 115 | #define DEVICE_NAME "ipmi_si" |
116 | 116 | ||
117 | static struct device_driver ipmi_driver = { | 117 | static struct platform_driver ipmi_driver = { |
118 | .name = DEVICE_NAME, | 118 | .driver = { |
119 | .bus = &platform_bus_type | 119 | .name = DEVICE_NAME, |
120 | .bus = &platform_bus_type | ||
121 | } | ||
120 | }; | 122 | }; |
121 | 123 | ||
122 | 124 | ||
@@ -2868,7 +2870,7 @@ static int try_smi_init(struct smi_info *new_smi) | |||
2868 | goto out_err; | 2870 | goto out_err; |
2869 | } | 2871 | } |
2870 | new_smi->dev = &new_smi->pdev->dev; | 2872 | new_smi->dev = &new_smi->pdev->dev; |
2871 | new_smi->dev->driver = &ipmi_driver; | 2873 | new_smi->dev->driver = &ipmi_driver.driver; |
2872 | 2874 | ||
2873 | rv = platform_device_add(new_smi->pdev); | 2875 | rv = platform_device_add(new_smi->pdev); |
2874 | if (rv) { | 2876 | if (rv) { |
@@ -2983,7 +2985,7 @@ static __devinit int init_ipmi_si(void) | |||
2983 | initialized = 1; | 2985 | initialized = 1; |
2984 | 2986 | ||
2985 | /* Register the device drivers. */ | 2987 | /* Register the device drivers. */ |
2986 | rv = driver_register(&ipmi_driver); | 2988 | rv = driver_register(&ipmi_driver.driver); |
2987 | if (rv) { | 2989 | if (rv) { |
2988 | printk(KERN_ERR | 2990 | printk(KERN_ERR |
2989 | "init_ipmi_si: Unable to register driver: %d\n", | 2991 | "init_ipmi_si: Unable to register driver: %d\n", |
@@ -3052,7 +3054,7 @@ static __devinit int init_ipmi_si(void) | |||
3052 | #ifdef CONFIG_PPC_OF | 3054 | #ifdef CONFIG_PPC_OF |
3053 | of_unregister_platform_driver(&ipmi_of_platform_driver); | 3055 | of_unregister_platform_driver(&ipmi_of_platform_driver); |
3054 | #endif | 3056 | #endif |
3055 | driver_unregister(&ipmi_driver); | 3057 | driver_unregister(&ipmi_driver.driver); |
3056 | printk(KERN_WARNING | 3058 | printk(KERN_WARNING |
3057 | "ipmi_si: Unable to find any System Interface(s)\n"); | 3059 | "ipmi_si: Unable to find any System Interface(s)\n"); |
3058 | return -ENODEV; | 3060 | return -ENODEV; |
@@ -3151,7 +3153,7 @@ static __exit void cleanup_ipmi_si(void) | |||
3151 | cleanup_one_si(e); | 3153 | cleanup_one_si(e); |
3152 | mutex_unlock(&smi_infos_lock); | 3154 | mutex_unlock(&smi_infos_lock); |
3153 | 3155 | ||
3154 | driver_unregister(&ipmi_driver); | 3156 | driver_unregister(&ipmi_driver.driver); |
3155 | } | 3157 | } |
3156 | module_exit(cleanup_ipmi_si); | 3158 | module_exit(cleanup_ipmi_si); |
3157 | 3159 | ||
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 2457b07dabd6..f4374437a033 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -523,7 +523,7 @@ static int acpi_driver_registered; | |||
523 | 523 | ||
524 | static int sonypi_ec_write(u8 addr, u8 value) | 524 | static int sonypi_ec_write(u8 addr, u8 value) |
525 | { | 525 | { |
526 | #ifdef CONFIG_ACPI_EC | 526 | #ifdef CONFIG_ACPI |
527 | if (SONYPI_ACPI_ACTIVE) | 527 | if (SONYPI_ACPI_ACTIVE) |
528 | return ec_write(addr, value); | 528 | return ec_write(addr, value); |
529 | #endif | 529 | #endif |
@@ -539,7 +539,7 @@ static int sonypi_ec_write(u8 addr, u8 value) | |||
539 | 539 | ||
540 | static int sonypi_ec_read(u8 addr, u8 *value) | 540 | static int sonypi_ec_read(u8 addr, u8 *value) |
541 | { | 541 | { |
542 | #ifdef CONFIG_ACPI_EC | 542 | #ifdef CONFIG_ACPI |
543 | if (SONYPI_ACPI_ACTIVE) | 543 | if (SONYPI_ACPI_ACTIVE) |
544 | return ec_read(addr, value); | 544 | return ec_read(addr, value); |
545 | #endif | 545 | #endif |
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c index 242fd46fda22..a16b94f12eb2 100644 --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c | |||
@@ -72,7 +72,7 @@ | |||
72 | /* | 72 | /* |
73 | * There is a bunch of documentation about the card, jumpers, config | 73 | * There is a bunch of documentation about the card, jumpers, config |
74 | * settings, restrictions, cables, device names and numbers in | 74 | * settings, restrictions, cables, device names and numbers in |
75 | * Documentation/specialix.txt | 75 | * Documentation/serial/specialix.txt |
76 | */ | 76 | */ |
77 | 77 | ||
78 | #include <linux/module.h> | 78 | #include <linux/module.h> |
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index dc003a3a787d..5317e08221ec 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -399,8 +399,8 @@ int dma_async_device_register(struct dma_device *device) | |||
399 | chan->chan_id = chancnt++; | 399 | chan->chan_id = chancnt++; |
400 | chan->dev.class = &dma_devclass; | 400 | chan->dev.class = &dma_devclass; |
401 | chan->dev.parent = device->dev; | 401 | chan->dev.parent = device->dev; |
402 | snprintf(chan->dev.bus_id, BUS_ID_SIZE, "dma%dchan%d", | 402 | dev_set_name(&chan->dev, "dma%dchan%d", |
403 | device->dev_id, chan->chan_id); | 403 | device->dev_id, chan->chan_id); |
404 | 404 | ||
405 | rc = device_register(&chan->dev); | 405 | rc = device_register(&chan->dev); |
406 | if (rc) { | 406 | if (rc) { |
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index d1e381e35a9e..ed9636bfb54a 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c | |||
@@ -20,11 +20,11 @@ static unsigned int test_buf_size = 16384; | |||
20 | module_param(test_buf_size, uint, S_IRUGO); | 20 | module_param(test_buf_size, uint, S_IRUGO); |
21 | MODULE_PARM_DESC(test_buf_size, "Size of the memcpy test buffer"); | 21 | MODULE_PARM_DESC(test_buf_size, "Size of the memcpy test buffer"); |
22 | 22 | ||
23 | static char test_channel[BUS_ID_SIZE]; | 23 | static char test_channel[20]; |
24 | module_param_string(channel, test_channel, sizeof(test_channel), S_IRUGO); | 24 | module_param_string(channel, test_channel, sizeof(test_channel), S_IRUGO); |
25 | MODULE_PARM_DESC(channel, "Bus ID of the channel to test (default: any)"); | 25 | MODULE_PARM_DESC(channel, "Bus ID of the channel to test (default: any)"); |
26 | 26 | ||
27 | static char test_device[BUS_ID_SIZE]; | 27 | static char test_device[20]; |
28 | module_param_string(device, test_device, sizeof(test_device), S_IRUGO); | 28 | module_param_string(device, test_device, sizeof(test_device), S_IRUGO); |
29 | MODULE_PARM_DESC(device, "Bus ID of the DMA Engine to test (default: any)"); | 29 | MODULE_PARM_DESC(device, "Bus ID of the DMA Engine to test (default: any)"); |
30 | 30 | ||
@@ -80,14 +80,14 @@ static bool dmatest_match_channel(struct dma_chan *chan) | |||
80 | { | 80 | { |
81 | if (test_channel[0] == '\0') | 81 | if (test_channel[0] == '\0') |
82 | return true; | 82 | return true; |
83 | return strcmp(chan->dev.bus_id, test_channel) == 0; | 83 | return strcmp(dev_name(&chan->dev), test_channel) == 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | static bool dmatest_match_device(struct dma_device *device) | 86 | static bool dmatest_match_device(struct dma_device *device) |
87 | { | 87 | { |
88 | if (test_device[0] == '\0') | 88 | if (test_device[0] == '\0') |
89 | return true; | 89 | return true; |
90 | return strcmp(device->dev->bus_id, test_device) == 0; | 90 | return strcmp(dev_name(device->dev), test_device) == 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static unsigned long dmatest_random(void) | 93 | static unsigned long dmatest_random(void) |
@@ -332,7 +332,7 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan) | |||
332 | 332 | ||
333 | dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL); | 333 | dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL); |
334 | if (!dtc) { | 334 | if (!dtc) { |
335 | pr_warning("dmatest: No memory for %s\n", chan->dev.bus_id); | 335 | pr_warning("dmatest: No memory for %s\n", dev_name(&chan->dev)); |
336 | return DMA_NAK; | 336 | return DMA_NAK; |
337 | } | 337 | } |
338 | 338 | ||
@@ -343,16 +343,16 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan) | |||
343 | thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL); | 343 | thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL); |
344 | if (!thread) { | 344 | if (!thread) { |
345 | pr_warning("dmatest: No memory for %s-test%u\n", | 345 | pr_warning("dmatest: No memory for %s-test%u\n", |
346 | chan->dev.bus_id, i); | 346 | dev_name(&chan->dev), i); |
347 | break; | 347 | break; |
348 | } | 348 | } |
349 | thread->chan = dtc->chan; | 349 | thread->chan = dtc->chan; |
350 | smp_wmb(); | 350 | smp_wmb(); |
351 | thread->task = kthread_run(dmatest_func, thread, "%s-test%u", | 351 | thread->task = kthread_run(dmatest_func, thread, "%s-test%u", |
352 | chan->dev.bus_id, i); | 352 | dev_name(&chan->dev), i); |
353 | if (IS_ERR(thread->task)) { | 353 | if (IS_ERR(thread->task)) { |
354 | pr_warning("dmatest: Failed to run thread %s-test%u\n", | 354 | pr_warning("dmatest: Failed to run thread %s-test%u\n", |
355 | chan->dev.bus_id, i); | 355 | dev_name(&chan->dev), i); |
356 | kfree(thread); | 356 | kfree(thread); |
357 | break; | 357 | break; |
358 | } | 358 | } |
@@ -362,7 +362,7 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan) | |||
362 | list_add_tail(&thread->node, &dtc->threads); | 362 | list_add_tail(&thread->node, &dtc->threads); |
363 | } | 363 | } |
364 | 364 | ||
365 | pr_info("dmatest: Started %u threads using %s\n", i, chan->dev.bus_id); | 365 | pr_info("dmatest: Started %u threads using %s\n", i, dev_name(&chan->dev)); |
366 | 366 | ||
367 | list_add_tail(&dtc->node, &dmatest_channels); | 367 | list_add_tail(&dtc->node, &dmatest_channels); |
368 | nr_channels++; | 368 | nr_channels++; |
@@ -379,7 +379,7 @@ static enum dma_state_client dmatest_remove_channel(struct dma_chan *chan) | |||
379 | list_del(&dtc->node); | 379 | list_del(&dtc->node); |
380 | dmatest_cleanup_channel(dtc); | 380 | dmatest_cleanup_channel(dtc); |
381 | pr_debug("dmatest: lost channel %s\n", | 381 | pr_debug("dmatest: lost channel %s\n", |
382 | chan->dev.bus_id); | 382 | dev_name(&chan->dev)); |
383 | return DMA_ACK; | 383 | return DMA_ACK; |
384 | } | 384 | } |
385 | } | 385 | } |
@@ -418,7 +418,7 @@ dmatest_event(struct dma_client *client, struct dma_chan *chan, | |||
418 | 418 | ||
419 | default: | 419 | default: |
420 | pr_info("dmatest: Unhandled event %u (%s)\n", | 420 | pr_info("dmatest: Unhandled event %u (%s)\n", |
421 | state, chan->dev.bus_id); | 421 | state, dev_name(&chan->dev)); |
422 | break; | 422 | break; |
423 | } | 423 | } |
424 | 424 | ||
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c index 71fba82462cb..c7a9306d951d 100644 --- a/drivers/dma/iop-adma.c +++ b/drivers/dma/iop-adma.c | |||
@@ -411,6 +411,7 @@ iop_adma_tx_submit(struct dma_async_tx_descriptor *tx) | |||
411 | int slot_cnt; | 411 | int slot_cnt; |
412 | int slots_per_op; | 412 | int slots_per_op; |
413 | dma_cookie_t cookie; | 413 | dma_cookie_t cookie; |
414 | dma_addr_t next_dma; | ||
414 | 415 | ||
415 | grp_start = sw_desc->group_head; | 416 | grp_start = sw_desc->group_head; |
416 | slot_cnt = grp_start->slot_cnt; | 417 | slot_cnt = grp_start->slot_cnt; |
@@ -425,12 +426,12 @@ iop_adma_tx_submit(struct dma_async_tx_descriptor *tx) | |||
425 | &old_chain_tail->chain_node); | 426 | &old_chain_tail->chain_node); |
426 | 427 | ||
427 | /* fix up the hardware chain */ | 428 | /* fix up the hardware chain */ |
428 | iop_desc_set_next_desc(old_chain_tail, grp_start->async_tx.phys); | 429 | next_dma = grp_start->async_tx.phys; |
430 | iop_desc_set_next_desc(old_chain_tail, next_dma); | ||
431 | BUG_ON(iop_desc_get_next_desc(old_chain_tail) != next_dma); /* flush */ | ||
429 | 432 | ||
430 | /* 1/ don't add pre-chained descriptors | 433 | /* check for pre-chained descriptors */ |
431 | * 2/ dummy read to flush next_desc write | 434 | iop_paranoia(iop_desc_get_next_desc(sw_desc)); |
432 | */ | ||
433 | BUG_ON(iop_desc_get_next_desc(sw_desc)); | ||
434 | 435 | ||
435 | /* increment the pending count by the number of slots | 436 | /* increment the pending count by the number of slots |
436 | * memcpy operations have a 1:1 (slot:operation) relation | 437 | * memcpy operations have a 1:1 (slot:operation) relation |
diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c index f0d9b415db50..d335086f4a26 100644 --- a/drivers/edac/i5000_edac.c +++ b/drivers/edac/i5000_edac.c | |||
@@ -1381,6 +1381,7 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) | |||
1381 | if (mci == NULL) | 1381 | if (mci == NULL) |
1382 | return -ENOMEM; | 1382 | return -ENOMEM; |
1383 | 1383 | ||
1384 | kobject_get(&mci->edac_mci_kobj); | ||
1384 | debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci); | 1385 | debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci); |
1385 | 1386 | ||
1386 | mci->dev = &pdev->dev; /* record ptr to the generic device */ | 1387 | mci->dev = &pdev->dev; /* record ptr to the generic device */ |
@@ -1453,6 +1454,7 @@ fail1: | |||
1453 | i5000_put_devices(mci); | 1454 | i5000_put_devices(mci); |
1454 | 1455 | ||
1455 | fail0: | 1456 | fail0: |
1457 | kobject_put(&mci->edac_mci_kobj); | ||
1456 | edac_mc_free(mci); | 1458 | edac_mc_free(mci); |
1457 | return -ENODEV; | 1459 | return -ENODEV; |
1458 | } | 1460 | } |
@@ -1498,7 +1500,7 @@ static void __devexit i5000_remove_one(struct pci_dev *pdev) | |||
1498 | 1500 | ||
1499 | /* retrieve references to resources, and free those resources */ | 1501 | /* retrieve references to resources, and free those resources */ |
1500 | i5000_put_devices(mci); | 1502 | i5000_put_devices(mci); |
1501 | 1503 | kobject_put(&mci->edac_mci_kobj); | |
1502 | edac_mc_free(mci); | 1504 | edac_mc_free(mci); |
1503 | } | 1505 | } |
1504 | 1506 | ||
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 7f2ee27fe76b..48f49d93d249 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -65,6 +65,14 @@ config GPIO_SYSFS | |||
65 | 65 | ||
66 | # put expanders in the right section, in alphabetical order | 66 | # put expanders in the right section, in alphabetical order |
67 | 67 | ||
68 | comment "Memory mapped GPIO expanders:" | ||
69 | |||
70 | config GPIO_XILINX | ||
71 | bool "Xilinx GPIO support" | ||
72 | depends on PPC_OF | ||
73 | help | ||
74 | Say yes here to support the Xilinx FPGA GPIO device | ||
75 | |||
68 | comment "I2C GPIO expanders:" | 76 | comment "I2C GPIO expanders:" |
69 | 77 | ||
70 | config GPIO_MAX732X | 78 | config GPIO_MAX732X |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 6aafdeb9ad03..49ac64e515e6 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -10,4 +10,5 @@ obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o | |||
10 | obj-$(CONFIG_GPIO_PCA953X) += pca953x.o | 10 | obj-$(CONFIG_GPIO_PCA953X) += pca953x.o |
11 | obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o | 11 | obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o |
12 | obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o | 12 | obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o |
13 | obj-$(CONFIG_GPIO_XILINX) += xilinx_gpio.o | ||
13 | obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o | 14 | obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o |
diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c new file mode 100644 index 000000000000..3c1177abebd3 --- /dev/null +++ b/drivers/gpio/xilinx_gpio.c | |||
@@ -0,0 +1,235 @@ | |||
1 | /* | ||
2 | * Xilinx gpio driver | ||
3 | * | ||
4 | * Copyright 2008 Xilinx, Inc. | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * You should have received a copy of the GNU General Public License | ||
11 | * along with this program; if not, write to the Free Software | ||
12 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/of_device.h> | ||
18 | #include <linux/of_platform.h> | ||
19 | #include <linux/of_gpio.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <linux/gpio.h> | ||
22 | |||
23 | /* Register Offset Definitions */ | ||
24 | #define XGPIO_DATA_OFFSET (0x0) /* Data register */ | ||
25 | #define XGPIO_TRI_OFFSET (0x4) /* I/O direction register */ | ||
26 | |||
27 | struct xgpio_instance { | ||
28 | struct of_mm_gpio_chip mmchip; | ||
29 | u32 gpio_state; /* GPIO state shadow register */ | ||
30 | u32 gpio_dir; /* GPIO direction shadow register */ | ||
31 | spinlock_t gpio_lock; /* Lock used for synchronization */ | ||
32 | }; | ||
33 | |||
34 | /** | ||
35 | * xgpio_get - Read the specified signal of the GPIO device. | ||
36 | * @gc: Pointer to gpio_chip device structure. | ||
37 | * @gpio: GPIO signal number. | ||
38 | * | ||
39 | * This function reads the specified signal of the GPIO device. It returns 0 if | ||
40 | * the signal clear, 1 if signal is set or negative value on error. | ||
41 | */ | ||
42 | static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) | ||
43 | { | ||
44 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
45 | |||
46 | return (in_be32(mm_gc->regs + XGPIO_DATA_OFFSET) >> gpio) & 1; | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * xgpio_set - Write the specified signal of the GPIO device. | ||
51 | * @gc: Pointer to gpio_chip device structure. | ||
52 | * @gpio: GPIO signal number. | ||
53 | * @val: Value to be written to specified signal. | ||
54 | * | ||
55 | * This function writes the specified value in to the specified signal of the | ||
56 | * GPIO device. | ||
57 | */ | ||
58 | static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | ||
59 | { | ||
60 | unsigned long flags; | ||
61 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
62 | struct xgpio_instance *chip = | ||
63 | container_of(mm_gc, struct xgpio_instance, mmchip); | ||
64 | |||
65 | spin_lock_irqsave(&chip->gpio_lock, flags); | ||
66 | |||
67 | /* Write to GPIO signal and set its direction to output */ | ||
68 | if (val) | ||
69 | chip->gpio_state |= 1 << gpio; | ||
70 | else | ||
71 | chip->gpio_state &= ~(1 << gpio); | ||
72 | out_be32(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state); | ||
73 | |||
74 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * xgpio_dir_in - Set the direction of the specified GPIO signal as input. | ||
79 | * @gc: Pointer to gpio_chip device structure. | ||
80 | * @gpio: GPIO signal number. | ||
81 | * | ||
82 | * This function sets the direction of specified GPIO signal as input. | ||
83 | * It returns 0 if direction of GPIO signals is set as input otherwise it | ||
84 | * returns negative error value. | ||
85 | */ | ||
86 | static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | ||
87 | { | ||
88 | unsigned long flags; | ||
89 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
90 | struct xgpio_instance *chip = | ||
91 | container_of(mm_gc, struct xgpio_instance, mmchip); | ||
92 | |||
93 | spin_lock_irqsave(&chip->gpio_lock, flags); | ||
94 | |||
95 | /* Set the GPIO bit in shadow register and set direction as input */ | ||
96 | chip->gpio_dir |= (1 << gpio); | ||
97 | out_be32(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir); | ||
98 | |||
99 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * xgpio_dir_out - Set the direction of the specified GPIO signal as output. | ||
106 | * @gc: Pointer to gpio_chip device structure. | ||
107 | * @gpio: GPIO signal number. | ||
108 | * @val: Value to be written to specified signal. | ||
109 | * | ||
110 | * This function sets the direction of specified GPIO signal as output. If all | ||
111 | * GPIO signals of GPIO chip is configured as input then it returns | ||
112 | * error otherwise it returns 0. | ||
113 | */ | ||
114 | static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | ||
115 | { | ||
116 | unsigned long flags; | ||
117 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
118 | struct xgpio_instance *chip = | ||
119 | container_of(mm_gc, struct xgpio_instance, mmchip); | ||
120 | |||
121 | spin_lock_irqsave(&chip->gpio_lock, flags); | ||
122 | |||
123 | /* Write state of GPIO signal */ | ||
124 | if (val) | ||
125 | chip->gpio_state |= 1 << gpio; | ||
126 | else | ||
127 | chip->gpio_state &= ~(1 << gpio); | ||
128 | out_be32(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state); | ||
129 | |||
130 | /* Clear the GPIO bit in shadow register and set direction as output */ | ||
131 | chip->gpio_dir &= (~(1 << gpio)); | ||
132 | out_be32(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir); | ||
133 | |||
134 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * xgpio_save_regs - Set initial values of GPIO pins | ||
141 | * @mm_gc: pointer to memory mapped GPIO chip structure | ||
142 | */ | ||
143 | static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) | ||
144 | { | ||
145 | struct xgpio_instance *chip = | ||
146 | container_of(mm_gc, struct xgpio_instance, mmchip); | ||
147 | |||
148 | out_be32(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state); | ||
149 | out_be32(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir); | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * xgpio_of_probe - Probe method for the GPIO device. | ||
154 | * @np: pointer to device tree node | ||
155 | * | ||
156 | * This function probes the GPIO device in the device tree. It initializes the | ||
157 | * driver data structure. It returns 0, if the driver is bound to the GPIO | ||
158 | * device, or a negative value if there is an error. | ||
159 | */ | ||
160 | static int __devinit xgpio_of_probe(struct device_node *np) | ||
161 | { | ||
162 | struct xgpio_instance *chip; | ||
163 | struct of_gpio_chip *ofchip; | ||
164 | int status = 0; | ||
165 | const u32 *tree_info; | ||
166 | |||
167 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
168 | if (!chip) | ||
169 | return -ENOMEM; | ||
170 | ofchip = &chip->mmchip.of_gc; | ||
171 | |||
172 | /* Update GPIO state shadow register with default value */ | ||
173 | tree_info = of_get_property(np, "xlnx,dout-default", NULL); | ||
174 | if (tree_info) | ||
175 | chip->gpio_state = *tree_info; | ||
176 | |||
177 | /* Update GPIO direction shadow register with default value */ | ||
178 | chip->gpio_dir = 0xFFFFFFFF; /* By default, all pins are inputs */ | ||
179 | tree_info = of_get_property(np, "xlnx,tri-default", NULL); | ||
180 | if (tree_info) | ||
181 | chip->gpio_dir = *tree_info; | ||
182 | |||
183 | /* Check device node and parent device node for device width */ | ||
184 | ofchip->gc.ngpio = 32; /* By default assume full GPIO controller */ | ||
185 | tree_info = of_get_property(np, "xlnx,gpio-width", NULL); | ||
186 | if (!tree_info) | ||
187 | tree_info = of_get_property(np->parent, | ||
188 | "xlnx,gpio-width", NULL); | ||
189 | if (tree_info) | ||
190 | ofchip->gc.ngpio = *tree_info; | ||
191 | |||
192 | spin_lock_init(&chip->gpio_lock); | ||
193 | |||
194 | ofchip->gpio_cells = 2; | ||
195 | ofchip->gc.direction_input = xgpio_dir_in; | ||
196 | ofchip->gc.direction_output = xgpio_dir_out; | ||
197 | ofchip->gc.get = xgpio_get; | ||
198 | ofchip->gc.set = xgpio_set; | ||
199 | |||
200 | chip->mmchip.save_regs = xgpio_save_regs; | ||
201 | |||
202 | /* Call the OF gpio helper to setup and register the GPIO device */ | ||
203 | status = of_mm_gpiochip_add(np, &chip->mmchip); | ||
204 | if (status) { | ||
205 | kfree(chip); | ||
206 | pr_err("%s: error in probe function with status %d\n", | ||
207 | np->full_name, status); | ||
208 | return status; | ||
209 | } | ||
210 | pr_info("XGpio: %s: registered\n", np->full_name); | ||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | static struct of_device_id xgpio_of_match[] __devinitdata = { | ||
215 | { .compatible = "xlnx,xps-gpio-1.00.a", }, | ||
216 | { /* end of list */ }, | ||
217 | }; | ||
218 | |||
219 | static int __init xgpio_init(void) | ||
220 | { | ||
221 | struct device_node *np; | ||
222 | |||
223 | for_each_matching_node(np, xgpio_of_match) | ||
224 | xgpio_of_probe(np); | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | /* Make sure we get initialized before anyone else tries to use us */ | ||
230 | subsys_initcall(xgpio_init); | ||
231 | /* No exit call at the moment as we cannot unregister of GPIO chips */ | ||
232 | |||
233 | MODULE_AUTHOR("Xilinx, Inc."); | ||
234 | MODULE_DESCRIPTION("Xilinx GPIO driver"); | ||
235 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index c6ab4ba60c52..9b97795e45ad 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c | |||
@@ -55,10 +55,11 @@ struct apple_key_translation { | |||
55 | 55 | ||
56 | static struct apple_key_translation apple_fn_keys[] = { | 56 | static struct apple_key_translation apple_fn_keys[] = { |
57 | { KEY_BACKSPACE, KEY_DELETE }, | 57 | { KEY_BACKSPACE, KEY_DELETE }, |
58 | { KEY_ENTER, KEY_INSERT }, | ||
58 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | 59 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
59 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | 60 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
60 | { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Exposé */ | 61 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, |
61 | { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */ | 62 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, |
62 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, | 63 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, |
63 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, | 64 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, |
64 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, | 65 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, |
@@ -418,6 +419,12 @@ static const struct hid_device_id apple_devices[] = { | |||
418 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | 419 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
419 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), | 420 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), |
420 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | 421 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
422 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), | ||
423 | .driver_data = APPLE_HAS_FN }, | ||
424 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), | ||
425 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | ||
426 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), | ||
427 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | ||
421 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), | 428 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), |
422 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | 429 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
423 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), | 430 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index d3671b4049c0..147ec591a806 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1250,9 +1250,11 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1250 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, | 1250 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
1251 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, | 1251 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
1252 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, | 1252 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
1253 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, | ||
1254 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, | ||
1255 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, | ||
1253 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1256 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
1254 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1257 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
1255 | { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, | ||
1256 | { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, | 1258 | { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, |
1257 | { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) }, | 1259 | { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) }, |
1258 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, | 1260 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, |
@@ -1265,7 +1267,6 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1265 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, | 1267 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, |
1266 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) }, | 1268 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) }, |
1267 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, | 1269 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, |
1268 | { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, | ||
1269 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, | 1270 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, |
1270 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, | 1271 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, |
1271 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, | 1272 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, |
@@ -1409,6 +1410,7 @@ static const struct hid_device_id hid_ignore_list[] = { | |||
1409 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, | 1410 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, |
1410 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, | 1411 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, |
1411 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)}, | 1412 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)}, |
1413 | { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, | ||
1412 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, | 1414 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, |
1413 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, | 1415 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, |
1414 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, | 1416 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, |
@@ -1486,6 +1488,7 @@ static const struct hid_device_id hid_ignore_list[] = { | |||
1486 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, | 1488 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, |
1487 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, | 1489 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, |
1488 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, | 1490 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, |
1491 | { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, | ||
1489 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, | 1492 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, |
1490 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, | 1493 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, |
1491 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, | 1494 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, |
@@ -1573,6 +1576,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = { | |||
1573 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, | 1576 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
1574 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, | 1577 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
1575 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, | 1578 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
1579 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, | ||
1580 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, | ||
1581 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, | ||
1576 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1582 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
1577 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1583 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
1578 | { } | 1584 | { } |
@@ -1730,7 +1736,7 @@ static int __init hid_init(void) | |||
1730 | goto err_bus; | 1736 | goto err_bus; |
1731 | 1737 | ||
1732 | #ifdef CONFIG_HID_COMPAT | 1738 | #ifdef CONFIG_HID_COMPAT |
1733 | hid_compat_wq = create_workqueue("hid_compat"); | 1739 | hid_compat_wq = create_singlethread_workqueue("hid_compat"); |
1734 | if (!hid_compat_wq) { | 1740 | if (!hid_compat_wq) { |
1735 | hidraw_exit(); | 1741 | hidraw_exit(); |
1736 | goto err; | 1742 | goto err; |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index f05bcbbbb0d5..d70075dd3d81 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -82,6 +82,9 @@ | |||
82 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 | 82 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 |
83 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 | 83 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 |
84 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 | 84 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 |
85 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 | ||
86 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 | ||
87 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 | ||
85 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a | 88 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a |
86 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b | 89 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b |
87 | #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241 | 90 | #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241 |
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 894d52e05bf9..7685ae6808c4 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -38,7 +38,7 @@ static int hidraw_major; | |||
38 | static struct cdev hidraw_cdev; | 38 | static struct cdev hidraw_cdev; |
39 | static struct class *hidraw_class; | 39 | static struct class *hidraw_class; |
40 | static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; | 40 | static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; |
41 | static DEFINE_SPINLOCK(minors_lock); | 41 | static DEFINE_MUTEX(minors_lock); |
42 | 42 | ||
43 | static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) | 43 | static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
44 | { | 44 | { |
@@ -159,13 +159,13 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
159 | struct hidraw_list *list; | 159 | struct hidraw_list *list; |
160 | int err = 0; | 160 | int err = 0; |
161 | 161 | ||
162 | lock_kernel(); | ||
163 | if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { | 162 | if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { |
164 | err = -ENOMEM; | 163 | err = -ENOMEM; |
165 | goto out; | 164 | goto out; |
166 | } | 165 | } |
167 | 166 | ||
168 | spin_lock(&minors_lock); | 167 | lock_kernel(); |
168 | mutex_lock(&minors_lock); | ||
169 | if (!hidraw_table[minor]) { | 169 | if (!hidraw_table[minor]) { |
170 | printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n", | 170 | printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n", |
171 | minor); | 171 | minor); |
@@ -180,13 +180,16 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
180 | file->private_data = list; | 180 | file->private_data = list; |
181 | 181 | ||
182 | dev = hidraw_table[minor]; | 182 | dev = hidraw_table[minor]; |
183 | if (!dev->open++) | 183 | if (!dev->open++) { |
184 | dev->hid->ll_driver->open(dev->hid); | 184 | err = dev->hid->ll_driver->open(dev->hid); |
185 | if (err < 0) | ||
186 | dev->open--; | ||
187 | } | ||
185 | 188 | ||
186 | out_unlock: | 189 | out_unlock: |
187 | spin_unlock(&minors_lock); | 190 | mutex_unlock(&minors_lock); |
188 | out: | ||
189 | unlock_kernel(); | 191 | unlock_kernel(); |
192 | out: | ||
190 | return err; | 193 | return err; |
191 | 194 | ||
192 | } | 195 | } |
@@ -310,7 +313,7 @@ int hidraw_connect(struct hid_device *hid) | |||
310 | 313 | ||
311 | result = -EINVAL; | 314 | result = -EINVAL; |
312 | 315 | ||
313 | spin_lock(&minors_lock); | 316 | mutex_lock(&minors_lock); |
314 | 317 | ||
315 | for (minor = 0; minor < HIDRAW_MAX_DEVICES; minor++) { | 318 | for (minor = 0; minor < HIDRAW_MAX_DEVICES; minor++) { |
316 | if (hidraw_table[minor]) | 319 | if (hidraw_table[minor]) |
@@ -320,9 +323,8 @@ int hidraw_connect(struct hid_device *hid) | |||
320 | break; | 323 | break; |
321 | } | 324 | } |
322 | 325 | ||
323 | spin_unlock(&minors_lock); | ||
324 | |||
325 | if (result) { | 326 | if (result) { |
327 | mutex_unlock(&minors_lock); | ||
326 | kfree(dev); | 328 | kfree(dev); |
327 | goto out; | 329 | goto out; |
328 | } | 330 | } |
@@ -331,14 +333,14 @@ int hidraw_connect(struct hid_device *hid) | |||
331 | NULL, "%s%d", "hidraw", minor); | 333 | NULL, "%s%d", "hidraw", minor); |
332 | 334 | ||
333 | if (IS_ERR(dev->dev)) { | 335 | if (IS_ERR(dev->dev)) { |
334 | spin_lock(&minors_lock); | ||
335 | hidraw_table[minor] = NULL; | 336 | hidraw_table[minor] = NULL; |
336 | spin_unlock(&minors_lock); | 337 | mutex_unlock(&minors_lock); |
337 | result = PTR_ERR(dev->dev); | 338 | result = PTR_ERR(dev->dev); |
338 | kfree(dev); | 339 | kfree(dev); |
339 | goto out; | 340 | goto out; |
340 | } | 341 | } |
341 | 342 | ||
343 | mutex_unlock(&minors_lock); | ||
342 | init_waitqueue_head(&dev->wait); | 344 | init_waitqueue_head(&dev->wait); |
343 | INIT_LIST_HEAD(&dev->list); | 345 | INIT_LIST_HEAD(&dev->list); |
344 | 346 | ||
@@ -360,9 +362,9 @@ void hidraw_disconnect(struct hid_device *hid) | |||
360 | 362 | ||
361 | hidraw->exist = 0; | 363 | hidraw->exist = 0; |
362 | 364 | ||
363 | spin_lock(&minors_lock); | 365 | mutex_lock(&minors_lock); |
364 | hidraw_table[hidraw->minor] = NULL; | 366 | hidraw_table[hidraw->minor] = NULL; |
365 | spin_unlock(&minors_lock); | 367 | mutex_unlock(&minors_lock); |
366 | 368 | ||
367 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); | 369 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); |
368 | 370 | ||
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 18e5ddd722cd..d746bf8284dd 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -781,6 +781,8 @@ static int usbhid_start(struct hid_device *hid) | |||
781 | unsigned int n, insize = 0; | 781 | unsigned int n, insize = 0; |
782 | int ret; | 782 | int ret; |
783 | 783 | ||
784 | clear_bit(HID_DISCONNECTED, &usbhid->iofl); | ||
785 | |||
784 | usbhid->bufsize = HID_MIN_BUFFER_SIZE; | 786 | usbhid->bufsize = HID_MIN_BUFFER_SIZE; |
785 | hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); | 787 | hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); |
786 | hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize); | 788 | hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize); |
@@ -847,12 +849,6 @@ static int usbhid_start(struct hid_device *hid) | |||
847 | } | 849 | } |
848 | } | 850 | } |
849 | 851 | ||
850 | if (!usbhid->urbin) { | ||
851 | err_hid("couldn't find an input interrupt endpoint"); | ||
852 | ret = -ENODEV; | ||
853 | goto fail; | ||
854 | } | ||
855 | |||
856 | init_waitqueue_head(&usbhid->wait); | 852 | init_waitqueue_head(&usbhid->wait); |
857 | INIT_WORK(&usbhid->reset_work, hid_reset); | 853 | INIT_WORK(&usbhid->reset_work, hid_reset); |
858 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | 854 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); |
@@ -888,6 +884,9 @@ fail: | |||
888 | usb_free_urb(usbhid->urbin); | 884 | usb_free_urb(usbhid->urbin); |
889 | usb_free_urb(usbhid->urbout); | 885 | usb_free_urb(usbhid->urbout); |
890 | usb_free_urb(usbhid->urbctrl); | 886 | usb_free_urb(usbhid->urbctrl); |
887 | usbhid->urbin = NULL; | ||
888 | usbhid->urbout = NULL; | ||
889 | usbhid->urbctrl = NULL; | ||
891 | hid_free_buffers(dev, hid); | 890 | hid_free_buffers(dev, hid); |
892 | mutex_unlock(&usbhid->setup); | 891 | mutex_unlock(&usbhid->setup); |
893 | return ret; | 892 | return ret; |
@@ -924,6 +923,9 @@ static void usbhid_stop(struct hid_device *hid) | |||
924 | usb_free_urb(usbhid->urbin); | 923 | usb_free_urb(usbhid->urbin); |
925 | usb_free_urb(usbhid->urbctrl); | 924 | usb_free_urb(usbhid->urbctrl); |
926 | usb_free_urb(usbhid->urbout); | 925 | usb_free_urb(usbhid->urbout); |
926 | usbhid->urbin = NULL; /* don't mess up next start */ | ||
927 | usbhid->urbctrl = NULL; | ||
928 | usbhid->urbout = NULL; | ||
927 | 929 | ||
928 | hid_free_buffers(hid_to_usb_dev(hid), hid); | 930 | hid_free_buffers(hid_to_usb_dev(hid), hid); |
929 | mutex_unlock(&usbhid->setup); | 931 | mutex_unlock(&usbhid->setup); |
@@ -940,15 +942,26 @@ static struct hid_ll_driver usb_hid_driver = { | |||
940 | 942 | ||
941 | static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | 943 | static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) |
942 | { | 944 | { |
945 | struct usb_host_interface *interface = intf->cur_altsetting; | ||
943 | struct usb_device *dev = interface_to_usbdev(intf); | 946 | struct usb_device *dev = interface_to_usbdev(intf); |
944 | struct usbhid_device *usbhid; | 947 | struct usbhid_device *usbhid; |
945 | struct hid_device *hid; | 948 | struct hid_device *hid; |
949 | unsigned int n, has_in = 0; | ||
946 | size_t len; | 950 | size_t len; |
947 | int ret; | 951 | int ret; |
948 | 952 | ||
949 | dbg_hid("HID probe called for ifnum %d\n", | 953 | dbg_hid("HID probe called for ifnum %d\n", |
950 | intf->altsetting->desc.bInterfaceNumber); | 954 | intf->altsetting->desc.bInterfaceNumber); |
951 | 955 | ||
956 | for (n = 0; n < interface->desc.bNumEndpoints; n++) | ||
957 | if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) | ||
958 | has_in++; | ||
959 | if (!has_in) { | ||
960 | dev_err(&intf->dev, "couldn't find an input interrupt " | ||
961 | "endpoint\n"); | ||
962 | return -ENODEV; | ||
963 | } | ||
964 | |||
952 | hid = hid_allocate_device(); | 965 | hid = hid_allocate_device(); |
953 | if (IS_ERR(hid)) | 966 | if (IS_ERR(hid)) |
954 | return PTR_ERR(hid); | 967 | return PTR_ERR(hid); |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 6de1e0ffd391..c709e821f04b 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -159,6 +159,16 @@ config SENSORS_ADM9240 | |||
159 | This driver can also be built as a module. If so, the module | 159 | This driver can also be built as a module. If so, the module |
160 | will be called adm9240. | 160 | will be called adm9240. |
161 | 161 | ||
162 | config SENSORS_ADT7462 | ||
163 | tristate "Analog Devices ADT7462" | ||
164 | depends on I2C && EXPERIMENTAL | ||
165 | help | ||
166 | If you say yes here you get support for the Analog Devices | ||
167 | ADT7462 temperature monitoring chips. | ||
168 | |||
169 | This driver can also be built as a module. If so, the module | ||
170 | will be called adt7462. | ||
171 | |||
162 | config SENSORS_ADT7470 | 172 | config SENSORS_ADT7470 |
163 | tristate "Analog Devices ADT7470" | 173 | tristate "Analog Devices ADT7470" |
164 | depends on I2C && EXPERIMENTAL | 174 | depends on I2C && EXPERIMENTAL |
@@ -825,6 +835,25 @@ config SENSORS_HDAPS | |||
825 | Say Y here if you have an applicable laptop and want to experience | 835 | Say Y here if you have an applicable laptop and want to experience |
826 | the awesome power of hdaps. | 836 | the awesome power of hdaps. |
827 | 837 | ||
838 | config SENSORS_LIS3LV02D | ||
839 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" | ||
840 | depends on ACPI && INPUT | ||
841 | default n | ||
842 | help | ||
843 | This driver provides support for the LIS3LV02Dx accelerometer. In | ||
844 | particular, it can be found in a number of HP laptops, which have the | ||
845 | "Mobile Data Protection System 3D" or "3D DriveGuard" feature. On such | ||
846 | systems the driver should load automatically (via ACPI). The | ||
847 | accelerometer might also be found in other systems, connected via SPI | ||
848 | or I2C. The accelerometer data is readable via | ||
849 | /sys/devices/platform/lis3lv02d. | ||
850 | |||
851 | This driver also provides an absolute input class device, allowing | ||
852 | the laptop to act as a pinball machine-esque joystick. | ||
853 | |||
854 | This driver can also be built as a module. If so, the module | ||
855 | will be called lis3lv02d. | ||
856 | |||
828 | config SENSORS_APPLESMC | 857 | config SENSORS_APPLESMC |
829 | tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" | 858 | tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" |
830 | depends on INPUT && X86 | 859 | depends on INPUT && X86 |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 042d5a78622e..58fc5be5355d 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -25,6 +25,7 @@ obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o | |||
25 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o | 25 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o |
26 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o | 26 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o |
27 | obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o | 27 | obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o |
28 | obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o | ||
28 | obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o | 29 | obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o |
29 | obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o | 30 | obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o |
30 | obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o | 31 | obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o |
@@ -48,6 +49,7 @@ obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o | |||
48 | obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o | 49 | obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o |
49 | obj-$(CONFIG_SENSORS_IT87) += it87.o | 50 | obj-$(CONFIG_SENSORS_IT87) += it87.o |
50 | obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o | 51 | obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o |
52 | obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o | ||
51 | obj-$(CONFIG_SENSORS_LM63) += lm63.o | 53 | obj-$(CONFIG_SENSORS_LM63) += lm63.o |
52 | obj-$(CONFIG_SENSORS_LM70) += lm70.o | 54 | obj-$(CONFIG_SENSORS_LM70) += lm70.o |
53 | obj-$(CONFIG_SENSORS_LM75) += lm75.o | 55 | obj-$(CONFIG_SENSORS_LM75) += lm75.o |
diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c new file mode 100644 index 000000000000..66107b4dc12a --- /dev/null +++ b/drivers/hwmon/adt7462.c | |||
@@ -0,0 +1,2002 @@ | |||
1 | /* | ||
2 | * A hwmon driver for the Analog Devices ADT7462 | ||
3 | * Copyright (C) 2008 IBM | ||
4 | * | ||
5 | * Author: Darrick J. Wong <djwong@us.ibm.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/hwmon.h> | ||
26 | #include <linux/hwmon-sysfs.h> | ||
27 | #include <linux/err.h> | ||
28 | #include <linux/mutex.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/log2.h> | ||
31 | |||
32 | /* Addresses to scan */ | ||
33 | static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END }; | ||
34 | |||
35 | /* Insmod parameters */ | ||
36 | I2C_CLIENT_INSMOD_1(adt7462); | ||
37 | |||
38 | /* ADT7462 registers */ | ||
39 | #define ADT7462_REG_DEVICE 0x3D | ||
40 | #define ADT7462_REG_VENDOR 0x3E | ||
41 | #define ADT7462_REG_REVISION 0x3F | ||
42 | |||
43 | #define ADT7462_REG_MIN_TEMP_BASE_ADDR 0x44 | ||
44 | #define ADT7462_REG_MIN_TEMP_MAX_ADDR 0x47 | ||
45 | #define ADT7462_REG_MAX_TEMP_BASE_ADDR 0x48 | ||
46 | #define ADT7462_REG_MAX_TEMP_MAX_ADDR 0x4B | ||
47 | #define ADT7462_REG_TEMP_BASE_ADDR 0x88 | ||
48 | #define ADT7462_REG_TEMP_MAX_ADDR 0x8F | ||
49 | |||
50 | #define ADT7462_REG_FAN_BASE_ADDR 0x98 | ||
51 | #define ADT7462_REG_FAN_MAX_ADDR 0x9F | ||
52 | #define ADT7462_REG_FAN2_BASE_ADDR 0xA2 | ||
53 | #define ADT7462_REG_FAN2_MAX_ADDR 0xA9 | ||
54 | #define ADT7462_REG_FAN_ENABLE 0x07 | ||
55 | #define ADT7462_REG_FAN_MIN_BASE_ADDR 0x78 | ||
56 | #define ADT7462_REG_FAN_MIN_MAX_ADDR 0x7F | ||
57 | |||
58 | #define ADT7462_REG_CFG2 0x02 | ||
59 | #define ADT7462_FSPD_MASK 0x20 | ||
60 | |||
61 | #define ADT7462_REG_PWM_BASE_ADDR 0xAA | ||
62 | #define ADT7462_REG_PWM_MAX_ADDR 0xAD | ||
63 | #define ADT7462_REG_PWM_MIN_BASE_ADDR 0x28 | ||
64 | #define ADT7462_REG_PWM_MIN_MAX_ADDR 0x2B | ||
65 | #define ADT7462_REG_PWM_MAX 0x2C | ||
66 | #define ADT7462_REG_PWM_TEMP_MIN_BASE_ADDR 0x5C | ||
67 | #define ADT7462_REG_PWM_TEMP_MIN_MAX_ADDR 0x5F | ||
68 | #define ADT7462_REG_PWM_TEMP_RANGE_BASE_ADDR 0x60 | ||
69 | #define ADT7462_REG_PWM_TEMP_RANGE_MAX_ADDR 0x63 | ||
70 | #define ADT7462_PWM_HYST_MASK 0x0F | ||
71 | #define ADT7462_PWM_RANGE_MASK 0xF0 | ||
72 | #define ADT7462_PWM_RANGE_SHIFT 4 | ||
73 | #define ADT7462_REG_PWM_CFG_BASE_ADDR 0x21 | ||
74 | #define ADT7462_REG_PWM_CFG_MAX_ADDR 0x24 | ||
75 | #define ADT7462_PWM_CHANNEL_MASK 0xE0 | ||
76 | #define ADT7462_PWM_CHANNEL_SHIFT 5 | ||
77 | |||
78 | #define ADT7462_REG_PIN_CFG_BASE_ADDR 0x10 | ||
79 | #define ADT7462_REG_PIN_CFG_MAX_ADDR 0x13 | ||
80 | #define ADT7462_PIN7_INPUT 0x01 /* cfg0 */ | ||
81 | #define ADT7462_DIODE3_INPUT 0x20 | ||
82 | #define ADT7462_DIODE1_INPUT 0x40 | ||
83 | #define ADT7462_VID_INPUT 0x80 | ||
84 | #define ADT7462_PIN22_INPUT 0x04 /* cfg1 */ | ||
85 | #define ADT7462_PIN21_INPUT 0x08 | ||
86 | #define ADT7462_PIN19_INPUT 0x10 | ||
87 | #define ADT7462_PIN15_INPUT 0x20 | ||
88 | #define ADT7462_PIN13_INPUT 0x40 | ||
89 | #define ADT7462_PIN8_INPUT 0x80 | ||
90 | #define ADT7462_PIN23_MASK 0x03 | ||
91 | #define ADT7462_PIN23_SHIFT 0 | ||
92 | #define ADT7462_PIN26_MASK 0x0C /* cfg2 */ | ||
93 | #define ADT7462_PIN26_SHIFT 2 | ||
94 | #define ADT7462_PIN25_MASK 0x30 | ||
95 | #define ADT7462_PIN25_SHIFT 4 | ||
96 | #define ADT7462_PIN24_MASK 0xC0 | ||
97 | #define ADT7462_PIN24_SHIFT 6 | ||
98 | #define ADT7462_PIN26_VOLT_INPUT 0x08 | ||
99 | #define ADT7462_PIN25_VOLT_INPUT 0x20 | ||
100 | #define ADT7462_PIN28_SHIFT 6 /* cfg3 */ | ||
101 | #define ADT7462_PIN28_VOLT 0x5 | ||
102 | |||
103 | #define ADT7462_REG_ALARM1 0xB8 | ||
104 | #define ADT7462_LT_ALARM 0x02 | ||
105 | #define ADT7462_R1T_ALARM 0x04 | ||
106 | #define ADT7462_R2T_ALARM 0x08 | ||
107 | #define ADT7462_R3T_ALARM 0x10 | ||
108 | #define ADT7462_REG_ALARM2 0xBB | ||
109 | #define ADT7462_V0_ALARM 0x01 | ||
110 | #define ADT7462_V1_ALARM 0x02 | ||
111 | #define ADT7462_V2_ALARM 0x04 | ||
112 | #define ADT7462_V3_ALARM 0x08 | ||
113 | #define ADT7462_V4_ALARM 0x10 | ||
114 | #define ADT7462_V5_ALARM 0x20 | ||
115 | #define ADT7462_V6_ALARM 0x40 | ||
116 | #define ADT7462_V7_ALARM 0x80 | ||
117 | #define ADT7462_REG_ALARM3 0xBC | ||
118 | #define ADT7462_V8_ALARM 0x08 | ||
119 | #define ADT7462_V9_ALARM 0x10 | ||
120 | #define ADT7462_V10_ALARM 0x20 | ||
121 | #define ADT7462_V11_ALARM 0x40 | ||
122 | #define ADT7462_V12_ALARM 0x80 | ||
123 | #define ADT7462_REG_ALARM4 0xBD | ||
124 | #define ADT7462_F0_ALARM 0x01 | ||
125 | #define ADT7462_F1_ALARM 0x02 | ||
126 | #define ADT7462_F2_ALARM 0x04 | ||
127 | #define ADT7462_F3_ALARM 0x08 | ||
128 | #define ADT7462_F4_ALARM 0x10 | ||
129 | #define ADT7462_F5_ALARM 0x20 | ||
130 | #define ADT7462_F6_ALARM 0x40 | ||
131 | #define ADT7462_F7_ALARM 0x80 | ||
132 | #define ADT7462_ALARM1 0x0000 | ||
133 | #define ADT7462_ALARM2 0x0100 | ||
134 | #define ADT7462_ALARM3 0x0200 | ||
135 | #define ADT7462_ALARM4 0x0300 | ||
136 | #define ADT7462_ALARM_REG_SHIFT 8 | ||
137 | #define ADT7462_ALARM_FLAG_MASK 0x0F | ||
138 | |||
139 | #define ADT7462_TEMP_COUNT 4 | ||
140 | #define ADT7462_TEMP_REG(x) (ADT7462_REG_TEMP_BASE_ADDR + (x * 2)) | ||
141 | #define ADT7462_TEMP_MIN_REG(x) (ADT7462_REG_MIN_TEMP_BASE_ADDR + (x)) | ||
142 | #define ADT7462_TEMP_MAX_REG(x) (ADT7462_REG_MAX_TEMP_BASE_ADDR + (x)) | ||
143 | #define TEMP_FRAC_OFFSET 6 | ||
144 | |||
145 | #define ADT7462_FAN_COUNT 8 | ||
146 | #define ADT7462_REG_FAN_MIN(x) (ADT7462_REG_FAN_MIN_BASE_ADDR + (x)) | ||
147 | |||
148 | #define ADT7462_PWM_COUNT 4 | ||
149 | #define ADT7462_REG_PWM(x) (ADT7462_REG_PWM_BASE_ADDR + (x)) | ||
150 | #define ADT7462_REG_PWM_MIN(x) (ADT7462_REG_PWM_MIN_BASE_ADDR + (x)) | ||
151 | #define ADT7462_REG_PWM_TMIN(x) \ | ||
152 | (ADT7462_REG_PWM_TEMP_MIN_BASE_ADDR + (x)) | ||
153 | #define ADT7462_REG_PWM_TRANGE(x) \ | ||
154 | (ADT7462_REG_PWM_TEMP_RANGE_BASE_ADDR + (x)) | ||
155 | |||
156 | #define ADT7462_PIN_CFG_REG_COUNT 4 | ||
157 | #define ADT7462_REG_PIN_CFG(x) (ADT7462_REG_PIN_CFG_BASE_ADDR + (x)) | ||
158 | #define ADT7462_REG_PWM_CFG(x) (ADT7462_REG_PWM_CFG_BASE_ADDR + (x)) | ||
159 | |||
160 | #define ADT7462_ALARM_REG_COUNT 4 | ||
161 | |||
162 | /* | ||
163 | * The chip can measure 13 different voltage sources: | ||
164 | * | ||
165 | * 1. +12V1 (pin 7) | ||
166 | * 2. Vccp1/+2.5V/+1.8V/+1.5V (pin 23) | ||
167 | * 3. +12V3 (pin 22) | ||
168 | * 4. +5V (pin 21) | ||
169 | * 5. +1.25V/+0.9V (pin 19) | ||
170 | * 6. +2.5V/+1.8V (pin 15) | ||
171 | * 7. +3.3v (pin 13) | ||
172 | * 8. +12V2 (pin 8) | ||
173 | * 9. Vbatt/FSB_Vtt (pin 26) | ||
174 | * A. +3.3V/+1.2V1 (pin 25) | ||
175 | * B. Vccp2/+2.5V/+1.8V/+1.5V (pin 24) | ||
176 | * C. +1.5V ICH (only if BOTH pin 28/29 are set to +1.5V) | ||
177 | * D. +1.5V 3GPIO (only if BOTH pin 28/29 are set to +1.5V) | ||
178 | * | ||
179 | * Each of these 13 has a factor to convert raw to voltage. Even better, | ||
180 | * the pins can be connected to other sensors (tach/gpio/hot/etc), which | ||
181 | * makes the bookkeeping tricky. | ||
182 | * | ||
183 | * Some, but not all, of these voltages have low/high limits. | ||
184 | */ | ||
185 | #define ADT7462_VOLT_COUNT 12 | ||
186 | |||
187 | #define ADT7462_VENDOR 0x41 | ||
188 | #define ADT7462_DEVICE 0x62 | ||
189 | /* datasheet only mentions a revision 4 */ | ||
190 | #define ADT7462_REVISION 0x04 | ||
191 | |||
192 | /* How often do we reread sensors values? (In jiffies) */ | ||
193 | #define SENSOR_REFRESH_INTERVAL (2 * HZ) | ||
194 | |||
195 | /* How often do we reread sensor limit values? (In jiffies) */ | ||
196 | #define LIMIT_REFRESH_INTERVAL (60 * HZ) | ||
197 | |||
198 | /* datasheet says to divide this number by the fan reading to get fan rpm */ | ||
199 | #define FAN_PERIOD_TO_RPM(x) ((90000 * 60) / (x)) | ||
200 | #define FAN_RPM_TO_PERIOD FAN_PERIOD_TO_RPM | ||
201 | #define FAN_PERIOD_INVALID 65535 | ||
202 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) | ||
203 | |||
204 | #define MASK_AND_SHIFT(value, prefix) \ | ||
205 | (((value) & prefix##_MASK) >> prefix##_SHIFT) | ||
206 | |||
207 | #define ROUND_DIV(x, divisor) (((x) + ((divisor) / 2)) / (divisor)) | ||
208 | |||
209 | struct adt7462_data { | ||
210 | struct device *hwmon_dev; | ||
211 | struct attribute_group attrs; | ||
212 | struct mutex lock; | ||
213 | char sensors_valid; | ||
214 | char limits_valid; | ||
215 | unsigned long sensors_last_updated; /* In jiffies */ | ||
216 | unsigned long limits_last_updated; /* In jiffies */ | ||
217 | |||
218 | u8 temp[ADT7462_TEMP_COUNT]; | ||
219 | /* bits 6-7 are quarter pieces of temp */ | ||
220 | u8 temp_frac[ADT7462_TEMP_COUNT]; | ||
221 | u8 temp_min[ADT7462_TEMP_COUNT]; | ||
222 | u8 temp_max[ADT7462_TEMP_COUNT]; | ||
223 | u16 fan[ADT7462_FAN_COUNT]; | ||
224 | u8 fan_enabled; | ||
225 | u8 fan_min[ADT7462_FAN_COUNT]; | ||
226 | u8 cfg2; | ||
227 | u8 pwm[ADT7462_PWM_COUNT]; | ||
228 | u8 pin_cfg[ADT7462_PIN_CFG_REG_COUNT]; | ||
229 | u8 voltages[ADT7462_VOLT_COUNT]; | ||
230 | u8 volt_max[ADT7462_VOLT_COUNT]; | ||
231 | u8 volt_min[ADT7462_VOLT_COUNT]; | ||
232 | u8 pwm_min[ADT7462_PWM_COUNT]; | ||
233 | u8 pwm_tmin[ADT7462_PWM_COUNT]; | ||
234 | u8 pwm_trange[ADT7462_PWM_COUNT]; | ||
235 | u8 pwm_max; /* only one per chip */ | ||
236 | u8 pwm_cfg[ADT7462_PWM_COUNT]; | ||
237 | u8 alarms[ADT7462_ALARM_REG_COUNT]; | ||
238 | }; | ||
239 | |||
240 | static int adt7462_probe(struct i2c_client *client, | ||
241 | const struct i2c_device_id *id); | ||
242 | static int adt7462_detect(struct i2c_client *client, int kind, | ||
243 | struct i2c_board_info *info); | ||
244 | static int adt7462_remove(struct i2c_client *client); | ||
245 | |||
246 | static const struct i2c_device_id adt7462_id[] = { | ||
247 | { "adt7462", adt7462 }, | ||
248 | { } | ||
249 | }; | ||
250 | MODULE_DEVICE_TABLE(i2c, adt7462_id); | ||
251 | |||
252 | static struct i2c_driver adt7462_driver = { | ||
253 | .class = I2C_CLASS_HWMON, | ||
254 | .driver = { | ||
255 | .name = "adt7462", | ||
256 | }, | ||
257 | .probe = adt7462_probe, | ||
258 | .remove = adt7462_remove, | ||
259 | .id_table = adt7462_id, | ||
260 | .detect = adt7462_detect, | ||
261 | .address_data = &addr_data, | ||
262 | }; | ||
263 | |||
264 | /* | ||
265 | * 16-bit registers on the ADT7462 are low-byte first. The data sheet says | ||
266 | * that the low byte must be read before the high byte. | ||
267 | */ | ||
268 | static inline int adt7462_read_word_data(struct i2c_client *client, u8 reg) | ||
269 | { | ||
270 | u16 foo; | ||
271 | foo = i2c_smbus_read_byte_data(client, reg); | ||
272 | foo |= ((u16)i2c_smbus_read_byte_data(client, reg + 1) << 8); | ||
273 | return foo; | ||
274 | } | ||
275 | |||
276 | /* For some reason these registers are not contiguous. */ | ||
277 | static int ADT7462_REG_FAN(int fan) | ||
278 | { | ||
279 | if (fan < 4) | ||
280 | return ADT7462_REG_FAN_BASE_ADDR + (2 * fan); | ||
281 | return ADT7462_REG_FAN2_BASE_ADDR + (2 * (fan - 4)); | ||
282 | } | ||
283 | |||
284 | /* Voltage registers are scattered everywhere */ | ||
285 | static int ADT7462_REG_VOLT_MAX(struct adt7462_data *data, int which) | ||
286 | { | ||
287 | switch (which) { | ||
288 | case 0: | ||
289 | if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) | ||
290 | return 0x7C; | ||
291 | break; | ||
292 | case 1: | ||
293 | return 0x69; | ||
294 | case 2: | ||
295 | if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) | ||
296 | return 0x7F; | ||
297 | break; | ||
298 | case 3: | ||
299 | if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) | ||
300 | return 0x7E; | ||
301 | break; | ||
302 | case 4: | ||
303 | if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) | ||
304 | return 0x4B; | ||
305 | break; | ||
306 | case 5: | ||
307 | if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) | ||
308 | return 0x49; | ||
309 | break; | ||
310 | case 6: | ||
311 | if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) | ||
312 | return 0x68; | ||
313 | break; | ||
314 | case 7: | ||
315 | if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) | ||
316 | return 0x7D; | ||
317 | break; | ||
318 | case 8: | ||
319 | if (!(data->pin_cfg[2] & ADT7462_PIN26_VOLT_INPUT)) | ||
320 | return 0x6C; | ||
321 | break; | ||
322 | case 9: | ||
323 | if (!(data->pin_cfg[2] & ADT7462_PIN25_VOLT_INPUT)) | ||
324 | return 0x6B; | ||
325 | break; | ||
326 | case 10: | ||
327 | return 0x6A; | ||
328 | case 11: | ||
329 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
330 | ADT7462_PIN28_VOLT && | ||
331 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
332 | return 0x50; | ||
333 | break; | ||
334 | case 12: | ||
335 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
336 | ADT7462_PIN28_VOLT && | ||
337 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
338 | return 0x4C; | ||
339 | break; | ||
340 | } | ||
341 | return -ENODEV; | ||
342 | } | ||
343 | |||
344 | static int ADT7462_REG_VOLT_MIN(struct adt7462_data *data, int which) | ||
345 | { | ||
346 | switch (which) { | ||
347 | case 0: | ||
348 | if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) | ||
349 | return 0x6D; | ||
350 | break; | ||
351 | case 1: | ||
352 | return 0x72; | ||
353 | case 2: | ||
354 | if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) | ||
355 | return 0x6F; | ||
356 | break; | ||
357 | case 3: | ||
358 | if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) | ||
359 | return 0x71; | ||
360 | break; | ||
361 | case 4: | ||
362 | if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) | ||
363 | return 0x47; | ||
364 | break; | ||
365 | case 5: | ||
366 | if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) | ||
367 | return 0x45; | ||
368 | break; | ||
369 | case 6: | ||
370 | if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) | ||
371 | return 0x70; | ||
372 | break; | ||
373 | case 7: | ||
374 | if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) | ||
375 | return 0x6E; | ||
376 | break; | ||
377 | case 8: | ||
378 | if (!(data->pin_cfg[2] & ADT7462_PIN26_VOLT_INPUT)) | ||
379 | return 0x75; | ||
380 | break; | ||
381 | case 9: | ||
382 | if (!(data->pin_cfg[2] & ADT7462_PIN25_VOLT_INPUT)) | ||
383 | return 0x74; | ||
384 | break; | ||
385 | case 10: | ||
386 | return 0x73; | ||
387 | case 11: | ||
388 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
389 | ADT7462_PIN28_VOLT && | ||
390 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
391 | return 0x76; | ||
392 | break; | ||
393 | case 12: | ||
394 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
395 | ADT7462_PIN28_VOLT && | ||
396 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
397 | return 0x77; | ||
398 | break; | ||
399 | } | ||
400 | return -ENODEV; | ||
401 | } | ||
402 | |||
403 | static int ADT7462_REG_VOLT(struct adt7462_data *data, int which) | ||
404 | { | ||
405 | switch (which) { | ||
406 | case 0: | ||
407 | if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) | ||
408 | return 0xA3; | ||
409 | break; | ||
410 | case 1: | ||
411 | return 0x90; | ||
412 | case 2: | ||
413 | if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) | ||
414 | return 0xA9; | ||
415 | break; | ||
416 | case 3: | ||
417 | if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) | ||
418 | return 0xA7; | ||
419 | break; | ||
420 | case 4: | ||
421 | if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) | ||
422 | return 0x8F; | ||
423 | break; | ||
424 | case 5: | ||
425 | if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) | ||
426 | return 0x8B; | ||
427 | break; | ||
428 | case 6: | ||
429 | if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) | ||
430 | return 0x96; | ||
431 | break; | ||
432 | case 7: | ||
433 | if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) | ||
434 | return 0xA5; | ||
435 | break; | ||
436 | case 8: | ||
437 | if (!(data->pin_cfg[2] & ADT7462_PIN26_VOLT_INPUT)) | ||
438 | return 0x93; | ||
439 | break; | ||
440 | case 9: | ||
441 | if (!(data->pin_cfg[2] & ADT7462_PIN25_VOLT_INPUT)) | ||
442 | return 0x92; | ||
443 | break; | ||
444 | case 10: | ||
445 | return 0x91; | ||
446 | case 11: | ||
447 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
448 | ADT7462_PIN28_VOLT && | ||
449 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
450 | return 0x94; | ||
451 | break; | ||
452 | case 12: | ||
453 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
454 | ADT7462_PIN28_VOLT && | ||
455 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
456 | return 0x95; | ||
457 | break; | ||
458 | } | ||
459 | return -ENODEV; | ||
460 | } | ||
461 | |||
462 | /* Provide labels for sysfs */ | ||
463 | static const char *voltage_label(struct adt7462_data *data, int which) | ||
464 | { | ||
465 | switch (which) { | ||
466 | case 0: | ||
467 | if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) | ||
468 | return "+12V1"; | ||
469 | break; | ||
470 | case 1: | ||
471 | switch (MASK_AND_SHIFT(data->pin_cfg[1], ADT7462_PIN23)) { | ||
472 | case 0: | ||
473 | return "Vccp1"; | ||
474 | case 1: | ||
475 | return "+2.5V"; | ||
476 | case 2: | ||
477 | return "+1.8V"; | ||
478 | case 3: | ||
479 | return "+1.5V"; | ||
480 | } | ||
481 | case 2: | ||
482 | if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) | ||
483 | return "+12V3"; | ||
484 | break; | ||
485 | case 3: | ||
486 | if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) | ||
487 | return "+5V"; | ||
488 | break; | ||
489 | case 4: | ||
490 | if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) { | ||
491 | if (data->pin_cfg[1] & ADT7462_PIN19_INPUT) | ||
492 | return "+0.9V"; | ||
493 | return "+1.25V"; | ||
494 | } | ||
495 | break; | ||
496 | case 5: | ||
497 | if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) { | ||
498 | if (data->pin_cfg[1] & ADT7462_PIN19_INPUT) | ||
499 | return "+1.8V"; | ||
500 | return "+2.5V"; | ||
501 | } | ||
502 | break; | ||
503 | case 6: | ||
504 | if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) | ||
505 | return "+3.3V"; | ||
506 | break; | ||
507 | case 7: | ||
508 | if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) | ||
509 | return "+12V2"; | ||
510 | break; | ||
511 | case 8: | ||
512 | switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN26)) { | ||
513 | case 0: | ||
514 | return "Vbatt"; | ||
515 | case 1: | ||
516 | return "FSB_Vtt"; | ||
517 | } | ||
518 | break; | ||
519 | case 9: | ||
520 | switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN25)) { | ||
521 | case 0: | ||
522 | return "+3.3V"; | ||
523 | case 1: | ||
524 | return "+1.2V1"; | ||
525 | } | ||
526 | break; | ||
527 | case 10: | ||
528 | switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN24)) { | ||
529 | case 0: | ||
530 | return "Vccp2"; | ||
531 | case 1: | ||
532 | return "+2.5V"; | ||
533 | case 2: | ||
534 | return "+1.8V"; | ||
535 | case 3: | ||
536 | return "+1.5"; | ||
537 | } | ||
538 | case 11: | ||
539 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
540 | ADT7462_PIN28_VOLT && | ||
541 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
542 | return "+1.5V ICH"; | ||
543 | break; | ||
544 | case 12: | ||
545 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
546 | ADT7462_PIN28_VOLT && | ||
547 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
548 | return "+1.5V 3GPIO"; | ||
549 | break; | ||
550 | } | ||
551 | return "N/A"; | ||
552 | } | ||
553 | |||
554 | /* Multipliers are actually in uV, not mV. */ | ||
555 | static int voltage_multiplier(struct adt7462_data *data, int which) | ||
556 | { | ||
557 | switch (which) { | ||
558 | case 0: | ||
559 | if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT)) | ||
560 | return 62500; | ||
561 | break; | ||
562 | case 1: | ||
563 | switch (MASK_AND_SHIFT(data->pin_cfg[1], ADT7462_PIN23)) { | ||
564 | case 0: | ||
565 | if (data->pin_cfg[0] & ADT7462_VID_INPUT) | ||
566 | return 12500; | ||
567 | return 6250; | ||
568 | case 1: | ||
569 | return 13000; | ||
570 | case 2: | ||
571 | return 9400; | ||
572 | case 3: | ||
573 | return 7800; | ||
574 | } | ||
575 | case 2: | ||
576 | if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) | ||
577 | return 62500; | ||
578 | break; | ||
579 | case 3: | ||
580 | if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT)) | ||
581 | return 26000; | ||
582 | break; | ||
583 | case 4: | ||
584 | if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT)) { | ||
585 | if (data->pin_cfg[1] & ADT7462_PIN19_INPUT) | ||
586 | return 4690; | ||
587 | return 6500; | ||
588 | } | ||
589 | break; | ||
590 | case 5: | ||
591 | if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT)) { | ||
592 | if (data->pin_cfg[1] & ADT7462_PIN15_INPUT) | ||
593 | return 9400; | ||
594 | return 13000; | ||
595 | } | ||
596 | break; | ||
597 | case 6: | ||
598 | if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT)) | ||
599 | return 17200; | ||
600 | break; | ||
601 | case 7: | ||
602 | if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT)) | ||
603 | return 62500; | ||
604 | break; | ||
605 | case 8: | ||
606 | switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN26)) { | ||
607 | case 0: | ||
608 | return 15600; | ||
609 | case 1: | ||
610 | return 6250; | ||
611 | } | ||
612 | break; | ||
613 | case 9: | ||
614 | switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN25)) { | ||
615 | case 0: | ||
616 | return 17200; | ||
617 | case 1: | ||
618 | return 6250; | ||
619 | } | ||
620 | break; | ||
621 | case 10: | ||
622 | switch (MASK_AND_SHIFT(data->pin_cfg[2], ADT7462_PIN24)) { | ||
623 | case 0: | ||
624 | return 6250; | ||
625 | case 1: | ||
626 | return 13000; | ||
627 | case 2: | ||
628 | return 9400; | ||
629 | case 3: | ||
630 | return 7800; | ||
631 | } | ||
632 | case 11: | ||
633 | case 12: | ||
634 | if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == | ||
635 | ADT7462_PIN28_VOLT && | ||
636 | !(data->pin_cfg[0] & ADT7462_VID_INPUT)) | ||
637 | return 7800; | ||
638 | } | ||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | static int temp_enabled(struct adt7462_data *data, int which) | ||
643 | { | ||
644 | switch (which) { | ||
645 | case 0: | ||
646 | case 2: | ||
647 | return 1; | ||
648 | case 1: | ||
649 | if (data->pin_cfg[0] & ADT7462_DIODE1_INPUT) | ||
650 | return 1; | ||
651 | break; | ||
652 | case 3: | ||
653 | if (data->pin_cfg[0] & ADT7462_DIODE3_INPUT) | ||
654 | return 1; | ||
655 | break; | ||
656 | } | ||
657 | return 0; | ||
658 | } | ||
659 | |||
660 | static const char *temp_label(struct adt7462_data *data, int which) | ||
661 | { | ||
662 | switch (which) { | ||
663 | case 0: | ||
664 | return "local"; | ||
665 | case 1: | ||
666 | if (data->pin_cfg[0] & ADT7462_DIODE1_INPUT) | ||
667 | return "remote1"; | ||
668 | break; | ||
669 | case 2: | ||
670 | return "remote2"; | ||
671 | case 3: | ||
672 | if (data->pin_cfg[0] & ADT7462_DIODE3_INPUT) | ||
673 | return "remote3"; | ||
674 | break; | ||
675 | } | ||
676 | return "N/A"; | ||
677 | } | ||
678 | |||
679 | /* Map Trange register values to mC */ | ||
680 | #define NUM_TRANGE_VALUES 16 | ||
681 | static const int trange_values[NUM_TRANGE_VALUES] = { | ||
682 | 2000, | ||
683 | 2500, | ||
684 | 3300, | ||
685 | 4000, | ||
686 | 5000, | ||
687 | 6700, | ||
688 | 8000, | ||
689 | 10000, | ||
690 | 13300, | ||
691 | 16000, | ||
692 | 20000, | ||
693 | 26700, | ||
694 | 32000, | ||
695 | 40000, | ||
696 | 53300, | ||
697 | 80000 | ||
698 | }; | ||
699 | |||
700 | static int find_trange_value(int trange) | ||
701 | { | ||
702 | int i; | ||
703 | |||
704 | for (i = 0; i < NUM_TRANGE_VALUES; i++) | ||
705 | if (trange_values[i] == trange) | ||
706 | return i; | ||
707 | |||
708 | return -ENODEV; | ||
709 | } | ||
710 | |||
711 | static struct adt7462_data *adt7462_update_device(struct device *dev) | ||
712 | { | ||
713 | struct i2c_client *client = to_i2c_client(dev); | ||
714 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
715 | unsigned long local_jiffies = jiffies; | ||
716 | int i; | ||
717 | |||
718 | mutex_lock(&data->lock); | ||
719 | if (time_before(local_jiffies, data->sensors_last_updated + | ||
720 | SENSOR_REFRESH_INTERVAL) | ||
721 | && data->sensors_valid) | ||
722 | goto no_sensor_update; | ||
723 | |||
724 | for (i = 0; i < ADT7462_TEMP_COUNT; i++) { | ||
725 | /* | ||
726 | * Reading the fractional register locks the integral | ||
727 | * register until both have been read. | ||
728 | */ | ||
729 | data->temp_frac[i] = i2c_smbus_read_byte_data(client, | ||
730 | ADT7462_TEMP_REG(i)); | ||
731 | data->temp[i] = i2c_smbus_read_byte_data(client, | ||
732 | ADT7462_TEMP_REG(i) + 1); | ||
733 | } | ||
734 | |||
735 | for (i = 0; i < ADT7462_FAN_COUNT; i++) | ||
736 | data->fan[i] = adt7462_read_word_data(client, | ||
737 | ADT7462_REG_FAN(i)); | ||
738 | |||
739 | data->fan_enabled = i2c_smbus_read_byte_data(client, | ||
740 | ADT7462_REG_FAN_ENABLE); | ||
741 | |||
742 | for (i = 0; i < ADT7462_PWM_COUNT; i++) | ||
743 | data->pwm[i] = i2c_smbus_read_byte_data(client, | ||
744 | ADT7462_REG_PWM(i)); | ||
745 | |||
746 | for (i = 0; i < ADT7462_PIN_CFG_REG_COUNT; i++) | ||
747 | data->pin_cfg[i] = i2c_smbus_read_byte_data(client, | ||
748 | ADT7462_REG_PIN_CFG(i)); | ||
749 | |||
750 | for (i = 0; i < ADT7462_VOLT_COUNT; i++) { | ||
751 | int reg = ADT7462_REG_VOLT(data, i); | ||
752 | if (!reg) | ||
753 | data->voltages[i] = 0; | ||
754 | else | ||
755 | data->voltages[i] = i2c_smbus_read_byte_data(client, | ||
756 | reg); | ||
757 | } | ||
758 | |||
759 | data->alarms[0] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM1); | ||
760 | data->alarms[1] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM2); | ||
761 | data->alarms[2] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM3); | ||
762 | data->alarms[3] = i2c_smbus_read_byte_data(client, ADT7462_REG_ALARM4); | ||
763 | |||
764 | data->sensors_last_updated = local_jiffies; | ||
765 | data->sensors_valid = 1; | ||
766 | |||
767 | no_sensor_update: | ||
768 | if (time_before(local_jiffies, data->limits_last_updated + | ||
769 | LIMIT_REFRESH_INTERVAL) | ||
770 | && data->limits_valid) | ||
771 | goto out; | ||
772 | |||
773 | for (i = 0; i < ADT7462_TEMP_COUNT; i++) { | ||
774 | data->temp_min[i] = i2c_smbus_read_byte_data(client, | ||
775 | ADT7462_TEMP_MIN_REG(i)); | ||
776 | data->temp_max[i] = i2c_smbus_read_byte_data(client, | ||
777 | ADT7462_TEMP_MAX_REG(i)); | ||
778 | } | ||
779 | |||
780 | for (i = 0; i < ADT7462_FAN_COUNT; i++) | ||
781 | data->fan_min[i] = i2c_smbus_read_byte_data(client, | ||
782 | ADT7462_REG_FAN_MIN(i)); | ||
783 | |||
784 | for (i = 0; i < ADT7462_VOLT_COUNT; i++) { | ||
785 | int reg = ADT7462_REG_VOLT_MAX(data, i); | ||
786 | data->volt_max[i] = | ||
787 | (reg ? i2c_smbus_read_byte_data(client, reg) : 0); | ||
788 | |||
789 | reg = ADT7462_REG_VOLT_MIN(data, i); | ||
790 | data->volt_min[i] = | ||
791 | (reg ? i2c_smbus_read_byte_data(client, reg) : 0); | ||
792 | } | ||
793 | |||
794 | for (i = 0; i < ADT7462_PWM_COUNT; i++) { | ||
795 | data->pwm_min[i] = i2c_smbus_read_byte_data(client, | ||
796 | ADT7462_REG_PWM_MIN(i)); | ||
797 | data->pwm_tmin[i] = i2c_smbus_read_byte_data(client, | ||
798 | ADT7462_REG_PWM_TMIN(i)); | ||
799 | data->pwm_trange[i] = i2c_smbus_read_byte_data(client, | ||
800 | ADT7462_REG_PWM_TRANGE(i)); | ||
801 | data->pwm_cfg[i] = i2c_smbus_read_byte_data(client, | ||
802 | ADT7462_REG_PWM_CFG(i)); | ||
803 | } | ||
804 | |||
805 | data->pwm_max = i2c_smbus_read_byte_data(client, ADT7462_REG_PWM_MAX); | ||
806 | |||
807 | data->cfg2 = i2c_smbus_read_byte_data(client, ADT7462_REG_CFG2); | ||
808 | |||
809 | data->limits_last_updated = local_jiffies; | ||
810 | data->limits_valid = 1; | ||
811 | |||
812 | out: | ||
813 | mutex_unlock(&data->lock); | ||
814 | return data; | ||
815 | } | ||
816 | |||
817 | static ssize_t show_temp_min(struct device *dev, | ||
818 | struct device_attribute *devattr, | ||
819 | char *buf) | ||
820 | { | ||
821 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
822 | struct adt7462_data *data = adt7462_update_device(dev); | ||
823 | |||
824 | if (!temp_enabled(data, attr->index)) | ||
825 | return sprintf(buf, "0\n"); | ||
826 | |||
827 | return sprintf(buf, "%d\n", 1000 * (data->temp_min[attr->index] - 64)); | ||
828 | } | ||
829 | |||
830 | static ssize_t set_temp_min(struct device *dev, | ||
831 | struct device_attribute *devattr, | ||
832 | const char *buf, | ||
833 | size_t count) | ||
834 | { | ||
835 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
836 | struct i2c_client *client = to_i2c_client(dev); | ||
837 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
838 | long temp; | ||
839 | |||
840 | if (strict_strtol(buf, 10, &temp) || !temp_enabled(data, attr->index)) | ||
841 | return -EINVAL; | ||
842 | |||
843 | temp = ROUND_DIV(temp, 1000) + 64; | ||
844 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
845 | |||
846 | mutex_lock(&data->lock); | ||
847 | data->temp_min[attr->index] = temp; | ||
848 | i2c_smbus_write_byte_data(client, ADT7462_TEMP_MIN_REG(attr->index), | ||
849 | temp); | ||
850 | mutex_unlock(&data->lock); | ||
851 | |||
852 | return count; | ||
853 | } | ||
854 | |||
855 | static ssize_t show_temp_max(struct device *dev, | ||
856 | struct device_attribute *devattr, | ||
857 | char *buf) | ||
858 | { | ||
859 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
860 | struct adt7462_data *data = adt7462_update_device(dev); | ||
861 | |||
862 | if (!temp_enabled(data, attr->index)) | ||
863 | return sprintf(buf, "0\n"); | ||
864 | |||
865 | return sprintf(buf, "%d\n", 1000 * (data->temp_max[attr->index] - 64)); | ||
866 | } | ||
867 | |||
868 | static ssize_t set_temp_max(struct device *dev, | ||
869 | struct device_attribute *devattr, | ||
870 | const char *buf, | ||
871 | size_t count) | ||
872 | { | ||
873 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
874 | struct i2c_client *client = to_i2c_client(dev); | ||
875 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
876 | long temp; | ||
877 | |||
878 | if (strict_strtol(buf, 10, &temp) || !temp_enabled(data, attr->index)) | ||
879 | return -EINVAL; | ||
880 | |||
881 | temp = ROUND_DIV(temp, 1000) + 64; | ||
882 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
883 | |||
884 | mutex_lock(&data->lock); | ||
885 | data->temp_max[attr->index] = temp; | ||
886 | i2c_smbus_write_byte_data(client, ADT7462_TEMP_MAX_REG(attr->index), | ||
887 | temp); | ||
888 | mutex_unlock(&data->lock); | ||
889 | |||
890 | return count; | ||
891 | } | ||
892 | |||
893 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | ||
894 | char *buf) | ||
895 | { | ||
896 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
897 | struct adt7462_data *data = adt7462_update_device(dev); | ||
898 | u8 frac = data->temp_frac[attr->index] >> TEMP_FRAC_OFFSET; | ||
899 | |||
900 | if (!temp_enabled(data, attr->index)) | ||
901 | return sprintf(buf, "0\n"); | ||
902 | |||
903 | return sprintf(buf, "%d\n", 1000 * (data->temp[attr->index] - 64) + | ||
904 | 250 * frac); | ||
905 | } | ||
906 | |||
907 | static ssize_t show_temp_label(struct device *dev, | ||
908 | struct device_attribute *devattr, | ||
909 | char *buf) | ||
910 | { | ||
911 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
912 | struct adt7462_data *data = adt7462_update_device(dev); | ||
913 | |||
914 | return sprintf(buf, "%s\n", temp_label(data, attr->index)); | ||
915 | } | ||
916 | |||
917 | static ssize_t show_volt_max(struct device *dev, | ||
918 | struct device_attribute *devattr, | ||
919 | char *buf) | ||
920 | { | ||
921 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
922 | struct adt7462_data *data = adt7462_update_device(dev); | ||
923 | int x = voltage_multiplier(data, attr->index); | ||
924 | |||
925 | x *= data->volt_max[attr->index]; | ||
926 | x /= 1000; /* convert from uV to mV */ | ||
927 | |||
928 | return sprintf(buf, "%d\n", x); | ||
929 | } | ||
930 | |||
931 | static ssize_t set_volt_max(struct device *dev, | ||
932 | struct device_attribute *devattr, | ||
933 | const char *buf, | ||
934 | size_t count) | ||
935 | { | ||
936 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
937 | struct i2c_client *client = to_i2c_client(dev); | ||
938 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
939 | int x = voltage_multiplier(data, attr->index); | ||
940 | long temp; | ||
941 | |||
942 | if (strict_strtol(buf, 10, &temp) || !x) | ||
943 | return -EINVAL; | ||
944 | |||
945 | temp *= 1000; /* convert mV to uV */ | ||
946 | temp = ROUND_DIV(temp, x); | ||
947 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
948 | |||
949 | mutex_lock(&data->lock); | ||
950 | data->volt_max[attr->index] = temp; | ||
951 | i2c_smbus_write_byte_data(client, | ||
952 | ADT7462_REG_VOLT_MAX(data, attr->index), | ||
953 | temp); | ||
954 | mutex_unlock(&data->lock); | ||
955 | |||
956 | return count; | ||
957 | } | ||
958 | |||
959 | static ssize_t show_volt_min(struct device *dev, | ||
960 | struct device_attribute *devattr, | ||
961 | char *buf) | ||
962 | { | ||
963 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
964 | struct adt7462_data *data = adt7462_update_device(dev); | ||
965 | int x = voltage_multiplier(data, attr->index); | ||
966 | |||
967 | x *= data->volt_min[attr->index]; | ||
968 | x /= 1000; /* convert from uV to mV */ | ||
969 | |||
970 | return sprintf(buf, "%d\n", x); | ||
971 | } | ||
972 | |||
973 | static ssize_t set_volt_min(struct device *dev, | ||
974 | struct device_attribute *devattr, | ||
975 | const char *buf, | ||
976 | size_t count) | ||
977 | { | ||
978 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
979 | struct i2c_client *client = to_i2c_client(dev); | ||
980 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
981 | int x = voltage_multiplier(data, attr->index); | ||
982 | long temp; | ||
983 | |||
984 | if (strict_strtol(buf, 10, &temp) || !x) | ||
985 | return -EINVAL; | ||
986 | |||
987 | temp *= 1000; /* convert mV to uV */ | ||
988 | temp = ROUND_DIV(temp, x); | ||
989 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
990 | |||
991 | mutex_lock(&data->lock); | ||
992 | data->volt_min[attr->index] = temp; | ||
993 | i2c_smbus_write_byte_data(client, | ||
994 | ADT7462_REG_VOLT_MIN(data, attr->index), | ||
995 | temp); | ||
996 | mutex_unlock(&data->lock); | ||
997 | |||
998 | return count; | ||
999 | } | ||
1000 | |||
1001 | static ssize_t show_voltage(struct device *dev, | ||
1002 | struct device_attribute *devattr, | ||
1003 | char *buf) | ||
1004 | { | ||
1005 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1006 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1007 | int x = voltage_multiplier(data, attr->index); | ||
1008 | |||
1009 | x *= data->voltages[attr->index]; | ||
1010 | x /= 1000; /* convert from uV to mV */ | ||
1011 | |||
1012 | return sprintf(buf, "%d\n", x); | ||
1013 | } | ||
1014 | |||
1015 | static ssize_t show_voltage_label(struct device *dev, | ||
1016 | struct device_attribute *devattr, | ||
1017 | char *buf) | ||
1018 | { | ||
1019 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1020 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1021 | |||
1022 | return sprintf(buf, "%s\n", voltage_label(data, attr->index)); | ||
1023 | } | ||
1024 | |||
1025 | static ssize_t show_alarm(struct device *dev, | ||
1026 | struct device_attribute *devattr, | ||
1027 | char *buf) | ||
1028 | { | ||
1029 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1030 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1031 | int reg = attr->index >> ADT7462_ALARM_REG_SHIFT; | ||
1032 | int mask = attr->index & ADT7462_ALARM_FLAG_MASK; | ||
1033 | |||
1034 | if (data->alarms[reg] & mask) | ||
1035 | return sprintf(buf, "1\n"); | ||
1036 | else | ||
1037 | return sprintf(buf, "0\n"); | ||
1038 | } | ||
1039 | |||
1040 | static int fan_enabled(struct adt7462_data *data, int fan) | ||
1041 | { | ||
1042 | return data->fan_enabled & (1 << fan); | ||
1043 | } | ||
1044 | |||
1045 | static ssize_t show_fan_min(struct device *dev, | ||
1046 | struct device_attribute *devattr, | ||
1047 | char *buf) | ||
1048 | { | ||
1049 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1050 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1051 | u16 temp; | ||
1052 | |||
1053 | /* Only the MSB of the min fan period is stored... */ | ||
1054 | temp = data->fan_min[attr->index]; | ||
1055 | temp <<= 8; | ||
1056 | |||
1057 | if (!fan_enabled(data, attr->index) || | ||
1058 | !FAN_DATA_VALID(temp)) | ||
1059 | return sprintf(buf, "0\n"); | ||
1060 | |||
1061 | return sprintf(buf, "%d\n", FAN_PERIOD_TO_RPM(temp)); | ||
1062 | } | ||
1063 | |||
1064 | static ssize_t set_fan_min(struct device *dev, | ||
1065 | struct device_attribute *devattr, | ||
1066 | const char *buf, size_t count) | ||
1067 | { | ||
1068 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1069 | struct i2c_client *client = to_i2c_client(dev); | ||
1070 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1071 | long temp; | ||
1072 | |||
1073 | if (strict_strtol(buf, 10, &temp) || !temp || | ||
1074 | !fan_enabled(data, attr->index)) | ||
1075 | return -EINVAL; | ||
1076 | |||
1077 | temp = FAN_RPM_TO_PERIOD(temp); | ||
1078 | temp >>= 8; | ||
1079 | temp = SENSORS_LIMIT(temp, 1, 255); | ||
1080 | |||
1081 | mutex_lock(&data->lock); | ||
1082 | data->fan_min[attr->index] = temp; | ||
1083 | i2c_smbus_write_byte_data(client, ADT7462_REG_FAN_MIN(attr->index), | ||
1084 | temp); | ||
1085 | mutex_unlock(&data->lock); | ||
1086 | |||
1087 | return count; | ||
1088 | } | ||
1089 | |||
1090 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, | ||
1091 | char *buf) | ||
1092 | { | ||
1093 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1094 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1095 | |||
1096 | if (!fan_enabled(data, attr->index) || | ||
1097 | !FAN_DATA_VALID(data->fan[attr->index])) | ||
1098 | return sprintf(buf, "0\n"); | ||
1099 | |||
1100 | return sprintf(buf, "%d\n", | ||
1101 | FAN_PERIOD_TO_RPM(data->fan[attr->index])); | ||
1102 | } | ||
1103 | |||
1104 | static ssize_t show_force_pwm_max(struct device *dev, | ||
1105 | struct device_attribute *devattr, | ||
1106 | char *buf) | ||
1107 | { | ||
1108 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1109 | return sprintf(buf, "%d\n", (data->cfg2 & ADT7462_FSPD_MASK ? 1 : 0)); | ||
1110 | } | ||
1111 | |||
1112 | static ssize_t set_force_pwm_max(struct device *dev, | ||
1113 | struct device_attribute *devattr, | ||
1114 | const char *buf, | ||
1115 | size_t count) | ||
1116 | { | ||
1117 | struct i2c_client *client = to_i2c_client(dev); | ||
1118 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1119 | long temp; | ||
1120 | u8 reg; | ||
1121 | |||
1122 | if (strict_strtol(buf, 10, &temp)) | ||
1123 | return -EINVAL; | ||
1124 | |||
1125 | mutex_lock(&data->lock); | ||
1126 | reg = i2c_smbus_read_byte_data(client, ADT7462_REG_CFG2); | ||
1127 | if (temp) | ||
1128 | reg |= ADT7462_FSPD_MASK; | ||
1129 | else | ||
1130 | reg &= ~ADT7462_FSPD_MASK; | ||
1131 | data->cfg2 = reg; | ||
1132 | i2c_smbus_write_byte_data(client, ADT7462_REG_CFG2, reg); | ||
1133 | mutex_unlock(&data->lock); | ||
1134 | |||
1135 | return count; | ||
1136 | } | ||
1137 | |||
1138 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, | ||
1139 | char *buf) | ||
1140 | { | ||
1141 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1142 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1143 | return sprintf(buf, "%d\n", data->pwm[attr->index]); | ||
1144 | } | ||
1145 | |||
1146 | static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, | ||
1147 | const char *buf, size_t count) | ||
1148 | { | ||
1149 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1150 | struct i2c_client *client = to_i2c_client(dev); | ||
1151 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1152 | long temp; | ||
1153 | |||
1154 | if (strict_strtol(buf, 10, &temp)) | ||
1155 | return -EINVAL; | ||
1156 | |||
1157 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
1158 | |||
1159 | mutex_lock(&data->lock); | ||
1160 | data->pwm[attr->index] = temp; | ||
1161 | i2c_smbus_write_byte_data(client, ADT7462_REG_PWM(attr->index), temp); | ||
1162 | mutex_unlock(&data->lock); | ||
1163 | |||
1164 | return count; | ||
1165 | } | ||
1166 | |||
1167 | static ssize_t show_pwm_max(struct device *dev, | ||
1168 | struct device_attribute *devattr, | ||
1169 | char *buf) | ||
1170 | { | ||
1171 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1172 | return sprintf(buf, "%d\n", data->pwm_max); | ||
1173 | } | ||
1174 | |||
1175 | static ssize_t set_pwm_max(struct device *dev, | ||
1176 | struct device_attribute *devattr, | ||
1177 | const char *buf, | ||
1178 | size_t count) | ||
1179 | { | ||
1180 | struct i2c_client *client = to_i2c_client(dev); | ||
1181 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1182 | long temp; | ||
1183 | |||
1184 | if (strict_strtol(buf, 10, &temp)) | ||
1185 | return -EINVAL; | ||
1186 | |||
1187 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
1188 | |||
1189 | mutex_lock(&data->lock); | ||
1190 | data->pwm_max = temp; | ||
1191 | i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_MAX, temp); | ||
1192 | mutex_unlock(&data->lock); | ||
1193 | |||
1194 | return count; | ||
1195 | } | ||
1196 | |||
1197 | static ssize_t show_pwm_min(struct device *dev, | ||
1198 | struct device_attribute *devattr, | ||
1199 | char *buf) | ||
1200 | { | ||
1201 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1202 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1203 | return sprintf(buf, "%d\n", data->pwm_min[attr->index]); | ||
1204 | } | ||
1205 | |||
1206 | static ssize_t set_pwm_min(struct device *dev, | ||
1207 | struct device_attribute *devattr, | ||
1208 | const char *buf, | ||
1209 | size_t count) | ||
1210 | { | ||
1211 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1212 | struct i2c_client *client = to_i2c_client(dev); | ||
1213 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1214 | long temp; | ||
1215 | |||
1216 | if (strict_strtol(buf, 10, &temp)) | ||
1217 | return -EINVAL; | ||
1218 | |||
1219 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
1220 | |||
1221 | mutex_lock(&data->lock); | ||
1222 | data->pwm_min[attr->index] = temp; | ||
1223 | i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_MIN(attr->index), | ||
1224 | temp); | ||
1225 | mutex_unlock(&data->lock); | ||
1226 | |||
1227 | return count; | ||
1228 | } | ||
1229 | |||
1230 | static ssize_t show_pwm_hyst(struct device *dev, | ||
1231 | struct device_attribute *devattr, | ||
1232 | char *buf) | ||
1233 | { | ||
1234 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1235 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1236 | return sprintf(buf, "%d\n", 1000 * | ||
1237 | (data->pwm_trange[attr->index] & ADT7462_PWM_HYST_MASK)); | ||
1238 | } | ||
1239 | |||
1240 | static ssize_t set_pwm_hyst(struct device *dev, | ||
1241 | struct device_attribute *devattr, | ||
1242 | const char *buf, | ||
1243 | size_t count) | ||
1244 | { | ||
1245 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1246 | struct i2c_client *client = to_i2c_client(dev); | ||
1247 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1248 | long temp; | ||
1249 | |||
1250 | if (strict_strtol(buf, 10, &temp)) | ||
1251 | return -EINVAL; | ||
1252 | |||
1253 | temp = ROUND_DIV(temp, 1000); | ||
1254 | temp = SENSORS_LIMIT(temp, 0, 15); | ||
1255 | |||
1256 | /* package things up */ | ||
1257 | temp &= ADT7462_PWM_HYST_MASK; | ||
1258 | temp |= data->pwm_trange[attr->index] & ADT7462_PWM_RANGE_MASK; | ||
1259 | |||
1260 | mutex_lock(&data->lock); | ||
1261 | data->pwm_trange[attr->index] = temp; | ||
1262 | i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_TRANGE(attr->index), | ||
1263 | temp); | ||
1264 | mutex_unlock(&data->lock); | ||
1265 | |||
1266 | return count; | ||
1267 | } | ||
1268 | |||
1269 | static ssize_t show_pwm_tmax(struct device *dev, | ||
1270 | struct device_attribute *devattr, | ||
1271 | char *buf) | ||
1272 | { | ||
1273 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1274 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1275 | |||
1276 | /* tmax = tmin + trange */ | ||
1277 | int trange = trange_values[data->pwm_trange[attr->index] >> | ||
1278 | ADT7462_PWM_RANGE_SHIFT]; | ||
1279 | int tmin = (data->pwm_tmin[attr->index] - 64) * 1000; | ||
1280 | |||
1281 | return sprintf(buf, "%d\n", tmin + trange); | ||
1282 | } | ||
1283 | |||
1284 | static ssize_t set_pwm_tmax(struct device *dev, | ||
1285 | struct device_attribute *devattr, | ||
1286 | const char *buf, | ||
1287 | size_t count) | ||
1288 | { | ||
1289 | int temp; | ||
1290 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1291 | struct i2c_client *client = to_i2c_client(dev); | ||
1292 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1293 | int tmin, trange_value; | ||
1294 | long trange; | ||
1295 | |||
1296 | if (strict_strtol(buf, 10, &trange)) | ||
1297 | return -EINVAL; | ||
1298 | |||
1299 | /* trange = tmax - tmin */ | ||
1300 | tmin = (data->pwm_tmin[attr->index] - 64) * 1000; | ||
1301 | trange_value = find_trange_value(trange - tmin); | ||
1302 | |||
1303 | if (trange_value < 0) | ||
1304 | return -EINVAL; | ||
1305 | |||
1306 | temp = trange_value << ADT7462_PWM_RANGE_SHIFT; | ||
1307 | temp |= data->pwm_trange[attr->index] & ADT7462_PWM_HYST_MASK; | ||
1308 | |||
1309 | mutex_lock(&data->lock); | ||
1310 | data->pwm_trange[attr->index] = temp; | ||
1311 | i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_TRANGE(attr->index), | ||
1312 | temp); | ||
1313 | mutex_unlock(&data->lock); | ||
1314 | |||
1315 | return count; | ||
1316 | } | ||
1317 | |||
1318 | static ssize_t show_pwm_tmin(struct device *dev, | ||
1319 | struct device_attribute *devattr, | ||
1320 | char *buf) | ||
1321 | { | ||
1322 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1323 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1324 | return sprintf(buf, "%d\n", 1000 * (data->pwm_tmin[attr->index] - 64)); | ||
1325 | } | ||
1326 | |||
1327 | static ssize_t set_pwm_tmin(struct device *dev, | ||
1328 | struct device_attribute *devattr, | ||
1329 | const char *buf, | ||
1330 | size_t count) | ||
1331 | { | ||
1332 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1333 | struct i2c_client *client = to_i2c_client(dev); | ||
1334 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1335 | long temp; | ||
1336 | |||
1337 | if (strict_strtol(buf, 10, &temp)) | ||
1338 | return -EINVAL; | ||
1339 | |||
1340 | temp = ROUND_DIV(temp, 1000) + 64; | ||
1341 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
1342 | |||
1343 | mutex_lock(&data->lock); | ||
1344 | data->pwm_tmin[attr->index] = temp; | ||
1345 | i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_TMIN(attr->index), | ||
1346 | temp); | ||
1347 | mutex_unlock(&data->lock); | ||
1348 | |||
1349 | return count; | ||
1350 | } | ||
1351 | |||
1352 | static ssize_t show_pwm_auto(struct device *dev, | ||
1353 | struct device_attribute *devattr, | ||
1354 | char *buf) | ||
1355 | { | ||
1356 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1357 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1358 | int cfg = data->pwm_cfg[attr->index] >> ADT7462_PWM_CHANNEL_SHIFT; | ||
1359 | |||
1360 | switch (cfg) { | ||
1361 | case 4: /* off */ | ||
1362 | return sprintf(buf, "0\n"); | ||
1363 | case 7: /* manual */ | ||
1364 | return sprintf(buf, "1\n"); | ||
1365 | default: /* automatic */ | ||
1366 | return sprintf(buf, "2\n"); | ||
1367 | } | ||
1368 | } | ||
1369 | |||
1370 | static void set_pwm_channel(struct i2c_client *client, | ||
1371 | struct adt7462_data *data, | ||
1372 | int which, | ||
1373 | int value) | ||
1374 | { | ||
1375 | int temp = data->pwm_cfg[which] & ~ADT7462_PWM_CHANNEL_MASK; | ||
1376 | temp |= value << ADT7462_PWM_CHANNEL_SHIFT; | ||
1377 | |||
1378 | mutex_lock(&data->lock); | ||
1379 | data->pwm_cfg[which] = temp; | ||
1380 | i2c_smbus_write_byte_data(client, ADT7462_REG_PWM_CFG(which), temp); | ||
1381 | mutex_unlock(&data->lock); | ||
1382 | } | ||
1383 | |||
1384 | static ssize_t set_pwm_auto(struct device *dev, | ||
1385 | struct device_attribute *devattr, | ||
1386 | const char *buf, | ||
1387 | size_t count) | ||
1388 | { | ||
1389 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1390 | struct i2c_client *client = to_i2c_client(dev); | ||
1391 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1392 | long temp; | ||
1393 | |||
1394 | if (strict_strtol(buf, 10, &temp)) | ||
1395 | return -EINVAL; | ||
1396 | |||
1397 | switch (temp) { | ||
1398 | case 0: /* off */ | ||
1399 | set_pwm_channel(client, data, attr->index, 4); | ||
1400 | return count; | ||
1401 | case 1: /* manual */ | ||
1402 | set_pwm_channel(client, data, attr->index, 7); | ||
1403 | return count; | ||
1404 | default: | ||
1405 | return -EINVAL; | ||
1406 | } | ||
1407 | } | ||
1408 | |||
1409 | static ssize_t show_pwm_auto_temp(struct device *dev, | ||
1410 | struct device_attribute *devattr, | ||
1411 | char *buf) | ||
1412 | { | ||
1413 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1414 | struct adt7462_data *data = adt7462_update_device(dev); | ||
1415 | int channel = data->pwm_cfg[attr->index] >> ADT7462_PWM_CHANNEL_SHIFT; | ||
1416 | |||
1417 | switch (channel) { | ||
1418 | case 0: /* temp[1234] only */ | ||
1419 | case 1: | ||
1420 | case 2: | ||
1421 | case 3: | ||
1422 | return sprintf(buf, "%d\n", (1 << channel)); | ||
1423 | case 5: /* temp1 & temp4 */ | ||
1424 | return sprintf(buf, "9\n"); | ||
1425 | case 6: | ||
1426 | return sprintf(buf, "15\n"); | ||
1427 | default: | ||
1428 | return sprintf(buf, "0\n"); | ||
1429 | } | ||
1430 | } | ||
1431 | |||
1432 | static int cvt_auto_temp(int input) | ||
1433 | { | ||
1434 | if (input == 0xF) | ||
1435 | return 6; | ||
1436 | if (input == 0x9) | ||
1437 | return 5; | ||
1438 | if (input < 1 || !is_power_of_2(input)) | ||
1439 | return -EINVAL; | ||
1440 | return ilog2(input); | ||
1441 | } | ||
1442 | |||
1443 | static ssize_t set_pwm_auto_temp(struct device *dev, | ||
1444 | struct device_attribute *devattr, | ||
1445 | const char *buf, | ||
1446 | size_t count) | ||
1447 | { | ||
1448 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
1449 | struct i2c_client *client = to_i2c_client(dev); | ||
1450 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1451 | long temp; | ||
1452 | |||
1453 | if (strict_strtol(buf, 10, &temp)) | ||
1454 | return -EINVAL; | ||
1455 | |||
1456 | temp = cvt_auto_temp(temp); | ||
1457 | if (temp < 0) | ||
1458 | return temp; | ||
1459 | |||
1460 | set_pwm_channel(client, data, attr->index, temp); | ||
1461 | |||
1462 | return count; | ||
1463 | } | ||
1464 | |||
1465 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, | ||
1466 | set_temp_max, 0); | ||
1467 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, | ||
1468 | set_temp_max, 1); | ||
1469 | static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_max, | ||
1470 | set_temp_max, 2); | ||
1471 | static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_max, | ||
1472 | set_temp_max, 3); | ||
1473 | |||
1474 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, | ||
1475 | set_temp_min, 0); | ||
1476 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, | ||
1477 | set_temp_min, 1); | ||
1478 | static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_temp_min, | ||
1479 | set_temp_min, 2); | ||
1480 | static SENSOR_DEVICE_ATTR(temp4_min, S_IWUSR | S_IRUGO, show_temp_min, | ||
1481 | set_temp_min, 3); | ||
1482 | |||
1483 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | ||
1484 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); | ||
1485 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); | ||
1486 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); | ||
1487 | |||
1488 | static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_temp_label, NULL, 0); | ||
1489 | static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, show_temp_label, NULL, 1); | ||
1490 | static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, show_temp_label, NULL, 2); | ||
1491 | static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, show_temp_label, NULL, 3); | ||
1492 | |||
1493 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, | ||
1494 | ADT7462_ALARM1 | ADT7462_LT_ALARM); | ||
1495 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, | ||
1496 | ADT7462_ALARM1 | ADT7462_R1T_ALARM); | ||
1497 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, | ||
1498 | ADT7462_ALARM1 | ADT7462_R2T_ALARM); | ||
1499 | static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL, | ||
1500 | ADT7462_ALARM1 | ADT7462_R3T_ALARM); | ||
1501 | |||
1502 | static SENSOR_DEVICE_ATTR(in1_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1503 | set_volt_max, 0); | ||
1504 | static SENSOR_DEVICE_ATTR(in2_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1505 | set_volt_max, 1); | ||
1506 | static SENSOR_DEVICE_ATTR(in3_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1507 | set_volt_max, 2); | ||
1508 | static SENSOR_DEVICE_ATTR(in4_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1509 | set_volt_max, 3); | ||
1510 | static SENSOR_DEVICE_ATTR(in5_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1511 | set_volt_max, 4); | ||
1512 | static SENSOR_DEVICE_ATTR(in6_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1513 | set_volt_max, 5); | ||
1514 | static SENSOR_DEVICE_ATTR(in7_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1515 | set_volt_max, 6); | ||
1516 | static SENSOR_DEVICE_ATTR(in8_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1517 | set_volt_max, 7); | ||
1518 | static SENSOR_DEVICE_ATTR(in9_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1519 | set_volt_max, 8); | ||
1520 | static SENSOR_DEVICE_ATTR(in10_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1521 | set_volt_max, 9); | ||
1522 | static SENSOR_DEVICE_ATTR(in11_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1523 | set_volt_max, 10); | ||
1524 | static SENSOR_DEVICE_ATTR(in12_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1525 | set_volt_max, 11); | ||
1526 | static SENSOR_DEVICE_ATTR(in13_max, S_IWUSR | S_IRUGO, show_volt_max, | ||
1527 | set_volt_max, 12); | ||
1528 | |||
1529 | static SENSOR_DEVICE_ATTR(in1_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1530 | set_volt_min, 0); | ||
1531 | static SENSOR_DEVICE_ATTR(in2_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1532 | set_volt_min, 1); | ||
1533 | static SENSOR_DEVICE_ATTR(in3_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1534 | set_volt_min, 2); | ||
1535 | static SENSOR_DEVICE_ATTR(in4_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1536 | set_volt_min, 3); | ||
1537 | static SENSOR_DEVICE_ATTR(in5_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1538 | set_volt_min, 4); | ||
1539 | static SENSOR_DEVICE_ATTR(in6_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1540 | set_volt_min, 5); | ||
1541 | static SENSOR_DEVICE_ATTR(in7_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1542 | set_volt_min, 6); | ||
1543 | static SENSOR_DEVICE_ATTR(in8_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1544 | set_volt_min, 7); | ||
1545 | static SENSOR_DEVICE_ATTR(in9_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1546 | set_volt_min, 8); | ||
1547 | static SENSOR_DEVICE_ATTR(in10_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1548 | set_volt_min, 9); | ||
1549 | static SENSOR_DEVICE_ATTR(in11_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1550 | set_volt_min, 10); | ||
1551 | static SENSOR_DEVICE_ATTR(in12_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1552 | set_volt_min, 11); | ||
1553 | static SENSOR_DEVICE_ATTR(in13_min, S_IWUSR | S_IRUGO, show_volt_min, | ||
1554 | set_volt_min, 12); | ||
1555 | |||
1556 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 0); | ||
1557 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 1); | ||
1558 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_voltage, NULL, 2); | ||
1559 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_voltage, NULL, 3); | ||
1560 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_voltage, NULL, 4); | ||
1561 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 5); | ||
1562 | static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 6); | ||
1563 | static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_voltage, NULL, 7); | ||
1564 | static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_voltage, NULL, 8); | ||
1565 | static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_voltage, NULL, 9); | ||
1566 | static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_voltage, NULL, 10); | ||
1567 | static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_voltage, NULL, 11); | ||
1568 | static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, show_voltage, NULL, 12); | ||
1569 | |||
1570 | static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_voltage_label, NULL, 0); | ||
1571 | static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_voltage_label, NULL, 1); | ||
1572 | static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_voltage_label, NULL, 2); | ||
1573 | static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_voltage_label, NULL, 3); | ||
1574 | static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_voltage_label, NULL, 4); | ||
1575 | static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_voltage_label, NULL, 5); | ||
1576 | static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_voltage_label, NULL, 6); | ||
1577 | static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_voltage_label, NULL, 7); | ||
1578 | static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_voltage_label, NULL, 8); | ||
1579 | static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_voltage_label, NULL, 9); | ||
1580 | static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_voltage_label, NULL, 10); | ||
1581 | static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_voltage_label, NULL, 11); | ||
1582 | static SENSOR_DEVICE_ATTR(in13_label, S_IRUGO, show_voltage_label, NULL, 12); | ||
1583 | |||
1584 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, | ||
1585 | ADT7462_ALARM2 | ADT7462_V0_ALARM); | ||
1586 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, | ||
1587 | ADT7462_ALARM2 | ADT7462_V7_ALARM); | ||
1588 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, | ||
1589 | ADT7462_ALARM2 | ADT7462_V2_ALARM); | ||
1590 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, | ||
1591 | ADT7462_ALARM2 | ADT7462_V6_ALARM); | ||
1592 | static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, | ||
1593 | ADT7462_ALARM2 | ADT7462_V5_ALARM); | ||
1594 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, | ||
1595 | ADT7462_ALARM2 | ADT7462_V4_ALARM); | ||
1596 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, | ||
1597 | ADT7462_ALARM2 | ADT7462_V3_ALARM); | ||
1598 | static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, | ||
1599 | ADT7462_ALARM2 | ADT7462_V1_ALARM); | ||
1600 | static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, | ||
1601 | ADT7462_ALARM3 | ADT7462_V10_ALARM); | ||
1602 | static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, | ||
1603 | ADT7462_ALARM3 | ADT7462_V9_ALARM); | ||
1604 | static SENSOR_DEVICE_ATTR(in11_alarm, S_IRUGO, show_alarm, NULL, | ||
1605 | ADT7462_ALARM3 | ADT7462_V8_ALARM); | ||
1606 | static SENSOR_DEVICE_ATTR(in12_alarm, S_IRUGO, show_alarm, NULL, | ||
1607 | ADT7462_ALARM3 | ADT7462_V11_ALARM); | ||
1608 | static SENSOR_DEVICE_ATTR(in13_alarm, S_IRUGO, show_alarm, NULL, | ||
1609 | ADT7462_ALARM3 | ADT7462_V12_ALARM); | ||
1610 | |||
1611 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1612 | set_fan_min, 0); | ||
1613 | static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1614 | set_fan_min, 1); | ||
1615 | static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1616 | set_fan_min, 2); | ||
1617 | static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1618 | set_fan_min, 3); | ||
1619 | static SENSOR_DEVICE_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1620 | set_fan_min, 4); | ||
1621 | static SENSOR_DEVICE_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1622 | set_fan_min, 5); | ||
1623 | static SENSOR_DEVICE_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1624 | set_fan_min, 6); | ||
1625 | static SENSOR_DEVICE_ATTR(fan8_min, S_IWUSR | S_IRUGO, show_fan_min, | ||
1626 | set_fan_min, 7); | ||
1627 | |||
1628 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | ||
1629 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); | ||
1630 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); | ||
1631 | static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); | ||
1632 | static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4); | ||
1633 | static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 5); | ||
1634 | static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 6); | ||
1635 | static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan, NULL, 7); | ||
1636 | |||
1637 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, | ||
1638 | ADT7462_ALARM4 | ADT7462_F0_ALARM); | ||
1639 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, | ||
1640 | ADT7462_ALARM4 | ADT7462_F1_ALARM); | ||
1641 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, | ||
1642 | ADT7462_ALARM4 | ADT7462_F2_ALARM); | ||
1643 | static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, | ||
1644 | ADT7462_ALARM4 | ADT7462_F3_ALARM); | ||
1645 | static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, | ||
1646 | ADT7462_ALARM4 | ADT7462_F4_ALARM); | ||
1647 | static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, | ||
1648 | ADT7462_ALARM4 | ADT7462_F5_ALARM); | ||
1649 | static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_alarm, NULL, | ||
1650 | ADT7462_ALARM4 | ADT7462_F6_ALARM); | ||
1651 | static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_alarm, NULL, | ||
1652 | ADT7462_ALARM4 | ADT7462_F7_ALARM); | ||
1653 | |||
1654 | static SENSOR_DEVICE_ATTR(force_pwm_max, S_IWUSR | S_IRUGO, | ||
1655 | show_force_pwm_max, set_force_pwm_max, 0); | ||
1656 | |||
1657 | static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); | ||
1658 | static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); | ||
1659 | static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); | ||
1660 | static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); | ||
1661 | |||
1662 | static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IWUSR | S_IRUGO, | ||
1663 | show_pwm_min, set_pwm_min, 0); | ||
1664 | static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IWUSR | S_IRUGO, | ||
1665 | show_pwm_min, set_pwm_min, 1); | ||
1666 | static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IWUSR | S_IRUGO, | ||
1667 | show_pwm_min, set_pwm_min, 2); | ||
1668 | static SENSOR_DEVICE_ATTR(pwm4_auto_point1_pwm, S_IWUSR | S_IRUGO, | ||
1669 | show_pwm_min, set_pwm_min, 3); | ||
1670 | |||
1671 | static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IWUSR | S_IRUGO, | ||
1672 | show_pwm_max, set_pwm_max, 0); | ||
1673 | static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IWUSR | S_IRUGO, | ||
1674 | show_pwm_max, set_pwm_max, 1); | ||
1675 | static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IWUSR | S_IRUGO, | ||
1676 | show_pwm_max, set_pwm_max, 2); | ||
1677 | static SENSOR_DEVICE_ATTR(pwm4_auto_point2_pwm, S_IWUSR | S_IRUGO, | ||
1678 | show_pwm_max, set_pwm_max, 3); | ||
1679 | |||
1680 | static SENSOR_DEVICE_ATTR(temp1_auto_point1_hyst, S_IWUSR | S_IRUGO, | ||
1681 | show_pwm_hyst, set_pwm_hyst, 0); | ||
1682 | static SENSOR_DEVICE_ATTR(temp2_auto_point1_hyst, S_IWUSR | S_IRUGO, | ||
1683 | show_pwm_hyst, set_pwm_hyst, 1); | ||
1684 | static SENSOR_DEVICE_ATTR(temp3_auto_point1_hyst, S_IWUSR | S_IRUGO, | ||
1685 | show_pwm_hyst, set_pwm_hyst, 2); | ||
1686 | static SENSOR_DEVICE_ATTR(temp4_auto_point1_hyst, S_IWUSR | S_IRUGO, | ||
1687 | show_pwm_hyst, set_pwm_hyst, 3); | ||
1688 | |||
1689 | static SENSOR_DEVICE_ATTR(temp1_auto_point2_hyst, S_IWUSR | S_IRUGO, | ||
1690 | show_pwm_hyst, set_pwm_hyst, 0); | ||
1691 | static SENSOR_DEVICE_ATTR(temp2_auto_point2_hyst, S_IWUSR | S_IRUGO, | ||
1692 | show_pwm_hyst, set_pwm_hyst, 1); | ||
1693 | static SENSOR_DEVICE_ATTR(temp3_auto_point2_hyst, S_IWUSR | S_IRUGO, | ||
1694 | show_pwm_hyst, set_pwm_hyst, 2); | ||
1695 | static SENSOR_DEVICE_ATTR(temp4_auto_point2_hyst, S_IWUSR | S_IRUGO, | ||
1696 | show_pwm_hyst, set_pwm_hyst, 3); | ||
1697 | |||
1698 | static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp, S_IWUSR | S_IRUGO, | ||
1699 | show_pwm_tmin, set_pwm_tmin, 0); | ||
1700 | static SENSOR_DEVICE_ATTR(temp2_auto_point1_temp, S_IWUSR | S_IRUGO, | ||
1701 | show_pwm_tmin, set_pwm_tmin, 1); | ||
1702 | static SENSOR_DEVICE_ATTR(temp3_auto_point1_temp, S_IWUSR | S_IRUGO, | ||
1703 | show_pwm_tmin, set_pwm_tmin, 2); | ||
1704 | static SENSOR_DEVICE_ATTR(temp4_auto_point1_temp, S_IWUSR | S_IRUGO, | ||
1705 | show_pwm_tmin, set_pwm_tmin, 3); | ||
1706 | |||
1707 | static SENSOR_DEVICE_ATTR(temp1_auto_point2_temp, S_IWUSR | S_IRUGO, | ||
1708 | show_pwm_tmax, set_pwm_tmax, 0); | ||
1709 | static SENSOR_DEVICE_ATTR(temp2_auto_point2_temp, S_IWUSR | S_IRUGO, | ||
1710 | show_pwm_tmax, set_pwm_tmax, 1); | ||
1711 | static SENSOR_DEVICE_ATTR(temp3_auto_point2_temp, S_IWUSR | S_IRUGO, | ||
1712 | show_pwm_tmax, set_pwm_tmax, 2); | ||
1713 | static SENSOR_DEVICE_ATTR(temp4_auto_point2_temp, S_IWUSR | S_IRUGO, | ||
1714 | show_pwm_tmax, set_pwm_tmax, 3); | ||
1715 | |||
1716 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, show_pwm_auto, | ||
1717 | set_pwm_auto, 0); | ||
1718 | static SENSOR_DEVICE_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, show_pwm_auto, | ||
1719 | set_pwm_auto, 1); | ||
1720 | static SENSOR_DEVICE_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, show_pwm_auto, | ||
1721 | set_pwm_auto, 2); | ||
1722 | static SENSOR_DEVICE_ATTR(pwm4_enable, S_IWUSR | S_IRUGO, show_pwm_auto, | ||
1723 | set_pwm_auto, 3); | ||
1724 | |||
1725 | static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp, S_IWUSR | S_IRUGO, | ||
1726 | show_pwm_auto_temp, set_pwm_auto_temp, 0); | ||
1727 | static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp, S_IWUSR | S_IRUGO, | ||
1728 | show_pwm_auto_temp, set_pwm_auto_temp, 1); | ||
1729 | static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO, | ||
1730 | show_pwm_auto_temp, set_pwm_auto_temp, 2); | ||
1731 | static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO, | ||
1732 | show_pwm_auto_temp, set_pwm_auto_temp, 3); | ||
1733 | |||
1734 | static struct attribute *adt7462_attr[] = | ||
1735 | { | ||
1736 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
1737 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
1738 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
1739 | &sensor_dev_attr_temp4_max.dev_attr.attr, | ||
1740 | |||
1741 | &sensor_dev_attr_temp1_min.dev_attr.attr, | ||
1742 | &sensor_dev_attr_temp2_min.dev_attr.attr, | ||
1743 | &sensor_dev_attr_temp3_min.dev_attr.attr, | ||
1744 | &sensor_dev_attr_temp4_min.dev_attr.attr, | ||
1745 | |||
1746 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
1747 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
1748 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
1749 | &sensor_dev_attr_temp4_input.dev_attr.attr, | ||
1750 | |||
1751 | &sensor_dev_attr_temp1_label.dev_attr.attr, | ||
1752 | &sensor_dev_attr_temp2_label.dev_attr.attr, | ||
1753 | &sensor_dev_attr_temp3_label.dev_attr.attr, | ||
1754 | &sensor_dev_attr_temp4_label.dev_attr.attr, | ||
1755 | |||
1756 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
1757 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | ||
1758 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
1759 | &sensor_dev_attr_temp4_alarm.dev_attr.attr, | ||
1760 | |||
1761 | &sensor_dev_attr_in1_max.dev_attr.attr, | ||
1762 | &sensor_dev_attr_in2_max.dev_attr.attr, | ||
1763 | &sensor_dev_attr_in3_max.dev_attr.attr, | ||
1764 | &sensor_dev_attr_in4_max.dev_attr.attr, | ||
1765 | &sensor_dev_attr_in5_max.dev_attr.attr, | ||
1766 | &sensor_dev_attr_in6_max.dev_attr.attr, | ||
1767 | &sensor_dev_attr_in7_max.dev_attr.attr, | ||
1768 | &sensor_dev_attr_in8_max.dev_attr.attr, | ||
1769 | &sensor_dev_attr_in9_max.dev_attr.attr, | ||
1770 | &sensor_dev_attr_in10_max.dev_attr.attr, | ||
1771 | &sensor_dev_attr_in11_max.dev_attr.attr, | ||
1772 | &sensor_dev_attr_in12_max.dev_attr.attr, | ||
1773 | &sensor_dev_attr_in13_max.dev_attr.attr, | ||
1774 | |||
1775 | &sensor_dev_attr_in1_min.dev_attr.attr, | ||
1776 | &sensor_dev_attr_in2_min.dev_attr.attr, | ||
1777 | &sensor_dev_attr_in3_min.dev_attr.attr, | ||
1778 | &sensor_dev_attr_in4_min.dev_attr.attr, | ||
1779 | &sensor_dev_attr_in5_min.dev_attr.attr, | ||
1780 | &sensor_dev_attr_in6_min.dev_attr.attr, | ||
1781 | &sensor_dev_attr_in7_min.dev_attr.attr, | ||
1782 | &sensor_dev_attr_in8_min.dev_attr.attr, | ||
1783 | &sensor_dev_attr_in9_min.dev_attr.attr, | ||
1784 | &sensor_dev_attr_in10_min.dev_attr.attr, | ||
1785 | &sensor_dev_attr_in11_min.dev_attr.attr, | ||
1786 | &sensor_dev_attr_in12_min.dev_attr.attr, | ||
1787 | &sensor_dev_attr_in13_min.dev_attr.attr, | ||
1788 | |||
1789 | &sensor_dev_attr_in1_input.dev_attr.attr, | ||
1790 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
1791 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
1792 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
1793 | &sensor_dev_attr_in5_input.dev_attr.attr, | ||
1794 | &sensor_dev_attr_in6_input.dev_attr.attr, | ||
1795 | &sensor_dev_attr_in7_input.dev_attr.attr, | ||
1796 | &sensor_dev_attr_in8_input.dev_attr.attr, | ||
1797 | &sensor_dev_attr_in9_input.dev_attr.attr, | ||
1798 | &sensor_dev_attr_in10_input.dev_attr.attr, | ||
1799 | &sensor_dev_attr_in11_input.dev_attr.attr, | ||
1800 | &sensor_dev_attr_in12_input.dev_attr.attr, | ||
1801 | &sensor_dev_attr_in13_input.dev_attr.attr, | ||
1802 | |||
1803 | &sensor_dev_attr_in1_label.dev_attr.attr, | ||
1804 | &sensor_dev_attr_in2_label.dev_attr.attr, | ||
1805 | &sensor_dev_attr_in3_label.dev_attr.attr, | ||
1806 | &sensor_dev_attr_in4_label.dev_attr.attr, | ||
1807 | &sensor_dev_attr_in5_label.dev_attr.attr, | ||
1808 | &sensor_dev_attr_in6_label.dev_attr.attr, | ||
1809 | &sensor_dev_attr_in7_label.dev_attr.attr, | ||
1810 | &sensor_dev_attr_in8_label.dev_attr.attr, | ||
1811 | &sensor_dev_attr_in9_label.dev_attr.attr, | ||
1812 | &sensor_dev_attr_in10_label.dev_attr.attr, | ||
1813 | &sensor_dev_attr_in11_label.dev_attr.attr, | ||
1814 | &sensor_dev_attr_in12_label.dev_attr.attr, | ||
1815 | &sensor_dev_attr_in13_label.dev_attr.attr, | ||
1816 | |||
1817 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
1818 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
1819 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
1820 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
1821 | &sensor_dev_attr_in5_alarm.dev_attr.attr, | ||
1822 | &sensor_dev_attr_in6_alarm.dev_attr.attr, | ||
1823 | &sensor_dev_attr_in7_alarm.dev_attr.attr, | ||
1824 | &sensor_dev_attr_in8_alarm.dev_attr.attr, | ||
1825 | &sensor_dev_attr_in9_alarm.dev_attr.attr, | ||
1826 | &sensor_dev_attr_in10_alarm.dev_attr.attr, | ||
1827 | &sensor_dev_attr_in11_alarm.dev_attr.attr, | ||
1828 | &sensor_dev_attr_in12_alarm.dev_attr.attr, | ||
1829 | &sensor_dev_attr_in13_alarm.dev_attr.attr, | ||
1830 | |||
1831 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
1832 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
1833 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
1834 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
1835 | &sensor_dev_attr_fan5_min.dev_attr.attr, | ||
1836 | &sensor_dev_attr_fan6_min.dev_attr.attr, | ||
1837 | &sensor_dev_attr_fan7_min.dev_attr.attr, | ||
1838 | &sensor_dev_attr_fan8_min.dev_attr.attr, | ||
1839 | |||
1840 | &sensor_dev_attr_fan1_input.dev_attr.attr, | ||
1841 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
1842 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
1843 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
1844 | &sensor_dev_attr_fan5_input.dev_attr.attr, | ||
1845 | &sensor_dev_attr_fan6_input.dev_attr.attr, | ||
1846 | &sensor_dev_attr_fan7_input.dev_attr.attr, | ||
1847 | &sensor_dev_attr_fan8_input.dev_attr.attr, | ||
1848 | |||
1849 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
1850 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
1851 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
1852 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | ||
1853 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, | ||
1854 | &sensor_dev_attr_fan6_alarm.dev_attr.attr, | ||
1855 | &sensor_dev_attr_fan7_alarm.dev_attr.attr, | ||
1856 | &sensor_dev_attr_fan8_alarm.dev_attr.attr, | ||
1857 | |||
1858 | &sensor_dev_attr_force_pwm_max.dev_attr.attr, | ||
1859 | &sensor_dev_attr_pwm1.dev_attr.attr, | ||
1860 | &sensor_dev_attr_pwm2.dev_attr.attr, | ||
1861 | &sensor_dev_attr_pwm3.dev_attr.attr, | ||
1862 | &sensor_dev_attr_pwm4.dev_attr.attr, | ||
1863 | |||
1864 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | ||
1865 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | ||
1866 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | ||
1867 | &sensor_dev_attr_pwm4_auto_point1_pwm.dev_attr.attr, | ||
1868 | |||
1869 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, | ||
1870 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, | ||
1871 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | ||
1872 | &sensor_dev_attr_pwm4_auto_point2_pwm.dev_attr.attr, | ||
1873 | |||
1874 | &sensor_dev_attr_temp1_auto_point1_hyst.dev_attr.attr, | ||
1875 | &sensor_dev_attr_temp2_auto_point1_hyst.dev_attr.attr, | ||
1876 | &sensor_dev_attr_temp3_auto_point1_hyst.dev_attr.attr, | ||
1877 | &sensor_dev_attr_temp4_auto_point1_hyst.dev_attr.attr, | ||
1878 | |||
1879 | &sensor_dev_attr_temp1_auto_point2_hyst.dev_attr.attr, | ||
1880 | &sensor_dev_attr_temp2_auto_point2_hyst.dev_attr.attr, | ||
1881 | &sensor_dev_attr_temp3_auto_point2_hyst.dev_attr.attr, | ||
1882 | &sensor_dev_attr_temp4_auto_point2_hyst.dev_attr.attr, | ||
1883 | |||
1884 | &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr, | ||
1885 | &sensor_dev_attr_temp2_auto_point1_temp.dev_attr.attr, | ||
1886 | &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr, | ||
1887 | &sensor_dev_attr_temp4_auto_point1_temp.dev_attr.attr, | ||
1888 | |||
1889 | &sensor_dev_attr_temp1_auto_point2_temp.dev_attr.attr, | ||
1890 | &sensor_dev_attr_temp2_auto_point2_temp.dev_attr.attr, | ||
1891 | &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr, | ||
1892 | &sensor_dev_attr_temp4_auto_point2_temp.dev_attr.attr, | ||
1893 | |||
1894 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | ||
1895 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1896 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | ||
1897 | &sensor_dev_attr_pwm4_enable.dev_attr.attr, | ||
1898 | |||
1899 | &sensor_dev_attr_pwm1_auto_channels_temp.dev_attr.attr, | ||
1900 | &sensor_dev_attr_pwm2_auto_channels_temp.dev_attr.attr, | ||
1901 | &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, | ||
1902 | &sensor_dev_attr_pwm4_auto_channels_temp.dev_attr.attr, | ||
1903 | NULL | ||
1904 | }; | ||
1905 | |||
1906 | /* Return 0 if detection is successful, -ENODEV otherwise */ | ||
1907 | static int adt7462_detect(struct i2c_client *client, int kind, | ||
1908 | struct i2c_board_info *info) | ||
1909 | { | ||
1910 | struct i2c_adapter *adapter = client->adapter; | ||
1911 | |||
1912 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
1913 | return -ENODEV; | ||
1914 | |||
1915 | if (kind <= 0) { | ||
1916 | int vendor, device, revision; | ||
1917 | |||
1918 | vendor = i2c_smbus_read_byte_data(client, ADT7462_REG_VENDOR); | ||
1919 | if (vendor != ADT7462_VENDOR) | ||
1920 | return -ENODEV; | ||
1921 | |||
1922 | device = i2c_smbus_read_byte_data(client, ADT7462_REG_DEVICE); | ||
1923 | if (device != ADT7462_DEVICE) | ||
1924 | return -ENODEV; | ||
1925 | |||
1926 | revision = i2c_smbus_read_byte_data(client, | ||
1927 | ADT7462_REG_REVISION); | ||
1928 | if (revision != ADT7462_REVISION) | ||
1929 | return -ENODEV; | ||
1930 | } else | ||
1931 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
1932 | |||
1933 | strlcpy(info->type, "adt7462", I2C_NAME_SIZE); | ||
1934 | |||
1935 | return 0; | ||
1936 | } | ||
1937 | |||
1938 | static int adt7462_probe(struct i2c_client *client, | ||
1939 | const struct i2c_device_id *id) | ||
1940 | { | ||
1941 | struct adt7462_data *data; | ||
1942 | int err; | ||
1943 | |||
1944 | data = kzalloc(sizeof(struct adt7462_data), GFP_KERNEL); | ||
1945 | if (!data) { | ||
1946 | err = -ENOMEM; | ||
1947 | goto exit; | ||
1948 | } | ||
1949 | |||
1950 | i2c_set_clientdata(client, data); | ||
1951 | mutex_init(&data->lock); | ||
1952 | |||
1953 | dev_info(&client->dev, "%s chip found\n", client->name); | ||
1954 | |||
1955 | /* Register sysfs hooks */ | ||
1956 | data->attrs.attrs = adt7462_attr; | ||
1957 | err = sysfs_create_group(&client->dev.kobj, &data->attrs); | ||
1958 | if (err) | ||
1959 | goto exit_free; | ||
1960 | |||
1961 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
1962 | if (IS_ERR(data->hwmon_dev)) { | ||
1963 | err = PTR_ERR(data->hwmon_dev); | ||
1964 | goto exit_remove; | ||
1965 | } | ||
1966 | |||
1967 | return 0; | ||
1968 | |||
1969 | exit_remove: | ||
1970 | sysfs_remove_group(&client->dev.kobj, &data->attrs); | ||
1971 | exit_free: | ||
1972 | kfree(data); | ||
1973 | exit: | ||
1974 | return err; | ||
1975 | } | ||
1976 | |||
1977 | static int adt7462_remove(struct i2c_client *client) | ||
1978 | { | ||
1979 | struct adt7462_data *data = i2c_get_clientdata(client); | ||
1980 | |||
1981 | hwmon_device_unregister(data->hwmon_dev); | ||
1982 | sysfs_remove_group(&client->dev.kobj, &data->attrs); | ||
1983 | kfree(data); | ||
1984 | return 0; | ||
1985 | } | ||
1986 | |||
1987 | static int __init adt7462_init(void) | ||
1988 | { | ||
1989 | return i2c_add_driver(&adt7462_driver); | ||
1990 | } | ||
1991 | |||
1992 | static void __exit adt7462_exit(void) | ||
1993 | { | ||
1994 | i2c_del_driver(&adt7462_driver); | ||
1995 | } | ||
1996 | |||
1997 | MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>"); | ||
1998 | MODULE_DESCRIPTION("ADT7462 driver"); | ||
1999 | MODULE_LICENSE("GPL"); | ||
2000 | |||
2001 | module_init(adt7462_init); | ||
2002 | module_exit(adt7462_exit); | ||
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index d368d8f845e1..1311a595147e 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c | |||
@@ -137,6 +137,8 @@ I2C_CLIENT_INSMOD_1(adt7470); | |||
137 | #define FAN_PERIOD_INVALID 65535 | 137 | #define FAN_PERIOD_INVALID 65535 |
138 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) | 138 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) |
139 | 139 | ||
140 | #define ROUND_DIV(x, divisor) (((x) + ((divisor) / 2)) / (divisor)) | ||
141 | |||
140 | struct adt7470_data { | 142 | struct adt7470_data { |
141 | struct device *hwmon_dev; | 143 | struct device *hwmon_dev; |
142 | struct attribute_group attrs; | 144 | struct attribute_group attrs; |
@@ -353,7 +355,13 @@ static ssize_t set_temp_min(struct device *dev, | |||
353 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 355 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
354 | struct i2c_client *client = to_i2c_client(dev); | 356 | struct i2c_client *client = to_i2c_client(dev); |
355 | struct adt7470_data *data = i2c_get_clientdata(client); | 357 | struct adt7470_data *data = i2c_get_clientdata(client); |
356 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 358 | long temp; |
359 | |||
360 | if (strict_strtol(buf, 10, &temp)) | ||
361 | return -EINVAL; | ||
362 | |||
363 | temp = ROUND_DIV(temp, 1000); | ||
364 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
357 | 365 | ||
358 | mutex_lock(&data->lock); | 366 | mutex_lock(&data->lock); |
359 | data->temp_min[attr->index] = temp; | 367 | data->temp_min[attr->index] = temp; |
@@ -381,7 +389,13 @@ static ssize_t set_temp_max(struct device *dev, | |||
381 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 389 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
382 | struct i2c_client *client = to_i2c_client(dev); | 390 | struct i2c_client *client = to_i2c_client(dev); |
383 | struct adt7470_data *data = i2c_get_clientdata(client); | 391 | struct adt7470_data *data = i2c_get_clientdata(client); |
384 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 392 | long temp; |
393 | |||
394 | if (strict_strtol(buf, 10, &temp)) | ||
395 | return -EINVAL; | ||
396 | |||
397 | temp = ROUND_DIV(temp, 1000); | ||
398 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
385 | 399 | ||
386 | mutex_lock(&data->lock); | 400 | mutex_lock(&data->lock); |
387 | data->temp_max[attr->index] = temp; | 401 | data->temp_max[attr->index] = temp; |
@@ -430,11 +444,13 @@ static ssize_t set_fan_max(struct device *dev, | |||
430 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 444 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
431 | struct i2c_client *client = to_i2c_client(dev); | 445 | struct i2c_client *client = to_i2c_client(dev); |
432 | struct adt7470_data *data = i2c_get_clientdata(client); | 446 | struct adt7470_data *data = i2c_get_clientdata(client); |
433 | int temp = simple_strtol(buf, NULL, 10); | 447 | long temp; |
434 | 448 | ||
435 | if (!temp) | 449 | if (strict_strtol(buf, 10, &temp) || !temp) |
436 | return -EINVAL; | 450 | return -EINVAL; |
451 | |||
437 | temp = FAN_RPM_TO_PERIOD(temp); | 452 | temp = FAN_RPM_TO_PERIOD(temp); |
453 | temp = SENSORS_LIMIT(temp, 1, 65534); | ||
438 | 454 | ||
439 | mutex_lock(&data->lock); | 455 | mutex_lock(&data->lock); |
440 | data->fan_max[attr->index] = temp; | 456 | data->fan_max[attr->index] = temp; |
@@ -465,11 +481,13 @@ static ssize_t set_fan_min(struct device *dev, | |||
465 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 481 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
466 | struct i2c_client *client = to_i2c_client(dev); | 482 | struct i2c_client *client = to_i2c_client(dev); |
467 | struct adt7470_data *data = i2c_get_clientdata(client); | 483 | struct adt7470_data *data = i2c_get_clientdata(client); |
468 | int temp = simple_strtol(buf, NULL, 10); | 484 | long temp; |
469 | 485 | ||
470 | if (!temp) | 486 | if (strict_strtol(buf, 10, &temp) || !temp) |
471 | return -EINVAL; | 487 | return -EINVAL; |
488 | |||
472 | temp = FAN_RPM_TO_PERIOD(temp); | 489 | temp = FAN_RPM_TO_PERIOD(temp); |
490 | temp = SENSORS_LIMIT(temp, 1, 65534); | ||
473 | 491 | ||
474 | mutex_lock(&data->lock); | 492 | mutex_lock(&data->lock); |
475 | data->fan_min[attr->index] = temp; | 493 | data->fan_min[attr->index] = temp; |
@@ -507,9 +525,12 @@ static ssize_t set_force_pwm_max(struct device *dev, | |||
507 | { | 525 | { |
508 | struct i2c_client *client = to_i2c_client(dev); | 526 | struct i2c_client *client = to_i2c_client(dev); |
509 | struct adt7470_data *data = i2c_get_clientdata(client); | 527 | struct adt7470_data *data = i2c_get_clientdata(client); |
510 | int temp = simple_strtol(buf, NULL, 10); | 528 | long temp; |
511 | u8 reg; | 529 | u8 reg; |
512 | 530 | ||
531 | if (strict_strtol(buf, 10, &temp)) | ||
532 | return -EINVAL; | ||
533 | |||
513 | mutex_lock(&data->lock); | 534 | mutex_lock(&data->lock); |
514 | data->force_pwm_max = temp; | 535 | data->force_pwm_max = temp; |
515 | reg = i2c_smbus_read_byte_data(client, ADT7470_REG_CFG); | 536 | reg = i2c_smbus_read_byte_data(client, ADT7470_REG_CFG); |
@@ -537,7 +558,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, | |||
537 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 558 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
538 | struct i2c_client *client = to_i2c_client(dev); | 559 | struct i2c_client *client = to_i2c_client(dev); |
539 | struct adt7470_data *data = i2c_get_clientdata(client); | 560 | struct adt7470_data *data = i2c_get_clientdata(client); |
540 | int temp = simple_strtol(buf, NULL, 10); | 561 | long temp; |
562 | |||
563 | if (strict_strtol(buf, 10, &temp)) | ||
564 | return -EINVAL; | ||
565 | |||
566 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
541 | 567 | ||
542 | mutex_lock(&data->lock); | 568 | mutex_lock(&data->lock); |
543 | data->pwm[attr->index] = temp; | 569 | data->pwm[attr->index] = temp; |
@@ -564,7 +590,12 @@ static ssize_t set_pwm_max(struct device *dev, | |||
564 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 590 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
565 | struct i2c_client *client = to_i2c_client(dev); | 591 | struct i2c_client *client = to_i2c_client(dev); |
566 | struct adt7470_data *data = i2c_get_clientdata(client); | 592 | struct adt7470_data *data = i2c_get_clientdata(client); |
567 | int temp = simple_strtol(buf, NULL, 10); | 593 | long temp; |
594 | |||
595 | if (strict_strtol(buf, 10, &temp)) | ||
596 | return -EINVAL; | ||
597 | |||
598 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
568 | 599 | ||
569 | mutex_lock(&data->lock); | 600 | mutex_lock(&data->lock); |
570 | data->pwm_max[attr->index] = temp; | 601 | data->pwm_max[attr->index] = temp; |
@@ -592,7 +623,12 @@ static ssize_t set_pwm_min(struct device *dev, | |||
592 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 623 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
593 | struct i2c_client *client = to_i2c_client(dev); | 624 | struct i2c_client *client = to_i2c_client(dev); |
594 | struct adt7470_data *data = i2c_get_clientdata(client); | 625 | struct adt7470_data *data = i2c_get_clientdata(client); |
595 | int temp = simple_strtol(buf, NULL, 10); | 626 | long temp; |
627 | |||
628 | if (strict_strtol(buf, 10, &temp)) | ||
629 | return -EINVAL; | ||
630 | |||
631 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
596 | 632 | ||
597 | mutex_lock(&data->lock); | 633 | mutex_lock(&data->lock); |
598 | data->pwm_min[attr->index] = temp; | 634 | data->pwm_min[attr->index] = temp; |
@@ -630,7 +666,13 @@ static ssize_t set_pwm_tmin(struct device *dev, | |||
630 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 666 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
631 | struct i2c_client *client = to_i2c_client(dev); | 667 | struct i2c_client *client = to_i2c_client(dev); |
632 | struct adt7470_data *data = i2c_get_clientdata(client); | 668 | struct adt7470_data *data = i2c_get_clientdata(client); |
633 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 669 | long temp; |
670 | |||
671 | if (strict_strtol(buf, 10, &temp)) | ||
672 | return -EINVAL; | ||
673 | |||
674 | temp = ROUND_DIV(temp, 1000); | ||
675 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
634 | 676 | ||
635 | mutex_lock(&data->lock); | 677 | mutex_lock(&data->lock); |
636 | data->pwm_tmin[attr->index] = temp; | 678 | data->pwm_tmin[attr->index] = temp; |
@@ -658,11 +700,14 @@ static ssize_t set_pwm_auto(struct device *dev, | |||
658 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 700 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
659 | struct i2c_client *client = to_i2c_client(dev); | 701 | struct i2c_client *client = to_i2c_client(dev); |
660 | struct adt7470_data *data = i2c_get_clientdata(client); | 702 | struct adt7470_data *data = i2c_get_clientdata(client); |
661 | int temp = simple_strtol(buf, NULL, 10); | ||
662 | int pwm_auto_reg = ADT7470_REG_PWM_CFG(attr->index); | 703 | int pwm_auto_reg = ADT7470_REG_PWM_CFG(attr->index); |
663 | int pwm_auto_reg_mask; | 704 | int pwm_auto_reg_mask; |
705 | long temp; | ||
664 | u8 reg; | 706 | u8 reg; |
665 | 707 | ||
708 | if (strict_strtol(buf, 10, &temp)) | ||
709 | return -EINVAL; | ||
710 | |||
666 | if (attr->index % 2) | 711 | if (attr->index % 2) |
667 | pwm_auto_reg_mask = ADT7470_PWM2_AUTO_MASK; | 712 | pwm_auto_reg_mask = ADT7470_PWM2_AUTO_MASK; |
668 | else | 713 | else |
@@ -716,10 +761,14 @@ static ssize_t set_pwm_auto_temp(struct device *dev, | |||
716 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 761 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
717 | struct i2c_client *client = to_i2c_client(dev); | 762 | struct i2c_client *client = to_i2c_client(dev); |
718 | struct adt7470_data *data = i2c_get_clientdata(client); | 763 | struct adt7470_data *data = i2c_get_clientdata(client); |
719 | int temp = cvt_auto_temp(simple_strtol(buf, NULL, 10)); | ||
720 | int pwm_auto_reg = ADT7470_REG_PWM_AUTO_TEMP(attr->index); | 764 | int pwm_auto_reg = ADT7470_REG_PWM_AUTO_TEMP(attr->index); |
765 | long temp; | ||
721 | u8 reg; | 766 | u8 reg; |
722 | 767 | ||
768 | if (strict_strtol(buf, 10, &temp)) | ||
769 | return -EINVAL; | ||
770 | |||
771 | temp = cvt_auto_temp(temp); | ||
723 | if (temp < 0) | 772 | if (temp < 0) |
724 | return temp; | 773 | return temp; |
725 | 774 | ||
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c index b9a8ea30c99c..18aa30866a6c 100644 --- a/drivers/hwmon/adt7473.c +++ b/drivers/hwmon/adt7473.c | |||
@@ -129,6 +129,8 @@ I2C_CLIENT_INSMOD_1(adt7473); | |||
129 | #define FAN_PERIOD_INVALID 65535 | 129 | #define FAN_PERIOD_INVALID 65535 |
130 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) | 130 | #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID) |
131 | 131 | ||
132 | #define ROUND_DIV(x, divisor) (((x) + ((divisor) / 2)) / (divisor)) | ||
133 | |||
132 | struct adt7473_data { | 134 | struct adt7473_data { |
133 | struct device *hwmon_dev; | 135 | struct device *hwmon_dev; |
134 | struct attribute_group attrs; | 136 | struct attribute_group attrs; |
@@ -357,7 +359,12 @@ static ssize_t set_volt_min(struct device *dev, | |||
357 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 359 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
358 | struct i2c_client *client = to_i2c_client(dev); | 360 | struct i2c_client *client = to_i2c_client(dev); |
359 | struct adt7473_data *data = i2c_get_clientdata(client); | 361 | struct adt7473_data *data = i2c_get_clientdata(client); |
360 | int volt = encode_volt(attr->index, simple_strtol(buf, NULL, 10)); | 362 | long volt; |
363 | |||
364 | if (strict_strtol(buf, 10, &volt)) | ||
365 | return -EINVAL; | ||
366 | |||
367 | volt = encode_volt(attr->index, volt); | ||
361 | 368 | ||
362 | mutex_lock(&data->lock); | 369 | mutex_lock(&data->lock); |
363 | data->volt_min[attr->index] = volt; | 370 | data->volt_min[attr->index] = volt; |
@@ -386,7 +393,12 @@ static ssize_t set_volt_max(struct device *dev, | |||
386 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 393 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
387 | struct i2c_client *client = to_i2c_client(dev); | 394 | struct i2c_client *client = to_i2c_client(dev); |
388 | struct adt7473_data *data = i2c_get_clientdata(client); | 395 | struct adt7473_data *data = i2c_get_clientdata(client); |
389 | int volt = encode_volt(attr->index, simple_strtol(buf, NULL, 10)); | 396 | long volt; |
397 | |||
398 | if (strict_strtol(buf, 10, &volt)) | ||
399 | return -EINVAL; | ||
400 | |||
401 | volt = encode_volt(attr->index, volt); | ||
390 | 402 | ||
391 | mutex_lock(&data->lock); | 403 | mutex_lock(&data->lock); |
392 | data->volt_max[attr->index] = volt; | 404 | data->volt_max[attr->index] = volt; |
@@ -419,7 +431,8 @@ static int decode_temp(u8 twos_complement, u8 raw) | |||
419 | 431 | ||
420 | static u8 encode_temp(u8 twos_complement, int cooked) | 432 | static u8 encode_temp(u8 twos_complement, int cooked) |
421 | { | 433 | { |
422 | return twos_complement ? cooked & 0xFF : cooked + 64; | 434 | u8 ret = twos_complement ? cooked & 0xFF : cooked + 64; |
435 | return SENSORS_LIMIT(ret, 0, 255); | ||
423 | } | 436 | } |
424 | 437 | ||
425 | static ssize_t show_temp_min(struct device *dev, | 438 | static ssize_t show_temp_min(struct device *dev, |
@@ -441,7 +454,12 @@ static ssize_t set_temp_min(struct device *dev, | |||
441 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 454 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
442 | struct i2c_client *client = to_i2c_client(dev); | 455 | struct i2c_client *client = to_i2c_client(dev); |
443 | struct adt7473_data *data = i2c_get_clientdata(client); | 456 | struct adt7473_data *data = i2c_get_clientdata(client); |
444 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 457 | long temp; |
458 | |||
459 | if (strict_strtol(buf, 10, &temp)) | ||
460 | return -EINVAL; | ||
461 | |||
462 | temp = ROUND_DIV(temp, 1000); | ||
445 | temp = encode_temp(data->temp_twos_complement, temp); | 463 | temp = encode_temp(data->temp_twos_complement, temp); |
446 | 464 | ||
447 | mutex_lock(&data->lock); | 465 | mutex_lock(&data->lock); |
@@ -472,7 +490,12 @@ static ssize_t set_temp_max(struct device *dev, | |||
472 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 490 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
473 | struct i2c_client *client = to_i2c_client(dev); | 491 | struct i2c_client *client = to_i2c_client(dev); |
474 | struct adt7473_data *data = i2c_get_clientdata(client); | 492 | struct adt7473_data *data = i2c_get_clientdata(client); |
475 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 493 | long temp; |
494 | |||
495 | if (strict_strtol(buf, 10, &temp)) | ||
496 | return -EINVAL; | ||
497 | |||
498 | temp = ROUND_DIV(temp, 1000); | ||
476 | temp = encode_temp(data->temp_twos_complement, temp); | 499 | temp = encode_temp(data->temp_twos_complement, temp); |
477 | 500 | ||
478 | mutex_lock(&data->lock); | 501 | mutex_lock(&data->lock); |
@@ -515,11 +538,13 @@ static ssize_t set_fan_min(struct device *dev, | |||
515 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 538 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
516 | struct i2c_client *client = to_i2c_client(dev); | 539 | struct i2c_client *client = to_i2c_client(dev); |
517 | struct adt7473_data *data = i2c_get_clientdata(client); | 540 | struct adt7473_data *data = i2c_get_clientdata(client); |
518 | int temp = simple_strtol(buf, NULL, 10); | 541 | long temp; |
519 | 542 | ||
520 | if (!temp) | 543 | if (strict_strtol(buf, 10, &temp) || !temp) |
521 | return -EINVAL; | 544 | return -EINVAL; |
545 | |||
522 | temp = FAN_RPM_TO_PERIOD(temp); | 546 | temp = FAN_RPM_TO_PERIOD(temp); |
547 | temp = SENSORS_LIMIT(temp, 1, 65534); | ||
523 | 548 | ||
524 | mutex_lock(&data->lock); | 549 | mutex_lock(&data->lock); |
525 | data->fan_min[attr->index] = temp; | 550 | data->fan_min[attr->index] = temp; |
@@ -558,7 +583,10 @@ static ssize_t set_max_duty_at_crit(struct device *dev, | |||
558 | u8 reg; | 583 | u8 reg; |
559 | struct i2c_client *client = to_i2c_client(dev); | 584 | struct i2c_client *client = to_i2c_client(dev); |
560 | struct adt7473_data *data = i2c_get_clientdata(client); | 585 | struct adt7473_data *data = i2c_get_clientdata(client); |
561 | int temp = simple_strtol(buf, NULL, 10); | 586 | long temp; |
587 | |||
588 | if (strict_strtol(buf, 10, &temp)) | ||
589 | return -EINVAL; | ||
562 | 590 | ||
563 | mutex_lock(&data->lock); | 591 | mutex_lock(&data->lock); |
564 | data->max_duty_at_overheat = !!temp; | 592 | data->max_duty_at_overheat = !!temp; |
@@ -587,7 +615,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, | |||
587 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 615 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
588 | struct i2c_client *client = to_i2c_client(dev); | 616 | struct i2c_client *client = to_i2c_client(dev); |
589 | struct adt7473_data *data = i2c_get_clientdata(client); | 617 | struct adt7473_data *data = i2c_get_clientdata(client); |
590 | int temp = simple_strtol(buf, NULL, 10); | 618 | long temp; |
619 | |||
620 | if (strict_strtol(buf, 10, &temp)) | ||
621 | return -EINVAL; | ||
622 | |||
623 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
591 | 624 | ||
592 | mutex_lock(&data->lock); | 625 | mutex_lock(&data->lock); |
593 | data->pwm[attr->index] = temp; | 626 | data->pwm[attr->index] = temp; |
@@ -614,7 +647,12 @@ static ssize_t set_pwm_max(struct device *dev, | |||
614 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 647 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
615 | struct i2c_client *client = to_i2c_client(dev); | 648 | struct i2c_client *client = to_i2c_client(dev); |
616 | struct adt7473_data *data = i2c_get_clientdata(client); | 649 | struct adt7473_data *data = i2c_get_clientdata(client); |
617 | int temp = simple_strtol(buf, NULL, 10); | 650 | long temp; |
651 | |||
652 | if (strict_strtol(buf, 10, &temp)) | ||
653 | return -EINVAL; | ||
654 | |||
655 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
618 | 656 | ||
619 | mutex_lock(&data->lock); | 657 | mutex_lock(&data->lock); |
620 | data->pwm_max[attr->index] = temp; | 658 | data->pwm_max[attr->index] = temp; |
@@ -642,7 +680,12 @@ static ssize_t set_pwm_min(struct device *dev, | |||
642 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 680 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
643 | struct i2c_client *client = to_i2c_client(dev); | 681 | struct i2c_client *client = to_i2c_client(dev); |
644 | struct adt7473_data *data = i2c_get_clientdata(client); | 682 | struct adt7473_data *data = i2c_get_clientdata(client); |
645 | int temp = simple_strtol(buf, NULL, 10); | 683 | long temp; |
684 | |||
685 | if (strict_strtol(buf, 10, &temp)) | ||
686 | return -EINVAL; | ||
687 | |||
688 | temp = SENSORS_LIMIT(temp, 0, 255); | ||
646 | 689 | ||
647 | mutex_lock(&data->lock); | 690 | mutex_lock(&data->lock); |
648 | data->pwm_min[attr->index] = temp; | 691 | data->pwm_min[attr->index] = temp; |
@@ -672,7 +715,12 @@ static ssize_t set_temp_tmax(struct device *dev, | |||
672 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 715 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
673 | struct i2c_client *client = to_i2c_client(dev); | 716 | struct i2c_client *client = to_i2c_client(dev); |
674 | struct adt7473_data *data = i2c_get_clientdata(client); | 717 | struct adt7473_data *data = i2c_get_clientdata(client); |
675 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 718 | long temp; |
719 | |||
720 | if (strict_strtol(buf, 10, &temp)) | ||
721 | return -EINVAL; | ||
722 | |||
723 | temp = ROUND_DIV(temp, 1000); | ||
676 | temp = encode_temp(data->temp_twos_complement, temp); | 724 | temp = encode_temp(data->temp_twos_complement, temp); |
677 | 725 | ||
678 | mutex_lock(&data->lock); | 726 | mutex_lock(&data->lock); |
@@ -703,7 +751,12 @@ static ssize_t set_temp_tmin(struct device *dev, | |||
703 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 751 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
704 | struct i2c_client *client = to_i2c_client(dev); | 752 | struct i2c_client *client = to_i2c_client(dev); |
705 | struct adt7473_data *data = i2c_get_clientdata(client); | 753 | struct adt7473_data *data = i2c_get_clientdata(client); |
706 | int temp = simple_strtol(buf, NULL, 10) / 1000; | 754 | long temp; |
755 | |||
756 | if (strict_strtol(buf, 10, &temp)) | ||
757 | return -EINVAL; | ||
758 | |||
759 | temp = ROUND_DIV(temp, 1000); | ||
707 | temp = encode_temp(data->temp_twos_complement, temp); | 760 | temp = encode_temp(data->temp_twos_complement, temp); |
708 | 761 | ||
709 | mutex_lock(&data->lock); | 762 | mutex_lock(&data->lock); |
@@ -741,7 +794,10 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
741 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 794 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
742 | struct i2c_client *client = to_i2c_client(dev); | 795 | struct i2c_client *client = to_i2c_client(dev); |
743 | struct adt7473_data *data = i2c_get_clientdata(client); | 796 | struct adt7473_data *data = i2c_get_clientdata(client); |
744 | int temp = simple_strtol(buf, NULL, 10); | 797 | long temp; |
798 | |||
799 | if (strict_strtol(buf, 10, &temp)) | ||
800 | return -EINVAL; | ||
745 | 801 | ||
746 | switch (temp) { | 802 | switch (temp) { |
747 | case 0: | 803 | case 0: |
@@ -805,7 +861,10 @@ static ssize_t set_pwm_auto_temp(struct device *dev, | |||
805 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 861 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
806 | struct i2c_client *client = to_i2c_client(dev); | 862 | struct i2c_client *client = to_i2c_client(dev); |
807 | struct adt7473_data *data = i2c_get_clientdata(client); | 863 | struct adt7473_data *data = i2c_get_clientdata(client); |
808 | int temp = simple_strtol(buf, NULL, 10); | 864 | long temp; |
865 | |||
866 | if (strict_strtol(buf, 10, &temp)) | ||
867 | return -EINVAL; | ||
809 | 868 | ||
810 | switch (temp) { | 869 | switch (temp) { |
811 | case 1: | 870 | case 1: |
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index be3285912cb7..488e45cd43d7 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -1280,7 +1280,7 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = { | |||
1280 | { .accelerometer = 0, .light = 0, .temperature_set = 4 }, | 1280 | { .accelerometer = 0, .light = 0, .temperature_set = 4 }, |
1281 | /* iMac: temperature set 5 */ | 1281 | /* iMac: temperature set 5 */ |
1282 | { .accelerometer = 0, .light = 0, .temperature_set = 5 }, | 1282 | { .accelerometer = 0, .light = 0, .temperature_set = 5 }, |
1283 | /* MacBook3: accelerometer and temperature set 6 */ | 1283 | /* MacBook3, MacBook4: accelerometer and temperature set 6 */ |
1284 | { .accelerometer = 1, .light = 0, .temperature_set = 6 }, | 1284 | { .accelerometer = 1, .light = 0, .temperature_set = 6 }, |
1285 | /* MacBook Air: accelerometer, backlight and temperature set 7 */ | 1285 | /* MacBook Air: accelerometer, backlight and temperature set 7 */ |
1286 | { .accelerometer = 1, .light = 1, .temperature_set = 7 }, | 1286 | { .accelerometer = 1, .light = 1, .temperature_set = 7 }, |
@@ -1329,6 +1329,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { | |||
1329 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1329 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), |
1330 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBook3") }, | 1330 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBook3") }, |
1331 | &applesmc_dmi_data[6]}, | 1331 | &applesmc_dmi_data[6]}, |
1332 | { applesmc_dmi_match, "Apple MacBook 4", { | ||
1333 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), | ||
1334 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBook4") }, | ||
1335 | &applesmc_dmi_data[6]}, | ||
1332 | { applesmc_dmi_match, "Apple MacBook 5", { | 1336 | { applesmc_dmi_match, "Apple MacBook 5", { |
1333 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), | 1337 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1334 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBook5") }, | 1338 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBook5") }, |
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c index 7b0ed5dea399..fe74609a7feb 100644 --- a/drivers/hwmon/ibmaem.c +++ b/drivers/hwmon/ibmaem.c | |||
@@ -88,9 +88,11 @@ | |||
88 | static DEFINE_IDR(aem_idr); | 88 | static DEFINE_IDR(aem_idr); |
89 | static DEFINE_SPINLOCK(aem_idr_lock); | 89 | static DEFINE_SPINLOCK(aem_idr_lock); |
90 | 90 | ||
91 | static struct device_driver aem_driver = { | 91 | static struct platform_driver aem_driver = { |
92 | .name = DRVNAME, | 92 | .driver = { |
93 | .bus = &platform_bus_type, | 93 | .name = DRVNAME, |
94 | .bus = &platform_bus_type, | ||
95 | } | ||
94 | }; | 96 | }; |
95 | 97 | ||
96 | struct aem_ipmi_data { | 98 | struct aem_ipmi_data { |
@@ -583,7 +585,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) | |||
583 | data->pdev = platform_device_alloc(DRVNAME, data->id); | 585 | data->pdev = platform_device_alloc(DRVNAME, data->id); |
584 | if (!data->pdev) | 586 | if (!data->pdev) |
585 | goto dev_err; | 587 | goto dev_err; |
586 | data->pdev->dev.driver = &aem_driver; | 588 | data->pdev->dev.driver = &aem_driver.driver; |
587 | 589 | ||
588 | res = platform_device_add(data->pdev); | 590 | res = platform_device_add(data->pdev); |
589 | if (res) | 591 | if (res) |
@@ -716,7 +718,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, | |||
716 | data->pdev = platform_device_alloc(DRVNAME, data->id); | 718 | data->pdev = platform_device_alloc(DRVNAME, data->id); |
717 | if (!data->pdev) | 719 | if (!data->pdev) |
718 | goto dev_err; | 720 | goto dev_err; |
719 | data->pdev->dev.driver = &aem_driver; | 721 | data->pdev->dev.driver = &aem_driver.driver; |
720 | 722 | ||
721 | res = platform_device_add(data->pdev); | 723 | res = platform_device_add(data->pdev); |
722 | if (res) | 724 | if (res) |
@@ -1085,7 +1087,7 @@ static int __init aem_init(void) | |||
1085 | { | 1087 | { |
1086 | int res; | 1088 | int res; |
1087 | 1089 | ||
1088 | res = driver_register(&aem_driver); | 1090 | res = driver_register(&aem_driver.driver); |
1089 | if (res) { | 1091 | if (res) { |
1090 | printk(KERN_ERR "Can't register aem driver\n"); | 1092 | printk(KERN_ERR "Can't register aem driver\n"); |
1091 | return res; | 1093 | return res; |
@@ -1097,7 +1099,7 @@ static int __init aem_init(void) | |||
1097 | return 0; | 1099 | return 0; |
1098 | 1100 | ||
1099 | ipmi_reg_err: | 1101 | ipmi_reg_err: |
1100 | driver_unregister(&aem_driver); | 1102 | driver_unregister(&aem_driver.driver); |
1101 | return res; | 1103 | return res; |
1102 | 1104 | ||
1103 | } | 1105 | } |
@@ -1107,7 +1109,7 @@ static void __exit aem_exit(void) | |||
1107 | struct aem_data *p1, *next1; | 1109 | struct aem_data *p1, *next1; |
1108 | 1110 | ||
1109 | ipmi_smi_watcher_unregister(&driver_data.bmc_events); | 1111 | ipmi_smi_watcher_unregister(&driver_data.bmc_events); |
1110 | driver_unregister(&aem_driver); | 1112 | driver_unregister(&aem_driver.driver); |
1111 | list_for_each_entry_safe(p1, next1, &driver_data.aem_devices, list) | 1113 | list_for_each_entry_safe(p1, next1, &driver_data.aem_devices, list) |
1112 | aem_delete(p1); | 1114 | aem_delete(p1); |
1113 | } | 1115 | } |
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c new file mode 100644 index 000000000000..c002144c76bc --- /dev/null +++ b/drivers/hwmon/lis3lv02d.c | |||
@@ -0,0 +1,581 @@ | |||
1 | /* | ||
2 | * lis3lv02d.c - ST LIS3LV02DL accelerometer driver | ||
3 | * | ||
4 | * Copyright (C) 2007-2008 Yan Burman | ||
5 | * Copyright (C) 2008 Eric Piel | ||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/dmi.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/input.h> | ||
30 | #include <linux/kthread.h> | ||
31 | #include <linux/semaphore.h> | ||
32 | #include <linux/delay.h> | ||
33 | #include <linux/wait.h> | ||
34 | #include <linux/poll.h> | ||
35 | #include <linux/freezer.h> | ||
36 | #include <linux/uaccess.h> | ||
37 | #include <acpi/acpi_drivers.h> | ||
38 | #include <asm/atomic.h> | ||
39 | #include "lis3lv02d.h" | ||
40 | |||
41 | #define DRIVER_NAME "lis3lv02d" | ||
42 | #define ACPI_MDPS_CLASS "accelerometer" | ||
43 | |||
44 | /* joystick device poll interval in milliseconds */ | ||
45 | #define MDPS_POLL_INTERVAL 50 | ||
46 | /* | ||
47 | * The sensor can also generate interrupts (DRDY) but it's pretty pointless | ||
48 | * because their are generated even if the data do not change. So it's better | ||
49 | * to keep the interrupt for the free-fall event. The values are updated at | ||
50 | * 40Hz (at the lowest frequency), but as it can be pretty time consuming on | ||
51 | * some low processor, we poll the sensor only at 20Hz... enough for the | ||
52 | * joystick. | ||
53 | */ | ||
54 | |||
55 | /* Maximum value our axis may get for the input device (signed 12 bits) */ | ||
56 | #define MDPS_MAX_VAL 2048 | ||
57 | |||
58 | struct axis_conversion { | ||
59 | s8 x; | ||
60 | s8 y; | ||
61 | s8 z; | ||
62 | }; | ||
63 | |||
64 | struct acpi_lis3lv02d { | ||
65 | struct acpi_device *device; /* The ACPI device */ | ||
66 | struct input_dev *idev; /* input device */ | ||
67 | struct task_struct *kthread; /* kthread for input */ | ||
68 | struct mutex lock; | ||
69 | struct platform_device *pdev; /* platform device */ | ||
70 | atomic_t count; /* interrupt count after last read */ | ||
71 | int xcalib; /* calibrated null value for x */ | ||
72 | int ycalib; /* calibrated null value for y */ | ||
73 | int zcalib; /* calibrated null value for z */ | ||
74 | unsigned char is_on; /* whether the device is on or off */ | ||
75 | unsigned char usage; /* usage counter */ | ||
76 | struct axis_conversion ac; /* hw -> logical axis */ | ||
77 | }; | ||
78 | |||
79 | static struct acpi_lis3lv02d adev; | ||
80 | |||
81 | static int lis3lv02d_remove_fs(void); | ||
82 | static int lis3lv02d_add_fs(struct acpi_device *device); | ||
83 | |||
84 | /* For automatic insertion of the module */ | ||
85 | static struct acpi_device_id lis3lv02d_device_ids[] = { | ||
86 | {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */ | ||
87 | {"", 0}, | ||
88 | }; | ||
89 | MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids); | ||
90 | |||
91 | /** | ||
92 | * lis3lv02d_acpi_init - ACPI _INI method: initialize the device. | ||
93 | * @handle: the handle of the device | ||
94 | * | ||
95 | * Returns AE_OK on success. | ||
96 | */ | ||
97 | static inline acpi_status lis3lv02d_acpi_init(acpi_handle handle) | ||
98 | { | ||
99 | return acpi_evaluate_object(handle, METHOD_NAME__INI, NULL, NULL); | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * lis3lv02d_acpi_read - ACPI ALRD method: read a register | ||
104 | * @handle: the handle of the device | ||
105 | * @reg: the register to read | ||
106 | * @ret: result of the operation | ||
107 | * | ||
108 | * Returns AE_OK on success. | ||
109 | */ | ||
110 | static acpi_status lis3lv02d_acpi_read(acpi_handle handle, int reg, u8 *ret) | ||
111 | { | ||
112 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | ||
113 | struct acpi_object_list args = { 1, &arg0 }; | ||
114 | unsigned long long lret; | ||
115 | acpi_status status; | ||
116 | |||
117 | arg0.integer.value = reg; | ||
118 | |||
119 | status = acpi_evaluate_integer(handle, "ALRD", &args, &lret); | ||
120 | *ret = lret; | ||
121 | return status; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * lis3lv02d_acpi_write - ACPI ALWR method: write to a register | ||
126 | * @handle: the handle of the device | ||
127 | * @reg: the register to write to | ||
128 | * @val: the value to write | ||
129 | * | ||
130 | * Returns AE_OK on success. | ||
131 | */ | ||
132 | static acpi_status lis3lv02d_acpi_write(acpi_handle handle, int reg, u8 val) | ||
133 | { | ||
134 | unsigned long long ret; /* Not used when writting */ | ||
135 | union acpi_object in_obj[2]; | ||
136 | struct acpi_object_list args = { 2, in_obj }; | ||
137 | |||
138 | in_obj[0].type = ACPI_TYPE_INTEGER; | ||
139 | in_obj[0].integer.value = reg; | ||
140 | in_obj[1].type = ACPI_TYPE_INTEGER; | ||
141 | in_obj[1].integer.value = val; | ||
142 | |||
143 | return acpi_evaluate_integer(handle, "ALWR", &args, &ret); | ||
144 | } | ||
145 | |||
146 | static s16 lis3lv02d_read_16(acpi_handle handle, int reg) | ||
147 | { | ||
148 | u8 lo, hi; | ||
149 | |||
150 | lis3lv02d_acpi_read(handle, reg, &lo); | ||
151 | lis3lv02d_acpi_read(handle, reg + 1, &hi); | ||
152 | /* In "12 bit right justified" mode, bit 6, bit 7, bit 8 = bit 5 */ | ||
153 | return (s16)((hi << 8) | lo); | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * lis3lv02d_get_axis - For the given axis, give the value converted | ||
158 | * @axis: 1,2,3 - can also be negative | ||
159 | * @hw_values: raw values returned by the hardware | ||
160 | * | ||
161 | * Returns the converted value. | ||
162 | */ | ||
163 | static inline int lis3lv02d_get_axis(s8 axis, int hw_values[3]) | ||
164 | { | ||
165 | if (axis > 0) | ||
166 | return hw_values[axis - 1]; | ||
167 | else | ||
168 | return -hw_values[-axis - 1]; | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * lis3lv02d_get_xyz - Get X, Y and Z axis values from the accelerometer | ||
173 | * @handle: the handle to the device | ||
174 | * @x: where to store the X axis value | ||
175 | * @y: where to store the Y axis value | ||
176 | * @z: where to store the Z axis value | ||
177 | * | ||
178 | * Note that 40Hz input device can eat up about 10% CPU at 800MHZ | ||
179 | */ | ||
180 | static void lis3lv02d_get_xyz(acpi_handle handle, int *x, int *y, int *z) | ||
181 | { | ||
182 | int position[3]; | ||
183 | |||
184 | position[0] = lis3lv02d_read_16(handle, OUTX_L); | ||
185 | position[1] = lis3lv02d_read_16(handle, OUTY_L); | ||
186 | position[2] = lis3lv02d_read_16(handle, OUTZ_L); | ||
187 | |||
188 | *x = lis3lv02d_get_axis(adev.ac.x, position); | ||
189 | *y = lis3lv02d_get_axis(adev.ac.y, position); | ||
190 | *z = lis3lv02d_get_axis(adev.ac.z, position); | ||
191 | } | ||
192 | |||
193 | static inline void lis3lv02d_poweroff(acpi_handle handle) | ||
194 | { | ||
195 | adev.is_on = 0; | ||
196 | /* disable X,Y,Z axis and power down */ | ||
197 | lis3lv02d_acpi_write(handle, CTRL_REG1, 0x00); | ||
198 | } | ||
199 | |||
200 | static void lis3lv02d_poweron(acpi_handle handle) | ||
201 | { | ||
202 | u8 val; | ||
203 | |||
204 | adev.is_on = 1; | ||
205 | lis3lv02d_acpi_init(handle); | ||
206 | lis3lv02d_acpi_write(handle, FF_WU_CFG, 0); | ||
207 | /* | ||
208 | * BDU: LSB and MSB values are not updated until both have been read. | ||
209 | * So the value read will always be correct. | ||
210 | * IEN: Interrupt for free-fall and DD, not for data-ready. | ||
211 | */ | ||
212 | lis3lv02d_acpi_read(handle, CTRL_REG2, &val); | ||
213 | val |= CTRL2_BDU | CTRL2_IEN; | ||
214 | lis3lv02d_acpi_write(handle, CTRL_REG2, val); | ||
215 | } | ||
216 | |||
217 | #ifdef CONFIG_PM | ||
218 | static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state) | ||
219 | { | ||
220 | /* make sure the device is off when we suspend */ | ||
221 | lis3lv02d_poweroff(device->handle); | ||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | static int lis3lv02d_resume(struct acpi_device *device) | ||
226 | { | ||
227 | /* put back the device in the right state (ACPI might turn it on) */ | ||
228 | mutex_lock(&adev.lock); | ||
229 | if (adev.usage > 0) | ||
230 | lis3lv02d_poweron(device->handle); | ||
231 | else | ||
232 | lis3lv02d_poweroff(device->handle); | ||
233 | mutex_unlock(&adev.lock); | ||
234 | return 0; | ||
235 | } | ||
236 | #else | ||
237 | #define lis3lv02d_suspend NULL | ||
238 | #define lis3lv02d_resume NULL | ||
239 | #endif | ||
240 | |||
241 | |||
242 | /* | ||
243 | * To be called before starting to use the device. It makes sure that the | ||
244 | * device will always be on until a call to lis3lv02d_decrease_use(). Not to be | ||
245 | * used from interrupt context. | ||
246 | */ | ||
247 | static void lis3lv02d_increase_use(struct acpi_lis3lv02d *dev) | ||
248 | { | ||
249 | mutex_lock(&dev->lock); | ||
250 | dev->usage++; | ||
251 | if (dev->usage == 1) { | ||
252 | if (!dev->is_on) | ||
253 | lis3lv02d_poweron(dev->device->handle); | ||
254 | } | ||
255 | mutex_unlock(&dev->lock); | ||
256 | } | ||
257 | |||
258 | /* | ||
259 | * To be called whenever a usage of the device is stopped. | ||
260 | * It will make sure to turn off the device when there is not usage. | ||
261 | */ | ||
262 | static void lis3lv02d_decrease_use(struct acpi_lis3lv02d *dev) | ||
263 | { | ||
264 | mutex_lock(&dev->lock); | ||
265 | dev->usage--; | ||
266 | if (dev->usage == 0) | ||
267 | lis3lv02d_poweroff(dev->device->handle); | ||
268 | mutex_unlock(&dev->lock); | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * lis3lv02d_joystick_kthread - Kthread polling function | ||
273 | * @data: unused - here to conform to threadfn prototype | ||
274 | */ | ||
275 | static int lis3lv02d_joystick_kthread(void *data) | ||
276 | { | ||
277 | int x, y, z; | ||
278 | |||
279 | while (!kthread_should_stop()) { | ||
280 | lis3lv02d_get_xyz(adev.device->handle, &x, &y, &z); | ||
281 | input_report_abs(adev.idev, ABS_X, x - adev.xcalib); | ||
282 | input_report_abs(adev.idev, ABS_Y, y - adev.ycalib); | ||
283 | input_report_abs(adev.idev, ABS_Z, z - adev.zcalib); | ||
284 | |||
285 | input_sync(adev.idev); | ||
286 | |||
287 | try_to_freeze(); | ||
288 | msleep_interruptible(MDPS_POLL_INTERVAL); | ||
289 | } | ||
290 | |||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | static int lis3lv02d_joystick_open(struct input_dev *input) | ||
295 | { | ||
296 | lis3lv02d_increase_use(&adev); | ||
297 | adev.kthread = kthread_run(lis3lv02d_joystick_kthread, NULL, "klis3lv02d"); | ||
298 | if (IS_ERR(adev.kthread)) { | ||
299 | lis3lv02d_decrease_use(&adev); | ||
300 | return PTR_ERR(adev.kthread); | ||
301 | } | ||
302 | |||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | static void lis3lv02d_joystick_close(struct input_dev *input) | ||
307 | { | ||
308 | kthread_stop(adev.kthread); | ||
309 | lis3lv02d_decrease_use(&adev); | ||
310 | } | ||
311 | |||
312 | |||
313 | static inline void lis3lv02d_calibrate_joystick(void) | ||
314 | { | ||
315 | lis3lv02d_get_xyz(adev.device->handle, &adev.xcalib, &adev.ycalib, &adev.zcalib); | ||
316 | } | ||
317 | |||
318 | static int lis3lv02d_joystick_enable(void) | ||
319 | { | ||
320 | int err; | ||
321 | |||
322 | if (adev.idev) | ||
323 | return -EINVAL; | ||
324 | |||
325 | adev.idev = input_allocate_device(); | ||
326 | if (!adev.idev) | ||
327 | return -ENOMEM; | ||
328 | |||
329 | lis3lv02d_calibrate_joystick(); | ||
330 | |||
331 | adev.idev->name = "ST LIS3LV02DL Accelerometer"; | ||
332 | adev.idev->phys = DRIVER_NAME "/input0"; | ||
333 | adev.idev->id.bustype = BUS_HOST; | ||
334 | adev.idev->id.vendor = 0; | ||
335 | adev.idev->dev.parent = &adev.pdev->dev; | ||
336 | adev.idev->open = lis3lv02d_joystick_open; | ||
337 | adev.idev->close = lis3lv02d_joystick_close; | ||
338 | |||
339 | set_bit(EV_ABS, adev.idev->evbit); | ||
340 | input_set_abs_params(adev.idev, ABS_X, -MDPS_MAX_VAL, MDPS_MAX_VAL, 3, 3); | ||
341 | input_set_abs_params(adev.idev, ABS_Y, -MDPS_MAX_VAL, MDPS_MAX_VAL, 3, 3); | ||
342 | input_set_abs_params(adev.idev, ABS_Z, -MDPS_MAX_VAL, MDPS_MAX_VAL, 3, 3); | ||
343 | |||
344 | err = input_register_device(adev.idev); | ||
345 | if (err) { | ||
346 | input_free_device(adev.idev); | ||
347 | adev.idev = NULL; | ||
348 | } | ||
349 | |||
350 | return err; | ||
351 | } | ||
352 | |||
353 | static void lis3lv02d_joystick_disable(void) | ||
354 | { | ||
355 | if (!adev.idev) | ||
356 | return; | ||
357 | |||
358 | input_unregister_device(adev.idev); | ||
359 | adev.idev = NULL; | ||
360 | } | ||
361 | |||
362 | |||
363 | /* | ||
364 | * Initialise the accelerometer and the various subsystems. | ||
365 | * Should be rather independant of the bus system. | ||
366 | */ | ||
367 | static int lis3lv02d_init_device(struct acpi_lis3lv02d *dev) | ||
368 | { | ||
369 | mutex_init(&dev->lock); | ||
370 | lis3lv02d_add_fs(dev->device); | ||
371 | lis3lv02d_increase_use(dev); | ||
372 | |||
373 | if (lis3lv02d_joystick_enable()) | ||
374 | printk(KERN_ERR DRIVER_NAME ": joystick initialization failed\n"); | ||
375 | |||
376 | lis3lv02d_decrease_use(dev); | ||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static int lis3lv02d_dmi_matched(const struct dmi_system_id *dmi) | ||
381 | { | ||
382 | adev.ac = *((struct axis_conversion *)dmi->driver_data); | ||
383 | printk(KERN_INFO DRIVER_NAME ": hardware type %s found.\n", dmi->ident); | ||
384 | |||
385 | return 1; | ||
386 | } | ||
387 | |||
388 | /* Represents, for each axis seen by userspace, the corresponding hw axis (+1). | ||
389 | * If the value is negative, the opposite of the hw value is used. */ | ||
390 | static struct axis_conversion lis3lv02d_axis_normal = {1, 2, 3}; | ||
391 | static struct axis_conversion lis3lv02d_axis_y_inverted = {1, -2, 3}; | ||
392 | static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3}; | ||
393 | static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3}; | ||
394 | static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3}; | ||
395 | static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3}; | ||
396 | |||
397 | #define AXIS_DMI_MATCH(_ident, _name, _axis) { \ | ||
398 | .ident = _ident, \ | ||
399 | .callback = lis3lv02d_dmi_matched, \ | ||
400 | .matches = { \ | ||
401 | DMI_MATCH(DMI_PRODUCT_NAME, _name) \ | ||
402 | }, \ | ||
403 | .driver_data = &lis3lv02d_axis_##_axis \ | ||
404 | } | ||
405 | static struct dmi_system_id lis3lv02d_dmi_ids[] = { | ||
406 | /* product names are truncated to match all kinds of a same model */ | ||
407 | AXIS_DMI_MATCH("NC64x0", "HP Compaq nc64", x_inverted), | ||
408 | AXIS_DMI_MATCH("NC84x0", "HP Compaq nc84", z_inverted), | ||
409 | AXIS_DMI_MATCH("NX9420", "HP Compaq nx9420", x_inverted), | ||
410 | AXIS_DMI_MATCH("NW9440", "HP Compaq nw9440", x_inverted), | ||
411 | AXIS_DMI_MATCH("NC2510", "HP Compaq 2510", y_inverted), | ||
412 | AXIS_DMI_MATCH("NC8510", "HP Compaq 8510", xy_swap_inverted), | ||
413 | AXIS_DMI_MATCH("HP2133", "HP 2133", xy_rotated_left), | ||
414 | { NULL, } | ||
415 | /* Laptop models without axis info (yet): | ||
416 | * "NC651xx" "HP Compaq 651" | ||
417 | * "NC671xx" "HP Compaq 671" | ||
418 | * "NC6910" "HP Compaq 6910" | ||
419 | * HP Compaq 8710x Notebook PC / Mobile Workstation | ||
420 | * "NC2400" "HP Compaq nc2400" | ||
421 | * "NX74x0" "HP Compaq nx74" | ||
422 | * "NX6325" "HP Compaq nx6325" | ||
423 | * "NC4400" "HP Compaq nc4400" | ||
424 | */ | ||
425 | }; | ||
426 | |||
427 | static int lis3lv02d_add(struct acpi_device *device) | ||
428 | { | ||
429 | u8 val; | ||
430 | |||
431 | if (!device) | ||
432 | return -EINVAL; | ||
433 | |||
434 | adev.device = device; | ||
435 | strcpy(acpi_device_name(device), DRIVER_NAME); | ||
436 | strcpy(acpi_device_class(device), ACPI_MDPS_CLASS); | ||
437 | device->driver_data = &adev; | ||
438 | |||
439 | lis3lv02d_acpi_read(device->handle, WHO_AM_I, &val); | ||
440 | if ((val != LIS3LV02DL_ID) && (val != LIS302DL_ID)) { | ||
441 | printk(KERN_ERR DRIVER_NAME | ||
442 | ": Accelerometer chip not LIS3LV02D{L,Q}\n"); | ||
443 | } | ||
444 | |||
445 | /* If possible use a "standard" axes order */ | ||
446 | if (dmi_check_system(lis3lv02d_dmi_ids) == 0) { | ||
447 | printk(KERN_INFO DRIVER_NAME ": laptop model unknown, " | ||
448 | "using default axes configuration\n"); | ||
449 | adev.ac = lis3lv02d_axis_normal; | ||
450 | } | ||
451 | |||
452 | return lis3lv02d_init_device(&adev); | ||
453 | } | ||
454 | |||
455 | static int lis3lv02d_remove(struct acpi_device *device, int type) | ||
456 | { | ||
457 | if (!device) | ||
458 | return -EINVAL; | ||
459 | |||
460 | lis3lv02d_joystick_disable(); | ||
461 | lis3lv02d_poweroff(device->handle); | ||
462 | |||
463 | return lis3lv02d_remove_fs(); | ||
464 | } | ||
465 | |||
466 | |||
467 | /* Sysfs stuff */ | ||
468 | static ssize_t lis3lv02d_position_show(struct device *dev, | ||
469 | struct device_attribute *attr, char *buf) | ||
470 | { | ||
471 | int x, y, z; | ||
472 | |||
473 | lis3lv02d_increase_use(&adev); | ||
474 | lis3lv02d_get_xyz(adev.device->handle, &x, &y, &z); | ||
475 | lis3lv02d_decrease_use(&adev); | ||
476 | return sprintf(buf, "(%d,%d,%d)\n", x, y, z); | ||
477 | } | ||
478 | |||
479 | static ssize_t lis3lv02d_calibrate_show(struct device *dev, | ||
480 | struct device_attribute *attr, char *buf) | ||
481 | { | ||
482 | return sprintf(buf, "(%d,%d,%d)\n", adev.xcalib, adev.ycalib, adev.zcalib); | ||
483 | } | ||
484 | |||
485 | static ssize_t lis3lv02d_calibrate_store(struct device *dev, | ||
486 | struct device_attribute *attr, | ||
487 | const char *buf, size_t count) | ||
488 | { | ||
489 | lis3lv02d_increase_use(&adev); | ||
490 | lis3lv02d_calibrate_joystick(); | ||
491 | lis3lv02d_decrease_use(&adev); | ||
492 | return count; | ||
493 | } | ||
494 | |||
495 | /* conversion btw sampling rate and the register values */ | ||
496 | static int lis3lv02dl_df_val[4] = {40, 160, 640, 2560}; | ||
497 | static ssize_t lis3lv02d_rate_show(struct device *dev, | ||
498 | struct device_attribute *attr, char *buf) | ||
499 | { | ||
500 | u8 ctrl; | ||
501 | int val; | ||
502 | |||
503 | lis3lv02d_increase_use(&adev); | ||
504 | lis3lv02d_acpi_read(adev.device->handle, CTRL_REG1, &ctrl); | ||
505 | lis3lv02d_decrease_use(&adev); | ||
506 | val = (ctrl & (CTRL1_DF0 | CTRL1_DF1)) >> 4; | ||
507 | return sprintf(buf, "%d\n", lis3lv02dl_df_val[val]); | ||
508 | } | ||
509 | |||
510 | static DEVICE_ATTR(position, S_IRUGO, lis3lv02d_position_show, NULL); | ||
511 | static DEVICE_ATTR(calibrate, S_IRUGO|S_IWUSR, lis3lv02d_calibrate_show, | ||
512 | lis3lv02d_calibrate_store); | ||
513 | static DEVICE_ATTR(rate, S_IRUGO, lis3lv02d_rate_show, NULL); | ||
514 | |||
515 | static struct attribute *lis3lv02d_attributes[] = { | ||
516 | &dev_attr_position.attr, | ||
517 | &dev_attr_calibrate.attr, | ||
518 | &dev_attr_rate.attr, | ||
519 | NULL | ||
520 | }; | ||
521 | |||
522 | static struct attribute_group lis3lv02d_attribute_group = { | ||
523 | .attrs = lis3lv02d_attributes | ||
524 | }; | ||
525 | |||
526 | static int lis3lv02d_add_fs(struct acpi_device *device) | ||
527 | { | ||
528 | adev.pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); | ||
529 | if (IS_ERR(adev.pdev)) | ||
530 | return PTR_ERR(adev.pdev); | ||
531 | |||
532 | return sysfs_create_group(&adev.pdev->dev.kobj, &lis3lv02d_attribute_group); | ||
533 | } | ||
534 | |||
535 | static int lis3lv02d_remove_fs(void) | ||
536 | { | ||
537 | sysfs_remove_group(&adev.pdev->dev.kobj, &lis3lv02d_attribute_group); | ||
538 | platform_device_unregister(adev.pdev); | ||
539 | return 0; | ||
540 | } | ||
541 | |||
542 | /* For the HP MDPS aka 3D Driveguard */ | ||
543 | static struct acpi_driver lis3lv02d_driver = { | ||
544 | .name = DRIVER_NAME, | ||
545 | .class = ACPI_MDPS_CLASS, | ||
546 | .ids = lis3lv02d_device_ids, | ||
547 | .ops = { | ||
548 | .add = lis3lv02d_add, | ||
549 | .remove = lis3lv02d_remove, | ||
550 | .suspend = lis3lv02d_suspend, | ||
551 | .resume = lis3lv02d_resume, | ||
552 | } | ||
553 | }; | ||
554 | |||
555 | static int __init lis3lv02d_init_module(void) | ||
556 | { | ||
557 | int ret; | ||
558 | |||
559 | if (acpi_disabled) | ||
560 | return -ENODEV; | ||
561 | |||
562 | ret = acpi_bus_register_driver(&lis3lv02d_driver); | ||
563 | if (ret < 0) | ||
564 | return ret; | ||
565 | |||
566 | printk(KERN_INFO DRIVER_NAME " driver loaded.\n"); | ||
567 | |||
568 | return 0; | ||
569 | } | ||
570 | |||
571 | static void __exit lis3lv02d_exit_module(void) | ||
572 | { | ||
573 | acpi_bus_unregister_driver(&lis3lv02d_driver); | ||
574 | } | ||
575 | |||
576 | MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver"); | ||
577 | MODULE_AUTHOR("Yan Burman and Eric Piel"); | ||
578 | MODULE_LICENSE("GPL"); | ||
579 | |||
580 | module_init(lis3lv02d_init_module); | ||
581 | module_exit(lis3lv02d_exit_module); | ||
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h new file mode 100644 index 000000000000..330cfc60e948 --- /dev/null +++ b/drivers/hwmon/lis3lv02d.h | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * lis3lv02d.h - ST LIS3LV02DL accelerometer driver | ||
3 | * | ||
4 | * Copyright (C) 2007-2008 Yan Burman | ||
5 | * Copyright (C) 2008 Eric Piel | ||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to | ||
24 | * be connected via SPI. There exists also several similar chips (such as LIS302DL or | ||
25 | * LIS3L02DQ) but not in the HP laptops and they have slightly different registers. | ||
26 | * They can also be connected via I²C. | ||
27 | */ | ||
28 | |||
29 | #define LIS3LV02DL_ID 0x3A /* Also the LIS3LV02DQ */ | ||
30 | #define LIS302DL_ID 0x3B /* Also the LIS202DL! */ | ||
31 | |||
32 | enum lis3lv02d_reg { | ||
33 | WHO_AM_I = 0x0F, | ||
34 | OFFSET_X = 0x16, | ||
35 | OFFSET_Y = 0x17, | ||
36 | OFFSET_Z = 0x18, | ||
37 | GAIN_X = 0x19, | ||
38 | GAIN_Y = 0x1A, | ||
39 | GAIN_Z = 0x1B, | ||
40 | CTRL_REG1 = 0x20, | ||
41 | CTRL_REG2 = 0x21, | ||
42 | CTRL_REG3 = 0x22, | ||
43 | HP_FILTER_RESET = 0x23, | ||
44 | STATUS_REG = 0x27, | ||
45 | OUTX_L = 0x28, | ||
46 | OUTX_H = 0x29, | ||
47 | OUTY_L = 0x2A, | ||
48 | OUTY_H = 0x2B, | ||
49 | OUTZ_L = 0x2C, | ||
50 | OUTZ_H = 0x2D, | ||
51 | FF_WU_CFG = 0x30, | ||
52 | FF_WU_SRC = 0x31, | ||
53 | FF_WU_ACK = 0x32, | ||
54 | FF_WU_THS_L = 0x34, | ||
55 | FF_WU_THS_H = 0x35, | ||
56 | FF_WU_DURATION = 0x36, | ||
57 | DD_CFG = 0x38, | ||
58 | DD_SRC = 0x39, | ||
59 | DD_ACK = 0x3A, | ||
60 | DD_THSI_L = 0x3C, | ||
61 | DD_THSI_H = 0x3D, | ||
62 | DD_THSE_L = 0x3E, | ||
63 | DD_THSE_H = 0x3F, | ||
64 | }; | ||
65 | |||
66 | enum lis3lv02d_ctrl1 { | ||
67 | CTRL1_Xen = 0x01, | ||
68 | CTRL1_Yen = 0x02, | ||
69 | CTRL1_Zen = 0x04, | ||
70 | CTRL1_ST = 0x08, | ||
71 | CTRL1_DF0 = 0x10, | ||
72 | CTRL1_DF1 = 0x20, | ||
73 | CTRL1_PD0 = 0x40, | ||
74 | CTRL1_PD1 = 0x80, | ||
75 | }; | ||
76 | enum lis3lv02d_ctrl2 { | ||
77 | CTRL2_DAS = 0x01, | ||
78 | CTRL2_SIM = 0x02, | ||
79 | CTRL2_DRDY = 0x04, | ||
80 | CTRL2_IEN = 0x08, | ||
81 | CTRL2_BOOT = 0x10, | ||
82 | CTRL2_BLE = 0x20, | ||
83 | CTRL2_BDU = 0x40, /* Block Data Update */ | ||
84 | CTRL2_FS = 0x80, /* Full Scale selection */ | ||
85 | }; | ||
86 | |||
87 | |||
88 | enum lis3lv02d_ctrl3 { | ||
89 | CTRL3_CFS0 = 0x01, | ||
90 | CTRL3_CFS1 = 0x02, | ||
91 | CTRL3_FDS = 0x10, | ||
92 | CTRL3_HPFF = 0x20, | ||
93 | CTRL3_HPDD = 0x40, | ||
94 | CTRL3_ECK = 0x80, | ||
95 | }; | ||
96 | |||
97 | enum lis3lv02d_status_reg { | ||
98 | STATUS_XDA = 0x01, | ||
99 | STATUS_YDA = 0x02, | ||
100 | STATUS_ZDA = 0x04, | ||
101 | STATUS_XYZDA = 0x08, | ||
102 | STATUS_XOR = 0x10, | ||
103 | STATUS_YOR = 0x20, | ||
104 | STATUS_ZOR = 0x40, | ||
105 | STATUS_XYZOR = 0x80, | ||
106 | }; | ||
107 | |||
108 | enum lis3lv02d_ff_wu_cfg { | ||
109 | FF_WU_CFG_XLIE = 0x01, | ||
110 | FF_WU_CFG_XHIE = 0x02, | ||
111 | FF_WU_CFG_YLIE = 0x04, | ||
112 | FF_WU_CFG_YHIE = 0x08, | ||
113 | FF_WU_CFG_ZLIE = 0x10, | ||
114 | FF_WU_CFG_ZHIE = 0x20, | ||
115 | FF_WU_CFG_LIR = 0x40, | ||
116 | FF_WU_CFG_AOI = 0x80, | ||
117 | }; | ||
118 | |||
119 | enum lis3lv02d_ff_wu_src { | ||
120 | FF_WU_SRC_XL = 0x01, | ||
121 | FF_WU_SRC_XH = 0x02, | ||
122 | FF_WU_SRC_YL = 0x04, | ||
123 | FF_WU_SRC_YH = 0x08, | ||
124 | FF_WU_SRC_ZL = 0x10, | ||
125 | FF_WU_SRC_ZH = 0x20, | ||
126 | FF_WU_SRC_IA = 0x40, | ||
127 | }; | ||
128 | |||
129 | enum lis3lv02d_dd_cfg { | ||
130 | DD_CFG_XLIE = 0x01, | ||
131 | DD_CFG_XHIE = 0x02, | ||
132 | DD_CFG_YLIE = 0x04, | ||
133 | DD_CFG_YHIE = 0x08, | ||
134 | DD_CFG_ZLIE = 0x10, | ||
135 | DD_CFG_ZHIE = 0x20, | ||
136 | DD_CFG_LIR = 0x40, | ||
137 | DD_CFG_IEND = 0x80, | ||
138 | }; | ||
139 | |||
140 | enum lis3lv02d_dd_src { | ||
141 | DD_SRC_XL = 0x01, | ||
142 | DD_SRC_XH = 0x02, | ||
143 | DD_SRC_YL = 0x04, | ||
144 | DD_SRC_YH = 0x08, | ||
145 | DD_SRC_ZL = 0x10, | ||
146 | DD_SRC_ZH = 0x20, | ||
147 | DD_SRC_IA = 0x40, | ||
148 | }; | ||
149 | |||
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 3ff0285396fa..cfc1ee90f5a3 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -39,7 +39,8 @@ | |||
39 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 39 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
40 | 40 | ||
41 | /* Insmod parameters */ | 41 | /* Insmod parameters */ |
42 | I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); | 42 | I2C_CLIENT_INSMOD_7(lm85b, lm85c, adm1027, adt7463, adt7468, emc6d100, |
43 | emc6d102); | ||
43 | 44 | ||
44 | /* The LM85 registers */ | 45 | /* The LM85 registers */ |
45 | 46 | ||
@@ -59,6 +60,12 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); | |||
59 | 60 | ||
60 | #define LM85_REG_COMPANY 0x3e | 61 | #define LM85_REG_COMPANY 0x3e |
61 | #define LM85_REG_VERSTEP 0x3f | 62 | #define LM85_REG_VERSTEP 0x3f |
63 | |||
64 | #define ADT7468_REG_CFG5 0x7c | ||
65 | #define ADT7468_OFF64 0x01 | ||
66 | #define IS_ADT7468_OFF64(data) \ | ||
67 | ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_OFF64)) | ||
68 | |||
62 | /* These are the recognized values for the above regs */ | 69 | /* These are the recognized values for the above regs */ |
63 | #define LM85_COMPANY_NATIONAL 0x01 | 70 | #define LM85_COMPANY_NATIONAL 0x01 |
64 | #define LM85_COMPANY_ANALOG_DEV 0x41 | 71 | #define LM85_COMPANY_ANALOG_DEV 0x41 |
@@ -70,6 +77,8 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); | |||
70 | #define LM85_VERSTEP_ADM1027 0x60 | 77 | #define LM85_VERSTEP_ADM1027 0x60 |
71 | #define LM85_VERSTEP_ADT7463 0x62 | 78 | #define LM85_VERSTEP_ADT7463 0x62 |
72 | #define LM85_VERSTEP_ADT7463C 0x6A | 79 | #define LM85_VERSTEP_ADT7463C 0x6A |
80 | #define LM85_VERSTEP_ADT7468_1 0x71 | ||
81 | #define LM85_VERSTEP_ADT7468_2 0x72 | ||
73 | #define LM85_VERSTEP_EMC6D100_A0 0x60 | 82 | #define LM85_VERSTEP_EMC6D100_A0 0x60 |
74 | #define LM85_VERSTEP_EMC6D100_A1 0x61 | 83 | #define LM85_VERSTEP_EMC6D100_A1 0x61 |
75 | #define LM85_VERSTEP_EMC6D102 0x65 | 84 | #define LM85_VERSTEP_EMC6D102 0x65 |
@@ -306,6 +315,7 @@ struct lm85_data { | |||
306 | u8 vid; /* Register value */ | 315 | u8 vid; /* Register value */ |
307 | u8 vrm; /* VRM version */ | 316 | u8 vrm; /* VRM version */ |
308 | u32 alarms; /* Register encoding, combined */ | 317 | u32 alarms; /* Register encoding, combined */ |
318 | u8 cfg5; /* Config Register 5 on ADT7468 */ | ||
309 | struct lm85_autofan autofan[3]; | 319 | struct lm85_autofan autofan[3]; |
310 | struct lm85_zone zone[3]; | 320 | struct lm85_zone zone[3]; |
311 | }; | 321 | }; |
@@ -685,6 +695,9 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
685 | struct lm85_data *data = i2c_get_clientdata(client); | 695 | struct lm85_data *data = i2c_get_clientdata(client); |
686 | long val = simple_strtol(buf, NULL, 10); | 696 | long val = simple_strtol(buf, NULL, 10); |
687 | 697 | ||
698 | if (IS_ADT7468_OFF64(data)) | ||
699 | val += 64; | ||
700 | |||
688 | mutex_lock(&data->update_lock); | 701 | mutex_lock(&data->update_lock); |
689 | data->temp_min[nr] = TEMP_TO_REG(val); | 702 | data->temp_min[nr] = TEMP_TO_REG(val); |
690 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); | 703 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); |
@@ -708,6 +721,9 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
708 | struct lm85_data *data = i2c_get_clientdata(client); | 721 | struct lm85_data *data = i2c_get_clientdata(client); |
709 | long val = simple_strtol(buf, NULL, 10); | 722 | long val = simple_strtol(buf, NULL, 10); |
710 | 723 | ||
724 | if (IS_ADT7468_OFF64(data)) | ||
725 | val += 64; | ||
726 | |||
711 | mutex_lock(&data->update_lock); | 727 | mutex_lock(&data->update_lock); |
712 | data->temp_max[nr] = TEMP_TO_REG(val); | 728 | data->temp_max[nr] = TEMP_TO_REG(val); |
713 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); | 729 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); |
@@ -1163,6 +1179,10 @@ static int lm85_detect(struct i2c_client *client, int kind, | |||
1163 | case LM85_VERSTEP_ADT7463C: | 1179 | case LM85_VERSTEP_ADT7463C: |
1164 | kind = adt7463; | 1180 | kind = adt7463; |
1165 | break; | 1181 | break; |
1182 | case LM85_VERSTEP_ADT7468_1: | ||
1183 | case LM85_VERSTEP_ADT7468_2: | ||
1184 | kind = adt7468; | ||
1185 | break; | ||
1166 | } | 1186 | } |
1167 | } else if (company == LM85_COMPANY_SMSC) { | 1187 | } else if (company == LM85_COMPANY_SMSC) { |
1168 | switch (verstep) { | 1188 | switch (verstep) { |
@@ -1195,6 +1215,9 @@ static int lm85_detect(struct i2c_client *client, int kind, | |||
1195 | case adt7463: | 1215 | case adt7463: |
1196 | type_name = "adt7463"; | 1216 | type_name = "adt7463"; |
1197 | break; | 1217 | break; |
1218 | case adt7468: | ||
1219 | type_name = "adt7468"; | ||
1220 | break; | ||
1198 | case emc6d100: | 1221 | case emc6d100: |
1199 | type_name = "emc6d100"; | 1222 | type_name = "emc6d100"; |
1200 | break; | 1223 | break; |
@@ -1246,10 +1269,11 @@ static int lm85_probe(struct i2c_client *client, | |||
1246 | if (err) | 1269 | if (err) |
1247 | goto err_kfree; | 1270 | goto err_kfree; |
1248 | 1271 | ||
1249 | /* The ADT7463 has an optional VRM 10 mode where pin 21 is used | 1272 | /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used |
1250 | as a sixth digital VID input rather than an analog input. */ | 1273 | as a sixth digital VID input rather than an analog input. */ |
1251 | data->vid = lm85_read_value(client, LM85_REG_VID); | 1274 | data->vid = lm85_read_value(client, LM85_REG_VID); |
1252 | if (!(data->type == adt7463 && (data->vid & 0x80))) | 1275 | if (!((data->type == adt7463 || data->type == adt7468) && |
1276 | (data->vid & 0x80))) | ||
1253 | if ((err = sysfs_create_group(&client->dev.kobj, | 1277 | if ((err = sysfs_create_group(&client->dev.kobj, |
1254 | &lm85_group_in4))) | 1278 | &lm85_group_in4))) |
1255 | goto err_remove_files; | 1279 | goto err_remove_files; |
@@ -1357,7 +1381,8 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1357 | * There are 2 additional resolution bits per channel and we | 1381 | * There are 2 additional resolution bits per channel and we |
1358 | * have room for 4, so we shift them to the left. | 1382 | * have room for 4, so we shift them to the left. |
1359 | */ | 1383 | */ |
1360 | if (data->type == adm1027 || data->type == adt7463) { | 1384 | if (data->type == adm1027 || data->type == adt7463 || |
1385 | data->type == adt7468) { | ||
1361 | int ext1 = lm85_read_value(client, | 1386 | int ext1 = lm85_read_value(client, |
1362 | ADM1027_REG_EXTEND_ADC1); | 1387 | ADM1027_REG_EXTEND_ADC1); |
1363 | int ext2 = lm85_read_value(client, | 1388 | int ext2 = lm85_read_value(client, |
@@ -1382,16 +1407,23 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1382 | lm85_read_value(client, LM85_REG_FAN(i)); | 1407 | lm85_read_value(client, LM85_REG_FAN(i)); |
1383 | } | 1408 | } |
1384 | 1409 | ||
1385 | if (!(data->type == adt7463 && (data->vid & 0x80))) { | 1410 | if (!((data->type == adt7463 || data->type == adt7468) && |
1411 | (data->vid & 0x80))) { | ||
1386 | data->in[4] = lm85_read_value(client, | 1412 | data->in[4] = lm85_read_value(client, |
1387 | LM85_REG_IN(4)); | 1413 | LM85_REG_IN(4)); |
1388 | } | 1414 | } |
1389 | 1415 | ||
1416 | if (data->type == adt7468) | ||
1417 | data->cfg5 = lm85_read_value(client, ADT7468_REG_CFG5); | ||
1418 | |||
1390 | for (i = 0; i <= 2; ++i) { | 1419 | for (i = 0; i <= 2; ++i) { |
1391 | data->temp[i] = | 1420 | data->temp[i] = |
1392 | lm85_read_value(client, LM85_REG_TEMP(i)); | 1421 | lm85_read_value(client, LM85_REG_TEMP(i)); |
1393 | data->pwm[i] = | 1422 | data->pwm[i] = |
1394 | lm85_read_value(client, LM85_REG_PWM(i)); | 1423 | lm85_read_value(client, LM85_REG_PWM(i)); |
1424 | |||
1425 | if (IS_ADT7468_OFF64(data)) | ||
1426 | data->temp[i] -= 64; | ||
1395 | } | 1427 | } |
1396 | 1428 | ||
1397 | data->alarms = lm85_read_value(client, LM85_REG_ALARM1); | 1429 | data->alarms = lm85_read_value(client, LM85_REG_ALARM1); |
@@ -1446,7 +1478,8 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1446 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); | 1478 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); |
1447 | } | 1479 | } |
1448 | 1480 | ||
1449 | if (!(data->type == adt7463 && (data->vid & 0x80))) { | 1481 | if (!((data->type == adt7463 || data->type == adt7468) && |
1482 | (data->vid & 0x80))) { | ||
1450 | data->in_min[4] = lm85_read_value(client, | 1483 | data->in_min[4] = lm85_read_value(client, |
1451 | LM85_REG_IN_MIN(4)); | 1484 | LM85_REG_IN_MIN(4)); |
1452 | data->in_max[4] = lm85_read_value(client, | 1485 | data->in_max[4] = lm85_read_value(client, |
@@ -1481,6 +1514,13 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1481 | lm85_read_value(client, LM85_REG_AFAN_LIMIT(i)); | 1514 | lm85_read_value(client, LM85_REG_AFAN_LIMIT(i)); |
1482 | data->zone[i].critical = | 1515 | data->zone[i].critical = |
1483 | lm85_read_value(client, LM85_REG_AFAN_CRITICAL(i)); | 1516 | lm85_read_value(client, LM85_REG_AFAN_CRITICAL(i)); |
1517 | |||
1518 | if (IS_ADT7468_OFF64(data)) { | ||
1519 | data->temp_min[i] -= 64; | ||
1520 | data->temp_max[i] -= 64; | ||
1521 | data->zone[i].limit -= 64; | ||
1522 | data->zone[i].critical -= 64; | ||
1523 | } | ||
1484 | } | 1524 | } |
1485 | 1525 | ||
1486 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); | 1526 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 640cbb237328..3384a717fec0 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -318,7 +318,8 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) | |||
318 | } else | 318 | } else |
319 | data = i2c_op(pd, OP_RX, 0); | 319 | data = i2c_op(pd, OP_RX, 0); |
320 | 320 | ||
321 | pd->msg->buf[real_pos] = data; | 321 | if (real_pos >= 0) |
322 | pd->msg->buf[real_pos] = data; | ||
322 | } while (0); | 323 | } while (0); |
323 | 324 | ||
324 | pd->pos++; | 325 | pd->pos++; |
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c index cb199c815b53..f50210fe558f 100644 --- a/drivers/ide/ide-cs.c +++ b/drivers/ide/ide-cs.c | |||
@@ -444,6 +444,7 @@ static struct pcmcia_device_id ide_ids[] = { | |||
444 | PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), | 444 | PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), |
445 | PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), | 445 | PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), |
446 | PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), | 446 | PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), |
447 | PCMCIA_DEVICE_PROD_ID2("Flash Card", 0x5a362506), | ||
447 | PCMCIA_DEVICE_NULL, | 448 | PCMCIA_DEVICE_NULL, |
448 | }; | 449 | }; |
449 | MODULE_DEVICE_TABLE(pcmcia, ide_ids); | 450 | MODULE_DEVICE_TABLE(pcmcia, ide_ids); |
diff --git a/drivers/idle/Kconfig b/drivers/idle/Kconfig index 108264de0ac9..f15e90a453d1 100644 --- a/drivers/idle/Kconfig +++ b/drivers/idle/Kconfig | |||
@@ -1,5 +1,6 @@ | |||
1 | 1 | ||
2 | menu "Memory power savings" | 2 | menu "Memory power savings" |
3 | depends on X86_64 | ||
3 | 4 | ||
4 | config I7300_IDLE_IOAT_CHANNEL | 5 | config I7300_IDLE_IOAT_CHANNEL |
5 | bool | 6 | bool |
@@ -7,7 +8,7 @@ config I7300_IDLE_IOAT_CHANNEL | |||
7 | config I7300_IDLE | 8 | config I7300_IDLE |
8 | tristate "Intel chipset idle memory power saving driver" | 9 | tristate "Intel chipset idle memory power saving driver" |
9 | select I7300_IDLE_IOAT_CHANNEL | 10 | select I7300_IDLE_IOAT_CHANNEL |
10 | depends on X86_64 && EXPERIMENTAL | 11 | depends on EXPERIMENTAL |
11 | help | 12 | help |
12 | Enable memory power savings when idle with certain Intel server | 13 | Enable memory power savings when idle with certain Intel server |
13 | chipsets. The chipset must have I/O AT support, such as the | 14 | chipsets. The chipset must have I/O AT support, such as the |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index ecff98043589..160ef482712d 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
@@ -1102,9 +1102,7 @@ static u64 fw_vers_string_to_u64(struct iwch_dev *iwch_dev) | |||
1102 | char *cp, *next; | 1102 | char *cp, *next; |
1103 | unsigned fw_maj, fw_min, fw_mic; | 1103 | unsigned fw_maj, fw_min, fw_mic; |
1104 | 1104 | ||
1105 | rtnl_lock(); | ||
1106 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | 1105 | lldev->ethtool_ops->get_drvinfo(lldev, &info); |
1107 | rtnl_unlock(); | ||
1108 | 1106 | ||
1109 | next = info.fw_version + 1; | 1107 | next = info.fw_version + 1; |
1110 | cp = strsep(&next, "."); | 1108 | cp = strsep(&next, "."); |
@@ -1192,9 +1190,7 @@ static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, ch | |||
1192 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; | 1190 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; |
1193 | 1191 | ||
1194 | PDBG("%s dev 0x%p\n", __func__, dev); | 1192 | PDBG("%s dev 0x%p\n", __func__, dev); |
1195 | rtnl_lock(); | ||
1196 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | 1193 | lldev->ethtool_ops->get_drvinfo(lldev, &info); |
1197 | rtnl_unlock(); | ||
1198 | return sprintf(buf, "%s\n", info.fw_version); | 1194 | return sprintf(buf, "%s\n", info.fw_version); |
1199 | } | 1195 | } |
1200 | 1196 | ||
@@ -1207,9 +1203,7 @@ static ssize_t show_hca(struct device *dev, struct device_attribute *attr, | |||
1207 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; | 1203 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; |
1208 | 1204 | ||
1209 | PDBG("%s dev 0x%p\n", __func__, dev); | 1205 | PDBG("%s dev 0x%p\n", __func__, dev); |
1210 | rtnl_lock(); | ||
1211 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | 1206 | lldev->ethtool_ops->get_drvinfo(lldev, &info); |
1212 | rtnl_unlock(); | ||
1213 | return sprintf(buf, "%s\n", info.driver); | 1207 | return sprintf(buf, "%s\n", info.driver); |
1214 | } | 1208 | } |
1215 | 1209 | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c index 3e4585c2318a..19661b2f0406 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c | |||
@@ -745,7 +745,6 @@ int iwch_post_zb_read(struct iwch_qp *qhp) | |||
745 | wqe->read.rdmaop = T3_READ_REQ; | 745 | wqe->read.rdmaop = T3_READ_REQ; |
746 | wqe->read.reserved[0] = 0; | 746 | wqe->read.reserved[0] = 0; |
747 | wqe->read.reserved[1] = 0; | 747 | wqe->read.reserved[1] = 0; |
748 | wqe->read.reserved[2] = 0; | ||
749 | wqe->read.rem_stag = cpu_to_be32(1); | 748 | wqe->read.rem_stag = cpu_to_be32(1); |
750 | wqe->read.rem_to = cpu_to_be64(1); | 749 | wqe->read.rem_to = cpu_to_be64(1); |
751 | wqe->read.local_stag = cpu_to_be32(1); | 750 | wqe->read.local_stag = cpu_to_be32(1); |
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c index cb55be04442c..757035ea246f 100644 --- a/drivers/infiniband/hw/ehca/ehca_irq.c +++ b/drivers/infiniband/hw/ehca/ehca_irq.c | |||
@@ -359,36 +359,48 @@ static void notify_port_conf_change(struct ehca_shca *shca, int port_num) | |||
359 | *old_attr = new_attr; | 359 | *old_attr = new_attr; |
360 | } | 360 | } |
361 | 361 | ||
362 | /* replay modify_qp for sqps -- return 0 if all is well, 1 if AQP1 destroyed */ | ||
363 | static int replay_modify_qp(struct ehca_sport *sport) | ||
364 | { | ||
365 | int aqp1_destroyed; | ||
366 | unsigned long flags; | ||
367 | |||
368 | spin_lock_irqsave(&sport->mod_sqp_lock, flags); | ||
369 | |||
370 | aqp1_destroyed = !sport->ibqp_sqp[IB_QPT_GSI]; | ||
371 | |||
372 | if (sport->ibqp_sqp[IB_QPT_SMI]) | ||
373 | ehca_recover_sqp(sport->ibqp_sqp[IB_QPT_SMI]); | ||
374 | if (!aqp1_destroyed) | ||
375 | ehca_recover_sqp(sport->ibqp_sqp[IB_QPT_GSI]); | ||
376 | |||
377 | spin_unlock_irqrestore(&sport->mod_sqp_lock, flags); | ||
378 | |||
379 | return aqp1_destroyed; | ||
380 | } | ||
381 | |||
362 | static void parse_ec(struct ehca_shca *shca, u64 eqe) | 382 | static void parse_ec(struct ehca_shca *shca, u64 eqe) |
363 | { | 383 | { |
364 | u8 ec = EHCA_BMASK_GET(NEQE_EVENT_CODE, eqe); | 384 | u8 ec = EHCA_BMASK_GET(NEQE_EVENT_CODE, eqe); |
365 | u8 port = EHCA_BMASK_GET(NEQE_PORT_NUMBER, eqe); | 385 | u8 port = EHCA_BMASK_GET(NEQE_PORT_NUMBER, eqe); |
366 | u8 spec_event; | 386 | u8 spec_event; |
367 | struct ehca_sport *sport = &shca->sport[port - 1]; | 387 | struct ehca_sport *sport = &shca->sport[port - 1]; |
368 | unsigned long flags; | ||
369 | 388 | ||
370 | switch (ec) { | 389 | switch (ec) { |
371 | case 0x30: /* port availability change */ | 390 | case 0x30: /* port availability change */ |
372 | if (EHCA_BMASK_GET(NEQE_PORT_AVAILABILITY, eqe)) { | 391 | if (EHCA_BMASK_GET(NEQE_PORT_AVAILABILITY, eqe)) { |
373 | int suppress_event; | 392 | /* only replay modify_qp calls in autodetect mode; |
374 | /* replay modify_qp for sqps */ | 393 | * if AQP1 was destroyed, the port is already down |
375 | spin_lock_irqsave(&sport->mod_sqp_lock, flags); | 394 | * again and we can drop the event. |
376 | suppress_event = !sport->ibqp_sqp[IB_QPT_GSI]; | 395 | */ |
377 | if (sport->ibqp_sqp[IB_QPT_SMI]) | 396 | if (ehca_nr_ports < 0) |
378 | ehca_recover_sqp(sport->ibqp_sqp[IB_QPT_SMI]); | 397 | if (replay_modify_qp(sport)) |
379 | if (!suppress_event) | 398 | break; |
380 | ehca_recover_sqp(sport->ibqp_sqp[IB_QPT_GSI]); | ||
381 | spin_unlock_irqrestore(&sport->mod_sqp_lock, flags); | ||
382 | |||
383 | /* AQP1 was destroyed, ignore this event */ | ||
384 | if (suppress_event) | ||
385 | break; | ||
386 | 399 | ||
387 | sport->port_state = IB_PORT_ACTIVE; | 400 | sport->port_state = IB_PORT_ACTIVE; |
388 | dispatch_port_event(shca, port, IB_EVENT_PORT_ACTIVE, | 401 | dispatch_port_event(shca, port, IB_EVENT_PORT_ACTIVE, |
389 | "is active"); | 402 | "is active"); |
390 | ehca_query_sma_attr(shca, port, | 403 | ehca_query_sma_attr(shca, port, &sport->saved_attr); |
391 | &sport->saved_attr); | ||
392 | } else { | 404 | } else { |
393 | sport->port_state = IB_PORT_DOWN; | 405 | sport->port_state = IB_PORT_DOWN; |
394 | dispatch_port_event(shca, port, IB_EVENT_PORT_ERR, | 406 | dispatch_port_event(shca, port, IB_EVENT_PORT_ERR, |
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c index 4d54b9f64567..9e05ee2db39b 100644 --- a/drivers/infiniband/hw/ehca/ehca_qp.c +++ b/drivers/infiniband/hw/ehca/ehca_qp.c | |||
@@ -860,6 +860,11 @@ static struct ehca_qp *internal_create_qp( | |||
860 | if (qp_type == IB_QPT_GSI) { | 860 | if (qp_type == IB_QPT_GSI) { |
861 | h_ret = ehca_define_sqp(shca, my_qp, init_attr); | 861 | h_ret = ehca_define_sqp(shca, my_qp, init_attr); |
862 | if (h_ret != H_SUCCESS) { | 862 | if (h_ret != H_SUCCESS) { |
863 | kfree(my_qp->mod_qp_parm); | ||
864 | my_qp->mod_qp_parm = NULL; | ||
865 | /* the QP pointer is no longer valid */ | ||
866 | shca->sport[init_attr->port_num - 1].ibqp_sqp[qp_type] = | ||
867 | NULL; | ||
863 | ret = ehca2ib_return_code(h_ret); | 868 | ret = ehca2ib_return_code(h_ret); |
864 | goto create_qp_exit6; | 869 | goto create_qp_exit6; |
865 | } | 870 | } |
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c index fc0f6d9e6030..2296832f94da 100644 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c | |||
@@ -156,7 +156,7 @@ bail: | |||
156 | /** | 156 | /** |
157 | * ipath_get_rwqe - copy the next RWQE into the QP's RWQE | 157 | * ipath_get_rwqe - copy the next RWQE into the QP's RWQE |
158 | * @qp: the QP | 158 | * @qp: the QP |
159 | * @wr_id_only: update wr_id only, not SGEs | 159 | * @wr_id_only: update qp->r_wr_id only, not qp->r_sge |
160 | * | 160 | * |
161 | * Return 0 if no RWQE is available, otherwise return 1. | 161 | * Return 0 if no RWQE is available, otherwise return 1. |
162 | * | 162 | * |
@@ -173,8 +173,6 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only) | |||
173 | u32 tail; | 173 | u32 tail; |
174 | int ret; | 174 | int ret; |
175 | 175 | ||
176 | qp->r_sge.sg_list = qp->r_sg_list; | ||
177 | |||
178 | if (qp->ibqp.srq) { | 176 | if (qp->ibqp.srq) { |
179 | srq = to_isrq(qp->ibqp.srq); | 177 | srq = to_isrq(qp->ibqp.srq); |
180 | handler = srq->ibsrq.event_handler; | 178 | handler = srq->ibsrq.event_handler; |
@@ -206,8 +204,10 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only) | |||
206 | wqe = get_rwqe_ptr(rq, tail); | 204 | wqe = get_rwqe_ptr(rq, tail); |
207 | if (++tail >= rq->size) | 205 | if (++tail >= rq->size) |
208 | tail = 0; | 206 | tail = 0; |
209 | } while (!wr_id_only && !ipath_init_sge(qp, wqe, &qp->r_len, | 207 | if (wr_id_only) |
210 | &qp->r_sge)); | 208 | break; |
209 | qp->r_sge.sg_list = qp->r_sg_list; | ||
210 | } while (!ipath_init_sge(qp, wqe, &qp->r_len, &qp->r_sge)); | ||
211 | qp->r_wr_id = wqe->wr_id; | 211 | qp->r_wr_id = wqe->wr_id; |
212 | wq->tail = tail; | 212 | wq->tail = tail; |
213 | 213 | ||
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c index 87f5c5a87b98..8e4d26d56a95 100644 --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c | |||
@@ -205,6 +205,7 @@ struct ib_mr *mlx4_ib_alloc_fast_reg_mr(struct ib_pd *pd, | |||
205 | goto err_mr; | 205 | goto err_mr; |
206 | 206 | ||
207 | mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key; | 207 | mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key; |
208 | mr->umem = NULL; | ||
208 | 209 | ||
209 | return &mr->ibmr; | 210 | return &mr->ibmr; |
210 | 211 | ||
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c index a2b04d62b1a4..aa1dc41f04c8 100644 --- a/drivers/infiniband/hw/nes/nes.c +++ b/drivers/infiniband/hw/nes/nes.c | |||
@@ -95,6 +95,10 @@ unsigned int wqm_quanta = 0x10000; | |||
95 | module_param(wqm_quanta, int, 0644); | 95 | module_param(wqm_quanta, int, 0644); |
96 | MODULE_PARM_DESC(wqm_quanta, "WQM quanta"); | 96 | MODULE_PARM_DESC(wqm_quanta, "WQM quanta"); |
97 | 97 | ||
98 | static unsigned int limit_maxrdreqsz; | ||
99 | module_param(limit_maxrdreqsz, bool, 0644); | ||
100 | MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes"); | ||
101 | |||
98 | LIST_HEAD(nes_adapter_list); | 102 | LIST_HEAD(nes_adapter_list); |
99 | static LIST_HEAD(nes_dev_list); | 103 | static LIST_HEAD(nes_dev_list); |
100 | 104 | ||
@@ -588,6 +592,18 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i | |||
588 | nesdev->nesadapter->port_count; | 592 | nesdev->nesadapter->port_count; |
589 | } | 593 | } |
590 | 594 | ||
595 | if ((limit_maxrdreqsz || | ||
596 | ((nesdev->nesadapter->phy_type[0] == NES_PHY_TYPE_GLADIUS) && | ||
597 | (hw_rev == NE020_REV1))) && | ||
598 | (pcie_get_readrq(pcidev) > 256)) { | ||
599 | if (pcie_set_readrq(pcidev, 256)) | ||
600 | printk(KERN_ERR PFX "Unable to set max read request" | ||
601 | " to 256 bytes\n"); | ||
602 | else | ||
603 | nes_debug(NES_DBG_INIT, "Max read request size set" | ||
604 | " to 256 bytes\n"); | ||
605 | } | ||
606 | |||
591 | tasklet_init(&nesdev->dpc_tasklet, nes_dpc, (unsigned long)nesdev); | 607 | tasklet_init(&nesdev->dpc_tasklet, nes_dpc, (unsigned long)nesdev); |
592 | 608 | ||
593 | /* bring up the Control QP */ | 609 | /* bring up the Control QP */ |
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h index 610b9d859597..bc0b4de04450 100644 --- a/drivers/infiniband/hw/nes/nes_hw.h +++ b/drivers/infiniband/hw/nes/nes_hw.h | |||
@@ -40,6 +40,7 @@ | |||
40 | #define NES_PHY_TYPE_ARGUS 4 | 40 | #define NES_PHY_TYPE_ARGUS 4 |
41 | #define NES_PHY_TYPE_PUMA_1G 5 | 41 | #define NES_PHY_TYPE_PUMA_1G 5 |
42 | #define NES_PHY_TYPE_PUMA_10G 6 | 42 | #define NES_PHY_TYPE_PUMA_10G 6 |
43 | #define NES_PHY_TYPE_GLADIUS 7 | ||
43 | 44 | ||
44 | #define NES_MULTICAST_PF_MAX 8 | 45 | #define NES_MULTICAST_PF_MAX 8 |
45 | 46 | ||
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 932e56fcf774..d36c9a0bf1bb 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c | |||
@@ -220,14 +220,14 @@ static int nes_bind_mw(struct ib_qp *ibqp, struct ib_mw *ibmw, | |||
220 | if (nesqp->ibqp_state > IB_QPS_RTS) | 220 | if (nesqp->ibqp_state > IB_QPS_RTS) |
221 | return -EINVAL; | 221 | return -EINVAL; |
222 | 222 | ||
223 | spin_lock_irqsave(&nesqp->lock, flags); | 223 | spin_lock_irqsave(&nesqp->lock, flags); |
224 | 224 | ||
225 | head = nesqp->hwqp.sq_head; | 225 | head = nesqp->hwqp.sq_head; |
226 | qsize = nesqp->hwqp.sq_tail; | 226 | qsize = nesqp->hwqp.sq_tail; |
227 | 227 | ||
228 | /* Check for SQ overflow */ | 228 | /* Check for SQ overflow */ |
229 | if (((head + (2 * qsize) - nesqp->hwqp.sq_tail) % qsize) == (qsize - 1)) { | 229 | if (((head + (2 * qsize) - nesqp->hwqp.sq_tail) % qsize) == (qsize - 1)) { |
230 | spin_unlock_irqrestore(&nesqp->lock, flags); | 230 | spin_unlock_irqrestore(&nesqp->lock, flags); |
231 | return -EINVAL; | 231 | return -EINVAL; |
232 | } | 232 | } |
233 | 233 | ||
@@ -269,7 +269,7 @@ static int nes_bind_mw(struct ib_qp *ibqp, struct ib_mw *ibmw, | |||
269 | nes_write32(nesdev->regs+NES_WQE_ALLOC, | 269 | nes_write32(nesdev->regs+NES_WQE_ALLOC, |
270 | (1 << 24) | 0x00800000 | nesqp->hwqp.qp_id); | 270 | (1 << 24) | 0x00800000 | nesqp->hwqp.qp_id); |
271 | 271 | ||
272 | spin_unlock_irqrestore(&nesqp->lock, flags); | 272 | spin_unlock_irqrestore(&nesqp->lock, flags); |
273 | 273 | ||
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
@@ -349,7 +349,7 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
349 | if (nesfmr->nesmr.pbls_used > nesadapter->free_4kpbl) { | 349 | if (nesfmr->nesmr.pbls_used > nesadapter->free_4kpbl) { |
350 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | 350 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); |
351 | ret = -ENOMEM; | 351 | ret = -ENOMEM; |
352 | goto failed_vpbl_alloc; | 352 | goto failed_vpbl_avail; |
353 | } else { | 353 | } else { |
354 | nesadapter->free_4kpbl -= nesfmr->nesmr.pbls_used; | 354 | nesadapter->free_4kpbl -= nesfmr->nesmr.pbls_used; |
355 | } | 355 | } |
@@ -357,7 +357,7 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
357 | if (nesfmr->nesmr.pbls_used > nesadapter->free_256pbl) { | 357 | if (nesfmr->nesmr.pbls_used > nesadapter->free_256pbl) { |
358 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | 358 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); |
359 | ret = -ENOMEM; | 359 | ret = -ENOMEM; |
360 | goto failed_vpbl_alloc; | 360 | goto failed_vpbl_avail; |
361 | } else { | 361 | } else { |
362 | nesadapter->free_256pbl -= nesfmr->nesmr.pbls_used; | 362 | nesadapter->free_256pbl -= nesfmr->nesmr.pbls_used; |
363 | } | 363 | } |
@@ -391,14 +391,14 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
391 | goto failed_vpbl_alloc; | 391 | goto failed_vpbl_alloc; |
392 | } | 392 | } |
393 | 393 | ||
394 | nesfmr->root_vpbl.leaf_vpbl = kzalloc(sizeof(*nesfmr->root_vpbl.leaf_vpbl)*1024, GFP_KERNEL); | 394 | nesfmr->leaf_pbl_cnt = nesfmr->nesmr.pbls_used-1; |
395 | nesfmr->root_vpbl.leaf_vpbl = kzalloc(sizeof(*nesfmr->root_vpbl.leaf_vpbl)*1024, GFP_ATOMIC); | ||
395 | if (!nesfmr->root_vpbl.leaf_vpbl) { | 396 | if (!nesfmr->root_vpbl.leaf_vpbl) { |
396 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | 397 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); |
397 | ret = -ENOMEM; | 398 | ret = -ENOMEM; |
398 | goto failed_leaf_vpbl_alloc; | 399 | goto failed_leaf_vpbl_alloc; |
399 | } | 400 | } |
400 | 401 | ||
401 | nesfmr->leaf_pbl_cnt = nesfmr->nesmr.pbls_used-1; | ||
402 | nes_debug(NES_DBG_MR, "two level pbl, root_vpbl.pbl_vbase=%p" | 402 | nes_debug(NES_DBG_MR, "two level pbl, root_vpbl.pbl_vbase=%p" |
403 | " leaf_pbl_cnt=%d root_vpbl.leaf_vpbl=%p\n", | 403 | " leaf_pbl_cnt=%d root_vpbl.leaf_vpbl=%p\n", |
404 | nesfmr->root_vpbl.pbl_vbase, nesfmr->leaf_pbl_cnt, nesfmr->root_vpbl.leaf_vpbl); | 404 | nesfmr->root_vpbl.pbl_vbase, nesfmr->leaf_pbl_cnt, nesfmr->root_vpbl.leaf_vpbl); |
@@ -519,6 +519,16 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
519 | nesfmr->root_vpbl.pbl_pbase); | 519 | nesfmr->root_vpbl.pbl_pbase); |
520 | 520 | ||
521 | failed_vpbl_alloc: | 521 | failed_vpbl_alloc: |
522 | if (nesfmr->nesmr.pbls_used != 0) { | ||
523 | spin_lock_irqsave(&nesadapter->pbl_lock, flags); | ||
524 | if (nesfmr->nesmr.pbl_4k) | ||
525 | nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used; | ||
526 | else | ||
527 | nesadapter->free_256pbl += nesfmr->nesmr.pbls_used; | ||
528 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | ||
529 | } | ||
530 | |||
531 | failed_vpbl_avail: | ||
522 | kfree(nesfmr); | 532 | kfree(nesfmr); |
523 | 533 | ||
524 | failed_fmr_alloc: | 534 | failed_fmr_alloc: |
@@ -534,18 +544,14 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
534 | */ | 544 | */ |
535 | static int nes_dealloc_fmr(struct ib_fmr *ibfmr) | 545 | static int nes_dealloc_fmr(struct ib_fmr *ibfmr) |
536 | { | 546 | { |
547 | unsigned long flags; | ||
537 | struct nes_mr *nesmr = to_nesmr_from_ibfmr(ibfmr); | 548 | struct nes_mr *nesmr = to_nesmr_from_ibfmr(ibfmr); |
538 | struct nes_fmr *nesfmr = to_nesfmr(nesmr); | 549 | struct nes_fmr *nesfmr = to_nesfmr(nesmr); |
539 | struct nes_vnic *nesvnic = to_nesvnic(ibfmr->device); | 550 | struct nes_vnic *nesvnic = to_nesvnic(ibfmr->device); |
540 | struct nes_device *nesdev = nesvnic->nesdev; | 551 | struct nes_device *nesdev = nesvnic->nesdev; |
541 | struct nes_mr temp_nesmr = *nesmr; | 552 | struct nes_adapter *nesadapter = nesdev->nesadapter; |
542 | int i = 0; | 553 | int i = 0; |
543 | 554 | ||
544 | temp_nesmr.ibmw.device = ibfmr->device; | ||
545 | temp_nesmr.ibmw.pd = ibfmr->pd; | ||
546 | temp_nesmr.ibmw.rkey = ibfmr->rkey; | ||
547 | temp_nesmr.ibmw.uobject = NULL; | ||
548 | |||
549 | /* free the resources */ | 555 | /* free the resources */ |
550 | if (nesfmr->leaf_pbl_cnt == 0) { | 556 | if (nesfmr->leaf_pbl_cnt == 0) { |
551 | /* single PBL case */ | 557 | /* single PBL case */ |
@@ -561,8 +567,24 @@ static int nes_dealloc_fmr(struct ib_fmr *ibfmr) | |||
561 | pci_free_consistent(nesdev->pcidev, 8192, nesfmr->root_vpbl.pbl_vbase, | 567 | pci_free_consistent(nesdev->pcidev, 8192, nesfmr->root_vpbl.pbl_vbase, |
562 | nesfmr->root_vpbl.pbl_pbase); | 568 | nesfmr->root_vpbl.pbl_pbase); |
563 | } | 569 | } |
570 | nesmr->ibmw.device = ibfmr->device; | ||
571 | nesmr->ibmw.pd = ibfmr->pd; | ||
572 | nesmr->ibmw.rkey = ibfmr->rkey; | ||
573 | nesmr->ibmw.uobject = NULL; | ||
564 | 574 | ||
565 | return nes_dealloc_mw(&temp_nesmr.ibmw); | 575 | if (nesfmr->nesmr.pbls_used != 0) { |
576 | spin_lock_irqsave(&nesadapter->pbl_lock, flags); | ||
577 | if (nesfmr->nesmr.pbl_4k) { | ||
578 | nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used; | ||
579 | WARN_ON(nesadapter->free_4kpbl > nesadapter->max_4kpbl); | ||
580 | } else { | ||
581 | nesadapter->free_256pbl += nesfmr->nesmr.pbls_used; | ||
582 | WARN_ON(nesadapter->free_256pbl > nesadapter->max_256pbl); | ||
583 | } | ||
584 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | ||
585 | } | ||
586 | |||
587 | return nes_dealloc_mw(&nesmr->ibmw); | ||
566 | } | 588 | } |
567 | 589 | ||
568 | 590 | ||
@@ -1595,7 +1617,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, | |||
1595 | nes_ucontext->mcrqf = req.mcrqf; | 1617 | nes_ucontext->mcrqf = req.mcrqf; |
1596 | if (nes_ucontext->mcrqf) { | 1618 | if (nes_ucontext->mcrqf) { |
1597 | if (nes_ucontext->mcrqf & 0x80000000) | 1619 | if (nes_ucontext->mcrqf & 0x80000000) |
1598 | nescq->hw_cq.cq_number = nesvnic->nic.qp_id + 12 + (nes_ucontext->mcrqf & 0xf) - 1; | 1620 | nescq->hw_cq.cq_number = nesvnic->nic.qp_id + 28 + 2 * ((nes_ucontext->mcrqf & 0xf) - 1); |
1599 | else if (nes_ucontext->mcrqf & 0x40000000) | 1621 | else if (nes_ucontext->mcrqf & 0x40000000) |
1600 | nescq->hw_cq.cq_number = nes_ucontext->mcrqf & 0xffff; | 1622 | nescq->hw_cq.cq_number = nes_ucontext->mcrqf & 0xffff; |
1601 | else | 1623 | else |
@@ -3212,7 +3234,7 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr, | |||
3212 | if (nesqp->ibqp_state > IB_QPS_RTS) | 3234 | if (nesqp->ibqp_state > IB_QPS_RTS) |
3213 | return -EINVAL; | 3235 | return -EINVAL; |
3214 | 3236 | ||
3215 | spin_lock_irqsave(&nesqp->lock, flags); | 3237 | spin_lock_irqsave(&nesqp->lock, flags); |
3216 | 3238 | ||
3217 | head = nesqp->hwqp.sq_head; | 3239 | head = nesqp->hwqp.sq_head; |
3218 | 3240 | ||
@@ -3337,7 +3359,7 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr, | |||
3337 | (counter << 24) | 0x00800000 | nesqp->hwqp.qp_id); | 3359 | (counter << 24) | 0x00800000 | nesqp->hwqp.qp_id); |
3338 | } | 3360 | } |
3339 | 3361 | ||
3340 | spin_unlock_irqrestore(&nesqp->lock, flags); | 3362 | spin_unlock_irqrestore(&nesqp->lock, flags); |
3341 | 3363 | ||
3342 | if (err) | 3364 | if (err) |
3343 | *bad_wr = ib_wr; | 3365 | *bad_wr = ib_wr; |
@@ -3368,7 +3390,7 @@ static int nes_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr, | |||
3368 | if (nesqp->ibqp_state > IB_QPS_RTS) | 3390 | if (nesqp->ibqp_state > IB_QPS_RTS) |
3369 | return -EINVAL; | 3391 | return -EINVAL; |
3370 | 3392 | ||
3371 | spin_lock_irqsave(&nesqp->lock, flags); | 3393 | spin_lock_irqsave(&nesqp->lock, flags); |
3372 | 3394 | ||
3373 | head = nesqp->hwqp.rq_head; | 3395 | head = nesqp->hwqp.rq_head; |
3374 | 3396 | ||
@@ -3421,7 +3443,7 @@ static int nes_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr, | |||
3421 | nes_write32(nesdev->regs+NES_WQE_ALLOC, (counter<<24) | nesqp->hwqp.qp_id); | 3443 | nes_write32(nesdev->regs+NES_WQE_ALLOC, (counter<<24) | nesqp->hwqp.qp_id); |
3422 | } | 3444 | } |
3423 | 3445 | ||
3424 | spin_unlock_irqrestore(&nesqp->lock, flags); | 3446 | spin_unlock_irqrestore(&nesqp->lock, flags); |
3425 | 3447 | ||
3426 | if (err) | 3448 | if (err) |
3427 | *bad_wr = ib_wr; | 3449 | *bad_wr = ib_wr; |
@@ -3453,7 +3475,7 @@ static int nes_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry) | |||
3453 | 3475 | ||
3454 | nes_debug(NES_DBG_CQ, "\n"); | 3476 | nes_debug(NES_DBG_CQ, "\n"); |
3455 | 3477 | ||
3456 | spin_lock_irqsave(&nescq->lock, flags); | 3478 | spin_lock_irqsave(&nescq->lock, flags); |
3457 | 3479 | ||
3458 | head = nescq->hw_cq.cq_head; | 3480 | head = nescq->hw_cq.cq_head; |
3459 | cq_size = nescq->hw_cq.cq_size; | 3481 | cq_size = nescq->hw_cq.cq_size; |
@@ -3562,7 +3584,7 @@ static int nes_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry) | |||
3562 | nes_debug(NES_DBG_CQ, "Reporting %u completions for CQ%u.\n", | 3584 | nes_debug(NES_DBG_CQ, "Reporting %u completions for CQ%u.\n", |
3563 | cqe_count, nescq->hw_cq.cq_number); | 3585 | cqe_count, nescq->hw_cq.cq_number); |
3564 | 3586 | ||
3565 | spin_unlock_irqrestore(&nescq->lock, flags); | 3587 | spin_unlock_irqrestore(&nescq->lock, flags); |
3566 | 3588 | ||
3567 | return cqe_count; | 3589 | return cqe_count; |
3568 | } | 3590 | } |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index fddded7900d1..85257f6b9576 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -106,12 +106,13 @@ int ipoib_open(struct net_device *dev) | |||
106 | 106 | ||
107 | ipoib_dbg(priv, "bringing up interface\n"); | 107 | ipoib_dbg(priv, "bringing up interface\n"); |
108 | 108 | ||
109 | napi_enable(&priv->napi); | ||
110 | set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); | 109 | set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); |
111 | 110 | ||
112 | if (ipoib_pkey_dev_delay_open(dev)) | 111 | if (ipoib_pkey_dev_delay_open(dev)) |
113 | return 0; | 112 | return 0; |
114 | 113 | ||
114 | napi_enable(&priv->napi); | ||
115 | |||
115 | if (ipoib_ib_dev_open(dev)) { | 116 | if (ipoib_ib_dev_open(dev)) { |
116 | napi_disable(&priv->napi); | 117 | napi_disable(&priv->napi); |
117 | return -EINVAL; | 118 | return -EINVAL; |
@@ -546,6 +547,7 @@ static int path_rec_start(struct net_device *dev, | |||
546 | if (path->query_id < 0) { | 547 | if (path->query_id < 0) { |
547 | ipoib_warn(priv, "ib_sa_path_rec_get failed: %d\n", path->query_id); | 548 | ipoib_warn(priv, "ib_sa_path_rec_get failed: %d\n", path->query_id); |
548 | path->query = NULL; | 549 | path->query = NULL; |
550 | complete(&path->done); | ||
549 | return path->query_id; | 551 | return path->query_id; |
550 | } | 552 | } |
551 | 553 | ||
@@ -662,7 +664,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, | |||
662 | skb_push(skb, sizeof *phdr); | 664 | skb_push(skb, sizeof *phdr); |
663 | __skb_queue_tail(&path->queue, skb); | 665 | __skb_queue_tail(&path->queue, skb); |
664 | 666 | ||
665 | if (path_rec_start(dev, path)) { | 667 | if (!path->query && path_rec_start(dev, path)) { |
666 | spin_unlock_irqrestore(&priv->lock, flags); | 668 | spin_unlock_irqrestore(&priv->lock, flags); |
667 | path_free(dev, path); | 669 | path_free(dev, path); |
668 | return; | 670 | return; |
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index bb904a0a98bd..1bfc55d7a26c 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c | |||
@@ -1641,8 +1641,10 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp) | |||
1641 | /* slarp reply, send own ip/netmask; if values are nonsense remote | 1641 | /* slarp reply, send own ip/netmask; if values are nonsense remote |
1642 | * should think we are unable to provide it with an address via SLARP */ | 1642 | * should think we are unable to provide it with an address via SLARP */ |
1643 | p += put_u32(p, CISCO_SLARP_REPLY); | 1643 | p += put_u32(p, CISCO_SLARP_REPLY); |
1644 | p += put_u32(p, addr); // address | 1644 | *(__be32 *)p = addr; // address |
1645 | p += put_u32(p, mask); // netmask | 1645 | p += 4; |
1646 | *(__be32 *)p = mask; // netmask | ||
1647 | p += 4; | ||
1646 | p += put_u16(p, 0); // unused | 1648 | p += put_u16(p, 0); // unused |
1647 | 1649 | ||
1648 | isdn_net_write_super(lp, skb); | 1650 | isdn_net_write_super(lp, skb); |
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 4840733cd903..3d7f4923cd13 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -441,13 +441,13 @@ static void process_queued_ios(struct work_struct *work) | |||
441 | __choose_pgpath(m); | 441 | __choose_pgpath(m); |
442 | 442 | ||
443 | pgpath = m->current_pgpath; | 443 | pgpath = m->current_pgpath; |
444 | m->pgpath_to_activate = m->current_pgpath; | ||
445 | 444 | ||
446 | if ((pgpath && !m->queue_io) || | 445 | if ((pgpath && !m->queue_io) || |
447 | (!pgpath && !m->queue_if_no_path)) | 446 | (!pgpath && !m->queue_if_no_path)) |
448 | must_queue = 0; | 447 | must_queue = 0; |
449 | 448 | ||
450 | if (m->pg_init_required && !m->pg_init_in_progress) { | 449 | if (m->pg_init_required && !m->pg_init_in_progress && pgpath) { |
450 | m->pgpath_to_activate = pgpath; | ||
451 | m->pg_init_count++; | 451 | m->pg_init_count++; |
452 | m->pg_init_required = 0; | 452 | m->pg_init_required = 0; |
453 | m->pg_init_in_progress = 1; | 453 | m->pg_init_in_progress = 1; |
@@ -708,6 +708,10 @@ static int parse_hw_handler(struct arg_set *as, struct multipath *m) | |||
708 | m->hw_handler_name = NULL; | 708 | m->hw_handler_name = NULL; |
709 | return -EINVAL; | 709 | return -EINVAL; |
710 | } | 710 | } |
711 | |||
712 | if (hw_argc > 1) | ||
713 | DMWARN("Ignoring user-specified arguments for " | ||
714 | "hardware handler \"%s\"", m->hw_handler_name); | ||
711 | consume(as, hw_argc - 1); | 715 | consume(as, hw_argc - 1); |
712 | 716 | ||
713 | return 0; | 717 | return 0; |
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 9d7b53ed75b2..ec43f9fa4b2a 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -1032,6 +1032,7 @@ static void mirror_dtr(struct dm_target *ti) | |||
1032 | 1032 | ||
1033 | del_timer_sync(&ms->timer); | 1033 | del_timer_sync(&ms->timer); |
1034 | flush_workqueue(ms->kmirrord_wq); | 1034 | flush_workqueue(ms->kmirrord_wq); |
1035 | flush_scheduled_work(); | ||
1035 | dm_kcopyd_client_destroy(ms->kcopyd_client); | 1036 | dm_kcopyd_client_destroy(ms->kcopyd_client); |
1036 | destroy_workqueue(ms->kmirrord_wq); | 1037 | destroy_workqueue(ms->kmirrord_wq); |
1037 | free_context(ms, ti, ms->nr_mirrors); | 1038 | free_context(ms, ti, ms->nr_mirrors); |
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a2d068dbe9e2..9e4ef88d421e 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c | |||
@@ -320,8 +320,10 @@ int __init dm_stripe_init(void) | |||
320 | int r; | 320 | int r; |
321 | 321 | ||
322 | r = dm_register_target(&stripe_target); | 322 | r = dm_register_target(&stripe_target); |
323 | if (r < 0) | 323 | if (r < 0) { |
324 | DMWARN("target registration failed"); | 324 | DMWARN("target registration failed"); |
325 | return r; | ||
326 | } | ||
325 | 327 | ||
326 | kstriped = create_singlethread_workqueue("kstriped"); | 328 | kstriped = create_singlethread_workqueue("kstriped"); |
327 | if (!kstriped) { | 329 | if (!kstriped) { |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 6963ad148408..c99e4728ff41 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -375,7 +375,7 @@ static void start_io_acct(struct dm_io *io) | |||
375 | dm_disk(md)->part0.in_flight = atomic_inc_return(&md->pending); | 375 | dm_disk(md)->part0.in_flight = atomic_inc_return(&md->pending); |
376 | } | 376 | } |
377 | 377 | ||
378 | static int end_io_acct(struct dm_io *io) | 378 | static void end_io_acct(struct dm_io *io) |
379 | { | 379 | { |
380 | struct mapped_device *md = io->md; | 380 | struct mapped_device *md = io->md; |
381 | struct bio *bio = io->bio; | 381 | struct bio *bio = io->bio; |
@@ -391,7 +391,9 @@ static int end_io_acct(struct dm_io *io) | |||
391 | dm_disk(md)->part0.in_flight = pending = | 391 | dm_disk(md)->part0.in_flight = pending = |
392 | atomic_dec_return(&md->pending); | 392 | atomic_dec_return(&md->pending); |
393 | 393 | ||
394 | return !pending; | 394 | /* nudge anyone waiting on suspend queue */ |
395 | if (!pending) | ||
396 | wake_up(&md->wait); | ||
395 | } | 397 | } |
396 | 398 | ||
397 | /* | 399 | /* |
@@ -499,9 +501,7 @@ static void dec_pending(struct dm_io *io, int error) | |||
499 | spin_unlock_irqrestore(&io->md->pushback_lock, flags); | 501 | spin_unlock_irqrestore(&io->md->pushback_lock, flags); |
500 | } | 502 | } |
501 | 503 | ||
502 | if (end_io_acct(io)) | 504 | end_io_acct(io); |
503 | /* nudge anyone waiting on suspend queue */ | ||
504 | wake_up(&io->md->wait); | ||
505 | 505 | ||
506 | if (io->error != DM_ENDIO_REQUEUE) { | 506 | if (io->error != DM_ENDIO_REQUEUE) { |
507 | blk_add_trace_bio(io->md->queue, io->bio, | 507 | blk_add_trace_bio(io->md->queue, io->bio, |
@@ -937,16 +937,24 @@ static void dm_unplug_all(struct request_queue *q) | |||
937 | 937 | ||
938 | static int dm_any_congested(void *congested_data, int bdi_bits) | 938 | static int dm_any_congested(void *congested_data, int bdi_bits) |
939 | { | 939 | { |
940 | int r; | 940 | int r = bdi_bits; |
941 | struct mapped_device *md = (struct mapped_device *) congested_data; | 941 | struct mapped_device *md = congested_data; |
942 | struct dm_table *map = dm_get_table(md); | 942 | struct dm_table *map; |
943 | 943 | ||
944 | if (!map || test_bit(DMF_BLOCK_IO, &md->flags)) | 944 | atomic_inc(&md->pending); |
945 | r = bdi_bits; | 945 | |
946 | else | 946 | if (!test_bit(DMF_BLOCK_IO, &md->flags)) { |
947 | r = dm_table_any_congested(map, bdi_bits); | 947 | map = dm_get_table(md); |
948 | if (map) { | ||
949 | r = dm_table_any_congested(map, bdi_bits); | ||
950 | dm_table_put(map); | ||
951 | } | ||
952 | } | ||
953 | |||
954 | if (!atomic_dec_return(&md->pending)) | ||
955 | /* nudge anyone waiting on suspend queue */ | ||
956 | wake_up(&md->wait); | ||
948 | 957 | ||
949 | dm_table_put(map); | ||
950 | return r; | 958 | return r; |
951 | } | 959 | } |
952 | 960 | ||
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index b59e47272abf..3720f0e03a16 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * experimental driver for simple i2c audio chips. | 2 | * Driver for simple i2c audio chips. |
3 | * | 3 | * |
4 | * Copyright (c) 2000 Gerd Knorr | 4 | * Copyright (c) 2000 Gerd Knorr |
5 | * based on code by: | 5 | * based on code by: |
@@ -7,6 +7,10 @@ | |||
7 | * Steve VanDeBogart (vandebo@uclink.berkeley.edu) | 7 | * Steve VanDeBogart (vandebo@uclink.berkeley.edu) |
8 | * Greg Alexander (galexand@acm.org) | 8 | * Greg Alexander (galexand@acm.org) |
9 | * | 9 | * |
10 | * Copyright(c) 2005-2008 Mauro Carvalho Chehab | ||
11 | * - Some cleanups, code fixes, etc | ||
12 | * - Convert it to V4L2 API | ||
13 | * | ||
10 | * This code is placed under the terms of the GNU General Public License | 14 | * This code is placed under the terms of the GNU General Public License |
11 | * | 15 | * |
12 | * OPTIONS: | 16 | * OPTIONS: |
@@ -30,6 +34,7 @@ | |||
30 | 34 | ||
31 | #include <media/tvaudio.h> | 35 | #include <media/tvaudio.h> |
32 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
37 | #include <media/v4l2-ioctl.h> | ||
33 | #include <media/v4l2-chip-ident.h> | 38 | #include <media/v4l2-chip-ident.h> |
34 | #include <media/v4l2-i2c-drv-legacy.h> | 39 | #include <media/v4l2-i2c-drv-legacy.h> |
35 | 40 | ||
@@ -58,7 +63,6 @@ typedef int (*checkit)(struct CHIPSTATE*); | |||
58 | typedef int (*initialize)(struct CHIPSTATE*); | 63 | typedef int (*initialize)(struct CHIPSTATE*); |
59 | typedef int (*getmode)(struct CHIPSTATE*); | 64 | typedef int (*getmode)(struct CHIPSTATE*); |
60 | typedef void (*setmode)(struct CHIPSTATE*, int mode); | 65 | typedef void (*setmode)(struct CHIPSTATE*, int mode); |
61 | typedef void (*checkmode)(struct CHIPSTATE*); | ||
62 | 66 | ||
63 | /* i2c command */ | 67 | /* i2c command */ |
64 | typedef struct AUDIOCMD { | 68 | typedef struct AUDIOCMD { |
@@ -79,6 +83,7 @@ struct CHIPDESC { | |||
79 | #define CHIP_HAS_VOLUME 1 | 83 | #define CHIP_HAS_VOLUME 1 |
80 | #define CHIP_HAS_BASSTREBLE 2 | 84 | #define CHIP_HAS_BASSTREBLE 2 |
81 | #define CHIP_HAS_INPUTSEL 4 | 85 | #define CHIP_HAS_INPUTSEL 4 |
86 | #define CHIP_NEED_CHECKMODE 8 | ||
82 | 87 | ||
83 | /* various i2c command sequences */ | 88 | /* various i2c command sequences */ |
84 | audiocmd init; | 89 | audiocmd init; |
@@ -96,23 +101,20 @@ struct CHIPDESC { | |||
96 | getmode getmode; | 101 | getmode getmode; |
97 | setmode setmode; | 102 | setmode setmode; |
98 | 103 | ||
99 | /* check / autoswitch audio after channel switches */ | ||
100 | checkmode checkmode; | ||
101 | |||
102 | /* input switch register + values for v4l inputs */ | 104 | /* input switch register + values for v4l inputs */ |
103 | int inputreg; | 105 | int inputreg; |
104 | int inputmap[4]; | 106 | int inputmap[4]; |
105 | int inputmute; | 107 | int inputmute; |
106 | int inputmask; | 108 | int inputmask; |
107 | }; | 109 | }; |
108 | static struct CHIPDESC chiplist[]; | ||
109 | 110 | ||
110 | /* current state of the chip */ | 111 | /* current state of the chip */ |
111 | struct CHIPSTATE { | 112 | struct CHIPSTATE { |
112 | struct i2c_client *c; | 113 | struct i2c_client *c; |
113 | 114 | ||
114 | /* index into CHIPDESC array */ | 115 | /* chip-specific description - should point to |
115 | int type; | 116 | an entry at CHIPDESC table */ |
117 | struct CHIPDESC *desc; | ||
116 | 118 | ||
117 | /* shadow register set */ | 119 | /* shadow register set */ |
118 | audiocmd shadow; | 120 | audiocmd shadow; |
@@ -152,7 +154,7 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
152 | { | 154 | { |
153 | unsigned char buffer[2]; | 155 | unsigned char buffer[2]; |
154 | 156 | ||
155 | if (-1 == subaddr) { | 157 | if (subaddr < 0) { |
156 | v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n", | 158 | v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n", |
157 | chip->c->name, val); | 159 | chip->c->name, val); |
158 | chip->shadow.bytes[1] = val; | 160 | chip->shadow.bytes[1] = val; |
@@ -163,6 +165,13 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
163 | return -1; | 165 | return -1; |
164 | } | 166 | } |
165 | } else { | 167 | } else { |
168 | if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) { | ||
169 | v4l_info(chip->c, | ||
170 | "Tried to access a non-existent register: %d\n", | ||
171 | subaddr); | ||
172 | return -EINVAL; | ||
173 | } | ||
174 | |||
166 | v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n", | 175 | v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n", |
167 | chip->c->name, subaddr, val); | 176 | chip->c->name, subaddr, val); |
168 | chip->shadow.bytes[subaddr+1] = val; | 177 | chip->shadow.bytes[subaddr+1] = val; |
@@ -177,12 +186,20 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
177 | return 0; | 186 | return 0; |
178 | } | 187 | } |
179 | 188 | ||
180 | static int chip_write_masked(struct CHIPSTATE *chip, int subaddr, int val, int mask) | 189 | static int chip_write_masked(struct CHIPSTATE *chip, |
190 | int subaddr, int val, int mask) | ||
181 | { | 191 | { |
182 | if (mask != 0) { | 192 | if (mask != 0) { |
183 | if (-1 == subaddr) { | 193 | if (subaddr < 0) { |
184 | val = (chip->shadow.bytes[1] & ~mask) | (val & mask); | 194 | val = (chip->shadow.bytes[1] & ~mask) | (val & mask); |
185 | } else { | 195 | } else { |
196 | if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) { | ||
197 | v4l_info(chip->c, | ||
198 | "Tried to access a non-existent register: %d\n", | ||
199 | subaddr); | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | |||
186 | val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask); | 203 | val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask); |
187 | } | 204 | } |
188 | } | 205 | } |
@@ -228,6 +245,15 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) | |||
228 | if (0 == cmd->count) | 245 | if (0 == cmd->count) |
229 | return 0; | 246 | return 0; |
230 | 247 | ||
248 | if (cmd->count + cmd->bytes[0] - 1 >= ARRAY_SIZE(chip->shadow.bytes)) { | ||
249 | v4l_info(chip->c, | ||
250 | "Tried to access a non-existent register range: %d to %d\n", | ||
251 | cmd->bytes[0] + 1, cmd->bytes[0] + cmd->count - 1); | ||
252 | return -EINVAL; | ||
253 | } | ||
254 | |||
255 | /* FIXME: it seems that the shadow bytes are wrong bellow !*/ | ||
256 | |||
231 | /* update our shadow register set; print bytes if (debug > 0) */ | 257 | /* update our shadow register set; print bytes if (debug > 0) */ |
232 | v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:", | 258 | v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:", |
233 | chip->c->name, name,cmd->bytes[0]); | 259 | chip->c->name, name,cmd->bytes[0]); |
@@ -263,7 +289,8 @@ static void chip_thread_wake(unsigned long data) | |||
263 | static int chip_thread(void *data) | 289 | static int chip_thread(void *data) |
264 | { | 290 | { |
265 | struct CHIPSTATE *chip = data; | 291 | struct CHIPSTATE *chip = data; |
266 | struct CHIPDESC *desc = chiplist + chip->type; | 292 | struct CHIPDESC *desc = chip->desc; |
293 | int mode; | ||
267 | 294 | ||
268 | v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name); | 295 | v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name); |
269 | set_freezable(); | 296 | set_freezable(); |
@@ -282,7 +309,26 @@ static int chip_thread(void *data) | |||
282 | continue; | 309 | continue; |
283 | 310 | ||
284 | /* have a look what's going on */ | 311 | /* have a look what's going on */ |
285 | desc->checkmode(chip); | 312 | mode = desc->getmode(chip); |
313 | if (mode == chip->prevmode) | ||
314 | continue; | ||
315 | |||
316 | /* chip detected a new audio mode - set it */ | ||
317 | v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n", | ||
318 | chip->c->name); | ||
319 | |||
320 | chip->prevmode = mode; | ||
321 | |||
322 | if (mode & V4L2_TUNER_MODE_STEREO) | ||
323 | desc->setmode(chip, V4L2_TUNER_MODE_STEREO); | ||
324 | if (mode & V4L2_TUNER_MODE_LANG1_LANG2) | ||
325 | desc->setmode(chip, V4L2_TUNER_MODE_STEREO); | ||
326 | else if (mode & V4L2_TUNER_MODE_LANG1) | ||
327 | desc->setmode(chip, V4L2_TUNER_MODE_LANG1); | ||
328 | else if (mode & V4L2_TUNER_MODE_LANG2) | ||
329 | desc->setmode(chip, V4L2_TUNER_MODE_LANG2); | ||
330 | else | ||
331 | desc->setmode(chip, V4L2_TUNER_MODE_MONO); | ||
286 | 332 | ||
287 | /* schedule next check */ | 333 | /* schedule next check */ |
288 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); | 334 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); |
@@ -292,29 +338,6 @@ static int chip_thread(void *data) | |||
292 | return 0; | 338 | return 0; |
293 | } | 339 | } |
294 | 340 | ||
295 | static void generic_checkmode(struct CHIPSTATE *chip) | ||
296 | { | ||
297 | struct CHIPDESC *desc = chiplist + chip->type; | ||
298 | int mode = desc->getmode(chip); | ||
299 | |||
300 | if (mode == chip->prevmode) | ||
301 | return; | ||
302 | |||
303 | v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n", chip->c->name); | ||
304 | chip->prevmode = mode; | ||
305 | |||
306 | if (mode & V4L2_TUNER_MODE_STEREO) | ||
307 | desc->setmode(chip,V4L2_TUNER_MODE_STEREO); | ||
308 | if (mode & V4L2_TUNER_MODE_LANG1_LANG2) | ||
309 | desc->setmode(chip,V4L2_TUNER_MODE_STEREO); | ||
310 | else if (mode & V4L2_TUNER_MODE_LANG1) | ||
311 | desc->setmode(chip,V4L2_TUNER_MODE_LANG1); | ||
312 | else if (mode & V4L2_TUNER_MODE_LANG2) | ||
313 | desc->setmode(chip,V4L2_TUNER_MODE_LANG2); | ||
314 | else | ||
315 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); | ||
316 | } | ||
317 | |||
318 | /* ---------------------------------------------------------------------- */ | 341 | /* ---------------------------------------------------------------------- */ |
319 | /* audio chip descriptions - defines+functions for tda9840 */ | 342 | /* audio chip descriptions - defines+functions for tda9840 */ |
320 | 343 | ||
@@ -777,7 +800,7 @@ static struct tda9874a_MODES { | |||
777 | char *name; | 800 | char *name; |
778 | audiocmd cmd; | 801 | audiocmd cmd; |
779 | } tda9874a_modelist[9] = { | 802 | } tda9874a_modelist[9] = { |
780 | { "A2, B/G", | 803 | { "A2, B/G", /* default */ |
781 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} }, | 804 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} }, |
782 | { "A2, M (Korea)", | 805 | { "A2, M (Korea)", |
783 | { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} }, | 806 | { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} }, |
@@ -791,7 +814,7 @@ static struct tda9874a_MODES { | |||
791 | { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} }, | 814 | { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} }, |
792 | { "NICAM, B/G", | 815 | { "NICAM, B/G", |
793 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} }, | 816 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} }, |
794 | { "NICAM, D/K", /* default */ | 817 | { "NICAM, D/K", |
795 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} }, | 818 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} }, |
796 | { "NICAM, L", | 819 | { "NICAM, L", |
797 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} } | 820 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} } |
@@ -981,7 +1004,7 @@ static int tda9874a_initialize(struct CHIPSTATE *chip) | |||
981 | { | 1004 | { |
982 | if (tda9874a_SIF > 2) | 1005 | if (tda9874a_SIF > 2) |
983 | tda9874a_SIF = 1; | 1006 | tda9874a_SIF = 1; |
984 | if (tda9874a_STD > 8) | 1007 | if (tda9874a_STD >= ARRAY_SIZE(tda9874a_modelist)) |
985 | tda9874a_STD = 0; | 1008 | tda9874a_STD = 0; |
986 | if(tda9874a_AMSEL > 1) | 1009 | if(tda9874a_AMSEL > 1) |
987 | tda9874a_AMSEL = 0; | 1010 | tda9874a_AMSEL = 0; |
@@ -1089,7 +1112,7 @@ static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; } | |||
1089 | 1112 | ||
1090 | static int tda8425_initialize(struct CHIPSTATE *chip) | 1113 | static int tda8425_initialize(struct CHIPSTATE *chip) |
1091 | { | 1114 | { |
1092 | struct CHIPDESC *desc = chiplist + chip->type; | 1115 | struct CHIPDESC *desc = chip->desc; |
1093 | int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1, | 1116 | int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1, |
1094 | /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF}; | 1117 | /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF}; |
1095 | 1118 | ||
@@ -1259,27 +1282,28 @@ static struct CHIPDESC chiplist[] = { | |||
1259 | .addr_lo = I2C_ADDR_TDA9840 >> 1, | 1282 | .addr_lo = I2C_ADDR_TDA9840 >> 1, |
1260 | .addr_hi = I2C_ADDR_TDA9840 >> 1, | 1283 | .addr_hi = I2C_ADDR_TDA9840 >> 1, |
1261 | .registers = 5, | 1284 | .registers = 5, |
1285 | .flags = CHIP_NEED_CHECKMODE, | ||
1262 | 1286 | ||
1287 | /* callbacks */ | ||
1263 | .checkit = tda9840_checkit, | 1288 | .checkit = tda9840_checkit, |
1264 | .getmode = tda9840_getmode, | 1289 | .getmode = tda9840_getmode, |
1265 | .setmode = tda9840_setmode, | 1290 | .setmode = tda9840_setmode, |
1266 | .checkmode = generic_checkmode, | ||
1267 | 1291 | ||
1268 | .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN | 1292 | .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN |
1269 | /* ,TDA9840_SW, TDA9840_MONO */} } | 1293 | /* ,TDA9840_SW, TDA9840_MONO */} } |
1270 | }, | 1294 | }, |
1271 | { | 1295 | { |
1272 | .name = "tda9873h", | 1296 | .name = "tda9873h", |
1273 | .checkit = tda9873_checkit, | ||
1274 | .insmodopt = &tda9873, | 1297 | .insmodopt = &tda9873, |
1275 | .addr_lo = I2C_ADDR_TDA985x_L >> 1, | 1298 | .addr_lo = I2C_ADDR_TDA985x_L >> 1, |
1276 | .addr_hi = I2C_ADDR_TDA985x_H >> 1, | 1299 | .addr_hi = I2C_ADDR_TDA985x_H >> 1, |
1277 | .registers = 3, | 1300 | .registers = 3, |
1278 | .flags = CHIP_HAS_INPUTSEL, | 1301 | .flags = CHIP_HAS_INPUTSEL | CHIP_NEED_CHECKMODE, |
1279 | 1302 | ||
1303 | /* callbacks */ | ||
1304 | .checkit = tda9873_checkit, | ||
1280 | .getmode = tda9873_getmode, | 1305 | .getmode = tda9873_getmode, |
1281 | .setmode = tda9873_setmode, | 1306 | .setmode = tda9873_setmode, |
1282 | .checkmode = generic_checkmode, | ||
1283 | 1307 | ||
1284 | .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, | 1308 | .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, |
1285 | .inputreg = TDA9873_SW, | 1309 | .inputreg = TDA9873_SW, |
@@ -1290,15 +1314,16 @@ static struct CHIPDESC chiplist[] = { | |||
1290 | }, | 1314 | }, |
1291 | { | 1315 | { |
1292 | .name = "tda9874h/a", | 1316 | .name = "tda9874h/a", |
1293 | .checkit = tda9874a_checkit, | ||
1294 | .initialize = tda9874a_initialize, | ||
1295 | .insmodopt = &tda9874a, | 1317 | .insmodopt = &tda9874a, |
1296 | .addr_lo = I2C_ADDR_TDA9874 >> 1, | 1318 | .addr_lo = I2C_ADDR_TDA9874 >> 1, |
1297 | .addr_hi = I2C_ADDR_TDA9874 >> 1, | 1319 | .addr_hi = I2C_ADDR_TDA9874 >> 1, |
1320 | .flags = CHIP_NEED_CHECKMODE, | ||
1298 | 1321 | ||
1322 | /* callbacks */ | ||
1323 | .initialize = tda9874a_initialize, | ||
1324 | .checkit = tda9874a_checkit, | ||
1299 | .getmode = tda9874a_getmode, | 1325 | .getmode = tda9874a_getmode, |
1300 | .setmode = tda9874a_setmode, | 1326 | .setmode = tda9874a_setmode, |
1301 | .checkmode = generic_checkmode, | ||
1302 | }, | 1327 | }, |
1303 | { | 1328 | { |
1304 | .name = "tda9850", | 1329 | .name = "tda9850", |
@@ -1324,10 +1349,11 @@ static struct CHIPDESC chiplist[] = { | |||
1324 | .rightreg = TDA9855_VR, | 1349 | .rightreg = TDA9855_VR, |
1325 | .bassreg = TDA9855_BA, | 1350 | .bassreg = TDA9855_BA, |
1326 | .treblereg = TDA9855_TR, | 1351 | .treblereg = TDA9855_TR, |
1352 | |||
1353 | /* callbacks */ | ||
1327 | .volfunc = tda9855_volume, | 1354 | .volfunc = tda9855_volume, |
1328 | .bassfunc = tda9855_bass, | 1355 | .bassfunc = tda9855_bass, |
1329 | .treblefunc = tda9855_treble, | 1356 | .treblefunc = tda9855_treble, |
1330 | |||
1331 | .getmode = tda985x_getmode, | 1357 | .getmode = tda985x_getmode, |
1332 | .setmode = tda985x_setmode, | 1358 | .setmode = tda985x_setmode, |
1333 | 1359 | ||
@@ -1348,6 +1374,8 @@ static struct CHIPDESC chiplist[] = { | |||
1348 | .rightreg = TEA6300_VL, | 1374 | .rightreg = TEA6300_VL, |
1349 | .bassreg = TEA6300_BA, | 1375 | .bassreg = TEA6300_BA, |
1350 | .treblereg = TEA6300_TR, | 1376 | .treblereg = TEA6300_TR, |
1377 | |||
1378 | /* callbacks */ | ||
1351 | .volfunc = tea6300_shift10, | 1379 | .volfunc = tea6300_shift10, |
1352 | .bassfunc = tea6300_shift12, | 1380 | .bassfunc = tea6300_shift12, |
1353 | .treblefunc = tea6300_shift12, | 1381 | .treblefunc = tea6300_shift12, |
@@ -1358,7 +1386,6 @@ static struct CHIPDESC chiplist[] = { | |||
1358 | }, | 1386 | }, |
1359 | { | 1387 | { |
1360 | .name = "tea6320", | 1388 | .name = "tea6320", |
1361 | .initialize = tea6320_initialize, | ||
1362 | .insmodopt = &tea6320, | 1389 | .insmodopt = &tea6320, |
1363 | .addr_lo = I2C_ADDR_TEA6300 >> 1, | 1390 | .addr_lo = I2C_ADDR_TEA6300 >> 1, |
1364 | .addr_hi = I2C_ADDR_TEA6300 >> 1, | 1391 | .addr_hi = I2C_ADDR_TEA6300 >> 1, |
@@ -1369,6 +1396,9 @@ static struct CHIPDESC chiplist[] = { | |||
1369 | .rightreg = TEA6320_V, | 1396 | .rightreg = TEA6320_V, |
1370 | .bassreg = TEA6320_BA, | 1397 | .bassreg = TEA6320_BA, |
1371 | .treblereg = TEA6320_TR, | 1398 | .treblereg = TEA6320_TR, |
1399 | |||
1400 | /* callbacks */ | ||
1401 | .initialize = tea6320_initialize, | ||
1372 | .volfunc = tea6320_volume, | 1402 | .volfunc = tea6320_volume, |
1373 | .bassfunc = tea6320_shift11, | 1403 | .bassfunc = tea6320_shift11, |
1374 | .treblefunc = tea6320_shift11, | 1404 | .treblefunc = tea6320_shift11, |
@@ -1401,16 +1431,18 @@ static struct CHIPDESC chiplist[] = { | |||
1401 | .rightreg = TDA8425_VR, | 1431 | .rightreg = TDA8425_VR, |
1402 | .bassreg = TDA8425_BA, | 1432 | .bassreg = TDA8425_BA, |
1403 | .treblereg = TDA8425_TR, | 1433 | .treblereg = TDA8425_TR, |
1434 | |||
1435 | /* callbacks */ | ||
1436 | .initialize = tda8425_initialize, | ||
1404 | .volfunc = tda8425_shift10, | 1437 | .volfunc = tda8425_shift10, |
1405 | .bassfunc = tda8425_shift12, | 1438 | .bassfunc = tda8425_shift12, |
1406 | .treblefunc = tda8425_shift12, | 1439 | .treblefunc = tda8425_shift12, |
1440 | .setmode = tda8425_setmode, | ||
1407 | 1441 | ||
1408 | .inputreg = TDA8425_S1, | 1442 | .inputreg = TDA8425_S1, |
1409 | .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, | 1443 | .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, |
1410 | .inputmute = TDA8425_S1_OFF, | 1444 | .inputmute = TDA8425_S1_OFF, |
1411 | 1445 | ||
1412 | .setmode = tda8425_setmode, | ||
1413 | .initialize = tda8425_initialize, | ||
1414 | }, | 1446 | }, |
1415 | { | 1447 | { |
1416 | .name = "pic16c54 (PV951)", | 1448 | .name = "pic16c54 (PV951)", |
@@ -1434,10 +1466,11 @@ static struct CHIPDESC chiplist[] = { | |||
1434 | .addr_lo = I2C_ADDR_TDA9840 >> 1, | 1466 | .addr_lo = I2C_ADDR_TDA9840 >> 1, |
1435 | .addr_hi = I2C_ADDR_TDA9840 >> 1, | 1467 | .addr_hi = I2C_ADDR_TDA9840 >> 1, |
1436 | .registers = 2, | 1468 | .registers = 2, |
1469 | .flags = CHIP_NEED_CHECKMODE, | ||
1437 | 1470 | ||
1471 | /* callbacks */ | ||
1438 | .getmode = ta8874z_getmode, | 1472 | .getmode = ta8874z_getmode, |
1439 | .setmode = ta8874z_setmode, | 1473 | .setmode = ta8874z_setmode, |
1440 | .checkmode = generic_checkmode, | ||
1441 | 1474 | ||
1442 | .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, | 1475 | .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, |
1443 | }, | 1476 | }, |
@@ -1481,6 +1514,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1481 | } | 1514 | } |
1482 | if (desc->name == NULL) { | 1515 | if (desc->name == NULL) { |
1483 | v4l_dbg(1, debug, client, "no matching chip description found\n"); | 1516 | v4l_dbg(1, debug, client, "no matching chip description found\n"); |
1517 | kfree(chip); | ||
1484 | return -EIO; | 1518 | return -EIO; |
1485 | } | 1519 | } |
1486 | v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); | 1520 | v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); |
@@ -1494,7 +1528,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1494 | /* fill required data structures */ | 1528 | /* fill required data structures */ |
1495 | if (!id) | 1529 | if (!id) |
1496 | strlcpy(client->name, desc->name, I2C_NAME_SIZE); | 1530 | strlcpy(client->name, desc->name, I2C_NAME_SIZE); |
1497 | chip->type = desc-chiplist; | 1531 | chip->desc = desc; |
1498 | chip->shadow.count = desc->registers+1; | 1532 | chip->shadow.count = desc->registers+1; |
1499 | chip->prevmode = -1; | 1533 | chip->prevmode = -1; |
1500 | chip->audmode = V4L2_TUNER_MODE_LANG1; | 1534 | chip->audmode = V4L2_TUNER_MODE_LANG1; |
@@ -1506,20 +1540,49 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1506 | chip_cmd(chip,"init",&desc->init); | 1540 | chip_cmd(chip,"init",&desc->init); |
1507 | 1541 | ||
1508 | if (desc->flags & CHIP_HAS_VOLUME) { | 1542 | if (desc->flags & CHIP_HAS_VOLUME) { |
1509 | chip->left = desc->leftinit ? desc->leftinit : 65535; | 1543 | if (!desc->volfunc) { |
1510 | chip->right = desc->rightinit ? desc->rightinit : 65535; | 1544 | /* This shouldn't be happen. Warn user, but keep working |
1511 | chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); | 1545 | without volume controls |
1512 | chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); | 1546 | */ |
1547 | v4l_info(chip->c, "volume callback undefined!\n"); | ||
1548 | desc->flags &= ~CHIP_HAS_VOLUME; | ||
1549 | } else { | ||
1550 | chip->left = desc->leftinit ? desc->leftinit : 65535; | ||
1551 | chip->right = desc->rightinit ? desc->rightinit : 65535; | ||
1552 | chip_write(chip, desc->leftreg, | ||
1553 | desc->volfunc(chip->left)); | ||
1554 | chip_write(chip, desc->rightreg, | ||
1555 | desc->volfunc(chip->right)); | ||
1556 | } | ||
1513 | } | 1557 | } |
1514 | if (desc->flags & CHIP_HAS_BASSTREBLE) { | 1558 | if (desc->flags & CHIP_HAS_BASSTREBLE) { |
1515 | chip->treble = desc->trebleinit ? desc->trebleinit : 32768; | 1559 | if (!desc->bassfunc || !desc->treblefunc) { |
1516 | chip->bass = desc->bassinit ? desc->bassinit : 32768; | 1560 | /* This shouldn't be happen. Warn user, but keep working |
1517 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); | 1561 | without bass/treble controls |
1518 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); | 1562 | */ |
1563 | v4l_info(chip->c, "bass/treble callbacks undefined!\n"); | ||
1564 | desc->flags &= ~CHIP_HAS_BASSTREBLE; | ||
1565 | } else { | ||
1566 | chip->treble = desc->trebleinit ? | ||
1567 | desc->trebleinit : 32768; | ||
1568 | chip->bass = desc->bassinit ? | ||
1569 | desc->bassinit : 32768; | ||
1570 | chip_write(chip, desc->bassreg, | ||
1571 | desc->bassfunc(chip->bass)); | ||
1572 | chip_write(chip, desc->treblereg, | ||
1573 | desc->treblefunc(chip->treble)); | ||
1574 | } | ||
1519 | } | 1575 | } |
1520 | 1576 | ||
1521 | chip->thread = NULL; | 1577 | chip->thread = NULL; |
1522 | if (desc->checkmode) { | 1578 | if (desc->flags & CHIP_NEED_CHECKMODE) { |
1579 | if (!desc->getmode || !desc->setmode) { | ||
1580 | /* This shouldn't be happen. Warn user, but keep working | ||
1581 | without kthread | ||
1582 | */ | ||
1583 | v4l_info(chip->c, "set/get mode callbacks undefined!\n"); | ||
1584 | return 0; | ||
1585 | } | ||
1523 | /* start async thread */ | 1586 | /* start async thread */ |
1524 | init_timer(&chip->wt); | 1587 | init_timer(&chip->wt); |
1525 | chip->wt.function = chip_thread_wake; | 1588 | chip->wt.function = chip_thread_wake; |
@@ -1552,7 +1615,7 @@ static int chip_remove(struct i2c_client *client) | |||
1552 | static int tvaudio_get_ctrl(struct CHIPSTATE *chip, | 1615 | static int tvaudio_get_ctrl(struct CHIPSTATE *chip, |
1553 | struct v4l2_control *ctrl) | 1616 | struct v4l2_control *ctrl) |
1554 | { | 1617 | { |
1555 | struct CHIPDESC *desc = chiplist + chip->type; | 1618 | struct CHIPDESC *desc = chip->desc; |
1556 | 1619 | ||
1557 | switch (ctrl->id) { | 1620 | switch (ctrl->id) { |
1558 | case V4L2_CID_AUDIO_MUTE: | 1621 | case V4L2_CID_AUDIO_MUTE: |
@@ -1576,13 +1639,13 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip, | |||
1576 | return 0; | 1639 | return 0; |
1577 | } | 1640 | } |
1578 | case V4L2_CID_AUDIO_BASS: | 1641 | case V4L2_CID_AUDIO_BASS: |
1579 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1642 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1580 | break; | 1643 | break; |
1581 | ctrl->value = chip->bass; | 1644 | ctrl->value = chip->bass; |
1582 | return 0; | 1645 | return 0; |
1583 | case V4L2_CID_AUDIO_TREBLE: | 1646 | case V4L2_CID_AUDIO_TREBLE: |
1584 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1647 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1585 | return -EINVAL; | 1648 | break; |
1586 | ctrl->value = chip->treble; | 1649 | ctrl->value = chip->treble; |
1587 | return 0; | 1650 | return 0; |
1588 | } | 1651 | } |
@@ -1592,7 +1655,7 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip, | |||
1592 | static int tvaudio_set_ctrl(struct CHIPSTATE *chip, | 1655 | static int tvaudio_set_ctrl(struct CHIPSTATE *chip, |
1593 | struct v4l2_control *ctrl) | 1656 | struct v4l2_control *ctrl) |
1594 | { | 1657 | { |
1595 | struct CHIPDESC *desc = chiplist + chip->type; | 1658 | struct CHIPDESC *desc = chip->desc; |
1596 | 1659 | ||
1597 | switch (ctrl->id) { | 1660 | switch (ctrl->id) { |
1598 | case V4L2_CID_AUDIO_MUTE: | 1661 | case V4L2_CID_AUDIO_MUTE: |
@@ -1642,16 +1705,15 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip, | |||
1642 | return 0; | 1705 | return 0; |
1643 | } | 1706 | } |
1644 | case V4L2_CID_AUDIO_BASS: | 1707 | case V4L2_CID_AUDIO_BASS: |
1645 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1708 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1646 | break; | 1709 | break; |
1647 | chip->bass = ctrl->value; | 1710 | chip->bass = ctrl->value; |
1648 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); | 1711 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); |
1649 | 1712 | ||
1650 | return 0; | 1713 | return 0; |
1651 | case V4L2_CID_AUDIO_TREBLE: | 1714 | case V4L2_CID_AUDIO_TREBLE: |
1652 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1715 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1653 | return -EINVAL; | 1716 | break; |
1654 | |||
1655 | chip->treble = ctrl->value; | 1717 | chip->treble = ctrl->value; |
1656 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); | 1718 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); |
1657 | 1719 | ||
@@ -1668,9 +1730,12 @@ static int chip_command(struct i2c_client *client, | |||
1668 | unsigned int cmd, void *arg) | 1730 | unsigned int cmd, void *arg) |
1669 | { | 1731 | { |
1670 | struct CHIPSTATE *chip = i2c_get_clientdata(client); | 1732 | struct CHIPSTATE *chip = i2c_get_clientdata(client); |
1671 | struct CHIPDESC *desc = chiplist + chip->type; | 1733 | struct CHIPDESC *desc = chip->desc; |
1672 | 1734 | ||
1673 | v4l_dbg(1, debug, chip->c, "%s: chip_command 0x%x\n", chip->c->name, cmd); | 1735 | if (debug > 0) { |
1736 | v4l_i2c_print_ioctl(chip->c, cmd); | ||
1737 | printk("\n"); | ||
1738 | } | ||
1674 | 1739 | ||
1675 | switch (cmd) { | 1740 | switch (cmd) { |
1676 | case AUDC_SET_RADIO: | 1741 | case AUDC_SET_RADIO: |
@@ -1695,7 +1760,7 @@ static int chip_command(struct i2c_client *client, | |||
1695 | break; | 1760 | break; |
1696 | case V4L2_CID_AUDIO_BASS: | 1761 | case V4L2_CID_AUDIO_BASS: |
1697 | case V4L2_CID_AUDIO_TREBLE: | 1762 | case V4L2_CID_AUDIO_TREBLE: |
1698 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1763 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1699 | return -EINVAL; | 1764 | return -EINVAL; |
1700 | break; | 1765 | break; |
1701 | default: | 1766 | default: |
@@ -1792,12 +1857,20 @@ static int chip_command(struct i2c_client *client, | |||
1792 | break; | 1857 | break; |
1793 | case VIDIOC_S_FREQUENCY: | 1858 | case VIDIOC_S_FREQUENCY: |
1794 | chip->mode = 0; /* automatic */ | 1859 | chip->mode = 0; /* automatic */ |
1795 | if (desc->checkmode && desc->setmode) { | 1860 | |
1861 | /* For chips that provide getmode and setmode, and doesn't | ||
1862 | automatically follows the stereo carrier, a kthread is | ||
1863 | created to set the audio standard. In this case, when then | ||
1864 | the video channel is changed, tvaudio starts on MONO mode. | ||
1865 | After waiting for 2 seconds, the kernel thread is called, | ||
1866 | to follow whatever audio standard is pointed by the | ||
1867 | audio carrier. | ||
1868 | */ | ||
1869 | if (chip->thread) { | ||
1796 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); | 1870 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); |
1797 | if (chip->prevmode != V4L2_TUNER_MODE_MONO) | 1871 | if (chip->prevmode != V4L2_TUNER_MODE_MONO) |
1798 | chip->prevmode = -1; /* reset previous mode */ | 1872 | chip->prevmode = -1; /* reset previous mode */ |
1799 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); | 1873 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); |
1800 | /* the thread will call checkmode() later */ | ||
1801 | } | 1874 | } |
1802 | break; | 1875 | break; |
1803 | 1876 | ||
@@ -1836,9 +1909,3 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = { | |||
1836 | .legacy_probe = chip_legacy_probe, | 1909 | .legacy_probe = chip_legacy_probe, |
1837 | .id_table = chip_id, | 1910 | .id_table = chip_id, |
1838 | }; | 1911 | }; |
1839 | |||
1840 | /* | ||
1841 | * Local variables: | ||
1842 | * c-basic-offset: 8 | ||
1843 | * End: | ||
1844 | */ | ||
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c index b57326ae464d..0b5bd85dfcec 100644 --- a/drivers/mfd/da903x.c +++ b/drivers/mfd/da903x.c | |||
@@ -267,7 +267,7 @@ static int da9030_mask_events(struct da903x_chip *chip, unsigned int events) | |||
267 | { | 267 | { |
268 | uint8_t v[3]; | 268 | uint8_t v[3]; |
269 | 269 | ||
270 | chip->events_mask &= ~events; | 270 | chip->events_mask |= events; |
271 | 271 | ||
272 | v[0] = (chip->events_mask & 0xff); | 272 | v[0] = (chip->events_mask & 0xff); |
273 | v[1] = (chip->events_mask >> 8) & 0xff; | 273 | v[1] = (chip->events_mask >> 8) & 0xff; |
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c index 8dfe21bb3bd1..3e0ce0e50ea2 100644 --- a/drivers/mfd/wm8350-i2c.c +++ b/drivers/mfd/wm8350-i2c.c | |||
@@ -30,7 +30,12 @@ static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg, | |||
30 | ret = i2c_master_send(wm8350->i2c_client, ®, 1); | 30 | ret = i2c_master_send(wm8350->i2c_client, ®, 1); |
31 | if (ret < 0) | 31 | if (ret < 0) |
32 | return ret; | 32 | return ret; |
33 | return i2c_master_recv(wm8350->i2c_client, dest, bytes); | 33 | ret = i2c_master_recv(wm8350->i2c_client, dest, bytes); |
34 | if (ret < 0) | ||
35 | return ret; | ||
36 | if (ret != bytes) | ||
37 | return -EIO; | ||
38 | return 0; | ||
34 | } | 39 | } |
35 | 40 | ||
36 | static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg, | 41 | static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg, |
@@ -38,13 +43,19 @@ static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg, | |||
38 | { | 43 | { |
39 | /* we add 1 byte for device register */ | 44 | /* we add 1 byte for device register */ |
40 | u8 msg[(WM8350_MAX_REGISTER << 1) + 1]; | 45 | u8 msg[(WM8350_MAX_REGISTER << 1) + 1]; |
46 | int ret; | ||
41 | 47 | ||
42 | if (bytes > ((WM8350_MAX_REGISTER << 1) + 1)) | 48 | if (bytes > ((WM8350_MAX_REGISTER << 1) + 1)) |
43 | return -EINVAL; | 49 | return -EINVAL; |
44 | 50 | ||
45 | msg[0] = reg; | 51 | msg[0] = reg; |
46 | memcpy(&msg[1], src, bytes); | 52 | memcpy(&msg[1], src, bytes); |
47 | return i2c_master_send(wm8350->i2c_client, msg, bytes + 1); | 53 | ret = i2c_master_send(wm8350->i2c_client, msg, bytes + 1); |
54 | if (ret < 0) | ||
55 | return ret; | ||
56 | if (ret != bytes + 1) | ||
57 | return -EIO; | ||
58 | return 0; | ||
48 | } | 59 | } |
49 | 60 | ||
50 | static int wm8350_i2c_probe(struct i2c_client *i2c, | 61 | static int wm8350_i2c_probe(struct i2c_client *i2c, |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 9494400e8fd0..fee7304102af 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -227,10 +227,20 @@ config HP_WMI | |||
227 | To compile this driver as a module, choose M here: the module will | 227 | To compile this driver as a module, choose M here: the module will |
228 | be called hp-wmi. | 228 | be called hp-wmi. |
229 | 229 | ||
230 | config ICS932S401 | ||
231 | tristate "Integrated Circuits ICS932S401" | ||
232 | depends on I2C && EXPERIMENTAL | ||
233 | help | ||
234 | If you say yes here you get support for the Integrated Circuits | ||
235 | ICS932S401 clock control chips. | ||
236 | |||
237 | This driver can also be built as a module. If so, the module | ||
238 | will be called ics932s401. | ||
239 | |||
230 | config MSI_LAPTOP | 240 | config MSI_LAPTOP |
231 | tristate "MSI Laptop Extras" | 241 | tristate "MSI Laptop Extras" |
232 | depends on X86 | 242 | depends on X86 |
233 | depends on ACPI_EC | 243 | depends on ACPI |
234 | depends on BACKLIGHT_CLASS_DEVICE | 244 | depends on BACKLIGHT_CLASS_DEVICE |
235 | ---help--- | 245 | ---help--- |
236 | This is a driver for laptops built by MSI (MICRO-STAR | 246 | This is a driver for laptops built by MSI (MICRO-STAR |
@@ -260,7 +270,7 @@ config PANASONIC_LAPTOP | |||
260 | config COMPAL_LAPTOP | 270 | config COMPAL_LAPTOP |
261 | tristate "Compal Laptop Extras" | 271 | tristate "Compal Laptop Extras" |
262 | depends on X86 | 272 | depends on X86 |
263 | depends on ACPI_EC | 273 | depends on ACPI |
264 | depends on BACKLIGHT_CLASS_DEVICE | 274 | depends on BACKLIGHT_CLASS_DEVICE |
265 | ---help--- | 275 | ---help--- |
266 | This is a driver for laptops built by Compal: | 276 | This is a driver for laptops built by Compal: |
@@ -488,4 +498,6 @@ config SGI_GRU_DEBUG | |||
488 | This option enables addition debugging code for the SGI GRU driver. If | 498 | This option enables addition debugging code for the SGI GRU driver. If |
489 | you are unsure, say N. | 499 | you are unsure, say N. |
490 | 500 | ||
501 | source "drivers/misc/c2port/Kconfig" | ||
502 | |||
491 | endif # MISC_DEVICES | 503 | endif # MISC_DEVICES |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 909e2468cdc9..817f7f5ab3bd 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -14,6 +14,7 @@ obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o | |||
14 | obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o | 14 | obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o |
15 | obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o | 15 | obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o |
16 | obj-$(CONFIG_HP_WMI) += hp-wmi.o | 16 | obj-$(CONFIG_HP_WMI) += hp-wmi.o |
17 | obj-$(CONFIG_ICS932S401) += ics932s401.o | ||
17 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o | 18 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o |
18 | obj-$(CONFIG_LKDTM) += lkdtm.o | 19 | obj-$(CONFIG_LKDTM) += lkdtm.o |
19 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o | 20 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o |
@@ -31,3 +32,4 @@ obj-$(CONFIG_KGDB_TESTS) += kgdbts.o | |||
31 | obj-$(CONFIG_SGI_XP) += sgi-xp/ | 32 | obj-$(CONFIG_SGI_XP) += sgi-xp/ |
32 | obj-$(CONFIG_SGI_GRU) += sgi-gru/ | 33 | obj-$(CONFIG_SGI_GRU) += sgi-gru/ |
33 | obj-$(CONFIG_HP_ILO) += hpilo.o | 34 | obj-$(CONFIG_HP_ILO) += hpilo.o |
35 | obj-$(CONFIG_C2PORT) += c2port/ | ||
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c index 0532a2de2ce4..94c9f911824e 100644 --- a/drivers/misc/acer-wmi.c +++ b/drivers/misc/acer-wmi.c | |||
@@ -1297,6 +1297,12 @@ static int __init acer_wmi_init(void) | |||
1297 | 1297 | ||
1298 | set_quirks(); | 1298 | set_quirks(); |
1299 | 1299 | ||
1300 | if (!acpi_video_backlight_support() && has_cap(ACER_CAP_BRIGHTNESS)) { | ||
1301 | interface->capability &= ~ACER_CAP_BRIGHTNESS; | ||
1302 | printk(ACER_INFO "Brightness must be controlled by " | ||
1303 | "generic video driver\n"); | ||
1304 | } | ||
1305 | |||
1300 | if (platform_driver_register(&acer_platform_driver)) { | 1306 | if (platform_driver_register(&acer_platform_driver)) { |
1301 | printk(ACER_ERR "Unable to register platform driver.\n"); | 1307 | printk(ACER_ERR "Unable to register platform driver.\n"); |
1302 | goto error_platform_register; | 1308 | goto error_platform_register; |
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index a9d5228724a6..8fb8b3591048 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c | |||
@@ -1208,9 +1208,13 @@ static int __init asus_laptop_init(void) | |||
1208 | 1208 | ||
1209 | dev = acpi_get_physical_device(hotk->device->handle); | 1209 | dev = acpi_get_physical_device(hotk->device->handle); |
1210 | 1210 | ||
1211 | result = asus_backlight_init(dev); | 1211 | if (!acpi_video_backlight_support()) { |
1212 | if (result) | 1212 | result = asus_backlight_init(dev); |
1213 | goto fail_backlight; | 1213 | if (result) |
1214 | goto fail_backlight; | ||
1215 | } else | ||
1216 | printk(ASUS_INFO "Brightness ignored, must be controlled by " | ||
1217 | "ACPI video driver\n"); | ||
1214 | 1218 | ||
1215 | result = asus_led_init(dev); | 1219 | result = asus_led_init(dev); |
1216 | if (result) | 1220 | if (result) |
diff --git a/drivers/misc/c2port/Kconfig b/drivers/misc/c2port/Kconfig new file mode 100644 index 000000000000..e46af9a5810d --- /dev/null +++ b/drivers/misc/c2port/Kconfig | |||
@@ -0,0 +1,35 @@ | |||
1 | # | ||
2 | # C2 port devices | ||
3 | # | ||
4 | |||
5 | menuconfig C2PORT | ||
6 | tristate "Silicon Labs C2 port support (EXPERIMENTAL)" | ||
7 | depends on EXPERIMENTAL | ||
8 | default no | ||
9 | help | ||
10 | This option enables support for Silicon Labs C2 port used to | ||
11 | program Silicon micro controller chips (and other 8051 compatible). | ||
12 | |||
13 | If your board have no such micro controllers you don't need this | ||
14 | interface at all. | ||
15 | |||
16 | To compile this driver as a module, choose M here: the module will | ||
17 | be called c2port_core. Note that you also need a client module | ||
18 | usually called c2port-*. | ||
19 | |||
20 | If you are not sure, say N here. | ||
21 | |||
22 | if C2PORT | ||
23 | |||
24 | config C2PORT_DURAMAR_2150 | ||
25 | tristate "C2 port support for Eurotech's Duramar 2150 (EXPERIMENTAL)" | ||
26 | depends on X86 && C2PORT | ||
27 | default no | ||
28 | help | ||
29 | This option enables C2 support for the Eurotech's Duramar 2150 | ||
30 | on board micro controller. | ||
31 | |||
32 | To compile this driver as a module, choose M here: the module will | ||
33 | be called c2port-duramar2150. | ||
34 | |||
35 | endif # C2PORT | ||
diff --git a/drivers/misc/c2port/Makefile b/drivers/misc/c2port/Makefile new file mode 100644 index 000000000000..3b2cf43d60f5 --- /dev/null +++ b/drivers/misc/c2port/Makefile | |||
@@ -0,0 +1,3 @@ | |||
1 | obj-$(CONFIG_C2PORT) += core.o | ||
2 | |||
3 | obj-$(CONFIG_C2PORT_DURAMAR_2150) += c2port-duramar2150.o | ||
diff --git a/drivers/misc/c2port/c2port-duramar2150.c b/drivers/misc/c2port/c2port-duramar2150.c new file mode 100644 index 000000000000..338dcc121507 --- /dev/null +++ b/drivers/misc/c2port/c2port-duramar2150.c | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | * Silicon Labs C2 port Linux support for Eurotech Duramar 2150 | ||
3 | * | ||
4 | * Copyright (c) 2008 Rodolfo Giometti <giometti@linux.it> | ||
5 | * Copyright (c) 2008 Eurotech S.p.A. <info@eurotech.it> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License version 2 as published by | ||
9 | * the Free Software Foundation | ||
10 | */ | ||
11 | |||
12 | #include <linux/errno.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/c2port.h> | ||
19 | |||
20 | #define DATA_PORT 0x325 | ||
21 | #define DIR_PORT 0x326 | ||
22 | #define C2D (1 << 0) | ||
23 | #define C2CK (1 << 1) | ||
24 | |||
25 | static DEFINE_MUTEX(update_lock); | ||
26 | |||
27 | /* | ||
28 | * C2 port operations | ||
29 | */ | ||
30 | |||
31 | static void duramar2150_c2port_access(struct c2port_device *dev, int status) | ||
32 | { | ||
33 | u8 v; | ||
34 | |||
35 | mutex_lock(&update_lock); | ||
36 | |||
37 | v = inb(DIR_PORT); | ||
38 | |||
39 | /* 0 = input, 1 = output */ | ||
40 | if (status) | ||
41 | outb(v | (C2D | C2CK), DIR_PORT); | ||
42 | else | ||
43 | /* When access is "off" is important that both lines are set | ||
44 | * as inputs or hi-impedence */ | ||
45 | outb(v & ~(C2D | C2CK), DIR_PORT); | ||
46 | |||
47 | mutex_unlock(&update_lock); | ||
48 | } | ||
49 | |||
50 | static void duramar2150_c2port_c2d_dir(struct c2port_device *dev, int dir) | ||
51 | { | ||
52 | u8 v; | ||
53 | |||
54 | mutex_lock(&update_lock); | ||
55 | |||
56 | v = inb(DIR_PORT); | ||
57 | |||
58 | if (dir) | ||
59 | outb(v & ~C2D, DIR_PORT); | ||
60 | else | ||
61 | outb(v | C2D, DIR_PORT); | ||
62 | |||
63 | mutex_unlock(&update_lock); | ||
64 | } | ||
65 | |||
66 | static int duramar2150_c2port_c2d_get(struct c2port_device *dev) | ||
67 | { | ||
68 | return inb(DATA_PORT) & C2D; | ||
69 | } | ||
70 | |||
71 | static void duramar2150_c2port_c2d_set(struct c2port_device *dev, int status) | ||
72 | { | ||
73 | u8 v; | ||
74 | |||
75 | mutex_lock(&update_lock); | ||
76 | |||
77 | v = inb(DATA_PORT); | ||
78 | |||
79 | if (status) | ||
80 | outb(v | C2D, DATA_PORT); | ||
81 | else | ||
82 | outb(v & ~C2D, DATA_PORT); | ||
83 | |||
84 | mutex_unlock(&update_lock); | ||
85 | } | ||
86 | |||
87 | static void duramar2150_c2port_c2ck_set(struct c2port_device *dev, int status) | ||
88 | { | ||
89 | u8 v; | ||
90 | |||
91 | mutex_lock(&update_lock); | ||
92 | |||
93 | v = inb(DATA_PORT); | ||
94 | |||
95 | if (status) | ||
96 | outb(v | C2CK, DATA_PORT); | ||
97 | else | ||
98 | outb(v & ~C2CK, DATA_PORT); | ||
99 | |||
100 | mutex_unlock(&update_lock); | ||
101 | } | ||
102 | |||
103 | static struct c2port_ops duramar2150_c2port_ops = { | ||
104 | .block_size = 512, /* bytes */ | ||
105 | .blocks_num = 30, /* total flash size: 15360 bytes */ | ||
106 | |||
107 | .access = duramar2150_c2port_access, | ||
108 | .c2d_dir = duramar2150_c2port_c2d_dir, | ||
109 | .c2d_get = duramar2150_c2port_c2d_get, | ||
110 | .c2d_set = duramar2150_c2port_c2d_set, | ||
111 | .c2ck_set = duramar2150_c2port_c2ck_set, | ||
112 | }; | ||
113 | |||
114 | static struct c2port_device *duramar2150_c2port_dev; | ||
115 | |||
116 | /* | ||
117 | * Module stuff | ||
118 | */ | ||
119 | |||
120 | static int __init duramar2150_c2port_init(void) | ||
121 | { | ||
122 | struct resource *res; | ||
123 | int ret = 0; | ||
124 | |||
125 | res = request_region(0x325, 2, "c2port"); | ||
126 | if (!res) | ||
127 | return -EBUSY; | ||
128 | |||
129 | duramar2150_c2port_dev = c2port_device_register("uc", | ||
130 | &duramar2150_c2port_ops, NULL); | ||
131 | if (!duramar2150_c2port_dev) { | ||
132 | ret = -ENODEV; | ||
133 | goto free_region; | ||
134 | } | ||
135 | |||
136 | return 0; | ||
137 | |||
138 | free_region: | ||
139 | release_region(0x325, 2); | ||
140 | return ret; | ||
141 | } | ||
142 | |||
143 | static void __exit duramar2150_c2port_exit(void) | ||
144 | { | ||
145 | /* Setup the GPIOs as input by default (access = 0) */ | ||
146 | duramar2150_c2port_access(duramar2150_c2port_dev, 0); | ||
147 | |||
148 | c2port_device_unregister(duramar2150_c2port_dev); | ||
149 | |||
150 | release_region(0x325, 2); | ||
151 | } | ||
152 | |||
153 | module_init(duramar2150_c2port_init); | ||
154 | module_exit(duramar2150_c2port_exit); | ||
155 | |||
156 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | ||
157 | MODULE_DESCRIPTION("Silicon Labs C2 port Linux support for Duramar 2150"); | ||
158 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c new file mode 100644 index 000000000000..0207dd59090d --- /dev/null +++ b/drivers/misc/c2port/core.c | |||
@@ -0,0 +1,1003 @@ | |||
1 | /* | ||
2 | * Silicon Labs C2 port core Linux support | ||
3 | * | ||
4 | * Copyright (c) 2007 Rodolfo Giometti <giometti@linux.it> | ||
5 | * Copyright (c) 2007 Eurotech S.p.A. <info@eurotech.it> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License version 2 as published by | ||
9 | * the Free Software Foundation | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/errno.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/ctype.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/idr.h> | ||
21 | #include <linux/sched.h> | ||
22 | |||
23 | #include <linux/c2port.h> | ||
24 | |||
25 | #define DRIVER_NAME "c2port" | ||
26 | #define DRIVER_VERSION "0.51.0" | ||
27 | |||
28 | static DEFINE_SPINLOCK(c2port_idr_lock); | ||
29 | static DEFINE_IDR(c2port_idr); | ||
30 | |||
31 | /* | ||
32 | * Local variables | ||
33 | */ | ||
34 | |||
35 | static struct class *c2port_class; | ||
36 | |||
37 | /* | ||
38 | * C2 registers & commands defines | ||
39 | */ | ||
40 | |||
41 | /* C2 registers */ | ||
42 | #define C2PORT_DEVICEID 0x00 | ||
43 | #define C2PORT_REVID 0x01 | ||
44 | #define C2PORT_FPCTL 0x02 | ||
45 | #define C2PORT_FPDAT 0xB4 | ||
46 | |||
47 | /* C2 interface commands */ | ||
48 | #define C2PORT_GET_VERSION 0x01 | ||
49 | #define C2PORT_DEVICE_ERASE 0x03 | ||
50 | #define C2PORT_BLOCK_READ 0x06 | ||
51 | #define C2PORT_BLOCK_WRITE 0x07 | ||
52 | #define C2PORT_PAGE_ERASE 0x08 | ||
53 | |||
54 | /* C2 status return codes */ | ||
55 | #define C2PORT_INVALID_COMMAND 0x00 | ||
56 | #define C2PORT_COMMAND_FAILED 0x02 | ||
57 | #define C2PORT_COMMAND_OK 0x0d | ||
58 | |||
59 | /* | ||
60 | * C2 port low level signal managements | ||
61 | */ | ||
62 | |||
63 | static void c2port_reset(struct c2port_device *dev) | ||
64 | { | ||
65 | struct c2port_ops *ops = dev->ops; | ||
66 | |||
67 | /* To reset the device we have to keep clock line low for at least | ||
68 | * 20us. | ||
69 | */ | ||
70 | local_irq_disable(); | ||
71 | ops->c2ck_set(dev, 0); | ||
72 | udelay(25); | ||
73 | ops->c2ck_set(dev, 1); | ||
74 | local_irq_enable(); | ||
75 | |||
76 | udelay(1); | ||
77 | } | ||
78 | |||
79 | static void c2port_strobe_ck(struct c2port_device *dev) | ||
80 | { | ||
81 | struct c2port_ops *ops = dev->ops; | ||
82 | |||
83 | /* During hi-low-hi transition we disable local IRQs to avoid | ||
84 | * interructions since C2 port specification says that it must be | ||
85 | * shorter than 5us, otherwise the microcontroller may consider | ||
86 | * it as a reset signal! | ||
87 | */ | ||
88 | local_irq_disable(); | ||
89 | ops->c2ck_set(dev, 0); | ||
90 | udelay(1); | ||
91 | ops->c2ck_set(dev, 1); | ||
92 | local_irq_enable(); | ||
93 | |||
94 | udelay(1); | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | * C2 port basic functions | ||
99 | */ | ||
100 | |||
101 | static void c2port_write_ar(struct c2port_device *dev, u8 addr) | ||
102 | { | ||
103 | struct c2port_ops *ops = dev->ops; | ||
104 | int i; | ||
105 | |||
106 | /* START field */ | ||
107 | c2port_strobe_ck(dev); | ||
108 | |||
109 | /* INS field (11b, LSB first) */ | ||
110 | ops->c2d_dir(dev, 0); | ||
111 | ops->c2d_set(dev, 1); | ||
112 | c2port_strobe_ck(dev); | ||
113 | ops->c2d_set(dev, 1); | ||
114 | c2port_strobe_ck(dev); | ||
115 | |||
116 | /* ADDRESS field */ | ||
117 | for (i = 0; i < 8; i++) { | ||
118 | ops->c2d_set(dev, addr & 0x01); | ||
119 | c2port_strobe_ck(dev); | ||
120 | |||
121 | addr >>= 1; | ||
122 | } | ||
123 | |||
124 | /* STOP field */ | ||
125 | ops->c2d_dir(dev, 1); | ||
126 | c2port_strobe_ck(dev); | ||
127 | } | ||
128 | |||
129 | static int c2port_read_ar(struct c2port_device *dev, u8 *addr) | ||
130 | { | ||
131 | struct c2port_ops *ops = dev->ops; | ||
132 | int i; | ||
133 | |||
134 | /* START field */ | ||
135 | c2port_strobe_ck(dev); | ||
136 | |||
137 | /* INS field (10b, LSB first) */ | ||
138 | ops->c2d_dir(dev, 0); | ||
139 | ops->c2d_set(dev, 0); | ||
140 | c2port_strobe_ck(dev); | ||
141 | ops->c2d_set(dev, 1); | ||
142 | c2port_strobe_ck(dev); | ||
143 | |||
144 | /* ADDRESS field */ | ||
145 | ops->c2d_dir(dev, 1); | ||
146 | *addr = 0; | ||
147 | for (i = 0; i < 8; i++) { | ||
148 | *addr >>= 1; /* shift in 8-bit ADDRESS field LSB first */ | ||
149 | |||
150 | c2port_strobe_ck(dev); | ||
151 | if (ops->c2d_get(dev)) | ||
152 | *addr |= 0x80; | ||
153 | } | ||
154 | |||
155 | /* STOP field */ | ||
156 | c2port_strobe_ck(dev); | ||
157 | |||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static int c2port_write_dr(struct c2port_device *dev, u8 data) | ||
162 | { | ||
163 | struct c2port_ops *ops = dev->ops; | ||
164 | int timeout, i; | ||
165 | |||
166 | /* START field */ | ||
167 | c2port_strobe_ck(dev); | ||
168 | |||
169 | /* INS field (01b, LSB first) */ | ||
170 | ops->c2d_dir(dev, 0); | ||
171 | ops->c2d_set(dev, 1); | ||
172 | c2port_strobe_ck(dev); | ||
173 | ops->c2d_set(dev, 0); | ||
174 | c2port_strobe_ck(dev); | ||
175 | |||
176 | /* LENGTH field (00b, LSB first -> 1 byte) */ | ||
177 | ops->c2d_set(dev, 0); | ||
178 | c2port_strobe_ck(dev); | ||
179 | ops->c2d_set(dev, 0); | ||
180 | c2port_strobe_ck(dev); | ||
181 | |||
182 | /* DATA field */ | ||
183 | for (i = 0; i < 8; i++) { | ||
184 | ops->c2d_set(dev, data & 0x01); | ||
185 | c2port_strobe_ck(dev); | ||
186 | |||
187 | data >>= 1; | ||
188 | } | ||
189 | |||
190 | /* WAIT field */ | ||
191 | ops->c2d_dir(dev, 1); | ||
192 | timeout = 20; | ||
193 | do { | ||
194 | c2port_strobe_ck(dev); | ||
195 | if (ops->c2d_get(dev)) | ||
196 | break; | ||
197 | |||
198 | udelay(1); | ||
199 | } while (--timeout > 0); | ||
200 | if (timeout == 0) | ||
201 | return -EIO; | ||
202 | |||
203 | /* STOP field */ | ||
204 | c2port_strobe_ck(dev); | ||
205 | |||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | static int c2port_read_dr(struct c2port_device *dev, u8 *data) | ||
210 | { | ||
211 | struct c2port_ops *ops = dev->ops; | ||
212 | int timeout, i; | ||
213 | |||
214 | /* START field */ | ||
215 | c2port_strobe_ck(dev); | ||
216 | |||
217 | /* INS field (00b, LSB first) */ | ||
218 | ops->c2d_dir(dev, 0); | ||
219 | ops->c2d_set(dev, 0); | ||
220 | c2port_strobe_ck(dev); | ||
221 | ops->c2d_set(dev, 0); | ||
222 | c2port_strobe_ck(dev); | ||
223 | |||
224 | /* LENGTH field (00b, LSB first -> 1 byte) */ | ||
225 | ops->c2d_set(dev, 0); | ||
226 | c2port_strobe_ck(dev); | ||
227 | ops->c2d_set(dev, 0); | ||
228 | c2port_strobe_ck(dev); | ||
229 | |||
230 | /* WAIT field */ | ||
231 | ops->c2d_dir(dev, 1); | ||
232 | timeout = 20; | ||
233 | do { | ||
234 | c2port_strobe_ck(dev); | ||
235 | if (ops->c2d_get(dev)) | ||
236 | break; | ||
237 | |||
238 | udelay(1); | ||
239 | } while (--timeout > 0); | ||
240 | if (timeout == 0) | ||
241 | return -EIO; | ||
242 | |||
243 | /* DATA field */ | ||
244 | *data = 0; | ||
245 | for (i = 0; i < 8; i++) { | ||
246 | *data >>= 1; /* shift in 8-bit DATA field LSB first */ | ||
247 | |||
248 | c2port_strobe_ck(dev); | ||
249 | if (ops->c2d_get(dev)) | ||
250 | *data |= 0x80; | ||
251 | } | ||
252 | |||
253 | /* STOP field */ | ||
254 | c2port_strobe_ck(dev); | ||
255 | |||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static int c2port_poll_in_busy(struct c2port_device *dev) | ||
260 | { | ||
261 | u8 addr; | ||
262 | int ret, timeout = 20; | ||
263 | |||
264 | do { | ||
265 | ret = (c2port_read_ar(dev, &addr)); | ||
266 | if (ret < 0) | ||
267 | return -EIO; | ||
268 | |||
269 | if (!(addr & 0x02)) | ||
270 | break; | ||
271 | |||
272 | udelay(1); | ||
273 | } while (--timeout > 0); | ||
274 | if (timeout == 0) | ||
275 | return -EIO; | ||
276 | |||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | static int c2port_poll_out_ready(struct c2port_device *dev) | ||
281 | { | ||
282 | u8 addr; | ||
283 | int ret, timeout = 10000; /* erase flash needs long time... */ | ||
284 | |||
285 | do { | ||
286 | ret = (c2port_read_ar(dev, &addr)); | ||
287 | if (ret < 0) | ||
288 | return -EIO; | ||
289 | |||
290 | if (addr & 0x01) | ||
291 | break; | ||
292 | |||
293 | udelay(1); | ||
294 | } while (--timeout > 0); | ||
295 | if (timeout == 0) | ||
296 | return -EIO; | ||
297 | |||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | /* | ||
302 | * sysfs methods | ||
303 | */ | ||
304 | |||
305 | static ssize_t c2port_show_name(struct device *dev, | ||
306 | struct device_attribute *attr, char *buf) | ||
307 | { | ||
308 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
309 | |||
310 | return sprintf(buf, "%s\n", c2dev->name); | ||
311 | } | ||
312 | |||
313 | static ssize_t c2port_show_flash_blocks_num(struct device *dev, | ||
314 | struct device_attribute *attr, char *buf) | ||
315 | { | ||
316 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
317 | struct c2port_ops *ops = c2dev->ops; | ||
318 | |||
319 | return sprintf(buf, "%d\n", ops->blocks_num); | ||
320 | } | ||
321 | |||
322 | static ssize_t c2port_show_flash_block_size(struct device *dev, | ||
323 | struct device_attribute *attr, char *buf) | ||
324 | { | ||
325 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
326 | struct c2port_ops *ops = c2dev->ops; | ||
327 | |||
328 | return sprintf(buf, "%d\n", ops->block_size); | ||
329 | } | ||
330 | |||
331 | static ssize_t c2port_show_flash_size(struct device *dev, | ||
332 | struct device_attribute *attr, char *buf) | ||
333 | { | ||
334 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
335 | struct c2port_ops *ops = c2dev->ops; | ||
336 | |||
337 | return sprintf(buf, "%d\n", ops->blocks_num * ops->block_size); | ||
338 | } | ||
339 | |||
340 | static ssize_t c2port_show_access(struct device *dev, | ||
341 | struct device_attribute *attr, char *buf) | ||
342 | { | ||
343 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
344 | |||
345 | return sprintf(buf, "%d\n", c2dev->access); | ||
346 | } | ||
347 | |||
348 | static ssize_t c2port_store_access(struct device *dev, | ||
349 | struct device_attribute *attr, | ||
350 | const char *buf, size_t count) | ||
351 | { | ||
352 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
353 | struct c2port_ops *ops = c2dev->ops; | ||
354 | int status, ret; | ||
355 | |||
356 | ret = sscanf(buf, "%d", &status); | ||
357 | if (ret != 1) | ||
358 | return -EINVAL; | ||
359 | |||
360 | mutex_lock(&c2dev->mutex); | ||
361 | |||
362 | c2dev->access = !!status; | ||
363 | |||
364 | /* If access is "on" clock should be HIGH _before_ setting the line | ||
365 | * as output and data line should be set as INPUT anyway */ | ||
366 | if (c2dev->access) | ||
367 | ops->c2ck_set(c2dev, 1); | ||
368 | ops->access(c2dev, c2dev->access); | ||
369 | if (c2dev->access) | ||
370 | ops->c2d_dir(c2dev, 1); | ||
371 | |||
372 | mutex_unlock(&c2dev->mutex); | ||
373 | |||
374 | return count; | ||
375 | } | ||
376 | |||
377 | static ssize_t c2port_store_reset(struct device *dev, | ||
378 | struct device_attribute *attr, | ||
379 | const char *buf, size_t count) | ||
380 | { | ||
381 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
382 | |||
383 | /* Check the device access status */ | ||
384 | if (!c2dev->access) | ||
385 | return -EBUSY; | ||
386 | |||
387 | mutex_lock(&c2dev->mutex); | ||
388 | |||
389 | c2port_reset(c2dev); | ||
390 | c2dev->flash_access = 0; | ||
391 | |||
392 | mutex_unlock(&c2dev->mutex); | ||
393 | |||
394 | return count; | ||
395 | } | ||
396 | |||
397 | static ssize_t __c2port_show_dev_id(struct c2port_device *dev, char *buf) | ||
398 | { | ||
399 | u8 data; | ||
400 | int ret; | ||
401 | |||
402 | /* Select DEVICEID register for C2 data register accesses */ | ||
403 | c2port_write_ar(dev, C2PORT_DEVICEID); | ||
404 | |||
405 | /* Read and return the device ID register */ | ||
406 | ret = c2port_read_dr(dev, &data); | ||
407 | if (ret < 0) | ||
408 | return ret; | ||
409 | |||
410 | return sprintf(buf, "%d\n", data); | ||
411 | } | ||
412 | |||
413 | static ssize_t c2port_show_dev_id(struct device *dev, | ||
414 | struct device_attribute *attr, char *buf) | ||
415 | { | ||
416 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
417 | ssize_t ret; | ||
418 | |||
419 | /* Check the device access status */ | ||
420 | if (!c2dev->access) | ||
421 | return -EBUSY; | ||
422 | |||
423 | mutex_lock(&c2dev->mutex); | ||
424 | ret = __c2port_show_dev_id(c2dev, buf); | ||
425 | mutex_unlock(&c2dev->mutex); | ||
426 | |||
427 | if (ret < 0) | ||
428 | dev_err(dev, "cannot read from %s\n", c2dev->name); | ||
429 | |||
430 | return ret; | ||
431 | } | ||
432 | |||
433 | static ssize_t __c2port_show_rev_id(struct c2port_device *dev, char *buf) | ||
434 | { | ||
435 | u8 data; | ||
436 | int ret; | ||
437 | |||
438 | /* Select REVID register for C2 data register accesses */ | ||
439 | c2port_write_ar(dev, C2PORT_REVID); | ||
440 | |||
441 | /* Read and return the revision ID register */ | ||
442 | ret = c2port_read_dr(dev, &data); | ||
443 | if (ret < 0) | ||
444 | return ret; | ||
445 | |||
446 | return sprintf(buf, "%d\n", data); | ||
447 | } | ||
448 | |||
449 | static ssize_t c2port_show_rev_id(struct device *dev, | ||
450 | struct device_attribute *attr, char *buf) | ||
451 | { | ||
452 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
453 | ssize_t ret; | ||
454 | |||
455 | /* Check the device access status */ | ||
456 | if (!c2dev->access) | ||
457 | return -EBUSY; | ||
458 | |||
459 | mutex_lock(&c2dev->mutex); | ||
460 | ret = __c2port_show_rev_id(c2dev, buf); | ||
461 | mutex_unlock(&c2dev->mutex); | ||
462 | |||
463 | if (ret < 0) | ||
464 | dev_err(c2dev->dev, "cannot read from %s\n", c2dev->name); | ||
465 | |||
466 | return ret; | ||
467 | } | ||
468 | |||
469 | static ssize_t c2port_show_flash_access(struct device *dev, | ||
470 | struct device_attribute *attr, char *buf) | ||
471 | { | ||
472 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
473 | |||
474 | return sprintf(buf, "%d\n", c2dev->flash_access); | ||
475 | } | ||
476 | |||
477 | static ssize_t __c2port_store_flash_access(struct c2port_device *dev, | ||
478 | int status) | ||
479 | { | ||
480 | int ret; | ||
481 | |||
482 | /* Check the device access status */ | ||
483 | if (!dev->access) | ||
484 | return -EBUSY; | ||
485 | |||
486 | dev->flash_access = !!status; | ||
487 | |||
488 | /* If flash_access is off we have nothing to do... */ | ||
489 | if (dev->flash_access == 0) | ||
490 | return 0; | ||
491 | |||
492 | /* Target the C2 flash programming control register for C2 data | ||
493 | * register access */ | ||
494 | c2port_write_ar(dev, C2PORT_FPCTL); | ||
495 | |||
496 | /* Write the first keycode to enable C2 Flash programming */ | ||
497 | ret = c2port_write_dr(dev, 0x02); | ||
498 | if (ret < 0) | ||
499 | return ret; | ||
500 | |||
501 | /* Write the second keycode to enable C2 Flash programming */ | ||
502 | ret = c2port_write_dr(dev, 0x01); | ||
503 | if (ret < 0) | ||
504 | return ret; | ||
505 | |||
506 | /* Delay for at least 20ms to ensure the target is ready for | ||
507 | * C2 flash programming */ | ||
508 | mdelay(25); | ||
509 | |||
510 | return 0; | ||
511 | } | ||
512 | |||
513 | static ssize_t c2port_store_flash_access(struct device *dev, | ||
514 | struct device_attribute *attr, | ||
515 | const char *buf, size_t count) | ||
516 | { | ||
517 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
518 | int status; | ||
519 | ssize_t ret; | ||
520 | |||
521 | ret = sscanf(buf, "%d", &status); | ||
522 | if (ret != 1) | ||
523 | return -EINVAL; | ||
524 | |||
525 | mutex_lock(&c2dev->mutex); | ||
526 | ret = __c2port_store_flash_access(c2dev, status); | ||
527 | mutex_unlock(&c2dev->mutex); | ||
528 | |||
529 | if (ret < 0) { | ||
530 | dev_err(c2dev->dev, "cannot enable %s flash programming\n", | ||
531 | c2dev->name); | ||
532 | return ret; | ||
533 | } | ||
534 | |||
535 | return count; | ||
536 | } | ||
537 | |||
538 | static ssize_t __c2port_write_flash_erase(struct c2port_device *dev) | ||
539 | { | ||
540 | u8 status; | ||
541 | int ret; | ||
542 | |||
543 | /* Target the C2 flash programming data register for C2 data register | ||
544 | * access. | ||
545 | */ | ||
546 | c2port_write_ar(dev, C2PORT_FPDAT); | ||
547 | |||
548 | /* Send device erase command */ | ||
549 | c2port_write_dr(dev, C2PORT_DEVICE_ERASE); | ||
550 | |||
551 | /* Wait for input acknowledge */ | ||
552 | ret = c2port_poll_in_busy(dev); | ||
553 | if (ret < 0) | ||
554 | return ret; | ||
555 | |||
556 | /* Should check status before starting FLASH access sequence */ | ||
557 | |||
558 | /* Wait for status information */ | ||
559 | ret = c2port_poll_out_ready(dev); | ||
560 | if (ret < 0) | ||
561 | return ret; | ||
562 | |||
563 | /* Read flash programming interface status */ | ||
564 | ret = c2port_read_dr(dev, &status); | ||
565 | if (ret < 0) | ||
566 | return ret; | ||
567 | if (status != C2PORT_COMMAND_OK) | ||
568 | return -EBUSY; | ||
569 | |||
570 | /* Send a three-byte arming sequence to enable the device erase. | ||
571 | * If the sequence is not received correctly, the command will be | ||
572 | * ignored. | ||
573 | * Sequence is: 0xde, 0xad, 0xa5. | ||
574 | */ | ||
575 | c2port_write_dr(dev, 0xde); | ||
576 | ret = c2port_poll_in_busy(dev); | ||
577 | if (ret < 0) | ||
578 | return ret; | ||
579 | c2port_write_dr(dev, 0xad); | ||
580 | ret = c2port_poll_in_busy(dev); | ||
581 | if (ret < 0) | ||
582 | return ret; | ||
583 | c2port_write_dr(dev, 0xa5); | ||
584 | ret = c2port_poll_in_busy(dev); | ||
585 | if (ret < 0) | ||
586 | return ret; | ||
587 | |||
588 | ret = c2port_poll_out_ready(dev); | ||
589 | if (ret < 0) | ||
590 | return ret; | ||
591 | |||
592 | return 0; | ||
593 | } | ||
594 | |||
595 | static ssize_t c2port_store_flash_erase(struct device *dev, | ||
596 | struct device_attribute *attr, | ||
597 | const char *buf, size_t count) | ||
598 | { | ||
599 | struct c2port_device *c2dev = dev_get_drvdata(dev); | ||
600 | int ret; | ||
601 | |||
602 | /* Check the device and flash access status */ | ||
603 | if (!c2dev->access || !c2dev->flash_access) | ||
604 | return -EBUSY; | ||
605 | |||
606 | mutex_lock(&c2dev->mutex); | ||
607 | ret = __c2port_write_flash_erase(c2dev); | ||
608 | mutex_unlock(&c2dev->mutex); | ||
609 | |||
610 | if (ret < 0) { | ||
611 | dev_err(c2dev->dev, "cannot erase %s flash\n", c2dev->name); | ||
612 | return ret; | ||
613 | } | ||
614 | |||
615 | return count; | ||
616 | } | ||
617 | |||
618 | static ssize_t __c2port_read_flash_data(struct c2port_device *dev, | ||
619 | char *buffer, loff_t offset, size_t count) | ||
620 | { | ||
621 | struct c2port_ops *ops = dev->ops; | ||
622 | u8 status, nread = 128; | ||
623 | int i, ret; | ||
624 | |||
625 | /* Check for flash end */ | ||
626 | if (offset >= ops->block_size * ops->blocks_num) | ||
627 | return 0; | ||
628 | |||
629 | if (ops->block_size * ops->blocks_num - offset < nread) | ||
630 | nread = ops->block_size * ops->blocks_num - offset; | ||
631 | if (count < nread) | ||
632 | nread = count; | ||
633 | if (nread == 0) | ||
634 | return nread; | ||
635 | |||
636 | /* Target the C2 flash programming data register for C2 data register | ||
637 | * access */ | ||
638 | c2port_write_ar(dev, C2PORT_FPDAT); | ||
639 | |||
640 | /* Send flash block read command */ | ||
641 | c2port_write_dr(dev, C2PORT_BLOCK_READ); | ||
642 | |||
643 | /* Wait for input acknowledge */ | ||
644 | ret = c2port_poll_in_busy(dev); | ||
645 | if (ret < 0) | ||
646 | return ret; | ||
647 | |||
648 | /* Should check status before starting FLASH access sequence */ | ||
649 | |||
650 | /* Wait for status information */ | ||
651 | ret = c2port_poll_out_ready(dev); | ||
652 | if (ret < 0) | ||
653 | return ret; | ||
654 | |||
655 | /* Read flash programming interface status */ | ||
656 | ret = c2port_read_dr(dev, &status); | ||
657 | if (ret < 0) | ||
658 | return ret; | ||
659 | if (status != C2PORT_COMMAND_OK) | ||
660 | return -EBUSY; | ||
661 | |||
662 | /* Send address high byte */ | ||
663 | c2port_write_dr(dev, offset >> 8); | ||
664 | ret = c2port_poll_in_busy(dev); | ||
665 | if (ret < 0) | ||
666 | return ret; | ||
667 | |||
668 | /* Send address low byte */ | ||
669 | c2port_write_dr(dev, offset & 0x00ff); | ||
670 | ret = c2port_poll_in_busy(dev); | ||
671 | if (ret < 0) | ||
672 | return ret; | ||
673 | |||
674 | /* Send address block size */ | ||
675 | c2port_write_dr(dev, nread); | ||
676 | ret = c2port_poll_in_busy(dev); | ||
677 | if (ret < 0) | ||
678 | return ret; | ||
679 | |||
680 | /* Should check status before reading FLASH block */ | ||
681 | |||
682 | /* Wait for status information */ | ||
683 | ret = c2port_poll_out_ready(dev); | ||
684 | if (ret < 0) | ||
685 | return ret; | ||
686 | |||
687 | /* Read flash programming interface status */ | ||
688 | ret = c2port_read_dr(dev, &status); | ||
689 | if (ret < 0) | ||
690 | return ret; | ||
691 | if (status != C2PORT_COMMAND_OK) | ||
692 | return -EBUSY; | ||
693 | |||
694 | /* Read flash block */ | ||
695 | for (i = 0; i < nread; i++) { | ||
696 | ret = c2port_poll_out_ready(dev); | ||
697 | if (ret < 0) | ||
698 | return ret; | ||
699 | |||
700 | ret = c2port_read_dr(dev, buffer+i); | ||
701 | if (ret < 0) | ||
702 | return ret; | ||
703 | } | ||
704 | |||
705 | return nread; | ||
706 | } | ||
707 | |||
708 | static ssize_t c2port_read_flash_data(struct kobject *kobj, | ||
709 | struct bin_attribute *attr, | ||
710 | char *buffer, loff_t offset, size_t count) | ||
711 | { | ||
712 | struct c2port_device *c2dev = | ||
713 | dev_get_drvdata(container_of(kobj, | ||
714 | struct device, kobj)); | ||
715 | ssize_t ret; | ||
716 | |||
717 | /* Check the device and flash access status */ | ||
718 | if (!c2dev->access || !c2dev->flash_access) | ||
719 | return -EBUSY; | ||
720 | |||
721 | mutex_lock(&c2dev->mutex); | ||
722 | ret = __c2port_read_flash_data(c2dev, buffer, offset, count); | ||
723 | mutex_unlock(&c2dev->mutex); | ||
724 | |||
725 | if (ret < 0) | ||
726 | dev_err(c2dev->dev, "cannot read %s flash\n", c2dev->name); | ||
727 | |||
728 | return ret; | ||
729 | } | ||
730 | |||
731 | static ssize_t __c2port_write_flash_data(struct c2port_device *dev, | ||
732 | char *buffer, loff_t offset, size_t count) | ||
733 | { | ||
734 | struct c2port_ops *ops = dev->ops; | ||
735 | u8 status, nwrite = 128; | ||
736 | int i, ret; | ||
737 | |||
738 | if (nwrite > count) | ||
739 | nwrite = count; | ||
740 | if (ops->block_size * ops->blocks_num - offset < nwrite) | ||
741 | nwrite = ops->block_size * ops->blocks_num - offset; | ||
742 | |||
743 | /* Check for flash end */ | ||
744 | if (offset >= ops->block_size * ops->blocks_num) | ||
745 | return -EINVAL; | ||
746 | |||
747 | /* Target the C2 flash programming data register for C2 data register | ||
748 | * access */ | ||
749 | c2port_write_ar(dev, C2PORT_FPDAT); | ||
750 | |||
751 | /* Send flash block write command */ | ||
752 | c2port_write_dr(dev, C2PORT_BLOCK_WRITE); | ||
753 | |||
754 | /* Wait for input acknowledge */ | ||
755 | ret = c2port_poll_in_busy(dev); | ||
756 | if (ret < 0) | ||
757 | return ret; | ||
758 | |||
759 | /* Should check status before starting FLASH access sequence */ | ||
760 | |||
761 | /* Wait for status information */ | ||
762 | ret = c2port_poll_out_ready(dev); | ||
763 | if (ret < 0) | ||
764 | return ret; | ||
765 | |||
766 | /* Read flash programming interface status */ | ||
767 | ret = c2port_read_dr(dev, &status); | ||
768 | if (ret < 0) | ||
769 | return ret; | ||
770 | if (status != C2PORT_COMMAND_OK) | ||
771 | return -EBUSY; | ||
772 | |||
773 | /* Send address high byte */ | ||
774 | c2port_write_dr(dev, offset >> 8); | ||
775 | ret = c2port_poll_in_busy(dev); | ||
776 | if (ret < 0) | ||
777 | return ret; | ||
778 | |||
779 | /* Send address low byte */ | ||
780 | c2port_write_dr(dev, offset & 0x00ff); | ||
781 | ret = c2port_poll_in_busy(dev); | ||
782 | if (ret < 0) | ||
783 | return ret; | ||
784 | |||
785 | /* Send address block size */ | ||
786 | c2port_write_dr(dev, nwrite); | ||
787 | ret = c2port_poll_in_busy(dev); | ||
788 | if (ret < 0) | ||
789 | return ret; | ||
790 | |||
791 | /* Should check status before writing FLASH block */ | ||
792 | |||
793 | /* Wait for status information */ | ||
794 | ret = c2port_poll_out_ready(dev); | ||
795 | if (ret < 0) | ||
796 | return ret; | ||
797 | |||
798 | /* Read flash programming interface status */ | ||
799 | ret = c2port_read_dr(dev, &status); | ||
800 | if (ret < 0) | ||
801 | return ret; | ||
802 | if (status != C2PORT_COMMAND_OK) | ||
803 | return -EBUSY; | ||
804 | |||
805 | /* Write flash block */ | ||
806 | for (i = 0; i < nwrite; i++) { | ||
807 | ret = c2port_write_dr(dev, *(buffer+i)); | ||
808 | if (ret < 0) | ||
809 | return ret; | ||
810 | |||
811 | ret = c2port_poll_in_busy(dev); | ||
812 | if (ret < 0) | ||
813 | return ret; | ||
814 | |||
815 | } | ||
816 | |||
817 | /* Wait for last flash write to complete */ | ||
818 | ret = c2port_poll_out_ready(dev); | ||
819 | if (ret < 0) | ||
820 | return ret; | ||
821 | |||
822 | return nwrite; | ||
823 | } | ||
824 | |||
825 | static ssize_t c2port_write_flash_data(struct kobject *kobj, | ||
826 | struct bin_attribute *attr, | ||
827 | char *buffer, loff_t offset, size_t count) | ||
828 | { | ||
829 | struct c2port_device *c2dev = | ||
830 | dev_get_drvdata(container_of(kobj, | ||
831 | struct device, kobj)); | ||
832 | int ret; | ||
833 | |||
834 | /* Check the device access status */ | ||
835 | if (!c2dev->access || !c2dev->flash_access) | ||
836 | return -EBUSY; | ||
837 | |||
838 | mutex_lock(&c2dev->mutex); | ||
839 | ret = __c2port_write_flash_data(c2dev, buffer, offset, count); | ||
840 | mutex_unlock(&c2dev->mutex); | ||
841 | |||
842 | if (ret < 0) | ||
843 | dev_err(c2dev->dev, "cannot write %s flash\n", c2dev->name); | ||
844 | |||
845 | return ret; | ||
846 | } | ||
847 | |||
848 | /* | ||
849 | * Class attributes | ||
850 | */ | ||
851 | |||
852 | static struct device_attribute c2port_attrs[] = { | ||
853 | __ATTR(name, 0444, c2port_show_name, NULL), | ||
854 | __ATTR(flash_blocks_num, 0444, c2port_show_flash_blocks_num, NULL), | ||
855 | __ATTR(flash_block_size, 0444, c2port_show_flash_block_size, NULL), | ||
856 | __ATTR(flash_size, 0444, c2port_show_flash_size, NULL), | ||
857 | __ATTR(access, 0644, c2port_show_access, c2port_store_access), | ||
858 | __ATTR(reset, 0200, NULL, c2port_store_reset), | ||
859 | __ATTR(dev_id, 0444, c2port_show_dev_id, NULL), | ||
860 | __ATTR(rev_id, 0444, c2port_show_rev_id, NULL), | ||
861 | |||
862 | __ATTR(flash_access, 0644, c2port_show_flash_access, | ||
863 | c2port_store_flash_access), | ||
864 | __ATTR(flash_erase, 0200, NULL, c2port_store_flash_erase), | ||
865 | __ATTR_NULL, | ||
866 | }; | ||
867 | |||
868 | static struct bin_attribute c2port_bin_attrs = { | ||
869 | .attr = { | ||
870 | .name = "flash_data", | ||
871 | .mode = 0644 | ||
872 | }, | ||
873 | .read = c2port_read_flash_data, | ||
874 | .write = c2port_write_flash_data, | ||
875 | /* .size is computed at run-time */ | ||
876 | }; | ||
877 | |||
878 | /* | ||
879 | * Exported functions | ||
880 | */ | ||
881 | |||
882 | struct c2port_device *c2port_device_register(char *name, | ||
883 | struct c2port_ops *ops, void *devdata) | ||
884 | { | ||
885 | struct c2port_device *c2dev; | ||
886 | int id, ret; | ||
887 | |||
888 | if (unlikely(!ops) || unlikely(!ops->access) || \ | ||
889 | unlikely(!ops->c2d_dir) || unlikely(!ops->c2ck_set) || \ | ||
890 | unlikely(!ops->c2d_get) || unlikely(!ops->c2d_set)) | ||
891 | return ERR_PTR(-EINVAL); | ||
892 | |||
893 | c2dev = kmalloc(sizeof(struct c2port_device), GFP_KERNEL); | ||
894 | if (unlikely(!c2dev)) | ||
895 | return ERR_PTR(-ENOMEM); | ||
896 | |||
897 | ret = idr_pre_get(&c2port_idr, GFP_KERNEL); | ||
898 | if (!ret) { | ||
899 | ret = -ENOMEM; | ||
900 | goto error_idr_get_new; | ||
901 | } | ||
902 | |||
903 | spin_lock_irq(&c2port_idr_lock); | ||
904 | ret = idr_get_new(&c2port_idr, c2dev, &id); | ||
905 | spin_unlock_irq(&c2port_idr_lock); | ||
906 | |||
907 | if (ret < 0) | ||
908 | goto error_idr_get_new; | ||
909 | c2dev->id = id; | ||
910 | |||
911 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, | ||
912 | "c2port%d", id); | ||
913 | if (unlikely(!c2dev->dev)) { | ||
914 | ret = -ENOMEM; | ||
915 | goto error_device_create; | ||
916 | } | ||
917 | dev_set_drvdata(c2dev->dev, c2dev); | ||
918 | |||
919 | strncpy(c2dev->name, name, C2PORT_NAME_LEN); | ||
920 | c2dev->ops = ops; | ||
921 | mutex_init(&c2dev->mutex); | ||
922 | |||
923 | /* Create binary file */ | ||
924 | c2port_bin_attrs.size = ops->blocks_num * ops->block_size; | ||
925 | ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs); | ||
926 | if (unlikely(ret)) | ||
927 | goto error_device_create_bin_file; | ||
928 | |||
929 | /* By default C2 port access is off */ | ||
930 | c2dev->access = c2dev->flash_access = 0; | ||
931 | ops->access(c2dev, 0); | ||
932 | |||
933 | dev_info(c2dev->dev, "C2 port %s added\n", name); | ||
934 | dev_info(c2dev->dev, "%s flash has %d blocks x %d bytes " | ||
935 | "(%d bytes total)\n", | ||
936 | name, ops->blocks_num, ops->block_size, | ||
937 | ops->blocks_num * ops->block_size); | ||
938 | |||
939 | return c2dev; | ||
940 | |||
941 | error_device_create_bin_file: | ||
942 | device_destroy(c2port_class, 0); | ||
943 | |||
944 | error_device_create: | ||
945 | spin_lock_irq(&c2port_idr_lock); | ||
946 | idr_remove(&c2port_idr, id); | ||
947 | spin_unlock_irq(&c2port_idr_lock); | ||
948 | |||
949 | error_idr_get_new: | ||
950 | kfree(c2dev); | ||
951 | |||
952 | return ERR_PTR(ret); | ||
953 | } | ||
954 | EXPORT_SYMBOL(c2port_device_register); | ||
955 | |||
956 | void c2port_device_unregister(struct c2port_device *c2dev) | ||
957 | { | ||
958 | if (!c2dev) | ||
959 | return; | ||
960 | |||
961 | dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name); | ||
962 | |||
963 | device_remove_bin_file(c2dev->dev, &c2port_bin_attrs); | ||
964 | spin_lock_irq(&c2port_idr_lock); | ||
965 | idr_remove(&c2port_idr, c2dev->id); | ||
966 | spin_unlock_irq(&c2port_idr_lock); | ||
967 | |||
968 | device_destroy(c2port_class, c2dev->id); | ||
969 | |||
970 | kfree(c2dev); | ||
971 | } | ||
972 | EXPORT_SYMBOL(c2port_device_unregister); | ||
973 | |||
974 | /* | ||
975 | * Module stuff | ||
976 | */ | ||
977 | |||
978 | static int __init c2port_init(void) | ||
979 | { | ||
980 | printk(KERN_INFO "Silicon Labs C2 port support v. " DRIVER_VERSION | ||
981 | " - (C) 2007 Rodolfo Giometti\n"); | ||
982 | |||
983 | c2port_class = class_create(THIS_MODULE, "c2port"); | ||
984 | if (!c2port_class) { | ||
985 | printk(KERN_ERR "c2port: failed to allocate class\n"); | ||
986 | return -ENOMEM; | ||
987 | } | ||
988 | c2port_class->dev_attrs = c2port_attrs; | ||
989 | |||
990 | return 0; | ||
991 | } | ||
992 | |||
993 | static void __exit c2port_exit(void) | ||
994 | { | ||
995 | class_destroy(c2port_class); | ||
996 | } | ||
997 | |||
998 | module_init(c2port_init); | ||
999 | module_exit(c2port_exit); | ||
1000 | |||
1001 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | ||
1002 | MODULE_DESCRIPTION("Silicon Labs C2 port support v. " DRIVER_VERSION); | ||
1003 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/misc/compal-laptop.c b/drivers/misc/compal-laptop.c index 344b790a6253..11003bba10d3 100644 --- a/drivers/misc/compal-laptop.c +++ b/drivers/misc/compal-laptop.c | |||
@@ -326,12 +326,14 @@ static int __init compal_init(void) | |||
326 | 326 | ||
327 | /* Register backlight stuff */ | 327 | /* Register backlight stuff */ |
328 | 328 | ||
329 | compalbl_device = backlight_device_register("compal-laptop", NULL, NULL, | 329 | if (!acpi_video_backlight_support()) { |
330 | &compalbl_ops); | 330 | compalbl_device = backlight_device_register("compal-laptop", NULL, NULL, |
331 | if (IS_ERR(compalbl_device)) | 331 | &compalbl_ops); |
332 | return PTR_ERR(compalbl_device); | 332 | if (IS_ERR(compalbl_device)) |
333 | return PTR_ERR(compalbl_device); | ||
333 | 334 | ||
334 | compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1; | 335 | compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1; |
336 | } | ||
335 | 337 | ||
336 | ret = platform_driver_register(&compal_driver); | 338 | ret = platform_driver_register(&compal_driver); |
337 | if (ret) | 339 | if (ret) |
diff --git a/drivers/misc/eeepc-laptop.c b/drivers/misc/eeepc-laptop.c index 9ef98b2d5039..02fe2b8b8939 100644 --- a/drivers/misc/eeepc-laptop.c +++ b/drivers/misc/eeepc-laptop.c | |||
@@ -825,9 +825,15 @@ static int __init eeepc_laptop_init(void) | |||
825 | return -ENODEV; | 825 | return -ENODEV; |
826 | } | 826 | } |
827 | dev = acpi_get_physical_device(ehotk->device->handle); | 827 | dev = acpi_get_physical_device(ehotk->device->handle); |
828 | result = eeepc_backlight_init(dev); | 828 | |
829 | if (result) | 829 | if (!acpi_video_backlight_support()) { |
830 | goto fail_backlight; | 830 | result = eeepc_backlight_init(dev); |
831 | if (result) | ||
832 | goto fail_backlight; | ||
833 | } else | ||
834 | printk(EEEPC_INFO "Backlight controlled by ACPI video " | ||
835 | "driver\n"); | ||
836 | |||
831 | result = eeepc_hwmon_init(dev); | 837 | result = eeepc_hwmon_init(dev); |
832 | if (result) | 838 | if (result) |
833 | goto fail_hwmon; | 839 | goto fail_hwmon; |
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c index d2cf0bfe3163..a7dd3e9fb79d 100644 --- a/drivers/misc/fujitsu-laptop.c +++ b/drivers/misc/fujitsu-laptop.c | |||
@@ -464,6 +464,14 @@ static int dmi_check_cb_s6410(const struct dmi_system_id *id) | |||
464 | return 0; | 464 | return 0; |
465 | } | 465 | } |
466 | 466 | ||
467 | static int dmi_check_cb_s6420(const struct dmi_system_id *id) | ||
468 | { | ||
469 | dmi_check_cb_common(id); | ||
470 | fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */ | ||
471 | fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */ | ||
472 | return 0; | ||
473 | } | ||
474 | |||
467 | static int dmi_check_cb_p8010(const struct dmi_system_id *id) | 475 | static int dmi_check_cb_p8010(const struct dmi_system_id *id) |
468 | { | 476 | { |
469 | dmi_check_cb_common(id); | 477 | dmi_check_cb_common(id); |
@@ -473,7 +481,7 @@ static int dmi_check_cb_p8010(const struct dmi_system_id *id) | |||
473 | return 0; | 481 | return 0; |
474 | } | 482 | } |
475 | 483 | ||
476 | static struct dmi_system_id __initdata fujitsu_dmi_table[] = { | 484 | static struct dmi_system_id fujitsu_dmi_table[] = { |
477 | { | 485 | { |
478 | .ident = "Fujitsu Siemens S6410", | 486 | .ident = "Fujitsu Siemens S6410", |
479 | .matches = { | 487 | .matches = { |
@@ -482,6 +490,13 @@ static struct dmi_system_id __initdata fujitsu_dmi_table[] = { | |||
482 | }, | 490 | }, |
483 | .callback = dmi_check_cb_s6410}, | 491 | .callback = dmi_check_cb_s6410}, |
484 | { | 492 | { |
493 | .ident = "Fujitsu Siemens S6420", | ||
494 | .matches = { | ||
495 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
496 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6420"), | ||
497 | }, | ||
498 | .callback = dmi_check_cb_s6420}, | ||
499 | { | ||
485 | .ident = "Fujitsu LifeBook P8010", | 500 | .ident = "Fujitsu LifeBook P8010", |
486 | .matches = { | 501 | .matches = { |
487 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), | 502 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), |
@@ -990,16 +1005,16 @@ static int __init fujitsu_init(void) | |||
990 | 1005 | ||
991 | /* Register backlight stuff */ | 1006 | /* Register backlight stuff */ |
992 | 1007 | ||
993 | fujitsu->bl_device = | 1008 | if (!acpi_video_backlight_support()) { |
994 | backlight_device_register("fujitsu-laptop", NULL, NULL, | 1009 | fujitsu->bl_device = |
995 | &fujitsubl_ops); | 1010 | backlight_device_register("fujitsu-laptop", NULL, NULL, |
996 | if (IS_ERR(fujitsu->bl_device)) | 1011 | &fujitsubl_ops); |
997 | return PTR_ERR(fujitsu->bl_device); | 1012 | if (IS_ERR(fujitsu->bl_device)) |
998 | 1013 | return PTR_ERR(fujitsu->bl_device); | |
999 | max_brightness = fujitsu->max_brightness; | 1014 | max_brightness = fujitsu->max_brightness; |
1000 | 1015 | fujitsu->bl_device->props.max_brightness = max_brightness - 1; | |
1001 | fujitsu->bl_device->props.max_brightness = max_brightness - 1; | 1016 | fujitsu->bl_device->props.brightness = fujitsu->brightness_level; |
1002 | fujitsu->bl_device->props.brightness = fujitsu->brightness_level; | 1017 | } |
1003 | 1018 | ||
1004 | ret = platform_driver_register(&fujitsupf_driver); | 1019 | ret = platform_driver_register(&fujitsupf_driver); |
1005 | if (ret) | 1020 | if (ret) |
@@ -1035,7 +1050,8 @@ fail_hotkey: | |||
1035 | 1050 | ||
1036 | fail_backlight: | 1051 | fail_backlight: |
1037 | 1052 | ||
1038 | backlight_device_unregister(fujitsu->bl_device); | 1053 | if (fujitsu->bl_device) |
1054 | backlight_device_unregister(fujitsu->bl_device); | ||
1039 | 1055 | ||
1040 | fail_platform_device2: | 1056 | fail_platform_device2: |
1041 | 1057 | ||
@@ -1062,7 +1078,8 @@ static void __exit fujitsu_cleanup(void) | |||
1062 | &fujitsupf_attribute_group); | 1078 | &fujitsupf_attribute_group); |
1063 | platform_device_unregister(fujitsu->pf_device); | 1079 | platform_device_unregister(fujitsu->pf_device); |
1064 | platform_driver_unregister(&fujitsupf_driver); | 1080 | platform_driver_unregister(&fujitsupf_driver); |
1065 | backlight_device_unregister(fujitsu->bl_device); | 1081 | if (fujitsu->bl_device) |
1082 | backlight_device_unregister(fujitsu->bl_device); | ||
1066 | 1083 | ||
1067 | acpi_bus_unregister_driver(&acpi_fujitsu_driver); | 1084 | acpi_bus_unregister_driver(&acpi_fujitsu_driver); |
1068 | 1085 | ||
diff --git a/drivers/misc/ics932s401.c b/drivers/misc/ics932s401.c new file mode 100644 index 000000000000..6e43ab4231ae --- /dev/null +++ b/drivers/misc/ics932s401.c | |||
@@ -0,0 +1,515 @@ | |||
1 | /* | ||
2 | * A driver for the Integrated Circuits ICS932S401 | ||
3 | * Copyright (C) 2008 IBM | ||
4 | * | ||
5 | * Author: Darrick J. Wong <djwong@us.ibm.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/err.h> | ||
26 | #include <linux/mutex.h> | ||
27 | #include <linux/delay.h> | ||
28 | #include <linux/log2.h> | ||
29 | |||
30 | /* Addresses to scan */ | ||
31 | static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END }; | ||
32 | |||
33 | /* Insmod parameters */ | ||
34 | I2C_CLIENT_INSMOD_1(ics932s401); | ||
35 | |||
36 | /* ICS932S401 registers */ | ||
37 | #define ICS932S401_REG_CFG2 0x01 | ||
38 | #define ICS932S401_CFG1_SPREAD 0x01 | ||
39 | #define ICS932S401_REG_CFG7 0x06 | ||
40 | #define ICS932S401_FS_MASK 0x07 | ||
41 | #define ICS932S401_REG_VENDOR_REV 0x07 | ||
42 | #define ICS932S401_VENDOR 1 | ||
43 | #define ICS932S401_VENDOR_MASK 0x0F | ||
44 | #define ICS932S401_REV 4 | ||
45 | #define ICS932S401_REV_SHIFT 4 | ||
46 | #define ICS932S401_REG_DEVICE 0x09 | ||
47 | #define ICS932S401_DEVICE 11 | ||
48 | #define ICS932S401_REG_CTRL 0x0A | ||
49 | #define ICS932S401_MN_ENABLED 0x80 | ||
50 | #define ICS932S401_CPU_ALT 0x04 | ||
51 | #define ICS932S401_SRC_ALT 0x08 | ||
52 | #define ICS932S401_REG_CPU_M_CTRL 0x0B | ||
53 | #define ICS932S401_M_MASK 0x3F | ||
54 | #define ICS932S401_REG_CPU_N_CTRL 0x0C | ||
55 | #define ICS932S401_REG_CPU_SPREAD1 0x0D | ||
56 | #define ICS932S401_REG_CPU_SPREAD2 0x0E | ||
57 | #define ICS932S401_SPREAD_MASK 0x7FFF | ||
58 | #define ICS932S401_REG_SRC_M_CTRL 0x0F | ||
59 | #define ICS932S401_REG_SRC_N_CTRL 0x10 | ||
60 | #define ICS932S401_REG_SRC_SPREAD1 0x11 | ||
61 | #define ICS932S401_REG_SRC_SPREAD2 0x12 | ||
62 | #define ICS932S401_REG_CPU_DIVISOR 0x13 | ||
63 | #define ICS932S401_CPU_DIVISOR_SHIFT 4 | ||
64 | #define ICS932S401_REG_PCISRC_DIVISOR 0x14 | ||
65 | #define ICS932S401_SRC_DIVISOR_MASK 0x0F | ||
66 | #define ICS932S401_PCI_DIVISOR_SHIFT 4 | ||
67 | |||
68 | /* Base clock is 14.318MHz */ | ||
69 | #define BASE_CLOCK 14318 | ||
70 | |||
71 | #define NUM_REGS 21 | ||
72 | #define NUM_MIRRORED_REGS 15 | ||
73 | |||
74 | static int regs_to_copy[NUM_MIRRORED_REGS] = { | ||
75 | ICS932S401_REG_CFG2, | ||
76 | ICS932S401_REG_CFG7, | ||
77 | ICS932S401_REG_VENDOR_REV, | ||
78 | ICS932S401_REG_DEVICE, | ||
79 | ICS932S401_REG_CTRL, | ||
80 | ICS932S401_REG_CPU_M_CTRL, | ||
81 | ICS932S401_REG_CPU_N_CTRL, | ||
82 | ICS932S401_REG_CPU_SPREAD1, | ||
83 | ICS932S401_REG_CPU_SPREAD2, | ||
84 | ICS932S401_REG_SRC_M_CTRL, | ||
85 | ICS932S401_REG_SRC_N_CTRL, | ||
86 | ICS932S401_REG_SRC_SPREAD1, | ||
87 | ICS932S401_REG_SRC_SPREAD2, | ||
88 | ICS932S401_REG_CPU_DIVISOR, | ||
89 | ICS932S401_REG_PCISRC_DIVISOR, | ||
90 | }; | ||
91 | |||
92 | /* How often do we reread sensors values? (In jiffies) */ | ||
93 | #define SENSOR_REFRESH_INTERVAL (2 * HZ) | ||
94 | |||
95 | /* How often do we reread sensor limit values? (In jiffies) */ | ||
96 | #define LIMIT_REFRESH_INTERVAL (60 * HZ) | ||
97 | |||
98 | struct ics932s401_data { | ||
99 | struct attribute_group attrs; | ||
100 | struct mutex lock; | ||
101 | char sensors_valid; | ||
102 | unsigned long sensors_last_updated; /* In jiffies */ | ||
103 | |||
104 | u8 regs[NUM_REGS]; | ||
105 | }; | ||
106 | |||
107 | static int ics932s401_probe(struct i2c_client *client, | ||
108 | const struct i2c_device_id *id); | ||
109 | static int ics932s401_detect(struct i2c_client *client, int kind, | ||
110 | struct i2c_board_info *info); | ||
111 | static int ics932s401_remove(struct i2c_client *client); | ||
112 | |||
113 | static const struct i2c_device_id ics932s401_id[] = { | ||
114 | { "ics932s401", ics932s401 }, | ||
115 | { } | ||
116 | }; | ||
117 | MODULE_DEVICE_TABLE(i2c, ics932s401_id); | ||
118 | |||
119 | static struct i2c_driver ics932s401_driver = { | ||
120 | .class = I2C_CLASS_HWMON, | ||
121 | .driver = { | ||
122 | .name = "ics932s401", | ||
123 | }, | ||
124 | .probe = ics932s401_probe, | ||
125 | .remove = ics932s401_remove, | ||
126 | .id_table = ics932s401_id, | ||
127 | .detect = ics932s401_detect, | ||
128 | .address_data = &addr_data, | ||
129 | }; | ||
130 | |||
131 | static struct ics932s401_data *ics932s401_update_device(struct device *dev) | ||
132 | { | ||
133 | struct i2c_client *client = to_i2c_client(dev); | ||
134 | struct ics932s401_data *data = i2c_get_clientdata(client); | ||
135 | unsigned long local_jiffies = jiffies; | ||
136 | int i, temp; | ||
137 | |||
138 | mutex_lock(&data->lock); | ||
139 | if (time_before(local_jiffies, data->sensors_last_updated + | ||
140 | SENSOR_REFRESH_INTERVAL) | ||
141 | && data->sensors_valid) | ||
142 | goto out; | ||
143 | |||
144 | /* | ||
145 | * Each register must be read as a word and then right shifted 8 bits. | ||
146 | * Not really sure why this is; setting the "byte count programming" | ||
147 | * register to 1 does not fix this problem. | ||
148 | */ | ||
149 | for (i = 0; i < NUM_MIRRORED_REGS; i++) { | ||
150 | temp = i2c_smbus_read_word_data(client, regs_to_copy[i]); | ||
151 | data->regs[regs_to_copy[i]] = temp >> 8; | ||
152 | } | ||
153 | |||
154 | data->sensors_last_updated = local_jiffies; | ||
155 | data->sensors_valid = 1; | ||
156 | |||
157 | out: | ||
158 | mutex_unlock(&data->lock); | ||
159 | return data; | ||
160 | } | ||
161 | |||
162 | static ssize_t show_spread_enabled(struct device *dev, | ||
163 | struct device_attribute *devattr, | ||
164 | char *buf) | ||
165 | { | ||
166 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
167 | |||
168 | if (data->regs[ICS932S401_REG_CFG2] & ICS932S401_CFG1_SPREAD) | ||
169 | return sprintf(buf, "1\n"); | ||
170 | |||
171 | return sprintf(buf, "0\n"); | ||
172 | } | ||
173 | |||
174 | /* bit to cpu khz map */ | ||
175 | static const int fs_speeds[] = { | ||
176 | 266666, | ||
177 | 133333, | ||
178 | 200000, | ||
179 | 166666, | ||
180 | 333333, | ||
181 | 100000, | ||
182 | 400000, | ||
183 | 0, | ||
184 | }; | ||
185 | |||
186 | /* clock divisor map */ | ||
187 | static const int divisors[] = {2, 3, 5, 15, 4, 6, 10, 30, 8, 12, 20, 60, 16, | ||
188 | 24, 40, 120}; | ||
189 | |||
190 | /* Calculate CPU frequency from the M/N registers. */ | ||
191 | static int calculate_cpu_freq(struct ics932s401_data *data) | ||
192 | { | ||
193 | int m, n, freq; | ||
194 | |||
195 | m = data->regs[ICS932S401_REG_CPU_M_CTRL] & ICS932S401_M_MASK; | ||
196 | n = data->regs[ICS932S401_REG_CPU_N_CTRL]; | ||
197 | |||
198 | /* Pull in bits 8 & 9 from the M register */ | ||
199 | n |= ((int)data->regs[ICS932S401_REG_CPU_M_CTRL] & 0x80) << 1; | ||
200 | n |= ((int)data->regs[ICS932S401_REG_CPU_M_CTRL] & 0x40) << 3; | ||
201 | |||
202 | freq = BASE_CLOCK * (n + 8) / (m + 2); | ||
203 | freq /= divisors[data->regs[ICS932S401_REG_CPU_DIVISOR] >> | ||
204 | ICS932S401_CPU_DIVISOR_SHIFT]; | ||
205 | |||
206 | return freq; | ||
207 | } | ||
208 | |||
209 | static ssize_t show_cpu_clock(struct device *dev, | ||
210 | struct device_attribute *devattr, | ||
211 | char *buf) | ||
212 | { | ||
213 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
214 | |||
215 | return sprintf(buf, "%d\n", calculate_cpu_freq(data)); | ||
216 | } | ||
217 | |||
218 | static ssize_t show_cpu_clock_sel(struct device *dev, | ||
219 | struct device_attribute *devattr, | ||
220 | char *buf) | ||
221 | { | ||
222 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
223 | int freq; | ||
224 | |||
225 | if (data->regs[ICS932S401_REG_CTRL] & ICS932S401_MN_ENABLED) | ||
226 | freq = calculate_cpu_freq(data); | ||
227 | else { | ||
228 | /* Freq is neatly wrapped up for us */ | ||
229 | int fid = data->regs[ICS932S401_REG_CFG7] & ICS932S401_FS_MASK; | ||
230 | freq = fs_speeds[fid]; | ||
231 | if (data->regs[ICS932S401_REG_CTRL] & ICS932S401_CPU_ALT) { | ||
232 | switch (freq) { | ||
233 | case 166666: | ||
234 | freq = 160000; | ||
235 | break; | ||
236 | case 333333: | ||
237 | freq = 320000; | ||
238 | break; | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | |||
243 | return sprintf(buf, "%d\n", freq); | ||
244 | } | ||
245 | |||
246 | /* Calculate SRC frequency from the M/N registers. */ | ||
247 | static int calculate_src_freq(struct ics932s401_data *data) | ||
248 | { | ||
249 | int m, n, freq; | ||
250 | |||
251 | m = data->regs[ICS932S401_REG_SRC_M_CTRL] & ICS932S401_M_MASK; | ||
252 | n = data->regs[ICS932S401_REG_SRC_N_CTRL]; | ||
253 | |||
254 | /* Pull in bits 8 & 9 from the M register */ | ||
255 | n |= ((int)data->regs[ICS932S401_REG_SRC_M_CTRL] & 0x80) << 1; | ||
256 | n |= ((int)data->regs[ICS932S401_REG_SRC_M_CTRL] & 0x40) << 3; | ||
257 | |||
258 | freq = BASE_CLOCK * (n + 8) / (m + 2); | ||
259 | freq /= divisors[data->regs[ICS932S401_REG_PCISRC_DIVISOR] & | ||
260 | ICS932S401_SRC_DIVISOR_MASK]; | ||
261 | |||
262 | return freq; | ||
263 | } | ||
264 | |||
265 | static ssize_t show_src_clock(struct device *dev, | ||
266 | struct device_attribute *devattr, | ||
267 | char *buf) | ||
268 | { | ||
269 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
270 | |||
271 | return sprintf(buf, "%d\n", calculate_src_freq(data)); | ||
272 | } | ||
273 | |||
274 | static ssize_t show_src_clock_sel(struct device *dev, | ||
275 | struct device_attribute *devattr, | ||
276 | char *buf) | ||
277 | { | ||
278 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
279 | int freq; | ||
280 | |||
281 | if (data->regs[ICS932S401_REG_CTRL] & ICS932S401_MN_ENABLED) | ||
282 | freq = calculate_src_freq(data); | ||
283 | else | ||
284 | /* Freq is neatly wrapped up for us */ | ||
285 | if (data->regs[ICS932S401_REG_CTRL] & ICS932S401_CPU_ALT && | ||
286 | data->regs[ICS932S401_REG_CTRL] & ICS932S401_SRC_ALT) | ||
287 | freq = 96000; | ||
288 | else | ||
289 | freq = 100000; | ||
290 | |||
291 | return sprintf(buf, "%d\n", freq); | ||
292 | } | ||
293 | |||
294 | /* Calculate PCI frequency from the SRC M/N registers. */ | ||
295 | static int calculate_pci_freq(struct ics932s401_data *data) | ||
296 | { | ||
297 | int m, n, freq; | ||
298 | |||
299 | m = data->regs[ICS932S401_REG_SRC_M_CTRL] & ICS932S401_M_MASK; | ||
300 | n = data->regs[ICS932S401_REG_SRC_N_CTRL]; | ||
301 | |||
302 | /* Pull in bits 8 & 9 from the M register */ | ||
303 | n |= ((int)data->regs[ICS932S401_REG_SRC_M_CTRL] & 0x80) << 1; | ||
304 | n |= ((int)data->regs[ICS932S401_REG_SRC_M_CTRL] & 0x40) << 3; | ||
305 | |||
306 | freq = BASE_CLOCK * (n + 8) / (m + 2); | ||
307 | freq /= divisors[data->regs[ICS932S401_REG_PCISRC_DIVISOR] >> | ||
308 | ICS932S401_PCI_DIVISOR_SHIFT]; | ||
309 | |||
310 | return freq; | ||
311 | } | ||
312 | |||
313 | static ssize_t show_pci_clock(struct device *dev, | ||
314 | struct device_attribute *devattr, | ||
315 | char *buf) | ||
316 | { | ||
317 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
318 | |||
319 | return sprintf(buf, "%d\n", calculate_pci_freq(data)); | ||
320 | } | ||
321 | |||
322 | static ssize_t show_pci_clock_sel(struct device *dev, | ||
323 | struct device_attribute *devattr, | ||
324 | char *buf) | ||
325 | { | ||
326 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
327 | int freq; | ||
328 | |||
329 | if (data->regs[ICS932S401_REG_CTRL] & ICS932S401_MN_ENABLED) | ||
330 | freq = calculate_pci_freq(data); | ||
331 | else | ||
332 | freq = 33333; | ||
333 | |||
334 | return sprintf(buf, "%d\n", freq); | ||
335 | } | ||
336 | |||
337 | static ssize_t show_value(struct device *dev, | ||
338 | struct device_attribute *devattr, | ||
339 | char *buf); | ||
340 | |||
341 | static ssize_t show_spread(struct device *dev, | ||
342 | struct device_attribute *devattr, | ||
343 | char *buf); | ||
344 | |||
345 | static DEVICE_ATTR(spread_enabled, S_IRUGO, show_spread_enabled, NULL); | ||
346 | static DEVICE_ATTR(cpu_clock_selection, S_IRUGO, show_cpu_clock_sel, NULL); | ||
347 | static DEVICE_ATTR(cpu_clock, S_IRUGO, show_cpu_clock, NULL); | ||
348 | static DEVICE_ATTR(src_clock_selection, S_IRUGO, show_src_clock_sel, NULL); | ||
349 | static DEVICE_ATTR(src_clock, S_IRUGO, show_src_clock, NULL); | ||
350 | static DEVICE_ATTR(pci_clock_selection, S_IRUGO, show_pci_clock_sel, NULL); | ||
351 | static DEVICE_ATTR(pci_clock, S_IRUGO, show_pci_clock, NULL); | ||
352 | static DEVICE_ATTR(usb_clock, S_IRUGO, show_value, NULL); | ||
353 | static DEVICE_ATTR(ref_clock, S_IRUGO, show_value, NULL); | ||
354 | static DEVICE_ATTR(cpu_spread, S_IRUGO, show_spread, NULL); | ||
355 | static DEVICE_ATTR(src_spread, S_IRUGO, show_spread, NULL); | ||
356 | |||
357 | static struct attribute *ics932s401_attr[] = | ||
358 | { | ||
359 | &dev_attr_spread_enabled.attr, | ||
360 | &dev_attr_cpu_clock_selection.attr, | ||
361 | &dev_attr_cpu_clock.attr, | ||
362 | &dev_attr_src_clock_selection.attr, | ||
363 | &dev_attr_src_clock.attr, | ||
364 | &dev_attr_pci_clock_selection.attr, | ||
365 | &dev_attr_pci_clock.attr, | ||
366 | &dev_attr_usb_clock.attr, | ||
367 | &dev_attr_ref_clock.attr, | ||
368 | &dev_attr_cpu_spread.attr, | ||
369 | &dev_attr_src_spread.attr, | ||
370 | NULL | ||
371 | }; | ||
372 | |||
373 | static ssize_t show_value(struct device *dev, | ||
374 | struct device_attribute *devattr, | ||
375 | char *buf) | ||
376 | { | ||
377 | int x; | ||
378 | |||
379 | if (devattr == &dev_attr_usb_clock) | ||
380 | x = 48000; | ||
381 | else if (devattr == &dev_attr_ref_clock) | ||
382 | x = BASE_CLOCK; | ||
383 | else | ||
384 | BUG(); | ||
385 | |||
386 | return sprintf(buf, "%d\n", x); | ||
387 | } | ||
388 | |||
389 | static ssize_t show_spread(struct device *dev, | ||
390 | struct device_attribute *devattr, | ||
391 | char *buf) | ||
392 | { | ||
393 | struct ics932s401_data *data = ics932s401_update_device(dev); | ||
394 | int reg; | ||
395 | unsigned long val; | ||
396 | |||
397 | if (!(data->regs[ICS932S401_REG_CFG2] & ICS932S401_CFG1_SPREAD)) | ||
398 | return sprintf(buf, "0%%\n"); | ||
399 | |||
400 | if (devattr == &dev_attr_src_spread) | ||
401 | reg = ICS932S401_REG_SRC_SPREAD1; | ||
402 | else if (devattr == &dev_attr_cpu_spread) | ||
403 | reg = ICS932S401_REG_CPU_SPREAD1; | ||
404 | else | ||
405 | BUG(); | ||
406 | |||
407 | val = data->regs[reg] | (data->regs[reg + 1] << 8); | ||
408 | val &= ICS932S401_SPREAD_MASK; | ||
409 | |||
410 | /* Scale 0..2^14 to -0.5. */ | ||
411 | val = 500000 * val / 16384; | ||
412 | return sprintf(buf, "-0.%lu%%\n", val); | ||
413 | } | ||
414 | |||
415 | /* Return 0 if detection is successful, -ENODEV otherwise */ | ||
416 | static int ics932s401_detect(struct i2c_client *client, int kind, | ||
417 | struct i2c_board_info *info) | ||
418 | { | ||
419 | struct i2c_adapter *adapter = client->adapter; | ||
420 | |||
421 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
422 | return -ENODEV; | ||
423 | |||
424 | if (kind <= 0) { | ||
425 | int vendor, device, revision; | ||
426 | |||
427 | vendor = i2c_smbus_read_word_data(client, | ||
428 | ICS932S401_REG_VENDOR_REV); | ||
429 | vendor >>= 8; | ||
430 | revision = vendor >> ICS932S401_REV_SHIFT; | ||
431 | vendor &= ICS932S401_VENDOR_MASK; | ||
432 | if (vendor != ICS932S401_VENDOR) | ||
433 | return -ENODEV; | ||
434 | |||
435 | device = i2c_smbus_read_word_data(client, | ||
436 | ICS932S401_REG_DEVICE); | ||
437 | device >>= 8; | ||
438 | if (device != ICS932S401_DEVICE) | ||
439 | return -ENODEV; | ||
440 | |||
441 | if (revision != ICS932S401_REV) | ||
442 | dev_info(&adapter->dev, "Unknown revision %d\n", | ||
443 | revision); | ||
444 | } else | ||
445 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
446 | |||
447 | strlcpy(info->type, "ics932s401", I2C_NAME_SIZE); | ||
448 | |||
449 | return 0; | ||
450 | } | ||
451 | |||
452 | static int ics932s401_probe(struct i2c_client *client, | ||
453 | const struct i2c_device_id *id) | ||
454 | { | ||
455 | struct ics932s401_data *data; | ||
456 | int err; | ||
457 | |||
458 | data = kzalloc(sizeof(struct ics932s401_data), GFP_KERNEL); | ||
459 | if (!data) { | ||
460 | err = -ENOMEM; | ||
461 | goto exit; | ||
462 | } | ||
463 | |||
464 | i2c_set_clientdata(client, data); | ||
465 | mutex_init(&data->lock); | ||
466 | |||
467 | dev_info(&client->dev, "%s chip found\n", client->name); | ||
468 | |||
469 | /* Register sysfs hooks */ | ||
470 | data->attrs.attrs = ics932s401_attr; | ||
471 | err = sysfs_create_group(&client->dev.kobj, &data->attrs); | ||
472 | if (err) | ||
473 | goto exit_free; | ||
474 | |||
475 | return 0; | ||
476 | |||
477 | exit_free: | ||
478 | kfree(data); | ||
479 | exit: | ||
480 | return err; | ||
481 | } | ||
482 | |||
483 | static int ics932s401_remove(struct i2c_client *client) | ||
484 | { | ||
485 | struct ics932s401_data *data = i2c_get_clientdata(client); | ||
486 | |||
487 | sysfs_remove_group(&client->dev.kobj, &data->attrs); | ||
488 | kfree(data); | ||
489 | return 0; | ||
490 | } | ||
491 | |||
492 | static int __init ics932s401_init(void) | ||
493 | { | ||
494 | return i2c_add_driver(&ics932s401_driver); | ||
495 | } | ||
496 | |||
497 | static void __exit ics932s401_exit(void) | ||
498 | { | ||
499 | i2c_del_driver(&ics932s401_driver); | ||
500 | } | ||
501 | |||
502 | MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>"); | ||
503 | MODULE_DESCRIPTION("ICS932S401 driver"); | ||
504 | MODULE_LICENSE("GPL"); | ||
505 | |||
506 | module_init(ics932s401_init); | ||
507 | module_exit(ics932s401_exit); | ||
508 | |||
509 | /* IBM IntelliStation Z30 */ | ||
510 | MODULE_ALIAS("dmi:bvnIBM:*:rn9228:*"); | ||
511 | MODULE_ALIAS("dmi:bvnIBM:*:rn9232:*"); | ||
512 | |||
513 | /* IBM x3650/x3550 */ | ||
514 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3650*"); | ||
515 | MODULE_ALIAS("dmi:bvnIBM:*:pnIBMSystemx3550*"); | ||
diff --git a/drivers/misc/intel_menlow.c b/drivers/misc/intel_menlow.c index e00a2756e97e..27b7662955bb 100644 --- a/drivers/misc/intel_menlow.c +++ b/drivers/misc/intel_menlow.c | |||
@@ -52,6 +52,11 @@ MODULE_LICENSE("GPL"); | |||
52 | #define MEMORY_ARG_CUR_BANDWIDTH 1 | 52 | #define MEMORY_ARG_CUR_BANDWIDTH 1 |
53 | #define MEMORY_ARG_MAX_BANDWIDTH 0 | 53 | #define MEMORY_ARG_MAX_BANDWIDTH 0 |
54 | 54 | ||
55 | /* | ||
56 | * GTHS returning 'n' would mean that [0,n-1] states are supported | ||
57 | * In that case max_cstate would be n-1 | ||
58 | * GTHS returning '0' would mean that no bandwidth control states are supported | ||
59 | */ | ||
55 | static int memory_get_int_max_bandwidth(struct thermal_cooling_device *cdev, | 60 | static int memory_get_int_max_bandwidth(struct thermal_cooling_device *cdev, |
56 | unsigned long *max_state) | 61 | unsigned long *max_state) |
57 | { | 62 | { |
@@ -71,6 +76,9 @@ static int memory_get_int_max_bandwidth(struct thermal_cooling_device *cdev, | |||
71 | if (ACPI_FAILURE(status)) | 76 | if (ACPI_FAILURE(status)) |
72 | return -EFAULT; | 77 | return -EFAULT; |
73 | 78 | ||
79 | if (!value) | ||
80 | return -EINVAL; | ||
81 | |||
74 | *max_state = value - 1; | 82 | *max_state = value - 1; |
75 | return 0; | 83 | return 0; |
76 | } | 84 | } |
@@ -121,7 +129,7 @@ static int memory_set_cur_bandwidth(struct thermal_cooling_device *cdev, | |||
121 | if (memory_get_int_max_bandwidth(cdev, &max_state)) | 129 | if (memory_get_int_max_bandwidth(cdev, &max_state)) |
122 | return -EFAULT; | 130 | return -EFAULT; |
123 | 131 | ||
124 | if (max_state < 0 || state > max_state) | 132 | if (state > max_state) |
125 | return -EINVAL; | 133 | return -EINVAL; |
126 | 134 | ||
127 | arg_list.count = 1; | 135 | arg_list.count = 1; |
diff --git a/drivers/misc/msi-laptop.c b/drivers/misc/msi-laptop.c index de898c6938f3..759763d18e4c 100644 --- a/drivers/misc/msi-laptop.c +++ b/drivers/misc/msi-laptop.c | |||
@@ -347,12 +347,16 @@ static int __init msi_init(void) | |||
347 | 347 | ||
348 | /* Register backlight stuff */ | 348 | /* Register backlight stuff */ |
349 | 349 | ||
350 | msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL, | 350 | if (acpi_video_backlight_support()) { |
351 | &msibl_ops); | 351 | printk(KERN_INFO "MSI: Brightness ignored, must be controlled " |
352 | if (IS_ERR(msibl_device)) | 352 | "by ACPI video driver\n"); |
353 | return PTR_ERR(msibl_device); | 353 | } else { |
354 | 354 | msibl_device = backlight_device_register("msi-laptop-bl", NULL, | |
355 | msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1; | 355 | NULL, &msibl_ops); |
356 | if (IS_ERR(msibl_device)) | ||
357 | return PTR_ERR(msibl_device); | ||
358 | msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1; | ||
359 | } | ||
356 | 360 | ||
357 | ret = platform_driver_register(&msipf_driver); | 361 | ret = platform_driver_register(&msipf_driver); |
358 | if (ret) | 362 | if (ret) |
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c index 06f07e19dc70..7bcb81002dcf 100644 --- a/drivers/misc/sony-laptop.c +++ b/drivers/misc/sony-laptop.c | |||
@@ -1038,7 +1038,11 @@ static int sony_nc_add(struct acpi_device *device) | |||
1038 | goto outinput; | 1038 | goto outinput; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", &handle))) { | 1041 | if (!acpi_video_backlight_support()) { |
1042 | printk(KERN_INFO DRV_PFX "Sony: Brightness ignored, must be " | ||
1043 | "controlled by ACPI video driver\n"); | ||
1044 | } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", | ||
1045 | &handle))) { | ||
1042 | sony_backlight_device = backlight_device_register("sony", NULL, | 1046 | sony_backlight_device = backlight_device_register("sony", NULL, |
1043 | NULL, | 1047 | NULL, |
1044 | &sony_backlight_ops); | 1048 | &sony_backlight_ops); |
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 4db1cf9078d9..7a4a26b0edd2 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -4932,16 +4932,25 @@ static int __init brightness_init(struct ibm_init_struct *iibm) | |||
4932 | */ | 4932 | */ |
4933 | b = tpacpi_check_std_acpi_brightness_support(); | 4933 | b = tpacpi_check_std_acpi_brightness_support(); |
4934 | if (b > 0) { | 4934 | if (b > 0) { |
4935 | if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) { | 4935 | |
4936 | printk(TPACPI_NOTICE | 4936 | if (acpi_video_backlight_support()) { |
4937 | "Lenovo BIOS switched to ACPI backlight " | 4937 | if (brightness_enable > 1) { |
4938 | "control mode\n"); | 4938 | printk(TPACPI_NOTICE |
4939 | } | 4939 | "Standard ACPI backlight interface " |
4940 | if (brightness_enable > 1) { | 4940 | "available, not loading native one.\n"); |
4941 | printk(TPACPI_NOTICE | 4941 | return 1; |
4942 | "standard ACPI backlight interface " | 4942 | } else if (brightness_enable == 1) { |
4943 | "available, not loading native one...\n"); | 4943 | printk(TPACPI_NOTICE |
4944 | return 1; | 4944 | "Backlight control force enabled, even if standard " |
4945 | "ACPI backlight interface is available\n"); | ||
4946 | } | ||
4947 | } else { | ||
4948 | if (brightness_enable > 1) { | ||
4949 | printk(TPACPI_NOTICE | ||
4950 | "Standard ACPI backlight interface not " | ||
4951 | "available, thinkpad_acpi native " | ||
4952 | "brightness control enabled\n"); | ||
4953 | } | ||
4945 | } | 4954 | } |
4946 | } | 4955 | } |
4947 | 4956 | ||
diff --git a/drivers/mtd/maps/cdb89712.c b/drivers/mtd/maps/cdb89712.c index e5059aa3c724..8d92d8db9a98 100644 --- a/drivers/mtd/maps/cdb89712.c +++ b/drivers/mtd/maps/cdb89712.c | |||
@@ -14,7 +14,18 @@ | |||
14 | #include <linux/mtd/map.h> | 14 | #include <linux/mtd/map.h> |
15 | #include <linux/mtd/partitions.h> | 15 | #include <linux/mtd/partitions.h> |
16 | 16 | ||
17 | 17 | /* dynamic ioremap() areas */ | |
18 | #define FLASH_START 0x00000000 | ||
19 | #define FLASH_SIZE 0x800000 | ||
20 | #define FLASH_WIDTH 4 | ||
21 | |||
22 | #define SRAM_START 0x60000000 | ||
23 | #define SRAM_SIZE 0xc000 | ||
24 | #define SRAM_WIDTH 4 | ||
25 | |||
26 | #define BOOTROM_START 0x70000000 | ||
27 | #define BOOTROM_SIZE 0x80 | ||
28 | #define BOOTROM_WIDTH 4 | ||
18 | 29 | ||
19 | 30 | ||
20 | static struct mtd_info *flash_mtd; | 31 | static struct mtd_info *flash_mtd; |
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c index 35fef655ccc4..3b959fad1c4e 100644 --- a/drivers/mtd/maps/h720x-flash.c +++ b/drivers/mtd/maps/h720x-flash.c | |||
@@ -24,8 +24,8 @@ static struct mtd_info *mymtd; | |||
24 | static struct map_info h720x_map = { | 24 | static struct map_info h720x_map = { |
25 | .name = "H720X", | 25 | .name = "H720X", |
26 | .bankwidth = 4, | 26 | .bankwidth = 4, |
27 | .size = FLASH_SIZE, | 27 | .size = H720X_FLASH_SIZE, |
28 | .phys = FLASH_PHYS, | 28 | .phys = H720X_FLASH_PHYS, |
29 | }; | 29 | }; |
30 | 30 | ||
31 | static struct mtd_partition h720x_partitions[] = { | 31 | static struct mtd_partition h720x_partitions[] = { |
@@ -70,7 +70,7 @@ int __init h720x_mtd_init(void) | |||
70 | 70 | ||
71 | char *part_type = NULL; | 71 | char *part_type = NULL; |
72 | 72 | ||
73 | h720x_map.virt = ioremap(FLASH_PHYS, FLASH_SIZE); | 73 | h720x_map.virt = ioremap(h720x_map.phys, h720x_map.size); |
74 | 74 | ||
75 | if (!h720x_map.virt) { | 75 | if (!h720x_map.virt) { |
76 | printk(KERN_ERR "H720x-MTD: ioremap failed\n"); | 76 | printk(KERN_ERR "H720x-MTD: ioremap failed\n"); |
diff --git a/drivers/net/atl1e/atl1e_hw.c b/drivers/net/atl1e/atl1e_hw.c index 8cbc1b59bd62..4a7700620119 100644 --- a/drivers/net/atl1e/atl1e_hw.c +++ b/drivers/net/atl1e/atl1e_hw.c | |||
@@ -163,9 +163,6 @@ int atl1e_read_mac_addr(struct atl1e_hw *hw) | |||
163 | * atl1e_hash_mc_addr | 163 | * atl1e_hash_mc_addr |
164 | * purpose | 164 | * purpose |
165 | * set hash value for a multicast address | 165 | * set hash value for a multicast address |
166 | * hash calcu processing : | ||
167 | * 1. calcu 32bit CRC for multicast address | ||
168 | * 2. reverse crc with MSB to LSB | ||
169 | */ | 166 | */ |
170 | u32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr) | 167 | u32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr) |
171 | { | 168 | { |
@@ -174,7 +171,6 @@ u32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr) | |||
174 | int i; | 171 | int i; |
175 | 172 | ||
176 | crc32 = ether_crc_le(6, mc_addr); | 173 | crc32 = ether_crc_le(6, mc_addr); |
177 | crc32 = ~crc32; | ||
178 | for (i = 0; i < 32; i++) | 174 | for (i = 0; i < 32; i++) |
179 | value |= (((crc32 >> i) & 1) << (31 - i)); | 175 | value |= (((crc32 >> i) & 1) << (31 - i)); |
180 | 176 | ||
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c index 246d92b42636..aef403d299ee 100644 --- a/drivers/net/atlx/atl1.c +++ b/drivers/net/atlx/atl1.c | |||
@@ -3404,14 +3404,8 @@ static void atl1_get_wol(struct net_device *netdev, | |||
3404 | { | 3404 | { |
3405 | struct atl1_adapter *adapter = netdev_priv(netdev); | 3405 | struct atl1_adapter *adapter = netdev_priv(netdev); |
3406 | 3406 | ||
3407 | wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC; | 3407 | wol->supported = WAKE_MAGIC; |
3408 | wol->wolopts = 0; | 3408 | wol->wolopts = 0; |
3409 | if (adapter->wol & ATLX_WUFC_EX) | ||
3410 | wol->wolopts |= WAKE_UCAST; | ||
3411 | if (adapter->wol & ATLX_WUFC_MC) | ||
3412 | wol->wolopts |= WAKE_MCAST; | ||
3413 | if (adapter->wol & ATLX_WUFC_BC) | ||
3414 | wol->wolopts |= WAKE_BCAST; | ||
3415 | if (adapter->wol & ATLX_WUFC_MAG) | 3409 | if (adapter->wol & ATLX_WUFC_MAG) |
3416 | wol->wolopts |= WAKE_MAGIC; | 3410 | wol->wolopts |= WAKE_MAGIC; |
3417 | return; | 3411 | return; |
@@ -3422,15 +3416,10 @@ static int atl1_set_wol(struct net_device *netdev, | |||
3422 | { | 3416 | { |
3423 | struct atl1_adapter *adapter = netdev_priv(netdev); | 3417 | struct atl1_adapter *adapter = netdev_priv(netdev); |
3424 | 3418 | ||
3425 | if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) | 3419 | if (wol->wolopts & (WAKE_PHY | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | |
3420 | WAKE_ARP | WAKE_MAGICSECURE)) | ||
3426 | return -EOPNOTSUPP; | 3421 | return -EOPNOTSUPP; |
3427 | adapter->wol = 0; | 3422 | adapter->wol = 0; |
3428 | if (wol->wolopts & WAKE_UCAST) | ||
3429 | adapter->wol |= ATLX_WUFC_EX; | ||
3430 | if (wol->wolopts & WAKE_MCAST) | ||
3431 | adapter->wol |= ATLX_WUFC_MC; | ||
3432 | if (wol->wolopts & WAKE_BCAST) | ||
3433 | adapter->wol |= ATLX_WUFC_BC; | ||
3434 | if (wol->wolopts & WAKE_MAGIC) | 3423 | if (wol->wolopts & WAKE_MAGIC) |
3435 | adapter->wol |= ATLX_WUFC_MAG; | 3424 | adapter->wol |= ATLX_WUFC_MAG; |
3436 | return 0; | 3425 | return 0; |
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 430d430bce29..d07e3f148951 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -7204,10 +7204,13 @@ static void | |||
7204 | poll_bnx2(struct net_device *dev) | 7204 | poll_bnx2(struct net_device *dev) |
7205 | { | 7205 | { |
7206 | struct bnx2 *bp = netdev_priv(dev); | 7206 | struct bnx2 *bp = netdev_priv(dev); |
7207 | int i; | ||
7207 | 7208 | ||
7208 | disable_irq(bp->pdev->irq); | 7209 | for (i = 0; i < bp->irq_nvecs; i++) { |
7209 | bnx2_interrupt(bp->pdev->irq, dev); | 7210 | disable_irq(bp->irq_tbl[i].vector); |
7210 | enable_irq(bp->pdev->irq); | 7211 | bnx2_interrupt(bp->irq_tbl[i].vector, &bp->bnx2_napi[i]); |
7212 | enable_irq(bp->irq_tbl[i].vector); | ||
7213 | } | ||
7211 | } | 7214 | } |
7212 | #endif | 7215 | #endif |
7213 | 7216 | ||
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index 1ace41a13ac3..2c341f83d327 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -1307,8 +1307,10 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
1307 | u32 fw_vers = 0; | 1307 | u32 fw_vers = 0; |
1308 | u32 tp_vers = 0; | 1308 | u32 tp_vers = 0; |
1309 | 1309 | ||
1310 | spin_lock(&adapter->stats_lock); | ||
1310 | t3_get_fw_version(adapter, &fw_vers); | 1311 | t3_get_fw_version(adapter, &fw_vers); |
1311 | t3_get_tp_version(adapter, &tp_vers); | 1312 | t3_get_tp_version(adapter, &tp_vers); |
1313 | spin_unlock(&adapter->stats_lock); | ||
1312 | 1314 | ||
1313 | strcpy(info->driver, DRV_NAME); | 1315 | strcpy(info->driver, DRV_NAME); |
1314 | strcpy(info->version, DRV_VERSION); | 1316 | strcpy(info->version, DRV_VERSION); |
@@ -2699,7 +2701,7 @@ static void set_nqsets(struct adapter *adap) | |||
2699 | int hwports = adap->params.nports; | 2701 | int hwports = adap->params.nports; |
2700 | int nqsets = SGE_QSETS; | 2702 | int nqsets = SGE_QSETS; |
2701 | 2703 | ||
2702 | if (adap->params.rev > 0) { | 2704 | if (adap->params.rev > 0 && adap->flags & USING_MSIX) { |
2703 | if (hwports == 2 && | 2705 | if (hwports == 2 && |
2704 | (hwports * nqsets > SGE_QSETS || | 2706 | (hwports * nqsets > SGE_QSETS || |
2705 | num_cpus >= nqsets / hwports)) | 2707 | num_cpus >= nqsets / hwports)) |
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c index 968f64be3743..9a0898b0dbce 100644 --- a/drivers/net/cxgb3/t3_hw.c +++ b/drivers/net/cxgb3/t3_hw.c | |||
@@ -572,7 +572,7 @@ struct t3_vpd { | |||
572 | u32 pad; /* for multiple-of-4 sizing and alignment */ | 572 | u32 pad; /* for multiple-of-4 sizing and alignment */ |
573 | }; | 573 | }; |
574 | 574 | ||
575 | #define EEPROM_MAX_POLL 4 | 575 | #define EEPROM_MAX_POLL 40 |
576 | #define EEPROM_STAT_ADDR 0x4000 | 576 | #define EEPROM_STAT_ADDR 0x4000 |
577 | #define VPD_BASE 0xc00 | 577 | #define VPD_BASE 0xc00 |
578 | 578 | ||
@@ -3690,6 +3690,12 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, | |||
3690 | ; | 3690 | ; |
3691 | 3691 | ||
3692 | pti = &port_types[adapter->params.vpd.port_type[j]]; | 3692 | pti = &port_types[adapter->params.vpd.port_type[j]]; |
3693 | if (!pti->phy_prep) { | ||
3694 | CH_ALERT(adapter, "Invalid port type index %d\n", | ||
3695 | adapter->params.vpd.port_type[j]); | ||
3696 | return -EINVAL; | ||
3697 | } | ||
3698 | |||
3693 | ret = pti->phy_prep(&p->phy, adapter, ai->phy_base_addr + j, | 3699 | ret = pti->phy_prep(&p->phy, adapter, ai->phy_base_addr + j, |
3694 | ai->mdio_ops); | 3700 | ai->mdio_ops); |
3695 | if (ret) | 3701 | if (ret) |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 3d69fae781cf..e8bfcce6b319 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -166,7 +166,7 @@ | |||
166 | 166 | ||
167 | #define DRV_NAME "e100" | 167 | #define DRV_NAME "e100" |
168 | #define DRV_EXT "-NAPI" | 168 | #define DRV_EXT "-NAPI" |
169 | #define DRV_VERSION "3.5.23-k4"DRV_EXT | 169 | #define DRV_VERSION "3.5.23-k6"DRV_EXT |
170 | #define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" | 170 | #define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" |
171 | #define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation" | 171 | #define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation" |
172 | #define PFX DRV_NAME ": " | 172 | #define PFX DRV_NAME ": " |
@@ -1804,7 +1804,7 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) | |||
1804 | struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; | 1804 | struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; |
1805 | put_unaligned_le32(rx->dma_addr, &prev_rfd->link); | 1805 | put_unaligned_le32(rx->dma_addr, &prev_rfd->link); |
1806 | pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, | 1806 | pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, |
1807 | sizeof(struct rfd), PCI_DMA_TODEVICE); | 1807 | sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); |
1808 | } | 1808 | } |
1809 | 1809 | ||
1810 | return 0; | 1810 | return 0; |
@@ -1823,7 +1823,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, | |||
1823 | 1823 | ||
1824 | /* Need to sync before taking a peek at cb_complete bit */ | 1824 | /* Need to sync before taking a peek at cb_complete bit */ |
1825 | pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr, | 1825 | pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr, |
1826 | sizeof(struct rfd), PCI_DMA_FROMDEVICE); | 1826 | sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); |
1827 | rfd_status = le16_to_cpu(rfd->status); | 1827 | rfd_status = le16_to_cpu(rfd->status); |
1828 | 1828 | ||
1829 | DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status); | 1829 | DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status); |
@@ -1850,7 +1850,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, | |||
1850 | 1850 | ||
1851 | /* Get data */ | 1851 | /* Get data */ |
1852 | pci_unmap_single(nic->pdev, rx->dma_addr, | 1852 | pci_unmap_single(nic->pdev, rx->dma_addr, |
1853 | RFD_BUF_LEN, PCI_DMA_FROMDEVICE); | 1853 | RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); |
1854 | 1854 | ||
1855 | /* If this buffer has the el bit, but we think the receiver | 1855 | /* If this buffer has the el bit, but we think the receiver |
1856 | * is still running, check to see if it really stopped while | 1856 | * is still running, check to see if it really stopped while |
@@ -1943,7 +1943,7 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done, | |||
1943 | new_before_last_rfd->command |= cpu_to_le16(cb_el); | 1943 | new_before_last_rfd->command |= cpu_to_le16(cb_el); |
1944 | pci_dma_sync_single_for_device(nic->pdev, | 1944 | pci_dma_sync_single_for_device(nic->pdev, |
1945 | new_before_last_rx->dma_addr, sizeof(struct rfd), | 1945 | new_before_last_rx->dma_addr, sizeof(struct rfd), |
1946 | PCI_DMA_TODEVICE); | 1946 | PCI_DMA_BIDIRECTIONAL); |
1947 | 1947 | ||
1948 | /* Now that we have a new stopping point, we can clear the old | 1948 | /* Now that we have a new stopping point, we can clear the old |
1949 | * stopping point. We must sync twice to get the proper | 1949 | * stopping point. We must sync twice to get the proper |
@@ -1951,11 +1951,11 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done, | |||
1951 | old_before_last_rfd->command &= ~cpu_to_le16(cb_el); | 1951 | old_before_last_rfd->command &= ~cpu_to_le16(cb_el); |
1952 | pci_dma_sync_single_for_device(nic->pdev, | 1952 | pci_dma_sync_single_for_device(nic->pdev, |
1953 | old_before_last_rx->dma_addr, sizeof(struct rfd), | 1953 | old_before_last_rx->dma_addr, sizeof(struct rfd), |
1954 | PCI_DMA_TODEVICE); | 1954 | PCI_DMA_BIDIRECTIONAL); |
1955 | old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN); | 1955 | old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN); |
1956 | pci_dma_sync_single_for_device(nic->pdev, | 1956 | pci_dma_sync_single_for_device(nic->pdev, |
1957 | old_before_last_rx->dma_addr, sizeof(struct rfd), | 1957 | old_before_last_rx->dma_addr, sizeof(struct rfd), |
1958 | PCI_DMA_TODEVICE); | 1958 | PCI_DMA_BIDIRECTIONAL); |
1959 | } | 1959 | } |
1960 | 1960 | ||
1961 | if(restart_required) { | 1961 | if(restart_required) { |
@@ -1978,7 +1978,7 @@ static void e100_rx_clean_list(struct nic *nic) | |||
1978 | for(rx = nic->rxs, i = 0; i < count; rx++, i++) { | 1978 | for(rx = nic->rxs, i = 0; i < count; rx++, i++) { |
1979 | if(rx->skb) { | 1979 | if(rx->skb) { |
1980 | pci_unmap_single(nic->pdev, rx->dma_addr, | 1980 | pci_unmap_single(nic->pdev, rx->dma_addr, |
1981 | RFD_BUF_LEN, PCI_DMA_FROMDEVICE); | 1981 | RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); |
1982 | dev_kfree_skb(rx->skb); | 1982 | dev_kfree_skb(rx->skb); |
1983 | } | 1983 | } |
1984 | } | 1984 | } |
@@ -2021,7 +2021,7 @@ static int e100_rx_alloc_list(struct nic *nic) | |||
2021 | before_last->command |= cpu_to_le16(cb_el); | 2021 | before_last->command |= cpu_to_le16(cb_el); |
2022 | before_last->size = 0; | 2022 | before_last->size = 0; |
2023 | pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr, | 2023 | pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr, |
2024 | sizeof(struct rfd), PCI_DMA_TODEVICE); | 2024 | sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); |
2025 | 2025 | ||
2026 | nic->rx_to_use = nic->rx_to_clean = nic->rxs; | 2026 | nic->rx_to_use = nic->rx_to_clean = nic->rxs; |
2027 | nic->ru_running = RU_SUSPENDED; | 2027 | nic->ru_running = RU_SUSPENDED; |
@@ -2222,7 +2222,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) | |||
2222 | msleep(10); | 2222 | msleep(10); |
2223 | 2223 | ||
2224 | pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, | 2224 | pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, |
2225 | RFD_BUF_LEN, PCI_DMA_FROMDEVICE); | 2225 | RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); |
2226 | 2226 | ||
2227 | if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), | 2227 | if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), |
2228 | skb->data, ETH_DATA_LEN)) | 2228 | skb->data, ETH_DATA_LEN)) |
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index 6a3893acfe04..c854c96f5ab3 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c | |||
@@ -1774,7 +1774,8 @@ static void e1000_get_wol(struct net_device *netdev, | |||
1774 | 1774 | ||
1775 | /* this function will set ->supported = 0 and return 1 if wol is not | 1775 | /* this function will set ->supported = 0 and return 1 if wol is not |
1776 | * supported by this hardware */ | 1776 | * supported by this hardware */ |
1777 | if (e1000_wol_exclusion(adapter, wol)) | 1777 | if (e1000_wol_exclusion(adapter, wol) || |
1778 | !device_can_wakeup(&adapter->pdev->dev)) | ||
1778 | return; | 1779 | return; |
1779 | 1780 | ||
1780 | /* apply any specific unsupported masks here */ | 1781 | /* apply any specific unsupported masks here */ |
@@ -1811,7 +1812,8 @@ static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
1811 | if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) | 1812 | if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) |
1812 | return -EOPNOTSUPP; | 1813 | return -EOPNOTSUPP; |
1813 | 1814 | ||
1814 | if (e1000_wol_exclusion(adapter, wol)) | 1815 | if (e1000_wol_exclusion(adapter, wol) || |
1816 | !device_can_wakeup(&adapter->pdev->dev)) | ||
1815 | return wol->wolopts ? -EOPNOTSUPP : 0; | 1817 | return wol->wolopts ? -EOPNOTSUPP : 0; |
1816 | 1818 | ||
1817 | switch (hw->device_id) { | 1819 | switch (hw->device_id) { |
@@ -1838,6 +1840,8 @@ static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
1838 | if (wol->wolopts & WAKE_MAGIC) | 1840 | if (wol->wolopts & WAKE_MAGIC) |
1839 | adapter->wol |= E1000_WUFC_MAG; | 1841 | adapter->wol |= E1000_WUFC_MAG; |
1840 | 1842 | ||
1843 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); | ||
1844 | |||
1841 | return 0; | 1845 | return 0; |
1842 | } | 1846 | } |
1843 | 1847 | ||
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index fac82152e4c8..872799b746f5 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -1179,6 +1179,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
1179 | 1179 | ||
1180 | /* initialize the wol settings based on the eeprom settings */ | 1180 | /* initialize the wol settings based on the eeprom settings */ |
1181 | adapter->wol = adapter->eeprom_wol; | 1181 | adapter->wol = adapter->eeprom_wol; |
1182 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); | ||
1182 | 1183 | ||
1183 | /* print bus type/speed/width info */ | 1184 | /* print bus type/speed/width info */ |
1184 | DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ", | 1185 | DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ", |
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index c55de1c027af..c55fd6fdb91c 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h | |||
@@ -299,6 +299,7 @@ struct e1000_adapter { | |||
299 | unsigned long led_status; | 299 | unsigned long led_status; |
300 | 300 | ||
301 | unsigned int flags; | 301 | unsigned int flags; |
302 | unsigned int flags2; | ||
302 | struct work_struct downshift_task; | 303 | struct work_struct downshift_task; |
303 | struct work_struct update_phy_task; | 304 | struct work_struct update_phy_task; |
304 | }; | 305 | }; |
@@ -306,6 +307,7 @@ struct e1000_adapter { | |||
306 | struct e1000_info { | 307 | struct e1000_info { |
307 | enum e1000_mac_type mac; | 308 | enum e1000_mac_type mac; |
308 | unsigned int flags; | 309 | unsigned int flags; |
310 | unsigned int flags2; | ||
309 | u32 pba; | 311 | u32 pba; |
310 | s32 (*get_variants)(struct e1000_adapter *); | 312 | s32 (*get_variants)(struct e1000_adapter *); |
311 | struct e1000_mac_operations *mac_ops; | 313 | struct e1000_mac_operations *mac_ops; |
@@ -347,6 +349,9 @@ struct e1000_info { | |||
347 | #define FLAG_RX_RESTART_NOW (1 << 30) | 349 | #define FLAG_RX_RESTART_NOW (1 << 30) |
348 | #define FLAG_MSI_TEST_FAILED (1 << 31) | 350 | #define FLAG_MSI_TEST_FAILED (1 << 31) |
349 | 351 | ||
352 | /* CRC Stripping defines */ | ||
353 | #define FLAG2_CRC_STRIPPING (1 << 0) | ||
354 | |||
350 | #define E1000_RX_DESC_PS(R, i) \ | 355 | #define E1000_RX_DESC_PS(R, i) \ |
351 | (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) | 356 | (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) |
352 | #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) | 357 | #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) |
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 70c11c811a08..62421ce96311 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c | |||
@@ -1713,7 +1713,8 @@ static void e1000_get_wol(struct net_device *netdev, | |||
1713 | wol->supported = 0; | 1713 | wol->supported = 0; |
1714 | wol->wolopts = 0; | 1714 | wol->wolopts = 0; |
1715 | 1715 | ||
1716 | if (!(adapter->flags & FLAG_HAS_WOL)) | 1716 | if (!(adapter->flags & FLAG_HAS_WOL) || |
1717 | !device_can_wakeup(&adapter->pdev->dev)) | ||
1717 | return; | 1718 | return; |
1718 | 1719 | ||
1719 | wol->supported = WAKE_UCAST | WAKE_MCAST | | 1720 | wol->supported = WAKE_UCAST | WAKE_MCAST | |
@@ -1751,7 +1752,8 @@ static int e1000_set_wol(struct net_device *netdev, | |||
1751 | if (wol->wolopts & WAKE_MAGICSECURE) | 1752 | if (wol->wolopts & WAKE_MAGICSECURE) |
1752 | return -EOPNOTSUPP; | 1753 | return -EOPNOTSUPP; |
1753 | 1754 | ||
1754 | if (!(adapter->flags & FLAG_HAS_WOL)) | 1755 | if (!(adapter->flags & FLAG_HAS_WOL) || |
1756 | !device_can_wakeup(&adapter->pdev->dev)) | ||
1755 | return wol->wolopts ? -EOPNOTSUPP : 0; | 1757 | return wol->wolopts ? -EOPNOTSUPP : 0; |
1756 | 1758 | ||
1757 | /* these settings will always override what we currently have */ | 1759 | /* these settings will always override what we currently have */ |
@@ -1770,6 +1772,8 @@ static int e1000_set_wol(struct net_device *netdev, | |||
1770 | if (wol->wolopts & WAKE_ARP) | 1772 | if (wol->wolopts & WAKE_ARP) |
1771 | adapter->wol |= E1000_WUFC_ARP; | 1773 | adapter->wol |= E1000_WUFC_ARP; |
1772 | 1774 | ||
1775 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); | ||
1776 | |||
1773 | return 0; | 1777 | return 0; |
1774 | } | 1778 | } |
1775 | 1779 | ||
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index abd492b7336d..91795f78c3e4 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -499,6 +499,10 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
499 | goto next_desc; | 499 | goto next_desc; |
500 | } | 500 | } |
501 | 501 | ||
502 | /* adjust length to remove Ethernet CRC */ | ||
503 | if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) | ||
504 | length -= 4; | ||
505 | |||
502 | total_rx_bytes += length; | 506 | total_rx_bytes += length; |
503 | total_rx_packets++; | 507 | total_rx_packets++; |
504 | 508 | ||
@@ -804,6 +808,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
804 | pci_dma_sync_single_for_device(pdev, ps_page->dma, | 808 | pci_dma_sync_single_for_device(pdev, ps_page->dma, |
805 | PAGE_SIZE, PCI_DMA_FROMDEVICE); | 809 | PAGE_SIZE, PCI_DMA_FROMDEVICE); |
806 | 810 | ||
811 | /* remove the CRC */ | ||
812 | if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) | ||
813 | l1 -= 4; | ||
814 | |||
807 | skb_put(skb, l1); | 815 | skb_put(skb, l1); |
808 | goto copydone; | 816 | goto copydone; |
809 | } /* if */ | 817 | } /* if */ |
@@ -825,6 +833,12 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
825 | skb->truesize += length; | 833 | skb->truesize += length; |
826 | } | 834 | } |
827 | 835 | ||
836 | /* strip the ethernet crc, problem is we're using pages now so | ||
837 | * this whole operation can get a little cpu intensive | ||
838 | */ | ||
839 | if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) | ||
840 | pskb_trim(skb, skb->len - 4); | ||
841 | |||
828 | copydone: | 842 | copydone: |
829 | total_rx_bytes += skb->len; | 843 | total_rx_bytes += skb->len; |
830 | total_rx_packets++; | 844 | total_rx_packets++; |
@@ -2301,8 +2315,12 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) | |||
2301 | else | 2315 | else |
2302 | rctl |= E1000_RCTL_LPE; | 2316 | rctl |= E1000_RCTL_LPE; |
2303 | 2317 | ||
2304 | /* Enable hardware CRC frame stripping */ | 2318 | /* Some systems expect that the CRC is included in SMBUS traffic. The |
2305 | rctl |= E1000_RCTL_SECRC; | 2319 | * hardware strips the CRC before sending to both SMBUS (BMC) and to |
2320 | * host memory when this is enabled | ||
2321 | */ | ||
2322 | if (adapter->flags2 & FLAG2_CRC_STRIPPING) | ||
2323 | rctl |= E1000_RCTL_SECRC; | ||
2306 | 2324 | ||
2307 | /* Setup buffer sizes */ | 2325 | /* Setup buffer sizes */ |
2308 | rctl &= ~E1000_RCTL_SZ_4096; | 2326 | rctl &= ~E1000_RCTL_SZ_4096; |
@@ -4766,6 +4784,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
4766 | adapter->ei = ei; | 4784 | adapter->ei = ei; |
4767 | adapter->pba = ei->pba; | 4785 | adapter->pba = ei->pba; |
4768 | adapter->flags = ei->flags; | 4786 | adapter->flags = ei->flags; |
4787 | adapter->flags2 = ei->flags2; | ||
4769 | adapter->hw.adapter = adapter; | 4788 | adapter->hw.adapter = adapter; |
4770 | adapter->hw.mac.type = ei->mac; | 4789 | adapter->hw.mac.type = ei->mac; |
4771 | adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; | 4790 | adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; |
@@ -4970,6 +4989,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
4970 | 4989 | ||
4971 | /* initialize the wol settings based on the eeprom settings */ | 4990 | /* initialize the wol settings based on the eeprom settings */ |
4972 | adapter->wol = adapter->eeprom_wol; | 4991 | adapter->wol = adapter->eeprom_wol; |
4992 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); | ||
4973 | 4993 | ||
4974 | /* reset the hardware with the new settings */ | 4994 | /* reset the hardware with the new settings */ |
4975 | e1000e_reset(adapter); | 4995 | e1000e_reset(adapter); |
@@ -5008,6 +5028,7 @@ err_hw_init: | |||
5008 | err_sw_init: | 5028 | err_sw_init: |
5009 | if (adapter->hw.flash_address) | 5029 | if (adapter->hw.flash_address) |
5010 | iounmap(adapter->hw.flash_address); | 5030 | iounmap(adapter->hw.flash_address); |
5031 | e1000e_reset_interrupt_capability(adapter); | ||
5011 | err_flashmap: | 5032 | err_flashmap: |
5012 | iounmap(adapter->hw.hw_addr); | 5033 | iounmap(adapter->hw.hw_addr); |
5013 | err_ioremap: | 5034 | err_ioremap: |
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c index 77a3d7207a5f..e909f96698e8 100644 --- a/drivers/net/e1000e/param.c +++ b/drivers/net/e1000e/param.c | |||
@@ -151,6 +151,16 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); | |||
151 | */ | 151 | */ |
152 | E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); | 152 | E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); |
153 | 153 | ||
154 | /* | ||
155 | * Enable CRC Stripping | ||
156 | * | ||
157 | * Valid Range: 0, 1 | ||
158 | * | ||
159 | * Default Value: 1 (enabled) | ||
160 | */ | ||
161 | E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \ | ||
162 | "the CRC"); | ||
163 | |||
154 | struct e1000_option { | 164 | struct e1000_option { |
155 | enum { enable_option, range_option, list_option } type; | 165 | enum { enable_option, range_option, list_option } type; |
156 | const char *name; | 166 | const char *name; |
@@ -404,6 +414,21 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |||
404 | adapter->flags |= FLAG_SMART_POWER_DOWN; | 414 | adapter->flags |= FLAG_SMART_POWER_DOWN; |
405 | } | 415 | } |
406 | } | 416 | } |
417 | { /* CRC Stripping */ | ||
418 | const struct e1000_option opt = { | ||
419 | .type = enable_option, | ||
420 | .name = "CRC Stripping", | ||
421 | .err = "defaulting to enabled", | ||
422 | .def = OPTION_ENABLED | ||
423 | }; | ||
424 | |||
425 | if (num_CrcStripping > bd) { | ||
426 | unsigned int crc_stripping = CrcStripping[bd]; | ||
427 | e1000_validate_option(&crc_stripping, &opt, adapter); | ||
428 | if (crc_stripping == OPTION_ENABLED) | ||
429 | adapter->flags2 |= FLAG2_CRC_STRIPPING; | ||
430 | } | ||
431 | } | ||
407 | { /* Kumeran Lock Loss Workaround */ | 432 | { /* Kumeran Lock Loss Workaround */ |
408 | const struct e1000_option opt = { | 433 | const struct e1000_option opt = { |
409 | .type = enable_option, | 434 | .type = enable_option, |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 83a5cb6aa23b..c4af949bf860 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -1407,6 +1407,10 @@ static int gfar_clean_tx_ring(struct net_device *dev) | |||
1407 | if (bdp->status & TXBD_DEF) | 1407 | if (bdp->status & TXBD_DEF) |
1408 | dev->stats.collisions++; | 1408 | dev->stats.collisions++; |
1409 | 1409 | ||
1410 | /* Unmap the DMA memory */ | ||
1411 | dma_unmap_single(&priv->dev->dev, bdp->bufPtr, | ||
1412 | bdp->length, DMA_TO_DEVICE); | ||
1413 | |||
1410 | /* Free the sk buffer associated with this TxBD */ | 1414 | /* Free the sk buffer associated with this TxBD */ |
1411 | dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]); | 1415 | dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]); |
1412 | 1416 | ||
@@ -1666,6 +1670,9 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit) | |||
1666 | 1670 | ||
1667 | skb = priv->rx_skbuff[priv->skb_currx]; | 1671 | skb = priv->rx_skbuff[priv->skb_currx]; |
1668 | 1672 | ||
1673 | dma_unmap_single(&priv->dev->dev, bdp->bufPtr, | ||
1674 | priv->rx_buffer_size, DMA_FROM_DEVICE); | ||
1675 | |||
1669 | /* We drop the frame if we failed to allocate a new buffer */ | 1676 | /* We drop the frame if we failed to allocate a new buffer */ |
1670 | if (unlikely(!newskb || !(bdp->status & RXBD_LAST) || | 1677 | if (unlikely(!newskb || !(bdp->status & RXBD_LAST) || |
1671 | bdp->status & RXBD_ERR)) { | 1678 | bdp->status & RXBD_ERR)) { |
@@ -1674,14 +1681,8 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit) | |||
1674 | if (unlikely(!newskb)) | 1681 | if (unlikely(!newskb)) |
1675 | newskb = skb; | 1682 | newskb = skb; |
1676 | 1683 | ||
1677 | if (skb) { | 1684 | if (skb) |
1678 | dma_unmap_single(&priv->dev->dev, | ||
1679 | bdp->bufPtr, | ||
1680 | priv->rx_buffer_size, | ||
1681 | DMA_FROM_DEVICE); | ||
1682 | |||
1683 | dev_kfree_skb_any(skb); | 1685 | dev_kfree_skb_any(skb); |
1684 | } | ||
1685 | } else { | 1686 | } else { |
1686 | /* Increment the number of packets */ | 1687 | /* Increment the number of packets */ |
1687 | dev->stats.rx_packets++; | 1688 | dev->stats.rx_packets++; |
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index 58906c984be9..89964fa739a0 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -1776,7 +1776,8 @@ static void igb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
1776 | 1776 | ||
1777 | /* this function will set ->supported = 0 and return 1 if wol is not | 1777 | /* this function will set ->supported = 0 and return 1 if wol is not |
1778 | * supported by this hardware */ | 1778 | * supported by this hardware */ |
1779 | if (igb_wol_exclusion(adapter, wol)) | 1779 | if (igb_wol_exclusion(adapter, wol) || |
1780 | !device_can_wakeup(&adapter->pdev->dev)) | ||
1780 | return; | 1781 | return; |
1781 | 1782 | ||
1782 | /* apply any specific unsupported masks here */ | 1783 | /* apply any specific unsupported masks here */ |
@@ -1805,7 +1806,8 @@ static int igb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
1805 | if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) | 1806 | if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) |
1806 | return -EOPNOTSUPP; | 1807 | return -EOPNOTSUPP; |
1807 | 1808 | ||
1808 | if (igb_wol_exclusion(adapter, wol)) | 1809 | if (igb_wol_exclusion(adapter, wol) || |
1810 | !device_can_wakeup(&adapter->pdev->dev)) | ||
1809 | return wol->wolopts ? -EOPNOTSUPP : 0; | 1811 | return wol->wolopts ? -EOPNOTSUPP : 0; |
1810 | 1812 | ||
1811 | switch (hw->device_id) { | 1813 | switch (hw->device_id) { |
@@ -1825,6 +1827,8 @@ static int igb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
1825 | if (wol->wolopts & WAKE_MAGIC) | 1827 | if (wol->wolopts & WAKE_MAGIC) |
1826 | adapter->wol |= E1000_WUFC_MAG; | 1828 | adapter->wol |= E1000_WUFC_MAG; |
1827 | 1829 | ||
1830 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); | ||
1831 | |||
1828 | return 0; | 1832 | return 0; |
1829 | } | 1833 | } |
1830 | 1834 | ||
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 1f397cd99414..1cbae85b1426 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -1019,10 +1019,9 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1019 | state &= ~PCIE_LINK_STATE_L0S; | 1019 | state &= ~PCIE_LINK_STATE_L0S; |
1020 | pci_write_config_word(us_dev, pos + PCI_EXP_LNKCTL, | 1020 | pci_write_config_word(us_dev, pos + PCI_EXP_LNKCTL, |
1021 | state); | 1021 | state); |
1022 | printk(KERN_INFO "Disabling ASPM L0s upstream switch " | 1022 | dev_info(&pdev->dev, |
1023 | "port %x:%x.%x\n", us_dev->bus->number, | 1023 | "Disabling ASPM L0s upstream switch port %s\n", |
1024 | PCI_SLOT(us_dev->devfn), | 1024 | pci_name(us_dev)); |
1025 | PCI_FUNC(us_dev->devfn)); | ||
1026 | } | 1025 | } |
1027 | default: | 1026 | default: |
1028 | break; | 1027 | break; |
@@ -1244,6 +1243,7 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1244 | 1243 | ||
1245 | /* initialize the wol settings based on the eeprom settings */ | 1244 | /* initialize the wol settings based on the eeprom settings */ |
1246 | adapter->wol = adapter->eeprom_wol; | 1245 | adapter->wol = adapter->eeprom_wol; |
1246 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); | ||
1247 | 1247 | ||
1248 | /* reset the hardware with the new settings */ | 1248 | /* reset the hardware with the new settings */ |
1249 | igb_reset(adapter); | 1249 | igb_reset(adapter); |
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c index a3f732418c49..96e709d6440a 100644 --- a/drivers/net/mlx4/en_netdev.c +++ b/drivers/net/mlx4/en_netdev.c | |||
@@ -656,10 +656,10 @@ static int mlx4_en_start_port(struct net_device *dev) | |||
656 | /* Configure port */ | 656 | /* Configure port */ |
657 | err = mlx4_SET_PORT_general(mdev->dev, priv->port, | 657 | err = mlx4_SET_PORT_general(mdev->dev, priv->port, |
658 | priv->rx_skb_size + ETH_FCS_LEN, | 658 | priv->rx_skb_size + ETH_FCS_LEN, |
659 | mdev->profile.tx_pause, | 659 | priv->prof->tx_pause, |
660 | mdev->profile.tx_ppp, | 660 | priv->prof->tx_ppp, |
661 | mdev->profile.rx_pause, | 661 | priv->prof->rx_pause, |
662 | mdev->profile.rx_ppp); | 662 | priv->prof->rx_ppp); |
663 | if (err) { | 663 | if (err) { |
664 | mlx4_err(mdev, "Failed setting port general configurations" | 664 | mlx4_err(mdev, "Failed setting port general configurations" |
665 | " for port %d, with error %d\n", priv->port, err); | 665 | " for port %d, with error %d\n", priv->port, err); |
diff --git a/drivers/net/mlx4/en_params.c b/drivers/net/mlx4/en_params.c index c2e69b1bcd0a..95706ee1c019 100644 --- a/drivers/net/mlx4/en_params.c +++ b/drivers/net/mlx4/en_params.c | |||
@@ -90,6 +90,7 @@ MLX4_EN_PARM_INT(rx_ring_size2, MLX4_EN_AUTO_CONF, "Rx ring size for port 2"); | |||
90 | int mlx4_en_get_profile(struct mlx4_en_dev *mdev) | 90 | int mlx4_en_get_profile(struct mlx4_en_dev *mdev) |
91 | { | 91 | { |
92 | struct mlx4_en_profile *params = &mdev->profile; | 92 | struct mlx4_en_profile *params = &mdev->profile; |
93 | int i; | ||
93 | 94 | ||
94 | params->rx_moder_cnt = min_t(int, rx_moder_cnt, MLX4_EN_AUTO_CONF); | 95 | params->rx_moder_cnt = min_t(int, rx_moder_cnt, MLX4_EN_AUTO_CONF); |
95 | params->rx_moder_time = min_t(int, rx_moder_time, MLX4_EN_AUTO_CONF); | 96 | params->rx_moder_time = min_t(int, rx_moder_time, MLX4_EN_AUTO_CONF); |
@@ -97,11 +98,13 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev) | |||
97 | params->rss_xor = (rss_xor != 0); | 98 | params->rss_xor = (rss_xor != 0); |
98 | params->rss_mask = rss_mask & 0x1f; | 99 | params->rss_mask = rss_mask & 0x1f; |
99 | params->num_lro = min_t(int, num_lro , MLX4_EN_MAX_LRO_DESCRIPTORS); | 100 | params->num_lro = min_t(int, num_lro , MLX4_EN_MAX_LRO_DESCRIPTORS); |
100 | params->rx_pause = pprx; | 101 | for (i = 1; i <= MLX4_MAX_PORTS; i++) { |
101 | params->rx_ppp = pfcrx; | 102 | params->prof[i].rx_pause = pprx; |
102 | params->tx_pause = pptx; | 103 | params->prof[i].rx_ppp = pfcrx; |
103 | params->tx_ppp = pfctx; | 104 | params->prof[i].tx_pause = pptx; |
104 | if (params->rx_ppp || params->tx_ppp) { | 105 | params->prof[i].tx_ppp = pfctx; |
106 | } | ||
107 | if (pfcrx || pfctx) { | ||
105 | params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM; | 108 | params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM; |
106 | params->prof[2].tx_ring_num = MLX4_EN_TX_RING_NUM; | 109 | params->prof[2].tx_ring_num = MLX4_EN_TX_RING_NUM; |
107 | } else { | 110 | } else { |
@@ -407,14 +410,14 @@ static int mlx4_en_set_pauseparam(struct net_device *dev, | |||
407 | struct mlx4_en_dev *mdev = priv->mdev; | 410 | struct mlx4_en_dev *mdev = priv->mdev; |
408 | int err; | 411 | int err; |
409 | 412 | ||
410 | mdev->profile.tx_pause = pause->tx_pause != 0; | 413 | priv->prof->tx_pause = pause->tx_pause != 0; |
411 | mdev->profile.rx_pause = pause->rx_pause != 0; | 414 | priv->prof->rx_pause = pause->rx_pause != 0; |
412 | err = mlx4_SET_PORT_general(mdev->dev, priv->port, | 415 | err = mlx4_SET_PORT_general(mdev->dev, priv->port, |
413 | priv->rx_skb_size + ETH_FCS_LEN, | 416 | priv->rx_skb_size + ETH_FCS_LEN, |
414 | mdev->profile.tx_pause, | 417 | priv->prof->tx_pause, |
415 | mdev->profile.tx_ppp, | 418 | priv->prof->tx_ppp, |
416 | mdev->profile.rx_pause, | 419 | priv->prof->rx_pause, |
417 | mdev->profile.rx_ppp); | 420 | priv->prof->rx_ppp); |
418 | if (err) | 421 | if (err) |
419 | mlx4_err(mdev, "Failed setting pause params to\n"); | 422 | mlx4_err(mdev, "Failed setting pause params to\n"); |
420 | 423 | ||
@@ -425,10 +428,9 @@ static void mlx4_en_get_pauseparam(struct net_device *dev, | |||
425 | struct ethtool_pauseparam *pause) | 428 | struct ethtool_pauseparam *pause) |
426 | { | 429 | { |
427 | struct mlx4_en_priv *priv = netdev_priv(dev); | 430 | struct mlx4_en_priv *priv = netdev_priv(dev); |
428 | struct mlx4_en_dev *mdev = priv->mdev; | ||
429 | 431 | ||
430 | pause->tx_pause = mdev->profile.tx_pause; | 432 | pause->tx_pause = priv->prof->tx_pause; |
431 | pause->rx_pause = mdev->profile.rx_pause; | 433 | pause->rx_pause = priv->prof->rx_pause; |
432 | } | 434 | } |
433 | 435 | ||
434 | static void mlx4_en_get_ringparam(struct net_device *dev, | 436 | static void mlx4_en_get_ringparam(struct net_device *dev, |
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index fa431fad0eec..56a2e213fe62 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h | |||
@@ -87,6 +87,9 @@ enum { | |||
87 | 87 | ||
88 | #ifdef CONFIG_MLX4_DEBUG | 88 | #ifdef CONFIG_MLX4_DEBUG |
89 | extern int mlx4_debug_level; | 89 | extern int mlx4_debug_level; |
90 | #else /* CONFIG_MLX4_DEBUG */ | ||
91 | #define mlx4_debug_level (0) | ||
92 | #endif /* CONFIG_MLX4_DEBUG */ | ||
90 | 93 | ||
91 | #define mlx4_dbg(mdev, format, arg...) \ | 94 | #define mlx4_dbg(mdev, format, arg...) \ |
92 | do { \ | 95 | do { \ |
@@ -94,12 +97,6 @@ extern int mlx4_debug_level; | |||
94 | dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ## arg); \ | 97 | dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ## arg); \ |
95 | } while (0) | 98 | } while (0) |
96 | 99 | ||
97 | #else /* CONFIG_MLX4_DEBUG */ | ||
98 | |||
99 | #define mlx4_dbg(mdev, format, arg...) do { (void) mdev; } while (0) | ||
100 | |||
101 | #endif /* CONFIG_MLX4_DEBUG */ | ||
102 | |||
103 | #define mlx4_err(mdev, format, arg...) \ | 100 | #define mlx4_err(mdev, format, arg...) \ |
104 | dev_err(&mdev->pdev->dev, format, ## arg) | 101 | dev_err(&mdev->pdev->dev, format, ## arg) |
105 | #define mlx4_info(mdev, format, arg...) \ | 102 | #define mlx4_info(mdev, format, arg...) \ |
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h index 11fb17c6e97b..98ddc0811f93 100644 --- a/drivers/net/mlx4/mlx4_en.h +++ b/drivers/net/mlx4/mlx4_en.h | |||
@@ -322,6 +322,10 @@ struct mlx4_en_port_profile { | |||
322 | u32 rx_ring_num; | 322 | u32 rx_ring_num; |
323 | u32 tx_ring_size; | 323 | u32 tx_ring_size; |
324 | u32 rx_ring_size; | 324 | u32 rx_ring_size; |
325 | u8 rx_pause; | ||
326 | u8 rx_ppp; | ||
327 | u8 tx_pause; | ||
328 | u8 tx_ppp; | ||
325 | }; | 329 | }; |
326 | 330 | ||
327 | struct mlx4_en_profile { | 331 | struct mlx4_en_profile { |
@@ -333,10 +337,6 @@ struct mlx4_en_profile { | |||
333 | int rx_moder_cnt; | 337 | int rx_moder_cnt; |
334 | int rx_moder_time; | 338 | int rx_moder_time; |
335 | int auto_moder; | 339 | int auto_moder; |
336 | u8 rx_pause; | ||
337 | u8 rx_ppp; | ||
338 | u8 tx_pause; | ||
339 | u8 tx_ppp; | ||
340 | u8 no_reset; | 340 | u8 no_reset; |
341 | struct mlx4_en_port_profile prof[MLX4_MAX_PORTS + 1]; | 341 | struct mlx4_en_port_profile prof[MLX4_MAX_PORTS + 1]; |
342 | }; | 342 | }; |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index a5f428bcc0eb..b37867097308 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -75,7 +75,7 @@ | |||
75 | #include "myri10ge_mcp.h" | 75 | #include "myri10ge_mcp.h" |
76 | #include "myri10ge_mcp_gen_header.h" | 76 | #include "myri10ge_mcp_gen_header.h" |
77 | 77 | ||
78 | #define MYRI10GE_VERSION_STR "1.4.3-1.375" | 78 | #define MYRI10GE_VERSION_STR "1.4.3-1.378" |
79 | 79 | ||
80 | MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); | 80 | MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); |
81 | MODULE_AUTHOR("Maintainer: help@myri.com"); | 81 | MODULE_AUTHOR("Maintainer: help@myri.com"); |
@@ -1393,6 +1393,7 @@ myri10ge_tx_done(struct myri10ge_slice_state *ss, int mcp_index) | |||
1393 | if (tx->req == tx->done) { | 1393 | if (tx->req == tx->done) { |
1394 | tx->queue_active = 0; | 1394 | tx->queue_active = 0; |
1395 | put_be32(htonl(1), tx->send_stop); | 1395 | put_be32(htonl(1), tx->send_stop); |
1396 | mb(); | ||
1396 | mmiowb(); | 1397 | mmiowb(); |
1397 | } | 1398 | } |
1398 | __netif_tx_unlock(dev_queue); | 1399 | __netif_tx_unlock(dev_queue); |
@@ -2865,6 +2866,7 @@ again: | |||
2865 | if ((mgp->dev->real_num_tx_queues > 1) && tx->queue_active == 0) { | 2866 | if ((mgp->dev->real_num_tx_queues > 1) && tx->queue_active == 0) { |
2866 | tx->queue_active = 1; | 2867 | tx->queue_active = 1; |
2867 | put_be32(htonl(1), tx->send_go); | 2868 | put_be32(htonl(1), tx->send_go); |
2869 | mb(); | ||
2868 | mmiowb(); | 2870 | mmiowb(); |
2869 | } | 2871 | } |
2870 | tx->pkt_start++; | 2872 | tx->pkt_start++; |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index 9acb5d70a3ae..1b6f548c4411 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -33,8 +33,8 @@ | |||
33 | 33 | ||
34 | #define DRV_MODULE_NAME "niu" | 34 | #define DRV_MODULE_NAME "niu" |
35 | #define PFX DRV_MODULE_NAME ": " | 35 | #define PFX DRV_MODULE_NAME ": " |
36 | #define DRV_MODULE_VERSION "0.9" | 36 | #define DRV_MODULE_VERSION "1.0" |
37 | #define DRV_MODULE_RELDATE "May 4, 2008" | 37 | #define DRV_MODULE_RELDATE "Nov 14, 2008" |
38 | 38 | ||
39 | static char version[] __devinitdata = | 39 | static char version[] __devinitdata = |
40 | DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; | 40 | DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; |
@@ -51,8 +51,7 @@ MODULE_VERSION(DRV_MODULE_VERSION); | |||
51 | #ifndef readq | 51 | #ifndef readq |
52 | static u64 readq(void __iomem *reg) | 52 | static u64 readq(void __iomem *reg) |
53 | { | 53 | { |
54 | return (((u64)readl(reg + 0x4UL) << 32) | | 54 | return ((u64) readl(reg)) | (((u64) readl(reg + 4UL)) << 32); |
55 | (u64)readl(reg)); | ||
56 | } | 55 | } |
57 | 56 | ||
58 | static void writeq(u64 val, void __iomem *reg) | 57 | static void writeq(u64 val, void __iomem *reg) |
@@ -407,7 +406,7 @@ static int esr2_set_rx_cfg(struct niu *np, unsigned long channel, u32 val) | |||
407 | } | 406 | } |
408 | 407 | ||
409 | /* Mode is always 10G fiber. */ | 408 | /* Mode is always 10G fiber. */ |
410 | static int serdes_init_niu(struct niu *np) | 409 | static int serdes_init_niu_10g_fiber(struct niu *np) |
411 | { | 410 | { |
412 | struct niu_link_config *lp = &np->link_config; | 411 | struct niu_link_config *lp = &np->link_config; |
413 | u32 tx_cfg, rx_cfg; | 412 | u32 tx_cfg, rx_cfg; |
@@ -444,6 +443,223 @@ static int serdes_init_niu(struct niu *np) | |||
444 | return 0; | 443 | return 0; |
445 | } | 444 | } |
446 | 445 | ||
446 | static int serdes_init_niu_1g_serdes(struct niu *np) | ||
447 | { | ||
448 | struct niu_link_config *lp = &np->link_config; | ||
449 | u16 pll_cfg, pll_sts; | ||
450 | int max_retry = 100; | ||
451 | u64 sig, mask, val; | ||
452 | u32 tx_cfg, rx_cfg; | ||
453 | unsigned long i; | ||
454 | int err; | ||
455 | |||
456 | tx_cfg = (PLL_TX_CFG_ENTX | PLL_TX_CFG_SWING_1375MV | | ||
457 | PLL_TX_CFG_RATE_HALF); | ||
458 | rx_cfg = (PLL_RX_CFG_ENRX | PLL_RX_CFG_TERM_0P8VDDT | | ||
459 | PLL_RX_CFG_ALIGN_ENA | PLL_RX_CFG_LOS_LTHRESH | | ||
460 | PLL_RX_CFG_RATE_HALF); | ||
461 | |||
462 | if (np->port == 0) | ||
463 | rx_cfg |= PLL_RX_CFG_EQ_LP_ADAPTIVE; | ||
464 | |||
465 | if (lp->loopback_mode == LOOPBACK_PHY) { | ||
466 | u16 test_cfg = PLL_TEST_CFG_LOOPBACK_CML_DIS; | ||
467 | |||
468 | mdio_write(np, np->port, NIU_ESR2_DEV_ADDR, | ||
469 | ESR2_TI_PLL_TEST_CFG_L, test_cfg); | ||
470 | |||
471 | tx_cfg |= PLL_TX_CFG_ENTEST; | ||
472 | rx_cfg |= PLL_RX_CFG_ENTEST; | ||
473 | } | ||
474 | |||
475 | /* Initialize PLL for 1G */ | ||
476 | pll_cfg = (PLL_CFG_ENPLL | PLL_CFG_MPY_8X); | ||
477 | |||
478 | err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR, | ||
479 | ESR2_TI_PLL_CFG_L, pll_cfg); | ||
480 | if (err) { | ||
481 | dev_err(np->device, PFX "NIU Port %d " | ||
482 | "serdes_init_niu_1g_serdes: " | ||
483 | "mdio write to ESR2_TI_PLL_CFG_L failed", np->port); | ||
484 | return err; | ||
485 | } | ||
486 | |||
487 | pll_sts = PLL_CFG_ENPLL; | ||
488 | |||
489 | err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR, | ||
490 | ESR2_TI_PLL_STS_L, pll_sts); | ||
491 | if (err) { | ||
492 | dev_err(np->device, PFX "NIU Port %d " | ||
493 | "serdes_init_niu_1g_serdes: " | ||
494 | "mdio write to ESR2_TI_PLL_STS_L failed", np->port); | ||
495 | return err; | ||
496 | } | ||
497 | |||
498 | udelay(200); | ||
499 | |||
500 | /* Initialize all 4 lanes of the SERDES. */ | ||
501 | for (i = 0; i < 4; i++) { | ||
502 | err = esr2_set_tx_cfg(np, i, tx_cfg); | ||
503 | if (err) | ||
504 | return err; | ||
505 | } | ||
506 | |||
507 | for (i = 0; i < 4; i++) { | ||
508 | err = esr2_set_rx_cfg(np, i, rx_cfg); | ||
509 | if (err) | ||
510 | return err; | ||
511 | } | ||
512 | |||
513 | switch (np->port) { | ||
514 | case 0: | ||
515 | val = (ESR_INT_SRDY0_P0 | ESR_INT_DET0_P0); | ||
516 | mask = val; | ||
517 | break; | ||
518 | |||
519 | case 1: | ||
520 | val = (ESR_INT_SRDY0_P1 | ESR_INT_DET0_P1); | ||
521 | mask = val; | ||
522 | break; | ||
523 | |||
524 | default: | ||
525 | return -EINVAL; | ||
526 | } | ||
527 | |||
528 | while (max_retry--) { | ||
529 | sig = nr64(ESR_INT_SIGNALS); | ||
530 | if ((sig & mask) == val) | ||
531 | break; | ||
532 | |||
533 | mdelay(500); | ||
534 | } | ||
535 | |||
536 | if ((sig & mask) != val) { | ||
537 | dev_err(np->device, PFX "Port %u signal bits [%08x] are not " | ||
538 | "[%08x]\n", np->port, (int) (sig & mask), (int) val); | ||
539 | return -ENODEV; | ||
540 | } | ||
541 | |||
542 | return 0; | ||
543 | } | ||
544 | |||
545 | static int serdes_init_niu_10g_serdes(struct niu *np) | ||
546 | { | ||
547 | struct niu_link_config *lp = &np->link_config; | ||
548 | u32 tx_cfg, rx_cfg, pll_cfg, pll_sts; | ||
549 | int max_retry = 100; | ||
550 | u64 sig, mask, val; | ||
551 | unsigned long i; | ||
552 | int err; | ||
553 | |||
554 | tx_cfg = (PLL_TX_CFG_ENTX | PLL_TX_CFG_SWING_1375MV); | ||
555 | rx_cfg = (PLL_RX_CFG_ENRX | PLL_RX_CFG_TERM_0P8VDDT | | ||
556 | PLL_RX_CFG_ALIGN_ENA | PLL_RX_CFG_LOS_LTHRESH | | ||
557 | PLL_RX_CFG_EQ_LP_ADAPTIVE); | ||
558 | |||
559 | if (lp->loopback_mode == LOOPBACK_PHY) { | ||
560 | u16 test_cfg = PLL_TEST_CFG_LOOPBACK_CML_DIS; | ||
561 | |||
562 | mdio_write(np, np->port, NIU_ESR2_DEV_ADDR, | ||
563 | ESR2_TI_PLL_TEST_CFG_L, test_cfg); | ||
564 | |||
565 | tx_cfg |= PLL_TX_CFG_ENTEST; | ||
566 | rx_cfg |= PLL_RX_CFG_ENTEST; | ||
567 | } | ||
568 | |||
569 | /* Initialize PLL for 10G */ | ||
570 | pll_cfg = (PLL_CFG_ENPLL | PLL_CFG_MPY_10X); | ||
571 | |||
572 | err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR, | ||
573 | ESR2_TI_PLL_CFG_L, pll_cfg & 0xffff); | ||
574 | if (err) { | ||
575 | dev_err(np->device, PFX "NIU Port %d " | ||
576 | "serdes_init_niu_10g_serdes: " | ||
577 | "mdio write to ESR2_TI_PLL_CFG_L failed", np->port); | ||
578 | return err; | ||
579 | } | ||
580 | |||
581 | pll_sts = PLL_CFG_ENPLL; | ||
582 | |||
583 | err = mdio_write(np, np->port, NIU_ESR2_DEV_ADDR, | ||
584 | ESR2_TI_PLL_STS_L, pll_sts & 0xffff); | ||
585 | if (err) { | ||
586 | dev_err(np->device, PFX "NIU Port %d " | ||
587 | "serdes_init_niu_10g_serdes: " | ||
588 | "mdio write to ESR2_TI_PLL_STS_L failed", np->port); | ||
589 | return err; | ||
590 | } | ||
591 | |||
592 | udelay(200); | ||
593 | |||
594 | /* Initialize all 4 lanes of the SERDES. */ | ||
595 | for (i = 0; i < 4; i++) { | ||
596 | err = esr2_set_tx_cfg(np, i, tx_cfg); | ||
597 | if (err) | ||
598 | return err; | ||
599 | } | ||
600 | |||
601 | for (i = 0; i < 4; i++) { | ||
602 | err = esr2_set_rx_cfg(np, i, rx_cfg); | ||
603 | if (err) | ||
604 | return err; | ||
605 | } | ||
606 | |||
607 | /* check if serdes is ready */ | ||
608 | |||
609 | switch (np->port) { | ||
610 | case 0: | ||
611 | mask = ESR_INT_SIGNALS_P0_BITS; | ||
612 | val = (ESR_INT_SRDY0_P0 | | ||
613 | ESR_INT_DET0_P0 | | ||
614 | ESR_INT_XSRDY_P0 | | ||
615 | ESR_INT_XDP_P0_CH3 | | ||
616 | ESR_INT_XDP_P0_CH2 | | ||
617 | ESR_INT_XDP_P0_CH1 | | ||
618 | ESR_INT_XDP_P0_CH0); | ||
619 | break; | ||
620 | |||
621 | case 1: | ||
622 | mask = ESR_INT_SIGNALS_P1_BITS; | ||
623 | val = (ESR_INT_SRDY0_P1 | | ||
624 | ESR_INT_DET0_P1 | | ||
625 | ESR_INT_XSRDY_P1 | | ||
626 | ESR_INT_XDP_P1_CH3 | | ||
627 | ESR_INT_XDP_P1_CH2 | | ||
628 | ESR_INT_XDP_P1_CH1 | | ||
629 | ESR_INT_XDP_P1_CH0); | ||
630 | break; | ||
631 | |||
632 | default: | ||
633 | return -EINVAL; | ||
634 | } | ||
635 | |||
636 | while (max_retry--) { | ||
637 | sig = nr64(ESR_INT_SIGNALS); | ||
638 | if ((sig & mask) == val) | ||
639 | break; | ||
640 | |||
641 | mdelay(500); | ||
642 | } | ||
643 | |||
644 | if ((sig & mask) != val) { | ||
645 | pr_info(PFX "NIU Port %u signal bits [%08x] are not " | ||
646 | "[%08x] for 10G...trying 1G\n", | ||
647 | np->port, (int) (sig & mask), (int) val); | ||
648 | |||
649 | /* 10G failed, try initializing at 1G */ | ||
650 | err = serdes_init_niu_1g_serdes(np); | ||
651 | if (!err) { | ||
652 | np->flags &= ~NIU_FLAGS_10G; | ||
653 | np->mac_xcvr = MAC_XCVR_PCS; | ||
654 | } else { | ||
655 | dev_err(np->device, PFX "Port %u 10G/1G SERDES " | ||
656 | "Link Failed \n", np->port); | ||
657 | return -ENODEV; | ||
658 | } | ||
659 | } | ||
660 | return 0; | ||
661 | } | ||
662 | |||
447 | static int esr_read_rxtx_ctrl(struct niu *np, unsigned long chan, u32 *val) | 663 | static int esr_read_rxtx_ctrl(struct niu *np, unsigned long chan, u32 *val) |
448 | { | 664 | { |
449 | int err; | 665 | int err; |
@@ -1955,13 +2171,23 @@ static const struct niu_phy_ops phy_ops_10g_serdes = { | |||
1955 | .link_status = link_status_10g_serdes, | 2171 | .link_status = link_status_10g_serdes, |
1956 | }; | 2172 | }; |
1957 | 2173 | ||
2174 | static const struct niu_phy_ops phy_ops_10g_serdes_niu = { | ||
2175 | .serdes_init = serdes_init_niu_10g_serdes, | ||
2176 | .link_status = link_status_10g_serdes, | ||
2177 | }; | ||
2178 | |||
2179 | static const struct niu_phy_ops phy_ops_1g_serdes_niu = { | ||
2180 | .serdes_init = serdes_init_niu_1g_serdes, | ||
2181 | .link_status = link_status_1g_serdes, | ||
2182 | }; | ||
2183 | |||
1958 | static const struct niu_phy_ops phy_ops_1g_rgmii = { | 2184 | static const struct niu_phy_ops phy_ops_1g_rgmii = { |
1959 | .xcvr_init = xcvr_init_1g_rgmii, | 2185 | .xcvr_init = xcvr_init_1g_rgmii, |
1960 | .link_status = link_status_1g_rgmii, | 2186 | .link_status = link_status_1g_rgmii, |
1961 | }; | 2187 | }; |
1962 | 2188 | ||
1963 | static const struct niu_phy_ops phy_ops_10g_fiber_niu = { | 2189 | static const struct niu_phy_ops phy_ops_10g_fiber_niu = { |
1964 | .serdes_init = serdes_init_niu, | 2190 | .serdes_init = serdes_init_niu_10g_fiber, |
1965 | .xcvr_init = xcvr_init_10g, | 2191 | .xcvr_init = xcvr_init_10g, |
1966 | .link_status = link_status_10g, | 2192 | .link_status = link_status_10g, |
1967 | }; | 2193 | }; |
@@ -1999,11 +2225,21 @@ struct niu_phy_template { | |||
1999 | u32 phy_addr_base; | 2225 | u32 phy_addr_base; |
2000 | }; | 2226 | }; |
2001 | 2227 | ||
2002 | static const struct niu_phy_template phy_template_niu = { | 2228 | static const struct niu_phy_template phy_template_niu_10g_fiber = { |
2003 | .ops = &phy_ops_10g_fiber_niu, | 2229 | .ops = &phy_ops_10g_fiber_niu, |
2004 | .phy_addr_base = 16, | 2230 | .phy_addr_base = 16, |
2005 | }; | 2231 | }; |
2006 | 2232 | ||
2233 | static const struct niu_phy_template phy_template_niu_10g_serdes = { | ||
2234 | .ops = &phy_ops_10g_serdes_niu, | ||
2235 | .phy_addr_base = 0, | ||
2236 | }; | ||
2237 | |||
2238 | static const struct niu_phy_template phy_template_niu_1g_serdes = { | ||
2239 | .ops = &phy_ops_1g_serdes_niu, | ||
2240 | .phy_addr_base = 0, | ||
2241 | }; | ||
2242 | |||
2007 | static const struct niu_phy_template phy_template_10g_fiber = { | 2243 | static const struct niu_phy_template phy_template_10g_fiber = { |
2008 | .ops = &phy_ops_10g_fiber, | 2244 | .ops = &phy_ops_10g_fiber, |
2009 | .phy_addr_base = 8, | 2245 | .phy_addr_base = 8, |
@@ -2183,8 +2419,25 @@ static int niu_determine_phy_disposition(struct niu *np) | |||
2183 | u32 phy_addr_off = 0; | 2419 | u32 phy_addr_off = 0; |
2184 | 2420 | ||
2185 | if (plat_type == PLAT_TYPE_NIU) { | 2421 | if (plat_type == PLAT_TYPE_NIU) { |
2186 | tp = &phy_template_niu; | 2422 | switch (np->flags & |
2187 | phy_addr_off += np->port; | 2423 | (NIU_FLAGS_10G | |
2424 | NIU_FLAGS_FIBER | | ||
2425 | NIU_FLAGS_XCVR_SERDES)) { | ||
2426 | case NIU_FLAGS_10G | NIU_FLAGS_XCVR_SERDES: | ||
2427 | /* 10G Serdes */ | ||
2428 | tp = &phy_template_niu_10g_serdes; | ||
2429 | break; | ||
2430 | case NIU_FLAGS_XCVR_SERDES: | ||
2431 | /* 1G Serdes */ | ||
2432 | tp = &phy_template_niu_1g_serdes; | ||
2433 | break; | ||
2434 | case NIU_FLAGS_10G | NIU_FLAGS_FIBER: | ||
2435 | /* 10G Fiber */ | ||
2436 | default: | ||
2437 | tp = &phy_template_niu_10g_fiber; | ||
2438 | phy_addr_off += np->port; | ||
2439 | break; | ||
2440 | } | ||
2188 | } else { | 2441 | } else { |
2189 | switch (np->flags & | 2442 | switch (np->flags & |
2190 | (NIU_FLAGS_10G | | 2443 | (NIU_FLAGS_10G | |
@@ -7214,6 +7467,12 @@ static int __devinit niu_phy_type_prop_decode(struct niu *np, | |||
7214 | np->flags |= NIU_FLAGS_10G; | 7467 | np->flags |= NIU_FLAGS_10G; |
7215 | np->flags &= ~NIU_FLAGS_FIBER; | 7468 | np->flags &= ~NIU_FLAGS_FIBER; |
7216 | np->mac_xcvr = MAC_XCVR_XPCS; | 7469 | np->mac_xcvr = MAC_XCVR_XPCS; |
7470 | } else if (!strcmp(phy_prop, "xgsd") || !strcmp(phy_prop, "gsd")) { | ||
7471 | /* 10G Serdes or 1G Serdes, default to 10G */ | ||
7472 | np->flags |= NIU_FLAGS_10G; | ||
7473 | np->flags &= ~NIU_FLAGS_FIBER; | ||
7474 | np->flags |= NIU_FLAGS_XCVR_SERDES; | ||
7475 | np->mac_xcvr = MAC_XCVR_XPCS; | ||
7217 | } else { | 7476 | } else { |
7218 | return -EINVAL; | 7477 | return -EINVAL; |
7219 | } | 7478 | } |
@@ -7742,6 +8001,8 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent) | |||
7742 | u32 val; | 8001 | u32 val; |
7743 | int err; | 8002 | int err; |
7744 | 8003 | ||
8004 | num_10g = num_1g = 0; | ||
8005 | |||
7745 | if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) || | 8006 | if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) || |
7746 | !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) { | 8007 | !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) { |
7747 | num_10g = 0; | 8008 | num_10g = 0; |
@@ -7758,6 +8019,16 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent) | |||
7758 | parent->num_ports = 2; | 8019 | parent->num_ports = 2; |
7759 | val = (phy_encode(PORT_TYPE_10G, 0) | | 8020 | val = (phy_encode(PORT_TYPE_10G, 0) | |
7760 | phy_encode(PORT_TYPE_10G, 1)); | 8021 | phy_encode(PORT_TYPE_10G, 1)); |
8022 | } else if ((np->flags & NIU_FLAGS_XCVR_SERDES) && | ||
8023 | (parent->plat_type == PLAT_TYPE_NIU)) { | ||
8024 | /* this is the Monza case */ | ||
8025 | if (np->flags & NIU_FLAGS_10G) { | ||
8026 | val = (phy_encode(PORT_TYPE_10G, 0) | | ||
8027 | phy_encode(PORT_TYPE_10G, 1)); | ||
8028 | } else { | ||
8029 | val = (phy_encode(PORT_TYPE_1G, 0) | | ||
8030 | phy_encode(PORT_TYPE_1G, 1)); | ||
8031 | } | ||
7761 | } else { | 8032 | } else { |
7762 | err = fill_phy_probe_info(np, parent, info); | 8033 | err = fill_phy_probe_info(np, parent, info); |
7763 | if (err) | 8034 | if (err) |
@@ -8657,7 +8928,9 @@ static void __devinit niu_device_announce(struct niu *np) | |||
8657 | dev->name, | 8928 | dev->name, |
8658 | (np->flags & NIU_FLAGS_XMAC ? "XMAC" : "BMAC"), | 8929 | (np->flags & NIU_FLAGS_XMAC ? "XMAC" : "BMAC"), |
8659 | (np->flags & NIU_FLAGS_10G ? "10G" : "1G"), | 8930 | (np->flags & NIU_FLAGS_10G ? "10G" : "1G"), |
8660 | (np->flags & NIU_FLAGS_FIBER ? "FIBER" : "COPPER"), | 8931 | (np->flags & NIU_FLAGS_FIBER ? "FIBER" : |
8932 | (np->flags & NIU_FLAGS_XCVR_SERDES ? "SERDES" : | ||
8933 | "COPPER")), | ||
8661 | (np->mac_xcvr == MAC_XCVR_MII ? "MII" : | 8934 | (np->mac_xcvr == MAC_XCVR_MII ? "MII" : |
8662 | (np->mac_xcvr == MAC_XCVR_PCS ? "PCS" : "XPCS")), | 8935 | (np->mac_xcvr == MAC_XCVR_PCS ? "PCS" : "XPCS")), |
8663 | np->vpd.phy_type); | 8936 | np->vpd.phy_type); |
diff --git a/drivers/net/niu.h b/drivers/net/niu.h index c6fa883daa22..180ca8ae93de 100644 --- a/drivers/net/niu.h +++ b/drivers/net/niu.h | |||
@@ -1048,6 +1048,13 @@ | |||
1048 | #define PLL_CFG_LD_SHIFT 8 | 1048 | #define PLL_CFG_LD_SHIFT 8 |
1049 | #define PLL_CFG_MPY 0x0000001e | 1049 | #define PLL_CFG_MPY 0x0000001e |
1050 | #define PLL_CFG_MPY_SHIFT 1 | 1050 | #define PLL_CFG_MPY_SHIFT 1 |
1051 | #define PLL_CFG_MPY_4X 0x0 | ||
1052 | #define PLL_CFG_MPY_5X 0x00000002 | ||
1053 | #define PLL_CFG_MPY_6X 0x00000004 | ||
1054 | #define PLL_CFG_MPY_8X 0x00000008 | ||
1055 | #define PLL_CFG_MPY_10X 0x0000000a | ||
1056 | #define PLL_CFG_MPY_12X 0x0000000c | ||
1057 | #define PLL_CFG_MPY_12P5X 0x0000000e | ||
1051 | #define PLL_CFG_ENPLL 0x00000001 | 1058 | #define PLL_CFG_ENPLL 0x00000001 |
1052 | 1059 | ||
1053 | #define ESR2_TI_PLL_STS_L (ESR2_BASE + 0x002) | 1060 | #define ESR2_TI_PLL_STS_L (ESR2_BASE + 0x002) |
@@ -1093,6 +1100,9 @@ | |||
1093 | #define PLL_TX_CFG_INVPAIR 0x00000080 | 1100 | #define PLL_TX_CFG_INVPAIR 0x00000080 |
1094 | #define PLL_TX_CFG_RATE 0x00000060 | 1101 | #define PLL_TX_CFG_RATE 0x00000060 |
1095 | #define PLL_TX_CFG_RATE_SHIFT 5 | 1102 | #define PLL_TX_CFG_RATE_SHIFT 5 |
1103 | #define PLL_TX_CFG_RATE_FULL 0x0 | ||
1104 | #define PLL_TX_CFG_RATE_HALF 0x20 | ||
1105 | #define PLL_TX_CFG_RATE_QUAD 0x40 | ||
1096 | #define PLL_TX_CFG_BUSWIDTH 0x0000001c | 1106 | #define PLL_TX_CFG_BUSWIDTH 0x0000001c |
1097 | #define PLL_TX_CFG_BUSWIDTH_SHIFT 2 | 1107 | #define PLL_TX_CFG_BUSWIDTH_SHIFT 2 |
1098 | #define PLL_TX_CFG_ENTEST 0x00000002 | 1108 | #define PLL_TX_CFG_ENTEST 0x00000002 |
@@ -1132,6 +1142,9 @@ | |||
1132 | #define PLL_RX_CFG_INVPAIR 0x00000080 | 1142 | #define PLL_RX_CFG_INVPAIR 0x00000080 |
1133 | #define PLL_RX_CFG_RATE 0x00000060 | 1143 | #define PLL_RX_CFG_RATE 0x00000060 |
1134 | #define PLL_RX_CFG_RATE_SHIFT 5 | 1144 | #define PLL_RX_CFG_RATE_SHIFT 5 |
1145 | #define PLL_RX_CFG_RATE_FULL 0x0 | ||
1146 | #define PLL_RX_CFG_RATE_HALF 0x20 | ||
1147 | #define PLL_RX_CFG_RATE_QUAD 0x40 | ||
1135 | #define PLL_RX_CFG_BUSWIDTH 0x0000001c | 1148 | #define PLL_RX_CFG_BUSWIDTH 0x0000001c |
1136 | #define PLL_RX_CFG_BUSWIDTH_SHIFT 2 | 1149 | #define PLL_RX_CFG_BUSWIDTH_SHIFT 2 |
1137 | #define PLL_RX_CFG_ENTEST 0x00000002 | 1150 | #define PLL_RX_CFG_ENTEST 0x00000002 |
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 4aa547947040..eb6411c4694f 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c | |||
@@ -227,6 +227,59 @@ static int m88e1111_config_init(struct phy_device *phydev) | |||
227 | return 0; | 227 | return 0; |
228 | } | 228 | } |
229 | 229 | ||
230 | static int m88e1118_config_aneg(struct phy_device *phydev) | ||
231 | { | ||
232 | int err; | ||
233 | |||
234 | err = phy_write(phydev, MII_BMCR, BMCR_RESET); | ||
235 | if (err < 0) | ||
236 | return err; | ||
237 | |||
238 | err = phy_write(phydev, MII_M1011_PHY_SCR, | ||
239 | MII_M1011_PHY_SCR_AUTO_CROSS); | ||
240 | if (err < 0) | ||
241 | return err; | ||
242 | |||
243 | err = genphy_config_aneg(phydev); | ||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static int m88e1118_config_init(struct phy_device *phydev) | ||
248 | { | ||
249 | int err; | ||
250 | |||
251 | /* Change address */ | ||
252 | err = phy_write(phydev, 0x16, 0x0002); | ||
253 | if (err < 0) | ||
254 | return err; | ||
255 | |||
256 | /* Enable 1000 Mbit */ | ||
257 | err = phy_write(phydev, 0x15, 0x1070); | ||
258 | if (err < 0) | ||
259 | return err; | ||
260 | |||
261 | /* Change address */ | ||
262 | err = phy_write(phydev, 0x16, 0x0003); | ||
263 | if (err < 0) | ||
264 | return err; | ||
265 | |||
266 | /* Adjust LED Control */ | ||
267 | err = phy_write(phydev, 0x10, 0x021e); | ||
268 | if (err < 0) | ||
269 | return err; | ||
270 | |||
271 | /* Reset address */ | ||
272 | err = phy_write(phydev, 0x16, 0x0); | ||
273 | if (err < 0) | ||
274 | return err; | ||
275 | |||
276 | err = phy_write(phydev, MII_BMCR, BMCR_RESET); | ||
277 | if (err < 0) | ||
278 | return err; | ||
279 | |||
280 | return 0; | ||
281 | } | ||
282 | |||
230 | static int m88e1145_config_init(struct phy_device *phydev) | 283 | static int m88e1145_config_init(struct phy_device *phydev) |
231 | { | 284 | { |
232 | int err; | 285 | int err; |
@@ -416,6 +469,19 @@ static struct phy_driver marvell_drivers[] = { | |||
416 | .driver = { .owner = THIS_MODULE }, | 469 | .driver = { .owner = THIS_MODULE }, |
417 | }, | 470 | }, |
418 | { | 471 | { |
472 | .phy_id = 0x01410e10, | ||
473 | .phy_id_mask = 0xfffffff0, | ||
474 | .name = "Marvell 88E1118", | ||
475 | .features = PHY_GBIT_FEATURES, | ||
476 | .flags = PHY_HAS_INTERRUPT, | ||
477 | .config_init = &m88e1118_config_init, | ||
478 | .config_aneg = &m88e1118_config_aneg, | ||
479 | .read_status = &genphy_read_status, | ||
480 | .ack_interrupt = &marvell_ack_interrupt, | ||
481 | .config_intr = &marvell_config_intr, | ||
482 | .driver = {.owner = THIS_MODULE,}, | ||
483 | }, | ||
484 | { | ||
419 | .phy_id = 0x01410cd0, | 485 | .phy_id = 0x01410cd0, |
420 | .phy_id_mask = 0xfffffff0, | 486 | .phy_id_mask = 0xfffffff0, |
421 | .name = "Marvell 88E1145", | 487 | .name = "Marvell 88E1145", |
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index d0ed1ef284a8..536bda1f428b 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
@@ -136,7 +136,7 @@ void mdiobus_unregister(struct mii_bus *bus) | |||
136 | BUG_ON(bus->state != MDIOBUS_REGISTERED); | 136 | BUG_ON(bus->state != MDIOBUS_REGISTERED); |
137 | bus->state = MDIOBUS_UNREGISTERED; | 137 | bus->state = MDIOBUS_UNREGISTERED; |
138 | 138 | ||
139 | device_unregister(&bus->dev); | 139 | device_del(&bus->dev); |
140 | for (i = 0; i < PHY_MAX_ADDR; i++) { | 140 | for (i = 0; i < PHY_MAX_ADDR; i++) { |
141 | if (bus->phy_map[i]) | 141 | if (bus->phy_map[i]) |
142 | device_unregister(&bus->phy_map[i]->dev); | 142 | device_unregister(&bus->phy_map[i]->dev); |
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index e11b03b2b25a..8fb1faca883a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -227,8 +227,8 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr) | |||
227 | if (r) | 227 | if (r) |
228 | return ERR_PTR(r); | 228 | return ERR_PTR(r); |
229 | 229 | ||
230 | /* If the phy_id is all Fs, there is no device there */ | 230 | /* If the phy_id is all Fs or all 0s, there is no device there */ |
231 | if (0xffffffff == phy_id) | 231 | if ((0xffff == phy_id) || (0x00 == phy_id)) |
232 | return NULL; | 232 | return NULL; |
233 | 233 | ||
234 | dev = phy_device_create(bus, addr, phy_id); | 234 | dev = phy_device_create(bus, addr, phy_id); |
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c index 3cdd07c45b6d..508452c02151 100644 --- a/drivers/net/qla3xxx.c +++ b/drivers/net/qla3xxx.c | |||
@@ -1515,9 +1515,6 @@ static u32 ql_get_link_state(struct ql3_adapter *qdev) | |||
1515 | linkState = LS_UP; | 1515 | linkState = LS_UP; |
1516 | } else { | 1516 | } else { |
1517 | linkState = LS_DOWN; | 1517 | linkState = LS_DOWN; |
1518 | if (netif_msg_link(qdev)) | ||
1519 | printk(KERN_WARNING PFX | ||
1520 | "%s: Link is down.\n", qdev->ndev->name); | ||
1521 | } | 1518 | } |
1522 | return linkState; | 1519 | return linkState; |
1523 | } | 1520 | } |
@@ -1581,10 +1578,6 @@ static int ql_finish_auto_neg(struct ql3_adapter *qdev) | |||
1581 | ql_mac_enable(qdev, 1); | 1578 | ql_mac_enable(qdev, 1); |
1582 | } | 1579 | } |
1583 | 1580 | ||
1584 | if (netif_msg_link(qdev)) | ||
1585 | printk(KERN_DEBUG PFX | ||
1586 | "%s: Change port_link_state LS_DOWN to LS_UP.\n", | ||
1587 | qdev->ndev->name); | ||
1588 | qdev->port_link_state = LS_UP; | 1581 | qdev->port_link_state = LS_UP; |
1589 | netif_start_queue(qdev->ndev); | 1582 | netif_start_queue(qdev->ndev); |
1590 | netif_carrier_on(qdev->ndev); | 1583 | netif_carrier_on(qdev->ndev); |
@@ -1655,14 +1648,9 @@ static void ql_link_state_machine_work(struct work_struct *work) | |||
1655 | /* Fall Through */ | 1648 | /* Fall Through */ |
1656 | 1649 | ||
1657 | case LS_DOWN: | 1650 | case LS_DOWN: |
1658 | if (netif_msg_link(qdev)) | ||
1659 | printk(KERN_DEBUG PFX | ||
1660 | "%s: port_link_state = LS_DOWN.\n", | ||
1661 | qdev->ndev->name); | ||
1662 | if (curr_link_state == LS_UP) { | 1651 | if (curr_link_state == LS_UP) { |
1663 | if (netif_msg_link(qdev)) | 1652 | if (netif_msg_link(qdev)) |
1664 | printk(KERN_DEBUG PFX | 1653 | printk(KERN_INFO PFX "%s: Link is up.\n", |
1665 | "%s: curr_link_state = LS_UP.\n", | ||
1666 | qdev->ndev->name); | 1654 | qdev->ndev->name); |
1667 | if (ql_is_auto_neg_complete(qdev)) | 1655 | if (ql_is_auto_neg_complete(qdev)) |
1668 | ql_finish_auto_neg(qdev); | 1656 | ql_finish_auto_neg(qdev); |
@@ -1670,6 +1658,7 @@ static void ql_link_state_machine_work(struct work_struct *work) | |||
1670 | if (qdev->port_link_state == LS_UP) | 1658 | if (qdev->port_link_state == LS_UP) |
1671 | ql_link_down_detect_clear(qdev); | 1659 | ql_link_down_detect_clear(qdev); |
1672 | 1660 | ||
1661 | qdev->port_link_state = LS_UP; | ||
1673 | } | 1662 | } |
1674 | break; | 1663 | break; |
1675 | 1664 | ||
@@ -1678,12 +1667,14 @@ static void ql_link_state_machine_work(struct work_struct *work) | |||
1678 | * See if the link is currently down or went down and came | 1667 | * See if the link is currently down or went down and came |
1679 | * back up | 1668 | * back up |
1680 | */ | 1669 | */ |
1681 | if ((curr_link_state == LS_DOWN) || ql_link_down_detect(qdev)) { | 1670 | if (curr_link_state == LS_DOWN) { |
1682 | if (netif_msg_link(qdev)) | 1671 | if (netif_msg_link(qdev)) |
1683 | printk(KERN_INFO PFX "%s: Link is down.\n", | 1672 | printk(KERN_INFO PFX "%s: Link is down.\n", |
1684 | qdev->ndev->name); | 1673 | qdev->ndev->name); |
1685 | qdev->port_link_state = LS_DOWN; | 1674 | qdev->port_link_state = LS_DOWN; |
1686 | } | 1675 | } |
1676 | if (ql_link_down_detect(qdev)) | ||
1677 | qdev->port_link_state = LS_DOWN; | ||
1687 | break; | 1678 | break; |
1688 | } | 1679 | } |
1689 | spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); | 1680 | spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); |
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 5051554ff05b..1f26ab0e7986 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c | |||
@@ -2050,7 +2050,9 @@ err_out: | |||
2050 | */ | 2050 | */ |
2051 | static int smc911x_drv_probe(struct platform_device *pdev) | 2051 | static int smc911x_drv_probe(struct platform_device *pdev) |
2052 | { | 2052 | { |
2053 | #ifdef SMC_DYNAMIC_BUS_CONFIG | ||
2053 | struct smc911x_platdata *pd = pdev->dev.platform_data; | 2054 | struct smc911x_platdata *pd = pdev->dev.platform_data; |
2055 | #endif | ||
2054 | struct net_device *ndev; | 2056 | struct net_device *ndev; |
2055 | struct resource *res; | 2057 | struct resource *res; |
2056 | struct smc911x_local *lp; | 2058 | struct smc911x_local *lp; |
@@ -2182,9 +2184,9 @@ static int smc911x_drv_resume(struct platform_device *dev) | |||
2182 | 2184 | ||
2183 | if (netif_running(ndev)) { | 2185 | if (netif_running(ndev)) { |
2184 | smc911x_reset(ndev); | 2186 | smc911x_reset(ndev); |
2185 | smc911x_enable(ndev); | ||
2186 | if (lp->phy_type != 0) | 2187 | if (lp->phy_type != 0) |
2187 | smc911x_phy_configure(&lp->phy_configure); | 2188 | smc911x_phy_configure(&lp->phy_configure); |
2189 | smc911x_enable(ndev); | ||
2188 | netif_device_attach(ndev); | 2190 | netif_device_attach(ndev); |
2189 | } | 2191 | } |
2190 | } | 2192 | } |
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c index 85f38a6b6a49..68a7f5414133 100644 --- a/drivers/net/ucc_geth_ethtool.c +++ b/drivers/net/ucc_geth_ethtool.c | |||
@@ -323,17 +323,17 @@ static void uec_get_ethtool_stats(struct net_device *netdev, | |||
323 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) { | 323 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) { |
324 | base = (u32 __iomem *)&ugeth->ug_regs->tx64; | 324 | base = (u32 __iomem *)&ugeth->ug_regs->tx64; |
325 | for (i = 0; i < UEC_HW_STATS_LEN; i++) | 325 | for (i = 0; i < UEC_HW_STATS_LEN; i++) |
326 | data[j++] = (u64)in_be32(&base[i]); | 326 | data[j++] = in_be32(&base[i]); |
327 | } | 327 | } |
328 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { | 328 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { |
329 | base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram; | 329 | base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram; |
330 | for (i = 0; i < UEC_TX_FW_STATS_LEN; i++) | 330 | for (i = 0; i < UEC_TX_FW_STATS_LEN; i++) |
331 | data[j++] = (u64)in_be32(&base[i]); | 331 | data[j++] = base ? in_be32(&base[i]) : 0; |
332 | } | 332 | } |
333 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) { | 333 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) { |
334 | base = (u32 __iomem *)ugeth->p_rx_fw_statistics_pram; | 334 | base = (u32 __iomem *)ugeth->p_rx_fw_statistics_pram; |
335 | for (i = 0; i < UEC_RX_FW_STATS_LEN; i++) | 335 | for (i = 0; i < UEC_RX_FW_STATS_LEN; i++) |
336 | data[j++] = (u64)in_be32(&base[i]); | 336 | data[j++] = base ? in_be32(&base[i]) : 0; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c index 37ecf845edfe..e12cdb4543b4 100644 --- a/drivers/net/usb/asix.c +++ b/drivers/net/usb/asix.c | |||
@@ -1444,6 +1444,10 @@ static const struct usb_device_id products [] = { | |||
1444 | // Apple USB Ethernet Adapter | 1444 | // Apple USB Ethernet Adapter |
1445 | USB_DEVICE(0x05ac, 0x1402), | 1445 | USB_DEVICE(0x05ac, 0x1402), |
1446 | .driver_info = (unsigned long) &ax88772_info, | 1446 | .driver_info = (unsigned long) &ax88772_info, |
1447 | }, { | ||
1448 | // Cables-to-Go USB Ethernet Adapter | ||
1449 | USB_DEVICE(0x0b95, 0x772a), | ||
1450 | .driver_info = (unsigned long) &ax88772_info, | ||
1447 | }, | 1451 | }, |
1448 | { }, // END | 1452 | { }, // END |
1449 | }; | 1453 | }; |
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index 3590ea5a902d..11cb3e504e1c 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c | |||
@@ -2296,7 +2296,7 @@ static void velocity_set_multi(struct net_device *dev) | |||
2296 | } | 2296 | } |
2297 | 2297 | ||
2298 | mac_set_cam_mask(regs, vptr->mCAMmask); | 2298 | mac_set_cam_mask(regs, vptr->mCAMmask); |
2299 | rx_mode = (RCR_AM | RCR_AB); | 2299 | rx_mode = RCR_AM | RCR_AB | RCR_AP; |
2300 | } | 2300 | } |
2301 | if (dev->mtu > 1500) | 2301 | if (dev->mtu > 1500) |
2302 | rx_mode |= RCR_AL; | 2302 | rx_mode |= RCR_AL; |
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h index ffdf4876121b..a68f97c39359 100644 --- a/drivers/net/wireless/hostap/hostap_wlan.h +++ b/drivers/net/wireless/hostap/hostap_wlan.h | |||
@@ -918,9 +918,12 @@ struct hostap_interface { | |||
918 | 918 | ||
919 | /* | 919 | /* |
920 | * TX meta data - stored in skb->cb buffer, so this must not be increased over | 920 | * TX meta data - stored in skb->cb buffer, so this must not be increased over |
921 | * the 40-byte limit | 921 | * the 48-byte limit. |
922 | * THE PADDING THIS STARTS WITH IS A HORRIBLE HACK THAT SHOULD NOT LIVE | ||
923 | * TO SEE THE DAY. | ||
922 | */ | 924 | */ |
923 | struct hostap_skb_tx_data { | 925 | struct hostap_skb_tx_data { |
926 | unsigned int __padding_for_default_qdiscs; | ||
924 | u32 magic; /* HOSTAP_SKB_TX_DATA_MAGIC */ | 927 | u32 magic; /* HOSTAP_SKB_TX_DATA_MAGIC */ |
925 | u8 rate; /* transmit rate */ | 928 | u8 rate; /* transmit rate */ |
926 | #define HOSTAP_TX_FLAGS_WDS BIT(0) | 929 | #define HOSTAP_TX_FLAGS_WDS BIT(0) |
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c index 431e3c78bf27..69eb0132593b 100644 --- a/drivers/net/wireless/rtl8187_dev.c +++ b/drivers/net/wireless/rtl8187_dev.c | |||
@@ -48,6 +48,9 @@ static struct usb_device_id rtl8187_table[] __devinitdata = { | |||
48 | {USB_DEVICE(0x03f0, 0xca02), .driver_info = DEVICE_RTL8187}, | 48 | {USB_DEVICE(0x03f0, 0xca02), .driver_info = DEVICE_RTL8187}, |
49 | /* Sitecom */ | 49 | /* Sitecom */ |
50 | {USB_DEVICE(0x0df6, 0x000d), .driver_info = DEVICE_RTL8187}, | 50 | {USB_DEVICE(0x0df6, 0x000d), .driver_info = DEVICE_RTL8187}, |
51 | {USB_DEVICE(0x0df6, 0x0028), .driver_info = DEVICE_RTL8187B}, | ||
52 | /* Abocom */ | ||
53 | {USB_DEVICE(0x13d1, 0xabe6), .driver_info = DEVICE_RTL8187}, | ||
51 | {} | 54 | {} |
52 | }; | 55 | }; |
53 | 56 | ||
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index b3a63edb6901..ae5ec76dca77 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -63,7 +63,7 @@ static acpi_status acpi_run_osc(acpi_handle handle, | |||
63 | union acpi_object in_params[4]; | 63 | union acpi_object in_params[4]; |
64 | struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; | 64 | struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; |
65 | union acpi_object *out_obj; | 65 | union acpi_object *out_obj; |
66 | u32 osc_dw0, flags = osc_args->capbuf[OSC_QUERY_TYPE]; | 66 | u32 errors, flags = osc_args->capbuf[OSC_QUERY_TYPE]; |
67 | 67 | ||
68 | /* Setting up input parameters */ | 68 | /* Setting up input parameters */ |
69 | input.count = 4; | 69 | input.count = 4; |
@@ -92,15 +92,16 @@ static acpi_status acpi_run_osc(acpi_handle handle, | |||
92 | status = AE_TYPE; | 92 | status = AE_TYPE; |
93 | goto out_kfree; | 93 | goto out_kfree; |
94 | } | 94 | } |
95 | osc_dw0 = *((u32 *)out_obj->buffer.pointer); | 95 | /* Need to ignore the bit0 in result code */ |
96 | if (osc_dw0) { | 96 | errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0); |
97 | if (osc_dw0 & OSC_REQUEST_ERROR) | 97 | if (errors) { |
98 | if (errors & OSC_REQUEST_ERROR) | ||
98 | printk(KERN_DEBUG "_OSC request fails\n"); | 99 | printk(KERN_DEBUG "_OSC request fails\n"); |
99 | if (osc_dw0 & OSC_INVALID_UUID_ERROR) | 100 | if (errors & OSC_INVALID_UUID_ERROR) |
100 | printk(KERN_DEBUG "_OSC invalid UUID\n"); | 101 | printk(KERN_DEBUG "_OSC invalid UUID\n"); |
101 | if (osc_dw0 & OSC_INVALID_REVISION_ERROR) | 102 | if (errors & OSC_INVALID_REVISION_ERROR) |
102 | printk(KERN_DEBUG "_OSC invalid revision\n"); | 103 | printk(KERN_DEBUG "_OSC invalid revision\n"); |
103 | if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { | 104 | if (errors & OSC_CAPABILITIES_MASK_ERROR) { |
104 | if (flags & OSC_QUERY_ENABLE) | 105 | if (flags & OSC_QUERY_ENABLE) |
105 | goto out_success; | 106 | goto out_success; |
106 | printk(KERN_DEBUG "_OSC FW not grant req. control\n"); | 107 | printk(KERN_DEBUG "_OSC FW not grant req. control\n"); |
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index dcce9f5d8465..4a110b7b2673 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -351,10 +351,11 @@ int verify_cis_cache(struct pcmcia_socket *s) | |||
351 | char *buf; | 351 | char *buf; |
352 | 352 | ||
353 | buf = kmalloc(256, GFP_KERNEL); | 353 | buf = kmalloc(256, GFP_KERNEL); |
354 | if (buf == NULL) | 354 | if (buf == NULL) { |
355 | dev_printk(KERN_WARNING, &s->dev, | 355 | dev_printk(KERN_WARNING, &s->dev, |
356 | "no memory for verifying CIS\n"); | 356 | "no memory for verifying CIS\n"); |
357 | return -ENOMEM; | 357 | return -ENOMEM; |
358 | } | ||
358 | list_for_each_entry(cis, &s->cis_cache, node) { | 359 | list_for_each_entry(cis, &s->cis_cache, node) { |
359 | int len = cis->len; | 360 | int len = cis->len; |
360 | 361 | ||
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index c68c5d338285..0660ad182589 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c | |||
@@ -186,12 +186,6 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) | |||
186 | 186 | ||
187 | spin_lock_init(&socket->lock); | 187 | spin_lock_init(&socket->lock); |
188 | 188 | ||
189 | if (socket->resource_ops->init) { | ||
190 | ret = socket->resource_ops->init(socket); | ||
191 | if (ret) | ||
192 | return (ret); | ||
193 | } | ||
194 | |||
195 | /* try to obtain a socket number [yes, it gets ugly if we | 189 | /* try to obtain a socket number [yes, it gets ugly if we |
196 | * register more than 2^sizeof(unsigned int) pcmcia | 190 | * register more than 2^sizeof(unsigned int) pcmcia |
197 | * sockets... but the socket number is deprecated | 191 | * sockets... but the socket number is deprecated |
@@ -226,7 +220,7 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) | |||
226 | /* set proper values in socket->dev */ | 220 | /* set proper values in socket->dev */ |
227 | dev_set_drvdata(&socket->dev, socket); | 221 | dev_set_drvdata(&socket->dev, socket); |
228 | socket->dev.class = &pcmcia_socket_class; | 222 | socket->dev.class = &pcmcia_socket_class; |
229 | snprintf(socket->dev.bus_id, BUS_ID_SIZE, "pcmcia_socket%u", socket->sock); | 223 | dev_set_name(&socket->dev, "pcmcia_socket%u", socket->sock); |
230 | 224 | ||
231 | /* base address = 0, map = 0 */ | 225 | /* base address = 0, map = 0 */ |
232 | socket->cis_mem.flags = 0; | 226 | socket->cis_mem.flags = 0; |
@@ -239,6 +233,12 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) | |||
239 | mutex_init(&socket->skt_mutex); | 233 | mutex_init(&socket->skt_mutex); |
240 | spin_lock_init(&socket->thread_lock); | 234 | spin_lock_init(&socket->thread_lock); |
241 | 235 | ||
236 | if (socket->resource_ops->init) { | ||
237 | ret = socket->resource_ops->init(socket); | ||
238 | if (ret) | ||
239 | goto err; | ||
240 | } | ||
241 | |||
242 | tsk = kthread_run(pccardd, socket, "pccardd"); | 242 | tsk = kthread_run(pccardd, socket, "pccardd"); |
243 | if (IS_ERR(tsk)) { | 243 | if (IS_ERR(tsk)) { |
244 | ret = PTR_ERR(tsk); | 244 | ret = PTR_ERR(tsk); |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 795660255490..47cab31ff6e4 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -622,7 +622,6 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f | |||
622 | { | 622 | { |
623 | struct pcmcia_device *p_dev, *tmp_dev; | 623 | struct pcmcia_device *p_dev, *tmp_dev; |
624 | unsigned long flags; | 624 | unsigned long flags; |
625 | int bus_id_len; | ||
626 | 625 | ||
627 | s = pcmcia_get_socket(s); | 626 | s = pcmcia_get_socket(s); |
628 | if (!s) | 627 | if (!s) |
@@ -650,12 +649,12 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f | |||
650 | /* by default don't allow DMA */ | 649 | /* by default don't allow DMA */ |
651 | p_dev->dma_mask = DMA_MASK_NONE; | 650 | p_dev->dma_mask = DMA_MASK_NONE; |
652 | p_dev->dev.dma_mask = &p_dev->dma_mask; | 651 | p_dev->dev.dma_mask = &p_dev->dma_mask; |
653 | bus_id_len = sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); | 652 | dev_set_name(&p_dev->dev, "%d.%d", p_dev->socket->sock, p_dev->device_no); |
654 | 653 | if (!dev_name(&p_dev->dev)) | |
655 | p_dev->devname = kmalloc(6 + bus_id_len + 1, GFP_KERNEL); | 654 | goto err_free; |
655 | p_dev->devname = kasprintf(GFP_KERNEL, "pcmcia%s", dev_name(&p_dev->dev)); | ||
656 | if (!p_dev->devname) | 656 | if (!p_dev->devname) |
657 | goto err_free; | 657 | goto err_free; |
658 | sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); | ||
659 | ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname); | 658 | ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname); |
660 | 659 | ||
661 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 660 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); |
@@ -668,6 +667,8 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f | |||
668 | list_for_each_entry(tmp_dev, &s->devices_list, socket_device_list) | 667 | list_for_each_entry(tmp_dev, &s->devices_list, socket_device_list) |
669 | if (p_dev->func == tmp_dev->func) { | 668 | if (p_dev->func == tmp_dev->func) { |
670 | p_dev->function_config = tmp_dev->function_config; | 669 | p_dev->function_config = tmp_dev->function_config; |
670 | p_dev->io = tmp_dev->io; | ||
671 | p_dev->irq = tmp_dev->irq; | ||
671 | kref_get(&p_dev->function_config->ref); | 672 | kref_get(&p_dev->function_config->ref); |
672 | } | 673 | } |
673 | 674 | ||
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 76d4a98f0955..f5d0ba8e22d5 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -302,9 +302,10 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
302 | /* We only allow changing Vpp1 and Vpp2 to the same value */ | 302 | /* We only allow changing Vpp1 and Vpp2 to the same value */ |
303 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && | 303 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && |
304 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { | 304 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { |
305 | if (mod->Vpp1 != mod->Vpp2) | 305 | if (mod->Vpp1 != mod->Vpp2) { |
306 | ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n"); | 306 | ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n"); |
307 | return -EINVAL; | 307 | return -EINVAL; |
308 | } | ||
308 | s->socket.Vpp = mod->Vpp1; | 309 | s->socket.Vpp = mod->Vpp1; |
309 | if (s->ops->set_socket(s, &s->socket)) { | 310 | if (s->ops->set_socket(s, &s->socket)) { |
310 | dev_printk(KERN_WARNING, &s->dev, | 311 | dev_printk(KERN_WARNING, &s->dev, |
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 17f4ecf1c0c5..9ca22c7aafb2 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -71,7 +71,7 @@ static DEFINE_MUTEX(rsrc_mutex); | |||
71 | ======================================================================*/ | 71 | ======================================================================*/ |
72 | 72 | ||
73 | static struct resource * | 73 | static struct resource * |
74 | make_resource(resource_size_t b, resource_size_t n, int flags, char *name) | 74 | make_resource(resource_size_t b, resource_size_t n, int flags, const char *name) |
75 | { | 75 | { |
76 | struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); | 76 | struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); |
77 | 77 | ||
@@ -624,7 +624,7 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star | |||
624 | static struct resource *nonstatic_find_io_region(unsigned long base, int num, | 624 | static struct resource *nonstatic_find_io_region(unsigned long base, int num, |
625 | unsigned long align, struct pcmcia_socket *s) | 625 | unsigned long align, struct pcmcia_socket *s) |
626 | { | 626 | { |
627 | struct resource *res = make_resource(0, num, IORESOURCE_IO, s->dev.bus_id); | 627 | struct resource *res = make_resource(0, num, IORESOURCE_IO, dev_name(&s->dev)); |
628 | struct socket_data *s_data = s->resource_data; | 628 | struct socket_data *s_data = s->resource_data; |
629 | struct pcmcia_align_data data; | 629 | struct pcmcia_align_data data; |
630 | unsigned long min = base; | 630 | unsigned long min = base; |
@@ -658,7 +658,7 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num, | |||
658 | static struct resource * nonstatic_find_mem_region(u_long base, u_long num, | 658 | static struct resource * nonstatic_find_mem_region(u_long base, u_long num, |
659 | u_long align, int low, struct pcmcia_socket *s) | 659 | u_long align, int low, struct pcmcia_socket *s) |
660 | { | 660 | { |
661 | struct resource *res = make_resource(0, num, IORESOURCE_MEM, s->dev.bus_id); | 661 | struct resource *res = make_resource(0, num, IORESOURCE_MEM, dev_name(&s->dev)); |
662 | struct socket_data *s_data = s->resource_data; | 662 | struct socket_data *s_data = s->resource_data; |
663 | struct pcmcia_align_data data; | 663 | struct pcmcia_align_data data; |
664 | unsigned long min, max; | 664 | unsigned long min, max; |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 8abbb2020af9..123092d8a984 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -277,6 +277,14 @@ config RTC_DRV_FM3130 | |||
277 | This driver can also be built as a module. If so the module | 277 | This driver can also be built as a module. If so the module |
278 | will be called rtc-fm3130. | 278 | will be called rtc-fm3130. |
279 | 279 | ||
280 | config RTC_DRV_RX8581 | ||
281 | tristate "Epson RX-8581" | ||
282 | help | ||
283 | If you say yes here you will get support for the Epson RX-8581. | ||
284 | |||
285 | This driver can also be built as a module. If so the module | ||
286 | will be called rtc-rx8581. | ||
287 | |||
280 | endif # I2C | 288 | endif # I2C |
281 | 289 | ||
282 | comment "SPI RTC drivers" | 290 | comment "SPI RTC drivers" |
@@ -302,6 +310,17 @@ config RTC_DRV_DS1305 | |||
302 | This driver can also be built as a module. If so, the module | 310 | This driver can also be built as a module. If so, the module |
303 | will be called rtc-ds1305. | 311 | will be called rtc-ds1305. |
304 | 312 | ||
313 | config RTC_DRV_DS1390 | ||
314 | tristate "Dallas/Maxim DS1390/93/94" | ||
315 | help | ||
316 | If you say yes here you get support for the DS1390/93/94 chips. | ||
317 | |||
318 | This driver only supports the RTC feature, and not other chip | ||
319 | features such as alarms and trickle charging. | ||
320 | |||
321 | This driver can also be built as a module. If so, the module | ||
322 | will be called rtc-ds1390. | ||
323 | |||
305 | config RTC_DRV_MAX6902 | 324 | config RTC_DRV_MAX6902 |
306 | tristate "Maxim MAX6902" | 325 | tristate "Maxim MAX6902" |
307 | help | 326 | help |
@@ -468,6 +487,16 @@ config RTC_DRV_V3020 | |||
468 | This driver can also be built as a module. If so, the module | 487 | This driver can also be built as a module. If so, the module |
469 | will be called rtc-v3020. | 488 | will be called rtc-v3020. |
470 | 489 | ||
490 | config RTC_DRV_WM8350 | ||
491 | tristate "Wolfson Microelectronics WM8350 RTC" | ||
492 | depends on MFD_WM8350 | ||
493 | help | ||
494 | If you say yes here you will get support for the RTC subsystem | ||
495 | of the Wolfson Microelectronics WM8350. | ||
496 | |||
497 | This driver can also be built as a module. If so, the module | ||
498 | will be called "rtc-wm8350". | ||
499 | |||
471 | comment "on-CPU RTC drivers" | 500 | comment "on-CPU RTC drivers" |
472 | 501 | ||
473 | config RTC_DRV_OMAP | 502 | config RTC_DRV_OMAP |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index e9e8474cc8fe..6e79c912bf9e 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -28,6 +28,7 @@ obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o | |||
28 | obj-$(CONFIG_RTC_DRV_DS1305) += rtc-ds1305.o | 28 | obj-$(CONFIG_RTC_DRV_DS1305) += rtc-ds1305.o |
29 | obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o | 29 | obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o |
30 | obj-$(CONFIG_RTC_DRV_DS1374) += rtc-ds1374.o | 30 | obj-$(CONFIG_RTC_DRV_DS1374) += rtc-ds1374.o |
31 | obj-$(CONFIG_RTC_DRV_DS1390) += rtc-ds1390.o | ||
31 | obj-$(CONFIG_RTC_DRV_DS1511) += rtc-ds1511.o | 32 | obj-$(CONFIG_RTC_DRV_DS1511) += rtc-ds1511.o |
32 | obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o | 33 | obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o |
33 | obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o | 34 | obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o |
@@ -57,6 +58,7 @@ obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o | |||
57 | obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o | 58 | obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o |
58 | obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o | 59 | obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o |
59 | obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o | 60 | obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o |
61 | obj-$(CONFIG_RTC_DRV_RX8581) += rtc-rx8581.o | ||
60 | obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o | 62 | obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o |
61 | obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o | 63 | obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o |
62 | obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o | 64 | obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o |
@@ -66,4 +68,5 @@ obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o | |||
66 | obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl4030.o | 68 | obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl4030.o |
67 | obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o | 69 | obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o |
68 | obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o | 70 | obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o |
71 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o | ||
69 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o | 72 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o |
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c new file mode 100644 index 000000000000..599e976bf014 --- /dev/null +++ b/drivers/rtc/rtc-ds1390.c | |||
@@ -0,0 +1,220 @@ | |||
1 | /* | ||
2 | * rtc-ds1390.c -- driver for DS1390/93/94 | ||
3 | * | ||
4 | * Copyright (C) 2008 Mercury IMC Ltd | ||
5 | * Written by Mark Jackson <mpfj@mimc.co.uk> | ||
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 version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * NOTE : Currently this driver only supports the bare minimum for read | ||
12 | * and write the RTC. The extra features provided by the chip family | ||
13 | * (alarms, trickle charger, different control registers) are unavailable. | ||
14 | */ | ||
15 | |||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/rtc.h> | ||
18 | #include <linux/spi/spi.h> | ||
19 | #include <linux/bcd.h> | ||
20 | |||
21 | #define DS1390_REG_100THS 0x00 | ||
22 | #define DS1390_REG_SECONDS 0x01 | ||
23 | #define DS1390_REG_MINUTES 0x02 | ||
24 | #define DS1390_REG_HOURS 0x03 | ||
25 | #define DS1390_REG_DAY 0x04 | ||
26 | #define DS1390_REG_DATE 0x05 | ||
27 | #define DS1390_REG_MONTH_CENT 0x06 | ||
28 | #define DS1390_REG_YEAR 0x07 | ||
29 | |||
30 | #define DS1390_REG_ALARM_100THS 0x08 | ||
31 | #define DS1390_REG_ALARM_SECONDS 0x09 | ||
32 | #define DS1390_REG_ALARM_MINUTES 0x0A | ||
33 | #define DS1390_REG_ALARM_HOURS 0x0B | ||
34 | #define DS1390_REG_ALARM_DAY_DATE 0x0C | ||
35 | |||
36 | #define DS1390_REG_CONTROL 0x0D | ||
37 | #define DS1390_REG_STATUS 0x0E | ||
38 | #define DS1390_REG_TRICKLE 0x0F | ||
39 | |||
40 | struct ds1390 { | ||
41 | struct rtc_device *rtc; | ||
42 | u8 txrx_buf[9]; /* cmd + 8 registers */ | ||
43 | }; | ||
44 | |||
45 | static void ds1390_set_reg(struct device *dev, unsigned char address, | ||
46 | unsigned char data) | ||
47 | { | ||
48 | struct spi_device *spi = to_spi_device(dev); | ||
49 | struct ds1390 *chip = dev_get_drvdata(dev); | ||
50 | |||
51 | /* Set MSB to indicate write */ | ||
52 | chip->txrx_buf[0] = address | 0x80; | ||
53 | chip->txrx_buf[1] = data; | ||
54 | |||
55 | /* do the i/o */ | ||
56 | spi_write_then_read(spi, chip->txrx_buf, 2, NULL, 0); | ||
57 | } | ||
58 | |||
59 | static int ds1390_get_reg(struct device *dev, unsigned char address, | ||
60 | unsigned char *data) | ||
61 | { | ||
62 | struct spi_device *spi = to_spi_device(dev); | ||
63 | struct ds1390 *chip = dev_get_drvdata(dev); | ||
64 | int status; | ||
65 | |||
66 | if (!data) | ||
67 | return -EINVAL; | ||
68 | |||
69 | /* Clear MSB to indicate read */ | ||
70 | chip->txrx_buf[0] = address & 0x7f; | ||
71 | /* do the i/o */ | ||
72 | status = spi_write_then_read(spi, chip->txrx_buf, 1, chip->txrx_buf, 1); | ||
73 | if (status != 0) | ||
74 | return status; | ||
75 | |||
76 | *data = chip->txrx_buf[1]; | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int ds1390_get_datetime(struct device *dev, struct rtc_time *dt) | ||
82 | { | ||
83 | struct spi_device *spi = to_spi_device(dev); | ||
84 | struct ds1390 *chip = dev_get_drvdata(dev); | ||
85 | int status; | ||
86 | |||
87 | /* build the message */ | ||
88 | chip->txrx_buf[0] = DS1390_REG_SECONDS; | ||
89 | |||
90 | /* do the i/o */ | ||
91 | status = spi_write_then_read(spi, chip->txrx_buf, 1, chip->txrx_buf, 8); | ||
92 | if (status != 0) | ||
93 | return status; | ||
94 | |||
95 | /* The chip sends data in this order: | ||
96 | * Seconds, Minutes, Hours, Day, Date, Month / Century, Year */ | ||
97 | dt->tm_sec = bcd2bin(chip->txrx_buf[0]); | ||
98 | dt->tm_min = bcd2bin(chip->txrx_buf[1]); | ||
99 | dt->tm_hour = bcd2bin(chip->txrx_buf[2]); | ||
100 | dt->tm_wday = bcd2bin(chip->txrx_buf[3]); | ||
101 | dt->tm_mday = bcd2bin(chip->txrx_buf[4]); | ||
102 | /* mask off century bit */ | ||
103 | dt->tm_mon = bcd2bin(chip->txrx_buf[5] & 0x7f) - 1; | ||
104 | /* adjust for century bit */ | ||
105 | dt->tm_year = bcd2bin(chip->txrx_buf[6]) + ((chip->txrx_buf[5] & 0x80) ? 100 : 0); | ||
106 | |||
107 | return rtc_valid_tm(dt); | ||
108 | } | ||
109 | |||
110 | static int ds1390_set_datetime(struct device *dev, struct rtc_time *dt) | ||
111 | { | ||
112 | struct spi_device *spi = to_spi_device(dev); | ||
113 | struct ds1390 *chip = dev_get_drvdata(dev); | ||
114 | |||
115 | /* build the message */ | ||
116 | chip->txrx_buf[0] = DS1390_REG_SECONDS | 0x80; | ||
117 | chip->txrx_buf[1] = bin2bcd(dt->tm_sec); | ||
118 | chip->txrx_buf[2] = bin2bcd(dt->tm_min); | ||
119 | chip->txrx_buf[3] = bin2bcd(dt->tm_hour); | ||
120 | chip->txrx_buf[4] = bin2bcd(dt->tm_wday); | ||
121 | chip->txrx_buf[5] = bin2bcd(dt->tm_mday); | ||
122 | chip->txrx_buf[6] = bin2bcd(dt->tm_mon + 1) | | ||
123 | ((dt->tm_year > 99) ? 0x80 : 0x00); | ||
124 | chip->txrx_buf[7] = bin2bcd(dt->tm_year % 100); | ||
125 | |||
126 | /* do the i/o */ | ||
127 | return spi_write_then_read(spi, chip->txrx_buf, 8, NULL, 0); | ||
128 | } | ||
129 | |||
130 | static int ds1390_read_time(struct device *dev, struct rtc_time *tm) | ||
131 | { | ||
132 | return ds1390_get_datetime(dev, tm); | ||
133 | } | ||
134 | |||
135 | static int ds1390_set_time(struct device *dev, struct rtc_time *tm) | ||
136 | { | ||
137 | return ds1390_set_datetime(dev, tm); | ||
138 | } | ||
139 | |||
140 | static const struct rtc_class_ops ds1390_rtc_ops = { | ||
141 | .read_time = ds1390_read_time, | ||
142 | .set_time = ds1390_set_time, | ||
143 | }; | ||
144 | |||
145 | static int __devinit ds1390_probe(struct spi_device *spi) | ||
146 | { | ||
147 | struct rtc_device *rtc; | ||
148 | unsigned char tmp; | ||
149 | struct ds1390 *chip; | ||
150 | int res; | ||
151 | |||
152 | printk(KERN_DEBUG "DS1390 SPI RTC driver\n"); | ||
153 | |||
154 | rtc = rtc_device_register("ds1390", | ||
155 | &spi->dev, &ds1390_rtc_ops, THIS_MODULE); | ||
156 | if (IS_ERR(rtc)) { | ||
157 | printk(KERN_ALERT "RTC : unable to register device\n"); | ||
158 | return PTR_ERR(rtc); | ||
159 | } | ||
160 | |||
161 | spi->mode = SPI_MODE_3; | ||
162 | spi->bits_per_word = 8; | ||
163 | spi_setup(spi); | ||
164 | |||
165 | chip = kzalloc(sizeof *chip, GFP_KERNEL); | ||
166 | if (!chip) { | ||
167 | printk(KERN_ALERT "RTC : unable to allocate device memory\n"); | ||
168 | rtc_device_unregister(rtc); | ||
169 | return -ENOMEM; | ||
170 | } | ||
171 | chip->rtc = rtc; | ||
172 | dev_set_drvdata(&spi->dev, chip); | ||
173 | |||
174 | res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp); | ||
175 | if (res) { | ||
176 | printk(KERN_ALERT "RTC : unable to read device\n"); | ||
177 | rtc_device_unregister(rtc); | ||
178 | return res; | ||
179 | } | ||
180 | |||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | static int __devexit ds1390_remove(struct spi_device *spi) | ||
185 | { | ||
186 | struct ds1390 *chip = platform_get_drvdata(spi); | ||
187 | struct rtc_device *rtc = chip->rtc; | ||
188 | |||
189 | if (rtc) | ||
190 | rtc_device_unregister(rtc); | ||
191 | |||
192 | kfree(chip); | ||
193 | |||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static struct spi_driver ds1390_driver = { | ||
198 | .driver = { | ||
199 | .name = "rtc-ds1390", | ||
200 | .owner = THIS_MODULE, | ||
201 | }, | ||
202 | .probe = ds1390_probe, | ||
203 | .remove = __devexit_p(ds1390_remove), | ||
204 | }; | ||
205 | |||
206 | static __init int ds1390_init(void) | ||
207 | { | ||
208 | return spi_register_driver(&ds1390_driver); | ||
209 | } | ||
210 | module_init(ds1390_init); | ||
211 | |||
212 | static __exit void ds1390_exit(void) | ||
213 | { | ||
214 | spi_unregister_driver(&ds1390_driver); | ||
215 | } | ||
216 | module_exit(ds1390_exit); | ||
217 | |||
218 | MODULE_DESCRIPTION("DS1390/93/94 SPI RTC driver"); | ||
219 | MODULE_AUTHOR("Mark Jackson <mpfj@mimc.co.uk>"); | ||
220 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c new file mode 100644 index 000000000000..c9522f3bc21c --- /dev/null +++ b/drivers/rtc/rtc-rx8581.c | |||
@@ -0,0 +1,281 @@ | |||
1 | /* | ||
2 | * An I2C driver for the Epson RX8581 RTC | ||
3 | * | ||
4 | * Author: Martyn Welch <martyn.welch@gefanuc.com> | ||
5 | * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc. | ||
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 version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * Based on: rtc-pcf8563.c (An I2C driver for the Philips PCF8563 RTC) | ||
12 | * Copyright 2005-06 Tower Technologies | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/i2c.h> | ||
17 | #include <linux/bcd.h> | ||
18 | #include <linux/rtc.h> | ||
19 | #include <linux/log2.h> | ||
20 | |||
21 | #define DRV_VERSION "0.1" | ||
22 | |||
23 | #define RX8581_REG_SC 0x00 /* Second in BCD */ | ||
24 | #define RX8581_REG_MN 0x01 /* Minute in BCD */ | ||
25 | #define RX8581_REG_HR 0x02 /* Hour in BCD */ | ||
26 | #define RX8581_REG_DW 0x03 /* Day of Week */ | ||
27 | #define RX8581_REG_DM 0x04 /* Day of Month in BCD */ | ||
28 | #define RX8581_REG_MO 0x05 /* Month in BCD */ | ||
29 | #define RX8581_REG_YR 0x06 /* Year in BCD */ | ||
30 | #define RX8581_REG_RAM 0x07 /* RAM */ | ||
31 | #define RX8581_REG_AMN 0x08 /* Alarm Min in BCD*/ | ||
32 | #define RX8581_REG_AHR 0x09 /* Alarm Hour in BCD */ | ||
33 | #define RX8581_REG_ADM 0x0A | ||
34 | #define RX8581_REG_ADW 0x0A | ||
35 | #define RX8581_REG_TMR0 0x0B | ||
36 | #define RX8581_REG_TMR1 0x0C | ||
37 | #define RX8581_REG_EXT 0x0D /* Extension Register */ | ||
38 | #define RX8581_REG_FLAG 0x0E /* Flag Register */ | ||
39 | #define RX8581_REG_CTRL 0x0F /* Control Register */ | ||
40 | |||
41 | |||
42 | /* Flag Register bit definitions */ | ||
43 | #define RX8581_FLAG_UF 0x20 /* Update */ | ||
44 | #define RX8581_FLAG_TF 0x10 /* Timer */ | ||
45 | #define RX8581_FLAG_AF 0x08 /* Alarm */ | ||
46 | #define RX8581_FLAG_VLF 0x02 /* Voltage Low */ | ||
47 | |||
48 | /* Control Register bit definitions */ | ||
49 | #define RX8581_CTRL_UIE 0x20 /* Update Interrupt Enable */ | ||
50 | #define RX8581_CTRL_TIE 0x10 /* Timer Interrupt Enable */ | ||
51 | #define RX8581_CTRL_AIE 0x08 /* Alarm Interrupt Enable */ | ||
52 | #define RX8581_CTRL_STOP 0x02 /* STOP bit */ | ||
53 | #define RX8581_CTRL_RESET 0x01 /* RESET bit */ | ||
54 | |||
55 | static struct i2c_driver rx8581_driver; | ||
56 | |||
57 | /* | ||
58 | * In the routines that deal directly with the rx8581 hardware, we use | ||
59 | * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch. | ||
60 | */ | ||
61 | static int rx8581_get_datetime(struct i2c_client *client, struct rtc_time *tm) | ||
62 | { | ||
63 | unsigned char date[7]; | ||
64 | int data, err; | ||
65 | |||
66 | /* First we ensure that the "update flag" is not set, we read the | ||
67 | * time and date then re-read the "update flag". If the update flag | ||
68 | * has been set, we know that the time has changed during the read so | ||
69 | * we repeat the whole process again. | ||
70 | */ | ||
71 | data = i2c_smbus_read_byte_data(client, RX8581_REG_FLAG); | ||
72 | if (data < 0) { | ||
73 | dev_err(&client->dev, "Unable to read device flags\n"); | ||
74 | return -EIO; | ||
75 | } | ||
76 | |||
77 | do { | ||
78 | /* If update flag set, clear it */ | ||
79 | if (data & RX8581_FLAG_UF) { | ||
80 | err = i2c_smbus_write_byte_data(client, | ||
81 | RX8581_REG_FLAG, (data & ~RX8581_FLAG_UF)); | ||
82 | if (err != 0) { | ||
83 | dev_err(&client->dev, "Unable to write device " | ||
84 | "flags\n"); | ||
85 | return -EIO; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | /* Now read time and date */ | ||
90 | err = i2c_smbus_read_i2c_block_data(client, RX8581_REG_SC, | ||
91 | 7, date); | ||
92 | if (err < 0) { | ||
93 | dev_err(&client->dev, "Unable to read date\n"); | ||
94 | return -EIO; | ||
95 | } | ||
96 | |||
97 | /* Check flag register */ | ||
98 | data = i2c_smbus_read_byte_data(client, RX8581_REG_FLAG); | ||
99 | if (data < 0) { | ||
100 | dev_err(&client->dev, "Unable to read device flags\n"); | ||
101 | return -EIO; | ||
102 | } | ||
103 | } while (data & RX8581_FLAG_UF); | ||
104 | |||
105 | if (data & RX8581_FLAG_VLF) | ||
106 | dev_info(&client->dev, | ||
107 | "low voltage detected, date/time is not reliable.\n"); | ||
108 | |||
109 | dev_dbg(&client->dev, | ||
110 | "%s: raw data is sec=%02x, min=%02x, hr=%02x, " | ||
111 | "wday=%02x, mday=%02x, mon=%02x, year=%02x\n", | ||
112 | __func__, | ||
113 | date[0], date[1], date[2], date[3], date[4], date[5], date[6]); | ||
114 | |||
115 | tm->tm_sec = bcd2bin(date[RX8581_REG_SC] & 0x7F); | ||
116 | tm->tm_min = bcd2bin(date[RX8581_REG_MN] & 0x7F); | ||
117 | tm->tm_hour = bcd2bin(date[RX8581_REG_HR] & 0x3F); /* rtc hr 0-23 */ | ||
118 | tm->tm_wday = ilog2(date[RX8581_REG_DW] & 0x7F); | ||
119 | tm->tm_mday = bcd2bin(date[RX8581_REG_DM] & 0x3F); | ||
120 | tm->tm_mon = bcd2bin(date[RX8581_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ | ||
121 | tm->tm_year = bcd2bin(date[RX8581_REG_YR]); | ||
122 | if (tm->tm_year < 70) | ||
123 | tm->tm_year += 100; /* assume we are in 1970...2069 */ | ||
124 | |||
125 | |||
126 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | ||
127 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
128 | __func__, | ||
129 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
130 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
131 | |||
132 | err = rtc_valid_tm(tm); | ||
133 | if (err < 0) | ||
134 | dev_err(&client->dev, "retrieved date/time is not valid.\n"); | ||
135 | |||
136 | return err; | ||
137 | } | ||
138 | |||
139 | static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm) | ||
140 | { | ||
141 | int data, err; | ||
142 | unsigned char buf[7]; | ||
143 | |||
144 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " | ||
145 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
146 | __func__, | ||
147 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
148 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
149 | |||
150 | /* hours, minutes and seconds */ | ||
151 | buf[RX8581_REG_SC] = bin2bcd(tm->tm_sec); | ||
152 | buf[RX8581_REG_MN] = bin2bcd(tm->tm_min); | ||
153 | buf[RX8581_REG_HR] = bin2bcd(tm->tm_hour); | ||
154 | |||
155 | buf[RX8581_REG_DM] = bin2bcd(tm->tm_mday); | ||
156 | |||
157 | /* month, 1 - 12 */ | ||
158 | buf[RX8581_REG_MO] = bin2bcd(tm->tm_mon + 1); | ||
159 | |||
160 | /* year and century */ | ||
161 | buf[RX8581_REG_YR] = bin2bcd(tm->tm_year % 100); | ||
162 | buf[RX8581_REG_DW] = (0x1 << tm->tm_wday); | ||
163 | |||
164 | /* Stop the clock */ | ||
165 | data = i2c_smbus_read_byte_data(client, RX8581_REG_CTRL); | ||
166 | if (data < 0) { | ||
167 | dev_err(&client->dev, "Unable to read control register\n"); | ||
168 | return -EIO; | ||
169 | } | ||
170 | |||
171 | err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, | ||
172 | (data | RX8581_CTRL_STOP)); | ||
173 | if (err < 0) { | ||
174 | dev_err(&client->dev, "Unable to write control register\n"); | ||
175 | return -EIO; | ||
176 | } | ||
177 | |||
178 | /* write register's data */ | ||
179 | err = i2c_smbus_write_i2c_block_data(client, RX8581_REG_SC, 7, buf); | ||
180 | if (err < 0) { | ||
181 | dev_err(&client->dev, "Unable to write to date registers\n"); | ||
182 | return -EIO; | ||
183 | } | ||
184 | |||
185 | /* Restart the clock */ | ||
186 | data = i2c_smbus_read_byte_data(client, RX8581_REG_CTRL); | ||
187 | if (data < 0) { | ||
188 | dev_err(&client->dev, "Unable to read control register\n"); | ||
189 | return -EIO; | ||
190 | } | ||
191 | |||
192 | err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, | ||
193 | (data | ~(RX8581_CTRL_STOP))); | ||
194 | if (err != 0) { | ||
195 | dev_err(&client->dev, "Unable to write control register\n"); | ||
196 | return -EIO; | ||
197 | } | ||
198 | |||
199 | return 0; | ||
200 | } | ||
201 | |||
202 | static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
203 | { | ||
204 | return rx8581_get_datetime(to_i2c_client(dev), tm); | ||
205 | } | ||
206 | |||
207 | static int rx8581_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
208 | { | ||
209 | return rx8581_set_datetime(to_i2c_client(dev), tm); | ||
210 | } | ||
211 | |||
212 | static const struct rtc_class_ops rx8581_rtc_ops = { | ||
213 | .read_time = rx8581_rtc_read_time, | ||
214 | .set_time = rx8581_rtc_set_time, | ||
215 | }; | ||
216 | |||
217 | static int __devinit rx8581_probe(struct i2c_client *client, | ||
218 | const struct i2c_device_id *id) | ||
219 | { | ||
220 | struct rtc_device *rtc; | ||
221 | |||
222 | dev_dbg(&client->dev, "%s\n", __func__); | ||
223 | |||
224 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | ||
225 | return -ENODEV; | ||
226 | |||
227 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | ||
228 | |||
229 | rtc = rtc_device_register(rx8581_driver.driver.name, | ||
230 | &client->dev, &rx8581_rtc_ops, THIS_MODULE); | ||
231 | |||
232 | if (IS_ERR(rtc)) | ||
233 | return PTR_ERR(rtc); | ||
234 | |||
235 | i2c_set_clientdata(client, rtc); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int __devexit rx8581_remove(struct i2c_client *client) | ||
241 | { | ||
242 | struct rtc_device *rtc = i2c_get_clientdata(client); | ||
243 | |||
244 | rtc_device_unregister(rtc); | ||
245 | |||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | static const struct i2c_device_id rx8581_id[] = { | ||
250 | { "rx8581", 0 }, | ||
251 | { } | ||
252 | }; | ||
253 | MODULE_DEVICE_TABLE(i2c, rx8581_id); | ||
254 | |||
255 | static struct i2c_driver rx8581_driver = { | ||
256 | .driver = { | ||
257 | .name = "rtc-rx8581", | ||
258 | .owner = THIS_MODULE, | ||
259 | }, | ||
260 | .probe = rx8581_probe, | ||
261 | .remove = __devexit_p(rx8581_remove), | ||
262 | .id_table = rx8581_id, | ||
263 | }; | ||
264 | |||
265 | static int __init rx8581_init(void) | ||
266 | { | ||
267 | return i2c_add_driver(&rx8581_driver); | ||
268 | } | ||
269 | |||
270 | static void __exit rx8581_exit(void) | ||
271 | { | ||
272 | i2c_del_driver(&rx8581_driver); | ||
273 | } | ||
274 | |||
275 | MODULE_AUTHOR("Martyn Welch <martyn.welch@gefanuc.com>"); | ||
276 | MODULE_DESCRIPTION("Epson RX-8581 RTC driver"); | ||
277 | MODULE_LICENSE("GPL"); | ||
278 | MODULE_VERSION(DRV_VERSION); | ||
279 | |||
280 | module_init(rx8581_init); | ||
281 | module_exit(rx8581_exit); | ||
diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c index 2012ccbb4a53..5b2261052a65 100644 --- a/drivers/rtc/rtc-sun4v.c +++ b/drivers/rtc/rtc-sun4v.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* rtc-sun4c.c: Hypervisor based RTC for SUN4V systems. | 1 | /* rtc-sun4v.c: Hypervisor based RTC for SUN4V systems. |
2 | * | 2 | * |
3 | * Copyright (C) 2008 David S. Miller <davem@davemloft.net> | 3 | * Copyright (C) 2008 David S. Miller <davem@davemloft.net> |
4 | */ | 4 | */ |
@@ -7,21 +7,11 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/time.h> | ||
11 | #include <linux/rtc.h> | 10 | #include <linux/rtc.h> |
12 | #include <linux/platform_device.h> | 11 | #include <linux/platform_device.h> |
13 | 12 | ||
14 | #include <asm/hypervisor.h> | 13 | #include <asm/hypervisor.h> |
15 | 14 | ||
16 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | ||
17 | MODULE_DESCRIPTION("SUN4V RTC driver"); | ||
18 | MODULE_LICENSE("GPL"); | ||
19 | |||
20 | struct sun4v_rtc { | ||
21 | struct rtc_device *rtc; | ||
22 | spinlock_t lock; | ||
23 | }; | ||
24 | |||
25 | static unsigned long hypervisor_get_time(void) | 15 | static unsigned long hypervisor_get_time(void) |
26 | { | 16 | { |
27 | unsigned long ret, time; | 17 | unsigned long ret, time; |
@@ -45,15 +35,7 @@ retry: | |||
45 | 35 | ||
46 | static int sun4v_read_time(struct device *dev, struct rtc_time *tm) | 36 | static int sun4v_read_time(struct device *dev, struct rtc_time *tm) |
47 | { | 37 | { |
48 | struct sun4v_rtc *p = dev_get_drvdata(dev); | 38 | rtc_time_to_tm(hypervisor_get_time(), tm); |
49 | unsigned long flags, secs; | ||
50 | |||
51 | spin_lock_irqsave(&p->lock, flags); | ||
52 | secs = hypervisor_get_time(); | ||
53 | spin_unlock_irqrestore(&p->lock, flags); | ||
54 | |||
55 | rtc_time_to_tm(secs, tm); | ||
56 | |||
57 | return 0; | 39 | return 0; |
58 | } | 40 | } |
59 | 41 | ||
@@ -80,19 +62,14 @@ retry: | |||
80 | 62 | ||
81 | static int sun4v_set_time(struct device *dev, struct rtc_time *tm) | 63 | static int sun4v_set_time(struct device *dev, struct rtc_time *tm) |
82 | { | 64 | { |
83 | struct sun4v_rtc *p = dev_get_drvdata(dev); | 65 | unsigned long secs; |
84 | unsigned long flags, secs; | ||
85 | int err; | 66 | int err; |
86 | 67 | ||
87 | err = rtc_tm_to_time(tm, &secs); | 68 | err = rtc_tm_to_time(tm, &secs); |
88 | if (err) | 69 | if (err) |
89 | return err; | 70 | return err; |
90 | 71 | ||
91 | spin_lock_irqsave(&p->lock, flags); | 72 | return hypervisor_set_time(secs); |
92 | err = hypervisor_set_time(secs); | ||
93 | spin_unlock_irqrestore(&p->lock, flags); | ||
94 | |||
95 | return err; | ||
96 | } | 73 | } |
97 | 74 | ||
98 | static const struct rtc_class_ops sun4v_rtc_ops = { | 75 | static const struct rtc_class_ops sun4v_rtc_ops = { |
@@ -100,33 +77,22 @@ static const struct rtc_class_ops sun4v_rtc_ops = { | |||
100 | .set_time = sun4v_set_time, | 77 | .set_time = sun4v_set_time, |
101 | }; | 78 | }; |
102 | 79 | ||
103 | static int __devinit sun4v_rtc_probe(struct platform_device *pdev) | 80 | static int __init sun4v_rtc_probe(struct platform_device *pdev) |
104 | { | 81 | { |
105 | struct sun4v_rtc *p = kzalloc(sizeof(*p), GFP_KERNEL); | 82 | struct rtc_device *rtc = rtc_device_register("sun4v", &pdev->dev, |
106 | |||
107 | if (!p) | ||
108 | return -ENOMEM; | ||
109 | |||
110 | spin_lock_init(&p->lock); | ||
111 | |||
112 | p->rtc = rtc_device_register("sun4v", &pdev->dev, | ||
113 | &sun4v_rtc_ops, THIS_MODULE); | 83 | &sun4v_rtc_ops, THIS_MODULE); |
114 | if (IS_ERR(p->rtc)) { | 84 | if (IS_ERR(rtc)) |
115 | int err = PTR_ERR(p->rtc); | 85 | return PTR_ERR(rtc); |
116 | kfree(p); | 86 | |
117 | return err; | 87 | platform_set_drvdata(pdev, rtc); |
118 | } | ||
119 | platform_set_drvdata(pdev, p); | ||
120 | return 0; | 88 | return 0; |
121 | } | 89 | } |
122 | 90 | ||
123 | static int __devexit sun4v_rtc_remove(struct platform_device *pdev) | 91 | static int __exit sun4v_rtc_remove(struct platform_device *pdev) |
124 | { | 92 | { |
125 | struct sun4v_rtc *p = platform_get_drvdata(pdev); | 93 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
126 | |||
127 | rtc_device_unregister(p->rtc); | ||
128 | kfree(p); | ||
129 | 94 | ||
95 | rtc_device_unregister(rtc); | ||
130 | return 0; | 96 | return 0; |
131 | } | 97 | } |
132 | 98 | ||
@@ -135,13 +101,12 @@ static struct platform_driver sun4v_rtc_driver = { | |||
135 | .name = "rtc-sun4v", | 101 | .name = "rtc-sun4v", |
136 | .owner = THIS_MODULE, | 102 | .owner = THIS_MODULE, |
137 | }, | 103 | }, |
138 | .probe = sun4v_rtc_probe, | 104 | .remove = __exit_p(sun4v_rtc_remove), |
139 | .remove = __devexit_p(sun4v_rtc_remove), | ||
140 | }; | 105 | }; |
141 | 106 | ||
142 | static int __init sun4v_rtc_init(void) | 107 | static int __init sun4v_rtc_init(void) |
143 | { | 108 | { |
144 | return platform_driver_register(&sun4v_rtc_driver); | 109 | return platform_driver_probe(&sun4v_rtc_driver, sun4v_rtc_probe); |
145 | } | 110 | } |
146 | 111 | ||
147 | static void __exit sun4v_rtc_exit(void) | 112 | static void __exit sun4v_rtc_exit(void) |
@@ -151,3 +116,7 @@ static void __exit sun4v_rtc_exit(void) | |||
151 | 116 | ||
152 | module_init(sun4v_rtc_init); | 117 | module_init(sun4v_rtc_init); |
153 | module_exit(sun4v_rtc_exit); | 118 | module_exit(sun4v_rtc_exit); |
119 | |||
120 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | ||
121 | MODULE_DESCRIPTION("SUN4V RTC driver"); | ||
122 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c new file mode 100644 index 000000000000..5c5e3aa91385 --- /dev/null +++ b/drivers/rtc/rtc-wm8350.c | |||
@@ -0,0 +1,514 @@ | |||
1 | /* | ||
2 | * Real Time Clock driver for Wolfson Microelectronics WM8350 | ||
3 | * | ||
4 | * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. | ||
5 | * | ||
6 | * Author: Liam Girdwood | ||
7 | * linux@wolfsonmicro.com | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/time.h> | ||
19 | #include <linux/rtc.h> | ||
20 | #include <linux/bcd.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/ioctl.h> | ||
23 | #include <linux/completion.h> | ||
24 | #include <linux/mfd/wm8350/rtc.h> | ||
25 | #include <linux/mfd/wm8350/core.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | |||
29 | #define WM8350_SET_ALM_RETRIES 5 | ||
30 | #define WM8350_SET_TIME_RETRIES 5 | ||
31 | #define WM8350_GET_TIME_RETRIES 5 | ||
32 | |||
33 | #define to_wm8350_from_rtc_dev(d) container_of(d, struct wm8350, rtc.pdev.dev) | ||
34 | |||
35 | /* | ||
36 | * Read current time and date in RTC | ||
37 | */ | ||
38 | static int wm8350_rtc_readtime(struct device *dev, struct rtc_time *tm) | ||
39 | { | ||
40 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
41 | u16 time1[4], time2[4]; | ||
42 | int retries = WM8350_GET_TIME_RETRIES, ret; | ||
43 | |||
44 | /* | ||
45 | * Read the time twice and compare. | ||
46 | * If time1 == time2, then time is valid else retry. | ||
47 | */ | ||
48 | do { | ||
49 | ret = wm8350_block_read(wm8350, WM8350_RTC_SECONDS_MINUTES, | ||
50 | 4, time1); | ||
51 | if (ret < 0) | ||
52 | return ret; | ||
53 | ret = wm8350_block_read(wm8350, WM8350_RTC_SECONDS_MINUTES, | ||
54 | 4, time2); | ||
55 | if (ret < 0) | ||
56 | return ret; | ||
57 | |||
58 | if (memcmp(time1, time2, sizeof(time1)) == 0) { | ||
59 | tm->tm_sec = time1[0] & WM8350_RTC_SECS_MASK; | ||
60 | |||
61 | tm->tm_min = (time1[0] & WM8350_RTC_MINS_MASK) | ||
62 | >> WM8350_RTC_MINS_SHIFT; | ||
63 | |||
64 | tm->tm_hour = time1[1] & WM8350_RTC_HRS_MASK; | ||
65 | |||
66 | tm->tm_wday = ((time1[1] >> WM8350_RTC_DAY_SHIFT) | ||
67 | & 0x7) - 1; | ||
68 | |||
69 | tm->tm_mon = ((time1[2] & WM8350_RTC_MTH_MASK) | ||
70 | >> WM8350_RTC_MTH_SHIFT) - 1; | ||
71 | |||
72 | tm->tm_mday = (time1[2] & WM8350_RTC_DATE_MASK); | ||
73 | |||
74 | tm->tm_year = ((time1[3] & WM8350_RTC_YHUNDREDS_MASK) | ||
75 | >> WM8350_RTC_YHUNDREDS_SHIFT) * 100; | ||
76 | tm->tm_year += time1[3] & WM8350_RTC_YUNITS_MASK; | ||
77 | |||
78 | tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, | ||
79 | tm->tm_year); | ||
80 | tm->tm_year -= 1900; | ||
81 | |||
82 | dev_dbg(dev, "Read (%d left): %04x %04x %04x %04x\n", | ||
83 | retries, | ||
84 | time1[0], time1[1], time1[2], time1[3]); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | } while (retries--); | ||
89 | |||
90 | dev_err(dev, "timed out reading RTC time\n"); | ||
91 | return -EIO; | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Set current time and date in RTC | ||
96 | */ | ||
97 | static int wm8350_rtc_settime(struct device *dev, struct rtc_time *tm) | ||
98 | { | ||
99 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
100 | u16 time[4]; | ||
101 | u16 rtc_ctrl; | ||
102 | int ret, retries = WM8350_SET_TIME_RETRIES; | ||
103 | |||
104 | time[0] = tm->tm_sec; | ||
105 | time[0] |= tm->tm_min << WM8350_RTC_MINS_SHIFT; | ||
106 | time[1] = tm->tm_hour; | ||
107 | time[1] |= (tm->tm_wday + 1) << WM8350_RTC_DAY_SHIFT; | ||
108 | time[2] = tm->tm_mday; | ||
109 | time[2] |= (tm->tm_mon + 1) << WM8350_RTC_MTH_SHIFT; | ||
110 | time[3] = ((tm->tm_year + 1900) / 100) << WM8350_RTC_YHUNDREDS_SHIFT; | ||
111 | time[3] |= (tm->tm_year + 1900) % 100; | ||
112 | |||
113 | dev_dbg(dev, "Setting: %04x %04x %04x %04x\n", | ||
114 | time[0], time[1], time[2], time[3]); | ||
115 | |||
116 | /* Set RTC_SET to stop the clock */ | ||
117 | ret = wm8350_set_bits(wm8350, WM8350_RTC_TIME_CONTROL, WM8350_RTC_SET); | ||
118 | if (ret < 0) | ||
119 | return ret; | ||
120 | |||
121 | /* Wait until confirmation of stopping */ | ||
122 | do { | ||
123 | rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); | ||
124 | schedule_timeout_uninterruptible(msecs_to_jiffies(1)); | ||
125 | } while (retries-- && !(rtc_ctrl & WM8350_RTC_STS)); | ||
126 | |||
127 | if (!retries) { | ||
128 | dev_err(dev, "timed out on set confirmation\n"); | ||
129 | return -EIO; | ||
130 | } | ||
131 | |||
132 | /* Write time to RTC */ | ||
133 | ret = wm8350_block_write(wm8350, WM8350_RTC_SECONDS_MINUTES, 4, time); | ||
134 | if (ret < 0) | ||
135 | return ret; | ||
136 | |||
137 | /* Clear RTC_SET to start the clock */ | ||
138 | ret = wm8350_clear_bits(wm8350, WM8350_RTC_TIME_CONTROL, | ||
139 | WM8350_RTC_SET); | ||
140 | return ret; | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | * Read alarm time and date in RTC | ||
145 | */ | ||
146 | static int wm8350_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
147 | { | ||
148 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
149 | struct rtc_time *tm = &alrm->time; | ||
150 | u16 time[4]; | ||
151 | int ret; | ||
152 | |||
153 | ret = wm8350_block_read(wm8350, WM8350_ALARM_SECONDS_MINUTES, 4, time); | ||
154 | if (ret < 0) | ||
155 | return ret; | ||
156 | |||
157 | tm->tm_sec = time[0] & WM8350_RTC_ALMSECS_MASK; | ||
158 | if (tm->tm_sec == WM8350_RTC_ALMSECS_MASK) | ||
159 | tm->tm_sec = -1; | ||
160 | |||
161 | tm->tm_min = time[0] & WM8350_RTC_ALMMINS_MASK; | ||
162 | if (tm->tm_min == WM8350_RTC_ALMMINS_MASK) | ||
163 | tm->tm_min = -1; | ||
164 | else | ||
165 | tm->tm_min >>= WM8350_RTC_ALMMINS_SHIFT; | ||
166 | |||
167 | tm->tm_hour = time[1] & WM8350_RTC_ALMHRS_MASK; | ||
168 | if (tm->tm_hour == WM8350_RTC_ALMHRS_MASK) | ||
169 | tm->tm_hour = -1; | ||
170 | |||
171 | tm->tm_wday = ((time[1] >> WM8350_RTC_ALMDAY_SHIFT) & 0x7) - 1; | ||
172 | if (tm->tm_wday > 7) | ||
173 | tm->tm_wday = -1; | ||
174 | |||
175 | tm->tm_mon = time[2] & WM8350_RTC_ALMMTH_MASK; | ||
176 | if (tm->tm_mon == WM8350_RTC_ALMMTH_MASK) | ||
177 | tm->tm_mon = -1; | ||
178 | else | ||
179 | tm->tm_mon = (tm->tm_mon >> WM8350_RTC_ALMMTH_SHIFT) - 1; | ||
180 | |||
181 | tm->tm_mday = (time[2] & WM8350_RTC_ALMDATE_MASK); | ||
182 | if (tm->tm_mday == WM8350_RTC_ALMDATE_MASK) | ||
183 | tm->tm_mday = -1; | ||
184 | |||
185 | tm->tm_year = -1; | ||
186 | |||
187 | alrm->enabled = !(time[3] & WM8350_RTC_ALMSTS); | ||
188 | |||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | static int wm8350_rtc_stop_alarm(struct wm8350 *wm8350) | ||
193 | { | ||
194 | int retries = WM8350_SET_ALM_RETRIES; | ||
195 | u16 rtc_ctrl; | ||
196 | int ret; | ||
197 | |||
198 | /* Set RTC_SET to stop the clock */ | ||
199 | ret = wm8350_set_bits(wm8350, WM8350_RTC_TIME_CONTROL, | ||
200 | WM8350_RTC_ALMSET); | ||
201 | if (ret < 0) | ||
202 | return ret; | ||
203 | |||
204 | /* Wait until confirmation of stopping */ | ||
205 | do { | ||
206 | rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); | ||
207 | schedule_timeout_uninterruptible(msecs_to_jiffies(1)); | ||
208 | } while (retries-- && !(rtc_ctrl & WM8350_RTC_ALMSTS)); | ||
209 | |||
210 | if (!(rtc_ctrl & WM8350_RTC_ALMSTS)) | ||
211 | return -ETIMEDOUT; | ||
212 | |||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | static int wm8350_rtc_start_alarm(struct wm8350 *wm8350) | ||
217 | { | ||
218 | int ret; | ||
219 | int retries = WM8350_SET_ALM_RETRIES; | ||
220 | u16 rtc_ctrl; | ||
221 | |||
222 | ret = wm8350_clear_bits(wm8350, WM8350_RTC_TIME_CONTROL, | ||
223 | WM8350_RTC_ALMSET); | ||
224 | if (ret < 0) | ||
225 | return ret; | ||
226 | |||
227 | /* Wait until confirmation */ | ||
228 | do { | ||
229 | rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); | ||
230 | schedule_timeout_uninterruptible(msecs_to_jiffies(1)); | ||
231 | } while (retries-- && rtc_ctrl & WM8350_RTC_ALMSTS); | ||
232 | |||
233 | if (rtc_ctrl & WM8350_RTC_ALMSTS) | ||
234 | return -ETIMEDOUT; | ||
235 | |||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | static int wm8350_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
240 | { | ||
241 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
242 | struct rtc_time *tm = &alrm->time; | ||
243 | u16 time[3]; | ||
244 | int ret; | ||
245 | |||
246 | memset(time, 0, sizeof(time)); | ||
247 | |||
248 | if (tm->tm_sec != -1) | ||
249 | time[0] |= tm->tm_sec; | ||
250 | else | ||
251 | time[0] |= WM8350_RTC_ALMSECS_MASK; | ||
252 | |||
253 | if (tm->tm_min != -1) | ||
254 | time[0] |= tm->tm_min << WM8350_RTC_ALMMINS_SHIFT; | ||
255 | else | ||
256 | time[0] |= WM8350_RTC_ALMMINS_MASK; | ||
257 | |||
258 | if (tm->tm_hour != -1) | ||
259 | time[1] |= tm->tm_hour; | ||
260 | else | ||
261 | time[1] |= WM8350_RTC_ALMHRS_MASK; | ||
262 | |||
263 | if (tm->tm_wday != -1) | ||
264 | time[1] |= (tm->tm_wday + 1) << WM8350_RTC_ALMDAY_SHIFT; | ||
265 | else | ||
266 | time[1] |= WM8350_RTC_ALMDAY_MASK; | ||
267 | |||
268 | if (tm->tm_mday != -1) | ||
269 | time[2] |= tm->tm_mday; | ||
270 | else | ||
271 | time[2] |= WM8350_RTC_ALMDATE_MASK; | ||
272 | |||
273 | if (tm->tm_mon != -1) | ||
274 | time[2] |= (tm->tm_mon + 1) << WM8350_RTC_ALMMTH_SHIFT; | ||
275 | else | ||
276 | time[2] |= WM8350_RTC_ALMMTH_MASK; | ||
277 | |||
278 | ret = wm8350_rtc_stop_alarm(wm8350); | ||
279 | if (ret < 0) | ||
280 | return ret; | ||
281 | |||
282 | /* Write time to RTC */ | ||
283 | ret = wm8350_block_write(wm8350, WM8350_ALARM_SECONDS_MINUTES, | ||
284 | 3, time); | ||
285 | if (ret < 0) | ||
286 | return ret; | ||
287 | |||
288 | if (alrm->enabled) | ||
289 | ret = wm8350_rtc_start_alarm(wm8350); | ||
290 | |||
291 | return ret; | ||
292 | } | ||
293 | |||
294 | /* | ||
295 | * Handle commands from user-space | ||
296 | */ | ||
297 | static int wm8350_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
298 | unsigned long arg) | ||
299 | { | ||
300 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
301 | |||
302 | switch (cmd) { | ||
303 | case RTC_AIE_OFF: | ||
304 | return wm8350_rtc_stop_alarm(wm8350); | ||
305 | case RTC_AIE_ON: | ||
306 | return wm8350_rtc_start_alarm(wm8350); | ||
307 | |||
308 | case RTC_UIE_OFF: | ||
309 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
310 | break; | ||
311 | case RTC_UIE_ON: | ||
312 | wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
313 | break; | ||
314 | |||
315 | default: | ||
316 | return -ENOIOCTLCMD; | ||
317 | } | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | static void wm8350_rtc_alarm_handler(struct wm8350 *wm8350, int irq, | ||
323 | void *data) | ||
324 | { | ||
325 | struct rtc_device *rtc = wm8350->rtc.rtc; | ||
326 | int ret; | ||
327 | |||
328 | rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF); | ||
329 | |||
330 | /* Make it one shot */ | ||
331 | ret = wm8350_set_bits(wm8350, WM8350_RTC_TIME_CONTROL, | ||
332 | WM8350_RTC_ALMSET); | ||
333 | if (ret != 0) { | ||
334 | dev_err(&(wm8350->rtc.pdev->dev), | ||
335 | "Failed to disable alarm: %d\n", ret); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | static void wm8350_rtc_update_handler(struct wm8350 *wm8350, int irq, | ||
340 | void *data) | ||
341 | { | ||
342 | struct rtc_device *rtc = wm8350->rtc.rtc; | ||
343 | |||
344 | rtc_update_irq(rtc, 1, RTC_IRQF | RTC_UF); | ||
345 | } | ||
346 | |||
347 | static const struct rtc_class_ops wm8350_rtc_ops = { | ||
348 | .ioctl = wm8350_rtc_ioctl, | ||
349 | .read_time = wm8350_rtc_readtime, | ||
350 | .set_time = wm8350_rtc_settime, | ||
351 | .read_alarm = wm8350_rtc_readalarm, | ||
352 | .set_alarm = wm8350_rtc_setalarm, | ||
353 | }; | ||
354 | |||
355 | #ifdef CONFIG_PM | ||
356 | static int wm8350_rtc_suspend(struct platform_device *pdev, pm_message_t state) | ||
357 | { | ||
358 | struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev); | ||
359 | int ret = 0; | ||
360 | u16 reg; | ||
361 | |||
362 | reg = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); | ||
363 | |||
364 | if (device_may_wakeup(&wm8350->rtc.pdev->dev) && | ||
365 | reg & WM8350_RTC_ALMSTS) { | ||
366 | ret = wm8350_rtc_stop_alarm(wm8350); | ||
367 | if (ret != 0) | ||
368 | dev_err(&pdev->dev, "Failed to stop RTC alarm: %d\n", | ||
369 | ret); | ||
370 | } | ||
371 | |||
372 | return ret; | ||
373 | } | ||
374 | |||
375 | static int wm8350_rtc_resume(struct platform_device *pdev) | ||
376 | { | ||
377 | struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev); | ||
378 | int ret; | ||
379 | |||
380 | if (wm8350->rtc.alarm_enabled) { | ||
381 | ret = wm8350_rtc_start_alarm(wm8350); | ||
382 | if (ret != 0) | ||
383 | dev_err(&pdev->dev, | ||
384 | "Failed to restart RTC alarm: %d\n", ret); | ||
385 | } | ||
386 | |||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | #else | ||
391 | #define wm8350_rtc_suspend NULL | ||
392 | #define wm8350_rtc_resume NULL | ||
393 | #endif | ||
394 | |||
395 | static int wm8350_rtc_probe(struct platform_device *pdev) | ||
396 | { | ||
397 | struct wm8350 *wm8350 = platform_get_drvdata(pdev); | ||
398 | struct wm8350_rtc *wm_rtc = &wm8350->rtc; | ||
399 | int ret = 0; | ||
400 | u16 timectl, power5; | ||
401 | |||
402 | timectl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); | ||
403 | if (timectl & WM8350_RTC_BCD) { | ||
404 | dev_err(&pdev->dev, "RTC BCD mode not supported\n"); | ||
405 | return -EINVAL; | ||
406 | } | ||
407 | if (timectl & WM8350_RTC_12HR) { | ||
408 | dev_err(&pdev->dev, "RTC 12 hour mode not supported\n"); | ||
409 | return -EINVAL; | ||
410 | } | ||
411 | |||
412 | /* enable the RTC if it's not already enabled */ | ||
413 | power5 = wm8350_reg_read(wm8350, WM8350_POWER_MGMT_5); | ||
414 | if (!(power5 & WM8350_RTC_TICK_ENA)) { | ||
415 | dev_info(wm8350->dev, "Starting RTC\n"); | ||
416 | |||
417 | wm8350_reg_unlock(wm8350); | ||
418 | |||
419 | ret = wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, | ||
420 | WM8350_RTC_TICK_ENA); | ||
421 | if (ret < 0) { | ||
422 | dev_err(&pdev->dev, "failed to enable RTC: %d\n", ret); | ||
423 | return ret; | ||
424 | } | ||
425 | |||
426 | wm8350_reg_lock(wm8350); | ||
427 | } | ||
428 | |||
429 | if (timectl & WM8350_RTC_STS) { | ||
430 | int retries; | ||
431 | |||
432 | ret = wm8350_clear_bits(wm8350, WM8350_RTC_TIME_CONTROL, | ||
433 | WM8350_RTC_SET); | ||
434 | if (ret < 0) { | ||
435 | dev_err(&pdev->dev, "failed to start: %d\n", ret); | ||
436 | return ret; | ||
437 | } | ||
438 | |||
439 | retries = WM8350_SET_TIME_RETRIES; | ||
440 | do { | ||
441 | timectl = wm8350_reg_read(wm8350, | ||
442 | WM8350_RTC_TIME_CONTROL); | ||
443 | } while (timectl & WM8350_RTC_STS && retries--); | ||
444 | |||
445 | if (retries == 0) { | ||
446 | dev_err(&pdev->dev, "failed to start: timeout\n"); | ||
447 | return -ENODEV; | ||
448 | } | ||
449 | } | ||
450 | |||
451 | device_init_wakeup(&pdev->dev, 1); | ||
452 | |||
453 | wm_rtc->rtc = rtc_device_register("wm8350", &pdev->dev, | ||
454 | &wm8350_rtc_ops, THIS_MODULE); | ||
455 | if (IS_ERR(wm_rtc->rtc)) { | ||
456 | ret = PTR_ERR(wm_rtc->rtc); | ||
457 | dev_err(&pdev->dev, "failed to register RTC: %d\n", ret); | ||
458 | return ret; | ||
459 | } | ||
460 | |||
461 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
462 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_PER); | ||
463 | |||
464 | wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC, | ||
465 | wm8350_rtc_update_handler, NULL); | ||
466 | |||
467 | wm8350_register_irq(wm8350, WM8350_IRQ_RTC_ALM, | ||
468 | wm8350_rtc_alarm_handler, NULL); | ||
469 | wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_ALM); | ||
470 | |||
471 | return 0; | ||
472 | } | ||
473 | |||
474 | static int __devexit wm8350_rtc_remove(struct platform_device *pdev) | ||
475 | { | ||
476 | struct wm8350 *wm8350 = platform_get_drvdata(pdev); | ||
477 | struct wm8350_rtc *wm_rtc = &wm8350->rtc; | ||
478 | |||
479 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
480 | |||
481 | wm8350_free_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
482 | wm8350_free_irq(wm8350, WM8350_IRQ_RTC_ALM); | ||
483 | |||
484 | rtc_device_unregister(wm_rtc->rtc); | ||
485 | |||
486 | return 0; | ||
487 | } | ||
488 | |||
489 | static struct platform_driver wm8350_rtc_driver = { | ||
490 | .probe = wm8350_rtc_probe, | ||
491 | .remove = __devexit_p(wm8350_rtc_remove), | ||
492 | .suspend = wm8350_rtc_suspend, | ||
493 | .resume = wm8350_rtc_resume, | ||
494 | .driver = { | ||
495 | .name = "wm8350-rtc", | ||
496 | }, | ||
497 | }; | ||
498 | |||
499 | static int __init wm8350_rtc_init(void) | ||
500 | { | ||
501 | return platform_driver_register(&wm8350_rtc_driver); | ||
502 | } | ||
503 | module_init(wm8350_rtc_init); | ||
504 | |||
505 | static void __exit wm8350_rtc_exit(void) | ||
506 | { | ||
507 | platform_driver_unregister(&wm8350_rtc_driver); | ||
508 | } | ||
509 | module_exit(wm8350_rtc_exit); | ||
510 | |||
511 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | ||
512 | MODULE_DESCRIPTION("RTC driver for the WM8350"); | ||
513 | MODULE_LICENSE("GPL"); | ||
514 | MODULE_ALIAS("platform:wm8350-rtc"); | ||
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 4b76fca64a6f..363bd1303d21 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -1746,6 +1746,11 @@ restart: | |||
1746 | goto restart; | 1746 | goto restart; |
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | /* log sense for fatal error */ | ||
1750 | if (cqr->status == DASD_CQR_FAILED) { | ||
1751 | dasd_log_sense(cqr, &cqr->irb); | ||
1752 | } | ||
1753 | |||
1749 | /* First of all call extended error reporting. */ | 1754 | /* First of all call extended error reporting. */ |
1750 | if (dasd_eer_enabled(base) && | 1755 | if (dasd_eer_enabled(base) && |
1751 | cqr->status == DASD_CQR_FAILED) { | 1756 | cqr->status == DASD_CQR_FAILED) { |
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c index eb5f1b8bc57f..ec9c0bcf66ee 100644 --- a/drivers/s390/char/sclp_cmd.c +++ b/drivers/s390/char/sclp_cmd.c | |||
@@ -324,6 +324,9 @@ static int do_assign_storage(sclp_cmdw_t cmd, u16 rn) | |||
324 | case 0x0120: | 324 | case 0x0120: |
325 | break; | 325 | break; |
326 | default: | 326 | default: |
327 | pr_warning("assign storage failed (cmd=0x%08x, " | ||
328 | "response=0x%04x, rn=0x%04x)\n", cmd, | ||
329 | sccb->header.response_code, rn); | ||
327 | rc = -EIO; | 330 | rc = -EIO; |
328 | break; | 331 | break; |
329 | } | 332 | } |
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 4e78c82194b4..4e4008325e28 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c | |||
@@ -874,11 +874,15 @@ void ccw_device_move_to_orphanage(struct work_struct *work) | |||
874 | replacing_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev); | 874 | replacing_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev); |
875 | if (replacing_cdev) { | 875 | if (replacing_cdev) { |
876 | sch_attach_disconnected_device(sch, replacing_cdev); | 876 | sch_attach_disconnected_device(sch, replacing_cdev); |
877 | /* Release reference from get_disc_ccwdev_by_dev_id() */ | ||
878 | put_device(&cdev->dev); | ||
877 | return; | 879 | return; |
878 | } | 880 | } |
879 | replacing_cdev = get_orphaned_ccwdev_by_dev_id(css, &dev_id); | 881 | replacing_cdev = get_orphaned_ccwdev_by_dev_id(css, &dev_id); |
880 | if (replacing_cdev) { | 882 | if (replacing_cdev) { |
881 | sch_attach_orphaned_device(sch, replacing_cdev); | 883 | sch_attach_orphaned_device(sch, replacing_cdev); |
884 | /* Release reference from get_orphaned_ccwdev_by_dev_id() */ | ||
885 | put_device(&cdev->dev); | ||
882 | return; | 886 | return; |
883 | } | 887 | } |
884 | sch_create_and_recog_new_device(sch); | 888 | sch_create_and_recog_new_device(sch); |
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index ff4a6931bb8e..3d442444c618 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c | |||
@@ -322,13 +322,13 @@ static int __init kvm_devices_init(void) | |||
322 | return rc; | 322 | return rc; |
323 | } | 323 | } |
324 | 324 | ||
325 | rc = vmem_add_mapping(PFN_PHYS(max_pfn), PAGE_SIZE); | 325 | rc = vmem_add_mapping(real_memory_size, PAGE_SIZE); |
326 | if (rc) { | 326 | if (rc) { |
327 | s390_root_dev_unregister(kvm_root); | 327 | s390_root_dev_unregister(kvm_root); |
328 | return rc; | 328 | return rc; |
329 | } | 329 | } |
330 | 330 | ||
331 | kvm_devices = (void *) PFN_PHYS(max_pfn); | 331 | kvm_devices = (void *) real_memory_size; |
332 | 332 | ||
333 | ctl_set_bit(0, 9); | 333 | ctl_set_bit(0, 9); |
334 | register_external_interrupt(0x2603, kvm_extint_handler); | 334 | register_external_interrupt(0x2603, kvm_extint_handler); |
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index 3b56220fb900..3d4e3e3f3fc0 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c | |||
@@ -610,7 +610,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, | |||
610 | atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status); | 610 | atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status); |
611 | atomic_set(&port->refcount, 0); | 611 | atomic_set(&port->refcount, 0); |
612 | 612 | ||
613 | dev_set_name(&port->sysfs_device, "0x%016llx", wwpn); | 613 | dev_set_name(&port->sysfs_device, "0x%016llx", |
614 | (unsigned long long)wwpn); | ||
614 | port->sysfs_device.parent = &adapter->ccw_device->dev; | 615 | port->sysfs_device.parent = &adapter->ccw_device->dev; |
615 | 616 | ||
616 | port->sysfs_device.release = zfcp_sysfs_port_release; | 617 | port->sysfs_device.release = zfcp_sysfs_port_release; |
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c index b04038c74786..951a8d409d1d 100644 --- a/drivers/s390/scsi/zfcp_ccw.c +++ b/drivers/s390/scsi/zfcp_ccw.c | |||
@@ -116,7 +116,9 @@ static int zfcp_ccw_set_online(struct ccw_device *ccw_device) | |||
116 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 85, | 116 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 85, |
117 | NULL); | 117 | NULL); |
118 | zfcp_erp_wait(adapter); | 118 | zfcp_erp_wait(adapter); |
119 | goto out; | 119 | up(&zfcp_data.config_sema); |
120 | flush_work(&adapter->scan_work); | ||
121 | return 0; | ||
120 | 122 | ||
121 | out_scsi_register: | 123 | out_scsi_register: |
122 | zfcp_erp_thread_kill(adapter); | 124 | zfcp_erp_thread_kill(adapter); |
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index 060f5f2352ec..31012d58cfb7 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c | |||
@@ -30,7 +30,7 @@ static void zfcp_dbf_hexdump(debug_info_t *dbf, void *to, int to_len, | |||
30 | dump->offset = offset; | 30 | dump->offset = offset; |
31 | dump->size = min(from_len - offset, room); | 31 | dump->size = min(from_len - offset, room); |
32 | memcpy(dump->data, from + offset, dump->size); | 32 | memcpy(dump->data, from + offset, dump->size); |
33 | debug_event(dbf, level, dump, dump->size); | 33 | debug_event(dbf, level, dump, dump->size + sizeof(*dump)); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
@@ -108,7 +108,7 @@ static int zfcp_dbf_view_header(debug_info_t *id, struct debug_view *view, | |||
108 | t.tv_sec, t.tv_nsec); | 108 | t.tv_sec, t.tv_nsec); |
109 | zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); | 109 | zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); |
110 | } else { | 110 | } else { |
111 | zfcp_dbf_outd(&p, NULL, dump->data, dump->size, dump->offset, | 111 | zfcp_dbf_outd(&p, "", dump->data, dump->size, dump->offset, |
112 | dump->total_size); | 112 | dump->total_size); |
113 | if ((dump->offset + dump->size) == dump->total_size) | 113 | if ((dump->offset + dump->size) == dump->total_size) |
114 | p += sprintf(p, "\n"); | 114 | p += sprintf(p, "\n"); |
@@ -366,6 +366,7 @@ static void zfcp_hba_dbf_view_response(char **p, | |||
366 | break; | 366 | break; |
367 | zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx", r->u.fcp.cmnd); | 367 | zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx", r->u.fcp.cmnd); |
368 | zfcp_dbf_out(p, "scsi_serial", "0x%016Lx", r->u.fcp.serial); | 368 | zfcp_dbf_out(p, "scsi_serial", "0x%016Lx", r->u.fcp.serial); |
369 | p += sprintf(*p, "\n"); | ||
369 | break; | 370 | break; |
370 | 371 | ||
371 | case FSF_QTCB_OPEN_PORT_WITH_DID: | 372 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
@@ -465,7 +466,8 @@ static int zfcp_hba_dbf_view_format(debug_info_t *id, struct debug_view *view, | |||
465 | else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0) | 466 | else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0) |
466 | zfcp_hba_dbf_view_berr(&p, &r->u.berr); | 467 | zfcp_hba_dbf_view_berr(&p, &r->u.berr); |
467 | 468 | ||
468 | p += sprintf(p, "\n"); | 469 | if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) != 0) |
470 | p += sprintf(p, "\n"); | ||
469 | return p - out_buf; | 471 | return p - out_buf; |
470 | } | 472 | } |
471 | 473 | ||
@@ -880,6 +882,7 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req) | |||
880 | struct ct_hdr *hdr = sg_virt(ct->req); | 882 | struct ct_hdr *hdr = sg_virt(ct->req); |
881 | struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; | 883 | struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; |
882 | struct zfcp_san_dbf_record_ct_request *oct = &r->u.ct_req; | 884 | struct zfcp_san_dbf_record_ct_request *oct = &r->u.ct_req; |
885 | int level = 3; | ||
883 | unsigned long flags; | 886 | unsigned long flags; |
884 | 887 | ||
885 | spin_lock_irqsave(&adapter->san_dbf_lock, flags); | 888 | spin_lock_irqsave(&adapter->san_dbf_lock, flags); |
@@ -896,9 +899,10 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req) | |||
896 | oct->options = hdr->options; | 899 | oct->options = hdr->options; |
897 | oct->max_res_size = hdr->max_res_size; | 900 | oct->max_res_size = hdr->max_res_size; |
898 | oct->len = min((int)ct->req->length - (int)sizeof(struct ct_hdr), | 901 | oct->len = min((int)ct->req->length - (int)sizeof(struct ct_hdr), |
899 | ZFCP_DBF_CT_PAYLOAD); | 902 | ZFCP_DBF_SAN_MAX_PAYLOAD); |
900 | memcpy(oct->payload, (void *)hdr + sizeof(struct ct_hdr), oct->len); | 903 | debug_event(adapter->san_dbf, level, r, sizeof(*r)); |
901 | debug_event(adapter->san_dbf, 3, r, sizeof(*r)); | 904 | zfcp_dbf_hexdump(adapter->san_dbf, r, sizeof(*r), level, |
905 | (void *)hdr + sizeof(struct ct_hdr), oct->len); | ||
902 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); | 906 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); |
903 | } | 907 | } |
904 | 908 | ||
@@ -914,6 +918,7 @@ void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req) | |||
914 | struct ct_hdr *hdr = sg_virt(ct->resp); | 918 | struct ct_hdr *hdr = sg_virt(ct->resp); |
915 | struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; | 919 | struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; |
916 | struct zfcp_san_dbf_record_ct_response *rct = &r->u.ct_resp; | 920 | struct zfcp_san_dbf_record_ct_response *rct = &r->u.ct_resp; |
921 | int level = 3; | ||
917 | unsigned long flags; | 922 | unsigned long flags; |
918 | 923 | ||
919 | spin_lock_irqsave(&adapter->san_dbf_lock, flags); | 924 | spin_lock_irqsave(&adapter->san_dbf_lock, flags); |
@@ -929,9 +934,10 @@ void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req) | |||
929 | rct->expl = hdr->reason_code_expl; | 934 | rct->expl = hdr->reason_code_expl; |
930 | rct->vendor_unique = hdr->vendor_unique; | 935 | rct->vendor_unique = hdr->vendor_unique; |
931 | rct->len = min((int)ct->resp->length - (int)sizeof(struct ct_hdr), | 936 | rct->len = min((int)ct->resp->length - (int)sizeof(struct ct_hdr), |
932 | ZFCP_DBF_CT_PAYLOAD); | 937 | ZFCP_DBF_SAN_MAX_PAYLOAD); |
933 | memcpy(rct->payload, (void *)hdr + sizeof(struct ct_hdr), rct->len); | 938 | debug_event(adapter->san_dbf, level, r, sizeof(*r)); |
934 | debug_event(adapter->san_dbf, 3, r, sizeof(*r)); | 939 | zfcp_dbf_hexdump(adapter->san_dbf, r, sizeof(*r), level, |
940 | (void *)hdr + sizeof(struct ct_hdr), rct->len); | ||
935 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); | 941 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); |
936 | } | 942 | } |
937 | 943 | ||
@@ -954,7 +960,7 @@ static void zfcp_san_dbf_event_els(const char *tag, int level, | |||
954 | rec->u.els.ls_code = ls_code; | 960 | rec->u.els.ls_code = ls_code; |
955 | debug_event(adapter->san_dbf, level, rec, sizeof(*rec)); | 961 | debug_event(adapter->san_dbf, level, rec, sizeof(*rec)); |
956 | zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level, | 962 | zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level, |
957 | buffer, min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD)); | 963 | buffer, min(buflen, ZFCP_DBF_SAN_MAX_PAYLOAD)); |
958 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); | 964 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); |
959 | } | 965 | } |
960 | 966 | ||
@@ -1008,8 +1014,6 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view, | |||
1008 | char *out_buf, const char *in_buf) | 1014 | char *out_buf, const char *in_buf) |
1009 | { | 1015 | { |
1010 | struct zfcp_san_dbf_record *r = (struct zfcp_san_dbf_record *)in_buf; | 1016 | struct zfcp_san_dbf_record *r = (struct zfcp_san_dbf_record *)in_buf; |
1011 | char *buffer = NULL; | ||
1012 | int buflen = 0, total = 0; | ||
1013 | char *p = out_buf; | 1017 | char *p = out_buf; |
1014 | 1018 | ||
1015 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) | 1019 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
@@ -1029,9 +1033,6 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view, | |||
1029 | zfcp_dbf_out(&p, "gs_subtype", "0x%02x", ct->gs_subtype); | 1033 | zfcp_dbf_out(&p, "gs_subtype", "0x%02x", ct->gs_subtype); |
1030 | zfcp_dbf_out(&p, "options", "0x%02x", ct->options); | 1034 | zfcp_dbf_out(&p, "options", "0x%02x", ct->options); |
1031 | zfcp_dbf_out(&p, "max_res_size", "0x%04x", ct->max_res_size); | 1035 | zfcp_dbf_out(&p, "max_res_size", "0x%04x", ct->max_res_size); |
1032 | total = ct->len; | ||
1033 | buffer = ct->payload; | ||
1034 | buflen = min(total, ZFCP_DBF_CT_PAYLOAD); | ||
1035 | } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) { | 1036 | } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) { |
1036 | struct zfcp_san_dbf_record_ct_response *ct = &r->u.ct_resp; | 1037 | struct zfcp_san_dbf_record_ct_response *ct = &r->u.ct_resp; |
1037 | zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code); | 1038 | zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code); |
@@ -1039,23 +1040,12 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view, | |||
1039 | zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code); | 1040 | zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code); |
1040 | zfcp_dbf_out(&p, "reason_code_expl", "0x%02x", ct->expl); | 1041 | zfcp_dbf_out(&p, "reason_code_expl", "0x%02x", ct->expl); |
1041 | zfcp_dbf_out(&p, "vendor_unique", "0x%02x", ct->vendor_unique); | 1042 | zfcp_dbf_out(&p, "vendor_unique", "0x%02x", ct->vendor_unique); |
1042 | total = ct->len; | ||
1043 | buffer = ct->payload; | ||
1044 | buflen = min(total, ZFCP_DBF_CT_PAYLOAD); | ||
1045 | } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 || | 1043 | } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 || |
1046 | strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 || | 1044 | strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 || |
1047 | strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) { | 1045 | strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) { |
1048 | struct zfcp_san_dbf_record_els *els = &r->u.els; | 1046 | struct zfcp_san_dbf_record_els *els = &r->u.els; |
1049 | zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code); | 1047 | zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code); |
1050 | total = els->len; | ||
1051 | buffer = els->payload; | ||
1052 | buflen = min(total, ZFCP_DBF_ELS_PAYLOAD); | ||
1053 | } | 1048 | } |
1054 | |||
1055 | zfcp_dbf_outd(&p, "payload", buffer, buflen, 0, total); | ||
1056 | if (buflen == total) | ||
1057 | p += sprintf(p, "\n"); | ||
1058 | |||
1059 | return p - out_buf; | 1049 | return p - out_buf; |
1060 | } | 1050 | } |
1061 | 1051 | ||
diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h index e8f450801fea..5d6b2dff855b 100644 --- a/drivers/s390/scsi/zfcp_dbf.h +++ b/drivers/s390/scsi/zfcp_dbf.h | |||
@@ -163,8 +163,6 @@ struct zfcp_san_dbf_record_ct_request { | |||
163 | u8 options; | 163 | u8 options; |
164 | u16 max_res_size; | 164 | u16 max_res_size; |
165 | u32 len; | 165 | u32 len; |
166 | #define ZFCP_DBF_CT_PAYLOAD 24 | ||
167 | u8 payload[ZFCP_DBF_CT_PAYLOAD]; | ||
168 | } __attribute__ ((packed)); | 166 | } __attribute__ ((packed)); |
169 | 167 | ||
170 | struct zfcp_san_dbf_record_ct_response { | 168 | struct zfcp_san_dbf_record_ct_response { |
@@ -174,15 +172,11 @@ struct zfcp_san_dbf_record_ct_response { | |||
174 | u8 expl; | 172 | u8 expl; |
175 | u8 vendor_unique; | 173 | u8 vendor_unique; |
176 | u32 len; | 174 | u32 len; |
177 | u8 payload[ZFCP_DBF_CT_PAYLOAD]; | ||
178 | } __attribute__ ((packed)); | 175 | } __attribute__ ((packed)); |
179 | 176 | ||
180 | struct zfcp_san_dbf_record_els { | 177 | struct zfcp_san_dbf_record_els { |
181 | u8 ls_code; | 178 | u8 ls_code; |
182 | u32 len; | 179 | u32 len; |
183 | #define ZFCP_DBF_ELS_PAYLOAD 32 | ||
184 | #define ZFCP_DBF_ELS_MAX_PAYLOAD 1024 | ||
185 | u8 payload[ZFCP_DBF_ELS_PAYLOAD]; | ||
186 | } __attribute__ ((packed)); | 180 | } __attribute__ ((packed)); |
187 | 181 | ||
188 | struct zfcp_san_dbf_record { | 182 | struct zfcp_san_dbf_record { |
@@ -196,6 +190,8 @@ struct zfcp_san_dbf_record { | |||
196 | struct zfcp_san_dbf_record_ct_response ct_resp; | 190 | struct zfcp_san_dbf_record_ct_response ct_resp; |
197 | struct zfcp_san_dbf_record_els els; | 191 | struct zfcp_san_dbf_record_els els; |
198 | } u; | 192 | } u; |
193 | #define ZFCP_DBF_SAN_MAX_PAYLOAD 1024 | ||
194 | u8 payload[32]; | ||
199 | } __attribute__ ((packed)); | 195 | } __attribute__ ((packed)); |
200 | 196 | ||
201 | struct zfcp_scsi_dbf_record { | 197 | struct zfcp_scsi_dbf_record { |
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 9040f738ff33..35364f64da7f 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c | |||
@@ -472,6 +472,7 @@ static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) | |||
472 | ZFCP_STATUS_ERP_TIMEDOUT)) { | 472 | ZFCP_STATUS_ERP_TIMEDOUT)) { |
473 | act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; | 473 | act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; |
474 | zfcp_rec_dbf_event_action(142, act); | 474 | zfcp_rec_dbf_event_action(142, act); |
475 | act->fsf_req->erp_action = NULL; | ||
475 | } | 476 | } |
476 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) | 477 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) |
477 | zfcp_rec_dbf_event_action(143, act); | 478 | zfcp_rec_dbf_event_action(143, act); |
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 5ae1d497e5ed..d024442ee128 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c | |||
@@ -683,6 +683,7 @@ static struct zfcp_fsf_req *zfcp_fsf_alloc_noqtcb(mempool_t *pool) | |||
683 | if (!req) | 683 | if (!req) |
684 | return NULL; | 684 | return NULL; |
685 | memset(req, 0, sizeof(*req)); | 685 | memset(req, 0, sizeof(*req)); |
686 | req->pool = pool; | ||
686 | return req; | 687 | return req; |
687 | } | 688 | } |
688 | 689 | ||
@@ -769,28 +770,24 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_adapter *adapter, | |||
769 | static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) | 770 | static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) |
770 | { | 771 | { |
771 | struct zfcp_adapter *adapter = req->adapter; | 772 | struct zfcp_adapter *adapter = req->adapter; |
772 | struct zfcp_qdio_queue *req_q = &adapter->req_q; | 773 | unsigned long flags; |
773 | int idx; | 774 | int idx; |
774 | 775 | ||
775 | /* put allocated FSF request into hash table */ | 776 | /* put allocated FSF request into hash table */ |
776 | spin_lock(&adapter->req_list_lock); | 777 | spin_lock_irqsave(&adapter->req_list_lock, flags); |
777 | idx = zfcp_reqlist_hash(req->req_id); | 778 | idx = zfcp_reqlist_hash(req->req_id); |
778 | list_add_tail(&req->list, &adapter->req_list[idx]); | 779 | list_add_tail(&req->list, &adapter->req_list[idx]); |
779 | spin_unlock(&adapter->req_list_lock); | 780 | spin_unlock_irqrestore(&adapter->req_list_lock, flags); |
780 | 781 | ||
781 | req->qdio_outb_usage = atomic_read(&req_q->count); | 782 | req->qdio_outb_usage = atomic_read(&adapter->req_q.count); |
782 | req->issued = get_clock(); | 783 | req->issued = get_clock(); |
783 | if (zfcp_qdio_send(req)) { | 784 | if (zfcp_qdio_send(req)) { |
784 | /* Queues are down..... */ | ||
785 | del_timer(&req->timer); | 785 | del_timer(&req->timer); |
786 | spin_lock(&adapter->req_list_lock); | 786 | spin_lock_irqsave(&adapter->req_list_lock, flags); |
787 | zfcp_reqlist_remove(adapter, req); | 787 | /* lookup request again, list might have changed */ |
788 | spin_unlock(&adapter->req_list_lock); | 788 | if (zfcp_reqlist_find_safe(adapter, req)) |
789 | /* undo changes in request queue made for this request */ | 789 | zfcp_reqlist_remove(adapter, req); |
790 | atomic_add(req->sbal_number, &req_q->count); | 790 | spin_unlock_irqrestore(&adapter->req_list_lock, flags); |
791 | req_q->first -= req->sbal_number; | ||
792 | req_q->first += QDIO_MAX_BUFFERS_PER_Q; | ||
793 | req_q->first %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */ | ||
794 | zfcp_erp_adapter_reopen(adapter, 0, 116, req); | 791 | zfcp_erp_adapter_reopen(adapter, 0, 116, req); |
795 | return -EIO; | 792 | return -EIO; |
796 | } | 793 | } |
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index ca8f85f3dad4..e46fd3e9f68f 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c | |||
@@ -24,14 +24,10 @@ char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu) | |||
24 | static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) | 24 | static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) |
25 | { | 25 | { |
26 | struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; | 26 | struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; |
27 | WARN_ON(!unit); | 27 | atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status); |
28 | if (unit) { | 28 | unit->device = NULL; |
29 | atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status); | 29 | zfcp_erp_unit_failed(unit, 12, NULL); |
30 | sdpnt->hostdata = NULL; | 30 | zfcp_unit_put(unit); |
31 | unit->device = NULL; | ||
32 | zfcp_erp_unit_failed(unit, 12, NULL); | ||
33 | zfcp_unit_put(unit); | ||
34 | } | ||
35 | } | 31 | } |
36 | 32 | ||
37 | static int zfcp_scsi_slave_configure(struct scsi_device *sdp) | 33 | static int zfcp_scsi_slave_configure(struct scsi_device *sdp) |
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 8aba4fdfb522..6194ed5d02c4 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -2445,7 +2445,7 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) | |||
2445 | hba_status = detailed_status >> 8; | 2445 | hba_status = detailed_status >> 8; |
2446 | 2446 | ||
2447 | // calculate resid for sg | 2447 | // calculate resid for sg |
2448 | scsi_set_resid(cmd, scsi_bufflen(cmd) - readl(reply+5)); | 2448 | scsi_set_resid(cmd, scsi_bufflen(cmd) - readl(reply+20)); |
2449 | 2449 | ||
2450 | pHba = (adpt_hba*) cmd->device->host->hostdata[0]; | 2450 | pHba = (adpt_hba*) cmd->device->host->hostdata[0]; |
2451 | 2451 | ||
@@ -2456,7 +2456,7 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) | |||
2456 | case I2O_SCSI_DSC_SUCCESS: | 2456 | case I2O_SCSI_DSC_SUCCESS: |
2457 | cmd->result = (DID_OK << 16); | 2457 | cmd->result = (DID_OK << 16); |
2458 | // handle underflow | 2458 | // handle underflow |
2459 | if(readl(reply+5) < cmd->underflow ) { | 2459 | if (readl(reply+20) < cmd->underflow) { |
2460 | cmd->result = (DID_ERROR <<16); | 2460 | cmd->result = (DID_ERROR <<16); |
2461 | printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name); | 2461 | printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name); |
2462 | } | 2462 | } |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 28c9da7d4a5c..7dc62deb4087 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -4402,6 +4402,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) | |||
4402 | scb_t *scb; | 4402 | scb_t *scb; |
4403 | int rval; | 4403 | int rval; |
4404 | 4404 | ||
4405 | scmd = scsi_allocate_command(GFP_KERNEL); | ||
4406 | if (!scmd) | ||
4407 | return -ENOMEM; | ||
4408 | |||
4405 | /* | 4409 | /* |
4406 | * The internal commands share one command id and hence are | 4410 | * The internal commands share one command id and hence are |
4407 | * serialized. This is so because we want to reserve maximum number of | 4411 | * serialized. This is so because we want to reserve maximum number of |
@@ -4412,12 +4416,11 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) | |||
4412 | scb = &adapter->int_scb; | 4416 | scb = &adapter->int_scb; |
4413 | memset(scb, 0, sizeof(scb_t)); | 4417 | memset(scb, 0, sizeof(scb_t)); |
4414 | 4418 | ||
4415 | scmd = &adapter->int_scmd; | ||
4416 | memset(scmd, 0, sizeof(Scsi_Cmnd)); | ||
4417 | |||
4418 | sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL); | 4419 | sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL); |
4419 | scmd->device = sdev; | 4420 | scmd->device = sdev; |
4420 | 4421 | ||
4422 | memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb)); | ||
4423 | scmd->cmnd = adapter->int_cdb; | ||
4421 | scmd->device->host = adapter->host; | 4424 | scmd->device->host = adapter->host; |
4422 | scmd->host_scribble = (void *)scb; | 4425 | scmd->host_scribble = (void *)scb; |
4423 | scmd->cmnd[0] = MEGA_INTERNAL_CMD; | 4426 | scmd->cmnd[0] = MEGA_INTERNAL_CMD; |
@@ -4456,6 +4459,8 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) | |||
4456 | 4459 | ||
4457 | mutex_unlock(&adapter->int_mtx); | 4460 | mutex_unlock(&adapter->int_mtx); |
4458 | 4461 | ||
4462 | scsi_free_command(GFP_KERNEL, scmd); | ||
4463 | |||
4459 | return rval; | 4464 | return rval; |
4460 | } | 4465 | } |
4461 | 4466 | ||
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h index ee70bd4ae4ba..795201fa0b48 100644 --- a/drivers/scsi/megaraid.h +++ b/drivers/scsi/megaraid.h | |||
@@ -888,8 +888,8 @@ typedef struct { | |||
888 | 888 | ||
889 | u8 sglen; /* f/w supported scatter-gather list length */ | 889 | u8 sglen; /* f/w supported scatter-gather list length */ |
890 | 890 | ||
891 | unsigned char int_cdb[MAX_COMMAND_SIZE]; | ||
891 | scb_t int_scb; | 892 | scb_t int_scb; |
892 | Scsi_Cmnd int_scmd; | ||
893 | struct mutex int_mtx; /* To synchronize the internal | 893 | struct mutex int_mtx; /* To synchronize the internal |
894 | commands */ | 894 | commands */ |
895 | struct completion int_waitq; /* wait queue for internal | 895 | struct completion int_waitq; /* wait queue for internal |
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index f25f41a499e5..b97194096d8e 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h | |||
@@ -2547,7 +2547,6 @@ typedef struct scsi_qla_host { | |||
2547 | uint8_t fcode_revision[16]; | 2547 | uint8_t fcode_revision[16]; |
2548 | uint32_t fw_revision[4]; | 2548 | uint32_t fw_revision[4]; |
2549 | 2549 | ||
2550 | uint16_t fdt_odd_index; | ||
2551 | uint32_t fdt_wrt_disable; | 2550 | uint32_t fdt_wrt_disable; |
2552 | uint32_t fdt_erase_cmd; | 2551 | uint32_t fdt_erase_cmd; |
2553 | uint32_t fdt_block_size; | 2552 | uint32_t fdt_block_size; |
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index a470f2d3270d..4218f20f5ed5 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
@@ -140,7 +140,6 @@ int | |||
140 | qla2100_pci_config(scsi_qla_host_t *ha) | 140 | qla2100_pci_config(scsi_qla_host_t *ha) |
141 | { | 141 | { |
142 | uint16_t w; | 142 | uint16_t w; |
143 | uint32_t d; | ||
144 | unsigned long flags; | 143 | unsigned long flags; |
145 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 144 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
146 | 145 | ||
@@ -151,10 +150,7 @@ qla2100_pci_config(scsi_qla_host_t *ha) | |||
151 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); | 150 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
152 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); | 151 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
153 | 152 | ||
154 | /* Reset expansion ROM address decode enable */ | 153 | pci_disable_rom(ha->pdev); |
155 | pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); | ||
156 | d &= ~PCI_ROM_ADDRESS_ENABLE; | ||
157 | pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d); | ||
158 | 154 | ||
159 | /* Get PCI bus information. */ | 155 | /* Get PCI bus information. */ |
160 | spin_lock_irqsave(&ha->hardware_lock, flags); | 156 | spin_lock_irqsave(&ha->hardware_lock, flags); |
@@ -174,7 +170,6 @@ int | |||
174 | qla2300_pci_config(scsi_qla_host_t *ha) | 170 | qla2300_pci_config(scsi_qla_host_t *ha) |
175 | { | 171 | { |
176 | uint16_t w; | 172 | uint16_t w; |
177 | uint32_t d; | ||
178 | unsigned long flags = 0; | 173 | unsigned long flags = 0; |
179 | uint32_t cnt; | 174 | uint32_t cnt; |
180 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 175 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
@@ -236,10 +231,7 @@ qla2300_pci_config(scsi_qla_host_t *ha) | |||
236 | 231 | ||
237 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); | 232 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); |
238 | 233 | ||
239 | /* Reset expansion ROM address decode enable */ | 234 | pci_disable_rom(ha->pdev); |
240 | pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); | ||
241 | d &= ~PCI_ROM_ADDRESS_ENABLE; | ||
242 | pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d); | ||
243 | 235 | ||
244 | /* Get PCI bus information. */ | 236 | /* Get PCI bus information. */ |
245 | spin_lock_irqsave(&ha->hardware_lock, flags); | 237 | spin_lock_irqsave(&ha->hardware_lock, flags); |
@@ -259,7 +251,6 @@ int | |||
259 | qla24xx_pci_config(scsi_qla_host_t *ha) | 251 | qla24xx_pci_config(scsi_qla_host_t *ha) |
260 | { | 252 | { |
261 | uint16_t w; | 253 | uint16_t w; |
262 | uint32_t d; | ||
263 | unsigned long flags = 0; | 254 | unsigned long flags = 0; |
264 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | 255 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
265 | 256 | ||
@@ -281,10 +272,7 @@ qla24xx_pci_config(scsi_qla_host_t *ha) | |||
281 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) | 272 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) |
282 | pcie_set_readrq(ha->pdev, 2048); | 273 | pcie_set_readrq(ha->pdev, 2048); |
283 | 274 | ||
284 | /* Reset expansion ROM address decode enable */ | 275 | pci_disable_rom(ha->pdev); |
285 | pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); | ||
286 | d &= ~PCI_ROM_ADDRESS_ENABLE; | ||
287 | pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d); | ||
288 | 276 | ||
289 | ha->chip_revision = ha->pdev->revision; | 277 | ha->chip_revision = ha->pdev->revision; |
290 | 278 | ||
@@ -306,7 +294,6 @@ int | |||
306 | qla25xx_pci_config(scsi_qla_host_t *ha) | 294 | qla25xx_pci_config(scsi_qla_host_t *ha) |
307 | { | 295 | { |
308 | uint16_t w; | 296 | uint16_t w; |
309 | uint32_t d; | ||
310 | 297 | ||
311 | pci_set_master(ha->pdev); | 298 | pci_set_master(ha->pdev); |
312 | pci_try_set_mwi(ha->pdev); | 299 | pci_try_set_mwi(ha->pdev); |
@@ -320,10 +307,7 @@ qla25xx_pci_config(scsi_qla_host_t *ha) | |||
320 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) | 307 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) |
321 | pcie_set_readrq(ha->pdev, 2048); | 308 | pcie_set_readrq(ha->pdev, 2048); |
322 | 309 | ||
323 | /* Reset expansion ROM address decode enable */ | 310 | pci_disable_rom(ha->pdev); |
324 | pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); | ||
325 | d &= ~PCI_ROM_ADDRESS_ENABLE; | ||
326 | pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d); | ||
327 | 311 | ||
328 | ha->chip_revision = ha->pdev->revision; | 312 | ha->chip_revision = ha->pdev->revision; |
329 | 313 | ||
@@ -980,7 +964,6 @@ qla2x00_setup_chip(scsi_qla_host_t *ha) | |||
980 | &ha->fw_minor_version, | 964 | &ha->fw_minor_version, |
981 | &ha->fw_subminor_version, | 965 | &ha->fw_subminor_version, |
982 | &ha->fw_attributes, &ha->fw_memory_size); | 966 | &ha->fw_attributes, &ha->fw_memory_size); |
983 | qla2x00_resize_request_q(ha); | ||
984 | ha->flags.npiv_supported = 0; | 967 | ha->flags.npiv_supported = 0; |
985 | if ((IS_QLA24XX(ha) || IS_QLA25XX(ha) || | 968 | if ((IS_QLA24XX(ha) || IS_QLA25XX(ha) || |
986 | IS_QLA84XX(ha)) && | 969 | IS_QLA84XX(ha)) && |
@@ -992,6 +975,7 @@ qla2x00_setup_chip(scsi_qla_host_t *ha) | |||
992 | ha->max_npiv_vports = | 975 | ha->max_npiv_vports = |
993 | MIN_MULTI_ID_FABRIC - 1; | 976 | MIN_MULTI_ID_FABRIC - 1; |
994 | } | 977 | } |
978 | qla2x00_resize_request_q(ha); | ||
995 | 979 | ||
996 | if (ql2xallocfwdump) | 980 | if (ql2xallocfwdump) |
997 | qla2x00_alloc_fw_dump(ha); | 981 | qla2x00_alloc_fw_dump(ha); |
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 36bc6851e23d..3402746ec128 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c | |||
@@ -1964,7 +1964,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt, | |||
1964 | *cur_iocb_cnt = mcp->mb[7]; | 1964 | *cur_iocb_cnt = mcp->mb[7]; |
1965 | if (orig_iocb_cnt) | 1965 | if (orig_iocb_cnt) |
1966 | *orig_iocb_cnt = mcp->mb[10]; | 1966 | *orig_iocb_cnt = mcp->mb[10]; |
1967 | if (max_npiv_vports) | 1967 | if (ha->flags.npiv_supported && max_npiv_vports) |
1968 | *max_npiv_vports = mcp->mb[11]; | 1968 | *max_npiv_vports = mcp->mb[11]; |
1969 | } | 1969 | } |
1970 | 1970 | ||
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 21dd182ad512..35567203ef61 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -728,6 +728,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
728 | if (ha->isp_ops->abort_command(ha, sp)) { | 728 | if (ha->isp_ops->abort_command(ha, sp)) { |
729 | DEBUG2(printk("%s(%ld): abort_command " | 729 | DEBUG2(printk("%s(%ld): abort_command " |
730 | "mbx failed.\n", __func__, ha->host_no)); | 730 | "mbx failed.\n", __func__, ha->host_no)); |
731 | ret = FAILED; | ||
731 | } else { | 732 | } else { |
732 | DEBUG3(printk("%s(%ld): abort_command " | 733 | DEBUG3(printk("%s(%ld): abort_command " |
733 | "mbx success.\n", __func__, ha->host_no)); | 734 | "mbx success.\n", __func__, ha->host_no)); |
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index 90a13211717f..e4af678eb2d6 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c | |||
@@ -722,6 +722,7 @@ done: | |||
722 | static void | 722 | static void |
723 | qla2xxx_get_fdt_info(scsi_qla_host_t *ha) | 723 | qla2xxx_get_fdt_info(scsi_qla_host_t *ha) |
724 | { | 724 | { |
725 | #define FLASH_BLK_SIZE_4K 0x1000 | ||
725 | #define FLASH_BLK_SIZE_32K 0x8000 | 726 | #define FLASH_BLK_SIZE_32K 0x8000 |
726 | #define FLASH_BLK_SIZE_64K 0x10000 | 727 | #define FLASH_BLK_SIZE_64K 0x10000 |
727 | const char *loc, *locations[] = { "MID", "FDT" }; | 728 | const char *loc, *locations[] = { "MID", "FDT" }; |
@@ -755,7 +756,6 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *ha) | |||
755 | loc = locations[1]; | 756 | loc = locations[1]; |
756 | mid = le16_to_cpu(fdt->man_id); | 757 | mid = le16_to_cpu(fdt->man_id); |
757 | fid = le16_to_cpu(fdt->id); | 758 | fid = le16_to_cpu(fdt->id); |
758 | ha->fdt_odd_index = mid == 0x1f; | ||
759 | ha->fdt_wrt_disable = fdt->wrt_disable_bits; | 759 | ha->fdt_wrt_disable = fdt->wrt_disable_bits; |
760 | ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0300 | fdt->erase_cmd); | 760 | ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0300 | fdt->erase_cmd); |
761 | ha->fdt_block_size = le32_to_cpu(fdt->block_size); | 761 | ha->fdt_block_size = le32_to_cpu(fdt->block_size); |
@@ -788,8 +788,7 @@ no_flash_data: | |||
788 | ha->fdt_block_size = FLASH_BLK_SIZE_64K; | 788 | ha->fdt_block_size = FLASH_BLK_SIZE_64K; |
789 | break; | 789 | break; |
790 | case 0x1f: /* Atmel 26DF081A. */ | 790 | case 0x1f: /* Atmel 26DF081A. */ |
791 | ha->fdt_odd_index = 1; | 791 | ha->fdt_block_size = FLASH_BLK_SIZE_4K; |
792 | ha->fdt_block_size = FLASH_BLK_SIZE_64K; | ||
793 | ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0320); | 792 | ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0320); |
794 | ha->fdt_unprotect_sec_cmd = flash_conf_to_access_addr(0x0339); | 793 | ha->fdt_unprotect_sec_cmd = flash_conf_to_access_addr(0x0339); |
795 | ha->fdt_protect_sec_cmd = flash_conf_to_access_addr(0x0336); | 794 | ha->fdt_protect_sec_cmd = flash_conf_to_access_addr(0x0336); |
@@ -801,9 +800,9 @@ no_flash_data: | |||
801 | } | 800 | } |
802 | done: | 801 | done: |
803 | DEBUG2(qla_printk(KERN_DEBUG, ha, "FDT[%s]: (0x%x/0x%x) erase=0x%x " | 802 | DEBUG2(qla_printk(KERN_DEBUG, ha, "FDT[%s]: (0x%x/0x%x) erase=0x%x " |
804 | "pro=%x upro=%x idx=%d wrtd=0x%x blk=0x%x.\n", loc, mid, fid, | 803 | "pro=%x upro=%x wrtd=0x%x blk=0x%x.\n", loc, mid, fid, |
805 | ha->fdt_erase_cmd, ha->fdt_protect_sec_cmd, | 804 | ha->fdt_erase_cmd, ha->fdt_protect_sec_cmd, |
806 | ha->fdt_unprotect_sec_cmd, ha->fdt_odd_index, ha->fdt_wrt_disable, | 805 | ha->fdt_unprotect_sec_cmd, ha->fdt_wrt_disable, |
807 | ha->fdt_block_size)); | 806 | ha->fdt_block_size)); |
808 | } | 807 | } |
809 | 808 | ||
@@ -987,13 +986,9 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, | |||
987 | qla24xx_unprotect_flash(ha); | 986 | qla24xx_unprotect_flash(ha); |
988 | 987 | ||
989 | for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { | 988 | for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { |
990 | if (ha->fdt_odd_index) { | 989 | |
991 | findex = faddr << 2; | 990 | findex = faddr; |
992 | fdata = findex & sec_mask; | 991 | fdata = (findex & sec_mask) << 2; |
993 | } else { | ||
994 | findex = faddr; | ||
995 | fdata = (findex & sec_mask) << 2; | ||
996 | } | ||
997 | 992 | ||
998 | /* Are we at the beginning of a sector? */ | 993 | /* Are we at the beginning of a sector? */ |
999 | if ((findex & rest_addr) == 0) { | 994 | if ((findex & rest_addr) == 0) { |
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index be5e299df528..eea6720adf16 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++ b/drivers/scsi/qla2xxx/qla_version.h | |||
@@ -7,7 +7,7 @@ | |||
7 | /* | 7 | /* |
8 | * Driver version | 8 | * Driver version |
9 | */ | 9 | */ |
10 | #define QLA2XXX_VERSION "8.02.01-k8" | 10 | #define QLA2XXX_VERSION "8.02.01-k9" |
11 | 11 | ||
12 | #define QLA_DRIVER_MAJOR_VER 8 | 12 | #define QLA_DRIVER_MAJOR_VER 8 |
13 | #define QLA_DRIVER_MINOR_VER 2 | 13 | #define QLA_DRIVER_MINOR_VER 2 |
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 94ed262bdf0c..386361778ebb 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -1340,9 +1340,10 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd) | |||
1340 | * LLD/transport was disrupted during processing of the IO. | 1340 | * LLD/transport was disrupted during processing of the IO. |
1341 | * The transport class is now blocked/blocking, | 1341 | * The transport class is now blocked/blocking, |
1342 | * and the transport will decide what to do with the IO | 1342 | * and the transport will decide what to do with the IO |
1343 | * based on its timers and recovery capablilities. | 1343 | * based on its timers and recovery capablilities if |
1344 | * there are enough retries. | ||
1344 | */ | 1345 | */ |
1345 | return ADD_TO_MLQUEUE; | 1346 | goto maybe_retry; |
1346 | case DID_TRANSPORT_FAILFAST: | 1347 | case DID_TRANSPORT_FAILFAST: |
1347 | /* | 1348 | /* |
1348 | * The transport decided to failfast the IO (most likely | 1349 | * The transport decided to failfast the IO (most likely |
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 5c0f32c7fbf6..165fc010978c 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -144,9 +144,9 @@ static void put_char(struct uart_port *port, char c) | |||
144 | status = sci_in(port, SCxSR); | 144 | status = sci_in(port, SCxSR); |
145 | } while (!(status & SCxSR_TDxE(port))); | 145 | } while (!(status & SCxSR_TDxE(port))); |
146 | 146 | ||
147 | sci_out(port, SCxTDR, c); | ||
148 | sci_in(port, SCxSR); /* Dummy read */ | 147 | sci_in(port, SCxSR); /* Dummy read */ |
149 | sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); | 148 | sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); |
149 | sci_out(port, SCxTDR, c); | ||
150 | 150 | ||
151 | spin_unlock_irqrestore(&port->lock, flags); | 151 | spin_unlock_irqrestore(&port->lock, flags); |
152 | } | 152 | } |
@@ -478,10 +478,10 @@ static void sci_transmit_chars(struct uart_port *port) | |||
478 | return; | 478 | return; |
479 | } | 479 | } |
480 | 480 | ||
481 | if (port->type == PORT_SCIF) | 481 | if (port->type == PORT_SCI) |
482 | count = scif_txroom(port); | ||
483 | else | ||
484 | count = sci_txroom(port); | 482 | count = sci_txroom(port); |
483 | else | ||
484 | count = scif_txroom(port); | ||
485 | 485 | ||
486 | do { | 486 | do { |
487 | unsigned char c; | 487 | unsigned char c; |
@@ -510,7 +510,7 @@ static void sci_transmit_chars(struct uart_port *port) | |||
510 | } else { | 510 | } else { |
511 | ctrl = sci_in(port, SCSCR); | 511 | ctrl = sci_in(port, SCSCR); |
512 | 512 | ||
513 | if (port->type == PORT_SCIF) { | 513 | if (port->type != PORT_SCI) { |
514 | sci_in(port, SCxSR); /* Dummy read */ | 514 | sci_in(port, SCxSR); /* Dummy read */ |
515 | sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); | 515 | sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); |
516 | } | 516 | } |
@@ -536,10 +536,10 @@ static inline void sci_receive_chars(struct uart_port *port) | |||
536 | return; | 536 | return; |
537 | 537 | ||
538 | while (1) { | 538 | while (1) { |
539 | if (port->type == PORT_SCIF) | 539 | if (port->type == PORT_SCI) |
540 | count = scif_rxroom(port); | ||
541 | else | ||
542 | count = sci_rxroom(port); | 540 | count = sci_rxroom(port); |
541 | else | ||
542 | count = scif_rxroom(port); | ||
543 | 543 | ||
544 | /* Don't copy more bytes than there is room for in the buffer */ | 544 | /* Don't copy more bytes than there is room for in the buffer */ |
545 | count = tty_buffer_request_room(tty, count); | 545 | count = tty_buffer_request_room(tty, count); |
@@ -714,7 +714,7 @@ static inline int sci_handle_breaks(struct uart_port *port) | |||
714 | 714 | ||
715 | #if defined(SCIF_ORER) | 715 | #if defined(SCIF_ORER) |
716 | /* XXX: Handle SCIF overrun error */ | 716 | /* XXX: Handle SCIF overrun error */ |
717 | if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { | 717 | if (port->type != PORT_SCI && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { |
718 | sci_out(port, SCLSR, 0); | 718 | sci_out(port, SCLSR, 0); |
719 | if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { | 719 | if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { |
720 | copied++; | 720 | copied++; |
@@ -1042,7 +1042,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1042 | 1042 | ||
1043 | sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ | 1043 | sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ |
1044 | 1044 | ||
1045 | if (port->type == PORT_SCIF) | 1045 | if (port->type != PORT_SCI) |
1046 | sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); | 1046 | sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); |
1047 | 1047 | ||
1048 | smr_val = sci_in(port, SCSMR) & 3; | 1048 | smr_val = sci_in(port, SCSMR) & 3; |
@@ -1085,6 +1085,7 @@ static const char *sci_type(struct uart_port *port) | |||
1085 | case PORT_SCI: return "sci"; | 1085 | case PORT_SCI: return "sci"; |
1086 | case PORT_SCIF: return "scif"; | 1086 | case PORT_SCIF: return "scif"; |
1087 | case PORT_IRDA: return "irda"; | 1087 | case PORT_IRDA: return "irda"; |
1088 | case PORT_SCIFA: return "scifa"; | ||
1088 | } | 1089 | } |
1089 | 1090 | ||
1090 | return NULL; | 1091 | return NULL; |
@@ -1112,6 +1113,7 @@ static void sci_config_port(struct uart_port *port, int flags) | |||
1112 | s->init_pins = sci_init_pins_sci; | 1113 | s->init_pins = sci_init_pins_sci; |
1113 | break; | 1114 | break; |
1114 | case PORT_SCIF: | 1115 | case PORT_SCIF: |
1116 | case PORT_SCIFA: | ||
1115 | s->init_pins = sci_init_pins_scif; | 1117 | s->init_pins = sci_init_pins_scif; |
1116 | break; | 1118 | break; |
1117 | case PORT_IRDA: | 1119 | case PORT_IRDA: |
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index 6163a45f968f..9f33b064172e 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h | |||
@@ -289,18 +289,18 @@ | |||
289 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ | 289 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ |
290 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ | 290 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
291 | { \ | 291 | { \ |
292 | if (port->type == PORT_SCI) { \ | 292 | if (port->type == PORT_SCIF) { \ |
293 | SCI_IN(sci_size, sci_offset) \ | 293 | SCI_IN(scif_size, scif_offset) \ |
294 | } else { \ | 294 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
295 | SCI_IN(scif_size, scif_offset); \ | 295 | SCI_IN(sci_size, sci_offset); \ |
296 | } \ | 296 | } \ |
297 | } \ | 297 | } \ |
298 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ | 298 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
299 | { \ | 299 | { \ |
300 | if (port->type == PORT_SCI) { \ | 300 | if (port->type == PORT_SCIF) { \ |
301 | SCI_OUT(sci_size, sci_offset, value) \ | 301 | SCI_OUT(scif_size, scif_offset, value) \ |
302 | } else { \ | 302 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
303 | SCI_OUT(scif_size, scif_offset, value); \ | 303 | SCI_OUT(sci_size, sci_offset, value); \ |
304 | } \ | 304 | } \ |
305 | } | 305 | } |
306 | 306 | ||
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 02f9320f3efc..8abae4ad0fa5 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c | |||
@@ -766,6 +766,7 @@ static int __init atmel_spi_probe(struct platform_device *pdev) | |||
766 | /* Initialize the hardware */ | 766 | /* Initialize the hardware */ |
767 | clk_enable(clk); | 767 | clk_enable(clk); |
768 | spi_writel(as, CR, SPI_BIT(SWRST)); | 768 | spi_writel(as, CR, SPI_BIT(SWRST)); |
769 | spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ | ||
769 | spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS)); | 770 | spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS)); |
770 | spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); | 771 | spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); |
771 | spi_writel(as, CR, SPI_BIT(SPIEN)); | 772 | spi_writel(as, CR, SPI_BIT(SPIEN)); |
@@ -782,6 +783,7 @@ static int __init atmel_spi_probe(struct platform_device *pdev) | |||
782 | 783 | ||
783 | out_reset_hw: | 784 | out_reset_hw: |
784 | spi_writel(as, CR, SPI_BIT(SWRST)); | 785 | spi_writel(as, CR, SPI_BIT(SWRST)); |
786 | spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ | ||
785 | clk_disable(clk); | 787 | clk_disable(clk); |
786 | free_irq(irq, master); | 788 | free_irq(irq, master); |
787 | out_unmap_regs: | 789 | out_unmap_regs: |
@@ -805,6 +807,7 @@ static int __exit atmel_spi_remove(struct platform_device *pdev) | |||
805 | spin_lock_irq(&as->lock); | 807 | spin_lock_irq(&as->lock); |
806 | as->stopping = 1; | 808 | as->stopping = 1; |
807 | spi_writel(as, CR, SPI_BIT(SWRST)); | 809 | spi_writel(as, CR, SPI_BIT(SWRST)); |
810 | spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ | ||
808 | spi_readl(as, SR); | 811 | spi_readl(as, SR); |
809 | spin_unlock_irq(&as->lock); | 812 | spin_unlock_irq(&as->lock); |
810 | 813 | ||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 20104443081a..d50a99f70aee 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -158,16 +158,12 @@ static int acm_wb_is_avail(struct acm *acm) | |||
158 | } | 158 | } |
159 | 159 | ||
160 | /* | 160 | /* |
161 | * Finish write. | 161 | * Finish write. Caller must hold acm->write_lock |
162 | */ | 162 | */ |
163 | static void acm_write_done(struct acm *acm, struct acm_wb *wb) | 163 | static void acm_write_done(struct acm *acm, struct acm_wb *wb) |
164 | { | 164 | { |
165 | unsigned long flags; | ||
166 | |||
167 | spin_lock_irqsave(&acm->write_lock, flags); | ||
168 | wb->use = 0; | 165 | wb->use = 0; |
169 | acm->transmitting--; | 166 | acm->transmitting--; |
170 | spin_unlock_irqrestore(&acm->write_lock, flags); | ||
171 | } | 167 | } |
172 | 168 | ||
173 | /* | 169 | /* |
@@ -482,6 +478,7 @@ static void acm_write_bulk(struct urb *urb) | |||
482 | { | 478 | { |
483 | struct acm_wb *wb = urb->context; | 479 | struct acm_wb *wb = urb->context; |
484 | struct acm *acm = wb->instance; | 480 | struct acm *acm = wb->instance; |
481 | unsigned long flags; | ||
485 | 482 | ||
486 | if (verbose || urb->status | 483 | if (verbose || urb->status |
487 | || (urb->actual_length != urb->transfer_buffer_length)) | 484 | || (urb->actual_length != urb->transfer_buffer_length)) |
@@ -490,7 +487,9 @@ static void acm_write_bulk(struct urb *urb) | |||
490 | urb->transfer_buffer_length, | 487 | urb->transfer_buffer_length, |
491 | urb->status); | 488 | urb->status); |
492 | 489 | ||
490 | spin_lock_irqsave(&acm->write_lock, flags); | ||
493 | acm_write_done(acm, wb); | 491 | acm_write_done(acm, wb); |
492 | spin_unlock_irqrestore(&acm->write_lock, flags); | ||
494 | if (ACM_READY(acm)) | 493 | if (ACM_READY(acm)) |
495 | schedule_work(&acm->work); | 494 | schedule_work(&acm->work); |
496 | else | 495 | else |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 887738577b28..6d1048faf08e 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -1091,6 +1091,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1091 | continue; | 1091 | continue; |
1092 | dev_dbg(&dev->dev, "unregistering interface %s\n", | 1092 | dev_dbg(&dev->dev, "unregistering interface %s\n", |
1093 | dev_name(&interface->dev)); | 1093 | dev_name(&interface->dev)); |
1094 | interface->unregistering = 1; | ||
1094 | usb_remove_sysfs_intf_files(interface); | 1095 | usb_remove_sysfs_intf_files(interface); |
1095 | device_del(&interface->dev); | 1096 | device_del(&interface->dev); |
1096 | } | 1097 | } |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index f66fba11fbd5..4fb65fdc9dc3 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -840,7 +840,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf) | |||
840 | struct usb_host_interface *alt = intf->cur_altsetting; | 840 | struct usb_host_interface *alt = intf->cur_altsetting; |
841 | int retval; | 841 | int retval; |
842 | 842 | ||
843 | if (intf->sysfs_files_created) | 843 | if (intf->sysfs_files_created || intf->unregistering) |
844 | return 0; | 844 | return 0; |
845 | 845 | ||
846 | /* The interface string may be present in some altsettings | 846 | /* The interface string may be present in some altsettings |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 4342bd9c3bb6..1f68af9db3f7 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -85,8 +85,8 @@ EXPORT_SYMBOL_GPL(usb_alloc_urb); | |||
85 | * Must be called when a user of a urb is finished with it. When the last user | 85 | * Must be called when a user of a urb is finished with it. When the last user |
86 | * of the urb calls this function, the memory of the urb is freed. | 86 | * of the urb calls this function, the memory of the urb is freed. |
87 | * | 87 | * |
88 | * Note: The transfer buffer associated with the urb is not freed, that must be | 88 | * Note: The transfer buffer associated with the urb is not freed unless the |
89 | * done elsewhere. | 89 | * URB_FREE_BUFFER transfer flag is set. |
90 | */ | 90 | */ |
91 | void usb_free_urb(struct urb *urb) | 91 | void usb_free_urb(struct urb *urb) |
92 | { | 92 | { |
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index 5ee1590b8e9c..c1d34df0b157 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
@@ -463,7 +463,11 @@ static int acm_cdc_notify(struct f_acm *acm, u8 type, u16 value, | |||
463 | notify->wLength = cpu_to_le16(length); | 463 | notify->wLength = cpu_to_le16(length); |
464 | memcpy(buf, data, length); | 464 | memcpy(buf, data, length); |
465 | 465 | ||
466 | /* ep_queue() can complete immediately if it fills the fifo... */ | ||
467 | spin_unlock(&acm->lock); | ||
466 | status = usb_ep_queue(ep, req, GFP_ATOMIC); | 468 | status = usb_ep_queue(ep, req, GFP_ATOMIC); |
469 | spin_lock(&acm->lock); | ||
470 | |||
467 | if (status < 0) { | 471 | if (status < 0) { |
468 | ERROR(acm->port.func.config->cdev, | 472 | ERROR(acm->port.func.config->cdev, |
469 | "acm ttyGS%d can't notify serial state, %d\n", | 473 | "acm ttyGS%d can't notify serial state, %d\n", |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 56f592dc0b36..f3a75a929e0a 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -110,29 +110,18 @@ config USB_ISP116X_HCD | |||
110 | 110 | ||
111 | config USB_ISP1760_HCD | 111 | config USB_ISP1760_HCD |
112 | tristate "ISP 1760 HCD support" | 112 | tristate "ISP 1760 HCD support" |
113 | depends on USB && EXPERIMENTAL | 113 | depends on USB && EXPERIMENTAL && (PCI || PPC_OF) |
114 | ---help--- | 114 | ---help--- |
115 | The ISP1760 chip is a USB 2.0 host controller. | 115 | The ISP1760 chip is a USB 2.0 host controller. |
116 | 116 | ||
117 | This driver does not support isochronous transfers or OTG. | 117 | This driver does not support isochronous transfers or OTG. |
118 | This USB controller is usually attached to a non-DMA-Master | ||
119 | capable bus. NXP's eval kit brings this chip on PCI card | ||
120 | where the chip itself is behind a PLB to simulate such | ||
121 | a bus. | ||
118 | 122 | ||
119 | To compile this driver as a module, choose M here: the | 123 | To compile this driver as a module, choose M here: the |
120 | module will be called isp1760-hcd. | 124 | module will be called isp1760. |
121 | |||
122 | config USB_ISP1760_PCI | ||
123 | bool "Support for the PCI bus" | ||
124 | depends on USB_ISP1760_HCD && PCI | ||
125 | ---help--- | ||
126 | Enables support for the device present on the PCI bus. | ||
127 | This should only be required if you happen to have the eval kit from | ||
128 | NXP and you are going to test it. | ||
129 | |||
130 | config USB_ISP1760_OF | ||
131 | bool "Support for the OF platform bus" | ||
132 | depends on USB_ISP1760_HCD && PPC_OF | ||
133 | ---help--- | ||
134 | Enables support for the device present on the PowerPC | ||
135 | OpenFirmware platform bus. | ||
136 | 125 | ||
137 | config USB_OHCI_HCD | 126 | config USB_OHCI_HCD |
138 | tristate "OHCI HCD support" | 127 | tristate "OHCI HCD support" |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 15a803b206b8..4725d15d096f 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -643,7 +643,7 @@ static int ehci_run (struct usb_hcd *hcd) | |||
643 | static irqreturn_t ehci_irq (struct usb_hcd *hcd) | 643 | static irqreturn_t ehci_irq (struct usb_hcd *hcd) |
644 | { | 644 | { |
645 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 645 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
646 | u32 status, pcd_status = 0, cmd; | 646 | u32 status, masked_status, pcd_status = 0, cmd; |
647 | int bh; | 647 | int bh; |
648 | 648 | ||
649 | spin_lock (&ehci->lock); | 649 | spin_lock (&ehci->lock); |
@@ -656,14 +656,14 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
656 | goto dead; | 656 | goto dead; |
657 | } | 657 | } |
658 | 658 | ||
659 | status &= INTR_MASK; | 659 | masked_status = status & INTR_MASK; |
660 | if (!status) { /* irq sharing? */ | 660 | if (!masked_status) { /* irq sharing? */ |
661 | spin_unlock(&ehci->lock); | 661 | spin_unlock(&ehci->lock); |
662 | return IRQ_NONE; | 662 | return IRQ_NONE; |
663 | } | 663 | } |
664 | 664 | ||
665 | /* clear (just) interrupts */ | 665 | /* clear (just) interrupts */ |
666 | ehci_writel(ehci, status, &ehci->regs->status); | 666 | ehci_writel(ehci, masked_status, &ehci->regs->status); |
667 | cmd = ehci_readl(ehci, &ehci->regs->command); | 667 | cmd = ehci_readl(ehci, &ehci->regs->command); |
668 | bh = 0; | 668 | bh = 0; |
669 | 669 | ||
@@ -734,18 +734,17 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
734 | 734 | ||
735 | /* PCI errors [4.15.2.4] */ | 735 | /* PCI errors [4.15.2.4] */ |
736 | if (unlikely ((status & STS_FATAL) != 0)) { | 736 | if (unlikely ((status & STS_FATAL) != 0)) { |
737 | ehci_err(ehci, "fatal error\n"); | ||
737 | dbg_cmd(ehci, "fatal", cmd); | 738 | dbg_cmd(ehci, "fatal", cmd); |
738 | dbg_status(ehci, "fatal", status); | 739 | dbg_status(ehci, "fatal", status); |
739 | if (status & STS_HALT) { | 740 | ehci_halt(ehci); |
740 | ehci_err (ehci, "fatal error\n"); | ||
741 | dead: | 741 | dead: |
742 | ehci_reset (ehci); | 742 | ehci_reset(ehci); |
743 | ehci_writel(ehci, 0, &ehci->regs->configured_flag); | 743 | ehci_writel(ehci, 0, &ehci->regs->configured_flag); |
744 | /* generic layer kills/unlinks all urbs, then | 744 | /* generic layer kills/unlinks all urbs, then |
745 | * uses ehci_stop to clean up the rest | 745 | * uses ehci_stop to clean up the rest |
746 | */ | 746 | */ |
747 | bh = 1; | 747 | bh = 1; |
748 | } | ||
749 | } | 748 | } |
750 | 749 | ||
751 | if (bh) | 750 | if (bh) |
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index 0eba894bcb01..9c9da35abc6c 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c | |||
@@ -205,6 +205,7 @@ static int ps3_ehci_remove(struct ps3_system_bus_device *dev) | |||
205 | 205 | ||
206 | tmp = hcd->irq; | 206 | tmp = hcd->irq; |
207 | 207 | ||
208 | ehci_shutdown(hcd); | ||
208 | usb_remove_hcd(hcd); | 209 | usb_remove_hcd(hcd); |
209 | 210 | ||
210 | ps3_system_bus_set_driver_data(dev, NULL); | 211 | ps3_system_bus_set_driver_data(dev, NULL); |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 4a0c5a78b2ed..a081ee65bde6 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -918,7 +918,7 @@ iso_stream_init ( | |||
918 | */ | 918 | */ |
919 | stream->usecs = HS_USECS_ISO (maxp); | 919 | stream->usecs = HS_USECS_ISO (maxp); |
920 | bandwidth = stream->usecs * 8; | 920 | bandwidth = stream->usecs * 8; |
921 | bandwidth /= 1 << (interval - 1); | 921 | bandwidth /= interval; |
922 | 922 | ||
923 | } else { | 923 | } else { |
924 | u32 addr; | 924 | u32 addr; |
@@ -951,7 +951,7 @@ iso_stream_init ( | |||
951 | } else | 951 | } else |
952 | stream->raw_mask = smask_out [hs_transfers - 1]; | 952 | stream->raw_mask = smask_out [hs_transfers - 1]; |
953 | bandwidth = stream->usecs + stream->c_usecs; | 953 | bandwidth = stream->usecs + stream->c_usecs; |
954 | bandwidth /= 1 << (interval + 2); | 954 | bandwidth /= interval << 3; |
955 | 955 | ||
956 | /* stream->splits gets created from raw_mask later */ | 956 | /* stream->splits gets created from raw_mask later */ |
957 | stream->address = cpu_to_hc32(ehci, addr); | 957 | stream->address = cpu_to_hc32(ehci, addr); |
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index af849f596135..b87ca7cf4b37 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c | |||
@@ -14,16 +14,16 @@ | |||
14 | #include "../core/hcd.h" | 14 | #include "../core/hcd.h" |
15 | #include "isp1760-hcd.h" | 15 | #include "isp1760-hcd.h" |
16 | 16 | ||
17 | #ifdef CONFIG_USB_ISP1760_OF | 17 | #ifdef CONFIG_PPC_OF |
18 | #include <linux/of.h> | 18 | #include <linux/of.h> |
19 | #include <linux/of_platform.h> | 19 | #include <linux/of_platform.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | #ifdef CONFIG_USB_ISP1760_PCI | 22 | #ifdef CONFIG_PCI |
23 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | #ifdef CONFIG_USB_ISP1760_OF | 26 | #ifdef CONFIG_PPC_OF |
27 | static int of_isp1760_probe(struct of_device *dev, | 27 | static int of_isp1760_probe(struct of_device *dev, |
28 | const struct of_device_id *match) | 28 | const struct of_device_id *match) |
29 | { | 29 | { |
@@ -128,7 +128,7 @@ static struct of_platform_driver isp1760_of_driver = { | |||
128 | }; | 128 | }; |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef CONFIG_USB_ISP1760_PCI | 131 | #ifdef CONFIG_PCI |
132 | static u32 nxp_pci_io_base; | 132 | static u32 nxp_pci_io_base; |
133 | static u32 iolength; | 133 | static u32 iolength; |
134 | static u32 pci_mem_phy0; | 134 | static u32 pci_mem_phy0; |
@@ -288,28 +288,28 @@ static struct pci_driver isp1761_pci_driver = { | |||
288 | 288 | ||
289 | static int __init isp1760_init(void) | 289 | static int __init isp1760_init(void) |
290 | { | 290 | { |
291 | int ret = -ENODEV; | 291 | int ret; |
292 | 292 | ||
293 | init_kmem_once(); | 293 | init_kmem_once(); |
294 | 294 | ||
295 | #ifdef CONFIG_USB_ISP1760_OF | 295 | #ifdef CONFIG_PPC_OF |
296 | ret = of_register_platform_driver(&isp1760_of_driver); | 296 | ret = of_register_platform_driver(&isp1760_of_driver); |
297 | if (ret) { | 297 | if (ret) { |
298 | deinit_kmem_cache(); | 298 | deinit_kmem_cache(); |
299 | return ret; | 299 | return ret; |
300 | } | 300 | } |
301 | #endif | 301 | #endif |
302 | #ifdef CONFIG_USB_ISP1760_PCI | 302 | #ifdef CONFIG_PCI |
303 | ret = pci_register_driver(&isp1761_pci_driver); | 303 | ret = pci_register_driver(&isp1761_pci_driver); |
304 | if (ret) | 304 | if (ret) |
305 | goto unreg_of; | 305 | goto unreg_of; |
306 | #endif | 306 | #endif |
307 | return ret; | 307 | return ret; |
308 | 308 | ||
309 | #ifdef CONFIG_USB_ISP1760_PCI | 309 | #ifdef CONFIG_PCI |
310 | unreg_of: | 310 | unreg_of: |
311 | #endif | 311 | #endif |
312 | #ifdef CONFIG_USB_ISP1760_OF | 312 | #ifdef CONFIG_PPC_OF |
313 | of_unregister_platform_driver(&isp1760_of_driver); | 313 | of_unregister_platform_driver(&isp1760_of_driver); |
314 | #endif | 314 | #endif |
315 | deinit_kmem_cache(); | 315 | deinit_kmem_cache(); |
@@ -319,10 +319,10 @@ module_init(isp1760_init); | |||
319 | 319 | ||
320 | static void __exit isp1760_exit(void) | 320 | static void __exit isp1760_exit(void) |
321 | { | 321 | { |
322 | #ifdef CONFIG_USB_ISP1760_OF | 322 | #ifdef CONFIG_PPC_OF |
323 | of_unregister_platform_driver(&isp1760_of_driver); | 323 | of_unregister_platform_driver(&isp1760_of_driver); |
324 | #endif | 324 | #endif |
325 | #ifdef CONFIG_USB_ISP1760_PCI | 325 | #ifdef CONFIG_PCI |
326 | pci_unregister_driver(&isp1761_pci_driver); | 326 | pci_unregister_driver(&isp1761_pci_driver); |
327 | #endif | 327 | #endif |
328 | deinit_kmem_cache(); | 328 | deinit_kmem_cache(); |
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c index 2089d8a46c4b..3c1a3b5f89f1 100644 --- a/drivers/usb/host/ohci-ps3.c +++ b/drivers/usb/host/ohci-ps3.c | |||
@@ -192,7 +192,7 @@ fail_start: | |||
192 | return result; | 192 | return result; |
193 | } | 193 | } |
194 | 194 | ||
195 | static int ps3_ohci_remove (struct ps3_system_bus_device *dev) | 195 | static int ps3_ohci_remove(struct ps3_system_bus_device *dev) |
196 | { | 196 | { |
197 | unsigned int tmp; | 197 | unsigned int tmp; |
198 | struct usb_hcd *hcd = | 198 | struct usb_hcd *hcd = |
@@ -205,6 +205,7 @@ static int ps3_ohci_remove (struct ps3_system_bus_device *dev) | |||
205 | 205 | ||
206 | tmp = hcd->irq; | 206 | tmp = hcd->irq; |
207 | 207 | ||
208 | ohci_shutdown(hcd); | ||
208 | usb_remove_hcd(hcd); | 209 | usb_remove_hcd(hcd); |
209 | 210 | ||
210 | ps3_system_bus_set_driver_data(dev, NULL); | 211 | ps3_system_bus_set_driver_data(dev, NULL); |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index c18d8790c410..2376f24f3c83 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -1763,11 +1763,12 @@ static void r8a66597_timer(unsigned long _r8a66597) | |||
1763 | { | 1763 | { |
1764 | struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; | 1764 | struct r8a66597 *r8a66597 = (struct r8a66597 *)_r8a66597; |
1765 | unsigned long flags; | 1765 | unsigned long flags; |
1766 | int port; | ||
1766 | 1767 | ||
1767 | spin_lock_irqsave(&r8a66597->lock, flags); | 1768 | spin_lock_irqsave(&r8a66597->lock, flags); |
1768 | 1769 | ||
1769 | r8a66597_root_hub_control(r8a66597, 0); | 1770 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) |
1770 | r8a66597_root_hub_control(r8a66597, 1); | 1771 | r8a66597_root_hub_control(r8a66597, port); |
1771 | 1772 | ||
1772 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1773 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
1773 | } | 1774 | } |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 69c34a58e205..b4ec716de7da 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -3270,6 +3270,7 @@ static struct usb_device_id sisusb_table [] = { | |||
3270 | { USB_DEVICE(0x0711, 0x0900) }, | 3270 | { USB_DEVICE(0x0711, 0x0900) }, |
3271 | { USB_DEVICE(0x0711, 0x0901) }, | 3271 | { USB_DEVICE(0x0711, 0x0901) }, |
3272 | { USB_DEVICE(0x0711, 0x0902) }, | 3272 | { USB_DEVICE(0x0711, 0x0902) }, |
3273 | { USB_DEVICE(0x0711, 0x0903) }, | ||
3273 | { USB_DEVICE(0x0711, 0x0918) }, | 3274 | { USB_DEVICE(0x0711, 0x0918) }, |
3274 | { USB_DEVICE(0x182d, 0x021c) }, | 3275 | { USB_DEVICE(0x182d, 0x021c) }, |
3275 | { USB_DEVICE(0x182d, 0x0269) }, | 3276 | { USB_DEVICE(0x182d, 0x0269) }, |
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c index 8648470c81ca..63dff9ba73c5 100644 --- a/drivers/usb/misc/vstusb.c +++ b/drivers/usb/misc/vstusb.c | |||
@@ -620,7 +620,7 @@ static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
620 | __func__); | 620 | __func__); |
621 | retval = -EFAULT; | 621 | retval = -EFAULT; |
622 | } else { | 622 | } else { |
623 | dev_dbg(&dev->dev, "%s: recv %d bytes from pipe %d\n", | 623 | dev_dbg(&dev->dev, "%s: recv %zd bytes from pipe %d\n", |
624 | __func__, usb_data.count, usb_data.pipe); | 624 | __func__, usb_data.count, usb_data.pipe); |
625 | } | 625 | } |
626 | 626 | ||
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 4a35745b30be..5280dba9b1fb 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -114,8 +114,8 @@ | |||
114 | 114 | ||
115 | 115 | ||
116 | 116 | ||
117 | unsigned debug; | 117 | unsigned musb_debug; |
118 | module_param(debug, uint, S_IRUGO | S_IWUSR); | 118 | module_param(musb_debug, uint, S_IRUGO | S_IWUSR); |
119 | MODULE_PARM_DESC(debug, "Debug message level. Default = 0"); | 119 | MODULE_PARM_DESC(debug, "Debug message level. Default = 0"); |
120 | 120 | ||
121 | #define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia" | 121 | #define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia" |
@@ -2248,7 +2248,7 @@ static int __init musb_init(void) | |||
2248 | "host" | 2248 | "host" |
2249 | #endif | 2249 | #endif |
2250 | ", debug=%d\n", | 2250 | ", debug=%d\n", |
2251 | musb_driver_name, debug); | 2251 | musb_driver_name, musb_debug); |
2252 | return platform_driver_probe(&musb_driver, musb_probe); | 2252 | return platform_driver_probe(&musb_driver, musb_probe); |
2253 | } | 2253 | } |
2254 | 2254 | ||
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h index 4d2794441b15..9fc1db44c72c 100644 --- a/drivers/usb/musb/musb_debug.h +++ b/drivers/usb/musb/musb_debug.h | |||
@@ -48,11 +48,11 @@ | |||
48 | __func__, __LINE__ , ## args); \ | 48 | __func__, __LINE__ , ## args); \ |
49 | } } while (0) | 49 | } } while (0) |
50 | 50 | ||
51 | extern unsigned debug; | 51 | extern unsigned musb_debug; |
52 | 52 | ||
53 | static inline int _dbg_level(unsigned l) | 53 | static inline int _dbg_level(unsigned l) |
54 | { | 54 | { |
55 | return debug >= l; | 55 | return musb_debug >= l; |
56 | } | 56 | } |
57 | 57 | ||
58 | #define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args) | 58 | #define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args) |
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 3133990f04ec..e45e70bcc5e2 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -378,6 +378,19 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status) | |||
378 | 378 | ||
379 | switch (qh->type) { | 379 | switch (qh->type) { |
380 | 380 | ||
381 | case USB_ENDPOINT_XFER_CONTROL: | ||
382 | case USB_ENDPOINT_XFER_BULK: | ||
383 | /* fifo policy for these lists, except that NAKing | ||
384 | * should rotate a qh to the end (for fairness). | ||
385 | */ | ||
386 | if (qh->mux == 1) { | ||
387 | head = qh->ring.prev; | ||
388 | list_del(&qh->ring); | ||
389 | kfree(qh); | ||
390 | qh = first_qh(head); | ||
391 | break; | ||
392 | } | ||
393 | |||
381 | case USB_ENDPOINT_XFER_ISOC: | 394 | case USB_ENDPOINT_XFER_ISOC: |
382 | case USB_ENDPOINT_XFER_INT: | 395 | case USB_ENDPOINT_XFER_INT: |
383 | /* this is where periodic bandwidth should be | 396 | /* this is where periodic bandwidth should be |
@@ -388,17 +401,6 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status) | |||
388 | kfree(qh); | 401 | kfree(qh); |
389 | qh = NULL; | 402 | qh = NULL; |
390 | break; | 403 | break; |
391 | |||
392 | case USB_ENDPOINT_XFER_CONTROL: | ||
393 | case USB_ENDPOINT_XFER_BULK: | ||
394 | /* fifo policy for these lists, except that NAKing | ||
395 | * should rotate a qh to the end (for fairness). | ||
396 | */ | ||
397 | head = qh->ring.prev; | ||
398 | list_del(&qh->ring); | ||
399 | kfree(qh); | ||
400 | qh = first_qh(head); | ||
401 | break; | ||
402 | } | 404 | } |
403 | } | 405 | } |
404 | return qh; | 406 | return qh; |
@@ -1507,10 +1509,29 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1507 | musb_writew(hw_ep->regs, MUSB_RXCSR, val); | 1509 | musb_writew(hw_ep->regs, MUSB_RXCSR, val); |
1508 | 1510 | ||
1509 | #ifdef CONFIG_USB_INVENTRA_DMA | 1511 | #ifdef CONFIG_USB_INVENTRA_DMA |
1512 | if (usb_pipeisoc(pipe)) { | ||
1513 | struct usb_iso_packet_descriptor *d; | ||
1514 | |||
1515 | d = urb->iso_frame_desc + qh->iso_idx; | ||
1516 | d->actual_length = xfer_len; | ||
1517 | |||
1518 | /* even if there was an error, we did the dma | ||
1519 | * for iso_frame_desc->length | ||
1520 | */ | ||
1521 | if (d->status != EILSEQ && d->status != -EOVERFLOW) | ||
1522 | d->status = 0; | ||
1523 | |||
1524 | if (++qh->iso_idx >= urb->number_of_packets) | ||
1525 | done = true; | ||
1526 | else | ||
1527 | done = false; | ||
1528 | |||
1529 | } else { | ||
1510 | /* done if urb buffer is full or short packet is recd */ | 1530 | /* done if urb buffer is full or short packet is recd */ |
1511 | done = (urb->actual_length + xfer_len >= | 1531 | done = (urb->actual_length + xfer_len >= |
1512 | urb->transfer_buffer_length | 1532 | urb->transfer_buffer_length |
1513 | || dma->actual_len < qh->maxpacket); | 1533 | || dma->actual_len < qh->maxpacket); |
1534 | } | ||
1514 | 1535 | ||
1515 | /* send IN token for next packet, without AUTOREQ */ | 1536 | /* send IN token for next packet, without AUTOREQ */ |
1516 | if (!done) { | 1537 | if (!done) { |
@@ -1547,7 +1568,8 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1547 | if (dma) { | 1568 | if (dma) { |
1548 | struct dma_controller *c; | 1569 | struct dma_controller *c; |
1549 | u16 rx_count; | 1570 | u16 rx_count; |
1550 | int ret; | 1571 | int ret, length; |
1572 | dma_addr_t buf; | ||
1551 | 1573 | ||
1552 | rx_count = musb_readw(epio, MUSB_RXCOUNT); | 1574 | rx_count = musb_readw(epio, MUSB_RXCOUNT); |
1553 | 1575 | ||
@@ -1560,6 +1582,35 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1560 | 1582 | ||
1561 | c = musb->dma_controller; | 1583 | c = musb->dma_controller; |
1562 | 1584 | ||
1585 | if (usb_pipeisoc(pipe)) { | ||
1586 | int status = 0; | ||
1587 | struct usb_iso_packet_descriptor *d; | ||
1588 | |||
1589 | d = urb->iso_frame_desc + qh->iso_idx; | ||
1590 | |||
1591 | if (iso_err) { | ||
1592 | status = -EILSEQ; | ||
1593 | urb->error_count++; | ||
1594 | } | ||
1595 | if (rx_count > d->length) { | ||
1596 | if (status == 0) { | ||
1597 | status = -EOVERFLOW; | ||
1598 | urb->error_count++; | ||
1599 | } | ||
1600 | DBG(2, "** OVERFLOW %d into %d\n",\ | ||
1601 | rx_count, d->length); | ||
1602 | |||
1603 | length = d->length; | ||
1604 | } else | ||
1605 | length = rx_count; | ||
1606 | d->status = status; | ||
1607 | buf = urb->transfer_dma + d->offset; | ||
1608 | } else { | ||
1609 | length = rx_count; | ||
1610 | buf = urb->transfer_dma + | ||
1611 | urb->actual_length; | ||
1612 | } | ||
1613 | |||
1563 | dma->desired_mode = 0; | 1614 | dma->desired_mode = 0; |
1564 | #ifdef USE_MODE1 | 1615 | #ifdef USE_MODE1 |
1565 | /* because of the issue below, mode 1 will | 1616 | /* because of the issue below, mode 1 will |
@@ -1571,6 +1622,12 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1571 | urb->actual_length) | 1622 | urb->actual_length) |
1572 | > qh->maxpacket) | 1623 | > qh->maxpacket) |
1573 | dma->desired_mode = 1; | 1624 | dma->desired_mode = 1; |
1625 | if (rx_count < hw_ep->max_packet_sz_rx) { | ||
1626 | length = rx_count; | ||
1627 | dma->bDesiredMode = 0; | ||
1628 | } else { | ||
1629 | length = urb->transfer_buffer_length; | ||
1630 | } | ||
1574 | #endif | 1631 | #endif |
1575 | 1632 | ||
1576 | /* Disadvantage of using mode 1: | 1633 | /* Disadvantage of using mode 1: |
@@ -1608,12 +1665,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1608 | */ | 1665 | */ |
1609 | ret = c->channel_program( | 1666 | ret = c->channel_program( |
1610 | dma, qh->maxpacket, | 1667 | dma, qh->maxpacket, |
1611 | dma->desired_mode, | 1668 | dma->desired_mode, buf, length); |
1612 | urb->transfer_dma | ||
1613 | + urb->actual_length, | ||
1614 | (dma->desired_mode == 0) | ||
1615 | ? rx_count | ||
1616 | : urb->transfer_buffer_length); | ||
1617 | 1669 | ||
1618 | if (!ret) { | 1670 | if (!ret) { |
1619 | c->channel_release(dma); | 1671 | c->channel_release(dma); |
@@ -1631,19 +1683,6 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1631 | } | 1683 | } |
1632 | } | 1684 | } |
1633 | 1685 | ||
1634 | if (dma && usb_pipeisoc(pipe)) { | ||
1635 | struct usb_iso_packet_descriptor *d; | ||
1636 | int iso_stat = status; | ||
1637 | |||
1638 | d = urb->iso_frame_desc + qh->iso_idx; | ||
1639 | d->actual_length += xfer_len; | ||
1640 | if (iso_err) { | ||
1641 | iso_stat = -EILSEQ; | ||
1642 | urb->error_count++; | ||
1643 | } | ||
1644 | d->status = iso_stat; | ||
1645 | } | ||
1646 | |||
1647 | finish: | 1686 | finish: |
1648 | urb->actual_length += xfer_len; | 1687 | urb->actual_length += xfer_len; |
1649 | qh->offset += xfer_len; | 1688 | qh->offset += xfer_len; |
@@ -1671,22 +1710,9 @@ static int musb_schedule( | |||
1671 | struct list_head *head = NULL; | 1710 | struct list_head *head = NULL; |
1672 | 1711 | ||
1673 | /* use fixed hardware for control and bulk */ | 1712 | /* use fixed hardware for control and bulk */ |
1674 | switch (qh->type) { | 1713 | if (qh->type == USB_ENDPOINT_XFER_CONTROL) { |
1675 | case USB_ENDPOINT_XFER_CONTROL: | ||
1676 | head = &musb->control; | 1714 | head = &musb->control; |
1677 | hw_ep = musb->control_ep; | 1715 | hw_ep = musb->control_ep; |
1678 | break; | ||
1679 | case USB_ENDPOINT_XFER_BULK: | ||
1680 | hw_ep = musb->bulk_ep; | ||
1681 | if (is_in) | ||
1682 | head = &musb->in_bulk; | ||
1683 | else | ||
1684 | head = &musb->out_bulk; | ||
1685 | break; | ||
1686 | } | ||
1687 | if (head) { | ||
1688 | idle = list_empty(head); | ||
1689 | list_add_tail(&qh->ring, head); | ||
1690 | goto success; | 1716 | goto success; |
1691 | } | 1717 | } |
1692 | 1718 | ||
@@ -1725,19 +1751,34 @@ static int musb_schedule( | |||
1725 | else | 1751 | else |
1726 | diff = hw_ep->max_packet_sz_tx - qh->maxpacket; | 1752 | diff = hw_ep->max_packet_sz_tx - qh->maxpacket; |
1727 | 1753 | ||
1728 | if (diff > 0 && best_diff > diff) { | 1754 | if (diff >= 0 && best_diff > diff) { |
1729 | best_diff = diff; | 1755 | best_diff = diff; |
1730 | best_end = epnum; | 1756 | best_end = epnum; |
1731 | } | 1757 | } |
1732 | } | 1758 | } |
1733 | if (best_end < 0) | 1759 | /* use bulk reserved ep1 if no other ep is free */ |
1760 | if (best_end > 0 && qh->type == USB_ENDPOINT_XFER_BULK) { | ||
1761 | hw_ep = musb->bulk_ep; | ||
1762 | if (is_in) | ||
1763 | head = &musb->in_bulk; | ||
1764 | else | ||
1765 | head = &musb->out_bulk; | ||
1766 | goto success; | ||
1767 | } else if (best_end < 0) { | ||
1734 | return -ENOSPC; | 1768 | return -ENOSPC; |
1769 | } | ||
1735 | 1770 | ||
1736 | idle = 1; | 1771 | idle = 1; |
1772 | qh->mux = 0; | ||
1737 | hw_ep = musb->endpoints + best_end; | 1773 | hw_ep = musb->endpoints + best_end; |
1738 | musb->periodic[best_end] = qh; | 1774 | musb->periodic[best_end] = qh; |
1739 | DBG(4, "qh %p periodic slot %d\n", qh, best_end); | 1775 | DBG(4, "qh %p periodic slot %d\n", qh, best_end); |
1740 | success: | 1776 | success: |
1777 | if (head) { | ||
1778 | idle = list_empty(head); | ||
1779 | list_add_tail(&qh->ring, head); | ||
1780 | qh->mux = 1; | ||
1781 | } | ||
1741 | qh->hw_ep = hw_ep; | 1782 | qh->hw_ep = hw_ep; |
1742 | qh->hep->hcpriv = qh; | 1783 | qh->hep->hcpriv = qh; |
1743 | if (idle) | 1784 | if (idle) |
@@ -2015,11 +2056,13 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
2015 | sched = &musb->control; | 2056 | sched = &musb->control; |
2016 | break; | 2057 | break; |
2017 | case USB_ENDPOINT_XFER_BULK: | 2058 | case USB_ENDPOINT_XFER_BULK: |
2018 | if (usb_pipein(urb->pipe)) | 2059 | if (qh->mux == 1) { |
2019 | sched = &musb->in_bulk; | 2060 | if (usb_pipein(urb->pipe)) |
2020 | else | 2061 | sched = &musb->in_bulk; |
2021 | sched = &musb->out_bulk; | 2062 | else |
2022 | break; | 2063 | sched = &musb->out_bulk; |
2064 | break; | ||
2065 | } | ||
2023 | default: | 2066 | default: |
2024 | /* REVISIT when we get a schedule tree, periodic | 2067 | /* REVISIT when we get a schedule tree, periodic |
2025 | * transfers won't always be at the head of a | 2068 | * transfers won't always be at the head of a |
@@ -2067,11 +2110,13 @@ musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep) | |||
2067 | sched = &musb->control; | 2110 | sched = &musb->control; |
2068 | break; | 2111 | break; |
2069 | case USB_ENDPOINT_XFER_BULK: | 2112 | case USB_ENDPOINT_XFER_BULK: |
2070 | if (is_in) | 2113 | if (qh->mux == 1) { |
2071 | sched = &musb->in_bulk; | 2114 | if (is_in) |
2072 | else | 2115 | sched = &musb->in_bulk; |
2073 | sched = &musb->out_bulk; | 2116 | else |
2074 | break; | 2117 | sched = &musb->out_bulk; |
2118 | break; | ||
2119 | } | ||
2075 | default: | 2120 | default: |
2076 | /* REVISIT when we get a schedule tree, periodic transfers | 2121 | /* REVISIT when we get a schedule tree, periodic transfers |
2077 | * won't always be at the head of a singleton queue... | 2122 | * won't always be at the head of a singleton queue... |
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 77bcdb9d5b32..0b7fbcd21963 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h | |||
@@ -53,6 +53,7 @@ struct musb_qh { | |||
53 | 53 | ||
54 | struct list_head ring; /* of musb_qh */ | 54 | struct list_head ring; /* of musb_qh */ |
55 | /* struct musb_qh *next; */ /* for periodic tree */ | 55 | /* struct musb_qh *next; */ /* for periodic tree */ |
56 | u8 mux; /* qh multiplexed to hw_ep */ | ||
56 | 57 | ||
57 | unsigned offset; /* in urb->transfer_buffer */ | 58 | unsigned offset; /* in urb->transfer_buffer */ |
58 | unsigned segsize; /* current xfer fragment */ | 59 | unsigned segsize; /* current xfer fragment */ |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 9d2dcb121c5e..ce6c162920f7 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -53,7 +53,9 @@ static void musb_do_idle(unsigned long _musb) | |||
53 | { | 53 | { |
54 | struct musb *musb = (void *)_musb; | 54 | struct musb *musb = (void *)_musb; |
55 | unsigned long flags; | 55 | unsigned long flags; |
56 | #ifdef CONFIG_USB_MUSB_HDRC_HCD | ||
56 | u8 power; | 57 | u8 power; |
58 | #endif | ||
57 | u8 devctl; | 59 | u8 devctl; |
58 | 60 | ||
59 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); | 61 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index b73b036f3d77..ee8fca92a4ac 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -605,7 +605,7 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode) | |||
605 | 605 | ||
606 | if (musb->board_mode != MUSB_OTG) { | 606 | if (musb->board_mode != MUSB_OTG) { |
607 | ERR("Changing mode currently only supported in OTG mode\n"); | 607 | ERR("Changing mode currently only supported in OTG mode\n"); |
608 | return; | 608 | return -EINVAL; |
609 | } | 609 | } |
610 | 610 | ||
611 | otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); | 611 | otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 8008d0bc80ad..9035d7256b03 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -67,6 +67,7 @@ static struct usb_device_id id_table [] = { | |||
67 | { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */ | 67 | { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */ |
68 | { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ | 68 | { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ |
69 | { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ | 69 | { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ |
70 | { USB_DEVICE(0x10C4, 0x8054) }, /* Enfora GSM2228 */ | ||
70 | { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ | 71 | { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ |
71 | { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */ | 72 | { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */ |
72 | { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ | 73 | { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ |
@@ -85,6 +86,7 @@ static struct usb_device_id id_table [] = { | |||
85 | { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ | 86 | { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ |
86 | { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ | 87 | { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ |
87 | { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ | 88 | { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ |
89 | { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */ | ||
88 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ | 90 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
89 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ | 91 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ |
90 | { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ | 92 | { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index bd07eaa300b9..6fa1ec441b61 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -160,6 +160,11 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po | |||
160 | 160 | ||
161 | #define NOVATELWIRELESS_VENDOR_ID 0x1410 | 161 | #define NOVATELWIRELESS_VENDOR_ID 0x1410 |
162 | 162 | ||
163 | /* YISO PRODUCTS */ | ||
164 | |||
165 | #define YISO_VENDOR_ID 0x0EAB | ||
166 | #define YISO_PRODUCT_U893 0xC893 | ||
167 | |||
163 | /* MERLIN EVDO PRODUCTS */ | 168 | /* MERLIN EVDO PRODUCTS */ |
164 | #define NOVATELWIRELESS_PRODUCT_V640 0x1100 | 169 | #define NOVATELWIRELESS_PRODUCT_V640 0x1100 |
165 | #define NOVATELWIRELESS_PRODUCT_V620 0x1110 | 170 | #define NOVATELWIRELESS_PRODUCT_V620 0x1110 |
@@ -408,6 +413,7 @@ static struct usb_device_id option_ids[] = { | |||
408 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, | 413 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, |
409 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, | 414 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, |
410 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, | 415 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, |
416 | { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, | ||
411 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 417 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, |
412 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 418 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, |
413 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, | 419 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, |
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index 3d9249632ae1..c68b738900bd 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -2,8 +2,8 @@ | |||
2 | # USB Storage driver configuration | 2 | # USB Storage driver configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | comment "NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'" | 5 | comment "NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;" |
6 | comment "may also be needed; see USB_STORAGE Help for more information" | 6 | comment "see USB_STORAGE Help for more information" |
7 | depends on USB | 7 | depends on USB |
8 | 8 | ||
9 | config USB_STORAGE | 9 | config USB_STORAGE |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index fb9e20e624c1..d4e5fc86e43c 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -253,6 +253,14 @@ UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591, | |||
253 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 253 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
254 | US_FL_FIX_CAPACITY ), | 254 | US_FL_FIX_CAPACITY ), |
255 | 255 | ||
256 | /* Submitted by Ricky Wong Yung Fei <evilbladewarrior@gmail.com> */ | ||
257 | /* Nokia 7610 Supernova - Too many sectors reported in usb storage mode */ | ||
258 | UNUSUAL_DEV( 0x0421, 0x00f5, 0x0000, 0x0470, | ||
259 | "Nokia", | ||
260 | "7610 Supernova", | ||
261 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
262 | US_FL_FIX_CAPACITY ), | ||
263 | |||
256 | /* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ | 264 | /* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ |
257 | UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, | 265 | UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, |
258 | "SMSC", | 266 | "SMSC", |
@@ -418,6 +426,13 @@ UNUSUAL_DEV( 0x04b0, 0x0417, 0x0100, 0x0100, | |||
418 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 426 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
419 | US_FL_FIX_CAPACITY), | 427 | US_FL_FIX_CAPACITY), |
420 | 428 | ||
429 | /* Reported by paul ready <lxtwin@homecall.co.uk> */ | ||
430 | UNUSUAL_DEV( 0x04b0, 0x0419, 0x0100, 0x0200, | ||
431 | "NIKON", | ||
432 | "NIKON DSC D300", | ||
433 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
434 | US_FL_FIX_CAPACITY), | ||
435 | |||
421 | /* Reported by Doug Maxey (dwm@austin.ibm.com) */ | 436 | /* Reported by Doug Maxey (dwm@austin.ibm.com) */ |
422 | UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, | 437 | UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, |
423 | "IBM", | 438 | "IBM", |
@@ -1258,6 +1273,13 @@ UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001, | |||
1258 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1273 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1259 | US_FL_FIX_INQUIRY), | 1274 | US_FL_FIX_INQUIRY), |
1260 | 1275 | ||
1276 | /* Reported by Luciano Rocha <luciano@eurotux.com> */ | ||
1277 | UNUSUAL_DEV( 0x0840, 0x0082, 0x0001, 0x0001, | ||
1278 | "Argosy", | ||
1279 | "Storage", | ||
1280 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1281 | US_FL_FIX_CAPACITY), | ||
1282 | |||
1261 | /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. | 1283 | /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. |
1262 | * Flag will support Bulk devices which use a standards-violating 32-byte | 1284 | * Flag will support Bulk devices which use a standards-violating 32-byte |
1263 | * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with | 1285 | * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with |
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig index c4493091c655..a14d5b6e4c7c 100644 --- a/drivers/w1/masters/Kconfig +++ b/drivers/w1/masters/Kconfig | |||
@@ -52,5 +52,12 @@ config W1_MASTER_GPIO | |||
52 | This support is also available as a module. If so, the module | 52 | This support is also available as a module. If so, the module |
53 | will be called w1-gpio.ko. | 53 | will be called w1-gpio.ko. |
54 | 54 | ||
55 | config HDQ_MASTER_OMAP | ||
56 | tristate "OMAP HDQ driver" | ||
57 | depends on ARCH_OMAP2430 || ARCH_OMAP34XX | ||
58 | help | ||
59 | Say Y here if you want support for the 1-wire or HDQ Interface | ||
60 | on an OMAP processor. | ||
61 | |||
55 | endmenu | 62 | endmenu |
56 | 63 | ||
diff --git a/drivers/w1/masters/Makefile b/drivers/w1/masters/Makefile index 1420b5bbdda8..bc4714a75f3a 100644 --- a/drivers/w1/masters/Makefile +++ b/drivers/w1/masters/Makefile | |||
@@ -7,3 +7,4 @@ obj-$(CONFIG_W1_MASTER_DS2490) += ds2490.o | |||
7 | obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o | 7 | obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o |
8 | obj-$(CONFIG_W1_MASTER_DS1WM) += ds1wm.o | 8 | obj-$(CONFIG_W1_MASTER_DS1WM) += ds1wm.o |
9 | obj-$(CONFIG_W1_MASTER_GPIO) += w1-gpio.o | 9 | obj-$(CONFIG_W1_MASTER_GPIO) += w1-gpio.o |
10 | obj-$(CONFIG_HDQ_MASTER_OMAP) += omap_hdq.o | ||
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c new file mode 100644 index 000000000000..1295625c4825 --- /dev/null +++ b/drivers/w1/masters/omap_hdq.c | |||
@@ -0,0 +1,725 @@ | |||
1 | /* | ||
2 | * drivers/w1/masters/omap_hdq.c | ||
3 | * | ||
4 | * Copyright (C) 2007 Texas Instruments, Inc. | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public License | ||
7 | * version 2. This program is licensed "as is" without any warranty of any | ||
8 | * kind, whether express or implied. | ||
9 | * | ||
10 | */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/clk.h> | ||
17 | #include <linux/io.h> | ||
18 | |||
19 | #include <asm/irq.h> | ||
20 | #include <mach/hardware.h> | ||
21 | |||
22 | #include "../w1.h" | ||
23 | #include "../w1_int.h" | ||
24 | |||
25 | #define MOD_NAME "OMAP_HDQ:" | ||
26 | |||
27 | #define OMAP_HDQ_REVISION 0x00 | ||
28 | #define OMAP_HDQ_TX_DATA 0x04 | ||
29 | #define OMAP_HDQ_RX_DATA 0x08 | ||
30 | #define OMAP_HDQ_CTRL_STATUS 0x0c | ||
31 | #define OMAP_HDQ_CTRL_STATUS_INTERRUPTMASK (1<<6) | ||
32 | #define OMAP_HDQ_CTRL_STATUS_CLOCKENABLE (1<<5) | ||
33 | #define OMAP_HDQ_CTRL_STATUS_GO (1<<4) | ||
34 | #define OMAP_HDQ_CTRL_STATUS_INITIALIZATION (1<<2) | ||
35 | #define OMAP_HDQ_CTRL_STATUS_DIR (1<<1) | ||
36 | #define OMAP_HDQ_CTRL_STATUS_MODE (1<<0) | ||
37 | #define OMAP_HDQ_INT_STATUS 0x10 | ||
38 | #define OMAP_HDQ_INT_STATUS_TXCOMPLETE (1<<2) | ||
39 | #define OMAP_HDQ_INT_STATUS_RXCOMPLETE (1<<1) | ||
40 | #define OMAP_HDQ_INT_STATUS_TIMEOUT (1<<0) | ||
41 | #define OMAP_HDQ_SYSCONFIG 0x14 | ||
42 | #define OMAP_HDQ_SYSCONFIG_SOFTRESET (1<<1) | ||
43 | #define OMAP_HDQ_SYSCONFIG_AUTOIDLE (1<<0) | ||
44 | #define OMAP_HDQ_SYSSTATUS 0x18 | ||
45 | #define OMAP_HDQ_SYSSTATUS_RESETDONE (1<<0) | ||
46 | |||
47 | #define OMAP_HDQ_FLAG_CLEAR 0 | ||
48 | #define OMAP_HDQ_FLAG_SET 1 | ||
49 | #define OMAP_HDQ_TIMEOUT (HZ/5) | ||
50 | |||
51 | #define OMAP_HDQ_MAX_USER 4 | ||
52 | |||
53 | static DECLARE_WAIT_QUEUE_HEAD(hdq_wait_queue); | ||
54 | static int w1_id; | ||
55 | |||
56 | struct hdq_data { | ||
57 | struct device *dev; | ||
58 | void __iomem *hdq_base; | ||
59 | /* lock status update */ | ||
60 | struct mutex hdq_mutex; | ||
61 | int hdq_usecount; | ||
62 | struct clk *hdq_ick; | ||
63 | struct clk *hdq_fck; | ||
64 | u8 hdq_irqstatus; | ||
65 | /* device lock */ | ||
66 | spinlock_t hdq_spinlock; | ||
67 | /* | ||
68 | * Used to control the call to omap_hdq_get and omap_hdq_put. | ||
69 | * HDQ Protocol: Write the CMD|REG_address first, followed by | ||
70 | * the data wrire or read. | ||
71 | */ | ||
72 | int init_trans; | ||
73 | }; | ||
74 | |||
75 | static int __init omap_hdq_probe(struct platform_device *pdev); | ||
76 | static int omap_hdq_remove(struct platform_device *pdev); | ||
77 | |||
78 | static struct platform_driver omap_hdq_driver = { | ||
79 | .probe = omap_hdq_probe, | ||
80 | .remove = omap_hdq_remove, | ||
81 | .driver = { | ||
82 | .name = "omap_hdq", | ||
83 | }, | ||
84 | }; | ||
85 | |||
86 | static u8 omap_w1_read_byte(void *_hdq); | ||
87 | static void omap_w1_write_byte(void *_hdq, u8 byte); | ||
88 | static u8 omap_w1_reset_bus(void *_hdq); | ||
89 | static void omap_w1_search_bus(void *_hdq, u8 search_type, | ||
90 | w1_slave_found_callback slave_found); | ||
91 | |||
92 | |||
93 | static struct w1_bus_master omap_w1_master = { | ||
94 | .read_byte = omap_w1_read_byte, | ||
95 | .write_byte = omap_w1_write_byte, | ||
96 | .reset_bus = omap_w1_reset_bus, | ||
97 | .search = omap_w1_search_bus, | ||
98 | }; | ||
99 | |||
100 | /* HDQ register I/O routines */ | ||
101 | static inline u8 hdq_reg_in(struct hdq_data *hdq_data, u32 offset) | ||
102 | { | ||
103 | return __raw_readb(hdq_data->hdq_base + offset); | ||
104 | } | ||
105 | |||
106 | static inline void hdq_reg_out(struct hdq_data *hdq_data, u32 offset, u8 val) | ||
107 | { | ||
108 | __raw_writeb(val, hdq_data->hdq_base + offset); | ||
109 | } | ||
110 | |||
111 | static inline u8 hdq_reg_merge(struct hdq_data *hdq_data, u32 offset, | ||
112 | u8 val, u8 mask) | ||
113 | { | ||
114 | u8 new_val = (__raw_readb(hdq_data->hdq_base + offset) & ~mask) | ||
115 | | (val & mask); | ||
116 | __raw_writeb(new_val, hdq_data->hdq_base + offset); | ||
117 | |||
118 | return new_val; | ||
119 | } | ||
120 | |||
121 | /* | ||
122 | * Wait for one or more bits in flag change. | ||
123 | * HDQ_FLAG_SET: wait until any bit in the flag is set. | ||
124 | * HDQ_FLAG_CLEAR: wait until all bits in the flag are cleared. | ||
125 | * return 0 on success and -ETIMEDOUT in the case of timeout. | ||
126 | */ | ||
127 | static int hdq_wait_for_flag(struct hdq_data *hdq_data, u32 offset, | ||
128 | u8 flag, u8 flag_set, u8 *status) | ||
129 | { | ||
130 | int ret = 0; | ||
131 | unsigned long timeout = jiffies + OMAP_HDQ_TIMEOUT; | ||
132 | |||
133 | if (flag_set == OMAP_HDQ_FLAG_CLEAR) { | ||
134 | /* wait for the flag clear */ | ||
135 | while (((*status = hdq_reg_in(hdq_data, offset)) & flag) | ||
136 | && time_before(jiffies, timeout)) { | ||
137 | schedule_timeout_uninterruptible(1); | ||
138 | } | ||
139 | if (*status & flag) | ||
140 | ret = -ETIMEDOUT; | ||
141 | } else if (flag_set == OMAP_HDQ_FLAG_SET) { | ||
142 | /* wait for the flag set */ | ||
143 | while (!((*status = hdq_reg_in(hdq_data, offset)) & flag) | ||
144 | && time_before(jiffies, timeout)) { | ||
145 | schedule_timeout_uninterruptible(1); | ||
146 | } | ||
147 | if (!(*status & flag)) | ||
148 | ret = -ETIMEDOUT; | ||
149 | } else | ||
150 | return -EINVAL; | ||
151 | |||
152 | return ret; | ||
153 | } | ||
154 | |||
155 | /* write out a byte and fill *status with HDQ_INT_STATUS */ | ||
156 | static int hdq_write_byte(struct hdq_data *hdq_data, u8 val, u8 *status) | ||
157 | { | ||
158 | int ret; | ||
159 | u8 tmp_status; | ||
160 | unsigned long irqflags; | ||
161 | |||
162 | *status = 0; | ||
163 | |||
164 | spin_lock_irqsave(&hdq_data->hdq_spinlock, irqflags); | ||
165 | /* clear interrupt flags via a dummy read */ | ||
166 | hdq_reg_in(hdq_data, OMAP_HDQ_INT_STATUS); | ||
167 | /* ISR loads it with new INT_STATUS */ | ||
168 | hdq_data->hdq_irqstatus = 0; | ||
169 | spin_unlock_irqrestore(&hdq_data->hdq_spinlock, irqflags); | ||
170 | |||
171 | hdq_reg_out(hdq_data, OMAP_HDQ_TX_DATA, val); | ||
172 | |||
173 | /* set the GO bit */ | ||
174 | hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, OMAP_HDQ_CTRL_STATUS_GO, | ||
175 | OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_GO); | ||
176 | /* wait for the TXCOMPLETE bit */ | ||
177 | ret = wait_event_timeout(hdq_wait_queue, | ||
178 | hdq_data->hdq_irqstatus, OMAP_HDQ_TIMEOUT); | ||
179 | if (ret == 0) { | ||
180 | dev_dbg(hdq_data->dev, "TX wait elapsed\n"); | ||
181 | goto out; | ||
182 | } | ||
183 | |||
184 | *status = hdq_data->hdq_irqstatus; | ||
185 | /* check irqstatus */ | ||
186 | if (!(*status & OMAP_HDQ_INT_STATUS_TXCOMPLETE)) { | ||
187 | dev_dbg(hdq_data->dev, "timeout waiting for" | ||
188 | "TXCOMPLETE/RXCOMPLETE, %x", *status); | ||
189 | ret = -ETIMEDOUT; | ||
190 | goto out; | ||
191 | } | ||
192 | |||
193 | /* wait for the GO bit return to zero */ | ||
194 | ret = hdq_wait_for_flag(hdq_data, OMAP_HDQ_CTRL_STATUS, | ||
195 | OMAP_HDQ_CTRL_STATUS_GO, | ||
196 | OMAP_HDQ_FLAG_CLEAR, &tmp_status); | ||
197 | if (ret) { | ||
198 | dev_dbg(hdq_data->dev, "timeout waiting GO bit" | ||
199 | "return to zero, %x", tmp_status); | ||
200 | } | ||
201 | |||
202 | out: | ||
203 | return ret; | ||
204 | } | ||
205 | |||
206 | /* HDQ Interrupt service routine */ | ||
207 | static irqreturn_t hdq_isr(int irq, void *_hdq) | ||
208 | { | ||
209 | struct hdq_data *hdq_data = _hdq; | ||
210 | unsigned long irqflags; | ||
211 | |||
212 | spin_lock_irqsave(&hdq_data->hdq_spinlock, irqflags); | ||
213 | hdq_data->hdq_irqstatus = hdq_reg_in(hdq_data, OMAP_HDQ_INT_STATUS); | ||
214 | spin_unlock_irqrestore(&hdq_data->hdq_spinlock, irqflags); | ||
215 | dev_dbg(hdq_data->dev, "hdq_isr: %x", hdq_data->hdq_irqstatus); | ||
216 | |||
217 | if (hdq_data->hdq_irqstatus & | ||
218 | (OMAP_HDQ_INT_STATUS_TXCOMPLETE | OMAP_HDQ_INT_STATUS_RXCOMPLETE | ||
219 | | OMAP_HDQ_INT_STATUS_TIMEOUT)) { | ||
220 | /* wake up sleeping process */ | ||
221 | wake_up(&hdq_wait_queue); | ||
222 | } | ||
223 | |||
224 | return IRQ_HANDLED; | ||
225 | } | ||
226 | |||
227 | /* HDQ Mode: always return success */ | ||
228 | static u8 omap_w1_reset_bus(void *_hdq) | ||
229 | { | ||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | /* W1 search callback function */ | ||
234 | static void omap_w1_search_bus(void *_hdq, u8 search_type, | ||
235 | w1_slave_found_callback slave_found) | ||
236 | { | ||
237 | u64 module_id, rn_le, cs, id; | ||
238 | |||
239 | if (w1_id) | ||
240 | module_id = w1_id; | ||
241 | else | ||
242 | module_id = 0x1; | ||
243 | |||
244 | rn_le = cpu_to_le64(module_id); | ||
245 | /* | ||
246 | * HDQ might not obey truly the 1-wire spec. | ||
247 | * So calculate CRC based on module parameter. | ||
248 | */ | ||
249 | cs = w1_calc_crc8((u8 *)&rn_le, 7); | ||
250 | id = (cs << 56) | module_id; | ||
251 | |||
252 | slave_found(_hdq, id); | ||
253 | } | ||
254 | |||
255 | static int _omap_hdq_reset(struct hdq_data *hdq_data) | ||
256 | { | ||
257 | int ret; | ||
258 | u8 tmp_status; | ||
259 | |||
260 | hdq_reg_out(hdq_data, OMAP_HDQ_SYSCONFIG, OMAP_HDQ_SYSCONFIG_SOFTRESET); | ||
261 | /* | ||
262 | * Select HDQ mode & enable clocks. | ||
263 | * It is observed that INT flags can't be cleared via a read and GO/INIT | ||
264 | * won't return to zero if interrupt is disabled. So we always enable | ||
265 | * interrupt. | ||
266 | */ | ||
267 | hdq_reg_out(hdq_data, OMAP_HDQ_CTRL_STATUS, | ||
268 | OMAP_HDQ_CTRL_STATUS_CLOCKENABLE | | ||
269 | OMAP_HDQ_CTRL_STATUS_INTERRUPTMASK); | ||
270 | |||
271 | /* wait for reset to complete */ | ||
272 | ret = hdq_wait_for_flag(hdq_data, OMAP_HDQ_SYSSTATUS, | ||
273 | OMAP_HDQ_SYSSTATUS_RESETDONE, OMAP_HDQ_FLAG_SET, &tmp_status); | ||
274 | if (ret) | ||
275 | dev_dbg(hdq_data->dev, "timeout waiting HDQ reset, %x", | ||
276 | tmp_status); | ||
277 | else { | ||
278 | hdq_reg_out(hdq_data, OMAP_HDQ_CTRL_STATUS, | ||
279 | OMAP_HDQ_CTRL_STATUS_CLOCKENABLE | | ||
280 | OMAP_HDQ_CTRL_STATUS_INTERRUPTMASK); | ||
281 | hdq_reg_out(hdq_data, OMAP_HDQ_SYSCONFIG, | ||
282 | OMAP_HDQ_SYSCONFIG_AUTOIDLE); | ||
283 | } | ||
284 | |||
285 | return ret; | ||
286 | } | ||
287 | |||
288 | /* Issue break pulse to the device */ | ||
289 | static int omap_hdq_break(struct hdq_data *hdq_data) | ||
290 | { | ||
291 | int ret = 0; | ||
292 | u8 tmp_status; | ||
293 | unsigned long irqflags; | ||
294 | |||
295 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
296 | if (ret < 0) { | ||
297 | dev_dbg(hdq_data->dev, "Could not acquire mutex\n"); | ||
298 | ret = -EINTR; | ||
299 | goto rtn; | ||
300 | } | ||
301 | |||
302 | spin_lock_irqsave(&hdq_data->hdq_spinlock, irqflags); | ||
303 | /* clear interrupt flags via a dummy read */ | ||
304 | hdq_reg_in(hdq_data, OMAP_HDQ_INT_STATUS); | ||
305 | /* ISR loads it with new INT_STATUS */ | ||
306 | hdq_data->hdq_irqstatus = 0; | ||
307 | spin_unlock_irqrestore(&hdq_data->hdq_spinlock, irqflags); | ||
308 | |||
309 | /* set the INIT and GO bit */ | ||
310 | hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, | ||
311 | OMAP_HDQ_CTRL_STATUS_INITIALIZATION | OMAP_HDQ_CTRL_STATUS_GO, | ||
312 | OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_INITIALIZATION | | ||
313 | OMAP_HDQ_CTRL_STATUS_GO); | ||
314 | |||
315 | /* wait for the TIMEOUT bit */ | ||
316 | ret = wait_event_timeout(hdq_wait_queue, | ||
317 | hdq_data->hdq_irqstatus, OMAP_HDQ_TIMEOUT); | ||
318 | if (ret == 0) { | ||
319 | dev_dbg(hdq_data->dev, "break wait elapsed\n"); | ||
320 | ret = -EINTR; | ||
321 | goto out; | ||
322 | } | ||
323 | |||
324 | tmp_status = hdq_data->hdq_irqstatus; | ||
325 | /* check irqstatus */ | ||
326 | if (!(tmp_status & OMAP_HDQ_INT_STATUS_TIMEOUT)) { | ||
327 | dev_dbg(hdq_data->dev, "timeout waiting for TIMEOUT, %x", | ||
328 | tmp_status); | ||
329 | ret = -ETIMEDOUT; | ||
330 | goto out; | ||
331 | } | ||
332 | /* | ||
333 | * wait for both INIT and GO bits rerurn to zero. | ||
334 | * zero wait time expected for interrupt mode. | ||
335 | */ | ||
336 | ret = hdq_wait_for_flag(hdq_data, OMAP_HDQ_CTRL_STATUS, | ||
337 | OMAP_HDQ_CTRL_STATUS_INITIALIZATION | | ||
338 | OMAP_HDQ_CTRL_STATUS_GO, OMAP_HDQ_FLAG_CLEAR, | ||
339 | &tmp_status); | ||
340 | if (ret) | ||
341 | dev_dbg(hdq_data->dev, "timeout waiting INIT&GO bits" | ||
342 | "return to zero, %x", tmp_status); | ||
343 | |||
344 | out: | ||
345 | mutex_unlock(&hdq_data->hdq_mutex); | ||
346 | rtn: | ||
347 | return ret; | ||
348 | } | ||
349 | |||
350 | static int hdq_read_byte(struct hdq_data *hdq_data, u8 *val) | ||
351 | { | ||
352 | int ret = 0; | ||
353 | u8 status; | ||
354 | unsigned long timeout = jiffies + OMAP_HDQ_TIMEOUT; | ||
355 | |||
356 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
357 | if (ret < 0) { | ||
358 | ret = -EINTR; | ||
359 | goto rtn; | ||
360 | } | ||
361 | |||
362 | if (!hdq_data->hdq_usecount) { | ||
363 | ret = -EINVAL; | ||
364 | goto out; | ||
365 | } | ||
366 | |||
367 | if (!(hdq_data->hdq_irqstatus & OMAP_HDQ_INT_STATUS_RXCOMPLETE)) { | ||
368 | hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, | ||
369 | OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_GO, | ||
370 | OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_GO); | ||
371 | /* | ||
372 | * The RX comes immediately after TX. It | ||
373 | * triggers another interrupt before we | ||
374 | * sleep. So we have to wait for RXCOMPLETE bit. | ||
375 | */ | ||
376 | while (!(hdq_data->hdq_irqstatus | ||
377 | & OMAP_HDQ_INT_STATUS_RXCOMPLETE) | ||
378 | && time_before(jiffies, timeout)) { | ||
379 | schedule_timeout_uninterruptible(1); | ||
380 | } | ||
381 | hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, 0, | ||
382 | OMAP_HDQ_CTRL_STATUS_DIR); | ||
383 | status = hdq_data->hdq_irqstatus; | ||
384 | /* check irqstatus */ | ||
385 | if (!(status & OMAP_HDQ_INT_STATUS_RXCOMPLETE)) { | ||
386 | dev_dbg(hdq_data->dev, "timeout waiting for" | ||
387 | "RXCOMPLETE, %x", status); | ||
388 | ret = -ETIMEDOUT; | ||
389 | goto out; | ||
390 | } | ||
391 | } | ||
392 | /* the data is ready. Read it in! */ | ||
393 | *val = hdq_reg_in(hdq_data, OMAP_HDQ_RX_DATA); | ||
394 | out: | ||
395 | mutex_unlock(&hdq_data->hdq_mutex); | ||
396 | rtn: | ||
397 | return 0; | ||
398 | |||
399 | } | ||
400 | |||
401 | /* Enable clocks and set the controller to HDQ mode */ | ||
402 | static int omap_hdq_get(struct hdq_data *hdq_data) | ||
403 | { | ||
404 | int ret = 0; | ||
405 | |||
406 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
407 | if (ret < 0) { | ||
408 | ret = -EINTR; | ||
409 | goto rtn; | ||
410 | } | ||
411 | |||
412 | if (OMAP_HDQ_MAX_USER == hdq_data->hdq_usecount) { | ||
413 | dev_dbg(hdq_data->dev, "attempt to exceed the max use count"); | ||
414 | ret = -EINVAL; | ||
415 | goto out; | ||
416 | } else { | ||
417 | hdq_data->hdq_usecount++; | ||
418 | try_module_get(THIS_MODULE); | ||
419 | if (1 == hdq_data->hdq_usecount) { | ||
420 | if (clk_enable(hdq_data->hdq_ick)) { | ||
421 | dev_dbg(hdq_data->dev, "Can not enable ick\n"); | ||
422 | ret = -ENODEV; | ||
423 | goto clk_err; | ||
424 | } | ||
425 | if (clk_enable(hdq_data->hdq_fck)) { | ||
426 | dev_dbg(hdq_data->dev, "Can not enable fck\n"); | ||
427 | clk_disable(hdq_data->hdq_ick); | ||
428 | ret = -ENODEV; | ||
429 | goto clk_err; | ||
430 | } | ||
431 | |||
432 | /* make sure HDQ is out of reset */ | ||
433 | if (!(hdq_reg_in(hdq_data, OMAP_HDQ_SYSSTATUS) & | ||
434 | OMAP_HDQ_SYSSTATUS_RESETDONE)) { | ||
435 | ret = _omap_hdq_reset(hdq_data); | ||
436 | if (ret) | ||
437 | /* back up the count */ | ||
438 | hdq_data->hdq_usecount--; | ||
439 | } else { | ||
440 | /* select HDQ mode & enable clocks */ | ||
441 | hdq_reg_out(hdq_data, OMAP_HDQ_CTRL_STATUS, | ||
442 | OMAP_HDQ_CTRL_STATUS_CLOCKENABLE | | ||
443 | OMAP_HDQ_CTRL_STATUS_INTERRUPTMASK); | ||
444 | hdq_reg_out(hdq_data, OMAP_HDQ_SYSCONFIG, | ||
445 | OMAP_HDQ_SYSCONFIG_AUTOIDLE); | ||
446 | hdq_reg_in(hdq_data, OMAP_HDQ_INT_STATUS); | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | |||
451 | clk_err: | ||
452 | clk_put(hdq_data->hdq_ick); | ||
453 | clk_put(hdq_data->hdq_fck); | ||
454 | out: | ||
455 | mutex_unlock(&hdq_data->hdq_mutex); | ||
456 | rtn: | ||
457 | return ret; | ||
458 | } | ||
459 | |||
460 | /* Disable clocks to the module */ | ||
461 | static int omap_hdq_put(struct hdq_data *hdq_data) | ||
462 | { | ||
463 | int ret = 0; | ||
464 | |||
465 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
466 | if (ret < 0) | ||
467 | return -EINTR; | ||
468 | |||
469 | if (0 == hdq_data->hdq_usecount) { | ||
470 | dev_dbg(hdq_data->dev, "attempt to decrement use count" | ||
471 | "when it is zero"); | ||
472 | ret = -EINVAL; | ||
473 | } else { | ||
474 | hdq_data->hdq_usecount--; | ||
475 | module_put(THIS_MODULE); | ||
476 | if (0 == hdq_data->hdq_usecount) { | ||
477 | clk_disable(hdq_data->hdq_ick); | ||
478 | clk_disable(hdq_data->hdq_fck); | ||
479 | } | ||
480 | } | ||
481 | mutex_unlock(&hdq_data->hdq_mutex); | ||
482 | |||
483 | return ret; | ||
484 | } | ||
485 | |||
486 | /* Read a byte of data from the device */ | ||
487 | static u8 omap_w1_read_byte(void *_hdq) | ||
488 | { | ||
489 | struct hdq_data *hdq_data = _hdq; | ||
490 | u8 val = 0; | ||
491 | int ret; | ||
492 | |||
493 | ret = hdq_read_byte(hdq_data, &val); | ||
494 | if (ret) { | ||
495 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
496 | if (ret < 0) { | ||
497 | dev_dbg(hdq_data->dev, "Could not acquire mutex\n"); | ||
498 | return -EINTR; | ||
499 | } | ||
500 | hdq_data->init_trans = 0; | ||
501 | mutex_unlock(&hdq_data->hdq_mutex); | ||
502 | omap_hdq_put(hdq_data); | ||
503 | return -1; | ||
504 | } | ||
505 | |||
506 | /* Write followed by a read, release the module */ | ||
507 | if (hdq_data->init_trans) { | ||
508 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
509 | if (ret < 0) { | ||
510 | dev_dbg(hdq_data->dev, "Could not acquire mutex\n"); | ||
511 | return -EINTR; | ||
512 | } | ||
513 | hdq_data->init_trans = 0; | ||
514 | mutex_unlock(&hdq_data->hdq_mutex); | ||
515 | omap_hdq_put(hdq_data); | ||
516 | } | ||
517 | |||
518 | return val; | ||
519 | } | ||
520 | |||
521 | /* Write a byte of data to the device */ | ||
522 | static void omap_w1_write_byte(void *_hdq, u8 byte) | ||
523 | { | ||
524 | struct hdq_data *hdq_data = _hdq; | ||
525 | int ret; | ||
526 | u8 status; | ||
527 | |||
528 | /* First write to initialize the transfer */ | ||
529 | if (hdq_data->init_trans == 0) | ||
530 | omap_hdq_get(hdq_data); | ||
531 | |||
532 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
533 | if (ret < 0) { | ||
534 | dev_dbg(hdq_data->dev, "Could not acquire mutex\n"); | ||
535 | return; | ||
536 | } | ||
537 | hdq_data->init_trans++; | ||
538 | mutex_unlock(&hdq_data->hdq_mutex); | ||
539 | |||
540 | ret = hdq_write_byte(hdq_data, byte, &status); | ||
541 | if (ret == 0) { | ||
542 | dev_dbg(hdq_data->dev, "TX failure:Ctrl status %x\n", status); | ||
543 | return; | ||
544 | } | ||
545 | |||
546 | /* Second write, data transfered. Release the module */ | ||
547 | if (hdq_data->init_trans > 1) { | ||
548 | omap_hdq_put(hdq_data); | ||
549 | ret = mutex_lock_interruptible(&hdq_data->hdq_mutex); | ||
550 | if (ret < 0) { | ||
551 | dev_dbg(hdq_data->dev, "Could not acquire mutex\n"); | ||
552 | return; | ||
553 | } | ||
554 | hdq_data->init_trans = 0; | ||
555 | mutex_unlock(&hdq_data->hdq_mutex); | ||
556 | } | ||
557 | |||
558 | return; | ||
559 | } | ||
560 | |||
561 | static int __init omap_hdq_probe(struct platform_device *pdev) | ||
562 | { | ||
563 | struct hdq_data *hdq_data; | ||
564 | struct resource *res; | ||
565 | int ret, irq; | ||
566 | u8 rev; | ||
567 | |||
568 | hdq_data = kmalloc(sizeof(*hdq_data), GFP_KERNEL); | ||
569 | if (!hdq_data) { | ||
570 | dev_dbg(&pdev->dev, "unable to allocate memory\n"); | ||
571 | ret = -ENOMEM; | ||
572 | goto err_kmalloc; | ||
573 | } | ||
574 | |||
575 | hdq_data->dev = &pdev->dev; | ||
576 | platform_set_drvdata(pdev, hdq_data); | ||
577 | |||
578 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
579 | if (!res) { | ||
580 | dev_dbg(&pdev->dev, "unable to get resource\n"); | ||
581 | ret = -ENXIO; | ||
582 | goto err_resource; | ||
583 | } | ||
584 | |||
585 | hdq_data->hdq_base = ioremap(res->start, SZ_4K); | ||
586 | if (!hdq_data->hdq_base) { | ||
587 | dev_dbg(&pdev->dev, "ioremap failed\n"); | ||
588 | ret = -EINVAL; | ||
589 | goto err_ioremap; | ||
590 | } | ||
591 | |||
592 | /* get interface & functional clock objects */ | ||
593 | hdq_data->hdq_ick = clk_get(&pdev->dev, "hdq_ick"); | ||
594 | hdq_data->hdq_fck = clk_get(&pdev->dev, "hdq_fck"); | ||
595 | |||
596 | if (IS_ERR(hdq_data->hdq_ick) || IS_ERR(hdq_data->hdq_fck)) { | ||
597 | dev_dbg(&pdev->dev, "Can't get HDQ clock objects\n"); | ||
598 | if (IS_ERR(hdq_data->hdq_ick)) { | ||
599 | ret = PTR_ERR(hdq_data->hdq_ick); | ||
600 | goto err_clk; | ||
601 | } | ||
602 | if (IS_ERR(hdq_data->hdq_fck)) { | ||
603 | ret = PTR_ERR(hdq_data->hdq_fck); | ||
604 | clk_put(hdq_data->hdq_ick); | ||
605 | goto err_clk; | ||
606 | } | ||
607 | } | ||
608 | |||
609 | hdq_data->hdq_usecount = 0; | ||
610 | mutex_init(&hdq_data->hdq_mutex); | ||
611 | |||
612 | if (clk_enable(hdq_data->hdq_ick)) { | ||
613 | dev_dbg(&pdev->dev, "Can not enable ick\n"); | ||
614 | ret = -ENODEV; | ||
615 | goto err_intfclk; | ||
616 | } | ||
617 | |||
618 | if (clk_enable(hdq_data->hdq_fck)) { | ||
619 | dev_dbg(&pdev->dev, "Can not enable fck\n"); | ||
620 | ret = -ENODEV; | ||
621 | goto err_fnclk; | ||
622 | } | ||
623 | |||
624 | rev = hdq_reg_in(hdq_data, OMAP_HDQ_REVISION); | ||
625 | dev_info(&pdev->dev, "OMAP HDQ Hardware Rev %c.%c. Driver in %s mode\n", | ||
626 | (rev >> 4) + '0', (rev & 0x0f) + '0', "Interrupt"); | ||
627 | |||
628 | spin_lock_init(&hdq_data->hdq_spinlock); | ||
629 | |||
630 | irq = platform_get_irq(pdev, 0); | ||
631 | if (irq < 0) { | ||
632 | ret = -ENXIO; | ||
633 | goto err_irq; | ||
634 | } | ||
635 | |||
636 | ret = request_irq(irq, hdq_isr, IRQF_DISABLED, "omap_hdq", hdq_data); | ||
637 | if (ret < 0) { | ||
638 | dev_dbg(&pdev->dev, "could not request irq\n"); | ||
639 | goto err_irq; | ||
640 | } | ||
641 | |||
642 | omap_hdq_break(hdq_data); | ||
643 | |||
644 | /* don't clock the HDQ until it is needed */ | ||
645 | clk_disable(hdq_data->hdq_ick); | ||
646 | clk_disable(hdq_data->hdq_fck); | ||
647 | |||
648 | omap_w1_master.data = hdq_data; | ||
649 | |||
650 | ret = w1_add_master_device(&omap_w1_master); | ||
651 | if (ret) { | ||
652 | dev_dbg(&pdev->dev, "Failure in registering w1 master\n"); | ||
653 | goto err_w1; | ||
654 | } | ||
655 | |||
656 | return 0; | ||
657 | |||
658 | err_w1: | ||
659 | err_irq: | ||
660 | clk_disable(hdq_data->hdq_fck); | ||
661 | |||
662 | err_fnclk: | ||
663 | clk_disable(hdq_data->hdq_ick); | ||
664 | |||
665 | err_intfclk: | ||
666 | clk_put(hdq_data->hdq_ick); | ||
667 | clk_put(hdq_data->hdq_fck); | ||
668 | |||
669 | err_clk: | ||
670 | iounmap(hdq_data->hdq_base); | ||
671 | |||
672 | err_ioremap: | ||
673 | err_resource: | ||
674 | platform_set_drvdata(pdev, NULL); | ||
675 | kfree(hdq_data); | ||
676 | |||
677 | err_kmalloc: | ||
678 | return ret; | ||
679 | |||
680 | } | ||
681 | |||
682 | static int omap_hdq_remove(struct platform_device *pdev) | ||
683 | { | ||
684 | struct hdq_data *hdq_data = platform_get_drvdata(pdev); | ||
685 | |||
686 | mutex_lock(&hdq_data->hdq_mutex); | ||
687 | |||
688 | if (hdq_data->hdq_usecount) { | ||
689 | dev_dbg(&pdev->dev, "removed when use count is not zero\n"); | ||
690 | return -EBUSY; | ||
691 | } | ||
692 | |||
693 | mutex_unlock(&hdq_data->hdq_mutex); | ||
694 | |||
695 | /* remove module dependency */ | ||
696 | clk_put(hdq_data->hdq_ick); | ||
697 | clk_put(hdq_data->hdq_fck); | ||
698 | free_irq(INT_24XX_HDQ_IRQ, hdq_data); | ||
699 | platform_set_drvdata(pdev, NULL); | ||
700 | iounmap(hdq_data->hdq_base); | ||
701 | kfree(hdq_data); | ||
702 | |||
703 | return 0; | ||
704 | } | ||
705 | |||
706 | static int __init | ||
707 | omap_hdq_init(void) | ||
708 | { | ||
709 | return platform_driver_register(&omap_hdq_driver); | ||
710 | } | ||
711 | module_init(omap_hdq_init); | ||
712 | |||
713 | static void __exit | ||
714 | omap_hdq_exit(void) | ||
715 | { | ||
716 | platform_driver_unregister(&omap_hdq_driver); | ||
717 | } | ||
718 | module_exit(omap_hdq_exit); | ||
719 | |||
720 | module_param(w1_id, int, S_IRUSR); | ||
721 | MODULE_PARM_DESC(w1_id, "1-wire id for the slave detection"); | ||
722 | |||
723 | MODULE_AUTHOR("Texas Instruments"); | ||
724 | MODULE_DESCRIPTION("HDQ driver Library"); | ||
725 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index 3df29a122f84..8d0b1fb1e52e 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig | |||
@@ -44,4 +44,11 @@ config W1_SLAVE_DS2760 | |||
44 | 44 | ||
45 | If you are unsure, say N. | 45 | If you are unsure, say N. |
46 | 46 | ||
47 | config W1_SLAVE_BQ27000 | ||
48 | tristate "BQ27000 slave support" | ||
49 | depends on W1 | ||
50 | help | ||
51 | Say Y here if you want to use a hdq | ||
52 | bq27000 slave support. | ||
53 | |||
47 | endmenu | 54 | endmenu |
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile index a8eb7524df1d..990f400b6d22 100644 --- a/drivers/w1/slaves/Makefile +++ b/drivers/w1/slaves/Makefile | |||
@@ -6,4 +6,4 @@ obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o | |||
6 | obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o | 6 | obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o |
7 | obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o | 7 | obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o |
8 | obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o | 8 | obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o |
9 | 9 | obj-$(CONFIG_W1_SLAVE_BQ27000) += w1_bq27000.o | |
diff --git a/drivers/w1/slaves/w1_bq27000.c b/drivers/w1/slaves/w1_bq27000.c new file mode 100644 index 000000000000..8f4c91f6c680 --- /dev/null +++ b/drivers/w1/slaves/w1_bq27000.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * drivers/w1/slaves/w1_bq27000.c | ||
3 | * | ||
4 | * Copyright (C) 2007 Texas Instruments, Inc. | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public License | ||
7 | * version 2. This program is licensed "as is" without any warranty of any | ||
8 | * kind, whether express or implied. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/mutex.h> | ||
18 | |||
19 | #include "../w1.h" | ||
20 | #include "../w1_int.h" | ||
21 | #include "../w1_family.h" | ||
22 | |||
23 | #define HDQ_CMD_READ (0) | ||
24 | #define HDQ_CMD_WRITE (1<<7) | ||
25 | |||
26 | static int F_ID; | ||
27 | |||
28 | void w1_bq27000_write(struct device *dev, u8 buf, u8 reg) | ||
29 | { | ||
30 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | ||
31 | |||
32 | if (!dev) { | ||
33 | pr_info("Could not obtain slave dev ptr\n"); | ||
34 | return; | ||
35 | } | ||
36 | |||
37 | w1_write_8(sl->master, HDQ_CMD_WRITE | reg); | ||
38 | w1_write_8(sl->master, buf); | ||
39 | } | ||
40 | EXPORT_SYMBOL(w1_bq27000_write); | ||
41 | |||
42 | int w1_bq27000_read(struct device *dev, u8 reg) | ||
43 | { | ||
44 | u8 val; | ||
45 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | ||
46 | |||
47 | if (!dev) | ||
48 | return 0; | ||
49 | |||
50 | w1_write_8(sl->master, HDQ_CMD_READ | reg); | ||
51 | val = w1_read_8(sl->master); | ||
52 | |||
53 | return val; | ||
54 | } | ||
55 | EXPORT_SYMBOL(w1_bq27000_read); | ||
56 | |||
57 | static int w1_bq27000_add_slave(struct w1_slave *sl) | ||
58 | { | ||
59 | int ret; | ||
60 | int id = 1; | ||
61 | struct platform_device *pdev; | ||
62 | |||
63 | pdev = platform_device_alloc("bq27000-battery", id); | ||
64 | if (!pdev) { | ||
65 | ret = -ENOMEM; | ||
66 | return ret; | ||
67 | } | ||
68 | pdev->dev.parent = &sl->dev; | ||
69 | |||
70 | ret = platform_device_add(pdev); | ||
71 | if (ret) | ||
72 | goto pdev_add_failed; | ||
73 | |||
74 | dev_set_drvdata(&sl->dev, pdev); | ||
75 | |||
76 | goto success; | ||
77 | |||
78 | pdev_add_failed: | ||
79 | platform_device_unregister(pdev); | ||
80 | success: | ||
81 | return ret; | ||
82 | } | ||
83 | |||
84 | static void w1_bq27000_remove_slave(struct w1_slave *sl) | ||
85 | { | ||
86 | struct platform_device *pdev = dev_get_drvdata(&sl->dev); | ||
87 | |||
88 | platform_device_unregister(pdev); | ||
89 | } | ||
90 | |||
91 | static struct w1_family_ops w1_bq27000_fops = { | ||
92 | .add_slave = w1_bq27000_add_slave, | ||
93 | .remove_slave = w1_bq27000_remove_slave, | ||
94 | }; | ||
95 | |||
96 | static struct w1_family w1_bq27000_family = { | ||
97 | .fid = 1, | ||
98 | .fops = &w1_bq27000_fops, | ||
99 | }; | ||
100 | |||
101 | static int __init w1_bq27000_init(void) | ||
102 | { | ||
103 | if (F_ID) | ||
104 | w1_bq27000_family.fid = F_ID; | ||
105 | |||
106 | return w1_register_family(&w1_bq27000_family); | ||
107 | } | ||
108 | |||
109 | static void __exit w1_bq27000_exit(void) | ||
110 | { | ||
111 | w1_unregister_family(&w1_bq27000_family); | ||
112 | } | ||
113 | |||
114 | |||
115 | module_init(w1_bq27000_init); | ||
116 | module_exit(w1_bq27000_exit); | ||
117 | |||
118 | module_param(F_ID, int, S_IRUSR); | ||
119 | MODULE_PARM_DESC(F_ID, "1-wire slave FID for BQ device"); | ||
120 | |||
121 | MODULE_LICENSE("GPL"); | ||
122 | MODULE_AUTHOR("Texas Instruments Ltd"); | ||
123 | MODULE_DESCRIPTION("HDQ/1-wire slave driver bq27000 battery monitor chip"); | ||
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index cdaa6fffbfc7..97304bd83ec9 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h | |||
@@ -206,6 +206,7 @@ void w1_slave_detach(struct w1_slave *sl); | |||
206 | 206 | ||
207 | u8 w1_triplet(struct w1_master *dev, int bdir); | 207 | u8 w1_triplet(struct w1_master *dev, int bdir); |
208 | void w1_write_8(struct w1_master *, u8); | 208 | void w1_write_8(struct w1_master *, u8); |
209 | u8 w1_read_8(struct w1_master *); | ||
209 | int w1_reset_bus(struct w1_master *); | 210 | int w1_reset_bus(struct w1_master *); |
210 | u8 w1_calc_crc8(u8 *, int); | 211 | u8 w1_calc_crc8(u8 *, int); |
211 | void w1_write_block(struct w1_master *, const u8 *, int); | 212 | void w1_write_block(struct w1_master *, const u8 *, int); |
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c index f4f82f1f486e..0d15b0eaf79a 100644 --- a/drivers/w1/w1_io.c +++ b/drivers/w1/w1_io.c | |||
@@ -217,7 +217,7 @@ u8 w1_triplet(struct w1_master *dev, int bdir) | |||
217 | * @param dev the master device | 217 | * @param dev the master device |
218 | * @return the byte read | 218 | * @return the byte read |
219 | */ | 219 | */ |
220 | static u8 w1_read_8(struct w1_master * dev) | 220 | u8 w1_read_8(struct w1_master *dev) |
221 | { | 221 | { |
222 | int i; | 222 | int i; |
223 | u8 res = 0; | 223 | u8 res = 0; |
@@ -230,6 +230,7 @@ static u8 w1_read_8(struct w1_master * dev) | |||
230 | 230 | ||
231 | return res; | 231 | return res; |
232 | } | 232 | } |
233 | EXPORT_SYMBOL_GPL(w1_read_8); | ||
233 | 234 | ||
234 | /** | 235 | /** |
235 | * Writes a series of bytes. | 236 | * Writes a series of bytes. |
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 69a12aae91d3..490e34bbf27a 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -107,12 +107,13 @@ void cifs_dump_mids(struct TCP_Server_Info *server) | |||
107 | #ifdef CONFIG_PROC_FS | 107 | #ifdef CONFIG_PROC_FS |
108 | static int cifs_debug_data_proc_show(struct seq_file *m, void *v) | 108 | static int cifs_debug_data_proc_show(struct seq_file *m, void *v) |
109 | { | 109 | { |
110 | struct list_head *tmp; | 110 | struct list_head *tmp1, *tmp2, *tmp3; |
111 | struct list_head *tmp1; | ||
112 | struct mid_q_entry *mid_entry; | 111 | struct mid_q_entry *mid_entry; |
112 | struct TCP_Server_Info *server; | ||
113 | struct cifsSesInfo *ses; | 113 | struct cifsSesInfo *ses; |
114 | struct cifsTconInfo *tcon; | 114 | struct cifsTconInfo *tcon; |
115 | int i; | 115 | int i, j; |
116 | __u32 dev_type; | ||
116 | 117 | ||
117 | seq_puts(m, | 118 | seq_puts(m, |
118 | "Display Internal CIFS Data Structures for Debugging\n" | 119 | "Display Internal CIFS Data Structures for Debugging\n" |
@@ -122,46 +123,78 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) | |||
122 | seq_printf(m, "Servers:"); | 123 | seq_printf(m, "Servers:"); |
123 | 124 | ||
124 | i = 0; | 125 | i = 0; |
125 | read_lock(&GlobalSMBSeslock); | 126 | read_lock(&cifs_tcp_ses_lock); |
126 | list_for_each(tmp, &GlobalSMBSessionList) { | 127 | list_for_each(tmp1, &cifs_tcp_ses_list) { |
128 | server = list_entry(tmp1, struct TCP_Server_Info, | ||
129 | tcp_ses_list); | ||
127 | i++; | 130 | i++; |
128 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 131 | list_for_each(tmp2, &server->smb_ses_list) { |
129 | if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || | 132 | ses = list_entry(tmp2, struct cifsSesInfo, |
130 | (ses->serverNOS == NULL)) { | 133 | smb_ses_list); |
131 | seq_printf(m, "\nentry for %s not fully " | 134 | if ((ses->serverDomain == NULL) || |
132 | "displayed\n\t", ses->serverName); | 135 | (ses->serverOS == NULL) || |
133 | } else { | 136 | (ses->serverNOS == NULL)) { |
134 | seq_printf(m, | 137 | seq_printf(m, "\n%d) entry for %s not fully " |
135 | "\n%d) Name: %s Domain: %s Mounts: %d OS:" | 138 | "displayed\n\t", i, ses->serverName); |
136 | " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" | 139 | } else { |
140 | seq_printf(m, | ||
141 | "\n%d) Name: %s Domain: %s Uses: %d OS:" | ||
142 | " %s\n\tNOS: %s\tCapability: 0x%x\n\tSMB" | ||
137 | " session status: %d\t", | 143 | " session status: %d\t", |
138 | i, ses->serverName, ses->serverDomain, | 144 | i, ses->serverName, ses->serverDomain, |
139 | atomic_read(&ses->inUse), | 145 | ses->ses_count, ses->serverOS, ses->serverNOS, |
140 | ses->serverOS, ses->serverNOS, | ||
141 | ses->capabilities, ses->status); | 146 | ses->capabilities, ses->status); |
142 | } | 147 | } |
143 | if (ses->server) { | ||
144 | seq_printf(m, "TCP status: %d\n\tLocal Users To " | 148 | seq_printf(m, "TCP status: %d\n\tLocal Users To " |
145 | "Server: %d SecMode: 0x%x Req On Wire: %d", | 149 | "Server: %d SecMode: 0x%x Req On Wire: %d", |
146 | ses->server->tcpStatus, | 150 | server->tcpStatus, server->srv_count, |
147 | atomic_read(&ses->server->socketUseCount), | 151 | server->secMode, |
148 | ses->server->secMode, | 152 | atomic_read(&server->inFlight)); |
149 | atomic_read(&ses->server->inFlight)); | ||
150 | 153 | ||
151 | #ifdef CONFIG_CIFS_STATS2 | 154 | #ifdef CONFIG_CIFS_STATS2 |
152 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", | 155 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", |
153 | atomic_read(&ses->server->inSend), | 156 | atomic_read(&server->inSend), |
154 | atomic_read(&ses->server->num_waiters)); | 157 | atomic_read(&server->num_waiters)); |
155 | #endif | 158 | #endif |
156 | 159 | ||
157 | seq_puts(m, "\nMIDs:\n"); | 160 | seq_puts(m, "\n\tShares:"); |
161 | j = 0; | ||
162 | list_for_each(tmp3, &ses->tcon_list) { | ||
163 | tcon = list_entry(tmp3, struct cifsTconInfo, | ||
164 | tcon_list); | ||
165 | ++j; | ||
166 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); | ||
167 | seq_printf(m, "\n\t%d) %s Mounts: %d ", j, | ||
168 | tcon->treeName, tcon->tc_count); | ||
169 | if (tcon->nativeFileSystem) { | ||
170 | seq_printf(m, "Type: %s ", | ||
171 | tcon->nativeFileSystem); | ||
172 | } | ||
173 | seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x" | ||
174 | "\nPathComponentMax: %d Status: 0x%d", | ||
175 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), | ||
176 | le32_to_cpu(tcon->fsAttrInfo.Attributes), | ||
177 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), | ||
178 | tcon->tidStatus); | ||
179 | if (dev_type == FILE_DEVICE_DISK) | ||
180 | seq_puts(m, " type: DISK "); | ||
181 | else if (dev_type == FILE_DEVICE_CD_ROM) | ||
182 | seq_puts(m, " type: CDROM "); | ||
183 | else | ||
184 | seq_printf(m, " type: %d ", dev_type); | ||
185 | |||
186 | if (tcon->need_reconnect) | ||
187 | seq_puts(m, "\tDISCONNECTED "); | ||
188 | seq_putc(m, '\n'); | ||
189 | } | ||
190 | |||
191 | seq_puts(m, "\n\tMIDs:\n"); | ||
158 | 192 | ||
159 | spin_lock(&GlobalMid_Lock); | 193 | spin_lock(&GlobalMid_Lock); |
160 | list_for_each(tmp1, &ses->server->pending_mid_q) { | 194 | list_for_each(tmp3, &server->pending_mid_q) { |
161 | mid_entry = list_entry(tmp1, struct | 195 | mid_entry = list_entry(tmp3, struct mid_q_entry, |
162 | mid_q_entry, | ||
163 | qhead); | 196 | qhead); |
164 | seq_printf(m, "State: %d com: %d pid:" | 197 | seq_printf(m, "\tState: %d com: %d pid:" |
165 | " %d tsk: %p mid %d\n", | 198 | " %d tsk: %p mid %d\n", |
166 | mid_entry->midState, | 199 | mid_entry->midState, |
167 | (int)mid_entry->command, | 200 | (int)mid_entry->command, |
@@ -171,44 +204,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) | |||
171 | } | 204 | } |
172 | spin_unlock(&GlobalMid_Lock); | 205 | spin_unlock(&GlobalMid_Lock); |
173 | } | 206 | } |
174 | |||
175 | } | ||
176 | read_unlock(&GlobalSMBSeslock); | ||
177 | seq_putc(m, '\n'); | ||
178 | |||
179 | seq_puts(m, "Shares:"); | ||
180 | |||
181 | i = 0; | ||
182 | read_lock(&GlobalSMBSeslock); | ||
183 | list_for_each(tmp, &GlobalTreeConnectionList) { | ||
184 | __u32 dev_type; | ||
185 | i++; | ||
186 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | ||
187 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); | ||
188 | seq_printf(m, "\n%d) %s Uses: %d ", i, | ||
189 | tcon->treeName, atomic_read(&tcon->useCount)); | ||
190 | if (tcon->nativeFileSystem) { | ||
191 | seq_printf(m, "Type: %s ", | ||
192 | tcon->nativeFileSystem); | ||
193 | } | ||
194 | seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x" | ||
195 | "\nPathComponentMax: %d Status: %d", | ||
196 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), | ||
197 | le32_to_cpu(tcon->fsAttrInfo.Attributes), | ||
198 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), | ||
199 | tcon->tidStatus); | ||
200 | if (dev_type == FILE_DEVICE_DISK) | ||
201 | seq_puts(m, " type: DISK "); | ||
202 | else if (dev_type == FILE_DEVICE_CD_ROM) | ||
203 | seq_puts(m, " type: CDROM "); | ||
204 | else | ||
205 | seq_printf(m, " type: %d ", dev_type); | ||
206 | |||
207 | if (tcon->tidStatus == CifsNeedReconnect) | ||
208 | seq_puts(m, "\tDISCONNECTED "); | ||
209 | } | 207 | } |
210 | read_unlock(&GlobalSMBSeslock); | 208 | read_unlock(&cifs_tcp_ses_lock); |
211 | |||
212 | seq_putc(m, '\n'); | 209 | seq_putc(m, '\n'); |
213 | 210 | ||
214 | /* BB add code to dump additional info such as TCP session info now */ | 211 | /* BB add code to dump additional info such as TCP session info now */ |
@@ -234,7 +231,9 @@ static ssize_t cifs_stats_proc_write(struct file *file, | |||
234 | { | 231 | { |
235 | char c; | 232 | char c; |
236 | int rc; | 233 | int rc; |
237 | struct list_head *tmp; | 234 | struct list_head *tmp1, *tmp2, *tmp3; |
235 | struct TCP_Server_Info *server; | ||
236 | struct cifsSesInfo *ses; | ||
238 | struct cifsTconInfo *tcon; | 237 | struct cifsTconInfo *tcon; |
239 | 238 | ||
240 | rc = get_user(c, buffer); | 239 | rc = get_user(c, buffer); |
@@ -242,33 +241,42 @@ static ssize_t cifs_stats_proc_write(struct file *file, | |||
242 | return rc; | 241 | return rc; |
243 | 242 | ||
244 | if (c == '1' || c == 'y' || c == 'Y' || c == '0') { | 243 | if (c == '1' || c == 'y' || c == 'Y' || c == '0') { |
245 | read_lock(&GlobalSMBSeslock); | ||
246 | #ifdef CONFIG_CIFS_STATS2 | 244 | #ifdef CONFIG_CIFS_STATS2 |
247 | atomic_set(&totBufAllocCount, 0); | 245 | atomic_set(&totBufAllocCount, 0); |
248 | atomic_set(&totSmBufAllocCount, 0); | 246 | atomic_set(&totSmBufAllocCount, 0); |
249 | #endif /* CONFIG_CIFS_STATS2 */ | 247 | #endif /* CONFIG_CIFS_STATS2 */ |
250 | list_for_each(tmp, &GlobalTreeConnectionList) { | 248 | read_lock(&cifs_tcp_ses_lock); |
251 | tcon = list_entry(tmp, struct cifsTconInfo, | 249 | list_for_each(tmp1, &cifs_tcp_ses_list) { |
252 | cifsConnectionList); | 250 | server = list_entry(tmp1, struct TCP_Server_Info, |
253 | atomic_set(&tcon->num_smbs_sent, 0); | 251 | tcp_ses_list); |
254 | atomic_set(&tcon->num_writes, 0); | 252 | list_for_each(tmp2, &server->smb_ses_list) { |
255 | atomic_set(&tcon->num_reads, 0); | 253 | ses = list_entry(tmp2, struct cifsSesInfo, |
256 | atomic_set(&tcon->num_oplock_brks, 0); | 254 | smb_ses_list); |
257 | atomic_set(&tcon->num_opens, 0); | 255 | list_for_each(tmp3, &ses->tcon_list) { |
258 | atomic_set(&tcon->num_closes, 0); | 256 | tcon = list_entry(tmp3, |
259 | atomic_set(&tcon->num_deletes, 0); | 257 | struct cifsTconInfo, |
260 | atomic_set(&tcon->num_mkdirs, 0); | 258 | tcon_list); |
261 | atomic_set(&tcon->num_rmdirs, 0); | 259 | atomic_set(&tcon->num_smbs_sent, 0); |
262 | atomic_set(&tcon->num_renames, 0); | 260 | atomic_set(&tcon->num_writes, 0); |
263 | atomic_set(&tcon->num_t2renames, 0); | 261 | atomic_set(&tcon->num_reads, 0); |
264 | atomic_set(&tcon->num_ffirst, 0); | 262 | atomic_set(&tcon->num_oplock_brks, 0); |
265 | atomic_set(&tcon->num_fnext, 0); | 263 | atomic_set(&tcon->num_opens, 0); |
266 | atomic_set(&tcon->num_fclose, 0); | 264 | atomic_set(&tcon->num_closes, 0); |
267 | atomic_set(&tcon->num_hardlinks, 0); | 265 | atomic_set(&tcon->num_deletes, 0); |
268 | atomic_set(&tcon->num_symlinks, 0); | 266 | atomic_set(&tcon->num_mkdirs, 0); |
269 | atomic_set(&tcon->num_locks, 0); | 267 | atomic_set(&tcon->num_rmdirs, 0); |
268 | atomic_set(&tcon->num_renames, 0); | ||
269 | atomic_set(&tcon->num_t2renames, 0); | ||
270 | atomic_set(&tcon->num_ffirst, 0); | ||
271 | atomic_set(&tcon->num_fnext, 0); | ||
272 | atomic_set(&tcon->num_fclose, 0); | ||
273 | atomic_set(&tcon->num_hardlinks, 0); | ||
274 | atomic_set(&tcon->num_symlinks, 0); | ||
275 | atomic_set(&tcon->num_locks, 0); | ||
276 | } | ||
277 | } | ||
270 | } | 278 | } |
271 | read_unlock(&GlobalSMBSeslock); | 279 | read_unlock(&cifs_tcp_ses_lock); |
272 | } | 280 | } |
273 | 281 | ||
274 | return count; | 282 | return count; |
@@ -277,7 +285,9 @@ static ssize_t cifs_stats_proc_write(struct file *file, | |||
277 | static int cifs_stats_proc_show(struct seq_file *m, void *v) | 285 | static int cifs_stats_proc_show(struct seq_file *m, void *v) |
278 | { | 286 | { |
279 | int i; | 287 | int i; |
280 | struct list_head *tmp; | 288 | struct list_head *tmp1, *tmp2, *tmp3; |
289 | struct TCP_Server_Info *server; | ||
290 | struct cifsSesInfo *ses; | ||
281 | struct cifsTconInfo *tcon; | 291 | struct cifsTconInfo *tcon; |
282 | 292 | ||
283 | seq_printf(m, | 293 | seq_printf(m, |
@@ -306,44 +316,55 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v) | |||
306 | GlobalCurrentXid, GlobalMaxActiveXid); | 316 | GlobalCurrentXid, GlobalMaxActiveXid); |
307 | 317 | ||
308 | i = 0; | 318 | i = 0; |
309 | read_lock(&GlobalSMBSeslock); | 319 | read_lock(&cifs_tcp_ses_lock); |
310 | list_for_each(tmp, &GlobalTreeConnectionList) { | 320 | list_for_each(tmp1, &cifs_tcp_ses_list) { |
311 | i++; | 321 | server = list_entry(tmp1, struct TCP_Server_Info, |
312 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 322 | tcp_ses_list); |
313 | seq_printf(m, "\n%d) %s", i, tcon->treeName); | 323 | list_for_each(tmp2, &server->smb_ses_list) { |
314 | if (tcon->tidStatus == CifsNeedReconnect) | 324 | ses = list_entry(tmp2, struct cifsSesInfo, |
315 | seq_puts(m, "\tDISCONNECTED "); | 325 | smb_ses_list); |
316 | seq_printf(m, "\nSMBs: %d Oplock Breaks: %d", | 326 | list_for_each(tmp3, &ses->tcon_list) { |
317 | atomic_read(&tcon->num_smbs_sent), | 327 | tcon = list_entry(tmp3, |
318 | atomic_read(&tcon->num_oplock_brks)); | 328 | struct cifsTconInfo, |
319 | seq_printf(m, "\nReads: %d Bytes: %lld", | 329 | tcon_list); |
320 | atomic_read(&tcon->num_reads), | 330 | i++; |
321 | (long long)(tcon->bytes_read)); | 331 | seq_printf(m, "\n%d) %s", i, tcon->treeName); |
322 | seq_printf(m, "\nWrites: %d Bytes: %lld", | 332 | if (tcon->need_reconnect) |
323 | atomic_read(&tcon->num_writes), | 333 | seq_puts(m, "\tDISCONNECTED "); |
324 | (long long)(tcon->bytes_written)); | 334 | seq_printf(m, "\nSMBs: %d Oplock Breaks: %d", |
325 | seq_printf(m, | 335 | atomic_read(&tcon->num_smbs_sent), |
326 | "\nLocks: %d HardLinks: %d Symlinks: %d", | 336 | atomic_read(&tcon->num_oplock_brks)); |
327 | atomic_read(&tcon->num_locks), | 337 | seq_printf(m, "\nReads: %d Bytes: %lld", |
328 | atomic_read(&tcon->num_hardlinks), | 338 | atomic_read(&tcon->num_reads), |
329 | atomic_read(&tcon->num_symlinks)); | 339 | (long long)(tcon->bytes_read)); |
330 | 340 | seq_printf(m, "\nWrites: %d Bytes: %lld", | |
331 | seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d", | 341 | atomic_read(&tcon->num_writes), |
332 | atomic_read(&tcon->num_opens), | 342 | (long long)(tcon->bytes_written)); |
333 | atomic_read(&tcon->num_closes), | 343 | seq_printf(m, "\nLocks: %d HardLinks: %d " |
334 | atomic_read(&tcon->num_deletes)); | 344 | "Symlinks: %d", |
335 | seq_printf(m, "\nMkdirs: %d Rmdirs: %d", | 345 | atomic_read(&tcon->num_locks), |
336 | atomic_read(&tcon->num_mkdirs), | 346 | atomic_read(&tcon->num_hardlinks), |
337 | atomic_read(&tcon->num_rmdirs)); | 347 | atomic_read(&tcon->num_symlinks)); |
338 | seq_printf(m, "\nRenames: %d T2 Renames %d", | 348 | seq_printf(m, "\nOpens: %d Closes: %d" |
339 | atomic_read(&tcon->num_renames), | 349 | "Deletes: %d", |
340 | atomic_read(&tcon->num_t2renames)); | 350 | atomic_read(&tcon->num_opens), |
341 | seq_printf(m, "\nFindFirst: %d FNext %d FClose %d", | 351 | atomic_read(&tcon->num_closes), |
342 | atomic_read(&tcon->num_ffirst), | 352 | atomic_read(&tcon->num_deletes)); |
343 | atomic_read(&tcon->num_fnext), | 353 | seq_printf(m, "\nMkdirs: %d Rmdirs: %d", |
344 | atomic_read(&tcon->num_fclose)); | 354 | atomic_read(&tcon->num_mkdirs), |
355 | atomic_read(&tcon->num_rmdirs)); | ||
356 | seq_printf(m, "\nRenames: %d T2 Renames %d", | ||
357 | atomic_read(&tcon->num_renames), | ||
358 | atomic_read(&tcon->num_t2renames)); | ||
359 | seq_printf(m, "\nFindFirst: %d FNext %d " | ||
360 | "FClose %d", | ||
361 | atomic_read(&tcon->num_ffirst), | ||
362 | atomic_read(&tcon->num_fnext), | ||
363 | atomic_read(&tcon->num_fclose)); | ||
364 | } | ||
365 | } | ||
345 | } | 366 | } |
346 | read_unlock(&GlobalSMBSeslock); | 367 | read_unlock(&cifs_tcp_ses_lock); |
347 | 368 | ||
348 | seq_putc(m, '\n'); | 369 | seq_putc(m, '\n'); |
349 | return 0; | 370 | return 0; |
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index d2c8eef84f3c..e1c18362ba46 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c | |||
@@ -106,7 +106,8 @@ static char *cifs_get_share_name(const char *node_name) | |||
106 | /** | 106 | /** |
107 | * compose_mount_options - creates mount options for refferral | 107 | * compose_mount_options - creates mount options for refferral |
108 | * @sb_mountdata: parent/root DFS mount options (template) | 108 | * @sb_mountdata: parent/root DFS mount options (template) |
109 | * @ref_unc: refferral server UNC | 109 | * @dentry: point where we are going to mount |
110 | * @ref: server's referral | ||
110 | * @devname: pointer for saving device name | 111 | * @devname: pointer for saving device name |
111 | * | 112 | * |
112 | * creates mount options for submount based on template options sb_mountdata | 113 | * creates mount options for submount based on template options sb_mountdata |
@@ -116,7 +117,8 @@ static char *cifs_get_share_name(const char *node_name) | |||
116 | * Caller is responcible for freeing retunrned value if it is not error. | 117 | * Caller is responcible for freeing retunrned value if it is not error. |
117 | */ | 118 | */ |
118 | static char *compose_mount_options(const char *sb_mountdata, | 119 | static char *compose_mount_options(const char *sb_mountdata, |
119 | const char *ref_unc, | 120 | struct dentry *dentry, |
121 | const struct dfs_info3_param *ref, | ||
120 | char **devname) | 122 | char **devname) |
121 | { | 123 | { |
122 | int rc; | 124 | int rc; |
@@ -126,11 +128,12 @@ static char *compose_mount_options(const char *sb_mountdata, | |||
126 | char *srvIP = NULL; | 128 | char *srvIP = NULL; |
127 | char sep = ','; | 129 | char sep = ','; |
128 | int off, noff; | 130 | int off, noff; |
131 | char *fullpath; | ||
129 | 132 | ||
130 | if (sb_mountdata == NULL) | 133 | if (sb_mountdata == NULL) |
131 | return ERR_PTR(-EINVAL); | 134 | return ERR_PTR(-EINVAL); |
132 | 135 | ||
133 | *devname = cifs_get_share_name(ref_unc); | 136 | *devname = cifs_get_share_name(ref->node_name); |
134 | rc = dns_resolve_server_name_to_ip(*devname, &srvIP); | 137 | rc = dns_resolve_server_name_to_ip(*devname, &srvIP); |
135 | if (rc != 0) { | 138 | if (rc != 0) { |
136 | cERROR(1, ("%s: Failed to resolve server part of %s to IP", | 139 | cERROR(1, ("%s: Failed to resolve server part of %s to IP", |
@@ -138,7 +141,12 @@ static char *compose_mount_options(const char *sb_mountdata, | |||
138 | mountdata = ERR_PTR(rc); | 141 | mountdata = ERR_PTR(rc); |
139 | goto compose_mount_options_out; | 142 | goto compose_mount_options_out; |
140 | } | 143 | } |
141 | md_len = strlen(sb_mountdata) + strlen(srvIP) + strlen(ref_unc) + 3; | 144 | /* md_len = strlen(...) + 12 for 'sep+prefixpath=' |
145 | * assuming that we have 'unc=' and 'ip=' in | ||
146 | * the original sb_mountdata | ||
147 | */ | ||
148 | md_len = strlen(sb_mountdata) + strlen(srvIP) + | ||
149 | strlen(ref->node_name) + 12; | ||
142 | mountdata = kzalloc(md_len+1, GFP_KERNEL); | 150 | mountdata = kzalloc(md_len+1, GFP_KERNEL); |
143 | if (mountdata == NULL) { | 151 | if (mountdata == NULL) { |
144 | mountdata = ERR_PTR(-ENOMEM); | 152 | mountdata = ERR_PTR(-ENOMEM); |
@@ -152,41 +160,56 @@ static char *compose_mount_options(const char *sb_mountdata, | |||
152 | strncpy(mountdata, sb_mountdata, 5); | 160 | strncpy(mountdata, sb_mountdata, 5); |
153 | off += 5; | 161 | off += 5; |
154 | } | 162 | } |
155 | while ((tkn_e = strchr(sb_mountdata+off, sep))) { | 163 | |
156 | noff = (tkn_e - (sb_mountdata+off)) + 1; | 164 | do { |
157 | if (strnicmp(sb_mountdata+off, "unc=", 4) == 0) { | 165 | tkn_e = strchr(sb_mountdata + off, sep); |
166 | if (tkn_e == NULL) | ||
167 | noff = strlen(sb_mountdata + off); | ||
168 | else | ||
169 | noff = tkn_e - (sb_mountdata + off) + 1; | ||
170 | |||
171 | if (strnicmp(sb_mountdata + off, "unc=", 4) == 0) { | ||
158 | off += noff; | 172 | off += noff; |
159 | continue; | 173 | continue; |
160 | } | 174 | } |
161 | if (strnicmp(sb_mountdata+off, "ip=", 3) == 0) { | 175 | if (strnicmp(sb_mountdata + off, "ip=", 3) == 0) { |
162 | off += noff; | 176 | off += noff; |
163 | continue; | 177 | continue; |
164 | } | 178 | } |
165 | if (strnicmp(sb_mountdata+off, "prefixpath=", 3) == 0) { | 179 | if (strnicmp(sb_mountdata + off, "prefixpath=", 11) == 0) { |
166 | off += noff; | 180 | off += noff; |
167 | continue; | 181 | continue; |
168 | } | 182 | } |
169 | strncat(mountdata, sb_mountdata+off, noff); | 183 | strncat(mountdata, sb_mountdata + off, noff); |
170 | off += noff; | 184 | off += noff; |
171 | } | 185 | } while (tkn_e); |
172 | strcat(mountdata, sb_mountdata+off); | 186 | strcat(mountdata, sb_mountdata + off); |
173 | mountdata[md_len] = '\0'; | 187 | mountdata[md_len] = '\0'; |
174 | 188 | ||
175 | /* copy new IP and ref share name */ | 189 | /* copy new IP and ref share name */ |
176 | strcat(mountdata, ",ip="); | 190 | if (mountdata[strlen(mountdata) - 1] != sep) |
191 | strncat(mountdata, &sep, 1); | ||
192 | strcat(mountdata, "ip="); | ||
177 | strcat(mountdata, srvIP); | 193 | strcat(mountdata, srvIP); |
178 | strcat(mountdata, ",unc="); | 194 | strncat(mountdata, &sep, 1); |
195 | strcat(mountdata, "unc="); | ||
179 | strcat(mountdata, *devname); | 196 | strcat(mountdata, *devname); |
180 | 197 | ||
181 | /* find & copy prefixpath */ | 198 | /* find & copy prefixpath */ |
182 | tkn_e = strchr(ref_unc+2, '\\'); | 199 | tkn_e = strchr(ref->node_name + 2, '\\'); |
183 | if (tkn_e) { | 200 | if (tkn_e == NULL) /* invalid unc, missing share name*/ |
184 | tkn_e = strchr(tkn_e+1, '\\'); | 201 | goto compose_mount_options_out; |
185 | if (tkn_e) { | 202 | |
186 | strcat(mountdata, ",prefixpath="); | 203 | fullpath = build_path_from_dentry(dentry); |
187 | strcat(mountdata, tkn_e+1); | 204 | tkn_e = strchr(tkn_e + 1, '\\'); |
188 | } | 205 | if (tkn_e || strlen(fullpath) - (ref->path_consumed)) { |
206 | strncat(mountdata, &sep, 1); | ||
207 | strcat(mountdata, "prefixpath="); | ||
208 | if (tkn_e) | ||
209 | strcat(mountdata, tkn_e + 1); | ||
210 | strcat(mountdata, fullpath + (ref->path_consumed)); | ||
189 | } | 211 | } |
212 | kfree(fullpath); | ||
190 | 213 | ||
191 | /*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/ | 214 | /*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/ |
192 | /*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/ | 215 | /*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/ |
@@ -198,7 +221,7 @@ compose_mount_options_out: | |||
198 | 221 | ||
199 | 222 | ||
200 | static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent, | 223 | static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent, |
201 | struct dentry *dentry, char *ref_unc) | 224 | struct dentry *dentry, const struct dfs_info3_param *ref) |
202 | { | 225 | { |
203 | struct cifs_sb_info *cifs_sb; | 226 | struct cifs_sb_info *cifs_sb; |
204 | struct vfsmount *mnt; | 227 | struct vfsmount *mnt; |
@@ -207,7 +230,7 @@ static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent, | |||
207 | 230 | ||
208 | cifs_sb = CIFS_SB(dentry->d_inode->i_sb); | 231 | cifs_sb = CIFS_SB(dentry->d_inode->i_sb); |
209 | mountdata = compose_mount_options(cifs_sb->mountdata, | 232 | mountdata = compose_mount_options(cifs_sb->mountdata, |
210 | ref_unc, &devname); | 233 | dentry, ref, &devname); |
211 | 234 | ||
212 | if (IS_ERR(mountdata)) | 235 | if (IS_ERR(mountdata)) |
213 | return (struct vfsmount *)mountdata; | 236 | return (struct vfsmount *)mountdata; |
@@ -310,7 +333,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) | |||
310 | } | 333 | } |
311 | mnt = cifs_dfs_do_refmount(nd->path.mnt, | 334 | mnt = cifs_dfs_do_refmount(nd->path.mnt, |
312 | nd->path.dentry, | 335 | nd->path.dentry, |
313 | referrals[i].node_name); | 336 | referrals + i); |
314 | cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p", | 337 | cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p", |
315 | __func__, | 338 | __func__, |
316 | referrals[i].node_name, mnt)); | 339 | referrals[i].node_name, mnt)); |
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c index fcee9298b620..0ab2fb5afef1 100644 --- a/fs/cifs/cifs_spnego.c +++ b/fs/cifs/cifs_spnego.c | |||
@@ -73,8 +73,8 @@ struct key_type cifs_spnego_key_type = { | |||
73 | * strlen(";sec=ntlmsspi") */ | 73 | * strlen(";sec=ntlmsspi") */ |
74 | #define MAX_MECH_STR_LEN 13 | 74 | #define MAX_MECH_STR_LEN 13 |
75 | 75 | ||
76 | /* max possible addr len eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60 */ | 76 | /* max possible addr len eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/128 */ |
77 | #define MAX_IPV6_ADDR_LEN 42 | 77 | #define MAX_IPV6_ADDR_LEN 43 |
78 | 78 | ||
79 | /* strlen of "host=" */ | 79 | /* strlen of "host=" */ |
80 | #define HOST_KEY_LEN 5 | 80 | #define HOST_KEY_LEN 5 |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index ac5915d61dca..d9cf467309e8 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -514,10 +514,11 @@ static void cifs_umount_begin(struct super_block *sb) | |||
514 | tcon = cifs_sb->tcon; | 514 | tcon = cifs_sb->tcon; |
515 | if (tcon == NULL) | 515 | if (tcon == NULL) |
516 | return; | 516 | return; |
517 | down(&tcon->tconSem); | 517 | |
518 | if (atomic_read(&tcon->useCount) == 1) | 518 | read_lock(&cifs_tcp_ses_lock); |
519 | if (tcon->tc_count == 1) | ||
519 | tcon->tidStatus = CifsExiting; | 520 | tcon->tidStatus = CifsExiting; |
520 | up(&tcon->tconSem); | 521 | read_unlock(&cifs_tcp_ses_lock); |
521 | 522 | ||
522 | /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ | 523 | /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ |
523 | /* cancel_notify_requests(tcon); */ | 524 | /* cancel_notify_requests(tcon); */ |
@@ -1013,7 +1014,7 @@ static int cifs_oplock_thread(void *dummyarg) | |||
1013 | not bother sending an oplock release if session | 1014 | not bother sending an oplock release if session |
1014 | to server still is disconnected since oplock | 1015 | to server still is disconnected since oplock |
1015 | already released by the server in that case */ | 1016 | already released by the server in that case */ |
1016 | if (pTcon->tidStatus != CifsNeedReconnect) { | 1017 | if (!pTcon->need_reconnect) { |
1017 | rc = CIFSSMBLock(0, pTcon, netfid, | 1018 | rc = CIFSSMBLock(0, pTcon, netfid, |
1018 | 0 /* len */ , 0 /* offset */, 0, | 1019 | 0 /* len */ , 0 /* offset */, 0, |
1019 | 0, LOCKING_ANDX_OPLOCK_RELEASE, | 1020 | 0, LOCKING_ANDX_OPLOCK_RELEASE, |
@@ -1031,24 +1032,24 @@ static int cifs_oplock_thread(void *dummyarg) | |||
1031 | static int cifs_dnotify_thread(void *dummyarg) | 1032 | static int cifs_dnotify_thread(void *dummyarg) |
1032 | { | 1033 | { |
1033 | struct list_head *tmp; | 1034 | struct list_head *tmp; |
1034 | struct cifsSesInfo *ses; | 1035 | struct TCP_Server_Info *server; |
1035 | 1036 | ||
1036 | do { | 1037 | do { |
1037 | if (try_to_freeze()) | 1038 | if (try_to_freeze()) |
1038 | continue; | 1039 | continue; |
1039 | set_current_state(TASK_INTERRUPTIBLE); | 1040 | set_current_state(TASK_INTERRUPTIBLE); |
1040 | schedule_timeout(15*HZ); | 1041 | schedule_timeout(15*HZ); |
1041 | read_lock(&GlobalSMBSeslock); | ||
1042 | /* check if any stuck requests that need | 1042 | /* check if any stuck requests that need |
1043 | to be woken up and wakeq so the | 1043 | to be woken up and wakeq so the |
1044 | thread can wake up and error out */ | 1044 | thread can wake up and error out */ |
1045 | list_for_each(tmp, &GlobalSMBSessionList) { | 1045 | read_lock(&cifs_tcp_ses_lock); |
1046 | ses = list_entry(tmp, struct cifsSesInfo, | 1046 | list_for_each(tmp, &cifs_tcp_ses_list) { |
1047 | cifsSessionList); | 1047 | server = list_entry(tmp, struct TCP_Server_Info, |
1048 | if (ses->server && atomic_read(&ses->server->inFlight)) | 1048 | tcp_ses_list); |
1049 | wake_up_all(&ses->server->response_q); | 1049 | if (atomic_read(&server->inFlight)) |
1050 | wake_up_all(&server->response_q); | ||
1050 | } | 1051 | } |
1051 | read_unlock(&GlobalSMBSeslock); | 1052 | read_unlock(&cifs_tcp_ses_lock); |
1052 | } while (!kthread_should_stop()); | 1053 | } while (!kthread_should_stop()); |
1053 | 1054 | ||
1054 | return 0; | 1055 | return 0; |
@@ -1059,9 +1060,7 @@ init_cifs(void) | |||
1059 | { | 1060 | { |
1060 | int rc = 0; | 1061 | int rc = 0; |
1061 | cifs_proc_init(); | 1062 | cifs_proc_init(); |
1062 | /* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */ | 1063 | INIT_LIST_HEAD(&cifs_tcp_ses_list); |
1063 | INIT_LIST_HEAD(&GlobalSMBSessionList); | ||
1064 | INIT_LIST_HEAD(&GlobalTreeConnectionList); | ||
1065 | INIT_LIST_HEAD(&GlobalOplock_Q); | 1064 | INIT_LIST_HEAD(&GlobalOplock_Q); |
1066 | #ifdef CONFIG_CIFS_EXPERIMENTAL | 1065 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
1067 | INIT_LIST_HEAD(&GlobalDnotifyReqList); | 1066 | INIT_LIST_HEAD(&GlobalDnotifyReqList); |
@@ -1089,6 +1088,7 @@ init_cifs(void) | |||
1089 | GlobalMaxActiveXid = 0; | 1088 | GlobalMaxActiveXid = 0; |
1090 | memset(Local_System_Name, 0, 15); | 1089 | memset(Local_System_Name, 0, 15); |
1091 | rwlock_init(&GlobalSMBSeslock); | 1090 | rwlock_init(&GlobalSMBSeslock); |
1091 | rwlock_init(&cifs_tcp_ses_lock); | ||
1092 | spin_lock_init(&GlobalMid_Lock); | 1092 | spin_lock_init(&GlobalMid_Lock); |
1093 | 1093 | ||
1094 | if (cifs_max_pending < 2) { | 1094 | if (cifs_max_pending < 2) { |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 1cb1189f24e0..f1ae1f57c30d 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -85,8 +85,7 @@ enum securityEnum { | |||
85 | }; | 85 | }; |
86 | 86 | ||
87 | enum protocolEnum { | 87 | enum protocolEnum { |
88 | IPV4 = 0, | 88 | TCP = 0, |
89 | IPV6, | ||
90 | SCTP | 89 | SCTP |
91 | /* Netbios frames protocol not supported at this time */ | 90 | /* Netbios frames protocol not supported at this time */ |
92 | }; | 91 | }; |
@@ -122,6 +121,9 @@ struct cifs_cred { | |||
122 | */ | 121 | */ |
123 | 122 | ||
124 | struct TCP_Server_Info { | 123 | struct TCP_Server_Info { |
124 | struct list_head tcp_ses_list; | ||
125 | struct list_head smb_ses_list; | ||
126 | int srv_count; /* reference counter */ | ||
125 | /* 15 character server name + 0x20 16th byte indicating type = srv */ | 127 | /* 15 character server name + 0x20 16th byte indicating type = srv */ |
126 | char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; | 128 | char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; |
127 | char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2]; | 129 | char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2]; |
@@ -143,7 +145,6 @@ struct TCP_Server_Info { | |||
143 | bool svlocal:1; /* local server or remote */ | 145 | bool svlocal:1; /* local server or remote */ |
144 | bool noblocksnd; /* use blocking sendmsg */ | 146 | bool noblocksnd; /* use blocking sendmsg */ |
145 | bool noautotune; /* do not autotune send buf sizes */ | 147 | bool noautotune; /* do not autotune send buf sizes */ |
146 | atomic_t socketUseCount; /* number of open cifs sessions on socket */ | ||
147 | atomic_t inFlight; /* number of requests on the wire to server */ | 148 | atomic_t inFlight; /* number of requests on the wire to server */ |
148 | #ifdef CONFIG_CIFS_STATS2 | 149 | #ifdef CONFIG_CIFS_STATS2 |
149 | atomic_t inSend; /* requests trying to send */ | 150 | atomic_t inSend; /* requests trying to send */ |
@@ -194,13 +195,14 @@ struct cifsUidInfo { | |||
194 | * Session structure. One of these for each uid session with a particular host | 195 | * Session structure. One of these for each uid session with a particular host |
195 | */ | 196 | */ |
196 | struct cifsSesInfo { | 197 | struct cifsSesInfo { |
197 | struct list_head cifsSessionList; | 198 | struct list_head smb_ses_list; |
199 | struct list_head tcon_list; | ||
198 | struct semaphore sesSem; | 200 | struct semaphore sesSem; |
199 | #if 0 | 201 | #if 0 |
200 | struct cifsUidInfo *uidInfo; /* pointer to user info */ | 202 | struct cifsUidInfo *uidInfo; /* pointer to user info */ |
201 | #endif | 203 | #endif |
202 | struct TCP_Server_Info *server; /* pointer to server info */ | 204 | struct TCP_Server_Info *server; /* pointer to server info */ |
203 | atomic_t inUse; /* # of mounts (tree connections) on this ses */ | 205 | int ses_count; /* reference counter */ |
204 | enum statusEnum status; | 206 | enum statusEnum status; |
205 | unsigned overrideSecFlg; /* if non-zero override global sec flags */ | 207 | unsigned overrideSecFlg; /* if non-zero override global sec flags */ |
206 | __u16 ipc_tid; /* special tid for connection to IPC share */ | 208 | __u16 ipc_tid; /* special tid for connection to IPC share */ |
@@ -216,6 +218,7 @@ struct cifsSesInfo { | |||
216 | char userName[MAX_USERNAME_SIZE + 1]; | 218 | char userName[MAX_USERNAME_SIZE + 1]; |
217 | char *domainName; | 219 | char *domainName; |
218 | char *password; | 220 | char *password; |
221 | bool need_reconnect:1; /* connection reset, uid now invalid */ | ||
219 | }; | 222 | }; |
220 | /* no more than one of the following three session flags may be set */ | 223 | /* no more than one of the following three session flags may be set */ |
221 | #define CIFS_SES_NT4 1 | 224 | #define CIFS_SES_NT4 1 |
@@ -230,16 +233,15 @@ struct cifsSesInfo { | |||
230 | * session | 233 | * session |
231 | */ | 234 | */ |
232 | struct cifsTconInfo { | 235 | struct cifsTconInfo { |
233 | struct list_head cifsConnectionList; | 236 | struct list_head tcon_list; |
237 | int tc_count; | ||
234 | struct list_head openFileList; | 238 | struct list_head openFileList; |
235 | struct semaphore tconSem; | ||
236 | struct cifsSesInfo *ses; /* pointer to session associated with */ | 239 | struct cifsSesInfo *ses; /* pointer to session associated with */ |
237 | char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ | 240 | char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ |
238 | char *nativeFileSystem; | 241 | char *nativeFileSystem; |
239 | __u16 tid; /* The 2 byte tree id */ | 242 | __u16 tid; /* The 2 byte tree id */ |
240 | __u16 Flags; /* optional support bits */ | 243 | __u16 Flags; /* optional support bits */ |
241 | enum statusEnum tidStatus; | 244 | enum statusEnum tidStatus; |
242 | atomic_t useCount; /* how many explicit/implicit mounts to share */ | ||
243 | #ifdef CONFIG_CIFS_STATS | 245 | #ifdef CONFIG_CIFS_STATS |
244 | atomic_t num_smbs_sent; | 246 | atomic_t num_smbs_sent; |
245 | atomic_t num_writes; | 247 | atomic_t num_writes; |
@@ -288,6 +290,7 @@ struct cifsTconInfo { | |||
288 | bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol | 290 | bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol |
289 | for this mount even if server would support */ | 291 | for this mount even if server would support */ |
290 | bool local_lease:1; /* check leases (only) on local system not remote */ | 292 | bool local_lease:1; /* check leases (only) on local system not remote */ |
293 | bool need_reconnect:1; /* connection reset, tid now invalid */ | ||
291 | /* BB add field for back pointer to sb struct(s)? */ | 294 | /* BB add field for back pointer to sb struct(s)? */ |
292 | }; | 295 | }; |
293 | 296 | ||
@@ -588,21 +591,21 @@ require use of the stronger protocol */ | |||
588 | #endif | 591 | #endif |
589 | 592 | ||
590 | /* | 593 | /* |
591 | * The list of servers that did not respond with NT LM 0.12. | 594 | * the list of TCP_Server_Info structures, ie each of the sockets |
592 | * This list helps improve performance and eliminate the messages indicating | 595 | * connecting our client to a distinct server (ip address), is |
593 | * that we had a communications error talking to the server in this list. | 596 | * chained together by cifs_tcp_ses_list. The list of all our SMB |
597 | * sessions (and from that the tree connections) can be found | ||
598 | * by iterating over cifs_tcp_ses_list | ||
594 | */ | 599 | */ |
595 | /* Feature not supported */ | 600 | GLOBAL_EXTERN struct list_head cifs_tcp_ses_list; |
596 | /* GLOBAL_EXTERN struct servers_not_supported *NotSuppList; */ | ||
597 | 601 | ||
598 | /* | 602 | /* |
599 | * The following is a hash table of all the users we know about. | 603 | * This lock protects the cifs_tcp_ses_list, the list of smb sessions per |
604 | * tcp session, and the list of tcon's per smb session. It also protects | ||
605 | * the reference counters for the server, smb session, and tcon. Finally, | ||
606 | * changes to the tcon->tidStatus should be done while holding this lock. | ||
600 | */ | 607 | */ |
601 | GLOBAL_EXTERN struct smbUidInfo *GlobalUidList[UID_HASH]; | 608 | GLOBAL_EXTERN rwlock_t cifs_tcp_ses_lock; |
602 | |||
603 | /* GLOBAL_EXTERN struct list_head GlobalServerList; BB not implemented yet */ | ||
604 | GLOBAL_EXTERN struct list_head GlobalSMBSessionList; | ||
605 | GLOBAL_EXTERN struct list_head GlobalTreeConnectionList; | ||
606 | GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */ | 609 | GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */ |
607 | 610 | ||
608 | GLOBAL_EXTERN struct list_head GlobalOplock_Q; | 611 | GLOBAL_EXTERN struct list_head GlobalOplock_Q; |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index d5eac48fc415..bdda46dd435a 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -190,10 +190,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
190 | /* need to prevent multiple threads trying to | 190 | /* need to prevent multiple threads trying to |
191 | simultaneously reconnect the same SMB session */ | 191 | simultaneously reconnect the same SMB session */ |
192 | down(&tcon->ses->sesSem); | 192 | down(&tcon->ses->sesSem); |
193 | if (tcon->ses->status == CifsNeedReconnect) | 193 | if (tcon->ses->need_reconnect) |
194 | rc = cifs_setup_session(0, tcon->ses, | 194 | rc = cifs_setup_session(0, tcon->ses, |
195 | nls_codepage); | 195 | nls_codepage); |
196 | if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { | 196 | if (!rc && (tcon->need_reconnect)) { |
197 | mark_open_files_invalid(tcon); | 197 | mark_open_files_invalid(tcon); |
198 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, | 198 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, |
199 | tcon, nls_codepage); | 199 | tcon, nls_codepage); |
@@ -295,7 +295,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
295 | check for tcp and smb session status done differently | 295 | check for tcp and smb session status done differently |
296 | for those three - in the calling routine */ | 296 | for those three - in the calling routine */ |
297 | if (tcon) { | 297 | if (tcon) { |
298 | if (tcon->tidStatus == CifsExiting) { | 298 | if (tcon->need_reconnect) { |
299 | /* only tree disconnect, open, and write, | 299 | /* only tree disconnect, open, and write, |
300 | (and ulogoff which does not have tcon) | 300 | (and ulogoff which does not have tcon) |
301 | are allowed as we start force umount */ | 301 | are allowed as we start force umount */ |
@@ -337,10 +337,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
337 | /* need to prevent multiple threads trying to | 337 | /* need to prevent multiple threads trying to |
338 | simultaneously reconnect the same SMB session */ | 338 | simultaneously reconnect the same SMB session */ |
339 | down(&tcon->ses->sesSem); | 339 | down(&tcon->ses->sesSem); |
340 | if (tcon->ses->status == CifsNeedReconnect) | 340 | if (tcon->ses->need_reconnect) |
341 | rc = cifs_setup_session(0, tcon->ses, | 341 | rc = cifs_setup_session(0, tcon->ses, |
342 | nls_codepage); | 342 | nls_codepage); |
343 | if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { | 343 | if (!rc && (tcon->need_reconnect)) { |
344 | mark_open_files_invalid(tcon); | 344 | mark_open_files_invalid(tcon); |
345 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, | 345 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, |
346 | tcon, nls_codepage); | 346 | tcon, nls_codepage); |
@@ -664,8 +664,9 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | |||
664 | rc = -EIO; | 664 | rc = -EIO; |
665 | goto neg_err_exit; | 665 | goto neg_err_exit; |
666 | } | 666 | } |
667 | 667 | read_lock(&cifs_tcp_ses_lock); | |
668 | if (server->socketUseCount.counter > 1) { | 668 | if (server->srv_count > 1) { |
669 | read_unlock(&cifs_tcp_ses_lock); | ||
669 | if (memcmp(server->server_GUID, | 670 | if (memcmp(server->server_GUID, |
670 | pSMBr->u.extended_response. | 671 | pSMBr->u.extended_response. |
671 | GUID, 16) != 0) { | 672 | GUID, 16) != 0) { |
@@ -674,9 +675,11 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | |||
674 | pSMBr->u.extended_response.GUID, | 675 | pSMBr->u.extended_response.GUID, |
675 | 16); | 676 | 16); |
676 | } | 677 | } |
677 | } else | 678 | } else { |
679 | read_unlock(&cifs_tcp_ses_lock); | ||
678 | memcpy(server->server_GUID, | 680 | memcpy(server->server_GUID, |
679 | pSMBr->u.extended_response.GUID, 16); | 681 | pSMBr->u.extended_response.GUID, 16); |
682 | } | ||
680 | 683 | ||
681 | if (count == 16) { | 684 | if (count == 16) { |
682 | server->secType = RawNTLMSSP; | 685 | server->secType = RawNTLMSSP; |
@@ -739,50 +742,31 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon) | |||
739 | int rc = 0; | 742 | int rc = 0; |
740 | 743 | ||
741 | cFYI(1, ("In tree disconnect")); | 744 | cFYI(1, ("In tree disconnect")); |
742 | /* | ||
743 | * If last user of the connection and | ||
744 | * connection alive - disconnect it | ||
745 | * If this is the last connection on the server session disconnect it | ||
746 | * (and inside session disconnect we should check if tcp socket needs | ||
747 | * to be freed and kernel thread woken up). | ||
748 | */ | ||
749 | if (tcon) | ||
750 | down(&tcon->tconSem); | ||
751 | else | ||
752 | return -EIO; | ||
753 | 745 | ||
754 | atomic_dec(&tcon->useCount); | 746 | /* BB: do we need to check this? These should never be NULL. */ |
755 | if (atomic_read(&tcon->useCount) > 0) { | 747 | if ((tcon->ses == NULL) || (tcon->ses->server == NULL)) |
756 | up(&tcon->tconSem); | 748 | return -EIO; |
757 | return -EBUSY; | ||
758 | } | ||
759 | 749 | ||
760 | /* No need to return error on this operation if tid invalidated and | 750 | /* |
761 | closed on server already e.g. due to tcp session crashing */ | 751 | * No need to return error on this operation if tid invalidated and |
762 | if (tcon->tidStatus == CifsNeedReconnect) { | 752 | * closed on server already e.g. due to tcp session crashing. Also, |
763 | up(&tcon->tconSem); | 753 | * the tcon is no longer on the list, so no need to take lock before |
754 | * checking this. | ||
755 | */ | ||
756 | if (tcon->need_reconnect) | ||
764 | return 0; | 757 | return 0; |
765 | } | ||
766 | 758 | ||
767 | if ((tcon->ses == NULL) || (tcon->ses->server == NULL)) { | ||
768 | up(&tcon->tconSem); | ||
769 | return -EIO; | ||
770 | } | ||
771 | rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, | 759 | rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, |
772 | (void **)&smb_buffer); | 760 | (void **)&smb_buffer); |
773 | if (rc) { | 761 | if (rc) |
774 | up(&tcon->tconSem); | ||
775 | return rc; | 762 | return rc; |
776 | } | ||
777 | 763 | ||
778 | rc = SendReceiveNoRsp(xid, tcon->ses, smb_buffer, 0); | 764 | rc = SendReceiveNoRsp(xid, tcon->ses, smb_buffer, 0); |
779 | if (rc) | 765 | if (rc) |
780 | cFYI(1, ("Tree disconnect failed %d", rc)); | 766 | cFYI(1, ("Tree disconnect failed %d", rc)); |
781 | 767 | ||
782 | up(&tcon->tconSem); | ||
783 | |||
784 | /* No need to return error on this operation if tid invalidated and | 768 | /* No need to return error on this operation if tid invalidated and |
785 | closed on server already e.g. due to tcp session crashing */ | 769 | closed on server already e.g. due to tcp session crashing */ |
786 | if (rc == -EAGAIN) | 770 | if (rc == -EAGAIN) |
787 | rc = 0; | 771 | rc = 0; |
788 | 772 | ||
@@ -796,43 +780,36 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) | |||
796 | int rc = 0; | 780 | int rc = 0; |
797 | 781 | ||
798 | cFYI(1, ("In SMBLogoff for session disconnect")); | 782 | cFYI(1, ("In SMBLogoff for session disconnect")); |
799 | if (ses) | 783 | |
800 | down(&ses->sesSem); | 784 | /* |
801 | else | 785 | * BB: do we need to check validity of ses and server? They should |
786 | * always be valid since we have an active reference. If not, that | ||
787 | * should probably be a BUG() | ||
788 | */ | ||
789 | if (!ses || !ses->server) | ||
802 | return -EIO; | 790 | return -EIO; |
803 | 791 | ||
804 | atomic_dec(&ses->inUse); | 792 | down(&ses->sesSem); |
805 | if (atomic_read(&ses->inUse) > 0) { | 793 | if (ses->need_reconnect) |
806 | up(&ses->sesSem); | 794 | goto session_already_dead; /* no need to send SMBlogoff if uid |
807 | return -EBUSY; | 795 | already closed due to reconnect */ |
808 | } | ||
809 | rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB); | 796 | rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB); |
810 | if (rc) { | 797 | if (rc) { |
811 | up(&ses->sesSem); | 798 | up(&ses->sesSem); |
812 | return rc; | 799 | return rc; |
813 | } | 800 | } |
814 | 801 | ||
815 | if (ses->server) { | 802 | pSMB->hdr.Mid = GetNextMid(ses->server); |
816 | pSMB->hdr.Mid = GetNextMid(ses->server); | ||
817 | 803 | ||
818 | if (ses->server->secMode & | 804 | if (ses->server->secMode & |
819 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 805 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
820 | pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 806 | pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
821 | } | ||
822 | 807 | ||
823 | pSMB->hdr.Uid = ses->Suid; | 808 | pSMB->hdr.Uid = ses->Suid; |
824 | 809 | ||
825 | pSMB->AndXCommand = 0xFF; | 810 | pSMB->AndXCommand = 0xFF; |
826 | rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); | 811 | rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); |
827 | if (ses->server) { | 812 | session_already_dead: |
828 | atomic_dec(&ses->server->socketUseCount); | ||
829 | if (atomic_read(&ses->server->socketUseCount) == 0) { | ||
830 | spin_lock(&GlobalMid_Lock); | ||
831 | ses->server->tcpStatus = CifsExiting; | ||
832 | spin_unlock(&GlobalMid_Lock); | ||
833 | rc = -ESHUTDOWN; | ||
834 | } | ||
835 | } | ||
836 | up(&ses->sesSem); | 813 | up(&ses->sesSem); |
837 | 814 | ||
838 | /* if session dead then we do not need to do ulogoff, | 815 | /* if session dead then we do not need to do ulogoff, |
@@ -3922,6 +3899,27 @@ GetInodeNumOut: | |||
3922 | return rc; | 3899 | return rc; |
3923 | } | 3900 | } |
3924 | 3901 | ||
3902 | /* computes length of UCS string converted to host codepage | ||
3903 | * @src: UCS string | ||
3904 | * @maxlen: length of the input string in UCS characters | ||
3905 | * (not in bytes) | ||
3906 | * | ||
3907 | * return: size of input string in host codepage | ||
3908 | */ | ||
3909 | static int hostlen_fromUCS(const __le16 *src, const int maxlen, | ||
3910 | const struct nls_table *nls_codepage) { | ||
3911 | int i; | ||
3912 | int hostlen = 0; | ||
3913 | char to[4]; | ||
3914 | int charlen; | ||
3915 | for (i = 0; (i < maxlen) && src[i]; ++i) { | ||
3916 | charlen = nls_codepage->uni2char(le16_to_cpu(src[i]), | ||
3917 | to, NLS_MAX_CHARSET_SIZE); | ||
3918 | hostlen += charlen > 0 ? charlen : 1; | ||
3919 | } | ||
3920 | return hostlen; | ||
3921 | } | ||
3922 | |||
3925 | /* parses DFS refferal V3 structure | 3923 | /* parses DFS refferal V3 structure |
3926 | * caller is responsible for freeing target_nodes | 3924 | * caller is responsible for freeing target_nodes |
3927 | * returns: | 3925 | * returns: |
@@ -3932,7 +3930,8 @@ static int | |||
3932 | parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | 3930 | parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, |
3933 | unsigned int *num_of_nodes, | 3931 | unsigned int *num_of_nodes, |
3934 | struct dfs_info3_param **target_nodes, | 3932 | struct dfs_info3_param **target_nodes, |
3935 | const struct nls_table *nls_codepage) | 3933 | const struct nls_table *nls_codepage, int remap, |
3934 | const char *searchName) | ||
3936 | { | 3935 | { |
3937 | int i, rc = 0; | 3936 | int i, rc = 0; |
3938 | char *data_end; | 3937 | char *data_end; |
@@ -3983,7 +3982,17 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
3983 | struct dfs_info3_param *node = (*target_nodes)+i; | 3982 | struct dfs_info3_param *node = (*target_nodes)+i; |
3984 | 3983 | ||
3985 | node->flags = le16_to_cpu(pSMBr->DFSFlags); | 3984 | node->flags = le16_to_cpu(pSMBr->DFSFlags); |
3986 | node->path_consumed = le16_to_cpu(pSMBr->PathConsumed); | 3985 | if (is_unicode) { |
3986 | __le16 *tmp = kmalloc(strlen(searchName)*2, GFP_KERNEL); | ||
3987 | cifsConvertToUCS((__le16 *) tmp, searchName, | ||
3988 | PATH_MAX, nls_codepage, remap); | ||
3989 | node->path_consumed = hostlen_fromUCS(tmp, | ||
3990 | le16_to_cpu(pSMBr->PathConsumed)/2, | ||
3991 | nls_codepage); | ||
3992 | kfree(tmp); | ||
3993 | } else | ||
3994 | node->path_consumed = le16_to_cpu(pSMBr->PathConsumed); | ||
3995 | |||
3987 | node->server_type = le16_to_cpu(ref->ServerType); | 3996 | node->server_type = le16_to_cpu(ref->ServerType); |
3988 | node->ref_flag = le16_to_cpu(ref->ReferralEntryFlags); | 3997 | node->ref_flag = le16_to_cpu(ref->ReferralEntryFlags); |
3989 | 3998 | ||
@@ -4116,7 +4125,8 @@ getDFSRetry: | |||
4116 | 4125 | ||
4117 | /* parse returned result into more usable form */ | 4126 | /* parse returned result into more usable form */ |
4118 | rc = parse_DFS_referrals(pSMBr, num_of_nodes, | 4127 | rc = parse_DFS_referrals(pSMBr, num_of_nodes, |
4119 | target_nodes, nls_codepage); | 4128 | target_nodes, nls_codepage, remap, |
4129 | searchName); | ||
4120 | 4130 | ||
4121 | GetDFSRefExit: | 4131 | GetDFSRefExit: |
4122 | cifs_buf_release(pSMB); | 4132 | cifs_buf_release(pSMB); |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e9f9248cb3fe..c7d341714586 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -124,7 +124,7 @@ static int | |||
124 | cifs_reconnect(struct TCP_Server_Info *server) | 124 | cifs_reconnect(struct TCP_Server_Info *server) |
125 | { | 125 | { |
126 | int rc = 0; | 126 | int rc = 0; |
127 | struct list_head *tmp; | 127 | struct list_head *tmp, *tmp2; |
128 | struct cifsSesInfo *ses; | 128 | struct cifsSesInfo *ses; |
129 | struct cifsTconInfo *tcon; | 129 | struct cifsTconInfo *tcon; |
130 | struct mid_q_entry *mid_entry; | 130 | struct mid_q_entry *mid_entry; |
@@ -144,23 +144,17 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
144 | 144 | ||
145 | /* before reconnecting the tcp session, mark the smb session (uid) | 145 | /* before reconnecting the tcp session, mark the smb session (uid) |
146 | and the tid bad so they are not used until reconnected */ | 146 | and the tid bad so they are not used until reconnected */ |
147 | read_lock(&GlobalSMBSeslock); | 147 | read_lock(&cifs_tcp_ses_lock); |
148 | list_for_each(tmp, &GlobalSMBSessionList) { | 148 | list_for_each(tmp, &server->smb_ses_list) { |
149 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 149 | ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); |
150 | if (ses->server) { | 150 | ses->need_reconnect = true; |
151 | if (ses->server == server) { | 151 | ses->ipc_tid = 0; |
152 | ses->status = CifsNeedReconnect; | 152 | list_for_each(tmp2, &ses->tcon_list) { |
153 | ses->ipc_tid = 0; | 153 | tcon = list_entry(tmp2, struct cifsTconInfo, tcon_list); |
154 | } | 154 | tcon->need_reconnect = true; |
155 | } | 155 | } |
156 | /* else tcp and smb sessions need reconnection */ | ||
157 | } | ||
158 | list_for_each(tmp, &GlobalTreeConnectionList) { | ||
159 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | ||
160 | if ((tcon->ses) && (tcon->ses->server == server)) | ||
161 | tcon->tidStatus = CifsNeedReconnect; | ||
162 | } | 156 | } |
163 | read_unlock(&GlobalSMBSeslock); | 157 | read_unlock(&cifs_tcp_ses_lock); |
164 | /* do not want to be sending data on a socket we are freeing */ | 158 | /* do not want to be sending data on a socket we are freeing */ |
165 | down(&server->tcpSem); | 159 | down(&server->tcpSem); |
166 | if (server->ssocket) { | 160 | if (server->ssocket) { |
@@ -193,7 +187,7 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
193 | while ((server->tcpStatus != CifsExiting) && | 187 | while ((server->tcpStatus != CifsExiting) && |
194 | (server->tcpStatus != CifsGood)) { | 188 | (server->tcpStatus != CifsGood)) { |
195 | try_to_freeze(); | 189 | try_to_freeze(); |
196 | if (server->protocolType == IPV6) { | 190 | if (server->addr.sockAddr6.sin6_family == AF_INET6) { |
197 | rc = ipv6_connect(&server->addr.sockAddr6, | 191 | rc = ipv6_connect(&server->addr.sockAddr6, |
198 | &server->ssocket, server->noautotune); | 192 | &server->ssocket, server->noautotune); |
199 | } else { | 193 | } else { |
@@ -417,9 +411,14 @@ incomplete_rcv: | |||
417 | msleep(1); /* minimum sleep to prevent looping | 411 | msleep(1); /* minimum sleep to prevent looping |
418 | allowing socket to clear and app threads to set | 412 | allowing socket to clear and app threads to set |
419 | tcpStatus CifsNeedReconnect if server hung */ | 413 | tcpStatus CifsNeedReconnect if server hung */ |
420 | if (pdu_length < 4) | 414 | if (pdu_length < 4) { |
415 | iov.iov_base = (4 - pdu_length) + | ||
416 | (char *)smb_buffer; | ||
417 | iov.iov_len = pdu_length; | ||
418 | smb_msg.msg_control = NULL; | ||
419 | smb_msg.msg_controllen = 0; | ||
421 | goto incomplete_rcv; | 420 | goto incomplete_rcv; |
422 | else | 421 | } else |
423 | continue; | 422 | continue; |
424 | } else if (length <= 0) { | 423 | } else if (length <= 0) { |
425 | if (server->tcpStatus == CifsNew) { | 424 | if (server->tcpStatus == CifsNew) { |
@@ -654,6 +653,11 @@ multi_t2_fnd: | |||
654 | } | 653 | } |
655 | } /* end while !EXITING */ | 654 | } /* end while !EXITING */ |
656 | 655 | ||
656 | /* take it off the list, if it's not already */ | ||
657 | write_lock(&cifs_tcp_ses_lock); | ||
658 | list_del_init(&server->tcp_ses_list); | ||
659 | write_unlock(&cifs_tcp_ses_lock); | ||
660 | |||
657 | spin_lock(&GlobalMid_Lock); | 661 | spin_lock(&GlobalMid_Lock); |
658 | server->tcpStatus = CifsExiting; | 662 | server->tcpStatus = CifsExiting; |
659 | spin_unlock(&GlobalMid_Lock); | 663 | spin_unlock(&GlobalMid_Lock); |
@@ -686,29 +690,29 @@ multi_t2_fnd: | |||
686 | if (smallbuf) /* no sense logging a debug message if NULL */ | 690 | if (smallbuf) /* no sense logging a debug message if NULL */ |
687 | cifs_small_buf_release(smallbuf); | 691 | cifs_small_buf_release(smallbuf); |
688 | 692 | ||
689 | read_lock(&GlobalSMBSeslock); | 693 | /* |
694 | * BB: we shouldn't have to do any of this. It shouldn't be | ||
695 | * possible to exit from the thread with active SMB sessions | ||
696 | */ | ||
697 | read_lock(&cifs_tcp_ses_lock); | ||
690 | if (list_empty(&server->pending_mid_q)) { | 698 | if (list_empty(&server->pending_mid_q)) { |
691 | /* loop through server session structures attached to this and | 699 | /* loop through server session structures attached to this and |
692 | mark them dead */ | 700 | mark them dead */ |
693 | list_for_each(tmp, &GlobalSMBSessionList) { | 701 | list_for_each(tmp, &server->smb_ses_list) { |
694 | ses = | 702 | ses = list_entry(tmp, struct cifsSesInfo, |
695 | list_entry(tmp, struct cifsSesInfo, | 703 | smb_ses_list); |
696 | cifsSessionList); | 704 | ses->status = CifsExiting; |
697 | if (ses->server == server) { | 705 | ses->server = NULL; |
698 | ses->status = CifsExiting; | ||
699 | ses->server = NULL; | ||
700 | } | ||
701 | } | 706 | } |
702 | read_unlock(&GlobalSMBSeslock); | 707 | read_unlock(&cifs_tcp_ses_lock); |
703 | } else { | 708 | } else { |
704 | /* although we can not zero the server struct pointer yet, | 709 | /* although we can not zero the server struct pointer yet, |
705 | since there are active requests which may depnd on them, | 710 | since there are active requests which may depnd on them, |
706 | mark the corresponding SMB sessions as exiting too */ | 711 | mark the corresponding SMB sessions as exiting too */ |
707 | list_for_each(tmp, &GlobalSMBSessionList) { | 712 | list_for_each(tmp, &server->smb_ses_list) { |
708 | ses = list_entry(tmp, struct cifsSesInfo, | 713 | ses = list_entry(tmp, struct cifsSesInfo, |
709 | cifsSessionList); | 714 | smb_ses_list); |
710 | if (ses->server == server) | 715 | ses->status = CifsExiting; |
711 | ses->status = CifsExiting; | ||
712 | } | 716 | } |
713 | 717 | ||
714 | spin_lock(&GlobalMid_Lock); | 718 | spin_lock(&GlobalMid_Lock); |
@@ -723,7 +727,7 @@ multi_t2_fnd: | |||
723 | } | 727 | } |
724 | } | 728 | } |
725 | spin_unlock(&GlobalMid_Lock); | 729 | spin_unlock(&GlobalMid_Lock); |
726 | read_unlock(&GlobalSMBSeslock); | 730 | read_unlock(&cifs_tcp_ses_lock); |
727 | /* 1/8th of sec is more than enough time for them to exit */ | 731 | /* 1/8th of sec is more than enough time for them to exit */ |
728 | msleep(125); | 732 | msleep(125); |
729 | } | 733 | } |
@@ -745,14 +749,13 @@ multi_t2_fnd: | |||
745 | if there are any pointing to this (e.g | 749 | if there are any pointing to this (e.g |
746 | if a crazy root user tried to kill cifsd | 750 | if a crazy root user tried to kill cifsd |
747 | kernel thread explicitly this might happen) */ | 751 | kernel thread explicitly this might happen) */ |
748 | write_lock(&GlobalSMBSeslock); | 752 | /* BB: This shouldn't be necessary, see above */ |
749 | list_for_each(tmp, &GlobalSMBSessionList) { | 753 | read_lock(&cifs_tcp_ses_lock); |
750 | ses = list_entry(tmp, struct cifsSesInfo, | 754 | list_for_each(tmp, &server->smb_ses_list) { |
751 | cifsSessionList); | 755 | ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); |
752 | if (ses->server == server) | 756 | ses->server = NULL; |
753 | ses->server = NULL; | ||
754 | } | 757 | } |
755 | write_unlock(&GlobalSMBSeslock); | 758 | read_unlock(&cifs_tcp_ses_lock); |
756 | 759 | ||
757 | kfree(server->hostname); | 760 | kfree(server->hostname); |
758 | task_to_wake = xchg(&server->tsk, NULL); | 761 | task_to_wake = xchg(&server->tsk, NULL); |
@@ -1352,94 +1355,158 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
1352 | return 0; | 1355 | return 0; |
1353 | } | 1356 | } |
1354 | 1357 | ||
1355 | static struct cifsSesInfo * | 1358 | static struct TCP_Server_Info * |
1356 | cifs_find_tcp_session(struct in_addr *target_ip_addr, | 1359 | cifs_find_tcp_session(struct sockaddr *addr) |
1357 | struct in6_addr *target_ip6_addr, | ||
1358 | char *userName, struct TCP_Server_Info **psrvTcp) | ||
1359 | { | 1360 | { |
1360 | struct list_head *tmp; | 1361 | struct list_head *tmp; |
1361 | struct cifsSesInfo *ses; | 1362 | struct TCP_Server_Info *server; |
1362 | 1363 | struct sockaddr_in *addr4 = (struct sockaddr_in *) addr; | |
1363 | *psrvTcp = NULL; | 1364 | struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr; |
1365 | |||
1366 | write_lock(&cifs_tcp_ses_lock); | ||
1367 | list_for_each(tmp, &cifs_tcp_ses_list) { | ||
1368 | server = list_entry(tmp, struct TCP_Server_Info, | ||
1369 | tcp_ses_list); | ||
1370 | /* | ||
1371 | * the demux thread can exit on its own while still in CifsNew | ||
1372 | * so don't accept any sockets in that state. Since the | ||
1373 | * tcpStatus never changes back to CifsNew it's safe to check | ||
1374 | * for this without a lock. | ||
1375 | */ | ||
1376 | if (server->tcpStatus == CifsNew) | ||
1377 | continue; | ||
1364 | 1378 | ||
1365 | read_lock(&GlobalSMBSeslock); | 1379 | if (addr->sa_family == AF_INET && |
1366 | list_for_each(tmp, &GlobalSMBSessionList) { | 1380 | (addr4->sin_addr.s_addr != |
1367 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 1381 | server->addr.sockAddr.sin_addr.s_addr)) |
1368 | if (!ses->server) | 1382 | continue; |
1383 | else if (addr->sa_family == AF_INET6 && | ||
1384 | memcmp(&server->addr.sockAddr6.sin6_addr, | ||
1385 | &addr6->sin6_addr, sizeof(addr6->sin6_addr))) | ||
1369 | continue; | 1386 | continue; |
1370 | 1387 | ||
1371 | if (target_ip_addr && | 1388 | ++server->srv_count; |
1372 | ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr) | 1389 | write_unlock(&cifs_tcp_ses_lock); |
1373 | continue; | 1390 | cFYI(1, ("Existing tcp session with server found")); |
1374 | else if (target_ip6_addr && | 1391 | return server; |
1375 | memcmp(&ses->server->addr.sockAddr6.sin6_addr, | 1392 | } |
1376 | target_ip6_addr, sizeof(*target_ip6_addr))) | 1393 | write_unlock(&cifs_tcp_ses_lock); |
1377 | continue; | 1394 | return NULL; |
1378 | /* BB lock server and tcp session; increment use count here?? */ | 1395 | } |
1379 | 1396 | ||
1380 | /* found a match on the TCP session */ | 1397 | static void |
1381 | *psrvTcp = ses->server; | 1398 | cifs_put_tcp_session(struct TCP_Server_Info *server) |
1399 | { | ||
1400 | struct task_struct *task; | ||
1382 | 1401 | ||
1383 | /* BB check if reconnection needed */ | 1402 | write_lock(&cifs_tcp_ses_lock); |
1384 | if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) { | 1403 | if (--server->srv_count > 0) { |
1385 | read_unlock(&GlobalSMBSeslock); | 1404 | write_unlock(&cifs_tcp_ses_lock); |
1386 | /* Found exact match on both TCP and | 1405 | return; |
1387 | SMB sessions */ | ||
1388 | return ses; | ||
1389 | } | ||
1390 | /* else tcp and smb sessions need reconnection */ | ||
1391 | } | 1406 | } |
1392 | read_unlock(&GlobalSMBSeslock); | ||
1393 | 1407 | ||
1394 | return NULL; | 1408 | list_del_init(&server->tcp_ses_list); |
1409 | write_unlock(&cifs_tcp_ses_lock); | ||
1410 | |||
1411 | spin_lock(&GlobalMid_Lock); | ||
1412 | server->tcpStatus = CifsExiting; | ||
1413 | spin_unlock(&GlobalMid_Lock); | ||
1414 | |||
1415 | task = xchg(&server->tsk, NULL); | ||
1416 | if (task) | ||
1417 | force_sig(SIGKILL, task); | ||
1395 | } | 1418 | } |
1396 | 1419 | ||
1397 | static struct cifsTconInfo * | 1420 | static struct cifsSesInfo * |
1398 | find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) | 1421 | cifs_find_smb_ses(struct TCP_Server_Info *server, char *username) |
1399 | { | 1422 | { |
1400 | struct list_head *tmp; | 1423 | struct list_head *tmp; |
1401 | struct cifsTconInfo *tcon; | 1424 | struct cifsSesInfo *ses; |
1402 | __be32 old_ip; | ||
1403 | |||
1404 | read_lock(&GlobalSMBSeslock); | ||
1405 | 1425 | ||
1406 | list_for_each(tmp, &GlobalTreeConnectionList) { | 1426 | write_lock(&cifs_tcp_ses_lock); |
1407 | cFYI(1, ("Next tcon")); | 1427 | list_for_each(tmp, &server->smb_ses_list) { |
1408 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 1428 | ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); |
1409 | if (!tcon->ses || !tcon->ses->server) | 1429 | if (strncmp(ses->userName, username, MAX_USERNAME_SIZE)) |
1410 | continue; | 1430 | continue; |
1411 | 1431 | ||
1412 | old_ip = tcon->ses->server->addr.sockAddr.sin_addr.s_addr; | 1432 | ++ses->ses_count; |
1413 | cFYI(1, ("old ip addr: %x == new ip %x ?", | 1433 | write_unlock(&cifs_tcp_ses_lock); |
1414 | old_ip, new_target_ip_addr)); | 1434 | return ses; |
1435 | } | ||
1436 | write_unlock(&cifs_tcp_ses_lock); | ||
1437 | return NULL; | ||
1438 | } | ||
1415 | 1439 | ||
1416 | if (old_ip != new_target_ip_addr) | 1440 | static void |
1417 | continue; | 1441 | cifs_put_smb_ses(struct cifsSesInfo *ses) |
1442 | { | ||
1443 | int xid; | ||
1444 | struct TCP_Server_Info *server = ses->server; | ||
1418 | 1445 | ||
1419 | /* BB lock tcon, server, tcp session and increment use count? */ | 1446 | write_lock(&cifs_tcp_ses_lock); |
1420 | /* found a match on the TCP session */ | 1447 | if (--ses->ses_count > 0) { |
1421 | /* BB check if reconnection needed */ | 1448 | write_unlock(&cifs_tcp_ses_lock); |
1422 | cFYI(1, ("IP match, old UNC: %s new: %s", | 1449 | return; |
1423 | tcon->treeName, uncName)); | 1450 | } |
1424 | 1451 | ||
1425 | if (strncmp(tcon->treeName, uncName, MAX_TREE_SIZE)) | 1452 | list_del_init(&ses->smb_ses_list); |
1426 | continue; | 1453 | write_unlock(&cifs_tcp_ses_lock); |
1427 | 1454 | ||
1428 | cFYI(1, ("and old usr: %s new: %s", | 1455 | if (ses->status == CifsGood) { |
1429 | tcon->treeName, uncName)); | 1456 | xid = GetXid(); |
1457 | CIFSSMBLogoff(xid, ses); | ||
1458 | _FreeXid(xid); | ||
1459 | } | ||
1460 | sesInfoFree(ses); | ||
1461 | cifs_put_tcp_session(server); | ||
1462 | } | ||
1430 | 1463 | ||
1431 | if (strncmp(tcon->ses->userName, userName, MAX_USERNAME_SIZE)) | 1464 | static struct cifsTconInfo * |
1465 | cifs_find_tcon(struct cifsSesInfo *ses, const char *unc) | ||
1466 | { | ||
1467 | struct list_head *tmp; | ||
1468 | struct cifsTconInfo *tcon; | ||
1469 | |||
1470 | write_lock(&cifs_tcp_ses_lock); | ||
1471 | list_for_each(tmp, &ses->tcon_list) { | ||
1472 | tcon = list_entry(tmp, struct cifsTconInfo, tcon_list); | ||
1473 | if (tcon->tidStatus == CifsExiting) | ||
1474 | continue; | ||
1475 | if (strncmp(tcon->treeName, unc, MAX_TREE_SIZE)) | ||
1432 | continue; | 1476 | continue; |
1433 | 1477 | ||
1434 | /* matched smb session (user name) */ | 1478 | ++tcon->tc_count; |
1435 | read_unlock(&GlobalSMBSeslock); | 1479 | write_unlock(&cifs_tcp_ses_lock); |
1436 | return tcon; | 1480 | return tcon; |
1437 | } | 1481 | } |
1438 | 1482 | write_unlock(&cifs_tcp_ses_lock); | |
1439 | read_unlock(&GlobalSMBSeslock); | ||
1440 | return NULL; | 1483 | return NULL; |
1441 | } | 1484 | } |
1442 | 1485 | ||
1486 | static void | ||
1487 | cifs_put_tcon(struct cifsTconInfo *tcon) | ||
1488 | { | ||
1489 | int xid; | ||
1490 | struct cifsSesInfo *ses = tcon->ses; | ||
1491 | |||
1492 | write_lock(&cifs_tcp_ses_lock); | ||
1493 | if (--tcon->tc_count > 0) { | ||
1494 | write_unlock(&cifs_tcp_ses_lock); | ||
1495 | return; | ||
1496 | } | ||
1497 | |||
1498 | list_del_init(&tcon->tcon_list); | ||
1499 | write_unlock(&cifs_tcp_ses_lock); | ||
1500 | |||
1501 | xid = GetXid(); | ||
1502 | CIFSSMBTDis(xid, tcon); | ||
1503 | _FreeXid(xid); | ||
1504 | |||
1505 | DeleteTconOplockQEntries(tcon); | ||
1506 | tconInfoFree(tcon); | ||
1507 | cifs_put_smb_ses(ses); | ||
1508 | } | ||
1509 | |||
1443 | int | 1510 | int |
1444 | get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, | 1511 | get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, |
1445 | const struct nls_table *nls_codepage, unsigned int *pnum_referrals, | 1512 | const struct nls_table *nls_codepage, unsigned int *pnum_referrals, |
@@ -1876,14 +1943,90 @@ convert_delimiter(char *path, char delim) | |||
1876 | } | 1943 | } |
1877 | } | 1944 | } |
1878 | 1945 | ||
1879 | static void | 1946 | static void setup_cifs_sb(struct smb_vol *pvolume_info, |
1880 | kill_cifsd(struct TCP_Server_Info *server) | 1947 | struct cifs_sb_info *cifs_sb) |
1881 | { | 1948 | { |
1882 | struct task_struct *task; | 1949 | if (pvolume_info->rsize > CIFSMaxBufSize) { |
1883 | 1950 | cERROR(1, ("rsize %d too large, using MaxBufSize", | |
1884 | task = xchg(&server->tsk, NULL); | 1951 | pvolume_info->rsize)); |
1885 | if (task) | 1952 | cifs_sb->rsize = CIFSMaxBufSize; |
1886 | force_sig(SIGKILL, task); | 1953 | } else if ((pvolume_info->rsize) && |
1954 | (pvolume_info->rsize <= CIFSMaxBufSize)) | ||
1955 | cifs_sb->rsize = pvolume_info->rsize; | ||
1956 | else /* default */ | ||
1957 | cifs_sb->rsize = CIFSMaxBufSize; | ||
1958 | |||
1959 | if (pvolume_info->wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { | ||
1960 | cERROR(1, ("wsize %d too large, using 4096 instead", | ||
1961 | pvolume_info->wsize)); | ||
1962 | cifs_sb->wsize = 4096; | ||
1963 | } else if (pvolume_info->wsize) | ||
1964 | cifs_sb->wsize = pvolume_info->wsize; | ||
1965 | else | ||
1966 | cifs_sb->wsize = min_t(const int, | ||
1967 | PAGEVEC_SIZE * PAGE_CACHE_SIZE, | ||
1968 | 127*1024); | ||
1969 | /* old default of CIFSMaxBufSize was too small now | ||
1970 | that SMB Write2 can send multiple pages in kvec. | ||
1971 | RFC1001 does not describe what happens when frame | ||
1972 | bigger than 128K is sent so use that as max in | ||
1973 | conjunction with 52K kvec constraint on arch with 4K | ||
1974 | page size */ | ||
1975 | |||
1976 | if (cifs_sb->rsize < 2048) { | ||
1977 | cifs_sb->rsize = 2048; | ||
1978 | /* Windows ME may prefer this */ | ||
1979 | cFYI(1, ("readsize set to minimum: 2048")); | ||
1980 | } | ||
1981 | /* calculate prepath */ | ||
1982 | cifs_sb->prepath = pvolume_info->prepath; | ||
1983 | if (cifs_sb->prepath) { | ||
1984 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); | ||
1985 | /* we can not convert the / to \ in the path | ||
1986 | separators in the prefixpath yet because we do not | ||
1987 | know (until reset_cifs_unix_caps is called later) | ||
1988 | whether POSIX PATH CAP is available. We normalize | ||
1989 | the / to \ after reset_cifs_unix_caps is called */ | ||
1990 | pvolume_info->prepath = NULL; | ||
1991 | } else | ||
1992 | cifs_sb->prepathlen = 0; | ||
1993 | cifs_sb->mnt_uid = pvolume_info->linux_uid; | ||
1994 | cifs_sb->mnt_gid = pvolume_info->linux_gid; | ||
1995 | cifs_sb->mnt_file_mode = pvolume_info->file_mode; | ||
1996 | cifs_sb->mnt_dir_mode = pvolume_info->dir_mode; | ||
1997 | cFYI(1, ("file mode: 0x%x dir mode: 0x%x", | ||
1998 | cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode)); | ||
1999 | |||
2000 | if (pvolume_info->noperm) | ||
2001 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; | ||
2002 | if (pvolume_info->setuids) | ||
2003 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID; | ||
2004 | if (pvolume_info->server_ino) | ||
2005 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM; | ||
2006 | if (pvolume_info->remap) | ||
2007 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR; | ||
2008 | if (pvolume_info->no_xattr) | ||
2009 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR; | ||
2010 | if (pvolume_info->sfu_emul) | ||
2011 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL; | ||
2012 | if (pvolume_info->nobrl) | ||
2013 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; | ||
2014 | if (pvolume_info->cifs_acl) | ||
2015 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; | ||
2016 | if (pvolume_info->override_uid) | ||
2017 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID; | ||
2018 | if (pvolume_info->override_gid) | ||
2019 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID; | ||
2020 | if (pvolume_info->dynperm) | ||
2021 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM; | ||
2022 | if (pvolume_info->direct_io) { | ||
2023 | cFYI(1, ("mounting share using direct i/o")); | ||
2024 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; | ||
2025 | } | ||
2026 | |||
2027 | if ((pvolume_info->cifs_acl) && (pvolume_info->dynperm)) | ||
2028 | cERROR(1, ("mount option dynperm ignored if cifsacl " | ||
2029 | "mount option supported")); | ||
1887 | } | 2030 | } |
1888 | 2031 | ||
1889 | int | 2032 | int |
@@ -1892,13 +2035,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1892 | { | 2035 | { |
1893 | int rc = 0; | 2036 | int rc = 0; |
1894 | int xid; | 2037 | int xid; |
1895 | int address_type = AF_INET; | ||
1896 | struct socket *csocket = NULL; | 2038 | struct socket *csocket = NULL; |
1897 | struct sockaddr_in sin_server; | 2039 | struct sockaddr addr; |
1898 | struct sockaddr_in6 sin_server6; | 2040 | struct sockaddr_in *sin_server = (struct sockaddr_in *) &addr; |
2041 | struct sockaddr_in6 *sin_server6 = (struct sockaddr_in6 *) &addr; | ||
1899 | struct smb_vol volume_info; | 2042 | struct smb_vol volume_info; |
1900 | struct cifsSesInfo *pSesInfo = NULL; | 2043 | struct cifsSesInfo *pSesInfo = NULL; |
1901 | struct cifsSesInfo *existingCifsSes = NULL; | ||
1902 | struct cifsTconInfo *tcon = NULL; | 2044 | struct cifsTconInfo *tcon = NULL; |
1903 | struct TCP_Server_Info *srvTcp = NULL; | 2045 | struct TCP_Server_Info *srvTcp = NULL; |
1904 | 2046 | ||
@@ -1906,6 +2048,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1906 | 2048 | ||
1907 | /* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */ | 2049 | /* cFYI(1, ("Entering cifs_mount. Xid: %d with: %s", xid, mount_data)); */ |
1908 | 2050 | ||
2051 | memset(&addr, 0, sizeof(struct sockaddr)); | ||
1909 | memset(&volume_info, 0, sizeof(struct smb_vol)); | 2052 | memset(&volume_info, 0, sizeof(struct smb_vol)); |
1910 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { | 2053 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { |
1911 | rc = -EINVAL; | 2054 | rc = -EINVAL; |
@@ -1928,16 +2071,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1928 | 2071 | ||
1929 | if (volume_info.UNCip && volume_info.UNC) { | 2072 | if (volume_info.UNCip && volume_info.UNC) { |
1930 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip, | 2073 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip, |
1931 | &sin_server.sin_addr.s_addr); | 2074 | &sin_server->sin_addr.s_addr); |
1932 | 2075 | ||
1933 | if (rc <= 0) { | 2076 | if (rc <= 0) { |
1934 | /* not ipv4 address, try ipv6 */ | 2077 | /* not ipv4 address, try ipv6 */ |
1935 | rc = cifs_inet_pton(AF_INET6, volume_info.UNCip, | 2078 | rc = cifs_inet_pton(AF_INET6, volume_info.UNCip, |
1936 | &sin_server6.sin6_addr.in6_u); | 2079 | &sin_server6->sin6_addr.in6_u); |
1937 | if (rc > 0) | 2080 | if (rc > 0) |
1938 | address_type = AF_INET6; | 2081 | addr.sa_family = AF_INET6; |
1939 | } else { | 2082 | } else { |
1940 | address_type = AF_INET; | 2083 | addr.sa_family = AF_INET; |
1941 | } | 2084 | } |
1942 | 2085 | ||
1943 | if (rc <= 0) { | 2086 | if (rc <= 0) { |
@@ -1977,41 +2120,25 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1977 | } | 2120 | } |
1978 | } | 2121 | } |
1979 | 2122 | ||
1980 | if (address_type == AF_INET) | 2123 | srvTcp = cifs_find_tcp_session(&addr); |
1981 | existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, | 2124 | if (!srvTcp) { /* create socket */ |
1982 | NULL /* no ipv6 addr */, | 2125 | if (addr.sa_family == AF_INET6) { |
1983 | volume_info.username, &srvTcp); | ||
1984 | else if (address_type == AF_INET6) { | ||
1985 | cFYI(1, ("looking for ipv6 address")); | ||
1986 | existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, | ||
1987 | &sin_server6.sin6_addr, | ||
1988 | volume_info.username, &srvTcp); | ||
1989 | } else { | ||
1990 | rc = -EINVAL; | ||
1991 | goto out; | ||
1992 | } | ||
1993 | |||
1994 | if (srvTcp) { | ||
1995 | cFYI(1, ("Existing tcp session with server found")); | ||
1996 | } else { /* create socket */ | ||
1997 | if (volume_info.port) | ||
1998 | sin_server.sin_port = htons(volume_info.port); | ||
1999 | else | ||
2000 | sin_server.sin_port = 0; | ||
2001 | if (address_type == AF_INET6) { | ||
2002 | cFYI(1, ("attempting ipv6 connect")); | 2126 | cFYI(1, ("attempting ipv6 connect")); |
2003 | /* BB should we allow ipv6 on port 139? */ | 2127 | /* BB should we allow ipv6 on port 139? */ |
2004 | /* other OS never observed in Wild doing 139 with v6 */ | 2128 | /* other OS never observed in Wild doing 139 with v6 */ |
2005 | rc = ipv6_connect(&sin_server6, &csocket, | 2129 | sin_server6->sin6_port = htons(volume_info.port); |
2130 | rc = ipv6_connect(sin_server6, &csocket, | ||
2006 | volume_info.noblocksnd); | 2131 | volume_info.noblocksnd); |
2007 | } else | 2132 | } else { |
2008 | rc = ipv4_connect(&sin_server, &csocket, | 2133 | sin_server->sin_port = htons(volume_info.port); |
2134 | rc = ipv4_connect(sin_server, &csocket, | ||
2009 | volume_info.source_rfc1001_name, | 2135 | volume_info.source_rfc1001_name, |
2010 | volume_info.target_rfc1001_name, | 2136 | volume_info.target_rfc1001_name, |
2011 | volume_info.noblocksnd, | 2137 | volume_info.noblocksnd, |
2012 | volume_info.noautotune); | 2138 | volume_info.noautotune); |
2139 | } | ||
2013 | if (rc < 0) { | 2140 | if (rc < 0) { |
2014 | cERROR(1, ("Error connecting to IPv4 socket. " | 2141 | cERROR(1, ("Error connecting to socket. " |
2015 | "Aborting operation")); | 2142 | "Aborting operation")); |
2016 | if (csocket != NULL) | 2143 | if (csocket != NULL) |
2017 | sock_release(csocket); | 2144 | sock_release(csocket); |
@@ -2026,12 +2153,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2026 | } else { | 2153 | } else { |
2027 | srvTcp->noblocksnd = volume_info.noblocksnd; | 2154 | srvTcp->noblocksnd = volume_info.noblocksnd; |
2028 | srvTcp->noautotune = volume_info.noautotune; | 2155 | srvTcp->noautotune = volume_info.noautotune; |
2029 | memcpy(&srvTcp->addr.sockAddr, &sin_server, | 2156 | if (addr.sa_family == AF_INET6) |
2030 | sizeof(struct sockaddr_in)); | 2157 | memcpy(&srvTcp->addr.sockAddr6, sin_server6, |
2158 | sizeof(struct sockaddr_in6)); | ||
2159 | else | ||
2160 | memcpy(&srvTcp->addr.sockAddr, sin_server, | ||
2161 | sizeof(struct sockaddr_in)); | ||
2031 | atomic_set(&srvTcp->inFlight, 0); | 2162 | atomic_set(&srvTcp->inFlight, 0); |
2032 | /* BB Add code for ipv6 case too */ | 2163 | /* BB Add code for ipv6 case too */ |
2033 | srvTcp->ssocket = csocket; | 2164 | srvTcp->ssocket = csocket; |
2034 | srvTcp->protocolType = IPV4; | ||
2035 | srvTcp->hostname = extract_hostname(volume_info.UNC); | 2165 | srvTcp->hostname = extract_hostname(volume_info.UNC); |
2036 | if (IS_ERR(srvTcp->hostname)) { | 2166 | if (IS_ERR(srvTcp->hostname)) { |
2037 | rc = PTR_ERR(srvTcp->hostname); | 2167 | rc = PTR_ERR(srvTcp->hostname); |
@@ -2061,15 +2191,28 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2061 | memcpy(srvTcp->server_RFC1001_name, | 2191 | memcpy(srvTcp->server_RFC1001_name, |
2062 | volume_info.target_rfc1001_name, 16); | 2192 | volume_info.target_rfc1001_name, 16); |
2063 | srvTcp->sequence_number = 0; | 2193 | srvTcp->sequence_number = 0; |
2194 | INIT_LIST_HEAD(&srvTcp->tcp_ses_list); | ||
2195 | INIT_LIST_HEAD(&srvTcp->smb_ses_list); | ||
2196 | ++srvTcp->srv_count; | ||
2197 | write_lock(&cifs_tcp_ses_lock); | ||
2198 | list_add(&srvTcp->tcp_ses_list, | ||
2199 | &cifs_tcp_ses_list); | ||
2200 | write_unlock(&cifs_tcp_ses_lock); | ||
2064 | } | 2201 | } |
2065 | } | 2202 | } |
2066 | 2203 | ||
2067 | if (existingCifsSes) { | 2204 | pSesInfo = cifs_find_smb_ses(srvTcp, volume_info.username); |
2068 | pSesInfo = existingCifsSes; | 2205 | if (pSesInfo) { |
2069 | cFYI(1, ("Existing smb sess found (status=%d)", | 2206 | cFYI(1, ("Existing smb sess found (status=%d)", |
2070 | pSesInfo->status)); | 2207 | pSesInfo->status)); |
2208 | /* | ||
2209 | * The existing SMB session already has a reference to srvTcp, | ||
2210 | * so we can put back the extra one we got before | ||
2211 | */ | ||
2212 | cifs_put_tcp_session(srvTcp); | ||
2213 | |||
2071 | down(&pSesInfo->sesSem); | 2214 | down(&pSesInfo->sesSem); |
2072 | if (pSesInfo->status == CifsNeedReconnect) { | 2215 | if (pSesInfo->need_reconnect) { |
2073 | cFYI(1, ("Session needs reconnect")); | 2216 | cFYI(1, ("Session needs reconnect")); |
2074 | rc = cifs_setup_session(xid, pSesInfo, | 2217 | rc = cifs_setup_session(xid, pSesInfo, |
2075 | cifs_sb->local_nls); | 2218 | cifs_sb->local_nls); |
@@ -2078,187 +2221,101 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2078 | } else if (!rc) { | 2221 | } else if (!rc) { |
2079 | cFYI(1, ("Existing smb sess not found")); | 2222 | cFYI(1, ("Existing smb sess not found")); |
2080 | pSesInfo = sesInfoAlloc(); | 2223 | pSesInfo = sesInfoAlloc(); |
2081 | if (pSesInfo == NULL) | 2224 | if (pSesInfo == NULL) { |
2082 | rc = -ENOMEM; | 2225 | rc = -ENOMEM; |
2083 | else { | 2226 | goto mount_fail_check; |
2084 | pSesInfo->server = srvTcp; | 2227 | } |
2085 | sprintf(pSesInfo->serverName, "%u.%u.%u.%u", | 2228 | |
2086 | NIPQUAD(sin_server.sin_addr.s_addr)); | 2229 | /* new SMB session uses our srvTcp ref */ |
2087 | } | 2230 | pSesInfo->server = srvTcp; |
2231 | sprintf(pSesInfo->serverName, "%u.%u.%u.%u", | ||
2232 | NIPQUAD(sin_server->sin_addr.s_addr)); | ||
2233 | |||
2234 | write_lock(&cifs_tcp_ses_lock); | ||
2235 | list_add(&pSesInfo->smb_ses_list, &srvTcp->smb_ses_list); | ||
2236 | write_unlock(&cifs_tcp_ses_lock); | ||
2237 | |||
2238 | /* volume_info.password freed at unmount */ | ||
2239 | if (volume_info.password) { | ||
2240 | pSesInfo->password = volume_info.password; | ||
2241 | /* set to NULL to prevent freeing on exit */ | ||
2242 | volume_info.password = NULL; | ||
2243 | } | ||
2244 | if (volume_info.username) | ||
2245 | strncpy(pSesInfo->userName, volume_info.username, | ||
2246 | MAX_USERNAME_SIZE); | ||
2247 | if (volume_info.domainname) { | ||
2248 | int len = strlen(volume_info.domainname); | ||
2249 | pSesInfo->domainName = kmalloc(len + 1, GFP_KERNEL); | ||
2250 | if (pSesInfo->domainName) | ||
2251 | strcpy(pSesInfo->domainName, | ||
2252 | volume_info.domainname); | ||
2253 | } | ||
2254 | pSesInfo->linux_uid = volume_info.linux_uid; | ||
2255 | pSesInfo->overrideSecFlg = volume_info.secFlg; | ||
2256 | down(&pSesInfo->sesSem); | ||
2088 | 2257 | ||
2089 | if (!rc) { | 2258 | /* BB FIXME need to pass vol->secFlgs BB */ |
2090 | /* volume_info.password freed at unmount */ | 2259 | rc = cifs_setup_session(xid, pSesInfo, |
2091 | if (volume_info.password) { | 2260 | cifs_sb->local_nls); |
2092 | pSesInfo->password = volume_info.password; | 2261 | up(&pSesInfo->sesSem); |
2093 | /* set to NULL to prevent freeing on exit */ | ||
2094 | volume_info.password = NULL; | ||
2095 | } | ||
2096 | if (volume_info.username) | ||
2097 | strncpy(pSesInfo->userName, | ||
2098 | volume_info.username, | ||
2099 | MAX_USERNAME_SIZE); | ||
2100 | if (volume_info.domainname) { | ||
2101 | int len = strlen(volume_info.domainname); | ||
2102 | pSesInfo->domainName = | ||
2103 | kmalloc(len + 1, GFP_KERNEL); | ||
2104 | if (pSesInfo->domainName) | ||
2105 | strcpy(pSesInfo->domainName, | ||
2106 | volume_info.domainname); | ||
2107 | } | ||
2108 | pSesInfo->linux_uid = volume_info.linux_uid; | ||
2109 | pSesInfo->overrideSecFlg = volume_info.secFlg; | ||
2110 | down(&pSesInfo->sesSem); | ||
2111 | /* BB FIXME need to pass vol->secFlgs BB */ | ||
2112 | rc = cifs_setup_session(xid, pSesInfo, | ||
2113 | cifs_sb->local_nls); | ||
2114 | up(&pSesInfo->sesSem); | ||
2115 | if (!rc) | ||
2116 | atomic_inc(&srvTcp->socketUseCount); | ||
2117 | } | ||
2118 | } | 2262 | } |
2119 | 2263 | ||
2120 | /* search for existing tcon to this server share */ | 2264 | /* search for existing tcon to this server share */ |
2121 | if (!rc) { | 2265 | if (!rc) { |
2122 | if (volume_info.rsize > CIFSMaxBufSize) { | 2266 | setup_cifs_sb(&volume_info, cifs_sb); |
2123 | cERROR(1, ("rsize %d too large, using MaxBufSize", | ||
2124 | volume_info.rsize)); | ||
2125 | cifs_sb->rsize = CIFSMaxBufSize; | ||
2126 | } else if ((volume_info.rsize) && | ||
2127 | (volume_info.rsize <= CIFSMaxBufSize)) | ||
2128 | cifs_sb->rsize = volume_info.rsize; | ||
2129 | else /* default */ | ||
2130 | cifs_sb->rsize = CIFSMaxBufSize; | ||
2131 | |||
2132 | if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { | ||
2133 | cERROR(1, ("wsize %d too large, using 4096 instead", | ||
2134 | volume_info.wsize)); | ||
2135 | cifs_sb->wsize = 4096; | ||
2136 | } else if (volume_info.wsize) | ||
2137 | cifs_sb->wsize = volume_info.wsize; | ||
2138 | else | ||
2139 | cifs_sb->wsize = | ||
2140 | min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE, | ||
2141 | 127*1024); | ||
2142 | /* old default of CIFSMaxBufSize was too small now | ||
2143 | that SMB Write2 can send multiple pages in kvec. | ||
2144 | RFC1001 does not describe what happens when frame | ||
2145 | bigger than 128K is sent so use that as max in | ||
2146 | conjunction with 52K kvec constraint on arch with 4K | ||
2147 | page size */ | ||
2148 | |||
2149 | if (cifs_sb->rsize < 2048) { | ||
2150 | cifs_sb->rsize = 2048; | ||
2151 | /* Windows ME may prefer this */ | ||
2152 | cFYI(1, ("readsize set to minimum: 2048")); | ||
2153 | } | ||
2154 | /* calculate prepath */ | ||
2155 | cifs_sb->prepath = volume_info.prepath; | ||
2156 | if (cifs_sb->prepath) { | ||
2157 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); | ||
2158 | /* we can not convert the / to \ in the path | ||
2159 | separators in the prefixpath yet because we do not | ||
2160 | know (until reset_cifs_unix_caps is called later) | ||
2161 | whether POSIX PATH CAP is available. We normalize | ||
2162 | the / to \ after reset_cifs_unix_caps is called */ | ||
2163 | volume_info.prepath = NULL; | ||
2164 | } else | ||
2165 | cifs_sb->prepathlen = 0; | ||
2166 | cifs_sb->mnt_uid = volume_info.linux_uid; | ||
2167 | cifs_sb->mnt_gid = volume_info.linux_gid; | ||
2168 | cifs_sb->mnt_file_mode = volume_info.file_mode; | ||
2169 | cifs_sb->mnt_dir_mode = volume_info.dir_mode; | ||
2170 | cFYI(1, ("file mode: 0x%x dir mode: 0x%x", | ||
2171 | cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode)); | ||
2172 | |||
2173 | if (volume_info.noperm) | ||
2174 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; | ||
2175 | if (volume_info.setuids) | ||
2176 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID; | ||
2177 | if (volume_info.server_ino) | ||
2178 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM; | ||
2179 | if (volume_info.remap) | ||
2180 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR; | ||
2181 | if (volume_info.no_xattr) | ||
2182 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR; | ||
2183 | if (volume_info.sfu_emul) | ||
2184 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL; | ||
2185 | if (volume_info.nobrl) | ||
2186 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; | ||
2187 | if (volume_info.cifs_acl) | ||
2188 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; | ||
2189 | if (volume_info.override_uid) | ||
2190 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID; | ||
2191 | if (volume_info.override_gid) | ||
2192 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID; | ||
2193 | if (volume_info.dynperm) | ||
2194 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM; | ||
2195 | if (volume_info.direct_io) { | ||
2196 | cFYI(1, ("mounting share using direct i/o")); | ||
2197 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; | ||
2198 | } | ||
2199 | 2267 | ||
2200 | if ((volume_info.cifs_acl) && (volume_info.dynperm)) | 2268 | tcon = cifs_find_tcon(pSesInfo, volume_info.UNC); |
2201 | cERROR(1, ("mount option dynperm ignored if cifsacl " | ||
2202 | "mount option supported")); | ||
2203 | |||
2204 | tcon = | ||
2205 | find_unc(sin_server.sin_addr.s_addr, volume_info.UNC, | ||
2206 | volume_info.username); | ||
2207 | if (tcon) { | 2269 | if (tcon) { |
2208 | cFYI(1, ("Found match on UNC path")); | 2270 | cFYI(1, ("Found match on UNC path")); |
2209 | /* we can have only one retry value for a connection | 2271 | /* existing tcon already has a reference */ |
2210 | to a share so for resources mounted more than once | 2272 | cifs_put_smb_ses(pSesInfo); |
2211 | to the same server share the last value passed in | ||
2212 | for the retry flag is used */ | ||
2213 | tcon->retry = volume_info.retry; | ||
2214 | tcon->nocase = volume_info.nocase; | ||
2215 | tcon->local_lease = volume_info.local_lease; | ||
2216 | if (tcon->seal != volume_info.seal) | 2273 | if (tcon->seal != volume_info.seal) |
2217 | cERROR(1, ("transport encryption setting " | 2274 | cERROR(1, ("transport encryption setting " |
2218 | "conflicts with existing tid")); | 2275 | "conflicts with existing tid")); |
2219 | } else { | 2276 | } else { |
2220 | tcon = tconInfoAlloc(); | 2277 | tcon = tconInfoAlloc(); |
2221 | if (tcon == NULL) | 2278 | if (tcon == NULL) { |
2222 | rc = -ENOMEM; | 2279 | rc = -ENOMEM; |
2223 | else { | 2280 | goto mount_fail_check; |
2224 | /* check for null share name ie connecting to | 2281 | } |
2225 | * dfs root */ | 2282 | tcon->ses = pSesInfo; |
2226 | 2283 | ||
2227 | /* BB check if this works for exactly length | 2284 | /* check for null share name ie connect to dfs root */ |
2228 | * three strings */ | 2285 | if ((strchr(volume_info.UNC + 3, '\\') == NULL) |
2229 | if ((strchr(volume_info.UNC + 3, '\\') == NULL) | 2286 | && (strchr(volume_info.UNC + 3, '/') == NULL)) { |
2230 | && (strchr(volume_info.UNC + 3, '/') == | 2287 | /* rc = connect_to_dfs_path(...) */ |
2231 | NULL)) { | 2288 | cFYI(1, ("DFS root not supported")); |
2232 | /* rc = connect_to_dfs_path(xid, pSesInfo, | 2289 | rc = -ENODEV; |
2233 | "", cifs_sb->local_nls, | 2290 | goto mount_fail_check; |
2234 | cifs_sb->mnt_cifs_flags & | 2291 | } else { |
2235 | CIFS_MOUNT_MAP_SPECIAL_CHR);*/ | 2292 | /* BB Do we need to wrap sesSem around |
2236 | cFYI(1, ("DFS root not supported")); | 2293 | * this TCon call and Unix SetFS as |
2237 | rc = -ENODEV; | 2294 | * we do on SessSetup and reconnect? */ |
2238 | goto out; | 2295 | rc = CIFSTCon(xid, pSesInfo, volume_info.UNC, |
2239 | } else { | 2296 | tcon, cifs_sb->local_nls); |
2240 | /* BB Do we need to wrap sesSem around | 2297 | cFYI(1, ("CIFS Tcon rc = %d", rc)); |
2241 | * this TCon call and Unix SetFS as | 2298 | if (volume_info.nodfs) { |
2242 | * we do on SessSetup and reconnect? */ | 2299 | tcon->Flags &= ~SMB_SHARE_IS_IN_DFS; |
2243 | rc = CIFSTCon(xid, pSesInfo, | 2300 | cFYI(1, ("DFS disabled (%d)", |
2244 | volume_info.UNC, | 2301 | tcon->Flags)); |
2245 | tcon, cifs_sb->local_nls); | ||
2246 | cFYI(1, ("CIFS Tcon rc = %d", rc)); | ||
2247 | if (volume_info.nodfs) { | ||
2248 | tcon->Flags &= | ||
2249 | ~SMB_SHARE_IS_IN_DFS; | ||
2250 | cFYI(1, ("DFS disabled (%d)", | ||
2251 | tcon->Flags)); | ||
2252 | } | ||
2253 | } | ||
2254 | if (!rc) { | ||
2255 | atomic_inc(&pSesInfo->inUse); | ||
2256 | tcon->retry = volume_info.retry; | ||
2257 | tcon->nocase = volume_info.nocase; | ||
2258 | tcon->seal = volume_info.seal; | ||
2259 | } | 2302 | } |
2260 | } | 2303 | } |
2261 | } | 2304 | if (rc) |
2305 | goto mount_fail_check; | ||
2306 | tcon->seal = volume_info.seal; | ||
2307 | write_lock(&cifs_tcp_ses_lock); | ||
2308 | list_add(&tcon->tcon_list, &pSesInfo->tcon_list); | ||
2309 | write_unlock(&cifs_tcp_ses_lock); | ||
2310 | } | ||
2311 | |||
2312 | /* we can have only one retry value for a connection | ||
2313 | to a share so for resources mounted more than once | ||
2314 | to the same server share the last value passed in | ||
2315 | for the retry flag is used */ | ||
2316 | tcon->retry = volume_info.retry; | ||
2317 | tcon->nocase = volume_info.nocase; | ||
2318 | tcon->local_lease = volume_info.local_lease; | ||
2262 | } | 2319 | } |
2263 | if (pSesInfo) { | 2320 | if (pSesInfo) { |
2264 | if (pSesInfo->capabilities & CAP_LARGE_FILES) { | 2321 | if (pSesInfo->capabilities & CAP_LARGE_FILES) { |
@@ -2270,80 +2327,49 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2270 | /* BB FIXME fix time_gran to be larger for LANMAN sessions */ | 2327 | /* BB FIXME fix time_gran to be larger for LANMAN sessions */ |
2271 | sb->s_time_gran = 100; | 2328 | sb->s_time_gran = 100; |
2272 | 2329 | ||
2273 | /* on error free sesinfo and tcon struct if needed */ | 2330 | mount_fail_check: |
2331 | /* on error free sesinfo and tcon struct if needed */ | ||
2274 | if (rc) { | 2332 | if (rc) { |
2275 | /* if session setup failed, use count is zero but | 2333 | /* If find_unc succeeded then rc == 0 so we can not end */ |
2276 | we still need to free cifsd thread */ | 2334 | /* up accidently freeing someone elses tcon struct */ |
2277 | if (atomic_read(&srvTcp->socketUseCount) == 0) { | 2335 | if (tcon) |
2278 | spin_lock(&GlobalMid_Lock); | 2336 | cifs_put_tcon(tcon); |
2279 | srvTcp->tcpStatus = CifsExiting; | 2337 | else if (pSesInfo) |
2280 | spin_unlock(&GlobalMid_Lock); | 2338 | cifs_put_smb_ses(pSesInfo); |
2281 | kill_cifsd(srvTcp); | ||
2282 | } | ||
2283 | /* If find_unc succeeded then rc == 0 so we can not end */ | ||
2284 | if (tcon) /* up accidently freeing someone elses tcon struct */ | ||
2285 | tconInfoFree(tcon); | ||
2286 | if (existingCifsSes == NULL) { | ||
2287 | if (pSesInfo) { | ||
2288 | if ((pSesInfo->server) && | ||
2289 | (pSesInfo->status == CifsGood)) { | ||
2290 | int temp_rc; | ||
2291 | temp_rc = CIFSSMBLogoff(xid, pSesInfo); | ||
2292 | /* if the socketUseCount is now zero */ | ||
2293 | if ((temp_rc == -ESHUTDOWN) && | ||
2294 | (pSesInfo->server)) | ||
2295 | kill_cifsd(pSesInfo->server); | ||
2296 | } else { | ||
2297 | cFYI(1, ("No session or bad tcon")); | ||
2298 | if (pSesInfo->server) { | ||
2299 | spin_lock(&GlobalMid_Lock); | ||
2300 | srvTcp->tcpStatus = CifsExiting; | ||
2301 | spin_unlock(&GlobalMid_Lock); | ||
2302 | kill_cifsd(pSesInfo->server); | ||
2303 | } | ||
2304 | } | ||
2305 | sesInfoFree(pSesInfo); | ||
2306 | /* pSesInfo = NULL; */ | ||
2307 | } | ||
2308 | } | ||
2309 | } else { | ||
2310 | atomic_inc(&tcon->useCount); | ||
2311 | cifs_sb->tcon = tcon; | ||
2312 | tcon->ses = pSesInfo; | ||
2313 | |||
2314 | /* do not care if following two calls succeed - informational */ | ||
2315 | if (!tcon->ipc) { | ||
2316 | CIFSSMBQFSDeviceInfo(xid, tcon); | ||
2317 | CIFSSMBQFSAttributeInfo(xid, tcon); | ||
2318 | } | ||
2319 | |||
2320 | /* tell server which Unix caps we support */ | ||
2321 | if (tcon->ses->capabilities & CAP_UNIX) | ||
2322 | /* reset of caps checks mount to see if unix extensions | ||
2323 | disabled for just this mount */ | ||
2324 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); | ||
2325 | else | 2339 | else |
2326 | tcon->unix_ext = 0; /* server does not support them */ | 2340 | cifs_put_tcp_session(srvTcp); |
2341 | goto out; | ||
2342 | } | ||
2343 | cifs_sb->tcon = tcon; | ||
2327 | 2344 | ||
2328 | /* convert forward to back slashes in prepath here if needed */ | 2345 | /* do not care if following two calls succeed - informational */ |
2329 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0) | 2346 | if (!tcon->ipc) { |
2330 | convert_delimiter(cifs_sb->prepath, | 2347 | CIFSSMBQFSDeviceInfo(xid, tcon); |
2331 | CIFS_DIR_SEP(cifs_sb)); | 2348 | CIFSSMBQFSAttributeInfo(xid, tcon); |
2349 | } | ||
2332 | 2350 | ||
2333 | if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) { | 2351 | /* tell server which Unix caps we support */ |
2334 | cifs_sb->rsize = 1024 * 127; | 2352 | if (tcon->ses->capabilities & CAP_UNIX) |
2335 | cFYI(DBG2, | 2353 | /* reset of caps checks mount to see if unix extensions |
2336 | ("no very large read support, rsize now 127K")); | 2354 | disabled for just this mount */ |
2337 | } | 2355 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); |
2338 | if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) | 2356 | else |
2339 | cifs_sb->wsize = min(cifs_sb->wsize, | 2357 | tcon->unix_ext = 0; /* server does not support them */ |
2340 | (tcon->ses->server->maxBuf - | 2358 | |
2341 | MAX_CIFS_HDR_SIZE)); | 2359 | /* convert forward to back slashes in prepath here if needed */ |
2342 | if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) | 2360 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0) |
2343 | cifs_sb->rsize = min(cifs_sb->rsize, | 2361 | convert_delimiter(cifs_sb->prepath, CIFS_DIR_SEP(cifs_sb)); |
2344 | (tcon->ses->server->maxBuf - | 2362 | |
2345 | MAX_CIFS_HDR_SIZE)); | 2363 | if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) { |
2364 | cifs_sb->rsize = 1024 * 127; | ||
2365 | cFYI(DBG2, ("no very large read support, rsize now 127K")); | ||
2346 | } | 2366 | } |
2367 | if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) | ||
2368 | cifs_sb->wsize = min(cifs_sb->wsize, | ||
2369 | (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)); | ||
2370 | if (!(tcon->ses->capabilities & CAP_LARGE_READ_X)) | ||
2371 | cifs_sb->rsize = min(cifs_sb->rsize, | ||
2372 | (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)); | ||
2347 | 2373 | ||
2348 | /* volume_info.password is freed above when existing session found | 2374 | /* volume_info.password is freed above when existing session found |
2349 | (in which case it is not needed anymore) but when new sesion is created | 2375 | (in which case it is not needed anymore) but when new sesion is created |
@@ -3513,6 +3539,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3513 | /* above now done in SendReceive */ | 3539 | /* above now done in SendReceive */ |
3514 | if ((rc == 0) && (tcon != NULL)) { | 3540 | if ((rc == 0) && (tcon != NULL)) { |
3515 | tcon->tidStatus = CifsGood; | 3541 | tcon->tidStatus = CifsGood; |
3542 | tcon->need_reconnect = false; | ||
3516 | tcon->tid = smb_buffer_response->Tid; | 3543 | tcon->tid = smb_buffer_response->Tid; |
3517 | bcc_ptr = pByteArea(smb_buffer_response); | 3544 | bcc_ptr = pByteArea(smb_buffer_response); |
3518 | length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); | 3545 | length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); |
@@ -3584,48 +3611,17 @@ int | |||
3584 | cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) | 3611 | cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) |
3585 | { | 3612 | { |
3586 | int rc = 0; | 3613 | int rc = 0; |
3587 | int xid; | ||
3588 | struct cifsSesInfo *ses = NULL; | ||
3589 | char *tmp; | 3614 | char *tmp; |
3590 | 3615 | ||
3591 | xid = GetXid(); | 3616 | if (cifs_sb->tcon) |
3592 | 3617 | cifs_put_tcon(cifs_sb->tcon); | |
3593 | if (cifs_sb->tcon) { | ||
3594 | ses = cifs_sb->tcon->ses; /* save ptr to ses before delete tcon!*/ | ||
3595 | rc = CIFSSMBTDis(xid, cifs_sb->tcon); | ||
3596 | if (rc == -EBUSY) { | ||
3597 | FreeXid(xid); | ||
3598 | return 0; | ||
3599 | } | ||
3600 | DeleteTconOplockQEntries(cifs_sb->tcon); | ||
3601 | tconInfoFree(cifs_sb->tcon); | ||
3602 | if ((ses) && (ses->server)) { | ||
3603 | /* save off task so we do not refer to ses later */ | ||
3604 | cFYI(1, ("About to do SMBLogoff ")); | ||
3605 | rc = CIFSSMBLogoff(xid, ses); | ||
3606 | if (rc == -EBUSY) { | ||
3607 | FreeXid(xid); | ||
3608 | return 0; | ||
3609 | } else if (rc == -ESHUTDOWN) { | ||
3610 | cFYI(1, ("Waking up socket by sending signal")); | ||
3611 | if (ses->server) | ||
3612 | kill_cifsd(ses->server); | ||
3613 | rc = 0; | ||
3614 | } /* else - we have an smb session | ||
3615 | left on this socket do not kill cifsd */ | ||
3616 | } else | ||
3617 | cFYI(1, ("No session or bad tcon")); | ||
3618 | } | ||
3619 | 3618 | ||
3620 | cifs_sb->tcon = NULL; | 3619 | cifs_sb->tcon = NULL; |
3621 | tmp = cifs_sb->prepath; | 3620 | tmp = cifs_sb->prepath; |
3622 | cifs_sb->prepathlen = 0; | 3621 | cifs_sb->prepathlen = 0; |
3623 | cifs_sb->prepath = NULL; | 3622 | cifs_sb->prepath = NULL; |
3624 | kfree(tmp); | 3623 | kfree(tmp); |
3625 | if (ses) | ||
3626 | sesInfoFree(ses); | ||
3627 | 3624 | ||
3628 | FreeXid(xid); | ||
3629 | return rc; | 3625 | return rc; |
3630 | } | 3626 | } |
3631 | 3627 | ||
@@ -3741,6 +3737,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3741 | cFYI(1, ("CIFS Session Established successfully")); | 3737 | cFYI(1, ("CIFS Session Established successfully")); |
3742 | spin_lock(&GlobalMid_Lock); | 3738 | spin_lock(&GlobalMid_Lock); |
3743 | pSesInfo->status = CifsGood; | 3739 | pSesInfo->status = CifsGood; |
3740 | pSesInfo->need_reconnect = false; | ||
3744 | spin_unlock(&GlobalMid_Lock); | 3741 | spin_unlock(&GlobalMid_Lock); |
3745 | } | 3742 | } |
3746 | 3743 | ||
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ead1a3bb0256..6449e1aae621 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -493,7 +493,7 @@ int cifs_close(struct inode *inode, struct file *file) | |||
493 | if (pTcon) { | 493 | if (pTcon) { |
494 | /* no sense reconnecting to close a file that is | 494 | /* no sense reconnecting to close a file that is |
495 | already closed */ | 495 | already closed */ |
496 | if (pTcon->tidStatus != CifsNeedReconnect) { | 496 | if (!pTcon->need_reconnect) { |
497 | timeout = 2; | 497 | timeout = 2; |
498 | while ((atomic_read(&pSMBFile->wrtPending) != 0) | 498 | while ((atomic_read(&pSMBFile->wrtPending) != 0) |
499 | && (timeout <= 2048)) { | 499 | && (timeout <= 2048)) { |
@@ -1404,7 +1404,10 @@ retry: | |||
1404 | if ((wbc->nr_to_write -= n_iov) <= 0) | 1404 | if ((wbc->nr_to_write -= n_iov) <= 0) |
1405 | done = 1; | 1405 | done = 1; |
1406 | index = next; | 1406 | index = next; |
1407 | } | 1407 | } else |
1408 | /* Need to re-find the pages we skipped */ | ||
1409 | index = pvec.pages[0]->index + 1; | ||
1410 | |||
1408 | pagevec_release(&pvec); | 1411 | pagevec_release(&pvec); |
1409 | } | 1412 | } |
1410 | if (!scanned && !done) { | 1413 | if (!scanned && !done) { |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 88786ba02d27..addd1dcc2d79 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -75,12 +75,12 @@ sesInfoAlloc(void) | |||
75 | 75 | ||
76 | ret_buf = kzalloc(sizeof(struct cifsSesInfo), GFP_KERNEL); | 76 | ret_buf = kzalloc(sizeof(struct cifsSesInfo), GFP_KERNEL); |
77 | if (ret_buf) { | 77 | if (ret_buf) { |
78 | write_lock(&GlobalSMBSeslock); | ||
79 | atomic_inc(&sesInfoAllocCount); | 78 | atomic_inc(&sesInfoAllocCount); |
80 | ret_buf->status = CifsNew; | 79 | ret_buf->status = CifsNew; |
81 | list_add(&ret_buf->cifsSessionList, &GlobalSMBSessionList); | 80 | ++ret_buf->ses_count; |
81 | INIT_LIST_HEAD(&ret_buf->smb_ses_list); | ||
82 | INIT_LIST_HEAD(&ret_buf->tcon_list); | ||
82 | init_MUTEX(&ret_buf->sesSem); | 83 | init_MUTEX(&ret_buf->sesSem); |
83 | write_unlock(&GlobalSMBSeslock); | ||
84 | } | 84 | } |
85 | return ret_buf; | 85 | return ret_buf; |
86 | } | 86 | } |
@@ -93,10 +93,7 @@ sesInfoFree(struct cifsSesInfo *buf_to_free) | |||
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | 95 | ||
96 | write_lock(&GlobalSMBSeslock); | ||
97 | atomic_dec(&sesInfoAllocCount); | 96 | atomic_dec(&sesInfoAllocCount); |
98 | list_del(&buf_to_free->cifsSessionList); | ||
99 | write_unlock(&GlobalSMBSeslock); | ||
100 | kfree(buf_to_free->serverOS); | 97 | kfree(buf_to_free->serverOS); |
101 | kfree(buf_to_free->serverDomain); | 98 | kfree(buf_to_free->serverDomain); |
102 | kfree(buf_to_free->serverNOS); | 99 | kfree(buf_to_free->serverNOS); |
@@ -111,17 +108,14 @@ tconInfoAlloc(void) | |||
111 | struct cifsTconInfo *ret_buf; | 108 | struct cifsTconInfo *ret_buf; |
112 | ret_buf = kzalloc(sizeof(struct cifsTconInfo), GFP_KERNEL); | 109 | ret_buf = kzalloc(sizeof(struct cifsTconInfo), GFP_KERNEL); |
113 | if (ret_buf) { | 110 | if (ret_buf) { |
114 | write_lock(&GlobalSMBSeslock); | ||
115 | atomic_inc(&tconInfoAllocCount); | 111 | atomic_inc(&tconInfoAllocCount); |
116 | list_add(&ret_buf->cifsConnectionList, | ||
117 | &GlobalTreeConnectionList); | ||
118 | ret_buf->tidStatus = CifsNew; | 112 | ret_buf->tidStatus = CifsNew; |
113 | ++ret_buf->tc_count; | ||
119 | INIT_LIST_HEAD(&ret_buf->openFileList); | 114 | INIT_LIST_HEAD(&ret_buf->openFileList); |
120 | init_MUTEX(&ret_buf->tconSem); | 115 | INIT_LIST_HEAD(&ret_buf->tcon_list); |
121 | #ifdef CONFIG_CIFS_STATS | 116 | #ifdef CONFIG_CIFS_STATS |
122 | spin_lock_init(&ret_buf->stat_lock); | 117 | spin_lock_init(&ret_buf->stat_lock); |
123 | #endif | 118 | #endif |
124 | write_unlock(&GlobalSMBSeslock); | ||
125 | } | 119 | } |
126 | return ret_buf; | 120 | return ret_buf; |
127 | } | 121 | } |
@@ -133,10 +127,7 @@ tconInfoFree(struct cifsTconInfo *buf_to_free) | |||
133 | cFYI(1, ("Null buffer passed to tconInfoFree")); | 127 | cFYI(1, ("Null buffer passed to tconInfoFree")); |
134 | return; | 128 | return; |
135 | } | 129 | } |
136 | write_lock(&GlobalSMBSeslock); | ||
137 | atomic_dec(&tconInfoAllocCount); | 130 | atomic_dec(&tconInfoAllocCount); |
138 | list_del(&buf_to_free->cifsConnectionList); | ||
139 | write_unlock(&GlobalSMBSeslock); | ||
140 | kfree(buf_to_free->nativeFileSystem); | 131 | kfree(buf_to_free->nativeFileSystem); |
141 | kfree(buf_to_free); | 132 | kfree(buf_to_free); |
142 | } | 133 | } |
@@ -350,9 +341,9 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
350 | if (current->fsuid != treeCon->ses->linux_uid) { | 341 | if (current->fsuid != treeCon->ses->linux_uid) { |
351 | cFYI(1, ("Multiuser mode and UID " | 342 | cFYI(1, ("Multiuser mode and UID " |
352 | "did not match tcon uid")); | 343 | "did not match tcon uid")); |
353 | read_lock(&GlobalSMBSeslock); | 344 | read_lock(&cifs_tcp_ses_lock); |
354 | list_for_each(temp_item, &GlobalSMBSessionList) { | 345 | list_for_each(temp_item, &treeCon->ses->server->smb_ses_list) { |
355 | ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); | 346 | ses = list_entry(temp_item, struct cifsSesInfo, smb_ses_list); |
356 | if (ses->linux_uid == current->fsuid) { | 347 | if (ses->linux_uid == current->fsuid) { |
357 | if (ses->server == treeCon->ses->server) { | 348 | if (ses->server == treeCon->ses->server) { |
358 | cFYI(1, ("found matching uid substitute right smb_uid")); | 349 | cFYI(1, ("found matching uid substitute right smb_uid")); |
@@ -364,7 +355,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
364 | } | 355 | } |
365 | } | 356 | } |
366 | } | 357 | } |
367 | read_unlock(&GlobalSMBSeslock); | 358 | read_unlock(&cifs_tcp_ses_lock); |
368 | } | 359 | } |
369 | } | 360 | } |
370 | } | 361 | } |
@@ -497,9 +488,10 @@ bool | |||
497 | is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | 488 | is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) |
498 | { | 489 | { |
499 | struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; | 490 | struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; |
500 | struct list_head *tmp; | 491 | struct list_head *tmp, *tmp1, *tmp2; |
501 | struct list_head *tmp1; | 492 | struct cifsSesInfo *ses; |
502 | struct cifsTconInfo *tcon; | 493 | struct cifsTconInfo *tcon; |
494 | struct cifsInodeInfo *pCifsInode; | ||
503 | struct cifsFileInfo *netfile; | 495 | struct cifsFileInfo *netfile; |
504 | 496 | ||
505 | cFYI(1, ("Checking for oplock break or dnotify response")); | 497 | cFYI(1, ("Checking for oplock break or dnotify response")); |
@@ -554,42 +546,42 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
554 | return false; | 546 | return false; |
555 | 547 | ||
556 | /* look up tcon based on tid & uid */ | 548 | /* look up tcon based on tid & uid */ |
557 | read_lock(&GlobalSMBSeslock); | 549 | read_lock(&cifs_tcp_ses_lock); |
558 | list_for_each(tmp, &GlobalTreeConnectionList) { | 550 | list_for_each(tmp, &srv->smb_ses_list) { |
559 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 551 | ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); |
560 | if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) { | 552 | list_for_each(tmp1, &ses->tcon_list) { |
553 | tcon = list_entry(tmp1, struct cifsTconInfo, tcon_list); | ||
554 | if (tcon->tid != buf->Tid) | ||
555 | continue; | ||
556 | |||
561 | cifs_stats_inc(&tcon->num_oplock_brks); | 557 | cifs_stats_inc(&tcon->num_oplock_brks); |
562 | list_for_each(tmp1, &tcon->openFileList) { | 558 | list_for_each(tmp2, &tcon->openFileList) { |
563 | netfile = list_entry(tmp1, struct cifsFileInfo, | 559 | netfile = list_entry(tmp2, struct cifsFileInfo, |
564 | tlist); | 560 | tlist); |
565 | if (pSMB->Fid == netfile->netfid) { | 561 | if (pSMB->Fid != netfile->netfid) |
566 | struct cifsInodeInfo *pCifsInode; | 562 | continue; |
567 | read_unlock(&GlobalSMBSeslock); | 563 | |
568 | cFYI(1, | 564 | read_unlock(&cifs_tcp_ses_lock); |
569 | ("file id match, oplock break")); | 565 | cFYI(1, ("file id match, oplock break")); |
570 | pCifsInode = | 566 | pCifsInode = CIFS_I(netfile->pInode); |
571 | CIFS_I(netfile->pInode); | 567 | pCifsInode->clientCanCacheAll = false; |
572 | pCifsInode->clientCanCacheAll = false; | 568 | if (pSMB->OplockLevel == 0) |
573 | if (pSMB->OplockLevel == 0) | 569 | pCifsInode->clientCanCacheRead = false; |
574 | pCifsInode->clientCanCacheRead | 570 | pCifsInode->oplockPending = true; |
575 | = false; | 571 | AllocOplockQEntry(netfile->pInode, |
576 | pCifsInode->oplockPending = true; | 572 | netfile->netfid, tcon); |
577 | AllocOplockQEntry(netfile->pInode, | 573 | cFYI(1, ("about to wake up oplock thread")); |
578 | netfile->netfid, | 574 | if (oplockThread) |
579 | tcon); | 575 | wake_up_process(oplockThread); |
580 | cFYI(1, | 576 | |
581 | ("about to wake up oplock thread")); | 577 | return true; |
582 | if (oplockThread) | ||
583 | wake_up_process(oplockThread); | ||
584 | return true; | ||
585 | } | ||
586 | } | 578 | } |
587 | read_unlock(&GlobalSMBSeslock); | 579 | read_unlock(&cifs_tcp_ses_lock); |
588 | cFYI(1, ("No matching file for oplock break")); | 580 | cFYI(1, ("No matching file for oplock break")); |
589 | return true; | 581 | return true; |
590 | } | 582 | } |
591 | } | 583 | } |
592 | read_unlock(&GlobalSMBSeslock); | 584 | read_unlock(&cifs_tcp_ses_lock); |
593 | cFYI(1, ("Can not process oplock break for non-existent connection")); | 585 | cFYI(1, ("Can not process oplock break for non-existent connection")); |
594 | return true; | 586 | return true; |
595 | } | 587 | } |
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index d910501de6d2..8d86b7960f0d 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -812,7 +812,7 @@ int dlm_release_lockspace(void *lockspace, int force) | |||
812 | error = release_lockspace(ls, force); | 812 | error = release_lockspace(ls, force); |
813 | if (!error) | 813 | if (!error) |
814 | ls_count--; | 814 | ls_count--; |
815 | else if (!ls_count) | 815 | if (!ls_count) |
816 | threads_stop(); | 816 | threads_stop(); |
817 | mutex_unlock(&ls_lock); | 817 | mutex_unlock(&ls_lock); |
818 | 818 | ||
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 5dec6d1356c4..f6c94f232ec1 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -2375,12 +2375,9 @@ int ext3_force_commit(struct super_block *sb) | |||
2375 | /* | 2375 | /* |
2376 | * Ext3 always journals updates to the superblock itself, so we don't | 2376 | * Ext3 always journals updates to the superblock itself, so we don't |
2377 | * have to propagate any other updates to the superblock on disk at this | 2377 | * have to propagate any other updates to the superblock on disk at this |
2378 | * point. Just start an async writeback to get the buffers on their way | 2378 | * point. (We can probably nuke this function altogether, and remove |
2379 | * to the disk. | 2379 | * any mention to sb->s_dirt in all of fs/ext3; eventual cleanup...) |
2380 | * | ||
2381 | * This implicitly triggers the writebehind on sync(). | ||
2382 | */ | 2380 | */ |
2383 | |||
2384 | static void ext3_write_super (struct super_block * sb) | 2381 | static void ext3_write_super (struct super_block * sb) |
2385 | { | 2382 | { |
2386 | if (mutex_trylock(&sb->s_lock) != 0) | 2383 | if (mutex_trylock(&sb->s_lock) != 0) |
diff --git a/fs/inotify.c b/fs/inotify.c index 690e72595e6e..7bbed1b89825 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
@@ -106,6 +106,20 @@ void get_inotify_watch(struct inotify_watch *watch) | |||
106 | } | 106 | } |
107 | EXPORT_SYMBOL_GPL(get_inotify_watch); | 107 | EXPORT_SYMBOL_GPL(get_inotify_watch); |
108 | 108 | ||
109 | int pin_inotify_watch(struct inotify_watch *watch) | ||
110 | { | ||
111 | struct super_block *sb = watch->inode->i_sb; | ||
112 | spin_lock(&sb_lock); | ||
113 | if (sb->s_count >= S_BIAS) { | ||
114 | atomic_inc(&sb->s_active); | ||
115 | spin_unlock(&sb_lock); | ||
116 | atomic_inc(&watch->count); | ||
117 | return 1; | ||
118 | } | ||
119 | spin_unlock(&sb_lock); | ||
120 | return 0; | ||
121 | } | ||
122 | |||
109 | /** | 123 | /** |
110 | * put_inotify_watch - decrements the ref count on a given watch. cleans up | 124 | * put_inotify_watch - decrements the ref count on a given watch. cleans up |
111 | * watch references if the count reaches zero. inotify_watch is freed by | 125 | * watch references if the count reaches zero. inotify_watch is freed by |
@@ -124,6 +138,13 @@ void put_inotify_watch(struct inotify_watch *watch) | |||
124 | } | 138 | } |
125 | EXPORT_SYMBOL_GPL(put_inotify_watch); | 139 | EXPORT_SYMBOL_GPL(put_inotify_watch); |
126 | 140 | ||
141 | void unpin_inotify_watch(struct inotify_watch *watch) | ||
142 | { | ||
143 | struct super_block *sb = watch->inode->i_sb; | ||
144 | put_inotify_watch(watch); | ||
145 | deactivate_super(sb); | ||
146 | } | ||
147 | |||
127 | /* | 148 | /* |
128 | * inotify_handle_get_wd - returns the next WD for use by the given handle | 149 | * inotify_handle_get_wd - returns the next WD for use by the given handle |
129 | * | 150 | * |
@@ -479,6 +500,112 @@ void inotify_init_watch(struct inotify_watch *watch) | |||
479 | } | 500 | } |
480 | EXPORT_SYMBOL_GPL(inotify_init_watch); | 501 | EXPORT_SYMBOL_GPL(inotify_init_watch); |
481 | 502 | ||
503 | /* | ||
504 | * Watch removals suck violently. To kick the watch out we need (in this | ||
505 | * order) inode->inotify_mutex and ih->mutex. That's fine if we have | ||
506 | * a hold on inode; however, for all other cases we need to make damn sure | ||
507 | * we don't race with umount. We can *NOT* just grab a reference to a | ||
508 | * watch - inotify_unmount_inodes() will happily sail past it and we'll end | ||
509 | * with reference to inode potentially outliving its superblock. Ideally | ||
510 | * we just want to grab an active reference to superblock if we can; that | ||
511 | * will make sure we won't go into inotify_umount_inodes() until we are | ||
512 | * done. Cleanup is just deactivate_super(). However, that leaves a messy | ||
513 | * case - what if we *are* racing with umount() and active references to | ||
514 | * superblock can't be acquired anymore? We can bump ->s_count, grab | ||
515 | * ->s_umount, which will almost certainly wait until the superblock is shut | ||
516 | * down and the watch in question is pining for fjords. That's fine, but | ||
517 | * there is a problem - we might have hit the window between ->s_active | ||
518 | * getting to 0 / ->s_count - below S_BIAS (i.e. the moment when superblock | ||
519 | * is past the point of no return and is heading for shutdown) and the | ||
520 | * moment when deactivate_super() acquires ->s_umount. We could just do | ||
521 | * drop_super() yield() and retry, but that's rather antisocial and this | ||
522 | * stuff is luser-triggerable. OTOH, having grabbed ->s_umount and having | ||
523 | * found that we'd got there first (i.e. that ->s_root is non-NULL) we know | ||
524 | * that we won't race with inotify_umount_inodes(). So we could grab a | ||
525 | * reference to watch and do the rest as above, just with drop_super() instead | ||
526 | * of deactivate_super(), right? Wrong. We had to drop ih->mutex before we | ||
527 | * could grab ->s_umount. So the watch could've been gone already. | ||
528 | * | ||
529 | * That still can be dealt with - we need to save watch->wd, do idr_find() | ||
530 | * and compare its result with our pointer. If they match, we either have | ||
531 | * the damn thing still alive or we'd lost not one but two races at once, | ||
532 | * the watch had been killed and a new one got created with the same ->wd | ||
533 | * at the same address. That couldn't have happened in inotify_destroy(), | ||
534 | * but inotify_rm_wd() could run into that. Still, "new one got created" | ||
535 | * is not a problem - we have every right to kill it or leave it alone, | ||
536 | * whatever's more convenient. | ||
537 | * | ||
538 | * So we can use idr_find(...) == watch && watch->inode->i_sb == sb as | ||
539 | * "grab it and kill it" check. If it's been our original watch, we are | ||
540 | * fine, if it's a newcomer - nevermind, just pretend that we'd won the | ||
541 | * race and kill the fscker anyway; we are safe since we know that its | ||
542 | * superblock won't be going away. | ||
543 | * | ||
544 | * And yes, this is far beyond mere "not very pretty"; so's the entire | ||
545 | * concept of inotify to start with. | ||
546 | */ | ||
547 | |||
548 | /** | ||
549 | * pin_to_kill - pin the watch down for removal | ||
550 | * @ih: inotify handle | ||
551 | * @watch: watch to kill | ||
552 | * | ||
553 | * Called with ih->mutex held, drops it. Possible return values: | ||
554 | * 0 - nothing to do, it has died | ||
555 | * 1 - remove it, drop the reference and deactivate_super() | ||
556 | * 2 - remove it, drop the reference and drop_super(); we tried hard to avoid | ||
557 | * that variant, since it involved a lot of PITA, but that's the best that | ||
558 | * could've been done. | ||
559 | */ | ||
560 | static int pin_to_kill(struct inotify_handle *ih, struct inotify_watch *watch) | ||
561 | { | ||
562 | struct super_block *sb = watch->inode->i_sb; | ||
563 | s32 wd = watch->wd; | ||
564 | |||
565 | spin_lock(&sb_lock); | ||
566 | if (sb->s_count >= S_BIAS) { | ||
567 | atomic_inc(&sb->s_active); | ||
568 | spin_unlock(&sb_lock); | ||
569 | get_inotify_watch(watch); | ||
570 | mutex_unlock(&ih->mutex); | ||
571 | return 1; /* the best outcome */ | ||
572 | } | ||
573 | sb->s_count++; | ||
574 | spin_unlock(&sb_lock); | ||
575 | mutex_unlock(&ih->mutex); /* can't grab ->s_umount under it */ | ||
576 | down_read(&sb->s_umount); | ||
577 | if (likely(!sb->s_root)) { | ||
578 | /* fs is already shut down; the watch is dead */ | ||
579 | drop_super(sb); | ||
580 | return 0; | ||
581 | } | ||
582 | /* raced with the final deactivate_super() */ | ||
583 | mutex_lock(&ih->mutex); | ||
584 | if (idr_find(&ih->idr, wd) != watch || watch->inode->i_sb != sb) { | ||
585 | /* the watch is dead */ | ||
586 | mutex_unlock(&ih->mutex); | ||
587 | drop_super(sb); | ||
588 | return 0; | ||
589 | } | ||
590 | /* still alive or freed and reused with the same sb and wd; kill */ | ||
591 | get_inotify_watch(watch); | ||
592 | mutex_unlock(&ih->mutex); | ||
593 | return 2; | ||
594 | } | ||
595 | |||
596 | static void unpin_and_kill(struct inotify_watch *watch, int how) | ||
597 | { | ||
598 | struct super_block *sb = watch->inode->i_sb; | ||
599 | put_inotify_watch(watch); | ||
600 | switch (how) { | ||
601 | case 1: | ||
602 | deactivate_super(sb); | ||
603 | break; | ||
604 | case 2: | ||
605 | drop_super(sb); | ||
606 | } | ||
607 | } | ||
608 | |||
482 | /** | 609 | /** |
483 | * inotify_destroy - clean up and destroy an inotify instance | 610 | * inotify_destroy - clean up and destroy an inotify instance |
484 | * @ih: inotify handle | 611 | * @ih: inotify handle |
@@ -490,11 +617,15 @@ void inotify_destroy(struct inotify_handle *ih) | |||
490 | * pretty. We cannot do a simple iteration over the list, because we | 617 | * pretty. We cannot do a simple iteration over the list, because we |
491 | * do not know the inode until we iterate to the watch. But we need to | 618 | * do not know the inode until we iterate to the watch. But we need to |
492 | * hold inode->inotify_mutex before ih->mutex. The following works. | 619 | * hold inode->inotify_mutex before ih->mutex. The following works. |
620 | * | ||
621 | * AV: it had to become even uglier to start working ;-/ | ||
493 | */ | 622 | */ |
494 | while (1) { | 623 | while (1) { |
495 | struct inotify_watch *watch; | 624 | struct inotify_watch *watch; |
496 | struct list_head *watches; | 625 | struct list_head *watches; |
626 | struct super_block *sb; | ||
497 | struct inode *inode; | 627 | struct inode *inode; |
628 | int how; | ||
498 | 629 | ||
499 | mutex_lock(&ih->mutex); | 630 | mutex_lock(&ih->mutex); |
500 | watches = &ih->watches; | 631 | watches = &ih->watches; |
@@ -503,8 +634,10 @@ void inotify_destroy(struct inotify_handle *ih) | |||
503 | break; | 634 | break; |
504 | } | 635 | } |
505 | watch = list_first_entry(watches, struct inotify_watch, h_list); | 636 | watch = list_first_entry(watches, struct inotify_watch, h_list); |
506 | get_inotify_watch(watch); | 637 | sb = watch->inode->i_sb; |
507 | mutex_unlock(&ih->mutex); | 638 | how = pin_to_kill(ih, watch); |
639 | if (!how) | ||
640 | continue; | ||
508 | 641 | ||
509 | inode = watch->inode; | 642 | inode = watch->inode; |
510 | mutex_lock(&inode->inotify_mutex); | 643 | mutex_lock(&inode->inotify_mutex); |
@@ -518,7 +651,7 @@ void inotify_destroy(struct inotify_handle *ih) | |||
518 | 651 | ||
519 | mutex_unlock(&ih->mutex); | 652 | mutex_unlock(&ih->mutex); |
520 | mutex_unlock(&inode->inotify_mutex); | 653 | mutex_unlock(&inode->inotify_mutex); |
521 | put_inotify_watch(watch); | 654 | unpin_and_kill(watch, how); |
522 | } | 655 | } |
523 | 656 | ||
524 | /* free this handle: the put matching the get in inotify_init() */ | 657 | /* free this handle: the put matching the get in inotify_init() */ |
@@ -719,7 +852,9 @@ void inotify_evict_watch(struct inotify_watch *watch) | |||
719 | int inotify_rm_wd(struct inotify_handle *ih, u32 wd) | 852 | int inotify_rm_wd(struct inotify_handle *ih, u32 wd) |
720 | { | 853 | { |
721 | struct inotify_watch *watch; | 854 | struct inotify_watch *watch; |
855 | struct super_block *sb; | ||
722 | struct inode *inode; | 856 | struct inode *inode; |
857 | int how; | ||
723 | 858 | ||
724 | mutex_lock(&ih->mutex); | 859 | mutex_lock(&ih->mutex); |
725 | watch = idr_find(&ih->idr, wd); | 860 | watch = idr_find(&ih->idr, wd); |
@@ -727,9 +862,12 @@ int inotify_rm_wd(struct inotify_handle *ih, u32 wd) | |||
727 | mutex_unlock(&ih->mutex); | 862 | mutex_unlock(&ih->mutex); |
728 | return -EINVAL; | 863 | return -EINVAL; |
729 | } | 864 | } |
730 | get_inotify_watch(watch); | 865 | sb = watch->inode->i_sb; |
866 | how = pin_to_kill(ih, watch); | ||
867 | if (!how) | ||
868 | return 0; | ||
869 | |||
731 | inode = watch->inode; | 870 | inode = watch->inode; |
732 | mutex_unlock(&ih->mutex); | ||
733 | 871 | ||
734 | mutex_lock(&inode->inotify_mutex); | 872 | mutex_lock(&inode->inotify_mutex); |
735 | mutex_lock(&ih->mutex); | 873 | mutex_lock(&ih->mutex); |
@@ -740,7 +878,7 @@ int inotify_rm_wd(struct inotify_handle *ih, u32 wd) | |||
740 | 878 | ||
741 | mutex_unlock(&ih->mutex); | 879 | mutex_unlock(&ih->mutex); |
742 | mutex_unlock(&inode->inotify_mutex); | 880 | mutex_unlock(&inode->inotify_mutex); |
743 | put_inotify_watch(watch); | 881 | unpin_and_kill(watch, how); |
744 | 882 | ||
745 | return 0; | 883 | return 0; |
746 | } | 884 | } |
diff --git a/fs/namespace.c b/fs/namespace.c index cce46702d33c..65b3dc844c87 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -1815,8 +1815,8 @@ static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts) | |||
1815 | while (!list_empty(&graveyard)) { | 1815 | while (!list_empty(&graveyard)) { |
1816 | m = list_first_entry(&graveyard, struct vfsmount, | 1816 | m = list_first_entry(&graveyard, struct vfsmount, |
1817 | mnt_expire); | 1817 | mnt_expire); |
1818 | touch_mnt_namespace(mnt->mnt_ns); | 1818 | touch_mnt_namespace(m->mnt_ns); |
1819 | umount_tree(mnt, 1, umounts); | 1819 | umount_tree(m, 1, umounts); |
1820 | } | 1820 | } |
1821 | } | 1821 | } |
1822 | } | 1822 | } |
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 633f7a0ebb2c..6d5b213b8a9b 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -348,8 +348,8 @@ static ssize_t whole_disk_show(struct device *dev, | |||
348 | static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, | 348 | static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, |
349 | whole_disk_show, NULL); | 349 | whole_disk_show, NULL); |
350 | 350 | ||
351 | int add_partition(struct gendisk *disk, int partno, | 351 | struct hd_struct *add_partition(struct gendisk *disk, int partno, |
352 | sector_t start, sector_t len, int flags) | 352 | sector_t start, sector_t len, int flags) |
353 | { | 353 | { |
354 | struct hd_struct *p; | 354 | struct hd_struct *p; |
355 | dev_t devt = MKDEV(0, 0); | 355 | dev_t devt = MKDEV(0, 0); |
@@ -361,15 +361,15 @@ int add_partition(struct gendisk *disk, int partno, | |||
361 | 361 | ||
362 | err = disk_expand_part_tbl(disk, partno); | 362 | err = disk_expand_part_tbl(disk, partno); |
363 | if (err) | 363 | if (err) |
364 | return err; | 364 | return ERR_PTR(err); |
365 | ptbl = disk->part_tbl; | 365 | ptbl = disk->part_tbl; |
366 | 366 | ||
367 | if (ptbl->part[partno]) | 367 | if (ptbl->part[partno]) |
368 | return -EBUSY; | 368 | return ERR_PTR(-EBUSY); |
369 | 369 | ||
370 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 370 | p = kzalloc(sizeof(*p), GFP_KERNEL); |
371 | if (!p) | 371 | if (!p) |
372 | return -ENOMEM; | 372 | return ERR_PTR(-EBUSY); |
373 | 373 | ||
374 | if (!init_part_stats(p)) { | 374 | if (!init_part_stats(p)) { |
375 | err = -ENOMEM; | 375 | err = -ENOMEM; |
@@ -395,7 +395,7 @@ int add_partition(struct gendisk *disk, int partno, | |||
395 | 395 | ||
396 | err = blk_alloc_devt(p, &devt); | 396 | err = blk_alloc_devt(p, &devt); |
397 | if (err) | 397 | if (err) |
398 | goto out_free; | 398 | goto out_free_stats; |
399 | pdev->devt = devt; | 399 | pdev->devt = devt; |
400 | 400 | ||
401 | /* delay uevent until 'holders' subdir is created */ | 401 | /* delay uevent until 'holders' subdir is created */ |
@@ -424,18 +424,20 @@ int add_partition(struct gendisk *disk, int partno, | |||
424 | if (!ddev->uevent_suppress) | 424 | if (!ddev->uevent_suppress) |
425 | kobject_uevent(&pdev->kobj, KOBJ_ADD); | 425 | kobject_uevent(&pdev->kobj, KOBJ_ADD); |
426 | 426 | ||
427 | return 0; | 427 | return p; |
428 | 428 | ||
429 | out_free_stats: | ||
430 | free_part_stats(p); | ||
429 | out_free: | 431 | out_free: |
430 | kfree(p); | 432 | kfree(p); |
431 | return err; | 433 | return ERR_PTR(err); |
432 | out_del: | 434 | out_del: |
433 | kobject_put(p->holder_dir); | 435 | kobject_put(p->holder_dir); |
434 | device_del(pdev); | 436 | device_del(pdev); |
435 | out_put: | 437 | out_put: |
436 | put_device(pdev); | 438 | put_device(pdev); |
437 | blk_free_devt(devt); | 439 | blk_free_devt(devt); |
438 | return err; | 440 | return ERR_PTR(err); |
439 | } | 441 | } |
440 | 442 | ||
441 | /* Not exported, helper to add_disk(). */ | 443 | /* Not exported, helper to add_disk(). */ |
@@ -566,15 +568,16 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) | |||
566 | disk->disk_name, p, (unsigned long long) size); | 568 | disk->disk_name, p, (unsigned long long) size); |
567 | size = get_capacity(disk) - from; | 569 | size = get_capacity(disk) - from; |
568 | } | 570 | } |
569 | res = add_partition(disk, p, from, size, state->parts[p].flags); | 571 | part = add_partition(disk, p, from, size, |
570 | if (res) { | 572 | state->parts[p].flags); |
571 | printk(KERN_ERR " %s: p%d could not be added: %d\n", | 573 | if (IS_ERR(part)) { |
572 | disk->disk_name, p, -res); | 574 | printk(KERN_ERR " %s: p%d could not be added: %ld\n", |
575 | disk->disk_name, p, -PTR_ERR(part)); | ||
573 | continue; | 576 | continue; |
574 | } | 577 | } |
575 | #ifdef CONFIG_BLK_DEV_MD | 578 | #ifdef CONFIG_BLK_DEV_MD |
576 | if (state->parts[p].flags & ADDPART_FLAG_RAID) | 579 | if (state->parts[p].flags & ADDPART_FLAG_RAID) |
577 | md_autodetect_dev(bdev->bd_dev+p); | 580 | md_autodetect_dev(part_to_dev(part)->devt); |
578 | #endif | 581 | #endif |
579 | } | 582 | } |
580 | kfree(state); | 583 | kfree(state); |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 94fcfff6863a..06ed10b7da9e 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -31,6 +31,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, | |||
31 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 31 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
32 | inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ | 32 | inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ |
33 | inode->i_mode = table->mode; | 33 | inode->i_mode = table->mode; |
34 | inode->i_uid = inode->i_gid = 0; | ||
34 | if (!table->child) { | 35 | if (!table->child) { |
35 | inode->i_mode |= S_IFREG; | 36 | inode->i_mode |= S_IFREG; |
36 | inode->i_op = &proc_sys_inode_operations; | 37 | inode->i_op = &proc_sys_inode_operations; |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 54a279e44c9a..e9f6574930ef 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -380,6 +380,8 @@ struct acpi_bus_type { | |||
380 | int register_acpi_bus_type(struct acpi_bus_type *); | 380 | int register_acpi_bus_type(struct acpi_bus_type *); |
381 | int unregister_acpi_bus_type(struct acpi_bus_type *); | 381 | int unregister_acpi_bus_type(struct acpi_bus_type *); |
382 | struct device *acpi_get_physical_device(acpi_handle); | 382 | struct device *acpi_get_physical_device(acpi_handle); |
383 | struct device *acpi_get_physical_pci_device(acpi_handle); | ||
384 | |||
383 | /* helper */ | 385 | /* helper */ |
384 | acpi_handle acpi_get_child(acpi_handle, acpi_integer); | 386 | acpi_handle acpi_get_child(acpi_handle, acpi_integer); |
385 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); | 387 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); |
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index cf04c6011c2a..5fc1bb0f4a90 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h | |||
@@ -31,8 +31,24 @@ | |||
31 | 31 | ||
32 | #define ACPI_MAX_STRING 80 | 32 | #define ACPI_MAX_STRING 80 |
33 | 33 | ||
34 | /* | ||
35 | * Please update drivers/acpi/debug.c and Documentation/acpi/debug.txt | ||
36 | * if you add to this list. | ||
37 | */ | ||
34 | #define ACPI_BUS_COMPONENT 0x00010000 | 38 | #define ACPI_BUS_COMPONENT 0x00010000 |
39 | #define ACPI_AC_COMPONENT 0x00020000 | ||
40 | #define ACPI_BATTERY_COMPONENT 0x00040000 | ||
41 | #define ACPI_BUTTON_COMPONENT 0x00080000 | ||
42 | #define ACPI_SBS_COMPONENT 0x00100000 | ||
43 | #define ACPI_FAN_COMPONENT 0x00200000 | ||
44 | #define ACPI_PCI_COMPONENT 0x00400000 | ||
45 | #define ACPI_POWER_COMPONENT 0x00800000 | ||
46 | #define ACPI_CONTAINER_COMPONENT 0x01000000 | ||
35 | #define ACPI_SYSTEM_COMPONENT 0x02000000 | 47 | #define ACPI_SYSTEM_COMPONENT 0x02000000 |
48 | #define ACPI_THERMAL_COMPONENT 0x04000000 | ||
49 | #define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000 | ||
50 | #define ACPI_VIDEO_COMPONENT 0x10000000 | ||
51 | #define ACPI_PROCESSOR_COMPONENT 0x20000000 | ||
36 | 52 | ||
37 | /* | 53 | /* |
38 | * _HID definitions | 54 | * _HID definitions |
@@ -41,6 +57,7 @@ | |||
41 | */ | 57 | */ |
42 | 58 | ||
43 | #define ACPI_POWER_HID "LNXPOWER" | 59 | #define ACPI_POWER_HID "LNXPOWER" |
60 | #define ACPI_PROCESSOR_OBJECT_HID "ACPI_CPU" | ||
44 | #define ACPI_PROCESSOR_HID "ACPI0007" | 61 | #define ACPI_PROCESSOR_HID "ACPI0007" |
45 | #define ACPI_SYSTEM_HID "LNXSYSTM" | 62 | #define ACPI_SYSTEM_HID "LNXSYSTM" |
46 | #define ACPI_THERMAL_HID "LNXTHERM" | 63 | #define ACPI_THERMAL_HID "LNXTHERM" |
@@ -54,7 +71,6 @@ | |||
54 | PCI | 71 | PCI |
55 | -------------------------------------------------------------------------- */ | 72 | -------------------------------------------------------------------------- */ |
56 | 73 | ||
57 | #define ACPI_PCI_COMPONENT 0x00400000 | ||
58 | 74 | ||
59 | /* ACPI PCI Interrupt Link (pci_link.c) */ | 75 | /* ACPI PCI Interrupt Link (pci_link.c) */ |
60 | 76 | ||
@@ -86,7 +102,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_device *device, int domain, | |||
86 | Power Resource | 102 | Power Resource |
87 | -------------------------------------------------------------------------- */ | 103 | -------------------------------------------------------------------------- */ |
88 | 104 | ||
89 | #ifdef CONFIG_ACPI_POWER | ||
90 | int acpi_device_sleep_wake(struct acpi_device *dev, | 105 | int acpi_device_sleep_wake(struct acpi_device *dev, |
91 | int enable, int sleep_state, int dev_state); | 106 | int enable, int sleep_state, int dev_state); |
92 | int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state); | 107 | int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state); |
@@ -94,15 +109,12 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev); | |||
94 | int acpi_power_get_inferred_state(struct acpi_device *device); | 109 | int acpi_power_get_inferred_state(struct acpi_device *device); |
95 | int acpi_power_transition(struct acpi_device *device, int state); | 110 | int acpi_power_transition(struct acpi_device *device, int state); |
96 | extern int acpi_power_nocheck; | 111 | extern int acpi_power_nocheck; |
97 | #endif | ||
98 | 112 | ||
99 | /* -------------------------------------------------------------------------- | 113 | /* -------------------------------------------------------------------------- |
100 | Embedded Controller | 114 | Embedded Controller |
101 | -------------------------------------------------------------------------- */ | 115 | -------------------------------------------------------------------------- */ |
102 | #ifdef CONFIG_ACPI_EC | ||
103 | int acpi_ec_ecdt_probe(void); | 116 | int acpi_ec_ecdt_probe(void); |
104 | int acpi_boot_ec_enable(void); | 117 | int acpi_boot_ec_enable(void); |
105 | #endif | ||
106 | 118 | ||
107 | /* -------------------------------------------------------------------------- | 119 | /* -------------------------------------------------------------------------- |
108 | Processor | 120 | Processor |
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 94d94e126e9f..33bc0e3b1954 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h | |||
@@ -252,9 +252,9 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status); | |||
252 | 252 | ||
253 | acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type); | 253 | acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type); |
254 | 254 | ||
255 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags); | 255 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number); |
256 | 256 | ||
257 | acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags); | 257 | acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number); |
258 | 258 | ||
259 | acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags); | 259 | acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags); |
260 | 260 | ||
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index e8936ab59627..7220361790b3 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h | |||
@@ -525,6 +525,7 @@ typedef u32 acpi_event_status; | |||
525 | #define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 | 525 | #define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 |
526 | #define ACPI_EVENT_FLAG_WAKE_ENABLED (acpi_event_status) 0x02 | 526 | #define ACPI_EVENT_FLAG_WAKE_ENABLED (acpi_event_status) 0x02 |
527 | #define ACPI_EVENT_FLAG_SET (acpi_event_status) 0x04 | 527 | #define ACPI_EVENT_FLAG_SET (acpi_event_status) 0x04 |
528 | #define ACPI_EVENT_FLAG_HANDLE (acpi_event_status) 0x08 | ||
528 | 529 | ||
529 | /* | 530 | /* |
530 | * General Purpose Events (GPE) | 531 | * General Purpose Events (GPE) |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index fd6a452b0ceb..fba8051fb297 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -163,8 +163,6 @@ struct acpi_pci_driver { | |||
163 | int acpi_pci_register_driver(struct acpi_pci_driver *driver); | 163 | int acpi_pci_register_driver(struct acpi_pci_driver *driver); |
164 | void acpi_pci_unregister_driver(struct acpi_pci_driver *driver); | 164 | void acpi_pci_unregister_driver(struct acpi_pci_driver *driver); |
165 | 165 | ||
166 | #ifdef CONFIG_ACPI_EC | ||
167 | |||
168 | extern int ec_read(u8 addr, u8 *val); | 166 | extern int ec_read(u8 addr, u8 *val); |
169 | extern int ec_write(u8 addr, u8 val); | 167 | extern int ec_write(u8 addr, u8 val); |
170 | extern int ec_transaction(u8 command, | 168 | extern int ec_transaction(u8 command, |
@@ -172,8 +170,6 @@ extern int ec_transaction(u8 command, | |||
172 | u8 *rdata, unsigned rdata_len, | 170 | u8 *rdata, unsigned rdata_len, |
173 | int force_poll); | 171 | int force_poll); |
174 | 172 | ||
175 | #endif /*CONFIG_ACPI_EC*/ | ||
176 | |||
177 | #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE) | 173 | #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE) |
178 | 174 | ||
179 | typedef void (*wmi_notify_handler) (u32 value, void *context); | 175 | typedef void (*wmi_notify_handler) (u32 value, void *context); |
@@ -194,6 +190,50 @@ extern bool wmi_has_guid(const char *guid); | |||
194 | 190 | ||
195 | #endif /* CONFIG_ACPI_WMI */ | 191 | #endif /* CONFIG_ACPI_WMI */ |
196 | 192 | ||
193 | #define ACPI_VIDEO_OUTPUT_SWITCHING 0x0001 | ||
194 | #define ACPI_VIDEO_DEVICE_POSTING 0x0002 | ||
195 | #define ACPI_VIDEO_ROM_AVAILABLE 0x0004 | ||
196 | #define ACPI_VIDEO_BACKLIGHT 0x0008 | ||
197 | #define ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR 0x0010 | ||
198 | #define ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO 0x0020 | ||
199 | #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR 0x0040 | ||
200 | #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO 0x0080 | ||
201 | #define ACPI_VIDEO_BACKLIGHT_DMI_VENDOR 0x0100 | ||
202 | #define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO 0x0200 | ||
203 | #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400 | ||
204 | #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800 | ||
205 | |||
206 | #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) | ||
207 | |||
208 | extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle); | ||
209 | extern long acpi_is_video_device(struct acpi_device *device); | ||
210 | extern int acpi_video_backlight_support(void); | ||
211 | extern int acpi_video_display_switch_support(void); | ||
212 | |||
213 | #else | ||
214 | |||
215 | static inline long acpi_video_get_capabilities(acpi_handle graphics_dev_handle) | ||
216 | { | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static inline long acpi_is_video_device(struct acpi_device *device) | ||
221 | { | ||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | static inline int acpi_video_backlight_support(void) | ||
226 | { | ||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static inline int acpi_video_display_switch_support(void) | ||
231 | { | ||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | #endif /* defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) */ | ||
236 | |||
197 | extern int acpi_blacklisted(void); | 237 | extern int acpi_blacklisted(void); |
198 | #ifdef CONFIG_DMI | 238 | #ifdef CONFIG_DMI |
199 | extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); | 239 | extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); |
diff --git a/include/linux/c2port.h b/include/linux/c2port.h new file mode 100644 index 000000000000..7b5a2388ba67 --- /dev/null +++ b/include/linux/c2port.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Silicon Labs C2 port Linux support | ||
3 | * | ||
4 | * Copyright (c) 2007 Rodolfo Giometti <giometti@linux.it> | ||
5 | * Copyright (c) 2007 Eurotech S.p.A. <info@eurotech.it> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License version 2 as published by | ||
9 | * the Free Software Foundation | ||
10 | */ | ||
11 | |||
12 | #include <linux/device.h> | ||
13 | |||
14 | #define C2PORT_NAME_LEN 32 | ||
15 | |||
16 | /* | ||
17 | * C2 port basic structs | ||
18 | */ | ||
19 | |||
20 | /* Main struct */ | ||
21 | struct c2port_ops; | ||
22 | struct c2port_device { | ||
23 | unsigned int access:1; | ||
24 | unsigned int flash_access:1; | ||
25 | |||
26 | int id; | ||
27 | char name[C2PORT_NAME_LEN]; | ||
28 | struct c2port_ops *ops; | ||
29 | struct mutex mutex; /* prevent races during read/write */ | ||
30 | |||
31 | struct device *dev; | ||
32 | |||
33 | void *private_data; | ||
34 | }; | ||
35 | |||
36 | /* Basic operations */ | ||
37 | struct c2port_ops { | ||
38 | /* Flash layout */ | ||
39 | unsigned short block_size; /* flash block size in bytes */ | ||
40 | unsigned short blocks_num; /* flash blocks number */ | ||
41 | |||
42 | /* Enable or disable the access to C2 port */ | ||
43 | void (*access)(struct c2port_device *dev, int status); | ||
44 | |||
45 | /* Set C2D data line as input/output */ | ||
46 | void (*c2d_dir)(struct c2port_device *dev, int dir); | ||
47 | |||
48 | /* Read/write C2D data line */ | ||
49 | int (*c2d_get)(struct c2port_device *dev); | ||
50 | void (*c2d_set)(struct c2port_device *dev, int status); | ||
51 | |||
52 | /* Write C2CK clock line */ | ||
53 | void (*c2ck_set)(struct c2port_device *dev, int status); | ||
54 | }; | ||
55 | |||
56 | /* | ||
57 | * Exported functions | ||
58 | */ | ||
59 | |||
60 | #define to_class_dev(obj) container_of((obj), struct class_device, kobj) | ||
61 | #define to_c2port_device(obj) container_of((obj), struct c2port_device, class) | ||
62 | |||
63 | extern struct c2port_device *c2port_device_register(char *name, | ||
64 | struct c2port_ops *ops, void *devdata); | ||
65 | extern void c2port_device_unregister(struct c2port_device *dev); | ||
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index e439e6aed832..3df7742ce246 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -522,7 +522,9 @@ extern char *disk_name (struct gendisk *hd, int partno, char *buf); | |||
522 | 522 | ||
523 | extern int disk_expand_part_tbl(struct gendisk *disk, int target); | 523 | extern int disk_expand_part_tbl(struct gendisk *disk, int target); |
524 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | 524 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
525 | extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int); | 525 | extern struct hd_struct * __must_check add_partition(struct gendisk *disk, |
526 | int partno, sector_t start, | ||
527 | sector_t len, int flags); | ||
526 | extern void delete_partition(struct gendisk *, int); | 528 | extern void delete_partition(struct gendisk *, int); |
527 | extern void printk_all_partitions(void); | 529 | extern void printk_all_partitions(void); |
528 | 530 | ||
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 07e510a3b00a..3eba43878dcb 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
@@ -46,9 +46,6 @@ enum hrtimer_restart { | |||
46 | * hrtimer callback modes: | 46 | * hrtimer callback modes: |
47 | * | 47 | * |
48 | * HRTIMER_CB_SOFTIRQ: Callback must run in softirq context | 48 | * HRTIMER_CB_SOFTIRQ: Callback must run in softirq context |
49 | * HRTIMER_CB_IRQSAFE: Callback may run in hardirq context | ||
50 | * HRTIMER_CB_IRQSAFE_NO_RESTART: Callback may run in hardirq context and | ||
51 | * does not restart the timer | ||
52 | * HRTIMER_CB_IRQSAFE_PERCPU: Callback must run in hardirq context | 49 | * HRTIMER_CB_IRQSAFE_PERCPU: Callback must run in hardirq context |
53 | * Special mode for tick emulation and | 50 | * Special mode for tick emulation and |
54 | * scheduler timer. Such timers are per | 51 | * scheduler timer. Such timers are per |
@@ -61,8 +58,6 @@ enum hrtimer_restart { | |||
61 | */ | 58 | */ |
62 | enum hrtimer_cb_mode { | 59 | enum hrtimer_cb_mode { |
63 | HRTIMER_CB_SOFTIRQ, | 60 | HRTIMER_CB_SOFTIRQ, |
64 | HRTIMER_CB_IRQSAFE, | ||
65 | HRTIMER_CB_IRQSAFE_NO_RESTART, | ||
66 | HRTIMER_CB_IRQSAFE_PERCPU, | 61 | HRTIMER_CB_IRQSAFE_PERCPU, |
67 | HRTIMER_CB_IRQSAFE_UNLOCKED, | 62 | HRTIMER_CB_IRQSAFE_UNLOCKED, |
68 | }; | 63 | }; |
diff --git a/include/linux/inotify.h b/include/linux/inotify.h index bd578578a8b9..37ea2894b3c0 100644 --- a/include/linux/inotify.h +++ b/include/linux/inotify.h | |||
@@ -134,6 +134,8 @@ extern void inotify_remove_watch_locked(struct inotify_handle *, | |||
134 | struct inotify_watch *); | 134 | struct inotify_watch *); |
135 | extern void get_inotify_watch(struct inotify_watch *); | 135 | extern void get_inotify_watch(struct inotify_watch *); |
136 | extern void put_inotify_watch(struct inotify_watch *); | 136 | extern void put_inotify_watch(struct inotify_watch *); |
137 | extern int pin_inotify_watch(struct inotify_watch *); | ||
138 | extern void unpin_inotify_watch(struct inotify_watch *); | ||
137 | 139 | ||
138 | #else | 140 | #else |
139 | 141 | ||
@@ -228,6 +230,15 @@ static inline void put_inotify_watch(struct inotify_watch *watch) | |||
228 | { | 230 | { |
229 | } | 231 | } |
230 | 232 | ||
233 | extern inline int pin_inotify_watch(struct inotify_watch *watch) | ||
234 | { | ||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | extern inline void unpin_inotify_watch(struct inotify_watch *watch) | ||
239 | { | ||
240 | } | ||
241 | |||
231 | #endif /* CONFIG_INOTIFY */ | 242 | #endif /* CONFIG_INOTIFY */ |
232 | 243 | ||
233 | #endif /* __KERNEL __ */ | 244 | #endif /* __KERNEL __ */ |
diff --git a/include/linux/input.h b/include/linux/input.h index b86fb5581ce6..5341e8251f8c 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -238,6 +238,7 @@ struct input_absinfo { | |||
238 | #define KEY_KPEQUAL 117 | 238 | #define KEY_KPEQUAL 117 |
239 | #define KEY_KPPLUSMINUS 118 | 239 | #define KEY_KPPLUSMINUS 118 |
240 | #define KEY_PAUSE 119 | 240 | #define KEY_PAUSE 119 |
241 | #define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ | ||
241 | 242 | ||
242 | #define KEY_KPCOMMA 121 | 243 | #define KEY_KPCOMMA 121 |
243 | #define KEY_HANGEUL 122 | 244 | #define KEY_HANGEUL 122 |
@@ -322,6 +323,7 @@ struct input_absinfo { | |||
322 | #define KEY_PAUSECD 201 | 323 | #define KEY_PAUSECD 201 |
323 | #define KEY_PROG3 202 | 324 | #define KEY_PROG3 202 |
324 | #define KEY_PROG4 203 | 325 | #define KEY_PROG4 203 |
326 | #define KEY_DASHBOARD 204 /* AL Dashboard */ | ||
325 | #define KEY_SUSPEND 205 | 327 | #define KEY_SUSPEND 205 |
326 | #define KEY_CLOSE 206 /* AC Close */ | 328 | #define KEY_CLOSE 206 /* AC Close */ |
327 | #define KEY_PLAY 207 | 329 | #define KEY_PLAY 207 |
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index fba141d3ca07..dc7e0d0a6474 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -318,32 +318,36 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
318 | return buf; | 318 | return buf; |
319 | } | 319 | } |
320 | 320 | ||
321 | #define pr_emerg(fmt, arg...) \ | 321 | #ifndef pr_fmt |
322 | printk(KERN_EMERG fmt, ##arg) | 322 | #define pr_fmt(fmt) fmt |
323 | #define pr_alert(fmt, arg...) \ | 323 | #endif |
324 | printk(KERN_ALERT fmt, ##arg) | 324 | |
325 | #define pr_crit(fmt, arg...) \ | 325 | #define pr_emerg(fmt, ...) \ |
326 | printk(KERN_CRIT fmt, ##arg) | 326 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
327 | #define pr_err(fmt, arg...) \ | 327 | #define pr_alert(fmt, ...) \ |
328 | printk(KERN_ERR fmt, ##arg) | 328 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
329 | #define pr_warning(fmt, arg...) \ | 329 | #define pr_crit(fmt, ...) \ |
330 | printk(KERN_WARNING fmt, ##arg) | 330 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
331 | #define pr_notice(fmt, arg...) \ | 331 | #define pr_err(fmt, ...) \ |
332 | printk(KERN_NOTICE fmt, ##arg) | 332 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
333 | #define pr_info(fmt, arg...) \ | 333 | #define pr_warning(fmt, ...) \ |
334 | printk(KERN_INFO fmt, ##arg) | 334 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
335 | #define pr_notice(fmt, ...) \ | ||
336 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
337 | #define pr_info(fmt, ...) \ | ||
338 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
335 | 339 | ||
336 | /* If you are writing a driver, please use dev_dbg instead */ | 340 | /* If you are writing a driver, please use dev_dbg instead */ |
337 | #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) | 341 | #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) |
338 | #define pr_debug(fmt, ...) do { \ | 342 | #define pr_debug(fmt, ...) do { \ |
339 | dynamic_pr_debug(fmt, ##__VA_ARGS__); \ | 343 | dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ |
340 | } while (0) | 344 | } while (0) |
341 | #elif defined(DEBUG) | 345 | #elif defined(DEBUG) |
342 | #define pr_debug(fmt, arg...) \ | 346 | #define pr_debug(fmt, ...) \ |
343 | printk(KERN_DEBUG fmt, ##arg) | 347 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
344 | #else | 348 | #else |
345 | #define pr_debug(fmt, arg...) \ | 349 | #define pr_debug(fmt, ...) \ |
346 | ({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; }) | 350 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) |
347 | #endif | 351 | #endif |
348 | 352 | ||
349 | /* | 353 | /* |
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 331e5f1c2d8e..29aec6e10020 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h | |||
@@ -331,10 +331,11 @@ static inline void lockdep_on(void) | |||
331 | # define lock_set_subclass(l, s, i) do { } while (0) | 331 | # define lock_set_subclass(l, s, i) do { } while (0) |
332 | # define lockdep_init() do { } while (0) | 332 | # define lockdep_init() do { } while (0) |
333 | # define lockdep_info() do { } while (0) | 333 | # define lockdep_info() do { } while (0) |
334 | # define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0) | 334 | # define lockdep_init_map(lock, name, key, sub) \ |
335 | do { (void)(name); (void)(key); } while (0) | ||
335 | # define lockdep_set_class(lock, key) do { (void)(key); } while (0) | 336 | # define lockdep_set_class(lock, key) do { (void)(key); } while (0) |
336 | # define lockdep_set_class_and_name(lock, key, name) \ | 337 | # define lockdep_set_class_and_name(lock, key, name) \ |
337 | do { (void)(key); } while (0) | 338 | do { (void)(key); (void)(name); } while (0) |
338 | #define lockdep_set_class_and_subclass(lock, key, sub) \ | 339 | #define lockdep_set_class_and_subclass(lock, key, sub) \ |
339 | do { (void)(key); } while (0) | 340 | do { (void)(key); } while (0) |
340 | #define lockdep_set_subclass(lock, sub) do { } while (0) | 341 | #define lockdep_set_subclass(lock, sub) do { } while (0) |
diff --git a/include/linux/mfd/wm8350/rtc.h b/include/linux/mfd/wm8350/rtc.h index dfda69e9f440..24add2bef6c9 100644 --- a/include/linux/mfd/wm8350/rtc.h +++ b/include/linux/mfd/wm8350/rtc.h | |||
@@ -261,6 +261,8 @@ | |||
261 | 261 | ||
262 | struct wm8350_rtc { | 262 | struct wm8350_rtc { |
263 | struct platform_device *pdev; | 263 | struct platform_device *pdev; |
264 | struct rtc_device *rtc; | ||
265 | int alarm_enabled; /* used over suspend/resume */ | ||
264 | }; | 266 | }; |
265 | 267 | ||
266 | #endif | 268 | #endif |
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h index 18a5b9ba9d40..00044b856453 100644 --- a/include/linux/ratelimit.h +++ b/include/linux/ratelimit.h | |||
@@ -17,11 +17,4 @@ struct ratelimit_state { | |||
17 | struct ratelimit_state name = {interval, burst,} | 17 | struct ratelimit_state name = {interval, burst,} |
18 | 18 | ||
19 | extern int __ratelimit(struct ratelimit_state *rs); | 19 | extern int __ratelimit(struct ratelimit_state *rs); |
20 | |||
21 | static inline int ratelimit(void) | ||
22 | { | ||
23 | static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, | ||
24 | DEFAULT_RATELIMIT_BURST); | ||
25 | return __ratelimit(&rs); | ||
26 | } | ||
27 | #endif | 20 | #endif |
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index e27f216361fc..4e4f1277f3bf 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h | |||
@@ -155,6 +155,9 @@ | |||
155 | 155 | ||
156 | #define PORT_SC26XX 82 | 156 | #define PORT_SC26XX 82 |
157 | 157 | ||
158 | /* SH-SCI */ | ||
159 | #define PORT_SCIFA 83 | ||
160 | |||
158 | #ifdef __KERNEL__ | 161 | #ifdef __KERNEL__ |
159 | 162 | ||
160 | #include <linux/compiler.h> | 163 | #include <linux/compiler.h> |
diff --git a/include/linux/slab.h b/include/linux/slab.h index ba965c84ae06..000da12b5cf0 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -23,6 +23,34 @@ | |||
23 | #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ | 23 | #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ |
24 | #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ | 24 | #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ |
25 | #define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ | 25 | #define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ |
26 | /* | ||
27 | * SLAB_DESTROY_BY_RCU - **WARNING** READ THIS! | ||
28 | * | ||
29 | * This delays freeing the SLAB page by a grace period, it does _NOT_ | ||
30 | * delay object freeing. This means that if you do kmem_cache_free() | ||
31 | * that memory location is free to be reused at any time. Thus it may | ||
32 | * be possible to see another object there in the same RCU grace period. | ||
33 | * | ||
34 | * This feature only ensures the memory location backing the object | ||
35 | * stays valid, the trick to using this is relying on an independent | ||
36 | * object validation pass. Something like: | ||
37 | * | ||
38 | * rcu_read_lock() | ||
39 | * again: | ||
40 | * obj = lockless_lookup(key); | ||
41 | * if (obj) { | ||
42 | * if (!try_get_ref(obj)) // might fail for free objects | ||
43 | * goto again; | ||
44 | * | ||
45 | * if (obj->key != key) { // not the object we expected | ||
46 | * put_ref(obj); | ||
47 | * goto again; | ||
48 | * } | ||
49 | * } | ||
50 | * rcu_read_unlock(); | ||
51 | * | ||
52 | * See also the comment on struct slab_rcu in mm/slab.c. | ||
53 | */ | ||
26 | #define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ | 54 | #define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ |
27 | #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ | 55 | #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ |
28 | #define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ | 56 | #define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 8fa973bede5e..f72aa51f7bcd 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -108,6 +108,7 @@ enum usb_interface_condition { | |||
108 | * (in probe()), bound to a driver, or unbinding (in disconnect()) | 108 | * (in probe()), bound to a driver, or unbinding (in disconnect()) |
109 | * @is_active: flag set when the interface is bound and not suspended. | 109 | * @is_active: flag set when the interface is bound and not suspended. |
110 | * @sysfs_files_created: sysfs attributes exist | 110 | * @sysfs_files_created: sysfs attributes exist |
111 | * @unregistering: flag set when the interface is being unregistered | ||
111 | * @needs_remote_wakeup: flag set when the driver requires remote-wakeup | 112 | * @needs_remote_wakeup: flag set when the driver requires remote-wakeup |
112 | * capability during autosuspend. | 113 | * capability during autosuspend. |
113 | * @needs_altsetting0: flag set when a set-interface request for altsetting 0 | 114 | * @needs_altsetting0: flag set when a set-interface request for altsetting 0 |
@@ -163,6 +164,7 @@ struct usb_interface { | |||
163 | enum usb_interface_condition condition; /* state of binding */ | 164 | enum usb_interface_condition condition; /* state of binding */ |
164 | unsigned is_active:1; /* the interface is not suspended */ | 165 | unsigned is_active:1; /* the interface is not suspended */ |
165 | unsigned sysfs_files_created:1; /* the sysfs attributes exist */ | 166 | unsigned sysfs_files_created:1; /* the sysfs attributes exist */ |
167 | unsigned unregistering:1; /* unregistration is in progress */ | ||
166 | unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ | 168 | unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ |
167 | unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ | 169 | unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ |
168 | unsigned needs_binding:1; /* needs delayed unbind/rebind */ | 170 | unsigned needs_binding:1; /* needs delayed unbind/rebind */ |
diff --git a/include/net/sock.h b/include/net/sock.h index c04f9e18ea22..2f47107f6d0f 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -815,7 +815,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb) | |||
815 | */ | 815 | */ |
816 | #define sock_lock_init_class_and_name(sk, sname, skey, name, key) \ | 816 | #define sock_lock_init_class_and_name(sk, sname, skey, name, key) \ |
817 | do { \ | 817 | do { \ |
818 | sk->sk_lock.owned = 0; \ | 818 | sk->sk_lock.owned = 0; \ |
819 | init_waitqueue_head(&sk->sk_lock.wq); \ | 819 | init_waitqueue_head(&sk->sk_lock.wq); \ |
820 | spin_lock_init(&(sk)->sk_lock.slock); \ | 820 | spin_lock_init(&(sk)->sk_lock.slock); \ |
821 | debug_check_no_locks_freed((void *)&(sk)->sk_lock, \ | 821 | debug_check_no_locks_freed((void *)&(sk)->sk_lock, \ |
diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h index 6ad87f485992..0c864db1a466 100644 --- a/include/video/atmel_lcdc.h +++ b/include/video/atmel_lcdc.h | |||
@@ -38,7 +38,7 @@ struct atmel_lcdfb_info { | |||
38 | spinlock_t lock; | 38 | spinlock_t lock; |
39 | struct fb_info *info; | 39 | struct fb_info *info; |
40 | void __iomem *mmio; | 40 | void __iomem *mmio; |
41 | unsigned long irq_base; | 41 | int irq_base; |
42 | struct work_struct task; | 42 | struct work_struct task; |
43 | 43 | ||
44 | unsigned int guard_time; | 44 | unsigned int guard_time; |
diff --git a/init/Kconfig b/init/Kconfig index f5bacb438711..f291f086caa1 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -354,7 +354,7 @@ config RT_GROUP_SCHED | |||
354 | setting below. If enabled, it will also make it impossible to | 354 | setting below. If enabled, it will also make it impossible to |
355 | schedule realtime tasks for non-root users until you allocate | 355 | schedule realtime tasks for non-root users until you allocate |
356 | realtime bandwidth for them. | 356 | realtime bandwidth for them. |
357 | See Documentation/sched-rt-group.txt for more information. | 357 | See Documentation/scheduler/sched-rt-group.txt for more information. |
358 | 358 | ||
359 | choice | 359 | choice |
360 | depends on GROUP_SCHED | 360 | depends on GROUP_SCHED |
@@ -771,8 +771,7 @@ config SLAB | |||
771 | help | 771 | help |
772 | The regular slab allocator that is established and known to work | 772 | The regular slab allocator that is established and known to work |
773 | well in all environments. It organizes cache hot objects in | 773 | well in all environments. It organizes cache hot objects in |
774 | per cpu and per node queues. SLAB is the default choice for | 774 | per cpu and per node queues. |
775 | a slab allocator. | ||
776 | 775 | ||
777 | config SLUB | 776 | config SLUB |
778 | bool "SLUB (Unqueued Allocator)" | 777 | bool "SLUB (Unqueued Allocator)" |
@@ -781,7 +780,8 @@ config SLUB | |||
781 | instead of managing queues of cached objects (SLAB approach). | 780 | instead of managing queues of cached objects (SLAB approach). |
782 | Per cpu caching is realized using slabs of objects instead | 781 | Per cpu caching is realized using slabs of objects instead |
783 | of queues of objects. SLUB can use memory efficiently | 782 | of queues of objects. SLUB can use memory efficiently |
784 | and has enhanced diagnostics. | 783 | and has enhanced diagnostics. SLUB is the default choice for |
784 | a slab allocator. | ||
785 | 785 | ||
786 | config SLOB | 786 | config SLOB |
787 | depends on EMBEDDED | 787 | depends on EMBEDDED |
diff --git a/kernel/Makefile b/kernel/Makefile index af3be57acbbb..03a45e7e87b7 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -11,8 +11,6 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ | |||
11 | hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ | 11 | hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ |
12 | notifier.o ksysfs.o pm_qos_params.o sched_clock.o | 12 | notifier.o ksysfs.o pm_qos_params.o sched_clock.o |
13 | 13 | ||
14 | CFLAGS_REMOVE_sched.o = -mno-spe | ||
15 | |||
16 | ifdef CONFIG_FUNCTION_TRACER | 14 | ifdef CONFIG_FUNCTION_TRACER |
17 | # Do not trace debug files and internal ftrace files | 15 | # Do not trace debug files and internal ftrace files |
18 | CFLAGS_REMOVE_lockdep.o = -pg | 16 | CFLAGS_REMOVE_lockdep.o = -pg |
@@ -21,7 +19,7 @@ CFLAGS_REMOVE_mutex-debug.o = -pg | |||
21 | CFLAGS_REMOVE_rtmutex-debug.o = -pg | 19 | CFLAGS_REMOVE_rtmutex-debug.o = -pg |
22 | CFLAGS_REMOVE_cgroup-debug.o = -pg | 20 | CFLAGS_REMOVE_cgroup-debug.o = -pg |
23 | CFLAGS_REMOVE_sched_clock.o = -pg | 21 | CFLAGS_REMOVE_sched_clock.o = -pg |
24 | CFLAGS_REMOVE_sched.o = -mno-spe -pg | 22 | CFLAGS_REMOVE_sched.o = -pg |
25 | endif | 23 | endif |
26 | ifdef CONFIG_FUNCTION_RET_TRACER | 24 | ifdef CONFIG_FUNCTION_RET_TRACER |
27 | CFLAGS_REMOVE_extable.o = -pg # For __kernel_text_address() | 25 | CFLAGS_REMOVE_extable.o = -pg # For __kernel_text_address() |
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index 8ba0e0d934f2..8b509441f49a 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c | |||
@@ -24,6 +24,7 @@ struct audit_chunk { | |||
24 | struct list_head trees; /* with root here */ | 24 | struct list_head trees; /* with root here */ |
25 | int dead; | 25 | int dead; |
26 | int count; | 26 | int count; |
27 | atomic_long_t refs; | ||
27 | struct rcu_head head; | 28 | struct rcu_head head; |
28 | struct node { | 29 | struct node { |
29 | struct list_head list; | 30 | struct list_head list; |
@@ -56,7 +57,8 @@ static LIST_HEAD(prune_list); | |||
56 | * tree is refcounted; one reference for "some rules on rules_list refer to | 57 | * tree is refcounted; one reference for "some rules on rules_list refer to |
57 | * it", one for each chunk with pointer to it. | 58 | * it", one for each chunk with pointer to it. |
58 | * | 59 | * |
59 | * chunk is refcounted by embedded inotify_watch. | 60 | * chunk is refcounted by embedded inotify_watch + .refs (non-zero refcount |
61 | * of watch contributes 1 to .refs). | ||
60 | * | 62 | * |
61 | * node.index allows to get from node.list to containing chunk. | 63 | * node.index allows to get from node.list to containing chunk. |
62 | * MSB of that sucker is stolen to mark taggings that we might have to | 64 | * MSB of that sucker is stolen to mark taggings that we might have to |
@@ -121,6 +123,7 @@ static struct audit_chunk *alloc_chunk(int count) | |||
121 | INIT_LIST_HEAD(&chunk->hash); | 123 | INIT_LIST_HEAD(&chunk->hash); |
122 | INIT_LIST_HEAD(&chunk->trees); | 124 | INIT_LIST_HEAD(&chunk->trees); |
123 | chunk->count = count; | 125 | chunk->count = count; |
126 | atomic_long_set(&chunk->refs, 1); | ||
124 | for (i = 0; i < count; i++) { | 127 | for (i = 0; i < count; i++) { |
125 | INIT_LIST_HEAD(&chunk->owners[i].list); | 128 | INIT_LIST_HEAD(&chunk->owners[i].list); |
126 | chunk->owners[i].index = i; | 129 | chunk->owners[i].index = i; |
@@ -129,9 +132,8 @@ static struct audit_chunk *alloc_chunk(int count) | |||
129 | return chunk; | 132 | return chunk; |
130 | } | 133 | } |
131 | 134 | ||
132 | static void __free_chunk(struct rcu_head *rcu) | 135 | static void free_chunk(struct audit_chunk *chunk) |
133 | { | 136 | { |
134 | struct audit_chunk *chunk = container_of(rcu, struct audit_chunk, head); | ||
135 | int i; | 137 | int i; |
136 | 138 | ||
137 | for (i = 0; i < chunk->count; i++) { | 139 | for (i = 0; i < chunk->count; i++) { |
@@ -141,14 +143,16 @@ static void __free_chunk(struct rcu_head *rcu) | |||
141 | kfree(chunk); | 143 | kfree(chunk); |
142 | } | 144 | } |
143 | 145 | ||
144 | static inline void free_chunk(struct audit_chunk *chunk) | 146 | void audit_put_chunk(struct audit_chunk *chunk) |
145 | { | 147 | { |
146 | call_rcu(&chunk->head, __free_chunk); | 148 | if (atomic_long_dec_and_test(&chunk->refs)) |
149 | free_chunk(chunk); | ||
147 | } | 150 | } |
148 | 151 | ||
149 | void audit_put_chunk(struct audit_chunk *chunk) | 152 | static void __put_chunk(struct rcu_head *rcu) |
150 | { | 153 | { |
151 | put_inotify_watch(&chunk->watch); | 154 | struct audit_chunk *chunk = container_of(rcu, struct audit_chunk, head); |
155 | audit_put_chunk(chunk); | ||
152 | } | 156 | } |
153 | 157 | ||
154 | enum {HASH_SIZE = 128}; | 158 | enum {HASH_SIZE = 128}; |
@@ -176,7 +180,7 @@ struct audit_chunk *audit_tree_lookup(const struct inode *inode) | |||
176 | 180 | ||
177 | list_for_each_entry_rcu(p, list, hash) { | 181 | list_for_each_entry_rcu(p, list, hash) { |
178 | if (p->watch.inode == inode) { | 182 | if (p->watch.inode == inode) { |
179 | get_inotify_watch(&p->watch); | 183 | atomic_long_inc(&p->refs); |
180 | return p; | 184 | return p; |
181 | } | 185 | } |
182 | } | 186 | } |
@@ -194,17 +198,49 @@ int audit_tree_match(struct audit_chunk *chunk, struct audit_tree *tree) | |||
194 | 198 | ||
195 | /* tagging and untagging inodes with trees */ | 199 | /* tagging and untagging inodes with trees */ |
196 | 200 | ||
197 | static void untag_chunk(struct audit_chunk *chunk, struct node *p) | 201 | static struct audit_chunk *find_chunk(struct node *p) |
202 | { | ||
203 | int index = p->index & ~(1U<<31); | ||
204 | p -= index; | ||
205 | return container_of(p, struct audit_chunk, owners[0]); | ||
206 | } | ||
207 | |||
208 | static void untag_chunk(struct node *p) | ||
198 | { | 209 | { |
210 | struct audit_chunk *chunk = find_chunk(p); | ||
199 | struct audit_chunk *new; | 211 | struct audit_chunk *new; |
200 | struct audit_tree *owner; | 212 | struct audit_tree *owner; |
201 | int size = chunk->count - 1; | 213 | int size = chunk->count - 1; |
202 | int i, j; | 214 | int i, j; |
203 | 215 | ||
216 | if (!pin_inotify_watch(&chunk->watch)) { | ||
217 | /* | ||
218 | * Filesystem is shutting down; all watches are getting | ||
219 | * evicted, just take it off the node list for this | ||
220 | * tree and let the eviction logics take care of the | ||
221 | * rest. | ||
222 | */ | ||
223 | owner = p->owner; | ||
224 | if (owner->root == chunk) { | ||
225 | list_del_init(&owner->same_root); | ||
226 | owner->root = NULL; | ||
227 | } | ||
228 | list_del_init(&p->list); | ||
229 | p->owner = NULL; | ||
230 | put_tree(owner); | ||
231 | return; | ||
232 | } | ||
233 | |||
234 | spin_unlock(&hash_lock); | ||
235 | |||
236 | /* | ||
237 | * pin_inotify_watch() succeeded, so the watch won't go away | ||
238 | * from under us. | ||
239 | */ | ||
204 | mutex_lock(&chunk->watch.inode->inotify_mutex); | 240 | mutex_lock(&chunk->watch.inode->inotify_mutex); |
205 | if (chunk->dead) { | 241 | if (chunk->dead) { |
206 | mutex_unlock(&chunk->watch.inode->inotify_mutex); | 242 | mutex_unlock(&chunk->watch.inode->inotify_mutex); |
207 | return; | 243 | goto out; |
208 | } | 244 | } |
209 | 245 | ||
210 | owner = p->owner; | 246 | owner = p->owner; |
@@ -221,7 +257,7 @@ static void untag_chunk(struct audit_chunk *chunk, struct node *p) | |||
221 | inotify_evict_watch(&chunk->watch); | 257 | inotify_evict_watch(&chunk->watch); |
222 | mutex_unlock(&chunk->watch.inode->inotify_mutex); | 258 | mutex_unlock(&chunk->watch.inode->inotify_mutex); |
223 | put_inotify_watch(&chunk->watch); | 259 | put_inotify_watch(&chunk->watch); |
224 | return; | 260 | goto out; |
225 | } | 261 | } |
226 | 262 | ||
227 | new = alloc_chunk(size); | 263 | new = alloc_chunk(size); |
@@ -263,7 +299,7 @@ static void untag_chunk(struct audit_chunk *chunk, struct node *p) | |||
263 | inotify_evict_watch(&chunk->watch); | 299 | inotify_evict_watch(&chunk->watch); |
264 | mutex_unlock(&chunk->watch.inode->inotify_mutex); | 300 | mutex_unlock(&chunk->watch.inode->inotify_mutex); |
265 | put_inotify_watch(&chunk->watch); | 301 | put_inotify_watch(&chunk->watch); |
266 | return; | 302 | goto out; |
267 | 303 | ||
268 | Fallback: | 304 | Fallback: |
269 | // do the best we can | 305 | // do the best we can |
@@ -277,6 +313,9 @@ Fallback: | |||
277 | put_tree(owner); | 313 | put_tree(owner); |
278 | spin_unlock(&hash_lock); | 314 | spin_unlock(&hash_lock); |
279 | mutex_unlock(&chunk->watch.inode->inotify_mutex); | 315 | mutex_unlock(&chunk->watch.inode->inotify_mutex); |
316 | out: | ||
317 | unpin_inotify_watch(&chunk->watch); | ||
318 | spin_lock(&hash_lock); | ||
280 | } | 319 | } |
281 | 320 | ||
282 | static int create_chunk(struct inode *inode, struct audit_tree *tree) | 321 | static int create_chunk(struct inode *inode, struct audit_tree *tree) |
@@ -387,13 +426,6 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) | |||
387 | return 0; | 426 | return 0; |
388 | } | 427 | } |
389 | 428 | ||
390 | static struct audit_chunk *find_chunk(struct node *p) | ||
391 | { | ||
392 | int index = p->index & ~(1U<<31); | ||
393 | p -= index; | ||
394 | return container_of(p, struct audit_chunk, owners[0]); | ||
395 | } | ||
396 | |||
397 | static void kill_rules(struct audit_tree *tree) | 429 | static void kill_rules(struct audit_tree *tree) |
398 | { | 430 | { |
399 | struct audit_krule *rule, *next; | 431 | struct audit_krule *rule, *next; |
@@ -431,17 +463,10 @@ static void prune_one(struct audit_tree *victim) | |||
431 | spin_lock(&hash_lock); | 463 | spin_lock(&hash_lock); |
432 | while (!list_empty(&victim->chunks)) { | 464 | while (!list_empty(&victim->chunks)) { |
433 | struct node *p; | 465 | struct node *p; |
434 | struct audit_chunk *chunk; | ||
435 | 466 | ||
436 | p = list_entry(victim->chunks.next, struct node, list); | 467 | p = list_entry(victim->chunks.next, struct node, list); |
437 | chunk = find_chunk(p); | ||
438 | get_inotify_watch(&chunk->watch); | ||
439 | spin_unlock(&hash_lock); | ||
440 | |||
441 | untag_chunk(chunk, p); | ||
442 | 468 | ||
443 | put_inotify_watch(&chunk->watch); | 469 | untag_chunk(p); |
444 | spin_lock(&hash_lock); | ||
445 | } | 470 | } |
446 | spin_unlock(&hash_lock); | 471 | spin_unlock(&hash_lock); |
447 | put_tree(victim); | 472 | put_tree(victim); |
@@ -469,7 +494,6 @@ static void trim_marked(struct audit_tree *tree) | |||
469 | 494 | ||
470 | while (!list_empty(&tree->chunks)) { | 495 | while (!list_empty(&tree->chunks)) { |
471 | struct node *node; | 496 | struct node *node; |
472 | struct audit_chunk *chunk; | ||
473 | 497 | ||
474 | node = list_entry(tree->chunks.next, struct node, list); | 498 | node = list_entry(tree->chunks.next, struct node, list); |
475 | 499 | ||
@@ -477,14 +501,7 @@ static void trim_marked(struct audit_tree *tree) | |||
477 | if (!(node->index & (1U<<31))) | 501 | if (!(node->index & (1U<<31))) |
478 | break; | 502 | break; |
479 | 503 | ||
480 | chunk = find_chunk(node); | 504 | untag_chunk(node); |
481 | get_inotify_watch(&chunk->watch); | ||
482 | spin_unlock(&hash_lock); | ||
483 | |||
484 | untag_chunk(chunk, node); | ||
485 | |||
486 | put_inotify_watch(&chunk->watch); | ||
487 | spin_lock(&hash_lock); | ||
488 | } | 505 | } |
489 | if (!tree->root && !tree->goner) { | 506 | if (!tree->root && !tree->goner) { |
490 | tree->goner = 1; | 507 | tree->goner = 1; |
@@ -878,7 +895,7 @@ static void handle_event(struct inotify_watch *watch, u32 wd, u32 mask, | |||
878 | static void destroy_watch(struct inotify_watch *watch) | 895 | static void destroy_watch(struct inotify_watch *watch) |
879 | { | 896 | { |
880 | struct audit_chunk *chunk = container_of(watch, struct audit_chunk, watch); | 897 | struct audit_chunk *chunk = container_of(watch, struct audit_chunk, watch); |
881 | free_chunk(chunk); | 898 | call_rcu(&chunk->head, __put_chunk); |
882 | } | 899 | } |
883 | 900 | ||
884 | static const struct inotify_operations rtree_inotify_ops = { | 901 | static const struct inotify_operations rtree_inotify_ops = { |
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index b7d354e2b0ef..9fd85a4640a0 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -1094,8 +1094,8 @@ static void audit_inotify_unregister(struct list_head *in_list) | |||
1094 | list_for_each_entry_safe(p, n, in_list, ilist) { | 1094 | list_for_each_entry_safe(p, n, in_list, ilist) { |
1095 | list_del(&p->ilist); | 1095 | list_del(&p->ilist); |
1096 | inotify_rm_watch(audit_ih, &p->wdata); | 1096 | inotify_rm_watch(audit_ih, &p->wdata); |
1097 | /* the put matching the get in audit_do_del_rule() */ | 1097 | /* the unpin matching the pin in audit_do_del_rule() */ |
1098 | put_inotify_watch(&p->wdata); | 1098 | unpin_inotify_watch(&p->wdata); |
1099 | } | 1099 | } |
1100 | } | 1100 | } |
1101 | 1101 | ||
@@ -1389,9 +1389,13 @@ static inline int audit_del_rule(struct audit_entry *entry, | |||
1389 | /* Put parent on the inotify un-registration | 1389 | /* Put parent on the inotify un-registration |
1390 | * list. Grab a reference before releasing | 1390 | * list. Grab a reference before releasing |
1391 | * audit_filter_mutex, to be released in | 1391 | * audit_filter_mutex, to be released in |
1392 | * audit_inotify_unregister(). */ | 1392 | * audit_inotify_unregister(). |
1393 | list_add(&parent->ilist, &inotify_list); | 1393 | * If filesystem is going away, just leave |
1394 | get_inotify_watch(&parent->wdata); | 1394 | * the sucker alone, eviction will take |
1395 | * care of it. | ||
1396 | */ | ||
1397 | if (pin_inotify_watch(&parent->wdata)) | ||
1398 | list_add(&parent->ilist, &inotify_list); | ||
1395 | } | 1399 | } |
1396 | } | 1400 | } |
1397 | } | 1401 | } |
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index 7fa476f01d05..fb249e2bcada 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c | |||
@@ -184,9 +184,20 @@ static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task) | |||
184 | { | 184 | { |
185 | struct freezer *freezer; | 185 | struct freezer *freezer; |
186 | 186 | ||
187 | task_lock(task); | 187 | /* |
188 | * No lock is needed, since the task isn't on tasklist yet, | ||
189 | * so it can't be moved to another cgroup, which means the | ||
190 | * freezer won't be removed and will be valid during this | ||
191 | * function call. | ||
192 | */ | ||
188 | freezer = task_freezer(task); | 193 | freezer = task_freezer(task); |
189 | task_unlock(task); | 194 | |
195 | /* | ||
196 | * The root cgroup is non-freezable, so we can skip the | ||
197 | * following check. | ||
198 | */ | ||
199 | if (!freezer->css.cgroup->parent) | ||
200 | return; | ||
190 | 201 | ||
191 | spin_lock_irq(&freezer->lock); | 202 | spin_lock_irq(&freezer->lock); |
192 | BUG_ON(freezer->state == CGROUP_FROZEN); | 203 | BUG_ON(freezer->state == CGROUP_FROZEN); |
@@ -331,7 +342,7 @@ static int freezer_write(struct cgroup *cgroup, | |||
331 | else if (strcmp(buffer, freezer_state_strs[CGROUP_FROZEN]) == 0) | 342 | else if (strcmp(buffer, freezer_state_strs[CGROUP_FROZEN]) == 0) |
332 | goal_state = CGROUP_FROZEN; | 343 | goal_state = CGROUP_FROZEN; |
333 | else | 344 | else |
334 | return -EIO; | 345 | return -EINVAL; |
335 | 346 | ||
336 | if (!cgroup_lock_live_group(cgroup)) | 347 | if (!cgroup_lock_live_group(cgroup)) |
337 | return -ENODEV; | 348 | return -ENODEV; |
@@ -350,6 +361,8 @@ static struct cftype files[] = { | |||
350 | 361 | ||
351 | static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup) | 362 | static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup) |
352 | { | 363 | { |
364 | if (!cgroup->parent) | ||
365 | return 0; | ||
353 | return cgroup_add_files(cgroup, ss, files, ARRAY_SIZE(files)); | 366 | return cgroup_add_files(cgroup, ss, files, ARRAY_SIZE(files)); |
354 | } | 367 | } |
355 | 368 | ||
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 3e00526f52ec..81fc6791a296 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -587,7 +587,6 @@ static int generate_sched_domains(cpumask_t **domains, | |||
587 | int ndoms; /* number of sched domains in result */ | 587 | int ndoms; /* number of sched domains in result */ |
588 | int nslot; /* next empty doms[] cpumask_t slot */ | 588 | int nslot; /* next empty doms[] cpumask_t slot */ |
589 | 589 | ||
590 | ndoms = 0; | ||
591 | doms = NULL; | 590 | doms = NULL; |
592 | dattr = NULL; | 591 | dattr = NULL; |
593 | csa = NULL; | 592 | csa = NULL; |
@@ -674,10 +673,8 @@ restart: | |||
674 | * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. | 673 | * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. |
675 | */ | 674 | */ |
676 | doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL); | 675 | doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL); |
677 | if (!doms) { | 676 | if (!doms) |
678 | ndoms = 0; | ||
679 | goto done; | 677 | goto done; |
680 | } | ||
681 | 678 | ||
682 | /* | 679 | /* |
683 | * The rest of the code, including the scheduler, can deal with | 680 | * The rest of the code, including the scheduler, can deal with |
@@ -732,6 +729,13 @@ restart: | |||
732 | done: | 729 | done: |
733 | kfree(csa); | 730 | kfree(csa); |
734 | 731 | ||
732 | /* | ||
733 | * Fallback to the default domain if kmalloc() failed. | ||
734 | * See comments in partition_sched_domains(). | ||
735 | */ | ||
736 | if (doms == NULL) | ||
737 | ndoms = 1; | ||
738 | |||
735 | *domains = doms; | 739 | *domains = doms; |
736 | *attributes = dattr; | 740 | *attributes = dattr; |
737 | return ndoms; | 741 | return ndoms; |
diff --git a/kernel/exit.c b/kernel/exit.c index f995d2418668..35c8ec2ba03a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <linux/cn_proc.h> | 40 | #include <linux/cn_proc.h> |
41 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
42 | #include <linux/futex.h> | 42 | #include <linux/futex.h> |
43 | #include <linux/compat.h> | ||
44 | #include <linux/pipe_fs_i.h> | 43 | #include <linux/pipe_fs_i.h> |
45 | #include <linux/audit.h> /* for audit_free() */ | 44 | #include <linux/audit.h> /* for audit_free() */ |
46 | #include <linux/resource.h> | 45 | #include <linux/resource.h> |
@@ -1063,14 +1062,6 @@ NORET_TYPE void do_exit(long code) | |||
1063 | exit_itimers(tsk->signal); | 1062 | exit_itimers(tsk->signal); |
1064 | } | 1063 | } |
1065 | acct_collect(code, group_dead); | 1064 | acct_collect(code, group_dead); |
1066 | #ifdef CONFIG_FUTEX | ||
1067 | if (unlikely(tsk->robust_list)) | ||
1068 | exit_robust_list(tsk); | ||
1069 | #ifdef CONFIG_COMPAT | ||
1070 | if (unlikely(tsk->compat_robust_list)) | ||
1071 | compat_exit_robust_list(tsk); | ||
1072 | #endif | ||
1073 | #endif | ||
1074 | if (group_dead) | 1065 | if (group_dead) |
1075 | tty_audit_exit(); | 1066 | tty_audit_exit(); |
1076 | if (unlikely(tsk->audit_context)) | 1067 | if (unlikely(tsk->audit_context)) |
diff --git a/kernel/fork.c b/kernel/fork.c index 0837d0deee5f..ac62f43ee430 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/jiffies.h> | 40 | #include <linux/jiffies.h> |
41 | #include <linux/tracehook.h> | 41 | #include <linux/tracehook.h> |
42 | #include <linux/futex.h> | 42 | #include <linux/futex.h> |
43 | #include <linux/compat.h> | ||
43 | #include <linux/task_io_accounting_ops.h> | 44 | #include <linux/task_io_accounting_ops.h> |
44 | #include <linux/rcupdate.h> | 45 | #include <linux/rcupdate.h> |
45 | #include <linux/ptrace.h> | 46 | #include <linux/ptrace.h> |
@@ -521,6 +522,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) | |||
521 | { | 522 | { |
522 | struct completion *vfork_done = tsk->vfork_done; | 523 | struct completion *vfork_done = tsk->vfork_done; |
523 | 524 | ||
525 | /* Get rid of any futexes when releasing the mm */ | ||
526 | #ifdef CONFIG_FUTEX | ||
527 | if (unlikely(tsk->robust_list)) | ||
528 | exit_robust_list(tsk); | ||
529 | #ifdef CONFIG_COMPAT | ||
530 | if (unlikely(tsk->compat_robust_list)) | ||
531 | compat_exit_robust_list(tsk); | ||
532 | #endif | ||
533 | #endif | ||
534 | |||
524 | /* Get rid of any cached register state */ | 535 | /* Get rid of any cached register state */ |
525 | deactivate_mm(tsk, mm); | 536 | deactivate_mm(tsk, mm); |
526 | 537 | ||
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 95d3949f2ae5..47e63349d1b2 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -664,14 +664,6 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer, | |||
664 | 664 | ||
665 | /* Timer is expired, act upon the callback mode */ | 665 | /* Timer is expired, act upon the callback mode */ |
666 | switch(timer->cb_mode) { | 666 | switch(timer->cb_mode) { |
667 | case HRTIMER_CB_IRQSAFE_NO_RESTART: | ||
668 | debug_hrtimer_deactivate(timer); | ||
669 | /* | ||
670 | * We can call the callback from here. No restart | ||
671 | * happens, so no danger of recursion | ||
672 | */ | ||
673 | BUG_ON(timer->function(timer) != HRTIMER_NORESTART); | ||
674 | return 1; | ||
675 | case HRTIMER_CB_IRQSAFE_PERCPU: | 667 | case HRTIMER_CB_IRQSAFE_PERCPU: |
676 | case HRTIMER_CB_IRQSAFE_UNLOCKED: | 668 | case HRTIMER_CB_IRQSAFE_UNLOCKED: |
677 | /* | 669 | /* |
@@ -683,7 +675,6 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer, | |||
683 | */ | 675 | */ |
684 | debug_hrtimer_deactivate(timer); | 676 | debug_hrtimer_deactivate(timer); |
685 | return 1; | 677 | return 1; |
686 | case HRTIMER_CB_IRQSAFE: | ||
687 | case HRTIMER_CB_SOFTIRQ: | 678 | case HRTIMER_CB_SOFTIRQ: |
688 | /* | 679 | /* |
689 | * Move everything else into the softirq pending list ! | 680 | * Move everything else into the softirq pending list ! |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 8b57a2597f21..9f8a3f25259a 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -72,7 +72,7 @@ static bool kprobe_enabled; | |||
72 | DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ | 72 | DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ |
73 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; | 73 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; |
74 | static struct { | 74 | static struct { |
75 | spinlock_t lock ____cacheline_aligned; | 75 | spinlock_t lock ____cacheline_aligned_in_smp; |
76 | } kretprobe_table_locks[KPROBE_TABLE_SIZE]; | 76 | } kretprobe_table_locks[KPROBE_TABLE_SIZE]; |
77 | 77 | ||
78 | static spinlock_t *kretprobe_table_lock_ptr(unsigned long hash) | 78 | static spinlock_t *kretprobe_table_lock_ptr(unsigned long hash) |
@@ -613,30 +613,37 @@ static int __kprobes __register_kprobe(struct kprobe *p, | |||
613 | return -EINVAL; | 613 | return -EINVAL; |
614 | p->addr = addr; | 614 | p->addr = addr; |
615 | 615 | ||
616 | if (!kernel_text_address((unsigned long) p->addr) || | 616 | preempt_disable(); |
617 | in_kprobes_functions((unsigned long) p->addr)) | 617 | if (!__kernel_text_address((unsigned long) p->addr) || |
618 | in_kprobes_functions((unsigned long) p->addr)) { | ||
619 | preempt_enable(); | ||
618 | return -EINVAL; | 620 | return -EINVAL; |
621 | } | ||
619 | 622 | ||
620 | p->mod_refcounted = 0; | 623 | p->mod_refcounted = 0; |
621 | 624 | ||
622 | /* | 625 | /* |
623 | * Check if are we probing a module. | 626 | * Check if are we probing a module. |
624 | */ | 627 | */ |
625 | probed_mod = module_text_address((unsigned long) p->addr); | 628 | probed_mod = __module_text_address((unsigned long) p->addr); |
626 | if (probed_mod) { | 629 | if (probed_mod) { |
627 | struct module *calling_mod = module_text_address(called_from); | 630 | struct module *calling_mod; |
631 | calling_mod = __module_text_address(called_from); | ||
628 | /* | 632 | /* |
629 | * We must allow modules to probe themself and in this case | 633 | * We must allow modules to probe themself and in this case |
630 | * avoid incrementing the module refcount, so as to allow | 634 | * avoid incrementing the module refcount, so as to allow |
631 | * unloading of self probing modules. | 635 | * unloading of self probing modules. |
632 | */ | 636 | */ |
633 | if (calling_mod && calling_mod != probed_mod) { | 637 | if (calling_mod && calling_mod != probed_mod) { |
634 | if (unlikely(!try_module_get(probed_mod))) | 638 | if (unlikely(!try_module_get(probed_mod))) { |
639 | preempt_enable(); | ||
635 | return -EINVAL; | 640 | return -EINVAL; |
641 | } | ||
636 | p->mod_refcounted = 1; | 642 | p->mod_refcounted = 1; |
637 | } else | 643 | } else |
638 | probed_mod = NULL; | 644 | probed_mod = NULL; |
639 | } | 645 | } |
646 | preempt_enable(); | ||
640 | 647 | ||
641 | p->nmissed = 0; | 648 | p->nmissed = 0; |
642 | INIT_LIST_HEAD(&p->list); | 649 | INIT_LIST_HEAD(&p->list); |
@@ -718,6 +725,10 @@ static void __kprobes __unregister_kprobe_bottom(struct kprobe *p) | |||
718 | struct kprobe *old_p; | 725 | struct kprobe *old_p; |
719 | 726 | ||
720 | if (p->mod_refcounted) { | 727 | if (p->mod_refcounted) { |
728 | /* | ||
729 | * Since we've already incremented refcount, | ||
730 | * we don't need to disable preemption. | ||
731 | */ | ||
721 | mod = module_text_address((unsigned long)p->addr); | 732 | mod = module_text_address((unsigned long)p->addr); |
722 | if (mod) | 733 | if (mod) |
723 | module_put(mod); | 734 | module_put(mod); |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 153dcb2639c3..895337b16a24 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -1308,9 +1308,10 @@ static inline int task_cputime_expired(const struct task_cputime *sample, | |||
1308 | */ | 1308 | */ |
1309 | static inline int fastpath_timer_check(struct task_struct *tsk) | 1309 | static inline int fastpath_timer_check(struct task_struct *tsk) |
1310 | { | 1310 | { |
1311 | struct signal_struct *sig = tsk->signal; | 1311 | struct signal_struct *sig; |
1312 | 1312 | ||
1313 | if (unlikely(!sig)) | 1313 | /* tsk == current, ensure it is safe to use ->signal/sighand */ |
1314 | if (unlikely(tsk->exit_state)) | ||
1314 | return 0; | 1315 | return 0; |
1315 | 1316 | ||
1316 | if (!task_cputime_zero(&tsk->cputime_expires)) { | 1317 | if (!task_cputime_zero(&tsk->cputime_expires)) { |
@@ -1323,6 +1324,8 @@ static inline int fastpath_timer_check(struct task_struct *tsk) | |||
1323 | if (task_cputime_expired(&task_sample, &tsk->cputime_expires)) | 1324 | if (task_cputime_expired(&task_sample, &tsk->cputime_expires)) |
1324 | return 1; | 1325 | return 1; |
1325 | } | 1326 | } |
1327 | |||
1328 | sig = tsk->signal; | ||
1326 | if (!task_cputime_zero(&sig->cputime_expires)) { | 1329 | if (!task_cputime_zero(&sig->cputime_expires)) { |
1327 | struct task_cputime group_sample; | 1330 | struct task_cputime group_sample; |
1328 | 1331 | ||
diff --git a/kernel/power/main.c b/kernel/power/main.c index 19122cf6d827..b8f7ce9473e8 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -174,7 +174,7 @@ static void suspend_test_finish(const char *label) | |||
174 | * has some performance issues. The stack dump of a WARN_ON | 174 | * has some performance issues. The stack dump of a WARN_ON |
175 | * is more likely to get the right attention than a printk... | 175 | * is more likely to get the right attention than a printk... |
176 | */ | 176 | */ |
177 | WARN_ON(msec > (TEST_SUSPEND_SECONDS * 1000)); | 177 | WARN(msec > (TEST_SUSPEND_SECONDS * 1000), "Component: %s\n", label); |
178 | } | 178 | } |
179 | 179 | ||
180 | #else | 180 | #else |
diff --git a/kernel/relay.c b/kernel/relay.c index 8d13a7855c08..32b0befdcb6a 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
@@ -400,7 +400,7 @@ void relay_reset(struct rchan *chan) | |||
400 | } | 400 | } |
401 | 401 | ||
402 | mutex_lock(&relay_channels_mutex); | 402 | mutex_lock(&relay_channels_mutex); |
403 | for_each_online_cpu(i) | 403 | for_each_possible_cpu(i) |
404 | if (chan->buf[i]) | 404 | if (chan->buf[i]) |
405 | __relay_reset(chan->buf[i], 0); | 405 | __relay_reset(chan->buf[i], 0); |
406 | mutex_unlock(&relay_channels_mutex); | 406 | mutex_unlock(&relay_channels_mutex); |
@@ -611,10 +611,9 @@ struct rchan *relay_open(const char *base_filename, | |||
611 | return chan; | 611 | return chan; |
612 | 612 | ||
613 | free_bufs: | 613 | free_bufs: |
614 | for_each_online_cpu(i) { | 614 | for_each_possible_cpu(i) { |
615 | if (!chan->buf[i]) | 615 | if (chan->buf[i]) |
616 | break; | 616 | relay_close_buf(chan->buf[i]); |
617 | relay_close_buf(chan->buf[i]); | ||
618 | } | 617 | } |
619 | 618 | ||
620 | kref_put(&chan->kref, relay_destroy_channel); | 619 | kref_put(&chan->kref, relay_destroy_channel); |
diff --git a/kernel/sched.c b/kernel/sched.c index 327f91c63c99..4de56108c86f 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -1462,6 +1462,8 @@ static unsigned long cpu_avg_load_per_task(int cpu) | |||
1462 | 1462 | ||
1463 | if (rq->nr_running) | 1463 | if (rq->nr_running) |
1464 | rq->avg_load_per_task = rq->load.weight / rq->nr_running; | 1464 | rq->avg_load_per_task = rq->load.weight / rq->nr_running; |
1465 | else | ||
1466 | rq->avg_load_per_task = 0; | ||
1465 | 1467 | ||
1466 | return rq->avg_load_per_task; | 1468 | return rq->avg_load_per_task; |
1467 | } | 1469 | } |
@@ -5874,6 +5876,8 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) | |||
5874 | struct rq *rq = cpu_rq(cpu); | 5876 | struct rq *rq = cpu_rq(cpu); |
5875 | unsigned long flags; | 5877 | unsigned long flags; |
5876 | 5878 | ||
5879 | spin_lock_irqsave(&rq->lock, flags); | ||
5880 | |||
5877 | __sched_fork(idle); | 5881 | __sched_fork(idle); |
5878 | idle->se.exec_start = sched_clock(); | 5882 | idle->se.exec_start = sched_clock(); |
5879 | 5883 | ||
@@ -5881,7 +5885,6 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) | |||
5881 | idle->cpus_allowed = cpumask_of_cpu(cpu); | 5885 | idle->cpus_allowed = cpumask_of_cpu(cpu); |
5882 | __set_task_cpu(idle, cpu); | 5886 | __set_task_cpu(idle, cpu); |
5883 | 5887 | ||
5884 | spin_lock_irqsave(&rq->lock, flags); | ||
5885 | rq->curr = rq->idle = idle; | 5888 | rq->curr = rq->idle = idle; |
5886 | #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) | 5889 | #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) |
5887 | idle->oncpu = 1; | 5890 | idle->oncpu = 1; |
@@ -7792,13 +7795,14 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur, | |||
7792 | * | 7795 | * |
7793 | * The passed in 'doms_new' should be kmalloc'd. This routine takes | 7796 | * The passed in 'doms_new' should be kmalloc'd. This routine takes |
7794 | * ownership of it and will kfree it when done with it. If the caller | 7797 | * ownership of it and will kfree it when done with it. If the caller |
7795 | * failed the kmalloc call, then it can pass in doms_new == NULL, | 7798 | * failed the kmalloc call, then it can pass in doms_new == NULL && |
7796 | * and partition_sched_domains() will fallback to the single partition | 7799 | * ndoms_new == 1, and partition_sched_domains() will fallback to |
7797 | * 'fallback_doms', it also forces the domains to be rebuilt. | 7800 | * the single partition 'fallback_doms', it also forces the domains |
7801 | * to be rebuilt. | ||
7798 | * | 7802 | * |
7799 | * If doms_new==NULL it will be replaced with cpu_online_map. | 7803 | * If doms_new == NULL it will be replaced with cpu_online_map. |
7800 | * ndoms_new==0 is a special case for destroying existing domains. | 7804 | * ndoms_new == 0 is a special case for destroying existing domains, |
7801 | * It will not create the default domain. | 7805 | * and it will not create the default domain. |
7802 | * | 7806 | * |
7803 | * Call with hotplug lock held | 7807 | * Call with hotplug lock held |
7804 | */ | 7808 | */ |
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c index 48ecc51e7701..26ed8e3d1c15 100644 --- a/kernel/sched_debug.c +++ b/kernel/sched_debug.c | |||
@@ -423,10 +423,11 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
423 | #undef __P | 423 | #undef __P |
424 | 424 | ||
425 | { | 425 | { |
426 | unsigned int this_cpu = raw_smp_processor_id(); | ||
426 | u64 t0, t1; | 427 | u64 t0, t1; |
427 | 428 | ||
428 | t0 = sched_clock(); | 429 | t0 = cpu_clock(this_cpu); |
429 | t1 = sched_clock(); | 430 | t1 = cpu_clock(this_cpu); |
430 | SEQ_printf(m, "%-35s:%21Ld\n", | 431 | SEQ_printf(m, "%-35s:%21Ld\n", |
431 | "clock-delta", (long long)(t1-t0)); | 432 | "clock-delta", (long long)(t1-t0)); |
432 | } | 433 | } |
diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h index ee71bec1da66..7dbf72a2b02c 100644 --- a/kernel/sched_stats.h +++ b/kernel/sched_stats.h | |||
@@ -298,9 +298,11 @@ static inline void account_group_user_time(struct task_struct *tsk, | |||
298 | { | 298 | { |
299 | struct signal_struct *sig; | 299 | struct signal_struct *sig; |
300 | 300 | ||
301 | sig = tsk->signal; | 301 | /* tsk == current, ensure it is safe to use ->signal */ |
302 | if (unlikely(!sig)) | 302 | if (unlikely(tsk->exit_state)) |
303 | return; | 303 | return; |
304 | |||
305 | sig = tsk->signal; | ||
304 | if (sig->cputime.totals) { | 306 | if (sig->cputime.totals) { |
305 | struct task_cputime *times; | 307 | struct task_cputime *times; |
306 | 308 | ||
@@ -325,9 +327,11 @@ static inline void account_group_system_time(struct task_struct *tsk, | |||
325 | { | 327 | { |
326 | struct signal_struct *sig; | 328 | struct signal_struct *sig; |
327 | 329 | ||
328 | sig = tsk->signal; | 330 | /* tsk == current, ensure it is safe to use ->signal */ |
329 | if (unlikely(!sig)) | 331 | if (unlikely(tsk->exit_state)) |
330 | return; | 332 | return; |
333 | |||
334 | sig = tsk->signal; | ||
331 | if (sig->cputime.totals) { | 335 | if (sig->cputime.totals) { |
332 | struct task_cputime *times; | 336 | struct task_cputime *times; |
333 | 337 | ||
@@ -353,8 +357,11 @@ static inline void account_group_exec_runtime(struct task_struct *tsk, | |||
353 | struct signal_struct *sig; | 357 | struct signal_struct *sig; |
354 | 358 | ||
355 | sig = tsk->signal; | 359 | sig = tsk->signal; |
360 | /* see __exit_signal()->task_rq_unlock_wait() */ | ||
361 | barrier(); | ||
356 | if (unlikely(!sig)) | 362 | if (unlikely(!sig)) |
357 | return; | 363 | return; |
364 | |||
358 | if (sig->cputime.totals) { | 365 | if (sig->cputime.totals) { |
359 | struct task_cputime *times; | 366 | struct task_cputime *times; |
360 | 367 | ||
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 9bc4c00872c9..24e8ceacc388 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -112,7 +112,7 @@ static int chill(void *unused) | |||
112 | int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) | 112 | int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) |
113 | { | 113 | { |
114 | struct work_struct *sm_work; | 114 | struct work_struct *sm_work; |
115 | int i; | 115 | int i, ret; |
116 | 116 | ||
117 | /* Set up initial state. */ | 117 | /* Set up initial state. */ |
118 | mutex_lock(&lock); | 118 | mutex_lock(&lock); |
@@ -137,8 +137,9 @@ int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) | |||
137 | /* This will release the thread on our CPU. */ | 137 | /* This will release the thread on our CPU. */ |
138 | put_cpu(); | 138 | put_cpu(); |
139 | flush_workqueue(stop_machine_wq); | 139 | flush_workqueue(stop_machine_wq); |
140 | ret = active.fnret; | ||
140 | mutex_unlock(&lock); | 141 | mutex_unlock(&lock); |
141 | return active.fnret; | 142 | return ret; |
142 | } | 143 | } |
143 | 144 | ||
144 | int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) | 145 | int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index caa4fda50f8a..85ced143c2c4 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -622,6 +622,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
622 | list_del_init(&page->list); | 622 | list_del_init(&page->list); |
623 | free_buffer_page(page); | 623 | free_buffer_page(page); |
624 | } | 624 | } |
625 | mutex_unlock(&buffer->mutex); | ||
625 | return -ENOMEM; | 626 | return -ENOMEM; |
626 | } | 627 | } |
627 | 628 | ||
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2596b5a968c4..5653c6b07ba1 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -518,7 +518,15 @@ int register_tracer(struct tracer *type) | |||
518 | return -1; | 518 | return -1; |
519 | } | 519 | } |
520 | 520 | ||
521 | /* | ||
522 | * When this gets called we hold the BKL which means that | ||
523 | * preemption is disabled. Various trace selftests however | ||
524 | * need to disable and enable preemption for successful tests. | ||
525 | * So we drop the BKL here and grab it after the tests again. | ||
526 | */ | ||
527 | unlock_kernel(); | ||
521 | mutex_lock(&trace_types_lock); | 528 | mutex_lock(&trace_types_lock); |
529 | |||
522 | for (t = trace_types; t; t = t->next) { | 530 | for (t = trace_types; t; t = t->next) { |
523 | if (strcmp(type->name, t->name) == 0) { | 531 | if (strcmp(type->name, t->name) == 0) { |
524 | /* already found */ | 532 | /* already found */ |
@@ -541,9 +549,9 @@ int register_tracer(struct tracer *type) | |||
541 | * internal tracing to verify that everything is in order. | 549 | * internal tracing to verify that everything is in order. |
542 | * If we fail, we do not register this tracer. | 550 | * If we fail, we do not register this tracer. |
543 | */ | 551 | */ |
544 | for_each_tracing_cpu(i) { | 552 | for_each_tracing_cpu(i) |
545 | tracing_reset(tr, i); | 553 | tracing_reset(tr, i); |
546 | } | 554 | |
547 | current_trace = type; | 555 | current_trace = type; |
548 | /* the test is responsible for initializing and enabling */ | 556 | /* the test is responsible for initializing and enabling */ |
549 | pr_info("Testing tracer %s: ", type->name); | 557 | pr_info("Testing tracer %s: ", type->name); |
@@ -555,9 +563,9 @@ int register_tracer(struct tracer *type) | |||
555 | goto out; | 563 | goto out; |
556 | } | 564 | } |
557 | /* Only reset on passing, to avoid touching corrupted buffers */ | 565 | /* Only reset on passing, to avoid touching corrupted buffers */ |
558 | for_each_tracing_cpu(i) { | 566 | for_each_tracing_cpu(i) |
559 | tracing_reset(tr, i); | 567 | tracing_reset(tr, i); |
560 | } | 568 | |
561 | printk(KERN_CONT "PASSED\n"); | 569 | printk(KERN_CONT "PASSED\n"); |
562 | } | 570 | } |
563 | #endif | 571 | #endif |
@@ -570,6 +578,7 @@ int register_tracer(struct tracer *type) | |||
570 | 578 | ||
571 | out: | 579 | out: |
572 | mutex_unlock(&trace_types_lock); | 580 | mutex_unlock(&trace_types_lock); |
581 | lock_kernel(); | ||
573 | 582 | ||
574 | return ret; | 583 | return ret; |
575 | } | 584 | } |
@@ -2178,6 +2187,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret) | |||
2178 | ring_buffer_read_finish(iter->buffer_iter[cpu]); | 2187 | ring_buffer_read_finish(iter->buffer_iter[cpu]); |
2179 | } | 2188 | } |
2180 | mutex_unlock(&trace_types_lock); | 2189 | mutex_unlock(&trace_types_lock); |
2190 | kfree(iter); | ||
2181 | 2191 | ||
2182 | return ERR_PTR(-ENOMEM); | 2192 | return ERR_PTR(-ENOMEM); |
2183 | } | 2193 | } |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 78330c37a61b..5f6c629a924d 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -467,9 +467,13 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, | |||
467 | dma_addr_t dev_addr; | 467 | dma_addr_t dev_addr; |
468 | void *ret; | 468 | void *ret; |
469 | int order = get_order(size); | 469 | int order = get_order(size); |
470 | u64 dma_mask = DMA_32BIT_MASK; | ||
471 | |||
472 | if (hwdev && hwdev->coherent_dma_mask) | ||
473 | dma_mask = hwdev->coherent_dma_mask; | ||
470 | 474 | ||
471 | ret = (void *)__get_free_pages(flags, order); | 475 | ret = (void *)__get_free_pages(flags, order); |
472 | if (ret && address_needs_mapping(hwdev, virt_to_bus(ret), size)) { | 476 | if (ret && !is_buffer_dma_capable(dma_mask, virt_to_bus(ret), size)) { |
473 | /* | 477 | /* |
474 | * The allocated memory isn't reachable by the device. | 478 | * The allocated memory isn't reachable by the device. |
475 | * Fall back on swiotlb_map_single(). | 479 | * Fall back on swiotlb_map_single(). |
@@ -493,9 +497,9 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, | |||
493 | dev_addr = virt_to_bus(ret); | 497 | dev_addr = virt_to_bus(ret); |
494 | 498 | ||
495 | /* Confirm address can be DMA'd by device */ | 499 | /* Confirm address can be DMA'd by device */ |
496 | if (address_needs_mapping(hwdev, dev_addr, size)) { | 500 | if (!is_buffer_dma_capable(dma_mask, dev_addr, size)) { |
497 | printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n", | 501 | printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n", |
498 | (unsigned long long)*hwdev->dma_mask, | 502 | (unsigned long long)dma_mask, |
499 | (unsigned long long)dev_addr); | 503 | (unsigned long long)dev_addr); |
500 | 504 | ||
501 | /* DMA_TO_DEVICE to avoid memcpy in unmap_single */ | 505 | /* DMA_TO_DEVICE to avoid memcpy in unmap_single */ |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d143ab67be44..6058b53dcb89 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -1796,6 +1796,7 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, | |||
1796 | static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, | 1796 | static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, |
1797 | struct page *page, unsigned long address) | 1797 | struct page *page, unsigned long address) |
1798 | { | 1798 | { |
1799 | struct hstate *h = hstate_vma(vma); | ||
1799 | struct vm_area_struct *iter_vma; | 1800 | struct vm_area_struct *iter_vma; |
1800 | struct address_space *mapping; | 1801 | struct address_space *mapping; |
1801 | struct prio_tree_iter iter; | 1802 | struct prio_tree_iter iter; |
@@ -1805,7 +1806,7 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1805 | * vm_pgoff is in PAGE_SIZE units, hence the different calculation | 1806 | * vm_pgoff is in PAGE_SIZE units, hence the different calculation |
1806 | * from page cache lookup which is in HPAGE_SIZE units. | 1807 | * from page cache lookup which is in HPAGE_SIZE units. |
1807 | */ | 1808 | */ |
1808 | address = address & huge_page_mask(hstate_vma(vma)); | 1809 | address = address & huge_page_mask(h); |
1809 | pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) | 1810 | pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) |
1810 | + (vma->vm_pgoff >> PAGE_SHIFT); | 1811 | + (vma->vm_pgoff >> PAGE_SHIFT); |
1811 | mapping = (struct address_space *)page_private(page); | 1812 | mapping = (struct address_space *)page_private(page); |
@@ -1824,7 +1825,7 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1824 | */ | 1825 | */ |
1825 | if (!is_vma_resv_set(iter_vma, HPAGE_RESV_OWNER)) | 1826 | if (!is_vma_resv_set(iter_vma, HPAGE_RESV_OWNER)) |
1826 | unmap_hugepage_range(iter_vma, | 1827 | unmap_hugepage_range(iter_vma, |
1827 | address, address + HPAGE_SIZE, | 1828 | address, address + huge_page_size(h), |
1828 | page); | 1829 | page); |
1829 | } | 1830 | } |
1830 | 1831 | ||
diff --git a/mm/mlock.c b/mm/mlock.c index 008ea70b7afa..1ada366570cb 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -66,14 +66,10 @@ void __clear_page_mlock(struct page *page) | |||
66 | putback_lru_page(page); | 66 | putback_lru_page(page); |
67 | } else { | 67 | } else { |
68 | /* | 68 | /* |
69 | * Page not on the LRU yet. Flush all pagevecs and retry. | 69 | * We lost the race. the page already moved to evictable list. |
70 | */ | 70 | */ |
71 | lru_add_drain_all(); | 71 | if (PageUnevictable(page)) |
72 | if (!isolate_lru_page(page)) | ||
73 | putback_lru_page(page); | ||
74 | else if (PageUnevictable(page)) | ||
75 | count_vm_event(UNEVICTABLE_PGSTRANDED); | 72 | count_vm_event(UNEVICTABLE_PGSTRANDED); |
76 | |||
77 | } | 73 | } |
78 | } | 74 | } |
79 | 75 | ||
@@ -166,7 +162,7 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, | |||
166 | unsigned long addr = start; | 162 | unsigned long addr = start; |
167 | struct page *pages[16]; /* 16 gives a reasonable batch */ | 163 | struct page *pages[16]; /* 16 gives a reasonable batch */ |
168 | int nr_pages = (end - start) / PAGE_SIZE; | 164 | int nr_pages = (end - start) / PAGE_SIZE; |
169 | int ret; | 165 | int ret = 0; |
170 | int gup_flags = 0; | 166 | int gup_flags = 0; |
171 | 167 | ||
172 | VM_BUG_ON(start & ~PAGE_MASK); | 168 | VM_BUG_ON(start & ~PAGE_MASK); |
@@ -187,8 +183,6 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, | |||
187 | if (vma->vm_flags & VM_WRITE) | 183 | if (vma->vm_flags & VM_WRITE) |
188 | gup_flags |= GUP_FLAGS_WRITE; | 184 | gup_flags |= GUP_FLAGS_WRITE; |
189 | 185 | ||
190 | lru_add_drain_all(); /* push cached pages to LRU */ | ||
191 | |||
192 | while (nr_pages > 0) { | 186 | while (nr_pages > 0) { |
193 | int i; | 187 | int i; |
194 | 188 | ||
@@ -251,8 +245,6 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, | |||
251 | ret = 0; | 245 | ret = 0; |
252 | } | 246 | } |
253 | 247 | ||
254 | lru_add_drain_all(); /* to update stats */ | ||
255 | |||
256 | return ret; /* count entire vma as locked_vm */ | 248 | return ret; /* count entire vma as locked_vm */ |
257 | } | 249 | } |
258 | 250 | ||
@@ -546,6 +538,8 @@ asmlinkage long sys_mlock(unsigned long start, size_t len) | |||
546 | if (!can_do_mlock()) | 538 | if (!can_do_mlock()) |
547 | return -EPERM; | 539 | return -EPERM; |
548 | 540 | ||
541 | lru_add_drain_all(); /* flush pagevec */ | ||
542 | |||
549 | down_write(¤t->mm->mmap_sem); | 543 | down_write(¤t->mm->mmap_sem); |
550 | len = PAGE_ALIGN(len + (start & ~PAGE_MASK)); | 544 | len = PAGE_ALIGN(len + (start & ~PAGE_MASK)); |
551 | start &= PAGE_MASK; | 545 | start &= PAGE_MASK; |
@@ -612,6 +606,8 @@ asmlinkage long sys_mlockall(int flags) | |||
612 | if (!can_do_mlock()) | 606 | if (!can_do_mlock()) |
613 | goto out; | 607 | goto out; |
614 | 608 | ||
609 | lru_add_drain_all(); /* flush pagevec */ | ||
610 | |||
615 | down_write(¤t->mm->mmap_sem); | 611 | down_write(¤t->mm->mmap_sem); |
616 | 612 | ||
617 | lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; | 613 | lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; |
@@ -1704,7 +1704,7 @@ find_extend_vma(struct mm_struct *mm, unsigned long addr) | |||
1704 | vma = find_vma_prev(mm, addr, &prev); | 1704 | vma = find_vma_prev(mm, addr, &prev); |
1705 | if (vma && (vma->vm_start <= addr)) | 1705 | if (vma && (vma->vm_start <= addr)) |
1706 | return vma; | 1706 | return vma; |
1707 | if (expand_stack(prev, addr)) | 1707 | if (!prev || expand_stack(prev, addr)) |
1708 | return NULL; | 1708 | return NULL; |
1709 | if (prev->vm_flags & VM_LOCKED) { | 1709 | if (prev->vm_flags & VM_LOCKED) { |
1710 | if (mlock_vma_pages_range(prev, addr, prev->vm_end) < 0) | 1710 | if (mlock_vma_pages_range(prev, addr, prev->vm_end) < 0) |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 54069e64e3a8..d8ac01474563 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1561,6 +1561,10 @@ nofail_alloc: | |||
1561 | 1561 | ||
1562 | /* We now go into synchronous reclaim */ | 1562 | /* We now go into synchronous reclaim */ |
1563 | cpuset_memory_pressure_bump(); | 1563 | cpuset_memory_pressure_bump(); |
1564 | /* | ||
1565 | * The task's cpuset might have expanded its set of allowable nodes | ||
1566 | */ | ||
1567 | cpuset_update_task_memory_state(); | ||
1564 | p->flags |= PF_MEMALLOC; | 1568 | p->flags |= PF_MEMALLOC; |
1565 | reclaim_state.reclaimed_slab = 0; | 1569 | reclaim_state.reclaimed_slab = 0; |
1566 | p->reclaim_state = &reclaim_state; | 1570 | p->reclaim_state = &reclaim_state; |
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index f59d797dc5a9..1223d927904d 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c | |||
@@ -165,7 +165,7 @@ int online_page_cgroup(unsigned long start_pfn, | |||
165 | unsigned long start, end, pfn; | 165 | unsigned long start, end, pfn; |
166 | int fail = 0; | 166 | int fail = 0; |
167 | 167 | ||
168 | start = start_pfn & (PAGES_PER_SECTION - 1); | 168 | start = start_pfn & ~(PAGES_PER_SECTION - 1); |
169 | end = ALIGN(start_pfn + nr_pages, PAGES_PER_SECTION); | 169 | end = ALIGN(start_pfn + nr_pages, PAGES_PER_SECTION); |
170 | 170 | ||
171 | for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION) { | 171 | for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION) { |
@@ -188,7 +188,7 @@ int offline_page_cgroup(unsigned long start_pfn, | |||
188 | { | 188 | { |
189 | unsigned long start, end, pfn; | 189 | unsigned long start, end, pfn; |
190 | 190 | ||
191 | start = start_pfn & (PAGES_PER_SECTION - 1); | 191 | start = start_pfn & ~(PAGES_PER_SECTION - 1); |
192 | end = ALIGN(start_pfn + nr_pages, PAGES_PER_SECTION); | 192 | end = ALIGN(start_pfn + nr_pages, PAGES_PER_SECTION); |
193 | 193 | ||
194 | for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) | 194 | for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 3b5860294bb6..c141b3e78071 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -2368,39 +2368,6 @@ int page_evictable(struct page *page, struct vm_area_struct *vma) | |||
2368 | return 1; | 2368 | return 1; |
2369 | } | 2369 | } |
2370 | 2370 | ||
2371 | static void show_page_path(struct page *page) | ||
2372 | { | ||
2373 | char buf[256]; | ||
2374 | if (page_is_file_cache(page)) { | ||
2375 | struct address_space *mapping = page->mapping; | ||
2376 | struct dentry *dentry; | ||
2377 | pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); | ||
2378 | |||
2379 | spin_lock(&mapping->i_mmap_lock); | ||
2380 | dentry = d_find_alias(mapping->host); | ||
2381 | printk(KERN_INFO "rescued: %s %lu\n", | ||
2382 | dentry_path(dentry, buf, 256), pgoff); | ||
2383 | spin_unlock(&mapping->i_mmap_lock); | ||
2384 | } else { | ||
2385 | #if defined(CONFIG_MM_OWNER) && defined(CONFIG_MMU) | ||
2386 | struct anon_vma *anon_vma; | ||
2387 | struct vm_area_struct *vma; | ||
2388 | |||
2389 | anon_vma = page_lock_anon_vma(page); | ||
2390 | if (!anon_vma) | ||
2391 | return; | ||
2392 | |||
2393 | list_for_each_entry(vma, &anon_vma->head, anon_vma_node) { | ||
2394 | printk(KERN_INFO "rescued: anon %s\n", | ||
2395 | vma->vm_mm->owner->comm); | ||
2396 | break; | ||
2397 | } | ||
2398 | page_unlock_anon_vma(anon_vma); | ||
2399 | #endif | ||
2400 | } | ||
2401 | } | ||
2402 | |||
2403 | |||
2404 | /** | 2371 | /** |
2405 | * check_move_unevictable_page - check page for evictability and move to appropriate zone lru list | 2372 | * check_move_unevictable_page - check page for evictability and move to appropriate zone lru list |
2406 | * @page: page to check evictability and move to appropriate lru list | 2373 | * @page: page to check evictability and move to appropriate lru list |
@@ -2421,8 +2388,6 @@ retry: | |||
2421 | if (page_evictable(page, NULL)) { | 2388 | if (page_evictable(page, NULL)) { |
2422 | enum lru_list l = LRU_INACTIVE_ANON + page_is_file_cache(page); | 2389 | enum lru_list l = LRU_INACTIVE_ANON + page_is_file_cache(page); |
2423 | 2390 | ||
2424 | show_page_path(page); | ||
2425 | |||
2426 | __dec_zone_state(zone, NR_UNEVICTABLE); | 2391 | __dec_zone_state(zone, NR_UNEVICTABLE); |
2427 | list_move(&page->lru, &zone->lru[l].list); | 2392 | list_move(&page->lru, &zone->lru[l].list); |
2428 | __inc_zone_state(zone, NR_INACTIVE_ANON + l); | 2393 | __inc_zone_state(zone, NR_INACTIVE_ANON + l); |
diff --git a/net/9p/Kconfig b/net/9p/Kconfig index c42c0c400bf9..0663f99e977a 100644 --- a/net/9p/Kconfig +++ b/net/9p/Kconfig | |||
@@ -13,22 +13,24 @@ menuconfig NET_9P | |||
13 | 13 | ||
14 | If unsure, say N. | 14 | If unsure, say N. |
15 | 15 | ||
16 | if NET_9P | ||
17 | |||
16 | config NET_9P_VIRTIO | 18 | config NET_9P_VIRTIO |
17 | depends on NET_9P && EXPERIMENTAL && VIRTIO | 19 | depends on EXPERIMENTAL && VIRTIO |
18 | tristate "9P Virtio Transport (Experimental)" | 20 | tristate "9P Virtio Transport (Experimental)" |
19 | help | 21 | help |
20 | This builds support for a transports between | 22 | This builds support for a transports between |
21 | guest partitions and a host partition. | 23 | guest partitions and a host partition. |
22 | 24 | ||
23 | config NET_9P_RDMA | 25 | config NET_9P_RDMA |
24 | depends on NET_9P && INFINIBAND && EXPERIMENTAL | 26 | depends on INET && INFINIBAND && EXPERIMENTAL |
25 | tristate "9P RDMA Transport (Experimental)" | 27 | tristate "9P RDMA Transport (Experimental)" |
26 | help | 28 | help |
27 | This builds support for a RDMA transport. | 29 | This builds support for an RDMA transport. |
28 | 30 | ||
29 | config NET_9P_DEBUG | 31 | config NET_9P_DEBUG |
30 | bool "Debug information" | 32 | bool "Debug information" |
31 | depends on NET_9P | ||
32 | help | 33 | help |
33 | Say Y if you want the 9P subsystem to log debug information. | 34 | Say Y if you want the 9P subsystem to log debug information. |
34 | 35 | ||
36 | endif | ||
diff --git a/net/compat.c b/net/compat.c index 67fb6a3834a3..6ce1a1cadcc0 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -226,14 +226,14 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat | |||
226 | return 0; /* XXX: return error? check spec. */ | 226 | return 0; /* XXX: return error? check spec. */ |
227 | } | 227 | } |
228 | 228 | ||
229 | if (level == SOL_SOCKET && type == SO_TIMESTAMP) { | 229 | if (level == SOL_SOCKET && type == SCM_TIMESTAMP) { |
230 | struct timeval *tv = (struct timeval *)data; | 230 | struct timeval *tv = (struct timeval *)data; |
231 | ctv.tv_sec = tv->tv_sec; | 231 | ctv.tv_sec = tv->tv_sec; |
232 | ctv.tv_usec = tv->tv_usec; | 232 | ctv.tv_usec = tv->tv_usec; |
233 | data = &ctv; | 233 | data = &ctv; |
234 | len = sizeof(ctv); | 234 | len = sizeof(ctv); |
235 | } | 235 | } |
236 | if (level == SOL_SOCKET && type == SO_TIMESTAMPNS) { | 236 | if (level == SOL_SOCKET && type == SCM_TIMESTAMPNS) { |
237 | struct timespec *ts = (struct timespec *)data; | 237 | struct timespec *ts = (struct timespec *)data; |
238 | cts.tv_sec = ts->tv_sec; | 238 | cts.tv_sec = ts->tv_sec; |
239 | cts.tv_nsec = ts->tv_nsec; | 239 | cts.tv_nsec = ts->tv_nsec; |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 31f29d2989fd..4dfb6b4d4559 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -878,7 +878,9 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, | |||
878 | if (ifm->ifi_change) | 878 | if (ifm->ifi_change) |
879 | flags = (flags & ifm->ifi_change) | | 879 | flags = (flags & ifm->ifi_change) | |
880 | (dev->flags & ~ifm->ifi_change); | 880 | (dev->flags & ~ifm->ifi_change); |
881 | dev_change_flags(dev, flags); | 881 | err = dev_change_flags(dev, flags); |
882 | if (err < 0) | ||
883 | goto errout; | ||
882 | } | 884 | } |
883 | 885 | ||
884 | if (tb[IFLA_TXQLEN]) | 886 | if (tb[IFLA_TXQLEN]) |
diff --git a/net/core/scm.c b/net/core/scm.c index ab242cc1acca..b12303dd39d9 100644 --- a/net/core/scm.c +++ b/net/core/scm.c | |||
@@ -75,7 +75,6 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp) | |||
75 | if (!fpl) | 75 | if (!fpl) |
76 | return -ENOMEM; | 76 | return -ENOMEM; |
77 | *fplp = fpl; | 77 | *fplp = fpl; |
78 | INIT_LIST_HEAD(&fpl->list); | ||
79 | fpl->count = 0; | 78 | fpl->count = 0; |
80 | } | 79 | } |
81 | fpp = &fpl->fp[fpl->count]; | 80 | fpp = &fpl->fp[fpl->count]; |
@@ -301,7 +300,6 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl) | |||
301 | 300 | ||
302 | new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL); | 301 | new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL); |
303 | if (new_fpl) { | 302 | if (new_fpl) { |
304 | INIT_LIST_HEAD(&new_fpl->list); | ||
305 | for (i=fpl->count-1; i>=0; i--) | 303 | for (i=fpl->count-1; i>=0; i--) |
306 | get_file(fpl->fp[i]); | 304 | get_file(fpl->fp[i]); |
307 | memcpy(new_fpl, fpl, sizeof(*fpl)); | 305 | memcpy(new_fpl, fpl, sizeof(*fpl)); |
diff --git a/net/core/sock.c b/net/core/sock.c index 5e2a3132a8c9..341e39456952 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -136,7 +136,6 @@ | |||
136 | static struct lock_class_key af_family_keys[AF_MAX]; | 136 | static struct lock_class_key af_family_keys[AF_MAX]; |
137 | static struct lock_class_key af_family_slock_keys[AF_MAX]; | 137 | static struct lock_class_key af_family_slock_keys[AF_MAX]; |
138 | 138 | ||
139 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
140 | /* | 139 | /* |
141 | * Make lock validator output more readable. (we pre-construct these | 140 | * Make lock validator output more readable. (we pre-construct these |
142 | * strings build-time, so that runtime initialization of socket | 141 | * strings build-time, so that runtime initialization of socket |
@@ -187,7 +186,6 @@ static const char *af_family_clock_key_strings[AF_MAX+1] = { | |||
187 | "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , | 186 | "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , |
188 | "clock-AF_MAX" | 187 | "clock-AF_MAX" |
189 | }; | 188 | }; |
190 | #endif | ||
191 | 189 | ||
192 | /* | 190 | /* |
193 | * sk_callback_lock locking rules are per-address-family, | 191 | * sk_callback_lock locking rules are per-address-family, |
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 861978a4f1a8..cfb38ac9d698 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c | |||
@@ -209,9 +209,17 @@ static int ip_local_deliver_finish(struct sk_buff *skb) | |||
209 | 209 | ||
210 | hash = protocol & (MAX_INET_PROTOS - 1); | 210 | hash = protocol & (MAX_INET_PROTOS - 1); |
211 | ipprot = rcu_dereference(inet_protos[hash]); | 211 | ipprot = rcu_dereference(inet_protos[hash]); |
212 | if (ipprot != NULL && (net == &init_net || ipprot->netns_ok)) { | 212 | if (ipprot != NULL) { |
213 | int ret; | 213 | int ret; |
214 | 214 | ||
215 | if (!net_eq(net, &init_net) && !ipprot->netns_ok) { | ||
216 | if (net_ratelimit()) | ||
217 | printk("%s: proto %d isn't netns-ready\n", | ||
218 | __func__, protocol); | ||
219 | kfree_skb(skb); | ||
220 | goto out; | ||
221 | } | ||
222 | |||
215 | if (!ipprot->no_policy) { | 223 | if (!ipprot->no_policy) { |
216 | if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { | 224 | if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { |
217 | kfree_skb(skb); | 225 | kfree_skb(skb); |
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c index af99776146ff..937549b8a921 100644 --- a/net/ipv4/tcp_htcp.c +++ b/net/ipv4/tcp_htcp.c | |||
@@ -69,9 +69,12 @@ static u32 htcp_cwnd_undo(struct sock *sk) | |||
69 | const struct tcp_sock *tp = tcp_sk(sk); | 69 | const struct tcp_sock *tp = tcp_sk(sk); |
70 | struct htcp *ca = inet_csk_ca(sk); | 70 | struct htcp *ca = inet_csk_ca(sk); |
71 | 71 | ||
72 | ca->last_cong = ca->undo_last_cong; | 72 | if (ca->undo_last_cong) { |
73 | ca->maxRTT = ca->undo_maxRTT; | 73 | ca->last_cong = ca->undo_last_cong; |
74 | ca->old_maxB = ca->undo_old_maxB; | 74 | ca->maxRTT = ca->undo_maxRTT; |
75 | ca->old_maxB = ca->undo_old_maxB; | ||
76 | ca->undo_last_cong = 0; | ||
77 | } | ||
75 | 78 | ||
76 | return max(tp->snd_cwnd, (tp->snd_ssthresh << 7) / ca->beta); | 79 | return max(tp->snd_cwnd, (tp->snd_ssthresh << 7) / ca->beta); |
77 | } | 80 | } |
@@ -268,7 +271,10 @@ static void htcp_state(struct sock *sk, u8 new_state) | |||
268 | case TCP_CA_Open: | 271 | case TCP_CA_Open: |
269 | { | 272 | { |
270 | struct htcp *ca = inet_csk_ca(sk); | 273 | struct htcp *ca = inet_csk_ca(sk); |
271 | ca->last_cong = jiffies; | 274 | if (ca->undo_last_cong) { |
275 | ca->last_cong = jiffies; | ||
276 | ca->undo_last_cong = 0; | ||
277 | } | ||
272 | } | 278 | } |
273 | break; | 279 | break; |
274 | case TCP_CA_CWR: | 280 | case TCP_CA_CWR: |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 410046a8cc91..e44deb8d4df2 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -661,6 +661,11 @@ int datagram_send_ctl(struct net *net, | |||
661 | switch (rthdr->type) { | 661 | switch (rthdr->type) { |
662 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) | 662 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) |
663 | case IPV6_SRCRT_TYPE_2: | 663 | case IPV6_SRCRT_TYPE_2: |
664 | if (rthdr->hdrlen != 2 || | ||
665 | rthdr->segments_left != 1) { | ||
666 | err = -EINVAL; | ||
667 | goto exit_f; | ||
668 | } | ||
664 | break; | 669 | break; |
665 | #endif | 670 | #endif |
666 | default: | 671 | default: |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 4e5eac301f91..2aa294be0c79 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
@@ -366,11 +366,16 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
366 | } | 366 | } |
367 | 367 | ||
368 | /* routing header option needs extra check */ | 368 | /* routing header option needs extra check */ |
369 | retv = -EINVAL; | ||
369 | if (optname == IPV6_RTHDR && opt && opt->srcrt) { | 370 | if (optname == IPV6_RTHDR && opt && opt->srcrt) { |
370 | struct ipv6_rt_hdr *rthdr = opt->srcrt; | 371 | struct ipv6_rt_hdr *rthdr = opt->srcrt; |
371 | switch (rthdr->type) { | 372 | switch (rthdr->type) { |
372 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) | 373 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) |
373 | case IPV6_SRCRT_TYPE_2: | 374 | case IPV6_SRCRT_TYPE_2: |
375 | if (rthdr->hdrlen != 2 || | ||
376 | rthdr->segments_left != 1) | ||
377 | goto sticky_done; | ||
378 | |||
374 | break; | 379 | break; |
375 | #endif | 380 | #endif |
376 | default: | 381 | default: |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 87665d7bb4f9..14d165f0df75 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -2570,14 +2570,14 @@ void ieee80211_notify_mac(struct ieee80211_hw *hw, | |||
2570 | 2570 | ||
2571 | switch (notif_type) { | 2571 | switch (notif_type) { |
2572 | case IEEE80211_NOTIFY_RE_ASSOC: | 2572 | case IEEE80211_NOTIFY_RE_ASSOC: |
2573 | rcu_read_lock(); | 2573 | rtnl_lock(); |
2574 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 2574 | list_for_each_entry(sdata, &local->interfaces, list) { |
2575 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 2575 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
2576 | continue; | 2576 | continue; |
2577 | 2577 | ||
2578 | ieee80211_sta_req_auth(sdata, &sdata->u.sta); | 2578 | ieee80211_sta_req_auth(sdata, &sdata->u.sta); |
2579 | } | 2579 | } |
2580 | rcu_read_unlock(); | 2580 | rtnl_unlock(); |
2581 | break; | 2581 | break; |
2582 | } | 2582 | } |
2583 | } | 2583 | } |
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index defeb7a0d502..7ab30f668b5a 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c | |||
@@ -144,8 +144,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev, | |||
144 | struct phonethdr *ph; | 144 | struct phonethdr *ph; |
145 | int err; | 145 | int err; |
146 | 146 | ||
147 | if (skb->len + 2 > 0xffff) { | 147 | if (skb->len + 2 > 0xffff /* Phonet length field limit */ || |
148 | /* Phonet length field would overflow */ | 148 | skb->len + sizeof(struct phonethdr) > dev->mtu) { |
149 | err = -EMSGSIZE; | 149 | err = -EMSGSIZE; |
150 | goto drop; | 150 | goto drop; |
151 | } | 151 | } |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 9b77b3e0fa98..3ecd7e797dee 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -37,6 +37,9 @@ static void snd_hda_generate_beep(struct work_struct *work) | |||
37 | container_of(work, struct hda_beep, beep_work); | 37 | container_of(work, struct hda_beep, beep_work); |
38 | struct hda_codec *codec = beep->codec; | 38 | struct hda_codec *codec = beep->codec; |
39 | 39 | ||
40 | if (!beep->enabled) | ||
41 | return; | ||
42 | |||
40 | /* generate tone */ | 43 | /* generate tone */ |
41 | snd_hda_codec_write_cache(codec, beep->nid, 0, | 44 | snd_hda_codec_write_cache(codec, beep->nid, 0, |
42 | AC_VERB_SET_BEEP_CONTROL, beep->tone); | 45 | AC_VERB_SET_BEEP_CONTROL, beep->tone); |
@@ -85,6 +88,10 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
85 | snprintf(beep->phys, sizeof(beep->phys), | 88 | snprintf(beep->phys, sizeof(beep->phys), |
86 | "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); | 89 | "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); |
87 | input_dev = input_allocate_device(); | 90 | input_dev = input_allocate_device(); |
91 | if (!input_dev) { | ||
92 | kfree(beep); | ||
93 | return -ENOMEM; | ||
94 | } | ||
88 | 95 | ||
89 | /* setup digital beep device */ | 96 | /* setup digital beep device */ |
90 | input_dev->name = "HDA Digital PCBeep"; | 97 | input_dev->name = "HDA Digital PCBeep"; |
@@ -115,6 +122,7 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
115 | beep->nid = nid; | 122 | beep->nid = nid; |
116 | beep->dev = input_dev; | 123 | beep->dev = input_dev; |
117 | beep->codec = codec; | 124 | beep->codec = codec; |
125 | beep->enabled = 1; | ||
118 | codec->beep = beep; | 126 | codec->beep = beep; |
119 | 127 | ||
120 | INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); | 128 | INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); |
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h index de4036e6e710..b9679f081cae 100644 --- a/sound/pci/hda/hda_beep.h +++ b/sound/pci/hda/hda_beep.h | |||
@@ -31,6 +31,7 @@ struct hda_beep { | |||
31 | char phys[32]; | 31 | char phys[32]; |
32 | int tone; | 32 | int tone; |
33 | int nid; | 33 | int nid; |
34 | int enabled; | ||
34 | struct work_struct beep_work; /* scheduled task for beep event */ | 35 | struct work_struct beep_work; /* scheduled task for beep event */ |
35 | }; | 36 | }; |
36 | 37 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index e6085915d86d..9563b5bbb272 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -36,9 +36,11 @@ | |||
36 | #include "hda_beep.h" | 36 | #include "hda_beep.h" |
37 | 37 | ||
38 | #define NUM_CONTROL_ALLOC 32 | 38 | #define NUM_CONTROL_ALLOC 32 |
39 | |||
40 | #define STAC_VREF_EVENT 0x00 | ||
41 | #define STAC_INSERT_EVENT 0x10 | ||
39 | #define STAC_PWR_EVENT 0x20 | 42 | #define STAC_PWR_EVENT 0x20 |
40 | #define STAC_HP_EVENT 0x30 | 43 | #define STAC_HP_EVENT 0x30 |
41 | #define STAC_VREF_EVENT 0x40 | ||
42 | 44 | ||
43 | enum { | 45 | enum { |
44 | STAC_REF, | 46 | STAC_REF, |
@@ -212,7 +214,7 @@ struct sigmatel_spec { | |||
212 | /* i/o switches */ | 214 | /* i/o switches */ |
213 | unsigned int io_switch[2]; | 215 | unsigned int io_switch[2]; |
214 | unsigned int clfe_swap; | 216 | unsigned int clfe_swap; |
215 | unsigned int hp_switch; | 217 | unsigned int hp_switch; /* NID of HP as line-out */ |
216 | unsigned int aloopback; | 218 | unsigned int aloopback; |
217 | 219 | ||
218 | struct hda_pcm pcm_rec[2]; /* PCM information */ | 220 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
@@ -1686,6 +1688,10 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | |||
1686 | /* SigmaTel reference board */ | 1688 | /* SigmaTel reference board */ |
1687 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 1689 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
1688 | "DFI LanParty", STAC_92HD71BXX_REF), | 1690 | "DFI LanParty", STAC_92HD71BXX_REF), |
1691 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2, | ||
1692 | "HP dv5", STAC_HP_M4), | ||
1693 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, | ||
1694 | "HP dv7", STAC_HP_M4), | ||
1689 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, | 1695 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
1690 | "unknown HP", STAC_HP_M4), | 1696 | "unknown HP", STAC_HP_M4), |
1691 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, | 1697 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
@@ -2443,7 +2449,7 @@ static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, | |||
2443 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2449 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2444 | struct sigmatel_spec *spec = codec->spec; | 2450 | struct sigmatel_spec *spec = codec->spec; |
2445 | 2451 | ||
2446 | ucontrol->value.integer.value[0] = spec->hp_switch; | 2452 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
2447 | return 0; | 2453 | return 0; |
2448 | } | 2454 | } |
2449 | 2455 | ||
@@ -2452,8 +2458,9 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, | |||
2452 | { | 2458 | { |
2453 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2459 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2454 | struct sigmatel_spec *spec = codec->spec; | 2460 | struct sigmatel_spec *spec = codec->spec; |
2455 | 2461 | int nid = kcontrol->private_value; | |
2456 | spec->hp_switch = ucontrol->value.integer.value[0]; | 2462 | |
2463 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; | ||
2457 | 2464 | ||
2458 | /* check to be sure that the ports are upto date with | 2465 | /* check to be sure that the ports are upto date with |
2459 | * switch changes | 2466 | * switch changes |
@@ -2586,8 +2593,10 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = { | |||
2586 | }; | 2593 | }; |
2587 | 2594 | ||
2588 | /* add dynamic controls */ | 2595 | /* add dynamic controls */ |
2589 | static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type, | 2596 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
2590 | int idx, const char *name, unsigned long val) | 2597 | struct snd_kcontrol_new *ktemp, |
2598 | int idx, const char *name, | ||
2599 | unsigned long val) | ||
2591 | { | 2600 | { |
2592 | struct snd_kcontrol_new *knew; | 2601 | struct snd_kcontrol_new *knew; |
2593 | 2602 | ||
@@ -2606,20 +2615,29 @@ static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type, | |||
2606 | } | 2615 | } |
2607 | 2616 | ||
2608 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | 2617 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
2609 | *knew = stac92xx_control_templates[type]; | 2618 | *knew = *ktemp; |
2610 | knew->index = idx; | 2619 | knew->index = idx; |
2611 | knew->name = kstrdup(name, GFP_KERNEL); | 2620 | knew->name = kstrdup(name, GFP_KERNEL); |
2612 | if (! knew->name) | 2621 | if (!knew->name) |
2613 | return -ENOMEM; | 2622 | return -ENOMEM; |
2614 | knew->private_value = val; | 2623 | knew->private_value = val; |
2615 | spec->num_kctl_used++; | 2624 | spec->num_kctl_used++; |
2616 | return 0; | 2625 | return 0; |
2617 | } | 2626 | } |
2618 | 2627 | ||
2628 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, | ||
2629 | int type, int idx, const char *name, | ||
2630 | unsigned long val) | ||
2631 | { | ||
2632 | return stac92xx_add_control_temp(spec, | ||
2633 | &stac92xx_control_templates[type], | ||
2634 | idx, name, val); | ||
2635 | } | ||
2636 | |||
2619 | 2637 | ||
2620 | /* add dynamic controls */ | 2638 | /* add dynamic controls */ |
2621 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, | 2639 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
2622 | const char *name, unsigned long val) | 2640 | const char *name, unsigned long val) |
2623 | { | 2641 | { |
2624 | return stac92xx_add_control_idx(spec, type, 0, name, val); | 2642 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
2625 | } | 2643 | } |
@@ -2862,7 +2880,8 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
2862 | if (cfg->hp_outs > 1) { | 2880 | if (cfg->hp_outs > 1) { |
2863 | err = stac92xx_add_control(spec, | 2881 | err = stac92xx_add_control(spec, |
2864 | STAC_CTL_WIDGET_HP_SWITCH, | 2882 | STAC_CTL_WIDGET_HP_SWITCH, |
2865 | "Headphone as Line Out Switch", 0); | 2883 | "Headphone as Line Out Switch", |
2884 | cfg->hp_pins[cfg->hp_outs - 1]); | ||
2866 | if (err < 0) | 2885 | if (err < 0) |
2867 | return err; | 2886 | return err; |
2868 | } | 2887 | } |
@@ -3060,6 +3079,43 @@ static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | |||
3060 | return 0; | 3079 | return 0; |
3061 | } | 3080 | } |
3062 | 3081 | ||
3082 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
3083 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info | ||
3084 | |||
3085 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, | ||
3086 | struct snd_ctl_elem_value *ucontrol) | ||
3087 | { | ||
3088 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3089 | ucontrol->value.integer.value[0] = codec->beep->enabled; | ||
3090 | return 0; | ||
3091 | } | ||
3092 | |||
3093 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, | ||
3094 | struct snd_ctl_elem_value *ucontrol) | ||
3095 | { | ||
3096 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3097 | int enabled = !!ucontrol->value.integer.value[0]; | ||
3098 | if (codec->beep->enabled != enabled) { | ||
3099 | codec->beep->enabled = enabled; | ||
3100 | return 1; | ||
3101 | } | ||
3102 | return 0; | ||
3103 | } | ||
3104 | |||
3105 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { | ||
3106 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
3107 | .info = stac92xx_dig_beep_switch_info, | ||
3108 | .get = stac92xx_dig_beep_switch_get, | ||
3109 | .put = stac92xx_dig_beep_switch_put, | ||
3110 | }; | ||
3111 | |||
3112 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) | ||
3113 | { | ||
3114 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, | ||
3115 | 0, "PC Beep Playback Switch", 0); | ||
3116 | } | ||
3117 | #endif | ||
3118 | |||
3063 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) | 3119 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
3064 | { | 3120 | { |
3065 | struct sigmatel_spec *spec = codec->spec; | 3121 | struct sigmatel_spec *spec = codec->spec; |
@@ -3366,6 +3422,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3366 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 3422 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
3367 | if (spec->digbeep_nid > 0) { | 3423 | if (spec->digbeep_nid > 0) { |
3368 | hda_nid_t nid = spec->digbeep_nid; | 3424 | hda_nid_t nid = spec->digbeep_nid; |
3425 | unsigned int caps; | ||
3369 | 3426 | ||
3370 | err = stac92xx_auto_create_beep_ctls(codec, nid); | 3427 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
3371 | if (err < 0) | 3428 | if (err < 0) |
@@ -3373,6 +3430,14 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3373 | err = snd_hda_attach_beep_device(codec, nid); | 3430 | err = snd_hda_attach_beep_device(codec, nid); |
3374 | if (err < 0) | 3431 | if (err < 0) |
3375 | return err; | 3432 | return err; |
3433 | /* if no beep switch is available, make its own one */ | ||
3434 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); | ||
3435 | if (codec->beep && | ||
3436 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { | ||
3437 | err = stac92xx_beep_switch_ctl(codec); | ||
3438 | if (err < 0) | ||
3439 | return err; | ||
3440 | } | ||
3376 | } | 3441 | } |
3377 | #endif | 3442 | #endif |
3378 | 3443 | ||
@@ -3530,6 +3595,12 @@ static int stac9200_parse_auto_config(struct hda_codec *codec) | |||
3530 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) | 3595 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
3531 | return err; | 3596 | return err; |
3532 | 3597 | ||
3598 | if (spec->num_muxes > 0) { | ||
3599 | err = stac92xx_auto_create_mux_input_ctls(codec); | ||
3600 | if (err < 0) | ||
3601 | return err; | ||
3602 | } | ||
3603 | |||
3533 | if (spec->autocfg.dig_out_pin) | 3604 | if (spec->autocfg.dig_out_pin) |
3534 | spec->multiout.dig_out_nid = 0x05; | 3605 | spec->multiout.dig_out_nid = 0x05; |
3535 | if (spec->autocfg.dig_in_pin) | 3606 | if (spec->autocfg.dig_in_pin) |
@@ -3647,14 +3718,18 @@ static int stac92xx_init(struct hda_codec *codec) | |||
3647 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 3718 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
3648 | hda_nid_t nid = cfg->input_pins[i]; | 3719 | hda_nid_t nid = cfg->input_pins[i]; |
3649 | if (nid) { | 3720 | if (nid) { |
3650 | unsigned int pinctl = snd_hda_codec_read(codec, nid, | 3721 | unsigned int pinctl; |
3651 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 3722 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
3652 | /* if PINCTL already set then skip */ | 3723 | /* for mic pins, force to initialize */ |
3653 | if (pinctl & AC_PINCAP_IN) | 3724 | pinctl = stac92xx_get_vref(codec, nid); |
3654 | continue; | 3725 | } else { |
3655 | pinctl = AC_PINCTL_IN_EN; | 3726 | pinctl = snd_hda_codec_read(codec, nid, 0, |
3656 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) | 3727 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
3657 | pinctl |= stac92xx_get_vref(codec, nid); | 3728 | /* if PINCTL already set then skip */ |
3729 | if (pinctl & AC_PINCTL_IN_EN) | ||
3730 | continue; | ||
3731 | } | ||
3732 | pinctl |= AC_PINCTL_IN_EN; | ||
3658 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | 3733 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
3659 | } | 3734 | } |
3660 | } | 3735 | } |
@@ -3776,11 +3851,30 @@ static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid) | |||
3776 | return 0; | 3851 | return 0; |
3777 | } | 3852 | } |
3778 | 3853 | ||
3854 | /* return non-zero if the hp-pin of the given array index isn't | ||
3855 | * a jack-detection target | ||
3856 | */ | ||
3857 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) | ||
3858 | { | ||
3859 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
3860 | |||
3861 | /* ignore sensing of shared line and mic jacks */ | ||
3862 | if (spec->line_switch && | ||
3863 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE]) | ||
3864 | return 1; | ||
3865 | if (spec->mic_switch && | ||
3866 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC]) | ||
3867 | return 1; | ||
3868 | /* ignore if the pin is set as line-out */ | ||
3869 | if (cfg->hp_pins[i] == spec->hp_switch) | ||
3870 | return 1; | ||
3871 | return 0; | ||
3872 | } | ||
3873 | |||
3779 | static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) | 3874 | static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) |
3780 | { | 3875 | { |
3781 | struct sigmatel_spec *spec = codec->spec; | 3876 | struct sigmatel_spec *spec = codec->spec; |
3782 | struct auto_pin_cfg *cfg = &spec->autocfg; | 3877 | struct auto_pin_cfg *cfg = &spec->autocfg; |
3783 | int nid = cfg->hp_pins[cfg->hp_outs - 1]; | ||
3784 | int i, presence; | 3878 | int i, presence; |
3785 | 3879 | ||
3786 | presence = 0; | 3880 | presence = 0; |
@@ -3791,15 +3885,16 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) | |||
3791 | for (i = 0; i < cfg->hp_outs; i++) { | 3885 | for (i = 0; i < cfg->hp_outs; i++) { |
3792 | if (presence) | 3886 | if (presence) |
3793 | break; | 3887 | break; |
3794 | if (spec->hp_switch && cfg->hp_pins[i] == nid) | 3888 | if (no_hp_sensing(spec, i)) |
3795 | break; | 3889 | continue; |
3796 | presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); | 3890 | presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); |
3797 | } | 3891 | } |
3798 | 3892 | ||
3799 | if (presence) { | 3893 | if (presence) { |
3800 | /* disable lineouts, enable hp */ | 3894 | /* disable lineouts */ |
3801 | if (spec->hp_switch) | 3895 | if (spec->hp_switch) |
3802 | stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN); | 3896 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
3897 | AC_PINCTL_OUT_EN); | ||
3803 | for (i = 0; i < cfg->line_outs; i++) | 3898 | for (i = 0; i < cfg->line_outs; i++) |
3804 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], | 3899 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
3805 | AC_PINCTL_OUT_EN); | 3900 | AC_PINCTL_OUT_EN); |
@@ -3811,9 +3906,10 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) | |||
3811 | spec->gpio_dir, spec->gpio_data & | 3906 | spec->gpio_dir, spec->gpio_data & |
3812 | ~spec->eapd_mask); | 3907 | ~spec->eapd_mask); |
3813 | } else { | 3908 | } else { |
3814 | /* enable lineouts, disable hp */ | 3909 | /* enable lineouts */ |
3815 | if (spec->hp_switch) | 3910 | if (spec->hp_switch) |
3816 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | 3911 | stac92xx_set_pinctl(codec, spec->hp_switch, |
3912 | AC_PINCTL_OUT_EN); | ||
3817 | for (i = 0; i < cfg->line_outs; i++) | 3913 | for (i = 0; i < cfg->line_outs; i++) |
3818 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], | 3914 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
3819 | AC_PINCTL_OUT_EN); | 3915 | AC_PINCTL_OUT_EN); |
@@ -3825,8 +3921,16 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) | |||
3825 | spec->gpio_dir, spec->gpio_data | | 3921 | spec->gpio_dir, spec->gpio_data | |
3826 | spec->eapd_mask); | 3922 | spec->eapd_mask); |
3827 | } | 3923 | } |
3828 | if (!spec->hp_switch && cfg->hp_outs > 1 && presence) | 3924 | /* toggle hp outs */ |
3829 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | 3925 | for (i = 0; i < cfg->hp_outs; i++) { |
3926 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; | ||
3927 | if (no_hp_sensing(spec, i)) | ||
3928 | continue; | ||
3929 | if (presence) | ||
3930 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); | ||
3931 | else | ||
3932 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); | ||
3933 | } | ||
3830 | } | 3934 | } |
3831 | 3935 | ||
3832 | static void stac92xx_pin_sense(struct hda_codec *codec, int idx) | 3936 | static void stac92xx_pin_sense(struct hda_codec *codec, int idx) |
@@ -4378,6 +4482,13 @@ again: | |||
4378 | stac92xx_set_config_regs(codec); | 4482 | stac92xx_set_config_regs(codec); |
4379 | } | 4483 | } |
4380 | 4484 | ||
4485 | if (spec->board_config > STAC_92HD71BXX_REF) { | ||
4486 | /* GPIO0 = EAPD */ | ||
4487 | spec->gpio_mask = 0x01; | ||
4488 | spec->gpio_dir = 0x01; | ||
4489 | spec->gpio_data = 0x01; | ||
4490 | } | ||
4491 | |||
4381 | switch (codec->vendor_id) { | 4492 | switch (codec->vendor_id) { |
4382 | case 0x111d76b6: /* 4 Port without Analog Mixer */ | 4493 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
4383 | case 0x111d76b7: | 4494 | case 0x111d76b7: |
@@ -4388,10 +4499,10 @@ again: | |||
4388 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; | 4499 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
4389 | break; | 4500 | break; |
4390 | case 0x111d7608: /* 5 Port with Analog Mixer */ | 4501 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
4391 | switch (codec->subsystem_id) { | 4502 | switch (spec->board_config) { |
4392 | case 0x103c361a: | 4503 | case STAC_HP_M4: |
4393 | /* Enable VREF power saving on GPIO1 detect */ | 4504 | /* Enable VREF power saving on GPIO1 detect */ |
4394 | snd_hda_codec_write(codec, codec->afg, 0, | 4505 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
4395 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); | 4506 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
4396 | snd_hda_codec_write_cache(codec, codec->afg, 0, | 4507 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
4397 | AC_VERB_SET_UNSOLICITED_ENABLE, | 4508 | AC_VERB_SET_UNSOLICITED_ENABLE, |
@@ -4437,13 +4548,6 @@ again: | |||
4437 | spec->aloopback_mask = 0x50; | 4548 | spec->aloopback_mask = 0x50; |
4438 | spec->aloopback_shift = 0; | 4549 | spec->aloopback_shift = 0; |
4439 | 4550 | ||
4440 | if (spec->board_config > STAC_92HD71BXX_REF) { | ||
4441 | /* GPIO0 = EAPD */ | ||
4442 | spec->gpio_mask = 0x01; | ||
4443 | spec->gpio_dir = 0x01; | ||
4444 | spec->gpio_data = 0x01; | ||
4445 | } | ||
4446 | |||
4447 | spec->powerdown_adcs = 1; | 4551 | spec->powerdown_adcs = 1; |
4448 | spec->digbeep_nid = 0x26; | 4552 | spec->digbeep_nid = 0x26; |
4449 | spec->mux_nids = stac92hd71bxx_mux_nids; | 4553 | spec->mux_nids = stac92hd71bxx_mux_nids; |
@@ -4791,7 +4895,7 @@ static int patch_stac9205(struct hda_codec *codec) | |||
4791 | stac92xx_set_config_reg(codec, 0x20, 0x1c410030); | 4895 | stac92xx_set_config_reg(codec, 0x20, 0x1c410030); |
4792 | 4896 | ||
4793 | /* Enable unsol response for GPIO4/Dock HP connection */ | 4897 | /* Enable unsol response for GPIO4/Dock HP connection */ |
4794 | snd_hda_codec_write(codec, codec->afg, 0, | 4898 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
4795 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); | 4899 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
4796 | snd_hda_codec_write_cache(codec, codec->afg, 0, | 4900 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
4797 | AC_VERB_SET_UNSOLICITED_ENABLE, | 4901 | AC_VERB_SET_UNSOLICITED_ENABLE, |
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 0e06c6c9fcc0..73de6e989b3d 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c | |||
@@ -1229,8 +1229,11 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1229 | return -ENOMEM; | 1229 | return -ENOMEM; |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) | 1232 | if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) { |
1233 | kfree(mgr); | ||
1234 | pci_disable_device(pci); | ||
1233 | return -ENODEV; | 1235 | return -ENODEV; |
1236 | } | ||
1234 | card_name = pcxhr_board_params[pci_id->driver_data].board_name; | 1237 | card_name = pcxhr_board_params[pci_id->driver_data].board_name; |
1235 | mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; | 1238 | mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; |
1236 | mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; | 1239 | mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; |