aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2010-05-02 23:28:58 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2010-05-02 23:28:58 -0400
commitdf2071bd081408318d659cd14a9cf6ff23d874c9 (patch)
treeb31291b5fd4b9f84c629833afbfaa8d431857475 /drivers/char
parent97e3d94aac1c3e95bd04d1b186479a4df3663ab8 (diff)
parentbe1066bbcd443a65df312fdecea7e4959adedb45 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ChangeLog775
-rw-r--r--drivers/char/agp/Kconfig2
-rw-r--r--drivers/char/agp/amd-k7-agp.c2
-rw-r--r--drivers/char/agp/backend.c1
-rw-r--r--drivers/char/agp/compat_ioctl.c1
-rw-r--r--drivers/char/agp/generic.c1
-rw-r--r--drivers/char/agp/hp-agp.c1
-rw-r--r--drivers/char/agp/intel-agp.c40
-rw-r--r--drivers/char/agp/nvidia-agp.c1
-rw-r--r--drivers/char/agp/sgi-agp.c1
-rw-r--r--drivers/char/agp/uninorth-agp.c1
-rw-r--r--drivers/char/amiserial.c4
-rw-r--r--drivers/char/applicom.c2
-rw-r--r--drivers/char/bfin_jtag_comm.c1
-rw-r--r--drivers/char/briq_panel.c1
-rw-r--r--drivers/char/bsr.c1
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/dsp56k.c1
-rw-r--r--drivers/char/epca.c1
-rw-r--r--drivers/char/generic_serial.c1
-rw-r--r--drivers/char/hpet.c5
-rw-r--r--drivers/char/hvc_console.c28
-rw-r--r--drivers/char/hvc_iseries.c2
-rw-r--r--drivers/char/hvc_iucv.c7
-rw-r--r--drivers/char/hvcs.c1
-rw-r--r--drivers/char/hw_random/intel-rng.c1
-rw-r--r--drivers/char/hw_random/n2-drv.c2
-rw-r--r--drivers/char/hw_random/octeon-rng.c1
-rw-r--r--drivers/char/hw_random/tx4939-rng.c1
-rw-r--r--drivers/char/ip2/i2hw.h2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c10
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c71
-rw-r--r--drivers/char/isicom.c10
-rw-r--r--drivers/char/istallion.c2
-rw-r--r--drivers/char/mbcs.c1
-rw-r--r--drivers/char/mem.c197
-rw-r--r--drivers/char/misc.c2
-rw-r--r--drivers/char/mmtimer.c3
-rw-r--r--drivers/char/moxa.c1
-rw-r--r--drivers/char/mxser.c11
-rw-r--r--drivers/char/n_tty.c17
-rw-r--r--drivers/char/nozomi.c1
-rw-r--r--drivers/char/nvram.c1
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c8
-rw-r--r--drivers/char/pcmcia/ipwireless/network.c1
-rw-r--r--drivers/char/ppdev.c1
-rw-r--r--drivers/char/ps3flash.c1
-rw-r--r--drivers/char/pty.c3
-rw-r--r--drivers/char/random.c2
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/char/rio/rioinit.c1
-rw-r--r--drivers/char/rio/riointr.c1
-rw-r--r--drivers/char/rio/rioparam.c1
-rw-r--r--drivers/char/rio/rioroute.c1
-rw-r--r--drivers/char/rio/riotty.c1
-rw-r--r--drivers/char/riscom8.c1
-rw-r--r--drivers/char/serial167.c3
-rw-r--r--drivers/char/snsc_event.c1
-rw-r--r--drivers/char/sonypi.c1
-rw-r--r--drivers/char/specialix.c1
-rw-r--r--drivers/char/stallion.c7
-rw-r--r--drivers/char/sysrq.c1
-rw-r--r--drivers/char/tpm/tpm.c1
-rw-r--r--drivers/char/tpm/tpm_bios.c1
-rw-r--r--drivers/char/tpm/tpm_nsc.c1
-rw-r--r--drivers/char/tpm/tpm_tis.c1
-rw-r--r--drivers/char/tty_audit.c2
-rw-r--r--drivers/char/tty_buffer.c4
-rw-r--r--drivers/char/tty_io.c4
-rw-r--r--drivers/char/tty_port.c2
-rw-r--r--drivers/char/viotape.c1
-rw-r--r--drivers/char/virtio_console.c110
-rw-r--r--drivers/char/vme_scc.c1
-rw-r--r--drivers/char/vt.c6
-rw-r--r--drivers/char/vt_ioctl.c39
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c1
76 files changed, 432 insertions, 996 deletions
diff --git a/drivers/char/ChangeLog b/drivers/char/ChangeLog
deleted file mode 100644
index 56b8a2e76ab1..000000000000
--- a/drivers/char/ChangeLog
+++ /dev/null
@@ -1,775 +0,0 @@
12001-08-11 Tim Waugh <twaugh@redhat.com>
2
3 * serial.c (get_pci_port): Deal with awkward Titan cards.
4
51998-08-26 Theodore Ts'o <tytso@rsts-11.mit.edu>
6
7 * serial.c (rs_open): Correctly decrement the module in-use count
8 on errors.
9
10Thu Feb 19 14:24:08 1998 Theodore Ts'o <tytso@rsts-11.mit.edu>
11
12 * tty_io.c (tty_name): Remove the non-reentrant (and non-SMP safe)
13 version of tty_name, and rename the reentrant _tty_name
14 function to be tty_name.
15 (tty_open): Add a warning message stating callout devices
16 are deprecated.
17
18Mon Dec 1 08:24:15 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
19
20 * tty_io.c (tty_get_baud_rate): Print a warning syslog if the
21 tty->alt_speed kludge is used; this means the system is
22 using the deprecated SPD_HI ioctls.
23
24Mon Nov 24 10:37:49 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
25
26 * serial.c, esp.c, rocket.c: Change drivers to take advantage of
27 tty_get_baud_rate().
28
29 * tty_io.c (tty_get_baud_rate): New function which computes the
30 correct baud rate for the tty. More factoring out of
31 common code out of the serial driver to the high-level tty
32 functions....
33
34Sat Nov 22 07:53:36 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
35
36 * serial.c, esp.c, rocket.c: Add tty->driver.break() routine, and
37 allow high-level tty code to handle the break and soft
38 carrier ioctls.
39
40 * tty_ioctl.c (n_tty_ioctl): Support TIOCGSOFTCAR and
41 TIOCSSOFTCAR, so that device drivers don't have to support
42 it.
43
44 * serial.c (autoconfig): Change 16750 test to hopefully eliminate
45 false results by people with strange 16550As being
46 detected as 16750s. Hopefully 16750s will still be
47 detected as 16750, and other weird UARTs won't get poorly
48 autodetected. If this doesn't work, I'll have to disable
49 the auto identification for the 16750.
50
51 * tty_io.c (tty_hangup): Now actually do the tty hangup
52 processing during the timer processing, and disable
53 interrupts while doing the hangup processing. This avoids
54 several nasty race conditions which happened when the
55 hangup processing was done asynchronously.
56 (tty_ioctl): Do break handling in the tty driver if
57 driver's break function is supported.
58 (tty_flip_buffer_push): New exported function which should
59 be used by drivers to push characters in the flip buffer
60 to the tty handler. This may either be done using a task
61 queue function for better CPU efficiency, or directly for
62 low latency operation.
63
64 * serial.c (rs_set_termios): Fix bug rs_set_termios when
65 transitioning away from B0, submitted by Stanislav
66 Voronyi.
67
68Thu Jun 19 20:05:58 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
69
70 * serial.c (begin_break, end_break, rs_ioctl): Applied patch
71 to support BSD ioctls to set and clear the break
72 condition explicitly.
73
74 * console.c (scrup, scrdown, insert_line, delete_line): Applied
75 fix suggested by Aaron Tiensivu to speed up block scrolls
76 up and down.
77
78 * n_tty.c (opost_block, write_chan): Added a modified "fast
79 console" patch which processes a block of text via
80 "cooking" efficiently.
81
82Wed Jun 18 15:25:50 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
83
84 * tty_io.c (init_dev, release_dev): Applied fix suggested by Bill
85 Hawes to prevent race conditions in the tty code.
86
87 * n_tty.c (n_tty_chars_in_buffer): Applied fix suggested by Bill
88 Hawes so that n_tty_chars_in_buffer returns the correct
89 value in the case when the tty is in cannonical mode. (To
90 avoid a pty deadlock with telnetd.)
91
92Thu Feb 27 01:53:08 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
93
94 * serial.c (change_speed): Add support for the termios flag
95 CMSPAR, which allows the user to select stick parity.
96 (i.e, if PARODD is set, the parity bit is always 1; if
97 PARRODD is not set, then the parity bit is always 0).
98
99Wed Feb 26 19:03:10 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
100
101 * serial.c (cleanup_module): Fix memory leak when using the serial
102 driver as a module; make sure tmp_buf gets freed!
103
104Tue Feb 25 11:01:59 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
105
106 * serial.c (set_modem_info): Add support for setting and clearing
107 the OUT1 and OUT2 bits. (For special case UART's, usually
108 for half-duplex.)
109 (autoconfig, change_speed): Fix TI 16750 support.
110
111Sun Feb 16 00:14:43 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
112
113 * tty_io.c (release_dev): Add sanity check to make sure there are
114 no waiters on tty->read_wait or tty->write_wait.
115
116 * serial.c (rs_init): Don't autoconfig a device if the I/O region
117 is already reserved.
118
119 * serial.c (serial_proc_info): Add support for /proc/serial.
120
121Thu Feb 13 00:49:10 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
122
123 * serial.c (receive_chars): When the UART repotrs an overrun
124 condition, it does so with a valid character. Changed to
125 not throw away the valid character, but instead report the
126 overrun after the valid character.
127
128 * serial.c: Added new #ifdef's for some of the advanced serial
129 driver features. A minimal driver that only supports COM
130 1/2/3/4 without sharing serial interrupts only takes 17k;
131 the full driver takes 32k.
132
133Wed Feb 12 14:50:44 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
134
135 * vt.c:
136 * pty.c:
137 * tty_ioctl.c:
138 * serial.c: Update routines to use the new 2.1 memory access
139 routines.
140
141Wed Dec 4 07:51:52 1996 Theodore Ts'o <tytso@localhost.mit.edu>
142
143 * serial.c (change_speed): Use save_flags(); cli() and
144 restore_flags() in order to ensure we don't accidentally
145 turn on interrupts when starting up the port.
146 (startup): Move the insertion of serial structure into the
147 IRQ chain earlier into the startup processing. Interrupts
148 should be off this whole time, but we eventually will want
149 to reduce this window.
150
151Thu Nov 21 10:05:22 1996 Theodore Ts'o <tytso@localhost.mit.edu>
152
153 * tty_ioctl.c (tty_wait_until_sent): Always check the driver
154 wait_until_ready routine, even if there are no characters
155 in the xmit buffer. (There may be charactes in the device
156 FIFO.)
157 (n_tty_ioctl): Add new flag tty->flow_stopped which
158 indicates whether the tty is stopped due to a request by
159 the TCXONC ioctl (used by tcflow). If so, don't let an
160 incoming XOFF character restart the tty. The tty can only
161 be restarted by another TCXONC request.
162
163 * tty_io.c (start_tty): Don't allow the tty to be restarted if
164 tty->flow_stopped is true.
165
166 * n_tty.c (n_tty_receive_char): If tty->flow_stopped is true, and
167 IXANY is set, don't eat a character trying to restart the
168 tty.
169
170 * serial.c (startup): Remove need for MCR_noint from the
171 async_struct structure. Only turn on DTR and RTS if the
172 baud rate is not zero.
173 (change_speed): More accurately calculate the timeout
174 value based on the word size. Move responsibility of
175 hangup when speed becomes B0 to rs_set_termios()
176 (set_serial_info): When changing the UART type set the
177 current xmit_fifo_size as well as the permanent
178 xmit_fifo_size.
179 (rs_ioctl): Fix TCSBRK (used by tcdrain) and TCSBRKP
180 ioctls to return EINTR if interrupted by a signal.
181 (rs_set_termios): If the baud rate changes to or from B0,
182 this function is now responsible for setting or clearing
183 DTR and RTS. DTR and RTS are only be changed on the
184 transition to or from the B0 state.
185 (rs_close): Wait for the characters to drain based on
186 info->timeout. At low baud rates (50 bps), it may take a
187 long time for the FIFO to completely drain out!
188 (rs_wait_until_sent): Fixed timeout handling. Now
189 releases control to the scheduler, but checks frequently
190 enough so that the function is sensitive enough to pass
191 the timing requirements of the NIST-PCTS.
192 (block_til_ready): When opening the device, don't turn on
193 DTR and RTS if the baud rate is B0.
194
195Thu Nov 14 00:06:09 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
196
197 * serial.c (autoconfig): Fix autoconfiguration problems;
198 info->flags wasn't getting initialized from the state
199 structure. Put in more paranoid test for the 16750.
200
201Fri Nov 8 20:19:50 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
202
203 * n_tty.c (n_tty_flush_buffer): Only call driver->unthrottle() if
204 the tty was previous throttled.
205 (n_tty_set_termios, write_chan): Add changes suggested by
206 Simon P. Allen to allow hardware cooking.
207
208 * tty_ioctl.c (set_termios): If we get a signal while waiting for
209 the tty to drain, return -EINTR.
210
211 * serial.c (change_speed): Add support for CREAD, as required by
212 POSIX.
213
214Sat Nov 2 20:43:10 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
215
216 * serial.c: Wholesale changes. Added support for the Startech
217 16650 and 16650V2 chips. (WARNING: the new startech
218 16650A may or may not work!) Added support for the
219 TI16750 (not yet tested). Split async_struct into a
220 transient part (async_struct) and a permanent part
221 (serial_state) which contains the configuration
222 information for the ports. Added new driver routines
223 wait_until_sent() and send_xchar() to help with POSIX
224 compliance. Added support for radio clocks which waggle
225 the carrier detect line (CONFIG_HARD_PPS).
226
227 * tty_ioctl.c (tty_wait_until_sent): Added call to new driver
228 function tty->driver.wait_until_sent(), which returns when
229 the tty's device xmit buffers are drained. Needed for
230 full POSIX compliance.
231
232 (send_prio_char): New function, called by the ioctl's
233 TCIOFF and TCION; uses the new driver call send_xchar(),
234 which will send the XON or XOFF character at high priority
235 (and even if tty output is stopped).
236
237Wed Jun 5 18:52:04 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
238
239 * pty.c (pty_close): When closing a pty, make sure packet mode is
240 cleared.
241
242Sun May 26 09:33:52 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
243
244 * vesa_blank.c (set_vesa_blanking): Add missing verify_area() call.
245
246 * selection.c (set_selection): Add missing verify_area() call.
247
248 * tty_io.c (tty_ioctl): Add missing verify_area() calls.
249
250 * serial.c (rs_ioctl): Add missing verify_area() calls.
251 (rs_init): Allow initialization of serial driver
252 configuration from a module.
253
254 * random.c (extract_entropy): Add missing verify_area call.
255 Don't limit number of characters returned to
256 32,768. Extract entropy is now no longer a inlined
257 function.
258
259 (random_read): Check return value in case extract_entropy
260 returns an error.
261
262 (secure_tcp_sequence_number): New function which returns a
263 secure TCP sequence number. This is needed to prevent some
264 nasty TCP hijacking attacks.
265
266 (init_std_data): Initialize using gettimeofday() instead of
267 struct timeval xtime.
268
269 (fast_add_entropy_word, add_entropy_word): Rename the
270 inline function add_entropy_word() to
271 fast_add_entropy_word(). Make add_entropy_word() be the
272 non-inlined function which is used in non-timing critical
273 places, in order to save space.
274
275 (initialize_benchmark, begin_benchmark, end_benchmark): New
276 functions defined when RANDOM_BENCHMARK is defined. They
277 allow us to benchmark the speed of the
278 add_timer_randomness() call.
279
280 (int_ln, rotate_left): Add two new inline functions with
281 i386 optimized asm instructions. This speeds up the
282 critical add_entropy_word() and add_timer_randomness()
283 functions, which are called from interrupt handlers.
284
285Tue May 7 22:51:11 1996 <tytso@rsts-11.mit.edu>
286
287 * random.c (add_timer_randomness): Limit the amount randomness
288 that we estimate to 12 bits. (An arbitrary amount).
289
290 (extract_entropy): To make it harder to analyze the hash
291 function, fold the hash function in half using XOR, and
292 use the folded result as the value to emit to the user.
293 Also, add timer randomness each pass through the
294 exact_entropy call, to increase the amount of unknown
295 values during the extraction process.
296
297 (random_ioctl): Use IOR/IOW definitions to define the
298 ioctl values used by the /dev/random driver. Allow the
299 old ioctl values to be used for backwards compatibility
300 (for a limited amount of time).
301
302Wed Apr 24 14:02:04 1996 Theodore Ts'o <tytso@rsts-11.mit.edu>
303
304 * random.c (add_timer_randomness): Use 2nd derivative as well to
305 better estimate entropy.
306
307 (rand_initialize): Explicitly initialize all the pointers
308 to NULL. (Clearing pointers using memset isn't portable.)
309 Initialize the random pool with OS-dependent data.
310
311 (random_write): Add sanity checking to the arguments to
312 random_write(), so that bad arguments won't cause a kernel
313 SEGV.
314
315 (random_read): Update the access time of the device inode
316 when you return data to the user.
317
318 (random_ioctl): Wake up the random_wait channel when there
319 are only WAIT_INPUT_BITS available. Add more paranoia
320 checks to make sure entropy_count doesn't go beyond the
321 bounds of (0, POOLSIZE). Add a few missing verify_area
322 checks. Add support for the RNDCLEARPOOL ioctl, which
323 zaps the random pool.
324
325 (add_timer_randomness): Wake up the random_wait
326 channel only when there are WAIT_INPUT_BITS available.
327
328 (random_select): Allow a random refresh daemon process to
329 select on /dev/random for writing; wake up the daemon when
330 there are less than WAIT_OUTPUT_BITS bits of randomness
331 available.
332
333Tue Apr 23 22:56:07 1996 <tytso@rsts-11.mit.edu>
334
335 * tty_io.c (init_dev): Change return code when user attempts to
336 open master pty which is already open from EAGAIN to EIO,
337 to match with BSD expectations. EIO is more correct
338 anyway, since EAGAIN implies that retrying will be
339 successful --- which it might be.... Eventually!!
340
341 * pty.c (pty_open, pty_close): Fix wait loop so that we don't
342 busy loop while waiting for the master side to open.
343 Fix tty opening/closing logic. TTY_SLAVE_CLOSED was
344 renamed to TTY_OTHER_CLOSED, so that the name is more
345 descriptive. Also fixed code so that the tty flag
346 actually works correctly now....
347
348Mon Apr 1 10:22:01 1996 <tytso@rsts-11.mit.edu>
349
350 * serial.c (rs_close): Cleaned up modularization changes.
351 Remove code which forced line discipline back to N_TTY
352 this is done in the tty upper layers, and there's no
353 reason to do it here. (Making this change also
354 removed the requirement that the serial module access
355 the internal kernel symbol "ldiscs".)
356
357 * tty_io.c (tty_init): Formally register a tty_driver entry for
358 /dev/tty (device 4, 0) and /dev/console (device 5, 0).
359 This guarantees that major device numbers 4 and 5 will be
360 reserved for the tty subsystem (as they have to be because
361 of /dev/tty and /dev/console). Removed tty_regdev, as
362 this interface is no longer necessary.
363
364Sun Mar 17 20:42:47 GMT 1996 <ah@doc.ic.ac.uk>
365
366 * serial.c : modularisation (changes in linux/fs/device.c allow
367 kerneld to automatically load the serial module).
368
369 * Makefile, Config.in : serial modularisation adds.
370
371 * tty_io.c : tty_init_ctty used by to register "cua" driver just
372 for the /dev/tty device (5,0). Added tty_regdev.
373
374 * serial.c (shutdown, rs_ioctl) : when port shuts down wakeup processes
375 waiting on delta_msr_wait. The TIOCMIWAIT ioctl returns EIO
376 if no change was done since the time of call.
377
378Sat Mar 16 14:33:13 1996 <aeb@cwi.nl>
379
380 * tty_io.c (disassociate_ctty): If disassociate_ctty is called by
381 exit, do not perform an implicit vhangup on a pty.
382
383Fri Feb 9 14:15:47 1996 <tytso@rsts-11.mit.edu>
384
385 * serial.c (block_til_ready): Fixed another race condition which
386 happens if a hangup happens during the open.
387
388Wed Jan 10 10:08:00 1996 <tytso@rsts-11.mit.edu>
389
390 * serial.c (block_til_ready): Remove race condition which happened
391 if a hangup condition happened during the setup of the
392 UART, before rs_open() called block_til_ready(). This
393 caused the info->count counter to be erroneously
394 decremented.
395
396 * serial.c (startup, rs_open): Remove race condition that could
397 cause a memory leak of one page. (Fortunately, both race
398 conditions were relatively rare in practice.)
399
400Tue Dec 5 13:21:27 1995 <tytso@rsts-11.mit.edu>
401
402 * serial.c (check_modem_status, rs_ioctl): Support the new
403 ioctl()'s TIOCGICOUNT, TIOCMIWAIT. These allow an
404 application program to wait on a modem serial register
405 status bit change, and to find out how many changes have
406 taken place for the MSR bits.
407
408 (rs_write): Eliminate a race condition which is introduced
409 if it is necessary to wait for the semaphore.
410
411Sat Nov 4 17:14:45 1995 <tytso@rsts-11.mit.edu>
412
413 * tty_io.c (tty_init): Move registration of TTY_MAJOR and
414 TTY_AUX_MAJOR to the end, so that /proc/devices looks
415 prettier.
416
417 * pty.c (pty_init): Use new major numbers for PTY master and slave
418 devices. This allow us to have more than 64 pty's. We
419 register the old pty devices for backwards compatibility.
420 Note that a system should either be using the old pty
421 devices or the new pty devices --- in general, it should
422 try to use both, since they map into the same pty table.
423 The old pty devices are strictly for backwards compatibility.
424
425Wed Oct 11 12:45:24 1995 <tytso@rsts-11.mit.edu>
426
427 * tty_io.c (disassociate_ctty): If disassociate_ctty is called by
428 exit, perform an implicit vhangup on the tty.
429
430 * pty.c (pty_close): When the master pty is closed, send a hangup
431 to the slave pty.
432 (pty_open): Use the flag TTY_SLAVE_CLOSED to test to see
433 if there are any open slave ptys, instead of using
434 tty->link->count. The old method got confused if there
435 were processes that had hung-up file descriptors on the
436 slave tty.
437
438Tue May 2 00:53:25 1995 <tytso@rsx-11.mit.edu>
439
440 * tty_io.c (tty_set_ldisc): Wait until the output buffer is
441 drained before closing the old line discipline --- needed
442 in only one case: XON/XOFF processing.
443
444 * n_tty.c (n_tty_close): Don't bother waiting until the output
445 driver is closed; in general, the line discipline
446 shouldn't care if the hardware is finished
447 transmitting before the line discipline terminates.
448
449 * tty_io.c (release_dev): Shutdown the line discipline after
450 decrementing the tty count variable; but set the
451 TTY_CLOSING flag so that we know that this tty structure
452 isn't long for this world.
453
454 * tty_io.c (init_dev): Add sanity code to check to see if
455 TTY_CLOSING is set on a tty structure; if so, something
456 bad has happened (probably a line discipline close blocked
457 when it shouldn't have; so do a kernel printk and then
458 return an error).
459
460Wed Apr 26 10:23:44 1995 Theodore Y. Ts'o <tytso@localhost>
461
462 * tty_io.c (release_dev): Try to shutdown the line discipline
463 *before* decrementing the tty count variable; this removes
464 a potential race condition which occurs when the line
465 discipline close blocks, and another process then tries
466 open the same serial port.
467
468 * serial.c (rs_hangup): When hanging up, flush the output buffer
469 before shutting down the UART. Otherwise the line
470 discipline close blocks waiting for the characters to get
471 flushed, which never happens until the serial port gets reused.
472
473Wed Apr 12 08:06:16 1995 Theodore Y. Ts'o <tytso@localhost>
474
475 * serial.c (do_serial_hangup, do_softint, check_modem_status,
476 rs_init): Hangups are now scheduled via a separate tqueue
477 structure in the async_struct structure, tqueue_hangup.
478 This task is pushed on to the tq_schedule queue, so that
479 it is processed synchronously by the scheduler.
480
481Sat Feb 18 12:13:51 1995 Theodore Y. Ts'o (tytso@rt-11)
482
483 * tty_io.c (disassociate_ctty, tty_open, tty_ioctl): Clear
484 current->tty_old_pgrp field when a session leader
485 acquires a controlling tty, and after a session leader
486 has disassociated from a controlling tty.
487
488Fri Feb 17 09:34:09 1995 Theodore Y. Ts'o (tytso@rt-11)
489
490 * serial.c (rs_interrupt_single, rs_interrupt, rs_interrupt_multi):
491 Change the number of passes made from 64 to be 256,
492 configurable with the #define RS_ISR_PASS_LIMIT.
493
494 * serial.c (rs_init, set_serial_info, get_serial_info, rs_close):
495 Remove support for closing_wait2. Instead, set
496 tty->closing and rely on the line discipline to prevent
497 echo wars.
498
499 * n_tty.c (n_tty_receive_char): IEXTEN does not need to be
500 enabled in order for IXANY to be active.
501
502 If tty->closing is set, then only process XON and XOFF
503 characters.
504
505Sun Feb 12 23:57:48 1995 Theodore Y. Ts'o (tytso@rt-11)
506
507 * serial.c (rs_timer): Change the interrupt poll time from 60
508 seconds to 10 seconds, configurable with the #define
509 RS_STROBE_TIME.
510
511 * serial.c (rs_interrupt_multi, startup, shutdown, rs_ioctl,
512 set_multiport_struct, get_multiport_struct): Add
513 provisions for a new type of interrupt service routine,
514 which better supports multiple serial ports on a single
515 IRQ.
516
517Sun Feb 5 19:35:11 1995 Theodore Y. Ts'o (tytso@rt-11)
518
519 * tty_ioctl.c (n_tty_ioctl, set_termios, tty_wait_until_sent):
520 * serial.c (rs_ioctl, rs_close):
521 * cyclades.c (cy_ioctl, cy_close):
522 * n_tty.c (n_tty_close): Rename wait_until_sent to
523 tty_wait_until_sent, so that it's a better name to export
524 in ksyms.c.
525
526Sat Feb 4 23:36:20 1995 Theodore Y. Ts'o (tytso@rt-11)
527
528 * serial.c (rs_close): Added missing check for closing_wait2 being
529 ASYNC_CLOSING_WAIT_NONE.
530
531Thu Jan 26 09:02:49 1995 Theodore Y. Ts'o (tytso@rt-11)
532
533 * serial.c (rs_init, set_serial_info, get_serial_info,
534 rs_close): Support close_wait in the serial driver.
535 This is helpful for slow devices (like serial
536 plotters) so that their outputs don't get flushed upon
537 device close. This has to be configurable because
538 normally we don't want ports to be hung up for long
539 periods of time during a close when they are not
540 connected to a device, or the device is powered off.
541
542 The default is to wait 30 seconds; in the case of a
543 very slow device, the close_wait timeout should be
544 lengthened. If it is set to 0, the kernel will wait
545 forever for all of the data to be transmitted.
546
547Thu Jan 17 01:17:20 1995 Theodore Y. Ts'o (tytso@rt-11)
548
549 * serial.c (startup, change_speed, rs_init): Add support to detect
550 the StarTech 16650 chip. Treat it as a 16450 for now,
551 because of its FIFO bugs.
552
553Thu Jan 5 21:21:57 1995 <dahinds@users.sourceforge.net>
554
555 * serial.c: (receive_char): Added counter to prevent infinite loop
556 when a PCMCIA serial device is ejected.
557
558Thu Dec 29 17:53:48 1994 <tytso@rsx-11.mit.edu>
559
560 * tty_io.c (check_tty_count): New procedure which checks
561 tty->count to make sure that it matches with the number of
562 open file descriptors which point at the structure. If
563 the number doesn't match, it prints a warning message.
564
565Wed Dec 28 15:41:51 1994 <tytso@rsx-11.mit.edu>
566
567 * tty_io.c (do_tty_hangup, disassociate_ctty): At hangup time,
568 save the tty's current foreground process group in the
569 session leader's task structure. When the session leader
570 terminates, send a SIGHUP, SIGCONT to that process group.
571 This is not required by POSIX, but it's not prohibited
572 either, and it appears to be the least intrusive way
573 to fix a problem that dialup servers have with
574 orphaned process groups caused by modem hangups.
575
576Thu Dec 8 14:52:11 1994 <tytso@rsx-11.mit.edu>
577
578 * serial.c (rs_ioctl): Don't allow most ioctl's if the serial port
579 isn't initialized.
580
581 * serial.c (rs_close): Don't clear the IER if the serial port
582 isn't initialized.
583
584 * serial.c (block_til_ready): Don't try to block on the dialin
585 port if the serial port isn't initialized.
586
587Wed Dec 7 10:48:30 1994 Si Park (si@wimpol.demon.co.uk)
588 * tty_io.c (tty_register_driver): Fix bug when linking onto
589 the tty_drivers list. We now test that there are elements
590 already on the list before setting the back link from the
591 first element to the new driver.
592
593 * tty_io.c (tty_unregister_driver): Fix bug in unlinking the
594 specified driver from the tty_drivers list. We were not
595 setting the back link correctly. This used to result in
596 a dangling back link pointer and cause panics on the next
597 call to get_tty_driver().
598
599Tue Nov 29 10:21:09 1994 Theodore Y. Ts'o (tytso@rt-11)
600
601 * tty_io.c (tty_unregister_driver): Fix bug in
602 tty_unregister_driver where the pointer to the refcount is
603 tested, instead of the refcount itself. This caused
604 tty_unregister_driver to always return EBUSY.
605
606Sat Nov 26 11:59:24 1994 Theodore Y. Ts'o (tytso@rt-11)
607
608 * tty_io.c (tty_ioctl): Add support for the new ioctl
609 TIOCTTYGSTRUCT, which allow a kernel debugging program
610 direct read access to the tty and tty_driver structures.
611
612Fri Nov 25 17:26:22 1994 Theodore Y. Ts'o (tytso@rt-11)
613
614 * serial.c (rs_set_termios): Don't wake up processes blocked in
615 open when the CLOCAL flag changes, since a blocking
616 open only samples the CLOCAL flag once when it blocks,
617 and doesn't check it again. (n.b. FreeBSD has a
618 different behavior for blocking opens; it's not clear
619 whether Linux or FreeBSD's interpretation is correct.
620 POSIX doesn't give clear guidance on this issue, so
621 this may change in the future....)
622
623 * serial.c (block_til_ready): Use the correct termios structure to
624 check the CLOCAL flag. If the cuaXX device is active,
625 then check the saved termios for the ttySXX device.
626 Otherwise, use the currently active termios structure.
627
628Sun Nov 6 21:05:44 1994 Theodore Y. Ts'o (tytso@rt-11)
629
630 * serial.c (change_speed): Add support for direct access of
631 57,600 and 115,200 bps.
632
633Wed Nov 2 10:32:36 1994 Theodore Y. Ts'o (tytso@rt-11)
634
635 * n_tty.c (n_tty_receive_room): Only allow excess characters
636 through if we are in ICANON mode *and* there are other no
637 pending lines in the buffer. Otherwise cut and paste over
638 4k breaks.
639
640Sat Oct 29 18:17:34 1994 Theodore Y. Ts'o (tytso@rt-11)
641
642 * serial.c (rs_ioctl, get_lsr_info): Added patch suggested by Arne
643 Riiber so that user mode programs can tell when the
644 transmitter shift register is empty.
645
646Thu Oct 27 23:14:29 1994 Theodore Y. Ts'o (tytso@rt-11)
647
648 * tty_ioctl.c (wait_until_sent): Added debugging printk statements
649 (under the #ifdef TTY_DEBUG_WAIT_UNTIL_SENT)
650
651 * serial.c (rs_interrupt, rs_interrupt_single, receive_chars,
652 change_speed, rs_close): rs_close now disables receiver
653 interrupts when closing the serial port. This allows the
654 serial port to close quickly when Linux and a modem (or a
655 mouse) are engaged in an echo war; when closing the serial
656 port, we now first stop listening to incoming characters,
657 and *then* wait for the transmit buffer to drain.
658
659 In order to make this change, the info->read_status_mask
660 is now used to control what bits of the line status
661 register are looked at in the interrupt routine in all
662 cases; previously it was only used in receive_chars to
663 select a few of the status bits.
664
665Mon Oct 24 23:36:21 1994 Theodore Y. Ts'o (tytso@rt-11)
666
667 * serial.c (rs_close): Add a timeout to the transmitter flush
668 loop; this is just a sanity check in case we have flaky
669 (or non-existent-but-configured-by-the-user) hardware.
670
671Fri Oct 21 09:37:23 1994 Theodore Y. Ts'o (tytso@rt-11)
672
673 * tty_io.c (tty_fasync): When asynchronous I/O is enabled, if the
674 process or process group has not be specified yet, set it
675 to be the tty's process group, or if that is not yet set,
676 to the current process's pid.
677
678Thu Oct 20 23:17:28 1994 Theodore Y. Ts'o (tytso@rt-11)
679
680 * n_tty.c (n_tty_receive_room): If we are doing input
681 canonicalization, let as many characters through as
682 possible, so that the excess characters can be "beeped".
683
684Tue Oct 18 10:02:43 1994 Theodore Y. Ts'o (tytso@rt-11)
685
686 * serial.c (rs_start): Removed an incorrect '!' that was
687 preventing transmit interrupts from being re-enabled in
688 rs_start(). Fortunately in most cases it would be
689 re-enabled elsewhere, but this still should be fixed
690 correctly.
691
692Sun Oct 9 23:46:03 1994 Theodore Y. Ts'o (tytso@rt-11)
693
694 * tty_io.c (do_tty_hangup): If the tty driver flags
695 TTY_DRIVER_RESET_TERMIOS is set, then reset the termios
696 settings back to the driver's initial configuration. This
697 allows the termios settings to be reset even if a process
698 has hung up file descriptors keeping a pty's termios from
699 being freed and reset.
700
701 * tty_io.c (release_dev): Fix memory leak. The pty's other
702 termios structure should also be freed.
703
704 * serial.c (rs_close, shutdown): Change how we wait for the
705 transmitter to completely drain before shutting down the
706 serial port. We now do it by scheduling in another
707 process instead of busy looping with the interrupts turned
708 on. This may eliminate some race condition problems that
709 some people seem to be reporting.
710
711Sun Sep 25 14:18:14 1994 Theodore Y. Ts'o (tytso@rt-11)
712
713 * tty_io.c (release_dev): When freeing a tty make sure that both
714 the tty and the o_tty (if present) aren't a process's
715 controlling tty. (Previously, we only checked the tty.)
716
717 * serial.c (change_speed): Only enable the Modem Status
718 Interrupt for a port if CLOCAL is not set or CRTSCTS
719 is set. If we're not checking the carrier detect and
720 CTS line, there's no point in enabling the modem
721 status interrupt. This will save spurious interrupts
722 from slowing down systems who have terminals that
723 don't support either line. (Of course, if you want
724 only one of CD and CTS support, you will need a
725 properly wired serial cable.)
726
727Thu Sep 22 08:32:48 1994 Theodore Y. Ts'o (tytso@rt-11)
728
729 * tty_io.c (do_SAK): Return if tty is null.
730
731 * tty_io.c (_tty_name): Return "NULL tty" if the passed in tty is
732 NULL.
733
734Sat Sep 17 13:19:25 1994 Theodore Y. Ts'o (tytso@rt-11)
735
736 * tty_ioctl.c (n_tty_ioctl): Fix TIOCGLCKTRMIOS and
737 TIOCSLCKTRMIOS, which were totally broken. Remove
738 extra indirection from argument; it should be a struct
739 termios *, not a struct termios **.
740 &real_tty->termios_locked should have been
741 real_tty->termios_locked. This caused us to be
742 reading and writing the termios_locked structure to
743 random places in kernel memory.
744
745 * tty_io.c (release_dev): Oops! Forgot to delete a critical kfree
746 of the locked_termios. This leaves the locked_termios
747 structure pointed at a freed object.
748
749Fri Sep 16 08:13:25 1994 Theodore Y. Ts'o (tytso@rt-11)
750
751 * tty_io.c (tty_open): Don't check for an exclusive open until
752 after the device specific open routine has been called.
753 Otherwise, the serial device ref counting will be screwed
754 up.
755
756 * serial.c (rs_open, block_til_ready): Don't set termios structure
757 until after block_til_ready has returned successfully.
758 Modify block_til_ready to check the normal_termios
759 structure directly, so it doesn't rely on termios being
760 set before it's called.
761
762Thu Sep 15 23:34:01 1994 Theodore Y. Ts'o (tytso@rt-11)
763
764 * serial.c (rs_close): Turn off interrupts during rs_close() to
765 prevent a race condition with the hangup code (which
766 runs during a software interrupt).
767
768 * tty_io.c (release_dev): Don't free the locked_termios structure;
769 its state must be retained across device opens.
770
771
772 * tty_io.c (tty_unregister_driver): Added function to unregister a
773 tty driver. (For loadable device drivers.)
774
775
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index 2fb3a480f6b0..4b66c69eaf57 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -57,7 +57,7 @@ config AGP_AMD
57 57
58config AGP_AMD64 58config AGP_AMD64
59 tristate "AMD Opteron/Athlon64 on-CPU GART support" 59 tristate "AMD Opteron/Athlon64 on-CPU GART support"
60 depends on AGP && X86 60 depends on AGP && X86 && K8_NB
61 help 61 help
62 This option gives you AGP support for the GLX component of 62 This option gives you AGP support for the GLX component of
63 X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. 63 X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 73dbf40c874d..a7637d72cef6 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -6,9 +6,9 @@
6#include <linux/pci.h> 6#include <linux/pci.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/agp_backend.h> 8#include <linux/agp_backend.h>
9#include <linux/gfp.h>
10#include <linux/page-flags.h> 9#include <linux/page-flags.h>
11#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/slab.h>
12#include "agp.h" 12#include "agp.h"
13 13
14#define AMD_MMBASE 0x14 14#define AMD_MMBASE 0x14
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index c3ab46da51a3..ee4f855611b6 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/slab.h>
33#include <linux/pagemap.h> 34#include <linux/pagemap.h>
34#include <linux/miscdevice.h> 35#include <linux/miscdevice.h>
35#include <linux/pm.h> 36#include <linux/pm.h>
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
index 58c57cb2518c..9d2c97a69cdd 100644
--- a/drivers/char/agp/compat_ioctl.c
+++ b/drivers/char/agp/compat_ioctl.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/agpgart.h> 32#include <linux/agpgart.h>
33#include <linux/slab.h>
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
34#include "agp.h" 35#include "agp.h"
35#include "compat_ioctl.h" 36#include "compat_ioctl.h"
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index c50543966eb2..fb86708e47ed 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -38,6 +38,7 @@
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/slab.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/cacheflush.h> 43#include <asm/cacheflush.h>
43#include <asm/pgtable.h> 44#include <asm/pgtable.h>
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 58752b70efea..056b289a1e89 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/agp_backend.h> 16#include <linux/agp_backend.h>
17#include <linux/log2.h> 17#include <linux/log2.h>
18#include <linux/slab.h>
18 19
19#include <asm/acpi-ext.h> 20#include <asm/acpi-ext.h>
20 21
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 919a28558d36..aa4248efc5d8 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/pci.h> 6#include <linux/pci.h>
7#include <linux/slab.h>
7#include <linux/init.h> 8#include <linux/init.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
9#include <linux/pagemap.h> 10#include <linux/pagemap.h>
@@ -97,6 +98,9 @@ EXPORT_SYMBOL(intel_agp_enabled);
97#define IS_PINEVIEW (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB || \ 98#define IS_PINEVIEW (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB || \
98 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_HB) 99 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_HB)
99 100
101#define IS_SNB (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || \
102 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB)
103
100#define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_EAGLELAKE_HB || \ 104#define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_EAGLELAKE_HB || \
101 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \ 105 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \
102 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \ 106 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \
@@ -107,8 +111,7 @@ EXPORT_SYMBOL(intel_agp_enabled);
107 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || \ 111 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || \
108 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB || \ 112 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB || \
109 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB || \ 113 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB || \
110 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || \ 114 IS_SNB)
111 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB)
112 115
113extern int agp_memory_reserved; 116extern int agp_memory_reserved;
114 117
@@ -175,6 +178,10 @@ extern int agp_memory_reserved;
175#define SNB_GMCH_GMS_STOLEN_448M (0xe << 3) 178#define SNB_GMCH_GMS_STOLEN_448M (0xe << 3)
176#define SNB_GMCH_GMS_STOLEN_480M (0xf << 3) 179#define SNB_GMCH_GMS_STOLEN_480M (0xf << 3)
177#define SNB_GMCH_GMS_STOLEN_512M (0x10 << 3) 180#define SNB_GMCH_GMS_STOLEN_512M (0x10 << 3)
181#define SNB_GTT_SIZE_0M (0 << 8)
182#define SNB_GTT_SIZE_1M (1 << 8)
183#define SNB_GTT_SIZE_2M (2 << 8)
184#define SNB_GTT_SIZE_MASK (3 << 8)
178 185
179static const struct aper_size_info_fixed intel_i810_sizes[] = 186static const struct aper_size_info_fixed intel_i810_sizes[] =
180{ 187{
@@ -298,7 +305,7 @@ static void intel_agp_insert_sg_entries(struct agp_memory *mem,
298 j++; 305 j++;
299 } 306 }
300 } else { 307 } else {
301 /* sg may merge pages, but we have to seperate 308 /* sg may merge pages, but we have to separate
302 * per-page addr for GTT */ 309 * per-page addr for GTT */
303 unsigned int len, m; 310 unsigned int len, m;
304 311
@@ -1200,6 +1207,9 @@ static void intel_i9xx_setup_flush(void)
1200 if (intel_private.ifp_resource.start) 1207 if (intel_private.ifp_resource.start)
1201 return; 1208 return;
1202 1209
1210 if (IS_SNB)
1211 return;
1212
1203 /* setup a resource for this object */ 1213 /* setup a resource for this object */
1204 intel_private.ifp_resource.name = "Intel Flush Page"; 1214 intel_private.ifp_resource.name = "Intel Flush Page";
1205 intel_private.ifp_resource.flags = IORESOURCE_MEM; 1215 intel_private.ifp_resource.flags = IORESOURCE_MEM;
@@ -1438,6 +1448,8 @@ static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
1438 1448
1439static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) 1449static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
1440{ 1450{
1451 u16 snb_gmch_ctl;
1452
1441 switch (agp_bridge->dev->device) { 1453 switch (agp_bridge->dev->device) {
1442 case PCI_DEVICE_ID_INTEL_GM45_HB: 1454 case PCI_DEVICE_ID_INTEL_GM45_HB:
1443 case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB: 1455 case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB:
@@ -1449,9 +1461,26 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
1449 case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB: 1461 case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB:
1450 case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB: 1462 case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB:
1451 case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB: 1463 case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB:
1464 *gtt_offset = *gtt_size = MB(2);
1465 break;
1452 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB: 1466 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB:
1453 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB: 1467 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB:
1454 *gtt_offset = *gtt_size = MB(2); 1468 *gtt_offset = MB(2);
1469
1470 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
1471 switch (snb_gmch_ctl & SNB_GTT_SIZE_MASK) {
1472 default:
1473 case SNB_GTT_SIZE_0M:
1474 printk(KERN_ERR "Bad GTT size mask: 0x%04x.\n", snb_gmch_ctl);
1475 *gtt_size = MB(0);
1476 break;
1477 case SNB_GTT_SIZE_1M:
1478 *gtt_size = MB(1);
1479 break;
1480 case SNB_GTT_SIZE_2M:
1481 *gtt_size = MB(2);
1482 break;
1483 }
1455 break; 1484 break;
1456 default: 1485 default:
1457 *gtt_offset = *gtt_size = KB(512); 1486 *gtt_offset = *gtt_size = KB(512);
@@ -1788,8 +1817,6 @@ static int intel_845_configure(void)
1788 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1)); 1817 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1));
1789 /* clear any possible error conditions */ 1818 /* clear any possible error conditions */
1790 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c); 1819 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c);
1791
1792 intel_i830_setup_flush();
1793 return 0; 1820 return 0;
1794} 1821}
1795 1822
@@ -2159,7 +2186,6 @@ static const struct agp_bridge_driver intel_845_driver = {
2159 .agp_destroy_page = agp_generic_destroy_page, 2186 .agp_destroy_page = agp_generic_destroy_page,
2160 .agp_destroy_pages = agp_generic_destroy_pages, 2187 .agp_destroy_pages = agp_generic_destroy_pages,
2161 .agp_type_to_mask_type = agp_generic_type_to_mask_type, 2188 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2162 .chipset_flush = intel_i830_chipset_flush,
2163}; 2189};
2164 2190
2165static const struct agp_bridge_driver intel_850_driver = { 2191static const struct agp_bridge_driver intel_850_driver = {
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 7e36d2b4f9d4..10f24e349a26 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -8,7 +8,6 @@
8#include <linux/pci.h> 8#include <linux/pci.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/agp_backend.h> 10#include <linux/agp_backend.h>
11#include <linux/gfp.h>
12#include <linux/page-flags.h> 11#include <linux/page-flags.h>
13#include <linux/mm.h> 12#include <linux/mm.h>
14#include <linux/jiffies.h> 13#include <linux/jiffies.h>
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 0d426ae39c85..ffa888cd1c88 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -14,6 +14,7 @@
14#include <linux/acpi.h> 14#include <linux/acpi.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/agp_backend.h> 19#include <linux/agp_backend.h>
19#include <asm/sn/addrs.h> 20#include <asm/sn/addrs.h>
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index d89da4ac061f..6f48931ac1ce 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -3,6 +3,7 @@
3 */ 3 */
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/pci.h> 5#include <linux/pci.h>
6#include <linux/slab.h>
6#include <linux/init.h> 7#include <linux/init.h>
7#include <linux/pagemap.h> 8#include <linux/pagemap.h>
8#include <linux/agp_backend.h> 9#include <linux/agp_backend.h>
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 6c32fbf07164..56b27671adc4 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -2021,8 +2021,6 @@ static int __init rs_init(void)
2021 state->baud_base = amiga_colorclock; 2021 state->baud_base = amiga_colorclock;
2022 state->xmit_fifo_size = 1; 2022 state->xmit_fifo_size = 1;
2023 2023
2024 local_irq_save(flags);
2025
2026 /* set ISRs, and then disable the rx interrupts */ 2024 /* set ISRs, and then disable the rx interrupts */
2027 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state); 2025 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state);
2028 if (error) 2026 if (error)
@@ -2033,6 +2031,8 @@ static int __init rs_init(void)
2033 if (error) 2031 if (error)
2034 goto fail_free_irq; 2032 goto fail_free_irq;
2035 2033
2034 local_irq_save(flags);
2035
2036 /* turn off Rx and Tx interrupts */ 2036 /* turn off Rx and Tx interrupts */
2037 custom.intena = IF_RBF | IF_TBE; 2037 custom.intena = IF_RBF | IF_TBE;
2038 mb(); 2038 mb();
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index fe2cb2f5db17..a7424bf7eacf 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -14,7 +14,7 @@
14/* et passe en argument a acinit, mais est scrute sur le bus pour s'adapter */ 14/* et passe en argument a acinit, mais est scrute sur le bus pour s'adapter */
15/* au nombre de cartes presentes sur le bus. IOCL code 6 affichait V2.4.3 */ 15/* au nombre de cartes presentes sur le bus. IOCL code 6 affichait V2.4.3 */
16/* F.LAFORSE 28/11/95 creation de fichiers acXX.o avec les differentes */ 16/* F.LAFORSE 28/11/95 creation de fichiers acXX.o avec les differentes */
17/* adresses de base des cartes, IOCTL 6 plus complet */ 17/* addresses de base des cartes, IOCTL 6 plus complet */
18/* J.PAGET le 19/08/96 copie de la version V2.6 en V2.8.0 sans modification */ 18/* J.PAGET le 19/08/96 copie de la version V2.6 en V2.8.0 sans modification */
19/* de code autre que le texte V2.6.1 en V2.8.0 */ 19/* de code autre que le texte V2.6.1 en V2.8.0 */
20/*****************************************************************************/ 20/*****************************************************************************/
diff --git a/drivers/char/bfin_jtag_comm.c b/drivers/char/bfin_jtag_comm.c
index 2628c7415ea8..e397df3ad98e 100644
--- a/drivers/char/bfin_jtag_comm.c
+++ b/drivers/char/bfin_jtag_comm.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h>
24#include <linux/tty.h> 25#include <linux/tty.h>
25#include <linux/tty_driver.h> 26#include <linux/tty_driver.h>
26#include <linux/tty_flip.h> 27#include <linux/tty_flip.h>
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
index d8cff909001c..555cd93c2ee5 100644
--- a/drivers/char/briq_panel.c
+++ b/drivers/char/briq_panel.c
@@ -14,7 +14,6 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/wait.h> 15#include <linux/wait.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/slab.h>
18#include <linux/ioport.h> 17#include <linux/ioport.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index c02db01f736e..7fef305774de 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -27,6 +27,7 @@
27#include <linux/cdev.h> 27#include <linux/cdev.h>
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/slab.h>
30#include <asm/pgtable.h> 31#include <asm/pgtable.h>
31#include <asm/io.h> 32#include <asm/io.h>
32 33
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index b861c08263a4..9824b4162904 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -79,6 +79,7 @@
79#include <linux/bitops.h> 79#include <linux/bitops.h>
80#include <linux/firmware.h> 80#include <linux/firmware.h>
81#include <linux/device.h> 81#include <linux/device.h>
82#include <linux/slab.h>
82 83
83#include <linux/io.h> 84#include <linux/io.h>
84#include <linux/uaccess.h> 85#include <linux/uaccess.h>
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 85832ab924e6..8a1b28a10ef0 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -24,7 +24,6 @@
24 */ 24 */
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h> /* for kmalloc() and kfree() */
28#include <linux/major.h> 27#include <linux/major.h>
29#include <linux/types.h> 28#include <linux/types.h>
30#include <linux/errno.h> 29#include <linux/errno.h>
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 17b044a71e02..6f5ffe1320f7 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -36,7 +36,6 @@
36#include <linux/ctype.h> 36#include <linux/ctype.h>
37#include <linux/tty.h> 37#include <linux/tty.h>
38#include <linux/tty_flip.h> 38#include <linux/tty_flip.h>
39#include <linux/slab.h>
40#include <linux/smp_lock.h> 39#include <linux/smp_lock.h>
41#include <linux/ioport.h> 40#include <linux/ioport.h>
42#include <linux/interrupt.h> 41#include <linux/interrupt.h>
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index d400cbd280f2..5954ee1dc953 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -29,6 +29,7 @@
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/tty_flip.h> 30#include <linux/tty_flip.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/gfp.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33 34
34#define DEBUG 35#define DEBUG
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index e481c5938bad..9ded667625ac 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -31,6 +31,7 @@
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/bitops.h> 32#include <linux/bitops.h>
33#include <linux/clocksource.h> 33#include <linux/clocksource.h>
34#include <linux/slab.h>
34 35
35#include <asm/current.h> 36#include <asm/current.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
@@ -215,9 +216,7 @@ static void hpet_timer_set_irq(struct hpet_dev *devp)
215 else 216 else
216 v &= ~0xffff; 217 v &= ~0xffff;
217 218
218 for (irq = find_first_bit(&v, HPET_MAX_IRQ); irq < HPET_MAX_IRQ; 219 for_each_set_bit(irq, &v, HPET_MAX_IRQ) {
219 irq = find_next_bit(&v, HPET_MAX_IRQ, 1 + irq)) {
220
221 if (irq >= nr_irqs) { 220 if (irq >= nr_irqs) {
222 irq = HPET_MAX_IRQ; 221 irq = HPET_MAX_IRQ;
223 break; 222 break;
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 465185fc0f52..35cca4c7fb18 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -38,6 +38,7 @@
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/freezer.h> 40#include <linux/freezer.h>
41#include <linux/slab.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43 44
@@ -312,6 +313,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
312 spin_lock_irqsave(&hp->lock, flags); 313 spin_lock_irqsave(&hp->lock, flags);
313 /* Check and then increment for fast path open. */ 314 /* Check and then increment for fast path open. */
314 if (hp->count++ > 0) { 315 if (hp->count++ > 0) {
316 tty_kref_get(tty);
315 spin_unlock_irqrestore(&hp->lock, flags); 317 spin_unlock_irqrestore(&hp->lock, flags);
316 hvc_kick(); 318 hvc_kick();
317 return 0; 319 return 0;
@@ -319,7 +321,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
319 321
320 tty->driver_data = hp; 322 tty->driver_data = hp;
321 323
322 hp->tty = tty; 324 hp->tty = tty_kref_get(tty);
323 325
324 spin_unlock_irqrestore(&hp->lock, flags); 326 spin_unlock_irqrestore(&hp->lock, flags);
325 327
@@ -336,6 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
336 spin_lock_irqsave(&hp->lock, flags); 338 spin_lock_irqsave(&hp->lock, flags);
337 hp->tty = NULL; 339 hp->tty = NULL;
338 spin_unlock_irqrestore(&hp->lock, flags); 340 spin_unlock_irqrestore(&hp->lock, flags);
341 tty_kref_put(tty);
339 tty->driver_data = NULL; 342 tty->driver_data = NULL;
340 kref_put(&hp->kref, destroy_hvc_struct); 343 kref_put(&hp->kref, destroy_hvc_struct);
341 printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc); 344 printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc);
@@ -363,6 +366,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
363 return; 366 return;
364 367
365 hp = tty->driver_data; 368 hp = tty->driver_data;
369
366 spin_lock_irqsave(&hp->lock, flags); 370 spin_lock_irqsave(&hp->lock, flags);
367 371
368 if (--hp->count == 0) { 372 if (--hp->count == 0) {
@@ -389,6 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
389 spin_unlock_irqrestore(&hp->lock, flags); 393 spin_unlock_irqrestore(&hp->lock, flags);
390 } 394 }
391 395
396 tty_kref_put(tty);
392 kref_put(&hp->kref, destroy_hvc_struct); 397 kref_put(&hp->kref, destroy_hvc_struct);
393} 398}
394 399
@@ -424,10 +429,11 @@ static void hvc_hangup(struct tty_struct *tty)
424 spin_unlock_irqrestore(&hp->lock, flags); 429 spin_unlock_irqrestore(&hp->lock, flags);
425 430
426 if (hp->ops->notifier_hangup) 431 if (hp->ops->notifier_hangup)
427 hp->ops->notifier_hangup(hp, hp->data); 432 hp->ops->notifier_hangup(hp, hp->data);
428 433
429 while(temp_open_count) { 434 while(temp_open_count) {
430 --temp_open_count; 435 --temp_open_count;
436 tty_kref_put(tty);
431 kref_put(&hp->kref, destroy_hvc_struct); 437 kref_put(&hp->kref, destroy_hvc_struct);
432 } 438 }
433} 439}
@@ -592,7 +598,7 @@ int hvc_poll(struct hvc_struct *hp)
592 } 598 }
593 599
594 /* No tty attached, just skip */ 600 /* No tty attached, just skip */
595 tty = hp->tty; 601 tty = tty_kref_get(hp->tty);
596 if (tty == NULL) 602 if (tty == NULL)
597 goto bail; 603 goto bail;
598 604
@@ -672,6 +678,8 @@ int hvc_poll(struct hvc_struct *hp)
672 678
673 tty_flip_buffer_push(tty); 679 tty_flip_buffer_push(tty);
674 } 680 }
681 if (tty)
682 tty_kref_put(tty);
675 683
676 return poll_mask; 684 return poll_mask;
677} 685}
@@ -807,7 +815,7 @@ int hvc_remove(struct hvc_struct *hp)
807 struct tty_struct *tty; 815 struct tty_struct *tty;
808 816
809 spin_lock_irqsave(&hp->lock, flags); 817 spin_lock_irqsave(&hp->lock, flags);
810 tty = hp->tty; 818 tty = tty_kref_get(hp->tty);
811 819
812 if (hp->index < MAX_NR_HVC_CONSOLES) 820 if (hp->index < MAX_NR_HVC_CONSOLES)
813 vtermnos[hp->index] = -1; 821 vtermnos[hp->index] = -1;
@@ -819,18 +827,18 @@ int hvc_remove(struct hvc_struct *hp)
819 /* 827 /*
820 * We 'put' the instance that was grabbed when the kref instance 828 * We 'put' the instance that was grabbed when the kref instance
821 * was initialized using kref_init(). Let the last holder of this 829 * was initialized using kref_init(). Let the last holder of this
822 * kref cause it to be removed, which will probably be the tty_hangup 830 * kref cause it to be removed, which will probably be the tty_vhangup
823 * below. 831 * below.
824 */ 832 */
825 kref_put(&hp->kref, destroy_hvc_struct); 833 kref_put(&hp->kref, destroy_hvc_struct);
826 834
827 /* 835 /*
828 * This function call will auto chain call hvc_hangup. The tty should 836 * This function call will auto chain call hvc_hangup.
829 * always be valid at this time unless a simultaneous tty close already
830 * cleaned up the hvc_struct.
831 */ 837 */
832 if (tty) 838 if (tty) {
833 tty_hangup(tty); 839 tty_vhangup(tty);
840 tty_kref_put(tty);
841 }
834 return 0; 842 return 0;
835} 843}
836EXPORT_SYMBOL_GPL(hvc_remove); 844EXPORT_SYMBOL_GPL(hvc_remove);
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c
index fd0242676a2a..21c54955084e 100644
--- a/drivers/char/hvc_iseries.c
+++ b/drivers/char/hvc_iseries.c
@@ -353,7 +353,7 @@ static void hvc_close_event(struct HvLpEvent *event)
353 353
354 if (!hvlpevent_is_int(event)) { 354 if (!hvlpevent_is_int(event)) {
355 printk(KERN_WARNING 355 printk(KERN_WARNING
356 "hvc: got unexpected close acknowlegement\n"); 356 "hvc: got unexpected close acknowledgement\n");
357 return; 357 return;
358 } 358 }
359 359
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c
index 21681a81cc35..5a80ad68ef22 100644
--- a/drivers/char/hvc_iucv.c
+++ b/drivers/char/hvc_iucv.c
@@ -12,6 +12,7 @@
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 13
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/slab.h>
15#include <asm/ebcdic.h> 16#include <asm/ebcdic.h>
16#include <linux/ctype.h> 17#include <linux/ctype.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
@@ -139,6 +140,8 @@ struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
139 * 140 *
140 * This function allocates a new struct iucv_tty_buffer element and, optionally, 141 * This function allocates a new struct iucv_tty_buffer element and, optionally,
141 * allocates an internal data buffer with the specified size @size. 142 * allocates an internal data buffer with the specified size @size.
143 * The internal data buffer is always allocated with GFP_DMA which is
144 * required for receiving and sending data with IUCV.
142 * Note: The total message size arises from the internal buffer size and the 145 * Note: The total message size arises from the internal buffer size and the
143 * members of the iucv_tty_msg structure. 146 * members of the iucv_tty_msg structure.
144 * The function returns NULL if memory allocation has failed. 147 * The function returns NULL if memory allocation has failed.
@@ -154,7 +157,7 @@ static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags)
154 157
155 if (size > 0) { 158 if (size > 0) {
156 bufp->msg.length = MSG_SIZE(size); 159 bufp->msg.length = MSG_SIZE(size);
157 bufp->mbuf = kmalloc(bufp->msg.length, flags); 160 bufp->mbuf = kmalloc(bufp->msg.length, flags | GFP_DMA);
158 if (!bufp->mbuf) { 161 if (!bufp->mbuf) {
159 mempool_free(bufp, hvc_iucv_mempool); 162 mempool_free(bufp, hvc_iucv_mempool);
160 return NULL; 163 return NULL;
@@ -237,7 +240,7 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv,
237 if (!rb->mbuf) { /* message not yet received ... */ 240 if (!rb->mbuf) { /* message not yet received ... */
238 /* allocate mem to store msg data; if no memory is available 241 /* allocate mem to store msg data; if no memory is available
239 * then leave the buffer on the list and re-try later */ 242 * then leave the buffer on the list and re-try later */
240 rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC); 243 rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC | GFP_DMA);
241 if (!rb->mbuf) 244 if (!rb->mbuf)
242 return -ENOMEM; 245 return -ENOMEM;
243 246
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 266b858b8f85..bedc6c1b6fa5 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -74,6 +74,7 @@
74#include <linux/module.h> 74#include <linux/module.h>
75#include <linux/moduleparam.h> 75#include <linux/moduleparam.h>
76#include <linux/sched.h> 76#include <linux/sched.h>
77#include <linux/slab.h>
77#include <linux/spinlock.h> 78#include <linux/spinlock.h>
78#include <linux/stat.h> 79#include <linux/stat.h>
79#include <linux/tty.h> 80#include <linux/tty.h>
diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
index 91b53eb1c053..86fe45c19968 100644
--- a/drivers/char/hw_random/intel-rng.c
+++ b/drivers/char/hw_random/intel-rng.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/stop_machine.h> 31#include <linux/stop_machine.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/slab.h>
33#include <asm/io.h> 34#include <asm/io.h>
34 35
35 36
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
index 9b3e09cd41f9..10f868eefaa6 100644
--- a/drivers/char/hw_random/n2-drv.c
+++ b/drivers/char/hw_random/n2-drv.c
@@ -71,7 +71,7 @@ MODULE_VERSION(DRV_MODULE_VERSION);
71 * x22 + x21 + x17 + x15 + x13 + x12 + x11 + x7 + x5 + x + 1 71 * x22 + x21 + x17 + x15 + x13 + x12 + x11 + x7 + x5 + x + 1
72 * 72 *
73 * The RNG_CTL_VCO value of each noise cell must be programmed 73 * The RNG_CTL_VCO value of each noise cell must be programmed
74 * seperately. This is why 4 control register values must be provided 74 * separately. This is why 4 control register values must be provided
75 * to the hypervisor. During a write, the hypervisor writes them all, 75 * to the hypervisor. During a write, the hypervisor writes them all,
76 * one at a time, to the actual RNG_CTL register. The first three 76 * one at a time, to the actual RNG_CTL register. The first three
77 * values are used to setup the desired RNG_CTL_VCO for each entropy 77 * values are used to setup the desired RNG_CTL_VCO for each entropy
diff --git a/drivers/char/hw_random/octeon-rng.c b/drivers/char/hw_random/octeon-rng.c
index 54b0d9ba65cf..9cd0feca318c 100644
--- a/drivers/char/hw_random/octeon-rng.c
+++ b/drivers/char/hw_random/octeon-rng.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/hw_random.h> 16#include <linux/hw_random.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/gfp.h>
18 19
19#include <asm/octeon/octeon.h> 20#include <asm/octeon/octeon.h>
20#include <asm/octeon/cvmx-rnm-defs.h> 21#include <asm/octeon/cvmx-rnm-defs.h>
diff --git a/drivers/char/hw_random/tx4939-rng.c b/drivers/char/hw_random/tx4939-rng.c
index 544d9085a8e8..0bc0cb70210b 100644
--- a/drivers/char/hw_random/tx4939-rng.c
+++ b/drivers/char/hw_random/tx4939-rng.c
@@ -14,6 +14,7 @@
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/hw_random.h> 16#include <linux/hw_random.h>
17#include <linux/gfp.h>
17 18
18#define TX4939_RNG_RCSR 0x00000000 19#define TX4939_RNG_RCSR 0x00000000
19#define TX4939_RNG_ROR(n) (0x00000018 + (n) * 8) 20#define TX4939_RNG_ROR(n) (0x00000018 + (n) * 8)
diff --git a/drivers/char/ip2/i2hw.h b/drivers/char/ip2/i2hw.h
index 8aa6e7ab8d5b..c0ba6c05f0cd 100644
--- a/drivers/char/ip2/i2hw.h
+++ b/drivers/char/ip2/i2hw.h
@@ -559,7 +559,7 @@ Loadware may be sent to the board in two ways:
559 559
5602) It may be hard-coded into your source by including a .h file (typically 5602) It may be hard-coded into your source by including a .h file (typically
561 supplied by Computone), which declares a data array and initializes every 561 supplied by Computone), which declares a data array and initializes every
562 element. This acheives the same result as if an entire loadware file had 562 element. This achieves the same result as if an entire loadware file had
563 been read into the array. 563 been read into the array.
564 564
565 This requires more data space in your program, but access to the file system 565 This requires more data space in your program, but access to the file system
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index ec5e3f8df648..c6ad4234378d 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2272,42 +2272,52 @@ static int create_files(struct bmc_device *bmc)
2272 bmc->device_id_attr.attr.name = "device_id"; 2272 bmc->device_id_attr.attr.name = "device_id";
2273 bmc->device_id_attr.attr.mode = S_IRUGO; 2273 bmc->device_id_attr.attr.mode = S_IRUGO;
2274 bmc->device_id_attr.show = device_id_show; 2274 bmc->device_id_attr.show = device_id_show;
2275 sysfs_attr_init(&bmc->device_id_attr.attr);
2275 2276
2276 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs"; 2277 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2277 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO; 2278 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2278 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show; 2279 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2280 sysfs_attr_init(&bmc->provides_dev_sdrs_attr.attr);
2279 2281
2280 bmc->revision_attr.attr.name = "revision"; 2282 bmc->revision_attr.attr.name = "revision";
2281 bmc->revision_attr.attr.mode = S_IRUGO; 2283 bmc->revision_attr.attr.mode = S_IRUGO;
2282 bmc->revision_attr.show = revision_show; 2284 bmc->revision_attr.show = revision_show;
2285 sysfs_attr_init(&bmc->revision_attr.attr);
2283 2286
2284 bmc->firmware_rev_attr.attr.name = "firmware_revision"; 2287 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2285 bmc->firmware_rev_attr.attr.mode = S_IRUGO; 2288 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2286 bmc->firmware_rev_attr.show = firmware_rev_show; 2289 bmc->firmware_rev_attr.show = firmware_rev_show;
2290 sysfs_attr_init(&bmc->firmware_rev_attr.attr);
2287 2291
2288 bmc->version_attr.attr.name = "ipmi_version"; 2292 bmc->version_attr.attr.name = "ipmi_version";
2289 bmc->version_attr.attr.mode = S_IRUGO; 2293 bmc->version_attr.attr.mode = S_IRUGO;
2290 bmc->version_attr.show = ipmi_version_show; 2294 bmc->version_attr.show = ipmi_version_show;
2295 sysfs_attr_init(&bmc->version_attr.attr);
2291 2296
2292 bmc->add_dev_support_attr.attr.name = "additional_device_support"; 2297 bmc->add_dev_support_attr.attr.name = "additional_device_support";
2293 bmc->add_dev_support_attr.attr.mode = S_IRUGO; 2298 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2294 bmc->add_dev_support_attr.show = add_dev_support_show; 2299 bmc->add_dev_support_attr.show = add_dev_support_show;
2300 sysfs_attr_init(&bmc->add_dev_support_attr.attr);
2295 2301
2296 bmc->manufacturer_id_attr.attr.name = "manufacturer_id"; 2302 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2297 bmc->manufacturer_id_attr.attr.mode = S_IRUGO; 2303 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2298 bmc->manufacturer_id_attr.show = manufacturer_id_show; 2304 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2305 sysfs_attr_init(&bmc->manufacturer_id_attr.attr);
2299 2306
2300 bmc->product_id_attr.attr.name = "product_id"; 2307 bmc->product_id_attr.attr.name = "product_id";
2301 bmc->product_id_attr.attr.mode = S_IRUGO; 2308 bmc->product_id_attr.attr.mode = S_IRUGO;
2302 bmc->product_id_attr.show = product_id_show; 2309 bmc->product_id_attr.show = product_id_show;
2310 sysfs_attr_init(&bmc->product_id_attr.attr);
2303 2311
2304 bmc->guid_attr.attr.name = "guid"; 2312 bmc->guid_attr.attr.name = "guid";
2305 bmc->guid_attr.attr.mode = S_IRUGO; 2313 bmc->guid_attr.attr.mode = S_IRUGO;
2306 bmc->guid_attr.show = guid_show; 2314 bmc->guid_attr.show = guid_show;
2315 sysfs_attr_init(&bmc->guid_attr.attr);
2307 2316
2308 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision"; 2317 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2309 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO; 2318 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2310 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show; 2319 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2320 sysfs_attr_init(&bmc->aux_firmware_rev_attr.attr);
2311 2321
2312 err = device_create_file(&bmc->dev->dev, 2322 err = device_create_file(&bmc->dev->dev,
2313 &bmc->device_id_attr); 2323 &bmc->device_id_attr);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 176f1751237f..4462b113ba3f 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -295,6 +295,9 @@ struct smi_info {
295static int force_kipmid[SI_MAX_PARMS]; 295static int force_kipmid[SI_MAX_PARMS];
296static int num_force_kipmid; 296static int num_force_kipmid;
297 297
298static unsigned int kipmid_max_busy_us[SI_MAX_PARMS];
299static int num_max_busy_us;
300
298static int unload_when_empty = 1; 301static int unload_when_empty = 1;
299 302
300static int try_smi_init(struct smi_info *smi); 303static int try_smi_init(struct smi_info *smi);
@@ -925,23 +928,77 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion)
925 } 928 }
926} 929}
927 930
931/*
932 * Use -1 in the nsec value of the busy waiting timespec to tell that
933 * we are spinning in kipmid looking for something and not delaying
934 * between checks
935 */
936static inline void ipmi_si_set_not_busy(struct timespec *ts)
937{
938 ts->tv_nsec = -1;
939}
940static inline int ipmi_si_is_busy(struct timespec *ts)
941{
942 return ts->tv_nsec != -1;
943}
944
945static int ipmi_thread_busy_wait(enum si_sm_result smi_result,
946 const struct smi_info *smi_info,
947 struct timespec *busy_until)
948{
949 unsigned int max_busy_us = 0;
950
951 if (smi_info->intf_num < num_max_busy_us)
952 max_busy_us = kipmid_max_busy_us[smi_info->intf_num];
953 if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY)
954 ipmi_si_set_not_busy(busy_until);
955 else if (!ipmi_si_is_busy(busy_until)) {
956 getnstimeofday(busy_until);
957 timespec_add_ns(busy_until, max_busy_us*NSEC_PER_USEC);
958 } else {
959 struct timespec now;
960 getnstimeofday(&now);
961 if (unlikely(timespec_compare(&now, busy_until) > 0)) {
962 ipmi_si_set_not_busy(busy_until);
963 return 0;
964 }
965 }
966 return 1;
967}
968
969
970/*
971 * A busy-waiting loop for speeding up IPMI operation.
972 *
973 * Lousy hardware makes this hard. This is only enabled for systems
974 * that are not BT and do not have interrupts. It starts spinning
975 * when an operation is complete or until max_busy tells it to stop
976 * (if that is enabled). See the paragraph on kimid_max_busy_us in
977 * Documentation/IPMI.txt for details.
978 */
928static int ipmi_thread(void *data) 979static int ipmi_thread(void *data)
929{ 980{
930 struct smi_info *smi_info = data; 981 struct smi_info *smi_info = data;
931 unsigned long flags; 982 unsigned long flags;
932 enum si_sm_result smi_result; 983 enum si_sm_result smi_result;
984 struct timespec busy_until;
933 985
986 ipmi_si_set_not_busy(&busy_until);
934 set_user_nice(current, 19); 987 set_user_nice(current, 19);
935 while (!kthread_should_stop()) { 988 while (!kthread_should_stop()) {
989 int busy_wait;
990
936 spin_lock_irqsave(&(smi_info->si_lock), flags); 991 spin_lock_irqsave(&(smi_info->si_lock), flags);
937 smi_result = smi_event_handler(smi_info, 0); 992 smi_result = smi_event_handler(smi_info, 0);
938 spin_unlock_irqrestore(&(smi_info->si_lock), flags); 993 spin_unlock_irqrestore(&(smi_info->si_lock), flags);
994 busy_wait = ipmi_thread_busy_wait(smi_result, smi_info,
995 &busy_until);
939 if (smi_result == SI_SM_CALL_WITHOUT_DELAY) 996 if (smi_result == SI_SM_CALL_WITHOUT_DELAY)
940 ; /* do nothing */ 997 ; /* do nothing */
941 else if (smi_result == SI_SM_CALL_WITH_DELAY) 998 else if (smi_result == SI_SM_CALL_WITH_DELAY && busy_wait)
942 schedule(); 999 schedule();
943 else 1000 else
944 schedule_timeout_interruptible(1); 1001 schedule_timeout_interruptible(0);
945 } 1002 }
946 return 0; 1003 return 0;
947} 1004}
@@ -1144,7 +1201,7 @@ static int regsizes[SI_MAX_PARMS];
1144static unsigned int num_regsizes; 1201static unsigned int num_regsizes;
1145static int regshifts[SI_MAX_PARMS]; 1202static int regshifts[SI_MAX_PARMS];
1146static unsigned int num_regshifts; 1203static unsigned int num_regshifts;
1147static int slave_addrs[SI_MAX_PARMS]; 1204static int slave_addrs[SI_MAX_PARMS]; /* Leaving 0 chooses the default value */
1148static unsigned int num_slave_addrs; 1205static unsigned int num_slave_addrs;
1149 1206
1150#define IPMI_IO_ADDR_SPACE 0 1207#define IPMI_IO_ADDR_SPACE 0
@@ -1212,6 +1269,11 @@ module_param(unload_when_empty, int, 0);
1212MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" 1269MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are"
1213 " specified or found, default is 1. Setting to 0" 1270 " specified or found, default is 1. Setting to 0"
1214 " is useful for hot add of devices using hotmod."); 1271 " is useful for hot add of devices using hotmod.");
1272module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644);
1273MODULE_PARM_DESC(kipmid_max_busy_us,
1274 "Max time (in microseconds) to busy-wait for IPMI data before"
1275 " sleeping. 0 (default) means to wait forever. Set to 100-500"
1276 " if kipmid is using up a lot of CPU time.");
1215 1277
1216 1278
1217static void std_irq_cleanup(struct smi_info *info) 1279static void std_irq_cleanup(struct smi_info *info)
@@ -1607,7 +1669,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
1607 regsize = 1; 1669 regsize = 1;
1608 regshift = 0; 1670 regshift = 0;
1609 irq = 0; 1671 irq = 0;
1610 ipmb = 0x20; 1672 ipmb = 0; /* Choose the default if not specified */
1611 1673
1612 next = strchr(curr, ':'); 1674 next = strchr(curr, ':');
1613 if (next) { 1675 if (next) {
@@ -1799,6 +1861,7 @@ static __devinit void hardcode_find_bmc(void)
1799 info->irq = irqs[i]; 1861 info->irq = irqs[i];
1800 if (info->irq) 1862 if (info->irq)
1801 info->irq_setup = std_irq_setup; 1863 info->irq_setup = std_irq_setup;
1864 info->slave_addr = slave_addrs[i];
1802 1865
1803 try_smi_init(info); 1866 try_smi_init(info);
1804 } 1867 }
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index be2e8f9a27c3..c1ab303455cf 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -130,6 +130,7 @@
130#include <linux/timer.h> 130#include <linux/timer.h>
131#include <linux/delay.h> 131#include <linux/delay.h>
132#include <linux/ioport.h> 132#include <linux/ioport.h>
133#include <linux/slab.h>
133 134
134#include <linux/uaccess.h> 135#include <linux/uaccess.h>
135#include <linux/io.h> 136#include <linux/io.h>
@@ -878,8 +879,8 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)
878 if (tport == NULL) 879 if (tport == NULL)
879 return -ENODEV; 880 return -ENODEV;
880 port = container_of(tport, struct isi_port, port); 881 port = container_of(tport, struct isi_port, port);
881 card = &isi_card[BOARD(tty->index)];
882 882
883 tty->driver_data = port;
883 return tty_port_open(tport, tty, filp); 884 return tty_port_open(tport, tty, filp);
884} 885}
885 886
@@ -935,7 +936,12 @@ static void isicom_shutdown(struct tty_port *port)
935static void isicom_close(struct tty_struct *tty, struct file *filp) 936static void isicom_close(struct tty_struct *tty, struct file *filp)
936{ 937{
937 struct isi_port *ip = tty->driver_data; 938 struct isi_port *ip = tty->driver_data;
938 struct tty_port *port = &ip->port; 939 struct tty_port *port;
940
941 if (ip == NULL)
942 return;
943
944 port = &ip->port;
939 if (isicom_paranoia_check(ip, tty->name, "isicom_close")) 945 if (isicom_paranoia_check(ip, tty->name, "isicom_close"))
940 return; 946 return;
941 tty_port_close(port, tty, filp); 947 tty_port_close(port, tty, filp);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 4cd6c527ee41..4e395c956a09 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -827,6 +827,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
827 return -ENODEV; 827 return -ENODEV;
828 if (portp->devnr < 1) 828 if (portp->devnr < 1)
829 return -ENODEV; 829 return -ENODEV;
830
831 tty->driver_data = portp;
830 return tty_port_open(&portp->port, tty, filp); 832 return tty_port_open(&portp->port, tty, filp);
831} 833}
832 834
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 87c67b42bc08..83bef4efe376 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -26,6 +26,7 @@
26#include <linux/uio.h> 26#include <linux/uio.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/smp_lock.h> 28#include <linux/smp_lock.h>
29#include <linux/slab.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/system.h> 32#include <asm/system.h>
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 48788db4e280..f54dab8acdcd 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds 4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * 5 *
6 * Added devfs support. 6 * Added devfs support.
7 * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu> 7 * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu>
8 * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com> 8 * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com>
9 */ 9 */
@@ -44,36 +44,6 @@ static inline unsigned long size_inside_page(unsigned long start,
44 return min(sz, size); 44 return min(sz, size);
45} 45}
46 46
47/*
48 * Architectures vary in how they handle caching for addresses
49 * outside of main memory.
50 *
51 */
52static inline int uncached_access(struct file *file, unsigned long addr)
53{
54#if defined(CONFIG_IA64)
55 /*
56 * On ia64, we ignore O_DSYNC because we cannot tolerate memory attribute aliases.
57 */
58 return !(efi_mem_attributes(addr) & EFI_MEMORY_WB);
59#elif defined(CONFIG_MIPS)
60 {
61 extern int __uncached_access(struct file *file,
62 unsigned long addr);
63
64 return __uncached_access(file, addr);
65 }
66#else
67 /*
68 * Accessing memory above the top the kernel knows about or through a file pointer
69 * that was marked O_DSYNC will be done non-cached.
70 */
71 if (file->f_flags & O_DSYNC)
72 return 1;
73 return addr >= __pa(high_memory);
74#endif
75}
76
77#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE 47#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
78static inline int valid_phys_addr_range(unsigned long addr, size_t count) 48static inline int valid_phys_addr_range(unsigned long addr, size_t count)
79{ 49{
@@ -115,15 +85,15 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
115} 85}
116#endif 86#endif
117 87
118void __attribute__((weak)) unxlate_dev_mem_ptr(unsigned long phys, void *addr) 88void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr)
119{ 89{
120} 90}
121 91
122/* 92/*
123 * This funcion reads the *physical* memory. The f_pos points directly to the 93 * This funcion reads the *physical* memory. The f_pos points directly to the
124 * memory location. 94 * memory location.
125 */ 95 */
126static ssize_t read_mem(struct file * file, char __user * buf, 96static ssize_t read_mem(struct file *file, char __user *buf,
127 size_t count, loff_t *ppos) 97 size_t count, loff_t *ppos)
128{ 98{
129 unsigned long p = *ppos; 99 unsigned long p = *ppos;
@@ -140,10 +110,10 @@ static ssize_t read_mem(struct file * file, char __user * buf,
140 if (sz > 0) { 110 if (sz > 0) {
141 if (clear_user(buf, sz)) 111 if (clear_user(buf, sz))
142 return -EFAULT; 112 return -EFAULT;
143 buf += sz; 113 buf += sz;
144 p += sz; 114 p += sz;
145 count -= sz; 115 count -= sz;
146 read += sz; 116 read += sz;
147 } 117 }
148 } 118 }
149#endif 119#endif
@@ -157,9 +127,9 @@ static ssize_t read_mem(struct file * file, char __user * buf,
157 return -EPERM; 127 return -EPERM;
158 128
159 /* 129 /*
160 * On ia64 if a page has been mapped somewhere as 130 * On ia64 if a page has been mapped somewhere as uncached, then
161 * uncached, then it must also be accessed uncached 131 * it must also be accessed uncached by the kernel or data
162 * by the kernel or data corruption may occur 132 * corruption may occur.
163 */ 133 */
164 ptr = xlate_dev_mem_ptr(p); 134 ptr = xlate_dev_mem_ptr(p);
165 if (!ptr) 135 if (!ptr)
@@ -180,7 +150,7 @@ static ssize_t read_mem(struct file * file, char __user * buf,
180 return read; 150 return read;
181} 151}
182 152
183static ssize_t write_mem(struct file * file, const char __user * buf, 153static ssize_t write_mem(struct file *file, const char __user *buf,
184 size_t count, loff_t *ppos) 154 size_t count, loff_t *ppos)
185{ 155{
186 unsigned long p = *ppos; 156 unsigned long p = *ppos;
@@ -212,9 +182,9 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
212 return -EPERM; 182 return -EPERM;
213 183
214 /* 184 /*
215 * On ia64 if a page has been mapped somewhere as 185 * On ia64 if a page has been mapped somewhere as uncached, then
216 * uncached, then it must also be accessed uncached 186 * it must also be accessed uncached by the kernel or data
217 * by the kernel or data corruption may occur 187 * corruption may occur.
218 */ 188 */
219 ptr = xlate_dev_mem_ptr(p); 189 ptr = xlate_dev_mem_ptr(p);
220 if (!ptr) { 190 if (!ptr) {
@@ -242,13 +212,48 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
242 return written; 212 return written;
243} 213}
244 214
245int __attribute__((weak)) phys_mem_access_prot_allowed(struct file *file, 215int __weak phys_mem_access_prot_allowed(struct file *file,
246 unsigned long pfn, unsigned long size, pgprot_t *vma_prot) 216 unsigned long pfn, unsigned long size, pgprot_t *vma_prot)
247{ 217{
248 return 1; 218 return 1;
249} 219}
250 220
251#ifndef __HAVE_PHYS_MEM_ACCESS_PROT 221#ifndef __HAVE_PHYS_MEM_ACCESS_PROT
222
223/*
224 * Architectures vary in how they handle caching for addresses
225 * outside of main memory.
226 *
227 */
228#ifdef pgprot_noncached
229static int uncached_access(struct file *file, unsigned long addr)
230{
231#if defined(CONFIG_IA64)
232 /*
233 * On ia64, we ignore O_DSYNC because we cannot tolerate memory
234 * attribute aliases.
235 */
236 return !(efi_mem_attributes(addr) & EFI_MEMORY_WB);
237#elif defined(CONFIG_MIPS)
238 {
239 extern int __uncached_access(struct file *file,
240 unsigned long addr);
241
242 return __uncached_access(file, addr);
243 }
244#else
245 /*
246 * Accessing memory above the top the kernel knows about or through a
247 * file pointer
248 * that was marked O_DSYNC will be done non-cached.
249 */
250 if (file->f_flags & O_DSYNC)
251 return 1;
252 return addr >= __pa(high_memory);
253#endif
254}
255#endif
256
252static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 257static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
253 unsigned long size, pgprot_t vma_prot) 258 unsigned long size, pgprot_t vma_prot)
254{ 259{
@@ -294,7 +299,7 @@ static const struct vm_operations_struct mmap_mem_ops = {
294#endif 299#endif
295}; 300};
296 301
297static int mmap_mem(struct file * file, struct vm_area_struct * vma) 302static int mmap_mem(struct file *file, struct vm_area_struct *vma)
298{ 303{
299 size_t size = vma->vm_end - vma->vm_start; 304 size_t size = vma->vm_end - vma->vm_start;
300 305
@@ -329,7 +334,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
329} 334}
330 335
331#ifdef CONFIG_DEVKMEM 336#ifdef CONFIG_DEVKMEM
332static int mmap_kmem(struct file * file, struct vm_area_struct * vma) 337static int mmap_kmem(struct file *file, struct vm_area_struct *vma)
333{ 338{
334 unsigned long pfn; 339 unsigned long pfn;
335 340
@@ -337,9 +342,9 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
337 pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; 342 pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT;
338 343
339 /* 344 /*
340 * RED-PEN: on some architectures there is more mapped memory 345 * RED-PEN: on some architectures there is more mapped memory than
341 * than available in mem_map which pfn_valid checks 346 * available in mem_map which pfn_valid checks for. Perhaps should add a
342 * for. Perhaps should add a new macro here. 347 * new macro here.
343 * 348 *
344 * RED-PEN: vmalloc is not supported right now. 349 * RED-PEN: vmalloc is not supported right now.
345 */ 350 */
@@ -389,7 +394,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
389/* 394/*
390 * This function reads the *virtual* memory as seen by the kernel. 395 * This function reads the *virtual* memory as seen by the kernel.
391 */ 396 */
392static ssize_t read_kmem(struct file *file, char __user *buf, 397static ssize_t read_kmem(struct file *file, char __user *buf,
393 size_t count, loff_t *ppos) 398 size_t count, loff_t *ppos)
394{ 399{
395 unsigned long p = *ppos; 400 unsigned long p = *ppos;
@@ -400,8 +405,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
400 read = 0; 405 read = 0;
401 if (p < (unsigned long) high_memory) { 406 if (p < (unsigned long) high_memory) {
402 low_count = count; 407 low_count = count;
403 if (count > (unsigned long) high_memory - p) 408 if (count > (unsigned long)high_memory - p)
404 low_count = (unsigned long) high_memory - p; 409 low_count = (unsigned long)high_memory - p;
405 410
406#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED 411#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
407 /* we don't have page 0 mapped on sparc and m68k.. */ 412 /* we don't have page 0 mapped on sparc and m68k.. */
@@ -465,9 +470,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
465} 470}
466 471
467 472
468static inline ssize_t 473static ssize_t do_write_kmem(unsigned long p, const char __user *buf,
469do_write_kmem(unsigned long p, const char __user *buf, 474 size_t count, loff_t *ppos)
470 size_t count, loff_t *ppos)
471{ 475{
472 ssize_t written, sz; 476 ssize_t written, sz;
473 unsigned long copied; 477 unsigned long copied;
@@ -491,9 +495,9 @@ do_write_kmem(unsigned long p, const char __user *buf,
491 sz = size_inside_page(p, count); 495 sz = size_inside_page(p, count);
492 496
493 /* 497 /*
494 * On ia64 if a page has been mapped somewhere as 498 * On ia64 if a page has been mapped somewhere as uncached, then
495 * uncached, then it must also be accessed uncached 499 * it must also be accessed uncached by the kernel or data
496 * by the kernel or data corruption may occur 500 * corruption may occur.
497 */ 501 */
498 ptr = xlate_dev_kmem_ptr((char *)p); 502 ptr = xlate_dev_kmem_ptr((char *)p);
499 503
@@ -514,11 +518,10 @@ do_write_kmem(unsigned long p, const char __user *buf,
514 return written; 518 return written;
515} 519}
516 520
517
518/* 521/*
519 * This function writes to the *virtual* memory as seen by the kernel. 522 * This function writes to the *virtual* memory as seen by the kernel.
520 */ 523 */
521static ssize_t write_kmem(struct file * file, const char __user * buf, 524static ssize_t write_kmem(struct file *file, const char __user *buf,
522 size_t count, loff_t *ppos) 525 size_t count, loff_t *ppos)
523{ 526{
524 unsigned long p = *ppos; 527 unsigned long p = *ppos;
@@ -570,17 +573,17 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
570#endif 573#endif
571 574
572#ifdef CONFIG_DEVPORT 575#ifdef CONFIG_DEVPORT
573static ssize_t read_port(struct file * file, char __user * buf, 576static ssize_t read_port(struct file *file, char __user *buf,
574 size_t count, loff_t *ppos) 577 size_t count, loff_t *ppos)
575{ 578{
576 unsigned long i = *ppos; 579 unsigned long i = *ppos;
577 char __user *tmp = buf; 580 char __user *tmp = buf;
578 581
579 if (!access_ok(VERIFY_WRITE, buf, count)) 582 if (!access_ok(VERIFY_WRITE, buf, count))
580 return -EFAULT; 583 return -EFAULT;
581 while (count-- > 0 && i < 65536) { 584 while (count-- > 0 && i < 65536) {
582 if (__put_user(inb(i),tmp) < 0) 585 if (__put_user(inb(i), tmp) < 0)
583 return -EFAULT; 586 return -EFAULT;
584 i++; 587 i++;
585 tmp++; 588 tmp++;
586 } 589 }
@@ -588,22 +591,22 @@ static ssize_t read_port(struct file * file, char __user * buf,
588 return tmp-buf; 591 return tmp-buf;
589} 592}
590 593
591static ssize_t write_port(struct file * file, const char __user * buf, 594static ssize_t write_port(struct file *file, const char __user *buf,
592 size_t count, loff_t *ppos) 595 size_t count, loff_t *ppos)
593{ 596{
594 unsigned long i = *ppos; 597 unsigned long i = *ppos;
595 const char __user * tmp = buf; 598 const char __user * tmp = buf;
596 599
597 if (!access_ok(VERIFY_READ,buf,count)) 600 if (!access_ok(VERIFY_READ, buf, count))
598 return -EFAULT; 601 return -EFAULT;
599 while (count-- > 0 && i < 65536) { 602 while (count-- > 0 && i < 65536) {
600 char c; 603 char c;
601 if (__get_user(c, tmp)) { 604 if (__get_user(c, tmp)) {
602 if (tmp > buf) 605 if (tmp > buf)
603 break; 606 break;
604 return -EFAULT; 607 return -EFAULT;
605 } 608 }
606 outb(c,i); 609 outb(c, i);
607 i++; 610 i++;
608 tmp++; 611 tmp++;
609 } 612 }
@@ -612,13 +615,13 @@ static ssize_t write_port(struct file * file, const char __user * buf,
612} 615}
613#endif 616#endif
614 617
615static ssize_t read_null(struct file * file, char __user * buf, 618static ssize_t read_null(struct file *file, char __user *buf,
616 size_t count, loff_t *ppos) 619 size_t count, loff_t *ppos)
617{ 620{
618 return 0; 621 return 0;
619} 622}
620 623
621static ssize_t write_null(struct file * file, const char __user * buf, 624static ssize_t write_null(struct file *file, const char __user *buf,
622 size_t count, loff_t *ppos) 625 size_t count, loff_t *ppos)
623{ 626{
624 return count; 627 return count;
@@ -630,13 +633,13 @@ static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf,
630 return sd->len; 633 return sd->len;
631} 634}
632 635
633static ssize_t splice_write_null(struct pipe_inode_info *pipe,struct file *out, 636static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
634 loff_t *ppos, size_t len, unsigned int flags) 637 loff_t *ppos, size_t len, unsigned int flags)
635{ 638{
636 return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); 639 return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
637} 640}
638 641
639static ssize_t read_zero(struct file * file, char __user * buf, 642static ssize_t read_zero(struct file *file, char __user *buf,
640 size_t count, loff_t *ppos) 643 size_t count, loff_t *ppos)
641{ 644{
642 size_t written; 645 size_t written;
@@ -667,7 +670,7 @@ static ssize_t read_zero(struct file * file, char __user * buf,
667 return written ? written : -EFAULT; 670 return written ? written : -EFAULT;
668} 671}
669 672
670static int mmap_zero(struct file * file, struct vm_area_struct * vma) 673static int mmap_zero(struct file *file, struct vm_area_struct *vma)
671{ 674{
672#ifndef CONFIG_MMU 675#ifndef CONFIG_MMU
673 return -ENOSYS; 676 return -ENOSYS;
@@ -677,7 +680,7 @@ static int mmap_zero(struct file * file, struct vm_area_struct * vma)
677 return 0; 680 return 0;
678} 681}
679 682
680static ssize_t write_full(struct file * file, const char __user * buf, 683static ssize_t write_full(struct file *file, const char __user *buf,
681 size_t count, loff_t *ppos) 684 size_t count, loff_t *ppos)
682{ 685{
683 return -ENOSPC; 686 return -ENOSPC;
@@ -688,8 +691,7 @@ static ssize_t write_full(struct file * file, const char __user * buf,
688 * can fopen() both devices with "a" now. This was previously impossible. 691 * can fopen() both devices with "a" now. This was previously impossible.
689 * -- SRB. 692 * -- SRB.
690 */ 693 */
691 694static loff_t null_lseek(struct file *file, loff_t offset, int orig)
692static loff_t null_lseek(struct file * file, loff_t offset, int orig)
693{ 695{
694 return file->f_pos = 0; 696 return file->f_pos = 0;
695} 697}
@@ -702,24 +704,26 @@ static loff_t null_lseek(struct file * file, loff_t offset, int orig)
702 * also note that seeking relative to the "end of file" isn't supported: 704 * also note that seeking relative to the "end of file" isn't supported:
703 * it has no meaning, so it returns -EINVAL. 705 * it has no meaning, so it returns -EINVAL.
704 */ 706 */
705static loff_t memory_lseek(struct file * file, loff_t offset, int orig) 707static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
706{ 708{
707 loff_t ret; 709 loff_t ret;
708 710
709 mutex_lock(&file->f_path.dentry->d_inode->i_mutex); 711 mutex_lock(&file->f_path.dentry->d_inode->i_mutex);
710 switch (orig) { 712 switch (orig) {
711 case 0: 713 case SEEK_CUR:
712 file->f_pos = offset; 714 offset += file->f_pos;
713 ret = file->f_pos; 715 case SEEK_SET:
714 force_successful_syscall_return(); 716 /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */
715 break; 717 if ((unsigned long long)offset >= ~0xFFFULL) {
716 case 1: 718 ret = -EOVERFLOW;
717 file->f_pos += offset;
718 ret = file->f_pos;
719 force_successful_syscall_return();
720 break; 719 break;
721 default: 720 }
722 ret = -EINVAL; 721 file->f_pos = offset;
722 ret = file->f_pos;
723 force_successful_syscall_return();
724 break;
725 default:
726 ret = -EINVAL;
723 } 727 }
724 mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); 728 mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
725 return ret; 729 return ret;
@@ -803,7 +807,7 @@ static const struct file_operations oldmem_fops = {
803}; 807};
804#endif 808#endif
805 809
806static ssize_t kmsg_write(struct file * file, const char __user * buf, 810static ssize_t kmsg_write(struct file *file, const char __user *buf,
807 size_t count, loff_t *ppos) 811 size_t count, loff_t *ppos)
808{ 812{
809 char *tmp; 813 char *tmp;
@@ -825,7 +829,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf,
825} 829}
826 830
827static const struct file_operations kmsg_fops = { 831static const struct file_operations kmsg_fops = {
828 .write = kmsg_write, 832 .write = kmsg_write,
829}; 833};
830 834
831static const struct memdev { 835static const struct memdev {
@@ -876,7 +880,7 @@ static int memory_open(struct inode *inode, struct file *filp)
876} 880}
877 881
878static const struct file_operations memory_fops = { 882static const struct file_operations memory_fops = {
879 .open = memory_open, 883 .open = memory_open,
880}; 884};
881 885
882static char *mem_devnode(struct device *dev, mode_t *mode) 886static char *mem_devnode(struct device *dev, mode_t *mode)
@@ -897,10 +901,13 @@ static int __init chr_dev_init(void)
897 if (err) 901 if (err)
898 return err; 902 return err;
899 903
900 if (register_chrdev(MEM_MAJOR,"mem",&memory_fops)) 904 if (register_chrdev(MEM_MAJOR, "mem", &memory_fops))
901 printk("unable to get major %d for memory devs\n", MEM_MAJOR); 905 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
902 906
903 mem_class = class_create(THIS_MODULE, "mem"); 907 mem_class = class_create(THIS_MODULE, "mem");
908 if (IS_ERR(mem_class))
909 return PTR_ERR(mem_class);
910
904 mem_class->devnode = mem_devnode; 911 mem_class->devnode = mem_devnode;
905 for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { 912 for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) {
906 if (!devlist[minor].name) 913 if (!devlist[minor].name)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 94a136e96c06..92ab03d28294 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -40,7 +40,6 @@
40#include <linux/miscdevice.h> 40#include <linux/miscdevice.h>
41#include <linux/kernel.h> 41#include <linux/kernel.h>
42#include <linux/major.h> 42#include <linux/major.h>
43#include <linux/slab.h>
44#include <linux/mutex.h> 43#include <linux/mutex.h>
45#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
46#include <linux/seq_file.h> 45#include <linux/seq_file.h>
@@ -49,6 +48,7 @@
49#include <linux/device.h> 48#include <linux/device.h>
50#include <linux/tty.h> 49#include <linux/tty.h>
51#include <linux/kmod.h> 50#include <linux/kmod.h>
51#include <linux/gfp.h>
52 52
53/* 53/*
54 * Head entry for the doubly linked miscdevice list 54 * Head entry for the doubly linked miscdevice list
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 918711aa56f3..ea7c99fa978f 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -33,6 +33,7 @@
33#include <linux/time.h> 33#include <linux/time.h>
34#include <linux/math64.h> 34#include <linux/math64.h>
35#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
36#include <linux/slab.h>
36 37
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38#include <asm/sn/addrs.h> 39#include <asm/sn/addrs.h>
@@ -546,7 +547,7 @@ static void mmtimer_tasklet(unsigned long data)
546{ 547{
547 int nodeid = data; 548 int nodeid = data;
548 struct mmtimer_node *mn = &timers[nodeid]; 549 struct mmtimer_node *mn = &timers[nodeid];
549 struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list); 550 struct mmtimer *x;
550 struct k_itimer *t; 551 struct k_itimer *t;
551 unsigned long flags; 552 unsigned long flags;
552 553
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 166495d6a1d7..107b0bd58d19 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -43,6 +43,7 @@
43#include <linux/pci.h> 43#include <linux/pci.h>
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/bitops.h> 45#include <linux/bitops.h>
46#include <linux/slab.h>
46 47
47#include <asm/system.h> 48#include <asm/system.h>
48#include <asm/io.h> 49#include <asm/io.h>
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index e0c5d2a69046..d2692d443f7b 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -33,12 +33,12 @@
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/fcntl.h> 34#include <linux/fcntl.h>
35#include <linux/ptrace.h> 35#include <linux/ptrace.h>
36#include <linux/gfp.h>
37#include <linux/ioport.h> 36#include <linux/ioport.h>
38#include <linux/mm.h> 37#include <linux/mm.h>
39#include <linux/delay.h> 38#include <linux/delay.h>
40#include <linux/pci.h> 39#include <linux/pci.h>
41#include <linux/bitops.h> 40#include <linux/bitops.h>
41#include <linux/slab.h>
42 42
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/io.h> 44#include <asm/io.h>
@@ -1011,6 +1011,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
1011 if (!info->ioaddr) 1011 if (!info->ioaddr)
1012 return -ENODEV; 1012 return -ENODEV;
1013 1013
1014 tty->driver_data = info;
1014 return tty_port_open(&info->port, tty, filp); 1015 return tty_port_open(&info->port, tty, filp);
1015} 1016}
1016 1017
@@ -1074,7 +1075,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1074 struct mxser_port *info = tty->driver_data; 1075 struct mxser_port *info = tty->driver_data;
1075 struct tty_port *port = &info->port; 1076 struct tty_port *port = &info->port;
1076 1077
1077 if (tty->index == MXSER_PORTS) 1078 if (tty->index == MXSER_PORTS || info == NULL)
1078 return; 1079 return;
1079 if (tty_port_close_start(port, tty, filp) == 0) 1080 if (tty_port_close_start(port, tty, filp) == 0)
1080 return; 1081 return;
@@ -1768,7 +1769,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1768 int len, lsr; 1769 int len, lsr;
1769 1770
1770 len = mxser_chars_in_buffer(tty); 1771 len = mxser_chars_in_buffer(tty);
1771 spin_lock(&info->slock); 1772 spin_lock_irq(&info->slock);
1772 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_THRE; 1773 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_THRE;
1773 spin_unlock_irq(&info->slock); 1774 spin_unlock_irq(&info->slock);
1774 len += (lsr ? 0 : 1); 1775 len += (lsr ? 0 : 1);
@@ -1778,12 +1779,12 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1778 case MOXA_ASPP_MON: { 1779 case MOXA_ASPP_MON: {
1779 int mcr, status; 1780 int mcr, status;
1780 1781
1781 spin_lock(&info->slock); 1782 spin_lock_irq(&info->slock);
1782 status = mxser_get_msr(info->ioaddr, 1, tty->index); 1783 status = mxser_get_msr(info->ioaddr, 1, tty->index);
1783 mxser_check_modem_status(tty, info, status); 1784 mxser_check_modem_status(tty, info, status);
1784 1785
1785 mcr = inb(info->ioaddr + UART_MCR); 1786 mcr = inb(info->ioaddr + UART_MCR);
1786 spin_unlock(&info->slock); 1787 spin_unlock_irq(&info->slock);
1787 1788
1788 if (mcr & MOXA_MUST_MCR_XON_FLAG) 1789 if (mcr & MOXA_MUST_MCR_XON_FLAG)
1789 info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD; 1790 info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD;
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 2e50f4dfc79c..bdae8327143c 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -48,6 +48,7 @@
48#include <linux/audit.h> 48#include <linux/audit.h>
49#include <linux/file.h> 49#include <linux/file.h>
50#include <linux/uaccess.h> 50#include <linux/uaccess.h>
51#include <linux/module.h>
51 52
52#include <asm/system.h> 53#include <asm/system.h>
53 54
@@ -2091,3 +2092,19 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = {
2091 .receive_buf = n_tty_receive_buf, 2092 .receive_buf = n_tty_receive_buf,
2092 .write_wakeup = n_tty_write_wakeup 2093 .write_wakeup = n_tty_write_wakeup
2093}; 2094};
2095
2096/**
2097 * n_tty_inherit_ops - inherit N_TTY methods
2098 * @ops: struct tty_ldisc_ops where to save N_TTY methods
2099 *
2100 * Used by a generic struct tty_ldisc_ops to easily inherit N_TTY
2101 * methods.
2102 */
2103
2104void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
2105{
2106 *ops = tty_ldisc_N_TTY;
2107 ops->owner = NULL;
2108 ops->refcount = ops->flags = 0;
2109}
2110EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index a3f32a15fde4..a6638003f530 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -55,6 +55,7 @@
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/kfifo.h> 56#include <linux/kfifo.h>
57#include <linux/uaccess.h> 57#include <linux/uaccess.h>
58#include <linux/slab.h>
58#include <asm/byteorder.h> 59#include <asm/byteorder.h>
59 60
60#include <linux/delay.h> 61#include <linux/delay.h>
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 5eb83c3ca20d..47e8f7b0e4c1 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -100,7 +100,6 @@
100#include <linux/types.h> 100#include <linux/types.h>
101#include <linux/errno.h> 101#include <linux/errno.h>
102#include <linux/miscdevice.h> 102#include <linux/miscdevice.h>
103#include <linux/slab.h>
104#include <linux/ioport.h> 103#include <linux/ioport.h>
105#include <linux/fcntl.h> 104#include <linux/fcntl.h>
106#include <linux/mc146818rtc.h> 105#include <linux/mc146818rtc.h>
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index c9bc896d68af..90b199f97bec 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1026,14 +1026,16 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
1026 1026
1027 xoutb(0, REG_FLAGS1(iobase)); /* clear detectCMM */ 1027 xoutb(0, REG_FLAGS1(iobase)); /* clear detectCMM */
1028 /* last check before exit */ 1028 /* last check before exit */
1029 if (!io_detect_cm4000(iobase, dev)) 1029 if (!io_detect_cm4000(iobase, dev)) {
1030 count = -ENODEV; 1030 rc = -ENODEV;
1031 goto release_io;
1032 }
1031 1033
1032 if (test_bit(IS_INVREV, &dev->flags) && count > 0) 1034 if (test_bit(IS_INVREV, &dev->flags) && count > 0)
1033 str_invert_revert(dev->rbuf, count); 1035 str_invert_revert(dev->rbuf, count);
1034 1036
1035 if (copy_to_user(buf, dev->rbuf, count)) 1037 if (copy_to_user(buf, dev->rbuf, count))
1036 return -EFAULT; 1038 rc = -EFAULT;
1037 1039
1038release_io: 1040release_io:
1039 clear_bit(LOCK_IO, &dev->flags); 1041 clear_bit(LOCK_IO, &dev->flags);
diff --git a/drivers/char/pcmcia/ipwireless/network.c b/drivers/char/pcmcia/ipwireless/network.c
index 590762a7f217..65920163f53d 100644
--- a/drivers/char/pcmcia/ipwireless/network.c
+++ b/drivers/char/pcmcia/ipwireless/network.c
@@ -21,6 +21,7 @@
21#include <linux/netdevice.h> 21#include <linux/netdevice.h>
22#include <linux/ppp_channel.h> 22#include <linux/ppp_channel.h>
23#include <linux/ppp_defs.h> 23#include <linux/ppp_defs.h>
24#include <linux/slab.h>
24#include <linux/if_ppp.h> 25#include <linux/if_ppp.h>
25#include <linux/skbuff.h> 26#include <linux/skbuff.h>
26 27
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 432655bcb04c..fdd37543aa79 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -64,6 +64,7 @@
64#include <linux/parport.h> 64#include <linux/parport.h>
65#include <linux/ctype.h> 65#include <linux/ctype.h>
66#include <linux/poll.h> 66#include <linux/poll.h>
67#include <linux/slab.h>
67#include <linux/major.h> 68#include <linux/major.h>
68#include <linux/ppdev.h> 69#include <linux/ppdev.h>
69#include <linux/smp_lock.h> 70#include <linux/smp_lock.h>
diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
index f424d394a286..606048b72bcf 100644
--- a/drivers/char/ps3flash.c
+++ b/drivers/char/ps3flash.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/slab.h>
23#include <linux/uaccess.h> 24#include <linux/uaccess.h>
24 25
25#include <asm/lv1call.h> 26#include <asm/lv1call.h>
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 385c44b3034f..d83a43130df4 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -29,6 +29,7 @@
29#include <linux/uaccess.h> 29#include <linux/uaccess.h>
30#include <linux/bitops.h> 30#include <linux/bitops.h>
31#include <linux/devpts_fs.h> 31#include <linux/devpts_fs.h>
32#include <linux/slab.h>
32 33
33#include <asm/system.h> 34#include <asm/system.h>
34 35
@@ -220,7 +221,7 @@ static void pty_set_termios(struct tty_struct *tty,
220 * @tty: tty being resized 221 * @tty: tty being resized
221 * @ws: window size being set. 222 * @ws: window size being set.
222 * 223 *
223 * Update the termios variables and send the neccessary signals to 224 * Update the termios variables and send the necessary signals to
224 * peform a terminal resize correctly 225 * peform a terminal resize correctly
225 */ 226 */
226 227
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 2849713d2231..2fd3d39995d5 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1191,7 +1191,7 @@ const struct file_operations urandom_fops = {
1191void generate_random_uuid(unsigned char uuid_out[16]) 1191void generate_random_uuid(unsigned char uuid_out[16])
1192{ 1192{
1193 get_random_bytes(uuid_out, 16); 1193 get_random_bytes(uuid_out, 16);
1194 /* Set UUID version to 4 --- truely random generation */ 1194 /* Set UUID version to 4 --- truly random generation */
1195 uuid_out[6] = (uuid_out[6] & 0x0F) | 0x40; 1195 uuid_out[6] = (uuid_out[6] & 0x0F) | 0x40;
1196 /* Set the UUID variant to DCE */ 1196 /* Set the UUID variant to DCE */
1197 uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80; 1197 uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80;
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 64acd05f71c8..8756ab0daa8b 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -20,6 +20,7 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
23#include <linux/gfp.h>
23 24
24#include <asm/uaccess.h> 25#include <asm/uaccess.h>
25 26
@@ -247,6 +248,7 @@ static const struct file_operations raw_fops = {
247 .aio_read = generic_file_aio_read, 248 .aio_read = generic_file_aio_read,
248 .write = do_sync_write, 249 .write = do_sync_write,
249 .aio_write = blkdev_aio_write, 250 .aio_write = blkdev_aio_write,
251 .fsync = blkdev_fsync,
250 .open = raw_open, 252 .open = raw_open,
251 .release= raw_release, 253 .release= raw_release,
252 .ioctl = raw_ioctl, 254 .ioctl = raw_ioctl,
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index be0ba401966e..24a282bb89d4 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/delay.h> 35#include <linux/delay.h>
37#include <asm/io.h> 36#include <asm/io.h>
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 71f87600907c..2e71aecae206 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/tty.h> 35#include <linux/tty.h>
37#include <linux/tty_flip.h> 36#include <linux/tty_flip.h>
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index d687c17be152..6415f3f32a72 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/tty.h> 35#include <linux/tty.h>
37#include <asm/io.h> 36#include <asm/io.h>
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index 706c2a25f7aa..f9b936ac3394 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <asm/io.h> 35#include <asm/io.h>
37#include <asm/system.h> 36#include <asm/system.h>
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 47fab7c33073..8a90393faf3c 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -34,7 +34,6 @@
34 34
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/sched.h> 36#include <linux/sched.h>
37#include <linux/slab.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39#include <linux/tty.h> 38#include <linux/tty.h>
40#include <linux/string.h> 39#include <linux/string.h>
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 0a8d1e56c993..b02332a5412f 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -909,6 +909,7 @@ static int rc_open(struct tty_struct *tty, struct file *filp)
909 if (error) 909 if (error)
910 return error; 910 return error;
911 911
912 tty->driver_data = port;
912 return tty_port_open(&port->port, tty, filp); 913 return tty_port_open(&port->port, tty, filp);
913} 914}
914 915
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 986aa606a6b6..8dfd24721a82 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -64,6 +64,7 @@
64#include <linux/module.h> 64#include <linux/module.h>
65#include <linux/bitops.h> 65#include <linux/bitops.h>
66#include <linux/tty_flip.h> 66#include <linux/tty_flip.h>
67#include <linux/gfp.h>
67 68
68#include <asm/system.h> 69#include <asm/system.h>
69#include <asm/io.h> 70#include <asm/io.h>
@@ -1989,7 +1990,7 @@ void mvme167_serial_console_setup(int cflag)
1989 /* 1990 /*
1990 * Attempt to set up all channels to something reasonable, and 1991 * Attempt to set up all channels to something reasonable, and
1991 * bang out a INIT_CHAN command. We should then be able to limit 1992 * bang out a INIT_CHAN command. We should then be able to limit
1992 * the ammount of fiddling we have to do in normal running. 1993 * the amount of fiddling we have to do in normal running.
1993 */ 1994 */
1994 1995
1995 for (ch = 3; ch >= 0; ch--) { 1996 for (ch = 3; ch >= 0; ch--) {
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index 55a95892ccf9..ee156948b9f8 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/slab.h>
20#include <asm/byteorder.h> 21#include <asm/byteorder.h>
21#include <asm/sn/sn_sal.h> 22#include <asm/sn/sn_sal.h>
22#include <asm/unaligned.h> 23#include <asm/unaligned.h>
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index bba727c3807e..73f66d03624d 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -50,6 +50,7 @@
50#include <linux/err.h> 50#include <linux/err.h>
51#include <linux/kfifo.h> 51#include <linux/kfifo.h>
52#include <linux/platform_device.h> 52#include <linux/platform_device.h>
53#include <linux/gfp.h>
53 54
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
55#include <asm/io.h> 56#include <asm/io.h>
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 07ac14d949ce..2c24fcdc722a 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -94,6 +94,7 @@
94#include <linux/pci.h> 94#include <linux/pci.h>
95#include <linux/init.h> 95#include <linux/init.h>
96#include <linux/uaccess.h> 96#include <linux/uaccess.h>
97#include <linux/gfp.h>
97 98
98#include "specialix_io8.h" 99#include "specialix_io8.h"
99#include "cd1865.h" 100#include "cd1865.h"
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 0e511d61f544..6049fd731924 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -724,7 +724,6 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
724{ 724{
725 struct stlport *portp; 725 struct stlport *portp;
726 struct stlbrd *brdp; 726 struct stlbrd *brdp;
727 struct tty_port *port;
728 unsigned int minordev, brdnr, panelnr; 727 unsigned int minordev, brdnr, panelnr;
729 int portnr; 728 int portnr;
730 729
@@ -754,7 +753,8 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
754 portp = brdp->panels[panelnr]->ports[portnr]; 753 portp = brdp->panels[panelnr]->ports[portnr];
755 if (portp == NULL) 754 if (portp == NULL)
756 return -ENODEV; 755 return -ENODEV;
757 port = &portp->port; 756
757 tty->driver_data = portp;
758 return tty_port_open(&portp->port, tty, filp); 758 return tty_port_open(&portp->port, tty, filp);
759 759
760} 760}
@@ -841,7 +841,8 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
841 pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp); 841 pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp);
842 842
843 portp = tty->driver_data; 843 portp = tty->driver_data;
844 BUG_ON(portp == NULL); 844 if(portp == NULL)
845 return;
845 tty_port_close(&portp->port, tty, filp); 846 tty_port_close(&portp->port, tty, filp);
846} 847}
847 848
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 1ae2de7d8b4f..59de2525d303 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -38,6 +38,7 @@
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/hrtimer.h> 39#include <linux/hrtimer.h>
40#include <linux/oom.h> 40#include <linux/oom.h>
41#include <linux/slab.h>
41 42
42#include <asm/ptrace.h> 43#include <asm/ptrace.h>
43#include <asm/irq_regs.h> 44#include <asm/irq_regs.h>
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index f06bb37defb1..068c816e6942 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/poll.h> 26#include <linux/poll.h>
27#include <linux/slab.h>
27#include <linux/mutex.h> 28#include <linux/mutex.h>
28#include <linux/spinlock.h> 29#include <linux/spinlock.h>
29 30
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index bf2170fb1cdd..0636520fa9bf 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -22,6 +22,7 @@
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h>
25#include <acpi/acpi.h> 26#include <acpi/acpi.h>
26#include "tpm.h" 27#include "tpm.h"
27 28
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 70efba2ee053..a605cb7dd898 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/slab.h>
23#include "tpm.h" 24#include "tpm.h"
24 25
25/* National definitions */ 26/* National definitions */
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 2405f17b29dd..94345994f8a6 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/moduleparam.h> 23#include <linux/moduleparam.h>
24#include <linux/pnp.h> 24#include <linux/pnp.h>
25#include <linux/slab.h>
25#include <linux/interrupt.h> 26#include <linux/interrupt.h>
26#include <linux/wait.h> 27#include <linux/wait.h>
27#include "tpm.h" 28#include "tpm.h"
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c
index ac16fbec72d0..1b8ee590b4ca 100644
--- a/drivers/char/tty_audit.c
+++ b/drivers/char/tty_audit.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/audit.h> 12#include <linux/audit.h>
13#include <linux/slab.h>
13#include <linux/tty.h> 14#include <linux/tty.h>
14 15
15struct tty_audit_buf { 16struct tty_audit_buf {
@@ -148,7 +149,6 @@ void tty_audit_fork(struct signal_struct *sig)
148 spin_lock_irq(&current->sighand->siglock); 149 spin_lock_irq(&current->sighand->siglock);
149 sig->audit_tty = current->signal->audit_tty; 150 sig->audit_tty = current->signal->audit_tty;
150 spin_unlock_irq(&current->sighand->siglock); 151 spin_unlock_irq(&current->sighand->siglock);
151 sig->tty_audit_buf = NULL;
152} 152}
153 153
154/** 154/**
diff --git a/drivers/char/tty_buffer.c b/drivers/char/tty_buffer.c
index af8d97715728..7ee52164d474 100644
--- a/drivers/char/tty_buffer.c
+++ b/drivers/char/tty_buffer.c
@@ -248,7 +248,7 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,
248{ 248{
249 int copied = 0; 249 int copied = 0;
250 do { 250 do {
251 int goal = min(size - copied, TTY_BUFFER_PAGE); 251 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
252 int space = tty_buffer_request_room(tty, goal); 252 int space = tty_buffer_request_room(tty, goal);
253 struct tty_buffer *tb = tty->buf.tail; 253 struct tty_buffer *tb = tty->buf.tail;
254 /* If there is no space then tb may be NULL */ 254 /* If there is no space then tb may be NULL */
@@ -285,7 +285,7 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
285{ 285{
286 int copied = 0; 286 int copied = 0;
287 do { 287 do {
288 int goal = min(size - copied, TTY_BUFFER_PAGE); 288 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
289 int space = tty_buffer_request_room(tty, goal); 289 int space = tty_buffer_request_room(tty, goal);
290 struct tty_buffer *tb = tty->buf.tail; 290 struct tty_buffer *tb = tty->buf.tail;
291 /* If there is no space then tb may be NULL */ 291 /* If there is no space then tb may be NULL */
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index dcb9083ecde0..6da962c9b21c 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1423,6 +1423,8 @@ static void release_one_tty(struct work_struct *work)
1423 list_del_init(&tty->tty_files); 1423 list_del_init(&tty->tty_files);
1424 file_list_unlock(); 1424 file_list_unlock();
1425 1425
1426 put_pid(tty->pgrp);
1427 put_pid(tty->session);
1426 free_tty_struct(tty); 1428 free_tty_struct(tty);
1427} 1429}
1428 1430
@@ -2028,7 +2030,7 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg)
2028 * @rows: rows (character) 2030 * @rows: rows (character)
2029 * @cols: cols (character) 2031 * @cols: cols (character)
2030 * 2032 *
2031 * Update the termios variables and send the neccessary signals to 2033 * Update the termios variables and send the necessary signals to
2032 * peform a terminal resize correctly 2034 * peform a terminal resize correctly
2033 */ 2035 */
2034 2036
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index be492dd66437..a3bd1d0b66cf 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -119,7 +119,7 @@ EXPORT_SYMBOL(tty_port_tty_set);
119static void tty_port_shutdown(struct tty_port *port) 119static void tty_port_shutdown(struct tty_port *port)
120{ 120{
121 mutex_lock(&port->mutex); 121 mutex_lock(&port->mutex);
122 if (port->ops->shutdown && 122 if (port->ops->shutdown && !port->console &&
123 test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) 123 test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags))
124 port->ops->shutdown(port); 124 port->ops->shutdown(port);
125 mutex_unlock(&port->mutex); 125 mutex_unlock(&port->mutex);
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 042c8149a6d1..1144a04cda6e 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -47,6 +47,7 @@
47#include <linux/proc_fs.h> 47#include <linux/proc_fs.h>
48#include <linux/seq_file.h> 48#include <linux/seq_file.h>
49#include <linux/smp_lock.h> 49#include <linux/smp_lock.h>
50#include <linux/slab.h>
50 51
51#include <asm/uaccess.h> 52#include <asm/uaccess.h>
52#include <asm/ioctls.h> 53#include <asm/ioctls.h>
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 213373b5f17f..196428c2287a 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -25,6 +25,7 @@
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/poll.h> 26#include <linux/poll.h>
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/slab.h>
28#include <linux/spinlock.h> 29#include <linux/spinlock.h>
29#include <linux/virtio.h> 30#include <linux/virtio.h>
30#include <linux/virtio_console.h> 31#include <linux/virtio_console.h>
@@ -32,6 +33,35 @@
32#include <linux/workqueue.h> 33#include <linux/workqueue.h>
33#include "hvc_console.h" 34#include "hvc_console.h"
34 35
36/* Moved here from .h file in order to disable MULTIPORT. */
37#define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */
38
39struct virtio_console_multiport_conf {
40 struct virtio_console_config config;
41 /* max. number of ports this device can hold */
42 __u32 max_nr_ports;
43 /* number of ports added so far */
44 __u32 nr_ports;
45} __attribute__((packed));
46
47/*
48 * A message that's passed between the Host and the Guest for a
49 * particular port.
50 */
51struct virtio_console_control {
52 __u32 id; /* Port number */
53 __u16 event; /* The kind of control event (see below) */
54 __u16 value; /* Extra information for the key */
55};
56
57/* Some events for control messages */
58#define VIRTIO_CONSOLE_PORT_READY 0
59#define VIRTIO_CONSOLE_CONSOLE_PORT 1
60#define VIRTIO_CONSOLE_RESIZE 2
61#define VIRTIO_CONSOLE_PORT_OPEN 3
62#define VIRTIO_CONSOLE_PORT_NAME 4
63#define VIRTIO_CONSOLE_PORT_REMOVE 5
64
35/* 65/*
36 * This is a global struct for storing common data for all the devices 66 * This is a global struct for storing common data for all the devices
37 * this driver handles. 67 * this driver handles.
@@ -120,7 +150,7 @@ struct ports_device {
120 spinlock_t cvq_lock; 150 spinlock_t cvq_lock;
121 151
122 /* The current config space is stored here */ 152 /* The current config space is stored here */
123 struct virtio_console_config config; 153 struct virtio_console_multiport_conf config;
124 154
125 /* The virtio device we're associated with */ 155 /* The virtio device we're associated with */
126 struct virtio_device *vdev; 156 struct virtio_device *vdev;
@@ -379,7 +409,7 @@ static ssize_t send_control_msg(struct port *port, unsigned int event,
379 struct scatterlist sg[1]; 409 struct scatterlist sg[1];
380 struct virtio_console_control cpkt; 410 struct virtio_console_control cpkt;
381 struct virtqueue *vq; 411 struct virtqueue *vq;
382 int len; 412 unsigned int len;
383 413
384 if (!use_multiport(port->portdev)) 414 if (!use_multiport(port->portdev))
385 return 0; 415 return 0;
@@ -415,20 +445,16 @@ static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count)
415 out_vq->vq_ops->kick(out_vq); 445 out_vq->vq_ops->kick(out_vq);
416 446
417 if (ret < 0) { 447 if (ret < 0) {
418 len = 0; 448 in_count = 0;
419 goto fail; 449 goto fail;
420 } 450 }
421 451
422 /* 452 /* Wait till the host acknowledges it pushed out the data we sent. */
423 * Wait till the host acknowledges it pushed out the data we
424 * sent. Also ensure we return to userspace the number of
425 * bytes that were successfully consumed by the host.
426 */
427 while (!out_vq->vq_ops->get_buf(out_vq, &len)) 453 while (!out_vq->vq_ops->get_buf(out_vq, &len))
428 cpu_relax(); 454 cpu_relax();
429fail: 455fail:
430 /* We're expected to return the amount of data we wrote */ 456 /* We're expected to return the amount of data we wrote */
431 return len; 457 return in_count;
432} 458}
433 459
434/* 460/*
@@ -645,13 +671,13 @@ static int put_chars(u32 vtermno, const char *buf, int count)
645{ 671{
646 struct port *port; 672 struct port *port;
647 673
674 if (unlikely(early_put_chars))
675 return early_put_chars(vtermno, buf, count);
676
648 port = find_port_by_vtermno(vtermno); 677 port = find_port_by_vtermno(vtermno);
649 if (!port) 678 if (!port)
650 return 0; 679 return 0;
651 680
652 if (unlikely(early_put_chars))
653 return early_put_chars(vtermno, buf, count);
654
655 return send_buf(port, (void *)buf, count); 681 return send_buf(port, (void *)buf, count);
656} 682}
657 683
@@ -681,6 +707,10 @@ static void resize_console(struct port *port)
681 struct virtio_device *vdev; 707 struct virtio_device *vdev;
682 struct winsize ws; 708 struct winsize ws;
683 709
710 /* The port could have been hot-unplugged */
711 if (!port)
712 return;
713
684 vdev = port->portdev->vdev; 714 vdev = port->portdev->vdev;
685 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) { 715 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) {
686 vdev->config->get(vdev, 716 vdev->config->get(vdev,
@@ -947,11 +977,18 @@ static void handle_control_message(struct ports_device *portdev,
947 */ 977 */
948 err = sysfs_create_group(&port->dev->kobj, 978 err = sysfs_create_group(&port->dev->kobj,
949 &port_attribute_group); 979 &port_attribute_group);
950 if (err) 980 if (err) {
951 dev_err(port->dev, 981 dev_err(port->dev,
952 "Error %d creating sysfs device attributes\n", 982 "Error %d creating sysfs device attributes\n",
953 err); 983 err);
954 984 } else {
985 /*
986 * Generate a udev event so that appropriate
987 * symlinks can be created based on udev
988 * rules.
989 */
990 kobject_uevent(&port->dev->kobj, KOBJ_CHANGE);
991 }
955 break; 992 break;
956 case VIRTIO_CONSOLE_PORT_REMOVE: 993 case VIRTIO_CONSOLE_PORT_REMOVE:
957 /* 994 /*
@@ -1071,27 +1108,27 @@ static void config_intr(struct virtio_device *vdev)
1071static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) 1108static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
1072{ 1109{
1073 struct port_buffer *buf; 1110 struct port_buffer *buf;
1074 unsigned int ret; 1111 unsigned int nr_added_bufs;
1075 int err; 1112 int ret;
1076 1113
1077 ret = 0; 1114 nr_added_bufs = 0;
1078 do { 1115 do {
1079 buf = alloc_buf(PAGE_SIZE); 1116 buf = alloc_buf(PAGE_SIZE);
1080 if (!buf) 1117 if (!buf)
1081 break; 1118 break;
1082 1119
1083 spin_lock_irq(lock); 1120 spin_lock_irq(lock);
1084 err = add_inbuf(vq, buf); 1121 ret = add_inbuf(vq, buf);
1085 if (err < 0) { 1122 if (ret < 0) {
1086 spin_unlock_irq(lock); 1123 spin_unlock_irq(lock);
1087 free_buf(buf); 1124 free_buf(buf);
1088 break; 1125 break;
1089 } 1126 }
1090 ret++; 1127 nr_added_bufs++;
1091 spin_unlock_irq(lock); 1128 spin_unlock_irq(lock);
1092 } while (err > 0); 1129 } while (ret > 0);
1093 1130
1094 return ret; 1131 return nr_added_bufs;
1095} 1132}
1096 1133
1097static int add_port(struct ports_device *portdev, u32 id) 1134static int add_port(struct ports_device *portdev, u32 id)
@@ -1100,6 +1137,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1100 struct port *port; 1137 struct port *port;
1101 struct port_buffer *buf; 1138 struct port_buffer *buf;
1102 dev_t devt; 1139 dev_t devt;
1140 unsigned int nr_added_bufs;
1103 int err; 1141 int err;
1104 1142
1105 port = kmalloc(sizeof(*port), GFP_KERNEL); 1143 port = kmalloc(sizeof(*port), GFP_KERNEL);
@@ -1144,8 +1182,8 @@ static int add_port(struct ports_device *portdev, u32 id)
1144 init_waitqueue_head(&port->waitqueue); 1182 init_waitqueue_head(&port->waitqueue);
1145 1183
1146 /* Fill the in_vq with buffers so the host can send us data. */ 1184 /* Fill the in_vq with buffers so the host can send us data. */
1147 err = fill_queue(port->in_vq, &port->inbuf_lock); 1185 nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock);
1148 if (!err) { 1186 if (!nr_added_bufs) {
1149 dev_err(port->dev, "Error allocating inbufs\n"); 1187 dev_err(port->dev, "Error allocating inbufs\n");
1150 err = -ENOMEM; 1188 err = -ENOMEM;
1151 goto free_device; 1189 goto free_device;
@@ -1205,7 +1243,7 @@ fail:
1205 */ 1243 */
1206static void config_work_handler(struct work_struct *work) 1244static void config_work_handler(struct work_struct *work)
1207{ 1245{
1208 struct virtio_console_config virtconconf; 1246 struct virtio_console_multiport_conf virtconconf;
1209 struct ports_device *portdev; 1247 struct ports_device *portdev;
1210 struct virtio_device *vdev; 1248 struct virtio_device *vdev;
1211 int err; 1249 int err;
@@ -1214,7 +1252,8 @@ static void config_work_handler(struct work_struct *work)
1214 1252
1215 vdev = portdev->vdev; 1253 vdev = portdev->vdev;
1216 vdev->config->get(vdev, 1254 vdev->config->get(vdev,
1217 offsetof(struct virtio_console_config, nr_ports), 1255 offsetof(struct virtio_console_multiport_conf,
1256 nr_ports),
1218 &virtconconf.nr_ports, 1257 &virtconconf.nr_ports,
1219 sizeof(virtconconf.nr_ports)); 1258 sizeof(virtconconf.nr_ports));
1220 1259
@@ -1406,16 +1445,19 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1406 multiport = false; 1445 multiport = false;
1407 portdev->config.nr_ports = 1; 1446 portdev->config.nr_ports = 1;
1408 portdev->config.max_nr_ports = 1; 1447 portdev->config.max_nr_ports = 1;
1448#if 0 /* Multiport is not quite ready yet --RR */
1409 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) { 1449 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) {
1410 multiport = true; 1450 multiport = true;
1411 vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT; 1451 vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT;
1412 1452
1413 vdev->config->get(vdev, offsetof(struct virtio_console_config, 1453 vdev->config->get(vdev,
1414 nr_ports), 1454 offsetof(struct virtio_console_multiport_conf,
1455 nr_ports),
1415 &portdev->config.nr_ports, 1456 &portdev->config.nr_ports,
1416 sizeof(portdev->config.nr_ports)); 1457 sizeof(portdev->config.nr_ports));
1417 vdev->config->get(vdev, offsetof(struct virtio_console_config, 1458 vdev->config->get(vdev,
1418 max_nr_ports), 1459 offsetof(struct virtio_console_multiport_conf,
1460 max_nr_ports),
1419 &portdev->config.max_nr_ports, 1461 &portdev->config.max_nr_ports,
1420 sizeof(portdev->config.max_nr_ports)); 1462 sizeof(portdev->config.max_nr_ports));
1421 if (portdev->config.nr_ports > portdev->config.max_nr_ports) { 1463 if (portdev->config.nr_ports > portdev->config.max_nr_ports) {
@@ -1431,6 +1473,7 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1431 1473
1432 /* Let the Host know we support multiple ports.*/ 1474 /* Let the Host know we support multiple ports.*/
1433 vdev->config->finalize_features(vdev); 1475 vdev->config->finalize_features(vdev);
1476#endif
1434 1477
1435 err = init_vqs(portdev); 1478 err = init_vqs(portdev);
1436 if (err < 0) { 1479 if (err < 0) {
@@ -1442,12 +1485,14 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1442 INIT_LIST_HEAD(&portdev->ports); 1485 INIT_LIST_HEAD(&portdev->ports);
1443 1486
1444 if (multiport) { 1487 if (multiport) {
1488 unsigned int nr_added_bufs;
1489
1445 spin_lock_init(&portdev->cvq_lock); 1490 spin_lock_init(&portdev->cvq_lock);
1446 INIT_WORK(&portdev->control_work, &control_work_handler); 1491 INIT_WORK(&portdev->control_work, &control_work_handler);
1447 INIT_WORK(&portdev->config_work, &config_work_handler); 1492 INIT_WORK(&portdev->config_work, &config_work_handler);
1448 1493
1449 err = fill_queue(portdev->c_ivq, &portdev->cvq_lock); 1494 nr_added_bufs = fill_queue(portdev->c_ivq, &portdev->cvq_lock);
1450 if (!err) { 1495 if (!nr_added_bufs) {
1451 dev_err(&vdev->dev, 1496 dev_err(&vdev->dev,
1452 "Error allocating buffers for control queue\n"); 1497 "Error allocating buffers for control queue\n");
1453 err = -ENOMEM; 1498 err = -ENOMEM;
@@ -1511,7 +1556,6 @@ static struct virtio_device_id id_table[] = {
1511 1556
1512static unsigned int features[] = { 1557static unsigned int features[] = {
1513 VIRTIO_CONSOLE_F_SIZE, 1558 VIRTIO_CONSOLE_F_SIZE,
1514 VIRTIO_CONSOLE_F_MULTIPORT,
1515}; 1559};
1516 1560
1517static struct virtio_driver virtio_console = { 1561static struct virtio_driver virtio_console = {
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index 8b24729fec89..12de1202d22c 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -27,7 +27,6 @@
27#include <linux/fcntl.h> 27#include <linux/fcntl.h>
28#include <linux/major.h> 28#include <linux/major.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h>
31#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
32#include <linux/console.h> 31#include <linux/console.h>
33#include <linux/init.h> 32#include <linux/init.h>
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 50faa1fb0f06..bd1d1164fec5 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -821,7 +821,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
821 * 821 *
822 * Resize a virtual console, clipping according to the actual constraints. 822 * Resize a virtual console, clipping according to the actual constraints.
823 * If the caller passes a tty structure then update the termios winsize 823 * If the caller passes a tty structure then update the termios winsize
824 * information and perform any neccessary signal handling. 824 * information and perform any necessary signal handling.
825 * 825 *
826 * Caller must hold the console semaphore. Takes the termios mutex and 826 * Caller must hold the console semaphore. Takes the termios mutex and
827 * ctrl_lock of the tty IFF a tty is passed. 827 * ctrl_lock of the tty IFF a tty is passed.
@@ -2119,8 +2119,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2119 uint8_t inverse; 2119 uint8_t inverse;
2120 uint8_t width; 2120 uint8_t width;
2121 u16 himask, charmask; 2121 u16 himask, charmask;
2122 const unsigned char *orig_buf = NULL;
2123 int orig_count;
2124 2122
2125 if (in_interrupt()) 2123 if (in_interrupt())
2126 return count; 2124 return count;
@@ -2142,8 +2140,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2142 release_console_sem(); 2140 release_console_sem();
2143 return 0; 2141 return 0;
2144 } 2142 }
2145 orig_buf = buf;
2146 orig_count = count;
2147 2143
2148 himask = vc->vc_hi_font_mask; 2144 himask = vc->vc_hi_font_mask;
2149 charmask = himask ? 0x1ff : 0xff; 2145 charmask = himask ? 0x1ff : 0xff;
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 87778dcf8727..6aa10284104a 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -888,7 +888,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
888 ret = -EFAULT; 888 ret = -EFAULT;
889 goto out; 889 goto out;
890 } 890 }
891 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS && tmp.mode != VT_PROCESS_AUTO) { 891 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) {
892 ret = -EINVAL; 892 ret = -EINVAL;
893 goto out; 893 goto out;
894 } 894 }
@@ -1622,7 +1622,7 @@ static void complete_change_console(struct vc_data *vc)
1622 * telling it that it has acquired. Also check if it has died and 1622 * telling it that it has acquired. Also check if it has died and
1623 * clean up (similar to logic employed in change_console()) 1623 * clean up (similar to logic employed in change_console())
1624 */ 1624 */
1625 if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { 1625 if (vc->vt_mode.mode == VT_PROCESS) {
1626 /* 1626 /*
1627 * Send the signal as privileged - kill_pid() will 1627 * Send the signal as privileged - kill_pid() will
1628 * tell us if the process has gone or something else 1628 * tell us if the process has gone or something else
@@ -1682,7 +1682,7 @@ void change_console(struct vc_data *new_vc)
1682 * vt to auto control. 1682 * vt to auto control.
1683 */ 1683 */
1684 vc = vc_cons[fg_console].d; 1684 vc = vc_cons[fg_console].d;
1685 if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { 1685 if (vc->vt_mode.mode == VT_PROCESS) {
1686 /* 1686 /*
1687 * Send the signal as privileged - kill_pid() will 1687 * Send the signal as privileged - kill_pid() will
1688 * tell us if the process has gone or something else 1688 * tell us if the process has gone or something else
@@ -1693,28 +1693,27 @@ void change_console(struct vc_data *new_vc)
1693 */ 1693 */
1694 vc->vt_newvt = new_vc->vc_num; 1694 vc->vt_newvt = new_vc->vc_num;
1695 if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) { 1695 if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) {
1696 if(vc->vt_mode.mode == VT_PROCESS)
1697 /*
1698 * It worked. Mark the vt to switch to and
1699 * return. The process needs to send us a
1700 * VT_RELDISP ioctl to complete the switch.
1701 */
1702 return;
1703 } else {
1704 /* 1696 /*
1705 * The controlling process has died, so we revert back to 1697 * It worked. Mark the vt to switch to and
1706 * normal operation. In this case, we'll also change back 1698 * return. The process needs to send us a
1707 * to KD_TEXT mode. I'm not sure if this is strictly correct 1699 * VT_RELDISP ioctl to complete the switch.
1708 * but it saves the agony when the X server dies and the screen
1709 * remains blanked due to KD_GRAPHICS! It would be nice to do
1710 * this outside of VT_PROCESS but there is no single process
1711 * to account for and tracking tty count may be undesirable.
1712 */ 1700 */
1713 reset_vc(vc); 1701 return;
1714 } 1702 }
1715 1703
1716 /* 1704 /*
1717 * Fall through to normal (VT_AUTO and VT_PROCESS_AUTO) handling of the switch... 1705 * The controlling process has died, so we revert back to
1706 * normal operation. In this case, we'll also change back
1707 * to KD_TEXT mode. I'm not sure if this is strictly correct
1708 * but it saves the agony when the X server dies and the screen
1709 * remains blanked due to KD_GRAPHICS! It would be nice to do
1710 * this outside of VT_PROCESS but there is no single process
1711 * to account for and tracking tty count may be undesirable.
1712 */
1713 reset_vc(vc);
1714
1715 /*
1716 * Fall through to normal (VT_AUTO) handling of the switch...
1718 */ 1717 */
1719 } 1718 }
1720 1719
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 4846d50199f3..7261b8d9087c 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -86,6 +86,7 @@
86#include <linux/fs.h> 86#include <linux/fs.h>
87#include <linux/cdev.h> 87#include <linux/cdev.h>
88#include <linux/platform_device.h> 88#include <linux/platform_device.h>
89#include <linux/slab.h>
89 90
90#include <asm/io.h> 91#include <asm/io.h>
91#include <asm/uaccess.h> 92#include <asm/uaccess.h>