aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-06-06 03:21:03 -0400
committerDmitry Torokhov <dtor_core@ameritech.net>2005-06-06 03:21:03 -0400
commit3c241f8337542655ee013a661b7f1770f561d3ef (patch)
tree79dd9a5dd12d305e1be7b926d414855377d2e192
parentdbf4ccd6043e58ed32fbf253fb3f0a9991e4c13a (diff)
parenteae936e21bd726f9d9555f2262d439fbcd61dccf (diff)
Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
-rw-r--r--Documentation/DocBook/libata.tmpl156
-rw-r--r--MAINTAINERS6
-rw-r--r--arch/ia64/ia32/sys_ia32.c2
-rw-r--r--arch/ia64/kernel/mca.c4
-rw-r--r--arch/m68knommu/kernel/process.c17
-rw-r--r--arch/ppc/syslib/prom_init.c10
-rw-r--r--arch/ppc64/kernel/entry.S9
-rw-r--r--arch/ppc64/kernel/head.S10
-rw-r--r--arch/ppc64/kernel/iSeries_setup.c22
-rw-r--r--arch/ppc64/kernel/idle.c8
-rw-r--r--arch/ppc64/kernel/pSeries_reconfig.c8
-rw-r--r--arch/ppc64/kernel/process.c3
-rw-r--r--arch/ppc64/kernel/prom_init.c112
-rw-r--r--arch/ppc64/kernel/setup.c56
-rw-r--r--arch/ppc64/kernel/smp.c3
-rw-r--r--arch/ppc64/kernel/sysfs.c8
-rw-r--r--arch/s390/appldata/appldata_base.c72
-rw-r--r--arch/s390/appldata/appldata_mem.c2
-rw-r--r--arch/s390/appldata/appldata_net_sum.c2
-rw-r--r--arch/s390/appldata/appldata_os.c4
-rw-r--r--arch/s390/kernel/ptrace.c55
-rw-r--r--arch/s390/mm/fault.c2
-rw-r--r--arch/sparc64/kernel/pci_iommu.c88
-rw-r--r--arch/sparc64/kernel/pci_psycho.c2
-rw-r--r--arch/sparc64/kernel/pci_sabre.c2
-rw-r--r--arch/sparc64/kernel/pci_schizo.c2
-rw-r--r--arch/sparc64/kernel/sbus.c20
-rw-r--r--drivers/atm/Makefile3
-rw-r--r--drivers/atm/fore200e.c6
-rw-r--r--drivers/atm/he.c6
-rw-r--r--drivers/atm/nicstar.c20
-rw-r--r--drivers/atm/zatm.c11
-rw-r--r--drivers/block/ub.c598
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c46
-rw-r--r--drivers/ide/pci/amd74xx.c3
-rw-r--r--drivers/net/hamradio/baycom_epp.c126
-rw-r--r--drivers/net/pcmcia/3c574_cs.c3
-rw-r--r--drivers/net/r8169.c31
-rw-r--r--drivers/net/shaper.c86
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c302
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c144
-rw-r--r--drivers/pci/hotplug/shpchprm_acpi.c4
-rw-r--r--drivers/scsi/ata_piix.c16
-rw-r--r--drivers/scsi/libata-core.c470
-rw-r--r--drivers/scsi/libata-scsi.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c24
-rw-r--r--drivers/scsi/scsi_scan.c1
-rw-r--r--drivers/serial/vr41xx_siu.c66
-rw-r--r--drivers/usb/core/sysfs.c22
-rw-r--r--drivers/usb/host/Kconfig11
-rw-r--r--drivers/usb/host/Makefile1
-rw-r--r--drivers/usb/host/sl811-hcd.c146
-rw-r--r--drivers/usb/host/sl811_cs.c442
-rw-r--r--drivers/usb/input/hid-core.c18
-rw-r--r--drivers/usb/media/pwc/ChangeLog143
-rw-r--r--drivers/usb/net/usbnet.c2
-rw-r--r--drivers/usb/serial/Kconfig11
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/cp2101.c363
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.h2
-rw-r--r--drivers/usb/serial/option.c729
-rw-r--r--drivers/usb/serial/usb-serial.c20
-rw-r--r--drivers/usb/storage/unusual_devs.h9
-rw-r--r--fs/cifs/README4
-rw-r--r--fs/cifs/cifsproto.h2
-rw-r--r--fs/cifs/cifssmb.c56
-rw-r--r--fs/cifs/dir.c3
-rw-r--r--fs/cifs/inode.c24
-rw-r--r--fs/cifs/misc.c1
-rw-r--r--fs/jbd/checkpoint.c5
-rw-r--r--fs/mpage.c5
-rw-r--r--fs/proc/proc_devtree.c105
-rw-r--r--include/asm-ppc64/processor.h186
-rw-r--r--include/asm-ppc64/prom.h13
-rw-r--r--include/asm-ppc64/thread_info.h4
-rw-r--r--include/asm-s390/user.h2
-rw-r--r--include/asm-sparc64/iommu.h2
-rw-r--r--include/asm-sparc64/pbm.h8
-rw-r--r--include/linux/if_shaper.h3
-rw-r--r--include/linux/libata.h58
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/pci_ids.h6
-rw-r--r--include/linux/usb.h6
-rw-r--r--net/ipv4/esp4.c2
-rw-r--r--net/ipv4/ipvs/Makefile2
-rw-r--r--net/ipv4/ipvs/ip_vs_proto.c3
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_icmp.c182
-rw-r--r--net/ipv4/netfilter/ip_queue.c10
-rw-r--r--net/ipv4/udp.c12
-rw-r--r--net/ipv6/ipv6_syms.c1
-rw-r--r--net/sched/sch_dsmark.c16
92 files changed, 3416 insertions, 1883 deletions
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index cf2fce7707d..6df1dfd18b6 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&lt;-&gt;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>
72void (*port_disable) (struct ata_port *); 80void (*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>
82void (*dev_config) (struct ata_port *, struct ata_device *); 93void (*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>
92void (*set_piomode) (struct ata_port *, struct ata_device *); 106void (*set_piomode) (struct ata_port *, struct ata_device *);
93void (*set_dmamode) (struct ata_port *, struct ata_device *); 107void (*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>
112void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); 129void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);
113void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); 130void (*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>
124void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); 144void (*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>
156int (*check_atapi_dma) (struct ata_queued_cmd *qc);
157 </programlisting>
158
159 <para>
160Allow low-level driver to filter ATA PACKET commands, returning a status
161indicating whether or not it is OK to use DMA for the supplied PACKET
162command.
163 </para>
164
165 </sect2>
166
167 <sect2><title>Read specific ATA shadow registers</title>
132 <programlisting> 168 <programlisting>
133u8 (*check_status)(struct ata_port *ap); 169u8 (*check_status)(struct ata_port *ap);
134void (*dev_select)(struct ata_port *ap, unsigned int device); 170u8 (*check_altstatus)(struct ata_port *ap);
171u8 (*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>
144void (*dev_select)(struct ata_port *ap, unsigned int device); 184void (*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
191meaning on FIS-based devices.
151 </para> 192 </para>
152 193
194 </sect2>
195
196 <sect2><title>Reset ATA bus</title>
153 <programlisting> 197 <programlisting>
154void (*phy_reset) (struct ata_port *ap); 198void (*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>
166void (*bmdma_setup) (struct ata_queued_cmd *qc); 213void (*bmdma_setup) (struct ata_queued_cmd *qc);
167void (*bmdma_start) (struct ata_queued_cmd *qc); 214void (*bmdma_start) (struct ata_queued_cmd *qc);
215void (*bmdma_stop) (struct ata_port *ap);
216u8 (*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 220When 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. 222the hardware's DMA engine. ->bmdma_status is used to read the standard
223PCI IDE DMA Status register.
174 </para> 224 </para>
175 225
226 <para>
227These hooks are typically either no-ops, or simply not implemented, in
228FIS-based drivers.
229 </para>
230
231 </sect2>
232
233 <sect2><title>High-level taskfile hooks</title>
176 <programlisting> 234 <programlisting>
177void (*qc_prep) (struct ata_queued_cmd *qc); 235void (*qc_prep) (struct ata_queued_cmd *qc);
178int (*qc_issue) (struct ata_queued_cmd *qc); 236int (*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>
199void (*eng_timeout) (struct ata_port *ap); 258void (*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 262This is a high level error handling function, called from the
204 error handling thread, when a command times out. 263error handling thread, when a command times out. Most newer
264hardware will implement its own error handling code here. IDE BMDMA
265drivers 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>
208irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); 272irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);
209void (*irq_clear) (struct ata_port *); 273void (*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>
220u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); 287u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
221void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, 288void (*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>
231int (*port_start) (struct ata_port *ap); 301int (*port_start) (struct ata_port *ap);
232void (*port_stop) (struct ata_port *ap); 302void (*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
319have completed. The hook must finalize hardware shutdown, release DMA
320and 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>
diff --git a/MAINTAINERS b/MAINTAINERS
index 97bc927d2c5..65ad8251e4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -239,6 +239,12 @@ L: linux-usb-devel@lists.sourceforge.net
239W: http://www.linux-usb.org/SpeedTouch/ 239W: http://www.linux-usb.org/SpeedTouch/
240S: Maintained 240S: Maintained
241 241
242ALI1563 I2C DRIVER
243P: Rudolf Marek
244M: r.marek@sh.cvut.cz
245L: sensors@stimpy.netroedge.com
246S: Maintained
247
242ALPHA PORT 248ALPHA PORT
243P: Richard Henderson 249P: Richard Henderson
244M: rth@twiddle.net 250M: rth@twiddle.net
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 247a21c64ae..c1e20d65dd6 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -2427,7 +2427,7 @@ sys32_epoll_wait(int epfd, struct epoll_event32 __user * events, int maxevents,
2427{ 2427{
2428 struct epoll_event *events64 = NULL; 2428 struct epoll_event *events64 = NULL;
2429 mm_segment_t old_fs = get_fs(); 2429 mm_segment_t old_fs = get_fs();
2430 int error, numevents, size; 2430 int numevents, size;
2431 int evt_idx; 2431 int evt_idx;
2432 int do_free_pages = 0; 2432 int do_free_pages = 0;
2433 2433
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 2c75741dcc6..736e328b5e6 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1103,8 +1103,6 @@ ia64_mca_cpe_int_caller(int cpe_irq, void *arg, struct pt_regs *ptregs)
1103 return IRQ_HANDLED; 1103 return IRQ_HANDLED;
1104} 1104}
1105 1105
1106#endif /* CONFIG_ACPI */
1107
1108/* 1106/*
1109 * ia64_mca_cpe_poll 1107 * ia64_mca_cpe_poll
1110 * 1108 *
@@ -1122,6 +1120,8 @@ ia64_mca_cpe_poll (unsigned long dummy)
1122 platform_send_ipi(first_cpu(cpu_online_map), IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0); 1120 platform_send_ipi(first_cpu(cpu_online_map), IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0);
1123} 1121}
1124 1122
1123#endif /* CONFIG_ACPI */
1124
1125/* 1125/*
1126 * C portion of the OS INIT handler 1126 * C portion of the OS INIT handler
1127 * 1127 *
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c
index 2b6c9d32b7a..c4a33f265dc 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 */
46void default_idle(void) 46void 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
55void (*idle)(void) = default_idle; 57void (*idle)(void) = default_idle;
@@ -63,7 +65,12 @@ void (*idle)(void) = default_idle;
63void cpu_idle(void) 65void 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
69void machine_restart(char * __unused) 76void machine_restart(char * __unused)
diff --git a/arch/ppc/syslib/prom_init.c b/arch/ppc/syslib/prom_init.c
index 2cee87137f2..7f15136830f 100644
--- a/arch/ppc/syslib/prom_init.c
+++ b/arch/ppc/syslib/prom_init.c
@@ -626,8 +626,18 @@ inspect_node(phandle node, struct device_node *dad,
626 l = call_prom("package-to-path", 3, 1, node, 626 l = call_prom("package-to-path", 3, 1, node,
627 mem_start, mem_end - mem_start); 627 mem_start, mem_end - mem_start);
628 if (l >= 0) { 628 if (l >= 0) {
629 char *p, *ep;
630
629 np->full_name = PTRUNRELOC((char *) mem_start); 631 np->full_name = PTRUNRELOC((char *) mem_start);
630 *(char *)(mem_start + l) = 0; 632 *(char *)(mem_start + l) = 0;
633 /* Fixup an Apple bug where they have bogus \0 chars in the
634 * middle of the path in some properties
635 */
636 for (p = (char *)mem_start, ep = p + l; p < ep; p++)
637 if ((*p) == '\0') {
638 memmove(p, p+1, ep - p);
639 ep--;
640 }
631 mem_start = ALIGNUL(mem_start + l + 1); 641 mem_start = ALIGNUL(mem_start + l + 1);
632 } 642 }
633 643
diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S
index d3604056e1a..b61572eb2a7 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 92a744c31ab..346dbf606b5 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
6341: 6341:
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 da20120f226..6d06eb550a3 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
853late_initcall(iSeries_src_init); 853late_initcall(iSeries_src_init);
854 854
855static 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
855void __init iSeries_early_setup(void) 877void __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 6abc621d3ba..f24ce2b8720 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/pSeries_reconfig.c b/arch/ppc64/kernel/pSeries_reconfig.c
index cb5443f2e49..dc2a69d412a 100644
--- a/arch/ppc64/kernel/pSeries_reconfig.c
+++ b/arch/ppc64/kernel/pSeries_reconfig.c
@@ -47,14 +47,6 @@ static void remove_node_proc_entries(struct device_node *np)
47 remove_proc_entry(pp->name, np->pde); 47 remove_proc_entry(pp->name, np->pde);
48 pp = pp->next; 48 pp = pp->next;
49 } 49 }
50
51 /* Assuming that symlinks have the same parent directory as
52 * np->pde.
53 */
54 if (np->name_link)
55 remove_proc_entry(np->name_link->name, parent->pde);
56 if (np->addr_link)
57 remove_proc_entry(np->addr_link->name, parent->pde);
58 if (np->pde) 50 if (np->pde)
59 remove_proc_entry(np->pde->name, parent->pde); 51 remove_proc_entry(np->pde->name, parent->pde);
60} 52}
diff --git a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c
index 8b068612273..cdfecbeb331 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 bc53967a864..b7683abfbe6 100644
--- a/arch/ppc64/kernel/prom_init.c
+++ b/arch/ppc64/kernel/prom_init.c
@@ -211,13 +211,23 @@ struct {
211 */ 211 */
212#define ADDR(x) (u32) ((unsigned long)(x) - offset) 212#define ADDR(x) (u32) ((unsigned long)(x) - offset)
213 213
214/*
215 * Error results ... some OF calls will return "-1" on error, some
216 * will return 0, some will return either. To simplify, here are
217 * macros to use with any ihandle or phandle return value to check if
218 * it is valid
219 */
220
221#define PROM_ERROR (-1u)
222#define PHANDLE_VALID(p) ((p) != 0 && (p) != PROM_ERROR)
223#define IHANDLE_VALID(i) ((i) != 0 && (i) != PROM_ERROR)
224
225
214/* This is the one and *ONLY* place where we actually call open 226/* This is the one and *ONLY* place where we actually call open
215 * firmware from, since we need to make sure we're running in 32b 227 * firmware from, since we need to make sure we're running in 32b
216 * mode when we do. We switch back to 64b mode upon return. 228 * mode when we do. We switch back to 64b mode upon return.
217 */ 229 */
218 230
219#define PROM_ERROR (-1)
220
221static int __init call_prom(const char *service, int nargs, int nret, ...) 231static int __init call_prom(const char *service, int nargs, int nret, ...)
222{ 232{
223 int i; 233 int i;
@@ -587,14 +597,13 @@ static void __init prom_send_capabilities(void)
587{ 597{
588 unsigned long offset = reloc_offset(); 598 unsigned long offset = reloc_offset();
589 ihandle elfloader; 599 ihandle elfloader;
590 int ret;
591 600
592 elfloader = call_prom("open", 1, 1, ADDR("/packages/elf-loader")); 601 elfloader = call_prom("open", 1, 1, ADDR("/packages/elf-loader"));
593 if (elfloader == 0) { 602 if (elfloader == 0) {
594 prom_printf("couldn't open /packages/elf-loader\n"); 603 prom_printf("couldn't open /packages/elf-loader\n");
595 return; 604 return;
596 } 605 }
597 ret = call_prom("call-method", 3, 1, ADDR("process-elf-header"), 606 call_prom("call-method", 3, 1, ADDR("process-elf-header"),
598 elfloader, ADDR(&fake_elf)); 607 elfloader, ADDR(&fake_elf));
599 call_prom("close", 1, 0, elfloader); 608 call_prom("close", 1, 0, elfloader);
600} 609}
@@ -646,7 +655,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
646 base = _ALIGN_UP(base + 0x100000, align)) { 655 base = _ALIGN_UP(base + 0x100000, align)) {
647 prom_debug(" trying: 0x%x\n\r", base); 656 prom_debug(" trying: 0x%x\n\r", base);
648 addr = (unsigned long)prom_claim(base, size, 0); 657 addr = (unsigned long)prom_claim(base, size, 0);
649 if ((int)addr != PROM_ERROR) 658 if (addr != PROM_ERROR)
650 break; 659 break;
651 addr = 0; 660 addr = 0;
652 if (align == 0) 661 if (align == 0)
@@ -708,7 +717,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
708 for(; base > RELOC(alloc_bottom); base = _ALIGN_DOWN(base - 0x100000, align)) { 717 for(; base > RELOC(alloc_bottom); base = _ALIGN_DOWN(base - 0x100000, align)) {
709 prom_debug(" trying: 0x%x\n\r", base); 718 prom_debug(" trying: 0x%x\n\r", base);
710 addr = (unsigned long)prom_claim(base, size, 0); 719 addr = (unsigned long)prom_claim(base, size, 0);
711 if ((int)addr != PROM_ERROR) 720 if (addr != PROM_ERROR)
712 break; 721 break;
713 addr = 0; 722 addr = 0;
714 } 723 }
@@ -902,18 +911,19 @@ static void __init prom_instantiate_rtas(void)
902{ 911{
903 unsigned long offset = reloc_offset(); 912 unsigned long offset = reloc_offset();
904 struct prom_t *_prom = PTRRELOC(&prom); 913 struct prom_t *_prom = PTRRELOC(&prom);
905 phandle prom_rtas, rtas_node; 914 phandle rtas_node;
915 ihandle rtas_inst;
906 u32 base, entry = 0; 916 u32 base, entry = 0;
907 u32 size = 0; 917 u32 size = 0;
908 918
909 prom_debug("prom_instantiate_rtas: start...\n"); 919 prom_debug("prom_instantiate_rtas: start...\n");
910 920
911 prom_rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); 921 rtas_node = call_prom("finddevice", 1, 1, ADDR("/rtas"));
912 prom_debug("prom_rtas: %x\n", prom_rtas); 922 prom_debug("rtas_node: %x\n", rtas_node);
913 if (prom_rtas == (phandle) -1) 923 if (!PHANDLE_VALID(rtas_node))
914 return; 924 return;
915 925
916 prom_getprop(prom_rtas, "rtas-size", &size, sizeof(size)); 926 prom_getprop(rtas_node, "rtas-size", &size, sizeof(size));
917 if (size == 0) 927 if (size == 0)
918 return; 928 return;
919 929
@@ -922,14 +932,18 @@ static void __init prom_instantiate_rtas(void)
922 prom_printf("RTAS allocation failed !\n"); 932 prom_printf("RTAS allocation failed !\n");
923 return; 933 return;
924 } 934 }
925 prom_printf("instantiating rtas at 0x%x", base);
926 935
927 rtas_node = call_prom("open", 1, 1, ADDR("/rtas")); 936 rtas_inst = call_prom("open", 1, 1, ADDR("/rtas"));
928 prom_printf("..."); 937 if (!IHANDLE_VALID(rtas_inst)) {
938 prom_printf("opening rtas package failed");
939 return;
940 }
941
942 prom_printf("instantiating rtas at 0x%x ...", base);
929 943
930 if (call_prom("call-method", 3, 2, 944 if (call_prom("call-method", 3, 2,
931 ADDR("instantiate-rtas"), 945 ADDR("instantiate-rtas"),
932 rtas_node, base) != PROM_ERROR) { 946 rtas_inst, base) != PROM_ERROR) {
933 entry = (long)_prom->args.rets[1]; 947 entry = (long)_prom->args.rets[1];
934 } 948 }
935 if (entry == 0) { 949 if (entry == 0) {
@@ -940,8 +954,8 @@ static void __init prom_instantiate_rtas(void)
940 954
941 reserve_mem(base, size); 955 reserve_mem(base, size);
942 956
943 prom_setprop(prom_rtas, "linux,rtas-base", &base, sizeof(base)); 957 prom_setprop(rtas_node, "linux,rtas-base", &base, sizeof(base));
944 prom_setprop(prom_rtas, "linux,rtas-entry", &entry, sizeof(entry)); 958 prom_setprop(rtas_node, "linux,rtas-entry", &entry, sizeof(entry));
945 959
946 prom_debug("rtas base = 0x%x\n", base); 960 prom_debug("rtas base = 0x%x\n", base);
947 prom_debug("rtas entry = 0x%x\n", entry); 961 prom_debug("rtas entry = 0x%x\n", entry);
@@ -1062,7 +1076,7 @@ static void __init prom_initialize_tce_table(void)
1062 1076
1063 prom_printf("opening PHB %s", path); 1077 prom_printf("opening PHB %s", path);
1064 phb_node = call_prom("open", 1, 1, path); 1078 phb_node = call_prom("open", 1, 1, path);
1065 if ( (long)phb_node <= 0) 1079 if (phb_node == 0)
1066 prom_printf("... failed\n"); 1080 prom_printf("... failed\n");
1067 else 1081 else
1068 prom_printf("... done\n"); 1082 prom_printf("... done\n");
@@ -1279,12 +1293,12 @@ static void __init prom_init_client_services(unsigned long pp)
1279 1293
1280 /* get a handle for the stdout device */ 1294 /* get a handle for the stdout device */
1281 _prom->chosen = call_prom("finddevice", 1, 1, ADDR("/chosen")); 1295 _prom->chosen = call_prom("finddevice", 1, 1, ADDR("/chosen"));
1282 if ((long)_prom->chosen <= 0) 1296 if (!PHANDLE_VALID(_prom->chosen))
1283 prom_panic("cannot find chosen"); /* msg won't be printed :( */ 1297 prom_panic("cannot find chosen"); /* msg won't be printed :( */
1284 1298
1285 /* get device tree root */ 1299 /* get device tree root */
1286 _prom->root = call_prom("finddevice", 1, 1, ADDR("/")); 1300 _prom->root = call_prom("finddevice", 1, 1, ADDR("/"));
1287 if ((long)_prom->root <= 0) 1301 if (!PHANDLE_VALID(_prom->root))
1288 prom_panic("cannot find device tree root"); /* msg won't be printed :( */ 1302 prom_panic("cannot find device tree root"); /* msg won't be printed :( */
1289} 1303}
1290 1304
@@ -1356,9 +1370,8 @@ static int __init prom_find_machine_type(void)
1356 } 1370 }
1357 /* 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 */
1358 rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); 1372 rtas = call_prom("finddevice", 1, 1, ADDR("/rtas"));
1359 if (rtas != (phandle) -1) { 1373 if (PHANDLE_VALID(rtas)) {
1360 unsigned long x; 1374 int x = prom_getproplen(rtas, "ibm,hypertas-functions");
1361 x = prom_getproplen(rtas, "ibm,hypertas-functions");
1362 if (x != PROM_ERROR) { 1375 if (x != PROM_ERROR) {
1363 prom_printf("Hypertas detected, assuming LPAR !\n"); 1376 prom_printf("Hypertas detected, assuming LPAR !\n");
1364 return PLATFORM_PSERIES_LPAR; 1377 return PLATFORM_PSERIES_LPAR;
@@ -1426,12 +1439,13 @@ static void __init prom_check_displays(void)
1426 * leave some room at the end of the path for appending extra 1439 * leave some room at the end of the path for appending extra
1427 * arguments 1440 * arguments
1428 */ 1441 */
1429 if (call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-10) < 0) 1442 if (call_prom("package-to-path", 3, 1, node, path,
1443 PROM_SCRATCH_SIZE-10) == PROM_ERROR)
1430 continue; 1444 continue;
1431 prom_printf("found display : %s, opening ... ", path); 1445 prom_printf("found display : %s, opening ... ", path);
1432 1446
1433 ih = call_prom("open", 1, 1, path); 1447 ih = call_prom("open", 1, 1, path);
1434 if (ih == (ihandle)0 || ih == (ihandle)-1) { 1448 if (ih == 0) {
1435 prom_printf("failed\n"); 1449 prom_printf("failed\n");
1436 continue; 1450 continue;
1437 } 1451 }
@@ -1514,6 +1528,12 @@ static unsigned long __init dt_find_string(char *str)
1514 return 0; 1528 return 0;
1515} 1529}
1516 1530
1531/*
1532 * The Open Firmware 1275 specification states properties must be 31 bytes or
1533 * less, however not all firmwares obey this. Make it 64 bytes to be safe.
1534 */
1535#define MAX_PROPERTY_NAME 64
1536
1517static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start, 1537static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start,
1518 unsigned long *mem_end) 1538 unsigned long *mem_end)
1519{ 1539{
@@ -1527,10 +1547,12 @@ static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start,
1527 /* get and store all property names */ 1547 /* get and store all property names */
1528 prev_name = RELOC(""); 1548 prev_name = RELOC("");
1529 for (;;) { 1549 for (;;) {
1530 1550 int rc;
1531 /* 32 is max len of name including nul. */ 1551
1532 namep = make_room(mem_start, mem_end, 32, 1); 1552 /* 64 is max len of name including nul. */
1533 if (call_prom("nextprop", 3, 1, node, prev_name, namep) <= 0) { 1553 namep = make_room(mem_start, mem_end, MAX_PROPERTY_NAME, 1);
1554 rc = call_prom("nextprop", 3, 1, node, prev_name, namep);
1555 if (rc != 1) {
1534 /* No more nodes: unwind alloc */ 1556 /* No more nodes: unwind alloc */
1535 *mem_start = (unsigned long)namep; 1557 *mem_start = (unsigned long)namep;
1536 break; 1558 break;
@@ -1555,18 +1577,12 @@ static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start,
1555 } 1577 }
1556} 1578}
1557 1579
1558/*
1559 * The Open Firmware 1275 specification states properties must be 31 bytes or
1560 * less, however not all firmwares obey this. Make it 64 bytes to be safe.
1561 */
1562#define MAX_PROPERTY_NAME 64
1563
1564static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, 1580static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
1565 unsigned long *mem_end) 1581 unsigned long *mem_end)
1566{ 1582{
1567 int l, align; 1583 int l, align;
1568 phandle child; 1584 phandle child;
1569 char *namep, *prev_name, *sstart; 1585 char *namep, *prev_name, *sstart, *p, *ep;
1570 unsigned long soff; 1586 unsigned long soff;
1571 unsigned char *valp; 1587 unsigned char *valp;
1572 unsigned long offset = reloc_offset(); 1588 unsigned long offset = reloc_offset();
@@ -1588,6 +1604,14 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
1588 call_prom("package-to-path", 3, 1, node, namep, l); 1604 call_prom("package-to-path", 3, 1, node, namep, l);
1589 } 1605 }
1590 namep[l] = '\0'; 1606 namep[l] = '\0';
1607 /* Fixup an Apple bug where they have bogus \0 chars in the
1608 * middle of the path in some properties
1609 */
1610 for (p = namep, ep = namep + l; p < ep; p++)
1611 if (*p == '\0') {
1612 memmove(p, p+1, ep - p);
1613 ep--; l--;
1614 }
1591 *mem_start = _ALIGN(((unsigned long) namep) + strlen(namep) + 1, 4); 1615 *mem_start = _ALIGN(((unsigned long) namep) + strlen(namep) + 1, 4);
1592 } 1616 }
1593 1617
@@ -1599,7 +1623,10 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
1599 prev_name = RELOC(""); 1623 prev_name = RELOC("");
1600 sstart = (char *)RELOC(dt_string_start); 1624 sstart = (char *)RELOC(dt_string_start);
1601 for (;;) { 1625 for (;;) {
1602 if (call_prom("nextprop", 3, 1, node, prev_name, pname) <= 0) 1626 int rc;
1627
1628 rc = call_prom("nextprop", 3, 1, node, prev_name, pname);
1629 if (rc != 1)
1603 break; 1630 break;
1604 1631
1605 /* find string offset */ 1632 /* find string offset */
@@ -1615,7 +1642,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
1615 l = call_prom("getproplen", 2, 1, node, pname); 1642 l = call_prom("getproplen", 2, 1, node, pname);
1616 1643
1617 /* sanity checks */ 1644 /* sanity checks */
1618 if (l < 0) 1645 if (l == PROM_ERROR)
1619 continue; 1646 continue;
1620 if (l > MAX_PROPERTY_LENGTH) { 1647 if (l > MAX_PROPERTY_LENGTH) {
1621 prom_printf("WARNING: ignoring large property "); 1648 prom_printf("WARNING: ignoring large property ");
@@ -1763,17 +1790,18 @@ static void __init fixup_device_tree(void)
1763 1790
1764 /* Some G5s have a missing interrupt definition, fix it up here */ 1791 /* Some G5s have a missing interrupt definition, fix it up here */
1765 u3 = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000")); 1792 u3 = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000"));
1766 if ((long)u3 <= 0) 1793 if (!PHANDLE_VALID(u3))
1767 return; 1794 return;
1768 i2c = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/i2c@f8001000")); 1795 i2c = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/i2c@f8001000"));
1769 if ((long)i2c <= 0) 1796 if (!PHANDLE_VALID(i2c))
1770 return; 1797 return;
1771 mpic = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/mpic@f8040000")); 1798 mpic = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/mpic@f8040000"));
1772 if ((long)mpic <= 0) 1799 if (!PHANDLE_VALID(mpic))
1773 return; 1800 return;
1774 1801
1775 /* check if proper rev of u3 */ 1802 /* check if proper rev of u3 */
1776 if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev)) <= 0) 1803 if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev))
1804 == PROM_ERROR)
1777 return; 1805 return;
1778 if (u3_rev != 0x35) 1806 if (u3_rev != 0x35)
1779 return; 1807 return;
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
index 21c57f539c2..dce198d3932 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
104extern void smp_release_cpus(void); 104extern void smp_release_cpus(void);
105 105
106unsigned long decr_overclock = 1;
107unsigned long decr_overclock_proc0 = 1;
108unsigned long decr_overclock_set = 0;
109unsigned long decr_overclock_proc0_set = 0;
110
111int have_of = 1; 106int have_of = 1;
112int boot_cpuid = 0; 107int boot_cpuid = 0;
113int boot_cpuid_phys = 0; 108int 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
1123int 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 */
1139void setup_default_decr(void) 1119void 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
1150int 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
1163int 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 3b906cd9403..9ef5d36d6b2 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
337extern unsigned long decr_overclock;
338extern struct gettimeofday_struct do_gtod; 337extern struct gettimeofday_struct do_gtod;
339 338
340struct thread_info *current_set[NR_CPUS]; 339struct 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 0925694c3ce..c8fa6569b2f 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 01ae1964c93..c067435bae4 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;
133static int appldata_timer_active; 134static int appldata_timer_active;
134 135
135/* 136/*
136 * Tasklet 137 * Work queue
137 */ 138 */
138static struct tasklet_struct appldata_tasklet_struct; 139static struct workqueue_struct *appldata_wq;
140static void appldata_work_fn(void *data);
141static 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);
144static LIST_HEAD(appldata_ops_list); 148static 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 */
153static void appldata_timer_function(unsigned long data, struct pt_regs *regs) 157static 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 */
169static void appldata_tasklet_function(unsigned long data) 173static 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);
489out: 494out:
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 */
584void appldata_unregister_ops(struct appldata_ops *ops) 589void 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 */
653static int __init appldata_init(void) 658static 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 */
683static void __exit appldata_exit(void) 693static 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 462ee9a84e7..f0e2fbed3d4 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
74static inline void appldata_debug_print(struct appldata_mem_data *mem_data) 74static 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 dd61638d302..2a4c7432db4 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
63static inline void appldata_print_debug(struct appldata_net_sum_data *net_data) 63static 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 b83f0748455..e0a476bf4fd 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
54struct appldata_os_data { 54struct 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
80static struct appldata_os_data *appldata_os_data; 80static struct appldata_os_data *appldata_os_data;
81 81
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 26889366929..06afa3103ac 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
130peek_user(struct task_struct *child, addr_t addr, addr_t data) 131peek_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
191poke_user(struct task_struct *child, addr_t addr, addr_t data) 211poke_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 80306bc8c79..75fde949d12 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/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index 33ca56c90da..2803bc7c2c7 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -196,6 +196,34 @@ static iopte_t *alloc_consistent_cluster(struct pci_iommu *iommu, unsigned long
196 return NULL; 196 return NULL;
197} 197}
198 198
199static int iommu_alloc_ctx(struct pci_iommu *iommu)
200{
201 int lowest = iommu->ctx_lowest_free;
202 int sz = IOMMU_NUM_CTXS - lowest;
203 int n = find_next_zero_bit(iommu->ctx_bitmap, sz, lowest);
204
205 if (unlikely(n == sz)) {
206 n = find_next_zero_bit(iommu->ctx_bitmap, lowest, 1);
207 if (unlikely(n == lowest)) {
208 printk(KERN_WARNING "IOMMU: Ran out of contexts.\n");
209 n = 0;
210 }
211 }
212 if (n)
213 __set_bit(n, iommu->ctx_bitmap);
214
215 return n;
216}
217
218static inline void iommu_free_ctx(struct pci_iommu *iommu, int ctx)
219{
220 if (likely(ctx)) {
221 __clear_bit(ctx, iommu->ctx_bitmap);
222 if (ctx < iommu->ctx_lowest_free)
223 iommu->ctx_lowest_free = ctx;
224 }
225}
226
199/* Allocate and map kernel buffer of size SIZE using consistent mode 227/* Allocate and map kernel buffer of size SIZE using consistent mode
200 * DMA for PCI device PDEV. Return non-NULL cpu-side address if 228 * DMA for PCI device PDEV. Return non-NULL cpu-side address if
201 * successful and set *DMA_ADDRP to the PCI side dma address. 229 * successful and set *DMA_ADDRP to the PCI side dma address.
@@ -236,7 +264,7 @@ void *pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_ad
236 npages = size >> IO_PAGE_SHIFT; 264 npages = size >> IO_PAGE_SHIFT;
237 ctx = 0; 265 ctx = 0;
238 if (iommu->iommu_ctxflush) 266 if (iommu->iommu_ctxflush)
239 ctx = iommu->iommu_cur_ctx++; 267 ctx = iommu_alloc_ctx(iommu);
240 first_page = __pa(first_page); 268 first_page = __pa(first_page);
241 while (npages--) { 269 while (npages--) {
242 iopte_val(*iopte) = (IOPTE_CONSISTENT(ctx) | 270 iopte_val(*iopte) = (IOPTE_CONSISTENT(ctx) |
@@ -317,6 +345,8 @@ void pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_
317 } 345 }
318 } 346 }
319 347
348 iommu_free_ctx(iommu, ctx);
349
320 spin_unlock_irqrestore(&iommu->lock, flags); 350 spin_unlock_irqrestore(&iommu->lock, flags);
321 351
322 order = get_order(size); 352 order = get_order(size);
@@ -360,7 +390,7 @@ dma_addr_t pci_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direct
360 base_paddr = __pa(oaddr & IO_PAGE_MASK); 390 base_paddr = __pa(oaddr & IO_PAGE_MASK);
361 ctx = 0; 391 ctx = 0;
362 if (iommu->iommu_ctxflush) 392 if (iommu->iommu_ctxflush)
363 ctx = iommu->iommu_cur_ctx++; 393 ctx = iommu_alloc_ctx(iommu);
364 if (strbuf->strbuf_enabled) 394 if (strbuf->strbuf_enabled)
365 iopte_protection = IOPTE_STREAMING(ctx); 395 iopte_protection = IOPTE_STREAMING(ctx);
366 else 396 else
@@ -380,39 +410,53 @@ bad:
380 return PCI_DMA_ERROR_CODE; 410 return PCI_DMA_ERROR_CODE;
381} 411}
382 412
383static void pci_strbuf_flush(struct pci_strbuf *strbuf, struct pci_iommu *iommu, u32 vaddr, unsigned long ctx, unsigned long npages) 413static void pci_strbuf_flush(struct pci_strbuf *strbuf, struct pci_iommu *iommu, u32 vaddr, unsigned long ctx, unsigned long npages, int direction)
384{ 414{
385 int limit; 415 int limit;
386 416
387 PCI_STC_FLUSHFLAG_INIT(strbuf);
388 if (strbuf->strbuf_ctxflush && 417 if (strbuf->strbuf_ctxflush &&
389 iommu->iommu_ctxflush) { 418 iommu->iommu_ctxflush) {
390 unsigned long matchreg, flushreg; 419 unsigned long matchreg, flushreg;
420 u64 val;
391 421
392 flushreg = strbuf->strbuf_ctxflush; 422 flushreg = strbuf->strbuf_ctxflush;
393 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 423 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx);
394 424
395 limit = 100000;
396 pci_iommu_write(flushreg, ctx); 425 pci_iommu_write(flushreg, ctx);
397 for(;;) { 426 val = pci_iommu_read(matchreg);
398 if (((long)pci_iommu_read(matchreg)) >= 0L) 427 val &= 0xffff;
399 break; 428 if (!val)
400 limit--; 429 goto do_flush_sync;
401 if (!limit) 430
402 break; 431 while (val) {
403 udelay(1); 432 if (val & 0x1)
433 pci_iommu_write(flushreg, ctx);
434 val >>= 1;
404 } 435 }
405 if (!limit) 436 val = pci_iommu_read(matchreg);
437 if (unlikely(val)) {
406 printk(KERN_WARNING "pci_strbuf_flush: ctx flush " 438 printk(KERN_WARNING "pci_strbuf_flush: ctx flush "
407 "timeout vaddr[%08x] ctx[%lx]\n", 439 "timeout matchreg[%lx] ctx[%lx]\n",
408 vaddr, ctx); 440 val, ctx);
441 goto do_page_flush;
442 }
409 } else { 443 } else {
410 unsigned long i; 444 unsigned long i;
411 445
446 do_page_flush:
412 for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE) 447 for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE)
413 pci_iommu_write(strbuf->strbuf_pflush, vaddr); 448 pci_iommu_write(strbuf->strbuf_pflush, vaddr);
414 } 449 }
415 450
451do_flush_sync:
452 /* If the device could not have possibly put dirty data into
453 * the streaming cache, no flush-flag synchronization needs
454 * to be performed.
455 */
456 if (direction == PCI_DMA_TODEVICE)
457 return;
458
459 PCI_STC_FLUSHFLAG_INIT(strbuf);
416 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); 460 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa);
417 (void) pci_iommu_read(iommu->write_complete_reg); 461 (void) pci_iommu_read(iommu->write_complete_reg);
418 462
@@ -466,7 +510,7 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int
466 510
467 /* Step 1: Kick data out of streaming buffers if necessary. */ 511 /* Step 1: Kick data out of streaming buffers if necessary. */
468 if (strbuf->strbuf_enabled) 512 if (strbuf->strbuf_enabled)
469 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 513 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
470 514
471 /* Step 2: Clear out first TSB entry. */ 515 /* Step 2: Clear out first TSB entry. */
472 iopte_make_dummy(iommu, base); 516 iopte_make_dummy(iommu, base);
@@ -474,6 +518,8 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int
474 free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, 518 free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base,
475 npages, ctx); 519 npages, ctx);
476 520
521 iommu_free_ctx(iommu, ctx);
522
477 spin_unlock_irqrestore(&iommu->lock, flags); 523 spin_unlock_irqrestore(&iommu->lock, flags);
478} 524}
479 525
@@ -613,7 +659,7 @@ int pci_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int
613 /* Step 4: Choose a context if necessary. */ 659 /* Step 4: Choose a context if necessary. */
614 ctx = 0; 660 ctx = 0;
615 if (iommu->iommu_ctxflush) 661 if (iommu->iommu_ctxflush)
616 ctx = iommu->iommu_cur_ctx++; 662 ctx = iommu_alloc_ctx(iommu);
617 663
618 /* Step 5: Create the mappings. */ 664 /* Step 5: Create the mappings. */
619 if (strbuf->strbuf_enabled) 665 if (strbuf->strbuf_enabled)
@@ -678,7 +724,7 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems,
678 724
679 /* Step 1: Kick data out of streaming buffers if necessary. */ 725 /* Step 1: Kick data out of streaming buffers if necessary. */
680 if (strbuf->strbuf_enabled) 726 if (strbuf->strbuf_enabled)
681 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 727 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
682 728
683 /* Step 2: Clear out first TSB entry. */ 729 /* Step 2: Clear out first TSB entry. */
684 iopte_make_dummy(iommu, base); 730 iopte_make_dummy(iommu, base);
@@ -686,6 +732,8 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems,
686 free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, 732 free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base,
687 npages, ctx); 733 npages, ctx);
688 734
735 iommu_free_ctx(iommu, ctx);
736
689 spin_unlock_irqrestore(&iommu->lock, flags); 737 spin_unlock_irqrestore(&iommu->lock, flags);
690} 738}
691 739
@@ -724,7 +772,7 @@ void pci_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_addr, size
724 } 772 }
725 773
726 /* Step 2: Kick data out of streaming buffers. */ 774 /* Step 2: Kick data out of streaming buffers. */
727 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 775 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
728 776
729 spin_unlock_irqrestore(&iommu->lock, flags); 777 spin_unlock_irqrestore(&iommu->lock, flags);
730} 778}
@@ -768,7 +816,7 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, i
768 i--; 816 i--;
769 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) 817 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length)
770 - bus_addr) >> IO_PAGE_SHIFT; 818 - bus_addr) >> IO_PAGE_SHIFT;
771 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 819 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
772 820
773 spin_unlock_irqrestore(&iommu->lock, flags); 821 spin_unlock_irqrestore(&iommu->lock, flags);
774} 822}
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
index 3567fa879e1..534320ef0db 100644
--- a/arch/sparc64/kernel/pci_psycho.c
+++ b/arch/sparc64/kernel/pci_psycho.c
@@ -1212,7 +1212,7 @@ static void __init psycho_iommu_init(struct pci_controller_info *p)
1212 1212
1213 /* Setup initial software IOMMU state. */ 1213 /* Setup initial software IOMMU state. */
1214 spin_lock_init(&iommu->lock); 1214 spin_lock_init(&iommu->lock);
1215 iommu->iommu_cur_ctx = 0; 1215 iommu->ctx_lowest_free = 1;
1216 1216
1217 /* Register addresses. */ 1217 /* Register addresses. */
1218 iommu->iommu_control = p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL; 1218 iommu->iommu_control = p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL;
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index 5525d1ec4af..53d333b4a4e 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -1265,7 +1265,7 @@ static void __init sabre_iommu_init(struct pci_controller_info *p,
1265 1265
1266 /* Setup initial software IOMMU state. */ 1266 /* Setup initial software IOMMU state. */
1267 spin_lock_init(&iommu->lock); 1267 spin_lock_init(&iommu->lock);
1268 iommu->iommu_cur_ctx = 0; 1268 iommu->ctx_lowest_free = 1;
1269 1269
1270 /* Register addresses. */ 1270 /* Register addresses. */
1271 iommu->iommu_control = p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL; 1271 iommu->iommu_control = p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL;
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
index e93fcadc372..5753175b94e 100644
--- a/arch/sparc64/kernel/pci_schizo.c
+++ b/arch/sparc64/kernel/pci_schizo.c
@@ -1753,7 +1753,7 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1753 1753
1754 /* Setup initial software IOMMU state. */ 1754 /* Setup initial software IOMMU state. */
1755 spin_lock_init(&iommu->lock); 1755 spin_lock_init(&iommu->lock);
1756 iommu->iommu_cur_ctx = 0; 1756 iommu->ctx_lowest_free = 1;
1757 1757
1758 /* Register addresses, SCHIZO has iommu ctx flushing. */ 1758 /* Register addresses, SCHIZO has iommu ctx flushing. */
1759 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL; 1759 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL;
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c
index 76ea6455433..89f5e019f24 100644
--- a/arch/sparc64/kernel/sbus.c
+++ b/arch/sparc64/kernel/sbus.c
@@ -117,17 +117,25 @@ static void iommu_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages
117 117
118#define STRBUF_TAG_VALID 0x02UL 118#define STRBUF_TAG_VALID 0x02UL
119 119
120static void sbus_strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages) 120static void sbus_strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages, int direction)
121{ 121{
122 unsigned long n; 122 unsigned long n;
123 int limit; 123 int limit;
124 124
125 iommu->strbuf_flushflag = 0UL;
126 n = npages; 125 n = npages;
127 while (n--) 126 while (n--)
128 upa_writeq(base + (n << IO_PAGE_SHIFT), 127 upa_writeq(base + (n << IO_PAGE_SHIFT),
129 iommu->strbuf_regs + STRBUF_PFLUSH); 128 iommu->strbuf_regs + STRBUF_PFLUSH);
130 129
130 /* If the device could not have possibly put dirty data into
131 * the streaming cache, no flush-flag synchronization needs
132 * to be performed.
133 */
134 if (direction == SBUS_DMA_TODEVICE)
135 return;
136
137 iommu->strbuf_flushflag = 0UL;
138
131 /* Whoopee cushion! */ 139 /* Whoopee cushion! */
132 upa_writeq(__pa(&iommu->strbuf_flushflag), 140 upa_writeq(__pa(&iommu->strbuf_flushflag),
133 iommu->strbuf_regs + STRBUF_FSYNC); 141 iommu->strbuf_regs + STRBUF_FSYNC);
@@ -421,7 +429,7 @@ void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t dma_addr, size_t size,
421 429
422 spin_lock_irqsave(&iommu->lock, flags); 430 spin_lock_irqsave(&iommu->lock, flags);
423 free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT); 431 free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT);
424 sbus_strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT); 432 sbus_strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT, direction);
425 spin_unlock_irqrestore(&iommu->lock, flags); 433 spin_unlock_irqrestore(&iommu->lock, flags);
426} 434}
427 435
@@ -584,7 +592,7 @@ void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sg, int nents, int
584 iommu = sdev->bus->iommu; 592 iommu = sdev->bus->iommu;
585 spin_lock_irqsave(&iommu->lock, flags); 593 spin_lock_irqsave(&iommu->lock, flags);
586 free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT); 594 free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT);
587 sbus_strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT); 595 sbus_strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT, direction);
588 spin_unlock_irqrestore(&iommu->lock, flags); 596 spin_unlock_irqrestore(&iommu->lock, flags);
589} 597}
590 598
@@ -596,7 +604,7 @@ void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev, dma_addr_t base, size_t
596 size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK)); 604 size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK));
597 605
598 spin_lock_irqsave(&iommu->lock, flags); 606 spin_lock_irqsave(&iommu->lock, flags);
599 sbus_strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT); 607 sbus_strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT, direction);
600 spin_unlock_irqrestore(&iommu->lock, flags); 608 spin_unlock_irqrestore(&iommu->lock, flags);
601} 609}
602 610
@@ -620,7 +628,7 @@ void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev, struct scatterlist *sg, int
620 size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base; 628 size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base;
621 629
622 spin_lock_irqsave(&iommu->lock, flags); 630 spin_lock_irqsave(&iommu->lock, flags);
623 sbus_strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT); 631 sbus_strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT, direction);
624 spin_unlock_irqrestore(&iommu->lock, flags); 632 spin_unlock_irqrestore(&iommu->lock, flags);
625} 633}
626 634
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile
index d1dcd8eae3c..5b77188527a 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
44endif 45endif
45 46
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 9e65bfb85ba..5f702199543 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 3022c548a13..df2c83fd549 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)
412init_one_failure: 412init_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)
2534open_failed: 2533open_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 85bf5c8442b..b2a7b754fd1 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 47a800519ad..8d5e65cb975 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 ce42889f98f..adc4dcc306f 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 */
264struct 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 */
257struct ub_dev { 292struct 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 */
303static void ub_cleanup(struct ub_dev *sc); 328static void ub_cleanup(struct ub_dev *sc);
304static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq); 329static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq);
305static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, 330static 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);
307static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, 332static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
308 struct request *rq); 333 struct request *rq);
309static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); 334static 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);
320static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, 345static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
321 int stalled_pipe); 346 int stalled_pipe);
322static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); 347static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd);
323static int ub_sync_tur(struct ub_dev *sc); 348static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun);
324static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret); 349static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
350 struct ub_capacity *ret);
351static 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
344static char ub_hostv[UB_MAX_HOSTS]; 371static char ub_hostv[UB_MAX_HOSTS];
372
345static DEFINE_SPINLOCK(ub_lock); /* Locks globals and ->openc */ 373static 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 */
524static void ub_cleanup(struct ub_dev *sc) 560static 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 */
550static struct ub_scsi_cmd *ub_get_cmd(struct ub_dev *sc) 596static 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
561static void ub_put_cmd(struct ub_dev *sc, struct ub_scsi_cmd *cmd) 607static 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
631static void ub_bd_rq_fn(request_queue_t *q) 677static 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
644static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq) 690static 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
688static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, 733static 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,
803static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) 848static 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 */
1434int 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 */
1471static void ub_revalidate(struct ub_dev *sc) 1473static 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)
1503static int ub_bd_open(struct inode *inode, struct file *filp) 1505static 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:
1567static int ub_bd_release(struct inode *inode, struct file *filp) 1572static 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 */
1598static int ub_bd_revalidate(struct gendisk *disk) 1604static 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 */
1627static int ub_bd_media_changed(struct gendisk *disk) 1627static 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
1651static struct block_device_operations ub_bd_fops = { 1651static 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 */
1672static int ub_sync_tur(struct ub_dev *sc) 1672static 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 */
1721static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret) 1722static 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 */
1820static 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
1895err_submit:
1896 kfree(p);
1897err_alloc:
1898 return rc;
1899}
1900
1901/*
1815 * Clear initial stalls. 1902 * Clear initial stalls.
1816 */ 1903 */
1817static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe) 1904static 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); */
2112err_diag:
2113 usb_set_intfdata(intf, NULL);
2114 // usb_put_intf(sc->intf);
2115 usb_put_dev(sc->dev);
2116 kfree(sc);
2117err_core:
2118 return rc;
2119}
2120
2121static 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,
2059err_blkqinit: 2185err_blkqinit:
2060 put_disk(disk); 2186 put_disk(disk);
2061err_diskalloc: 2187err_diskalloc:
2062 device_remove_file(&sc->intf->dev, &dev_attr_diag); 2188 list_del(&lun->link);
2063err_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);
2068err_id: 2190err_id:
2069 kfree(sc); 2191 kfree(lun);
2070err_core: 2192err_alloc:
2071 return rc; 2193 return rc;
2072} 2194}
2073 2195
2074static void ub_disconnect(struct usb_interface *intf) 2196static 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/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 35710818fe4..fdd881aee61 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -2,6 +2,7 @@
2 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge 2 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge
3 * 3 *
4 * Copyright (C) 2004 Patrick Mochel 4 * Copyright (C) 2004 Patrick Mochel
5 * 2005 Rudolf Marek <r.marek@sh.cvut.cz>
5 * 6 *
6 * The 1563 southbridge is deceptively similar to the 1533, with a 7 * The 1563 southbridge is deceptively similar to the 1533, with a
7 * few notable exceptions. One of those happens to be the fact they 8 * few notable exceptions. One of those happens to be the fact they
@@ -57,10 +58,11 @@
57#define HST_CNTL2_BLOCK 0x05 58#define HST_CNTL2_BLOCK 0x05
58 59
59 60
61#define HST_CNTL2_SIZEMASK 0x38
60 62
61static unsigned short ali1563_smba; 63static unsigned short ali1563_smba;
62 64
63static int ali1563_transaction(struct i2c_adapter * a) 65static int ali1563_transaction(struct i2c_adapter * a, int size)
64{ 66{
65 u32 data; 67 u32 data;
66 int timeout; 68 int timeout;
@@ -73,7 +75,7 @@ static int ali1563_transaction(struct i2c_adapter * a)
73 75
74 data = inb_p(SMB_HST_STS); 76 data = inb_p(SMB_HST_STS);
75 if (data & HST_STS_BAD) { 77 if (data & HST_STS_BAD) {
76 dev_warn(&a->dev,"ali1563: Trying to reset busy device\n"); 78 dev_err(&a->dev, "ali1563: Trying to reset busy device\n");
77 outb_p(data | HST_STS_BAD,SMB_HST_STS); 79 outb_p(data | HST_STS_BAD,SMB_HST_STS);
78 data = inb_p(SMB_HST_STS); 80 data = inb_p(SMB_HST_STS);
79 if (data & HST_STS_BAD) 81 if (data & HST_STS_BAD)
@@ -94,19 +96,31 @@ static int ali1563_transaction(struct i2c_adapter * a)
94 96
95 if (timeout && !(data & HST_STS_BAD)) 97 if (timeout && !(data & HST_STS_BAD))
96 return 0; 98 return 0;
97 dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n",
98 timeout ? "Timeout " : "",
99 data & HST_STS_FAIL ? "Transaction Failed " : "",
100 data & HST_STS_BUSERR ? "No response or Bus Collision " : "",
101 data & HST_STS_DEVERR ? "Device Error " : "",
102 !(data & HST_STS_DONE) ? "Transaction Never Finished " : "");
103 99
104 if (!(data & HST_STS_DONE)) 100 if (!timeout) {
101 dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n");
105 /* Issue 'kill' to host controller */ 102 /* Issue 'kill' to host controller */
106 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); 103 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2);
107 else 104 data = inb_p(SMB_HST_STS);
108 /* Issue timeout to reset all devices on bus */ 105 }
106
107 /* device error - no response, ignore the autodetection case */
108 if ((data & HST_STS_DEVERR) && (size != HST_CNTL2_QUICK)) {
109 dev_err(&a->dev, "Device error!\n");
110 }
111
112 /* bus collision */
113 if (data & HST_STS_BUSERR) {
114 dev_err(&a->dev, "Bus collision!\n");
115 /* Issue timeout, hoping it helps */
109 outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1); 116 outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1);
117 }
118
119 if (data & HST_STS_FAIL) {
120 dev_err(&a->dev, "Cleaning fail after KILL!\n");
121 outb_p(0x0,SMB_HST_CNTL2);
122 }
123
110 return -1; 124 return -1;
111} 125}
112 126
@@ -149,7 +163,7 @@ static int ali1563_block_start(struct i2c_adapter * a)
149 163
150 if (timeout && !(data & HST_STS_BAD)) 164 if (timeout && !(data & HST_STS_BAD))
151 return 0; 165 return 0;
152 dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n", 166 dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n",
153 timeout ? "Timeout " : "", 167 timeout ? "Timeout " : "",
154 data & HST_STS_FAIL ? "Transaction Failed " : "", 168 data & HST_STS_FAIL ? "Transaction Failed " : "",
155 data & HST_STS_BUSERR ? "No response or Bus Collision " : "", 169 data & HST_STS_BUSERR ? "No response or Bus Collision " : "",
@@ -242,13 +256,15 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
242 } 256 }
243 257
244 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); 258 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);
245 outb_p(inb_p(SMB_HST_CNTL2) | (size << 3), SMB_HST_CNTL2); 259 outb_p((inb_p(SMB_HST_CNTL2) & ~HST_CNTL2_SIZEMASK) | (size << 3), SMB_HST_CNTL2);
246 260
247 /* Write the command register */ 261 /* Write the command register */
262
248 switch(size) { 263 switch(size) {
249 case HST_CNTL2_BYTE: 264 case HST_CNTL2_BYTE:
250 if (rw== I2C_SMBUS_WRITE) 265 if (rw== I2C_SMBUS_WRITE)
251 outb_p(cmd, SMB_HST_CMD); 266 /* Beware it uses DAT0 register and not CMD! */
267 outb_p(cmd, SMB_HST_DAT0);
252 break; 268 break;
253 case HST_CNTL2_BYTE_DATA: 269 case HST_CNTL2_BYTE_DATA:
254 outb_p(cmd, SMB_HST_CMD); 270 outb_p(cmd, SMB_HST_CMD);
@@ -268,7 +284,7 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
268 goto Done; 284 goto Done;
269 } 285 }
270 286
271 if ((error = ali1563_transaction(a))) 287 if ((error = ali1563_transaction(a, size)))
272 goto Done; 288 goto Done;
273 289
274 if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK)) 290 if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK))
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 47225e32435..4e0f13d1d06 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -72,6 +72,7 @@ static struct amd_ide_chip {
72 { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, 0x50, AMD_UDMA_133 }, 72 { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, 0x50, AMD_UDMA_133 },
73 { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, AMD_UDMA_133 }, 73 { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, AMD_UDMA_133 },
74 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, AMD_UDMA_133 }, 74 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, AMD_UDMA_133 },
75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, AMD_UDMA_133 },
75 { 0 } 76 { 0 }
76}; 77};
77 78
@@ -487,6 +488,7 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
487 /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2"), 488 /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2"),
488 /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"), 489 /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"),
489 /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"), 490 /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"),
491 /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"),
490}; 492};
491 493
492static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 494static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -521,6 +523,7 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
521#endif 523#endif
522 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, 524 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 },
523 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, 525 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 },
526 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 },
524 { 0, }, 527 { 0, },
525}; 528};
526MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 529MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 1c563f905a5..a7f15d9f13e 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
401static void encode_hdlc(struct baycom_state *bc) 378static 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
644static int receive(struct net_device *dev, int cnt) 581static 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 41e51711480..c6e8b25f968 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 c59507f8a76..b3768d84474 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
2130static inline int rtl8169_fragmented_frame(u32 status)
2131{
2132 return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag);
2133}
2134
2130static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) 2135static 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 2246move_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 e68cf5fb492..20edeb34579 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
107static 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
123static void shaper_kick(struct shaper *sh); 103static void shaper_kick(struct shaper *sh);
124 104
125static 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
160static int shaper_qframe(struct shaper *shaper, struct sk_buff *skb) 133
134static 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
298static void shaper_timer(unsigned long data) 270static 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)
376static void shaper_flush(struct shaper *shaper) 338static 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
430static 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
436static struct net_device_stats *shaper_get_stats(struct net_device *dev) 389static 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/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 9e9dab7fe86..8132d946c38 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * CompactPCI Hot Plug Driver 2 * CompactPCI Hot Plug Driver
3 * 3 *
4 * Copyright (C) 2002 SOMA Networks, Inc. 4 * Copyright (C) 2002,2005 SOMA Networks, Inc.
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) 5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp. 6 * Copyright (C) 2001 IBM Corp.
7 * 7 *
@@ -45,10 +45,10 @@
45 45
46#define dbg(format, arg...) \ 46#define dbg(format, arg...) \
47 do { \ 47 do { \
48 if(cpci_debug) \ 48 if (cpci_debug) \
49 printk (KERN_DEBUG "%s: " format "\n", \ 49 printk (KERN_DEBUG "%s: " format "\n", \
50 MY_NAME , ## arg); \ 50 MY_NAME , ## arg); \
51 } while(0) 51 } while (0)
52#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 52#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
53#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 53#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
54#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 54#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
@@ -111,10 +111,8 @@ enable_slot(struct hotplug_slot *hotplug_slot)
111 111
112 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); 112 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name);
113 113
114 if(controller->ops->set_power) { 114 if (controller->ops->set_power)
115 retval = controller->ops->set_power(slot, 1); 115 retval = controller->ops->set_power(slot, 1);
116 }
117
118 return retval; 116 return retval;
119} 117}
120 118
@@ -126,37 +124,41 @@ disable_slot(struct hotplug_slot *hotplug_slot)
126 124
127 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); 125 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name);
128 126
127 down_write(&list_rwsem);
128
129 /* Unconfigure device */ 129 /* Unconfigure device */
130 dbg("%s - unconfiguring slot %s", 130 dbg("%s - unconfiguring slot %s",
131 __FUNCTION__, slot->hotplug_slot->name); 131 __FUNCTION__, slot->hotplug_slot->name);
132 if((retval = cpci_unconfigure_slot(slot))) { 132 if ((retval = cpci_unconfigure_slot(slot))) {
133 err("%s - could not unconfigure slot %s", 133 err("%s - could not unconfigure slot %s",
134 __FUNCTION__, slot->hotplug_slot->name); 134 __FUNCTION__, slot->hotplug_slot->name);
135 return retval; 135 goto disable_error;
136 } 136 }
137 dbg("%s - finished unconfiguring slot %s", 137 dbg("%s - finished unconfiguring slot %s",
138 __FUNCTION__, slot->hotplug_slot->name); 138 __FUNCTION__, slot->hotplug_slot->name);
139 139
140 /* Clear EXT (by setting it) */ 140 /* Clear EXT (by setting it) */
141 if(cpci_clear_ext(slot)) { 141 if (cpci_clear_ext(slot)) {
142 err("%s - could not clear EXT for slot %s", 142 err("%s - could not clear EXT for slot %s",
143 __FUNCTION__, slot->hotplug_slot->name); 143 __FUNCTION__, slot->hotplug_slot->name);
144 retval = -ENODEV; 144 retval = -ENODEV;
145 goto disable_error;
145 } 146 }
146 cpci_led_on(slot); 147 cpci_led_on(slot);
147 148
148 if(controller->ops->set_power) { 149 if (controller->ops->set_power)
149 retval = controller->ops->set_power(slot, 0); 150 if ((retval = controller->ops->set_power(slot, 0)))
150 } 151 goto disable_error;
151 152
152 if(update_adapter_status(slot->hotplug_slot, 0)) { 153 if (update_adapter_status(slot->hotplug_slot, 0))
153 warn("failure to update adapter file"); 154 warn("failure to update adapter file");
154 }
155 155
156 if(slot->extracting) { 156 if (slot->extracting) {
157 slot->extracting = 0; 157 slot->extracting = 0;
158 atomic_dec(&extracting); 158 atomic_dec(&extracting);
159 } 159 }
160disable_error:
161 up_write(&list_rwsem);
160 return retval; 162 return retval;
161} 163}
162 164
@@ -165,9 +167,8 @@ cpci_get_power_status(struct slot *slot)
165{ 167{
166 u8 power = 1; 168 u8 power = 1;
167 169
168 if(controller->ops->get_power) { 170 if (controller->ops->get_power)
169 power = controller->ops->get_power(slot); 171 power = controller->ops->get_power(slot);
170 }
171 return power; 172 return power;
172} 173}
173 174
@@ -237,9 +238,8 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
237 int status = -ENOMEM; 238 int status = -ENOMEM;
238 int i; 239 int i;
239 240
240 if(!(controller && bus)) { 241 if (!(controller && bus))
241 return -ENODEV; 242 return -ENODEV;
242 }
243 243
244 /* 244 /*
245 * Create a structure for each slot, and register that slot 245 * Create a structure for each slot, and register that slot
@@ -316,32 +316,30 @@ int
316cpci_hp_unregister_bus(struct pci_bus *bus) 316cpci_hp_unregister_bus(struct pci_bus *bus)
317{ 317{
318 struct slot *slot; 318 struct slot *slot;
319 struct list_head *tmp; 319 struct slot *tmp;
320 struct list_head *next; 320 int status = 0;
321 int status;
322 321
323 down_write(&list_rwsem); 322 down_write(&list_rwsem);
324 if(!slots) { 323 if (!slots) {
325 up_write(&list_rwsem); 324 up_write(&list_rwsem);
326 return -1; 325 return -1;
327 } 326 }
328 list_for_each_safe(tmp, next, &slot_list) { 327 list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) {
329 slot = list_entry(tmp, struct slot, slot_list); 328 if (slot->bus == bus) {
330 if(slot->bus == bus) { 329 list_del(&slot->slot_list);
330 slots--;
331
331 dbg("deregistering slot %s", slot->hotplug_slot->name); 332 dbg("deregistering slot %s", slot->hotplug_slot->name);
332 status = pci_hp_deregister(slot->hotplug_slot); 333 status = pci_hp_deregister(slot->hotplug_slot);
333 if(status) { 334 if (status) {
334 err("pci_hp_deregister failed with error %d", 335 err("pci_hp_deregister failed with error %d",
335 status); 336 status);
336 return status; 337 break;
337 } 338 }
338
339 list_del(&slot->slot_list);
340 slots--;
341 } 339 }
342 } 340 }
343 up_write(&list_rwsem); 341 up_write(&list_rwsem);
344 return 0; 342 return status;
345} 343}
346 344
347/* This is the interrupt mode interrupt handler */ 345/* This is the interrupt mode interrupt handler */
@@ -351,7 +349,7 @@ cpci_hp_intr(int irq, void *data, struct pt_regs *regs)
351 dbg("entered cpci_hp_intr"); 349 dbg("entered cpci_hp_intr");
352 350
353 /* Check to see if it was our interrupt */ 351 /* Check to see if it was our interrupt */
354 if((controller->irq_flags & SA_SHIRQ) && 352 if ((controller->irq_flags & SA_SHIRQ) &&
355 !controller->ops->check_irq(controller->dev_id)) { 353 !controller->ops->check_irq(controller->dev_id)) {
356 dbg("exited cpci_hp_intr, not our interrupt"); 354 dbg("exited cpci_hp_intr, not our interrupt");
357 return IRQ_NONE; 355 return IRQ_NONE;
@@ -373,38 +371,30 @@ cpci_hp_intr(int irq, void *data, struct pt_regs *regs)
373 * INS bits of the cold-inserted devices. 371 * INS bits of the cold-inserted devices.
374 */ 372 */
375static int 373static int
376init_slots(void) 374init_slots(int clear_ins)
377{ 375{
378 struct slot *slot; 376 struct slot *slot;
379 struct list_head *tmp;
380 struct pci_dev* dev; 377 struct pci_dev* dev;
381 378
382 dbg("%s - enter", __FUNCTION__); 379 dbg("%s - enter", __FUNCTION__);
383 down_read(&list_rwsem); 380 down_read(&list_rwsem);
384 if(!slots) { 381 if (!slots) {
385 up_read(&list_rwsem); 382 up_read(&list_rwsem);
386 return -1; 383 return -1;
387 } 384 }
388 list_for_each(tmp, &slot_list) { 385 list_for_each_entry(slot, &slot_list, slot_list) {
389 slot = list_entry(tmp, struct slot, slot_list);
390 dbg("%s - looking at slot %s", 386 dbg("%s - looking at slot %s",
391 __FUNCTION__, slot->hotplug_slot->name); 387 __FUNCTION__, slot->hotplug_slot->name);
392 if(cpci_check_and_clear_ins(slot)) { 388 if (clear_ins && cpci_check_and_clear_ins(slot))
393 dbg("%s - cleared INS for slot %s", 389 dbg("%s - cleared INS for slot %s",
394 __FUNCTION__, slot->hotplug_slot->name); 390 __FUNCTION__, slot->hotplug_slot->name);
395 dev = pci_find_slot(slot->bus->number, PCI_DEVFN(slot->number, 0)); 391 dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0));
396 if(dev) { 392 if (dev) {
397 if(update_adapter_status(slot->hotplug_slot, 1)) { 393 if (update_adapter_status(slot->hotplug_slot, 1))
398 warn("failure to update adapter file"); 394 warn("failure to update adapter file");
399 } 395 if (update_latch_status(slot->hotplug_slot, 1))
400 if(update_latch_status(slot->hotplug_slot, 1)) { 396 warn("failure to update latch file");
401 warn("failure to update latch file"); 397 slot->dev = dev;
402 }
403 slot->dev = dev;
404 } else {
405 err("%s - no driver attached to device in slot %s",
406 __FUNCTION__, slot->hotplug_slot->name);
407 }
408 } 398 }
409 } 399 }
410 up_read(&list_rwsem); 400 up_read(&list_rwsem);
@@ -416,26 +406,28 @@ static int
416check_slots(void) 406check_slots(void)
417{ 407{
418 struct slot *slot; 408 struct slot *slot;
419 struct list_head *tmp;
420 int extracted; 409 int extracted;
421 int inserted; 410 int inserted;
422 u16 hs_csr; 411 u16 hs_csr;
423 412
424 down_read(&list_rwsem); 413 down_read(&list_rwsem);
425 if(!slots) { 414 if (!slots) {
426 up_read(&list_rwsem); 415 up_read(&list_rwsem);
427 err("no slots registered, shutting down"); 416 err("no slots registered, shutting down");
428 return -1; 417 return -1;
429 } 418 }
430 extracted = inserted = 0; 419 extracted = inserted = 0;
431 list_for_each(tmp, &slot_list) { 420 list_for_each_entry(slot, &slot_list, slot_list) {
432 slot = list_entry(tmp, struct slot, slot_list);
433 dbg("%s - looking at slot %s", 421 dbg("%s - looking at slot %s",
434 __FUNCTION__, slot->hotplug_slot->name); 422 __FUNCTION__, slot->hotplug_slot->name);
435 if(cpci_check_and_clear_ins(slot)) { 423 if (cpci_check_and_clear_ins(slot)) {
436 /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */ 424 /*
437 if(slot->dev) { 425 * Some broken hardware (e.g. PLX 9054AB) asserts
438 warn("slot %s already inserted", slot->hotplug_slot->name); 426 * ENUM# twice...
427 */
428 if (slot->dev) {
429 warn("slot %s already inserted",
430 slot->hotplug_slot->name);
439 inserted++; 431 inserted++;
440 continue; 432 continue;
441 } 433 }
@@ -452,7 +444,7 @@ check_slots(void)
452 /* Configure device */ 444 /* Configure device */
453 dbg("%s - configuring slot %s", 445 dbg("%s - configuring slot %s",
454 __FUNCTION__, slot->hotplug_slot->name); 446 __FUNCTION__, slot->hotplug_slot->name);
455 if(cpci_configure_slot(slot)) { 447 if (cpci_configure_slot(slot)) {
456 err("%s - could not configure slot %s", 448 err("%s - could not configure slot %s",
457 __FUNCTION__, slot->hotplug_slot->name); 449 __FUNCTION__, slot->hotplug_slot->name);
458 continue; 450 continue;
@@ -465,13 +457,11 @@ check_slots(void)
465 dbg("%s - slot %s HS_CSR (2) = %04x", 457 dbg("%s - slot %s HS_CSR (2) = %04x",
466 __FUNCTION__, slot->hotplug_slot->name, hs_csr); 458 __FUNCTION__, slot->hotplug_slot->name, hs_csr);
467 459
468 if(update_latch_status(slot->hotplug_slot, 1)) { 460 if (update_latch_status(slot->hotplug_slot, 1))
469 warn("failure to update latch file"); 461 warn("failure to update latch file");
470 }
471 462
472 if(update_adapter_status(slot->hotplug_slot, 1)) { 463 if (update_adapter_status(slot->hotplug_slot, 1))
473 warn("failure to update adapter file"); 464 warn("failure to update adapter file");
474 }
475 465
476 cpci_led_off(slot); 466 cpci_led_off(slot);
477 467
@@ -481,7 +471,7 @@ check_slots(void)
481 __FUNCTION__, slot->hotplug_slot->name, hs_csr); 471 __FUNCTION__, slot->hotplug_slot->name, hs_csr);
482 472
483 inserted++; 473 inserted++;
484 } else if(cpci_check_ext(slot)) { 474 } else if (cpci_check_ext(slot)) {
485 /* Process extraction request */ 475 /* Process extraction request */
486 dbg("%s - slot %s extracted", 476 dbg("%s - slot %s extracted",
487 __FUNCTION__, slot->hotplug_slot->name); 477 __FUNCTION__, slot->hotplug_slot->name);
@@ -491,27 +481,25 @@ check_slots(void)
491 dbg("%s - slot %s HS_CSR = %04x", 481 dbg("%s - slot %s HS_CSR = %04x",
492 __FUNCTION__, slot->hotplug_slot->name, hs_csr); 482 __FUNCTION__, slot->hotplug_slot->name, hs_csr);
493 483
494 if(!slot->extracting) { 484 if (!slot->extracting) {
495 if(update_latch_status(slot->hotplug_slot, 0)) { 485 if (update_latch_status(slot->hotplug_slot, 0)) {
496 warn("failure to update latch file"); 486 warn("failure to update latch file");
497
498 } 487 }
499 atomic_inc(&extracting);
500 slot->extracting = 1; 488 slot->extracting = 1;
489 atomic_inc(&extracting);
501 } 490 }
502 extracted++; 491 extracted++;
503 } else if(slot->extracting) { 492 } else if (slot->extracting) {
504 hs_csr = cpci_get_hs_csr(slot); 493 hs_csr = cpci_get_hs_csr(slot);
505 if(hs_csr == 0xffff) { 494 if (hs_csr == 0xffff) {
506 /* 495 /*
507 * Hmmm, we're likely hosed at this point, should we 496 * Hmmm, we're likely hosed at this point, should we
508 * bother trying to tell the driver or not? 497 * bother trying to tell the driver or not?
509 */ 498 */
510 err("card in slot %s was improperly removed", 499 err("card in slot %s was improperly removed",
511 slot->hotplug_slot->name); 500 slot->hotplug_slot->name);
512 if(update_adapter_status(slot->hotplug_slot, 0)) { 501 if (update_adapter_status(slot->hotplug_slot, 0))
513 warn("failure to update adapter file"); 502 warn("failure to update adapter file");
514 }
515 slot->extracting = 0; 503 slot->extracting = 0;
516 atomic_dec(&extracting); 504 atomic_dec(&extracting);
517 } 505 }
@@ -520,10 +508,9 @@ check_slots(void)
520 up_read(&list_rwsem); 508 up_read(&list_rwsem);
521 dbg("inserted=%d, extracted=%d, extracting=%d", 509 dbg("inserted=%d, extracted=%d, extracting=%d",
522 inserted, extracted, atomic_read(&extracting)); 510 inserted, extracted, atomic_read(&extracting));
523 if(inserted || extracted) { 511 if (inserted || extracted)
524 return extracted; 512 return extracted;
525 } 513 else if (!atomic_read(&extracting)) {
526 else if(!atomic_read(&extracting)) {
527 err("cannot find ENUM# source, shutting down"); 514 err("cannot find ENUM# source, shutting down");
528 return -1; 515 return -1;
529 } 516 }
@@ -541,12 +528,12 @@ event_thread(void *data)
541 unlock_kernel(); 528 unlock_kernel();
542 529
543 dbg("%s - event thread started", __FUNCTION__); 530 dbg("%s - event thread started", __FUNCTION__);
544 while(1) { 531 while (1) {
545 dbg("event thread sleeping"); 532 dbg("event thread sleeping");
546 down_interruptible(&event_semaphore); 533 down_interruptible(&event_semaphore);
547 dbg("event thread woken, thread_finished = %d", 534 dbg("event thread woken, thread_finished = %d",
548 thread_finished); 535 thread_finished);
549 if(thread_finished || signal_pending(current)) 536 if (thread_finished || signal_pending(current))
550 break; 537 break;
551 do { 538 do {
552 rc = check_slots(); 539 rc = check_slots();
@@ -558,7 +545,9 @@ event_thread(void *data)
558 thread_finished = 1; 545 thread_finished = 1;
559 break; 546 break;
560 } 547 }
561 } while(atomic_read(&extracting) != 0); 548 } while (atomic_read(&extracting) && !thread_finished);
549 if (thread_finished)
550 break;
562 551
563 /* Re-enable ENUM# interrupt */ 552 /* Re-enable ENUM# interrupt */
564 dbg("%s - re-enabling irq", __FUNCTION__); 553 dbg("%s - re-enabling irq", __FUNCTION__);
@@ -579,21 +568,21 @@ poll_thread(void *data)
579 daemonize("cpci_hp_polld"); 568 daemonize("cpci_hp_polld");
580 unlock_kernel(); 569 unlock_kernel();
581 570
582 while(1) { 571 while (1) {
583 if(thread_finished || signal_pending(current)) 572 if (thread_finished || signal_pending(current))
584 break; 573 break;
585 if(controller->ops->query_enum()) { 574 if (controller->ops->query_enum()) {
586 do { 575 do {
587 rc = check_slots(); 576 rc = check_slots();
588 if(rc > 0) { 577 if (rc > 0) {
589 /* Give userspace a chance to handle extraction */ 578 /* Give userspace a chance to handle extraction */
590 msleep(500); 579 msleep(500);
591 } else if(rc < 0) { 580 } else if (rc < 0) {
592 dbg("%s - error checking slots", __FUNCTION__); 581 dbg("%s - error checking slots", __FUNCTION__);
593 thread_finished = 1; 582 thread_finished = 1;
594 break; 583 break;
595 } 584 }
596 } while(atomic_read(&extracting) != 0); 585 } while (atomic_read(&extracting) && !thread_finished);
597 } 586 }
598 msleep(100); 587 msleep(100);
599 } 588 }
@@ -612,12 +601,11 @@ cpci_start_thread(void)
612 init_MUTEX_LOCKED(&thread_exit); 601 init_MUTEX_LOCKED(&thread_exit);
613 thread_finished = 0; 602 thread_finished = 0;
614 603
615 if(controller->irq) { 604 if (controller->irq)
616 pid = kernel_thread(event_thread, NULL, 0); 605 pid = kernel_thread(event_thread, NULL, 0);
617 } else { 606 else
618 pid = kernel_thread(poll_thread, NULL, 0); 607 pid = kernel_thread(poll_thread, NULL, 0);
619 } 608 if (pid < 0) {
620 if(pid < 0) {
621 err("Can't start up our thread"); 609 err("Can't start up our thread");
622 return -1; 610 return -1;
623 } 611 }
@@ -630,9 +618,8 @@ cpci_stop_thread(void)
630{ 618{
631 thread_finished = 1; 619 thread_finished = 1;
632 dbg("thread finish command given"); 620 dbg("thread finish command given");
633 if(controller->irq) { 621 if (controller->irq)
634 up(&event_semaphore); 622 up(&event_semaphore);
635 }
636 dbg("wait for thread to exit"); 623 dbg("wait for thread to exit");
637 down(&thread_exit); 624 down(&thread_exit);
638} 625}
@@ -642,45 +629,67 @@ cpci_hp_register_controller(struct cpci_hp_controller *new_controller)
642{ 629{
643 int status = 0; 630 int status = 0;
644 631
645 if(!controller) { 632 if (controller)
646 controller = new_controller; 633 return -1;
647 if(controller->irq) { 634 if (!(new_controller && new_controller->ops))
648 if(request_irq(controller->irq, 635 return -EINVAL;
649 cpci_hp_intr, 636 if (new_controller->irq) {
650 controller->irq_flags, 637 if (!(new_controller->ops->enable_irq &&
651 MY_NAME, controller->dev_id)) { 638 new_controller->ops->disable_irq))
652 err("Can't get irq %d for the hotplug cPCI controller", controller->irq); 639 status = -EINVAL;
653 status = -ENODEV; 640 if (request_irq(new_controller->irq,
654 } 641 cpci_hp_intr,
655 dbg("%s - acquired controller irq %d", __FUNCTION__, 642 new_controller->irq_flags,
656 controller->irq); 643 MY_NAME,
644 new_controller->dev_id)) {
645 err("Can't get irq %d for the hotplug cPCI controller",
646 new_controller->irq);
647 status = -ENODEV;
657 } 648 }
658 } else { 649 dbg("%s - acquired controller irq %d",
659 err("cPCI hotplug controller already registered"); 650 __FUNCTION__, new_controller->irq);
660 status = -1;
661 } 651 }
652 if (!status)
653 controller = new_controller;
662 return status; 654 return status;
663} 655}
664 656
657static void
658cleanup_slots(void)
659{
660 struct slot *slot;
661 struct slot *tmp;
662
663 /*
664 * Unregister all of our slots with the pci_hotplug subsystem,
665 * and free up all memory that we had allocated.
666 */
667 down_write(&list_rwsem);
668 if (!slots)
669 goto cleanup_null;
670 list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) {
671 list_del(&slot->slot_list);
672 pci_hp_deregister(slot->hotplug_slot);
673 }
674cleanup_null:
675 up_write(&list_rwsem);
676 return;
677}
678
665int 679int
666cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller) 680cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller)
667{ 681{
668 int status = 0; 682 int status = 0;
669 683
670 if(controller) { 684 if (controller) {
671 if(atomic_read(&extracting) != 0) { 685 if (!thread_finished)
672 return -EBUSY;
673 }
674 if(!thread_finished) {
675 cpci_stop_thread(); 686 cpci_stop_thread();
676 } 687 if (controller->irq)
677 if(controller->irq) {
678 free_irq(controller->irq, controller->dev_id); 688 free_irq(controller->irq, controller->dev_id);
679 }
680 controller = NULL; 689 controller = NULL;
681 } else { 690 cleanup_slots();
691 } else
682 status = -ENODEV; 692 status = -ENODEV;
683 }
684 return status; 693 return status;
685} 694}
686 695
@@ -691,32 +700,28 @@ cpci_hp_start(void)
691 int status; 700 int status;
692 701
693 dbg("%s - enter", __FUNCTION__); 702 dbg("%s - enter", __FUNCTION__);
694 if(!controller) { 703 if (!controller)
695 return -ENODEV; 704 return -ENODEV;
696 }
697 705
698 down_read(&list_rwsem); 706 down_read(&list_rwsem);
699 if(list_empty(&slot_list)) { 707 if (list_empty(&slot_list)) {
700 up_read(&list_rwsem); 708 up_read(&list_rwsem);
701 return -ENODEV; 709 return -ENODEV;
702 } 710 }
703 up_read(&list_rwsem); 711 up_read(&list_rwsem);
704 712
705 if(first) { 713 status = init_slots(first);
706 status = init_slots(); 714 if (first)
707 if(status) {
708 return status;
709 }
710 first = 0; 715 first = 0;
711 } 716 if (status)
717 return status;
712 718
713 status = cpci_start_thread(); 719 status = cpci_start_thread();
714 if(status) { 720 if (status)
715 return status; 721 return status;
716 }
717 dbg("%s - thread started", __FUNCTION__); 722 dbg("%s - thread started", __FUNCTION__);
718 723
719 if(controller->irq) { 724 if (controller->irq) {
720 /* Start enum interrupt processing */ 725 /* Start enum interrupt processing */
721 dbg("%s - enabling irq", __FUNCTION__); 726 dbg("%s - enabling irq", __FUNCTION__);
722 controller->ops->enable_irq(); 727 controller->ops->enable_irq();
@@ -728,13 +733,9 @@ cpci_hp_start(void)
728int 733int
729cpci_hp_stop(void) 734cpci_hp_stop(void)
730{ 735{
731 if(!controller) { 736 if (!controller)
732 return -ENODEV; 737 return -ENODEV;
733 } 738 if (controller->irq) {
734 if(atomic_read(&extracting) != 0) {
735 return -EBUSY;
736 }
737 if(controller->irq) {
738 /* Stop enum interrupt processing */ 739 /* Stop enum interrupt processing */
739 dbg("%s - disabling irq", __FUNCTION__); 740 dbg("%s - disabling irq", __FUNCTION__);
740 controller->ops->disable_irq(); 741 controller->ops->disable_irq();
@@ -743,34 +744,6 @@ cpci_hp_stop(void)
743 return 0; 744 return 0;
744} 745}
745 746
746static void __exit
747cleanup_slots(void)
748{
749 struct list_head *tmp;
750 struct slot *slot;
751
752 /*
753 * Unregister all of our slots with the pci_hotplug subsystem,
754 * and free up all memory that we had allocated.
755 */
756 down_write(&list_rwsem);
757 if(!slots) {
758 goto null_cleanup;
759 }
760 list_for_each(tmp, &slot_list) {
761 slot = list_entry(tmp, struct slot, slot_list);
762 list_del(&slot->slot_list);
763 pci_hp_deregister(slot->hotplug_slot);
764 kfree(slot->hotplug_slot->info);
765 kfree(slot->hotplug_slot->name);
766 kfree(slot->hotplug_slot);
767 kfree(slot);
768 }
769 null_cleanup:
770 up_write(&list_rwsem);
771 return;
772}
773
774int __init 747int __init
775cpci_hotplug_init(int debug) 748cpci_hotplug_init(int debug)
776{ 749{
@@ -784,7 +757,8 @@ cpci_hotplug_exit(void)
784 /* 757 /*
785 * Clean everything up. 758 * Clean everything up.
786 */ 759 */
787 cleanup_slots(); 760 cpci_hp_stop();
761 cpci_hp_unregister_controller(controller);
788} 762}
789 763
790EXPORT_SYMBOL_GPL(cpci_hp_register_controller); 764EXPORT_SYMBOL_GPL(cpci_hp_register_controller);
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 69eb4fc54f2..c878028ad21 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * CompactPCI Hot Plug Driver PCI functions 2 * CompactPCI Hot Plug Driver PCI functions
3 * 3 *
4 * Copyright (C) 2002 by SOMA Networks, Inc. 4 * Copyright (C) 2002,2005 by SOMA Networks, Inc.
5 * 5 *
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -38,10 +38,10 @@ extern int cpci_debug;
38 38
39#define dbg(format, arg...) \ 39#define dbg(format, arg...) \
40 do { \ 40 do { \
41 if(cpci_debug) \ 41 if (cpci_debug) \
42 printk (KERN_DEBUG "%s: " format "\n", \ 42 printk (KERN_DEBUG "%s: " format "\n", \
43 MY_NAME , ## arg); \ 43 MY_NAME , ## arg); \
44 } while(0) 44 } while (0)
45#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 45#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
46#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 46#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
47#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 47#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
@@ -57,16 +57,15 @@ u8 cpci_get_attention_status(struct slot* slot)
57 hs_cap = pci_bus_find_capability(slot->bus, 57 hs_cap = pci_bus_find_capability(slot->bus,
58 slot->devfn, 58 slot->devfn,
59 PCI_CAP_ID_CHSWP); 59 PCI_CAP_ID_CHSWP);
60 if(!hs_cap) { 60 if (!hs_cap)
61 return 0; 61 return 0;
62 }
63 62
64 if(pci_bus_read_config_word(slot->bus, 63 if (pci_bus_read_config_word(slot->bus,
65 slot->devfn, 64 slot->devfn,
66 hs_cap + 2, 65 hs_cap + 2,
67 &hs_csr)) { 66 &hs_csr))
68 return 0; 67 return 0;
69 } 68
70 return hs_csr & 0x0008 ? 1 : 0; 69 return hs_csr & 0x0008 ? 1 : 0;
71} 70}
72 71
@@ -78,27 +77,22 @@ int cpci_set_attention_status(struct slot* slot, int status)
78 hs_cap = pci_bus_find_capability(slot->bus, 77 hs_cap = pci_bus_find_capability(slot->bus,
79 slot->devfn, 78 slot->devfn,
80 PCI_CAP_ID_CHSWP); 79 PCI_CAP_ID_CHSWP);
81 if(!hs_cap) { 80 if (!hs_cap)
82 return 0; 81 return 0;
83 } 82 if (pci_bus_read_config_word(slot->bus,
84
85 if(pci_bus_read_config_word(slot->bus,
86 slot->devfn, 83 slot->devfn,
87 hs_cap + 2, 84 hs_cap + 2,
88 &hs_csr)) { 85 &hs_csr))
89 return 0; 86 return 0;
90 } 87 if (status)
91 if(status) {
92 hs_csr |= HS_CSR_LOO; 88 hs_csr |= HS_CSR_LOO;
93 } else { 89 else
94 hs_csr &= ~HS_CSR_LOO; 90 hs_csr &= ~HS_CSR_LOO;
95 } 91 if (pci_bus_write_config_word(slot->bus,
96 if(pci_bus_write_config_word(slot->bus,
97 slot->devfn, 92 slot->devfn,
98 hs_cap + 2, 93 hs_cap + 2,
99 hs_csr)) { 94 hs_csr))
100 return 0; 95 return 0;
101 }
102 return 1; 96 return 1;
103} 97}
104 98
@@ -110,16 +104,13 @@ u16 cpci_get_hs_csr(struct slot* slot)
110 hs_cap = pci_bus_find_capability(slot->bus, 104 hs_cap = pci_bus_find_capability(slot->bus,
111 slot->devfn, 105 slot->devfn,
112 PCI_CAP_ID_CHSWP); 106 PCI_CAP_ID_CHSWP);
113 if(!hs_cap) { 107 if (!hs_cap)
114 return 0xFFFF; 108 return 0xFFFF;
115 } 109 if (pci_bus_read_config_word(slot->bus,
116
117 if(pci_bus_read_config_word(slot->bus,
118 slot->devfn, 110 slot->devfn,
119 hs_cap + 2, 111 hs_cap + 2,
120 &hs_csr)) { 112 &hs_csr))
121 return 0xFFFF; 113 return 0xFFFF;
122 }
123 return hs_csr; 114 return hs_csr;
124} 115}
125 116
@@ -132,24 +123,22 @@ int cpci_check_and_clear_ins(struct slot* slot)
132 hs_cap = pci_bus_find_capability(slot->bus, 123 hs_cap = pci_bus_find_capability(slot->bus,
133 slot->devfn, 124 slot->devfn,
134 PCI_CAP_ID_CHSWP); 125 PCI_CAP_ID_CHSWP);
135 if(!hs_cap) { 126 if (!hs_cap)
136 return 0; 127 return 0;
137 } 128 if (pci_bus_read_config_word(slot->bus,
138 if(pci_bus_read_config_word(slot->bus,
139 slot->devfn, 129 slot->devfn,
140 hs_cap + 2, 130 hs_cap + 2,
141 &hs_csr)) { 131 &hs_csr))
142 return 0; 132 return 0;
143 } 133 if (hs_csr & HS_CSR_INS) {
144 if(hs_csr & HS_CSR_INS) {
145 /* Clear INS (by setting it) */ 134 /* Clear INS (by setting it) */
146 if(pci_bus_write_config_word(slot->bus, 135 if (pci_bus_write_config_word(slot->bus,
147 slot->devfn, 136 slot->devfn,
148 hs_cap + 2, 137 hs_cap + 2,
149 hs_csr)) { 138 hs_csr))
150 ins = 0; 139 ins = 0;
151 } 140 else
152 ins = 1; 141 ins = 1;
153 } 142 }
154 return ins; 143 return ins;
155} 144}
@@ -163,18 +152,15 @@ int cpci_check_ext(struct slot* slot)
163 hs_cap = pci_bus_find_capability(slot->bus, 152 hs_cap = pci_bus_find_capability(slot->bus,
164 slot->devfn, 153 slot->devfn,
165 PCI_CAP_ID_CHSWP); 154 PCI_CAP_ID_CHSWP);
166 if(!hs_cap) { 155 if (!hs_cap)
167 return 0; 156 return 0;
168 } 157 if (pci_bus_read_config_word(slot->bus,
169 if(pci_bus_read_config_word(slot->bus,
170 slot->devfn, 158 slot->devfn,
171 hs_cap + 2, 159 hs_cap + 2,
172 &hs_csr)) { 160 &hs_csr))
173 return 0; 161 return 0;
174 } 162 if (hs_csr & HS_CSR_EXT)
175 if(hs_csr & HS_CSR_EXT) {
176 ext = 1; 163 ext = 1;
177 }
178 return ext; 164 return ext;
179} 165}
180 166
@@ -186,23 +172,20 @@ int cpci_clear_ext(struct slot* slot)
186 hs_cap = pci_bus_find_capability(slot->bus, 172 hs_cap = pci_bus_find_capability(slot->bus,
187 slot->devfn, 173 slot->devfn,
188 PCI_CAP_ID_CHSWP); 174 PCI_CAP_ID_CHSWP);
189 if(!hs_cap) { 175 if (!hs_cap)
190 return -ENODEV; 176 return -ENODEV;
191 } 177 if (pci_bus_read_config_word(slot->bus,
192 if(pci_bus_read_config_word(slot->bus,
193 slot->devfn, 178 slot->devfn,
194 hs_cap + 2, 179 hs_cap + 2,
195 &hs_csr)) { 180 &hs_csr))
196 return -ENODEV; 181 return -ENODEV;
197 } 182 if (hs_csr & HS_CSR_EXT) {
198 if(hs_csr & HS_CSR_EXT) {
199 /* Clear EXT (by setting it) */ 183 /* Clear EXT (by setting it) */
200 if(pci_bus_write_config_word(slot->bus, 184 if (pci_bus_write_config_word(slot->bus,
201 slot->devfn, 185 slot->devfn,
202 hs_cap + 2, 186 hs_cap + 2,
203 hs_csr)) { 187 hs_csr))
204 return -ENODEV; 188 return -ENODEV;
205 }
206 } 189 }
207 return 0; 190 return 0;
208} 191}
@@ -215,18 +198,16 @@ int cpci_led_on(struct slot* slot)
215 hs_cap = pci_bus_find_capability(slot->bus, 198 hs_cap = pci_bus_find_capability(slot->bus,
216 slot->devfn, 199 slot->devfn,
217 PCI_CAP_ID_CHSWP); 200 PCI_CAP_ID_CHSWP);
218 if(!hs_cap) { 201 if (!hs_cap)
219 return -ENODEV; 202 return -ENODEV;
220 } 203 if (pci_bus_read_config_word(slot->bus,
221 if(pci_bus_read_config_word(slot->bus,
222 slot->devfn, 204 slot->devfn,
223 hs_cap + 2, 205 hs_cap + 2,
224 &hs_csr)) { 206 &hs_csr))
225 return -ENODEV; 207 return -ENODEV;
226 } 208 if ((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) {
227 if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) {
228 hs_csr |= HS_CSR_LOO; 209 hs_csr |= HS_CSR_LOO;
229 if(pci_bus_write_config_word(slot->bus, 210 if (pci_bus_write_config_word(slot->bus,
230 slot->devfn, 211 slot->devfn,
231 hs_cap + 2, 212 hs_cap + 2,
232 hs_csr)) { 213 hs_csr)) {
@@ -246,18 +227,16 @@ int cpci_led_off(struct slot* slot)
246 hs_cap = pci_bus_find_capability(slot->bus, 227 hs_cap = pci_bus_find_capability(slot->bus,
247 slot->devfn, 228 slot->devfn,
248 PCI_CAP_ID_CHSWP); 229 PCI_CAP_ID_CHSWP);
249 if(!hs_cap) { 230 if (!hs_cap)
250 return -ENODEV; 231 return -ENODEV;
251 } 232 if (pci_bus_read_config_word(slot->bus,
252 if(pci_bus_read_config_word(slot->bus,
253 slot->devfn, 233 slot->devfn,
254 hs_cap + 2, 234 hs_cap + 2,
255 &hs_csr)) { 235 &hs_csr))
256 return -ENODEV; 236 return -ENODEV;
257 } 237 if (hs_csr & HS_CSR_LOO) {
258 if(hs_csr & HS_CSR_LOO) {
259 hs_csr &= ~HS_CSR_LOO; 238 hs_csr &= ~HS_CSR_LOO;
260 if(pci_bus_write_config_word(slot->bus, 239 if (pci_bus_write_config_word(slot->bus,
261 slot->devfn, 240 slot->devfn,
262 hs_cap + 2, 241 hs_cap + 2,
263 hs_csr)) { 242 hs_csr)) {
@@ -274,19 +253,6 @@ int cpci_led_off(struct slot* slot)
274 * Device configuration functions 253 * Device configuration functions
275 */ 254 */
276 255
277static void cpci_enable_device(struct pci_dev *dev)
278{
279 struct pci_bus *bus;
280
281 pci_enable_device(dev);
282 if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
283 bus = dev->subordinate;
284 list_for_each_entry(dev, &bus->devices, bus_list) {
285 cpci_enable_device(dev);
286 }
287 }
288}
289
290int cpci_configure_slot(struct slot* slot) 256int cpci_configure_slot(struct slot* slot)
291{ 257{
292 unsigned char busnr; 258 unsigned char busnr;
@@ -294,14 +260,14 @@ int cpci_configure_slot(struct slot* slot)
294 260
295 dbg("%s - enter", __FUNCTION__); 261 dbg("%s - enter", __FUNCTION__);
296 262
297 if(slot->dev == NULL) { 263 if (slot->dev == NULL) {
298 dbg("pci_dev null, finding %02x:%02x:%x", 264 dbg("pci_dev null, finding %02x:%02x:%x",
299 slot->bus->number, PCI_SLOT(slot->devfn), PCI_FUNC(slot->devfn)); 265 slot->bus->number, PCI_SLOT(slot->devfn), PCI_FUNC(slot->devfn));
300 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 266 slot->dev = pci_get_slot(slot->bus, slot->devfn);
301 } 267 }
302 268
303 /* Still NULL? Well then scan for it! */ 269 /* Still NULL? Well then scan for it! */
304 if(slot->dev == NULL) { 270 if (slot->dev == NULL) {
305 int n; 271 int n;
306 dbg("pci_dev still null"); 272 dbg("pci_dev still null");
307 273
@@ -311,10 +277,10 @@ int cpci_configure_slot(struct slot* slot)
311 */ 277 */
312 n = pci_scan_slot(slot->bus, slot->devfn); 278 n = pci_scan_slot(slot->bus, slot->devfn);
313 dbg("%s: pci_scan_slot returned %d", __FUNCTION__, n); 279 dbg("%s: pci_scan_slot returned %d", __FUNCTION__, n);
314 if(n > 0) 280 if (n > 0)
315 pci_bus_add_devices(slot->bus); 281 pci_bus_add_devices(slot->bus);
316 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 282 slot->dev = pci_get_slot(slot->bus, slot->devfn);
317 if(slot->dev == NULL) { 283 if (slot->dev == NULL) {
318 err("Could not find PCI device for slot %02x", slot->number); 284 err("Could not find PCI device for slot %02x", slot->number);
319 return 1; 285 return 1;
320 } 286 }
@@ -329,8 +295,6 @@ int cpci_configure_slot(struct slot* slot)
329 295
330 pci_bus_assign_resources(slot->dev->bus); 296 pci_bus_assign_resources(slot->dev->bus);
331 297
332 cpci_enable_device(slot->dev);
333
334 dbg("%s - exit", __FUNCTION__); 298 dbg("%s - exit", __FUNCTION__);
335 return 0; 299 return 0;
336} 300}
@@ -341,15 +305,15 @@ int cpci_unconfigure_slot(struct slot* slot)
341 struct pci_dev *dev; 305 struct pci_dev *dev;
342 306
343 dbg("%s - enter", __FUNCTION__); 307 dbg("%s - enter", __FUNCTION__);
344 if(!slot->dev) { 308 if (!slot->dev) {
345 err("No device for slot %02x\n", slot->number); 309 err("No device for slot %02x\n", slot->number);
346 return -ENODEV; 310 return -ENODEV;
347 } 311 }
348 312
349 for (i = 0; i < 8; i++) { 313 for (i = 0; i < 8; i++) {
350 dev = pci_find_slot(slot->bus->number, 314 dev = pci_get_slot(slot->bus,
351 PCI_DEVFN(PCI_SLOT(slot->devfn), i)); 315 PCI_DEVFN(PCI_SLOT(slot->devfn), i));
352 if(dev) { 316 if (dev) {
353 pci_remove_bus_device(dev); 317 pci_remove_bus_device(dev);
354 slot->dev = NULL; 318 slot->dev = NULL;
355 } 319 }
diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/shpchprm_acpi.c
index 243a51d88b8..7957cdc72cd 100644
--- a/drivers/pci/hotplug/shpchprm_acpi.c
+++ b/drivers/pci/hotplug/shpchprm_acpi.c
@@ -1626,7 +1626,7 @@ int shpchprm_set_hpp(
1626 pci_bus->number = func->bus; 1626 pci_bus->number = func->bus;
1627 devfn = PCI_DEVFN(func->device, func->function); 1627 devfn = PCI_DEVFN(func->device, func->function);
1628 1628
1629 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); 1629 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus);
1630 1630
1631 if (ab) { 1631 if (ab) {
1632 if (ab->_hpp) { 1632 if (ab->_hpp) {
@@ -1681,7 +1681,7 @@ void shpchprm_enable_card(
1681 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; 1681 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
1682 bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA; 1682 bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA;
1683 1683
1684 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); 1684 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus);
1685 if (ab) { 1685 if (ab) {
1686 if (ab->_hpp) { 1686 if (ab->_hpp) {
1687 if (ab->_hpp->enable_perr) { 1687 if (ab->_hpp->enable_perr) {
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 54c52349adc..3be54643925 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
677static int __init piix_init(void) 668static 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
699static void __exit piix_exit(void) 683static 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 30a88f0e7bd..21d194c6ace 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 */
189void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 211void 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 */
238void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) 272void 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 */
371void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) 422void 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 */
411u8 ata_check_status(struct ata_port *ap) 476u8 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 */
418u8 ata_altstatus(struct ata_port *ap) 497u8 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 */
428u8 ata_chk_err(struct ata_port *ap) 521u8 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 */
876void ata_noop_dev_select (struct ata_port *ap, unsigned int device) 982void 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
1238void ata_port_probe(struct ata_port *ap) 1356void 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 */
1250void __sata_phy_reset(struct ata_port *ap) 1373void __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 */
1298void sata_phy_reset(struct ata_port *ap) 1425void 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
1313void ata_port_disable(struct ata_port *ap) 1446void 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 */
1422static void ata_set_mode(struct ata_port *ap) 1558static 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
1915static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) 2066static 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
1956static void ata_sg_clean(struct ata_queued_cmd *qc) 2110static 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 */
1987static void ata_fill_sg(struct ata_queued_cmd *qc) 2145static 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 */
2060void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) 2252void 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
2077void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 2295void 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
2096static int ata_sg_setup_one(struct ata_queued_cmd *qc) 2316static 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
2203static void ata_pio_complete (struct ata_port *ap) 2428static 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 */
2243void swap_buf_le16(u16 *buf, unsigned int buf_words) 2480void 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
2420static void ata_pio_block(struct ata_port *ap) 2658static 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
2588static void ata_qc_timeout(struct ata_queued_cmd *qc) 2827static 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
2697static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) 2937static 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
2722struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 2963struct 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 */
2786void ata_qc_free(struct ata_queued_cmd *qc) 3028void 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 */
3068void ata_bmdma_start(struct ata_queued_cmd *qc) 3329void 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 */
3076void ata_bmdma_setup(struct ata_queued_cmd *qc) 3351void 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
3084void ata_bmdma_irq_clear(struct ata_port *ap) 3372void 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
3096u8 ata_bmdma_status(struct ata_port *ap) 3397u8 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
3107void ata_bmdma_stop(struct ata_port *ap) 3421void 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
3305int ata_port_start (struct ata_port *ap) 3637int 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
3318void ata_port_stop (struct ata_port *ap) 3662void 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
3608void ata_std_ports(struct ata_ioports *ioaddr) 3978void 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
3650struct ata_probe_ent * 4034struct ata_probe_ent *
3651ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) 4035ata_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
3961static int __init ata_init(void) 4345static 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 416ba67ba9e..7a4adc4c8f0 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 579448222d6..3c97aa45772 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 cca772624ae..8d0d302844a 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 5d2ceb623e6..1f985327b0d 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
240static unsigned int siu_tx_empty(struct uart_port *port) 240static 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
805static 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
848static 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
854static void wait_for_xmitr(struct uart_port *port) 804static 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 4ab50009291..4d0c9e65cd0 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}
320static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 318static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
321 319
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3196c3265ff..19e598c9641 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -124,3 +124,14 @@ config USB_SL811_HCD
124 To compile this driver as a module, choose M here: the 124 To compile this driver as a module, choose M here: the
125 module will be called sl811-hcd. 125 module will be called sl811-hcd.
126 126
127config USB_SL811_CS
128 tristate "CF/PCMCIA support for SL811HS HCD"
129 depends on USB_SL811_HCD && PCMCIA
130 default N
131 help
132 Wraps a PCMCIA driver around the SL811HS HCD, supporting the RATOC
133 REX-CFU1U CF card (often used with PDAs). If unsure, say N.
134
135 To compile this driver as a module, choose M here: the
136 module will be called "sl811_cs".
137
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index a574ca06cf6..5dbd3e7a27c 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -7,4 +7,5 @@ obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
7obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o 7obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
8obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o 8obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
9obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o 9obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o
10obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
10obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o 11obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index a374b769207..99d43f758ad 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -2,8 +2,8 @@
2 * SL811HS HCD (Host Controller Driver) for USB. 2 * SL811HS HCD (Host Controller Driver) for USB.
3 * 3 *
4 * Copyright (C) 2004 Psion Teklogix (for NetBook PRO) 4 * Copyright (C) 2004 Psion Teklogix (for NetBook PRO)
5 * Copyright (C) 2004 David Brownell 5 * Copyright (C) 2004-2005 David Brownell
6 * 6 *
7 * Periodic scheduling is based on Roman's OHCI code 7 * Periodic scheduling is based on Roman's OHCI code
8 * Copyright (C) 1999 Roman Weissgaerber 8 * Copyright (C) 1999 Roman Weissgaerber
9 * 9 *
@@ -15,7 +15,7 @@
15 * For documentation, see the SL811HS spec and the "SL811HS Embedded Host" 15 * For documentation, see the SL811HS spec and the "SL811HS Embedded Host"
16 * document (providing significant pieces missing from that spec); plus 16 * document (providing significant pieces missing from that spec); plus
17 * the SL811S spec if you want peripheral side info. 17 * the SL811S spec if you want peripheral side info.
18 */ 18 */
19 19
20/* 20/*
21 * Status: Passed basic stress testing, works with hubs, mice, keyboards, 21 * Status: Passed basic stress testing, works with hubs, mice, keyboards,
@@ -67,7 +67,7 @@
67MODULE_DESCRIPTION("SL811HS USB Host Controller Driver"); 67MODULE_DESCRIPTION("SL811HS USB Host Controller Driver");
68MODULE_LICENSE("GPL"); 68MODULE_LICENSE("GPL");
69 69
70#define DRIVER_VERSION "15 Dec 2004" 70#define DRIVER_VERSION "19 May 2005"
71 71
72 72
73#ifndef DEBUG 73#ifndef DEBUG
@@ -121,6 +121,10 @@ static void port_power(struct sl811 *sl811, int is_on)
121 /* reset as thoroughly as we can */ 121 /* reset as thoroughly as we can */
122 if (sl811->board && sl811->board->reset) 122 if (sl811->board && sl811->board->reset)
123 sl811->board->reset(hcd->self.controller); 123 sl811->board->reset(hcd->self.controller);
124 else {
125 sl811_write(sl811, SL11H_CTLREG1, SL11H_CTL1MASK_SE0);
126 mdelay(20);
127 }
124 128
125 sl811_write(sl811, SL11H_IRQ_ENABLE, 0); 129 sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
126 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1); 130 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
@@ -443,6 +447,7 @@ static void finish_request(
443 spin_lock(&urb->lock); 447 spin_lock(&urb->lock);
444 if (urb->status == -EINPROGRESS) 448 if (urb->status == -EINPROGRESS)
445 urb->status = status; 449 urb->status = status;
450 urb->hcpriv = NULL;
446 spin_unlock(&urb->lock); 451 spin_unlock(&urb->lock);
447 452
448 spin_unlock(&sl811->lock); 453 spin_unlock(&sl811->lock);
@@ -472,7 +477,7 @@ static void finish_request(
472 if (*prev) 477 if (*prev)
473 *prev = ep->next; 478 *prev = ep->next;
474 sl811->load[i] -= ep->load; 479 sl811->load[i] -= ep->load;
475 } 480 }
476 ep->branch = PERIODIC_SIZE; 481 ep->branch = PERIODIC_SIZE;
477 sl811->periodic_count--; 482 sl811->periodic_count--;
478 sl811_to_hcd(sl811)->self.bandwidth_allocated 483 sl811_to_hcd(sl811)->self.bandwidth_allocated
@@ -661,9 +666,9 @@ retry:
661 666
662#ifdef QUIRK2 667#ifdef QUIRK2
663 /* this may no longer be necessary ... */ 668 /* this may no longer be necessary ... */
664 if (irqstat == 0 && ret == IRQ_NONE) { 669 if (irqstat == 0) {
665 irqstat = checkdone(sl811); 670 irqstat = checkdone(sl811);
666 if (irqstat /* && irq != ~0 */ ) 671 if (irqstat)
667 sl811->stat_lost++; 672 sl811->stat_lost++;
668 } 673 }
669#endif 674#endif
@@ -722,7 +727,8 @@ retry:
722 if (sl811->active_a) { 727 if (sl811->active_a) {
723 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0); 728 sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
724 finish_request(sl811, sl811->active_a, 729 finish_request(sl811, sl811->active_a,
725 container_of(sl811->active_a->hep->urb_list.next, 730 container_of(sl811->active_a
731 ->hep->urb_list.next,
726 struct urb, urb_list), 732 struct urb, urb_list),
727 NULL, -ESHUTDOWN); 733 NULL, -ESHUTDOWN);
728 sl811->active_a = NULL; 734 sl811->active_a = NULL;
@@ -731,7 +737,8 @@ retry:
731 if (sl811->active_b) { 737 if (sl811->active_b) {
732 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0); 738 sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
733 finish_request(sl811, sl811->active_b, 739 finish_request(sl811, sl811->active_b,
734 container_of(sl811->active_b->hep->urb_list.next, 740 container_of(sl811->active_b
741 ->hep->urb_list.next,
735 struct urb, urb_list), 742 struct urb, urb_list),
736 NULL, -ESHUTDOWN); 743 NULL, -ESHUTDOWN);
737 sl811->active_b = NULL; 744 sl811->active_b = NULL;
@@ -761,7 +768,7 @@ retry:
761 goto retry; 768 goto retry;
762 } 769 }
763 770
764 if (sl811->periodic_count == 0 && list_empty(&sl811->async)) 771 if (sl811->periodic_count == 0 && list_empty(&sl811->async))
765 sofirq_off(sl811); 772 sofirq_off(sl811);
766 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable); 773 sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
767 774
@@ -796,7 +803,7 @@ static int balance(struct sl811 *sl811, u16 period, u16 load)
796 } 803 }
797 if (j < PERIODIC_SIZE) 804 if (j < PERIODIC_SIZE)
798 continue; 805 continue;
799 branch = i; 806 branch = i;
800 } 807 }
801 } 808 }
802 return branch; 809 return branch;
@@ -890,6 +897,7 @@ static int sl811h_urb_enqueue(
890 break; 897 break;
891 } 898 }
892 899
900 ep->hep = hep;
893 hep->hcpriv = ep; 901 hep->hcpriv = ep;
894 } 902 }
895 903
@@ -961,15 +969,16 @@ fail:
961static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) 969static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
962{ 970{
963 struct sl811 *sl811 = hcd_to_sl811(hcd); 971 struct sl811 *sl811 = hcd_to_sl811(hcd);
964 struct usb_host_endpoint *hep = urb->hcpriv; 972 struct usb_host_endpoint *hep;
965 unsigned long flags; 973 unsigned long flags;
966 struct sl811h_ep *ep; 974 struct sl811h_ep *ep;
967 int retval = 0; 975 int retval = 0;
968 976
977 spin_lock_irqsave(&sl811->lock, flags);
978 hep = urb->hcpriv;
969 if (!hep) 979 if (!hep)
970 return -EINVAL; 980 goto fail;
971 981
972 spin_lock_irqsave(&sl811->lock, flags);
973 ep = hep->hcpriv; 982 ep = hep->hcpriv;
974 if (ep) { 983 if (ep) {
975 /* finish right away if this urb can't be active ... 984 /* finish right away if this urb can't be active ...
@@ -1017,6 +1026,7 @@ static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
1017 VDBG("dequeue, urb %p active %s; wait4irq\n", urb, 1026 VDBG("dequeue, urb %p active %s; wait4irq\n", urb,
1018 (sl811->active_a == ep) ? "A" : "B"); 1027 (sl811->active_a == ep) ? "A" : "B");
1019 } else 1028 } else
1029fail:
1020 retval = -EINVAL; 1030 retval = -EINVAL;
1021 spin_unlock_irqrestore(&sl811->lock, flags); 1031 spin_unlock_irqrestore(&sl811->lock, flags);
1022 return retval; 1032 return retval;
@@ -1576,6 +1586,9 @@ sl811h_start(struct usb_hcd *hcd)
1576 if (sl811->board && sl811->board->power) 1586 if (sl811->board && sl811->board->power)
1577 hub_set_power_budget(udev, sl811->board->power * 2); 1587 hub_set_power_budget(udev, sl811->board->power * 2);
1578 1588
1589 /* enable power and interupts */
1590 port_power(sl811, 1);
1591
1579 return 0; 1592 return 0;
1580} 1593}
1581 1594
@@ -1618,7 +1631,7 @@ static struct hc_driver sl811h_hc_driver = {
1618 1631
1619/*-------------------------------------------------------------------------*/ 1632/*-------------------------------------------------------------------------*/
1620 1633
1621static int __init_or_module 1634static int __devexit
1622sl811h_remove(struct device *dev) 1635sl811h_remove(struct device *dev)
1623{ 1636{
1624 struct usb_hcd *hcd = dev_get_drvdata(dev); 1637 struct usb_hcd *hcd = dev_get_drvdata(dev);
@@ -1631,21 +1644,20 @@ sl811h_remove(struct device *dev)
1631 remove_debug_file(sl811); 1644 remove_debug_file(sl811);
1632 usb_remove_hcd(hcd); 1645 usb_remove_hcd(hcd);
1633 1646
1634 iounmap(sl811->data_reg); 1647 /* some platforms may use IORESOURCE_IO */
1635 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1648 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1636 release_mem_region(res->start, 1); 1649 if (res)
1650 iounmap(sl811->data_reg);
1637 1651
1638 iounmap(sl811->addr_reg);
1639 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1652 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1640 release_mem_region(res->start, 1); 1653 if (res)
1654 iounmap(sl811->addr_reg);
1641 1655
1642 usb_put_hcd(hcd); 1656 usb_put_hcd(hcd);
1643 return 0; 1657 return 0;
1644} 1658}
1645 1659
1646#define resource_len(r) (((r)->end - (r)->start) + 1) 1660static int __devinit
1647
1648static int __init
1649sl811h_probe(struct device *dev) 1661sl811h_probe(struct device *dev)
1650{ 1662{
1651 struct usb_hcd *hcd; 1663 struct usb_hcd *hcd;
@@ -1656,7 +1668,7 @@ sl811h_probe(struct device *dev)
1656 void __iomem *addr_reg; 1668 void __iomem *addr_reg;
1657 void __iomem *data_reg; 1669 void __iomem *data_reg;
1658 int retval; 1670 int retval;
1659 u8 tmp; 1671 u8 tmp, ioaddr = 0;
1660 1672
1661 /* basic sanity checks first. board-specific init logic should 1673 /* basic sanity checks first. board-specific init logic should
1662 * have initialized these three resources and probably board 1674 * have initialized these three resources and probably board
@@ -1664,13 +1676,8 @@ sl811h_probe(struct device *dev)
1664 * minimal sanity checking. 1676 * minimal sanity checking.
1665 */ 1677 */
1666 pdev = container_of(dev, struct platform_device, dev); 1678 pdev = container_of(dev, struct platform_device, dev);
1667 if (pdev->num_resources < 3)
1668 return -ENODEV;
1669
1670 addr = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1671 data = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1672 irq = platform_get_irq(pdev, 0); 1679 irq = platform_get_irq(pdev, 0);
1673 if (!addr || !data || irq < 0) 1680 if (pdev->num_resources < 3 || irq < 0)
1674 return -ENODEV; 1681 return -ENODEV;
1675 1682
1676 /* refuse to confuse usbcore */ 1683 /* refuse to confuse usbcore */
@@ -1679,24 +1686,31 @@ sl811h_probe(struct device *dev)
1679 return -EINVAL; 1686 return -EINVAL;
1680 } 1687 }
1681 1688
1682 if (!request_mem_region(addr->start, 1, hcd_name)) { 1689 /* the chip may be wired for either kind of addressing */
1683 retval = -EBUSY; 1690 addr = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1684 goto err1; 1691 data = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1685 } 1692 retval = -EBUSY;
1686 addr_reg = ioremap(addr->start, resource_len(addr)); 1693 if (!addr || !data) {
1687 if (addr_reg == NULL) { 1694 addr = platform_get_resource(pdev, IORESOURCE_IO, 0);
1688 retval = -ENOMEM; 1695 data = platform_get_resource(pdev, IORESOURCE_IO, 1);
1689 goto err2; 1696 if (!addr || !data)
1690 } 1697 return -ENODEV;
1698 ioaddr = 1;
1699
1700 addr_reg = (void __iomem *) addr->start;
1701 data_reg = (void __iomem *) data->start;
1702 } else {
1703 addr_reg = ioremap(addr->start, 1);
1704 if (addr_reg == NULL) {
1705 retval = -ENOMEM;
1706 goto err2;
1707 }
1691 1708
1692 if (!request_mem_region(data->start, 1, hcd_name)) { 1709 data_reg = ioremap(data->start, 1);
1693 retval = -EBUSY; 1710 if (data_reg == NULL) {
1694 goto err3; 1711 retval = -ENOMEM;
1695 } 1712 goto err4;
1696 data_reg = ioremap(data->start, resource_len(addr)); 1713 }
1697 if (data_reg == NULL) {
1698 retval = -ENOMEM;
1699 goto err4;
1700 } 1714 }
1701 1715
1702 /* allocate and initialize hcd */ 1716 /* allocate and initialize hcd */
@@ -1737,12 +1751,14 @@ sl811h_probe(struct device *dev)
1737 goto err6; 1751 goto err6;
1738 } 1752 }
1739 1753
1740 /* sl811s would need a different handler for this irq */ 1754 /* The chip's IRQ is level triggered, active high. A requirement
1741#ifdef CONFIG_ARM 1755 * for platform device setup is to cope with things like signal
1742 /* Cypress docs say the IRQ is IRQT_HIGH ... */ 1756 * inverters (e.g. CF is active low) or working only with edge
1743 set_irq_type(irq, IRQT_RISING); 1757 * triggers (e.g. most ARM CPUs). Initial driver stress testing
1744#endif 1758 * was on a system with single edge triggering, so most sorts of
1745 retval = usb_add_hcd(hcd, irq, SA_INTERRUPT); 1759 * triggering arrangement should work.
1760 */
1761 retval = usb_add_hcd(hcd, irq, SA_INTERRUPT | SA_SHIRQ);
1746 if (retval != 0) 1762 if (retval != 0)
1747 goto err6; 1763 goto err6;
1748 1764
@@ -1752,14 +1768,12 @@ sl811h_probe(struct device *dev)
1752 err6: 1768 err6:
1753 usb_put_hcd(hcd); 1769 usb_put_hcd(hcd);
1754 err5: 1770 err5:
1755 iounmap(data_reg); 1771 if (!ioaddr)
1772 iounmap(data_reg);
1756 err4: 1773 err4:
1757 release_mem_region(data->start, 1); 1774 if (!ioaddr)
1758 err3: 1775 iounmap(addr_reg);
1759 iounmap(addr_reg);
1760 err2: 1776 err2:
1761 release_mem_region(addr->start, 1);
1762 err1:
1763 DBG("init error, %d\n", retval); 1777 DBG("init error, %d\n", retval);
1764 return retval; 1778 return retval;
1765} 1779}
@@ -1767,7 +1781,7 @@ sl811h_probe(struct device *dev)
1767#ifdef CONFIG_PM 1781#ifdef CONFIG_PM
1768 1782
1769/* for this device there's no useful distinction between the controller 1783/* for this device there's no useful distinction between the controller
1770 * and its root hub, except that the root hub only gets direct PM calls 1784 * and its root hub, except that the root hub only gets direct PM calls
1771 * when CONFIG_USB_SUSPEND is enabled. 1785 * when CONFIG_USB_SUSPEND is enabled.
1772 */ 1786 */
1773 1787
@@ -1821,20 +1835,22 @@ sl811h_resume(struct device *dev, u32 phase)
1821#endif 1835#endif
1822 1836
1823 1837
1824static struct device_driver sl811h_driver = { 1838/* this driver is exported so sl811_cs can depend on it */
1839struct device_driver sl811h_driver = {
1825 .name = (char *) hcd_name, 1840 .name = (char *) hcd_name,
1826 .bus = &platform_bus_type, 1841 .bus = &platform_bus_type,
1827 1842
1828 .probe = sl811h_probe, 1843 .probe = sl811h_probe,
1829 .remove = sl811h_remove, 1844 .remove = __devexit_p(sl811h_remove),
1830 1845
1831 .suspend = sl811h_suspend, 1846 .suspend = sl811h_suspend,
1832 .resume = sl811h_resume, 1847 .resume = sl811h_resume,
1833}; 1848};
1849EXPORT_SYMBOL(sl811h_driver);
1834 1850
1835/*-------------------------------------------------------------------------*/ 1851/*-------------------------------------------------------------------------*/
1836 1852
1837static int __init sl811h_init(void) 1853static int __init sl811h_init(void)
1838{ 1854{
1839 if (usb_disabled()) 1855 if (usb_disabled())
1840 return -ENODEV; 1856 return -ENODEV;
@@ -1844,8 +1860,8 @@ static int __init sl811h_init(void)
1844} 1860}
1845module_init(sl811h_init); 1861module_init(sl811h_init);
1846 1862
1847static void __exit sl811h_cleanup(void) 1863static void __exit sl811h_cleanup(void)
1848{ 1864{
1849 driver_unregister(&sl811h_driver); 1865 driver_unregister(&sl811h_driver);
1850} 1866}
1851module_exit(sl811h_cleanup); 1867module_exit(sl811h_cleanup);
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
new file mode 100644
index 00000000000..6e173265095
--- /dev/null
+++ b/drivers/usb/host/sl811_cs.c
@@ -0,0 +1,442 @@
1/*
2 * PCMCIA driver for SL811HS (as found in REX-CFU1U)
3 * Filename: sl811_cs.c
4 * Author: Yukio Yamamoto
5 *
6 * Port to sl811-hcd and 2.6.x by
7 * Botond Botyanszki <boti@rocketmail.com>
8 * Simon Pickering
9 *
10 * Last update: 2005-05-12
11 */
12
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/sched.h>
17#include <linux/ptrace.h>
18#include <linux/slab.h>
19#include <linux/string.h>
20#include <linux/timer.h>
21#include <linux/ioport.h>
22
23#include <pcmcia/version.h>
24#include <pcmcia/cs_types.h>
25#include <pcmcia/cs.h>
26#include <pcmcia/cistpl.h>
27#include <pcmcia/cisreg.h>
28#include <pcmcia/ds.h>
29
30#include <linux/usb_sl811.h>
31
32MODULE_AUTHOR("Botond Botyanszki");
33MODULE_DESCRIPTION("REX-CFU1U PCMCIA driver for 2.6");
34MODULE_LICENSE("GPL");
35
36
37/*====================================================================*/
38/* MACROS */
39/*====================================================================*/
40
41#if defined(DEBUG) || defined(CONFIG_USB_DEBUG) || defined(PCMCIA_DEBUG)
42
43static int pc_debug = 0;
44module_param(pc_debug, int, 0644);
45
46#define DBG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG "sl811_cs: " args)
47
48#else
49#define DBG(n, args...) do{}while(0)
50#endif /* no debugging */
51
52#define INFO(args...) printk(KERN_INFO "sl811_cs: " args)
53
54#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
55
56#define CS_CHECK(fn, ret) \
57 do { \
58 last_fn = (fn); \
59 if ((last_ret = (ret)) != 0) \
60 goto cs_failed; \
61 } while (0)
62
63/*====================================================================*/
64/* VARIABLES */
65/*====================================================================*/
66
67static const char driver_name[DEV_NAME_LEN] = "sl811_cs";
68
69static dev_link_t *dev_list = NULL;
70
71static int irq_list[4] = { -1 };
72static int irq_list_count;
73
74module_param_array(irq_list, int, &irq_list_count, 0444);
75
76INT_MODULE_PARM(irq_mask, 0xdeb8);
77
78typedef struct local_info_t {
79 dev_link_t link;
80 dev_node_t node;
81} local_info_t;
82
83/*====================================================================*/
84
85static void release_platform_dev(struct device * dev)
86{
87 DBG(0, "sl811_cs platform_dev release\n");
88 dev->parent = NULL;
89}
90
91static struct sl811_platform_data platform_data = {
92 .potpg = 100,
93 .power = 50, /* == 100mA */
94 // .reset = ... FIXME: invoke CF reset on the card
95};
96
97static struct resource resources[] = {
98 [0] = {
99 .flags = IORESOURCE_IRQ,
100 },
101 [1] = {
102 // .name = "address",
103 .flags = IORESOURCE_IO,
104 },
105 [2] = {
106 // .name = "data",
107 .flags = IORESOURCE_IO,
108 },
109};
110
111extern struct device_driver sl811h_driver;
112
113static struct platform_device platform_dev = {
114 .id = -1,
115 .dev = {
116 .platform_data = &platform_data,
117 .release = release_platform_dev,
118 },
119 .resource = resources,
120 .num_resources = ARRAY_SIZE(resources),
121};
122
123static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq)
124{
125 if (platform_dev.dev.parent)
126 return -EBUSY;
127 platform_dev.dev.parent = parent;
128
129 /* finish seting up the platform device */
130 resources[0].start = irq;
131
132 resources[1].start = base_addr;
133 resources[1].end = base_addr;
134
135 resources[2].start = base_addr + 1;
136 resources[2].end = base_addr + 1;
137
138 /* The driver core will probe for us. We know sl811-hcd has been
139 * initialized already because of the link order dependency.
140 */
141 platform_dev.name = sl811h_driver.name;
142 return platform_device_register(&platform_dev);
143}
144
145/*====================================================================*/
146
147static void sl811_cs_detach(dev_link_t *link)
148{
149 dev_link_t **linkp;
150
151 DBG(0, "sl811_cs_detach(0x%p)\n", link);
152
153 /* Locate device structure */
154 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) {
155 if (*linkp == link)
156 break;
157 }
158 if (*linkp == NULL)
159 return;
160
161 /* Break the link with Card Services */
162 if (link->handle)
163 pcmcia_deregister_client(link->handle);
164
165 /* Unlink device structure, and free it */
166 *linkp = link->next;
167 /* This points to the parent local_info_t struct */
168 kfree(link->priv);
169}
170
171static void sl811_cs_release(dev_link_t * link)
172{
173
174 DBG(0, "sl811_cs_release(0x%p)\n", link);
175
176 if (link->open) {
177 DBG(1, "sl811_cs: release postponed, '%s' still open\n",
178 link->dev->dev_name);
179 link->state |= DEV_STALE_CONFIG;
180 return;
181 }
182
183 /* Unlink the device chain */
184 link->dev = NULL;
185
186 platform_device_unregister(&platform_dev);
187 pcmcia_release_configuration(link->handle);
188 if (link->io.NumPorts1)
189 pcmcia_release_io(link->handle, &link->io);
190 if (link->irq.AssignedIRQ)
191 pcmcia_release_irq(link->handle, &link->irq);
192 link->state &= ~DEV_CONFIG;
193
194 if (link->state & DEV_STALE_LINK)
195 sl811_cs_detach(link);
196}
197
198static void sl811_cs_config(dev_link_t *link)
199{
200 client_handle_t handle = link->handle;
201 struct device *parent = &handle_to_dev(handle);
202 local_info_t *dev = link->priv;
203 tuple_t tuple;
204 cisparse_t parse;
205 int last_fn, last_ret;
206 u_char buf[64];
207 config_info_t conf;
208 cistpl_cftable_entry_t dflt = { 0 };
209
210 DBG(0, "sl811_cs_config(0x%p)\n", link);
211
212 tuple.DesiredTuple = CISTPL_CONFIG;
213 tuple.Attributes = 0;
214 tuple.TupleData = buf;
215 tuple.TupleDataMax = sizeof(buf);
216 tuple.TupleOffset = 0;
217 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
218 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
219 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
220 link->conf.ConfigBase = parse.config.base;
221 link->conf.Present = parse.config.rmask[0];
222
223 /* Configure card */
224 link->state |= DEV_CONFIG;
225
226 /* Look up the current Vcc */
227 CS_CHECK(GetConfigurationInfo,
228 pcmcia_get_configuration_info(handle, &conf));
229 link->conf.Vcc = conf.Vcc;
230
231 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
232 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
233 while (1) {
234 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
235
236 if (pcmcia_get_tuple_data(handle, &tuple) != 0
237 || pcmcia_parse_tuple(handle, &tuple, &parse)
238 != 0)
239 goto next_entry;
240
241 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) {
242 dflt = *cfg;
243 }
244
245 if (cfg->index == 0)
246 goto next_entry;
247
248 link->conf.ConfigIndex = cfg->index;
249
250 /* Use power settings for Vcc and Vpp if present */
251 /* Note that the CIS values need to be rescaled */
252 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
253 if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000
254 != conf.Vcc)
255 goto next_entry;
256 } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) {
257 if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000
258 != conf.Vcc)
259 goto next_entry;
260 }
261
262 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
263 link->conf.Vpp1 = link->conf.Vpp2 =
264 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
265 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
266 link->conf.Vpp1 = link->conf.Vpp2 =
267 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
268
269 /* we need an interrupt */
270 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
271 link->conf.Attributes |= CONF_ENABLE_IRQ;
272
273 /* IO window settings */
274 link->io.NumPorts1 = link->io.NumPorts2 = 0;
275 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
276 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
277
278 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
279 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
280 link->io.BasePort1 = io->win[0].base;
281 link->io.NumPorts1 = io->win[0].len;
282
283 if (pcmcia_request_io(link->handle, &link->io) != 0)
284 goto next_entry;
285 }
286 break;
287
288next_entry:
289 if (link->io.NumPorts1)
290 pcmcia_release_io(link->handle, &link->io);
291 last_ret = pcmcia_get_next_tuple(handle, &tuple);
292 }
293
294 /* require an IRQ and two registers */
295 if (!link->io.NumPorts1 || link->io.NumPorts1 < 2)
296 goto cs_failed;
297 if (link->conf.Attributes & CONF_ENABLE_IRQ)
298 CS_CHECK(RequestIRQ,
299 pcmcia_request_irq(link->handle, &link->irq));
300 else
301 goto cs_failed;
302
303 CS_CHECK(RequestConfiguration,
304 pcmcia_request_configuration(link->handle, &link->conf));
305
306 sprintf(dev->node.dev_name, driver_name);
307 dev->node.major = dev->node.minor = 0;
308 link->dev = &dev->node;
309
310 printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
311 dev->node.dev_name, link->conf.ConfigIndex,
312 link->conf.Vcc/10, link->conf.Vcc%10);
313 if (link->conf.Vpp1)
314 printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10);
315 printk(", irq %d", link->irq.AssignedIRQ);
316 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
317 link->io.BasePort1+link->io.NumPorts1-1);
318 printk("\n");
319
320 link->state &= ~DEV_CONFIG_PENDING;
321
322 if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ)
323 < 0) {
324cs_failed:
325 printk("sl811_cs_config failed\n");
326 cs_error(link->handle, last_fn, last_ret);
327 sl811_cs_release(link);
328 link->state &= ~DEV_CONFIG_PENDING;
329 }
330}
331
332static int
333sl811_cs_event(event_t event, int priority, event_callback_args_t *args)
334{
335 dev_link_t *link = args->client_data;
336
337 DBG(1, "sl811_cs_event(0x%06x)\n", event);
338
339 switch (event) {
340 case CS_EVENT_CARD_REMOVAL:
341 link->state &= ~DEV_PRESENT;
342 if (link->state & DEV_CONFIG)
343 sl811_cs_release(link);
344 break;
345
346 case CS_EVENT_CARD_INSERTION:
347 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
348 sl811_cs_config(link);
349 break;
350
351 case CS_EVENT_PM_SUSPEND:
352 link->state |= DEV_SUSPEND;
353 /* Fall through... */
354 case CS_EVENT_RESET_PHYSICAL:
355 if (link->state & DEV_CONFIG)
356 pcmcia_release_configuration(link->handle);
357 break;
358
359 case CS_EVENT_PM_RESUME:
360 link->state &= ~DEV_SUSPEND;
361 /* Fall through... */
362 case CS_EVENT_CARD_RESET:
363 if (link->state & DEV_CONFIG)
364 pcmcia_request_configuration(link->handle, &link->conf);
365 DBG(0, "reset sl811-hcd here?\n");
366 break;
367 }
368 return 0;
369}
370
371static dev_link_t *sl811_cs_attach(void)
372{
373 local_info_t *local;
374 dev_link_t *link;
375 client_reg_t client_reg;
376 int ret, i;
377
378 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
379 if (!local)
380 return NULL;
381 memset(local, 0, sizeof(local_info_t));
382 link = &local->link;
383 link->priv = local;
384
385 /* Initialize */
386 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
387 link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID;
388 if (irq_list[0] == -1)
389 link->irq.IRQInfo2 = irq_mask;
390 else
391 for (i = 0; i < irq_list_count; i++)
392 link->irq.IRQInfo2 |= 1 << irq_list[i];
393 link->irq.Handler = NULL;
394
395 link->conf.Attributes = 0;
396 link->conf.Vcc = 33;
397 link->conf.IntType = INT_MEMORY_AND_IO;
398
399 /* Register with Card Services */
400 link->next = dev_list;
401 dev_list = link;
402 client_reg.dev_info = (dev_info_t *) &driver_name;
403 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
404 client_reg.EventMask =
405 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
406 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
407 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
408 client_reg.event_handler = &sl811_cs_event;
409 client_reg.Version = 0x0210;
410 client_reg.event_callback_args.client_data = link;
411 ret = pcmcia_register_client(&link->handle, &client_reg);
412 if (ret != CS_SUCCESS) {
413 cs_error(link->handle, RegisterClient, ret);
414 sl811_cs_detach(link);
415 return NULL;
416 }
417
418 return link;
419}
420
421static struct pcmcia_driver sl811_cs_driver = {
422 .owner = THIS_MODULE,
423 .drv = {
424 .name = (char *)driver_name,
425 },
426 .attach = sl811_cs_attach,
427 .detach = sl811_cs_detach,
428};
429
430/*====================================================================*/
431
432static int __init init_sl811_cs(void)
433{
434 return pcmcia_register_driver(&sl811_cs_driver);
435}
436module_init(init_sl811_cs);
437
438static void __exit exit_sl811_cs(void)
439{
440 pcmcia_unregister_driver(&sl811_cs_driver);
441}
442module_exit(exit_sl811_cs);
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 43215a98181..96959ec590a 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1318,6 +1318,8 @@ void hid_init_reports(struct hid_device *hid)
1318#define USB_DEVICE_ID_WACOM_INTUOS2 0x0040 1318#define USB_DEVICE_ID_WACOM_INTUOS2 0x0040
1319#define USB_DEVICE_ID_WACOM_VOLITO 0x0060 1319#define USB_DEVICE_ID_WACOM_VOLITO 0x0060
1320#define USB_DEVICE_ID_WACOM_PTU 0x0003 1320#define USB_DEVICE_ID_WACOM_PTU 0x0003
1321#define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0
1322#define USB_DEVICE_ID_WACOM_CINTIQ 0x003F
1321 1323
1322#define USB_VENDOR_ID_KBGEAR 0x084e 1324#define USB_VENDOR_ID_KBGEAR 0x084e
1323#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 1325#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
@@ -1404,6 +1406,7 @@ void hid_init_reports(struct hid_device *hid)
1404 1406
1405#define USB_VENDOR_ID_DELORME 0x1163 1407#define USB_VENDOR_ID_DELORME 0x1163
1406#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 1408#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100
1409#define USB_DEVICE_ID_DELORME_EM_LT20 0x0200
1407 1410
1408#define USB_VENDOR_ID_MCC 0x09db 1411#define USB_VENDOR_ID_MCC 0x09db
1409#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 1412#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076
@@ -1415,6 +1418,12 @@ void hid_init_reports(struct hid_device *hid)
1415#define USB_VENDOR_ID_BTC 0x046e 1418#define USB_VENDOR_ID_BTC 0x046e
1416#define USB_DEVICE_ID_BTC_KEYBOARD 0x5303 1419#define USB_DEVICE_ID_BTC_KEYBOARD 0x5303
1417 1420
1421#define USB_VENDOR_ID_VERNIER 0x08f7
1422#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
1423#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
1424#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
1425#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
1426
1418 1427
1419/* 1428/*
1420 * Alphabetically sorted blacklist by quirk type. 1429 * Alphabetically sorted blacklist by quirk type.
@@ -1440,6 +1449,7 @@ static struct hid_blacklist {
1440 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, 1449 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE },
1441 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, 1450 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE },
1442 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, 1451 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE },
1452 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE },
1443 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, 1453 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE },
1444 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, 1454 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE },
1445 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, 1455 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE },
@@ -1459,6 +1469,10 @@ static struct hid_blacklist {
1459 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE }, 1469 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE },
1460 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, 1470 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE },
1461 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE }, 1471 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE },
1472 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO, HID_QUIRK_IGNORE },
1473 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE },
1474 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE },
1475 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE },
1462 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PENPARTNER, HID_QUIRK_IGNORE }, 1476 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PENPARTNER, HID_QUIRK_IGNORE },
1463 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE, HID_QUIRK_IGNORE }, 1477 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE, HID_QUIRK_IGNORE },
1464 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 1, HID_QUIRK_IGNORE }, 1478 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 1, HID_QUIRK_IGNORE },
@@ -1484,6 +1498,10 @@ static struct hid_blacklist {
1484 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, 1498 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE },
1485 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, 1499 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE },
1486 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, 1500 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE },
1501 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3, HID_QUIRK_IGNORE },
1502 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 1, HID_QUIRK_IGNORE },
1503 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 2, HID_QUIRK_IGNORE },
1504 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_CINTIQ, HID_QUIRK_IGNORE },
1487 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1505 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
1488 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1506 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
1489 1507
diff --git a/drivers/usb/media/pwc/ChangeLog b/drivers/usb/media/pwc/ChangeLog
deleted file mode 100644
index b2eb71a9afb..00000000000
--- a/drivers/usb/media/pwc/ChangeLog
+++ /dev/null
@@ -1,143 +0,0 @@
19.0.2
2
3* Adding #ifdef to compile PWC before and after 2.6.5
4
59.0.1
6
79.0
8
9
108.12
11
12* Implement motorized pan/tilt feature for Logitech QuickCam Orbit/Spere.
13
148.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
198.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
278.10.1
28
29* Added IDs for PCVC720K/40 and Creative Labs Webcam Pro
30
318.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
378.9
38
39* Merging with kernel 2.5.49
40* Adding IDs for QuickCam Zoom & QuickCam Notebook
41
428.8
43
44* Fixing 'leds' parameter
45* Adding IDs for Logitech QuickCam Pro 4000
46* Making URB init/cleanup a little nicer
47
488.7
49
50* Incorporating changes in ioctl() parameter passing
51* Also changes to URB mechanism
52
538.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
658.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
738.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
798.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
878.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
978.1
98
99* Adding support for 750
100* Adding V4L GAUDIO/SAUDIO/UNIT ioctl() calls
101
1028.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
1097.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
1186.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
1256.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
1346.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 85476e76b24..4cbb408af72 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 bc798edf035..9438909e87a 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
458config 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
458config USB_SERIAL_OMNINET 469config 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 d56ff6d86cc..6c7cdcc99a9 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
32obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o 32obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
33obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 33obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
34obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 34obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
35obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
35obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 36obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
36obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 37obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
37obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o 38obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 7e9bb63eb46..4ace9964fc6 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*);
35static void cp2101_close(struct usb_serial_port*, struct file*); 43static void cp2101_close(struct usb_serial_port*, struct file*);
36static void cp2101_get_termios(struct usb_serial_port*); 44static void cp2101_get_termios(struct usb_serial_port*);
37static void cp2101_set_termios(struct usb_serial_port*, struct termios*); 45static void cp2101_set_termios(struct usb_serial_port*, struct termios*);
46static int cp2101_tiocmget (struct usb_serial_port *, struct file *);
47static int cp2101_tiocmset (struct usb_serial_port *, struct file *,
48 unsigned int, unsigned int);
38static void cp2101_break_ctl(struct usb_serial_port*, int); 49static void cp2101_break_ctl(struct usb_serial_port*, int);
39static int cp2101_startup (struct usb_serial *); 50static int cp2101_startup (struct usb_serial *);
40static void cp2101_shutdown(struct usb_serial*); 51static void cp2101_shutdown(struct usb_serial*);
@@ -43,9 +54,10 @@ static void cp2101_shutdown(struct usb_serial*);
43static int debug; 54static int debug;
44 55
45static struct usb_device_id id_table [] = { 56static 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
51MODULE_DEVICE_TABLE (usb, id_table); 63MODULE_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
119static 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 */
152static 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
152static 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 */
200static 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 */
255static 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
173static int cp2101_open (struct usb_serial_port *port, struct file *filp) 261static 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 */
238static void cp2101_get_termios (struct usb_serial_port *port) 331static 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
661static 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
691static 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
524static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) 711static 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
538static int cp2101_startup (struct usb_serial *serial) 725static 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/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 52394f08a94..051c3a77b41 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -364,6 +364,7 @@ static struct usb_device_id id_table_8U232AM [] = {
364 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0, 0x3ff) }, 364 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0, 0x3ff) },
365 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0, 0x3ff) }, 365 { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0, 0x3ff) },
366 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0, 0x3ff) }, 366 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0, 0x3ff) },
367 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0, 0x3ff) },
367 { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0, 0x3ff) }, 368 { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0, 0x3ff) },
368 { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0, 0x3ff) }, 369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0, 0x3ff) },
369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) }, 370 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) },
@@ -475,6 +476,7 @@ static struct usb_device_id id_table_FT232BM [] = {
475 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) }, 476 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
476 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) }, 477 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
477 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0x400, 0xffff) }, 478 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0x400, 0xffff) },
479 { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0x400, 0xffff) },
478 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, 480 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
479 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, 481 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
480 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) }, 482 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) },
@@ -618,6 +620,7 @@ static struct usb_device_id id_table_combined [] = {
618 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) }, 620 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
619 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) }, 621 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
620 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, 622 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
623 { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) },
621 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, 624 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
622 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, 625 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
623 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) }, 626 { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) },
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index a52bb13a9ce..8866376823a 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -144,6 +144,8 @@
144 144
145/* ELV USB Module UO100 (PID sent by Stefan Frings) */ 145/* ELV USB Module UO100 (PID sent by Stefan Frings) */
146#define FTDI_ELV_UO100_PID 0xFB58 /* Product Id */ 146#define FTDI_ELV_UO100_PID 0xFB58 /* Product Id */
147/* ELV USB Module UM100 (PID sent by Arnim Laeuger) */
148#define FTDI_ELV_UM100_PID 0xFB5A /* Product Id */
147 149
148/* 150/*
149 * Definitions for ID TECH (www.idt-net.com) devices 151 * Definitions for ID TECH (www.idt-net.com) devices
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
new file mode 100644
index 00000000000..b722175f108
--- /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 */
37static int option_open (struct usb_serial_port *port, struct file *filp);
38static void option_close (struct usb_serial_port *port, struct file *filp);
39static int option_startup (struct usb_serial *serial);
40static void option_shutdown (struct usb_serial *serial);
41static void option_rx_throttle (struct usb_serial_port *port);
42static void option_rx_unthrottle (struct usb_serial_port *port);
43static int option_write_room (struct usb_serial_port *port);
44
45static void option_instat_callback(struct urb *urb, struct pt_regs *regs);
46
47
48static int option_write (struct usb_serial_port *port,
49 const unsigned char *buf, int count);
50
51static int option_chars_in_buffer (struct usb_serial_port *port);
52static int option_ioctl (struct usb_serial_port *port, struct file *file,
53 unsigned int cmd, unsigned long arg);
54static void option_set_termios (struct usb_serial_port *port,
55 struct termios *old);
56static void option_break_ctl (struct usb_serial_port *port, int break_state);
57static int option_tiocmget (struct usb_serial_port *port, struct file *file);
58static int option_tiocmset (struct usb_serial_port *port, struct file *file,
59 unsigned int set, unsigned int clear);
60static 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
68static 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
74MODULE_DEVICE_TABLE(usb, option_ids);
75
76static 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 */
87static 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
113static 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
122struct 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. */
144static int __init
145option_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
159failed_driver_register:
160 usb_serial_deregister (&option_3port_device);
161failed_3port_device_register:
162 return retval;
163}
164
165static void __exit
166option_exit (void)
167{
168 usb_deregister (&option_driver);
169 usb_serial_deregister (&option_3port_device);
170}
171
172module_init(option_init);
173module_exit(option_exit);
174
175static void
176option_rx_throttle (struct usb_serial_port *port)
177{
178 dbg("%s", __FUNCTION__);
179}
180
181
182static void
183option_rx_unthrottle (struct usb_serial_port *port)
184{
185 dbg("%s", __FUNCTION__);
186}
187
188
189static void
190option_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
197static void
198option_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
206static int
207option_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
224static int
225option_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
244static int
245option_ioctl (struct usb_serial_port *port, struct file *file,
246 unsigned int cmd, unsigned long arg)
247{
248 return -ENOIOCTLCMD;
249}
250
251/* Write */
252static int
253option_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
333static void
334option_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
373static void
374option_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
386static void
387option_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
437static int
438option_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
457static int
458option_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
477static int
478option_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
530static inline void
531stop_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
539static void
540option_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 */
566static struct urb *
567option_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 */
591static void
592option_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
619static int
620option_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
644static int
645option_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
677static void
678option_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
722MODULE_AUTHOR(DRIVER_AUTHOR);
723MODULE_DESCRIPTION(DRIVER_DESC);
724MODULE_VERSION(DRIVER_VERSION);
725MODULE_LICENSE("GPL");
726
727module_param(debug, bool, S_IRUGO | S_IWUSR);
728MODULE_PARM_DESC(debug, "Debug messages");
729
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 4536f63faae..5da76dd8fb2 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1297,13 +1297,6 @@ static int __init usb_serial_init(void)
1297 goto exit_bus; 1297 goto exit_bus;
1298 } 1298 }
1299 1299
1300 /* register the generic driver, if we should */
1301 result = usb_serial_generic_register(debug);
1302 if (result < 0) {
1303 err("%s - registering generic driver failed", __FUNCTION__);
1304 goto exit_generic;
1305 }
1306
1307 usb_serial_tty_driver->owner = THIS_MODULE; 1300 usb_serial_tty_driver->owner = THIS_MODULE;
1308 usb_serial_tty_driver->driver_name = "usbserial"; 1301 usb_serial_tty_driver->driver_name = "usbserial";
1309 usb_serial_tty_driver->devfs_name = "usb/tts/"; 1302 usb_serial_tty_driver->devfs_name = "usb/tts/";
@@ -1329,17 +1322,24 @@ static int __init usb_serial_init(void)
1329 goto exit_tty; 1322 goto exit_tty;
1330 } 1323 }
1331 1324
1325 /* register the generic driver, if we should */
1326 result = usb_serial_generic_register(debug);
1327 if (result < 0) {
1328 err("%s - registering generic driver failed", __FUNCTION__);
1329 goto exit_generic;
1330 }
1331
1332 info(DRIVER_DESC " " DRIVER_VERSION); 1332 info(DRIVER_DESC " " DRIVER_VERSION);
1333 1333
1334 return result; 1334 return result;
1335 1335
1336exit_generic:
1337 usb_deregister(&usb_serial_driver);
1338
1336exit_tty: 1339exit_tty:
1337 tty_unregister_driver(usb_serial_tty_driver); 1340 tty_unregister_driver(usb_serial_tty_driver);
1338 1341
1339exit_reg_driver: 1342exit_reg_driver:
1340 usb_serial_generic_deregister();
1341
1342exit_generic:
1343 bus_unregister(&usb_serial_bus_type); 1343 bus_unregister(&usb_serial_bus_type);
1344 1344
1345exit_bus: 1345exit_bus:
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index d2891f47579..9fcc7bd1fbe 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 */
868UNUSUAL_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) */
866UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999, 875UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999,
867 "Trumpion", 876 "Trumpion",
diff --git a/fs/cifs/README b/fs/cifs/README
index e74df0c7325..34b0cf7111f 100644
--- a/fs/cifs/README
+++ b/fs/cifs/README
@@ -371,7 +371,7 @@ A partial list of the supported mount options follows:
371 on newly created files, directories, and devices (create, 371 on newly created files, directories, and devices (create,
372 mkdir, mknod) which will result in the server setting the 372 mkdir, mknod) which will result in the server setting the
373 uid and gid to the default (usually the server uid of the 373 uid and gid to the default (usually the server uid of the
374 usern who mounted the share). Letting the server (rather than 374 user who mounted the share). Letting the server (rather than
375 the client) set the uid and gid is the default. This 375 the client) set the uid and gid is the default. This
376 parameter has no effect if the CIFS Unix Extensions are not 376 parameter has no effect if the CIFS Unix Extensions are not
377 negotiated. 377 negotiated.
@@ -384,7 +384,7 @@ A partial list of the supported mount options follows:
384 client (e.g. when the application is doing large sequential 384 client (e.g. when the application is doing large sequential
385 reads bigger than page size without rereading the same data) 385 reads bigger than page size without rereading the same data)
386 this can provide better performance than the default 386 this can provide better performance than the default
387 behavior which caches reads (reaadahead) and writes 387 behavior which caches reads (readahead) and writes
388 (writebehind) through the local Linux client pagecache 388 (writebehind) through the local Linux client pagecache
389 if oplock (caching token) is granted and held. Note that 389 if oplock (caching token) is granted and held. Note that
390 direct allows write operations larger than page size 390 direct allows write operations larger than page size
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 0010511083f..ea239dea571 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -228,7 +228,7 @@ extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
228 const struct nls_table *nls_codepage, 228 const struct nls_table *nls_codepage,
229 int remap_special_chars); 229 int remap_special_chars);
230#endif /* CONFIG_CIFS_EXPERIMENTAL */ 230#endif /* CONFIG_CIFS_EXPERIMENTAL */
231extern int cifs_convertUCSpath(char *target, const __u16 *source, int maxlen, 231extern int cifs_convertUCSpath(char *target, const __le16 *source, int maxlen,
232 const struct nls_table * codepage); 232 const struct nls_table * codepage);
233extern int cifsConvertToUCS(__le16 * target, const char *source, int maxlen, 233extern int cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
234 const struct nls_table * cp, int mapChars); 234 const struct nls_table * cp, int mapChars);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 741ff0c69f3..3c628bf667a 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -567,7 +567,7 @@ DelFileRetry:
567 567
568 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 568 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
569 name_len = 569 name_len =
570 cifsConvertToUCS((__u16 *) pSMB->fileName, fileName, 570 cifsConvertToUCS((__le16 *) pSMB->fileName, fileName,
571 PATH_MAX, nls_codepage, remap); 571 PATH_MAX, nls_codepage, remap);
572 name_len++; /* trailing null */ 572 name_len++; /* trailing null */
573 name_len *= 2; 573 name_len *= 2;
@@ -665,7 +665,7 @@ MkDirRetry:
665 return rc; 665 return rc;
666 666
667 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 667 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
668 name_len = cifsConvertToUCS((__u16 *) pSMB->DirName, name, 668 name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, name,
669 PATH_MAX, nls_codepage, remap); 669 PATH_MAX, nls_codepage, remap);
670 name_len++; /* trailing null */ 670 name_len++; /* trailing null */
671 name_len *= 2; 671 name_len *= 2;
@@ -719,7 +719,7 @@ openRetry:
719 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 719 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
720 count = 1; /* account for one byte pad to word boundary */ 720 count = 1; /* account for one byte pad to word boundary */
721 name_len = 721 name_len =
722 cifsConvertToUCS((__u16 *) (pSMB->fileName + 1), 722 cifsConvertToUCS((__le16 *) (pSMB->fileName + 1),
723 fileName, PATH_MAX, nls_codepage, remap); 723 fileName, PATH_MAX, nls_codepage, remap);
724 name_len++; /* trailing null */ 724 name_len++; /* trailing null */
725 name_len *= 2; 725 name_len *= 2;
@@ -1141,7 +1141,7 @@ renameRetry:
1141 1141
1142 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1142 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1143 name_len = 1143 name_len =
1144 cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName, 1144 cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName,
1145 PATH_MAX, nls_codepage, remap); 1145 PATH_MAX, nls_codepage, remap);
1146 name_len++; /* trailing null */ 1146 name_len++; /* trailing null */
1147 name_len *= 2; 1147 name_len *= 2;
@@ -1149,7 +1149,7 @@ renameRetry:
1149 /* protocol requires ASCII signature byte on Unicode string */ 1149 /* protocol requires ASCII signature byte on Unicode string */
1150 pSMB->OldFileName[name_len + 1] = 0x00; 1150 pSMB->OldFileName[name_len + 1] = 0x00;
1151 name_len2 = 1151 name_len2 =
1152 cifsConvertToUCS((__u16 *) &pSMB->OldFileName[name_len + 2], 1152 cifsConvertToUCS((__le16 *) &pSMB->OldFileName[name_len + 2],
1153 toName, PATH_MAX, nls_codepage, remap); 1153 toName, PATH_MAX, nls_codepage, remap);
1154 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; 1154 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
1155 name_len2 *= 2; /* convert to bytes */ 1155 name_len2 *= 2; /* convert to bytes */
@@ -1236,10 +1236,10 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1236 /* unicode only call */ 1236 /* unicode only call */
1237 if(target_name == NULL) { 1237 if(target_name == NULL) {
1238 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); 1238 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid);
1239 len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name, 1239 len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
1240 dummy_string, 24, nls_codepage, remap); 1240 dummy_string, 24, nls_codepage, remap);
1241 } else { 1241 } else {
1242 len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name, 1242 len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
1243 target_name, PATH_MAX, nls_codepage, remap); 1243 target_name, PATH_MAX, nls_codepage, remap);
1244 } 1244 }
1245 rename_info->target_name_len = cpu_to_le32(2 * len_of_str); 1245 rename_info->target_name_len = cpu_to_le32(2 * len_of_str);
@@ -1296,7 +1296,7 @@ copyRetry:
1296 pSMB->Flags = cpu_to_le16(flags & COPY_TREE); 1296 pSMB->Flags = cpu_to_le16(flags & COPY_TREE);
1297 1297
1298 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1298 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1299 name_len = cifsConvertToUCS((__u16 *) pSMB->OldFileName, 1299 name_len = cifsConvertToUCS((__le16 *) pSMB->OldFileName,
1300 fromName, PATH_MAX, nls_codepage, 1300 fromName, PATH_MAX, nls_codepage,
1301 remap); 1301 remap);
1302 name_len++; /* trailing null */ 1302 name_len++; /* trailing null */
@@ -1304,7 +1304,7 @@ copyRetry:
1304 pSMB->OldFileName[name_len] = 0x04; /* pad */ 1304 pSMB->OldFileName[name_len] = 0x04; /* pad */
1305 /* protocol requires ASCII signature byte on Unicode string */ 1305 /* protocol requires ASCII signature byte on Unicode string */
1306 pSMB->OldFileName[name_len + 1] = 0x00; 1306 pSMB->OldFileName[name_len + 1] = 0x00;
1307 name_len2 = cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], 1307 name_len2 = cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2],
1308 toName, PATH_MAX, nls_codepage, remap); 1308 toName, PATH_MAX, nls_codepage, remap);
1309 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; 1309 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
1310 name_len2 *= 2; /* convert to bytes */ 1310 name_len2 *= 2; /* convert to bytes */
@@ -1453,7 +1453,7 @@ createHardLinkRetry:
1453 return rc; 1453 return rc;
1454 1454
1455 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1455 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1456 name_len = cifsConvertToUCS((__u16 *) pSMB->FileName, toName, 1456 name_len = cifsConvertToUCS((__le16 *) pSMB->FileName, toName,
1457 PATH_MAX, nls_codepage, remap); 1457 PATH_MAX, nls_codepage, remap);
1458 name_len++; /* trailing null */ 1458 name_len++; /* trailing null */
1459 name_len *= 2; 1459 name_len *= 2;
@@ -1476,7 +1476,7 @@ createHardLinkRetry:
1476 data_offset = (char *) (&pSMB->hdr.Protocol) + offset; 1476 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
1477 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1477 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1478 name_len_target = 1478 name_len_target =
1479 cifsConvertToUCS((__u16 *) data_offset, fromName, PATH_MAX, 1479 cifsConvertToUCS((__le16 *) data_offset, fromName, PATH_MAX,
1480 nls_codepage, remap); 1480 nls_codepage, remap);
1481 name_len_target++; /* trailing null */ 1481 name_len_target++; /* trailing null */
1482 name_len_target *= 2; 1482 name_len_target *= 2;
@@ -1546,14 +1546,14 @@ winCreateHardLinkRetry:
1546 1546
1547 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1547 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1548 name_len = 1548 name_len =
1549 cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName, 1549 cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName,
1550 PATH_MAX, nls_codepage, remap); 1550 PATH_MAX, nls_codepage, remap);
1551 name_len++; /* trailing null */ 1551 name_len++; /* trailing null */
1552 name_len *= 2; 1552 name_len *= 2;
1553 pSMB->OldFileName[name_len] = 0; /* pad */ 1553 pSMB->OldFileName[name_len] = 0; /* pad */
1554 pSMB->OldFileName[name_len + 1] = 0x04; 1554 pSMB->OldFileName[name_len + 1] = 0x04;
1555 name_len2 = 1555 name_len2 =
1556 cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], 1556 cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2],
1557 toName, PATH_MAX, nls_codepage, remap); 1557 toName, PATH_MAX, nls_codepage, remap);
1558 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; 1558 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
1559 name_len2 *= 2; /* convert to bytes */ 1559 name_len2 *= 2; /* convert to bytes */
@@ -1939,7 +1939,7 @@ queryAclRetry:
1939 1939
1940 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1940 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1941 name_len = 1941 name_len =
1942 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 1942 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
1943 PATH_MAX, nls_codepage, remap); 1943 PATH_MAX, nls_codepage, remap);
1944 name_len++; /* trailing null */ 1944 name_len++; /* trailing null */
1945 name_len *= 2; 1945 name_len *= 2;
@@ -2024,7 +2024,7 @@ setAclRetry:
2024 return rc; 2024 return rc;
2025 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2025 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2026 name_len = 2026 name_len =
2027 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 2027 cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
2028 PATH_MAX, nls_codepage, remap); 2028 PATH_MAX, nls_codepage, remap);
2029 name_len++; /* trailing null */ 2029 name_len++; /* trailing null */
2030 name_len *= 2; 2030 name_len *= 2;
@@ -2188,7 +2188,7 @@ QPathInfoRetry:
2188 2188
2189 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2189 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2190 name_len = 2190 name_len =
2191 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 2191 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
2192 PATH_MAX, nls_codepage, remap); 2192 PATH_MAX, nls_codepage, remap);
2193 name_len++; /* trailing null */ 2193 name_len++; /* trailing null */
2194 name_len *= 2; 2194 name_len *= 2;
@@ -2269,7 +2269,7 @@ UnixQPathInfoRetry:
2269 2269
2270 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2270 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2271 name_len = 2271 name_len =
2272 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 2272 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
2273 PATH_MAX, nls_codepage, remap); 2273 PATH_MAX, nls_codepage, remap);
2274 name_len++; /* trailing null */ 2274 name_len++; /* trailing null */
2275 name_len *= 2; 2275 name_len *= 2;
@@ -2350,7 +2350,7 @@ findUniqueRetry:
2350 2350
2351 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2351 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2352 name_len = 2352 name_len =
2353 cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX 2353 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, PATH_MAX
2354 /* find define for this maxpathcomponent */ 2354 /* find define for this maxpathcomponent */
2355 , nls_codepage); 2355 , nls_codepage);
2356 name_len++; /* trailing null */ 2356 name_len++; /* trailing null */
@@ -2435,7 +2435,7 @@ findFirstRetry:
2435 2435
2436 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2436 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2437 name_len = 2437 name_len =
2438 cifsConvertToUCS((__u16 *) pSMB->FileName,searchName, 2438 cifsConvertToUCS((__le16 *) pSMB->FileName,searchName,
2439 PATH_MAX, nls_codepage, remap); 2439 PATH_MAX, nls_codepage, remap);
2440 /* We can not add the asterik earlier in case 2440 /* We can not add the asterik earlier in case
2441 it got remapped to 0xF03A as if it were part of the 2441 it got remapped to 0xF03A as if it were part of the
@@ -2726,7 +2726,7 @@ GetInodeNumberRetry:
2726 2726
2727 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2727 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2728 name_len = 2728 name_len =
2729 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 2729 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
2730 PATH_MAX,nls_codepage, remap); 2730 PATH_MAX,nls_codepage, remap);
2731 name_len++; /* trailing null */ 2731 name_len++; /* trailing null */
2732 name_len *= 2; 2732 name_len *= 2;
@@ -2837,7 +2837,7 @@ getDFSRetry:
2837 if (ses->capabilities & CAP_UNICODE) { 2837 if (ses->capabilities & CAP_UNICODE) {
2838 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; 2838 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
2839 name_len = 2839 name_len =
2840 cifsConvertToUCS((__u16 *) pSMB->RequestFileName, 2840 cifsConvertToUCS((__le16 *) pSMB->RequestFileName,
2841 searchName, PATH_MAX, nls_codepage, remap); 2841 searchName, PATH_MAX, nls_codepage, remap);
2842 name_len++; /* trailing null */ 2842 name_len++; /* trailing null */
2843 name_len *= 2; 2843 name_len *= 2;
@@ -3369,7 +3369,7 @@ SetEOFRetry:
3369 3369
3370 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3370 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3371 name_len = 3371 name_len =
3372 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 3372 cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
3373 PATH_MAX, nls_codepage, remap); 3373 PATH_MAX, nls_codepage, remap);
3374 name_len++; /* trailing null */ 3374 name_len++; /* trailing null */
3375 name_len *= 2; 3375 name_len *= 2;
@@ -3627,7 +3627,7 @@ SetTimesRetry:
3627 3627
3628 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3628 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3629 name_len = 3629 name_len =
3630 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 3630 cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
3631 PATH_MAX, nls_codepage, remap); 3631 PATH_MAX, nls_codepage, remap);
3632 name_len++; /* trailing null */ 3632 name_len++; /* trailing null */
3633 name_len *= 2; 3633 name_len *= 2;
@@ -3708,7 +3708,7 @@ SetAttrLgcyRetry:
3708 3708
3709 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3709 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3710 name_len = 3710 name_len =
3711 ConvertToUCS((wchar_t *) pSMB->fileName, fileName, 3711 ConvertToUCS((__le16 *) pSMB->fileName, fileName,
3712 PATH_MAX, nls_codepage); 3712 PATH_MAX, nls_codepage);
3713 name_len++; /* trailing null */ 3713 name_len++; /* trailing null */
3714 name_len *= 2; 3714 name_len *= 2;
@@ -3759,7 +3759,7 @@ setPermsRetry:
3759 3759
3760 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3760 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3761 name_len = 3761 name_len =
3762 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 3762 cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
3763 PATH_MAX, nls_codepage, remap); 3763 PATH_MAX, nls_codepage, remap);
3764 name_len++; /* trailing null */ 3764 name_len++; /* trailing null */
3765 name_len *= 2; 3765 name_len *= 2;
@@ -3904,7 +3904,7 @@ QAllEAsRetry:
3904 3904
3905 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3905 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3906 name_len = 3906 name_len =
3907 cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, 3907 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
3908 PATH_MAX, nls_codepage, remap); 3908 PATH_MAX, nls_codepage, remap);
3909 name_len++; /* trailing null */ 3909 name_len++; /* trailing null */
3910 name_len *= 2; 3910 name_len *= 2;
@@ -4047,7 +4047,7 @@ QEARetry:
4047 4047
4048 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 4048 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
4049 name_len = 4049 name_len =
4050 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 4050 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
4051 PATH_MAX, nls_codepage, remap); 4051 PATH_MAX, nls_codepage, remap);
4052 name_len++; /* trailing null */ 4052 name_len++; /* trailing null */
4053 name_len *= 2; 4053 name_len *= 2;
@@ -4194,7 +4194,7 @@ SetEARetry:
4194 4194
4195 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 4195 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
4196 name_len = 4196 name_len =
4197 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 4197 cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
4198 PATH_MAX, nls_codepage, remap); 4198 PATH_MAX, nls_codepage, remap);
4199 name_len++; /* trailing null */ 4199 name_len++; /* trailing null */
4200 name_len *= 2; 4200 name_len *= 2;
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index e3137aa48cd..3f3538d4a1f 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -392,7 +392,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
392 rc = 0; 392 rc = 0;
393 d_add(direntry, NULL); 393 d_add(direntry, NULL);
394 } else { 394 } else {
395 cERROR(1,("Error 0x%x or on cifs_get_inode_info in lookup",rc)); 395 cERROR(1,("Error 0x%x on cifs_get_inode_info in lookup of %s",
396 rc,full_path));
396 /* BB special case check for Access Denied - watch security 397 /* BB special case check for Access Denied - watch security
397 exposure of returning dir info implicitly via different rc 398 exposure of returning dir info implicitly via different rc
398 if file exists or not but no access BB */ 399 if file exists or not but no access BB */
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 67094728826..b8b78cbb34c 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -422,7 +422,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
422 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 422 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
423 423
424 if (!rc) { 424 if (!rc) {
425 direntry->d_inode->i_nlink--; 425 if(direntry->d_inode)
426 direntry->d_inode->i_nlink--;
426 } else if (rc == -ENOENT) { 427 } else if (rc == -ENOENT) {
427 d_drop(direntry); 428 d_drop(direntry);
428 } else if (rc == -ETXTBSY) { 429 } else if (rc == -ETXTBSY) {
@@ -440,7 +441,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
440 cifs_sb->mnt_cifs_flags & 441 cifs_sb->mnt_cifs_flags &
441 CIFS_MOUNT_MAP_SPECIAL_CHR); 442 CIFS_MOUNT_MAP_SPECIAL_CHR);
442 CIFSSMBClose(xid, pTcon, netfid); 443 CIFSSMBClose(xid, pTcon, netfid);
443 direntry->d_inode->i_nlink--; 444 if(direntry->d_inode)
445 direntry->d_inode->i_nlink--;
444 } 446 }
445 } else if (rc == -EACCES) { 447 } else if (rc == -EACCES) {
446 /* try only if r/o attribute set in local lookup data? */ 448 /* try only if r/o attribute set in local lookup data? */
@@ -494,7 +496,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
494 cifs_sb->mnt_cifs_flags & 496 cifs_sb->mnt_cifs_flags &
495 CIFS_MOUNT_MAP_SPECIAL_CHR); 497 CIFS_MOUNT_MAP_SPECIAL_CHR);
496 if (!rc) { 498 if (!rc) {
497 direntry->d_inode->i_nlink--; 499 if(direntry->d_inode)
500 direntry->d_inode->i_nlink--;
498 } else if (rc == -ETXTBSY) { 501 } else if (rc == -ETXTBSY) {
499 int oplock = FALSE; 502 int oplock = FALSE;
500 __u16 netfid; 503 __u16 netfid;
@@ -514,17 +517,20 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
514 cifs_sb->mnt_cifs_flags & 517 cifs_sb->mnt_cifs_flags &
515 CIFS_MOUNT_MAP_SPECIAL_CHR); 518 CIFS_MOUNT_MAP_SPECIAL_CHR);
516 CIFSSMBClose(xid, pTcon, netfid); 519 CIFSSMBClose(xid, pTcon, netfid);
517 direntry->d_inode->i_nlink--; 520 if(direntry->d_inode)
521 direntry->d_inode->i_nlink--;
518 } 522 }
519 /* BB if rc = -ETXTBUSY goto the rename logic BB */ 523 /* BB if rc = -ETXTBUSY goto the rename logic BB */
520 } 524 }
521 } 525 }
522 } 526 }
523 cifsInode = CIFS_I(direntry->d_inode); 527 if(direntry->d_inode) {
524 cifsInode->time = 0; /* will force revalidate to get info when 528 cifsInode = CIFS_I(direntry->d_inode);
525 needed */ 529 cifsInode->time = 0; /* will force revalidate to get info
526 direntry->d_inode->i_ctime = inode->i_ctime = inode->i_mtime = 530 when needed */
527 current_fs_time(inode->i_sb); 531 direntry->d_inode->i_ctime = current_fs_time(inode->i_sb);
532 }
533 inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
528 cifsInode = CIFS_I(inode); 534 cifsInode = CIFS_I(inode);
529 cifsInode->time = 0; /* force revalidate of dir as well */ 535 cifsInode->time = 0; /* force revalidate of dir as well */
530 536
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index db14b503d89..072b4ee8c53 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -571,6 +571,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
571 break; 571 break;
572 case UNI_LESSTHAN: 572 case UNI_LESSTHAN:
573 target[j] = '<'; 573 target[j] = '<';
574 break;
574 default: 575 default:
575 len = cp->uni2char(src_char, &target[j], 576 len = cp->uni2char(src_char, &target[j],
576 NLS_MAX_CHARSET_SIZE); 577 NLS_MAX_CHARSET_SIZE);
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
index 98d830401c5..5a97e346bd9 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 b92c0e64aef..bb9aebe9386 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/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index 67423c696c0..6fd57f15419 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -12,15 +12,8 @@
12#include <asm/uaccess.h> 12#include <asm/uaccess.h>
13 13
14#ifndef HAVE_ARCH_DEVTREE_FIXUPS 14#ifndef HAVE_ARCH_DEVTREE_FIXUPS
15static inline void set_node_proc_entry(struct device_node *np, struct proc_dir_entry *de) 15static inline void set_node_proc_entry(struct device_node *np,
16{ 16 struct proc_dir_entry *de)
17}
18
19static void inline set_node_name_link(struct device_node *np, struct proc_dir_entry *de)
20{
21}
22
23static void inline set_node_addr_link(struct device_node *np, struct proc_dir_entry *de)
24{ 17{
25} 18}
26#endif 19#endif
@@ -58,89 +51,67 @@ static int property_read_proc(char *page, char **start, off_t off,
58/* 51/*
59 * Process a node, adding entries for its children and its properties. 52 * Process a node, adding entries for its children and its properties.
60 */ 53 */
61void proc_device_tree_add_node(struct device_node *np, struct proc_dir_entry *de) 54void proc_device_tree_add_node(struct device_node *np,
55 struct proc_dir_entry *de)
62{ 56{
63 struct property *pp; 57 struct property *pp;
64 struct proc_dir_entry *ent; 58 struct proc_dir_entry *ent;
65 struct device_node *child, *sib; 59 struct device_node *child;
66 const char *p, *at; 60 struct proc_dir_entry *list = NULL, **lastp;
67 int l; 61 const char *p;
68 struct proc_dir_entry *list, **lastp, *al;
69 62
70 set_node_proc_entry(np, de); 63 set_node_proc_entry(np, de);
71 lastp = &list; 64 lastp = &list;
72 for (pp = np->properties; pp != 0; pp = pp->next) { 65 for (child = NULL; (child = of_get_next_child(np, child));) {
73 /*
74 * Unfortunately proc_register puts each new entry
75 * at the beginning of the list. So we rearrange them.
76 */
77 ent = create_proc_read_entry(pp->name, strncmp(pp->name, "security-", 9) ?
78 S_IRUGO : S_IRUSR, de, property_read_proc, pp);
79 if (ent == 0)
80 break;
81 if (!strncmp(pp->name, "security-", 9))
82 ent->size = 0; /* don't leak number of password chars */
83 else
84 ent->size = pp->length;
85 *lastp = ent;
86 lastp = &ent->next;
87 }
88 child = NULL;
89 while ((child = of_get_next_child(np, child))) {
90 p = strrchr(child->full_name, '/'); 66 p = strrchr(child->full_name, '/');
91 if (!p) 67 if (!p)
92 p = child->full_name; 68 p = child->full_name;
93 else 69 else
94 ++p; 70 ++p;
95 /* chop off '@0' if the name ends with that */
96 l = strlen(p);
97 if (l > 2 && p[l-2] == '@' && p[l-1] == '0')
98 l -= 2;
99 ent = proc_mkdir(p, de); 71 ent = proc_mkdir(p, de);
100 if (ent == 0) 72 if (ent == 0)
101 break; 73 break;
102 *lastp = ent; 74 *lastp = ent;
75 ent->next = NULL;
103 lastp = &ent->next; 76 lastp = &ent->next;
104 proc_device_tree_add_node(child, ent); 77 proc_device_tree_add_node(child, ent);
105 78 }
106 /* 79 of_node_put(child);
107 * If we left the address part on the name, consider 80 for (pp = np->properties; pp != 0; pp = pp->next) {
108 * adding symlinks from the name and address parts.
109 */
110 if (p[l] != 0 || (at = strchr(p, '@')) == 0)
111 continue;
112
113 /* 81 /*
114 * If this is the first node with a given name property, 82 * Yet another Apple device-tree bogosity: on some machines,
115 * add a symlink with the name property as its name. 83 * they have properties & nodes with the same name. Those
84 * properties are quite unimportant for us though, thus we
85 * simply "skip" them here, but we do have to check.
116 */ 86 */
117 sib = NULL; 87 for (ent = list; ent != NULL; ent = ent->next)
118 while ((sib = of_get_next_child(np, sib)) && sib != child) 88 if (!strcmp(ent->name, pp->name))
119 if (sib->name && strcmp(sib->name, child->name) == 0)
120 break;
121 if (sib == child && strncmp(p, child->name, l) != 0) {
122 al = proc_symlink(child->name, de, ent->name);
123 if (al == 0) {
124 of_node_put(sib);
125 break; 89 break;
126 } 90 if (ent != NULL) {
127 set_node_name_link(child, al); 91 printk(KERN_WARNING "device-tree: property \"%s\" name"
128 *lastp = al; 92 " conflicts with node in %s\n", pp->name,
129 lastp = &al->next; 93 np->full_name);
94 continue;
130 } 95 }
131 of_node_put(sib); 96
132 /* 97 /*
133 * Add another directory with the @address part as its name. 98 * Unfortunately proc_register puts each new entry
99 * at the beginning of the list. So we rearrange them.
134 */ 100 */
135 al = proc_symlink(at, de, ent->name); 101 ent = create_proc_read_entry(pp->name,
136 if (al == 0) 102 strncmp(pp->name, "security-", 9)
103 ? S_IRUGO : S_IRUSR, de,
104 property_read_proc, pp);
105 if (ent == 0)
137 break; 106 break;
138 set_node_addr_link(child, al); 107 if (!strncmp(pp->name, "security-", 9))
139 *lastp = al; 108 ent->size = 0; /* don't leak number of password chars */
140 lastp = &al->next; 109 else
110 ent->size = pp->length;
111 ent->next = NULL;
112 *lastp = ent;
113 lastp = &ent->next;
141 } 114 }
142 of_node_put(child);
143 *lastp = NULL;
144 de->subdir = list; 115 de->subdir = list;
145} 116}
146 117
diff --git a/include/asm-ppc64/processor.h b/include/asm-ppc64/processor.h
index 0035efe2db2..809c634ba1d 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
499static 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
508static 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/prom.h b/include/asm-ppc64/prom.h
index 2440a2c90ae..04b1a84f7ca 100644
--- a/include/asm-ppc64/prom.h
+++ b/include/asm-ppc64/prom.h
@@ -147,9 +147,7 @@ struct device_node {
147 struct device_node *sibling; 147 struct device_node *sibling;
148 struct device_node *next; /* next device of same type */ 148 struct device_node *next; /* next device of same type */
149 struct device_node *allnext; /* next in list of all nodes */ 149 struct device_node *allnext; /* next in list of all nodes */
150 struct proc_dir_entry *pde; /* this node's proc directory */ 150 struct proc_dir_entry *pde; /* this node's proc directory */
151 struct proc_dir_entry *name_link; /* name symlink */
152 struct proc_dir_entry *addr_link; /* addr symlink */
153 struct kref kref; 151 struct kref kref;
154 unsigned long _flags; 152 unsigned long _flags;
155}; 153};
@@ -174,15 +172,6 @@ static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_e
174 dn->pde = de; 172 dn->pde = de;
175} 173}
176 174
177static void inline set_node_name_link(struct device_node *dn, struct proc_dir_entry *de)
178{
179 dn->name_link = de;
180}
181
182static void inline set_node_addr_link(struct device_node *dn, struct proc_dir_entry *de)
183{
184 dn->addr_link = de;
185}
186 175
187/* OBSOLETE: Old stlye node lookup */ 176/* OBSOLETE: Old stlye node lookup */
188extern struct device_node *find_devices(const char *name); 177extern struct device_node *find_devices(const char *name);
diff --git a/include/asm-ppc64/thread_info.h b/include/asm-ppc64/thread_info.h
index 037b5e06083..48b7900e90e 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 c64f8c181df..1dc74baf03c 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/asm-sparc64/iommu.h b/include/asm-sparc64/iommu.h
index 5fd16e42a04..0de7a3da79c 100644
--- a/include/asm-sparc64/iommu.h
+++ b/include/asm-sparc64/iommu.h
@@ -16,4 +16,6 @@
16#define IOPTE_CACHE 0x0000000000000010UL /* Cached (in UPA E-cache) */ 16#define IOPTE_CACHE 0x0000000000000010UL /* Cached (in UPA E-cache) */
17#define IOPTE_WRITE 0x0000000000000002UL /* Writeable */ 17#define IOPTE_WRITE 0x0000000000000002UL /* Writeable */
18 18
19#define IOMMU_NUM_CTXS 4096
20
19#endif /* !(_SPARC_IOMMU_H) */ 21#endif /* !(_SPARC_IOMMU_H) */
diff --git a/include/asm-sparc64/pbm.h b/include/asm-sparc64/pbm.h
index 92999631c81..4c15610a2ba 100644
--- a/include/asm-sparc64/pbm.h
+++ b/include/asm-sparc64/pbm.h
@@ -15,6 +15,7 @@
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/page.h> 16#include <asm/page.h>
17#include <asm/oplib.h> 17#include <asm/oplib.h>
18#include <asm/iommu.h>
18 19
19/* The abstraction used here is that there are PCI controllers, 20/* The abstraction used here is that there are PCI controllers,
20 * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules 21 * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
@@ -40,9 +41,6 @@ struct pci_iommu {
40 */ 41 */
41 spinlock_t lock; 42 spinlock_t lock;
42 43
43 /* Context allocator. */
44 unsigned int iommu_cur_ctx;
45
46 /* IOMMU page table, a linear array of ioptes. */ 44 /* IOMMU page table, a linear array of ioptes. */
47 iopte_t *page_table; /* The page table itself. */ 45 iopte_t *page_table; /* The page table itself. */
48 int page_table_sz_bits; /* log2 of ow many pages does it map? */ 46 int page_table_sz_bits; /* log2 of ow many pages does it map? */
@@ -87,6 +85,10 @@ struct pci_iommu {
87 u16 flush; 85 u16 flush;
88 } alloc_info[PBM_NCLUSTERS]; 86 } alloc_info[PBM_NCLUSTERS];
89 87
88 /* CTX allocation. */
89 unsigned long ctx_lowest_free;
90 unsigned long ctx_bitmap[IOMMU_NUM_CTXS / (sizeof(unsigned long) * 8)];
91
90 /* Here a PCI controller driver describes the areas of 92 /* Here a PCI controller driver describes the areas of
91 * PCI memory space where DMA to/from physical memory 93 * PCI memory space where DMA to/from physical memory
92 * are addressed. Drivers interrogate the PCI layer 94 * are addressed. Drivers interrogate the PCI layer
diff --git a/include/linux/if_shaper.h b/include/linux/if_shaper.h
index 0485b256d04..004e6f09a6e 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 e74f301e9ba..b009f801e7c 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
470static inline void ata_pause(struct ata_port *ap) 479static 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
476static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, 498static 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
490static inline u8 ata_wait_idle(struct ata_port *ap) 524static 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
528static inline u8 ata_irq_on(struct ata_port *ap) 574static 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
547static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) 605static 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 470af8c1a4a..ba5d1236aa1 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/pci_ids.h b/include/linux/pci_ids.h
index 7ccbc2e4272..b0d6134e1ee 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1230,6 +1230,12 @@
1230#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258 1230#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258
1231#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259 1231#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259
1232#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B 1232#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B
1233#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE 0x0265
1234#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266
1235#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267
1236#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268
1237#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269
1238#define PCI_DEVICE_ID_NVIDIA_MCP51_AUDIO 0x026B
1233#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 1239#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280
1234#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 1240#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281
1235#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 1241#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 41d1a644c9d..2d1ac505853 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 */
800struct urb 804struct 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/esp4.c b/net/ipv4/esp4.c
index 053a883247b..eae84cc39d3 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -478,7 +478,7 @@ static int __init esp4_init(void)
478{ 478{
479 struct xfrm_decap_state decap; 479 struct xfrm_decap_state decap;
480 480
481 if (sizeof(struct esp_decap_data) < 481 if (sizeof(struct esp_decap_data) >
482 sizeof(decap.decap_data)) { 482 sizeof(decap.decap_data)) {
483 extern void decap_data_too_small(void); 483 extern void decap_data_too_small(void);
484 484
diff --git a/net/ipv4/ipvs/Makefile b/net/ipv4/ipvs/Makefile
index a788461a40c..30e85de9fff 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
12ip_vs-objs := ip_vs_conn.o ip_vs_core.o ip_vs_ctl.o ip_vs_sched.o \ 12ip_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 253c46252bd..867d4e9c659 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 191e94aa1c1..00000000000
--- 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
21static int icmp_timeouts[1] = { 1*60*HZ };
22
23static char * icmp_state_name_table[1] = { "ICMP" };
24
25static struct ip_vs_conn *
26icmp_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
52static struct ip_vs_conn *
53icmp_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
78static int
79icmp_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
86static int
87icmp_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
100static void
101icmp_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
133static int
134icmp_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
142static int
143icmp_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
154static void icmp_init(struct ip_vs_protocol *pp)
155{
156 pp->timeout_table = icmp_timeouts;
157}
158
159static void icmp_exit(struct ip_vs_protocol *pp)
160{
161}
162
163struct 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/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index e5746b67441..eda1fba431a 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -3,6 +3,7 @@
3 * communicating with userspace via netlink. 3 * communicating with userspace via netlink.
4 * 4 *
5 * (C) 2000-2002 James Morris <jmorris@intercode.com.au> 5 * (C) 2000-2002 James Morris <jmorris@intercode.com.au>
6 * (C) 2003-2005 Netfilter Core Team <coreteam@netfilter.org>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -17,6 +18,7 @@
17 * 2005-01-10: Added /proc counter for dropped packets; fixed so 18 * 2005-01-10: Added /proc counter for dropped packets; fixed so
18 * packets aren't delivered to user space if they're going 19 * packets aren't delivered to user space if they're going
19 * to be dropped. 20 * to be dropped.
21 * 2005-05-26: local_bh_{disable,enable} around nf_reinject (Harald Welte)
20 * 22 *
21 */ 23 */
22#include <linux/module.h> 24#include <linux/module.h>
@@ -71,7 +73,15 @@ static DECLARE_MUTEX(ipqnl_sem);
71static void 73static void
72ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict) 74ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
73{ 75{
76 /* TCP input path (and probably other bits) assume to be called
77 * from softirq context, not from syscall, like ipq_issue_verdict is
78 * called. TCP input path deadlocks with locks taken from timer
79 * softirq, e.g. We therefore emulate this by local_bh_disable() */
80
81 local_bh_disable();
74 nf_reinject(entry->skb, entry->info, verdict); 82 nf_reinject(entry->skb, entry->info, verdict);
83 local_bh_enable();
84
75 kfree(entry); 85 kfree(entry);
76} 86}
77 87
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 4a6952e3fee..7c24e64b443 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -738,7 +738,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
738 unsigned long amount; 738 unsigned long amount;
739 739
740 amount = 0; 740 amount = 0;
741 spin_lock_irq(&sk->sk_receive_queue.lock); 741 spin_lock_bh(&sk->sk_receive_queue.lock);
742 skb = skb_peek(&sk->sk_receive_queue); 742 skb = skb_peek(&sk->sk_receive_queue);
743 if (skb != NULL) { 743 if (skb != NULL) {
744 /* 744 /*
@@ -748,7 +748,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
748 */ 748 */
749 amount = skb->len - sizeof(struct udphdr); 749 amount = skb->len - sizeof(struct udphdr);
750 } 750 }
751 spin_unlock_irq(&sk->sk_receive_queue.lock); 751 spin_unlock_bh(&sk->sk_receive_queue.lock);
752 return put_user(amount, (int __user *)arg); 752 return put_user(amount, (int __user *)arg);
753 } 753 }
754 754
@@ -848,12 +848,12 @@ csum_copy_err:
848 /* Clear queue. */ 848 /* Clear queue. */
849 if (flags&MSG_PEEK) { 849 if (flags&MSG_PEEK) {
850 int clear = 0; 850 int clear = 0;
851 spin_lock_irq(&sk->sk_receive_queue.lock); 851 spin_lock_bh(&sk->sk_receive_queue.lock);
852 if (skb == skb_peek(&sk->sk_receive_queue)) { 852 if (skb == skb_peek(&sk->sk_receive_queue)) {
853 __skb_unlink(skb, &sk->sk_receive_queue); 853 __skb_unlink(skb, &sk->sk_receive_queue);
854 clear = 1; 854 clear = 1;
855 } 855 }
856 spin_unlock_irq(&sk->sk_receive_queue.lock); 856 spin_unlock_bh(&sk->sk_receive_queue.lock);
857 if (clear) 857 if (clear)
858 kfree_skb(skb); 858 kfree_skb(skb);
859 } 859 }
@@ -1334,7 +1334,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
1334 struct sk_buff_head *rcvq = &sk->sk_receive_queue; 1334 struct sk_buff_head *rcvq = &sk->sk_receive_queue;
1335 struct sk_buff *skb; 1335 struct sk_buff *skb;
1336 1336
1337 spin_lock_irq(&rcvq->lock); 1337 spin_lock_bh(&rcvq->lock);
1338 while ((skb = skb_peek(rcvq)) != NULL) { 1338 while ((skb = skb_peek(rcvq)) != NULL) {
1339 if (udp_checksum_complete(skb)) { 1339 if (udp_checksum_complete(skb)) {
1340 UDP_INC_STATS_BH(UDP_MIB_INERRORS); 1340 UDP_INC_STATS_BH(UDP_MIB_INERRORS);
@@ -1345,7 +1345,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
1345 break; 1345 break;
1346 } 1346 }
1347 } 1347 }
1348 spin_unlock_irq(&rcvq->lock); 1348 spin_unlock_bh(&rcvq->lock);
1349 1349
1350 /* nothing to see, move along */ 1350 /* nothing to see, move along */
1351 if (skb == NULL) 1351 if (skb == NULL)
diff --git a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c
index 2f4c91ddc9a..5ade5a5d199 100644
--- a/net/ipv6/ipv6_syms.c
+++ b/net/ipv6/ipv6_syms.c
@@ -37,5 +37,4 @@ EXPORT_SYMBOL(in6_dev_finish_destroy);
37EXPORT_SYMBOL(xfrm6_rcv); 37EXPORT_SYMBOL(xfrm6_rcv);
38#endif 38#endif
39EXPORT_SYMBOL(rt6_lookup); 39EXPORT_SYMBOL(rt6_lookup);
40EXPORT_SYMBOL(fl6_sock_lookup);
41EXPORT_SYMBOL(ipv6_push_nfrag_opts); 40EXPORT_SYMBOL(ipv6_push_nfrag_opts);
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
index 8a3db9d95ba..d8bd2a569c7 100644
--- a/net/sched/sch_dsmark.c
+++ b/net/sched/sch_dsmark.c
@@ -18,7 +18,7 @@
18#include <asm/byteorder.h> 18#include <asm/byteorder.h>
19 19
20 20
21#if 1 /* control */ 21#if 0 /* control */
22#define DPRINTK(format,args...) printk(KERN_DEBUG format,##args) 22#define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
23#else 23#else
24#define DPRINTK(format,args...) 24#define DPRINTK(format,args...)
@@ -73,8 +73,13 @@ static int dsmark_graft(struct Qdisc *sch,unsigned long arg,
73 73
74 DPRINTK("dsmark_graft(sch %p,[qdisc %p],new %p,old %p)\n",sch,p,new, 74 DPRINTK("dsmark_graft(sch %p,[qdisc %p],new %p,old %p)\n",sch,p,new,
75 old); 75 old);
76 if (!new) 76
77 new = &noop_qdisc; 77 if (new == NULL) {
78 new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
79 if (new == NULL)
80 new = &noop_qdisc;
81 }
82
78 sch_tree_lock(sch); 83 sch_tree_lock(sch);
79 *old = xchg(&p->q,new); 84 *old = xchg(&p->q,new);
80 if (*old) 85 if (*old)
@@ -163,14 +168,15 @@ static void dsmark_walk(struct Qdisc *sch,struct qdisc_walker *walker)
163 return; 168 return;
164 for (i = 0; i < p->indices; i++) { 169 for (i = 0; i < p->indices; i++) {
165 if (p->mask[i] == 0xff && !p->value[i]) 170 if (p->mask[i] == 0xff && !p->value[i])
166 continue; 171 goto ignore;
167 if (walker->count >= walker->skip) { 172 if (walker->count >= walker->skip) {
168 if (walker->fn(sch, i+1, walker) < 0) { 173 if (walker->fn(sch, i+1, walker) < 0) {
169 walker->stop = 1; 174 walker->stop = 1;
170 break; 175 break;
171 } 176 }
172 } 177 }
173 walker->count++; 178ignore:
179 walker->count++;
174 } 180 }
175} 181}
176 182