diff options
| author | Steve French <sfrench@hera.kernel.org> | 2005-06-06 12:57:33 -0400 |
|---|---|---|
| committer | Steve French <sfrench@hera.kernel.org> | 2005-06-06 12:57:33 -0400 |
| commit | 0b68177ccd12866d9f19cafad212b861c9d02a8c (patch) | |
| tree | 6fc26aa59fb183fe9c86d44ae14ce423ad7211da | |
| parent | d0d2f2df65ddea9a30ddd117f769bfff65d3fc56 (diff) | |
| parent | 7cef5677ef3a8084f2588ce0a129dc95d65161f6 (diff) | |
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
56 files changed, 2337 insertions, 1322 deletions
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl index cf2fce7707da..6df1dfd18b65 100644 --- a/Documentation/DocBook/libata.tmpl +++ b/Documentation/DocBook/libata.tmpl | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | </authorgroup> | 14 | </authorgroup> |
| 15 | 15 | ||
| 16 | <copyright> | 16 | <copyright> |
| 17 | <year>2003</year> | 17 | <year>2003-2005</year> |
| 18 | <holder>Jeff Garzik</holder> | 18 | <holder>Jeff Garzik</holder> |
| 19 | </copyright> | 19 | </copyright> |
| 20 | 20 | ||
| @@ -44,30 +44,38 @@ | |||
| 44 | 44 | ||
| 45 | <toc></toc> | 45 | <toc></toc> |
| 46 | 46 | ||
| 47 | <chapter id="libataThanks"> | 47 | <chapter id="libataIntroduction"> |
| 48 | <title>Thanks</title> | 48 | <title>Introduction</title> |
| 49 | <para> | 49 | <para> |
| 50 | The bulk of the ATA knowledge comes thanks to long conversations with | 50 | libATA is a library used inside the Linux kernel to support ATA host |
| 51 | Andre Hedrick (www.linux-ide.org). | 51 | controllers and devices. libATA provides an ATA driver API, class |
| 52 | transports for ATA and ATAPI devices, and SCSI<->ATA translation | ||
| 53 | for ATA devices according to the T10 SAT specification. | ||
| 52 | </para> | 54 | </para> |
| 53 | <para> | 55 | <para> |
| 54 | Thanks to Alan Cox for pointing out similarities | 56 | This Guide documents the libATA driver API, library functions, library |
| 55 | between SATA and SCSI, and in general for motivation to hack on | 57 | internals, and a couple sample ATA low-level drivers. |
| 56 | libata. | ||
| 57 | </para> | ||
| 58 | <para> | ||
| 59 | libata's device detection | ||
| 60 | method, ata_pio_devchk, and in general all the early probing was | ||
| 61 | based on extensive study of Hale Landis's probe/reset code in his | ||
| 62 | ATADRVR driver (www.ata-atapi.com). | ||
| 63 | </para> | 58 | </para> |
| 64 | </chapter> | 59 | </chapter> |
| 65 | 60 | ||
| 66 | <chapter id="libataDriverApi"> | 61 | <chapter id="libataDriverApi"> |
| 67 | <title>libata Driver API</title> | 62 | <title>libata Driver API</title> |
| 63 | <para> | ||
| 64 | struct ata_port_operations is defined for every low-level libata | ||
| 65 | hardware driver, and it controls how the low-level driver | ||
| 66 | interfaces with the ATA and SCSI layers. | ||
| 67 | </para> | ||
| 68 | <para> | ||
| 69 | FIS-based drivers will hook into the system with ->qc_prep() and | ||
| 70 | ->qc_issue() high-level hooks. Hardware which behaves in a manner | ||
| 71 | similar to PCI IDE hardware may utilize several generic helpers, | ||
| 72 | defining at a bare minimum the bus I/O addresses of the ATA shadow | ||
| 73 | register blocks. | ||
| 74 | </para> | ||
| 68 | <sect1> | 75 | <sect1> |
| 69 | <title>struct ata_port_operations</title> | 76 | <title>struct ata_port_operations</title> |
| 70 | 77 | ||
| 78 | <sect2><title>Disable ATA port</title> | ||
| 71 | <programlisting> | 79 | <programlisting> |
| 72 | void (*port_disable) (struct ata_port *); | 80 | void (*port_disable) (struct ata_port *); |
| 73 | </programlisting> | 81 | </programlisting> |
| @@ -78,6 +86,9 @@ void (*port_disable) (struct ata_port *); | |||
| 78 | unplug). | 86 | unplug). |
| 79 | </para> | 87 | </para> |
| 80 | 88 | ||
| 89 | </sect2> | ||
| 90 | |||
| 91 | <sect2><title>Post-IDENTIFY device configuration</title> | ||
| 81 | <programlisting> | 92 | <programlisting> |
| 82 | void (*dev_config) (struct ata_port *, struct ata_device *); | 93 | void (*dev_config) (struct ata_port *, struct ata_device *); |
| 83 | </programlisting> | 94 | </programlisting> |
| @@ -88,6 +99,9 @@ void (*dev_config) (struct ata_port *, struct ata_device *); | |||
| 88 | issue of SET FEATURES - XFER MODE, and prior to operation. | 99 | issue of SET FEATURES - XFER MODE, and prior to operation. |
| 89 | </para> | 100 | </para> |
| 90 | 101 | ||
| 102 | </sect2> | ||
| 103 | |||
| 104 | <sect2><title>Set PIO/DMA mode</title> | ||
| 91 | <programlisting> | 105 | <programlisting> |
| 92 | void (*set_piomode) (struct ata_port *, struct ata_device *); | 106 | void (*set_piomode) (struct ata_port *, struct ata_device *); |
| 93 | void (*set_dmamode) (struct ata_port *, struct ata_device *); | 107 | void (*set_dmamode) (struct ata_port *, struct ata_device *); |
| @@ -108,6 +122,9 @@ void (*post_set_mode) (struct ata_port *ap); | |||
| 108 | ->set_dma_mode() is only called if DMA is possible. | 122 | ->set_dma_mode() is only called if DMA is possible. |
| 109 | </para> | 123 | </para> |
| 110 | 124 | ||
| 125 | </sect2> | ||
| 126 | |||
| 127 | <sect2><title>Taskfile read/write</title> | ||
| 111 | <programlisting> | 128 | <programlisting> |
| 112 | void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); | 129 | void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); |
| 113 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | 130 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); |
| @@ -120,6 +137,9 @@ void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | |||
| 120 | taskfile register values. | 137 | taskfile register values. |
| 121 | </para> | 138 | </para> |
| 122 | 139 | ||
| 140 | </sect2> | ||
| 141 | |||
| 142 | <sect2><title>ATA command execute</title> | ||
| 123 | <programlisting> | 143 | <programlisting> |
| 124 | void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); | 144 | void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); |
| 125 | </programlisting> | 145 | </programlisting> |
| @@ -129,17 +149,37 @@ void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); | |||
| 129 | ->tf_load(), to be initiated in hardware. | 149 | ->tf_load(), to be initiated in hardware. |
| 130 | </para> | 150 | </para> |
| 131 | 151 | ||
| 152 | </sect2> | ||
| 153 | |||
| 154 | <sect2><title>Per-cmd ATAPI DMA capabilities filter</title> | ||
| 155 | <programlisting> | ||
| 156 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); | ||
| 157 | </programlisting> | ||
| 158 | |||
| 159 | <para> | ||
| 160 | Allow low-level driver to filter ATA PACKET commands, returning a status | ||
| 161 | indicating whether or not it is OK to use DMA for the supplied PACKET | ||
| 162 | command. | ||
| 163 | </para> | ||
| 164 | |||
| 165 | </sect2> | ||
| 166 | |||
| 167 | <sect2><title>Read specific ATA shadow registers</title> | ||
| 132 | <programlisting> | 168 | <programlisting> |
| 133 | u8 (*check_status)(struct ata_port *ap); | 169 | u8 (*check_status)(struct ata_port *ap); |
| 134 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 170 | u8 (*check_altstatus)(struct ata_port *ap); |
| 171 | u8 (*check_err)(struct ata_port *ap); | ||
| 135 | </programlisting> | 172 | </programlisting> |
| 136 | 173 | ||
| 137 | <para> | 174 | <para> |
| 138 | Reads the Status ATA shadow register from hardware. On some | 175 | Reads the Status/AltStatus/Error ATA shadow register from |
| 139 | hardware, this has the side effect of clearing the interrupt | 176 | hardware. On some hardware, reading the Status register has |
| 140 | condition. | 177 | the side effect of clearing the interrupt condition. |
| 141 | </para> | 178 | </para> |
| 142 | 179 | ||
| 180 | </sect2> | ||
| 181 | |||
| 182 | <sect2><title>Select ATA device on bus</title> | ||
| 143 | <programlisting> | 183 | <programlisting> |
| 144 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 184 | void (*dev_select)(struct ata_port *ap, unsigned int device); |
| 145 | </programlisting> | 185 | </programlisting> |
| @@ -147,9 +187,13 @@ void (*dev_select)(struct ata_port *ap, unsigned int device); | |||
| 147 | <para> | 187 | <para> |
| 148 | Issues the low-level hardware command(s) that causes one of N | 188 | Issues the low-level hardware command(s) that causes one of N |
| 149 | hardware devices to be considered 'selected' (active and | 189 | hardware devices to be considered 'selected' (active and |
| 150 | available for use) on the ATA bus. | 190 | available for use) on the ATA bus. This generally has no |
| 191 | meaning on FIS-based devices. | ||
| 151 | </para> | 192 | </para> |
| 152 | 193 | ||
| 194 | </sect2> | ||
| 195 | |||
| 196 | <sect2><title>Reset ATA bus</title> | ||
| 153 | <programlisting> | 197 | <programlisting> |
| 154 | void (*phy_reset) (struct ata_port *ap); | 198 | void (*phy_reset) (struct ata_port *ap); |
| 155 | </programlisting> | 199 | </programlisting> |
| @@ -162,17 +206,31 @@ void (*phy_reset) (struct ata_port *ap); | |||
| 162 | functions ata_bus_reset() or sata_phy_reset() for this hook. | 206 | functions ata_bus_reset() or sata_phy_reset() for this hook. |
| 163 | </para> | 207 | </para> |
| 164 | 208 | ||
| 209 | </sect2> | ||
| 210 | |||
| 211 | <sect2><title>Control PCI IDE BMDMA engine</title> | ||
| 165 | <programlisting> | 212 | <programlisting> |
| 166 | void (*bmdma_setup) (struct ata_queued_cmd *qc); | 213 | void (*bmdma_setup) (struct ata_queued_cmd *qc); |
| 167 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 214 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
| 215 | void (*bmdma_stop) (struct ata_port *ap); | ||
| 216 | u8 (*bmdma_status) (struct ata_port *ap); | ||
| 168 | </programlisting> | 217 | </programlisting> |
| 169 | 218 | ||
| 170 | <para> | 219 | <para> |
| 171 | When setting up an IDE BMDMA transaction, these hooks arm | 220 | When setting up an IDE BMDMA transaction, these hooks arm |
| 172 | (->bmdma_setup) and fire (->bmdma_start) the hardware's DMA | 221 | (->bmdma_setup), fire (->bmdma_start), and halt (->bmdma_stop) |
| 173 | engine. | 222 | the hardware's DMA engine. ->bmdma_status is used to read the standard |
| 223 | PCI IDE DMA Status register. | ||
| 174 | </para> | 224 | </para> |
| 175 | 225 | ||
| 226 | <para> | ||
| 227 | These hooks are typically either no-ops, or simply not implemented, in | ||
| 228 | FIS-based drivers. | ||
| 229 | </para> | ||
| 230 | |||
| 231 | </sect2> | ||
| 232 | |||
| 233 | <sect2><title>High-level taskfile hooks</title> | ||
| 176 | <programlisting> | 234 | <programlisting> |
| 177 | void (*qc_prep) (struct ata_queued_cmd *qc); | 235 | void (*qc_prep) (struct ata_queued_cmd *qc); |
| 178 | int (*qc_issue) (struct ata_queued_cmd *qc); | 236 | int (*qc_issue) (struct ata_queued_cmd *qc); |
| @@ -190,20 +248,26 @@ int (*qc_issue) (struct ata_queued_cmd *qc); | |||
| 190 | ->qc_issue is used to make a command active, once the hardware | 248 | ->qc_issue is used to make a command active, once the hardware |
| 191 | and S/G tables have been prepared. IDE BMDMA drivers use the | 249 | and S/G tables have been prepared. IDE BMDMA drivers use the |
| 192 | helper function ata_qc_issue_prot() for taskfile protocol-based | 250 | helper function ata_qc_issue_prot() for taskfile protocol-based |
| 193 | dispatch. More advanced drivers roll their own ->qc_issue | 251 | dispatch. More advanced drivers implement their own ->qc_issue. |
| 194 | implementation, using this as the "issue new ATA command to | ||
| 195 | hardware" hook. | ||
| 196 | </para> | 252 | </para> |
| 197 | 253 | ||
| 254 | </sect2> | ||
| 255 | |||
| 256 | <sect2><title>Timeout (error) handling</title> | ||
| 198 | <programlisting> | 257 | <programlisting> |
| 199 | void (*eng_timeout) (struct ata_port *ap); | 258 | void (*eng_timeout) (struct ata_port *ap); |
| 200 | </programlisting> | 259 | </programlisting> |
| 201 | 260 | ||
| 202 | <para> | 261 | <para> |
| 203 | This is a high level error handling function, called from the | 262 | This is a high level error handling function, called from the |
| 204 | error handling thread, when a command times out. | 263 | error handling thread, when a command times out. Most newer |
| 264 | hardware will implement its own error handling code here. IDE BMDMA | ||
| 265 | drivers may use the helper function ata_eng_timeout(). | ||
| 205 | </para> | 266 | </para> |
| 206 | 267 | ||
| 268 | </sect2> | ||
| 269 | |||
| 270 | <sect2><title>Hardware interrupt handling</title> | ||
| 207 | <programlisting> | 271 | <programlisting> |
| 208 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); | 272 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); |
| 209 | void (*irq_clear) (struct ata_port *); | 273 | void (*irq_clear) (struct ata_port *); |
| @@ -216,6 +280,9 @@ void (*irq_clear) (struct ata_port *); | |||
| 216 | is quiet. | 280 | is quiet. |
| 217 | </para> | 281 | </para> |
| 218 | 282 | ||
| 283 | </sect2> | ||
| 284 | |||
| 285 | <sect2><title>SATA phy read/write</title> | ||
| 219 | <programlisting> | 286 | <programlisting> |
| 220 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); | 287 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); |
| 221 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | 288 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, |
| @@ -227,6 +294,9 @@ void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | |||
| 227 | if ->phy_reset hook called the sata_phy_reset() helper function. | 294 | if ->phy_reset hook called the sata_phy_reset() helper function. |
| 228 | </para> | 295 | </para> |
| 229 | 296 | ||
| 297 | </sect2> | ||
| 298 | |||
| 299 | <sect2><title>Init and shutdown</title> | ||
| 230 | <programlisting> | 300 | <programlisting> |
| 231 | int (*port_start) (struct ata_port *ap); | 301 | int (*port_start) (struct ata_port *ap); |
| 232 | void (*port_stop) (struct ata_port *ap); | 302 | void (*port_stop) (struct ata_port *ap); |
| @@ -240,15 +310,17 @@ void (*host_stop) (struct ata_host_set *host_set); | |||
| 240 | tasks. | 310 | tasks. |
| 241 | </para> | 311 | </para> |
| 242 | <para> | 312 | <para> |
| 243 | ->host_stop() is called when the rmmod or hot unplug process | ||
| 244 | begins. The hook must stop all hardware interrupts, DMA | ||
| 245 | engines, etc. | ||
| 246 | </para> | ||
| 247 | <para> | ||
| 248 | ->port_stop() is called after ->host_stop(). It's sole function | 313 | ->port_stop() is called after ->host_stop(). It's sole function |
| 249 | is to release DMA/memory resources, now that they are no longer | 314 | is to release DMA/memory resources, now that they are no longer |
| 250 | actively being used. | 315 | actively being used. |
| 251 | </para> | 316 | </para> |
| 317 | <para> | ||
| 318 | ->host_stop() is called after all ->port_stop() calls | ||
| 319 | have completed. The hook must finalize hardware shutdown, release DMA | ||
| 320 | and other resources, etc. | ||
| 321 | </para> | ||
| 322 | |||
| 323 | </sect2> | ||
| 252 | 324 | ||
| 253 | </sect1> | 325 | </sect1> |
| 254 | </chapter> | 326 | </chapter> |
| @@ -279,4 +351,24 @@ void (*host_stop) (struct ata_host_set *host_set); | |||
| 279 | !Idrivers/scsi/sata_sil.c | 351 | !Idrivers/scsi/sata_sil.c |
| 280 | </chapter> | 352 | </chapter> |
| 281 | 353 | ||
| 354 | <chapter id="libataThanks"> | ||
| 355 | <title>Thanks</title> | ||
| 356 | <para> | ||
| 357 | The bulk of the ATA knowledge comes thanks to long conversations with | ||
| 358 | Andre Hedrick (www.linux-ide.org), and long hours pondering the ATA | ||
| 359 | and SCSI specifications. | ||
| 360 | </para> | ||
| 361 | <para> | ||
| 362 | Thanks to Alan Cox for pointing out similarities | ||
| 363 | between SATA and SCSI, and in general for motivation to hack on | ||
| 364 | libata. | ||
| 365 | </para> | ||
| 366 | <para> | ||
| 367 | libata's device detection | ||
| 368 | method, ata_pio_devchk, and in general all the early probing was | ||
| 369 | based on extensive study of Hale Landis's probe/reset code in his | ||
| 370 | ATADRVR driver (www.ata-atapi.com). | ||
| 371 | </para> | ||
| 372 | </chapter> | ||
| 373 | |||
| 282 | </book> | 374 | </book> |
| @@ -1,7 +1,7 @@ | |||
| 1 | VERSION = 2 | 1 | VERSION = 2 |
| 2 | PATCHLEVEL = 6 | 2 | PATCHLEVEL = 6 |
| 3 | SUBLEVEL = 12 | 3 | SUBLEVEL = 12 |
| 4 | EXTRAVERSION =-rc5 | 4 | EXTRAVERSION =-rc6 |
| 5 | NAME=Woozy Numbat | 5 | NAME=Woozy Numbat |
| 6 | 6 | ||
| 7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c index 2b6c9d32b7a6..c4a33f265dc0 100644 --- a/arch/m68knommu/kernel/process.c +++ b/arch/m68knommu/kernel/process.c | |||
| @@ -45,11 +45,13 @@ asmlinkage void ret_from_fork(void); | |||
| 45 | */ | 45 | */ |
| 46 | void default_idle(void) | 46 | void default_idle(void) |
| 47 | { | 47 | { |
| 48 | while(1) { | 48 | local_irq_disable(); |
| 49 | if (need_resched()) | 49 | while (!need_resched()) { |
| 50 | __asm__("stop #0x2000" : : : "cc"); | 50 | /* This stop will re-enable interrupts */ |
| 51 | schedule(); | 51 | __asm__("stop #0x2000" : : : "cc"); |
| 52 | local_irq_disable(); | ||
| 52 | } | 53 | } |
| 54 | local_irq_enable(); | ||
| 53 | } | 55 | } |
| 54 | 56 | ||
| 55 | void (*idle)(void) = default_idle; | 57 | void (*idle)(void) = default_idle; |
| @@ -63,7 +65,12 @@ void (*idle)(void) = default_idle; | |||
| 63 | void cpu_idle(void) | 65 | void cpu_idle(void) |
| 64 | { | 66 | { |
| 65 | /* endless idle loop with no priority at all */ | 67 | /* endless idle loop with no priority at all */ |
| 66 | idle(); | 68 | while (1) { |
| 69 | idle(); | ||
| 70 | preempt_enable_no_resched(); | ||
| 71 | schedule(); | ||
| 72 | preempt_disable(); | ||
| 73 | } | ||
| 67 | } | 74 | } |
| 68 | 75 | ||
| 69 | void machine_restart(char * __unused) | 76 | void machine_restart(char * __unused) |
diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S index d3604056e1a9..b61572eb2a71 100644 --- a/arch/ppc64/kernel/entry.S +++ b/arch/ppc64/kernel/entry.S | |||
| @@ -436,15 +436,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) | |||
| 436 | REST_8GPRS(14, r1) | 436 | REST_8GPRS(14, r1) |
| 437 | REST_10GPRS(22, r1) | 437 | REST_10GPRS(22, r1) |
| 438 | 438 | ||
| 439 | #ifdef CONFIG_PPC_ISERIES | ||
| 440 | clrrdi r7,r1,THREAD_SHIFT /* get current_thread_info() */ | ||
| 441 | ld r7,TI_FLAGS(r7) /* Get run light flag */ | ||
| 442 | mfspr r9,CTRLF | ||
| 443 | srdi r7,r7,TIF_RUN_LIGHT | ||
| 444 | insrdi r9,r7,1,63 /* Insert run light into CTRL */ | ||
| 445 | mtspr CTRLT,r9 | ||
| 446 | #endif | ||
| 447 | |||
| 448 | /* convert old thread to its task_struct for return value */ | 439 | /* convert old thread to its task_struct for return value */ |
| 449 | addi r3,r3,-THREAD | 440 | addi r3,r3,-THREAD |
| 450 | ld r7,_NIP(r1) /* Return to _switch caller in new task */ | 441 | ld r7,_NIP(r1) /* Return to _switch caller in new task */ |
diff --git a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S index 92a744c31ab1..346dbf606b5d 100644 --- a/arch/ppc64/kernel/head.S +++ b/arch/ppc64/kernel/head.S | |||
| @@ -626,10 +626,10 @@ system_reset_iSeries: | |||
| 626 | lhz r24,PACAPACAINDEX(r13) /* Get processor # */ | 626 | lhz r24,PACAPACAINDEX(r13) /* Get processor # */ |
| 627 | cmpwi 0,r24,0 /* Are we processor 0? */ | 627 | cmpwi 0,r24,0 /* Are we processor 0? */ |
| 628 | beq .__start_initialization_iSeries /* Start up the first processor */ | 628 | beq .__start_initialization_iSeries /* Start up the first processor */ |
| 629 | mfspr r4,CTRLF | 629 | mfspr r4,SPRN_CTRLF |
| 630 | li r5,RUNLATCH /* Turn off the run light */ | 630 | li r5,CTRL_RUNLATCH /* Turn off the run light */ |
| 631 | andc r4,r4,r5 | 631 | andc r4,r4,r5 |
| 632 | mtspr CTRLT,r4 | 632 | mtspr SPRN_CTRLT,r4 |
| 633 | 633 | ||
| 634 | 1: | 634 | 1: |
| 635 | HMT_LOW | 635 | HMT_LOW |
| @@ -2082,9 +2082,9 @@ _GLOBAL(hmt_start_secondary) | |||
| 2082 | mfspr r4, HID0 | 2082 | mfspr r4, HID0 |
| 2083 | ori r4, r4, 0x1 | 2083 | ori r4, r4, 0x1 |
| 2084 | mtspr HID0, r4 | 2084 | mtspr HID0, r4 |
| 2085 | mfspr r4, CTRLF | 2085 | mfspr r4, SPRN_CTRLF |
| 2086 | oris r4, r4, 0x40 | 2086 | oris r4, r4, 0x40 |
| 2087 | mtspr CTRLT, r4 | 2087 | mtspr SPRN_CTRLT, r4 |
| 2088 | blr | 2088 | blr |
| 2089 | #endif | 2089 | #endif |
| 2090 | 2090 | ||
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c index da20120f2261..6d06eb550a3f 100644 --- a/arch/ppc64/kernel/iSeries_setup.c +++ b/arch/ppc64/kernel/iSeries_setup.c | |||
| @@ -852,6 +852,28 @@ static int __init iSeries_src_init(void) | |||
| 852 | 852 | ||
| 853 | late_initcall(iSeries_src_init); | 853 | late_initcall(iSeries_src_init); |
| 854 | 854 | ||
| 855 | static int set_spread_lpevents(char *str) | ||
| 856 | { | ||
| 857 | unsigned long i; | ||
| 858 | unsigned long val = simple_strtoul(str, NULL, 0); | ||
| 859 | |||
| 860 | /* | ||
| 861 | * The parameter is the number of processors to share in processing | ||
| 862 | * lp events. | ||
| 863 | */ | ||
| 864 | if (( val > 0) && (val <= NR_CPUS)) { | ||
| 865 | for (i = 1; i < val; ++i) | ||
| 866 | paca[i].lpqueue_ptr = paca[0].lpqueue_ptr; | ||
| 867 | |||
| 868 | printk("lpevent processing spread over %ld processors\n", val); | ||
| 869 | } else { | ||
| 870 | printk("invalid spread_lpevents %ld\n", val); | ||
| 871 | } | ||
| 872 | |||
| 873 | return 1; | ||
| 874 | } | ||
| 875 | __setup("spread_lpevents=", set_spread_lpevents); | ||
| 876 | |||
| 855 | void __init iSeries_early_setup(void) | 877 | void __init iSeries_early_setup(void) |
| 856 | { | 878 | { |
| 857 | iSeries_fixup_klimit(); | 879 | iSeries_fixup_klimit(); |
diff --git a/arch/ppc64/kernel/idle.c b/arch/ppc64/kernel/idle.c index 6abc621d3ba0..f24ce2b87200 100644 --- a/arch/ppc64/kernel/idle.c +++ b/arch/ppc64/kernel/idle.c | |||
| @@ -75,13 +75,9 @@ static int iSeries_idle(void) | |||
| 75 | { | 75 | { |
| 76 | struct paca_struct *lpaca; | 76 | struct paca_struct *lpaca; |
| 77 | long oldval; | 77 | long oldval; |
| 78 | unsigned long CTRL; | ||
| 79 | 78 | ||
| 80 | /* ensure iSeries run light will be out when idle */ | 79 | /* ensure iSeries run light will be out when idle */ |
| 81 | clear_thread_flag(TIF_RUN_LIGHT); | 80 | ppc64_runlatch_off(); |
| 82 | CTRL = mfspr(CTRLF); | ||
| 83 | CTRL &= ~RUNLATCH; | ||
| 84 | mtspr(CTRLT, CTRL); | ||
| 85 | 81 | ||
| 86 | lpaca = get_paca(); | 82 | lpaca = get_paca(); |
| 87 | 83 | ||
| @@ -111,7 +107,9 @@ static int iSeries_idle(void) | |||
| 111 | } | 107 | } |
| 112 | } | 108 | } |
| 113 | 109 | ||
| 110 | ppc64_runlatch_on(); | ||
| 114 | schedule(); | 111 | schedule(); |
| 112 | ppc64_runlatch_off(); | ||
| 115 | } | 113 | } |
| 116 | 114 | ||
| 117 | return 0; | 115 | return 0; |
diff --git a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c index 8b0686122738..cdfecbeb331f 100644 --- a/arch/ppc64/kernel/process.c +++ b/arch/ppc64/kernel/process.c | |||
| @@ -378,9 +378,6 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp, | |||
| 378 | childregs->gpr[1] = sp + sizeof(struct pt_regs); | 378 | childregs->gpr[1] = sp + sizeof(struct pt_regs); |
| 379 | p->thread.regs = NULL; /* no user register state */ | 379 | p->thread.regs = NULL; /* no user register state */ |
| 380 | clear_ti_thread_flag(p->thread_info, TIF_32BIT); | 380 | clear_ti_thread_flag(p->thread_info, TIF_32BIT); |
| 381 | #ifdef CONFIG_PPC_ISERIES | ||
| 382 | set_ti_thread_flag(p->thread_info, TIF_RUN_LIGHT); | ||
| 383 | #endif | ||
| 384 | } else { | 381 | } else { |
| 385 | childregs->gpr[1] = usp; | 382 | childregs->gpr[1] = usp; |
| 386 | p->thread.regs = childregs; | 383 | p->thread.regs = childregs; |
diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c index 1ac531ba7056..b7683abfbe6a 100644 --- a/arch/ppc64/kernel/prom_init.c +++ b/arch/ppc64/kernel/prom_init.c | |||
| @@ -1370,7 +1370,7 @@ static int __init prom_find_machine_type(void) | |||
| 1370 | } | 1370 | } |
| 1371 | /* Default to pSeries. We need to know if we are running LPAR */ | 1371 | /* Default to pSeries. We need to know if we are running LPAR */ |
| 1372 | rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); | 1372 | rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); |
| 1373 | if (!PHANDLE_VALID(rtas)) { | 1373 | if (PHANDLE_VALID(rtas)) { |
| 1374 | int x = prom_getproplen(rtas, "ibm,hypertas-functions"); | 1374 | int x = prom_getproplen(rtas, "ibm,hypertas-functions"); |
| 1375 | if (x != PROM_ERROR) { | 1375 | if (x != PROM_ERROR) { |
| 1376 | prom_printf("Hypertas detected, assuming LPAR !\n"); | 1376 | prom_printf("Hypertas detected, assuming LPAR !\n"); |
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c index 21c57f539c29..dce198d39328 100644 --- a/arch/ppc64/kernel/setup.c +++ b/arch/ppc64/kernel/setup.c | |||
| @@ -103,11 +103,6 @@ extern void unflatten_device_tree(void); | |||
| 103 | 103 | ||
| 104 | extern void smp_release_cpus(void); | 104 | extern void smp_release_cpus(void); |
| 105 | 105 | ||
| 106 | unsigned long decr_overclock = 1; | ||
| 107 | unsigned long decr_overclock_proc0 = 1; | ||
| 108 | unsigned long decr_overclock_set = 0; | ||
| 109 | unsigned long decr_overclock_proc0_set = 0; | ||
| 110 | |||
| 111 | int have_of = 1; | 106 | int have_of = 1; |
| 112 | int boot_cpuid = 0; | 107 | int boot_cpuid = 0; |
| 113 | int boot_cpuid_phys = 0; | 108 | int boot_cpuid_phys = 0; |
| @@ -1120,64 +1115,15 @@ void ppc64_dump_msg(unsigned int src, const char *msg) | |||
| 1120 | printk("[dump]%04x %s\n", src, msg); | 1115 | printk("[dump]%04x %s\n", src, msg); |
| 1121 | } | 1116 | } |
| 1122 | 1117 | ||
| 1123 | int set_spread_lpevents( char * str ) | ||
| 1124 | { | ||
| 1125 | /* The parameter is the number of processors to share in processing lp events */ | ||
| 1126 | unsigned long i; | ||
| 1127 | unsigned long val = simple_strtoul( str, NULL, 0 ); | ||
| 1128 | if ( ( val > 0 ) && ( val <= NR_CPUS ) ) { | ||
| 1129 | for ( i=1; i<val; ++i ) | ||
| 1130 | paca[i].lpqueue_ptr = paca[0].lpqueue_ptr; | ||
| 1131 | printk("lpevent processing spread over %ld processors\n", val); | ||
| 1132 | } | ||
| 1133 | else | ||
| 1134 | printk("invalid spreaqd_lpevents %ld\n", val); | ||
| 1135 | return 1; | ||
| 1136 | } | ||
| 1137 | |||
| 1138 | /* This should only be called on processor 0 during calibrate decr */ | 1118 | /* This should only be called on processor 0 during calibrate decr */ |
| 1139 | void setup_default_decr(void) | 1119 | void setup_default_decr(void) |
| 1140 | { | 1120 | { |
| 1141 | struct paca_struct *lpaca = get_paca(); | 1121 | struct paca_struct *lpaca = get_paca(); |
| 1142 | 1122 | ||
| 1143 | if ( decr_overclock_set && !decr_overclock_proc0_set ) | 1123 | lpaca->default_decr = tb_ticks_per_jiffy; |
| 1144 | decr_overclock_proc0 = decr_overclock; | ||
| 1145 | |||
| 1146 | lpaca->default_decr = tb_ticks_per_jiffy / decr_overclock_proc0; | ||
| 1147 | lpaca->next_jiffy_update_tb = get_tb() + tb_ticks_per_jiffy; | 1124 | lpaca->next_jiffy_update_tb = get_tb() + tb_ticks_per_jiffy; |
| 1148 | } | 1125 | } |
| 1149 | 1126 | ||
| 1150 | int set_decr_overclock_proc0( char * str ) | ||
| 1151 | { | ||
| 1152 | unsigned long val = simple_strtoul( str, NULL, 0 ); | ||
| 1153 | if ( ( val >= 1 ) && ( val <= 48 ) ) { | ||
| 1154 | decr_overclock_proc0_set = 1; | ||
| 1155 | decr_overclock_proc0 = val; | ||
| 1156 | printk("proc 0 decrementer overclock factor of %ld\n", val); | ||
| 1157 | } | ||
| 1158 | else | ||
| 1159 | printk("invalid proc 0 decrementer overclock factor of %ld\n", val); | ||
| 1160 | return 1; | ||
| 1161 | } | ||
| 1162 | |||
| 1163 | int set_decr_overclock( char * str ) | ||
| 1164 | { | ||
| 1165 | unsigned long val = simple_strtoul( str, NULL, 0 ); | ||
| 1166 | if ( ( val >= 1 ) && ( val <= 48 ) ) { | ||
| 1167 | decr_overclock_set = 1; | ||
| 1168 | decr_overclock = val; | ||
| 1169 | printk("decrementer overclock factor of %ld\n", val); | ||
| 1170 | } | ||
| 1171 | else | ||
| 1172 | printk("invalid decrementer overclock factor of %ld\n", val); | ||
| 1173 | return 1; | ||
| 1174 | |||
| 1175 | } | ||
| 1176 | |||
| 1177 | __setup("spread_lpevents=", set_spread_lpevents ); | ||
| 1178 | __setup("decr_overclock_proc0=", set_decr_overclock_proc0 ); | ||
| 1179 | __setup("decr_overclock=", set_decr_overclock ); | ||
| 1180 | |||
| 1181 | #ifndef CONFIG_PPC_ISERIES | 1127 | #ifndef CONFIG_PPC_ISERIES |
| 1182 | /* | 1128 | /* |
| 1183 | * This function can be used by platforms to "find" legacy serial ports. | 1129 | * This function can be used by platforms to "find" legacy serial ports. |
diff --git a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c index 3b906cd94037..9ef5d36d6b25 100644 --- a/arch/ppc64/kernel/smp.c +++ b/arch/ppc64/kernel/smp.c | |||
| @@ -334,7 +334,6 @@ void smp_call_function_interrupt(void) | |||
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | extern unsigned long decr_overclock; | ||
| 338 | extern struct gettimeofday_struct do_gtod; | 337 | extern struct gettimeofday_struct do_gtod; |
| 339 | 338 | ||
| 340 | struct thread_info *current_set[NR_CPUS]; | 339 | struct thread_info *current_set[NR_CPUS]; |
| @@ -491,7 +490,7 @@ int __devinit __cpu_up(unsigned int cpu) | |||
| 491 | if (smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu)) | 490 | if (smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu)) |
| 492 | return -EINVAL; | 491 | return -EINVAL; |
| 493 | 492 | ||
| 494 | paca[cpu].default_decr = tb_ticks_per_jiffy / decr_overclock; | 493 | paca[cpu].default_decr = tb_ticks_per_jiffy; |
| 495 | 494 | ||
| 496 | if (!cpu_has_feature(CPU_FTR_SLB)) { | 495 | if (!cpu_has_feature(CPU_FTR_SLB)) { |
| 497 | void *tmp; | 496 | void *tmp; |
diff --git a/arch/ppc64/kernel/sysfs.c b/arch/ppc64/kernel/sysfs.c index 0925694c3ce5..c8fa6569b2fd 100644 --- a/arch/ppc64/kernel/sysfs.c +++ b/arch/ppc64/kernel/sysfs.c | |||
| @@ -113,7 +113,6 @@ void ppc64_enable_pmcs(void) | |||
| 113 | #ifdef CONFIG_PPC_PSERIES | 113 | #ifdef CONFIG_PPC_PSERIES |
| 114 | unsigned long set, reset; | 114 | unsigned long set, reset; |
| 115 | int ret; | 115 | int ret; |
| 116 | unsigned int ctrl; | ||
| 117 | #endif /* CONFIG_PPC_PSERIES */ | 116 | #endif /* CONFIG_PPC_PSERIES */ |
| 118 | 117 | ||
| 119 | /* Only need to enable them once */ | 118 | /* Only need to enable them once */ |
| @@ -167,11 +166,8 @@ void ppc64_enable_pmcs(void) | |||
| 167 | * On SMT machines we have to set the run latch in the ctrl register | 166 | * On SMT machines we have to set the run latch in the ctrl register |
| 168 | * in order to make PMC6 spin. | 167 | * in order to make PMC6 spin. |
| 169 | */ | 168 | */ |
| 170 | if (cpu_has_feature(CPU_FTR_SMT)) { | 169 | if (cpu_has_feature(CPU_FTR_SMT)) |
| 171 | ctrl = mfspr(CTRLF); | 170 | ppc64_runlatch_on(); |
| 172 | ctrl |= RUNLATCH; | ||
| 173 | mtspr(CTRLT, ctrl); | ||
| 174 | } | ||
| 175 | #endif /* CONFIG_PPC_PSERIES */ | 171 | #endif /* CONFIG_PPC_PSERIES */ |
| 176 | } | 172 | } |
| 177 | 173 | ||
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index 01ae1964c938..c067435bae45 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | //#include <linux/kernel_stat.h> | 28 | //#include <linux/kernel_stat.h> |
| 29 | #include <linux/notifier.h> | 29 | #include <linux/notifier.h> |
| 30 | #include <linux/cpu.h> | 30 | #include <linux/cpu.h> |
| 31 | #include <linux/workqueue.h> | ||
| 31 | 32 | ||
| 32 | #include "appldata.h" | 33 | #include "appldata.h" |
| 33 | 34 | ||
| @@ -133,9 +134,12 @@ static int appldata_interval = APPLDATA_CPU_INTERVAL; | |||
| 133 | static int appldata_timer_active; | 134 | static int appldata_timer_active; |
| 134 | 135 | ||
| 135 | /* | 136 | /* |
| 136 | * Tasklet | 137 | * Work queue |
| 137 | */ | 138 | */ |
| 138 | static struct tasklet_struct appldata_tasklet_struct; | 139 | static struct workqueue_struct *appldata_wq; |
| 140 | static void appldata_work_fn(void *data); | ||
| 141 | static DECLARE_WORK(appldata_work, appldata_work_fn, NULL); | ||
| 142 | |||
| 139 | 143 | ||
| 140 | /* | 144 | /* |
| 141 | * Ops list | 145 | * Ops list |
| @@ -144,11 +148,11 @@ static DEFINE_SPINLOCK(appldata_ops_lock); | |||
| 144 | static LIST_HEAD(appldata_ops_list); | 148 | static LIST_HEAD(appldata_ops_list); |
| 145 | 149 | ||
| 146 | 150 | ||
| 147 | /************************* timer, tasklet, DIAG ******************************/ | 151 | /*************************** timer, work, DIAG *******************************/ |
| 148 | /* | 152 | /* |
| 149 | * appldata_timer_function() | 153 | * appldata_timer_function() |
| 150 | * | 154 | * |
| 151 | * schedule tasklet and reschedule timer | 155 | * schedule work and reschedule timer |
| 152 | */ | 156 | */ |
| 153 | static void appldata_timer_function(unsigned long data, struct pt_regs *regs) | 157 | static void appldata_timer_function(unsigned long data, struct pt_regs *regs) |
| 154 | { | 158 | { |
| @@ -157,22 +161,22 @@ static void appldata_timer_function(unsigned long data, struct pt_regs *regs) | |||
| 157 | atomic_read(&appldata_expire_count)); | 161 | atomic_read(&appldata_expire_count)); |
| 158 | if (atomic_dec_and_test(&appldata_expire_count)) { | 162 | if (atomic_dec_and_test(&appldata_expire_count)) { |
| 159 | atomic_set(&appldata_expire_count, num_online_cpus()); | 163 | atomic_set(&appldata_expire_count, num_online_cpus()); |
| 160 | tasklet_schedule((struct tasklet_struct *) data); | 164 | queue_work(appldata_wq, (struct work_struct *) data); |
| 161 | } | 165 | } |
| 162 | } | 166 | } |
| 163 | 167 | ||
| 164 | /* | 168 | /* |
| 165 | * appldata_tasklet_function() | 169 | * appldata_work_fn() |
| 166 | * | 170 | * |
| 167 | * call data gathering function for each (active) module | 171 | * call data gathering function for each (active) module |
| 168 | */ | 172 | */ |
| 169 | static void appldata_tasklet_function(unsigned long data) | 173 | static void appldata_work_fn(void *data) |
| 170 | { | 174 | { |
| 171 | struct list_head *lh; | 175 | struct list_head *lh; |
| 172 | struct appldata_ops *ops; | 176 | struct appldata_ops *ops; |
| 173 | int i; | 177 | int i; |
| 174 | 178 | ||
| 175 | P_DEBUG(" -= Tasklet =-\n"); | 179 | P_DEBUG(" -= Work Queue =-\n"); |
| 176 | i = 0; | 180 | i = 0; |
| 177 | spin_lock(&appldata_ops_lock); | 181 | spin_lock(&appldata_ops_lock); |
| 178 | list_for_each(lh, &appldata_ops_list) { | 182 | list_for_each(lh, &appldata_ops_list) { |
| @@ -231,7 +235,7 @@ static int appldata_diag(char record_nr, u16 function, unsigned long buffer, | |||
| 231 | : "=d" (ry) : "d" (&(appldata_parameter_list)) : "cc"); | 235 | : "=d" (ry) : "d" (&(appldata_parameter_list)) : "cc"); |
| 232 | return (int) ry; | 236 | return (int) ry; |
| 233 | } | 237 | } |
| 234 | /********************** timer, tasklet, DIAG <END> ***************************/ | 238 | /************************ timer, work, DIAG <END> ****************************/ |
| 235 | 239 | ||
| 236 | 240 | ||
| 237 | /****************************** /proc stuff **********************************/ | 241 | /****************************** /proc stuff **********************************/ |
| @@ -411,7 +415,7 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
| 411 | struct list_head *lh; | 415 | struct list_head *lh; |
| 412 | 416 | ||
| 413 | found = 0; | 417 | found = 0; |
| 414 | spin_lock_bh(&appldata_ops_lock); | 418 | spin_lock(&appldata_ops_lock); |
| 415 | list_for_each(lh, &appldata_ops_list) { | 419 | list_for_each(lh, &appldata_ops_list) { |
| 416 | tmp_ops = list_entry(lh, struct appldata_ops, list); | 420 | tmp_ops = list_entry(lh, struct appldata_ops, list); |
| 417 | if (&tmp_ops->ctl_table[2] == ctl) { | 421 | if (&tmp_ops->ctl_table[2] == ctl) { |
| @@ -419,15 +423,15 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
| 419 | } | 423 | } |
| 420 | } | 424 | } |
| 421 | if (!found) { | 425 | if (!found) { |
| 422 | spin_unlock_bh(&appldata_ops_lock); | 426 | spin_unlock(&appldata_ops_lock); |
| 423 | return -ENODEV; | 427 | return -ENODEV; |
| 424 | } | 428 | } |
| 425 | ops = ctl->data; | 429 | ops = ctl->data; |
| 426 | if (!try_module_get(ops->owner)) { // protect this function | 430 | if (!try_module_get(ops->owner)) { // protect this function |
| 427 | spin_unlock_bh(&appldata_ops_lock); | 431 | spin_unlock(&appldata_ops_lock); |
| 428 | return -ENODEV; | 432 | return -ENODEV; |
| 429 | } | 433 | } |
| 430 | spin_unlock_bh(&appldata_ops_lock); | 434 | spin_unlock(&appldata_ops_lock); |
| 431 | 435 | ||
| 432 | if (!*lenp || *ppos) { | 436 | if (!*lenp || *ppos) { |
| 433 | *lenp = 0; | 437 | *lenp = 0; |
| @@ -451,10 +455,11 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
| 451 | return -EFAULT; | 455 | return -EFAULT; |
| 452 | } | 456 | } |
| 453 | 457 | ||
| 454 | spin_lock_bh(&appldata_ops_lock); | 458 | spin_lock(&appldata_ops_lock); |
| 455 | if ((buf[0] == '1') && (ops->active == 0)) { | 459 | if ((buf[0] == '1') && (ops->active == 0)) { |
| 456 | if (!try_module_get(ops->owner)) { // protect tasklet | 460 | // protect work queue callback |
| 457 | spin_unlock_bh(&appldata_ops_lock); | 461 | if (!try_module_get(ops->owner)) { |
| 462 | spin_unlock(&appldata_ops_lock); | ||
| 458 | module_put(ops->owner); | 463 | module_put(ops->owner); |
| 459 | return -ENODEV; | 464 | return -ENODEV; |
| 460 | } | 465 | } |
| @@ -485,7 +490,7 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
| 485 | } | 490 | } |
| 486 | module_put(ops->owner); | 491 | module_put(ops->owner); |
| 487 | } | 492 | } |
| 488 | spin_unlock_bh(&appldata_ops_lock); | 493 | spin_unlock(&appldata_ops_lock); |
| 489 | out: | 494 | out: |
| 490 | *lenp = len; | 495 | *lenp = len; |
| 491 | *ppos += len; | 496 | *ppos += len; |
| @@ -529,7 +534,7 @@ int appldata_register_ops(struct appldata_ops *ops) | |||
| 529 | } | 534 | } |
| 530 | memset(ops->ctl_table, 0, 4*sizeof(struct ctl_table)); | 535 | memset(ops->ctl_table, 0, 4*sizeof(struct ctl_table)); |
| 531 | 536 | ||
| 532 | spin_lock_bh(&appldata_ops_lock); | 537 | spin_lock(&appldata_ops_lock); |
| 533 | list_for_each(lh, &appldata_ops_list) { | 538 | list_for_each(lh, &appldata_ops_list) { |
| 534 | tmp_ops = list_entry(lh, struct appldata_ops, list); | 539 | tmp_ops = list_entry(lh, struct appldata_ops, list); |
| 535 | P_DEBUG("register_ops loop: %i) name = %s, ctl = %i\n", | 540 | P_DEBUG("register_ops loop: %i) name = %s, ctl = %i\n", |
| @@ -541,18 +546,18 @@ int appldata_register_ops(struct appldata_ops *ops) | |||
| 541 | APPLDATA_PROC_NAME_LENGTH) == 0) { | 546 | APPLDATA_PROC_NAME_LENGTH) == 0) { |
| 542 | P_ERROR("Name \"%s\" already registered!\n", ops->name); | 547 | P_ERROR("Name \"%s\" already registered!\n", ops->name); |
| 543 | kfree(ops->ctl_table); | 548 | kfree(ops->ctl_table); |
| 544 | spin_unlock_bh(&appldata_ops_lock); | 549 | spin_unlock(&appldata_ops_lock); |
| 545 | return -EBUSY; | 550 | return -EBUSY; |
| 546 | } | 551 | } |
| 547 | if (tmp_ops->ctl_nr == ops->ctl_nr) { | 552 | if (tmp_ops->ctl_nr == ops->ctl_nr) { |
| 548 | P_ERROR("ctl_nr %i already registered!\n", ops->ctl_nr); | 553 | P_ERROR("ctl_nr %i already registered!\n", ops->ctl_nr); |
| 549 | kfree(ops->ctl_table); | 554 | kfree(ops->ctl_table); |
| 550 | spin_unlock_bh(&appldata_ops_lock); | 555 | spin_unlock(&appldata_ops_lock); |
| 551 | return -EBUSY; | 556 | return -EBUSY; |
| 552 | } | 557 | } |
| 553 | } | 558 | } |
| 554 | list_add(&ops->list, &appldata_ops_list); | 559 | list_add(&ops->list, &appldata_ops_list); |
| 555 | spin_unlock_bh(&appldata_ops_lock); | 560 | spin_unlock(&appldata_ops_lock); |
| 556 | 561 | ||
| 557 | ops->ctl_table[0].ctl_name = CTL_APPLDATA; | 562 | ops->ctl_table[0].ctl_name = CTL_APPLDATA; |
| 558 | ops->ctl_table[0].procname = appldata_proc_name; | 563 | ops->ctl_table[0].procname = appldata_proc_name; |
| @@ -583,12 +588,12 @@ int appldata_register_ops(struct appldata_ops *ops) | |||
| 583 | */ | 588 | */ |
| 584 | void appldata_unregister_ops(struct appldata_ops *ops) | 589 | void appldata_unregister_ops(struct appldata_ops *ops) |
| 585 | { | 590 | { |
| 586 | spin_lock_bh(&appldata_ops_lock); | 591 | spin_lock(&appldata_ops_lock); |
| 587 | unregister_sysctl_table(ops->sysctl_header); | 592 | unregister_sysctl_table(ops->sysctl_header); |
| 588 | list_del(&ops->list); | 593 | list_del(&ops->list); |
| 589 | kfree(ops->ctl_table); | 594 | kfree(ops->ctl_table); |
| 590 | ops->ctl_table = NULL; | 595 | ops->ctl_table = NULL; |
| 591 | spin_unlock_bh(&appldata_ops_lock); | 596 | spin_unlock(&appldata_ops_lock); |
| 592 | P_INFO("%s-ops unregistered!\n", ops->name); | 597 | P_INFO("%s-ops unregistered!\n", ops->name); |
| 593 | } | 598 | } |
| 594 | /********************** module-ops management <END> **************************/ | 599 | /********************** module-ops management <END> **************************/ |
| @@ -602,7 +607,7 @@ appldata_online_cpu(int cpu) | |||
| 602 | init_virt_timer(&per_cpu(appldata_timer, cpu)); | 607 | init_virt_timer(&per_cpu(appldata_timer, cpu)); |
| 603 | per_cpu(appldata_timer, cpu).function = appldata_timer_function; | 608 | per_cpu(appldata_timer, cpu).function = appldata_timer_function; |
| 604 | per_cpu(appldata_timer, cpu).data = (unsigned long) | 609 | per_cpu(appldata_timer, cpu).data = (unsigned long) |
| 605 | &appldata_tasklet_struct; | 610 | &appldata_work; |
| 606 | atomic_inc(&appldata_expire_count); | 611 | atomic_inc(&appldata_expire_count); |
| 607 | spin_lock(&appldata_timer_lock); | 612 | spin_lock(&appldata_timer_lock); |
| 608 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); | 613 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); |
| @@ -615,7 +620,7 @@ appldata_offline_cpu(int cpu) | |||
| 615 | del_virt_timer(&per_cpu(appldata_timer, cpu)); | 620 | del_virt_timer(&per_cpu(appldata_timer, cpu)); |
| 616 | if (atomic_dec_and_test(&appldata_expire_count)) { | 621 | if (atomic_dec_and_test(&appldata_expire_count)) { |
| 617 | atomic_set(&appldata_expire_count, num_online_cpus()); | 622 | atomic_set(&appldata_expire_count, num_online_cpus()); |
| 618 | tasklet_schedule(&appldata_tasklet_struct); | 623 | queue_work(appldata_wq, &appldata_work); |
| 619 | } | 624 | } |
| 620 | spin_lock(&appldata_timer_lock); | 625 | spin_lock(&appldata_timer_lock); |
| 621 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); | 626 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); |
| @@ -648,7 +653,7 @@ static struct notifier_block __devinitdata appldata_nb = { | |||
| 648 | /* | 653 | /* |
| 649 | * appldata_init() | 654 | * appldata_init() |
| 650 | * | 655 | * |
| 651 | * init timer and tasklet, register /proc entries | 656 | * init timer, register /proc entries |
| 652 | */ | 657 | */ |
| 653 | static int __init appldata_init(void) | 658 | static int __init appldata_init(void) |
| 654 | { | 659 | { |
| @@ -657,6 +662,12 @@ static int __init appldata_init(void) | |||
| 657 | P_DEBUG("sizeof(parameter_list) = %lu\n", | 662 | P_DEBUG("sizeof(parameter_list) = %lu\n", |
| 658 | sizeof(struct appldata_parameter_list)); | 663 | sizeof(struct appldata_parameter_list)); |
| 659 | 664 | ||
| 665 | appldata_wq = create_singlethread_workqueue("appldata"); | ||
| 666 | if (!appldata_wq) { | ||
| 667 | P_ERROR("Could not create work queue\n"); | ||
| 668 | return -ENOMEM; | ||
| 669 | } | ||
| 670 | |||
| 660 | for_each_online_cpu(i) | 671 | for_each_online_cpu(i) |
| 661 | appldata_online_cpu(i); | 672 | appldata_online_cpu(i); |
| 662 | 673 | ||
| @@ -670,7 +681,6 @@ static int __init appldata_init(void) | |||
| 670 | appldata_table[1].de->owner = THIS_MODULE; | 681 | appldata_table[1].de->owner = THIS_MODULE; |
| 671 | #endif | 682 | #endif |
| 672 | 683 | ||
| 673 | tasklet_init(&appldata_tasklet_struct, appldata_tasklet_function, 0); | ||
| 674 | P_DEBUG("Base interface initialized.\n"); | 684 | P_DEBUG("Base interface initialized.\n"); |
| 675 | return 0; | 685 | return 0; |
| 676 | } | 686 | } |
| @@ -678,7 +688,7 @@ static int __init appldata_init(void) | |||
| 678 | /* | 688 | /* |
| 679 | * appldata_exit() | 689 | * appldata_exit() |
| 680 | * | 690 | * |
| 681 | * stop timer and tasklet, unregister /proc entries | 691 | * stop timer, unregister /proc entries |
| 682 | */ | 692 | */ |
| 683 | static void __exit appldata_exit(void) | 693 | static void __exit appldata_exit(void) |
| 684 | { | 694 | { |
| @@ -690,7 +700,7 @@ static void __exit appldata_exit(void) | |||
| 690 | /* | 700 | /* |
| 691 | * ops list should be empty, but just in case something went wrong... | 701 | * ops list should be empty, but just in case something went wrong... |
| 692 | */ | 702 | */ |
| 693 | spin_lock_bh(&appldata_ops_lock); | 703 | spin_lock(&appldata_ops_lock); |
| 694 | list_for_each(lh, &appldata_ops_list) { | 704 | list_for_each(lh, &appldata_ops_list) { |
| 695 | ops = list_entry(lh, struct appldata_ops, list); | 705 | ops = list_entry(lh, struct appldata_ops, list); |
| 696 | rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, | 706 | rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, |
| @@ -700,7 +710,7 @@ static void __exit appldata_exit(void) | |||
| 700 | "return code: %d\n", ops->name, rc); | 710 | "return code: %d\n", ops->name, rc); |
| 701 | } | 711 | } |
| 702 | } | 712 | } |
| 703 | spin_unlock_bh(&appldata_ops_lock); | 713 | spin_unlock(&appldata_ops_lock); |
| 704 | 714 | ||
| 705 | for_each_online_cpu(i) | 715 | for_each_online_cpu(i) |
| 706 | appldata_offline_cpu(i); | 716 | appldata_offline_cpu(i); |
| @@ -709,7 +719,7 @@ static void __exit appldata_exit(void) | |||
| 709 | 719 | ||
| 710 | unregister_sysctl_table(appldata_sysctl_header); | 720 | unregister_sysctl_table(appldata_sysctl_header); |
| 711 | 721 | ||
| 712 | tasklet_kill(&appldata_tasklet_struct); | 722 | destroy_workqueue(appldata_wq); |
| 713 | P_DEBUG("... module unloaded!\n"); | 723 | P_DEBUG("... module unloaded!\n"); |
| 714 | } | 724 | } |
| 715 | /**************************** init / exit <END> ******************************/ | 725 | /**************************** init / exit <END> ******************************/ |
diff --git a/arch/s390/appldata/appldata_mem.c b/arch/s390/appldata/appldata_mem.c index 462ee9a84e76..f0e2fbed3d4c 100644 --- a/arch/s390/appldata/appldata_mem.c +++ b/arch/s390/appldata/appldata_mem.c | |||
| @@ -68,7 +68,7 @@ struct appldata_mem_data { | |||
| 68 | u64 pgmajfault; /* page faults (major only) */ | 68 | u64 pgmajfault; /* page faults (major only) */ |
| 69 | // <-- New in 2.6 | 69 | // <-- New in 2.6 |
| 70 | 70 | ||
| 71 | } appldata_mem_data; | 71 | } __attribute__((packed)) appldata_mem_data; |
| 72 | 72 | ||
| 73 | 73 | ||
| 74 | static inline void appldata_debug_print(struct appldata_mem_data *mem_data) | 74 | static inline void appldata_debug_print(struct appldata_mem_data *mem_data) |
diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c index dd61638d3027..2a4c7432db4a 100644 --- a/arch/s390/appldata/appldata_net_sum.c +++ b/arch/s390/appldata/appldata_net_sum.c | |||
| @@ -57,7 +57,7 @@ struct appldata_net_sum_data { | |||
| 57 | u64 rx_dropped; /* no space in linux buffers */ | 57 | u64 rx_dropped; /* no space in linux buffers */ |
| 58 | u64 tx_dropped; /* no space available in linux */ | 58 | u64 tx_dropped; /* no space available in linux */ |
| 59 | u64 collisions; /* collisions while transmitting */ | 59 | u64 collisions; /* collisions while transmitting */ |
| 60 | } appldata_net_sum_data; | 60 | } __attribute__((packed)) appldata_net_sum_data; |
| 61 | 61 | ||
| 62 | 62 | ||
| 63 | static inline void appldata_print_debug(struct appldata_net_sum_data *net_data) | 63 | static inline void appldata_print_debug(struct appldata_net_sum_data *net_data) |
diff --git a/arch/s390/appldata/appldata_os.c b/arch/s390/appldata/appldata_os.c index b83f07484551..e0a476bf4fd6 100644 --- a/arch/s390/appldata/appldata_os.c +++ b/arch/s390/appldata/appldata_os.c | |||
| @@ -49,7 +49,7 @@ struct appldata_os_per_cpu { | |||
| 49 | u32 per_cpu_softirq; /* ... spent in softirqs */ | 49 | u32 per_cpu_softirq; /* ... spent in softirqs */ |
| 50 | u32 per_cpu_iowait; /* ... spent while waiting for I/O */ | 50 | u32 per_cpu_iowait; /* ... spent while waiting for I/O */ |
| 51 | // <-- New in 2.6 | 51 | // <-- New in 2.6 |
| 52 | }; | 52 | } __attribute__((packed)); |
| 53 | 53 | ||
| 54 | struct appldata_os_data { | 54 | struct appldata_os_data { |
| 55 | u64 timestamp; | 55 | u64 timestamp; |
| @@ -75,7 +75,7 @@ struct appldata_os_data { | |||
| 75 | 75 | ||
| 76 | /* per cpu data */ | 76 | /* per cpu data */ |
| 77 | struct appldata_os_per_cpu os_cpu[0]; | 77 | struct appldata_os_per_cpu os_cpu[0]; |
| 78 | }; | 78 | } __attribute__((packed)); |
| 79 | 79 | ||
| 80 | static struct appldata_os_data *appldata_os_data; | 80 | static struct appldata_os_data *appldata_os_data; |
| 81 | 81 | ||
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index 26889366929a..06afa3103ace 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <asm/pgalloc.h> | 40 | #include <asm/pgalloc.h> |
| 41 | #include <asm/system.h> | 41 | #include <asm/system.h> |
| 42 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
| 43 | #include <asm/unistd.h> | ||
| 43 | 44 | ||
| 44 | #ifdef CONFIG_S390_SUPPORT | 45 | #ifdef CONFIG_S390_SUPPORT |
| 45 | #include "compat_ptrace.h" | 46 | #include "compat_ptrace.h" |
| @@ -130,13 +131,19 @@ static int | |||
| 130 | peek_user(struct task_struct *child, addr_t addr, addr_t data) | 131 | peek_user(struct task_struct *child, addr_t addr, addr_t data) |
| 131 | { | 132 | { |
| 132 | struct user *dummy = NULL; | 133 | struct user *dummy = NULL; |
| 133 | addr_t offset, tmp; | 134 | addr_t offset, tmp, mask; |
| 134 | 135 | ||
| 135 | /* | 136 | /* |
| 136 | * Stupid gdb peeks/pokes the access registers in 64 bit with | 137 | * Stupid gdb peeks/pokes the access registers in 64 bit with |
| 137 | * an alignment of 4. Programmers from hell... | 138 | * an alignment of 4. Programmers from hell... |
| 138 | */ | 139 | */ |
| 139 | if ((addr & 3) || addr > sizeof(struct user) - __ADDR_MASK) | 140 | mask = __ADDR_MASK; |
| 141 | #ifdef CONFIG_ARCH_S390X | ||
| 142 | if (addr >= (addr_t) &dummy->regs.acrs && | ||
| 143 | addr < (addr_t) &dummy->regs.orig_gpr2) | ||
| 144 | mask = 3; | ||
| 145 | #endif | ||
| 146 | if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK) | ||
| 140 | return -EIO; | 147 | return -EIO; |
| 141 | 148 | ||
| 142 | if (addr < (addr_t) &dummy->regs.acrs) { | 149 | if (addr < (addr_t) &dummy->regs.acrs) { |
| @@ -153,6 +160,16 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data) | |||
| 153 | * access registers are stored in the thread structure | 160 | * access registers are stored in the thread structure |
| 154 | */ | 161 | */ |
| 155 | offset = addr - (addr_t) &dummy->regs.acrs; | 162 | offset = addr - (addr_t) &dummy->regs.acrs; |
| 163 | #ifdef CONFIG_ARCH_S390X | ||
| 164 | /* | ||
| 165 | * Very special case: old & broken 64 bit gdb reading | ||
| 166 | * from acrs[15]. Result is a 64 bit value. Read the | ||
| 167 | * 32 bit acrs[15] value and shift it by 32. Sick... | ||
| 168 | */ | ||
| 169 | if (addr == (addr_t) &dummy->regs.acrs[15]) | ||
| 170 | tmp = ((unsigned long) child->thread.acrs[15]) << 32; | ||
| 171 | else | ||
| 172 | #endif | ||
| 156 | tmp = *(addr_t *)((addr_t) &child->thread.acrs + offset); | 173 | tmp = *(addr_t *)((addr_t) &child->thread.acrs + offset); |
| 157 | 174 | ||
| 158 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { | 175 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { |
| @@ -167,6 +184,9 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data) | |||
| 167 | */ | 184 | */ |
| 168 | offset = addr - (addr_t) &dummy->regs.fp_regs; | 185 | offset = addr - (addr_t) &dummy->regs.fp_regs; |
| 169 | tmp = *(addr_t *)((addr_t) &child->thread.fp_regs + offset); | 186 | tmp = *(addr_t *)((addr_t) &child->thread.fp_regs + offset); |
| 187 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc) | ||
| 188 | tmp &= (unsigned long) FPC_VALID_MASK | ||
| 189 | << (BITS_PER_LONG - 32); | ||
| 170 | 190 | ||
| 171 | } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) { | 191 | } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) { |
| 172 | /* | 192 | /* |
| @@ -191,13 +211,19 @@ static int | |||
| 191 | poke_user(struct task_struct *child, addr_t addr, addr_t data) | 211 | poke_user(struct task_struct *child, addr_t addr, addr_t data) |
| 192 | { | 212 | { |
| 193 | struct user *dummy = NULL; | 213 | struct user *dummy = NULL; |
| 194 | addr_t offset; | 214 | addr_t offset, mask; |
| 195 | 215 | ||
| 196 | /* | 216 | /* |
| 197 | * Stupid gdb peeks/pokes the access registers in 64 bit with | 217 | * Stupid gdb peeks/pokes the access registers in 64 bit with |
| 198 | * an alignment of 4. Programmers from hell indeed... | 218 | * an alignment of 4. Programmers from hell indeed... |
| 199 | */ | 219 | */ |
| 200 | if ((addr & 3) || addr > sizeof(struct user) - __ADDR_MASK) | 220 | mask = __ADDR_MASK; |
| 221 | #ifdef CONFIG_ARCH_S390X | ||
| 222 | if (addr >= (addr_t) &dummy->regs.acrs && | ||
| 223 | addr < (addr_t) &dummy->regs.orig_gpr2) | ||
| 224 | mask = 3; | ||
| 225 | #endif | ||
| 226 | if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK) | ||
| 201 | return -EIO; | 227 | return -EIO; |
| 202 | 228 | ||
| 203 | if (addr < (addr_t) &dummy->regs.acrs) { | 229 | if (addr < (addr_t) &dummy->regs.acrs) { |
| @@ -224,6 +250,17 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data) | |||
| 224 | * access registers are stored in the thread structure | 250 | * access registers are stored in the thread structure |
| 225 | */ | 251 | */ |
| 226 | offset = addr - (addr_t) &dummy->regs.acrs; | 252 | offset = addr - (addr_t) &dummy->regs.acrs; |
| 253 | #ifdef CONFIG_ARCH_S390X | ||
| 254 | /* | ||
| 255 | * Very special case: old & broken 64 bit gdb writing | ||
| 256 | * to acrs[15] with a 64 bit value. Ignore the lower | ||
| 257 | * half of the value and write the upper 32 bit to | ||
| 258 | * acrs[15]. Sick... | ||
| 259 | */ | ||
| 260 | if (addr == (addr_t) &dummy->regs.acrs[15]) | ||
| 261 | child->thread.acrs[15] = (unsigned int) (data >> 32); | ||
| 262 | else | ||
| 263 | #endif | ||
| 227 | *(addr_t *)((addr_t) &child->thread.acrs + offset) = data; | 264 | *(addr_t *)((addr_t) &child->thread.acrs + offset) = data; |
| 228 | 265 | ||
| 229 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { | 266 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { |
| @@ -237,7 +274,8 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data) | |||
| 237 | * floating point regs. are stored in the thread structure | 274 | * floating point regs. are stored in the thread structure |
| 238 | */ | 275 | */ |
| 239 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc && | 276 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc && |
| 240 | (data & ~FPC_VALID_MASK) != 0) | 277 | (data & ~((unsigned long) FPC_VALID_MASK |
| 278 | << (BITS_PER_LONG - 32))) != 0) | ||
| 241 | return -EINVAL; | 279 | return -EINVAL; |
| 242 | offset = addr - (addr_t) &dummy->regs.fp_regs; | 280 | offset = addr - (addr_t) &dummy->regs.fp_regs; |
| 243 | *(addr_t *)((addr_t) &child->thread.fp_regs + offset) = data; | 281 | *(addr_t *)((addr_t) &child->thread.fp_regs + offset) = data; |
| @@ -723,6 +761,13 @@ syscall_trace(struct pt_regs *regs, int entryexit) | |||
| 723 | ? 0x80 : 0)); | 761 | ? 0x80 : 0)); |
| 724 | 762 | ||
| 725 | /* | 763 | /* |
| 764 | * If the debuffer has set an invalid system call number, | ||
| 765 | * we prepare to skip the system call restart handling. | ||
| 766 | */ | ||
| 767 | if (!entryexit && regs->gprs[2] >= NR_syscalls) | ||
| 768 | regs->trap = -1; | ||
| 769 | |||
| 770 | /* | ||
| 726 | * this isn't the same as continuing with a signal, but it will do | 771 | * this isn't the same as continuing with a signal, but it will do |
| 727 | * for normal use. strace only continues with a signal if the | 772 | * for normal use. strace only continues with a signal if the |
| 728 | * stopping signal is not SIGTRAP. -brl | 773 | * stopping signal is not SIGTRAP. -brl |
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 80306bc8c799..75fde949d125 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c | |||
| @@ -207,7 +207,7 @@ do_exception(struct pt_regs *regs, unsigned long error_code, int is_protection) | |||
| 207 | * we are not in an interrupt and that there is a | 207 | * we are not in an interrupt and that there is a |
| 208 | * user context. | 208 | * user context. |
| 209 | */ | 209 | */ |
| 210 | if (user_address == 0 || in_interrupt() || !mm) | 210 | if (user_address == 0 || in_atomic() || !mm) |
| 211 | goto no_context; | 211 | goto no_context; |
| 212 | 212 | ||
| 213 | /* | 213 | /* |
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile index d1dcd8eae3c9..5b77188527a9 100644 --- a/drivers/atm/Makefile +++ b/drivers/atm/Makefile | |||
| @@ -39,7 +39,8 @@ ifeq ($(CONFIG_ATM_FORE200E_PCA),y) | |||
| 39 | fore_200e-objs += fore200e_pca_fw.o | 39 | fore_200e-objs += fore200e_pca_fw.o |
| 40 | # guess the target endianess to choose the right PCA-200E firmware image | 40 | # guess the target endianess to choose the right PCA-200E firmware image |
| 41 | ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y) | 41 | ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y) |
| 42 | CONFIG_ATM_FORE200E_PCA_FW = $(shell if test -n "`$(CC) -E -dM $(src)/../../include/asm/byteorder.h | grep ' __LITTLE_ENDIAN '`"; then echo $(obj)/pca200e.bin; else echo $(obj)/pca200e_ecd.bin2; fi) | 42 | byteorder.h := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h |
| 43 | CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2) | ||
| 43 | endif | 44 | endif |
| 44 | endif | 45 | endif |
| 45 | 46 | ||
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 9e65bfb85ba3..5f702199543a 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
| @@ -383,8 +383,7 @@ fore200e_shutdown(struct fore200e* fore200e) | |||
| 383 | switch(fore200e->state) { | 383 | switch(fore200e->state) { |
| 384 | 384 | ||
| 385 | case FORE200E_STATE_COMPLETE: | 385 | case FORE200E_STATE_COMPLETE: |
| 386 | if (fore200e->stats) | 386 | kfree(fore200e->stats); |
| 387 | kfree(fore200e->stats); | ||
| 388 | 387 | ||
| 389 | case FORE200E_STATE_IRQ: | 388 | case FORE200E_STATE_IRQ: |
| 390 | free_irq(fore200e->irq, fore200e->atm_dev); | 389 | free_irq(fore200e->irq, fore200e->atm_dev); |
| @@ -963,8 +962,7 @@ fore200e_tx_irq(struct fore200e* fore200e) | |||
| 963 | entry, txq->tail, entry->vc_map, entry->skb); | 962 | entry, txq->tail, entry->vc_map, entry->skb); |
| 964 | 963 | ||
| 965 | /* free copy of misaligned data */ | 964 | /* free copy of misaligned data */ |
| 966 | if (entry->data) | 965 | kfree(entry->data); |
| 967 | kfree(entry->data); | ||
| 968 | 966 | ||
| 969 | /* remove DMA mapping */ | 967 | /* remove DMA mapping */ |
| 970 | fore200e->bus->dma_unmap(fore200e, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length, | 968 | fore200e->bus->dma_unmap(fore200e, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length, |
diff --git a/drivers/atm/he.c b/drivers/atm/he.c index 3022c548a132..df2c83fd5496 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c | |||
| @@ -412,8 +412,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent) | |||
| 412 | init_one_failure: | 412 | init_one_failure: |
| 413 | if (atm_dev) | 413 | if (atm_dev) |
| 414 | atm_dev_deregister(atm_dev); | 414 | atm_dev_deregister(atm_dev); |
| 415 | if (he_dev) | 415 | kfree(he_dev); |
| 416 | kfree(he_dev); | ||
| 417 | pci_disable_device(pci_dev); | 416 | pci_disable_device(pci_dev); |
| 418 | return err; | 417 | return err; |
| 419 | } | 418 | } |
| @@ -2534,8 +2533,7 @@ he_open(struct atm_vcc *vcc) | |||
| 2534 | open_failed: | 2533 | open_failed: |
| 2535 | 2534 | ||
| 2536 | if (err) { | 2535 | if (err) { |
| 2537 | if (he_vcc) | 2536 | kfree(he_vcc); |
| 2538 | kfree(he_vcc); | ||
| 2539 | clear_bit(ATM_VF_ADDR, &vcc->flags); | 2537 | clear_bit(ATM_VF_ADDR, &vcc->flags); |
| 2540 | } | 2538 | } |
| 2541 | else | 2539 | else |
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index 85bf5c8442b0..b2a7b754fd14 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c | |||
| @@ -676,10 +676,10 @@ static int __devinit ns_init_card(int i, struct pci_dev *pcidev) | |||
| 676 | PRINTK("nicstar%d: RSQ base at 0x%x.\n", i, (u32) card->rsq.base); | 676 | PRINTK("nicstar%d: RSQ base at 0x%x.\n", i, (u32) card->rsq.base); |
| 677 | 677 | ||
| 678 | /* Initialize SCQ0, the only VBR SCQ used */ | 678 | /* Initialize SCQ0, the only VBR SCQ used */ |
| 679 | card->scq1 = (scq_info *) NULL; | 679 | card->scq1 = NULL; |
| 680 | card->scq2 = (scq_info *) NULL; | 680 | card->scq2 = NULL; |
| 681 | card->scq0 = get_scq(VBR_SCQSIZE, NS_VRSCD0); | 681 | card->scq0 = get_scq(VBR_SCQSIZE, NS_VRSCD0); |
| 682 | if (card->scq0 == (scq_info *) NULL) | 682 | if (card->scq0 == NULL) |
| 683 | { | 683 | { |
| 684 | printk("nicstar%d: can't get SCQ0.\n", i); | 684 | printk("nicstar%d: can't get SCQ0.\n", i); |
| 685 | error = 12; | 685 | error = 12; |
| @@ -993,24 +993,24 @@ static scq_info *get_scq(int size, u32 scd) | |||
| 993 | int i; | 993 | int i; |
| 994 | 994 | ||
| 995 | if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) | 995 | if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) |
| 996 | return (scq_info *) NULL; | 996 | return NULL; |
| 997 | 997 | ||
| 998 | scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL); | 998 | scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL); |
| 999 | if (scq == (scq_info *) NULL) | 999 | if (scq == NULL) |
| 1000 | return (scq_info *) NULL; | 1000 | return NULL; |
| 1001 | scq->org = kmalloc(2 * size, GFP_KERNEL); | 1001 | scq->org = kmalloc(2 * size, GFP_KERNEL); |
| 1002 | if (scq->org == NULL) | 1002 | if (scq->org == NULL) |
| 1003 | { | 1003 | { |
| 1004 | kfree(scq); | 1004 | kfree(scq); |
| 1005 | return (scq_info *) NULL; | 1005 | return NULL; |
| 1006 | } | 1006 | } |
| 1007 | scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) * | 1007 | scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) * |
| 1008 | (size / NS_SCQE_SIZE), GFP_KERNEL); | 1008 | (size / NS_SCQE_SIZE), GFP_KERNEL); |
| 1009 | if (scq->skb == (struct sk_buff **) NULL) | 1009 | if (scq->skb == NULL) |
| 1010 | { | 1010 | { |
| 1011 | kfree(scq->org); | 1011 | kfree(scq->org); |
| 1012 | kfree(scq); | 1012 | kfree(scq); |
| 1013 | return (scq_info *) NULL; | 1013 | return NULL; |
| 1014 | } | 1014 | } |
| 1015 | scq->num_entries = size / NS_SCQE_SIZE; | 1015 | scq->num_entries = size / NS_SCQE_SIZE; |
| 1016 | scq->base = (ns_scqe *) ALIGN_ADDRESS(scq->org, size); | 1016 | scq->base = (ns_scqe *) ALIGN_ADDRESS(scq->org, size); |
| @@ -1498,7 +1498,7 @@ static int ns_open(struct atm_vcc *vcc) | |||
| 1498 | vc->cbr_scd = NS_FRSCD + frscdi * NS_FRSCD_SIZE; | 1498 | vc->cbr_scd = NS_FRSCD + frscdi * NS_FRSCD_SIZE; |
| 1499 | 1499 | ||
| 1500 | scq = get_scq(CBR_SCQSIZE, vc->cbr_scd); | 1500 | scq = get_scq(CBR_SCQSIZE, vc->cbr_scd); |
| 1501 | if (scq == (scq_info *) NULL) | 1501 | if (scq == NULL) |
| 1502 | { | 1502 | { |
| 1503 | PRINTK("nicstar%d: can't get fixed rate SCQ.\n", card->index); | 1503 | PRINTK("nicstar%d: can't get fixed rate SCQ.\n", card->index); |
| 1504 | card->scd2vc[frscdi] = NULL; | 1504 | card->scd2vc[frscdi] = NULL; |
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 47a800519ad0..8d5e65cb9755 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c | |||
| @@ -902,7 +902,7 @@ static void close_tx(struct atm_vcc *vcc) | |||
| 902 | zatm_dev->tx_bw += vcc->qos.txtp.min_pcr; | 902 | zatm_dev->tx_bw += vcc->qos.txtp.min_pcr; |
| 903 | dealloc_shaper(vcc->dev,zatm_vcc->shaper); | 903 | dealloc_shaper(vcc->dev,zatm_vcc->shaper); |
| 904 | } | 904 | } |
| 905 | if (zatm_vcc->ring) kfree(zatm_vcc->ring); | 905 | kfree(zatm_vcc->ring); |
| 906 | } | 906 | } |
| 907 | 907 | ||
| 908 | 908 | ||
| @@ -1339,12 +1339,9 @@ static int __init zatm_start(struct atm_dev *dev) | |||
| 1339 | return 0; | 1339 | return 0; |
| 1340 | out: | 1340 | out: |
| 1341 | for (i = 0; i < NR_MBX; i++) | 1341 | for (i = 0; i < NR_MBX; i++) |
| 1342 | if (zatm_dev->mbx_start[i] != 0) | 1342 | kfree(zatm_dev->mbx_start[i]); |
| 1343 | kfree((void *) zatm_dev->mbx_start[i]); | 1343 | kfree(zatm_dev->rx_map); |
| 1344 | if (zatm_dev->rx_map != NULL) | 1344 | kfree(zatm_dev->tx_map); |
| 1345 | kfree(zatm_dev->rx_map); | ||
| 1346 | if (zatm_dev->tx_map != NULL) | ||
| 1347 | kfree(zatm_dev->tx_map); | ||
| 1348 | free_irq(zatm_dev->irq, dev); | 1345 | free_irq(zatm_dev->irq, dev); |
| 1349 | return error; | 1346 | return error; |
| 1350 | } | 1347 | } |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index ce42889f98fb..adc4dcc306f4 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
| @@ -8,13 +8,12 @@ | |||
| 8 | * and is not licensed separately. See file COPYING for details. | 8 | * and is not licensed separately. See file COPYING for details. |
| 9 | * | 9 | * |
| 10 | * TODO (sorted by decreasing priority) | 10 | * TODO (sorted by decreasing priority) |
| 11 | * -- Kill first_open (Al Viro fixed the block layer now) | ||
| 11 | * -- Do resets with usb_device_reset (needs a thread context, use khubd) | 12 | * -- Do resets with usb_device_reset (needs a thread context, use khubd) |
| 12 | * -- set readonly flag for CDs, set removable flag for CF readers | 13 | * -- set readonly flag for CDs, set removable flag for CF readers |
| 13 | * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) | 14 | * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) |
| 14 | * -- support pphaneuf's SDDR-75 with two LUNs (also broken capacity...) | ||
| 15 | * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries | 15 | * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries |
| 16 | * -- verify the 13 conditions and do bulk resets | 16 | * -- verify the 13 conditions and do bulk resets |
| 17 | * -- normal pool of commands instead of cmdv[]? | ||
| 18 | * -- kill last_pipe and simply do two-state clearing on both pipes | 17 | * -- kill last_pipe and simply do two-state clearing on both pipes |
| 19 | * -- verify protocol (bulk) from USB descriptors (maybe...) | 18 | * -- verify protocol (bulk) from USB descriptors (maybe...) |
| 20 | * -- highmem and sg | 19 | * -- highmem and sg |
| @@ -49,7 +48,14 @@ | |||
| 49 | #define US_SC_SCSI 0x06 /* Transparent */ | 48 | #define US_SC_SCSI 0x06 /* Transparent */ |
| 50 | 49 | ||
| 51 | /* | 50 | /* |
| 51 | * This many LUNs per USB device. | ||
| 52 | * Every one of them takes a host, see UB_MAX_HOSTS. | ||
| 52 | */ | 53 | */ |
| 54 | #define UB_MAX_LUNS 4 | ||
| 55 | |||
| 56 | /* | ||
| 57 | */ | ||
| 58 | |||
| 53 | #define UB_MINORS_PER_MAJOR 8 | 59 | #define UB_MINORS_PER_MAJOR 8 |
| 54 | 60 | ||
| 55 | #define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */ | 61 | #define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */ |
| @@ -65,7 +71,7 @@ struct bulk_cb_wrap { | |||
| 65 | u32 Tag; /* unique per command id */ | 71 | u32 Tag; /* unique per command id */ |
| 66 | __le32 DataTransferLength; /* size of data */ | 72 | __le32 DataTransferLength; /* size of data */ |
| 67 | u8 Flags; /* direction in bit 0 */ | 73 | u8 Flags; /* direction in bit 0 */ |
| 68 | u8 Lun; /* LUN normally 0 */ | 74 | u8 Lun; /* LUN */ |
| 69 | u8 Length; /* of of the CDB */ | 75 | u8 Length; /* of of the CDB */ |
| 70 | u8 CDB[UB_MAX_CDB_SIZE]; /* max command */ | 76 | u8 CDB[UB_MAX_CDB_SIZE]; /* max command */ |
| 71 | }; | 77 | }; |
| @@ -168,6 +174,7 @@ struct ub_scsi_cmd { | |||
| 168 | unsigned int len; /* Requested length */ | 174 | unsigned int len; /* Requested length */ |
| 169 | // struct scatterlist sgv[UB_MAX_REQ_SG]; | 175 | // struct scatterlist sgv[UB_MAX_REQ_SG]; |
| 170 | 176 | ||
| 177 | struct ub_lun *lun; | ||
| 171 | void (*done)(struct ub_dev *, struct ub_scsi_cmd *); | 178 | void (*done)(struct ub_dev *, struct ub_scsi_cmd *); |
| 172 | void *back; | 179 | void *back; |
| 173 | }; | 180 | }; |
| @@ -252,25 +259,47 @@ struct ub_scsi_cmd_queue { | |||
| 252 | }; | 259 | }; |
| 253 | 260 | ||
| 254 | /* | 261 | /* |
| 255 | * The UB device instance. | 262 | * The block device instance (one per LUN). |
| 263 | */ | ||
| 264 | struct ub_lun { | ||
| 265 | struct ub_dev *udev; | ||
| 266 | struct list_head link; | ||
| 267 | struct gendisk *disk; | ||
| 268 | int id; /* Host index */ | ||
| 269 | int num; /* LUN number */ | ||
| 270 | char name[16]; | ||
| 271 | |||
| 272 | int changed; /* Media was changed */ | ||
| 273 | int removable; | ||
| 274 | int readonly; | ||
| 275 | int first_open; /* Kludge. See ub_bd_open. */ | ||
| 276 | |||
| 277 | /* Use Ingo's mempool if or when we have more than one command. */ | ||
| 278 | /* | ||
| 279 | * Currently we never need more than one command for the whole device. | ||
| 280 | * However, giving every LUN a command is a cheap and automatic way | ||
| 281 | * to enforce fairness between them. | ||
| 282 | */ | ||
| 283 | int cmda[1]; | ||
| 284 | struct ub_scsi_cmd cmdv[1]; | ||
| 285 | |||
| 286 | struct ub_capacity capacity; | ||
| 287 | }; | ||
| 288 | |||
| 289 | /* | ||
| 290 | * The USB device instance. | ||
| 256 | */ | 291 | */ |
| 257 | struct ub_dev { | 292 | struct ub_dev { |
| 258 | spinlock_t lock; | 293 | spinlock_t lock; |
| 259 | int id; /* Number among ub's */ | ||
| 260 | atomic_t poison; /* The USB device is disconnected */ | 294 | atomic_t poison; /* The USB device is disconnected */ |
| 261 | int openc; /* protected by ub_lock! */ | 295 | int openc; /* protected by ub_lock! */ |
| 262 | /* kref is too implicit for our taste */ | 296 | /* kref is too implicit for our taste */ |
| 263 | unsigned int tagcnt; | 297 | unsigned int tagcnt; |
| 264 | int changed; /* Media was changed */ | 298 | char name[12]; |
| 265 | int removable; | ||
| 266 | int readonly; | ||
| 267 | int first_open; /* Kludge. See ub_bd_open. */ | ||
| 268 | char name[8]; | ||
| 269 | struct usb_device *dev; | 299 | struct usb_device *dev; |
| 270 | struct usb_interface *intf; | 300 | struct usb_interface *intf; |
| 271 | 301 | ||
| 272 | struct ub_capacity capacity; | 302 | struct list_head luns; |
| 273 | struct gendisk *disk; | ||
| 274 | 303 | ||
| 275 | unsigned int send_bulk_pipe; /* cached pipe values */ | 304 | unsigned int send_bulk_pipe; /* cached pipe values */ |
| 276 | unsigned int recv_bulk_pipe; | 305 | unsigned int recv_bulk_pipe; |
| @@ -279,10 +308,6 @@ struct ub_dev { | |||
| 279 | 308 | ||
| 280 | struct tasklet_struct tasklet; | 309 | struct tasklet_struct tasklet; |
| 281 | 310 | ||
| 282 | /* XXX Use Ingo's mempool (once we have more than one) */ | ||
| 283 | int cmda[1]; | ||
| 284 | struct ub_scsi_cmd cmdv[1]; | ||
| 285 | |||
| 286 | struct ub_scsi_cmd_queue cmd_queue; | 311 | struct ub_scsi_cmd_queue cmd_queue; |
| 287 | struct ub_scsi_cmd top_rqs_cmd; /* REQUEST SENSE */ | 312 | struct ub_scsi_cmd top_rqs_cmd; /* REQUEST SENSE */ |
| 288 | unsigned char top_sense[UB_SENSE_SIZE]; | 313 | unsigned char top_sense[UB_SENSE_SIZE]; |
| @@ -301,9 +326,9 @@ struct ub_dev { | |||
| 301 | /* | 326 | /* |
| 302 | */ | 327 | */ |
| 303 | static void ub_cleanup(struct ub_dev *sc); | 328 | static void ub_cleanup(struct ub_dev *sc); |
| 304 | static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq); | 329 | static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq); |
| 305 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 330 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, |
| 306 | struct request *rq); | 331 | struct ub_scsi_cmd *cmd, struct request *rq); |
| 307 | static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 332 | static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, |
| 308 | struct request *rq); | 333 | struct request *rq); |
| 309 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); | 334 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); |
| @@ -320,8 +345,10 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd); | |||
| 320 | static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 345 | static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, |
| 321 | int stalled_pipe); | 346 | int stalled_pipe); |
| 322 | static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); | 347 | static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); |
| 323 | static int ub_sync_tur(struct ub_dev *sc); | 348 | static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); |
| 324 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret); | 349 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, |
| 350 | struct ub_capacity *ret); | ||
| 351 | static int ub_probe_lun(struct ub_dev *sc, int lnum); | ||
| 325 | 352 | ||
| 326 | /* | 353 | /* |
| 327 | */ | 354 | */ |
| @@ -342,6 +369,7 @@ MODULE_DEVICE_TABLE(usb, ub_usb_ids); | |||
| 342 | */ | 369 | */ |
| 343 | #define UB_MAX_HOSTS 26 | 370 | #define UB_MAX_HOSTS 26 |
| 344 | static char ub_hostv[UB_MAX_HOSTS]; | 371 | static char ub_hostv[UB_MAX_HOSTS]; |
| 372 | |||
| 345 | static DEFINE_SPINLOCK(ub_lock); /* Locks globals and ->openc */ | 373 | static DEFINE_SPINLOCK(ub_lock); /* Locks globals and ->openc */ |
| 346 | 374 | ||
| 347 | /* | 375 | /* |
| @@ -406,6 +434,8 @@ static ssize_t ub_diag_show(struct device *dev, char *page) | |||
| 406 | { | 434 | { |
| 407 | struct usb_interface *intf; | 435 | struct usb_interface *intf; |
| 408 | struct ub_dev *sc; | 436 | struct ub_dev *sc; |
| 437 | struct list_head *p; | ||
| 438 | struct ub_lun *lun; | ||
| 409 | int cnt; | 439 | int cnt; |
| 410 | unsigned long flags; | 440 | unsigned long flags; |
| 411 | int nc, nh; | 441 | int nc, nh; |
| @@ -421,9 +451,15 @@ static ssize_t ub_diag_show(struct device *dev, char *page) | |||
| 421 | spin_lock_irqsave(&sc->lock, flags); | 451 | spin_lock_irqsave(&sc->lock, flags); |
| 422 | 452 | ||
| 423 | cnt += sprintf(page + cnt, | 453 | cnt += sprintf(page + cnt, |
| 424 | "qlen %d qmax %d changed %d removable %d readonly %d\n", | 454 | "qlen %d qmax %d\n", |
| 425 | sc->cmd_queue.qlen, sc->cmd_queue.qmax, | 455 | sc->cmd_queue.qlen, sc->cmd_queue.qmax); |
| 426 | sc->changed, sc->removable, sc->readonly); | 456 | |
| 457 | list_for_each (p, &sc->luns) { | ||
| 458 | lun = list_entry(p, struct ub_lun, link); | ||
| 459 | cnt += sprintf(page + cnt, | ||
| 460 | "lun %u changed %d removable %d readonly %d\n", | ||
| 461 | lun->num, lun->changed, lun->removable, lun->readonly); | ||
| 462 | } | ||
| 427 | 463 | ||
| 428 | if ((nc = sc->tr.cur + 1) == SCMD_TRACE_SZ) nc = 0; | 464 | if ((nc = sc->tr.cur + 1) == SCMD_TRACE_SZ) nc = 0; |
| 429 | for (j = 0; j < SCMD_TRACE_SZ; j++) { | 465 | for (j = 0; j < SCMD_TRACE_SZ; j++) { |
| @@ -523,53 +559,63 @@ static void ub_put(struct ub_dev *sc) | |||
| 523 | */ | 559 | */ |
| 524 | static void ub_cleanup(struct ub_dev *sc) | 560 | static void ub_cleanup(struct ub_dev *sc) |
| 525 | { | 561 | { |
| 562 | struct list_head *p; | ||
| 563 | struct ub_lun *lun; | ||
| 526 | request_queue_t *q; | 564 | request_queue_t *q; |
| 527 | 565 | ||
| 528 | /* I don't think queue can be NULL. But... Stolen from sx8.c */ | 566 | while (!list_empty(&sc->luns)) { |
| 529 | if ((q = sc->disk->queue) != NULL) | 567 | p = sc->luns.next; |
| 530 | blk_cleanup_queue(q); | 568 | lun = list_entry(p, struct ub_lun, link); |
| 569 | list_del(p); | ||
| 531 | 570 | ||
| 532 | /* | 571 | /* I don't think queue can be NULL. But... Stolen from sx8.c */ |
| 533 | * If we zero disk->private_data BEFORE put_disk, we have to check | 572 | if ((q = lun->disk->queue) != NULL) |
| 534 | * for NULL all over the place in open, release, check_media and | 573 | blk_cleanup_queue(q); |
| 535 | * revalidate, because the block level semaphore is well inside the | 574 | /* |
| 536 | * put_disk. But we cannot zero after the call, because *disk is gone. | 575 | * If we zero disk->private_data BEFORE put_disk, we have |
| 537 | * The sd.c is blatantly racy in this area. | 576 | * to check for NULL all over the place in open, release, |
| 538 | */ | 577 | * check_media and revalidate, because the block level |
| 539 | /* disk->private_data = NULL; */ | 578 | * semaphore is well inside the put_disk. |
| 540 | put_disk(sc->disk); | 579 | * But we cannot zero after the call, because *disk is gone. |
| 541 | sc->disk = NULL; | 580 | * The sd.c is blatantly racy in this area. |
| 581 | */ | ||
| 582 | /* disk->private_data = NULL; */ | ||
| 583 | put_disk(lun->disk); | ||
| 584 | lun->disk = NULL; | ||
| 585 | |||
| 586 | ub_id_put(lun->id); | ||
| 587 | kfree(lun); | ||
| 588 | } | ||
| 542 | 589 | ||
| 543 | ub_id_put(sc->id); | ||
| 544 | kfree(sc); | 590 | kfree(sc); |
| 545 | } | 591 | } |
| 546 | 592 | ||
| 547 | /* | 593 | /* |
| 548 | * The "command allocator". | 594 | * The "command allocator". |
| 549 | */ | 595 | */ |
| 550 | static struct ub_scsi_cmd *ub_get_cmd(struct ub_dev *sc) | 596 | static struct ub_scsi_cmd *ub_get_cmd(struct ub_lun *lun) |
| 551 | { | 597 | { |
| 552 | struct ub_scsi_cmd *ret; | 598 | struct ub_scsi_cmd *ret; |
| 553 | 599 | ||
| 554 | if (sc->cmda[0]) | 600 | if (lun->cmda[0]) |
| 555 | return NULL; | 601 | return NULL; |
| 556 | ret = &sc->cmdv[0]; | 602 | ret = &lun->cmdv[0]; |
| 557 | sc->cmda[0] = 1; | 603 | lun->cmda[0] = 1; |
| 558 | return ret; | 604 | return ret; |
| 559 | } | 605 | } |
| 560 | 606 | ||
| 561 | static void ub_put_cmd(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | 607 | static void ub_put_cmd(struct ub_lun *lun, struct ub_scsi_cmd *cmd) |
| 562 | { | 608 | { |
| 563 | if (cmd != &sc->cmdv[0]) { | 609 | if (cmd != &lun->cmdv[0]) { |
| 564 | printk(KERN_WARNING "%s: releasing a foreign cmd %p\n", | 610 | printk(KERN_WARNING "%s: releasing a foreign cmd %p\n", |
| 565 | sc->name, cmd); | 611 | lun->name, cmd); |
| 566 | return; | 612 | return; |
| 567 | } | 613 | } |
| 568 | if (!sc->cmda[0]) { | 614 | if (!lun->cmda[0]) { |
| 569 | printk(KERN_WARNING "%s: releasing a free cmd\n", sc->name); | 615 | printk(KERN_WARNING "%s: releasing a free cmd\n", lun->name); |
| 570 | return; | 616 | return; |
| 571 | } | 617 | } |
| 572 | sc->cmda[0] = 0; | 618 | lun->cmda[0] = 0; |
| 573 | } | 619 | } |
| 574 | 620 | ||
| 575 | /* | 621 | /* |
| @@ -630,29 +676,30 @@ static struct ub_scsi_cmd *ub_cmdq_pop(struct ub_dev *sc) | |||
| 630 | 676 | ||
| 631 | static void ub_bd_rq_fn(request_queue_t *q) | 677 | static void ub_bd_rq_fn(request_queue_t *q) |
| 632 | { | 678 | { |
| 633 | struct ub_dev *sc = q->queuedata; | 679 | struct ub_lun *lun = q->queuedata; |
| 634 | struct request *rq; | 680 | struct request *rq; |
| 635 | 681 | ||
| 636 | while ((rq = elv_next_request(q)) != NULL) { | 682 | while ((rq = elv_next_request(q)) != NULL) { |
| 637 | if (ub_bd_rq_fn_1(sc, rq) != 0) { | 683 | if (ub_bd_rq_fn_1(lun, rq) != 0) { |
| 638 | blk_stop_queue(q); | 684 | blk_stop_queue(q); |
| 639 | break; | 685 | break; |
| 640 | } | 686 | } |
| 641 | } | 687 | } |
| 642 | } | 688 | } |
| 643 | 689 | ||
| 644 | static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq) | 690 | static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq) |
| 645 | { | 691 | { |
| 692 | struct ub_dev *sc = lun->udev; | ||
| 646 | struct ub_scsi_cmd *cmd; | 693 | struct ub_scsi_cmd *cmd; |
| 647 | int rc; | 694 | int rc; |
| 648 | 695 | ||
| 649 | if (atomic_read(&sc->poison) || sc->changed) { | 696 | if (atomic_read(&sc->poison) || lun->changed) { |
| 650 | blkdev_dequeue_request(rq); | 697 | blkdev_dequeue_request(rq); |
| 651 | ub_end_rq(rq, 0); | 698 | ub_end_rq(rq, 0); |
| 652 | return 0; | 699 | return 0; |
| 653 | } | 700 | } |
| 654 | 701 | ||
| 655 | if ((cmd = ub_get_cmd(sc)) == NULL) | 702 | if ((cmd = ub_get_cmd(lun)) == NULL) |
| 656 | return -1; | 703 | return -1; |
| 657 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); | 704 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); |
| 658 | 705 | ||
| @@ -661,32 +708,30 @@ static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq) | |||
| 661 | if (blk_pc_request(rq)) { | 708 | if (blk_pc_request(rq)) { |
| 662 | rc = ub_cmd_build_packet(sc, cmd, rq); | 709 | rc = ub_cmd_build_packet(sc, cmd, rq); |
| 663 | } else { | 710 | } else { |
| 664 | rc = ub_cmd_build_block(sc, cmd, rq); | 711 | rc = ub_cmd_build_block(sc, lun, cmd, rq); |
| 665 | } | 712 | } |
| 666 | if (rc != 0) { | 713 | if (rc != 0) { |
| 667 | ub_put_cmd(sc, cmd); | 714 | ub_put_cmd(lun, cmd); |
| 668 | ub_end_rq(rq, 0); | 715 | ub_end_rq(rq, 0); |
| 669 | blk_start_queue(sc->disk->queue); | ||
| 670 | return 0; | 716 | return 0; |
| 671 | } | 717 | } |
| 672 | |||
| 673 | cmd->state = UB_CMDST_INIT; | 718 | cmd->state = UB_CMDST_INIT; |
| 719 | cmd->lun = lun; | ||
| 674 | cmd->done = ub_rw_cmd_done; | 720 | cmd->done = ub_rw_cmd_done; |
| 675 | cmd->back = rq; | 721 | cmd->back = rq; |
| 676 | 722 | ||
| 677 | cmd->tag = sc->tagcnt++; | 723 | cmd->tag = sc->tagcnt++; |
| 678 | if ((rc = ub_submit_scsi(sc, cmd)) != 0) { | 724 | if ((rc = ub_submit_scsi(sc, cmd)) != 0) { |
| 679 | ub_put_cmd(sc, cmd); | 725 | ub_put_cmd(lun, cmd); |
| 680 | ub_end_rq(rq, 0); | 726 | ub_end_rq(rq, 0); |
| 681 | blk_start_queue(sc->disk->queue); | ||
| 682 | return 0; | 727 | return 0; |
| 683 | } | 728 | } |
| 684 | 729 | ||
| 685 | return 0; | 730 | return 0; |
| 686 | } | 731 | } |
| 687 | 732 | ||
| 688 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 733 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, |
| 689 | struct request *rq) | 734 | struct ub_scsi_cmd *cmd, struct request *rq) |
| 690 | { | 735 | { |
| 691 | int ub_dir; | 736 | int ub_dir; |
| 692 | #if 0 /* We use rq->buffer for now */ | 737 | #if 0 /* We use rq->buffer for now */ |
| @@ -707,7 +752,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
| 707 | sg = &cmd->sgv[0]; | 752 | sg = &cmd->sgv[0]; |
| 708 | n_elem = blk_rq_map_sg(q, rq, sg); | 753 | n_elem = blk_rq_map_sg(q, rq, sg); |
| 709 | if (n_elem <= 0) { | 754 | if (n_elem <= 0) { |
| 710 | ub_put_cmd(sc, cmd); | 755 | ub_put_cmd(lun, cmd); |
| 711 | ub_end_rq(rq, 0); | 756 | ub_end_rq(rq, 0); |
| 712 | blk_start_queue(q); | 757 | blk_start_queue(q); |
| 713 | return 0; /* request with no s/g entries? */ | 758 | return 0; /* request with no s/g entries? */ |
| @@ -716,7 +761,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
| 716 | if (n_elem != 1) { /* Paranoia */ | 761 | if (n_elem != 1) { /* Paranoia */ |
| 717 | printk(KERN_WARNING "%s: request with %d segments\n", | 762 | printk(KERN_WARNING "%s: request with %d segments\n", |
| 718 | sc->name, n_elem); | 763 | sc->name, n_elem); |
| 719 | ub_put_cmd(sc, cmd); | 764 | ub_put_cmd(lun, cmd); |
| 720 | ub_end_rq(rq, 0); | 765 | ub_end_rq(rq, 0); |
| 721 | blk_start_queue(q); | 766 | blk_start_queue(q); |
| 722 | return 0; | 767 | return 0; |
| @@ -748,8 +793,8 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
| 748 | * The call to blk_queue_hardsect_size() guarantees that request | 793 | * The call to blk_queue_hardsect_size() guarantees that request |
| 749 | * is aligned, but it is given in terms of 512 byte units, always. | 794 | * is aligned, but it is given in terms of 512 byte units, always. |
| 750 | */ | 795 | */ |
| 751 | block = rq->sector >> sc->capacity.bshift; | 796 | block = rq->sector >> lun->capacity.bshift; |
| 752 | nblks = rq->nr_sectors >> sc->capacity.bshift; | 797 | nblks = rq->nr_sectors >> lun->capacity.bshift; |
| 753 | 798 | ||
| 754 | cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; | 799 | cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; |
| 755 | /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ | 800 | /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ |
| @@ -803,7 +848,8 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
| 803 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | 848 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) |
| 804 | { | 849 | { |
| 805 | struct request *rq = cmd->back; | 850 | struct request *rq = cmd->back; |
| 806 | struct gendisk *disk = sc->disk; | 851 | struct ub_lun *lun = cmd->lun; |
| 852 | struct gendisk *disk = lun->disk; | ||
| 807 | request_queue_t *q = disk->queue; | 853 | request_queue_t *q = disk->queue; |
| 808 | int uptodate; | 854 | int uptodate; |
| 809 | 855 | ||
| @@ -818,7 +864,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 818 | else | 864 | else |
| 819 | uptodate = 0; | 865 | uptodate = 0; |
| 820 | 866 | ||
| 821 | ub_put_cmd(sc, cmd); | 867 | ub_put_cmd(lun, cmd); |
| 822 | ub_end_rq(rq, uptodate); | 868 | ub_end_rq(rq, uptodate); |
| 823 | blk_start_queue(q); | 869 | blk_start_queue(q); |
| 824 | } | 870 | } |
| @@ -887,7 +933,7 @@ static int ub_scsi_cmd_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 887 | bcb->Tag = cmd->tag; /* Endianness is not important */ | 933 | bcb->Tag = cmd->tag; /* Endianness is not important */ |
| 888 | bcb->DataTransferLength = cpu_to_le32(cmd->len); | 934 | bcb->DataTransferLength = cpu_to_le32(cmd->len); |
| 889 | bcb->Flags = (cmd->dir == UB_DIR_READ) ? 0x80 : 0; | 935 | bcb->Flags = (cmd->dir == UB_DIR_READ) ? 0x80 : 0; |
| 890 | bcb->Lun = 0; /* No multi-LUN yet */ | 936 | bcb->Lun = (cmd->lun != NULL) ? cmd->lun->num : 0; |
| 891 | bcb->Length = cmd->cdb_len; | 937 | bcb->Length = cmd->cdb_len; |
| 892 | 938 | ||
| 893 | /* copy the command payload */ | 939 | /* copy the command payload */ |
| @@ -1002,9 +1048,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1002 | * The control pipe clears itself - nothing to do. | 1048 | * The control pipe clears itself - nothing to do. |
| 1003 | * XXX Might try to reset the device here and retry. | 1049 | * XXX Might try to reset the device here and retry. |
| 1004 | */ | 1050 | */ |
| 1005 | printk(KERN_NOTICE "%s: " | 1051 | printk(KERN_NOTICE "%s: stall on control pipe\n", |
| 1006 | "stall on control pipe for device %u\n", | 1052 | sc->name); |
| 1007 | sc->name, sc->dev->devnum); | ||
| 1008 | goto Bad_End; | 1053 | goto Bad_End; |
| 1009 | } | 1054 | } |
| 1010 | 1055 | ||
| @@ -1025,9 +1070,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1025 | * The control pipe clears itself - nothing to do. | 1070 | * The control pipe clears itself - nothing to do. |
| 1026 | * XXX Might try to reset the device here and retry. | 1071 | * XXX Might try to reset the device here and retry. |
| 1027 | */ | 1072 | */ |
| 1028 | printk(KERN_NOTICE "%s: " | 1073 | printk(KERN_NOTICE "%s: stall on control pipe\n", |
| 1029 | "stall on control pipe for device %u\n", | 1074 | sc->name); |
| 1030 | sc->name, sc->dev->devnum); | ||
| 1031 | goto Bad_End; | 1075 | goto Bad_End; |
| 1032 | } | 1076 | } |
| 1033 | 1077 | ||
| @@ -1046,9 +1090,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1046 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); | 1090 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); |
| 1047 | if (rc != 0) { | 1091 | if (rc != 0) { |
| 1048 | printk(KERN_NOTICE "%s: " | 1092 | printk(KERN_NOTICE "%s: " |
| 1049 | "unable to submit clear for device %u" | 1093 | "unable to submit clear (%d)\n", |
| 1050 | " (code %d)\n", | 1094 | sc->name, rc); |
| 1051 | sc->name, sc->dev->devnum, rc); | ||
| 1052 | /* | 1095 | /* |
| 1053 | * This is typically ENOMEM or some other such shit. | 1096 | * This is typically ENOMEM or some other such shit. |
| 1054 | * Retrying is pointless. Just do Bad End on it... | 1097 | * Retrying is pointless. Just do Bad End on it... |
| @@ -1107,9 +1150,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1107 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); | 1150 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); |
| 1108 | if (rc != 0) { | 1151 | if (rc != 0) { |
| 1109 | printk(KERN_NOTICE "%s: " | 1152 | printk(KERN_NOTICE "%s: " |
| 1110 | "unable to submit clear for device %u" | 1153 | "unable to submit clear (%d)\n", |
| 1111 | " (code %d)\n", | 1154 | sc->name, rc); |
| 1112 | sc->name, sc->dev->devnum, rc); | ||
| 1113 | /* | 1155 | /* |
| 1114 | * This is typically ENOMEM or some other such shit. | 1156 | * This is typically ENOMEM or some other such shit. |
| 1115 | * Retrying is pointless. Just do Bad End on it... | 1157 | * Retrying is pointless. Just do Bad End on it... |
| @@ -1140,9 +1182,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1140 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); | 1182 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); |
| 1141 | if (rc != 0) { | 1183 | if (rc != 0) { |
| 1142 | printk(KERN_NOTICE "%s: " | 1184 | printk(KERN_NOTICE "%s: " |
| 1143 | "unable to submit clear for device %u" | 1185 | "unable to submit clear (%d)\n", |
| 1144 | " (code %d)\n", | 1186 | sc->name, rc); |
| 1145 | sc->name, sc->dev->devnum, rc); | ||
| 1146 | /* | 1187 | /* |
| 1147 | * This is typically ENOMEM or some other such shit. | 1188 | * This is typically ENOMEM or some other such shit. |
| 1148 | * Retrying is pointless. Just do Bad End on it... | 1189 | * Retrying is pointless. Just do Bad End on it... |
| @@ -1164,9 +1205,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1164 | * encounter such a thing, try to read the CSW again. | 1205 | * encounter such a thing, try to read the CSW again. |
| 1165 | */ | 1206 | */ |
| 1166 | if (++cmd->stat_count >= 4) { | 1207 | if (++cmd->stat_count >= 4) { |
| 1167 | printk(KERN_NOTICE "%s: " | 1208 | printk(KERN_NOTICE "%s: unable to get CSW\n", |
| 1168 | "unable to get CSW on device %u\n", | 1209 | sc->name); |
| 1169 | sc->name, sc->dev->devnum); | ||
| 1170 | goto Bad_End; | 1210 | goto Bad_End; |
| 1171 | } | 1211 | } |
| 1172 | __ub_state_stat(sc, cmd); | 1212 | __ub_state_stat(sc, cmd); |
| @@ -1207,10 +1247,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1207 | */ | 1247 | */ |
| 1208 | if (++cmd->stat_count >= 4) { | 1248 | if (++cmd->stat_count >= 4) { |
| 1209 | printk(KERN_NOTICE "%s: " | 1249 | printk(KERN_NOTICE "%s: " |
| 1210 | "tag mismatch orig 0x%x reply 0x%x " | 1250 | "tag mismatch orig 0x%x reply 0x%x\n", |
| 1211 | "on device %u\n", | 1251 | sc->name, cmd->tag, bcs->Tag); |
| 1212 | sc->name, cmd->tag, bcs->Tag, | ||
| 1213 | sc->dev->devnum); | ||
| 1214 | goto Bad_End; | 1252 | goto Bad_End; |
| 1215 | } | 1253 | } |
| 1216 | __ub_state_stat(sc, cmd); | 1254 | __ub_state_stat(sc, cmd); |
| @@ -1244,8 +1282,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1244 | 1282 | ||
| 1245 | } else { | 1283 | } else { |
| 1246 | printk(KERN_WARNING "%s: " | 1284 | printk(KERN_WARNING "%s: " |
| 1247 | "wrong command state %d on device %u\n", | 1285 | "wrong command state %d\n", |
| 1248 | sc->name, cmd->state, sc->dev->devnum); | 1286 | sc->name, cmd->state); |
| 1249 | goto Bad_End; | 1287 | goto Bad_End; |
| 1250 | } | 1288 | } |
| 1251 | return; | 1289 | return; |
| @@ -1288,7 +1326,6 @@ static void __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1288 | 1326 | ||
| 1289 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { | 1327 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { |
| 1290 | /* XXX Clear stalls */ | 1328 | /* XXX Clear stalls */ |
| 1291 | printk("%s: CSW #%d submit failed (%d)\n", sc->name, cmd->tag, rc); /* P3 */ | ||
| 1292 | ub_complete(&sc->work_done); | 1329 | ub_complete(&sc->work_done); |
| 1293 | ub_state_done(sc, cmd, rc); | 1330 | ub_state_done(sc, cmd, rc); |
| 1294 | return; | 1331 | return; |
| @@ -1333,6 +1370,7 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1333 | scmd->state = UB_CMDST_INIT; | 1370 | scmd->state = UB_CMDST_INIT; |
| 1334 | scmd->data = sc->top_sense; | 1371 | scmd->data = sc->top_sense; |
| 1335 | scmd->len = UB_SENSE_SIZE; | 1372 | scmd->len = UB_SENSE_SIZE; |
| 1373 | scmd->lun = cmd->lun; | ||
| 1336 | scmd->done = ub_top_sense_done; | 1374 | scmd->done = ub_top_sense_done; |
| 1337 | scmd->back = cmd; | 1375 | scmd->back = cmd; |
| 1338 | 1376 | ||
| @@ -1411,14 +1449,14 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) | |||
| 1411 | } | 1449 | } |
| 1412 | if (cmd != scmd->back) { | 1450 | if (cmd != scmd->back) { |
| 1413 | printk(KERN_WARNING "%s: " | 1451 | printk(KERN_WARNING "%s: " |
| 1414 | "sense done for wrong command 0x%x on device %u\n", | 1452 | "sense done for wrong command 0x%x\n", |
| 1415 | sc->name, cmd->tag, sc->dev->devnum); | 1453 | sc->name, cmd->tag); |
| 1416 | return; | 1454 | return; |
| 1417 | } | 1455 | } |
| 1418 | if (cmd->state != UB_CMDST_SENSE) { | 1456 | if (cmd->state != UB_CMDST_SENSE) { |
| 1419 | printk(KERN_WARNING "%s: " | 1457 | printk(KERN_WARNING "%s: " |
| 1420 | "sense done with bad cmd state %d on device %u\n", | 1458 | "sense done with bad cmd state %d\n", |
| 1421 | sc->name, cmd->state, sc->dev->devnum); | 1459 | sc->name, cmd->state); |
| 1422 | return; | 1460 | return; |
| 1423 | } | 1461 | } |
| 1424 | 1462 | ||
| @@ -1429,68 +1467,32 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) | |||
| 1429 | ub_scsi_urb_compl(sc, cmd); | 1467 | ub_scsi_urb_compl(sc, cmd); |
| 1430 | } | 1468 | } |
| 1431 | 1469 | ||
| 1432 | #if 0 | ||
| 1433 | /* Determine what the maximum LUN supported is */ | ||
| 1434 | int usb_stor_Bulk_max_lun(struct us_data *us) | ||
| 1435 | { | ||
| 1436 | int result; | ||
| 1437 | |||
| 1438 | /* issue the command */ | ||
| 1439 | result = usb_stor_control_msg(us, us->recv_ctrl_pipe, | ||
| 1440 | US_BULK_GET_MAX_LUN, | ||
| 1441 | USB_DIR_IN | USB_TYPE_CLASS | | ||
| 1442 | USB_RECIP_INTERFACE, | ||
| 1443 | 0, us->ifnum, us->iobuf, 1, HZ); | ||
| 1444 | |||
| 1445 | /* | ||
| 1446 | * Some devices (i.e. Iomega Zip100) need this -- apparently | ||
| 1447 | * the bulk pipes get STALLed when the GetMaxLUN request is | ||
| 1448 | * processed. This is, in theory, harmless to all other devices | ||
| 1449 | * (regardless of if they stall or not). | ||
| 1450 | */ | ||
| 1451 | if (result < 0) { | ||
| 1452 | usb_stor_clear_halt(us, us->recv_bulk_pipe); | ||
| 1453 | usb_stor_clear_halt(us, us->send_bulk_pipe); | ||
| 1454 | } | ||
| 1455 | |||
| 1456 | US_DEBUGP("GetMaxLUN command result is %d, data is %d\n", | ||
| 1457 | result, us->iobuf[0]); | ||
| 1458 | |||
| 1459 | /* if we have a successful request, return the result */ | ||
| 1460 | if (result == 1) | ||
| 1461 | return us->iobuf[0]; | ||
| 1462 | |||
| 1463 | /* return the default -- no LUNs */ | ||
| 1464 | return 0; | ||
| 1465 | } | ||
| 1466 | #endif | ||
| 1467 | |||
| 1468 | /* | 1470 | /* |
| 1469 | * This is called from a process context. | 1471 | * This is called from a process context. |
| 1470 | */ | 1472 | */ |
| 1471 | static void ub_revalidate(struct ub_dev *sc) | 1473 | static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) |
| 1472 | { | 1474 | { |
| 1473 | 1475 | ||
| 1474 | sc->readonly = 0; /* XXX Query this from the device */ | 1476 | lun->readonly = 0; /* XXX Query this from the device */ |
| 1475 | 1477 | ||
| 1476 | sc->capacity.nsec = 0; | 1478 | lun->capacity.nsec = 0; |
| 1477 | sc->capacity.bsize = 512; | 1479 | lun->capacity.bsize = 512; |
| 1478 | sc->capacity.bshift = 0; | 1480 | lun->capacity.bshift = 0; |
| 1479 | 1481 | ||
| 1480 | if (ub_sync_tur(sc) != 0) | 1482 | if (ub_sync_tur(sc, lun) != 0) |
| 1481 | return; /* Not ready */ | 1483 | return; /* Not ready */ |
| 1482 | sc->changed = 0; | 1484 | lun->changed = 0; |
| 1483 | 1485 | ||
| 1484 | if (ub_sync_read_cap(sc, &sc->capacity) != 0) { | 1486 | if (ub_sync_read_cap(sc, lun, &lun->capacity) != 0) { |
| 1485 | /* | 1487 | /* |
| 1486 | * The retry here means something is wrong, either with the | 1488 | * The retry here means something is wrong, either with the |
| 1487 | * device, with the transport, or with our code. | 1489 | * device, with the transport, or with our code. |
| 1488 | * We keep this because sd.c has retries for capacity. | 1490 | * We keep this because sd.c has retries for capacity. |
| 1489 | */ | 1491 | */ |
| 1490 | if (ub_sync_read_cap(sc, &sc->capacity) != 0) { | 1492 | if (ub_sync_read_cap(sc, lun, &lun->capacity) != 0) { |
| 1491 | sc->capacity.nsec = 0; | 1493 | lun->capacity.nsec = 0; |
| 1492 | sc->capacity.bsize = 512; | 1494 | lun->capacity.bsize = 512; |
| 1493 | sc->capacity.bshift = 0; | 1495 | lun->capacity.bshift = 0; |
| 1494 | } | 1496 | } |
| 1495 | } | 1497 | } |
| 1496 | } | 1498 | } |
| @@ -1503,12 +1505,15 @@ static void ub_revalidate(struct ub_dev *sc) | |||
| 1503 | static int ub_bd_open(struct inode *inode, struct file *filp) | 1505 | static int ub_bd_open(struct inode *inode, struct file *filp) |
| 1504 | { | 1506 | { |
| 1505 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1507 | struct gendisk *disk = inode->i_bdev->bd_disk; |
| 1508 | struct ub_lun *lun; | ||
| 1506 | struct ub_dev *sc; | 1509 | struct ub_dev *sc; |
| 1507 | unsigned long flags; | 1510 | unsigned long flags; |
| 1508 | int rc; | 1511 | int rc; |
| 1509 | 1512 | ||
| 1510 | if ((sc = disk->private_data) == NULL) | 1513 | if ((lun = disk->private_data) == NULL) |
| 1511 | return -ENXIO; | 1514 | return -ENXIO; |
| 1515 | sc = lun->udev; | ||
| 1516 | |||
| 1512 | spin_lock_irqsave(&ub_lock, flags); | 1517 | spin_lock_irqsave(&ub_lock, flags); |
| 1513 | if (atomic_read(&sc->poison)) { | 1518 | if (atomic_read(&sc->poison)) { |
| 1514 | spin_unlock_irqrestore(&ub_lock, flags); | 1519 | spin_unlock_irqrestore(&ub_lock, flags); |
| @@ -1529,15 +1534,15 @@ static int ub_bd_open(struct inode *inode, struct file *filp) | |||
| 1529 | * The bottom line is, Al Viro says that we should not allow | 1534 | * The bottom line is, Al Viro says that we should not allow |
| 1530 | * bdev->bd_invalidated to be set when doing add_disk no matter what. | 1535 | * bdev->bd_invalidated to be set when doing add_disk no matter what. |
| 1531 | */ | 1536 | */ |
| 1532 | if (sc->first_open) { | 1537 | if (lun->first_open) { |
| 1533 | if (sc->changed) { | 1538 | lun->first_open = 0; |
| 1534 | sc->first_open = 0; | 1539 | if (lun->changed) { |
| 1535 | rc = -ENOMEDIUM; | 1540 | rc = -ENOMEDIUM; |
| 1536 | goto err_open; | 1541 | goto err_open; |
| 1537 | } | 1542 | } |
| 1538 | } | 1543 | } |
| 1539 | 1544 | ||
| 1540 | if (sc->removable || sc->readonly) | 1545 | if (lun->removable || lun->readonly) |
| 1541 | check_disk_change(inode->i_bdev); | 1546 | check_disk_change(inode->i_bdev); |
| 1542 | 1547 | ||
| 1543 | /* | 1548 | /* |
| @@ -1545,12 +1550,12 @@ static int ub_bd_open(struct inode *inode, struct file *filp) | |||
| 1545 | * under some pretty murky conditions (a failure of READ CAPACITY). | 1550 | * under some pretty murky conditions (a failure of READ CAPACITY). |
| 1546 | * We may need it one day. | 1551 | * We may need it one day. |
| 1547 | */ | 1552 | */ |
| 1548 | if (sc->removable && sc->changed && !(filp->f_flags & O_NDELAY)) { | 1553 | if (lun->removable && lun->changed && !(filp->f_flags & O_NDELAY)) { |
| 1549 | rc = -ENOMEDIUM; | 1554 | rc = -ENOMEDIUM; |
| 1550 | goto err_open; | 1555 | goto err_open; |
| 1551 | } | 1556 | } |
| 1552 | 1557 | ||
| 1553 | if (sc->readonly && (filp->f_mode & FMODE_WRITE)) { | 1558 | if (lun->readonly && (filp->f_mode & FMODE_WRITE)) { |
| 1554 | rc = -EROFS; | 1559 | rc = -EROFS; |
| 1555 | goto err_open; | 1560 | goto err_open; |
| 1556 | } | 1561 | } |
| @@ -1567,7 +1572,8 @@ err_open: | |||
| 1567 | static int ub_bd_release(struct inode *inode, struct file *filp) | 1572 | static int ub_bd_release(struct inode *inode, struct file *filp) |
| 1568 | { | 1573 | { |
| 1569 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1574 | struct gendisk *disk = inode->i_bdev->bd_disk; |
| 1570 | struct ub_dev *sc = disk->private_data; | 1575 | struct ub_lun *lun = disk->private_data; |
| 1576 | struct ub_dev *sc = lun->udev; | ||
| 1571 | 1577 | ||
| 1572 | ub_put(sc); | 1578 | ub_put(sc); |
| 1573 | return 0; | 1579 | return 0; |
| @@ -1597,20 +1603,14 @@ static int ub_bd_ioctl(struct inode *inode, struct file *filp, | |||
| 1597 | */ | 1603 | */ |
| 1598 | static int ub_bd_revalidate(struct gendisk *disk) | 1604 | static int ub_bd_revalidate(struct gendisk *disk) |
| 1599 | { | 1605 | { |
| 1600 | struct ub_dev *sc = disk->private_data; | 1606 | struct ub_lun *lun = disk->private_data; |
| 1601 | 1607 | ||
| 1602 | ub_revalidate(sc); | 1608 | ub_revalidate(lun->udev, lun); |
| 1603 | /* This is pretty much a long term P3 */ | ||
| 1604 | if (!atomic_read(&sc->poison)) { /* Cover sc->dev */ | ||
| 1605 | printk(KERN_INFO "%s: device %u capacity nsec %ld bsize %u\n", | ||
| 1606 | sc->name, sc->dev->devnum, | ||
| 1607 | sc->capacity.nsec, sc->capacity.bsize); | ||
| 1608 | } | ||
| 1609 | 1609 | ||
| 1610 | /* XXX Support sector size switching like in sr.c */ | 1610 | /* XXX Support sector size switching like in sr.c */ |
| 1611 | blk_queue_hardsect_size(disk->queue, sc->capacity.bsize); | 1611 | blk_queue_hardsect_size(disk->queue, lun->capacity.bsize); |
| 1612 | set_capacity(disk, sc->capacity.nsec); | 1612 | set_capacity(disk, lun->capacity.nsec); |
| 1613 | // set_disk_ro(sdkp->disk, sc->readonly); | 1613 | // set_disk_ro(sdkp->disk, lun->readonly); |
| 1614 | 1614 | ||
| 1615 | return 0; | 1615 | return 0; |
| 1616 | } | 1616 | } |
| @@ -1626,9 +1626,9 @@ static int ub_bd_revalidate(struct gendisk *disk) | |||
| 1626 | */ | 1626 | */ |
| 1627 | static int ub_bd_media_changed(struct gendisk *disk) | 1627 | static int ub_bd_media_changed(struct gendisk *disk) |
| 1628 | { | 1628 | { |
| 1629 | struct ub_dev *sc = disk->private_data; | 1629 | struct ub_lun *lun = disk->private_data; |
| 1630 | 1630 | ||
| 1631 | if (!sc->removable) | 1631 | if (!lun->removable) |
| 1632 | return 0; | 1632 | return 0; |
| 1633 | 1633 | ||
| 1634 | /* | 1634 | /* |
| @@ -1640,12 +1640,12 @@ static int ub_bd_media_changed(struct gendisk *disk) | |||
| 1640 | * will fail, then block layer discards the data. Since we never | 1640 | * will fail, then block layer discards the data. Since we never |
| 1641 | * spin drives up, such devices simply cannot be used with ub anyway. | 1641 | * spin drives up, such devices simply cannot be used with ub anyway. |
| 1642 | */ | 1642 | */ |
| 1643 | if (ub_sync_tur(sc) != 0) { | 1643 | if (ub_sync_tur(lun->udev, lun) != 0) { |
| 1644 | sc->changed = 1; | 1644 | lun->changed = 1; |
| 1645 | return 1; | 1645 | return 1; |
| 1646 | } | 1646 | } |
| 1647 | 1647 | ||
| 1648 | return sc->changed; | 1648 | return lun->changed; |
| 1649 | } | 1649 | } |
| 1650 | 1650 | ||
| 1651 | static struct block_device_operations ub_bd_fops = { | 1651 | static struct block_device_operations ub_bd_fops = { |
| @@ -1669,7 +1669,7 @@ static void ub_probe_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1669 | /* | 1669 | /* |
| 1670 | * Test if the device has a check condition on it, synchronously. | 1670 | * Test if the device has a check condition on it, synchronously. |
| 1671 | */ | 1671 | */ |
| 1672 | static int ub_sync_tur(struct ub_dev *sc) | 1672 | static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun) |
| 1673 | { | 1673 | { |
| 1674 | struct ub_scsi_cmd *cmd; | 1674 | struct ub_scsi_cmd *cmd; |
| 1675 | enum { ALLOC_SIZE = sizeof(struct ub_scsi_cmd) }; | 1675 | enum { ALLOC_SIZE = sizeof(struct ub_scsi_cmd) }; |
| @@ -1688,6 +1688,7 @@ static int ub_sync_tur(struct ub_dev *sc) | |||
| 1688 | cmd->cdb_len = 6; | 1688 | cmd->cdb_len = 6; |
| 1689 | cmd->dir = UB_DIR_NONE; | 1689 | cmd->dir = UB_DIR_NONE; |
| 1690 | cmd->state = UB_CMDST_INIT; | 1690 | cmd->state = UB_CMDST_INIT; |
| 1691 | cmd->lun = lun; /* This may be NULL, but that's ok */ | ||
| 1691 | cmd->done = ub_probe_done; | 1692 | cmd->done = ub_probe_done; |
| 1692 | cmd->back = &compl; | 1693 | cmd->back = &compl; |
| 1693 | 1694 | ||
| @@ -1718,7 +1719,8 @@ err_alloc: | |||
| 1718 | /* | 1719 | /* |
| 1719 | * Read the SCSI capacity synchronously (for probing). | 1720 | * Read the SCSI capacity synchronously (for probing). |
| 1720 | */ | 1721 | */ |
| 1721 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret) | 1722 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, |
| 1723 | struct ub_capacity *ret) | ||
| 1722 | { | 1724 | { |
| 1723 | struct ub_scsi_cmd *cmd; | 1725 | struct ub_scsi_cmd *cmd; |
| 1724 | char *p; | 1726 | char *p; |
| @@ -1743,6 +1745,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret) | |||
| 1743 | cmd->state = UB_CMDST_INIT; | 1745 | cmd->state = UB_CMDST_INIT; |
| 1744 | cmd->data = p; | 1746 | cmd->data = p; |
| 1745 | cmd->len = 8; | 1747 | cmd->len = 8; |
| 1748 | cmd->lun = lun; | ||
| 1746 | cmd->done = ub_probe_done; | 1749 | cmd->done = ub_probe_done; |
| 1747 | cmd->back = &compl; | 1750 | cmd->back = &compl; |
| 1748 | 1751 | ||
| @@ -1812,6 +1815,90 @@ static void ub_probe_timeout(unsigned long arg) | |||
| 1812 | } | 1815 | } |
| 1813 | 1816 | ||
| 1814 | /* | 1817 | /* |
| 1818 | * Get number of LUNs by the way of Bulk GetMaxLUN command. | ||
| 1819 | */ | ||
| 1820 | static int ub_sync_getmaxlun(struct ub_dev *sc) | ||
| 1821 | { | ||
| 1822 | int ifnum = sc->intf->cur_altsetting->desc.bInterfaceNumber; | ||
| 1823 | unsigned char *p; | ||
| 1824 | enum { ALLOC_SIZE = 1 }; | ||
| 1825 | struct usb_ctrlrequest *cr; | ||
| 1826 | struct completion compl; | ||
| 1827 | struct timer_list timer; | ||
| 1828 | int nluns; | ||
| 1829 | int rc; | ||
| 1830 | |||
| 1831 | init_completion(&compl); | ||
| 1832 | |||
| 1833 | rc = -ENOMEM; | ||
| 1834 | if ((p = kmalloc(ALLOC_SIZE, GFP_KERNEL)) == NULL) | ||
| 1835 | goto err_alloc; | ||
| 1836 | *p = 55; | ||
| 1837 | |||
| 1838 | cr = &sc->work_cr; | ||
| 1839 | cr->bRequestType = USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; | ||
| 1840 | cr->bRequest = US_BULK_GET_MAX_LUN; | ||
| 1841 | cr->wValue = cpu_to_le16(0); | ||
| 1842 | cr->wIndex = cpu_to_le16(ifnum); | ||
| 1843 | cr->wLength = cpu_to_le16(1); | ||
| 1844 | |||
| 1845 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->recv_ctrl_pipe, | ||
| 1846 | (unsigned char*) cr, p, 1, ub_probe_urb_complete, &compl); | ||
| 1847 | sc->work_urb.transfer_flags = 0; | ||
| 1848 | sc->work_urb.actual_length = 0; | ||
| 1849 | sc->work_urb.error_count = 0; | ||
| 1850 | sc->work_urb.status = 0; | ||
| 1851 | |||
| 1852 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { | ||
| 1853 | if (rc == -EPIPE) { | ||
| 1854 | printk("%s: Stall at GetMaxLUN, using 1 LUN\n", | ||
| 1855 | sc->name); /* P3 */ | ||
| 1856 | } else { | ||
| 1857 | printk(KERN_WARNING | ||
| 1858 | "%s: Unable to submit GetMaxLUN (%d)\n", | ||
| 1859 | sc->name, rc); | ||
| 1860 | } | ||
| 1861 | goto err_submit; | ||
| 1862 | } | ||
| 1863 | |||
| 1864 | init_timer(&timer); | ||
| 1865 | timer.function = ub_probe_timeout; | ||
| 1866 | timer.data = (unsigned long) &compl; | ||
| 1867 | timer.expires = jiffies + UB_CTRL_TIMEOUT; | ||
| 1868 | add_timer(&timer); | ||
| 1869 | |||
| 1870 | wait_for_completion(&compl); | ||
| 1871 | |||
| 1872 | del_timer_sync(&timer); | ||
| 1873 | usb_kill_urb(&sc->work_urb); | ||
| 1874 | |||
| 1875 | if (sc->work_urb.actual_length != 1) { | ||
| 1876 | printk("%s: GetMaxLUN returned %d bytes\n", sc->name, | ||
| 1877 | sc->work_urb.actual_length); /* P3 */ | ||
| 1878 | nluns = 0; | ||
| 1879 | } else { | ||
| 1880 | if ((nluns = *p) == 55) { | ||
| 1881 | nluns = 0; | ||
| 1882 | } else { | ||
| 1883 | /* GetMaxLUN returns the maximum LUN number */ | ||
| 1884 | nluns += 1; | ||
| 1885 | if (nluns > UB_MAX_LUNS) | ||
| 1886 | nluns = UB_MAX_LUNS; | ||
| 1887 | } | ||
| 1888 | printk("%s: GetMaxLUN returned %d, using %d LUNs\n", sc->name, | ||
| 1889 | *p, nluns); /* P3 */ | ||
| 1890 | } | ||
| 1891 | |||
| 1892 | kfree(p); | ||
| 1893 | return nluns; | ||
| 1894 | |||
| 1895 | err_submit: | ||
| 1896 | kfree(p); | ||
| 1897 | err_alloc: | ||
| 1898 | return rc; | ||
| 1899 | } | ||
| 1900 | |||
| 1901 | /* | ||
| 1815 | * Clear initial stalls. | 1902 | * Clear initial stalls. |
| 1816 | */ | 1903 | */ |
| 1817 | static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe) | 1904 | static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe) |
| @@ -1897,8 +1984,8 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev, | |||
| 1897 | } | 1984 | } |
| 1898 | 1985 | ||
| 1899 | if (ep_in == NULL || ep_out == NULL) { | 1986 | if (ep_in == NULL || ep_out == NULL) { |
| 1900 | printk(KERN_NOTICE "%s: device %u failed endpoint check\n", | 1987 | printk(KERN_NOTICE "%s: failed endpoint check\n", |
| 1901 | sc->name, sc->dev->devnum); | 1988 | sc->name); |
| 1902 | return -EIO; | 1989 | return -EIO; |
| 1903 | } | 1990 | } |
| 1904 | 1991 | ||
| @@ -1921,8 +2008,7 @@ static int ub_probe(struct usb_interface *intf, | |||
| 1921 | const struct usb_device_id *dev_id) | 2008 | const struct usb_device_id *dev_id) |
| 1922 | { | 2009 | { |
| 1923 | struct ub_dev *sc; | 2010 | struct ub_dev *sc; |
| 1924 | request_queue_t *q; | 2011 | int nluns; |
| 1925 | struct gendisk *disk; | ||
| 1926 | int rc; | 2012 | int rc; |
| 1927 | int i; | 2013 | int i; |
| 1928 | 2014 | ||
| @@ -1931,6 +2017,7 @@ static int ub_probe(struct usb_interface *intf, | |||
| 1931 | goto err_core; | 2017 | goto err_core; |
| 1932 | memset(sc, 0, sizeof(struct ub_dev)); | 2018 | memset(sc, 0, sizeof(struct ub_dev)); |
| 1933 | spin_lock_init(&sc->lock); | 2019 | spin_lock_init(&sc->lock); |
| 2020 | INIT_LIST_HEAD(&sc->luns); | ||
| 1934 | usb_init_urb(&sc->work_urb); | 2021 | usb_init_urb(&sc->work_urb); |
| 1935 | tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); | 2022 | tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); |
| 1936 | atomic_set(&sc->poison, 0); | 2023 | atomic_set(&sc->poison, 0); |
| @@ -1942,19 +2029,16 @@ static int ub_probe(struct usb_interface *intf, | |||
| 1942 | ub_init_completion(&sc->work_done); | 2029 | ub_init_completion(&sc->work_done); |
| 1943 | sc->work_done.done = 1; /* A little yuk, but oh well... */ | 2030 | sc->work_done.done = 1; /* A little yuk, but oh well... */ |
| 1944 | 2031 | ||
| 1945 | rc = -ENOSR; | ||
| 1946 | if ((sc->id = ub_id_get()) == -1) | ||
| 1947 | goto err_id; | ||
| 1948 | snprintf(sc->name, 8, DRV_NAME "%c", sc->id + 'a'); | ||
| 1949 | |||
| 1950 | sc->dev = interface_to_usbdev(intf); | 2032 | sc->dev = interface_to_usbdev(intf); |
| 1951 | sc->intf = intf; | 2033 | sc->intf = intf; |
| 1952 | // sc->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; | 2034 | // sc->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; |
| 1953 | |||
| 1954 | usb_set_intfdata(intf, sc); | 2035 | usb_set_intfdata(intf, sc); |
| 1955 | usb_get_dev(sc->dev); | 2036 | usb_get_dev(sc->dev); |
| 1956 | // usb_get_intf(sc->intf); /* Do we need this? */ | 2037 | // usb_get_intf(sc->intf); /* Do we need this? */ |
| 1957 | 2038 | ||
| 2039 | snprintf(sc->name, 12, DRV_NAME "(%d.%d)", | ||
| 2040 | sc->dev->bus->busnum, sc->dev->devnum); | ||
| 2041 | |||
| 1958 | /* XXX Verify that we can handle the device (from descriptors) */ | 2042 | /* XXX Verify that we can handle the device (from descriptors) */ |
| 1959 | 2043 | ||
| 1960 | ub_get_pipes(sc, sc->dev, intf); | 2044 | ub_get_pipes(sc, sc->dev, intf); |
| @@ -1992,35 +2076,88 @@ static int ub_probe(struct usb_interface *intf, | |||
| 1992 | * In any case it's not our business how revaliadation is implemented. | 2076 | * In any case it's not our business how revaliadation is implemented. |
| 1993 | */ | 2077 | */ |
| 1994 | for (i = 0; i < 3; i++) { /* Retries for benh's key */ | 2078 | for (i = 0; i < 3; i++) { /* Retries for benh's key */ |
| 1995 | if ((rc = ub_sync_tur(sc)) <= 0) break; | 2079 | if ((rc = ub_sync_tur(sc, NULL)) <= 0) break; |
| 1996 | if (rc != 0x6) break; | 2080 | if (rc != 0x6) break; |
| 1997 | msleep(10); | 2081 | msleep(10); |
| 1998 | } | 2082 | } |
| 1999 | 2083 | ||
| 2000 | sc->removable = 1; /* XXX Query this from the device */ | 2084 | nluns = 1; |
| 2001 | sc->changed = 1; /* ub_revalidate clears only */ | 2085 | for (i = 0; i < 3; i++) { |
| 2002 | sc->first_open = 1; | 2086 | if ((rc = ub_sync_getmaxlun(sc)) < 0) { |
| 2087 | /* | ||
| 2088 | * Some devices (i.e. Iomega Zip100) need this -- | ||
| 2089 | * apparently the bulk pipes get STALLed when the | ||
| 2090 | * GetMaxLUN request is processed. | ||
| 2091 | * XXX I have a ZIP-100, verify it does this. | ||
| 2092 | */ | ||
| 2093 | if (rc == -EPIPE) { | ||
| 2094 | ub_probe_clear_stall(sc, sc->recv_bulk_pipe); | ||
| 2095 | ub_probe_clear_stall(sc, sc->send_bulk_pipe); | ||
| 2096 | } | ||
| 2097 | break; | ||
| 2098 | } | ||
| 2099 | if (rc != 0) { | ||
| 2100 | nluns = rc; | ||
| 2101 | break; | ||
| 2102 | } | ||
| 2103 | mdelay(100); | ||
| 2104 | } | ||
| 2003 | 2105 | ||
| 2004 | ub_revalidate(sc); | 2106 | for (i = 0; i < nluns; i++) { |
| 2005 | /* This is pretty much a long term P3 */ | 2107 | ub_probe_lun(sc, i); |
| 2006 | printk(KERN_INFO "%s: device %u capacity nsec %ld bsize %u\n", | 2108 | } |
| 2007 | sc->name, sc->dev->devnum, sc->capacity.nsec, sc->capacity.bsize); | 2109 | return 0; |
| 2110 | |||
| 2111 | /* device_remove_file(&sc->intf->dev, &dev_attr_diag); */ | ||
| 2112 | err_diag: | ||
| 2113 | usb_set_intfdata(intf, NULL); | ||
| 2114 | // usb_put_intf(sc->intf); | ||
| 2115 | usb_put_dev(sc->dev); | ||
| 2116 | kfree(sc); | ||
| 2117 | err_core: | ||
| 2118 | return rc; | ||
| 2119 | } | ||
| 2120 | |||
| 2121 | static int ub_probe_lun(struct ub_dev *sc, int lnum) | ||
| 2122 | { | ||
| 2123 | struct ub_lun *lun; | ||
| 2124 | request_queue_t *q; | ||
| 2125 | struct gendisk *disk; | ||
| 2126 | int rc; | ||
| 2127 | |||
| 2128 | rc = -ENOMEM; | ||
| 2129 | if ((lun = kmalloc(sizeof(struct ub_lun), GFP_KERNEL)) == NULL) | ||
| 2130 | goto err_alloc; | ||
| 2131 | memset(lun, 0, sizeof(struct ub_lun)); | ||
| 2132 | lun->num = lnum; | ||
| 2133 | |||
| 2134 | rc = -ENOSR; | ||
| 2135 | if ((lun->id = ub_id_get()) == -1) | ||
| 2136 | goto err_id; | ||
| 2137 | |||
| 2138 | lun->udev = sc; | ||
| 2139 | list_add(&lun->link, &sc->luns); | ||
| 2140 | |||
| 2141 | snprintf(lun->name, 16, DRV_NAME "%c(%d.%d.%d)", | ||
| 2142 | lun->id + 'a', sc->dev->bus->busnum, sc->dev->devnum, lun->num); | ||
| 2143 | |||
| 2144 | lun->removable = 1; /* XXX Query this from the device */ | ||
| 2145 | lun->changed = 1; /* ub_revalidate clears only */ | ||
| 2146 | lun->first_open = 1; | ||
| 2147 | ub_revalidate(sc, lun); | ||
| 2008 | 2148 | ||
| 2009 | /* | ||
| 2010 | * Just one disk per sc currently, but maybe more. | ||
| 2011 | */ | ||
| 2012 | rc = -ENOMEM; | 2149 | rc = -ENOMEM; |
| 2013 | if ((disk = alloc_disk(UB_MINORS_PER_MAJOR)) == NULL) | 2150 | if ((disk = alloc_disk(UB_MINORS_PER_MAJOR)) == NULL) |
| 2014 | goto err_diskalloc; | 2151 | goto err_diskalloc; |
| 2015 | 2152 | ||
| 2016 | sc->disk = disk; | 2153 | lun->disk = disk; |
| 2017 | sprintf(disk->disk_name, DRV_NAME "%c", sc->id + 'a'); | 2154 | sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a'); |
| 2018 | sprintf(disk->devfs_name, DEVFS_NAME "/%c", sc->id + 'a'); | 2155 | sprintf(disk->devfs_name, DEVFS_NAME "/%c", lun->id + 'a'); |
| 2019 | disk->major = UB_MAJOR; | 2156 | disk->major = UB_MAJOR; |
| 2020 | disk->first_minor = sc->id * UB_MINORS_PER_MAJOR; | 2157 | disk->first_minor = lun->id * UB_MINORS_PER_MAJOR; |
| 2021 | disk->fops = &ub_bd_fops; | 2158 | disk->fops = &ub_bd_fops; |
| 2022 | disk->private_data = sc; | 2159 | disk->private_data = lun; |
| 2023 | disk->driverfs_dev = &intf->dev; | 2160 | disk->driverfs_dev = &sc->intf->dev; /* XXX Many to one ok? */ |
| 2024 | 2161 | ||
| 2025 | rc = -ENOMEM; | 2162 | rc = -ENOMEM; |
| 2026 | if ((q = blk_init_queue(ub_bd_rq_fn, &sc->lock)) == NULL) | 2163 | if ((q = blk_init_queue(ub_bd_rq_fn, &sc->lock)) == NULL) |
| @@ -2028,28 +2165,17 @@ static int ub_probe(struct usb_interface *intf, | |||
| 2028 | 2165 | ||
| 2029 | disk->queue = q; | 2166 | disk->queue = q; |
| 2030 | 2167 | ||
| 2031 | // blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); | 2168 | blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); |
| 2032 | blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); | 2169 | blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); |
| 2033 | blk_queue_max_phys_segments(q, UB_MAX_REQ_SG); | 2170 | blk_queue_max_phys_segments(q, UB_MAX_REQ_SG); |
| 2034 | // blk_queue_segment_boundary(q, CARM_SG_BOUNDARY); | 2171 | blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */ |
| 2035 | blk_queue_max_sectors(q, UB_MAX_SECTORS); | 2172 | blk_queue_max_sectors(q, UB_MAX_SECTORS); |
| 2036 | blk_queue_hardsect_size(q, sc->capacity.bsize); | 2173 | blk_queue_hardsect_size(q, lun->capacity.bsize); |
| 2037 | |||
| 2038 | /* | ||
| 2039 | * This is a serious infraction, caused by a deficiency in the | ||
| 2040 | * USB sg interface (usb_sg_wait()). We plan to remove this once | ||
| 2041 | * we get mileage on the driver and can justify a change to USB API. | ||
| 2042 | * See blk_queue_bounce_limit() to understand this part. | ||
| 2043 | * | ||
| 2044 | * XXX And I still need to be aware of the DMA mask in the HC. | ||
| 2045 | */ | ||
| 2046 | q->bounce_pfn = blk_max_low_pfn; | ||
| 2047 | q->bounce_gfp = GFP_NOIO; | ||
| 2048 | 2174 | ||
| 2049 | q->queuedata = sc; | 2175 | q->queuedata = lun; |
| 2050 | 2176 | ||
| 2051 | set_capacity(disk, sc->capacity.nsec); | 2177 | set_capacity(disk, lun->capacity.nsec); |
| 2052 | if (sc->removable) | 2178 | if (lun->removable) |
| 2053 | disk->flags |= GENHD_FL_REMOVABLE; | 2179 | disk->flags |= GENHD_FL_REMOVABLE; |
| 2054 | 2180 | ||
| 2055 | add_disk(disk); | 2181 | add_disk(disk); |
| @@ -2059,22 +2185,20 @@ static int ub_probe(struct usb_interface *intf, | |||
| 2059 | err_blkqinit: | 2185 | err_blkqinit: |
| 2060 | put_disk(disk); | 2186 | put_disk(disk); |
| 2061 | err_diskalloc: | 2187 | err_diskalloc: |
| 2062 | device_remove_file(&sc->intf->dev, &dev_attr_diag); | 2188 | list_del(&lun->link); |
| 2063 | err_diag: | 2189 | ub_id_put(lun->id); |
| 2064 | usb_set_intfdata(intf, NULL); | ||
| 2065 | // usb_put_intf(sc->intf); | ||
| 2066 | usb_put_dev(sc->dev); | ||
| 2067 | ub_id_put(sc->id); | ||
| 2068 | err_id: | 2190 | err_id: |
| 2069 | kfree(sc); | 2191 | kfree(lun); |
| 2070 | err_core: | 2192 | err_alloc: |
| 2071 | return rc; | 2193 | return rc; |
| 2072 | } | 2194 | } |
| 2073 | 2195 | ||
| 2074 | static void ub_disconnect(struct usb_interface *intf) | 2196 | static void ub_disconnect(struct usb_interface *intf) |
| 2075 | { | 2197 | { |
| 2076 | struct ub_dev *sc = usb_get_intfdata(intf); | 2198 | struct ub_dev *sc = usb_get_intfdata(intf); |
| 2077 | struct gendisk *disk = sc->disk; | 2199 | struct list_head *p; |
| 2200 | struct ub_lun *lun; | ||
| 2201 | struct gendisk *disk; | ||
| 2078 | unsigned long flags; | 2202 | unsigned long flags; |
| 2079 | 2203 | ||
| 2080 | /* | 2204 | /* |
| @@ -2124,14 +2248,18 @@ static void ub_disconnect(struct usb_interface *intf) | |||
| 2124 | /* | 2248 | /* |
| 2125 | * Unregister the upper layer. | 2249 | * Unregister the upper layer. |
| 2126 | */ | 2250 | */ |
| 2127 | if (disk->flags & GENHD_FL_UP) | 2251 | list_for_each (p, &sc->luns) { |
| 2128 | del_gendisk(disk); | 2252 | lun = list_entry(p, struct ub_lun, link); |
| 2129 | /* | 2253 | disk = lun->disk; |
| 2130 | * I wish I could do: | 2254 | if (disk->flags & GENHD_FL_UP) |
| 2131 | * set_bit(QUEUE_FLAG_DEAD, &q->queue_flags); | 2255 | del_gendisk(disk); |
| 2132 | * As it is, we rely on our internal poisoning and let | 2256 | /* |
| 2133 | * the upper levels to spin furiously failing all the I/O. | 2257 | * I wish I could do: |
| 2134 | */ | 2258 | * set_bit(QUEUE_FLAG_DEAD, &q->queue_flags); |
| 2259 | * As it is, we rely on our internal poisoning and let | ||
| 2260 | * the upper levels to spin furiously failing all the I/O. | ||
| 2261 | */ | ||
| 2262 | } | ||
| 2135 | 2263 | ||
| 2136 | /* | 2264 | /* |
| 2137 | * Taking a lock on a structure which is about to be freed | 2265 | * Taking a lock on a structure which is about to be freed |
| @@ -2182,8 +2310,8 @@ static int __init ub_init(void) | |||
| 2182 | { | 2310 | { |
| 2183 | int rc; | 2311 | int rc; |
| 2184 | 2312 | ||
| 2185 | /* P3 */ printk("ub: sizeof ub_scsi_cmd %zu ub_dev %zu\n", | 2313 | /* P3 */ printk("ub: sizeof ub_scsi_cmd %zu ub_dev %zu ub_lun %zu\n", |
| 2186 | sizeof(struct ub_scsi_cmd), sizeof(struct ub_dev)); | 2314 | sizeof(struct ub_scsi_cmd), sizeof(struct ub_dev), sizeof(struct ub_lun)); |
| 2187 | 2315 | ||
| 2188 | if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0) | 2316 | if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0) |
| 2189 | goto err_regblkdev; | 2317 | goto err_regblkdev; |
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 1c563f905a59..a7f15d9f13e5 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c | |||
| @@ -374,29 +374,6 @@ static inline void do_kiss_params(struct baycom_state *bc, | |||
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | /* --------------------------------------------------------------------- */ | 376 | /* --------------------------------------------------------------------- */ |
| 377 | /* | ||
| 378 | * high performance HDLC encoder | ||
| 379 | * yes, it's ugly, but generates pretty good code | ||
| 380 | */ | ||
| 381 | |||
| 382 | #define ENCODEITERA(j) \ | ||
| 383 | ({ \ | ||
| 384 | if (!(notbitstream & (0x1f0 << j))) \ | ||
| 385 | goto stuff##j; \ | ||
| 386 | encodeend##j: ; \ | ||
| 387 | }) | ||
| 388 | |||
| 389 | #define ENCODEITERB(j) \ | ||
| 390 | ({ \ | ||
| 391 | stuff##j: \ | ||
| 392 | bitstream &= ~(0x100 << j); \ | ||
| 393 | bitbuf = (bitbuf & (((2 << j) << numbit) - 1)) | \ | ||
| 394 | ((bitbuf & ~(((2 << j) << numbit) - 1)) << 1); \ | ||
| 395 | numbit++; \ | ||
| 396 | notbitstream = ~bitstream; \ | ||
| 397 | goto encodeend##j; \ | ||
| 398 | }) | ||
| 399 | |||
| 400 | 377 | ||
| 401 | static void encode_hdlc(struct baycom_state *bc) | 378 | static void encode_hdlc(struct baycom_state *bc) |
| 402 | { | 379 | { |
| @@ -405,6 +382,7 @@ static void encode_hdlc(struct baycom_state *bc) | |||
| 405 | int pkt_len; | 382 | int pkt_len; |
| 406 | unsigned bitstream, notbitstream, bitbuf, numbit, crc; | 383 | unsigned bitstream, notbitstream, bitbuf, numbit, crc; |
| 407 | unsigned char crcarr[2]; | 384 | unsigned char crcarr[2]; |
| 385 | int j; | ||
| 408 | 386 | ||
| 409 | if (bc->hdlctx.bufcnt > 0) | 387 | if (bc->hdlctx.bufcnt > 0) |
| 410 | return; | 388 | return; |
| @@ -429,24 +407,14 @@ static void encode_hdlc(struct baycom_state *bc) | |||
| 429 | pkt_len--; | 407 | pkt_len--; |
| 430 | if (!pkt_len) | 408 | if (!pkt_len) |
| 431 | bp = crcarr; | 409 | bp = crcarr; |
| 432 | ENCODEITERA(0); | 410 | for (j = 0; j < 8; j++) |
| 433 | ENCODEITERA(1); | 411 | if (unlikely(!(notbitstream & (0x1f0 << j)))) { |
| 434 | ENCODEITERA(2); | 412 | bitstream &= ~(0x100 << j); |
| 435 | ENCODEITERA(3); | 413 | bitbuf = (bitbuf & (((2 << j) << numbit) - 1)) | |
| 436 | ENCODEITERA(4); | 414 | ((bitbuf & ~(((2 << j) << numbit) - 1)) << 1); |
| 437 | ENCODEITERA(5); | 415 | numbit++; |
| 438 | ENCODEITERA(6); | 416 | notbitstream = ~bitstream; |
| 439 | ENCODEITERA(7); | 417 | } |
| 440 | goto enditer; | ||
| 441 | ENCODEITERB(0); | ||
| 442 | ENCODEITERB(1); | ||
| 443 | ENCODEITERB(2); | ||
| 444 | ENCODEITERB(3); | ||
| 445 | ENCODEITERB(4); | ||
| 446 | ENCODEITERB(5); | ||
| 447 | ENCODEITERB(6); | ||
| 448 | ENCODEITERB(7); | ||
| 449 | enditer: | ||
| 450 | numbit += 8; | 418 | numbit += 8; |
| 451 | while (numbit >= 8) { | 419 | while (numbit >= 8) { |
| 452 | *wp++ = bitbuf; | 420 | *wp++ = bitbuf; |
| @@ -610,37 +578,6 @@ static void do_rxpacket(struct net_device *dev) | |||
| 610 | bc->stats.rx_packets++; | 578 | bc->stats.rx_packets++; |
| 611 | } | 579 | } |
| 612 | 580 | ||
| 613 | #define DECODEITERA(j) \ | ||
| 614 | ({ \ | ||
| 615 | if (!(notbitstream & (0x0fc << j))) /* flag or abort */ \ | ||
| 616 | goto flgabrt##j; \ | ||
| 617 | if ((bitstream & (0x1f8 << j)) == (0xf8 << j)) /* stuffed bit */ \ | ||
| 618 | goto stuff##j; \ | ||
| 619 | enditer##j: ; \ | ||
| 620 | }) | ||
| 621 | |||
| 622 | #define DECODEITERB(j) \ | ||
| 623 | ({ \ | ||
| 624 | flgabrt##j: \ | ||
| 625 | if (!(notbitstream & (0x1fc << j))) { /* abort received */ \ | ||
| 626 | state = 0; \ | ||
| 627 | goto enditer##j; \ | ||
| 628 | } \ | ||
| 629 | if ((bitstream & (0x1fe << j)) != (0x0fc << j)) /* flag received */ \ | ||
| 630 | goto enditer##j; \ | ||
| 631 | if (state) \ | ||
| 632 | do_rxpacket(dev); \ | ||
| 633 | bc->hdlcrx.bufcnt = 0; \ | ||
| 634 | bc->hdlcrx.bufptr = bc->hdlcrx.buf; \ | ||
| 635 | state = 1; \ | ||
| 636 | numbits = 7-j; \ | ||
| 637 | goto enditer##j; \ | ||
| 638 | stuff##j: \ | ||
| 639 | numbits--; \ | ||
| 640 | bitbuf = (bitbuf & ((~0xff) << j)) | ((bitbuf & ~((~0xff) << j)) << 1); \ | ||
| 641 | goto enditer##j; \ | ||
| 642 | }) | ||
| 643 | |||
| 644 | static int receive(struct net_device *dev, int cnt) | 581 | static int receive(struct net_device *dev, int cnt) |
| 645 | { | 582 | { |
| 646 | struct baycom_state *bc = netdev_priv(dev); | 583 | struct baycom_state *bc = netdev_priv(dev); |
| @@ -649,6 +586,7 @@ static int receive(struct net_device *dev, int cnt) | |||
| 649 | unsigned char tmp[128]; | 586 | unsigned char tmp[128]; |
| 650 | unsigned char *cp; | 587 | unsigned char *cp; |
| 651 | int cnt2, ret = 0; | 588 | int cnt2, ret = 0; |
| 589 | int j; | ||
| 652 | 590 | ||
| 653 | numbits = bc->hdlcrx.numbits; | 591 | numbits = bc->hdlcrx.numbits; |
| 654 | state = bc->hdlcrx.state; | 592 | state = bc->hdlcrx.state; |
| @@ -669,24 +607,32 @@ static int receive(struct net_device *dev, int cnt) | |||
| 669 | bitbuf |= (*cp) << 8; | 607 | bitbuf |= (*cp) << 8; |
| 670 | numbits += 8; | 608 | numbits += 8; |
| 671 | notbitstream = ~bitstream; | 609 | notbitstream = ~bitstream; |
| 672 | DECODEITERA(0); | 610 | for (j = 0; j < 8; j++) { |
| 673 | DECODEITERA(1); | 611 | |
| 674 | DECODEITERA(2); | 612 | /* flag or abort */ |
| 675 | DECODEITERA(3); | 613 | if (unlikely(!(notbitstream & (0x0fc << j)))) { |
| 676 | DECODEITERA(4); | 614 | |
| 677 | DECODEITERA(5); | 615 | /* abort received */ |
| 678 | DECODEITERA(6); | 616 | if (!(notbitstream & (0x1fc << j))) |
| 679 | DECODEITERA(7); | 617 | state = 0; |
| 680 | goto enddec; | 618 | |
| 681 | DECODEITERB(0); | 619 | /* not flag received */ |
| 682 | DECODEITERB(1); | 620 | else if (!(bitstream & (0x1fe << j)) != (0x0fc << j)) { |
| 683 | DECODEITERB(2); | 621 | if (state) |
| 684 | DECODEITERB(3); | 622 | do_rxpacket(dev); |
| 685 | DECODEITERB(4); | 623 | bc->hdlcrx.bufcnt = 0; |
| 686 | DECODEITERB(5); | 624 | bc->hdlcrx.bufptr = bc->hdlcrx.buf; |
| 687 | DECODEITERB(6); | 625 | state = 1; |
| 688 | DECODEITERB(7); | 626 | numbits = 7-j; |
| 689 | enddec: | 627 | } |
| 628 | } | ||
| 629 | |||
| 630 | /* stuffed bit */ | ||
| 631 | else if (unlikely((bitstream & (0x1f8 << j)) == (0xf8 << j))) { | ||
| 632 | numbits--; | ||
| 633 | bitbuf = (bitbuf & ((~0xff) << j)) | ((bitbuf & ~((~0xff) << j)) << 1); | ||
| 634 | } | ||
| 635 | } | ||
| 690 | while (state && numbits >= 8) { | 636 | while (state && numbits >= 8) { |
| 691 | if (bc->hdlcrx.bufcnt >= TXBUFFER_SIZE) { | 637 | if (bc->hdlcrx.bufcnt >= TXBUFFER_SIZE) { |
| 692 | state = 0; | 638 | state = 0; |
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 41e517114807..c6e8b25f9685 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
| @@ -1274,6 +1274,9 @@ static int el3_close(struct net_device *dev) | |||
| 1274 | spin_lock_irqsave(&lp->window_lock, flags); | 1274 | spin_lock_irqsave(&lp->window_lock, flags); |
| 1275 | update_stats(dev); | 1275 | update_stats(dev); |
| 1276 | spin_unlock_irqrestore(&lp->window_lock, flags); | 1276 | spin_unlock_irqrestore(&lp->window_lock, flags); |
| 1277 | |||
| 1278 | /* force interrupts off */ | ||
| 1279 | outw(SetIntrEnb | 0x0000, ioaddr + EL3_CMD); | ||
| 1277 | } | 1280 | } |
| 1278 | 1281 | ||
| 1279 | link->open--; | 1282 | link->open--; |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index c59507f8a76b..b3768d844747 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
| @@ -1585,8 +1585,8 @@ rtl8169_hw_start(struct net_device *dev) | |||
| 1585 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 1585 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
| 1586 | RTL_W8(EarlyTxThres, EarlyTxThld); | 1586 | RTL_W8(EarlyTxThres, EarlyTxThld); |
| 1587 | 1587 | ||
| 1588 | /* For gigabit rtl8169, MTU + header + CRC + VLAN */ | 1588 | /* Low hurts. Let's disable the filtering. */ |
| 1589 | RTL_W16(RxMaxSize, tp->rx_buf_sz); | 1589 | RTL_W16(RxMaxSize, 16383); |
| 1590 | 1590 | ||
| 1591 | /* Set Rx Config register */ | 1591 | /* Set Rx Config register */ |
| 1592 | i = rtl8169_rx_config | | 1592 | i = rtl8169_rx_config | |
| @@ -2127,6 +2127,11 @@ rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
| 2127 | } | 2127 | } |
| 2128 | } | 2128 | } |
| 2129 | 2129 | ||
| 2130 | static inline int rtl8169_fragmented_frame(u32 status) | ||
| 2131 | { | ||
| 2132 | return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag); | ||
| 2133 | } | ||
| 2134 | |||
| 2130 | static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) | 2135 | static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) |
| 2131 | { | 2136 | { |
| 2132 | u32 opts1 = le32_to_cpu(desc->opts1); | 2137 | u32 opts1 = le32_to_cpu(desc->opts1); |
| @@ -2177,27 +2182,41 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
| 2177 | 2182 | ||
| 2178 | while (rx_left > 0) { | 2183 | while (rx_left > 0) { |
| 2179 | unsigned int entry = cur_rx % NUM_RX_DESC; | 2184 | unsigned int entry = cur_rx % NUM_RX_DESC; |
| 2185 | struct RxDesc *desc = tp->RxDescArray + entry; | ||
| 2180 | u32 status; | 2186 | u32 status; |
| 2181 | 2187 | ||
| 2182 | rmb(); | 2188 | rmb(); |
| 2183 | status = le32_to_cpu(tp->RxDescArray[entry].opts1); | 2189 | status = le32_to_cpu(desc->opts1); |
| 2184 | 2190 | ||
| 2185 | if (status & DescOwn) | 2191 | if (status & DescOwn) |
| 2186 | break; | 2192 | break; |
| 2187 | if (status & RxRES) { | 2193 | if (status & RxRES) { |
| 2188 | printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name); | 2194 | printk(KERN_INFO "%s: Rx ERROR. status = %08x\n", |
| 2195 | dev->name, status); | ||
| 2189 | tp->stats.rx_errors++; | 2196 | tp->stats.rx_errors++; |
| 2190 | if (status & (RxRWT | RxRUNT)) | 2197 | if (status & (RxRWT | RxRUNT)) |
| 2191 | tp->stats.rx_length_errors++; | 2198 | tp->stats.rx_length_errors++; |
| 2192 | if (status & RxCRC) | 2199 | if (status & RxCRC) |
| 2193 | tp->stats.rx_crc_errors++; | 2200 | tp->stats.rx_crc_errors++; |
| 2201 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | ||
| 2194 | } else { | 2202 | } else { |
| 2195 | struct RxDesc *desc = tp->RxDescArray + entry; | ||
| 2196 | struct sk_buff *skb = tp->Rx_skbuff[entry]; | 2203 | struct sk_buff *skb = tp->Rx_skbuff[entry]; |
| 2197 | int pkt_size = (status & 0x00001FFF) - 4; | 2204 | int pkt_size = (status & 0x00001FFF) - 4; |
| 2198 | void (*pci_action)(struct pci_dev *, dma_addr_t, | 2205 | void (*pci_action)(struct pci_dev *, dma_addr_t, |
| 2199 | size_t, int) = pci_dma_sync_single_for_device; | 2206 | size_t, int) = pci_dma_sync_single_for_device; |
| 2200 | 2207 | ||
| 2208 | /* | ||
| 2209 | * The driver does not support incoming fragmented | ||
| 2210 | * frames. They are seen as a symptom of over-mtu | ||
| 2211 | * sized frames. | ||
| 2212 | */ | ||
| 2213 | if (unlikely(rtl8169_fragmented_frame(status))) { | ||
| 2214 | tp->stats.rx_dropped++; | ||
| 2215 | tp->stats.rx_length_errors++; | ||
| 2216 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | ||
| 2217 | goto move_on; | ||
| 2218 | } | ||
| 2219 | |||
| 2201 | rtl8169_rx_csum(skb, desc); | 2220 | rtl8169_rx_csum(skb, desc); |
| 2202 | 2221 | ||
| 2203 | pci_dma_sync_single_for_cpu(tp->pci_dev, | 2222 | pci_dma_sync_single_for_cpu(tp->pci_dev, |
| @@ -2224,7 +2243,7 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
| 2224 | tp->stats.rx_bytes += pkt_size; | 2243 | tp->stats.rx_bytes += pkt_size; |
| 2225 | tp->stats.rx_packets++; | 2244 | tp->stats.rx_packets++; |
| 2226 | } | 2245 | } |
| 2227 | 2246 | move_on: | |
| 2228 | cur_rx++; | 2247 | cur_rx++; |
| 2229 | rx_left--; | 2248 | rx_left--; |
| 2230 | } | 2249 | } |
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c index e68cf5fb4920..20edeb345792 100644 --- a/drivers/net/shaper.c +++ b/drivers/net/shaper.c | |||
| @@ -100,35 +100,8 @@ static int sh_debug; /* Debug flag */ | |||
| 100 | 100 | ||
| 101 | #define SHAPER_BANNER "CymruNet Traffic Shaper BETA 0.04 for Linux 2.1\n" | 101 | #define SHAPER_BANNER "CymruNet Traffic Shaper BETA 0.04 for Linux 2.1\n" |
| 102 | 102 | ||
| 103 | /* | ||
| 104 | * Locking | ||
| 105 | */ | ||
| 106 | |||
| 107 | static int shaper_lock(struct shaper *sh) | ||
| 108 | { | ||
| 109 | /* | ||
| 110 | * Lock in an interrupt must fail | ||
| 111 | */ | ||
| 112 | while (test_and_set_bit(0, &sh->locked)) | ||
| 113 | { | ||
| 114 | if (!in_interrupt()) | ||
| 115 | sleep_on(&sh->wait_queue); | ||
| 116 | else | ||
| 117 | return 0; | ||
| 118 | |||
| 119 | } | ||
| 120 | return 1; | ||
| 121 | } | ||
| 122 | |||
| 123 | static void shaper_kick(struct shaper *sh); | 103 | static void shaper_kick(struct shaper *sh); |
| 124 | 104 | ||
| 125 | static void shaper_unlock(struct shaper *sh) | ||
| 126 | { | ||
| 127 | clear_bit(0, &sh->locked); | ||
| 128 | wake_up(&sh->wait_queue); | ||
| 129 | shaper_kick(sh); | ||
| 130 | } | ||
| 131 | |||
| 132 | /* | 105 | /* |
| 133 | * Compute clocks on a buffer | 106 | * Compute clocks on a buffer |
| 134 | */ | 107 | */ |
| @@ -157,17 +130,15 @@ static void shaper_setspeed(struct shaper *shaper, int bitspersec) | |||
| 157 | * Throw a frame at a shaper. | 130 | * Throw a frame at a shaper. |
| 158 | */ | 131 | */ |
| 159 | 132 | ||
| 160 | static int shaper_qframe(struct shaper *shaper, struct sk_buff *skb) | 133 | |
| 134 | static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
| 161 | { | 135 | { |
| 136 | struct shaper *shaper = dev->priv; | ||
| 162 | struct sk_buff *ptr; | 137 | struct sk_buff *ptr; |
| 163 | 138 | ||
| 164 | /* | 139 | if (down_trylock(&shaper->sem)) |
| 165 | * Get ready to work on this shaper. Lock may fail if its | 140 | return -1; |
| 166 | * an interrupt and locked. | 141 | |
| 167 | */ | ||
| 168 | |||
| 169 | if(!shaper_lock(shaper)) | ||
| 170 | return -1; | ||
| 171 | ptr=shaper->sendq.prev; | 142 | ptr=shaper->sendq.prev; |
| 172 | 143 | ||
| 173 | /* | 144 | /* |
| @@ -260,7 +231,8 @@ static int shaper_qframe(struct shaper *shaper, struct sk_buff *skb) | |||
| 260 | dev_kfree_skb(ptr); | 231 | dev_kfree_skb(ptr); |
| 261 | shaper->stats.collisions++; | 232 | shaper->stats.collisions++; |
| 262 | } | 233 | } |
| 263 | shaper_unlock(shaper); | 234 | shaper_kick(shaper); |
| 235 | up(&shaper->sem); | ||
| 264 | return 0; | 236 | return 0; |
| 265 | } | 237 | } |
| 266 | 238 | ||
| @@ -297,8 +269,13 @@ static void shaper_queue_xmit(struct shaper *shaper, struct sk_buff *skb) | |||
| 297 | 269 | ||
| 298 | static void shaper_timer(unsigned long data) | 270 | static void shaper_timer(unsigned long data) |
| 299 | { | 271 | { |
| 300 | struct shaper *sh=(struct shaper *)data; | 272 | struct shaper *shaper = (struct shaper *)data; |
| 301 | shaper_kick(sh); | 273 | |
| 274 | if (!down_trylock(&shaper->sem)) { | ||
| 275 | shaper_kick(shaper); | ||
| 276 | up(&shaper->sem); | ||
| 277 | } else | ||
| 278 | mod_timer(&shaper->timer, jiffies); | ||
| 302 | } | 279 | } |
| 303 | 280 | ||
| 304 | /* | 281 | /* |
| @@ -311,19 +288,6 @@ static void shaper_kick(struct shaper *shaper) | |||
| 311 | struct sk_buff *skb; | 288 | struct sk_buff *skb; |
| 312 | 289 | ||
| 313 | /* | 290 | /* |
| 314 | * Shaper unlock will kick | ||
| 315 | */ | ||
| 316 | |||
| 317 | if (test_and_set_bit(0, &shaper->locked)) | ||
| 318 | { | ||
| 319 | if(sh_debug) | ||
| 320 | printk("Shaper locked.\n"); | ||
| 321 | mod_timer(&shaper->timer, jiffies); | ||
| 322 | return; | ||
| 323 | } | ||
| 324 | |||
| 325 | |||
| 326 | /* | ||
| 327 | * Walk the list (may be empty) | 291 | * Walk the list (may be empty) |
| 328 | */ | 292 | */ |
| 329 | 293 | ||
| @@ -364,8 +328,6 @@ static void shaper_kick(struct shaper *shaper) | |||
| 364 | 328 | ||
| 365 | if(skb!=NULL) | 329 | if(skb!=NULL) |
| 366 | mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock); | 330 | mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock); |
| 367 | |||
| 368 | clear_bit(0, &shaper->locked); | ||
| 369 | } | 331 | } |
| 370 | 332 | ||
| 371 | 333 | ||
| @@ -376,14 +338,12 @@ static void shaper_kick(struct shaper *shaper) | |||
| 376 | static void shaper_flush(struct shaper *shaper) | 338 | static void shaper_flush(struct shaper *shaper) |
| 377 | { | 339 | { |
| 378 | struct sk_buff *skb; | 340 | struct sk_buff *skb; |
| 379 | if(!shaper_lock(shaper)) | 341 | |
| 380 | { | 342 | down(&shaper->sem); |
| 381 | printk(KERN_ERR "shaper: shaper_flush() called by an irq!\n"); | ||
| 382 | return; | ||
| 383 | } | ||
| 384 | while((skb=skb_dequeue(&shaper->sendq))!=NULL) | 343 | while((skb=skb_dequeue(&shaper->sendq))!=NULL) |
| 385 | dev_kfree_skb(skb); | 344 | dev_kfree_skb(skb); |
| 386 | shaper_unlock(shaper); | 345 | shaper_kick(shaper); |
| 346 | up(&shaper->sem); | ||
| 387 | } | 347 | } |
| 388 | 348 | ||
| 389 | /* | 349 | /* |
| @@ -426,13 +386,6 @@ static int shaper_close(struct net_device *dev) | |||
| 426 | * ARP and other resolutions and not before. | 386 | * ARP and other resolutions and not before. |
| 427 | */ | 387 | */ |
| 428 | 388 | ||
| 429 | |||
| 430 | static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
| 431 | { | ||
| 432 | struct shaper *sh=dev->priv; | ||
| 433 | return shaper_qframe(sh, skb); | ||
| 434 | } | ||
| 435 | |||
| 436 | static struct net_device_stats *shaper_get_stats(struct net_device *dev) | 389 | static struct net_device_stats *shaper_get_stats(struct net_device *dev) |
| 437 | { | 390 | { |
| 438 | struct shaper *sh=dev->priv; | 391 | struct shaper *sh=dev->priv; |
| @@ -623,7 +576,6 @@ static void shaper_init_priv(struct net_device *dev) | |||
| 623 | init_timer(&sh->timer); | 576 | init_timer(&sh->timer); |
| 624 | sh->timer.function=shaper_timer; | 577 | sh->timer.function=shaper_timer; |
| 625 | sh->timer.data=(unsigned long)sh; | 578 | sh->timer.data=(unsigned long)sh; |
| 626 | init_waitqueue_head(&sh->wait_queue); | ||
| 627 | } | 579 | } |
| 628 | 580 | ||
| 629 | /* | 581 | /* |
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 54c52349adc5..3be546439252 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
| @@ -665,15 +665,6 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 665 | return ata_pci_init_one(pdev, port_info, n_ports); | 665 | return ata_pci_init_one(pdev, port_info, n_ports); |
| 666 | } | 666 | } |
| 667 | 667 | ||
| 668 | /** | ||
| 669 | * piix_init - | ||
| 670 | * | ||
| 671 | * LOCKING: | ||
| 672 | * | ||
| 673 | * RETURNS: | ||
| 674 | * | ||
| 675 | */ | ||
| 676 | |||
| 677 | static int __init piix_init(void) | 668 | static int __init piix_init(void) |
| 678 | { | 669 | { |
| 679 | int rc; | 670 | int rc; |
| @@ -689,13 +680,6 @@ static int __init piix_init(void) | |||
| 689 | return 0; | 680 | return 0; |
| 690 | } | 681 | } |
| 691 | 682 | ||
| 692 | /** | ||
| 693 | * piix_exit - | ||
| 694 | * | ||
| 695 | * LOCKING: | ||
| 696 | * | ||
| 697 | */ | ||
| 698 | |||
| 699 | static void __exit piix_exit(void) | 683 | static void __exit piix_exit(void) |
| 700 | { | 684 | { |
| 701 | pci_unregister_driver(&piix_pci_driver); | 685 | pci_unregister_driver(&piix_pci_driver); |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 30a88f0e7bd6..21d194c6ace3 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
| @@ -186,6 +186,28 @@ static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
| 186 | ata_wait_idle(ap); | 186 | ata_wait_idle(ap); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | |||
| 190 | /** | ||
| 191 | * ata_tf_load - send taskfile registers to host controller | ||
| 192 | * @ap: Port to which output is sent | ||
| 193 | * @tf: ATA taskfile register set | ||
| 194 | * | ||
| 195 | * Outputs ATA taskfile to standard ATA host controller using MMIO | ||
| 196 | * or PIO as indicated by the ATA_FLAG_MMIO flag. | ||
| 197 | * Writes the control, feature, nsect, lbal, lbam, and lbah registers. | ||
| 198 | * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect, | ||
| 199 | * hob_lbal, hob_lbam, and hob_lbah. | ||
| 200 | * | ||
| 201 | * This function waits for idle (!BUSY and !DRQ) after writing | ||
| 202 | * registers. If the control register has a new value, this | ||
| 203 | * function also waits for idle after writing control and before | ||
| 204 | * writing the remaining registers. | ||
| 205 | * | ||
| 206 | * May be used as the tf_load() entry in ata_port_operations. | ||
| 207 | * | ||
| 208 | * LOCKING: | ||
| 209 | * Inherited from caller. | ||
| 210 | */ | ||
| 189 | void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) | 211 | void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) |
| 190 | { | 212 | { |
| 191 | if (ap->flags & ATA_FLAG_MMIO) | 213 | if (ap->flags & ATA_FLAG_MMIO) |
| @@ -195,11 +217,11 @@ void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) | |||
| 195 | } | 217 | } |
| 196 | 218 | ||
| 197 | /** | 219 | /** |
| 198 | * ata_exec_command - issue ATA command to host controller | 220 | * ata_exec_command_pio - issue ATA command to host controller |
| 199 | * @ap: port to which command is being issued | 221 | * @ap: port to which command is being issued |
| 200 | * @tf: ATA taskfile register set | 222 | * @tf: ATA taskfile register set |
| 201 | * | 223 | * |
| 202 | * Issues PIO/MMIO write to ATA command register, with proper | 224 | * Issues PIO write to ATA command register, with proper |
| 203 | * synchronization with interrupt handler / other threads. | 225 | * synchronization with interrupt handler / other threads. |
| 204 | * | 226 | * |
| 205 | * LOCKING: | 227 | * LOCKING: |
| @@ -235,6 +257,18 @@ static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
| 235 | ata_pause(ap); | 257 | ata_pause(ap); |
| 236 | } | 258 | } |
| 237 | 259 | ||
| 260 | |||
| 261 | /** | ||
| 262 | * ata_exec_command - issue ATA command to host controller | ||
| 263 | * @ap: port to which command is being issued | ||
| 264 | * @tf: ATA taskfile register set | ||
| 265 | * | ||
| 266 | * Issues PIO/MMIO write to ATA command register, with proper | ||
| 267 | * synchronization with interrupt handler / other threads. | ||
| 268 | * | ||
| 269 | * LOCKING: | ||
| 270 | * spin_lock_irqsave(host_set lock) | ||
| 271 | */ | ||
| 238 | void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) | 272 | void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) |
| 239 | { | 273 | { |
| 240 | if (ap->flags & ATA_FLAG_MMIO) | 274 | if (ap->flags & ATA_FLAG_MMIO) |
| @@ -305,7 +339,7 @@ void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf) | |||
| 305 | } | 339 | } |
| 306 | 340 | ||
| 307 | /** | 341 | /** |
| 308 | * ata_tf_read - input device's ATA taskfile shadow registers | 342 | * ata_tf_read_pio - input device's ATA taskfile shadow registers |
| 309 | * @ap: Port from which input is read | 343 | * @ap: Port from which input is read |
| 310 | * @tf: ATA taskfile register set for storing input | 344 | * @tf: ATA taskfile register set for storing input |
| 311 | * | 345 | * |
| @@ -368,6 +402,23 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
| 368 | } | 402 | } |
| 369 | } | 403 | } |
| 370 | 404 | ||
| 405 | |||
| 406 | /** | ||
| 407 | * ata_tf_read - input device's ATA taskfile shadow registers | ||
| 408 | * @ap: Port from which input is read | ||
| 409 | * @tf: ATA taskfile register set for storing input | ||
| 410 | * | ||
| 411 | * Reads ATA taskfile registers for currently-selected device | ||
| 412 | * into @tf. | ||
| 413 | * | ||
| 414 | * Reads nsect, lbal, lbam, lbah, and device. If ATA_TFLAG_LBA48 | ||
| 415 | * is set, also reads the hob registers. | ||
| 416 | * | ||
| 417 | * May be used as the tf_read() entry in ata_port_operations. | ||
| 418 | * | ||
| 419 | * LOCKING: | ||
| 420 | * Inherited from caller. | ||
| 421 | */ | ||
| 371 | void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | 422 | void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) |
| 372 | { | 423 | { |
| 373 | if (ap->flags & ATA_FLAG_MMIO) | 424 | if (ap->flags & ATA_FLAG_MMIO) |
| @@ -381,7 +432,7 @@ void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
| 381 | * @ap: port where the device is | 432 | * @ap: port where the device is |
| 382 | * | 433 | * |
| 383 | * Reads ATA taskfile status register for currently-selected device | 434 | * Reads ATA taskfile status register for currently-selected device |
| 384 | * and return it's value. This also clears pending interrupts | 435 | * and return its value. This also clears pending interrupts |
| 385 | * from this device | 436 | * from this device |
| 386 | * | 437 | * |
| 387 | * LOCKING: | 438 | * LOCKING: |
| @@ -397,7 +448,7 @@ static u8 ata_check_status_pio(struct ata_port *ap) | |||
| 397 | * @ap: port where the device is | 448 | * @ap: port where the device is |
| 398 | * | 449 | * |
| 399 | * Reads ATA taskfile status register for currently-selected device | 450 | * Reads ATA taskfile status register for currently-selected device |
| 400 | * via MMIO and return it's value. This also clears pending interrupts | 451 | * via MMIO and return its value. This also clears pending interrupts |
| 401 | * from this device | 452 | * from this device |
| 402 | * | 453 | * |
| 403 | * LOCKING: | 454 | * LOCKING: |
| @@ -408,6 +459,20 @@ static u8 ata_check_status_mmio(struct ata_port *ap) | |||
| 408 | return readb((void __iomem *) ap->ioaddr.status_addr); | 459 | return readb((void __iomem *) ap->ioaddr.status_addr); |
| 409 | } | 460 | } |
| 410 | 461 | ||
| 462 | |||
| 463 | /** | ||
| 464 | * ata_check_status - Read device status reg & clear interrupt | ||
| 465 | * @ap: port where the device is | ||
| 466 | * | ||
| 467 | * Reads ATA taskfile status register for currently-selected device | ||
| 468 | * and return its value. This also clears pending interrupts | ||
| 469 | * from this device | ||
| 470 | * | ||
| 471 | * May be used as the check_status() entry in ata_port_operations. | ||
| 472 | * | ||
| 473 | * LOCKING: | ||
| 474 | * Inherited from caller. | ||
| 475 | */ | ||
| 411 | u8 ata_check_status(struct ata_port *ap) | 476 | u8 ata_check_status(struct ata_port *ap) |
| 412 | { | 477 | { |
| 413 | if (ap->flags & ATA_FLAG_MMIO) | 478 | if (ap->flags & ATA_FLAG_MMIO) |
| @@ -415,6 +480,20 @@ u8 ata_check_status(struct ata_port *ap) | |||
| 415 | return ata_check_status_pio(ap); | 480 | return ata_check_status_pio(ap); |
| 416 | } | 481 | } |
| 417 | 482 | ||
| 483 | |||
| 484 | /** | ||
| 485 | * ata_altstatus - Read device alternate status reg | ||
| 486 | * @ap: port where the device is | ||
| 487 | * | ||
| 488 | * Reads ATA taskfile alternate status register for | ||
| 489 | * currently-selected device and return its value. | ||
| 490 | * | ||
| 491 | * Note: may NOT be used as the check_altstatus() entry in | ||
| 492 | * ata_port_operations. | ||
| 493 | * | ||
| 494 | * LOCKING: | ||
| 495 | * Inherited from caller. | ||
| 496 | */ | ||
| 418 | u8 ata_altstatus(struct ata_port *ap) | 497 | u8 ata_altstatus(struct ata_port *ap) |
| 419 | { | 498 | { |
| 420 | if (ap->ops->check_altstatus) | 499 | if (ap->ops->check_altstatus) |
| @@ -425,6 +504,20 @@ u8 ata_altstatus(struct ata_port *ap) | |||
| 425 | return inb(ap->ioaddr.altstatus_addr); | 504 | return inb(ap->ioaddr.altstatus_addr); |
| 426 | } | 505 | } |
| 427 | 506 | ||
| 507 | |||
| 508 | /** | ||
| 509 | * ata_chk_err - Read device error reg | ||
| 510 | * @ap: port where the device is | ||
| 511 | * | ||
| 512 | * Reads ATA taskfile error register for | ||
| 513 | * currently-selected device and return its value. | ||
| 514 | * | ||
| 515 | * Note: may NOT be used as the check_err() entry in | ||
| 516 | * ata_port_operations. | ||
| 517 | * | ||
| 518 | * LOCKING: | ||
| 519 | * Inherited from caller. | ||
| 520 | */ | ||
| 428 | u8 ata_chk_err(struct ata_port *ap) | 521 | u8 ata_chk_err(struct ata_port *ap) |
| 429 | { | 522 | { |
| 430 | if (ap->ops->check_err) | 523 | if (ap->ops->check_err) |
| @@ -873,10 +966,24 @@ void ata_dev_id_string(u16 *id, unsigned char *s, | |||
| 873 | } | 966 | } |
| 874 | } | 967 | } |
| 875 | 968 | ||
| 969 | |||
| 970 | /** | ||
| 971 | * ata_noop_dev_select - Select device 0/1 on ATA bus | ||
| 972 | * @ap: ATA channel to manipulate | ||
| 973 | * @device: ATA device (numbered from zero) to select | ||
| 974 | * | ||
| 975 | * This function performs no actual function. | ||
| 976 | * | ||
| 977 | * May be used as the dev_select() entry in ata_port_operations. | ||
| 978 | * | ||
| 979 | * LOCKING: | ||
| 980 | * caller. | ||
| 981 | */ | ||
| 876 | void ata_noop_dev_select (struct ata_port *ap, unsigned int device) | 982 | void ata_noop_dev_select (struct ata_port *ap, unsigned int device) |
| 877 | { | 983 | { |
| 878 | } | 984 | } |
| 879 | 985 | ||
| 986 | |||
| 880 | /** | 987 | /** |
| 881 | * ata_std_dev_select - Select device 0/1 on ATA bus | 988 | * ata_std_dev_select - Select device 0/1 on ATA bus |
| 882 | * @ap: ATA channel to manipulate | 989 | * @ap: ATA channel to manipulate |
| @@ -884,7 +991,9 @@ void ata_noop_dev_select (struct ata_port *ap, unsigned int device) | |||
| 884 | * | 991 | * |
| 885 | * Use the method defined in the ATA specification to | 992 | * Use the method defined in the ATA specification to |
| 886 | * make either device 0, or device 1, active on the | 993 | * make either device 0, or device 1, active on the |
| 887 | * ATA channel. | 994 | * ATA channel. Works with both PIO and MMIO. |
| 995 | * | ||
| 996 | * May be used as the dev_select() entry in ata_port_operations. | ||
| 888 | * | 997 | * |
| 889 | * LOCKING: | 998 | * LOCKING: |
| 890 | * caller. | 999 | * caller. |
| @@ -1190,7 +1299,12 @@ err_out: | |||
| 1190 | * ata_bus_probe - Reset and probe ATA bus | 1299 | * ata_bus_probe - Reset and probe ATA bus |
| 1191 | * @ap: Bus to probe | 1300 | * @ap: Bus to probe |
| 1192 | * | 1301 | * |
| 1302 | * Master ATA bus probing function. Initiates a hardware-dependent | ||
| 1303 | * bus reset, then attempts to identify any devices found on | ||
| 1304 | * the bus. | ||
| 1305 | * | ||
| 1193 | * LOCKING: | 1306 | * LOCKING: |
| 1307 | * PCI/etc. bus probe sem. | ||
| 1194 | * | 1308 | * |
| 1195 | * RETURNS: | 1309 | * RETURNS: |
| 1196 | * Zero on success, non-zero on error. | 1310 | * Zero on success, non-zero on error. |
| @@ -1229,10 +1343,14 @@ err_out: | |||
| 1229 | } | 1343 | } |
| 1230 | 1344 | ||
| 1231 | /** | 1345 | /** |
| 1232 | * ata_port_probe - | 1346 | * ata_port_probe - Mark port as enabled |
| 1233 | * @ap: | 1347 | * @ap: Port for which we indicate enablement |
| 1234 | * | 1348 | * |
| 1235 | * LOCKING: | 1349 | * Modify @ap data structure such that the system |
| 1350 | * thinks that the entire port is enabled. | ||
| 1351 | * | ||
| 1352 | * LOCKING: host_set lock, or some other form of | ||
| 1353 | * serialization. | ||
| 1236 | */ | 1354 | */ |
| 1237 | 1355 | ||
| 1238 | void ata_port_probe(struct ata_port *ap) | 1356 | void ata_port_probe(struct ata_port *ap) |
| @@ -1241,10 +1359,15 @@ void ata_port_probe(struct ata_port *ap) | |||
| 1241 | } | 1359 | } |
| 1242 | 1360 | ||
| 1243 | /** | 1361 | /** |
| 1244 | * __sata_phy_reset - | 1362 | * __sata_phy_reset - Wake/reset a low-level SATA PHY |
| 1245 | * @ap: | 1363 | * @ap: SATA port associated with target SATA PHY. |
| 1364 | * | ||
| 1365 | * This function issues commands to standard SATA Sxxx | ||
| 1366 | * PHY registers, to wake up the phy (and device), and | ||
| 1367 | * clear any reset condition. | ||
| 1246 | * | 1368 | * |
| 1247 | * LOCKING: | 1369 | * LOCKING: |
| 1370 | * PCI/etc. bus probe sem. | ||
| 1248 | * | 1371 | * |
| 1249 | */ | 1372 | */ |
| 1250 | void __sata_phy_reset(struct ata_port *ap) | 1373 | void __sata_phy_reset(struct ata_port *ap) |
| @@ -1289,10 +1412,14 @@ void __sata_phy_reset(struct ata_port *ap) | |||
| 1289 | } | 1412 | } |
| 1290 | 1413 | ||
| 1291 | /** | 1414 | /** |
| 1292 | * __sata_phy_reset - | 1415 | * sata_phy_reset - Reset SATA bus. |
| 1293 | * @ap: | 1416 | * @ap: SATA port associated with target SATA PHY. |
| 1417 | * | ||
| 1418 | * This function resets the SATA bus, and then probes | ||
| 1419 | * the bus for devices. | ||
| 1294 | * | 1420 | * |
| 1295 | * LOCKING: | 1421 | * LOCKING: |
| 1422 | * PCI/etc. bus probe sem. | ||
| 1296 | * | 1423 | * |
| 1297 | */ | 1424 | */ |
| 1298 | void sata_phy_reset(struct ata_port *ap) | 1425 | void sata_phy_reset(struct ata_port *ap) |
| @@ -1304,10 +1431,16 @@ void sata_phy_reset(struct ata_port *ap) | |||
| 1304 | } | 1431 | } |
| 1305 | 1432 | ||
| 1306 | /** | 1433 | /** |
| 1307 | * ata_port_disable - | 1434 | * ata_port_disable - Disable port. |
| 1308 | * @ap: | 1435 | * @ap: Port to be disabled. |
| 1309 | * | 1436 | * |
| 1310 | * LOCKING: | 1437 | * Modify @ap data structure such that the system |
| 1438 | * thinks that the entire port is disabled, and should | ||
| 1439 | * never attempt to probe or communicate with devices | ||
| 1440 | * on this port. | ||
| 1441 | * | ||
| 1442 | * LOCKING: host_set lock, or some other form of | ||
| 1443 | * serialization. | ||
| 1311 | */ | 1444 | */ |
| 1312 | 1445 | ||
| 1313 | void ata_port_disable(struct ata_port *ap) | 1446 | void ata_port_disable(struct ata_port *ap) |
| @@ -1416,7 +1549,10 @@ static void ata_host_set_dma(struct ata_port *ap, u8 xfer_mode, | |||
| 1416 | * ata_set_mode - Program timings and issue SET FEATURES - XFER | 1549 | * ata_set_mode - Program timings and issue SET FEATURES - XFER |
| 1417 | * @ap: port on which timings will be programmed | 1550 | * @ap: port on which timings will be programmed |
| 1418 | * | 1551 | * |
| 1552 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). | ||
| 1553 | * | ||
| 1419 | * LOCKING: | 1554 | * LOCKING: |
| 1555 | * PCI/etc. bus probe sem. | ||
| 1420 | * | 1556 | * |
| 1421 | */ | 1557 | */ |
| 1422 | static void ata_set_mode(struct ata_port *ap) | 1558 | static void ata_set_mode(struct ata_port *ap) |
| @@ -1467,7 +1603,10 @@ err_out: | |||
| 1467 | * @tmout_pat: impatience timeout | 1603 | * @tmout_pat: impatience timeout |
| 1468 | * @tmout: overall timeout | 1604 | * @tmout: overall timeout |
| 1469 | * | 1605 | * |
| 1470 | * LOCKING: | 1606 | * Sleep until ATA Status register bit BSY clears, |
| 1607 | * or a timeout occurs. | ||
| 1608 | * | ||
| 1609 | * LOCKING: None. | ||
| 1471 | * | 1610 | * |
| 1472 | */ | 1611 | */ |
| 1473 | 1612 | ||
| @@ -1553,10 +1692,14 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask) | |||
| 1553 | } | 1692 | } |
| 1554 | 1693 | ||
| 1555 | /** | 1694 | /** |
| 1556 | * ata_bus_edd - | 1695 | * ata_bus_edd - Issue EXECUTE DEVICE DIAGNOSTIC command. |
| 1557 | * @ap: | 1696 | * @ap: Port to reset and probe |
| 1697 | * | ||
| 1698 | * Use the EXECUTE DEVICE DIAGNOSTIC command to reset and | ||
| 1699 | * probe the bus. Not often used these days. | ||
| 1558 | * | 1700 | * |
| 1559 | * LOCKING: | 1701 | * LOCKING: |
| 1702 | * PCI/etc. bus probe sem. | ||
| 1560 | * | 1703 | * |
| 1561 | */ | 1704 | */ |
| 1562 | 1705 | ||
| @@ -1633,8 +1776,8 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
| 1633 | * the device is ATA or ATAPI. | 1776 | * the device is ATA or ATAPI. |
| 1634 | * | 1777 | * |
| 1635 | * LOCKING: | 1778 | * LOCKING: |
| 1636 | * Inherited from caller. Some functions called by this function | 1779 | * PCI/etc. bus probe sem. |
| 1637 | * obtain the host_set lock. | 1780 | * Obtains host_set lock. |
| 1638 | * | 1781 | * |
| 1639 | * SIDE EFFECTS: | 1782 | * SIDE EFFECTS: |
| 1640 | * Sets ATA_FLAG_PORT_DISABLED if bus reset fails. | 1783 | * Sets ATA_FLAG_PORT_DISABLED if bus reset fails. |
| @@ -1876,7 +2019,11 @@ static int fgb(u32 bitmap) | |||
| 1876 | * @xfer_mode_out: (output) SET FEATURES - XFER MODE code | 2019 | * @xfer_mode_out: (output) SET FEATURES - XFER MODE code |
| 1877 | * @xfer_shift_out: (output) bit shift that selects this mode | 2020 | * @xfer_shift_out: (output) bit shift that selects this mode |
| 1878 | * | 2021 | * |
| 2022 | * Based on host and device capabilities, determine the | ||
| 2023 | * maximum transfer mode that is amenable to all. | ||
| 2024 | * | ||
| 1879 | * LOCKING: | 2025 | * LOCKING: |
| 2026 | * PCI/etc. bus probe sem. | ||
| 1880 | * | 2027 | * |
| 1881 | * RETURNS: | 2028 | * RETURNS: |
| 1882 | * Zero on success, negative on error. | 2029 | * Zero on success, negative on error. |
| @@ -1909,7 +2056,11 @@ static int ata_choose_xfer_mode(struct ata_port *ap, | |||
| 1909 | * @ap: Port associated with device @dev | 2056 | * @ap: Port associated with device @dev |
| 1910 | * @dev: Device to which command will be sent | 2057 | * @dev: Device to which command will be sent |
| 1911 | * | 2058 | * |
| 2059 | * Issue SET FEATURES - XFER MODE command to device @dev | ||
| 2060 | * on port @ap. | ||
| 2061 | * | ||
| 1912 | * LOCKING: | 2062 | * LOCKING: |
| 2063 | * PCI/etc. bus probe sem. | ||
| 1913 | */ | 2064 | */ |
| 1914 | 2065 | ||
| 1915 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | 2066 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) |
| @@ -1947,10 +2098,13 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | |||
| 1947 | } | 2098 | } |
| 1948 | 2099 | ||
| 1949 | /** | 2100 | /** |
| 1950 | * ata_sg_clean - | 2101 | * ata_sg_clean - Unmap DMA memory associated with command |
| 1951 | * @qc: | 2102 | * @qc: Command containing DMA memory to be released |
| 2103 | * | ||
| 2104 | * Unmap all mapped DMA memory associated with this command. | ||
| 1952 | * | 2105 | * |
| 1953 | * LOCKING: | 2106 | * LOCKING: |
| 2107 | * spin_lock_irqsave(host_set lock) | ||
| 1954 | */ | 2108 | */ |
| 1955 | 2109 | ||
| 1956 | static void ata_sg_clean(struct ata_queued_cmd *qc) | 2110 | static void ata_sg_clean(struct ata_queued_cmd *qc) |
| @@ -1981,7 +2135,11 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
| 1981 | * ata_fill_sg - Fill PCI IDE PRD table | 2135 | * ata_fill_sg - Fill PCI IDE PRD table |
| 1982 | * @qc: Metadata associated with taskfile to be transferred | 2136 | * @qc: Metadata associated with taskfile to be transferred |
| 1983 | * | 2137 | * |
| 2138 | * Fill PCI IDE PRD (scatter-gather) table with segments | ||
| 2139 | * associated with the current disk command. | ||
| 2140 | * | ||
| 1984 | * LOCKING: | 2141 | * LOCKING: |
| 2142 | * spin_lock_irqsave(host_set lock) | ||
| 1985 | * | 2143 | * |
| 1986 | */ | 2144 | */ |
| 1987 | static void ata_fill_sg(struct ata_queued_cmd *qc) | 2145 | static void ata_fill_sg(struct ata_queued_cmd *qc) |
| @@ -2028,7 +2186,13 @@ static void ata_fill_sg(struct ata_queued_cmd *qc) | |||
| 2028 | * ata_check_atapi_dma - Check whether ATAPI DMA can be supported | 2186 | * ata_check_atapi_dma - Check whether ATAPI DMA can be supported |
| 2029 | * @qc: Metadata associated with taskfile to check | 2187 | * @qc: Metadata associated with taskfile to check |
| 2030 | * | 2188 | * |
| 2189 | * Allow low-level driver to filter ATA PACKET commands, returning | ||
| 2190 | * a status indicating whether or not it is OK to use DMA for the | ||
| 2191 | * supplied PACKET command. | ||
| 2192 | * | ||
| 2031 | * LOCKING: | 2193 | * LOCKING: |
| 2194 | * spin_lock_irqsave(host_set lock) | ||
| 2195 | * | ||
| 2032 | * RETURNS: 0 when ATAPI DMA can be used | 2196 | * RETURNS: 0 when ATAPI DMA can be used |
| 2033 | * nonzero otherwise | 2197 | * nonzero otherwise |
| 2034 | */ | 2198 | */ |
| @@ -2046,6 +2210,8 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc) | |||
| 2046 | * ata_qc_prep - Prepare taskfile for submission | 2210 | * ata_qc_prep - Prepare taskfile for submission |
| 2047 | * @qc: Metadata associated with taskfile to be prepared | 2211 | * @qc: Metadata associated with taskfile to be prepared |
| 2048 | * | 2212 | * |
| 2213 | * Prepare ATA taskfile for submission. | ||
| 2214 | * | ||
| 2049 | * LOCKING: | 2215 | * LOCKING: |
| 2050 | * spin_lock_irqsave(host_set lock) | 2216 | * spin_lock_irqsave(host_set lock) |
| 2051 | */ | 2217 | */ |
| @@ -2057,6 +2223,32 @@ void ata_qc_prep(struct ata_queued_cmd *qc) | |||
| 2057 | ata_fill_sg(qc); | 2223 | ata_fill_sg(qc); |
| 2058 | } | 2224 | } |
| 2059 | 2225 | ||
| 2226 | /** | ||
| 2227 | * ata_sg_init_one - Associate command with memory buffer | ||
| 2228 | * @qc: Command to be associated | ||
| 2229 | * @buf: Memory buffer | ||
| 2230 | * @buflen: Length of memory buffer, in bytes. | ||
| 2231 | * | ||
| 2232 | * Initialize the data-related elements of queued_cmd @qc | ||
| 2233 | * to point to a single memory buffer, @buf of byte length @buflen. | ||
| 2234 | * | ||
| 2235 | * LOCKING: | ||
| 2236 | * spin_lock_irqsave(host_set lock) | ||
| 2237 | */ | ||
| 2238 | |||
| 2239 | |||
| 2240 | |||
| 2241 | /** | ||
| 2242 | * ata_sg_init_one - Prepare a one-entry scatter-gather list. | ||
| 2243 | * @qc: Queued command | ||
| 2244 | * @buf: transfer buffer | ||
| 2245 | * @buflen: length of buf | ||
| 2246 | * | ||
| 2247 | * Builds a single-entry scatter-gather list to initiate a | ||
| 2248 | * transfer utilizing the specified buffer. | ||
| 2249 | * | ||
| 2250 | * LOCKING: | ||
| 2251 | */ | ||
| 2060 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | 2252 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) |
| 2061 | { | 2253 | { |
| 2062 | struct scatterlist *sg; | 2254 | struct scatterlist *sg; |
| @@ -2074,6 +2266,32 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | |||
| 2074 | sg->length = buflen; | 2266 | sg->length = buflen; |
| 2075 | } | 2267 | } |
| 2076 | 2268 | ||
| 2269 | /** | ||
| 2270 | * ata_sg_init - Associate command with scatter-gather table. | ||
| 2271 | * @qc: Command to be associated | ||
| 2272 | * @sg: Scatter-gather table. | ||
| 2273 | * @n_elem: Number of elements in s/g table. | ||
| 2274 | * | ||
| 2275 | * Initialize the data-related elements of queued_cmd @qc | ||
| 2276 | * to point to a scatter-gather table @sg, containing @n_elem | ||
| 2277 | * elements. | ||
| 2278 | * | ||
| 2279 | * LOCKING: | ||
| 2280 | * spin_lock_irqsave(host_set lock) | ||
| 2281 | */ | ||
| 2282 | |||
| 2283 | |||
| 2284 | /** | ||
| 2285 | * ata_sg_init - Assign a scatter gather list to a queued command | ||
| 2286 | * @qc: Queued command | ||
| 2287 | * @sg: Scatter-gather list | ||
| 2288 | * @n_elem: length of sg list | ||
| 2289 | * | ||
| 2290 | * Attaches a scatter-gather list to a queued command. | ||
| 2291 | * | ||
| 2292 | * LOCKING: | ||
| 2293 | */ | ||
| 2294 | |||
| 2077 | void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 2295 | void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
| 2078 | unsigned int n_elem) | 2296 | unsigned int n_elem) |
| 2079 | { | 2297 | { |
| @@ -2083,14 +2301,16 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | |||
| 2083 | } | 2301 | } |
| 2084 | 2302 | ||
| 2085 | /** | 2303 | /** |
| 2086 | * ata_sg_setup_one - | 2304 | * ata_sg_setup_one - DMA-map the memory buffer associated with a command. |
| 2087 | * @qc: | 2305 | * @qc: Command with memory buffer to be mapped. |
| 2306 | * | ||
| 2307 | * DMA-map the memory buffer associated with queued_cmd @qc. | ||
| 2088 | * | 2308 | * |
| 2089 | * LOCKING: | 2309 | * LOCKING: |
| 2090 | * spin_lock_irqsave(host_set lock) | 2310 | * spin_lock_irqsave(host_set lock) |
| 2091 | * | 2311 | * |
| 2092 | * RETURNS: | 2312 | * RETURNS: |
| 2093 | * | 2313 | * Zero on success, negative on error. |
| 2094 | */ | 2314 | */ |
| 2095 | 2315 | ||
| 2096 | static int ata_sg_setup_one(struct ata_queued_cmd *qc) | 2316 | static int ata_sg_setup_one(struct ata_queued_cmd *qc) |
| @@ -2115,13 +2335,16 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
| 2115 | } | 2335 | } |
| 2116 | 2336 | ||
| 2117 | /** | 2337 | /** |
| 2118 | * ata_sg_setup - | 2338 | * ata_sg_setup - DMA-map the scatter-gather table associated with a command. |
| 2119 | * @qc: | 2339 | * @qc: Command with scatter-gather table to be mapped. |
| 2340 | * | ||
| 2341 | * DMA-map the scatter-gather table associated with queued_cmd @qc. | ||
| 2120 | * | 2342 | * |
| 2121 | * LOCKING: | 2343 | * LOCKING: |
| 2122 | * spin_lock_irqsave(host_set lock) | 2344 | * spin_lock_irqsave(host_set lock) |
| 2123 | * | 2345 | * |
| 2124 | * RETURNS: | 2346 | * RETURNS: |
| 2347 | * Zero on success, negative on error. | ||
| 2125 | * | 2348 | * |
| 2126 | */ | 2349 | */ |
| 2127 | 2350 | ||
| @@ -2151,6 +2374,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
| 2151 | * @ap: | 2374 | * @ap: |
| 2152 | * | 2375 | * |
| 2153 | * LOCKING: | 2376 | * LOCKING: |
| 2377 | * None. (executing in kernel thread context) | ||
| 2154 | * | 2378 | * |
| 2155 | * RETURNS: | 2379 | * RETURNS: |
| 2156 | * | 2380 | * |
| @@ -2198,6 +2422,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
| 2198 | * @ap: | 2422 | * @ap: |
| 2199 | * | 2423 | * |
| 2200 | * LOCKING: | 2424 | * LOCKING: |
| 2425 | * None. (executing in kernel thread context) | ||
| 2201 | */ | 2426 | */ |
| 2202 | 2427 | ||
| 2203 | static void ata_pio_complete (struct ata_port *ap) | 2428 | static void ata_pio_complete (struct ata_port *ap) |
| @@ -2240,6 +2465,18 @@ static void ata_pio_complete (struct ata_port *ap) | |||
| 2240 | ata_qc_complete(qc, drv_stat); | 2465 | ata_qc_complete(qc, drv_stat); |
| 2241 | } | 2466 | } |
| 2242 | 2467 | ||
| 2468 | |||
| 2469 | /** | ||
| 2470 | * swap_buf_le16 - | ||
| 2471 | * @buf: Buffer to swap | ||
| 2472 | * @buf_words: Number of 16-bit words in buffer. | ||
| 2473 | * | ||
| 2474 | * Swap halves of 16-bit words if needed to convert from | ||
| 2475 | * little-endian byte order to native cpu byte order, or | ||
| 2476 | * vice-versa. | ||
| 2477 | * | ||
| 2478 | * LOCKING: | ||
| 2479 | */ | ||
| 2243 | void swap_buf_le16(u16 *buf, unsigned int buf_words) | 2480 | void swap_buf_le16(u16 *buf, unsigned int buf_words) |
| 2244 | { | 2481 | { |
| 2245 | #ifdef __BIG_ENDIAN | 2482 | #ifdef __BIG_ENDIAN |
| @@ -2415,6 +2652,7 @@ err_out: | |||
| 2415 | * @ap: | 2652 | * @ap: |
| 2416 | * | 2653 | * |
| 2417 | * LOCKING: | 2654 | * LOCKING: |
| 2655 | * None. (executing in kernel thread context) | ||
| 2418 | */ | 2656 | */ |
| 2419 | 2657 | ||
| 2420 | static void ata_pio_block(struct ata_port *ap) | 2658 | static void ata_pio_block(struct ata_port *ap) |
| @@ -2583,6 +2821,7 @@ static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | |||
| 2583 | * transaction completed successfully. | 2821 | * transaction completed successfully. |
| 2584 | * | 2822 | * |
| 2585 | * LOCKING: | 2823 | * LOCKING: |
| 2824 | * Inherited from SCSI layer (none, can sleep) | ||
| 2586 | */ | 2825 | */ |
| 2587 | 2826 | ||
| 2588 | static void ata_qc_timeout(struct ata_queued_cmd *qc) | 2827 | static void ata_qc_timeout(struct ata_queued_cmd *qc) |
| @@ -2692,6 +2931,7 @@ out: | |||
| 2692 | * @dev: Device from whom we request an available command structure | 2931 | * @dev: Device from whom we request an available command structure |
| 2693 | * | 2932 | * |
| 2694 | * LOCKING: | 2933 | * LOCKING: |
| 2934 | * None. | ||
| 2695 | */ | 2935 | */ |
| 2696 | 2936 | ||
| 2697 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | 2937 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) |
| @@ -2717,6 +2957,7 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | |||
| 2717 | * @dev: Device from whom we request an available command structure | 2957 | * @dev: Device from whom we request an available command structure |
| 2718 | * | 2958 | * |
| 2719 | * LOCKING: | 2959 | * LOCKING: |
| 2960 | * None. | ||
| 2720 | */ | 2961 | */ |
| 2721 | 2962 | ||
| 2722 | struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 2963 | struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, |
| @@ -2781,6 +3022,7 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
| 2781 | * in case something prevents using it. | 3022 | * in case something prevents using it. |
| 2782 | * | 3023 | * |
| 2783 | * LOCKING: | 3024 | * LOCKING: |
| 3025 | * spin_lock_irqsave(host_set lock) | ||
| 2784 | * | 3026 | * |
| 2785 | */ | 3027 | */ |
| 2786 | void ata_qc_free(struct ata_queued_cmd *qc) | 3028 | void ata_qc_free(struct ata_queued_cmd *qc) |
| @@ -2794,9 +3036,13 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
| 2794 | /** | 3036 | /** |
| 2795 | * ata_qc_complete - Complete an active ATA command | 3037 | * ata_qc_complete - Complete an active ATA command |
| 2796 | * @qc: Command to complete | 3038 | * @qc: Command to complete |
| 2797 | * @drv_stat: ATA status register contents | 3039 | * @drv_stat: ATA Status register contents |
| 3040 | * | ||
| 3041 | * Indicate to the mid and upper layers that an ATA | ||
| 3042 | * command has completed, with either an ok or not-ok status. | ||
| 2798 | * | 3043 | * |
| 2799 | * LOCKING: | 3044 | * LOCKING: |
| 3045 | * spin_lock_irqsave(host_set lock) | ||
| 2800 | * | 3046 | * |
| 2801 | */ | 3047 | */ |
| 2802 | 3048 | ||
| @@ -2892,6 +3138,7 @@ err_out: | |||
| 2892 | return -1; | 3138 | return -1; |
| 2893 | } | 3139 | } |
| 2894 | 3140 | ||
| 3141 | |||
| 2895 | /** | 3142 | /** |
| 2896 | * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner | 3143 | * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner |
| 2897 | * @qc: command to issue to device | 3144 | * @qc: command to issue to device |
| @@ -2901,6 +3148,8 @@ err_out: | |||
| 2901 | * classes called "protocols", and issuing each type of protocol | 3148 | * classes called "protocols", and issuing each type of protocol |
| 2902 | * is slightly different. | 3149 | * is slightly different. |
| 2903 | * | 3150 | * |
| 3151 | * May be used as the qc_issue() entry in ata_port_operations. | ||
| 3152 | * | ||
| 2904 | * LOCKING: | 3153 | * LOCKING: |
| 2905 | * spin_lock_irqsave(host_set lock) | 3154 | * spin_lock_irqsave(host_set lock) |
| 2906 | * | 3155 | * |
| @@ -2958,7 +3207,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
| 2958 | } | 3207 | } |
| 2959 | 3208 | ||
| 2960 | /** | 3209 | /** |
| 2961 | * ata_bmdma_setup - Set up PCI IDE BMDMA transaction | 3210 | * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction |
| 2962 | * @qc: Info associated with this ATA transaction. | 3211 | * @qc: Info associated with this ATA transaction. |
| 2963 | * | 3212 | * |
| 2964 | * LOCKING: | 3213 | * LOCKING: |
| @@ -3065,6 +3314,18 @@ static void ata_bmdma_start_pio (struct ata_queued_cmd *qc) | |||
| 3065 | ap->ioaddr.bmdma_addr + ATA_DMA_CMD); | 3314 | ap->ioaddr.bmdma_addr + ATA_DMA_CMD); |
| 3066 | } | 3315 | } |
| 3067 | 3316 | ||
| 3317 | |||
| 3318 | /** | ||
| 3319 | * ata_bmdma_start - Start a PCI IDE BMDMA transaction | ||
| 3320 | * @qc: Info associated with this ATA transaction. | ||
| 3321 | * | ||
| 3322 | * Writes the ATA_DMA_START flag to the DMA command register. | ||
| 3323 | * | ||
| 3324 | * May be used as the bmdma_start() entry in ata_port_operations. | ||
| 3325 | * | ||
| 3326 | * LOCKING: | ||
| 3327 | * spin_lock_irqsave(host_set lock) | ||
| 3328 | */ | ||
| 3068 | void ata_bmdma_start(struct ata_queued_cmd *qc) | 3329 | void ata_bmdma_start(struct ata_queued_cmd *qc) |
| 3069 | { | 3330 | { |
| 3070 | if (qc->ap->flags & ATA_FLAG_MMIO) | 3331 | if (qc->ap->flags & ATA_FLAG_MMIO) |
| @@ -3073,6 +3334,20 @@ void ata_bmdma_start(struct ata_queued_cmd *qc) | |||
| 3073 | ata_bmdma_start_pio(qc); | 3334 | ata_bmdma_start_pio(qc); |
| 3074 | } | 3335 | } |
| 3075 | 3336 | ||
| 3337 | |||
| 3338 | /** | ||
| 3339 | * ata_bmdma_setup - Set up PCI IDE BMDMA transaction | ||
| 3340 | * @qc: Info associated with this ATA transaction. | ||
| 3341 | * | ||
| 3342 | * Writes address of PRD table to device's PRD Table Address | ||
| 3343 | * register, sets the DMA control register, and calls | ||
| 3344 | * ops->exec_command() to start the transfer. | ||
| 3345 | * | ||
| 3346 | * May be used as the bmdma_setup() entry in ata_port_operations. | ||
| 3347 | * | ||
| 3348 | * LOCKING: | ||
| 3349 | * spin_lock_irqsave(host_set lock) | ||
| 3350 | */ | ||
| 3076 | void ata_bmdma_setup(struct ata_queued_cmd *qc) | 3351 | void ata_bmdma_setup(struct ata_queued_cmd *qc) |
| 3077 | { | 3352 | { |
| 3078 | if (qc->ap->flags & ATA_FLAG_MMIO) | 3353 | if (qc->ap->flags & ATA_FLAG_MMIO) |
| @@ -3081,6 +3356,19 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc) | |||
| 3081 | ata_bmdma_setup_pio(qc); | 3356 | ata_bmdma_setup_pio(qc); |
| 3082 | } | 3357 | } |
| 3083 | 3358 | ||
| 3359 | |||
| 3360 | /** | ||
| 3361 | * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt. | ||
| 3362 | * @ap: Port associated with this ATA transaction. | ||
| 3363 | * | ||
| 3364 | * Clear interrupt and error flags in DMA status register. | ||
| 3365 | * | ||
| 3366 | * May be used as the irq_clear() entry in ata_port_operations. | ||
| 3367 | * | ||
| 3368 | * LOCKING: | ||
| 3369 | * spin_lock_irqsave(host_set lock) | ||
| 3370 | */ | ||
| 3371 | |||
| 3084 | void ata_bmdma_irq_clear(struct ata_port *ap) | 3372 | void ata_bmdma_irq_clear(struct ata_port *ap) |
| 3085 | { | 3373 | { |
| 3086 | if (ap->flags & ATA_FLAG_MMIO) { | 3374 | if (ap->flags & ATA_FLAG_MMIO) { |
| @@ -3093,6 +3381,19 @@ void ata_bmdma_irq_clear(struct ata_port *ap) | |||
| 3093 | 3381 | ||
| 3094 | } | 3382 | } |
| 3095 | 3383 | ||
| 3384 | |||
| 3385 | /** | ||
| 3386 | * ata_bmdma_status - Read PCI IDE BMDMA status | ||
| 3387 | * @ap: Port associated with this ATA transaction. | ||
| 3388 | * | ||
| 3389 | * Read and return BMDMA status register. | ||
| 3390 | * | ||
| 3391 | * May be used as the bmdma_status() entry in ata_port_operations. | ||
| 3392 | * | ||
| 3393 | * LOCKING: | ||
| 3394 | * spin_lock_irqsave(host_set lock) | ||
| 3395 | */ | ||
| 3396 | |||
| 3096 | u8 ata_bmdma_status(struct ata_port *ap) | 3397 | u8 ata_bmdma_status(struct ata_port *ap) |
| 3097 | { | 3398 | { |
| 3098 | u8 host_stat; | 3399 | u8 host_stat; |
| @@ -3104,6 +3405,19 @@ u8 ata_bmdma_status(struct ata_port *ap) | |||
| 3104 | return host_stat; | 3405 | return host_stat; |
| 3105 | } | 3406 | } |
| 3106 | 3407 | ||
| 3408 | |||
| 3409 | /** | ||
| 3410 | * ata_bmdma_stop - Stop PCI IDE BMDMA transfer | ||
| 3411 | * @ap: Port associated with this ATA transaction. | ||
| 3412 | * | ||
| 3413 | * Clears the ATA_DMA_START flag in the dma control register | ||
| 3414 | * | ||
| 3415 | * May be used as the bmdma_stop() entry in ata_port_operations. | ||
| 3416 | * | ||
| 3417 | * LOCKING: | ||
| 3418 | * spin_lock_irqsave(host_set lock) | ||
| 3419 | */ | ||
| 3420 | |||
| 3107 | void ata_bmdma_stop(struct ata_port *ap) | 3421 | void ata_bmdma_stop(struct ata_port *ap) |
| 3108 | { | 3422 | { |
| 3109 | if (ap->flags & ATA_FLAG_MMIO) { | 3423 | if (ap->flags & ATA_FLAG_MMIO) { |
| @@ -3203,13 +3517,18 @@ idle_irq: | |||
| 3203 | 3517 | ||
| 3204 | /** | 3518 | /** |
| 3205 | * ata_interrupt - Default ATA host interrupt handler | 3519 | * ata_interrupt - Default ATA host interrupt handler |
| 3206 | * @irq: irq line | 3520 | * @irq: irq line (unused) |
| 3207 | * @dev_instance: pointer to our host information structure | 3521 | * @dev_instance: pointer to our ata_host_set information structure |
| 3208 | * @regs: unused | 3522 | * @regs: unused |
| 3209 | * | 3523 | * |
| 3524 | * Default interrupt handler for PCI IDE devices. Calls | ||
| 3525 | * ata_host_intr() for each port that is not disabled. | ||
| 3526 | * | ||
| 3210 | * LOCKING: | 3527 | * LOCKING: |
| 3528 | * Obtains host_set lock during operation. | ||
| 3211 | * | 3529 | * |
| 3212 | * RETURNS: | 3530 | * RETURNS: |
| 3531 | * IRQ_NONE or IRQ_HANDLED. | ||
| 3213 | * | 3532 | * |
| 3214 | */ | 3533 | */ |
| 3215 | 3534 | ||
| @@ -3302,6 +3621,19 @@ err_out: | |||
| 3302 | ata_qc_complete(qc, ATA_ERR); | 3621 | ata_qc_complete(qc, ATA_ERR); |
| 3303 | } | 3622 | } |
| 3304 | 3623 | ||
| 3624 | |||
| 3625 | /** | ||
| 3626 | * ata_port_start - Set port up for dma. | ||
| 3627 | * @ap: Port to initialize | ||
| 3628 | * | ||
| 3629 | * Called just after data structures for each port are | ||
| 3630 | * initialized. Allocates space for PRD table. | ||
| 3631 | * | ||
| 3632 | * May be used as the port_start() entry in ata_port_operations. | ||
| 3633 | * | ||
| 3634 | * LOCKING: | ||
| 3635 | */ | ||
| 3636 | |||
| 3305 | int ata_port_start (struct ata_port *ap) | 3637 | int ata_port_start (struct ata_port *ap) |
| 3306 | { | 3638 | { |
| 3307 | struct device *dev = ap->host_set->dev; | 3639 | struct device *dev = ap->host_set->dev; |
| @@ -3315,6 +3647,18 @@ int ata_port_start (struct ata_port *ap) | |||
| 3315 | return 0; | 3647 | return 0; |
| 3316 | } | 3648 | } |
| 3317 | 3649 | ||
| 3650 | |||
| 3651 | /** | ||
| 3652 | * ata_port_stop - Undo ata_port_start() | ||
| 3653 | * @ap: Port to shut down | ||
| 3654 | * | ||
| 3655 | * Frees the PRD table. | ||
| 3656 | * | ||
| 3657 | * May be used as the port_stop() entry in ata_port_operations. | ||
| 3658 | * | ||
| 3659 | * LOCKING: | ||
| 3660 | */ | ||
| 3661 | |||
| 3318 | void ata_port_stop (struct ata_port *ap) | 3662 | void ata_port_stop (struct ata_port *ap) |
| 3319 | { | 3663 | { |
| 3320 | struct device *dev = ap->host_set->dev; | 3664 | struct device *dev = ap->host_set->dev; |
| @@ -3357,7 +3701,11 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister) | |||
| 3357 | * @ent: Probe information provided by low-level driver | 3701 | * @ent: Probe information provided by low-level driver |
| 3358 | * @port_no: Port number associated with this ata_port | 3702 | * @port_no: Port number associated with this ata_port |
| 3359 | * | 3703 | * |
| 3704 | * Initialize a new ata_port structure, and its associated | ||
| 3705 | * scsi_host. | ||
| 3706 | * | ||
| 3360 | * LOCKING: | 3707 | * LOCKING: |
| 3708 | * Inherited from caller. | ||
| 3361 | * | 3709 | * |
| 3362 | */ | 3710 | */ |
| 3363 | 3711 | ||
| @@ -3412,9 +3760,13 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
| 3412 | * @host_set: Collections of ports to which we add | 3760 | * @host_set: Collections of ports to which we add |
| 3413 | * @port_no: Port number associated with this host | 3761 | * @port_no: Port number associated with this host |
| 3414 | * | 3762 | * |
| 3763 | * Attach low-level ATA driver to system. | ||
| 3764 | * | ||
| 3415 | * LOCKING: | 3765 | * LOCKING: |
| 3766 | * PCI/etc. bus probe sem. | ||
| 3416 | * | 3767 | * |
| 3417 | * RETURNS: | 3768 | * RETURNS: |
| 3769 | * New ata_port on success, for NULL on error. | ||
| 3418 | * | 3770 | * |
| 3419 | */ | 3771 | */ |
| 3420 | 3772 | ||
| @@ -3447,12 +3799,22 @@ err_out: | |||
| 3447 | } | 3799 | } |
| 3448 | 3800 | ||
| 3449 | /** | 3801 | /** |
| 3450 | * ata_device_add - | 3802 | * ata_device_add - Register hardware device with ATA and SCSI layers |
| 3451 | * @ent: | 3803 | * @ent: Probe information describing hardware device to be registered |
| 3804 | * | ||
| 3805 | * This function processes the information provided in the probe | ||
| 3806 | * information struct @ent, allocates the necessary ATA and SCSI | ||
| 3807 | * host information structures, initializes them, and registers | ||
| 3808 | * everything with requisite kernel subsystems. | ||
| 3809 | * | ||
| 3810 | * This function requests irqs, probes the ATA bus, and probes | ||
| 3811 | * the SCSI bus. | ||
| 3452 | * | 3812 | * |
| 3453 | * LOCKING: | 3813 | * LOCKING: |
| 3814 | * PCI/etc. bus probe sem. | ||
| 3454 | * | 3815 | * |
| 3455 | * RETURNS: | 3816 | * RETURNS: |
| 3817 | * Number of ports registered. Zero on error (no ports registered). | ||
| 3456 | * | 3818 | * |
| 3457 | */ | 3819 | */ |
| 3458 | 3820 | ||
| @@ -3604,7 +3966,15 @@ int ata_scsi_release(struct Scsi_Host *host) | |||
| 3604 | /** | 3966 | /** |
| 3605 | * ata_std_ports - initialize ioaddr with standard port offsets. | 3967 | * ata_std_ports - initialize ioaddr with standard port offsets. |
| 3606 | * @ioaddr: IO address structure to be initialized | 3968 | * @ioaddr: IO address structure to be initialized |
| 3969 | * | ||
| 3970 | * Utility function which initializes data_addr, error_addr, | ||
| 3971 | * feature_addr, nsect_addr, lbal_addr, lbam_addr, lbah_addr, | ||
| 3972 | * device_addr, status_addr, and command_addr to standard offsets | ||
| 3973 | * relative to cmd_addr. | ||
| 3974 | * | ||
| 3975 | * Does not set ctl_addr, altstatus_addr, bmdma_addr, or scr_addr. | ||
| 3607 | */ | 3976 | */ |
| 3977 | |||
| 3608 | void ata_std_ports(struct ata_ioports *ioaddr) | 3978 | void ata_std_ports(struct ata_ioports *ioaddr) |
| 3609 | { | 3979 | { |
| 3610 | ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA; | 3980 | ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA; |
| @@ -3646,6 +4016,20 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) | |||
| 3646 | return probe_ent; | 4016 | return probe_ent; |
| 3647 | } | 4017 | } |
| 3648 | 4018 | ||
| 4019 | |||
| 4020 | |||
| 4021 | /** | ||
| 4022 | * ata_pci_init_native_mode - Initialize native-mode driver | ||
| 4023 | * @pdev: pci device to be initialized | ||
| 4024 | * @port: array[2] of pointers to port info structures. | ||
| 4025 | * | ||
| 4026 | * Utility function which allocates and initializes an | ||
| 4027 | * ata_probe_ent structure for a standard dual-port | ||
| 4028 | * PIO-based IDE controller. The returned ata_probe_ent | ||
| 4029 | * structure can be passed to ata_device_add(). The returned | ||
| 4030 | * ata_probe_ent structure should then be freed with kfree(). | ||
| 4031 | */ | ||
| 4032 | |||
| 3649 | #ifdef CONFIG_PCI | 4033 | #ifdef CONFIG_PCI |
| 3650 | struct ata_probe_ent * | 4034 | struct ata_probe_ent * |
| 3651 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) | 4035 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) |
| @@ -3727,10 +4111,19 @@ ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port, | |||
| 3727 | * @port_info: Information from low-level host driver | 4111 | * @port_info: Information from low-level host driver |
| 3728 | * @n_ports: Number of ports attached to host controller | 4112 | * @n_ports: Number of ports attached to host controller |
| 3729 | * | 4113 | * |
| 4114 | * This is a helper function which can be called from a driver's | ||
| 4115 | * xxx_init_one() probe function if the hardware uses traditional | ||
| 4116 | * IDE taskfile registers. | ||
| 4117 | * | ||
| 4118 | * This function calls pci_enable_device(), reserves its register | ||
| 4119 | * regions, sets the dma mask, enables bus master mode, and calls | ||
| 4120 | * ata_device_add() | ||
| 4121 | * | ||
| 3730 | * LOCKING: | 4122 | * LOCKING: |
| 3731 | * Inherited from PCI layer (may sleep). | 4123 | * Inherited from PCI layer (may sleep). |
| 3732 | * | 4124 | * |
| 3733 | * RETURNS: | 4125 | * RETURNS: |
| 4126 | * Zero on success, negative on errno-based value on error. | ||
| 3734 | * | 4127 | * |
| 3735 | */ | 4128 | */ |
| 3736 | 4129 | ||
| @@ -3949,15 +4342,6 @@ int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits) | |||
| 3949 | #endif /* CONFIG_PCI */ | 4342 | #endif /* CONFIG_PCI */ |
| 3950 | 4343 | ||
| 3951 | 4344 | ||
| 3952 | /** | ||
| 3953 | * ata_init - | ||
| 3954 | * | ||
| 3955 | * LOCKING: | ||
| 3956 | * | ||
| 3957 | * RETURNS: | ||
| 3958 | * | ||
| 3959 | */ | ||
| 3960 | |||
| 3961 | static int __init ata_init(void) | 4345 | static int __init ata_init(void) |
| 3962 | { | 4346 | { |
| 3963 | ata_wq = create_workqueue("ata"); | 4347 | ata_wq = create_workqueue("ata"); |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 416ba67ba9ee..7a4adc4c8f09 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
| @@ -947,7 +947,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, | |||
| 947 | } | 947 | } |
| 948 | 948 | ||
| 949 | /** | 949 | /** |
| 950 | * ata_scsiop_noop - | 950 | * ata_scsiop_noop - Command handler that simply returns success. |
| 951 | * @args: device IDENTIFY data / SCSI command of interest. | 951 | * @args: device IDENTIFY data / SCSI command of interest. |
| 952 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. | 952 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. |
| 953 | * @buflen: Response buffer length. | 953 | * @buflen: Response buffer length. |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 579448222d69..3c97aa45772d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
| @@ -507,6 +507,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
| 507 | int ret, i; | 507 | int ret, i; |
| 508 | unsigned int id, lun; | 508 | unsigned int id, lun; |
| 509 | unsigned long serial; | 509 | unsigned long serial; |
| 510 | unsigned long flags; | ||
| 510 | 511 | ||
| 511 | if (!CMD_SP(cmd)) | 512 | if (!CMD_SP(cmd)) |
| 512 | return FAILED; | 513 | return FAILED; |
| @@ -519,7 +520,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
| 519 | 520 | ||
| 520 | /* Check active list for command command. */ | 521 | /* Check active list for command command. */ |
| 521 | spin_unlock_irq(ha->host->host_lock); | 522 | spin_unlock_irq(ha->host->host_lock); |
| 522 | spin_lock(&ha->hardware_lock); | 523 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 523 | for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { | 524 | for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { |
| 524 | sp = ha->outstanding_cmds[i]; | 525 | sp = ha->outstanding_cmds[i]; |
| 525 | 526 | ||
| @@ -534,7 +535,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
| 534 | sp->state)); | 535 | sp->state)); |
| 535 | DEBUG3(qla2x00_print_scsi_cmd(cmd);) | 536 | DEBUG3(qla2x00_print_scsi_cmd(cmd);) |
| 536 | 537 | ||
| 537 | spin_unlock(&ha->hardware_lock); | 538 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 538 | if (qla2x00_abort_command(ha, sp)) { | 539 | if (qla2x00_abort_command(ha, sp)) { |
| 539 | DEBUG2(printk("%s(%ld): abort_command " | 540 | DEBUG2(printk("%s(%ld): abort_command " |
| 540 | "mbx failed.\n", __func__, ha->host_no)); | 541 | "mbx failed.\n", __func__, ha->host_no)); |
| @@ -543,20 +544,19 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
| 543 | "mbx success.\n", __func__, ha->host_no)); | 544 | "mbx success.\n", __func__, ha->host_no)); |
| 544 | ret = SUCCESS; | 545 | ret = SUCCESS; |
| 545 | } | 546 | } |
| 546 | spin_lock(&ha->hardware_lock); | 547 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 547 | 548 | ||
| 548 | break; | 549 | break; |
| 549 | } | 550 | } |
| 551 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | ||
| 550 | 552 | ||
| 551 | /* Wait for the command to be returned. */ | 553 | /* Wait for the command to be returned. */ |
| 552 | if (ret == SUCCESS) { | 554 | if (ret == SUCCESS) { |
| 553 | spin_unlock(&ha->hardware_lock); | ||
| 554 | if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { | 555 | if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { |
| 555 | qla_printk(KERN_ERR, ha, | 556 | qla_printk(KERN_ERR, ha, |
| 556 | "scsi(%ld:%d:%d): Abort handler timed out -- %lx " | 557 | "scsi(%ld:%d:%d): Abort handler timed out -- %lx " |
| 557 | "%x.\n", ha->host_no, id, lun, serial, ret); | 558 | "%x.\n", ha->host_no, id, lun, serial, ret); |
| 558 | } | 559 | } |
| 559 | spin_lock(&ha->hardware_lock); | ||
| 560 | } | 560 | } |
| 561 | spin_lock_irq(ha->host->host_lock); | 561 | spin_lock_irq(ha->host->host_lock); |
| 562 | 562 | ||
| @@ -588,6 +588,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) | |||
| 588 | int status; | 588 | int status; |
| 589 | srb_t *sp; | 589 | srb_t *sp; |
| 590 | struct scsi_cmnd *cmd; | 590 | struct scsi_cmnd *cmd; |
| 591 | unsigned long flags; | ||
| 591 | 592 | ||
| 592 | status = 0; | 593 | status = 0; |
| 593 | 594 | ||
| @@ -596,11 +597,11 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) | |||
| 596 | * array | 597 | * array |
| 597 | */ | 598 | */ |
| 598 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 599 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 599 | spin_lock(&ha->hardware_lock); | 600 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 600 | sp = ha->outstanding_cmds[cnt]; | 601 | sp = ha->outstanding_cmds[cnt]; |
| 601 | if (sp) { | 602 | if (sp) { |
| 602 | cmd = sp->cmd; | 603 | cmd = sp->cmd; |
| 603 | spin_unlock(&ha->hardware_lock); | 604 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 604 | if (cmd->device->id == t) { | 605 | if (cmd->device->id == t) { |
| 605 | if (!qla2x00_eh_wait_on_command(ha, cmd)) { | 606 | if (!qla2x00_eh_wait_on_command(ha, cmd)) { |
| 606 | status = 1; | 607 | status = 1; |
| @@ -608,7 +609,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) | |||
| 608 | } | 609 | } |
| 609 | } | 610 | } |
| 610 | } else { | 611 | } else { |
| 611 | spin_unlock(&ha->hardware_lock); | 612 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 612 | } | 613 | } |
| 613 | } | 614 | } |
| 614 | return (status); | 615 | return (status); |
| @@ -740,6 +741,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha) | |||
| 740 | int status; | 741 | int status; |
| 741 | srb_t *sp; | 742 | srb_t *sp; |
| 742 | struct scsi_cmnd *cmd; | 743 | struct scsi_cmnd *cmd; |
| 744 | unsigned long flags; | ||
| 743 | 745 | ||
| 744 | status = 1; | 746 | status = 1; |
| 745 | 747 | ||
| @@ -748,17 +750,17 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha) | |||
| 748 | * array | 750 | * array |
| 749 | */ | 751 | */ |
| 750 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 752 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 751 | spin_lock(&ha->hardware_lock); | 753 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 752 | sp = ha->outstanding_cmds[cnt]; | 754 | sp = ha->outstanding_cmds[cnt]; |
| 753 | if (sp) { | 755 | if (sp) { |
| 754 | cmd = sp->cmd; | 756 | cmd = sp->cmd; |
| 755 | spin_unlock(&ha->hardware_lock); | 757 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 756 | status = qla2x00_eh_wait_on_command(ha, cmd); | 758 | status = qla2x00_eh_wait_on_command(ha, cmd); |
| 757 | if (status == 0) | 759 | if (status == 0) |
| 758 | break; | 760 | break; |
| 759 | } | 761 | } |
| 760 | else { | 762 | else { |
| 761 | spin_unlock(&ha->hardware_lock); | 763 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 762 | } | 764 | } |
| 763 | } | 765 | } |
| 764 | return (status); | 766 | return (status); |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index cca772624ae7..8d0d302844a1 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
| @@ -1197,6 +1197,7 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, | |||
| 1197 | if (!starget) | 1197 | if (!starget) |
| 1198 | return ERR_PTR(-ENOMEM); | 1198 | return ERR_PTR(-ENOMEM); |
| 1199 | 1199 | ||
| 1200 | get_device(&starget->dev); | ||
| 1200 | down(&shost->scan_mutex); | 1201 | down(&shost->scan_mutex); |
| 1201 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); | 1202 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); |
| 1202 | if (res != SCSI_SCAN_LUN_PRESENT) | 1203 | if (res != SCSI_SCAN_LUN_PRESENT) |
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index 5d2ceb623e6f..1f985327b0d4 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c | |||
| @@ -234,7 +234,7 @@ static inline const char *siu_type_name(struct uart_port *port) | |||
| 234 | return "DSIU"; | 234 | return "DSIU"; |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | return "unknown"; | 237 | return NULL; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | static unsigned int siu_tx_empty(struct uart_port *port) | 240 | static unsigned int siu_tx_empty(struct uart_port *port) |
| @@ -482,9 +482,6 @@ static irqreturn_t siu_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
| 482 | struct uart_port *port; | 482 | struct uart_port *port; |
| 483 | uint8_t iir, lsr; | 483 | uint8_t iir, lsr; |
| 484 | 484 | ||
| 485 | if (dev_id == NULL) | ||
| 486 | return IRQ_NONE; | ||
| 487 | |||
| 488 | port = (struct uart_port *)dev_id; | 485 | port = (struct uart_port *)dev_id; |
| 489 | 486 | ||
| 490 | iir = siu_read(port, UART_IIR); | 487 | iir = siu_read(port, UART_IIR); |
| @@ -507,6 +504,9 @@ static int siu_startup(struct uart_port *port) | |||
| 507 | { | 504 | { |
| 508 | int retval; | 505 | int retval; |
| 509 | 506 | ||
| 507 | if (port->membase == NULL) | ||
| 508 | return -ENODEV; | ||
| 509 | |||
| 510 | siu_clear_fifo(port); | 510 | siu_clear_fifo(port); |
| 511 | 511 | ||
| 512 | (void)siu_read(port, UART_LSR); | 512 | (void)siu_read(port, UART_LSR); |
| @@ -545,9 +545,6 @@ static void siu_shutdown(struct uart_port *port) | |||
| 545 | unsigned long flags; | 545 | unsigned long flags; |
| 546 | uint8_t lcr; | 546 | uint8_t lcr; |
| 547 | 547 | ||
| 548 | if (port->membase == NULL) | ||
| 549 | return; | ||
| 550 | |||
| 551 | siu_write(port, UART_IER, 0); | 548 | siu_write(port, UART_IER, 0); |
| 552 | 549 | ||
| 553 | spin_lock_irqsave(&port->lock, flags); | 550 | spin_lock_irqsave(&port->lock, flags); |
| @@ -802,53 +799,6 @@ static int siu_init_ports(void) | |||
| 802 | 799 | ||
| 803 | #ifdef CONFIG_SERIAL_VR41XX_CONSOLE | 800 | #ifdef CONFIG_SERIAL_VR41XX_CONSOLE |
| 804 | 801 | ||
| 805 | static void early_set_termios(struct uart_port *port, struct termios *new, | ||
| 806 | struct termios *old) | ||
| 807 | { | ||
| 808 | tcflag_t c_cflag; | ||
| 809 | uint8_t lcr; | ||
| 810 | unsigned int baud, quot; | ||
| 811 | |||
| 812 | c_cflag = new->c_cflag; | ||
| 813 | switch (c_cflag & CSIZE) { | ||
| 814 | case CS5: | ||
| 815 | lcr = UART_LCR_WLEN5; | ||
| 816 | break; | ||
| 817 | case CS6: | ||
| 818 | lcr = UART_LCR_WLEN6; | ||
| 819 | break; | ||
| 820 | case CS7: | ||
| 821 | lcr = UART_LCR_WLEN7; | ||
| 822 | break; | ||
| 823 | default: | ||
| 824 | lcr = UART_LCR_WLEN8; | ||
| 825 | break; | ||
| 826 | } | ||
| 827 | |||
| 828 | if (c_cflag & CSTOPB) | ||
| 829 | lcr |= UART_LCR_STOP; | ||
| 830 | if (c_cflag & PARENB) | ||
| 831 | lcr |= UART_LCR_PARITY; | ||
| 832 | if ((c_cflag & PARODD) != PARODD) | ||
| 833 | lcr |= UART_LCR_EPAR; | ||
| 834 | if (c_cflag & CMSPAR) | ||
| 835 | lcr |= UART_LCR_SPAR; | ||
| 836 | |||
| 837 | baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); | ||
| 838 | quot = uart_get_divisor(port, baud); | ||
| 839 | |||
| 840 | siu_write(port, UART_LCR, lcr | UART_LCR_DLAB); | ||
| 841 | |||
| 842 | siu_write(port, UART_DLL, (uint8_t)quot); | ||
| 843 | siu_write(port, UART_DLM, (uint8_t)(quot >> 8)); | ||
| 844 | |||
| 845 | siu_write(port, UART_LCR, lcr); | ||
| 846 | } | ||
| 847 | |||
| 848 | static struct uart_ops early_uart_ops = { | ||
| 849 | .set_termios = early_set_termios, | ||
| 850 | }; | ||
| 851 | |||
| 852 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | 802 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) |
| 853 | 803 | ||
| 854 | static void wait_for_xmitr(struct uart_port *port) | 804 | static void wait_for_xmitr(struct uart_port *port) |
| @@ -915,7 +865,7 @@ static int siu_console_setup(struct console *con, char *options) | |||
| 915 | if (port->membase == NULL) { | 865 | if (port->membase == NULL) { |
| 916 | if (port->mapbase == 0) | 866 | if (port->mapbase == 0) |
| 917 | return -ENODEV; | 867 | return -ENODEV; |
| 918 | port->membase = (unsigned char __iomem *)KSEG1ADDR(port->mapbase); | 868 | port->membase = ioremap(port->mapbase, siu_port_size(port)); |
| 919 | } | 869 | } |
| 920 | 870 | ||
| 921 | vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); | 871 | vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); |
| @@ -949,7 +899,7 @@ static int __devinit siu_console_init(void) | |||
| 949 | 899 | ||
| 950 | for (i = 0; i < num; i++) { | 900 | for (i = 0; i < num; i++) { |
| 951 | port = &siu_uart_ports[i]; | 901 | port = &siu_uart_ports[i]; |
| 952 | port->ops = &early_uart_ops; | 902 | port->ops = &siu_uart_ops; |
| 953 | } | 903 | } |
| 954 | 904 | ||
| 955 | register_console(&siu_console); | 905 | register_console(&siu_console); |
| @@ -994,8 +944,10 @@ static int siu_probe(struct device *dev) | |||
| 994 | port->dev = dev; | 944 | port->dev = dev; |
| 995 | 945 | ||
| 996 | retval = uart_add_one_port(&siu_uart_driver, port); | 946 | retval = uart_add_one_port(&siu_uart_driver, port); |
| 997 | if (retval) | 947 | if (retval < 0) { |
| 948 | port->dev = NULL; | ||
| 998 | break; | 949 | break; |
| 950 | } | ||
| 999 | } | 951 | } |
| 1000 | 952 | ||
| 1001 | if (i == 0 && retval < 0) { | 953 | if (i == 0 && retval < 0) { |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 4ab50009291d..4d0c9e65cd03 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
| @@ -290,32 +290,30 @@ static ssize_t show_modalias(struct device *dev, char *buf) | |||
| 290 | { | 290 | { |
| 291 | struct usb_interface *intf; | 291 | struct usb_interface *intf; |
| 292 | struct usb_device *udev; | 292 | struct usb_device *udev; |
| 293 | int len; | ||
| 293 | 294 | ||
| 294 | intf = to_usb_interface(dev); | 295 | intf = to_usb_interface(dev); |
| 295 | udev = interface_to_usbdev(intf); | 296 | udev = interface_to_usbdev(intf); |
| 296 | if (udev->descriptor.bDeviceClass == 0) { | ||
| 297 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
| 298 | 297 | ||
| 299 | return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n", | 298 | len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic", |
| 300 | le16_to_cpu(udev->descriptor.idVendor), | 299 | le16_to_cpu(udev->descriptor.idVendor), |
| 301 | le16_to_cpu(udev->descriptor.idProduct), | 300 | le16_to_cpu(udev->descriptor.idProduct), |
| 302 | le16_to_cpu(udev->descriptor.bcdDevice), | 301 | le16_to_cpu(udev->descriptor.bcdDevice), |
| 303 | udev->descriptor.bDeviceClass, | 302 | udev->descriptor.bDeviceClass, |
| 304 | udev->descriptor.bDeviceSubClass, | 303 | udev->descriptor.bDeviceSubClass, |
| 305 | udev->descriptor.bDeviceProtocol, | 304 | udev->descriptor.bDeviceProtocol); |
| 305 | buf += len; | ||
| 306 | |||
| 307 | if (udev->descriptor.bDeviceClass == 0) { | ||
| 308 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
| 309 | |||
| 310 | return len + sprintf(buf, "%02Xisc%02Xip%02X\n", | ||
| 306 | alt->desc.bInterfaceClass, | 311 | alt->desc.bInterfaceClass, |
| 307 | alt->desc.bInterfaceSubClass, | 312 | alt->desc.bInterfaceSubClass, |
| 308 | alt->desc.bInterfaceProtocol); | 313 | alt->desc.bInterfaceProtocol); |
| 309 | } else { | 314 | } else { |
| 310 | return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n", | 315 | return len + sprintf(buf, "*isc*ip*\n"); |
| 311 | le16_to_cpu(udev->descriptor.idVendor), | ||
| 312 | le16_to_cpu(udev->descriptor.idProduct), | ||
| 313 | le16_to_cpu(udev->descriptor.bcdDevice), | ||
| 314 | udev->descriptor.bDeviceClass, | ||
| 315 | udev->descriptor.bDeviceSubClass, | ||
| 316 | udev->descriptor.bDeviceProtocol); | ||
| 317 | } | 316 | } |
| 318 | |||
| 319 | } | 317 | } |
| 320 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 318 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
| 321 | 319 | ||
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 869ff73690ac..2d8bd9dcc6ed 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
| @@ -1315,6 +1315,8 @@ void hid_init_reports(struct hid_device *hid) | |||
| 1315 | #define USB_DEVICE_ID_WACOM_INTUOS2 0x0040 | 1315 | #define USB_DEVICE_ID_WACOM_INTUOS2 0x0040 |
| 1316 | #define USB_DEVICE_ID_WACOM_VOLITO 0x0060 | 1316 | #define USB_DEVICE_ID_WACOM_VOLITO 0x0060 |
| 1317 | #define USB_DEVICE_ID_WACOM_PTU 0x0003 | 1317 | #define USB_DEVICE_ID_WACOM_PTU 0x0003 |
| 1318 | #define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 | ||
| 1319 | #define USB_DEVICE_ID_WACOM_CINTIQ 0x003F | ||
| 1318 | 1320 | ||
| 1319 | #define USB_VENDOR_ID_KBGEAR 0x084e | 1321 | #define USB_VENDOR_ID_KBGEAR 0x084e |
| 1320 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 | 1322 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 |
| @@ -1401,6 +1403,7 @@ void hid_init_reports(struct hid_device *hid) | |||
| 1401 | 1403 | ||
| 1402 | #define USB_VENDOR_ID_DELORME 0x1163 | 1404 | #define USB_VENDOR_ID_DELORME 0x1163 |
| 1403 | #define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 | 1405 | #define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 |
| 1406 | #define USB_DEVICE_ID_DELORME_EM_LT20 0x0200 | ||
| 1404 | 1407 | ||
| 1405 | #define USB_VENDOR_ID_MCC 0x09db | 1408 | #define USB_VENDOR_ID_MCC 0x09db |
| 1406 | #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 | 1409 | #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 |
| @@ -1412,6 +1415,12 @@ void hid_init_reports(struct hid_device *hid) | |||
| 1412 | #define USB_VENDOR_ID_BTC 0x046e | 1415 | #define USB_VENDOR_ID_BTC 0x046e |
| 1413 | #define USB_DEVICE_ID_BTC_KEYBOARD 0x5303 | 1416 | #define USB_DEVICE_ID_BTC_KEYBOARD 0x5303 |
| 1414 | 1417 | ||
| 1418 | #define USB_VENDOR_ID_VERNIER 0x08f7 | ||
| 1419 | #define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 | ||
| 1420 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 | ||
| 1421 | #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 | ||
| 1422 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 | ||
| 1423 | |||
| 1415 | 1424 | ||
| 1416 | /* | 1425 | /* |
| 1417 | * Alphabetically sorted blacklist by quirk type. | 1426 | * Alphabetically sorted blacklist by quirk type. |
| @@ -1437,6 +1446,7 @@ static struct hid_blacklist { | |||
| 1437 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, | 1446 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, |
| 1438 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, | 1447 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, |
| 1439 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, | 1448 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, |
| 1449 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, | ||
| 1440 | { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, | 1450 | { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, |
| 1441 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, | 1451 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, |
| 1442 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, | 1452 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, |
| @@ -1456,6 +1466,10 @@ static struct hid_blacklist { | |||
| 1456 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE }, | 1466 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE }, |
| 1457 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, | 1467 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, |
| 1458 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE }, | 1468 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE }, |
| 1469 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO, HID_QUIRK_IGNORE }, | ||
| 1470 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE }, | ||
| 1471 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE }, | ||
| 1472 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, | ||
| 1459 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PENPARTNER, HID_QUIRK_IGNORE }, | 1473 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PENPARTNER, HID_QUIRK_IGNORE }, |
| 1460 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE, HID_QUIRK_IGNORE }, | 1474 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE, HID_QUIRK_IGNORE }, |
| 1461 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 1, HID_QUIRK_IGNORE }, | 1475 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 1, HID_QUIRK_IGNORE }, |
| @@ -1481,6 +1495,10 @@ static struct hid_blacklist { | |||
| 1481 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, | 1495 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, |
| 1482 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, | 1496 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, |
| 1483 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, | 1497 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, |
| 1498 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3, HID_QUIRK_IGNORE }, | ||
| 1499 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 1, HID_QUIRK_IGNORE }, | ||
| 1500 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 2, HID_QUIRK_IGNORE }, | ||
| 1501 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_CINTIQ, HID_QUIRK_IGNORE }, | ||
| 1484 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1502 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
| 1485 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1503 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
| 1486 | 1504 | ||
diff --git a/drivers/usb/media/pwc/ChangeLog b/drivers/usb/media/pwc/ChangeLog deleted file mode 100644 index b2eb71a9afb5..000000000000 --- a/drivers/usb/media/pwc/ChangeLog +++ /dev/null | |||
| @@ -1,143 +0,0 @@ | |||
| 1 | 9.0.2 | ||
| 2 | |||
| 3 | * Adding #ifdef to compile PWC before and after 2.6.5 | ||
| 4 | |||
| 5 | 9.0.1 | ||
| 6 | |||
| 7 | 9.0 | ||
| 8 | |||
| 9 | |||
| 10 | 8.12 | ||
| 11 | |||
| 12 | * Implement motorized pan/tilt feature for Logitech QuickCam Orbit/Spere. | ||
| 13 | |||
| 14 | 8.11.1 | ||
| 15 | |||
| 16 | * Fix for PCVC720/40, would not be able to set videomode | ||
| 17 | * Fix for Samsung MPC models, appearantly they are based on a newer chipset | ||
| 18 | |||
| 19 | 8.11 | ||
| 20 | |||
| 21 | * 20 dev_hints (per request) | ||
| 22 | * Hot unplugging should be better, no more dangling pointers or memory leaks | ||
| 23 | * Added reserved Logitech webcam IDs | ||
| 24 | * Device now remembers size & fps between close()/open() | ||
| 25 | * Removed palette stuff altogether | ||
| 26 | |||
| 27 | 8.10.1 | ||
| 28 | |||
| 29 | * Added IDs for PCVC720K/40 and Creative Labs Webcam Pro | ||
| 30 | |||
| 31 | 8.10 | ||
| 32 | |||
| 33 | * Fixed ID for QuickCam Notebook pro | ||
| 34 | * Added GREALSIZE ioctl() call | ||
| 35 | * Fixed bug in case PWCX was not loaded and invalid size was set | ||
| 36 | |||
| 37 | 8.9 | ||
| 38 | |||
| 39 | * Merging with kernel 2.5.49 | ||
| 40 | * Adding IDs for QuickCam Zoom & QuickCam Notebook | ||
| 41 | |||
| 42 | 8.8 | ||
| 43 | |||
| 44 | * Fixing 'leds' parameter | ||
| 45 | * Adding IDs for Logitech QuickCam Pro 4000 | ||
| 46 | * Making URB init/cleanup a little nicer | ||
| 47 | |||
| 48 | 8.7 | ||
| 49 | |||
| 50 | * Incorporating changes in ioctl() parameter passing | ||
| 51 | * Also changes to URB mechanism | ||
| 52 | |||
| 53 | 8.6 | ||
| 54 | |||
| 55 | * Added ID's for Visionite VCS UM100 and UC300 | ||
| 56 | * Removed YUV420-interlaced palette altogether (was confusing) | ||
| 57 | * Removed MIRROR stuff as it didn't work anyway | ||
| 58 | * Fixed a problem with the 'leds' parameter (wouldn't blink) | ||
| 59 | * Added ioctl()s for advanced features: 'extended' whitebalance ioctl()s, | ||
| 60 | CONTOUR, BACKLIGHT, FLICKER, DYNNOISE. | ||
| 61 | * VIDIOCGCAP.name now contains real camera model name instead of | ||
| 62 | 'Philips xxx webcam' | ||
| 63 | * Added PROBE ioctl (see previous point & API doc) | ||
| 64 | |||
| 65 | 8.5 | ||
| 66 | |||
| 67 | * Adding IDs for Creative Labs Webcam 5 | ||
| 68 | * Adding IDs for SOTEC CMS-001 webcam | ||
| 69 | * Solving possible hang in VIDIOCSYNC when unplugging the cam | ||
| 70 | * Forgot to return structure in VIDIOCPWCGAWB, oops | ||
| 71 | * Time interval for the LEDs are now in milliseconds | ||
| 72 | |||
| 73 | 8.4 | ||
| 74 | |||
| 75 | * Fixing power_save option for Vesta range | ||
| 76 | * Handling new error codes in ISOC callback | ||
| 77 | * Adding dev_hint module parameter, to specify /dev/videoX device nodes | ||
| 78 | |||
| 79 | 8.3 | ||
| 80 | |||
| 81 | * Adding Samsung C10 and C30 cameras | ||
| 82 | * Removing palette module parameter | ||
| 83 | * Fixed typo in ID of QuickCam 3000 Pro | ||
| 84 | * Adding LED settings (blinking while in use) for ToUCam cameras. | ||
| 85 | * Turns LED off when camera is not in use. | ||
| 86 | |||
| 87 | 8.2 | ||
| 88 | |||
| 89 | * Making module more silent when trace = 0 | ||
| 90 | * Adding QuickCam 3000 Pro IDs | ||
| 91 | * Chrominance control for the Vesta cameras | ||
| 92 | * Hopefully fixed problems on machines with BIGMEM and > 1GB of RAM | ||
| 93 | * Included Oliver Neukem's lock_kernel() patch | ||
| 94 | * Allocates less memory for image buffers | ||
| 95 | * Adds ioctl()s for the whitebalancing | ||
| 96 | |||
| 97 | 8.1 | ||
| 98 | |||
| 99 | * Adding support for 750 | ||
| 100 | * Adding V4L GAUDIO/SAUDIO/UNIT ioctl() calls | ||
| 101 | |||
| 102 | 8.0 | ||
| 103 | * 'damage control' after inclusion in 2.4.5. | ||
| 104 | * Changed wait-queue mechanism in read/mmap/poll according to the book. | ||
| 105 | * Included YUV420P palette. | ||
| 106 | * Changed interface to decompressor module. | ||
| 107 | * Cleaned up pwc structure a bit. | ||
| 108 | |||
| 109 | 7.0 | ||
| 110 | |||
| 111 | * Fixed bug in vcvt_420i_yuyv; extra variables on stack were misaligned. | ||
| 112 | * There is now a clear error message when an image size is selected that | ||
| 113 | is only supported using the decompressor, and the decompressor isn't | ||
| 114 | loaded. | ||
| 115 | * When the decompressor wasn't loaded, selecting large image size | ||
| 116 | would create skewed or double images. | ||
| 117 | |||
| 118 | 6.3 | ||
| 119 | |||
| 120 | * Introduced spinlocks for the buffer pointer manipulation; a number of | ||
| 121 | reports seem to suggest the down()/up() semaphores were the cause of | ||
| 122 | lockups, since they are not suitable for interrupt/user locking. | ||
| 123 | * Separated decompressor and core code into 2 modules. | ||
| 124 | |||
| 125 | 6.2 | ||
| 126 | |||
| 127 | * Non-integral image sizes are now padded with gray or black. | ||
| 128 | * Added SHUTTERSPEED ioctl(). | ||
| 129 | * Fixed buglet in VIDIOCPWCSAGC; the function would always return an error, | ||
| 130 | even though the call succeeded. | ||
| 131 | * Added hotplug support for 2.4.*. | ||
| 132 | * Memory: the 645/646 uses less memory now. | ||
| 133 | |||
| 134 | 6.1 | ||
| 135 | |||
| 136 | * VIDIOCSPICT returns -EINVAL with invalid palettes. | ||
| 137 | * Added saturation control. | ||
| 138 | * Split decompressors from rest. | ||
| 139 | * Fixed bug that would reset the framerate to the default framerate if | ||
| 140 | the rate field was set to 0 (which is not what I intended, nl. do not | ||
| 141 | change the framerate!). | ||
| 142 | * VIDIOCPWCSCQUAL (setting compression quality) now takes effect immediately. | ||
| 143 | * Workaround for a bug in the 730 sensor. | ||
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 85476e76b244..4cbb408af727 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
| @@ -2765,7 +2765,7 @@ static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf) | |||
| 2765 | } | 2765 | } |
| 2766 | /* expect bcdVersion 1.0, ignore */ | 2766 | /* expect bcdVersion 1.0, ignore */ |
| 2767 | if (memcmp(&desc->bGUID, blan_guid, 16) | 2767 | if (memcmp(&desc->bGUID, blan_guid, 16) |
| 2768 | && memcmp(&desc->bGUID, blan_guid, 16) ) { | 2768 | && memcmp(&desc->bGUID, safe_guid, 16) ) { |
| 2769 | /* hey, this one might _really_ be MDLM! */ | 2769 | /* hey, this one might _really_ be MDLM! */ |
| 2770 | dev_dbg (&intf->dev, "MDLM guid\n"); | 2770 | dev_dbg (&intf->dev, "MDLM guid\n"); |
| 2771 | goto bad_desc; | 2771 | goto bad_desc; |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index bc798edf0358..9438909e87a5 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
| @@ -455,6 +455,17 @@ config USB_SERIAL_XIRCOM | |||
| 455 | To compile this driver as a module, choose M here: the | 455 | To compile this driver as a module, choose M here: the |
| 456 | module will be called keyspan_pda. | 456 | module will be called keyspan_pda. |
| 457 | 457 | ||
| 458 | config USB_SERIAL_OPTION | ||
| 459 | tristate "USB Option PCMCIA serial driver" | ||
| 460 | depends on USB_SERIAL && USB_OHCI_HCD && PCCARD | ||
| 461 | help | ||
| 462 | Say Y here if you want to use an Option card. This is a | ||
| 463 | GSM card, controlled by three serial ports which are connected | ||
| 464 | via an OHCI adapter located on a PC card. | ||
| 465 | |||
| 466 | To compile this driver as a module, choose M here: the | ||
| 467 | module will be called option. | ||
| 468 | |||
| 458 | config USB_SERIAL_OMNINET | 469 | config USB_SERIAL_OMNINET |
| 459 | tristate "USB ZyXEL omni.net LCD Plus Driver (EXPERIMENTAL)" | 470 | tristate "USB ZyXEL omni.net LCD Plus Driver (EXPERIMENTAL)" |
| 460 | depends on USB_SERIAL && EXPERIMENTAL | 471 | depends on USB_SERIAL && EXPERIMENTAL |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index d56ff6d86cce..6c7cdcc99a9e 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
| @@ -32,6 +32,7 @@ obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o | |||
| 32 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o | 32 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o |
| 33 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o | 33 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o |
| 34 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o | 34 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o |
| 35 | obj-$(CONFIG_USB_SERIAL_OPTION) += option.o | ||
| 35 | obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o | 36 | obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o |
| 36 | obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o | 37 | obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o |
| 37 | obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o | 38 | obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 7e9bb63eb466..4ace9964fc6b 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
| @@ -7,6 +7,14 @@ | |||
| 7 | * modify it under the terms of the GNU General Public License version | 7 | * modify it under the terms of the GNU General Public License version |
| 8 | * 2 as published by the Free Software Foundation. | 8 | * 2 as published by the Free Software Foundation. |
| 9 | * | 9 | * |
| 10 | * Support to set flow control line levels using TIOCMGET and TIOCMSET | ||
| 11 | * thanks to Karl Hiramoto karl@hiramoto.org. RTSCTS hardware flow | ||
| 12 | * control thanks to Munir Nassar nassarmu@real-time.com | ||
| 13 | * | ||
| 14 | * Outstanding Issues: | ||
| 15 | * Buffers are not flushed when the port is opened. | ||
| 16 | * Multiple calls to write() may fail with "Resource temporarily unavailable" | ||
| 17 | * | ||
| 10 | */ | 18 | */ |
| 11 | 19 | ||
| 12 | #include <linux/config.h> | 20 | #include <linux/config.h> |
| @@ -24,7 +32,7 @@ | |||
| 24 | /* | 32 | /* |
| 25 | * Version Information | 33 | * Version Information |
| 26 | */ | 34 | */ |
| 27 | #define DRIVER_VERSION "v0.03" | 35 | #define DRIVER_VERSION "v0.04" |
| 28 | #define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver" | 36 | #define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver" |
| 29 | 37 | ||
| 30 | /* | 38 | /* |
| @@ -35,6 +43,9 @@ static void cp2101_cleanup(struct usb_serial_port*); | |||
| 35 | static void cp2101_close(struct usb_serial_port*, struct file*); | 43 | static void cp2101_close(struct usb_serial_port*, struct file*); |
| 36 | static void cp2101_get_termios(struct usb_serial_port*); | 44 | static void cp2101_get_termios(struct usb_serial_port*); |
| 37 | static void cp2101_set_termios(struct usb_serial_port*, struct termios*); | 45 | static void cp2101_set_termios(struct usb_serial_port*, struct termios*); |
| 46 | static int cp2101_tiocmget (struct usb_serial_port *, struct file *); | ||
| 47 | static int cp2101_tiocmset (struct usb_serial_port *, struct file *, | ||
| 48 | unsigned int, unsigned int); | ||
| 38 | static void cp2101_break_ctl(struct usb_serial_port*, int); | 49 | static void cp2101_break_ctl(struct usb_serial_port*, int); |
| 39 | static int cp2101_startup (struct usb_serial *); | 50 | static int cp2101_startup (struct usb_serial *); |
| 40 | static void cp2101_shutdown(struct usb_serial*); | 51 | static void cp2101_shutdown(struct usb_serial*); |
| @@ -43,9 +54,10 @@ static void cp2101_shutdown(struct usb_serial*); | |||
| 43 | static int debug; | 54 | static int debug; |
| 44 | 55 | ||
| 45 | static struct usb_device_id id_table [] = { | 56 | static struct usb_device_id id_table [] = { |
| 46 | {USB_DEVICE(0x10c4, 0xea60) }, /*Silicon labs factory default*/ | 57 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
| 47 | {USB_DEVICE(0x10ab, 0x10c5) }, /*Siemens MC60 Cable*/ | 58 | { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ |
| 48 | { } /* Terminating Entry*/ | 59 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ |
| 60 | { } /* Terminating Entry */ | ||
| 49 | }; | 61 | }; |
| 50 | 62 | ||
| 51 | MODULE_DEVICE_TABLE (usb, id_table); | 63 | MODULE_DEVICE_TABLE (usb, id_table); |
| @@ -70,32 +82,35 @@ static struct usb_serial_device_type cp2101_device = { | |||
| 70 | .close = cp2101_close, | 82 | .close = cp2101_close, |
| 71 | .break_ctl = cp2101_break_ctl, | 83 | .break_ctl = cp2101_break_ctl, |
| 72 | .set_termios = cp2101_set_termios, | 84 | .set_termios = cp2101_set_termios, |
| 85 | .tiocmget = cp2101_tiocmget, | ||
| 86 | .tiocmset = cp2101_tiocmset, | ||
| 73 | .attach = cp2101_startup, | 87 | .attach = cp2101_startup, |
| 74 | .shutdown = cp2101_shutdown, | 88 | .shutdown = cp2101_shutdown, |
| 75 | }; | 89 | }; |
| 76 | 90 | ||
| 77 | /*Config request types*/ | 91 | /* Config request types */ |
| 78 | #define REQTYPE_HOST_TO_DEVICE 0x41 | 92 | #define REQTYPE_HOST_TO_DEVICE 0x41 |
| 79 | #define REQTYPE_DEVICE_TO_HOST 0xc1 | 93 | #define REQTYPE_DEVICE_TO_HOST 0xc1 |
| 80 | 94 | ||
| 81 | /*Config SET requests. To GET, add 1 to the request number*/ | 95 | /* Config SET requests. To GET, add 1 to the request number */ |
| 82 | #define CP2101_UART 0x00 /*Enable / Disable*/ | 96 | #define CP2101_UART 0x00 /* Enable / Disable */ |
| 83 | #define CP2101_BAUDRATE 0x01 /*(BAUD_RATE_GEN_FREQ / baudrate)*/ | 97 | #define CP2101_BAUDRATE 0x01 /* (BAUD_RATE_GEN_FREQ / baudrate) */ |
| 84 | #define CP2101_BITS 0x03 /*0x(0)(data bits)(parity)(stop bits)*/ | 98 | #define CP2101_BITS 0x03 /* 0x(0)(databits)(parity)(stopbits) */ |
| 85 | #define CP2101_BREAK 0x05 /*On / Off*/ | 99 | #define CP2101_BREAK 0x05 /* On / Off */ |
| 86 | #define CP2101_DTRRTS 0x07 /*101 / 202 ???*/ | 100 | #define CP2101_CONTROL 0x07 /* Flow control line states */ |
| 87 | #define CP2101_CONFIG_16 0x13 /*16 bytes of config data ???*/ | 101 | #define CP2101_MODEMCTL 0x13 /* Modem controls */ |
| 88 | #define CP2101_CONFIG_6 0x19 /*6 bytes of config data ???*/ | 102 | #define CP2101_CONFIG_6 0x19 /* 6 bytes of config data ??? */ |
| 89 | 103 | ||
| 90 | /*CP2101_UART*/ | 104 | /* CP2101_UART */ |
| 91 | #define UART_ENABLE 0x0001 | 105 | #define UART_ENABLE 0x0001 |
| 92 | #define UART_DISABLE 0x0000 | 106 | #define UART_DISABLE 0x0000 |
| 93 | 107 | ||
| 94 | /*CP2101_BAUDRATE*/ | 108 | /* CP2101_BAUDRATE */ |
| 95 | #define BAUD_RATE_GEN_FREQ 0x384000 | 109 | #define BAUD_RATE_GEN_FREQ 0x384000 |
| 96 | 110 | ||
| 97 | /*CP2101_BITS*/ | 111 | /* CP2101_BITS */ |
| 98 | #define BITS_DATA_MASK 0X0f00 | 112 | #define BITS_DATA_MASK 0X0f00 |
| 113 | #define BITS_DATA_5 0X0500 | ||
| 99 | #define BITS_DATA_6 0X0600 | 114 | #define BITS_DATA_6 0X0600 |
| 100 | #define BITS_DATA_7 0X0700 | 115 | #define BITS_DATA_7 0X0700 |
| 101 | #define BITS_DATA_8 0X0800 | 116 | #define BITS_DATA_8 0X0800 |
| @@ -112,64 +127,137 @@ static struct usb_serial_device_type cp2101_device = { | |||
| 112 | #define BITS_STOP_1 0x0000 | 127 | #define BITS_STOP_1 0x0000 |
| 113 | #define BITS_STOP_1_5 0x0001 | 128 | #define BITS_STOP_1_5 0x0001 |
| 114 | #define BITS_STOP_2 0x0002 | 129 | #define BITS_STOP_2 0x0002 |
| 130 | |||
| 131 | /* CP2101_BREAK */ | ||
| 115 | #define BREAK_ON 0x0000 | 132 | #define BREAK_ON 0x0000 |
| 116 | #define BREAK_OFF 0x0001 | 133 | #define BREAK_OFF 0x0001 |
| 117 | 134 | ||
| 135 | /* CP2101_CONTROL */ | ||
| 136 | #define CONTROL_DTR 0x0001 | ||
| 137 | #define CONTROL_RTS 0x0002 | ||
| 138 | #define CONTROL_CTS 0x0010 | ||
| 139 | #define CONTROL_DSR 0x0020 | ||
| 140 | #define CONTROL_RING 0x0040 | ||
| 141 | #define CONTROL_DCD 0x0080 | ||
| 142 | #define CONTROL_WRITE_DTR 0x0100 | ||
| 143 | #define CONTROL_WRITE_RTS 0x0200 | ||
| 118 | 144 | ||
| 119 | static int cp2101_get_config(struct usb_serial_port* port, u8 request) | 145 | /* |
| 146 | * cp2101_get_config | ||
| 147 | * Reads from the CP2101 configuration registers | ||
| 148 | * 'size' is specified in bytes. | ||
| 149 | * 'data' is a pointer to a pre-allocated array of integers large | ||
| 150 | * enough to hold 'size' bytes (with 4 bytes to each integer) | ||
| 151 | */ | ||
| 152 | static int cp2101_get_config(struct usb_serial_port* port, u8 request, | ||
| 153 | unsigned int *data, int size) | ||
| 120 | { | 154 | { |
| 121 | struct usb_serial *serial = port->serial; | 155 | struct usb_serial *serial = port->serial; |
| 122 | unsigned char buf[4]; | 156 | u32 *buf; |
| 123 | unsigned int value; | 157 | int result, i, length; |
| 124 | int result, i; | 158 | |
| 159 | /* Number of integers required to contain the array */ | ||
| 160 | length = (((size - 1) | 3) + 1)/4; | ||
| 161 | |||
| 162 | buf = kmalloc (length * sizeof(u32), GFP_KERNEL); | ||
| 163 | memset(buf, 0, length * sizeof(u32)); | ||
| 164 | |||
| 165 | if (!buf) { | ||
| 166 | dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); | ||
| 167 | return -ENOMEM; | ||
| 168 | } | ||
| 125 | 169 | ||
| 126 | /*For get requests, the request number must be incremented*/ | 170 | /* For get requests, the request number must be incremented */ |
| 127 | request++; | 171 | request++; |
| 128 | 172 | ||
| 129 | /*Issue the request, attempting to read 4 bytes*/ | 173 | /* Issue the request, attempting to read 'size' bytes */ |
| 130 | result = usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev, 0), | 174 | result = usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev, 0), |
| 131 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, | 175 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, |
| 132 | 0, buf, 4, 300); | 176 | 0, buf, size, 300); |
| 133 | 177 | ||
| 134 | if (result < 0) { | 178 | /* Convert data into an array of integers */ |
| 135 | dev_err(&port->dev, "%s - Unable to send config request, " | 179 | for (i=0; i<length; i++) |
| 136 | "request=0x%x result=%d\n", | 180 | data[i] = le32_to_cpu(buf[i]); |
| 137 | __FUNCTION__, request, result); | ||
| 138 | return result; | ||
| 139 | } | ||
| 140 | 181 | ||
| 141 | /*Assemble each byte read into an integer value*/ | 182 | kfree(buf); |
| 142 | value = 0; | ||
| 143 | for (i=0; i<4 && i<result; i++) | ||
| 144 | value |= (buf[i] << (i * 8)); | ||
| 145 | 183 | ||
| 146 | dbg( " %s - request=0x%x result=%d value=0x%x", | 184 | if (result != size) { |
| 147 | __FUNCTION__, request, result, value); | 185 | dev_err(&port->dev, "%s - Unable to send config request, " |
| 186 | "request=0x%x size=%d result=%d\n", | ||
| 187 | __FUNCTION__, request, size, result); | ||
| 188 | return -EPROTO; | ||
| 189 | } | ||
| 148 | 190 | ||
| 149 | return value; | 191 | return 0; |
| 150 | } | 192 | } |
| 151 | 193 | ||
| 152 | static int cp2101_set_config(struct usb_serial_port* port, u8 request, u16 value) | 194 | /* |
| 195 | * cp2101_set_config | ||
| 196 | * Writes to the CP2101 configuration registers | ||
| 197 | * Values less than 16 bits wide are sent directly | ||
| 198 | * 'size' is specified in bytes. | ||
| 199 | */ | ||
| 200 | static int cp2101_set_config(struct usb_serial_port* port, u8 request, | ||
| 201 | unsigned int *data, int size) | ||
| 153 | { | 202 | { |
| 154 | struct usb_serial *serial = port->serial; | 203 | struct usb_serial *serial = port->serial; |
| 155 | int result; | 204 | u32 *buf; |
| 156 | result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), | 205 | int result, i, length; |
| 157 | request, REQTYPE_HOST_TO_DEVICE, value, | ||
| 158 | 0, NULL, 0, 300); | ||
| 159 | 206 | ||
| 160 | if (result <0) { | 207 | /* Number of integers required to contain the array */ |
| 161 | dev_err(&port->dev, "%s - Unable to send config request, " | 208 | length = (((size - 1) | 3) + 1)/4; |
| 162 | "request=0x%x value=0x%x result=%d\n", | 209 | |
| 163 | __FUNCTION__, request, value, result); | 210 | buf = kmalloc(length * sizeof(u32), GFP_KERNEL); |
| 164 | return result; | 211 | if (!buf) { |
| 212 | dev_err(&port->dev, "%s - out of memory.\n", | ||
| 213 | __FUNCTION__); | ||
| 214 | return -ENOMEM; | ||
| 215 | } | ||
| 216 | |||
| 217 | /* Array of integers into bytes */ | ||
| 218 | for (i = 0; i < length; i++) | ||
| 219 | buf[i] = cpu_to_le32(data[i]); | ||
| 220 | |||
| 221 | if (size > 2) { | ||
| 222 | result = usb_control_msg (serial->dev, | ||
| 223 | usb_sndctrlpipe(serial->dev, 0), | ||
| 224 | request, REQTYPE_HOST_TO_DEVICE, 0x0000, | ||
| 225 | 0, buf, size, 300); | ||
| 226 | } else { | ||
| 227 | result = usb_control_msg (serial->dev, | ||
| 228 | usb_sndctrlpipe(serial->dev, 0), | ||
| 229 | request, REQTYPE_HOST_TO_DEVICE, data[0], | ||
| 230 | 0, NULL, 0, 300); | ||
| 165 | } | 231 | } |
| 166 | 232 | ||
| 167 | dbg(" %s - request=0x%x value=0x%x result=%d", | 233 | kfree(buf); |
| 168 | __FUNCTION__, request, value, result); | 234 | |
| 235 | if ((size > 2 && result != size) || result < 0) { | ||
| 236 | dev_err(&port->dev, "%s - Unable to send request, " | ||
| 237 | "request=0x%x size=%d result=%d\n", | ||
| 238 | __FUNCTION__, request, size, result); | ||
| 239 | return -EPROTO; | ||
| 240 | } | ||
| 169 | 241 | ||
| 242 | /* Single data value */ | ||
| 243 | result = usb_control_msg (serial->dev, | ||
| 244 | usb_sndctrlpipe(serial->dev, 0), | ||
| 245 | request, REQTYPE_HOST_TO_DEVICE, data[0], | ||
| 246 | 0, NULL, 0, 300); | ||
| 170 | return 0; | 247 | return 0; |
| 171 | } | 248 | } |
| 172 | 249 | ||
| 250 | /* | ||
| 251 | * cp2101_set_config_single | ||
| 252 | * Convenience function for calling cp2101_set_config on single data values | ||
| 253 | * without requiring an integer pointer | ||
| 254 | */ | ||
| 255 | static inline int cp2101_set_config_single(struct usb_serial_port* port, | ||
| 256 | u8 request, unsigned int data) | ||
| 257 | { | ||
| 258 | return cp2101_set_config(port, request, &data, 2); | ||
| 259 | } | ||
| 260 | |||
| 173 | static int cp2101_open (struct usb_serial_port *port, struct file *filp) | 261 | static int cp2101_open (struct usb_serial_port *port, struct file *filp) |
| 174 | { | 262 | { |
| 175 | struct usb_serial *serial = port->serial; | 263 | struct usb_serial *serial = port->serial; |
| @@ -177,7 +265,7 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) | |||
| 177 | 265 | ||
| 178 | dbg("%s - port %d", __FUNCTION__, port->number); | 266 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 179 | 267 | ||
| 180 | if (cp2101_set_config(port, CP2101_UART, UART_ENABLE)) { | 268 | if (cp2101_set_config_single(port, CP2101_UART, UART_ENABLE)) { |
| 181 | dev_err(&port->dev, "%s - Unable to enable UART\n", | 269 | dev_err(&port->dev, "%s - Unable to enable UART\n", |
| 182 | __FUNCTION__); | 270 | __FUNCTION__); |
| 183 | return -EPROTO; | 271 | return -EPROTO; |
| @@ -198,9 +286,12 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) | |||
| 198 | return result; | 286 | return result; |
| 199 | } | 287 | } |
| 200 | 288 | ||
| 201 | /*Configure the termios structure*/ | 289 | /* Configure the termios structure */ |
| 202 | cp2101_get_termios(port); | 290 | cp2101_get_termios(port); |
| 203 | 291 | ||
| 292 | /* Set the DTR and RTS pins low */ | ||
| 293 | cp2101_tiocmset(port, NULL, TIOCM_DTR | TIOCM_RTS, 0); | ||
| 294 | |||
| 204 | return 0; | 295 | return 0; |
| 205 | } | 296 | } |
| 206 | 297 | ||
| @@ -228,16 +319,18 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) | |||
| 228 | usb_kill_urb(port->write_urb); | 319 | usb_kill_urb(port->write_urb); |
| 229 | usb_kill_urb(port->read_urb); | 320 | usb_kill_urb(port->read_urb); |
| 230 | 321 | ||
| 231 | cp2101_set_config(port, CP2101_UART, UART_DISABLE); | 322 | cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); |
| 232 | } | 323 | } |
| 233 | 324 | ||
| 234 | /* cp2101_get_termios*/ | 325 | /* |
| 235 | /* Reads the baud rate, data bits, parity and stop bits from the device*/ | 326 | * cp2101_get_termios |
| 236 | /* Corrects any unsupported values*/ | 327 | * Reads the baud rate, data bits, parity, stop bits and flow control mode |
| 237 | /* Configures the termios structure to reflect the state of the device*/ | 328 | * from the device, corrects any unsupported values, and configures the |
| 329 | * termios structure to reflect the state of the device | ||
| 330 | */ | ||
| 238 | static void cp2101_get_termios (struct usb_serial_port *port) | 331 | static void cp2101_get_termios (struct usb_serial_port *port) |
| 239 | { | 332 | { |
| 240 | unsigned int cflag; | 333 | unsigned int cflag, modem_ctl[4]; |
| 241 | int baud; | 334 | int baud; |
| 242 | int bits; | 335 | int bits; |
| 243 | 336 | ||
| @@ -249,15 +342,16 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
| 249 | } | 342 | } |
| 250 | cflag = port->tty->termios->c_cflag; | 343 | cflag = port->tty->termios->c_cflag; |
| 251 | 344 | ||
| 252 | baud = cp2101_get_config(port, CP2101_BAUDRATE); | 345 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); |
| 253 | /*Convert to baudrate*/ | 346 | /* Convert to baudrate */ |
| 254 | if (baud) | 347 | if (baud) |
| 255 | baud = BAUD_RATE_GEN_FREQ / baud; | 348 | baud = BAUD_RATE_GEN_FREQ / baud; |
| 256 | 349 | ||
| 257 | dbg("%s - baud rate = %d", __FUNCTION__, baud); | 350 | dbg("%s - baud rate = %d", __FUNCTION__, baud); |
| 258 | cflag &= ~CBAUD; | 351 | cflag &= ~CBAUD; |
| 259 | switch (baud) { | 352 | switch (baud) { |
| 260 | /* The baud rates which are commented out below | 353 | /* |
| 354 | * The baud rates which are commented out below | ||
| 261 | * appear to be supported by the device | 355 | * appear to be supported by the device |
| 262 | * but are non-standard | 356 | * but are non-standard |
| 263 | */ | 357 | */ |
| @@ -284,14 +378,18 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
| 284 | dbg("%s - Baud rate is not supported, " | 378 | dbg("%s - Baud rate is not supported, " |
| 285 | "using 9600 baud", __FUNCTION__); | 379 | "using 9600 baud", __FUNCTION__); |
| 286 | cflag |= B9600; | 380 | cflag |= B9600; |
| 287 | cp2101_set_config(port, CP2101_BAUDRATE, | 381 | cp2101_set_config_single(port, CP2101_BAUDRATE, |
| 288 | (BAUD_RATE_GEN_FREQ/9600)); | 382 | (BAUD_RATE_GEN_FREQ/9600)); |
| 289 | break; | 383 | break; |
| 290 | } | 384 | } |
| 291 | 385 | ||
| 292 | bits = cp2101_get_config(port, CP2101_BITS); | 386 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
| 293 | cflag &= ~CSIZE; | 387 | cflag &= ~CSIZE; |
| 294 | switch(bits & BITS_DATA_MASK) { | 388 | switch(bits & BITS_DATA_MASK) { |
| 389 | case BITS_DATA_5: | ||
| 390 | dbg("%s - data bits = 5", __FUNCTION__); | ||
| 391 | cflag |= CS5; | ||
| 392 | break; | ||
| 295 | case BITS_DATA_6: | 393 | case BITS_DATA_6: |
| 296 | dbg("%s - data bits = 6", __FUNCTION__); | 394 | dbg("%s - data bits = 6", __FUNCTION__); |
| 297 | cflag |= CS6; | 395 | cflag |= CS6; |
| @@ -310,7 +408,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
| 310 | cflag |= CS8; | 408 | cflag |= CS8; |
| 311 | bits &= ~BITS_DATA_MASK; | 409 | bits &= ~BITS_DATA_MASK; |
| 312 | bits |= BITS_DATA_8; | 410 | bits |= BITS_DATA_8; |
| 313 | cp2101_set_config(port, CP2101_BITS, bits); | 411 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
| 314 | break; | 412 | break; |
| 315 | default: | 413 | default: |
| 316 | dbg("%s - Unknown number of data bits, " | 414 | dbg("%s - Unknown number of data bits, " |
| @@ -318,7 +416,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
| 318 | cflag |= CS8; | 416 | cflag |= CS8; |
| 319 | bits &= ~BITS_DATA_MASK; | 417 | bits &= ~BITS_DATA_MASK; |
| 320 | bits |= BITS_DATA_8; | 418 | bits |= BITS_DATA_8; |
| 321 | cp2101_set_config(port, CP2101_BITS, bits); | 419 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
| 322 | break; | 420 | break; |
| 323 | } | 421 | } |
| 324 | 422 | ||
| @@ -341,21 +439,21 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
| 341 | "disabling parity)", __FUNCTION__); | 439 | "disabling parity)", __FUNCTION__); |
| 342 | cflag &= ~PARENB; | 440 | cflag &= ~PARENB; |
| 343 | bits &= ~BITS_PARITY_MASK; | 441 | bits &= ~BITS_PARITY_MASK; |
| 344 | cp2101_set_config(port, CP2101_BITS, bits); | 442 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
| 345 | break; | 443 | break; |
| 346 | case BITS_PARITY_SPACE: | 444 | case BITS_PARITY_SPACE: |
| 347 | dbg("%s - parity = SPACE (not supported, " | 445 | dbg("%s - parity = SPACE (not supported, " |
| 348 | "disabling parity)", __FUNCTION__); | 446 | "disabling parity)", __FUNCTION__); |
| 349 | cflag &= ~PARENB; | 447 | cflag &= ~PARENB; |
| 350 | bits &= ~BITS_PARITY_MASK; | 448 | bits &= ~BITS_PARITY_MASK; |
| 351 | cp2101_set_config(port, CP2101_BITS, bits); | 449 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
| 352 | break; | 450 | break; |
| 353 | default: | 451 | default: |
| 354 | dbg("%s - Unknown parity mode, " | 452 | dbg("%s - Unknown parity mode, " |
| 355 | "disabling parity", __FUNCTION__); | 453 | "disabling parity", __FUNCTION__); |
| 356 | cflag &= ~PARENB; | 454 | cflag &= ~PARENB; |
| 357 | bits &= ~BITS_PARITY_MASK; | 455 | bits &= ~BITS_PARITY_MASK; |
| 358 | cp2101_set_config(port, CP2101_BITS, bits); | 456 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
| 359 | break; | 457 | break; |
| 360 | } | 458 | } |
| 361 | 459 | ||
| @@ -366,9 +464,9 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
| 366 | break; | 464 | break; |
| 367 | case BITS_STOP_1_5: | 465 | case BITS_STOP_1_5: |
| 368 | dbg("%s - stop bits = 1.5 (not supported, " | 466 | dbg("%s - stop bits = 1.5 (not supported, " |
| 369 | "using 1 stop bit", __FUNCTION__); | 467 | "using 1 stop bit)", __FUNCTION__); |
| 370 | bits &= ~BITS_STOP_MASK; | 468 | bits &= ~BITS_STOP_MASK; |
| 371 | cp2101_set_config(port, CP2101_BITS, bits); | 469 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
| 372 | break; | 470 | break; |
| 373 | case BITS_STOP_2: | 471 | case BITS_STOP_2: |
| 374 | dbg("%s - stop bits = 2", __FUNCTION__); | 472 | dbg("%s - stop bits = 2", __FUNCTION__); |
| @@ -378,10 +476,19 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
| 378 | dbg("%s - Unknown number of stop bits, " | 476 | dbg("%s - Unknown number of stop bits, " |
| 379 | "using 1 stop bit", __FUNCTION__); | 477 | "using 1 stop bit", __FUNCTION__); |
| 380 | bits &= ~BITS_STOP_MASK; | 478 | bits &= ~BITS_STOP_MASK; |
| 381 | cp2101_set_config(port, CP2101_BITS, bits); | 479 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
| 382 | break; | 480 | break; |
| 383 | } | 481 | } |
| 384 | 482 | ||
| 483 | cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); | ||
| 484 | if (modem_ctl[0] & 0x0008) { | ||
| 485 | dbg("%s - flow control = CRTSCTS", __FUNCTION__); | ||
| 486 | cflag |= CRTSCTS; | ||
| 487 | } else { | ||
| 488 | dbg("%s - flow control = NONE", __FUNCTION__); | ||
| 489 | cflag &= ~CRTSCTS; | ||
| 490 | } | ||
| 491 | |||
| 385 | port->tty->termios->c_cflag = cflag; | 492 | port->tty->termios->c_cflag = cflag; |
| 386 | } | 493 | } |
| 387 | 494 | ||
| @@ -389,8 +496,8 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
| 389 | struct termios *old_termios) | 496 | struct termios *old_termios) |
| 390 | { | 497 | { |
| 391 | unsigned int cflag, old_cflag=0; | 498 | unsigned int cflag, old_cflag=0; |
| 392 | int baud=0; | 499 | int baud=0, bits; |
| 393 | int bits; | 500 | unsigned int modem_ctl[4]; |
| 394 | 501 | ||
| 395 | dbg("%s - port %d", __FUNCTION__, port->number); | 502 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 396 | 503 | ||
| @@ -400,7 +507,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
| 400 | } | 507 | } |
| 401 | cflag = port->tty->termios->c_cflag; | 508 | cflag = port->tty->termios->c_cflag; |
| 402 | 509 | ||
| 403 | /* check that they really want us to change something */ | 510 | /* Check that they really want us to change something */ |
| 404 | if (old_termios) { | 511 | if (old_termios) { |
| 405 | if ((cflag == old_termios->c_cflag) && | 512 | if ((cflag == old_termios->c_cflag) && |
| 406 | (RELEVANT_IFLAG(port->tty->termios->c_iflag) | 513 | (RELEVANT_IFLAG(port->tty->termios->c_iflag) |
| @@ -415,7 +522,8 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
| 415 | /* If the baud rate is to be updated*/ | 522 | /* If the baud rate is to be updated*/ |
| 416 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { | 523 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { |
| 417 | switch (cflag & CBAUD) { | 524 | switch (cflag & CBAUD) { |
| 418 | /* The baud rates which are commented out below | 525 | /* |
| 526 | * The baud rates which are commented out below | ||
| 419 | * appear to be supported by the device | 527 | * appear to be supported by the device |
| 420 | * but are non-standard | 528 | * but are non-standard |
| 421 | */ | 529 | */ |
| @@ -448,18 +556,22 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
| 448 | if (baud) { | 556 | if (baud) { |
| 449 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, | 557 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, |
| 450 | baud); | 558 | baud); |
| 451 | if (cp2101_set_config(port, CP2101_BAUDRATE, | 559 | if (cp2101_set_config_single(port, CP2101_BAUDRATE, |
| 452 | (BAUD_RATE_GEN_FREQ / baud))) | 560 | (BAUD_RATE_GEN_FREQ / baud))) |
| 453 | dev_err(&port->dev, "Baud rate requested not " | 561 | dev_err(&port->dev, "Baud rate requested not " |
| 454 | "supported by device\n"); | 562 | "supported by device\n"); |
| 455 | } | 563 | } |
| 456 | } | 564 | } |
| 457 | 565 | ||
| 458 | /*If the number of data bits is to be updated*/ | 566 | /* If the number of data bits is to be updated */ |
| 459 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { | 567 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { |
| 460 | bits = cp2101_get_config(port, CP2101_BITS); | 568 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
| 461 | bits &= ~BITS_DATA_MASK; | 569 | bits &= ~BITS_DATA_MASK; |
| 462 | switch (cflag & CSIZE) { | 570 | switch (cflag & CSIZE) { |
| 571 | case CS5: | ||
| 572 | bits |= BITS_DATA_5; | ||
| 573 | dbg("%s - data bits = 5", __FUNCTION__); | ||
| 574 | break; | ||
| 463 | case CS6: | 575 | case CS6: |
| 464 | bits |= BITS_DATA_6; | 576 | bits |= BITS_DATA_6; |
| 465 | dbg("%s - data bits = 6", __FUNCTION__); | 577 | dbg("%s - data bits = 6", __FUNCTION__); |
| @@ -483,13 +595,13 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
| 483 | bits |= BITS_DATA_8; | 595 | bits |= BITS_DATA_8; |
| 484 | break; | 596 | break; |
| 485 | } | 597 | } |
| 486 | if (cp2101_set_config(port, CP2101_BITS, bits)) | 598 | if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) |
| 487 | dev_err(&port->dev, "Number of data bits requested " | 599 | dev_err(&port->dev, "Number of data bits requested " |
| 488 | "not supported by device\n"); | 600 | "not supported by device\n"); |
| 489 | } | 601 | } |
| 490 | 602 | ||
| 491 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))) { | 603 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))) { |
| 492 | bits = cp2101_get_config(port, CP2101_BITS); | 604 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
| 493 | bits &= ~BITS_PARITY_MASK; | 605 | bits &= ~BITS_PARITY_MASK; |
| 494 | if (cflag & PARENB) { | 606 | if (cflag & PARENB) { |
| 495 | if (cflag & PARODD) { | 607 | if (cflag & PARODD) { |
| @@ -500,13 +612,13 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
| 500 | dbg("%s - parity = EVEN", __FUNCTION__); | 612 | dbg("%s - parity = EVEN", __FUNCTION__); |
| 501 | } | 613 | } |
| 502 | } | 614 | } |
| 503 | if (cp2101_set_config(port, CP2101_BITS, bits)) | 615 | if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) |
| 504 | dev_err(&port->dev, "Parity mode not supported " | 616 | dev_err(&port->dev, "Parity mode not supported " |
| 505 | "by device\n"); | 617 | "by device\n"); |
| 506 | } | 618 | } |
| 507 | 619 | ||
| 508 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { | 620 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
| 509 | bits = cp2101_get_config(port, CP2101_BITS); | 621 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
| 510 | bits &= ~BITS_STOP_MASK; | 622 | bits &= ~BITS_STOP_MASK; |
| 511 | if (cflag & CSTOPB) { | 623 | if (cflag & CSTOPB) { |
| 512 | bits |= BITS_STOP_2; | 624 | bits |= BITS_STOP_2; |
| @@ -515,15 +627,90 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
| 515 | bits |= BITS_STOP_1; | 627 | bits |= BITS_STOP_1; |
| 516 | dbg("%s - stop bits = 1", __FUNCTION__); | 628 | dbg("%s - stop bits = 1", __FUNCTION__); |
| 517 | } | 629 | } |
| 518 | if (cp2101_set_config(port, CP2101_BITS, bits)) | 630 | if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) |
| 519 | dev_err(&port->dev, "Number of stop bits requested " | 631 | dev_err(&port->dev, "Number of stop bits requested " |
| 520 | "not supported by device\n"); | 632 | "not supported by device\n"); |
| 521 | } | 633 | } |
| 634 | |||
| 635 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { | ||
| 636 | cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); | ||
| 637 | dbg("%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", | ||
| 638 | __FUNCTION__, modem_ctl[0], modem_ctl[1], | ||
| 639 | modem_ctl[2], modem_ctl[3]); | ||
| 640 | |||
| 641 | if (cflag & CRTSCTS) { | ||
| 642 | modem_ctl[0] &= ~0x7B; | ||
| 643 | modem_ctl[0] |= 0x09; | ||
| 644 | modem_ctl[1] = 0x80; | ||
| 645 | dbg("%s - flow control = CRTSCTS", __FUNCTION__); | ||
| 646 | } else { | ||
| 647 | modem_ctl[0] &= ~0x7B; | ||
| 648 | modem_ctl[0] |= 0x01; | ||
| 649 | modem_ctl[1] |= 0x40; | ||
| 650 | dbg("%s - flow control = NONE", __FUNCTION__); | ||
| 651 | } | ||
| 652 | |||
| 653 | dbg("%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", | ||
| 654 | __FUNCTION__, modem_ctl[0], modem_ctl[1], | ||
| 655 | modem_ctl[2], modem_ctl[3]); | ||
| 656 | cp2101_set_config(port, CP2101_MODEMCTL, modem_ctl, 16); | ||
| 657 | } | ||
| 658 | |||
| 659 | } | ||
| 660 | |||
| 661 | static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, | ||
| 662 | unsigned int set, unsigned int clear) | ||
| 663 | { | ||
| 664 | int control = 0; | ||
| 665 | |||
| 666 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
| 667 | |||
| 668 | if (set & TIOCM_RTS) { | ||
| 669 | control |= CONTROL_RTS; | ||
| 670 | control |= CONTROL_WRITE_RTS; | ||
| 671 | } | ||
| 672 | if (set & TIOCM_DTR) { | ||
| 673 | control |= CONTROL_DTR; | ||
| 674 | control |= CONTROL_WRITE_DTR; | ||
| 675 | } | ||
| 676 | if (clear & TIOCM_RTS) { | ||
| 677 | control &= ~CONTROL_RTS; | ||
| 678 | control |= CONTROL_WRITE_RTS; | ||
| 679 | } | ||
| 680 | if (clear & TIOCM_DTR) { | ||
| 681 | control &= ~CONTROL_DTR; | ||
| 682 | control |= CONTROL_WRITE_DTR; | ||
| 683 | } | ||
| 684 | |||
| 685 | dbg("%s - control = 0x%.4x", __FUNCTION__, control); | ||
| 686 | |||
| 687 | return cp2101_set_config(port, CP2101_CONTROL, &control, 2); | ||
| 688 | |||
| 689 | } | ||
| 690 | |||
| 691 | static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) | ||
| 692 | { | ||
| 693 | int control, result; | ||
| 694 | |||
| 695 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
| 696 | |||
| 697 | cp2101_get_config(port, CP2101_CONTROL, &control, 1); | ||
| 698 | |||
| 699 | result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0) | ||
| 700 | |((control & CONTROL_RTS) ? TIOCM_RTS : 0) | ||
| 701 | |((control & CONTROL_CTS) ? TIOCM_CTS : 0) | ||
| 702 | |((control & CONTROL_DSR) ? TIOCM_DSR : 0) | ||
| 703 | |((control & CONTROL_RING)? TIOCM_RI : 0) | ||
| 704 | |((control & CONTROL_DCD) ? TIOCM_CD : 0); | ||
| 705 | |||
| 706 | dbg("%s - control = 0x%.2x", __FUNCTION__, control); | ||
| 707 | |||
| 708 | return result; | ||
| 522 | } | 709 | } |
| 523 | 710 | ||
| 524 | static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) | 711 | static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) |
| 525 | { | 712 | { |
| 526 | u16 state; | 713 | int state; |
| 527 | 714 | ||
| 528 | dbg("%s - port %d", __FUNCTION__, port->number); | 715 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 529 | if (break_state == 0) | 716 | if (break_state == 0) |
| @@ -532,12 +719,12 @@ static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) | |||
| 532 | state = BREAK_ON; | 719 | state = BREAK_ON; |
| 533 | dbg("%s - turning break %s", __FUNCTION__, | 720 | dbg("%s - turning break %s", __FUNCTION__, |
| 534 | state==BREAK_OFF ? "off" : "on"); | 721 | state==BREAK_OFF ? "off" : "on"); |
| 535 | cp2101_set_config(port, CP2101_BREAK, state); | 722 | cp2101_set_config(port, CP2101_BREAK, &state, 2); |
| 536 | } | 723 | } |
| 537 | 724 | ||
| 538 | static int cp2101_startup (struct usb_serial *serial) | 725 | static int cp2101_startup (struct usb_serial *serial) |
| 539 | { | 726 | { |
| 540 | /*CP2101 buffers behave strangely unless device is reset*/ | 727 | /* CP2101 buffers behave strangely unless device is reset */ |
| 541 | usb_reset_device(serial->dev); | 728 | usb_reset_device(serial->dev); |
| 542 | return 0; | 729 | return 0; |
| 543 | } | 730 | } |
| @@ -548,7 +735,7 @@ static void cp2101_shutdown (struct usb_serial *serial) | |||
| 548 | 735 | ||
| 549 | dbg("%s", __FUNCTION__); | 736 | dbg("%s", __FUNCTION__); |
| 550 | 737 | ||
| 551 | /* stop reads and writes on all ports */ | 738 | /* Stop reads and writes on all ports */ |
| 552 | for (i=0; i < serial->num_ports; ++i) { | 739 | for (i=0; i < serial->num_ports; ++i) { |
| 553 | cp2101_cleanup(serial->port[i]); | 740 | cp2101_cleanup(serial->port[i]); |
| 554 | } | 741 | } |
| @@ -560,16 +747,16 @@ static int __init cp2101_init (void) | |||
| 560 | 747 | ||
| 561 | retval = usb_serial_register(&cp2101_device); | 748 | retval = usb_serial_register(&cp2101_device); |
| 562 | if (retval) | 749 | if (retval) |
| 563 | return retval; /*Failed to register*/ | 750 | return retval; /* Failed to register */ |
| 564 | 751 | ||
| 565 | retval = usb_register(&cp2101_driver); | 752 | retval = usb_register(&cp2101_driver); |
| 566 | if (retval) { | 753 | if (retval) { |
| 567 | /*Failed to register*/ | 754 | /* Failed to register */ |
| 568 | usb_serial_deregister(&cp2101_device); | 755 | usb_serial_deregister(&cp2101_device); |
| 569 | return retval; | 756 | return retval; |
| 570 | } | 757 | } |
| 571 | 758 | ||
| 572 | /*Success*/ | 759 | /* Success */ |
| 573 | info(DRIVER_DESC " " DRIVER_VERSION); | 760 | info(DRIVER_DESC " " DRIVER_VERSION); |
| 574 | return 0; | 761 | return 0; |
| 575 | } | 762 | } |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c new file mode 100644 index 000000000000..b722175f108f --- /dev/null +++ b/drivers/usb/serial/option.c | |||
| @@ -0,0 +1,729 @@ | |||
| 1 | /* | ||
| 2 | Option Card (PCMCIA to) USB to Serial Driver | ||
| 3 | |||
| 4 | Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de> | ||
| 5 | |||
| 6 | This driver is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of Version 2 of the GNU General Public License as | ||
| 8 | published by the Free Software Foundation. | ||
| 9 | |||
| 10 | Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org> | ||
| 11 | |||
| 12 | History: | ||
| 13 | |||
| 14 | 2005-05-19 v0.1 Initial version, based on incomplete docs | ||
| 15 | and analysis of misbehavior of the standard driver | ||
| 16 | 2005-05-20 v0.2 Extended the input buffer to avoid losing | ||
| 17 | random 64-byte chunks of data | ||
| 18 | 2005-05-21 v0.3 implemented chars_in_buffer() | ||
| 19 | turned on low_latency | ||
| 20 | simplified the code somewhat | ||
| 21 | */ | ||
| 22 | #define DRIVER_VERSION "v0.3" | ||
| 23 | #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" | ||
| 24 | #define DRIVER_DESC "Option Card (PC-Card to) USB to Serial Driver" | ||
| 25 | |||
| 26 | #include <linux/config.h> | ||
| 27 | #include <linux/kernel.h> | ||
| 28 | #include <linux/jiffies.h> | ||
| 29 | #include <linux/errno.h> | ||
| 30 | #include <linux/tty.h> | ||
| 31 | #include <linux/tty_flip.h> | ||
| 32 | #include <linux/module.h> | ||
| 33 | #include <linux/usb.h> | ||
| 34 | #include "usb-serial.h" | ||
| 35 | |||
| 36 | /* Function prototypes */ | ||
| 37 | static int option_open (struct usb_serial_port *port, struct file *filp); | ||
| 38 | static void option_close (struct usb_serial_port *port, struct file *filp); | ||
| 39 | static int option_startup (struct usb_serial *serial); | ||
| 40 | static void option_shutdown (struct usb_serial *serial); | ||
| 41 | static void option_rx_throttle (struct usb_serial_port *port); | ||
| 42 | static void option_rx_unthrottle (struct usb_serial_port *port); | ||
| 43 | static int option_write_room (struct usb_serial_port *port); | ||
| 44 | |||
| 45 | static void option_instat_callback(struct urb *urb, struct pt_regs *regs); | ||
| 46 | |||
| 47 | |||
| 48 | static int option_write (struct usb_serial_port *port, | ||
| 49 | const unsigned char *buf, int count); | ||
| 50 | |||
| 51 | static int option_chars_in_buffer (struct usb_serial_port *port); | ||
| 52 | static int option_ioctl (struct usb_serial_port *port, struct file *file, | ||
| 53 | unsigned int cmd, unsigned long arg); | ||
| 54 | static void option_set_termios (struct usb_serial_port *port, | ||
| 55 | struct termios *old); | ||
| 56 | static void option_break_ctl (struct usb_serial_port *port, int break_state); | ||
| 57 | static int option_tiocmget (struct usb_serial_port *port, struct file *file); | ||
| 58 | static int option_tiocmset (struct usb_serial_port *port, struct file *file, | ||
| 59 | unsigned int set, unsigned int clear); | ||
| 60 | static int option_send_setup (struct usb_serial_port *port); | ||
| 61 | |||
| 62 | /* Vendor and product IDs */ | ||
| 63 | #define OPTION_VENDOR_ID 0x0AF0 | ||
| 64 | |||
| 65 | #define OPTION_PRODUCT_OLD 0x5000 | ||
| 66 | #define OPTION_PRODUCT_WLAN 0x6000 | ||
| 67 | |||
| 68 | static struct usb_device_id option_ids[] = { | ||
| 69 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, | ||
| 70 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_WLAN) }, | ||
| 71 | { } /* Terminating entry */ | ||
| 72 | }; | ||
| 73 | |||
| 74 | MODULE_DEVICE_TABLE(usb, option_ids); | ||
| 75 | |||
| 76 | static struct usb_driver option_driver = { | ||
| 77 | .owner = THIS_MODULE, | ||
| 78 | .name = "option", | ||
| 79 | .probe = usb_serial_probe, | ||
| 80 | .disconnect = usb_serial_disconnect, | ||
| 81 | .id_table = option_ids, | ||
| 82 | }; | ||
| 83 | |||
| 84 | /* The card has three separate interfaces, wich the serial driver | ||
| 85 | * recognizes separately, thus num_port=1. | ||
| 86 | */ | ||
| 87 | static struct usb_serial_device_type option_3port_device = { | ||
| 88 | .owner = THIS_MODULE, | ||
| 89 | .name = "Option 3-port card", | ||
| 90 | .short_name = "option", | ||
| 91 | .id_table = option_ids, | ||
| 92 | .num_interrupt_in = NUM_DONT_CARE, | ||
| 93 | .num_bulk_in = NUM_DONT_CARE, | ||
| 94 | .num_bulk_out = NUM_DONT_CARE, | ||
| 95 | .num_ports = 1, /* 3 */ | ||
| 96 | .open = option_open, | ||
| 97 | .close = option_close, | ||
| 98 | .write = option_write, | ||
| 99 | .write_room = option_write_room, | ||
| 100 | .chars_in_buffer = option_chars_in_buffer, | ||
| 101 | .throttle = option_rx_throttle, | ||
| 102 | .unthrottle = option_rx_unthrottle, | ||
| 103 | .ioctl = option_ioctl, | ||
| 104 | .set_termios = option_set_termios, | ||
| 105 | .break_ctl = option_break_ctl, | ||
| 106 | .tiocmget = option_tiocmget, | ||
| 107 | .tiocmset = option_tiocmset, | ||
| 108 | .attach = option_startup, | ||
| 109 | .shutdown = option_shutdown, | ||
| 110 | .read_int_callback = option_instat_callback, | ||
| 111 | }; | ||
| 112 | |||
| 113 | static int debug; | ||
| 114 | |||
| 115 | /* per port private data */ | ||
| 116 | |||
| 117 | #define N_IN_URB 4 | ||
| 118 | #define N_OUT_URB 1 | ||
| 119 | #define IN_BUFLEN 1024 | ||
| 120 | #define OUT_BUFLEN 1024 | ||
| 121 | |||
| 122 | struct option_port_private { | ||
| 123 | /* Input endpoints and buffer for this port */ | ||
| 124 | struct urb *in_urbs[N_IN_URB]; | ||
| 125 | char in_buffer[N_IN_URB][IN_BUFLEN]; | ||
| 126 | /* Output endpoints and buffer for this port */ | ||
| 127 | struct urb *out_urbs[N_OUT_URB]; | ||
| 128 | char out_buffer[N_OUT_URB][OUT_BUFLEN]; | ||
| 129 | |||
| 130 | /* Settings for the port */ | ||
| 131 | int rts_state; /* Handshaking pins (outputs) */ | ||
| 132 | int dtr_state; | ||
| 133 | int cts_state; /* Handshaking pins (inputs) */ | ||
| 134 | int dsr_state; | ||
| 135 | int dcd_state; | ||
| 136 | int ri_state; | ||
| 137 | // int break_on; | ||
| 138 | |||
| 139 | unsigned long tx_start_time[N_OUT_URB]; | ||
| 140 | }; | ||
| 141 | |||
| 142 | |||
| 143 | /* Functions used by new usb-serial code. */ | ||
| 144 | static int __init | ||
| 145 | option_init (void) | ||
| 146 | { | ||
| 147 | int retval; | ||
| 148 | retval = usb_serial_register(&option_3port_device); | ||
| 149 | if (retval) | ||
| 150 | goto failed_3port_device_register; | ||
| 151 | retval = usb_register(&option_driver); | ||
| 152 | if (retval) | ||
| 153 | goto failed_driver_register; | ||
| 154 | |||
| 155 | info(DRIVER_DESC ": " DRIVER_VERSION); | ||
| 156 | |||
| 157 | return 0; | ||
| 158 | |||
| 159 | failed_driver_register: | ||
| 160 | usb_serial_deregister (&option_3port_device); | ||
| 161 | failed_3port_device_register: | ||
| 162 | return retval; | ||
| 163 | } | ||
| 164 | |||
| 165 | static void __exit | ||
| 166 | option_exit (void) | ||
| 167 | { | ||
| 168 | usb_deregister (&option_driver); | ||
| 169 | usb_serial_deregister (&option_3port_device); | ||
| 170 | } | ||
| 171 | |||
| 172 | module_init(option_init); | ||
| 173 | module_exit(option_exit); | ||
| 174 | |||
| 175 | static void | ||
| 176 | option_rx_throttle (struct usb_serial_port *port) | ||
| 177 | { | ||
| 178 | dbg("%s", __FUNCTION__); | ||
| 179 | } | ||
| 180 | |||
| 181 | |||
| 182 | static void | ||
| 183 | option_rx_unthrottle (struct usb_serial_port *port) | ||
| 184 | { | ||
| 185 | dbg("%s", __FUNCTION__); | ||
| 186 | } | ||
| 187 | |||
| 188 | |||
| 189 | static void | ||
| 190 | option_break_ctl (struct usb_serial_port *port, int break_state) | ||
| 191 | { | ||
| 192 | /* Unfortunately, I don't know how to send a break */ | ||
| 193 | dbg("%s", __FUNCTION__); | ||
| 194 | } | ||
| 195 | |||
| 196 | |||
| 197 | static void | ||
| 198 | option_set_termios (struct usb_serial_port *port, | ||
| 199 | struct termios *old_termios) | ||
| 200 | { | ||
| 201 | dbg("%s", __FUNCTION__); | ||
| 202 | |||
| 203 | option_send_setup(port); | ||
| 204 | } | ||
| 205 | |||
| 206 | static int | ||
| 207 | option_tiocmget(struct usb_serial_port *port, struct file *file) | ||
| 208 | { | ||
| 209 | unsigned int value; | ||
| 210 | struct option_port_private *portdata; | ||
| 211 | |||
| 212 | portdata = usb_get_serial_port_data(port); | ||
| 213 | |||
| 214 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | | ||
| 215 | ((portdata->dtr_state) ? TIOCM_DTR : 0) | | ||
| 216 | ((portdata->cts_state) ? TIOCM_CTS : 0) | | ||
| 217 | ((portdata->dsr_state) ? TIOCM_DSR : 0) | | ||
| 218 | ((portdata->dcd_state) ? TIOCM_CAR : 0) | | ||
| 219 | ((portdata->ri_state) ? TIOCM_RNG : 0); | ||
| 220 | |||
| 221 | return value; | ||
| 222 | } | ||
| 223 | |||
| 224 | static int | ||
| 225 | option_tiocmset (struct usb_serial_port *port, struct file *file, | ||
| 226 | unsigned int set, unsigned int clear) | ||
| 227 | { | ||
| 228 | struct option_port_private *portdata; | ||
| 229 | |||
| 230 | portdata = usb_get_serial_port_data(port); | ||
| 231 | |||
| 232 | if (set & TIOCM_RTS) | ||
| 233 | portdata->rts_state = 1; | ||
| 234 | if (set & TIOCM_DTR) | ||
| 235 | portdata->dtr_state = 1; | ||
| 236 | |||
| 237 | if (clear & TIOCM_RTS) | ||
| 238 | portdata->rts_state = 0; | ||
| 239 | if (clear & TIOCM_DTR) | ||
| 240 | portdata->dtr_state = 0; | ||
| 241 | return option_send_setup(port); | ||
| 242 | } | ||
| 243 | |||
| 244 | static int | ||
| 245 | option_ioctl (struct usb_serial_port *port, struct file *file, | ||
| 246 | unsigned int cmd, unsigned long arg) | ||
| 247 | { | ||
| 248 | return -ENOIOCTLCMD; | ||
| 249 | } | ||
| 250 | |||
| 251 | /* Write */ | ||
| 252 | static int | ||
| 253 | option_write(struct usb_serial_port *port, | ||
| 254 | const unsigned char *buf, int count) | ||
| 255 | { | ||
| 256 | struct option_port_private *portdata; | ||
| 257 | int i; | ||
| 258 | int left, todo; | ||
| 259 | struct urb *this_urb = NULL; /* spurious */ | ||
| 260 | int err; | ||
| 261 | |||
| 262 | portdata = usb_get_serial_port_data(port); | ||
| 263 | |||
| 264 | dbg("%s: write (%d chars)", __FUNCTION__, count); | ||
| 265 | |||
| 266 | #if 0 | ||
| 267 | spin_lock(&port->lock); | ||
| 268 | if (port->write_urb_busy) { | ||
| 269 | spin_unlock(&port->lock); | ||
| 270 | dbg("%s: already writing", __FUNCTION__); | ||
| 271 | return 0; | ||
| 272 | } | ||
| 273 | port->write_urb_busy = 1; | ||
| 274 | spin_unlock(&port->lock); | ||
| 275 | #endif | ||
| 276 | |||
| 277 | i = 0; | ||
| 278 | left = count; | ||
| 279 | while (left>0) { | ||
| 280 | todo = left; | ||
| 281 | if (todo > OUT_BUFLEN) | ||
| 282 | todo = OUT_BUFLEN; | ||
| 283 | |||
| 284 | for (;i < N_OUT_URB; i++) { | ||
| 285 | /* Check we have a valid urb/endpoint before we use it... */ | ||
| 286 | this_urb = portdata->out_urbs[i]; | ||
| 287 | if (this_urb->status != -EINPROGRESS) | ||
| 288 | break; | ||
| 289 | if (this_urb->transfer_flags & URB_ASYNC_UNLINK) | ||
| 290 | continue; | ||
| 291 | if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ)) | ||
| 292 | continue; | ||
| 293 | this_urb->transfer_flags |= URB_ASYNC_UNLINK; | ||
| 294 | usb_unlink_urb(this_urb); | ||
| 295 | } | ||
| 296 | |||
| 297 | if (i == N_OUT_URB) { | ||
| 298 | /* no bulk out free! */ | ||
| 299 | dbg("%s: no output urb -- left %d", __FUNCTION__,count-left); | ||
| 300 | #if 0 | ||
| 301 | port->write_urb_busy = 0; | ||
| 302 | #endif | ||
| 303 | return count-left; | ||
| 304 | } | ||
| 305 | |||
| 306 | dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i); | ||
| 307 | |||
| 308 | memcpy (this_urb->transfer_buffer, buf, todo); | ||
| 309 | |||
| 310 | /* send the data out the bulk port */ | ||
| 311 | this_urb->transfer_buffer_length = todo; | ||
| 312 | |||
| 313 | this_urb->transfer_flags &= ~URB_ASYNC_UNLINK; | ||
| 314 | this_urb->dev = port->serial->dev; | ||
| 315 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | ||
| 316 | if (err) { | ||
| 317 | dbg("usb_submit_urb %p (write bulk) failed (%d,, has %d)", this_urb, err, this_urb->status); | ||
| 318 | continue; | ||
| 319 | } | ||
| 320 | portdata->tx_start_time[i] = jiffies; | ||
| 321 | buf += todo; | ||
| 322 | left -= todo; | ||
| 323 | } | ||
| 324 | |||
| 325 | count -= left; | ||
| 326 | #if 0 | ||
| 327 | port->write_urb_busy = 0; | ||
| 328 | #endif | ||
| 329 | dbg("%s: wrote (did %d)", __FUNCTION__, count); | ||
| 330 | return count; | ||
| 331 | } | ||
| 332 | |||
| 333 | static void | ||
| 334 | option_indat_callback (struct urb *urb, struct pt_regs *regs) | ||
| 335 | { | ||
| 336 | int i, err; | ||
| 337 | int endpoint; | ||
| 338 | struct usb_serial_port *port; | ||
| 339 | struct tty_struct *tty; | ||
| 340 | unsigned char *data = urb->transfer_buffer; | ||
| 341 | |||
| 342 | dbg("%s: %p", __FUNCTION__, urb); | ||
| 343 | |||
| 344 | endpoint = usb_pipeendpoint(urb->pipe); | ||
| 345 | port = (struct usb_serial_port *) urb->context; | ||
| 346 | |||
| 347 | if (urb->status) { | ||
| 348 | dbg("%s: nonzero status: %d on endpoint %02x.", | ||
| 349 | __FUNCTION__, urb->status, endpoint); | ||
| 350 | } else { | ||
| 351 | tty = port->tty; | ||
| 352 | if (urb->actual_length) { | ||
| 353 | for (i = 0; i < urb->actual_length ; ++i) { | ||
| 354 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
| 355 | tty_flip_buffer_push(tty); | ||
| 356 | tty_insert_flip_char(tty, data[i], 0); | ||
| 357 | } | ||
| 358 | tty_flip_buffer_push(tty); | ||
| 359 | } else { | ||
| 360 | dbg("%s: empty read urb received", __FUNCTION__); | ||
| 361 | } | ||
| 362 | |||
| 363 | /* Resubmit urb so we continue receiving */ | ||
| 364 | if (port->open_count && urb->status != -ESHUTDOWN) { | ||
| 365 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
| 366 | if (err) | ||
| 367 | printk(KERN_ERR "%s: resubmit read urb failed. (%d)", __FUNCTION__, err); | ||
| 368 | } | ||
| 369 | } | ||
| 370 | return; | ||
| 371 | } | ||
| 372 | |||
| 373 | static void | ||
| 374 | option_outdat_callback (struct urb *urb, struct pt_regs *regs) | ||
| 375 | { | ||
| 376 | struct usb_serial_port *port; | ||
| 377 | |||
| 378 | dbg("%s", __FUNCTION__); | ||
| 379 | |||
| 380 | port = (struct usb_serial_port *) urb->context; | ||
| 381 | |||
| 382 | if (port->open_count) | ||
| 383 | schedule_work(&port->work); | ||
| 384 | } | ||
| 385 | |||
| 386 | static void | ||
| 387 | option_instat_callback (struct urb *urb, struct pt_regs *regs) | ||
| 388 | { | ||
| 389 | int err; | ||
| 390 | struct usb_serial_port *port = (struct usb_serial_port *) urb->context; | ||
| 391 | struct option_port_private *portdata = usb_get_serial_port_data(port); | ||
| 392 | struct usb_serial *serial = port->serial; | ||
| 393 | |||
| 394 | dbg("%s", __FUNCTION__); | ||
| 395 | dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata); | ||
| 396 | |||
| 397 | if (urb->status == 0) { | ||
| 398 | struct usb_ctrlrequest *req_pkt = | ||
| 399 | (struct usb_ctrlrequest *)urb->transfer_buffer; | ||
| 400 | |||
| 401 | if (!req_pkt) { | ||
| 402 | dbg("%s: NULL req_pkt\n", __FUNCTION__); | ||
| 403 | return; | ||
| 404 | } | ||
| 405 | if ((req_pkt->bRequestType == 0xA1) && (req_pkt->bRequest == 0x20)) { | ||
| 406 | int old_dcd_state; | ||
| 407 | unsigned char signals = *((unsigned char *) | ||
| 408 | urb->transfer_buffer + sizeof(struct usb_ctrlrequest)); | ||
| 409 | |||
| 410 | dbg("%s: signal x%x", __FUNCTION__, signals); | ||
| 411 | |||
| 412 | old_dcd_state = portdata->dcd_state; | ||
| 413 | portdata->cts_state = 1; | ||
| 414 | portdata->dcd_state = ((signals & 0x01) ? 1 : 0); | ||
| 415 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); | ||
| 416 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); | ||
| 417 | |||
| 418 | if (port->tty && !C_CLOCAL(port->tty) | ||
| 419 | && old_dcd_state && !portdata->dcd_state) { | ||
| 420 | tty_hangup(port->tty); | ||
| 421 | } | ||
| 422 | } else | ||
| 423 | dbg("%s: type %x req %x", __FUNCTION__, req_pkt->bRequestType,req_pkt->bRequest); | ||
| 424 | } else | ||
| 425 | dbg("%s: error %d", __FUNCTION__, urb->status); | ||
| 426 | |||
| 427 | /* Resubmit urb so we continue receiving IRQ data */ | ||
| 428 | if (urb->status != -ESHUTDOWN) { | ||
| 429 | urb->dev = serial->dev; | ||
| 430 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
| 431 | if (err) | ||
| 432 | dbg("%s: resubmit intr urb failed. (%d)", __FUNCTION__, err); | ||
| 433 | } | ||
| 434 | } | ||
| 435 | |||
| 436 | |||
| 437 | static int | ||
| 438 | option_write_room (struct usb_serial_port *port) | ||
| 439 | { | ||
| 440 | struct option_port_private *portdata; | ||
| 441 | int i; | ||
| 442 | int data_len = 0; | ||
| 443 | struct urb *this_urb; | ||
| 444 | |||
| 445 | portdata = usb_get_serial_port_data(port); | ||
| 446 | |||
| 447 | for (i=0; i < N_OUT_URB; i++) | ||
| 448 | this_urb = portdata->out_urbs[i]; | ||
| 449 | if (this_urb && this_urb->status != -EINPROGRESS) | ||
| 450 | data_len += OUT_BUFLEN; | ||
| 451 | |||
| 452 | dbg("%s: %d", __FUNCTION__, data_len); | ||
| 453 | return data_len; | ||
| 454 | } | ||
| 455 | |||
| 456 | |||
| 457 | static int | ||
| 458 | option_chars_in_buffer (struct usb_serial_port *port) | ||
| 459 | { | ||
| 460 | struct option_port_private *portdata; | ||
| 461 | int i; | ||
| 462 | int data_len = 0; | ||
| 463 | struct urb *this_urb; | ||
| 464 | |||
| 465 | portdata = usb_get_serial_port_data(port); | ||
| 466 | |||
| 467 | for (i=0; i < N_OUT_URB; i++) | ||
| 468 | this_urb = portdata->out_urbs[i]; | ||
| 469 | if (this_urb && this_urb->status == -EINPROGRESS) | ||
| 470 | data_len += this_urb->transfer_buffer_length; | ||
| 471 | |||
| 472 | dbg("%s: %d", __FUNCTION__, data_len); | ||
| 473 | return data_len; | ||
| 474 | } | ||
| 475 | |||
| 476 | |||
| 477 | static int | ||
| 478 | option_open (struct usb_serial_port *port, struct file *filp) | ||
| 479 | { | ||
| 480 | struct option_port_private *portdata; | ||
| 481 | struct usb_serial *serial = port->serial; | ||
| 482 | int i, err; | ||
| 483 | struct urb *urb; | ||
| 484 | |||
| 485 | portdata = usb_get_serial_port_data(port); | ||
| 486 | |||
| 487 | dbg("%s", __FUNCTION__); | ||
| 488 | |||
| 489 | /* Set some sane defaults */ | ||
| 490 | portdata->rts_state = 1; | ||
| 491 | portdata->dtr_state = 1; | ||
| 492 | |||
| 493 | /* Reset low level data toggle and start reading from endpoints */ | ||
| 494 | for (i = 0; i < N_IN_URB; i++) { | ||
| 495 | urb = portdata->in_urbs[i]; | ||
| 496 | if (! urb) | ||
| 497 | continue; | ||
| 498 | if (urb->dev != serial->dev) { | ||
| 499 | dbg("%s: dev %p != %p", __FUNCTION__, urb->dev, serial->dev); | ||
| 500 | continue; | ||
| 501 | } | ||
| 502 | |||
| 503 | /* make sure endpoint data toggle is synchronized with the device */ | ||
| 504 | |||
| 505 | usb_clear_halt(urb->dev, urb->pipe); | ||
| 506 | |||
| 507 | err = usb_submit_urb(urb, GFP_KERNEL); | ||
| 508 | if (err) { | ||
| 509 | dbg("%s: submit urb %d failed (%d) %d", __FUNCTION__, i, err, | ||
| 510 | urb->transfer_buffer_length); | ||
| 511 | } | ||
| 512 | } | ||
| 513 | |||
| 514 | /* Reset low level data toggle on out endpoints */ | ||
| 515 | for (i = 0; i < N_OUT_URB; i++) { | ||
| 516 | urb = portdata->out_urbs[i]; | ||
| 517 | if (! urb) | ||
| 518 | continue; | ||
| 519 | urb->dev = serial->dev; | ||
| 520 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ | ||
| 521 | } | ||
| 522 | |||
| 523 | port->tty->low_latency = 1; | ||
| 524 | |||
| 525 | option_send_setup(port); | ||
| 526 | |||
| 527 | return (0); | ||
| 528 | } | ||
| 529 | |||
| 530 | static inline void | ||
| 531 | stop_urb(struct urb *urb) | ||
| 532 | { | ||
| 533 | if (urb && urb->status == -EINPROGRESS) { | ||
| 534 | urb->transfer_flags &= ~URB_ASYNC_UNLINK; | ||
| 535 | usb_kill_urb(urb); | ||
| 536 | } | ||
| 537 | } | ||
| 538 | |||
| 539 | static void | ||
| 540 | option_close(struct usb_serial_port *port, struct file *filp) | ||
| 541 | { | ||
| 542 | int i; | ||
| 543 | struct usb_serial *serial = port->serial; | ||
| 544 | struct option_port_private *portdata; | ||
| 545 | |||
| 546 | dbg("%s", __FUNCTION__); | ||
| 547 | portdata = usb_get_serial_port_data(port); | ||
| 548 | |||
| 549 | portdata->rts_state = 0; | ||
| 550 | portdata->dtr_state = 0; | ||
| 551 | |||
| 552 | if (serial->dev) { | ||
| 553 | option_send_setup(port); | ||
| 554 | |||
| 555 | /* Stop reading/writing urbs */ | ||
| 556 | for (i = 0; i < N_IN_URB; i++) | ||
| 557 | stop_urb(portdata->in_urbs[i]); | ||
| 558 | for (i = 0; i < N_OUT_URB; i++) | ||
| 559 | stop_urb(portdata->out_urbs[i]); | ||
| 560 | } | ||
| 561 | port->tty = NULL; | ||
| 562 | } | ||
| 563 | |||
| 564 | |||
| 565 | /* Helper functions used by option_setup_urbs */ | ||
| 566 | static struct urb * | ||
| 567 | option_setup_urb (struct usb_serial *serial, int endpoint, | ||
| 568 | int dir, void *ctx, char *buf, int len, | ||
| 569 | void (*callback)(struct urb *, struct pt_regs *regs)) | ||
| 570 | { | ||
| 571 | struct urb *urb; | ||
| 572 | |||
| 573 | if (endpoint == -1) | ||
| 574 | return NULL; /* endpoint not needed */ | ||
| 575 | |||
| 576 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ | ||
| 577 | if (urb == NULL) { | ||
| 578 | dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint); | ||
| 579 | return NULL; | ||
| 580 | } | ||
| 581 | |||
| 582 | /* Fill URB using supplied data. */ | ||
| 583 | usb_fill_bulk_urb(urb, serial->dev, | ||
| 584 | usb_sndbulkpipe(serial->dev, endpoint) | dir, | ||
| 585 | buf, len, callback, ctx); | ||
| 586 | |||
| 587 | return urb; | ||
| 588 | } | ||
| 589 | |||
| 590 | /* Setup urbs */ | ||
| 591 | static void | ||
| 592 | option_setup_urbs(struct usb_serial *serial) | ||
| 593 | { | ||
| 594 | int j; | ||
| 595 | struct usb_serial_port *port; | ||
| 596 | struct option_port_private *portdata; | ||
| 597 | |||
| 598 | dbg("%s", __FUNCTION__); | ||
| 599 | |||
| 600 | port = serial->port[0]; | ||
| 601 | portdata = usb_get_serial_port_data(port); | ||
| 602 | |||
| 603 | /* Do indat endpoints first */ | ||
| 604 | for (j = 0; j <= N_IN_URB; ++j) { | ||
| 605 | portdata->in_urbs[j] = option_setup_urb (serial, | ||
| 606 | port->bulk_in_endpointAddress, USB_DIR_IN, port, | ||
| 607 | portdata->in_buffer[j], IN_BUFLEN, option_indat_callback); | ||
| 608 | } | ||
| 609 | |||
| 610 | /* outdat endpoints */ | ||
| 611 | for (j = 0; j <= N_OUT_URB; ++j) { | ||
| 612 | portdata->out_urbs[j] = option_setup_urb (serial, | ||
| 613 | port->bulk_out_endpointAddress, USB_DIR_OUT, port, | ||
| 614 | portdata->out_buffer[j], OUT_BUFLEN, option_outdat_callback); | ||
| 615 | } | ||
| 616 | } | ||
| 617 | |||
| 618 | |||
| 619 | static int | ||
| 620 | option_send_setup(struct usb_serial_port *port) | ||
| 621 | { | ||
| 622 | struct usb_serial *serial = port->serial; | ||
| 623 | struct option_port_private *portdata; | ||
| 624 | |||
| 625 | dbg("%s", __FUNCTION__); | ||
| 626 | |||
| 627 | portdata = usb_get_serial_port_data(port); | ||
| 628 | |||
| 629 | if (port->tty) { | ||
| 630 | int val = 0; | ||
| 631 | if (portdata->dtr_state) | ||
| 632 | val |= 0x01; | ||
| 633 | if (portdata->rts_state) | ||
| 634 | val |= 0x02; | ||
| 635 | |||
| 636 | return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | ||
| 637 | 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); | ||
| 638 | } | ||
| 639 | |||
| 640 | return 0; | ||
| 641 | } | ||
| 642 | |||
| 643 | |||
| 644 | static int | ||
| 645 | option_startup (struct usb_serial *serial) | ||
| 646 | { | ||
| 647 | int i, err; | ||
| 648 | struct usb_serial_port *port; | ||
| 649 | struct option_port_private *portdata; | ||
| 650 | |||
| 651 | dbg("%s", __FUNCTION__); | ||
| 652 | |||
| 653 | /* Now setup per port private data */ | ||
| 654 | for (i = 0; i < serial->num_ports; i++) { | ||
| 655 | port = serial->port[i]; | ||
| 656 | portdata = kmalloc(sizeof(struct option_port_private), GFP_KERNEL); | ||
| 657 | if (!portdata) { | ||
| 658 | dbg("%s: kmalloc for option_port_private (%d) failed!.", __FUNCTION__, i); | ||
| 659 | return (1); | ||
| 660 | } | ||
| 661 | memset(portdata, 0, sizeof(struct option_port_private)); | ||
| 662 | |||
| 663 | usb_set_serial_port_data(port, portdata); | ||
| 664 | |||
| 665 | if (! port->interrupt_in_urb) | ||
| 666 | continue; | ||
| 667 | err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | ||
| 668 | if (err) | ||
| 669 | dbg("%s: submit irq_in urb failed %d", __FUNCTION__, err); | ||
| 670 | } | ||
| 671 | |||
| 672 | option_setup_urbs(serial); | ||
| 673 | |||
| 674 | return (0); | ||
| 675 | } | ||
| 676 | |||
| 677 | static void | ||
| 678 | option_shutdown (struct usb_serial *serial) | ||
| 679 | { | ||
| 680 | int i, j; | ||
| 681 | struct usb_serial_port *port; | ||
| 682 | struct option_port_private *portdata; | ||
| 683 | |||
| 684 | dbg("%s", __FUNCTION__); | ||
| 685 | |||
| 686 | /* Stop reading/writing urbs */ | ||
| 687 | for (i = 0; i < serial->num_ports; ++i) { | ||
| 688 | port = serial->port[i]; | ||
| 689 | portdata = usb_get_serial_port_data(port); | ||
| 690 | for (j = 0; j < N_IN_URB; j++) | ||
| 691 | stop_urb(portdata->in_urbs[j]); | ||
| 692 | for (j = 0; j < N_OUT_URB; j++) | ||
| 693 | stop_urb(portdata->out_urbs[j]); | ||
| 694 | } | ||
| 695 | |||
| 696 | /* Now free them */ | ||
| 697 | for (i = 0; i < serial->num_ports; ++i) { | ||
| 698 | port = serial->port[i]; | ||
| 699 | portdata = usb_get_serial_port_data(port); | ||
| 700 | |||
| 701 | for (j = 0; j < N_IN_URB; j++) { | ||
| 702 | if (portdata->in_urbs[j]) { | ||
| 703 | usb_free_urb(portdata->in_urbs[j]); | ||
| 704 | portdata->in_urbs[j] = NULL; | ||
| 705 | } | ||
| 706 | } | ||
| 707 | for (j = 0; j < N_OUT_URB; j++) { | ||
| 708 | if (portdata->out_urbs[j]) { | ||
| 709 | usb_free_urb(portdata->out_urbs[j]); | ||
| 710 | portdata->out_urbs[j] = NULL; | ||
| 711 | } | ||
| 712 | } | ||
| 713 | } | ||
| 714 | |||
| 715 | /* Now free per port private data */ | ||
| 716 | for (i = 0; i < serial->num_ports; i++) { | ||
| 717 | port = serial->port[i]; | ||
| 718 | kfree(usb_get_serial_port_data(port)); | ||
| 719 | } | ||
| 720 | } | ||
| 721 | |||
| 722 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
| 723 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 724 | MODULE_VERSION(DRIVER_VERSION); | ||
| 725 | MODULE_LICENSE("GPL"); | ||
| 726 | |||
| 727 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
| 728 | MODULE_PARM_DESC(debug, "Debug messages"); | ||
| 729 | |||
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index d2891f475793..9fcc7bd1fbe4 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
| @@ -862,6 +862,15 @@ UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100, | |||
| 862 | US_SC_DEVICE, US_PR_BULK, NULL, | 862 | US_SC_DEVICE, US_PR_BULK, NULL, |
| 863 | US_FL_NEED_OVERRIDE ), | 863 | US_FL_NEED_OVERRIDE ), |
| 864 | 864 | ||
| 865 | /* Reported by Filippo Bardelli <filibard@libero.it> | ||
| 866 | * The device reports a subclass of RBC, which is wrong. | ||
| 867 | */ | ||
| 868 | UNUSUAL_DEV( 0x090a, 0x1050, 0x0100, 0x0100, | ||
| 869 | "Trumpion Microelectronics, Inc.", | ||
| 870 | "33520 USB Digital Voice Recorder", | ||
| 871 | US_SC_UFI, US_PR_DEVICE, NULL, | ||
| 872 | 0), | ||
| 873 | |||
| 865 | /* Trumpion Microelectronics MP3 player (felipe_alfaro@linuxmail.org) */ | 874 | /* Trumpion Microelectronics MP3 player (felipe_alfaro@linuxmail.org) */ |
| 866 | UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999, | 875 | UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999, |
| 867 | "Trumpion", | 876 | "Trumpion", |
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c index 98d830401c56..5a97e346bd95 100644 --- a/fs/jbd/checkpoint.c +++ b/fs/jbd/checkpoint.c | |||
| @@ -188,7 +188,6 @@ static int __cleanup_transaction(journal_t *journal, transaction_t *transaction) | |||
| 188 | } else { | 188 | } else { |
| 189 | jbd_unlock_bh_state(bh); | 189 | jbd_unlock_bh_state(bh); |
| 190 | } | 190 | } |
| 191 | jh = next_jh; | ||
| 192 | } while (jh != last_jh); | 191 | } while (jh != last_jh); |
| 193 | 192 | ||
| 194 | return ret; | 193 | return ret; |
| @@ -339,8 +338,10 @@ int log_do_checkpoint(journal_t *journal) | |||
| 339 | } | 338 | } |
| 340 | } while (jh != last_jh && !retry); | 339 | } while (jh != last_jh && !retry); |
| 341 | 340 | ||
| 342 | if (batch_count) | 341 | if (batch_count) { |
| 343 | __flush_batch(journal, bhs, &batch_count); | 342 | __flush_batch(journal, bhs, &batch_count); |
| 343 | retry = 1; | ||
| 344 | } | ||
| 344 | 345 | ||
| 345 | /* | 346 | /* |
| 346 | * If someone cleaned up this transaction while we slept, we're | 347 | * If someone cleaned up this transaction while we slept, we're |
diff --git a/fs/mpage.c b/fs/mpage.c index b92c0e64aefa..bb9aebe93862 100644 --- a/fs/mpage.c +++ b/fs/mpage.c | |||
| @@ -79,8 +79,11 @@ static int mpage_end_io_write(struct bio *bio, unsigned int bytes_done, int err) | |||
| 79 | if (--bvec >= bio->bi_io_vec) | 79 | if (--bvec >= bio->bi_io_vec) |
| 80 | prefetchw(&bvec->bv_page->flags); | 80 | prefetchw(&bvec->bv_page->flags); |
| 81 | 81 | ||
| 82 | if (!uptodate) | 82 | if (!uptodate){ |
| 83 | SetPageError(page); | 83 | SetPageError(page); |
| 84 | if (page->mapping) | ||
| 85 | set_bit(AS_EIO, &page->mapping->flags); | ||
| 86 | } | ||
| 84 | end_page_writeback(page); | 87 | end_page_writeback(page); |
| 85 | } while (bvec >= bio->bi_io_vec); | 88 | } while (bvec >= bio->bi_io_vec); |
| 86 | bio_put(bio); | 89 | bio_put(bio); |
diff --git a/include/asm-ppc64/processor.h b/include/asm-ppc64/processor.h index 0035efe2db2b..809c634ba1df 100644 --- a/include/asm-ppc64/processor.h +++ b/include/asm-ppc64/processor.h | |||
| @@ -120,103 +120,18 @@ | |||
| 120 | 120 | ||
| 121 | /* Special Purpose Registers (SPRNs)*/ | 121 | /* Special Purpose Registers (SPRNs)*/ |
| 122 | 122 | ||
| 123 | #define SPRN_CDBCR 0x3D7 /* Cache Debug Control Register */ | ||
| 124 | #define SPRN_CTR 0x009 /* Count Register */ | 123 | #define SPRN_CTR 0x009 /* Count Register */ |
| 125 | #define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ | 124 | #define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ |
| 126 | #define SPRN_DAC1 0x3F6 /* Data Address Compare 1 */ | 125 | #define DABR_TRANSLATION (1UL << 2) |
| 127 | #define SPRN_DAC2 0x3F7 /* Data Address Compare 2 */ | ||
| 128 | #define SPRN_DAR 0x013 /* Data Address Register */ | 126 | #define SPRN_DAR 0x013 /* Data Address Register */ |
| 129 | #define SPRN_DBCR 0x3F2 /* Debug Control Regsiter */ | ||
| 130 | #define DBCR_EDM 0x80000000 | ||
| 131 | #define DBCR_IDM 0x40000000 | ||
| 132 | #define DBCR_RST(x) (((x) & 0x3) << 28) | ||
| 133 | #define DBCR_RST_NONE 0 | ||
| 134 | #define DBCR_RST_CORE 1 | ||
| 135 | #define DBCR_RST_CHIP 2 | ||
| 136 | #define DBCR_RST_SYSTEM 3 | ||
| 137 | #define DBCR_IC 0x08000000 /* Instruction Completion Debug Evnt */ | ||
| 138 | #define DBCR_BT 0x04000000 /* Branch Taken Debug Event */ | ||
| 139 | #define DBCR_EDE 0x02000000 /* Exception Debug Event */ | ||
| 140 | #define DBCR_TDE 0x01000000 /* TRAP Debug Event */ | ||
| 141 | #define DBCR_FER 0x00F80000 /* First Events Remaining Mask */ | ||
| 142 | #define DBCR_FT 0x00040000 /* Freeze Timers on Debug Event */ | ||
| 143 | #define DBCR_IA1 0x00020000 /* Instr. Addr. Compare 1 Enable */ | ||
| 144 | #define DBCR_IA2 0x00010000 /* Instr. Addr. Compare 2 Enable */ | ||
| 145 | #define DBCR_D1R 0x00008000 /* Data Addr. Compare 1 Read Enable */ | ||
| 146 | #define DBCR_D1W 0x00004000 /* Data Addr. Compare 1 Write Enable */ | ||
| 147 | #define DBCR_D1S(x) (((x) & 0x3) << 12) /* Data Adrr. Compare 1 Size */ | ||
| 148 | #define DAC_BYTE 0 | ||
| 149 | #define DAC_HALF 1 | ||
| 150 | #define DAC_WORD 2 | ||
| 151 | #define DAC_QUAD 3 | ||
| 152 | #define DBCR_D2R 0x00000800 /* Data Addr. Compare 2 Read Enable */ | ||
| 153 | #define DBCR_D2W 0x00000400 /* Data Addr. Compare 2 Write Enable */ | ||
| 154 | #define DBCR_D2S(x) (((x) & 0x3) << 8) /* Data Addr. Compare 2 Size */ | ||
| 155 | #define DBCR_SBT 0x00000040 /* Second Branch Taken Debug Event */ | ||
| 156 | #define DBCR_SED 0x00000020 /* Second Exception Debug Event */ | ||
| 157 | #define DBCR_STD 0x00000010 /* Second Trap Debug Event */ | ||
| 158 | #define DBCR_SIA 0x00000008 /* Second IAC Enable */ | ||
| 159 | #define DBCR_SDA 0x00000004 /* Second DAC Enable */ | ||
| 160 | #define DBCR_JOI 0x00000002 /* JTAG Serial Outbound Int. Enable */ | ||
| 161 | #define DBCR_JII 0x00000001 /* JTAG Serial Inbound Int. Enable */ | ||
| 162 | #define SPRN_DBCR0 0x3F2 /* Debug Control Register 0 */ | ||
| 163 | #define SPRN_DBCR1 0x3BD /* Debug Control Register 1 */ | ||
| 164 | #define SPRN_DBSR 0x3F0 /* Debug Status Register */ | ||
| 165 | #define SPRN_DCCR 0x3FA /* Data Cache Cacheability Register */ | ||
| 166 | #define DCCR_NOCACHE 0 /* Noncacheable */ | ||
| 167 | #define DCCR_CACHE 1 /* Cacheable */ | ||
| 168 | #define SPRN_DCMP 0x3D1 /* Data TLB Compare Register */ | ||
| 169 | #define SPRN_DCWR 0x3BA /* Data Cache Write-thru Register */ | ||
| 170 | #define DCWR_COPY 0 /* Copy-back */ | ||
| 171 | #define DCWR_WRITE 1 /* Write-through */ | ||
| 172 | #define SPRN_DEAR 0x3D5 /* Data Error Address Register */ | ||
| 173 | #define SPRN_DEC 0x016 /* Decrement Register */ | 127 | #define SPRN_DEC 0x016 /* Decrement Register */ |
| 174 | #define SPRN_DMISS 0x3D0 /* Data TLB Miss Register */ | ||
| 175 | #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ | 128 | #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ |
| 176 | #define DSISR_NOHPTE 0x40000000 /* no translation found */ | 129 | #define DSISR_NOHPTE 0x40000000 /* no translation found */ |
| 177 | #define DSISR_PROTFAULT 0x08000000 /* protection fault */ | 130 | #define DSISR_PROTFAULT 0x08000000 /* protection fault */ |
| 178 | #define DSISR_ISSTORE 0x02000000 /* access was a store */ | 131 | #define DSISR_ISSTORE 0x02000000 /* access was a store */ |
| 179 | #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */ | 132 | #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */ |
| 180 | #define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */ | 133 | #define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */ |
| 181 | #define SPRN_EAR 0x11A /* External Address Register */ | ||
| 182 | #define SPRN_ESR 0x3D4 /* Exception Syndrome Register */ | ||
| 183 | #define ESR_IMCP 0x80000000 /* Instr. Machine Check - Protection */ | ||
| 184 | #define ESR_IMCN 0x40000000 /* Instr. Machine Check - Non-config */ | ||
| 185 | #define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */ | ||
| 186 | #define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */ | ||
| 187 | #define ESR_PIL 0x08000000 /* Program Exception - Illegal */ | ||
| 188 | #define ESR_PPR 0x04000000 /* Program Exception - Priveleged */ | ||
| 189 | #define ESR_PTR 0x02000000 /* Program Exception - Trap */ | ||
| 190 | #define ESR_DST 0x00800000 /* Storage Exception - Data miss */ | ||
| 191 | #define ESR_DIZ 0x00400000 /* Storage Exception - Zone fault */ | ||
| 192 | #define SPRN_EVPR 0x3D6 /* Exception Vector Prefix Register */ | ||
| 193 | #define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */ | ||
| 194 | #define SPRN_HASH2 0x3D3 /* Secondary Hash Address Resgister */ | ||
| 195 | #define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ | 134 | #define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ |
| 196 | #define HID0_EMCP (1<<31) /* Enable Machine Check pin */ | ||
| 197 | #define HID0_EBA (1<<29) /* Enable Bus Address Parity */ | ||
| 198 | #define HID0_EBD (1<<28) /* Enable Bus Data Parity */ | ||
| 199 | #define HID0_SBCLK (1<<27) | ||
| 200 | #define HID0_EICE (1<<26) | ||
| 201 | #define HID0_ECLK (1<<25) | ||
| 202 | #define HID0_PAR (1<<24) | ||
| 203 | #define HID0_DOZE (1<<23) | ||
| 204 | #define HID0_NAP (1<<22) | ||
| 205 | #define HID0_SLEEP (1<<21) | ||
| 206 | #define HID0_DPM (1<<20) | ||
| 207 | #define HID0_ICE (1<<15) /* Instruction Cache Enable */ | ||
| 208 | #define HID0_DCE (1<<14) /* Data Cache Enable */ | ||
| 209 | #define HID0_ILOCK (1<<13) /* Instruction Cache Lock */ | ||
| 210 | #define HID0_DLOCK (1<<12) /* Data Cache Lock */ | ||
| 211 | #define HID0_ICFI (1<<11) /* Instr. Cache Flash Invalidate */ | ||
| 212 | #define HID0_DCI (1<<10) /* Data Cache Invalidate */ | ||
| 213 | #define HID0_SPD (1<<9) /* Speculative disable */ | ||
| 214 | #define HID0_SGE (1<<7) /* Store Gathering Enable */ | ||
| 215 | #define HID0_SIED (1<<7) /* Serial Instr. Execution [Disable] */ | ||
| 216 | #define HID0_BTIC (1<<5) /* Branch Target Instruction Cache Enable */ | ||
| 217 | #define HID0_ABE (1<<3) /* Address Broadcast Enable */ | ||
| 218 | #define HID0_BHTE (1<<2) /* Branch History Table Enable */ | ||
| 219 | #define HID0_BTCD (1<<1) /* Branch target cache disable */ | ||
| 220 | #define SPRN_MSRDORM 0x3F1 /* Hardware Implementation Register 1 */ | 135 | #define SPRN_MSRDORM 0x3F1 /* Hardware Implementation Register 1 */ |
| 221 | #define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ | 136 | #define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ |
| 222 | #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ | 137 | #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ |
| @@ -225,23 +140,8 @@ | |||
| 225 | #define SPRN_HID5 0x3F6 /* 970 HID5 */ | 140 | #define SPRN_HID5 0x3F6 /* 970 HID5 */ |
| 226 | #define SPRN_TSC 0x3FD /* Thread switch control */ | 141 | #define SPRN_TSC 0x3FD /* Thread switch control */ |
| 227 | #define SPRN_TST 0x3FC /* Thread switch timeout */ | 142 | #define SPRN_TST 0x3FC /* Thread switch timeout */ |
| 228 | #define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */ | ||
| 229 | #define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */ | ||
| 230 | #define SPRN_ICCR 0x3FB /* Instruction Cache Cacheability Register */ | ||
| 231 | #define ICCR_NOCACHE 0 /* Noncacheable */ | ||
| 232 | #define ICCR_CACHE 1 /* Cacheable */ | ||
| 233 | #define SPRN_ICDBDR 0x3D3 /* Instruction Cache Debug Data Register */ | ||
| 234 | #define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */ | ||
| 235 | #define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */ | ||
| 236 | #define SPRN_IMISS 0x3D4 /* Instruction TLB Miss Register */ | ||
| 237 | #define SPRN_IMMR 0x27E /* Internal Memory Map Register */ | ||
| 238 | #define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */ | 143 | #define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */ |
| 239 | #define SPRN_LR 0x008 /* Link Register */ | 144 | #define SPRN_LR 0x008 /* Link Register */ |
| 240 | #define SPRN_PBL1 0x3FC /* Protection Bound Lower 1 */ | ||
| 241 | #define SPRN_PBL2 0x3FE /* Protection Bound Lower 2 */ | ||
| 242 | #define SPRN_PBU1 0x3FD /* Protection Bound Upper 1 */ | ||
| 243 | #define SPRN_PBU2 0x3FF /* Protection Bound Upper 2 */ | ||
| 244 | #define SPRN_PID 0x3B1 /* Process ID */ | ||
| 245 | #define SPRN_PIR 0x3FF /* Processor Identification Register */ | 145 | #define SPRN_PIR 0x3FF /* Processor Identification Register */ |
| 246 | #define SPRN_PIT 0x3DB /* Programmable Interval Timer */ | 146 | #define SPRN_PIT 0x3DB /* Programmable Interval Timer */ |
| 247 | #define SPRN_PURR 0x135 /* Processor Utilization of Resources Register */ | 147 | #define SPRN_PURR 0x135 /* Processor Utilization of Resources Register */ |
| @@ -249,9 +149,6 @@ | |||
| 249 | #define SPRN_RPA 0x3D6 /* Required Physical Address Register */ | 149 | #define SPRN_RPA 0x3D6 /* Required Physical Address Register */ |
| 250 | #define SPRN_SDA 0x3BF /* Sampled Data Address Register */ | 150 | #define SPRN_SDA 0x3BF /* Sampled Data Address Register */ |
| 251 | #define SPRN_SDR1 0x019 /* MMU Hash Base Register */ | 151 | #define SPRN_SDR1 0x019 /* MMU Hash Base Register */ |
| 252 | #define SPRN_SGR 0x3B9 /* Storage Guarded Register */ | ||
| 253 | #define SGR_NORMAL 0 | ||
| 254 | #define SGR_GUARDED 1 | ||
| 255 | #define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ | 152 | #define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ |
| 256 | #define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ | 153 | #define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ |
| 257 | #define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ | 154 | #define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ |
| @@ -264,50 +161,12 @@ | |||
| 264 | #define SPRN_TBWL 0x11C /* Time Base Lower Register (super, W/O) */ | 161 | #define SPRN_TBWL 0x11C /* Time Base Lower Register (super, W/O) */ |
| 265 | #define SPRN_TBWU 0x11D /* Time Base Write Upper Register (super, W/O) */ | 162 | #define SPRN_TBWU 0x11D /* Time Base Write Upper Register (super, W/O) */ |
| 266 | #define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */ | 163 | #define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */ |
| 267 | #define SPRN_TCR 0x3DA /* Timer Control Register */ | ||
| 268 | #define TCR_WP(x) (((x)&0x3)<<30) /* WDT Period */ | ||
| 269 | #define WP_2_17 0 /* 2^17 clocks */ | ||
| 270 | #define WP_2_21 1 /* 2^21 clocks */ | ||
| 271 | #define WP_2_25 2 /* 2^25 clocks */ | ||
| 272 | #define WP_2_29 3 /* 2^29 clocks */ | ||
| 273 | #define TCR_WRC(x) (((x)&0x3)<<28) /* WDT Reset Control */ | ||
| 274 | #define WRC_NONE 0 /* No reset will occur */ | ||
| 275 | #define WRC_CORE 1 /* Core reset will occur */ | ||
| 276 | #define WRC_CHIP 2 /* Chip reset will occur */ | ||
| 277 | #define WRC_SYSTEM 3 /* System reset will occur */ | ||
| 278 | #define TCR_WIE 0x08000000 /* WDT Interrupt Enable */ | ||
| 279 | #define TCR_PIE 0x04000000 /* PIT Interrupt Enable */ | ||
| 280 | #define TCR_FP(x) (((x)&0x3)<<24) /* FIT Period */ | ||
| 281 | #define FP_2_9 0 /* 2^9 clocks */ | ||
| 282 | #define FP_2_13 1 /* 2^13 clocks */ | ||
| 283 | #define FP_2_17 2 /* 2^17 clocks */ | ||
| 284 | #define FP_2_21 3 /* 2^21 clocks */ | ||
| 285 | #define TCR_FIE 0x00800000 /* FIT Interrupt Enable */ | ||
| 286 | #define TCR_ARE 0x00400000 /* Auto Reload Enable */ | ||
| 287 | #define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */ | ||
| 288 | #define THRM1_TIN (1<<0) | ||
| 289 | #define THRM1_TIV (1<<1) | ||
| 290 | #define THRM1_THRES (0x7f<<2) | ||
| 291 | #define THRM1_TID (1<<29) | ||
| 292 | #define THRM1_TIE (1<<30) | ||
| 293 | #define THRM1_V (1<<31) | ||
| 294 | #define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */ | ||
| 295 | #define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */ | ||
| 296 | #define THRM3_E (1<<31) | ||
| 297 | #define SPRN_TSR 0x3D8 /* Timer Status Register */ | ||
| 298 | #define TSR_ENW 0x80000000 /* Enable Next Watchdog */ | ||
| 299 | #define TSR_WIS 0x40000000 /* WDT Interrupt Status */ | ||
| 300 | #define TSR_WRS(x) (((x)&0x3)<<28) /* WDT Reset Status */ | ||
| 301 | #define WRS_NONE 0 /* No WDT reset occurred */ | ||
| 302 | #define WRS_CORE 1 /* WDT forced core reset */ | ||
| 303 | #define WRS_CHIP 2 /* WDT forced chip reset */ | ||
| 304 | #define WRS_SYSTEM 3 /* WDT forced system reset */ | ||
| 305 | #define TSR_PIS 0x08000000 /* PIT Interrupt Status */ | ||
| 306 | #define TSR_FIS 0x04000000 /* FIT Interrupt Status */ | ||
| 307 | #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ | 164 | #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ |
| 308 | #define SPRN_XER 0x001 /* Fixed Point Exception Register */ | 165 | #define SPRN_XER 0x001 /* Fixed Point Exception Register */ |
| 309 | #define SPRN_ZPR 0x3B0 /* Zone Protection Register */ | ||
| 310 | #define SPRN_VRSAVE 0x100 /* Vector save */ | 166 | #define SPRN_VRSAVE 0x100 /* Vector save */ |
| 167 | #define SPRN_CTRLF 0x088 | ||
| 168 | #define SPRN_CTRLT 0x098 | ||
| 169 | #define CTRL_RUNLATCH 0x1 | ||
| 311 | 170 | ||
| 312 | /* Performance monitor SPRs */ | 171 | /* Performance monitor SPRs */ |
| 313 | #define SPRN_SIAR 780 | 172 | #define SPRN_SIAR 780 |
| @@ -352,28 +211,19 @@ | |||
| 352 | #define CTR SPRN_CTR /* Counter Register */ | 211 | #define CTR SPRN_CTR /* Counter Register */ |
| 353 | #define DAR SPRN_DAR /* Data Address Register */ | 212 | #define DAR SPRN_DAR /* Data Address Register */ |
| 354 | #define DABR SPRN_DABR /* Data Address Breakpoint Register */ | 213 | #define DABR SPRN_DABR /* Data Address Breakpoint Register */ |
| 355 | #define DCMP SPRN_DCMP /* Data TLB Compare Register */ | ||
| 356 | #define DEC SPRN_DEC /* Decrement Register */ | 214 | #define DEC SPRN_DEC /* Decrement Register */ |
| 357 | #define DMISS SPRN_DMISS /* Data TLB Miss Register */ | ||
| 358 | #define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */ | 215 | #define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */ |
| 359 | #define EAR SPRN_EAR /* External Address Register */ | ||
| 360 | #define HASH1 SPRN_HASH1 /* Primary Hash Address Register */ | ||
| 361 | #define HASH2 SPRN_HASH2 /* Secondary Hash Address Register */ | ||
| 362 | #define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */ | 216 | #define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */ |
| 363 | #define MSRDORM SPRN_MSRDORM /* MSR Dormant Register */ | 217 | #define MSRDORM SPRN_MSRDORM /* MSR Dormant Register */ |
| 364 | #define NIADORM SPRN_NIADORM /* NIA Dormant Register */ | 218 | #define NIADORM SPRN_NIADORM /* NIA Dormant Register */ |
| 365 | #define TSC SPRN_TSC /* Thread switch control */ | 219 | #define TSC SPRN_TSC /* Thread switch control */ |
| 366 | #define TST SPRN_TST /* Thread switch timeout */ | 220 | #define TST SPRN_TST /* Thread switch timeout */ |
| 367 | #define IABR SPRN_IABR /* Instruction Address Breakpoint Register */ | 221 | #define IABR SPRN_IABR /* Instruction Address Breakpoint Register */ |
| 368 | #define ICMP SPRN_ICMP /* Instruction TLB Compare Register */ | ||
| 369 | #define IMISS SPRN_IMISS /* Instruction TLB Miss Register */ | ||
| 370 | #define IMMR SPRN_IMMR /* PPC 860/821 Internal Memory Map Register */ | ||
| 371 | #define L2CR SPRN_L2CR /* PPC 750 L2 control register */ | 222 | #define L2CR SPRN_L2CR /* PPC 750 L2 control register */ |
| 372 | #define __LR SPRN_LR | 223 | #define __LR SPRN_LR |
| 373 | #define PVR SPRN_PVR /* Processor Version */ | 224 | #define PVR SPRN_PVR /* Processor Version */ |
| 374 | #define PIR SPRN_PIR /* Processor ID */ | 225 | #define PIR SPRN_PIR /* Processor ID */ |
| 375 | #define PURR SPRN_PURR /* Processor Utilization of Resource Register */ | 226 | #define PURR SPRN_PURR /* Processor Utilization of Resource Register */ |
| 376 | //#define RPA SPRN_RPA /* Required Physical Address Register */ | ||
| 377 | #define SDR1 SPRN_SDR1 /* MMU hash base register */ | 227 | #define SDR1 SPRN_SDR1 /* MMU hash base register */ |
| 378 | #define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */ | 228 | #define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */ |
| 379 | #define SPR1 SPRN_SPRG1 | 229 | #define SPR1 SPRN_SPRG1 |
| @@ -389,10 +239,6 @@ | |||
| 389 | #define TBRU SPRN_TBRU /* Time Base Read Upper Register */ | 239 | #define TBRU SPRN_TBRU /* Time Base Read Upper Register */ |
| 390 | #define TBWL SPRN_TBWL /* Time Base Write Lower Register */ | 240 | #define TBWL SPRN_TBWL /* Time Base Write Lower Register */ |
| 391 | #define TBWU SPRN_TBWU /* Time Base Write Upper Register */ | 241 | #define TBWU SPRN_TBWU /* Time Base Write Upper Register */ |
| 392 | #define ICTC 1019 | ||
| 393 | #define THRM1 SPRN_THRM1 /* Thermal Management Register 1 */ | ||
| 394 | #define THRM2 SPRN_THRM2 /* Thermal Management Register 2 */ | ||
| 395 | #define THRM3 SPRN_THRM3 /* Thermal Management Register 3 */ | ||
| 396 | #define XER SPRN_XER | 242 | #define XER SPRN_XER |
| 397 | 243 | ||
| 398 | /* Processor Version Register (PVR) field extraction */ | 244 | /* Processor Version Register (PVR) field extraction */ |
| @@ -436,12 +282,6 @@ | |||
| 436 | #define XGLUE(a,b) a##b | 282 | #define XGLUE(a,b) a##b |
| 437 | #define GLUE(a,b) XGLUE(a,b) | 283 | #define GLUE(a,b) XGLUE(a,b) |
| 438 | 284 | ||
| 439 | /* iSeries CTRL register (for runlatch) */ | ||
| 440 | |||
| 441 | #define CTRLT 0x098 | ||
| 442 | #define CTRLF 0x088 | ||
| 443 | #define RUNLATCH 0x0001 | ||
| 444 | |||
| 445 | #ifdef __ASSEMBLY__ | 285 | #ifdef __ASSEMBLY__ |
| 446 | 286 | ||
| 447 | #define _GLOBAL(name) \ | 287 | #define _GLOBAL(name) \ |
| @@ -656,6 +496,24 @@ static inline void prefetchw(const void *x) | |||
| 656 | 496 | ||
| 657 | #define HAVE_ARCH_PICK_MMAP_LAYOUT | 497 | #define HAVE_ARCH_PICK_MMAP_LAYOUT |
| 658 | 498 | ||
| 499 | static inline void ppc64_runlatch_on(void) | ||
| 500 | { | ||
| 501 | unsigned long ctrl; | ||
| 502 | |||
| 503 | ctrl = mfspr(SPRN_CTRLF); | ||
| 504 | ctrl |= CTRL_RUNLATCH; | ||
| 505 | mtspr(SPRN_CTRLT, ctrl); | ||
| 506 | } | ||
| 507 | |||
| 508 | static inline void ppc64_runlatch_off(void) | ||
| 509 | { | ||
| 510 | unsigned long ctrl; | ||
| 511 | |||
| 512 | ctrl = mfspr(SPRN_CTRLF); | ||
| 513 | ctrl &= ~CTRL_RUNLATCH; | ||
| 514 | mtspr(SPRN_CTRLT, ctrl); | ||
| 515 | } | ||
| 516 | |||
| 659 | #endif /* __KERNEL__ */ | 517 | #endif /* __KERNEL__ */ |
| 660 | 518 | ||
| 661 | #endif /* __ASSEMBLY__ */ | 519 | #endif /* __ASSEMBLY__ */ |
diff --git a/include/asm-ppc64/thread_info.h b/include/asm-ppc64/thread_info.h index 037b5e06083c..48b7900e90ec 100644 --- a/include/asm-ppc64/thread_info.h +++ b/include/asm-ppc64/thread_info.h | |||
| @@ -96,7 +96,7 @@ static inline struct thread_info *current_thread_info(void) | |||
| 96 | #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling | 96 | #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling |
| 97 | TIF_NEED_RESCHED */ | 97 | TIF_NEED_RESCHED */ |
| 98 | #define TIF_32BIT 5 /* 32 bit binary */ | 98 | #define TIF_32BIT 5 /* 32 bit binary */ |
| 99 | #define TIF_RUN_LIGHT 6 /* iSeries run light */ | 99 | /* #define SPARE 6 */ |
| 100 | #define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */ | 100 | #define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */ |
| 101 | #define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */ | 101 | #define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */ |
| 102 | #define TIF_SINGLESTEP 9 /* singlestepping active */ | 102 | #define TIF_SINGLESTEP 9 /* singlestepping active */ |
| @@ -110,7 +110,7 @@ static inline struct thread_info *current_thread_info(void) | |||
| 110 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | 110 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
| 111 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | 111 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) |
| 112 | #define _TIF_32BIT (1<<TIF_32BIT) | 112 | #define _TIF_32BIT (1<<TIF_32BIT) |
| 113 | #define _TIF_RUN_LIGHT (1<<TIF_RUN_LIGHT) | 113 | /* #define _SPARE (1<<SPARE) */ |
| 114 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) | 114 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) |
| 115 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | 115 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) |
| 116 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | 116 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) |
diff --git a/include/asm-s390/user.h b/include/asm-s390/user.h index c64f8c181df3..1dc74baf03c4 100644 --- a/include/asm-s390/user.h +++ b/include/asm-s390/user.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | #define _S390_USER_H | 10 | #define _S390_USER_H |
| 11 | 11 | ||
| 12 | #include <asm/page.h> | 12 | #include <asm/page.h> |
| 13 | #include <linux/ptrace.h> | 13 | #include <asm/ptrace.h> |
| 14 | /* Core file format: The core file is written in such a way that gdb | 14 | /* Core file format: The core file is written in such a way that gdb |
| 15 | can understand it and provide useful information to the user (under | 15 | can understand it and provide useful information to the user (under |
| 16 | linux we use the 'trad-core' bfd). There are quite a number of | 16 | linux we use the 'trad-core' bfd). There are quite a number of |
diff --git a/include/linux/if_shaper.h b/include/linux/if_shaper.h index 0485b256d043..004e6f09a6e2 100644 --- a/include/linux/if_shaper.h +++ b/include/linux/if_shaper.h | |||
| @@ -23,7 +23,7 @@ struct shaper | |||
| 23 | __u32 shapeclock; | 23 | __u32 shapeclock; |
| 24 | unsigned long recovery; /* Time we can next clock a packet out on | 24 | unsigned long recovery; /* Time we can next clock a packet out on |
| 25 | an empty queue */ | 25 | an empty queue */ |
| 26 | unsigned long locked; | 26 | struct semaphore sem; |
| 27 | struct net_device_stats stats; | 27 | struct net_device_stats stats; |
| 28 | struct net_device *dev; | 28 | struct net_device *dev; |
| 29 | int (*hard_start_xmit) (struct sk_buff *skb, | 29 | int (*hard_start_xmit) (struct sk_buff *skb, |
| @@ -38,7 +38,6 @@ struct shaper | |||
| 38 | int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh); | 38 | int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh); |
| 39 | void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr); | 39 | void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr); |
| 40 | struct net_device_stats* (*get_stats)(struct net_device *dev); | 40 | struct net_device_stats* (*get_stats)(struct net_device *dev); |
| 41 | wait_queue_head_t wait_queue; | ||
| 42 | struct timer_list timer; | 41 | struct timer_list timer; |
| 43 | }; | 42 | }; |
| 44 | 43 | ||
diff --git a/include/linux/libata.h b/include/linux/libata.h index e74f301e9bae..b009f801e7c5 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
| @@ -467,12 +467,34 @@ static inline u8 ata_chk_status(struct ata_port *ap) | |||
| 467 | return ap->ops->check_status(ap); | 467 | return ap->ops->check_status(ap); |
| 468 | } | 468 | } |
| 469 | 469 | ||
| 470 | |||
| 471 | /** | ||
| 472 | * ata_pause - Flush writes and pause 400 nanoseconds. | ||
| 473 | * @ap: Port to wait for. | ||
| 474 | * | ||
| 475 | * LOCKING: | ||
| 476 | * Inherited from caller. | ||
| 477 | */ | ||
| 478 | |||
| 470 | static inline void ata_pause(struct ata_port *ap) | 479 | static inline void ata_pause(struct ata_port *ap) |
| 471 | { | 480 | { |
| 472 | ata_altstatus(ap); | 481 | ata_altstatus(ap); |
| 473 | ndelay(400); | 482 | ndelay(400); |
| 474 | } | 483 | } |
| 475 | 484 | ||
| 485 | |||
| 486 | /** | ||
| 487 | * ata_busy_wait - Wait for a port status register | ||
| 488 | * @ap: Port to wait for. | ||
| 489 | * | ||
| 490 | * Waits up to max*10 microseconds for the selected bits in the port's | ||
| 491 | * status register to be cleared. | ||
| 492 | * Returns final value of status register. | ||
| 493 | * | ||
| 494 | * LOCKING: | ||
| 495 | * Inherited from caller. | ||
| 496 | */ | ||
| 497 | |||
| 476 | static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, | 498 | static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, |
| 477 | unsigned int max) | 499 | unsigned int max) |
| 478 | { | 500 | { |
| @@ -487,6 +509,18 @@ static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, | |||
| 487 | return status; | 509 | return status; |
| 488 | } | 510 | } |
| 489 | 511 | ||
| 512 | |||
| 513 | /** | ||
| 514 | * ata_wait_idle - Wait for a port to be idle. | ||
| 515 | * @ap: Port to wait for. | ||
| 516 | * | ||
| 517 | * Waits up to 10ms for port's BUSY and DRQ signals to clear. | ||
| 518 | * Returns final value of status register. | ||
| 519 | * | ||
| 520 | * LOCKING: | ||
| 521 | * Inherited from caller. | ||
| 522 | */ | ||
| 523 | |||
| 490 | static inline u8 ata_wait_idle(struct ata_port *ap) | 524 | static inline u8 ata_wait_idle(struct ata_port *ap) |
| 491 | { | 525 | { |
| 492 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | 526 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); |
| @@ -525,6 +559,18 @@ static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, uns | |||
| 525 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; | 559 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; |
| 526 | } | 560 | } |
| 527 | 561 | ||
| 562 | |||
| 563 | /** | ||
| 564 | * ata_irq_on - Enable interrupts on a port. | ||
| 565 | * @ap: Port on which interrupts are enabled. | ||
| 566 | * | ||
| 567 | * Enable interrupts on a legacy IDE device using MMIO or PIO, | ||
| 568 | * wait for idle, clear any pending interrupts. | ||
| 569 | * | ||
| 570 | * LOCKING: | ||
| 571 | * Inherited from caller. | ||
| 572 | */ | ||
| 573 | |||
| 528 | static inline u8 ata_irq_on(struct ata_port *ap) | 574 | static inline u8 ata_irq_on(struct ata_port *ap) |
| 529 | { | 575 | { |
| 530 | struct ata_ioports *ioaddr = &ap->ioaddr; | 576 | struct ata_ioports *ioaddr = &ap->ioaddr; |
| @@ -544,6 +590,18 @@ static inline u8 ata_irq_on(struct ata_port *ap) | |||
| 544 | return tmp; | 590 | return tmp; |
| 545 | } | 591 | } |
| 546 | 592 | ||
| 593 | |||
| 594 | /** | ||
| 595 | * ata_irq_ack - Acknowledge a device interrupt. | ||
| 596 | * @ap: Port on which interrupts are enabled. | ||
| 597 | * | ||
| 598 | * Wait up to 10 ms for legacy IDE device to become idle (BUSY | ||
| 599 | * or BUSY+DRQ clear). Obtain dma status and port status from | ||
| 600 | * device. Clear the interrupt. Return port status. | ||
| 601 | * | ||
| 602 | * LOCKING: | ||
| 603 | */ | ||
| 604 | |||
| 547 | static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | 605 | static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) |
| 548 | { | 606 | { |
| 549 | unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; | 607 | unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 470af8c1a4a0..ba5d1236aa17 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -204,7 +204,7 @@ struct hh_cache | |||
| 204 | /* cached hardware header; allow for machine alignment needs. */ | 204 | /* cached hardware header; allow for machine alignment needs. */ |
| 205 | #define HH_DATA_MOD 16 | 205 | #define HH_DATA_MOD 16 |
| 206 | #define HH_DATA_OFF(__len) \ | 206 | #define HH_DATA_OFF(__len) \ |
| 207 | (HH_DATA_MOD - ((__len) & (HH_DATA_MOD - 1))) | 207 | (HH_DATA_MOD - (((__len - 1) & (HH_DATA_MOD - 1)) + 1)) |
| 208 | #define HH_DATA_ALIGN(__len) \ | 208 | #define HH_DATA_ALIGN(__len) \ |
| 209 | (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1)) | 209 | (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1)) |
| 210 | unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; | 210 | unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 41d1a644c9d4..2d1ac5058534 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -796,6 +796,10 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *); | |||
| 796 | * of the iso_frame_desc array, and the number of errors is reported in | 796 | * of the iso_frame_desc array, and the number of errors is reported in |
| 797 | * error_count. Completion callbacks for ISO transfers will normally | 797 | * error_count. Completion callbacks for ISO transfers will normally |
| 798 | * (re)submit URBs to ensure a constant transfer rate. | 798 | * (re)submit URBs to ensure a constant transfer rate. |
| 799 | * | ||
| 800 | * Note that even fields marked "public" should not be touched by the driver | ||
| 801 | * when the urb is owned by the hcd, that is, since the call to | ||
| 802 | * usb_submit_urb() till the entry into the completion routine. | ||
| 799 | */ | 803 | */ |
| 800 | struct urb | 804 | struct urb |
| 801 | { | 805 | { |
| @@ -803,12 +807,12 @@ struct urb | |||
| 803 | struct kref kref; /* reference count of the URB */ | 807 | struct kref kref; /* reference count of the URB */ |
| 804 | spinlock_t lock; /* lock for the URB */ | 808 | spinlock_t lock; /* lock for the URB */ |
| 805 | void *hcpriv; /* private data for host controller */ | 809 | void *hcpriv; /* private data for host controller */ |
| 806 | struct list_head urb_list; /* list pointer to all active urbs */ | ||
| 807 | int bandwidth; /* bandwidth for INT/ISO request */ | 810 | int bandwidth; /* bandwidth for INT/ISO request */ |
| 808 | atomic_t use_count; /* concurrent submissions counter */ | 811 | atomic_t use_count; /* concurrent submissions counter */ |
| 809 | u8 reject; /* submissions will fail */ | 812 | u8 reject; /* submissions will fail */ |
| 810 | 813 | ||
| 811 | /* public, documented fields in the urb that can be used by drivers */ | 814 | /* public, documented fields in the urb that can be used by drivers */ |
| 815 | struct list_head urb_list; /* list head for use by the urb owner */ | ||
| 812 | struct usb_device *dev; /* (in) pointer to associated device */ | 816 | struct usb_device *dev; /* (in) pointer to associated device */ |
| 813 | unsigned int pipe; /* (in) pipe information */ | 817 | unsigned int pipe; /* (in) pipe information */ |
| 814 | int status; /* (return) non-ISO status */ | 818 | int status; /* (return) non-ISO status */ |
diff --git a/net/ipv4/ipvs/Makefile b/net/ipv4/ipvs/Makefile index a788461a40c9..30e85de9ffff 100644 --- a/net/ipv4/ipvs/Makefile +++ b/net/ipv4/ipvs/Makefile | |||
| @@ -11,7 +11,7 @@ ip_vs_proto-objs-$(CONFIG_IP_VS_PROTO_AH) += ip_vs_proto_ah.o | |||
| 11 | 11 | ||
| 12 | ip_vs-objs := ip_vs_conn.o ip_vs_core.o ip_vs_ctl.o ip_vs_sched.o \ | 12 | ip_vs-objs := ip_vs_conn.o ip_vs_core.o ip_vs_ctl.o ip_vs_sched.o \ |
| 13 | ip_vs_xmit.o ip_vs_app.o ip_vs_sync.o \ | 13 | ip_vs_xmit.o ip_vs_app.o ip_vs_sync.o \ |
| 14 | ip_vs_est.o ip_vs_proto.o ip_vs_proto_icmp.o \ | 14 | ip_vs_est.o ip_vs_proto.o \ |
| 15 | $(ip_vs_proto-objs-y) | 15 | $(ip_vs_proto-objs-y) |
| 16 | 16 | ||
| 17 | 17 | ||
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c index 253c46252bd5..867d4e9c6594 100644 --- a/net/ipv4/ipvs/ip_vs_proto.c +++ b/net/ipv4/ipvs/ip_vs_proto.c | |||
| @@ -216,9 +216,6 @@ int ip_vs_protocol_init(void) | |||
| 216 | #ifdef CONFIG_IP_VS_PROTO_UDP | 216 | #ifdef CONFIG_IP_VS_PROTO_UDP |
| 217 | REGISTER_PROTOCOL(&ip_vs_protocol_udp); | 217 | REGISTER_PROTOCOL(&ip_vs_protocol_udp); |
| 218 | #endif | 218 | #endif |
| 219 | #ifdef CONFIG_IP_VS_PROTO_ICMP | ||
| 220 | REGISTER_PROTOCOL(&ip_vs_protocol_icmp); | ||
| 221 | #endif | ||
| 222 | #ifdef CONFIG_IP_VS_PROTO_AH | 219 | #ifdef CONFIG_IP_VS_PROTO_AH |
| 223 | REGISTER_PROTOCOL(&ip_vs_protocol_ah); | 220 | REGISTER_PROTOCOL(&ip_vs_protocol_ah); |
| 224 | #endif | 221 | #endif |
diff --git a/net/ipv4/ipvs/ip_vs_proto_icmp.c b/net/ipv4/ipvs/ip_vs_proto_icmp.c deleted file mode 100644 index 191e94aa1c1f..000000000000 --- a/net/ipv4/ipvs/ip_vs_proto_icmp.c +++ /dev/null | |||
| @@ -1,182 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * ip_vs_proto_icmp.c: ICMP load balancing support for IP Virtual Server | ||
| 3 | * | ||
| 4 | * Authors: Julian Anastasov <ja@ssi.bg>, March 2002 | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License | ||
| 8 | * version 2 as published by the Free Software Foundation; | ||
| 9 | * | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/module.h> | ||
| 13 | #include <linux/kernel.h> | ||
| 14 | #include <linux/icmp.h> | ||
| 15 | #include <linux/netfilter.h> | ||
| 16 | #include <linux/netfilter_ipv4.h> | ||
| 17 | |||
| 18 | #include <net/ip_vs.h> | ||
| 19 | |||
| 20 | |||
| 21 | static int icmp_timeouts[1] = { 1*60*HZ }; | ||
| 22 | |||
| 23 | static char * icmp_state_name_table[1] = { "ICMP" }; | ||
| 24 | |||
| 25 | static struct ip_vs_conn * | ||
| 26 | icmp_conn_in_get(const struct sk_buff *skb, | ||
| 27 | struct ip_vs_protocol *pp, | ||
| 28 | const struct iphdr *iph, | ||
| 29 | unsigned int proto_off, | ||
| 30 | int inverse) | ||
| 31 | { | ||
| 32 | #if 0 | ||
| 33 | struct ip_vs_conn *cp; | ||
| 34 | |||
| 35 | if (likely(!inverse)) { | ||
| 36 | cp = ip_vs_conn_in_get(iph->protocol, | ||
| 37 | iph->saddr, 0, | ||
| 38 | iph->daddr, 0); | ||
| 39 | } else { | ||
| 40 | cp = ip_vs_conn_in_get(iph->protocol, | ||
| 41 | iph->daddr, 0, | ||
| 42 | iph->saddr, 0); | ||
| 43 | } | ||
| 44 | |||
| 45 | return cp; | ||
| 46 | |||
| 47 | #else | ||
| 48 | return NULL; | ||
| 49 | #endif | ||
| 50 | } | ||
| 51 | |||
| 52 | static struct ip_vs_conn * | ||
| 53 | icmp_conn_out_get(const struct sk_buff *skb, | ||
| 54 | struct ip_vs_protocol *pp, | ||
| 55 | const struct iphdr *iph, | ||
| 56 | unsigned int proto_off, | ||
| 57 | int inverse) | ||
| 58 | { | ||
| 59 | #if 0 | ||
| 60 | struct ip_vs_conn *cp; | ||
| 61 | |||
| 62 | if (likely(!inverse)) { | ||
| 63 | cp = ip_vs_conn_out_get(iph->protocol, | ||
| 64 | iph->saddr, 0, | ||
| 65 | iph->daddr, 0); | ||
| 66 | } else { | ||
| 67 | cp = ip_vs_conn_out_get(IPPROTO_UDP, | ||
| 68 | iph->daddr, 0, | ||
| 69 | iph->saddr, 0); | ||
| 70 | } | ||
| 71 | |||
| 72 | return cp; | ||
| 73 | #else | ||
| 74 | return NULL; | ||
| 75 | #endif | ||
| 76 | } | ||
| 77 | |||
| 78 | static int | ||
| 79 | icmp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp, | ||
| 80 | int *verdict, struct ip_vs_conn **cpp) | ||
| 81 | { | ||
| 82 | *verdict = NF_ACCEPT; | ||
| 83 | return 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | static int | ||
| 87 | icmp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp) | ||
| 88 | { | ||
| 89 | if (!(skb->nh.iph->frag_off & __constant_htons(IP_OFFSET))) { | ||
| 90 | if (skb->ip_summed != CHECKSUM_UNNECESSARY) { | ||
| 91 | if (ip_vs_checksum_complete(skb, skb->nh.iph->ihl * 4)) { | ||
| 92 | IP_VS_DBG_RL_PKT(0, pp, skb, 0, "Failed checksum for"); | ||
| 93 | return 0; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | } | ||
| 97 | return 1; | ||
| 98 | } | ||
| 99 | |||
| 100 | static void | ||
| 101 | icmp_debug_packet(struct ip_vs_protocol *pp, | ||
| 102 | const struct sk_buff *skb, | ||
| 103 | int offset, | ||
| 104 | const char *msg) | ||
| 105 | { | ||
| 106 | char buf[256]; | ||
| 107 | struct iphdr _iph, *ih; | ||
| 108 | |||
| 109 | ih = skb_header_pointer(skb, offset, sizeof(_iph), &_iph); | ||
| 110 | if (ih == NULL) | ||
| 111 | sprintf(buf, "%s TRUNCATED", pp->name); | ||
| 112 | else if (ih->frag_off & __constant_htons(IP_OFFSET)) | ||
| 113 | sprintf(buf, "%s %u.%u.%u.%u->%u.%u.%u.%u frag", | ||
| 114 | pp->name, NIPQUAD(ih->saddr), | ||
| 115 | NIPQUAD(ih->daddr)); | ||
| 116 | else { | ||
| 117 | struct icmphdr _icmph, *ic; | ||
| 118 | |||
| 119 | ic = skb_header_pointer(skb, offset + ih->ihl*4, | ||
| 120 | sizeof(_icmph), &_icmph); | ||
| 121 | if (ic == NULL) | ||
| 122 | sprintf(buf, "%s TRUNCATED to %u bytes\n", | ||
| 123 | pp->name, skb->len - offset); | ||
| 124 | else | ||
| 125 | sprintf(buf, "%s %u.%u.%u.%u->%u.%u.%u.%u T:%d C:%d", | ||
| 126 | pp->name, NIPQUAD(ih->saddr), | ||
| 127 | NIPQUAD(ih->daddr), | ||
| 128 | ic->type, ic->code); | ||
| 129 | } | ||
| 130 | printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf); | ||
| 131 | } | ||
| 132 | |||
| 133 | static int | ||
| 134 | icmp_state_transition(struct ip_vs_conn *cp, int direction, | ||
| 135 | const struct sk_buff *skb, | ||
| 136 | struct ip_vs_protocol *pp) | ||
| 137 | { | ||
| 138 | cp->timeout = pp->timeout_table[IP_VS_ICMP_S_NORMAL]; | ||
| 139 | return 1; | ||
| 140 | } | ||
| 141 | |||
| 142 | static int | ||
| 143 | icmp_set_state_timeout(struct ip_vs_protocol *pp, char *sname, int to) | ||
| 144 | { | ||
| 145 | int num; | ||
| 146 | char **names; | ||
| 147 | |||
| 148 | num = IP_VS_ICMP_S_LAST; | ||
| 149 | names = icmp_state_name_table; | ||
| 150 | return ip_vs_set_state_timeout(pp->timeout_table, num, names, sname, to); | ||
| 151 | } | ||
| 152 | |||
| 153 | |||
| 154 | static void icmp_init(struct ip_vs_protocol *pp) | ||
| 155 | { | ||
| 156 | pp->timeout_table = icmp_timeouts; | ||
| 157 | } | ||
| 158 | |||
| 159 | static void icmp_exit(struct ip_vs_protocol *pp) | ||
| 160 | { | ||
| 161 | } | ||
| 162 | |||
| 163 | struct ip_vs_protocol ip_vs_protocol_icmp = { | ||
| 164 | .name = "ICMP", | ||
| 165 | .protocol = IPPROTO_ICMP, | ||
| 166 | .dont_defrag = 0, | ||
| 167 | .init = icmp_init, | ||
| 168 | .exit = icmp_exit, | ||
| 169 | .conn_schedule = icmp_conn_schedule, | ||
| 170 | .conn_in_get = icmp_conn_in_get, | ||
| 171 | .conn_out_get = icmp_conn_out_get, | ||
| 172 | .snat_handler = NULL, | ||
| 173 | .dnat_handler = NULL, | ||
| 174 | .csum_check = icmp_csum_check, | ||
| 175 | .state_transition = icmp_state_transition, | ||
| 176 | .register_app = NULL, | ||
| 177 | .unregister_app = NULL, | ||
| 178 | .app_conn_bind = NULL, | ||
| 179 | .debug_packet = icmp_debug_packet, | ||
| 180 | .timeout_change = NULL, | ||
| 181 | .set_state_timeout = icmp_set_state_timeout, | ||
| 182 | }; | ||
diff --git a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c index 2f4c91ddc9a3..5ade5a5d1990 100644 --- a/net/ipv6/ipv6_syms.c +++ b/net/ipv6/ipv6_syms.c | |||
| @@ -37,5 +37,4 @@ EXPORT_SYMBOL(in6_dev_finish_destroy); | |||
| 37 | EXPORT_SYMBOL(xfrm6_rcv); | 37 | EXPORT_SYMBOL(xfrm6_rcv); |
| 38 | #endif | 38 | #endif |
| 39 | EXPORT_SYMBOL(rt6_lookup); | 39 | EXPORT_SYMBOL(rt6_lookup); |
| 40 | EXPORT_SYMBOL(fl6_sock_lookup); | ||
| 41 | EXPORT_SYMBOL(ipv6_push_nfrag_opts); | 40 | EXPORT_SYMBOL(ipv6_push_nfrag_opts); |
