aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-11-15 11:06:24 -0500
committerArnd Bergmann <arnd@arndb.de>2012-11-15 11:06:24 -0500
commit9265c6a186ca19a57ab6ddd0b0f3644f85c6f2f1 (patch)
treed8c434ea98ee541ee17f4df87bb8e9020ce29b98 /drivers
parent49ea7fc094162fcaa83f5876b2090c816cc4498c (diff)
parent6ba54ab4a49bbad736b0254aa6bdf0cb83013815 (diff)
Merge branch 'omap/headers4' into next/cleanup
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bluetooth/hci_ldisc.c7
-rw-r--r--drivers/char/hw_random/omap-rng.c2
-rw-r--r--drivers/crypto/omap-aes.c8
-rw-r--r--drivers/crypto/omap-sham.c10
-rw-r--r--drivers/dma/omap-dma.c5
-rw-r--r--drivers/media/platform/omap/omap_vout.c4
-rw-r--r--drivers/media/platform/omap/omap_vout_vrfb.c6
-rw-r--r--drivers/media/platform/omap/omap_voutdef.h2
-rw-r--r--drivers/media/platform/omap3isp/isphist.c2
-rw-r--r--drivers/media/platform/omap3isp/ispstat.h2
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c1
-rw-r--r--drivers/media/platform/soc_camera/omap1_camera.c3
-rw-r--r--drivers/media/rc/ir-rx51.c1
-rw-r--r--drivers/mfd/menelaus.c2
-rw-r--r--drivers/mfd/omap-usb-host.c5
-rw-r--r--drivers/mfd/omap-usb-tll.c2
-rw-r--r--drivers/mfd/omap-usb.h2
-rw-r--r--drivers/mmc/host/omap.c35
-rw-r--r--drivers/mmc/host/omap_hsmmc.c4
-rw-r--r--drivers/mtd/nand/omap2.c129
-rw-r--r--drivers/mtd/onenand/omap2.c47
-rw-r--r--drivers/pcmcia/omap_cf.c2
-rw-r--r--drivers/staging/tidspbridge/include/dspbridge/host_os.h1
-rw-r--r--drivers/tty/n_tty.c752
-rw-r--r--drivers/tty/pty.c30
-rw-r--r--drivers/tty/serial/8250/8250.c9
-rw-r--r--drivers/tty/serial/8250/8250.h36
-rw-r--r--drivers/tty/serial/8250/8250_early.c2
-rw-r--r--drivers/tty/serial/samsung.c16
-rw-r--r--drivers/tty/tty_audit.c15
-rw-r--r--drivers/tty/tty_buffer.c228
-rw-r--r--drivers/tty/tty_io.c15
-rw-r--r--drivers/tty/tty_ldisc.c15
-rw-r--r--drivers/tty/tty_port.c2
-rw-r--r--drivers/tty/vt/selection.c9
-rw-r--r--drivers/usb/gadget/omap_udc.c4
-rw-r--r--drivers/usb/host/ehci-omap.c3
-rw-r--r--drivers/usb/host/ohci-omap.c5
-rw-r--r--drivers/usb/host/ohci-omap3.c1
-rw-r--r--drivers/usb/musb/am35x.c3
-rw-r--r--drivers/usb/musb/musb_dsps.c3
-rw-r--r--drivers/usb/musb/omap2430.h2
-rw-r--r--drivers/usb/musb/tusb6010_omap.c9
-rw-r--r--drivers/video/omap/lcd_inn1510.c7
-rw-r--r--drivers/video/omap/lcdc.c2
-rw-r--r--drivers/video/omap/omapfb_main.c2
-rw-r--r--drivers/video/omap/sossi.c2
-rw-r--r--drivers/video/omap2/dss/core.c2
-rw-r--r--drivers/video/omap2/dss/dispc.c43
-rw-r--r--drivers/video/omap2/dss/dss.c39
-rw-r--r--drivers/video/omap2/dss/dss_features.c64
-rw-r--r--drivers/video/omap2/dss/dss_features.h5
-rw-r--r--drivers/video/omap2/dss/hdmi.c3
-rw-r--r--drivers/video/omap2/omapfb/omapfb-ioctl.c2
-rw-r--r--drivers/video/omap2/omapfb/omapfb-main.c8
-rw-r--r--drivers/video/omap2/omapfb/omapfb-sysfs.c2
-rw-r--r--drivers/video/omap2/vrfb.c142
57 files changed, 1071 insertions, 693 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index c8abce3d2d9c..ed0fade46aed 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -270,15 +270,10 @@ static int hci_uart_send_frame(struct sk_buff *skb)
270 */ 270 */
271static int hci_uart_tty_open(struct tty_struct *tty) 271static int hci_uart_tty_open(struct tty_struct *tty)
272{ 272{
273 struct hci_uart *hu = (void *) tty->disc_data; 273 struct hci_uart *hu;
274 274
275 BT_DBG("tty %p", tty); 275 BT_DBG("tty %p", tty);
276 276
277 /* FIXME: This btw is bogus, nothing requires the old ldisc to clear
278 the pointer */
279 if (hu)
280 return -EEXIST;
281
282 /* Error if the tty has no write op instead of leaving an exploitable 277 /* Error if the tty has no write op instead of leaving an exploitable
283 hole */ 278 hole */
284 if (tty->ops->write == NULL) 279 if (tty->ops->write == NULL)
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index a5effd813abd..45e467dcc8c8 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -27,8 +27,6 @@
27 27
28#include <asm/io.h> 28#include <asm/io.h>
29 29
30#include <plat/cpu.h>
31
32#define RNG_OUT_REG 0x00 /* Output register */ 30#define RNG_OUT_REG 0x00 /* Output register */
33#define RNG_STAT_REG 0x04 /* Status register 31#define RNG_STAT_REG 0x04 /* Status register
34 [0] = STAT_BUSY */ 32 [0] = STAT_BUSY */
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index 093a8af59cbe..649a146e1382 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -29,8 +29,7 @@
29#include <crypto/scatterwalk.h> 29#include <crypto/scatterwalk.h>
30#include <crypto/aes.h> 30#include <crypto/aes.h>
31 31
32#include <plat/cpu.h> 32#include <plat-omap/dma-omap.h>
33#include <plat/dma.h>
34 33
35/* OMAP TRM gives bitfields as start:end, where start is the higher bit 34/* OMAP TRM gives bitfields as start:end, where start is the higher bit
36 number. For example 7:0 */ 35 number. For example 7:0 */
@@ -941,11 +940,6 @@ static int __init omap_aes_mod_init(void)
941{ 940{
942 pr_info("loading %s driver\n", "omap-aes"); 941 pr_info("loading %s driver\n", "omap-aes");
943 942
944 if (!cpu_class_is_omap2() || omap_type() != OMAP2_DEVICE_TYPE_SEC) {
945 pr_err("Unsupported cpu\n");
946 return -ENODEV;
947 }
948
949 return platform_driver_register(&omap_aes_driver); 943 return platform_driver_register(&omap_aes_driver);
950} 944}
951 945
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index a3fd6fc504b1..d76fe06b9417 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -37,8 +37,7 @@
37#include <crypto/hash.h> 37#include <crypto/hash.h>
38#include <crypto/internal/hash.h> 38#include <crypto/internal/hash.h>
39 39
40#include <plat/cpu.h> 40#include <plat-omap/dma-omap.h>
41#include <plat/dma.h>
42#include <mach/irqs.h> 41#include <mach/irqs.h>
43 42
44#define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04)) 43#define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04))
@@ -1289,13 +1288,6 @@ static int __init omap_sham_mod_init(void)
1289{ 1288{
1290 pr_info("loading %s driver\n", "omap-sham"); 1289 pr_info("loading %s driver\n", "omap-sham");
1291 1290
1292 if (!cpu_class_is_omap2() ||
1293 (omap_type() != OMAP2_DEVICE_TYPE_SEC &&
1294 omap_type() != OMAP2_DEVICE_TYPE_EMU)) {
1295 pr_err("Unsupported cpu\n");
1296 return -ENODEV;
1297 }
1298
1299 return platform_driver_register(&omap_sham_driver); 1291 return platform_driver_register(&omap_sham_driver);
1300} 1292}
1301 1293
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index bb2d8e7029eb..7d35c237fbf1 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -19,8 +19,7 @@
19 19
20#include "virt-dma.h" 20#include "virt-dma.h"
21 21
22#include <plat/cpu.h> 22#include <plat-omap/dma-omap.h>
23#include <plat/dma.h>
24 23
25struct omap_dmadev { 24struct omap_dmadev {
26 struct dma_device ddev; 25 struct dma_device ddev;
@@ -438,7 +437,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
438 omap_disable_dma_irq(c->dma_ch, OMAP_DMA_BLOCK_IRQ); 437 omap_disable_dma_irq(c->dma_ch, OMAP_DMA_BLOCK_IRQ);
439 } 438 }
440 439
441 if (!cpu_class_is_omap1()) { 440 if (dma_omap2plus()) {
442 omap_set_dma_src_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16); 441 omap_set_dma_src_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16);
443 omap_set_dma_dest_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16); 442 omap_set_dma_dest_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16);
444 } 443 }
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
index a3b1a34c896d..4b1becc86e54 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -45,8 +45,8 @@
45#include <media/v4l2-ioctl.h> 45#include <media/v4l2-ioctl.h>
46 46
47#include <plat/cpu.h> 47#include <plat/cpu.h>
48#include <plat/dma.h> 48#include <plat-omap/dma-omap.h>
49#include <plat/vrfb.h> 49#include <video/omapvrfb.h>
50#include <video/omapdss.h> 50#include <video/omapdss.h>
51 51
52#include "omap_voutlib.h" 52#include "omap_voutlib.h"
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c
index 4be26abf6cea..8340445a0ee5 100644
--- a/drivers/media/platform/omap/omap_vout_vrfb.c
+++ b/drivers/media/platform/omap/omap_vout_vrfb.c
@@ -16,12 +16,14 @@
16#include <media/videobuf-dma-contig.h> 16#include <media/videobuf-dma-contig.h>
17#include <media/v4l2-device.h> 17#include <media/v4l2-device.h>
18 18
19#include <plat/dma.h> 19#include <plat-omap/dma-omap.h>
20#include <plat/vrfb.h> 20#include <video/omapvrfb.h>
21 21
22#include "omap_voutdef.h" 22#include "omap_voutdef.h"
23#include "omap_voutlib.h" 23#include "omap_voutlib.h"
24 24
25#define OMAP_DMA_NO_DEVICE 0
26
25/* 27/*
26 * Function for allocating video buffers 28 * Function for allocating video buffers
27 */ 29 */
diff --git a/drivers/media/platform/omap/omap_voutdef.h b/drivers/media/platform/omap/omap_voutdef.h
index 27a95d23b913..9ccfe1f475a4 100644
--- a/drivers/media/platform/omap/omap_voutdef.h
+++ b/drivers/media/platform/omap/omap_voutdef.h
@@ -12,7 +12,7 @@
12#define OMAP_VOUTDEF_H 12#define OMAP_VOUTDEF_H
13 13
14#include <video/omapdss.h> 14#include <video/omapdss.h>
15#include <plat/vrfb.h> 15#include <video/omapvrfb.h>
16 16
17#define YUYV_BPP 2 17#define YUYV_BPP 2
18#define RGB565_BPP 2 18#define RGB565_BPP 2
diff --git a/drivers/media/platform/omap3isp/isphist.c b/drivers/media/platform/omap3isp/isphist.c
index d1a8dee5e1ca..e7f9c4292cc6 100644
--- a/drivers/media/platform/omap3isp/isphist.c
+++ b/drivers/media/platform/omap3isp/isphist.c
@@ -34,6 +34,8 @@
34#include "ispreg.h" 34#include "ispreg.h"
35#include "isphist.h" 35#include "isphist.h"
36 36
37#define OMAP24XX_DMA_NO_DEVICE 0
38
37#define HIST_CONFIG_DMA 1 39#define HIST_CONFIG_DMA 1
38 40
39#define HIST_USING_DMA(hist) ((hist)->dma_ch >= 0) 41#define HIST_USING_DMA(hist) ((hist)->dma_ch >= 0)
diff --git a/drivers/media/platform/omap3isp/ispstat.h b/drivers/media/platform/omap3isp/ispstat.h
index a6fe653eb237..40f87cdd7994 100644
--- a/drivers/media/platform/omap3isp/ispstat.h
+++ b/drivers/media/platform/omap3isp/ispstat.h
@@ -30,7 +30,7 @@
30 30
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/omap3isp.h> 32#include <linux/omap3isp.h>
33#include <plat/dma.h> 33#include <plat-omap/dma-omap.h>
34#include <media/v4l2-event.h> 34#include <media/v4l2-event.h>
35 35
36#include "isp.h" 36#include "isp.h"
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index a0b737fecf13..5bd40e6870cc 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -36,7 +36,6 @@
36#include <media/v4l2-ioctl.h> 36#include <media/v4l2-ioctl.h>
37#include <plat/iommu.h> 37#include <plat/iommu.h>
38#include <plat/iovmm.h> 38#include <plat/iovmm.h>
39#include <plat/omap-pm.h>
40 39
41#include "ispvideo.h" 40#include "ispvideo.h"
42#include "isp.h" 41#include "isp.h"
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c
index fa08c7695ccb..cae9ce6275e9 100644
--- a/drivers/media/platform/soc_camera/omap1_camera.c
+++ b/drivers/media/platform/soc_camera/omap1_camera.c
@@ -34,12 +34,13 @@
34#include <media/videobuf-dma-contig.h> 34#include <media/videobuf-dma-contig.h>
35#include <media/videobuf-dma-sg.h> 35#include <media/videobuf-dma-sg.h>
36 36
37#include <plat/dma.h> 37#include <plat-omap/dma-omap.h>
38 38
39 39
40#define DRIVER_NAME "omap1-camera" 40#define DRIVER_NAME "omap1-camera"
41#define DRIVER_VERSION "0.0.2" 41#define DRIVER_VERSION "0.0.2"
42 42
43#define OMAP_DMA_CAMERA_IF_RX 20
43 44
44/* 45/*
45 * --------------------------------------------------------------------------- 46 * ---------------------------------------------------------------------------
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index 546199e9ccc7..82e6c1e282d5 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -28,7 +28,6 @@
28 28
29#include <plat/dmtimer.h> 29#include <plat/dmtimer.h>
30#include <plat/clock.h> 30#include <plat/clock.h>
31#include <plat/omap-pm.h>
32 31
33#include <media/lirc.h> 32#include <media/lirc.h>
34#include <media/lirc_dev.h> 33#include <media/lirc_dev.h>
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 55d589981412..998ce8cb3065 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -41,11 +41,11 @@
41#include <linux/rtc.h> 41#include <linux/rtc.h>
42#include <linux/bcd.h> 42#include <linux/bcd.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/mfd/menelaus.h>
44 45
45#include <asm/mach/irq.h> 46#include <asm/mach/irq.h>
46 47
47#include <asm/gpio.h> 48#include <asm/gpio.h>
48#include <plat/menelaus.h>
49 49
50#define DRIVER_NAME "menelaus" 50#define DRIVER_NAME "menelaus"
51 51
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 23cec57c02ba..cebfe0a68aa7 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -26,9 +26,12 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <plat/cpu.h> 28#include <plat/cpu.h>
29#include <plat/usb.h> 29#include <linux/platform_device.h>
30#include <linux/platform_data/usb-omap.h>
30#include <linux/pm_runtime.h> 31#include <linux/pm_runtime.h>
31 32
33#include "omap-usb.h"
34
32#define USBHS_DRIVER_NAME "usbhs_omap" 35#define USBHS_DRIVER_NAME "usbhs_omap"
33#define OMAP_EHCI_DEVICE "ehci-omap" 36#define OMAP_EHCI_DEVICE "ehci-omap"
34#define OMAP_OHCI_DEVICE "ohci-omap3" 37#define OMAP_OHCI_DEVICE "ohci-omap3"
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 4b7757b84301..0db0dfa3d08c 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -25,8 +25,8 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <plat/usb.h>
29#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29#include <linux/platform_data/usb-omap.h>
30 30
31#define USBTLL_DRIVER_NAME "usbhs_tll" 31#define USBTLL_DRIVER_NAME "usbhs_tll"
32 32
diff --git a/drivers/mfd/omap-usb.h b/drivers/mfd/omap-usb.h
new file mode 100644
index 000000000000..972aa961b064
--- /dev/null
+++ b/drivers/mfd/omap-usb.h
@@ -0,0 +1,2 @@
1extern int omap_tll_enable(void);
2extern int omap_tll_disable(void);
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 48ad361613ef..ae115c01283b 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -28,9 +28,8 @@
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/scatterlist.h> 29#include <linux/scatterlist.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/platform_data/mmc-omap.h>
31 32
32#include <plat/mmc.h>
33#include <plat/dma.h>
34 33
35#define OMAP_MMC_REG_CMD 0x00 34#define OMAP_MMC_REG_CMD 0x00
36#define OMAP_MMC_REG_ARGL 0x01 35#define OMAP_MMC_REG_ARGL 0x01
@@ -72,6 +71,13 @@
72#define OMAP_MMC_STAT_CARD_BUSY (1 << 2) 71#define OMAP_MMC_STAT_CARD_BUSY (1 << 2)
73#define OMAP_MMC_STAT_END_OF_CMD (1 << 0) 72#define OMAP_MMC_STAT_END_OF_CMD (1 << 0)
74 73
74#define mmc_omap7xx() (host->features & MMC_OMAP7XX)
75#define mmc_omap15xx() (host->features & MMC_OMAP15XX)
76#define mmc_omap16xx() (host->features & MMC_OMAP16XX)
77#define MMC_OMAP1_MASK (MMC_OMAP7XX | MMC_OMAP15XX | MMC_OMAP16XX)
78#define mmc_omap1() (host->features & MMC_OMAP1_MASK)
79#define mmc_omap2() (!mmc_omap1())
80
75#define OMAP_MMC_REG(host, reg) (OMAP_MMC_REG_##reg << (host)->reg_shift) 81#define OMAP_MMC_REG(host, reg) (OMAP_MMC_REG_##reg << (host)->reg_shift)
76#define OMAP_MMC_READ(host, reg) __raw_readw((host)->virt_base + OMAP_MMC_REG(host, reg)) 82#define OMAP_MMC_READ(host, reg) __raw_readw((host)->virt_base + OMAP_MMC_REG(host, reg))
77#define OMAP_MMC_WRITE(host, reg, val) __raw_writew((val), (host)->virt_base + OMAP_MMC_REG(host, reg)) 83#define OMAP_MMC_WRITE(host, reg, val) __raw_writew((val), (host)->virt_base + OMAP_MMC_REG(host, reg))
@@ -84,6 +90,16 @@
84#define OMAP_MMC_CMDTYPE_AC 2 90#define OMAP_MMC_CMDTYPE_AC 2
85#define OMAP_MMC_CMDTYPE_ADTC 3 91#define OMAP_MMC_CMDTYPE_ADTC 3
86 92
93#define OMAP_DMA_MMC_TX 21
94#define OMAP_DMA_MMC_RX 22
95#define OMAP_DMA_MMC2_TX 54
96#define OMAP_DMA_MMC2_RX 55
97
98#define OMAP24XX_DMA_MMC2_TX 47
99#define OMAP24XX_DMA_MMC2_RX 48
100#define OMAP24XX_DMA_MMC1_TX 61
101#define OMAP24XX_DMA_MMC1_RX 62
102
87 103
88#define DRIVER_NAME "mmci-omap" 104#define DRIVER_NAME "mmci-omap"
89 105
@@ -147,6 +163,7 @@ struct mmc_omap_host {
147 u32 buffer_bytes_left; 163 u32 buffer_bytes_left;
148 u32 total_bytes_left; 164 u32 total_bytes_left;
149 165
166 unsigned features;
150 unsigned use_dma:1; 167 unsigned use_dma:1;
151 unsigned brs_received:1, dma_done:1; 168 unsigned brs_received:1, dma_done:1;
152 unsigned dma_in_use:1; 169 unsigned dma_in_use:1;
@@ -988,7 +1005,7 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
988 * blocksize is at least that large. Blocksize is 1005 * blocksize is at least that large. Blocksize is
989 * usually 512 bytes; but not for some SD reads. 1006 * usually 512 bytes; but not for some SD reads.
990 */ 1007 */
991 burst = cpu_is_omap15xx() ? 32 : 64; 1008 burst = mmc_omap15xx() ? 32 : 64;
992 if (burst > data->blksz) 1009 if (burst > data->blksz)
993 burst = data->blksz; 1010 burst = data->blksz;
994 1011
@@ -1104,8 +1121,7 @@ static void mmc_omap_set_power(struct mmc_omap_slot *slot, int power_on,
1104 if (slot->pdata->set_power != NULL) 1121 if (slot->pdata->set_power != NULL)
1105 slot->pdata->set_power(mmc_dev(slot->mmc), slot->id, power_on, 1122 slot->pdata->set_power(mmc_dev(slot->mmc), slot->id, power_on,
1106 vdd); 1123 vdd);
1107 1124 if (mmc_omap2()) {
1108 if (cpu_is_omap24xx()) {
1109 u16 w; 1125 u16 w;
1110 1126
1111 if (power_on) { 1127 if (power_on) {
@@ -1239,7 +1255,7 @@ static int __devinit mmc_omap_new_slot(struct mmc_omap_host *host, int id)
1239 mmc->ops = &mmc_omap_ops; 1255 mmc->ops = &mmc_omap_ops;
1240 mmc->f_min = 400000; 1256 mmc->f_min = 400000;
1241 1257
1242 if (cpu_class_is_omap2()) 1258 if (mmc_omap2())
1243 mmc->f_max = 48000000; 1259 mmc->f_max = 48000000;
1244 else 1260 else
1245 mmc->f_max = 24000000; 1261 mmc->f_max = 24000000;
@@ -1359,6 +1375,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev)
1359 init_waitqueue_head(&host->slot_wq); 1375 init_waitqueue_head(&host->slot_wq);
1360 1376
1361 host->pdata = pdata; 1377 host->pdata = pdata;
1378 host->features = host->pdata->slots[0].features;
1362 host->dev = &pdev->dev; 1379 host->dev = &pdev->dev;
1363 platform_set_drvdata(pdev, host); 1380 platform_set_drvdata(pdev, host);
1364 1381
@@ -1391,7 +1408,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev)
1391 host->dma_tx_burst = -1; 1408 host->dma_tx_burst = -1;
1392 host->dma_rx_burst = -1; 1409 host->dma_rx_burst = -1;
1393 1410
1394 if (cpu_is_omap24xx()) 1411 if (mmc_omap2())
1395 sig = host->id == 0 ? OMAP24XX_DMA_MMC1_TX : OMAP24XX_DMA_MMC2_TX; 1412 sig = host->id == 0 ? OMAP24XX_DMA_MMC1_TX : OMAP24XX_DMA_MMC2_TX;
1396 else 1413 else
1397 sig = host->id == 0 ? OMAP_DMA_MMC_TX : OMAP_DMA_MMC2_TX; 1414 sig = host->id == 0 ? OMAP_DMA_MMC_TX : OMAP_DMA_MMC2_TX;
@@ -1407,7 +1424,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev)
1407 dev_warn(host->dev, "unable to obtain TX DMA engine channel %u\n", 1424 dev_warn(host->dev, "unable to obtain TX DMA engine channel %u\n",
1408 sig); 1425 sig);
1409#endif 1426#endif
1410 if (cpu_is_omap24xx()) 1427 if (mmc_omap2())
1411 sig = host->id == 0 ? OMAP24XX_DMA_MMC1_RX : OMAP24XX_DMA_MMC2_RX; 1428 sig = host->id == 0 ? OMAP24XX_DMA_MMC1_RX : OMAP24XX_DMA_MMC2_RX;
1412 else 1429 else
1413 sig = host->id == 0 ? OMAP_DMA_MMC_RX : OMAP_DMA_MMC2_RX; 1430 sig = host->id == 0 ? OMAP_DMA_MMC_RX : OMAP_DMA_MMC2_RX;
@@ -1435,7 +1452,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev)
1435 } 1452 }
1436 1453
1437 host->nr_slots = pdata->nr_slots; 1454 host->nr_slots = pdata->nr_slots;
1438 host->reg_shift = (cpu_is_omap7xx() ? 1 : 2); 1455 host->reg_shift = (mmc_omap7xx() ? 1 : 2);
1439 1456
1440 host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0); 1457 host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
1441 if (!host->mmc_omap_wq) 1458 if (!host->mmc_omap_wq)
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index fedd258cc4ea..e7c185233b18 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -38,9 +38,7 @@
38#include <linux/gpio.h> 38#include <linux/gpio.h>
39#include <linux/regulator/consumer.h> 39#include <linux/regulator/consumer.h>
40#include <linux/pm_runtime.h> 40#include <linux/pm_runtime.h>
41#include <mach/hardware.h> 41#include <linux/platform_data/mmc-omap.h>
42#include <plat/mmc.h>
43#include <plat/cpu.h>
44 42
45/* OMAP HSMMC Host Controller Registers */ 43/* OMAP HSMMC Host Controller Registers */
46#define OMAP_HSMMC_SYSSTATUS 0x0014 44#define OMAP_HSMMC_SYSSTATUS 0x0014
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 5b3138620646..5c8978e90240 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -27,8 +27,7 @@
27#include <linux/bch.h> 27#include <linux/bch.h>
28#endif 28#endif
29 29
30#include <plat/dma.h> 30#include <plat-omap/dma-omap.h>
31#include <plat/gpmc.h>
32#include <linux/platform_data/mtd-nand-omap2.h> 31#include <linux/platform_data/mtd-nand-omap2.h>
33 32
34#define DRIVER_NAME "omap2-nand" 33#define DRIVER_NAME "omap2-nand"
@@ -106,10 +105,18 @@
106#define CS_MASK 0x7 105#define CS_MASK 0x7
107#define ENABLE_PREFETCH (0x1 << 7) 106#define ENABLE_PREFETCH (0x1 << 7)
108#define DMA_MPU_MODE_SHIFT 2 107#define DMA_MPU_MODE_SHIFT 2
108#define ECCSIZE0_SHIFT 12
109#define ECCSIZE1_SHIFT 22 109#define ECCSIZE1_SHIFT 22
110#define ECC1RESULTSIZE 0x1 110#define ECC1RESULTSIZE 0x1
111#define ECCCLEAR 0x100 111#define ECCCLEAR 0x100
112#define ECC1 0x1 112#define ECC1 0x1
113#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
114#define PREFETCH_FIFOTHRESHOLD(val) ((val) << 8)
115#define PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
116#define PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F)
117#define STATUS_BUFF_EMPTY 0x00000001
118
119#define OMAP24XX_DMA_GPMC 4
113 120
114/* oob info generated runtime depending on ecc algorithm and layout selected */ 121/* oob info generated runtime depending on ecc algorithm and layout selected */
115static struct nand_ecclayout omap_oobinfo; 122static struct nand_ecclayout omap_oobinfo;
@@ -269,7 +276,7 @@ static void omap_write_buf8(struct mtd_info *mtd, const u_char *buf, int len)
269 /* wait until buffer is available for write */ 276 /* wait until buffer is available for write */
270 do { 277 do {
271 status = readl(info->reg.gpmc_status) & 278 status = readl(info->reg.gpmc_status) &
272 GPMC_STATUS_BUFF_EMPTY; 279 STATUS_BUFF_EMPTY;
273 } while (!status); 280 } while (!status);
274 } 281 }
275} 282}
@@ -307,7 +314,7 @@ static void omap_write_buf16(struct mtd_info *mtd, const u_char * buf, int len)
307 /* wait until buffer is available for write */ 314 /* wait until buffer is available for write */
308 do { 315 do {
309 status = readl(info->reg.gpmc_status) & 316 status = readl(info->reg.gpmc_status) &
310 GPMC_STATUS_BUFF_EMPTY; 317 STATUS_BUFF_EMPTY;
311 } while (!status); 318 } while (!status);
312 } 319 }
313} 320}
@@ -348,7 +355,7 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char *buf, int len)
348 } else { 355 } else {
349 do { 356 do {
350 r_count = readl(info->reg.gpmc_prefetch_status); 357 r_count = readl(info->reg.gpmc_prefetch_status);
351 r_count = GPMC_PREFETCH_STATUS_FIFO_CNT(r_count); 358 r_count = PREFETCH_STATUS_FIFO_CNT(r_count);
352 r_count = r_count >> 2; 359 r_count = r_count >> 2;
353 ioread32_rep(info->nand.IO_ADDR_R, p, r_count); 360 ioread32_rep(info->nand.IO_ADDR_R, p, r_count);
354 p += r_count; 361 p += r_count;
@@ -395,7 +402,7 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
395 } else { 402 } else {
396 while (len) { 403 while (len) {
397 w_count = readl(info->reg.gpmc_prefetch_status); 404 w_count = readl(info->reg.gpmc_prefetch_status);
398 w_count = GPMC_PREFETCH_STATUS_FIFO_CNT(w_count); 405 w_count = PREFETCH_STATUS_FIFO_CNT(w_count);
399 w_count = w_count >> 1; 406 w_count = w_count >> 1;
400 for (i = 0; (i < w_count) && len; i++, len -= 2) 407 for (i = 0; (i < w_count) && len; i++, len -= 2)
401 iowrite16(*p++, info->nand.IO_ADDR_W); 408 iowrite16(*p++, info->nand.IO_ADDR_W);
@@ -407,7 +414,7 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
407 do { 414 do {
408 cpu_relax(); 415 cpu_relax();
409 val = readl(info->reg.gpmc_prefetch_status); 416 val = readl(info->reg.gpmc_prefetch_status);
410 val = GPMC_PREFETCH_STATUS_COUNT(val); 417 val = PREFETCH_STATUS_COUNT(val);
411 } while (val && (tim++ < limit)); 418 } while (val && (tim++ < limit));
412 419
413 /* disable and stop the PFPW engine */ 420 /* disable and stop the PFPW engine */
@@ -493,7 +500,7 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
493 do { 500 do {
494 cpu_relax(); 501 cpu_relax();
495 val = readl(info->reg.gpmc_prefetch_status); 502 val = readl(info->reg.gpmc_prefetch_status);
496 val = GPMC_PREFETCH_STATUS_COUNT(val); 503 val = PREFETCH_STATUS_COUNT(val);
497 } while (val && (tim++ < limit)); 504 } while (val && (tim++ < limit));
498 505
499 /* disable and stop the PFPW engine */ 506 /* disable and stop the PFPW engine */
@@ -556,7 +563,7 @@ static irqreturn_t omap_nand_irq(int this_irq, void *dev)
556 u32 bytes; 563 u32 bytes;
557 564
558 bytes = readl(info->reg.gpmc_prefetch_status); 565 bytes = readl(info->reg.gpmc_prefetch_status);
559 bytes = GPMC_PREFETCH_STATUS_FIFO_CNT(bytes); 566 bytes = PREFETCH_STATUS_FIFO_CNT(bytes);
560 bytes = bytes & 0xFFFC; /* io in multiple of 4 bytes */ 567 bytes = bytes & 0xFFFC; /* io in multiple of 4 bytes */
561 if (info->iomode == OMAP_NAND_IO_WRITE) { /* checks for write io */ 568 if (info->iomode == OMAP_NAND_IO_WRITE) { /* checks for write io */
562 if (this_irq == info->gpmc_irq_count) 569 if (this_irq == info->gpmc_irq_count)
@@ -682,7 +689,7 @@ static void omap_write_buf_irq_pref(struct mtd_info *mtd,
682 limit = (loops_per_jiffy * msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS)); 689 limit = (loops_per_jiffy * msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS));
683 do { 690 do {
684 val = readl(info->reg.gpmc_prefetch_status); 691 val = readl(info->reg.gpmc_prefetch_status);
685 val = GPMC_PREFETCH_STATUS_COUNT(val); 692 val = PREFETCH_STATUS_COUNT(val);
686 cpu_relax(); 693 cpu_relax();
687 } while (val && (tim++ < limit)); 694 } while (val && (tim++ < limit));
688 695
@@ -996,7 +1003,7 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
996 cond_resched(); 1003 cond_resched();
997 } 1004 }
998 1005
999 status = gpmc_nand_read(info->gpmc_cs, GPMC_NAND_DATA); 1006 status = readb(info->reg.gpmc_nand_data);
1000 return status; 1007 return status;
1001} 1008}
1002 1009
@@ -1029,19 +1036,45 @@ static int omap_dev_ready(struct mtd_info *mtd)
1029static void omap3_enable_hwecc_bch(struct mtd_info *mtd, int mode) 1036static void omap3_enable_hwecc_bch(struct mtd_info *mtd, int mode)
1030{ 1037{
1031 int nerrors; 1038 int nerrors;
1032 unsigned int dev_width; 1039 unsigned int dev_width, nsectors;
1033 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 1040 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
1034 mtd); 1041 mtd);
1035 struct nand_chip *chip = mtd->priv; 1042 struct nand_chip *chip = mtd->priv;
1043 u32 val;
1036 1044
1037 nerrors = (info->nand.ecc.bytes == 13) ? 8 : 4; 1045 nerrors = (info->nand.ecc.bytes == 13) ? 8 : 4;
1038 dev_width = (chip->options & NAND_BUSWIDTH_16) ? 1 : 0; 1046 dev_width = (chip->options & NAND_BUSWIDTH_16) ? 1 : 0;
1047 nsectors = 1;
1039 /* 1048 /*
1040 * Program GPMC to perform correction on one 512-byte sector at a time. 1049 * Program GPMC to perform correction on one 512-byte sector at a time.
1041 * Using 4 sectors at a time (i.e. ecc.size = 2048) is also possible and 1050 * Using 4 sectors at a time (i.e. ecc.size = 2048) is also possible and
1042 * gives a slight (5%) performance gain (but requires additional code). 1051 * gives a slight (5%) performance gain (but requires additional code).
1043 */ 1052 */
1044 (void)gpmc_enable_hwecc_bch(info->gpmc_cs, mode, dev_width, 1, nerrors); 1053
1054 writel(ECC1, info->reg.gpmc_ecc_control);
1055
1056 /*
1057 * When using BCH, sector size is hardcoded to 512 bytes.
1058 * Here we are using wrapping mode 6 both for reading and writing, with:
1059 * size0 = 0 (no additional protected byte in spare area)
1060 * size1 = 32 (skip 32 nibbles = 16 bytes per sector in spare area)
1061 */
1062 val = (32 << ECCSIZE1_SHIFT) | (0 << ECCSIZE0_SHIFT);
1063 writel(val, info->reg.gpmc_ecc_size_config);
1064
1065 /* BCH configuration */
1066 val = ((1 << 16) | /* enable BCH */
1067 (((nerrors == 8) ? 1 : 0) << 12) | /* 8 or 4 bits */
1068 (0x06 << 8) | /* wrap mode = 6 */
1069 (dev_width << 7) | /* bus width */
1070 (((nsectors-1) & 0x7) << 4) | /* number of sectors */
1071 (info->gpmc_cs << 1) | /* ECC CS */
1072 (0x1)); /* enable ECC */
1073
1074 writel(val, info->reg.gpmc_ecc_config);
1075
1076 /* clear ecc and enable bits */
1077 writel(ECCCLEAR | ECC1, info->reg.gpmc_ecc_control);
1045} 1078}
1046 1079
1047/** 1080/**
@@ -1055,7 +1088,32 @@ static int omap3_calculate_ecc_bch4(struct mtd_info *mtd, const u_char *dat,
1055{ 1088{
1056 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 1089 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
1057 mtd); 1090 mtd);
1058 return gpmc_calculate_ecc_bch4(info->gpmc_cs, dat, ecc_code); 1091 unsigned long nsectors, val1, val2;
1092 int i;
1093
1094 nsectors = ((readl(info->reg.gpmc_ecc_config) >> 4) & 0x7) + 1;
1095
1096 for (i = 0; i < nsectors; i++) {
1097
1098 /* Read hw-computed remainder */
1099 val1 = readl(info->reg.gpmc_bch_result0[i]);
1100 val2 = readl(info->reg.gpmc_bch_result1[i]);
1101
1102 /*
1103 * Add constant polynomial to remainder, in order to get an ecc
1104 * sequence of 0xFFs for a buffer filled with 0xFFs; and
1105 * left-justify the resulting polynomial.
1106 */
1107 *ecc_code++ = 0x28 ^ ((val2 >> 12) & 0xFF);
1108 *ecc_code++ = 0x13 ^ ((val2 >> 4) & 0xFF);
1109 *ecc_code++ = 0xcc ^ (((val2 & 0xF) << 4)|((val1 >> 28) & 0xF));
1110 *ecc_code++ = 0x39 ^ ((val1 >> 20) & 0xFF);
1111 *ecc_code++ = 0x96 ^ ((val1 >> 12) & 0xFF);
1112 *ecc_code++ = 0xac ^ ((val1 >> 4) & 0xFF);
1113 *ecc_code++ = 0x7f ^ ((val1 & 0xF) << 4);
1114 }
1115
1116 return 0;
1059} 1117}
1060 1118
1061/** 1119/**
@@ -1069,7 +1127,39 @@ static int omap3_calculate_ecc_bch8(struct mtd_info *mtd, const u_char *dat,
1069{ 1127{
1070 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 1128 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
1071 mtd); 1129 mtd);
1072 return gpmc_calculate_ecc_bch8(info->gpmc_cs, dat, ecc_code); 1130 unsigned long nsectors, val1, val2, val3, val4;
1131 int i;
1132
1133 nsectors = ((readl(info->reg.gpmc_ecc_config) >> 4) & 0x7) + 1;
1134
1135 for (i = 0; i < nsectors; i++) {
1136
1137 /* Read hw-computed remainder */
1138 val1 = readl(info->reg.gpmc_bch_result0[i]);
1139 val2 = readl(info->reg.gpmc_bch_result1[i]);
1140 val3 = readl(info->reg.gpmc_bch_result2[i]);
1141 val4 = readl(info->reg.gpmc_bch_result3[i]);
1142
1143 /*
1144 * Add constant polynomial to remainder, in order to get an ecc
1145 * sequence of 0xFFs for a buffer filled with 0xFFs.
1146 */
1147 *ecc_code++ = 0xef ^ (val4 & 0xFF);
1148 *ecc_code++ = 0x51 ^ ((val3 >> 24) & 0xFF);
1149 *ecc_code++ = 0x2e ^ ((val3 >> 16) & 0xFF);
1150 *ecc_code++ = 0x09 ^ ((val3 >> 8) & 0xFF);
1151 *ecc_code++ = 0xed ^ (val3 & 0xFF);
1152 *ecc_code++ = 0x93 ^ ((val2 >> 24) & 0xFF);
1153 *ecc_code++ = 0x9a ^ ((val2 >> 16) & 0xFF);
1154 *ecc_code++ = 0xc2 ^ ((val2 >> 8) & 0xFF);
1155 *ecc_code++ = 0x97 ^ (val2 & 0xFF);
1156 *ecc_code++ = 0x79 ^ ((val1 >> 24) & 0xFF);
1157 *ecc_code++ = 0xe5 ^ ((val1 >> 16) & 0xFF);
1158 *ecc_code++ = 0x24 ^ ((val1 >> 8) & 0xFF);
1159 *ecc_code++ = 0xb5 ^ (val1 & 0xFF);
1160 }
1161
1162 return 0;
1073} 1163}
1074 1164
1075/** 1165/**
@@ -1125,7 +1215,7 @@ static void omap3_free_bch(struct mtd_info *mtd)
1125 */ 1215 */
1126static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt) 1216static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt)
1127{ 1217{
1128 int ret, max_errors; 1218 int max_errors;
1129 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 1219 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
1130 mtd); 1220 mtd);
1131#ifdef CONFIG_MTD_NAND_OMAP_BCH8 1221#ifdef CONFIG_MTD_NAND_OMAP_BCH8
@@ -1142,11 +1232,6 @@ static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt)
1142 goto fail; 1232 goto fail;
1143 } 1233 }
1144 1234
1145 /* initialize GPMC BCH engine */
1146 ret = gpmc_init_hwecc_bch(info->gpmc_cs, 1, max_errors);
1147 if (ret)
1148 goto fail;
1149
1150 /* software bch library is only used to detect and locate errors */ 1235 /* software bch library is only used to detect and locate errors */
1151 info->bch = init_bch(13, max_errors, 0x201b /* hw polynomial */); 1236 info->bch = init_bch(13, max_errors, 0x201b /* hw polynomial */);
1152 if (!info->bch) 1237 if (!info->bch)
@@ -1513,7 +1598,7 @@ static int omap_nand_remove(struct platform_device *pdev)
1513 /* Release NAND device, its internal structures and partitions */ 1598 /* Release NAND device, its internal structures and partitions */
1514 nand_release(&info->mtd); 1599 nand_release(&info->mtd);
1515 iounmap(info->nand.IO_ADDR_R); 1600 iounmap(info->nand.IO_ADDR_R);
1516 release_mem_region(info->phys_base, NAND_IO_SIZE); 1601 release_mem_region(info->phys_base, info->mem_size);
1517 kfree(info); 1602 kfree(info);
1518 return 0; 1603 return 0;
1519} 1604}
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index 1961be985171..99f96e19ebea 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -38,12 +38,10 @@
38#include <linux/regulator/consumer.h> 38#include <linux/regulator/consumer.h>
39 39
40#include <asm/mach/flash.h> 40#include <asm/mach/flash.h>
41#include <plat/gpmc.h>
42#include <linux/platform_data/mtd-onenand-omap2.h> 41#include <linux/platform_data/mtd-onenand-omap2.h>
43#include <asm/gpio.h> 42#include <asm/gpio.h>
44 43
45#include <plat/dma.h> 44#include <plat-omap/dma-omap.h>
46#include <plat/cpu.h>
47 45
48#define DRIVER_NAME "omap2-onenand" 46#define DRIVER_NAME "omap2-onenand"
49 47
@@ -63,6 +61,7 @@ struct omap2_onenand {
63 int freq; 61 int freq;
64 int (*setup)(void __iomem *base, int *freq_ptr); 62 int (*setup)(void __iomem *base, int *freq_ptr);
65 struct regulator *regulator; 63 struct regulator *regulator;
64 u8 flags;
66}; 65};
67 66
68static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data) 67static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)
@@ -155,7 +154,7 @@ static int omap2_onenand_wait(struct mtd_info *mtd, int state)
155 if (!(syscfg & ONENAND_SYS_CFG1_IOBE)) { 154 if (!(syscfg & ONENAND_SYS_CFG1_IOBE)) {
156 syscfg |= ONENAND_SYS_CFG1_IOBE; 155 syscfg |= ONENAND_SYS_CFG1_IOBE;
157 write_reg(c, syscfg, ONENAND_REG_SYS_CFG1); 156 write_reg(c, syscfg, ONENAND_REG_SYS_CFG1);
158 if (cpu_is_omap34xx()) 157 if (c->flags & ONENAND_IN_OMAP34XX)
159 /* Add a delay to let GPIO settle */ 158 /* Add a delay to let GPIO settle */
160 syscfg = read_reg(c, ONENAND_REG_SYS_CFG1); 159 syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);
161 } 160 }
@@ -446,13 +445,19 @@ out_copy:
446 445
447#else 446#else
448 447
449int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area, 448static int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area,
450 unsigned char *buffer, int offset, 449 unsigned char *buffer, int offset,
451 size_t count); 450 size_t count)
451{
452 return -ENOSYS;
453}
452 454
453int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area, 455static int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area,
454 const unsigned char *buffer, 456 const unsigned char *buffer,
455 int offset, size_t count); 457 int offset, size_t count)
458{
459 return -ENOSYS;
460}
456 461
457#endif 462#endif
458 463
@@ -550,13 +555,19 @@ static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,
550 555
551#else 556#else
552 557
553int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area, 558static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,
554 unsigned char *buffer, int offset, 559 unsigned char *buffer, int offset,
555 size_t count); 560 size_t count)
561{
562 return -ENOSYS;
563}
556 564
557int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area, 565static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,
558 const unsigned char *buffer, 566 const unsigned char *buffer,
559 int offset, size_t count); 567 int offset, size_t count)
568{
569 return -ENOSYS;
570}
560 571
561#endif 572#endif
562 573
@@ -639,6 +650,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
639 650
640 init_completion(&c->irq_done); 651 init_completion(&c->irq_done);
641 init_completion(&c->dma_done); 652 init_completion(&c->dma_done);
653 c->flags = pdata->flags;
642 c->gpmc_cs = pdata->cs; 654 c->gpmc_cs = pdata->cs;
643 c->gpio_irq = pdata->gpio_irq; 655 c->gpio_irq = pdata->gpio_irq;
644 c->dma_channel = pdata->dma_channel; 656 c->dma_channel = pdata->dma_channel;
@@ -729,7 +741,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
729 this = &c->onenand; 741 this = &c->onenand;
730 if (c->dma_channel >= 0) { 742 if (c->dma_channel >= 0) {
731 this->wait = omap2_onenand_wait; 743 this->wait = omap2_onenand_wait;
732 if (cpu_is_omap34xx()) { 744 if (c->flags & ONENAND_IN_OMAP34XX) {
733 this->read_bufferram = omap3_onenand_read_bufferram; 745 this->read_bufferram = omap3_onenand_read_bufferram;
734 this->write_bufferram = omap3_onenand_write_bufferram; 746 this->write_bufferram = omap3_onenand_write_bufferram;
735 } else { 747 } else {
@@ -803,7 +815,6 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
803 } 815 }
804 iounmap(c->onenand.base); 816 iounmap(c->onenand.base);
805 release_mem_region(c->phys_base, c->mem_size); 817 release_mem_region(c->phys_base, c->mem_size);
806 gpmc_cs_free(c->gpmc_cs);
807 kfree(c); 818 kfree(c);
808 819
809 return 0; 820 return 0;
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index fa74efe82206..25c4b1993b3d 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -25,7 +25,7 @@
25#include <asm/sizes.h> 25#include <asm/sizes.h>
26 26
27#include <mach/mux.h> 27#include <mach/mux.h>
28#include <plat/tc.h> 28#include <mach/tc.h>
29 29
30 30
31/* NOTE: don't expect this to support many I/O cards. The 16xx chips have 31/* NOTE: don't expect this to support many I/O cards. The 16xx chips have
diff --git a/drivers/staging/tidspbridge/include/dspbridge/host_os.h b/drivers/staging/tidspbridge/include/dspbridge/host_os.h
index 5e2f4d82d925..7f3a1db31619 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/host_os.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/host_os.h
@@ -40,7 +40,6 @@
40#include <linux/vmalloc.h> 40#include <linux/vmalloc.h>
41#include <linux/ioport.h> 41#include <linux/ioport.h>
42#include <linux/platform_device.h> 42#include <linux/platform_device.h>
43#include <plat/clock.h>
44#include <linux/clk.h> 43#include <linux/clk.h>
45#include <plat/mailbox.h> 44#include <plat/mailbox.h>
46#include <linux/pagemap.h> 45#include <linux/pagemap.h>
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 8c0b7b42319c..60b076cc4e20 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -73,10 +73,42 @@
73#define ECHO_OP_SET_CANON_COL 0x81 73#define ECHO_OP_SET_CANON_COL 0x81
74#define ECHO_OP_ERASE_TAB 0x82 74#define ECHO_OP_ERASE_TAB 0x82
75 75
76struct n_tty_data {
77 unsigned int column;
78 unsigned long overrun_time;
79 int num_overrun;
80
81 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
82 unsigned char echo_overrun:1;
83
84 DECLARE_BITMAP(process_char_map, 256);
85 DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE);
86
87 char *read_buf;
88 int read_head;
89 int read_tail;
90 int read_cnt;
91
92 unsigned char *echo_buf;
93 unsigned int echo_pos;
94 unsigned int echo_cnt;
95
96 int canon_data;
97 unsigned long canon_head;
98 unsigned int canon_column;
99
100 struct mutex atomic_read_lock;
101 struct mutex output_lock;
102 struct mutex echo_lock;
103 spinlock_t read_lock;
104};
105
76static inline int tty_put_user(struct tty_struct *tty, unsigned char x, 106static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
77 unsigned char __user *ptr) 107 unsigned char __user *ptr)
78{ 108{
79 tty_audit_add_data(tty, &x, 1); 109 struct n_tty_data *ldata = tty->disc_data;
110
111 tty_audit_add_data(tty, &x, 1, ldata->icanon);
80 return put_user(x, ptr); 112 return put_user(x, ptr);
81} 113}
82 114
@@ -92,17 +124,18 @@ static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
92 124
93static void n_tty_set_room(struct tty_struct *tty) 125static void n_tty_set_room(struct tty_struct *tty)
94{ 126{
127 struct n_tty_data *ldata = tty->disc_data;
95 int left; 128 int left;
96 int old_left; 129 int old_left;
97 130
98 /* tty->read_cnt is not read locked ? */ 131 /* ldata->read_cnt is not read locked ? */
99 if (I_PARMRK(tty)) { 132 if (I_PARMRK(tty)) {
100 /* Multiply read_cnt by 3, since each byte might take up to 133 /* Multiply read_cnt by 3, since each byte might take up to
101 * three times as many spaces when PARMRK is set (depending on 134 * three times as many spaces when PARMRK is set (depending on
102 * its flags, e.g. parity error). */ 135 * its flags, e.g. parity error). */
103 left = N_TTY_BUF_SIZE - tty->read_cnt * 3 - 1; 136 left = N_TTY_BUF_SIZE - ldata->read_cnt * 3 - 1;
104 } else 137 } else
105 left = N_TTY_BUF_SIZE - tty->read_cnt - 1; 138 left = N_TTY_BUF_SIZE - ldata->read_cnt - 1;
106 139
107 /* 140 /*
108 * If we are doing input canonicalization, and there are no 141 * If we are doing input canonicalization, and there are no
@@ -111,44 +144,47 @@ static void n_tty_set_room(struct tty_struct *tty)
111 * characters will be beeped. 144 * characters will be beeped.
112 */ 145 */
113 if (left <= 0) 146 if (left <= 0)
114 left = tty->icanon && !tty->canon_data; 147 left = ldata->icanon && !ldata->canon_data;
115 old_left = tty->receive_room; 148 old_left = tty->receive_room;
116 tty->receive_room = left; 149 tty->receive_room = left;
117 150
118 /* Did this open up the receive buffer? We may need to flip */ 151 /* Did this open up the receive buffer? We may need to flip */
119 if (left && !old_left) 152 if (left && !old_left) {
120 schedule_work(&tty->buf.work); 153 WARN_RATELIMIT(tty->port->itty == NULL,
154 "scheduling with invalid itty");
155 schedule_work(&tty->port->buf.work);
156 }
121} 157}
122 158
123static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty) 159static void put_tty_queue_nolock(unsigned char c, struct n_tty_data *ldata)
124{ 160{
125 if (tty->read_cnt < N_TTY_BUF_SIZE) { 161 if (ldata->read_cnt < N_TTY_BUF_SIZE) {
126 tty->read_buf[tty->read_head] = c; 162 ldata->read_buf[ldata->read_head] = c;
127 tty->read_head = (tty->read_head + 1) & (N_TTY_BUF_SIZE-1); 163 ldata->read_head = (ldata->read_head + 1) & (N_TTY_BUF_SIZE-1);
128 tty->read_cnt++; 164 ldata->read_cnt++;
129 } 165 }
130} 166}
131 167
132/** 168/**
133 * put_tty_queue - add character to tty 169 * put_tty_queue - add character to tty
134 * @c: character 170 * @c: character
135 * @tty: tty device 171 * @ldata: n_tty data
136 * 172 *
137 * Add a character to the tty read_buf queue. This is done under the 173 * Add a character to the tty read_buf queue. This is done under the
138 * read_lock to serialize character addition and also to protect us 174 * read_lock to serialize character addition and also to protect us
139 * against parallel reads or flushes 175 * against parallel reads or flushes
140 */ 176 */
141 177
142static void put_tty_queue(unsigned char c, struct tty_struct *tty) 178static void put_tty_queue(unsigned char c, struct n_tty_data *ldata)
143{ 179{
144 unsigned long flags; 180 unsigned long flags;
145 /* 181 /*
146 * The problem of stomping on the buffers ends here. 182 * The problem of stomping on the buffers ends here.
147 * Why didn't anyone see this one coming? --AJK 183 * Why didn't anyone see this one coming? --AJK
148 */ 184 */
149 spin_lock_irqsave(&tty->read_lock, flags); 185 spin_lock_irqsave(&ldata->read_lock, flags);
150 put_tty_queue_nolock(c, tty); 186 put_tty_queue_nolock(c, ldata);
151 spin_unlock_irqrestore(&tty->read_lock, flags); 187 spin_unlock_irqrestore(&ldata->read_lock, flags);
152} 188}
153 189
154/** 190/**
@@ -179,18 +215,19 @@ static void check_unthrottle(struct tty_struct *tty)
179 215
180static void reset_buffer_flags(struct tty_struct *tty) 216static void reset_buffer_flags(struct tty_struct *tty)
181{ 217{
218 struct n_tty_data *ldata = tty->disc_data;
182 unsigned long flags; 219 unsigned long flags;
183 220
184 spin_lock_irqsave(&tty->read_lock, flags); 221 spin_lock_irqsave(&ldata->read_lock, flags);
185 tty->read_head = tty->read_tail = tty->read_cnt = 0; 222 ldata->read_head = ldata->read_tail = ldata->read_cnt = 0;
186 spin_unlock_irqrestore(&tty->read_lock, flags); 223 spin_unlock_irqrestore(&ldata->read_lock, flags);
187 224
188 mutex_lock(&tty->echo_lock); 225 mutex_lock(&ldata->echo_lock);
189 tty->echo_pos = tty->echo_cnt = tty->echo_overrun = 0; 226 ldata->echo_pos = ldata->echo_cnt = ldata->echo_overrun = 0;
190 mutex_unlock(&tty->echo_lock); 227 mutex_unlock(&ldata->echo_lock);
191 228
192 tty->canon_head = tty->canon_data = tty->erasing = 0; 229 ldata->canon_head = ldata->canon_data = ldata->erasing = 0;
193 memset(&tty->read_flags, 0, sizeof tty->read_flags); 230 bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
194 n_tty_set_room(tty); 231 n_tty_set_room(tty);
195} 232}
196 233
@@ -235,18 +272,19 @@ static void n_tty_flush_buffer(struct tty_struct *tty)
235 272
236static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) 273static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
237{ 274{
275 struct n_tty_data *ldata = tty->disc_data;
238 unsigned long flags; 276 unsigned long flags;
239 ssize_t n = 0; 277 ssize_t n = 0;
240 278
241 spin_lock_irqsave(&tty->read_lock, flags); 279 spin_lock_irqsave(&ldata->read_lock, flags);
242 if (!tty->icanon) { 280 if (!ldata->icanon) {
243 n = tty->read_cnt; 281 n = ldata->read_cnt;
244 } else if (tty->canon_data) { 282 } else if (ldata->canon_data) {
245 n = (tty->canon_head > tty->read_tail) ? 283 n = (ldata->canon_head > ldata->read_tail) ?
246 tty->canon_head - tty->read_tail : 284 ldata->canon_head - ldata->read_tail :
247 tty->canon_head + (N_TTY_BUF_SIZE - tty->read_tail); 285 ldata->canon_head + (N_TTY_BUF_SIZE - ldata->read_tail);
248 } 286 }
249 spin_unlock_irqrestore(&tty->read_lock, flags); 287 spin_unlock_irqrestore(&ldata->read_lock, flags);
250 return n; 288 return n;
251} 289}
252 290
@@ -301,6 +339,7 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty)
301 339
302static int do_output_char(unsigned char c, struct tty_struct *tty, int space) 340static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
303{ 341{
342 struct n_tty_data *ldata = tty->disc_data;
304 int spaces; 343 int spaces;
305 344
306 if (!space) 345 if (!space)
@@ -309,48 +348,48 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
309 switch (c) { 348 switch (c) {
310 case '\n': 349 case '\n':
311 if (O_ONLRET(tty)) 350 if (O_ONLRET(tty))
312 tty->column = 0; 351 ldata->column = 0;
313 if (O_ONLCR(tty)) { 352 if (O_ONLCR(tty)) {
314 if (space < 2) 353 if (space < 2)
315 return -1; 354 return -1;
316 tty->canon_column = tty->column = 0; 355 ldata->canon_column = ldata->column = 0;
317 tty->ops->write(tty, "\r\n", 2); 356 tty->ops->write(tty, "\r\n", 2);
318 return 2; 357 return 2;
319 } 358 }
320 tty->canon_column = tty->column; 359 ldata->canon_column = ldata->column;
321 break; 360 break;
322 case '\r': 361 case '\r':
323 if (O_ONOCR(tty) && tty->column == 0) 362 if (O_ONOCR(tty) && ldata->column == 0)
324 return 0; 363 return 0;
325 if (O_OCRNL(tty)) { 364 if (O_OCRNL(tty)) {
326 c = '\n'; 365 c = '\n';
327 if (O_ONLRET(tty)) 366 if (O_ONLRET(tty))
328 tty->canon_column = tty->column = 0; 367 ldata->canon_column = ldata->column = 0;
329 break; 368 break;
330 } 369 }
331 tty->canon_column = tty->column = 0; 370 ldata->canon_column = ldata->column = 0;
332 break; 371 break;
333 case '\t': 372 case '\t':
334 spaces = 8 - (tty->column & 7); 373 spaces = 8 - (ldata->column & 7);
335 if (O_TABDLY(tty) == XTABS) { 374 if (O_TABDLY(tty) == XTABS) {
336 if (space < spaces) 375 if (space < spaces)
337 return -1; 376 return -1;
338 tty->column += spaces; 377 ldata->column += spaces;
339 tty->ops->write(tty, " ", spaces); 378 tty->ops->write(tty, " ", spaces);
340 return spaces; 379 return spaces;
341 } 380 }
342 tty->column += spaces; 381 ldata->column += spaces;
343 break; 382 break;
344 case '\b': 383 case '\b':
345 if (tty->column > 0) 384 if (ldata->column > 0)
346 tty->column--; 385 ldata->column--;
347 break; 386 break;
348 default: 387 default:
349 if (!iscntrl(c)) { 388 if (!iscntrl(c)) {
350 if (O_OLCUC(tty)) 389 if (O_OLCUC(tty))
351 c = toupper(c); 390 c = toupper(c);
352 if (!is_continuation(c, tty)) 391 if (!is_continuation(c, tty))
353 tty->column++; 392 ldata->column++;
354 } 393 }
355 break; 394 break;
356 } 395 }
@@ -375,14 +414,15 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
375 414
376static int process_output(unsigned char c, struct tty_struct *tty) 415static int process_output(unsigned char c, struct tty_struct *tty)
377{ 416{
417 struct n_tty_data *ldata = tty->disc_data;
378 int space, retval; 418 int space, retval;
379 419
380 mutex_lock(&tty->output_lock); 420 mutex_lock(&ldata->output_lock);
381 421
382 space = tty_write_room(tty); 422 space = tty_write_room(tty);
383 retval = do_output_char(c, tty, space); 423 retval = do_output_char(c, tty, space);
384 424
385 mutex_unlock(&tty->output_lock); 425 mutex_unlock(&ldata->output_lock);
386 if (retval < 0) 426 if (retval < 0)
387 return -1; 427 return -1;
388 else 428 else
@@ -411,15 +451,16 @@ static int process_output(unsigned char c, struct tty_struct *tty)
411static ssize_t process_output_block(struct tty_struct *tty, 451static ssize_t process_output_block(struct tty_struct *tty,
412 const unsigned char *buf, unsigned int nr) 452 const unsigned char *buf, unsigned int nr)
413{ 453{
454 struct n_tty_data *ldata = tty->disc_data;
414 int space; 455 int space;
415 int i; 456 int i;
416 const unsigned char *cp; 457 const unsigned char *cp;
417 458
418 mutex_lock(&tty->output_lock); 459 mutex_lock(&ldata->output_lock);
419 460
420 space = tty_write_room(tty); 461 space = tty_write_room(tty);
421 if (!space) { 462 if (!space) {
422 mutex_unlock(&tty->output_lock); 463 mutex_unlock(&ldata->output_lock);
423 return 0; 464 return 0;
424 } 465 }
425 if (nr > space) 466 if (nr > space)
@@ -431,30 +472,30 @@ static ssize_t process_output_block(struct tty_struct *tty,
431 switch (c) { 472 switch (c) {
432 case '\n': 473 case '\n':
433 if (O_ONLRET(tty)) 474 if (O_ONLRET(tty))
434 tty->column = 0; 475 ldata->column = 0;
435 if (O_ONLCR(tty)) 476 if (O_ONLCR(tty))
436 goto break_out; 477 goto break_out;
437 tty->canon_column = tty->column; 478 ldata->canon_column = ldata->column;
438 break; 479 break;
439 case '\r': 480 case '\r':
440 if (O_ONOCR(tty) && tty->column == 0) 481 if (O_ONOCR(tty) && ldata->column == 0)
441 goto break_out; 482 goto break_out;
442 if (O_OCRNL(tty)) 483 if (O_OCRNL(tty))
443 goto break_out; 484 goto break_out;
444 tty->canon_column = tty->column = 0; 485 ldata->canon_column = ldata->column = 0;
445 break; 486 break;
446 case '\t': 487 case '\t':
447 goto break_out; 488 goto break_out;
448 case '\b': 489 case '\b':
449 if (tty->column > 0) 490 if (ldata->column > 0)
450 tty->column--; 491 ldata->column--;
451 break; 492 break;
452 default: 493 default:
453 if (!iscntrl(c)) { 494 if (!iscntrl(c)) {
454 if (O_OLCUC(tty)) 495 if (O_OLCUC(tty))
455 goto break_out; 496 goto break_out;
456 if (!is_continuation(c, tty)) 497 if (!is_continuation(c, tty))
457 tty->column++; 498 ldata->column++;
458 } 499 }
459 break; 500 break;
460 } 501 }
@@ -462,7 +503,7 @@ static ssize_t process_output_block(struct tty_struct *tty,
462break_out: 503break_out:
463 i = tty->ops->write(tty, buf, i); 504 i = tty->ops->write(tty, buf, i);
464 505
465 mutex_unlock(&tty->output_lock); 506 mutex_unlock(&ldata->output_lock);
466 return i; 507 return i;
467} 508}
468 509
@@ -494,21 +535,22 @@ break_out:
494 535
495static void process_echoes(struct tty_struct *tty) 536static void process_echoes(struct tty_struct *tty)
496{ 537{
538 struct n_tty_data *ldata = tty->disc_data;
497 int space, nr; 539 int space, nr;
498 unsigned char c; 540 unsigned char c;
499 unsigned char *cp, *buf_end; 541 unsigned char *cp, *buf_end;
500 542
501 if (!tty->echo_cnt) 543 if (!ldata->echo_cnt)
502 return; 544 return;
503 545
504 mutex_lock(&tty->output_lock); 546 mutex_lock(&ldata->output_lock);
505 mutex_lock(&tty->echo_lock); 547 mutex_lock(&ldata->echo_lock);
506 548
507 space = tty_write_room(tty); 549 space = tty_write_room(tty);
508 550
509 buf_end = tty->echo_buf + N_TTY_BUF_SIZE; 551 buf_end = ldata->echo_buf + N_TTY_BUF_SIZE;
510 cp = tty->echo_buf + tty->echo_pos; 552 cp = ldata->echo_buf + ldata->echo_pos;
511 nr = tty->echo_cnt; 553 nr = ldata->echo_cnt;
512 while (nr > 0) { 554 while (nr > 0) {
513 c = *cp; 555 c = *cp;
514 if (c == ECHO_OP_START) { 556 if (c == ECHO_OP_START) {
@@ -545,7 +587,7 @@ static void process_echoes(struct tty_struct *tty)
545 * Otherwise, tab spacing is normal. 587 * Otherwise, tab spacing is normal.
546 */ 588 */
547 if (!(num_chars & 0x80)) 589 if (!(num_chars & 0x80))
548 num_chars += tty->canon_column; 590 num_chars += ldata->canon_column;
549 num_bs = 8 - (num_chars & 7); 591 num_bs = 8 - (num_chars & 7);
550 592
551 if (num_bs > space) { 593 if (num_bs > space) {
@@ -555,22 +597,22 @@ static void process_echoes(struct tty_struct *tty)
555 space -= num_bs; 597 space -= num_bs;
556 while (num_bs--) { 598 while (num_bs--) {
557 tty_put_char(tty, '\b'); 599 tty_put_char(tty, '\b');
558 if (tty->column > 0) 600 if (ldata->column > 0)
559 tty->column--; 601 ldata->column--;
560 } 602 }
561 cp += 3; 603 cp += 3;
562 nr -= 3; 604 nr -= 3;
563 break; 605 break;
564 606
565 case ECHO_OP_SET_CANON_COL: 607 case ECHO_OP_SET_CANON_COL:
566 tty->canon_column = tty->column; 608 ldata->canon_column = ldata->column;
567 cp += 2; 609 cp += 2;
568 nr -= 2; 610 nr -= 2;
569 break; 611 break;
570 612
571 case ECHO_OP_MOVE_BACK_COL: 613 case ECHO_OP_MOVE_BACK_COL:
572 if (tty->column > 0) 614 if (ldata->column > 0)
573 tty->column--; 615 ldata->column--;
574 cp += 2; 616 cp += 2;
575 nr -= 2; 617 nr -= 2;
576 break; 618 break;
@@ -582,7 +624,7 @@ static void process_echoes(struct tty_struct *tty)
582 break; 624 break;
583 } 625 }
584 tty_put_char(tty, ECHO_OP_START); 626 tty_put_char(tty, ECHO_OP_START);
585 tty->column++; 627 ldata->column++;
586 space--; 628 space--;
587 cp += 2; 629 cp += 2;
588 nr -= 2; 630 nr -= 2;
@@ -604,7 +646,7 @@ static void process_echoes(struct tty_struct *tty)
604 } 646 }
605 tty_put_char(tty, '^'); 647 tty_put_char(tty, '^');
606 tty_put_char(tty, op ^ 0100); 648 tty_put_char(tty, op ^ 0100);
607 tty->column += 2; 649 ldata->column += 2;
608 space -= 2; 650 space -= 2;
609 cp += 2; 651 cp += 2;
610 nr -= 2; 652 nr -= 2;
@@ -635,20 +677,20 @@ static void process_echoes(struct tty_struct *tty)
635 } 677 }
636 678
637 if (nr == 0) { 679 if (nr == 0) {
638 tty->echo_pos = 0; 680 ldata->echo_pos = 0;
639 tty->echo_cnt = 0; 681 ldata->echo_cnt = 0;
640 tty->echo_overrun = 0; 682 ldata->echo_overrun = 0;
641 } else { 683 } else {
642 int num_processed = tty->echo_cnt - nr; 684 int num_processed = ldata->echo_cnt - nr;
643 tty->echo_pos += num_processed; 685 ldata->echo_pos += num_processed;
644 tty->echo_pos &= N_TTY_BUF_SIZE - 1; 686 ldata->echo_pos &= N_TTY_BUF_SIZE - 1;
645 tty->echo_cnt = nr; 687 ldata->echo_cnt = nr;
646 if (num_processed > 0) 688 if (num_processed > 0)
647 tty->echo_overrun = 0; 689 ldata->echo_overrun = 0;
648 } 690 }
649 691
650 mutex_unlock(&tty->echo_lock); 692 mutex_unlock(&ldata->echo_lock);
651 mutex_unlock(&tty->output_lock); 693 mutex_unlock(&ldata->output_lock);
652 694
653 if (tty->ops->flush_chars) 695 if (tty->ops->flush_chars)
654 tty->ops->flush_chars(tty); 696 tty->ops->flush_chars(tty);
@@ -657,72 +699,70 @@ static void process_echoes(struct tty_struct *tty)
657/** 699/**
658 * add_echo_byte - add a byte to the echo buffer 700 * add_echo_byte - add a byte to the echo buffer
659 * @c: unicode byte to echo 701 * @c: unicode byte to echo
660 * @tty: terminal device 702 * @ldata: n_tty data
661 * 703 *
662 * Add a character or operation byte to the echo buffer. 704 * Add a character or operation byte to the echo buffer.
663 * 705 *
664 * Should be called under the echo lock to protect the echo buffer. 706 * Should be called under the echo lock to protect the echo buffer.
665 */ 707 */
666 708
667static void add_echo_byte(unsigned char c, struct tty_struct *tty) 709static void add_echo_byte(unsigned char c, struct n_tty_data *ldata)
668{ 710{
669 int new_byte_pos; 711 int new_byte_pos;
670 712
671 if (tty->echo_cnt == N_TTY_BUF_SIZE) { 713 if (ldata->echo_cnt == N_TTY_BUF_SIZE) {
672 /* Circular buffer is already at capacity */ 714 /* Circular buffer is already at capacity */
673 new_byte_pos = tty->echo_pos; 715 new_byte_pos = ldata->echo_pos;
674 716
675 /* 717 /*
676 * Since the buffer start position needs to be advanced, 718 * Since the buffer start position needs to be advanced,
677 * be sure to step by a whole operation byte group. 719 * be sure to step by a whole operation byte group.
678 */ 720 */
679 if (tty->echo_buf[tty->echo_pos] == ECHO_OP_START) { 721 if (ldata->echo_buf[ldata->echo_pos] == ECHO_OP_START) {
680 if (tty->echo_buf[(tty->echo_pos + 1) & 722 if (ldata->echo_buf[(ldata->echo_pos + 1) &
681 (N_TTY_BUF_SIZE - 1)] == 723 (N_TTY_BUF_SIZE - 1)] ==
682 ECHO_OP_ERASE_TAB) { 724 ECHO_OP_ERASE_TAB) {
683 tty->echo_pos += 3; 725 ldata->echo_pos += 3;
684 tty->echo_cnt -= 2; 726 ldata->echo_cnt -= 2;
685 } else { 727 } else {
686 tty->echo_pos += 2; 728 ldata->echo_pos += 2;
687 tty->echo_cnt -= 1; 729 ldata->echo_cnt -= 1;
688 } 730 }
689 } else { 731 } else {
690 tty->echo_pos++; 732 ldata->echo_pos++;
691 } 733 }
692 tty->echo_pos &= N_TTY_BUF_SIZE - 1; 734 ldata->echo_pos &= N_TTY_BUF_SIZE - 1;
693 735
694 tty->echo_overrun = 1; 736 ldata->echo_overrun = 1;
695 } else { 737 } else {
696 new_byte_pos = tty->echo_pos + tty->echo_cnt; 738 new_byte_pos = ldata->echo_pos + ldata->echo_cnt;
697 new_byte_pos &= N_TTY_BUF_SIZE - 1; 739 new_byte_pos &= N_TTY_BUF_SIZE - 1;
698 tty->echo_cnt++; 740 ldata->echo_cnt++;
699 } 741 }
700 742
701 tty->echo_buf[new_byte_pos] = c; 743 ldata->echo_buf[new_byte_pos] = c;
702} 744}
703 745
704/** 746/**
705 * echo_move_back_col - add operation to move back a column 747 * echo_move_back_col - add operation to move back a column
706 * @tty: terminal device 748 * @ldata: n_tty data
707 * 749 *
708 * Add an operation to the echo buffer to move back one column. 750 * Add an operation to the echo buffer to move back one column.
709 * 751 *
710 * Locking: echo_lock to protect the echo buffer 752 * Locking: echo_lock to protect the echo buffer
711 */ 753 */
712 754
713static void echo_move_back_col(struct tty_struct *tty) 755static void echo_move_back_col(struct n_tty_data *ldata)
714{ 756{
715 mutex_lock(&tty->echo_lock); 757 mutex_lock(&ldata->echo_lock);
716 758 add_echo_byte(ECHO_OP_START, ldata);
717 add_echo_byte(ECHO_OP_START, tty); 759 add_echo_byte(ECHO_OP_MOVE_BACK_COL, ldata);
718 add_echo_byte(ECHO_OP_MOVE_BACK_COL, tty); 760 mutex_unlock(&ldata->echo_lock);
719
720 mutex_unlock(&tty->echo_lock);
721} 761}
722 762
723/** 763/**
724 * echo_set_canon_col - add operation to set the canon column 764 * echo_set_canon_col - add operation to set the canon column
725 * @tty: terminal device 765 * @ldata: n_tty data
726 * 766 *
727 * Add an operation to the echo buffer to set the canon column 767 * Add an operation to the echo buffer to set the canon column
728 * to the current column. 768 * to the current column.
@@ -730,21 +770,19 @@ static void echo_move_back_col(struct tty_struct *tty)
730 * Locking: echo_lock to protect the echo buffer 770 * Locking: echo_lock to protect the echo buffer
731 */ 771 */
732 772
733static void echo_set_canon_col(struct tty_struct *tty) 773static void echo_set_canon_col(struct n_tty_data *ldata)
734{ 774{
735 mutex_lock(&tty->echo_lock); 775 mutex_lock(&ldata->echo_lock);
736 776 add_echo_byte(ECHO_OP_START, ldata);
737 add_echo_byte(ECHO_OP_START, tty); 777 add_echo_byte(ECHO_OP_SET_CANON_COL, ldata);
738 add_echo_byte(ECHO_OP_SET_CANON_COL, tty); 778 mutex_unlock(&ldata->echo_lock);
739
740 mutex_unlock(&tty->echo_lock);
741} 779}
742 780
743/** 781/**
744 * echo_erase_tab - add operation to erase a tab 782 * echo_erase_tab - add operation to erase a tab
745 * @num_chars: number of character columns already used 783 * @num_chars: number of character columns already used
746 * @after_tab: true if num_chars starts after a previous tab 784 * @after_tab: true if num_chars starts after a previous tab
747 * @tty: terminal device 785 * @ldata: n_tty data
748 * 786 *
749 * Add an operation to the echo buffer to erase a tab. 787 * Add an operation to the echo buffer to erase a tab.
750 * 788 *
@@ -758,12 +796,12 @@ static void echo_set_canon_col(struct tty_struct *tty)
758 */ 796 */
759 797
760static void echo_erase_tab(unsigned int num_chars, int after_tab, 798static void echo_erase_tab(unsigned int num_chars, int after_tab,
761 struct tty_struct *tty) 799 struct n_tty_data *ldata)
762{ 800{
763 mutex_lock(&tty->echo_lock); 801 mutex_lock(&ldata->echo_lock);
764 802
765 add_echo_byte(ECHO_OP_START, tty); 803 add_echo_byte(ECHO_OP_START, ldata);
766 add_echo_byte(ECHO_OP_ERASE_TAB, tty); 804 add_echo_byte(ECHO_OP_ERASE_TAB, ldata);
767 805
768 /* We only need to know this modulo 8 (tab spacing) */ 806 /* We only need to know this modulo 8 (tab spacing) */
769 num_chars &= 7; 807 num_chars &= 7;
@@ -772,9 +810,9 @@ static void echo_erase_tab(unsigned int num_chars, int after_tab,
772 if (after_tab) 810 if (after_tab)
773 num_chars |= 0x80; 811 num_chars |= 0x80;
774 812
775 add_echo_byte(num_chars, tty); 813 add_echo_byte(num_chars, ldata);
776 814
777 mutex_unlock(&tty->echo_lock); 815 mutex_unlock(&ldata->echo_lock);
778} 816}
779 817
780/** 818/**
@@ -790,18 +828,16 @@ static void echo_erase_tab(unsigned int num_chars, int after_tab,
790 * Locking: echo_lock to protect the echo buffer 828 * Locking: echo_lock to protect the echo buffer
791 */ 829 */
792 830
793static void echo_char_raw(unsigned char c, struct tty_struct *tty) 831static void echo_char_raw(unsigned char c, struct n_tty_data *ldata)
794{ 832{
795 mutex_lock(&tty->echo_lock); 833 mutex_lock(&ldata->echo_lock);
796
797 if (c == ECHO_OP_START) { 834 if (c == ECHO_OP_START) {
798 add_echo_byte(ECHO_OP_START, tty); 835 add_echo_byte(ECHO_OP_START, ldata);
799 add_echo_byte(ECHO_OP_START, tty); 836 add_echo_byte(ECHO_OP_START, ldata);
800 } else { 837 } else {
801 add_echo_byte(c, tty); 838 add_echo_byte(c, ldata);
802 } 839 }
803 840 mutex_unlock(&ldata->echo_lock);
804 mutex_unlock(&tty->echo_lock);
805} 841}
806 842
807/** 843/**
@@ -820,30 +856,32 @@ static void echo_char_raw(unsigned char c, struct tty_struct *tty)
820 856
821static void echo_char(unsigned char c, struct tty_struct *tty) 857static void echo_char(unsigned char c, struct tty_struct *tty)
822{ 858{
823 mutex_lock(&tty->echo_lock); 859 struct n_tty_data *ldata = tty->disc_data;
860
861 mutex_lock(&ldata->echo_lock);
824 862
825 if (c == ECHO_OP_START) { 863 if (c == ECHO_OP_START) {
826 add_echo_byte(ECHO_OP_START, tty); 864 add_echo_byte(ECHO_OP_START, ldata);
827 add_echo_byte(ECHO_OP_START, tty); 865 add_echo_byte(ECHO_OP_START, ldata);
828 } else { 866 } else {
829 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') 867 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t')
830 add_echo_byte(ECHO_OP_START, tty); 868 add_echo_byte(ECHO_OP_START, ldata);
831 add_echo_byte(c, tty); 869 add_echo_byte(c, ldata);
832 } 870 }
833 871
834 mutex_unlock(&tty->echo_lock); 872 mutex_unlock(&ldata->echo_lock);
835} 873}
836 874
837/** 875/**
838 * finish_erasing - complete erase 876 * finish_erasing - complete erase
839 * @tty: tty doing the erase 877 * @ldata: n_tty data
840 */ 878 */
841 879
842static inline void finish_erasing(struct tty_struct *tty) 880static inline void finish_erasing(struct n_tty_data *ldata)
843{ 881{
844 if (tty->erasing) { 882 if (ldata->erasing) {
845 echo_char_raw('/', tty); 883 echo_char_raw('/', ldata);
846 tty->erasing = 0; 884 ldata->erasing = 0;
847 } 885 }
848} 886}
849 887
@@ -861,12 +899,13 @@ static inline void finish_erasing(struct tty_struct *tty)
861 899
862static void eraser(unsigned char c, struct tty_struct *tty) 900static void eraser(unsigned char c, struct tty_struct *tty)
863{ 901{
902 struct n_tty_data *ldata = tty->disc_data;
864 enum { ERASE, WERASE, KILL } kill_type; 903 enum { ERASE, WERASE, KILL } kill_type;
865 int head, seen_alnums, cnt; 904 int head, seen_alnums, cnt;
866 unsigned long flags; 905 unsigned long flags;
867 906
868 /* FIXME: locking needed ? */ 907 /* FIXME: locking needed ? */
869 if (tty->read_head == tty->canon_head) { 908 if (ldata->read_head == ldata->canon_head) {
870 /* process_output('\a', tty); */ /* what do you think? */ 909 /* process_output('\a', tty); */ /* what do you think? */
871 return; 910 return;
872 } 911 }
@@ -876,24 +915,24 @@ static void eraser(unsigned char c, struct tty_struct *tty)
876 kill_type = WERASE; 915 kill_type = WERASE;
877 else { 916 else {
878 if (!L_ECHO(tty)) { 917 if (!L_ECHO(tty)) {
879 spin_lock_irqsave(&tty->read_lock, flags); 918 spin_lock_irqsave(&ldata->read_lock, flags);
880 tty->read_cnt -= ((tty->read_head - tty->canon_head) & 919 ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &
881 (N_TTY_BUF_SIZE - 1)); 920 (N_TTY_BUF_SIZE - 1));
882 tty->read_head = tty->canon_head; 921 ldata->read_head = ldata->canon_head;
883 spin_unlock_irqrestore(&tty->read_lock, flags); 922 spin_unlock_irqrestore(&ldata->read_lock, flags);
884 return; 923 return;
885 } 924 }
886 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { 925 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) {
887 spin_lock_irqsave(&tty->read_lock, flags); 926 spin_lock_irqsave(&ldata->read_lock, flags);
888 tty->read_cnt -= ((tty->read_head - tty->canon_head) & 927 ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &
889 (N_TTY_BUF_SIZE - 1)); 928 (N_TTY_BUF_SIZE - 1));
890 tty->read_head = tty->canon_head; 929 ldata->read_head = ldata->canon_head;
891 spin_unlock_irqrestore(&tty->read_lock, flags); 930 spin_unlock_irqrestore(&ldata->read_lock, flags);
892 finish_erasing(tty); 931 finish_erasing(ldata);
893 echo_char(KILL_CHAR(tty), tty); 932 echo_char(KILL_CHAR(tty), tty);
894 /* Add a newline if ECHOK is on and ECHOKE is off. */ 933 /* Add a newline if ECHOK is on and ECHOKE is off. */
895 if (L_ECHOK(tty)) 934 if (L_ECHOK(tty))
896 echo_char_raw('\n', tty); 935 echo_char_raw('\n', ldata);
897 return; 936 return;
898 } 937 }
899 kill_type = KILL; 938 kill_type = KILL;
@@ -901,14 +940,14 @@ static void eraser(unsigned char c, struct tty_struct *tty)
901 940
902 seen_alnums = 0; 941 seen_alnums = 0;
903 /* FIXME: Locking ?? */ 942 /* FIXME: Locking ?? */
904 while (tty->read_head != tty->canon_head) { 943 while (ldata->read_head != ldata->canon_head) {
905 head = tty->read_head; 944 head = ldata->read_head;
906 945
907 /* erase a single possibly multibyte character */ 946 /* erase a single possibly multibyte character */
908 do { 947 do {
909 head = (head - 1) & (N_TTY_BUF_SIZE-1); 948 head = (head - 1) & (N_TTY_BUF_SIZE-1);
910 c = tty->read_buf[head]; 949 c = ldata->read_buf[head];
911 } while (is_continuation(c, tty) && head != tty->canon_head); 950 } while (is_continuation(c, tty) && head != ldata->canon_head);
912 951
913 /* do not partially erase */ 952 /* do not partially erase */
914 if (is_continuation(c, tty)) 953 if (is_continuation(c, tty))
@@ -921,30 +960,31 @@ static void eraser(unsigned char c, struct tty_struct *tty)
921 else if (seen_alnums) 960 else if (seen_alnums)
922 break; 961 break;
923 } 962 }
924 cnt = (tty->read_head - head) & (N_TTY_BUF_SIZE-1); 963 cnt = (ldata->read_head - head) & (N_TTY_BUF_SIZE-1);
925 spin_lock_irqsave(&tty->read_lock, flags); 964 spin_lock_irqsave(&ldata->read_lock, flags);
926 tty->read_head = head; 965 ldata->read_head = head;
927 tty->read_cnt -= cnt; 966 ldata->read_cnt -= cnt;
928 spin_unlock_irqrestore(&tty->read_lock, flags); 967 spin_unlock_irqrestore(&ldata->read_lock, flags);
929 if (L_ECHO(tty)) { 968 if (L_ECHO(tty)) {
930 if (L_ECHOPRT(tty)) { 969 if (L_ECHOPRT(tty)) {
931 if (!tty->erasing) { 970 if (!ldata->erasing) {
932 echo_char_raw('\\', tty); 971 echo_char_raw('\\', ldata);
933 tty->erasing = 1; 972 ldata->erasing = 1;
934 } 973 }
935 /* if cnt > 1, output a multi-byte character */ 974 /* if cnt > 1, output a multi-byte character */
936 echo_char(c, tty); 975 echo_char(c, tty);
937 while (--cnt > 0) { 976 while (--cnt > 0) {
938 head = (head+1) & (N_TTY_BUF_SIZE-1); 977 head = (head+1) & (N_TTY_BUF_SIZE-1);
939 echo_char_raw(tty->read_buf[head], tty); 978 echo_char_raw(ldata->read_buf[head],
940 echo_move_back_col(tty); 979 ldata);
980 echo_move_back_col(ldata);
941 } 981 }
942 } else if (kill_type == ERASE && !L_ECHOE(tty)) { 982 } else if (kill_type == ERASE && !L_ECHOE(tty)) {
943 echo_char(ERASE_CHAR(tty), tty); 983 echo_char(ERASE_CHAR(tty), tty);
944 } else if (c == '\t') { 984 } else if (c == '\t') {
945 unsigned int num_chars = 0; 985 unsigned int num_chars = 0;
946 int after_tab = 0; 986 int after_tab = 0;
947 unsigned long tail = tty->read_head; 987 unsigned long tail = ldata->read_head;
948 988
949 /* 989 /*
950 * Count the columns used for characters 990 * Count the columns used for characters
@@ -953,9 +993,9 @@ static void eraser(unsigned char c, struct tty_struct *tty)
953 * This info is used to go back the correct 993 * This info is used to go back the correct
954 * number of columns. 994 * number of columns.
955 */ 995 */
956 while (tail != tty->canon_head) { 996 while (tail != ldata->canon_head) {
957 tail = (tail-1) & (N_TTY_BUF_SIZE-1); 997 tail = (tail-1) & (N_TTY_BUF_SIZE-1);
958 c = tty->read_buf[tail]; 998 c = ldata->read_buf[tail];
959 if (c == '\t') { 999 if (c == '\t') {
960 after_tab = 1; 1000 after_tab = 1;
961 break; 1001 break;
@@ -966,25 +1006,25 @@ static void eraser(unsigned char c, struct tty_struct *tty)
966 num_chars++; 1006 num_chars++;
967 } 1007 }
968 } 1008 }
969 echo_erase_tab(num_chars, after_tab, tty); 1009 echo_erase_tab(num_chars, after_tab, ldata);
970 } else { 1010 } else {
971 if (iscntrl(c) && L_ECHOCTL(tty)) { 1011 if (iscntrl(c) && L_ECHOCTL(tty)) {
972 echo_char_raw('\b', tty); 1012 echo_char_raw('\b', ldata);
973 echo_char_raw(' ', tty); 1013 echo_char_raw(' ', ldata);
974 echo_char_raw('\b', tty); 1014 echo_char_raw('\b', ldata);
975 } 1015 }
976 if (!iscntrl(c) || L_ECHOCTL(tty)) { 1016 if (!iscntrl(c) || L_ECHOCTL(tty)) {
977 echo_char_raw('\b', tty); 1017 echo_char_raw('\b', ldata);
978 echo_char_raw(' ', tty); 1018 echo_char_raw(' ', ldata);
979 echo_char_raw('\b', tty); 1019 echo_char_raw('\b', ldata);
980 } 1020 }
981 } 1021 }
982 } 1022 }
983 if (kill_type == ERASE) 1023 if (kill_type == ERASE)
984 break; 1024 break;
985 } 1025 }
986 if (tty->read_head == tty->canon_head && L_ECHO(tty)) 1026 if (ldata->read_head == ldata->canon_head && L_ECHO(tty))
987 finish_erasing(tty); 1027 finish_erasing(ldata);
988} 1028}
989 1029
990/** 1030/**
@@ -1023,6 +1063,8 @@ static inline void isig(int sig, struct tty_struct *tty, int flush)
1023 1063
1024static inline void n_tty_receive_break(struct tty_struct *tty) 1064static inline void n_tty_receive_break(struct tty_struct *tty)
1025{ 1065{
1066 struct n_tty_data *ldata = tty->disc_data;
1067
1026 if (I_IGNBRK(tty)) 1068 if (I_IGNBRK(tty))
1027 return; 1069 return;
1028 if (I_BRKINT(tty)) { 1070 if (I_BRKINT(tty)) {
@@ -1030,10 +1072,10 @@ static inline void n_tty_receive_break(struct tty_struct *tty)
1030 return; 1072 return;
1031 } 1073 }
1032 if (I_PARMRK(tty)) { 1074 if (I_PARMRK(tty)) {
1033 put_tty_queue('\377', tty); 1075 put_tty_queue('\377', ldata);
1034 put_tty_queue('\0', tty); 1076 put_tty_queue('\0', ldata);
1035 } 1077 }
1036 put_tty_queue('\0', tty); 1078 put_tty_queue('\0', ldata);
1037 wake_up_interruptible(&tty->read_wait); 1079 wake_up_interruptible(&tty->read_wait);
1038} 1080}
1039 1081
@@ -1052,16 +1094,17 @@ static inline void n_tty_receive_break(struct tty_struct *tty)
1052 1094
1053static inline void n_tty_receive_overrun(struct tty_struct *tty) 1095static inline void n_tty_receive_overrun(struct tty_struct *tty)
1054{ 1096{
1097 struct n_tty_data *ldata = tty->disc_data;
1055 char buf[64]; 1098 char buf[64];
1056 1099
1057 tty->num_overrun++; 1100 ldata->num_overrun++;
1058 if (time_before(tty->overrun_time, jiffies - HZ) || 1101 if (time_after(jiffies, ldata->overrun_time + HZ) ||
1059 time_after(tty->overrun_time, jiffies)) { 1102 time_after(ldata->overrun_time, jiffies)) {
1060 printk(KERN_WARNING "%s: %d input overrun(s)\n", 1103 printk(KERN_WARNING "%s: %d input overrun(s)\n",
1061 tty_name(tty, buf), 1104 tty_name(tty, buf),
1062 tty->num_overrun); 1105 ldata->num_overrun);
1063 tty->overrun_time = jiffies; 1106 ldata->overrun_time = jiffies;
1064 tty->num_overrun = 0; 1107 ldata->num_overrun = 0;
1065 } 1108 }
1066} 1109}
1067 1110
@@ -1076,16 +1119,18 @@ static inline void n_tty_receive_overrun(struct tty_struct *tty)
1076static inline void n_tty_receive_parity_error(struct tty_struct *tty, 1119static inline void n_tty_receive_parity_error(struct tty_struct *tty,
1077 unsigned char c) 1120 unsigned char c)
1078{ 1121{
1122 struct n_tty_data *ldata = tty->disc_data;
1123
1079 if (I_IGNPAR(tty)) 1124 if (I_IGNPAR(tty))
1080 return; 1125 return;
1081 if (I_PARMRK(tty)) { 1126 if (I_PARMRK(tty)) {
1082 put_tty_queue('\377', tty); 1127 put_tty_queue('\377', ldata);
1083 put_tty_queue('\0', tty); 1128 put_tty_queue('\0', ldata);
1084 put_tty_queue(c, tty); 1129 put_tty_queue(c, ldata);
1085 } else if (I_INPCK(tty)) 1130 } else if (I_INPCK(tty))
1086 put_tty_queue('\0', tty); 1131 put_tty_queue('\0', ldata);
1087 else 1132 else
1088 put_tty_queue(c, tty); 1133 put_tty_queue(c, ldata);
1089 wake_up_interruptible(&tty->read_wait); 1134 wake_up_interruptible(&tty->read_wait);
1090} 1135}
1091 1136
@@ -1101,11 +1146,12 @@ static inline void n_tty_receive_parity_error(struct tty_struct *tty,
1101 1146
1102static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) 1147static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1103{ 1148{
1149 struct n_tty_data *ldata = tty->disc_data;
1104 unsigned long flags; 1150 unsigned long flags;
1105 int parmrk; 1151 int parmrk;
1106 1152
1107 if (tty->raw) { 1153 if (ldata->raw) {
1108 put_tty_queue(c, tty); 1154 put_tty_queue(c, ldata);
1109 return; 1155 return;
1110 } 1156 }
1111 1157
@@ -1115,7 +1161,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1115 c = tolower(c); 1161 c = tolower(c);
1116 1162
1117 if (L_EXTPROC(tty)) { 1163 if (L_EXTPROC(tty)) {
1118 put_tty_queue(c, tty); 1164 put_tty_queue(c, ldata);
1119 return; 1165 return;
1120 } 1166 }
1121 1167
@@ -1143,26 +1189,26 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1143 * handle specially, do shortcut processing to speed things 1189 * handle specially, do shortcut processing to speed things
1144 * up. 1190 * up.
1145 */ 1191 */
1146 if (!test_bit(c, tty->process_char_map) || tty->lnext) { 1192 if (!test_bit(c, ldata->process_char_map) || ldata->lnext) {
1147 tty->lnext = 0; 1193 ldata->lnext = 0;
1148 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; 1194 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
1149 if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { 1195 if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {
1150 /* beep if no space */ 1196 /* beep if no space */
1151 if (L_ECHO(tty)) 1197 if (L_ECHO(tty))
1152 process_output('\a', tty); 1198 process_output('\a', tty);
1153 return; 1199 return;
1154 } 1200 }
1155 if (L_ECHO(tty)) { 1201 if (L_ECHO(tty)) {
1156 finish_erasing(tty); 1202 finish_erasing(ldata);
1157 /* Record the column of first canon char. */ 1203 /* Record the column of first canon char. */
1158 if (tty->canon_head == tty->read_head) 1204 if (ldata->canon_head == ldata->read_head)
1159 echo_set_canon_col(tty); 1205 echo_set_canon_col(ldata);
1160 echo_char(c, tty); 1206 echo_char(c, tty);
1161 process_echoes(tty); 1207 process_echoes(tty);
1162 } 1208 }
1163 if (parmrk) 1209 if (parmrk)
1164 put_tty_queue(c, tty); 1210 put_tty_queue(c, ldata);
1165 put_tty_queue(c, tty); 1211 put_tty_queue(c, ldata);
1166 return; 1212 return;
1167 } 1213 }
1168 1214
@@ -1218,7 +1264,7 @@ send_signal:
1218 } else if (c == '\n' && I_INLCR(tty)) 1264 } else if (c == '\n' && I_INLCR(tty))
1219 c = '\r'; 1265 c = '\r';
1220 1266
1221 if (tty->icanon) { 1267 if (ldata->icanon) {
1222 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || 1268 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) ||
1223 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { 1269 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) {
1224 eraser(c, tty); 1270 eraser(c, tty);
@@ -1226,12 +1272,12 @@ send_signal:
1226 return; 1272 return;
1227 } 1273 }
1228 if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { 1274 if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) {
1229 tty->lnext = 1; 1275 ldata->lnext = 1;
1230 if (L_ECHO(tty)) { 1276 if (L_ECHO(tty)) {
1231 finish_erasing(tty); 1277 finish_erasing(ldata);
1232 if (L_ECHOCTL(tty)) { 1278 if (L_ECHOCTL(tty)) {
1233 echo_char_raw('^', tty); 1279 echo_char_raw('^', ldata);
1234 echo_char_raw('\b', tty); 1280 echo_char_raw('\b', ldata);
1235 process_echoes(tty); 1281 process_echoes(tty);
1236 } 1282 }
1237 } 1283 }
@@ -1239,34 +1285,34 @@ send_signal:
1239 } 1285 }
1240 if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && 1286 if (c == REPRINT_CHAR(tty) && L_ECHO(tty) &&
1241 L_IEXTEN(tty)) { 1287 L_IEXTEN(tty)) {
1242 unsigned long tail = tty->canon_head; 1288 unsigned long tail = ldata->canon_head;
1243 1289
1244 finish_erasing(tty); 1290 finish_erasing(ldata);
1245 echo_char(c, tty); 1291 echo_char(c, tty);
1246 echo_char_raw('\n', tty); 1292 echo_char_raw('\n', ldata);
1247 while (tail != tty->read_head) { 1293 while (tail != ldata->read_head) {
1248 echo_char(tty->read_buf[tail], tty); 1294 echo_char(ldata->read_buf[tail], tty);
1249 tail = (tail+1) & (N_TTY_BUF_SIZE-1); 1295 tail = (tail+1) & (N_TTY_BUF_SIZE-1);
1250 } 1296 }
1251 process_echoes(tty); 1297 process_echoes(tty);
1252 return; 1298 return;
1253 } 1299 }
1254 if (c == '\n') { 1300 if (c == '\n') {
1255 if (tty->read_cnt >= N_TTY_BUF_SIZE) { 1301 if (ldata->read_cnt >= N_TTY_BUF_SIZE) {
1256 if (L_ECHO(tty)) 1302 if (L_ECHO(tty))
1257 process_output('\a', tty); 1303 process_output('\a', tty);
1258 return; 1304 return;
1259 } 1305 }
1260 if (L_ECHO(tty) || L_ECHONL(tty)) { 1306 if (L_ECHO(tty) || L_ECHONL(tty)) {
1261 echo_char_raw('\n', tty); 1307 echo_char_raw('\n', ldata);
1262 process_echoes(tty); 1308 process_echoes(tty);
1263 } 1309 }
1264 goto handle_newline; 1310 goto handle_newline;
1265 } 1311 }
1266 if (c == EOF_CHAR(tty)) { 1312 if (c == EOF_CHAR(tty)) {
1267 if (tty->read_cnt >= N_TTY_BUF_SIZE) 1313 if (ldata->read_cnt >= N_TTY_BUF_SIZE)
1268 return; 1314 return;
1269 if (tty->canon_head != tty->read_head) 1315 if (ldata->canon_head != ldata->read_head)
1270 set_bit(TTY_PUSH, &tty->flags); 1316 set_bit(TTY_PUSH, &tty->flags);
1271 c = __DISABLED_CHAR; 1317 c = __DISABLED_CHAR;
1272 goto handle_newline; 1318 goto handle_newline;
@@ -1275,7 +1321,7 @@ send_signal:
1275 (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { 1321 (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) {
1276 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) 1322 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty))
1277 ? 1 : 0; 1323 ? 1 : 0;
1278 if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk)) { 1324 if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk)) {
1279 if (L_ECHO(tty)) 1325 if (L_ECHO(tty))
1280 process_output('\a', tty); 1326 process_output('\a', tty);
1281 return; 1327 return;
@@ -1285,8 +1331,8 @@ send_signal:
1285 */ 1331 */
1286 if (L_ECHO(tty)) { 1332 if (L_ECHO(tty)) {
1287 /* Record the column of first canon char. */ 1333 /* Record the column of first canon char. */
1288 if (tty->canon_head == tty->read_head) 1334 if (ldata->canon_head == ldata->read_head)
1289 echo_set_canon_col(tty); 1335 echo_set_canon_col(ldata);
1290 echo_char(c, tty); 1336 echo_char(c, tty);
1291 process_echoes(tty); 1337 process_echoes(tty);
1292 } 1338 }
@@ -1295,15 +1341,15 @@ send_signal:
1295 * EOL_CHAR and EOL2_CHAR? 1341 * EOL_CHAR and EOL2_CHAR?
1296 */ 1342 */
1297 if (parmrk) 1343 if (parmrk)
1298 put_tty_queue(c, tty); 1344 put_tty_queue(c, ldata);
1299 1345
1300handle_newline: 1346handle_newline:
1301 spin_lock_irqsave(&tty->read_lock, flags); 1347 spin_lock_irqsave(&ldata->read_lock, flags);
1302 set_bit(tty->read_head, tty->read_flags); 1348 set_bit(ldata->read_head, ldata->read_flags);
1303 put_tty_queue_nolock(c, tty); 1349 put_tty_queue_nolock(c, ldata);
1304 tty->canon_head = tty->read_head; 1350 ldata->canon_head = ldata->read_head;
1305 tty->canon_data++; 1351 ldata->canon_data++;
1306 spin_unlock_irqrestore(&tty->read_lock, flags); 1352 spin_unlock_irqrestore(&ldata->read_lock, flags);
1307 kill_fasync(&tty->fasync, SIGIO, POLL_IN); 1353 kill_fasync(&tty->fasync, SIGIO, POLL_IN);
1308 if (waitqueue_active(&tty->read_wait)) 1354 if (waitqueue_active(&tty->read_wait))
1309 wake_up_interruptible(&tty->read_wait); 1355 wake_up_interruptible(&tty->read_wait);
@@ -1312,29 +1358,29 @@ handle_newline:
1312 } 1358 }
1313 1359
1314 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; 1360 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
1315 if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { 1361 if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {
1316 /* beep if no space */ 1362 /* beep if no space */
1317 if (L_ECHO(tty)) 1363 if (L_ECHO(tty))
1318 process_output('\a', tty); 1364 process_output('\a', tty);
1319 return; 1365 return;
1320 } 1366 }
1321 if (L_ECHO(tty)) { 1367 if (L_ECHO(tty)) {
1322 finish_erasing(tty); 1368 finish_erasing(ldata);
1323 if (c == '\n') 1369 if (c == '\n')
1324 echo_char_raw('\n', tty); 1370 echo_char_raw('\n', ldata);
1325 else { 1371 else {
1326 /* Record the column of first canon char. */ 1372 /* Record the column of first canon char. */
1327 if (tty->canon_head == tty->read_head) 1373 if (ldata->canon_head == ldata->read_head)
1328 echo_set_canon_col(tty); 1374 echo_set_canon_col(ldata);
1329 echo_char(c, tty); 1375 echo_char(c, tty);
1330 } 1376 }
1331 process_echoes(tty); 1377 process_echoes(tty);
1332 } 1378 }
1333 1379
1334 if (parmrk) 1380 if (parmrk)
1335 put_tty_queue(c, tty); 1381 put_tty_queue(c, ldata);
1336 1382
1337 put_tty_queue(c, tty); 1383 put_tty_queue(c, ldata);
1338} 1384}
1339 1385
1340 1386
@@ -1369,33 +1415,31 @@ static void n_tty_write_wakeup(struct tty_struct *tty)
1369static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, 1415static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1370 char *fp, int count) 1416 char *fp, int count)
1371{ 1417{
1418 struct n_tty_data *ldata = tty->disc_data;
1372 const unsigned char *p; 1419 const unsigned char *p;
1373 char *f, flags = TTY_NORMAL; 1420 char *f, flags = TTY_NORMAL;
1374 int i; 1421 int i;
1375 char buf[64]; 1422 char buf[64];
1376 unsigned long cpuflags; 1423 unsigned long cpuflags;
1377 1424
1378 if (!tty->read_buf) 1425 if (ldata->real_raw) {
1379 return; 1426 spin_lock_irqsave(&ldata->read_lock, cpuflags);
1380 1427 i = min(N_TTY_BUF_SIZE - ldata->read_cnt,
1381 if (tty->real_raw) { 1428 N_TTY_BUF_SIZE - ldata->read_head);
1382 spin_lock_irqsave(&tty->read_lock, cpuflags);
1383 i = min(N_TTY_BUF_SIZE - tty->read_cnt,
1384 N_TTY_BUF_SIZE - tty->read_head);
1385 i = min(count, i); 1429 i = min(count, i);
1386 memcpy(tty->read_buf + tty->read_head, cp, i); 1430 memcpy(ldata->read_buf + ldata->read_head, cp, i);
1387 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); 1431 ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1);
1388 tty->read_cnt += i; 1432 ldata->read_cnt += i;
1389 cp += i; 1433 cp += i;
1390 count -= i; 1434 count -= i;
1391 1435
1392 i = min(N_TTY_BUF_SIZE - tty->read_cnt, 1436 i = min(N_TTY_BUF_SIZE - ldata->read_cnt,
1393 N_TTY_BUF_SIZE - tty->read_head); 1437 N_TTY_BUF_SIZE - ldata->read_head);
1394 i = min(count, i); 1438 i = min(count, i);
1395 memcpy(tty->read_buf + tty->read_head, cp, i); 1439 memcpy(ldata->read_buf + ldata->read_head, cp, i);
1396 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); 1440 ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1);
1397 tty->read_cnt += i; 1441 ldata->read_cnt += i;
1398 spin_unlock_irqrestore(&tty->read_lock, cpuflags); 1442 spin_unlock_irqrestore(&ldata->read_lock, cpuflags);
1399 } else { 1443 } else {
1400 for (i = count, p = cp, f = fp; i; i--, p++) { 1444 for (i = count, p = cp, f = fp; i; i--, p++) {
1401 if (f) 1445 if (f)
@@ -1426,7 +1470,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1426 1470
1427 n_tty_set_room(tty); 1471 n_tty_set_room(tty);
1428 1472
1429 if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) || 1473 if ((!ldata->icanon && (ldata->read_cnt >= tty->minimum_to_wake)) ||
1430 L_EXTPROC(tty)) { 1474 L_EXTPROC(tty)) {
1431 kill_fasync(&tty->fasync, SIGIO, POLL_IN); 1475 kill_fasync(&tty->fasync, SIGIO, POLL_IN);
1432 if (waitqueue_active(&tty->read_wait)) 1476 if (waitqueue_active(&tty->read_wait))
@@ -1470,25 +1514,25 @@ int is_ignored(int sig)
1470 1514
1471static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) 1515static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1472{ 1516{
1517 struct n_tty_data *ldata = tty->disc_data;
1473 int canon_change = 1; 1518 int canon_change = 1;
1474 BUG_ON(!tty);
1475 1519
1476 if (old) 1520 if (old)
1477 canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON; 1521 canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON;
1478 if (canon_change) { 1522 if (canon_change) {
1479 memset(&tty->read_flags, 0, sizeof tty->read_flags); 1523 bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
1480 tty->canon_head = tty->read_tail; 1524 ldata->canon_head = ldata->read_tail;
1481 tty->canon_data = 0; 1525 ldata->canon_data = 0;
1482 tty->erasing = 0; 1526 ldata->erasing = 0;
1483 } 1527 }
1484 1528
1485 if (canon_change && !L_ICANON(tty) && tty->read_cnt) 1529 if (canon_change && !L_ICANON(tty) && ldata->read_cnt)
1486 wake_up_interruptible(&tty->read_wait); 1530 wake_up_interruptible(&tty->read_wait);
1487 1531
1488 tty->icanon = (L_ICANON(tty) != 0); 1532 ldata->icanon = (L_ICANON(tty) != 0);
1489 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { 1533 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) {
1490 tty->raw = 1; 1534 ldata->raw = 1;
1491 tty->real_raw = 1; 1535 ldata->real_raw = 1;
1492 n_tty_set_room(tty); 1536 n_tty_set_room(tty);
1493 return; 1537 return;
1494 } 1538 }
@@ -1496,51 +1540,51 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1496 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) || 1540 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) ||
1497 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) || 1541 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) ||
1498 I_PARMRK(tty)) { 1542 I_PARMRK(tty)) {
1499 memset(tty->process_char_map, 0, 256/8); 1543 bitmap_zero(ldata->process_char_map, 256);
1500 1544
1501 if (I_IGNCR(tty) || I_ICRNL(tty)) 1545 if (I_IGNCR(tty) || I_ICRNL(tty))
1502 set_bit('\r', tty->process_char_map); 1546 set_bit('\r', ldata->process_char_map);
1503 if (I_INLCR(tty)) 1547 if (I_INLCR(tty))
1504 set_bit('\n', tty->process_char_map); 1548 set_bit('\n', ldata->process_char_map);
1505 1549
1506 if (L_ICANON(tty)) { 1550 if (L_ICANON(tty)) {
1507 set_bit(ERASE_CHAR(tty), tty->process_char_map); 1551 set_bit(ERASE_CHAR(tty), ldata->process_char_map);
1508 set_bit(KILL_CHAR(tty), tty->process_char_map); 1552 set_bit(KILL_CHAR(tty), ldata->process_char_map);
1509 set_bit(EOF_CHAR(tty), tty->process_char_map); 1553 set_bit(EOF_CHAR(tty), ldata->process_char_map);
1510 set_bit('\n', tty->process_char_map); 1554 set_bit('\n', ldata->process_char_map);
1511 set_bit(EOL_CHAR(tty), tty->process_char_map); 1555 set_bit(EOL_CHAR(tty), ldata->process_char_map);
1512 if (L_IEXTEN(tty)) { 1556 if (L_IEXTEN(tty)) {
1513 set_bit(WERASE_CHAR(tty), 1557 set_bit(WERASE_CHAR(tty),
1514 tty->process_char_map); 1558 ldata->process_char_map);
1515 set_bit(LNEXT_CHAR(tty), 1559 set_bit(LNEXT_CHAR(tty),
1516 tty->process_char_map); 1560 ldata->process_char_map);
1517 set_bit(EOL2_CHAR(tty), 1561 set_bit(EOL2_CHAR(tty),
1518 tty->process_char_map); 1562 ldata->process_char_map);
1519 if (L_ECHO(tty)) 1563 if (L_ECHO(tty))
1520 set_bit(REPRINT_CHAR(tty), 1564 set_bit(REPRINT_CHAR(tty),
1521 tty->process_char_map); 1565 ldata->process_char_map);
1522 } 1566 }
1523 } 1567 }
1524 if (I_IXON(tty)) { 1568 if (I_IXON(tty)) {
1525 set_bit(START_CHAR(tty), tty->process_char_map); 1569 set_bit(START_CHAR(tty), ldata->process_char_map);
1526 set_bit(STOP_CHAR(tty), tty->process_char_map); 1570 set_bit(STOP_CHAR(tty), ldata->process_char_map);
1527 } 1571 }
1528 if (L_ISIG(tty)) { 1572 if (L_ISIG(tty)) {
1529 set_bit(INTR_CHAR(tty), tty->process_char_map); 1573 set_bit(INTR_CHAR(tty), ldata->process_char_map);
1530 set_bit(QUIT_CHAR(tty), tty->process_char_map); 1574 set_bit(QUIT_CHAR(tty), ldata->process_char_map);
1531 set_bit(SUSP_CHAR(tty), tty->process_char_map); 1575 set_bit(SUSP_CHAR(tty), ldata->process_char_map);
1532 } 1576 }
1533 clear_bit(__DISABLED_CHAR, tty->process_char_map); 1577 clear_bit(__DISABLED_CHAR, ldata->process_char_map);
1534 tty->raw = 0; 1578 ldata->raw = 0;
1535 tty->real_raw = 0; 1579 ldata->real_raw = 0;
1536 } else { 1580 } else {
1537 tty->raw = 1; 1581 ldata->raw = 1;
1538 if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && 1582 if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) &&
1539 (I_IGNPAR(tty) || !I_INPCK(tty)) && 1583 (I_IGNPAR(tty) || !I_INPCK(tty)) &&
1540 (tty->driver->flags & TTY_DRIVER_REAL_RAW)) 1584 (tty->driver->flags & TTY_DRIVER_REAL_RAW))
1541 tty->real_raw = 1; 1585 ldata->real_raw = 1;
1542 else 1586 else
1543 tty->real_raw = 0; 1587 ldata->real_raw = 0;
1544 } 1588 }
1545 n_tty_set_room(tty); 1589 n_tty_set_room(tty);
1546 /* The termios change make the tty ready for I/O */ 1590 /* The termios change make the tty ready for I/O */
@@ -1560,15 +1604,13 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1560 1604
1561static void n_tty_close(struct tty_struct *tty) 1605static void n_tty_close(struct tty_struct *tty)
1562{ 1606{
1607 struct n_tty_data *ldata = tty->disc_data;
1608
1563 n_tty_flush_buffer(tty); 1609 n_tty_flush_buffer(tty);
1564 if (tty->read_buf) { 1610 kfree(ldata->read_buf);
1565 kfree(tty->read_buf); 1611 kfree(ldata->echo_buf);
1566 tty->read_buf = NULL; 1612 kfree(ldata);
1567 } 1613 tty->disc_data = NULL;
1568 if (tty->echo_buf) {
1569 kfree(tty->echo_buf);
1570 tty->echo_buf = NULL;
1571 }
1572} 1614}
1573 1615
1574/** 1616/**
@@ -1583,37 +1625,50 @@ static void n_tty_close(struct tty_struct *tty)
1583 1625
1584static int n_tty_open(struct tty_struct *tty) 1626static int n_tty_open(struct tty_struct *tty)
1585{ 1627{
1586 if (!tty) 1628 struct n_tty_data *ldata;
1587 return -EINVAL; 1629
1630 ldata = kzalloc(sizeof(*ldata), GFP_KERNEL);
1631 if (!ldata)
1632 goto err;
1633
1634 ldata->overrun_time = jiffies;
1635 mutex_init(&ldata->atomic_read_lock);
1636 mutex_init(&ldata->output_lock);
1637 mutex_init(&ldata->echo_lock);
1638 spin_lock_init(&ldata->read_lock);
1588 1639
1589 /* These are ugly. Currently a malloc failure here can panic */ 1640 /* These are ugly. Currently a malloc failure here can panic */
1590 if (!tty->read_buf) { 1641 ldata->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1591 tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 1642 ldata->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1592 if (!tty->read_buf) 1643 if (!ldata->read_buf || !ldata->echo_buf)
1593 return -ENOMEM; 1644 goto err_free_bufs;
1594 }
1595 if (!tty->echo_buf) {
1596 tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1597 1645
1598 if (!tty->echo_buf) 1646 tty->disc_data = ldata;
1599 return -ENOMEM;
1600 }
1601 reset_buffer_flags(tty); 1647 reset_buffer_flags(tty);
1602 tty_unthrottle(tty); 1648 tty_unthrottle(tty);
1603 tty->column = 0; 1649 ldata->column = 0;
1604 n_tty_set_termios(tty, NULL); 1650 n_tty_set_termios(tty, NULL);
1605 tty->minimum_to_wake = 1; 1651 tty->minimum_to_wake = 1;
1606 tty->closing = 0; 1652 tty->closing = 0;
1653
1607 return 0; 1654 return 0;
1655err_free_bufs:
1656 kfree(ldata->read_buf);
1657 kfree(ldata->echo_buf);
1658 kfree(ldata);
1659err:
1660 return -ENOMEM;
1608} 1661}
1609 1662
1610static inline int input_available_p(struct tty_struct *tty, int amt) 1663static inline int input_available_p(struct tty_struct *tty, int amt)
1611{ 1664{
1665 struct n_tty_data *ldata = tty->disc_data;
1666
1612 tty_flush_to_ldisc(tty); 1667 tty_flush_to_ldisc(tty);
1613 if (tty->icanon && !L_EXTPROC(tty)) { 1668 if (ldata->icanon && !L_EXTPROC(tty)) {
1614 if (tty->canon_data) 1669 if (ldata->canon_data)
1615 return 1; 1670 return 1;
1616 } else if (tty->read_cnt >= (amt ? amt : 1)) 1671 } else if (ldata->read_cnt >= (amt ? amt : 1))
1617 return 1; 1672 return 1;
1618 1673
1619 return 0; 1674 return 0;
@@ -1632,7 +1687,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1632 * buffer, and once to drain the space from the (physical) beginning of 1687 * buffer, and once to drain the space from the (physical) beginning of
1633 * the buffer to head pointer. 1688 * the buffer to head pointer.
1634 * 1689 *
1635 * Called under the tty->atomic_read_lock sem 1690 * Called under the ldata->atomic_read_lock sem
1636 * 1691 *
1637 */ 1692 */
1638 1693
@@ -1641,29 +1696,31 @@ static int copy_from_read_buf(struct tty_struct *tty,
1641 size_t *nr) 1696 size_t *nr)
1642 1697
1643{ 1698{
1699 struct n_tty_data *ldata = tty->disc_data;
1644 int retval; 1700 int retval;
1645 size_t n; 1701 size_t n;
1646 unsigned long flags; 1702 unsigned long flags;
1647 bool is_eof; 1703 bool is_eof;
1648 1704
1649 retval = 0; 1705 retval = 0;
1650 spin_lock_irqsave(&tty->read_lock, flags); 1706 spin_lock_irqsave(&ldata->read_lock, flags);
1651 n = min(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail); 1707 n = min(ldata->read_cnt, N_TTY_BUF_SIZE - ldata->read_tail);
1652 n = min(*nr, n); 1708 n = min(*nr, n);
1653 spin_unlock_irqrestore(&tty->read_lock, flags); 1709 spin_unlock_irqrestore(&ldata->read_lock, flags);
1654 if (n) { 1710 if (n) {
1655 retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n); 1711 retval = copy_to_user(*b, &ldata->read_buf[ldata->read_tail], n);
1656 n -= retval; 1712 n -= retval;
1657 is_eof = n == 1 && 1713 is_eof = n == 1 &&
1658 tty->read_buf[tty->read_tail] == EOF_CHAR(tty); 1714 ldata->read_buf[ldata->read_tail] == EOF_CHAR(tty);
1659 tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n); 1715 tty_audit_add_data(tty, &ldata->read_buf[ldata->read_tail], n,
1660 spin_lock_irqsave(&tty->read_lock, flags); 1716 ldata->icanon);
1661 tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1); 1717 spin_lock_irqsave(&ldata->read_lock, flags);
1662 tty->read_cnt -= n; 1718 ldata->read_tail = (ldata->read_tail + n) & (N_TTY_BUF_SIZE-1);
1719 ldata->read_cnt -= n;
1663 /* Turn single EOF into zero-length read */ 1720 /* Turn single EOF into zero-length read */
1664 if (L_EXTPROC(tty) && tty->icanon && is_eof && !tty->read_cnt) 1721 if (L_EXTPROC(tty) && ldata->icanon && is_eof && !ldata->read_cnt)
1665 n = 0; 1722 n = 0;
1666 spin_unlock_irqrestore(&tty->read_lock, flags); 1723 spin_unlock_irqrestore(&ldata->read_lock, flags);
1667 *b += n; 1724 *b += n;
1668 *nr -= n; 1725 *nr -= n;
1669 } 1726 }
@@ -1730,6 +1787,7 @@ static int job_control(struct tty_struct *tty, struct file *file)
1730static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, 1787static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
1731 unsigned char __user *buf, size_t nr) 1788 unsigned char __user *buf, size_t nr)
1732{ 1789{
1790 struct n_tty_data *ldata = tty->disc_data;
1733 unsigned char __user *b = buf; 1791 unsigned char __user *b = buf;
1734 DECLARE_WAITQUEUE(wait, current); 1792 DECLARE_WAITQUEUE(wait, current);
1735 int c; 1793 int c;
@@ -1741,17 +1799,13 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
1741 int packet; 1799 int packet;
1742 1800
1743do_it_again: 1801do_it_again:
1744
1745 if (WARN_ON(!tty->read_buf))
1746 return -EAGAIN;
1747
1748 c = job_control(tty, file); 1802 c = job_control(tty, file);
1749 if (c < 0) 1803 if (c < 0)
1750 return c; 1804 return c;
1751 1805
1752 minimum = time = 0; 1806 minimum = time = 0;
1753 timeout = MAX_SCHEDULE_TIMEOUT; 1807 timeout = MAX_SCHEDULE_TIMEOUT;
1754 if (!tty->icanon) { 1808 if (!ldata->icanon) {
1755 time = (HZ / 10) * TIME_CHAR(tty); 1809 time = (HZ / 10) * TIME_CHAR(tty);
1756 minimum = MIN_CHAR(tty); 1810 minimum = MIN_CHAR(tty);
1757 if (minimum) { 1811 if (minimum) {
@@ -1774,10 +1828,10 @@ do_it_again:
1774 * Internal serialization of reads. 1828 * Internal serialization of reads.
1775 */ 1829 */
1776 if (file->f_flags & O_NONBLOCK) { 1830 if (file->f_flags & O_NONBLOCK) {
1777 if (!mutex_trylock(&tty->atomic_read_lock)) 1831 if (!mutex_trylock(&ldata->atomic_read_lock))
1778 return -EAGAIN; 1832 return -EAGAIN;
1779 } else { 1833 } else {
1780 if (mutex_lock_interruptible(&tty->atomic_read_lock)) 1834 if (mutex_lock_interruptible(&ldata->atomic_read_lock))
1781 return -ERESTARTSYS; 1835 return -ERESTARTSYS;
1782 } 1836 }
1783 packet = tty->packet; 1837 packet = tty->packet;
@@ -1830,7 +1884,6 @@ do_it_again:
1830 /* FIXME: does n_tty_set_room need locking ? */ 1884 /* FIXME: does n_tty_set_room need locking ? */
1831 n_tty_set_room(tty); 1885 n_tty_set_room(tty);
1832 timeout = schedule_timeout(timeout); 1886 timeout = schedule_timeout(timeout);
1833 BUG_ON(!tty->read_buf);
1834 continue; 1887 continue;
1835 } 1888 }
1836 __set_current_state(TASK_RUNNING); 1889 __set_current_state(TASK_RUNNING);
@@ -1845,45 +1898,45 @@ do_it_again:
1845 nr--; 1898 nr--;
1846 } 1899 }
1847 1900
1848 if (tty->icanon && !L_EXTPROC(tty)) { 1901 if (ldata->icanon && !L_EXTPROC(tty)) {
1849 /* N.B. avoid overrun if nr == 0 */ 1902 /* N.B. avoid overrun if nr == 0 */
1850 spin_lock_irqsave(&tty->read_lock, flags); 1903 spin_lock_irqsave(&ldata->read_lock, flags);
1851 while (nr && tty->read_cnt) { 1904 while (nr && ldata->read_cnt) {
1852 int eol; 1905 int eol;
1853 1906
1854 eol = test_and_clear_bit(tty->read_tail, 1907 eol = test_and_clear_bit(ldata->read_tail,
1855 tty->read_flags); 1908 ldata->read_flags);
1856 c = tty->read_buf[tty->read_tail]; 1909 c = ldata->read_buf[ldata->read_tail];
1857 tty->read_tail = ((tty->read_tail+1) & 1910 ldata->read_tail = ((ldata->read_tail+1) &
1858 (N_TTY_BUF_SIZE-1)); 1911 (N_TTY_BUF_SIZE-1));
1859 tty->read_cnt--; 1912 ldata->read_cnt--;
1860 if (eol) { 1913 if (eol) {
1861 /* this test should be redundant: 1914 /* this test should be redundant:
1862 * we shouldn't be reading data if 1915 * we shouldn't be reading data if
1863 * canon_data is 0 1916 * canon_data is 0
1864 */ 1917 */
1865 if (--tty->canon_data < 0) 1918 if (--ldata->canon_data < 0)
1866 tty->canon_data = 0; 1919 ldata->canon_data = 0;
1867 } 1920 }
1868 spin_unlock_irqrestore(&tty->read_lock, flags); 1921 spin_unlock_irqrestore(&ldata->read_lock, flags);
1869 1922
1870 if (!eol || (c != __DISABLED_CHAR)) { 1923 if (!eol || (c != __DISABLED_CHAR)) {
1871 if (tty_put_user(tty, c, b++)) { 1924 if (tty_put_user(tty, c, b++)) {
1872 retval = -EFAULT; 1925 retval = -EFAULT;
1873 b--; 1926 b--;
1874 spin_lock_irqsave(&tty->read_lock, flags); 1927 spin_lock_irqsave(&ldata->read_lock, flags);
1875 break; 1928 break;
1876 } 1929 }
1877 nr--; 1930 nr--;
1878 } 1931 }
1879 if (eol) { 1932 if (eol) {
1880 tty_audit_push(tty); 1933 tty_audit_push(tty);
1881 spin_lock_irqsave(&tty->read_lock, flags); 1934 spin_lock_irqsave(&ldata->read_lock, flags);
1882 break; 1935 break;
1883 } 1936 }
1884 spin_lock_irqsave(&tty->read_lock, flags); 1937 spin_lock_irqsave(&ldata->read_lock, flags);
1885 } 1938 }
1886 spin_unlock_irqrestore(&tty->read_lock, flags); 1939 spin_unlock_irqrestore(&ldata->read_lock, flags);
1887 if (retval) 1940 if (retval)
1888 break; 1941 break;
1889 } else { 1942 } else {
@@ -1915,7 +1968,7 @@ do_it_again:
1915 if (time) 1968 if (time)
1916 timeout = time; 1969 timeout = time;
1917 } 1970 }
1918 mutex_unlock(&tty->atomic_read_lock); 1971 mutex_unlock(&ldata->atomic_read_lock);
1919 remove_wait_queue(&tty->read_wait, &wait); 1972 remove_wait_queue(&tty->read_wait, &wait);
1920 1973
1921 if (!waitqueue_active(&tty->read_wait)) 1974 if (!waitqueue_active(&tty->read_wait))
@@ -2076,19 +2129,19 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
2076 return mask; 2129 return mask;
2077} 2130}
2078 2131
2079static unsigned long inq_canon(struct tty_struct *tty) 2132static unsigned long inq_canon(struct n_tty_data *ldata)
2080{ 2133{
2081 int nr, head, tail; 2134 int nr, head, tail;
2082 2135
2083 if (!tty->canon_data) 2136 if (!ldata->canon_data)
2084 return 0; 2137 return 0;
2085 head = tty->canon_head; 2138 head = ldata->canon_head;
2086 tail = tty->read_tail; 2139 tail = ldata->read_tail;
2087 nr = (head - tail) & (N_TTY_BUF_SIZE-1); 2140 nr = (head - tail) & (N_TTY_BUF_SIZE-1);
2088 /* Skip EOF-chars.. */ 2141 /* Skip EOF-chars.. */
2089 while (head != tail) { 2142 while (head != tail) {
2090 if (test_bit(tail, tty->read_flags) && 2143 if (test_bit(tail, ldata->read_flags) &&
2091 tty->read_buf[tail] == __DISABLED_CHAR) 2144 ldata->read_buf[tail] == __DISABLED_CHAR)
2092 nr--; 2145 nr--;
2093 tail = (tail+1) & (N_TTY_BUF_SIZE-1); 2146 tail = (tail+1) & (N_TTY_BUF_SIZE-1);
2094 } 2147 }
@@ -2098,6 +2151,7 @@ static unsigned long inq_canon(struct tty_struct *tty)
2098static int n_tty_ioctl(struct tty_struct *tty, struct file *file, 2151static int n_tty_ioctl(struct tty_struct *tty, struct file *file,
2099 unsigned int cmd, unsigned long arg) 2152 unsigned int cmd, unsigned long arg)
2100{ 2153{
2154 struct n_tty_data *ldata = tty->disc_data;
2101 int retval; 2155 int retval;
2102 2156
2103 switch (cmd) { 2157 switch (cmd) {
@@ -2105,9 +2159,9 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file,
2105 return put_user(tty_chars_in_buffer(tty), (int __user *) arg); 2159 return put_user(tty_chars_in_buffer(tty), (int __user *) arg);
2106 case TIOCINQ: 2160 case TIOCINQ:
2107 /* FIXME: Locking */ 2161 /* FIXME: Locking */
2108 retval = tty->read_cnt; 2162 retval = ldata->read_cnt;
2109 if (L_ICANON(tty)) 2163 if (L_ICANON(tty))
2110 retval = inq_canon(tty); 2164 retval = inq_canon(ldata);
2111 return put_user(retval, (unsigned int __user *) arg); 2165 return put_user(retval, (unsigned int __user *) arg);
2112 default: 2166 default:
2113 return n_tty_ioctl_helper(tty, file, cmd, arg); 2167 return n_tty_ioctl_helper(tty, file, cmd, arg);
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index a82b39939a9c..4219f040adb8 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -4,9 +4,6 @@
4 * Added support for a Unix98-style ptmx device. 4 * Added support for a Unix98-style ptmx device.
5 * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998 5 * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998
6 * 6 *
7 * When reading this code see also fs/devpts. In particular note that the
8 * driver_data field is used by the devpts side as a binding to the devpts
9 * inode.
10 */ 7 */
11 8
12#include <linux/module.h> 9#include <linux/module.h>
@@ -59,7 +56,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
59#ifdef CONFIG_UNIX98_PTYS 56#ifdef CONFIG_UNIX98_PTYS
60 if (tty->driver == ptm_driver) { 57 if (tty->driver == ptm_driver) {
61 mutex_lock(&devpts_mutex); 58 mutex_lock(&devpts_mutex);
62 devpts_pty_kill(tty->link); 59 devpts_pty_kill(tty->link->driver_data);
63 mutex_unlock(&devpts_mutex); 60 mutex_unlock(&devpts_mutex);
64 } 61 }
65#endif 62#endif
@@ -96,7 +93,7 @@ static void pty_unthrottle(struct tty_struct *tty)
96 93
97static int pty_space(struct tty_struct *to) 94static int pty_space(struct tty_struct *to)
98{ 95{
99 int n = 8192 - to->buf.memory_used; 96 int n = 8192 - to->port->buf.memory_used;
100 if (n < 0) 97 if (n < 0)
101 return 0; 98 return 0;
102 return n; 99 return n;
@@ -348,6 +345,7 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
348 tty_port_init(ports[1]); 345 tty_port_init(ports[1]);
349 o_tty->port = ports[0]; 346 o_tty->port = ports[0];
350 tty->port = ports[1]; 347 tty->port = ports[1];
348 o_tty->port->itty = o_tty;
351 349
352 tty_driver_kref_get(driver); 350 tty_driver_kref_get(driver);
353 tty->count++; 351 tty->count++;
@@ -366,8 +364,15 @@ err:
366 return retval; 364 return retval;
367} 365}
368 366
367/* this is called once with whichever end is closed last */
368static void pty_unix98_shutdown(struct tty_struct *tty)
369{
370 devpts_kill_index(tty->driver_data, tty->index);
371}
372
369static void pty_cleanup(struct tty_struct *tty) 373static void pty_cleanup(struct tty_struct *tty)
370{ 374{
375 tty->port->itty = NULL;
371 kfree(tty->port); 376 kfree(tty->port);
372} 377}
373 378
@@ -547,7 +552,7 @@ static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver,
547 struct tty_struct *tty; 552 struct tty_struct *tty;
548 553
549 mutex_lock(&devpts_mutex); 554 mutex_lock(&devpts_mutex);
550 tty = devpts_get_tty(pts_inode, idx); 555 tty = devpts_get_priv(pts_inode);
551 mutex_unlock(&devpts_mutex); 556 mutex_unlock(&devpts_mutex);
552 /* Master must be open before slave */ 557 /* Master must be open before slave */
553 if (!tty) 558 if (!tty)
@@ -581,6 +586,7 @@ static const struct tty_operations ptm_unix98_ops = {
581 .set_termios = pty_set_termios, 586 .set_termios = pty_set_termios,
582 .ioctl = pty_unix98_ioctl, 587 .ioctl = pty_unix98_ioctl,
583 .resize = pty_resize, 588 .resize = pty_resize,
589 .shutdown = pty_unix98_shutdown,
584 .cleanup = pty_cleanup 590 .cleanup = pty_cleanup
585}; 591};
586 592
@@ -596,6 +602,7 @@ static const struct tty_operations pty_unix98_ops = {
596 .chars_in_buffer = pty_chars_in_buffer, 602 .chars_in_buffer = pty_chars_in_buffer,
597 .unthrottle = pty_unthrottle, 603 .unthrottle = pty_unthrottle,
598 .set_termios = pty_set_termios, 604 .set_termios = pty_set_termios,
605 .shutdown = pty_unix98_shutdown,
599 .cleanup = pty_cleanup, 606 .cleanup = pty_cleanup,
600}; 607};
601 608
@@ -614,6 +621,7 @@ static const struct tty_operations pty_unix98_ops = {
614static int ptmx_open(struct inode *inode, struct file *filp) 621static int ptmx_open(struct inode *inode, struct file *filp)
615{ 622{
616 struct tty_struct *tty; 623 struct tty_struct *tty;
624 struct inode *slave_inode;
617 int retval; 625 int retval;
618 int index; 626 int index;
619 627
@@ -650,15 +658,21 @@ static int ptmx_open(struct inode *inode, struct file *filp)
650 658
651 tty_add_file(tty, filp); 659 tty_add_file(tty, filp);
652 660
653 retval = devpts_pty_new(inode, tty->link); 661 slave_inode = devpts_pty_new(inode,
654 if (retval) 662 MKDEV(UNIX98_PTY_SLAVE_MAJOR, index), index,
663 tty->link);
664 if (IS_ERR(slave_inode)) {
665 retval = PTR_ERR(slave_inode);
655 goto err_release; 666 goto err_release;
667 }
656 668
657 retval = ptm_driver->ops->open(tty, filp); 669 retval = ptm_driver->ops->open(tty, filp);
658 if (retval) 670 if (retval)
659 goto err_release; 671 goto err_release;
660 672
661 tty_unlock(tty); 673 tty_unlock(tty);
674 tty->driver_data = inode;
675 tty->link->driver_data = slave_inode;
662 return 0; 676 return 0;
663err_release: 677err_release:
664 tty_unlock(tty); 678 tty_unlock(tty);
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 3ba4234592bc..5ccbd90540cf 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -2349,16 +2349,14 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2349 serial_port_out(port, UART_EFR, efr); 2349 serial_port_out(port, UART_EFR, efr);
2350 } 2350 }
2351 2351
2352#ifdef CONFIG_ARCH_OMAP1
2353 /* Workaround to enable 115200 baud on OMAP1510 internal ports */ 2352 /* Workaround to enable 115200 baud on OMAP1510 internal ports */
2354 if (cpu_is_omap1510() && is_omap_port(up)) { 2353 if (is_omap1510_8250(up)) {
2355 if (baud == 115200) { 2354 if (baud == 115200) {
2356 quot = 1; 2355 quot = 1;
2357 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 1); 2356 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 1);
2358 } else 2357 } else
2359 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 0); 2358 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 0);
2360 } 2359 }
2361#endif
2362 2360
2363 /* 2361 /*
2364 * For NatSemi, switch to bank 2 not bank 1, to avoid resetting EXCR2, 2362 * For NatSemi, switch to bank 2 not bank 1, to avoid resetting EXCR2,
@@ -2439,10 +2437,9 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt)
2439{ 2437{
2440 if (pt->port.iotype == UPIO_AU) 2438 if (pt->port.iotype == UPIO_AU)
2441 return 0x1000; 2439 return 0x1000;
2442#ifdef CONFIG_ARCH_OMAP1 2440 if (is_omap1_8250(pt))
2443 if (is_omap_port(pt))
2444 return 0x16 << pt->port.regshift; 2441 return 0x16 << pt->port.regshift;
2445#endif 2442
2446 return 8 << pt->port.regshift; 2443 return 8 << pt->port.regshift;
2447} 2444}
2448 2445
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 5a76f9c8d36b..3b4ea84898c2 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -106,3 +106,39 @@ static inline int serial8250_pnp_init(void) { return 0; }
106static inline void serial8250_pnp_exit(void) { } 106static inline void serial8250_pnp_exit(void) { }
107#endif 107#endif
108 108
109#ifdef CONFIG_ARCH_OMAP1
110static inline int is_omap1_8250(struct uart_8250_port *pt)
111{
112 int res;
113
114 switch (pt->port.mapbase) {
115 case OMAP1_UART1_BASE:
116 case OMAP1_UART2_BASE:
117 case OMAP1_UART3_BASE:
118 res = 1;
119 break;
120 default:
121 res = 0;
122 break;
123 }
124
125 return res;
126}
127
128static inline int is_omap1510_8250(struct uart_8250_port *pt)
129{
130 if (!cpu_is_omap1510())
131 return 0;
132
133 return is_omap1_8250(pt);
134}
135#else
136static inline int is_omap1_8250(struct uart_8250_port *pt)
137{
138 return 0;
139}
140static inline int is_omap1510_8250(struct uart_8250_port *pt)
141{
142 return 0;
143}
144#endif
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index eaafb98debed..843a150ba105 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -140,7 +140,7 @@ static void __init init_port(struct early_serial8250_device *device)
140 serial_out(port, UART_FCR, 0); /* no fifo */ 140 serial_out(port, UART_FCR, 0); /* no fifo */
141 serial_out(port, UART_MCR, 0x3); /* DTR + RTS */ 141 serial_out(port, UART_MCR, 0x3); /* DTR + RTS */
142 142
143 divisor = port->uartclk / (16 * device->baud); 143 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
144 c = serial_in(port, UART_LCR); 144 c = serial_in(port, UART_LCR);
145 serial_out(port, UART_LCR, c | UART_LCR_DLAB); 145 serial_out(port, UART_LCR, c | UART_LCR_DLAB);
146 serial_out(port, UART_DLL, divisor & 0xff); 146 serial_out(port, UART_DLL, divisor & 0xff);
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 7f04717176aa..740458ca62cc 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -530,16 +530,16 @@ static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level,
530 switch (level) { 530 switch (level) {
531 case 3: 531 case 3:
532 if (!IS_ERR(ourport->baudclk)) 532 if (!IS_ERR(ourport->baudclk))
533 clk_disable(ourport->baudclk); 533 clk_disable_unprepare(ourport->baudclk);
534 534
535 clk_disable(ourport->clk); 535 clk_disable_unprepare(ourport->clk);
536 break; 536 break;
537 537
538 case 0: 538 case 0:
539 clk_enable(ourport->clk); 539 clk_prepare_enable(ourport->clk);
540 540
541 if (!IS_ERR(ourport->baudclk)) 541 if (!IS_ERR(ourport->baudclk))
542 clk_enable(ourport->baudclk); 542 clk_prepare_enable(ourport->baudclk);
543 543
544 break; 544 break;
545 default: 545 default:
@@ -713,11 +713,11 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
713 s3c24xx_serial_setsource(port, clk_sel); 713 s3c24xx_serial_setsource(port, clk_sel);
714 714
715 if (!IS_ERR(ourport->baudclk)) { 715 if (!IS_ERR(ourport->baudclk)) {
716 clk_disable(ourport->baudclk); 716 clk_disable_unprepare(ourport->baudclk);
717 ourport->baudclk = ERR_PTR(-EINVAL); 717 ourport->baudclk = ERR_PTR(-EINVAL);
718 } 718 }
719 719
720 clk_enable(clk); 720 clk_prepare_enable(clk);
721 721
722 ourport->baudclk = clk; 722 ourport->baudclk = clk;
723 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; 723 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0;
@@ -1287,9 +1287,9 @@ static int s3c24xx_serial_resume(struct device *dev)
1287 struct s3c24xx_uart_port *ourport = to_ourport(port); 1287 struct s3c24xx_uart_port *ourport = to_ourport(port);
1288 1288
1289 if (port) { 1289 if (port) {
1290 clk_enable(ourport->clk); 1290 clk_prepare_enable(ourport->clk);
1291 s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port)); 1291 s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port));
1292 clk_disable(ourport->clk); 1292 clk_disable_unprepare(ourport->clk);
1293 1293
1294 uart_resume_port(&s3c24xx_uart_drv, port); 1294 uart_resume_port(&s3c24xx_uart_drv, port);
1295 } 1295 }
diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
index b0b39b823ccf..6953dc82850c 100644
--- a/drivers/tty/tty_audit.c
+++ b/drivers/tty/tty_audit.c
@@ -23,7 +23,7 @@ struct tty_audit_buf {
23}; 23};
24 24
25static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor, 25static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor,
26 int icanon) 26 unsigned icanon)
27{ 27{
28 struct tty_audit_buf *buf; 28 struct tty_audit_buf *buf;
29 29
@@ -239,7 +239,8 @@ int tty_audit_push_task(struct task_struct *tsk, kuid_t loginuid, u32 sessionid)
239 * if TTY auditing is disabled or out of memory. Otherwise, return a new 239 * if TTY auditing is disabled or out of memory. Otherwise, return a new
240 * reference to the buffer. 240 * reference to the buffer.
241 */ 241 */
242static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty) 242static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty,
243 unsigned icanon)
243{ 244{
244 struct tty_audit_buf *buf, *buf2; 245 struct tty_audit_buf *buf, *buf2;
245 246
@@ -257,7 +258,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty)
257 258
258 buf2 = tty_audit_buf_alloc(tty->driver->major, 259 buf2 = tty_audit_buf_alloc(tty->driver->major,
259 tty->driver->minor_start + tty->index, 260 tty->driver->minor_start + tty->index,
260 tty->icanon); 261 icanon);
261 if (buf2 == NULL) { 262 if (buf2 == NULL) {
262 audit_log_lost("out of memory in TTY auditing"); 263 audit_log_lost("out of memory in TTY auditing");
263 return NULL; 264 return NULL;
@@ -287,7 +288,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty)
287 * Audit @data of @size from @tty, if necessary. 288 * Audit @data of @size from @tty, if necessary.
288 */ 289 */
289void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, 290void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
290 size_t size) 291 size_t size, unsigned icanon)
291{ 292{
292 struct tty_audit_buf *buf; 293 struct tty_audit_buf *buf;
293 int major, minor; 294 int major, minor;
@@ -299,7 +300,7 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
299 && tty->driver->subtype == PTY_TYPE_MASTER) 300 && tty->driver->subtype == PTY_TYPE_MASTER)
300 return; 301 return;
301 302
302 buf = tty_audit_buf_get(tty); 303 buf = tty_audit_buf_get(tty, icanon);
303 if (!buf) 304 if (!buf)
304 return; 305 return;
305 306
@@ -307,11 +308,11 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
307 major = tty->driver->major; 308 major = tty->driver->major;
308 minor = tty->driver->minor_start + tty->index; 309 minor = tty->driver->minor_start + tty->index;
309 if (buf->major != major || buf->minor != minor 310 if (buf->major != major || buf->minor != minor
310 || buf->icanon != tty->icanon) { 311 || buf->icanon != icanon) {
311 tty_audit_buf_push_current(buf); 312 tty_audit_buf_push_current(buf);
312 buf->major = major; 313 buf->major = major;
313 buf->minor = minor; 314 buf->minor = minor;
314 buf->icanon = tty->icanon; 315 buf->icanon = icanon;
315 } 316 }
316 do { 317 do {
317 size_t run; 318 size_t run;
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 91e326ffe7db..6cf87d7afb7e 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -27,19 +27,21 @@
27 * Locking: none 27 * Locking: none
28 */ 28 */
29 29
30void tty_buffer_free_all(struct tty_struct *tty) 30void tty_buffer_free_all(struct tty_port *port)
31{ 31{
32 struct tty_bufhead *buf = &port->buf;
32 struct tty_buffer *thead; 33 struct tty_buffer *thead;
33 while ((thead = tty->buf.head) != NULL) { 34
34 tty->buf.head = thead->next; 35 while ((thead = buf->head) != NULL) {
36 buf->head = thead->next;
35 kfree(thead); 37 kfree(thead);
36 } 38 }
37 while ((thead = tty->buf.free) != NULL) { 39 while ((thead = buf->free) != NULL) {
38 tty->buf.free = thead->next; 40 buf->free = thead->next;
39 kfree(thead); 41 kfree(thead);
40 } 42 }
41 tty->buf.tail = NULL; 43 buf->tail = NULL;
42 tty->buf.memory_used = 0; 44 buf->memory_used = 0;
43} 45}
44 46
45/** 47/**
@@ -54,11 +56,11 @@ void tty_buffer_free_all(struct tty_struct *tty)
54 * Locking: Caller must hold tty->buf.lock 56 * Locking: Caller must hold tty->buf.lock
55 */ 57 */
56 58
57static struct tty_buffer *tty_buffer_alloc(struct tty_struct *tty, size_t size) 59static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size)
58{ 60{
59 struct tty_buffer *p; 61 struct tty_buffer *p;
60 62
61 if (tty->buf.memory_used + size > 65536) 63 if (port->buf.memory_used + size > 65536)
62 return NULL; 64 return NULL;
63 p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); 65 p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC);
64 if (p == NULL) 66 if (p == NULL)
@@ -70,7 +72,7 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_struct *tty, size_t size)
70 p->read = 0; 72 p->read = 0;
71 p->char_buf_ptr = (char *)(p->data); 73 p->char_buf_ptr = (char *)(p->data);
72 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; 74 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size;
73 tty->buf.memory_used += size; 75 port->buf.memory_used += size;
74 return p; 76 return p;
75} 77}
76 78
@@ -85,17 +87,19 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_struct *tty, size_t size)
85 * Locking: Caller must hold tty->buf.lock 87 * Locking: Caller must hold tty->buf.lock
86 */ 88 */
87 89
88static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b) 90static void tty_buffer_free(struct tty_port *port, struct tty_buffer *b)
89{ 91{
92 struct tty_bufhead *buf = &port->buf;
93
90 /* Dumb strategy for now - should keep some stats */ 94 /* Dumb strategy for now - should keep some stats */
91 tty->buf.memory_used -= b->size; 95 buf->memory_used -= b->size;
92 WARN_ON(tty->buf.memory_used < 0); 96 WARN_ON(buf->memory_used < 0);
93 97
94 if (b->size >= 512) 98 if (b->size >= 512)
95 kfree(b); 99 kfree(b);
96 else { 100 else {
97 b->next = tty->buf.free; 101 b->next = buf->free;
98 tty->buf.free = b; 102 buf->free = b;
99 } 103 }
100} 104}
101 105
@@ -110,15 +114,16 @@ static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b)
110 * Locking: Caller must hold tty->buf.lock 114 * Locking: Caller must hold tty->buf.lock
111 */ 115 */
112 116
113static void __tty_buffer_flush(struct tty_struct *tty) 117static void __tty_buffer_flush(struct tty_port *port)
114{ 118{
119 struct tty_bufhead *buf = &port->buf;
115 struct tty_buffer *thead; 120 struct tty_buffer *thead;
116 121
117 while ((thead = tty->buf.head) != NULL) { 122 while ((thead = buf->head) != NULL) {
118 tty->buf.head = thead->next; 123 buf->head = thead->next;
119 tty_buffer_free(tty, thead); 124 tty_buffer_free(port, thead);
120 } 125 }
121 tty->buf.tail = NULL; 126 buf->tail = NULL;
122} 127}
123 128
124/** 129/**
@@ -134,21 +139,24 @@ static void __tty_buffer_flush(struct tty_struct *tty)
134 139
135void tty_buffer_flush(struct tty_struct *tty) 140void tty_buffer_flush(struct tty_struct *tty)
136{ 141{
142 struct tty_port *port = tty->port;
143 struct tty_bufhead *buf = &port->buf;
137 unsigned long flags; 144 unsigned long flags;
138 spin_lock_irqsave(&tty->buf.lock, flags); 145
146 spin_lock_irqsave(&buf->lock, flags);
139 147
140 /* If the data is being pushed to the tty layer then we can't 148 /* If the data is being pushed to the tty layer then we can't
141 process it here. Instead set a flag and the flush_to_ldisc 149 process it here. Instead set a flag and the flush_to_ldisc
142 path will process the flush request before it exits */ 150 path will process the flush request before it exits */
143 if (test_bit(TTY_FLUSHING, &tty->flags)) { 151 if (test_bit(TTYP_FLUSHING, &port->iflags)) {
144 set_bit(TTY_FLUSHPENDING, &tty->flags); 152 set_bit(TTYP_FLUSHPENDING, &port->iflags);
145 spin_unlock_irqrestore(&tty->buf.lock, flags); 153 spin_unlock_irqrestore(&buf->lock, flags);
146 wait_event(tty->read_wait, 154 wait_event(tty->read_wait,
147 test_bit(TTY_FLUSHPENDING, &tty->flags) == 0); 155 test_bit(TTYP_FLUSHPENDING, &port->iflags) == 0);
148 return; 156 return;
149 } else 157 } else
150 __tty_buffer_flush(tty); 158 __tty_buffer_flush(port);
151 spin_unlock_irqrestore(&tty->buf.lock, flags); 159 spin_unlock_irqrestore(&buf->lock, flags);
152} 160}
153 161
154/** 162/**
@@ -163,9 +171,9 @@ void tty_buffer_flush(struct tty_struct *tty)
163 * Locking: Caller must hold tty->buf.lock 171 * Locking: Caller must hold tty->buf.lock
164 */ 172 */
165 173
166static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size) 174static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size)
167{ 175{
168 struct tty_buffer **tbh = &tty->buf.free; 176 struct tty_buffer **tbh = &port->buf.free;
169 while ((*tbh) != NULL) { 177 while ((*tbh) != NULL) {
170 struct tty_buffer *t = *tbh; 178 struct tty_buffer *t = *tbh;
171 if (t->size >= size) { 179 if (t->size >= size) {
@@ -174,14 +182,14 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size)
174 t->used = 0; 182 t->used = 0;
175 t->commit = 0; 183 t->commit = 0;
176 t->read = 0; 184 t->read = 0;
177 tty->buf.memory_used += t->size; 185 port->buf.memory_used += t->size;
178 return t; 186 return t;
179 } 187 }
180 tbh = &((*tbh)->next); 188 tbh = &((*tbh)->next);
181 } 189 }
182 /* Round the buffer size out */ 190 /* Round the buffer size out */
183 size = (size + 0xFF) & ~0xFF; 191 size = (size + 0xFF) & ~0xFF;
184 return tty_buffer_alloc(tty, size); 192 return tty_buffer_alloc(port, size);
185 /* Should possibly check if this fails for the largest buffer we 193 /* Should possibly check if this fails for the largest buffer we
186 have queued and recycle that ? */ 194 have queued and recycle that ? */
187} 195}
@@ -192,29 +200,31 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size)
192 * 200 *
193 * Make at least size bytes of linear space available for the tty 201 * Make at least size bytes of linear space available for the tty
194 * buffer. If we fail return the size we managed to find. 202 * buffer. If we fail return the size we managed to find.
195 * Locking: Caller must hold tty->buf.lock 203 * Locking: Caller must hold port->buf.lock
196 */ 204 */
197static int __tty_buffer_request_room(struct tty_struct *tty, size_t size) 205static int __tty_buffer_request_room(struct tty_port *port, size_t size)
198{ 206{
207 struct tty_bufhead *buf = &port->buf;
199 struct tty_buffer *b, *n; 208 struct tty_buffer *b, *n;
200 int left; 209 int left;
201 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to 210 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to
202 remove this conditional if its worth it. This would be invisible 211 remove this conditional if its worth it. This would be invisible
203 to the callers */ 212 to the callers */
204 if ((b = tty->buf.tail) != NULL) 213 b = buf->tail;
214 if (b != NULL)
205 left = b->size - b->used; 215 left = b->size - b->used;
206 else 216 else
207 left = 0; 217 left = 0;
208 218
209 if (left < size) { 219 if (left < size) {
210 /* This is the slow path - looking for new buffers to use */ 220 /* This is the slow path - looking for new buffers to use */
211 if ((n = tty_buffer_find(tty, size)) != NULL) { 221 if ((n = tty_buffer_find(port, size)) != NULL) {
212 if (b != NULL) { 222 if (b != NULL) {
213 b->next = n; 223 b->next = n;
214 b->commit = b->used; 224 b->commit = b->used;
215 } else 225 } else
216 tty->buf.head = n; 226 buf->head = n;
217 tty->buf.tail = n; 227 buf->tail = n;
218 } else 228 } else
219 size = left; 229 size = left;
220 } 230 }
@@ -231,16 +241,17 @@ static int __tty_buffer_request_room(struct tty_struct *tty, size_t size)
231 * Make at least size bytes of linear space available for the tty 241 * Make at least size bytes of linear space available for the tty
232 * buffer. If we fail return the size we managed to find. 242 * buffer. If we fail return the size we managed to find.
233 * 243 *
234 * Locking: Takes tty->buf.lock 244 * Locking: Takes port->buf.lock
235 */ 245 */
236int tty_buffer_request_room(struct tty_struct *tty, size_t size) 246int tty_buffer_request_room(struct tty_struct *tty, size_t size)
237{ 247{
248 struct tty_port *port = tty->port;
238 unsigned long flags; 249 unsigned long flags;
239 int length; 250 int length;
240 251
241 spin_lock_irqsave(&tty->buf.lock, flags); 252 spin_lock_irqsave(&port->buf.lock, flags);
242 length = __tty_buffer_request_room(tty, size); 253 length = __tty_buffer_request_room(port, size);
243 spin_unlock_irqrestore(&tty->buf.lock, flags); 254 spin_unlock_irqrestore(&port->buf.lock, flags);
244 return length; 255 return length;
245} 256}
246EXPORT_SYMBOL_GPL(tty_buffer_request_room); 257EXPORT_SYMBOL_GPL(tty_buffer_request_room);
@@ -255,12 +266,13 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room);
255 * Queue a series of bytes to the tty buffering. All the characters 266 * Queue a series of bytes to the tty buffering. All the characters
256 * passed are marked with the supplied flag. Returns the number added. 267 * passed are marked with the supplied flag. Returns the number added.
257 * 268 *
258 * Locking: Called functions may take tty->buf.lock 269 * Locking: Called functions may take port->buf.lock
259 */ 270 */
260 271
261int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, 272int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,
262 const unsigned char *chars, char flag, size_t size) 273 const unsigned char *chars, char flag, size_t size)
263{ 274{
275 struct tty_bufhead *buf = &tty->port->buf;
264 int copied = 0; 276 int copied = 0;
265 do { 277 do {
266 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); 278 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
@@ -268,18 +280,18 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,
268 unsigned long flags; 280 unsigned long flags;
269 struct tty_buffer *tb; 281 struct tty_buffer *tb;
270 282
271 spin_lock_irqsave(&tty->buf.lock, flags); 283 spin_lock_irqsave(&buf->lock, flags);
272 space = __tty_buffer_request_room(tty, goal); 284 space = __tty_buffer_request_room(tty->port, goal);
273 tb = tty->buf.tail; 285 tb = buf->tail;
274 /* If there is no space then tb may be NULL */ 286 /* If there is no space then tb may be NULL */
275 if (unlikely(space == 0)) { 287 if (unlikely(space == 0)) {
276 spin_unlock_irqrestore(&tty->buf.lock, flags); 288 spin_unlock_irqrestore(&buf->lock, flags);
277 break; 289 break;
278 } 290 }
279 memcpy(tb->char_buf_ptr + tb->used, chars, space); 291 memcpy(tb->char_buf_ptr + tb->used, chars, space);
280 memset(tb->flag_buf_ptr + tb->used, flag, space); 292 memset(tb->flag_buf_ptr + tb->used, flag, space);
281 tb->used += space; 293 tb->used += space;
282 spin_unlock_irqrestore(&tty->buf.lock, flags); 294 spin_unlock_irqrestore(&buf->lock, flags);
283 copied += space; 295 copied += space;
284 chars += space; 296 chars += space;
285 /* There is a small chance that we need to split the data over 297 /* There is a small chance that we need to split the data over
@@ -300,12 +312,13 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag);
300 * the flags array indicates the status of the character. Returns the 312 * the flags array indicates the status of the character. Returns the
301 * number added. 313 * number added.
302 * 314 *
303 * Locking: Called functions may take tty->buf.lock 315 * Locking: Called functions may take port->buf.lock
304 */ 316 */
305 317
306int tty_insert_flip_string_flags(struct tty_struct *tty, 318int tty_insert_flip_string_flags(struct tty_struct *tty,
307 const unsigned char *chars, const char *flags, size_t size) 319 const unsigned char *chars, const char *flags, size_t size)
308{ 320{
321 struct tty_bufhead *buf = &tty->port->buf;
309 int copied = 0; 322 int copied = 0;
310 do { 323 do {
311 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); 324 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
@@ -313,18 +326,18 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
313 unsigned long __flags; 326 unsigned long __flags;
314 struct tty_buffer *tb; 327 struct tty_buffer *tb;
315 328
316 spin_lock_irqsave(&tty->buf.lock, __flags); 329 spin_lock_irqsave(&buf->lock, __flags);
317 space = __tty_buffer_request_room(tty, goal); 330 space = __tty_buffer_request_room(tty->port, goal);
318 tb = tty->buf.tail; 331 tb = buf->tail;
319 /* If there is no space then tb may be NULL */ 332 /* If there is no space then tb may be NULL */
320 if (unlikely(space == 0)) { 333 if (unlikely(space == 0)) {
321 spin_unlock_irqrestore(&tty->buf.lock, __flags); 334 spin_unlock_irqrestore(&buf->lock, __flags);
322 break; 335 break;
323 } 336 }
324 memcpy(tb->char_buf_ptr + tb->used, chars, space); 337 memcpy(tb->char_buf_ptr + tb->used, chars, space);
325 memcpy(tb->flag_buf_ptr + tb->used, flags, space); 338 memcpy(tb->flag_buf_ptr + tb->used, flags, space);
326 tb->used += space; 339 tb->used += space;
327 spin_unlock_irqrestore(&tty->buf.lock, __flags); 340 spin_unlock_irqrestore(&buf->lock, __flags);
328 copied += space; 341 copied += space;
329 chars += space; 342 chars += space;
330 flags += space; 343 flags += space;
@@ -342,18 +355,23 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags);
342 * Takes any pending buffers and transfers their ownership to the 355 * Takes any pending buffers and transfers their ownership to the
343 * ldisc side of the queue. It then schedules those characters for 356 * ldisc side of the queue. It then schedules those characters for
344 * processing by the line discipline. 357 * processing by the line discipline.
358 * Note that this function can only be used when the low_latency flag
359 * is unset. Otherwise the workqueue won't be flushed.
345 * 360 *
346 * Locking: Takes tty->buf.lock 361 * Locking: Takes port->buf.lock
347 */ 362 */
348 363
349void tty_schedule_flip(struct tty_struct *tty) 364void tty_schedule_flip(struct tty_struct *tty)
350{ 365{
366 struct tty_bufhead *buf = &tty->port->buf;
351 unsigned long flags; 367 unsigned long flags;
352 spin_lock_irqsave(&tty->buf.lock, flags); 368 WARN_ON(tty->low_latency);
353 if (tty->buf.tail != NULL) 369
354 tty->buf.tail->commit = tty->buf.tail->used; 370 spin_lock_irqsave(&buf->lock, flags);
355 spin_unlock_irqrestore(&tty->buf.lock, flags); 371 if (buf->tail != NULL)
356 schedule_work(&tty->buf.work); 372 buf->tail->commit = buf->tail->used;
373 spin_unlock_irqrestore(&buf->lock, flags);
374 schedule_work(&buf->work);
357} 375}
358EXPORT_SYMBOL(tty_schedule_flip); 376EXPORT_SYMBOL(tty_schedule_flip);
359 377
@@ -369,26 +387,27 @@ EXPORT_SYMBOL(tty_schedule_flip);
369 * that need their own block copy routines into the buffer. There is no 387 * that need their own block copy routines into the buffer. There is no
370 * guarantee the buffer is a DMA target! 388 * guarantee the buffer is a DMA target!
371 * 389 *
372 * Locking: May call functions taking tty->buf.lock 390 * Locking: May call functions taking port->buf.lock
373 */ 391 */
374 392
375int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, 393int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars,
376 size_t size) 394 size_t size)
377{ 395{
396 struct tty_bufhead *buf = &tty->port->buf;
378 int space; 397 int space;
379 unsigned long flags; 398 unsigned long flags;
380 struct tty_buffer *tb; 399 struct tty_buffer *tb;
381 400
382 spin_lock_irqsave(&tty->buf.lock, flags); 401 spin_lock_irqsave(&buf->lock, flags);
383 space = __tty_buffer_request_room(tty, size); 402 space = __tty_buffer_request_room(tty->port, size);
384 403
385 tb = tty->buf.tail; 404 tb = buf->tail;
386 if (likely(space)) { 405 if (likely(space)) {
387 *chars = tb->char_buf_ptr + tb->used; 406 *chars = tb->char_buf_ptr + tb->used;
388 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); 407 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space);
389 tb->used += space; 408 tb->used += space;
390 } 409 }
391 spin_unlock_irqrestore(&tty->buf.lock, flags); 410 spin_unlock_irqrestore(&buf->lock, flags);
392 return space; 411 return space;
393} 412}
394EXPORT_SYMBOL_GPL(tty_prepare_flip_string); 413EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
@@ -406,26 +425,27 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
406 * that need their own block copy routines into the buffer. There is no 425 * that need their own block copy routines into the buffer. There is no
407 * guarantee the buffer is a DMA target! 426 * guarantee the buffer is a DMA target!
408 * 427 *
409 * Locking: May call functions taking tty->buf.lock 428 * Locking: May call functions taking port->buf.lock
410 */ 429 */
411 430
412int tty_prepare_flip_string_flags(struct tty_struct *tty, 431int tty_prepare_flip_string_flags(struct tty_struct *tty,
413 unsigned char **chars, char **flags, size_t size) 432 unsigned char **chars, char **flags, size_t size)
414{ 433{
434 struct tty_bufhead *buf = &tty->port->buf;
415 int space; 435 int space;
416 unsigned long __flags; 436 unsigned long __flags;
417 struct tty_buffer *tb; 437 struct tty_buffer *tb;
418 438
419 spin_lock_irqsave(&tty->buf.lock, __flags); 439 spin_lock_irqsave(&buf->lock, __flags);
420 space = __tty_buffer_request_room(tty, size); 440 space = __tty_buffer_request_room(tty->port, size);
421 441
422 tb = tty->buf.tail; 442 tb = buf->tail;
423 if (likely(space)) { 443 if (likely(space)) {
424 *chars = tb->char_buf_ptr + tb->used; 444 *chars = tb->char_buf_ptr + tb->used;
425 *flags = tb->flag_buf_ptr + tb->used; 445 *flags = tb->flag_buf_ptr + tb->used;
426 tb->used += space; 446 tb->used += space;
427 } 447 }
428 spin_unlock_irqrestore(&tty->buf.lock, __flags); 448 spin_unlock_irqrestore(&buf->lock, __flags);
429 return space; 449 return space;
430} 450}
431EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags); 451EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags);
@@ -446,20 +466,25 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags);
446 466
447static void flush_to_ldisc(struct work_struct *work) 467static void flush_to_ldisc(struct work_struct *work)
448{ 468{
449 struct tty_struct *tty = 469 struct tty_port *port = container_of(work, struct tty_port, buf.work);
450 container_of(work, struct tty_struct, buf.work); 470 struct tty_bufhead *buf = &port->buf;
471 struct tty_struct *tty;
451 unsigned long flags; 472 unsigned long flags;
452 struct tty_ldisc *disc; 473 struct tty_ldisc *disc;
453 474
475 tty = port->itty;
476 if (WARN_RATELIMIT(tty == NULL, "tty is NULL"))
477 return;
478
454 disc = tty_ldisc_ref(tty); 479 disc = tty_ldisc_ref(tty);
455 if (disc == NULL) /* !TTY_LDISC */ 480 if (disc == NULL) /* !TTY_LDISC */
456 return; 481 return;
457 482
458 spin_lock_irqsave(&tty->buf.lock, flags); 483 spin_lock_irqsave(&buf->lock, flags);
459 484
460 if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) { 485 if (!test_and_set_bit(TTYP_FLUSHING, &port->iflags)) {
461 struct tty_buffer *head; 486 struct tty_buffer *head;
462 while ((head = tty->buf.head) != NULL) { 487 while ((head = buf->head) != NULL) {
463 int count; 488 int count;
464 char *char_buf; 489 char *char_buf;
465 unsigned char *flag_buf; 490 unsigned char *flag_buf;
@@ -468,14 +493,14 @@ static void flush_to_ldisc(struct work_struct *work)
468 if (!count) { 493 if (!count) {
469 if (head->next == NULL) 494 if (head->next == NULL)
470 break; 495 break;
471 tty->buf.head = head->next; 496 buf->head = head->next;
472 tty_buffer_free(tty, head); 497 tty_buffer_free(port, head);
473 continue; 498 continue;
474 } 499 }
475 /* Ldisc or user is trying to flush the buffers 500 /* Ldisc or user is trying to flush the buffers
476 we are feeding to the ldisc, stop feeding the 501 we are feeding to the ldisc, stop feeding the
477 line discipline as we want to empty the queue */ 502 line discipline as we want to empty the queue */
478 if (test_bit(TTY_FLUSHPENDING, &tty->flags)) 503 if (test_bit(TTYP_FLUSHPENDING, &port->iflags))
479 break; 504 break;
480 if (!tty->receive_room) 505 if (!tty->receive_room)
481 break; 506 break;
@@ -484,22 +509,22 @@ static void flush_to_ldisc(struct work_struct *work)
484 char_buf = head->char_buf_ptr + head->read; 509 char_buf = head->char_buf_ptr + head->read;
485 flag_buf = head->flag_buf_ptr + head->read; 510 flag_buf = head->flag_buf_ptr + head->read;
486 head->read += count; 511 head->read += count;
487 spin_unlock_irqrestore(&tty->buf.lock, flags); 512 spin_unlock_irqrestore(&buf->lock, flags);
488 disc->ops->receive_buf(tty, char_buf, 513 disc->ops->receive_buf(tty, char_buf,
489 flag_buf, count); 514 flag_buf, count);
490 spin_lock_irqsave(&tty->buf.lock, flags); 515 spin_lock_irqsave(&buf->lock, flags);
491 } 516 }
492 clear_bit(TTY_FLUSHING, &tty->flags); 517 clear_bit(TTYP_FLUSHING, &port->iflags);
493 } 518 }
494 519
495 /* We may have a deferred request to flush the input buffer, 520 /* We may have a deferred request to flush the input buffer,
496 if so pull the chain under the lock and empty the queue */ 521 if so pull the chain under the lock and empty the queue */
497 if (test_bit(TTY_FLUSHPENDING, &tty->flags)) { 522 if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) {
498 __tty_buffer_flush(tty); 523 __tty_buffer_flush(port);
499 clear_bit(TTY_FLUSHPENDING, &tty->flags); 524 clear_bit(TTYP_FLUSHPENDING, &port->iflags);
500 wake_up(&tty->read_wait); 525 wake_up(&tty->read_wait);
501 } 526 }
502 spin_unlock_irqrestore(&tty->buf.lock, flags); 527 spin_unlock_irqrestore(&buf->lock, flags);
503 528
504 tty_ldisc_deref(disc); 529 tty_ldisc_deref(disc);
505} 530}
@@ -514,7 +539,8 @@ static void flush_to_ldisc(struct work_struct *work)
514 */ 539 */
515void tty_flush_to_ldisc(struct tty_struct *tty) 540void tty_flush_to_ldisc(struct tty_struct *tty)
516{ 541{
517 flush_work(&tty->buf.work); 542 if (!tty->low_latency)
543 flush_work(&tty->port->buf.work);
518} 544}
519 545
520/** 546/**
@@ -532,16 +558,18 @@ void tty_flush_to_ldisc(struct tty_struct *tty)
532 558
533void tty_flip_buffer_push(struct tty_struct *tty) 559void tty_flip_buffer_push(struct tty_struct *tty)
534{ 560{
561 struct tty_bufhead *buf = &tty->port->buf;
535 unsigned long flags; 562 unsigned long flags;
536 spin_lock_irqsave(&tty->buf.lock, flags); 563
537 if (tty->buf.tail != NULL) 564 spin_lock_irqsave(&buf->lock, flags);
538 tty->buf.tail->commit = tty->buf.tail->used; 565 if (buf->tail != NULL)
539 spin_unlock_irqrestore(&tty->buf.lock, flags); 566 buf->tail->commit = buf->tail->used;
567 spin_unlock_irqrestore(&buf->lock, flags);
540 568
541 if (tty->low_latency) 569 if (tty->low_latency)
542 flush_to_ldisc(&tty->buf.work); 570 flush_to_ldisc(&buf->work);
543 else 571 else
544 schedule_work(&tty->buf.work); 572 schedule_work(&buf->work);
545} 573}
546EXPORT_SYMBOL(tty_flip_buffer_push); 574EXPORT_SYMBOL(tty_flip_buffer_push);
547 575
@@ -555,13 +583,15 @@ EXPORT_SYMBOL(tty_flip_buffer_push);
555 * Locking: none 583 * Locking: none
556 */ 584 */
557 585
558void tty_buffer_init(struct tty_struct *tty) 586void tty_buffer_init(struct tty_port *port)
559{ 587{
560 spin_lock_init(&tty->buf.lock); 588 struct tty_bufhead *buf = &port->buf;
561 tty->buf.head = NULL; 589
562 tty->buf.tail = NULL; 590 spin_lock_init(&buf->lock);
563 tty->buf.free = NULL; 591 buf->head = NULL;
564 tty->buf.memory_used = 0; 592 buf->tail = NULL;
565 INIT_WORK(&tty->buf.work, flush_to_ldisc); 593 buf->free = NULL;
594 buf->memory_used = 0;
595 INIT_WORK(&buf->work, flush_to_ldisc);
566} 596}
567 597
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 2ea176b2280e..a3eba7f359ed 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -186,7 +186,6 @@ void free_tty_struct(struct tty_struct *tty)
186 if (tty->dev) 186 if (tty->dev)
187 put_device(tty->dev); 187 put_device(tty->dev);
188 kfree(tty->write_buf); 188 kfree(tty->write_buf);
189 tty_buffer_free_all(tty);
190 tty->magic = 0xDEADDEAD; 189 tty->magic = 0xDEADDEAD;
191 kfree(tty); 190 kfree(tty);
192} 191}
@@ -1417,6 +1416,8 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
1417 "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", 1416 "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n",
1418 __func__, tty->driver->name); 1417 __func__, tty->driver->name);
1419 1418
1419 tty->port->itty = tty;
1420
1420 /* 1421 /*
1421 * Structures all installed ... call the ldisc open routines. 1422 * Structures all installed ... call the ldisc open routines.
1422 * If we fail here just call release_tty to clean up. No need 1423 * If we fail here just call release_tty to clean up. No need
@@ -1552,6 +1553,7 @@ static void release_tty(struct tty_struct *tty, int idx)
1552 tty->ops->shutdown(tty); 1553 tty->ops->shutdown(tty);
1553 tty_free_termios(tty); 1554 tty_free_termios(tty);
1554 tty_driver_remove_tty(tty->driver, tty); 1555 tty_driver_remove_tty(tty->driver, tty);
1556 tty->port->itty = NULL;
1555 1557
1556 if (tty->link) 1558 if (tty->link)
1557 tty_kref_put(tty->link); 1559 tty_kref_put(tty->link);
@@ -1625,7 +1627,6 @@ int tty_release(struct inode *inode, struct file *filp)
1625 struct tty_struct *tty = file_tty(filp); 1627 struct tty_struct *tty = file_tty(filp);
1626 struct tty_struct *o_tty; 1628 struct tty_struct *o_tty;
1627 int pty_master, tty_closing, o_tty_closing, do_sleep; 1629 int pty_master, tty_closing, o_tty_closing, do_sleep;
1628 int devpts;
1629 int idx; 1630 int idx;
1630 char buf[64]; 1631 char buf[64];
1631 1632
@@ -1640,7 +1641,6 @@ int tty_release(struct inode *inode, struct file *filp)
1640 idx = tty->index; 1641 idx = tty->index;
1641 pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && 1642 pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
1642 tty->driver->subtype == PTY_TYPE_MASTER); 1643 tty->driver->subtype == PTY_TYPE_MASTER);
1643 devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0;
1644 /* Review: parallel close */ 1644 /* Review: parallel close */
1645 o_tty = tty->link; 1645 o_tty = tty->link;
1646 1646
@@ -1799,9 +1799,6 @@ int tty_release(struct inode *inode, struct file *filp)
1799 release_tty(tty, idx); 1799 release_tty(tty, idx);
1800 mutex_unlock(&tty_mutex); 1800 mutex_unlock(&tty_mutex);
1801 1801
1802 /* Make this pty number available for reallocation */
1803 if (devpts)
1804 devpts_kill_index(inode, idx);
1805 return 0; 1802 return 0;
1806} 1803}
1807 1804
@@ -2937,19 +2934,13 @@ void initialize_tty_struct(struct tty_struct *tty,
2937 tty_ldisc_init(tty); 2934 tty_ldisc_init(tty);
2938 tty->session = NULL; 2935 tty->session = NULL;
2939 tty->pgrp = NULL; 2936 tty->pgrp = NULL;
2940 tty->overrun_time = jiffies;
2941 tty_buffer_init(tty);
2942 mutex_init(&tty->legacy_mutex); 2937 mutex_init(&tty->legacy_mutex);
2943 mutex_init(&tty->termios_mutex); 2938 mutex_init(&tty->termios_mutex);
2944 mutex_init(&tty->ldisc_mutex); 2939 mutex_init(&tty->ldisc_mutex);
2945 init_waitqueue_head(&tty->write_wait); 2940 init_waitqueue_head(&tty->write_wait);
2946 init_waitqueue_head(&tty->read_wait); 2941 init_waitqueue_head(&tty->read_wait);
2947 INIT_WORK(&tty->hangup_work, do_tty_hangup); 2942 INIT_WORK(&tty->hangup_work, do_tty_hangup);
2948 mutex_init(&tty->atomic_read_lock);
2949 mutex_init(&tty->atomic_write_lock); 2943 mutex_init(&tty->atomic_write_lock);
2950 mutex_init(&tty->output_lock);
2951 mutex_init(&tty->echo_lock);
2952 spin_lock_init(&tty->read_lock);
2953 spin_lock_init(&tty->ctrl_lock); 2944 spin_lock_init(&tty->ctrl_lock);
2954 INIT_LIST_HEAD(&tty->tty_files); 2945 INIT_LIST_HEAD(&tty->tty_files);
2955 INIT_WORK(&tty->SAK_work, do_SAK_work); 2946 INIT_WORK(&tty->SAK_work, do_SAK_work);
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 0f2a2c5e704c..f4e6754525dc 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -512,7 +512,7 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
512static int tty_ldisc_halt(struct tty_struct *tty) 512static int tty_ldisc_halt(struct tty_struct *tty)
513{ 513{
514 clear_bit(TTY_LDISC, &tty->flags); 514 clear_bit(TTY_LDISC, &tty->flags);
515 return cancel_work_sync(&tty->buf.work); 515 return cancel_work_sync(&tty->port->buf.work);
516} 516}
517 517
518/** 518/**
@@ -525,7 +525,7 @@ static void tty_ldisc_flush_works(struct tty_struct *tty)
525{ 525{
526 flush_work(&tty->hangup_work); 526 flush_work(&tty->hangup_work);
527 flush_work(&tty->SAK_work); 527 flush_work(&tty->SAK_work);
528 flush_work(&tty->buf.work); 528 flush_work(&tty->port->buf.work);
529} 529}
530 530
531/** 531/**
@@ -704,9 +704,9 @@ enable:
704 /* Restart the work queue in case no characters kick it off. Safe if 704 /* Restart the work queue in case no characters kick it off. Safe if
705 already running */ 705 already running */
706 if (work) 706 if (work)
707 schedule_work(&tty->buf.work); 707 schedule_work(&tty->port->buf.work);
708 if (o_work) 708 if (o_work)
709 schedule_work(&o_tty->buf.work); 709 schedule_work(&o_tty->port->buf.work);
710 mutex_unlock(&tty->ldisc_mutex); 710 mutex_unlock(&tty->ldisc_mutex);
711 tty_unlock(tty); 711 tty_unlock(tty);
712 return retval; 712 return retval;
@@ -817,7 +817,7 @@ void tty_ldisc_hangup(struct tty_struct *tty)
817 */ 817 */
818 clear_bit(TTY_LDISC, &tty->flags); 818 clear_bit(TTY_LDISC, &tty->flags);
819 tty_unlock(tty); 819 tty_unlock(tty);
820 cancel_work_sync(&tty->buf.work); 820 cancel_work_sync(&tty->port->buf.work);
821 mutex_unlock(&tty->ldisc_mutex); 821 mutex_unlock(&tty->ldisc_mutex);
822retry: 822retry:
823 tty_lock(tty); 823 tty_lock(tty);
@@ -897,6 +897,11 @@ int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty)
897 897
898static void tty_ldisc_kill(struct tty_struct *tty) 898static void tty_ldisc_kill(struct tty_struct *tty)
899{ 899{
900 /* There cannot be users from userspace now. But there still might be
901 * drivers holding a reference via tty_ldisc_ref. Do not steal them the
902 * ldisc until they are done. */
903 tty_ldisc_wait_idle(tty, MAX_SCHEDULE_TIMEOUT);
904
900 mutex_lock(&tty->ldisc_mutex); 905 mutex_lock(&tty->ldisc_mutex);
901 /* 906 /*
902 * Now kill off the ldisc 907 * Now kill off the ldisc
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index d7bdd8d0c23f..416b42f7c346 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -21,6 +21,7 @@
21void tty_port_init(struct tty_port *port) 21void tty_port_init(struct tty_port *port)
22{ 22{
23 memset(port, 0, sizeof(*port)); 23 memset(port, 0, sizeof(*port));
24 tty_buffer_init(port);
24 init_waitqueue_head(&port->open_wait); 25 init_waitqueue_head(&port->open_wait);
25 init_waitqueue_head(&port->close_wait); 26 init_waitqueue_head(&port->close_wait);
26 init_waitqueue_head(&port->delta_msr_wait); 27 init_waitqueue_head(&port->delta_msr_wait);
@@ -126,6 +127,7 @@ static void tty_port_destructor(struct kref *kref)
126 struct tty_port *port = container_of(kref, struct tty_port, kref); 127 struct tty_port *port = container_of(kref, struct tty_port, kref);
127 if (port->xmit_buf) 128 if (port->xmit_buf)
128 free_page((unsigned long)port->xmit_buf); 129 free_page((unsigned long)port->xmit_buf);
130 tty_buffer_free_all(port);
129 if (port->ops->destruct) 131 if (port->ops->destruct)
130 port->ops->destruct(port); 132 port->ops->destruct(port);
131 else 133 else
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index 8e9b4be97a2d..60b7b6926059 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -341,15 +341,11 @@ int paste_selection(struct tty_struct *tty)
341 struct tty_ldisc *ld; 341 struct tty_ldisc *ld;
342 DECLARE_WAITQUEUE(wait, current); 342 DECLARE_WAITQUEUE(wait, current);
343 343
344
345 console_lock(); 344 console_lock();
346 poke_blanked_console(); 345 poke_blanked_console();
347 console_unlock(); 346 console_unlock();
348 347
349 /* FIXME: wtf is this supposed to achieve ? */ 348 ld = tty_ldisc_ref_wait(tty);
350 ld = tty_ldisc_ref(tty);
351 if (!ld)
352 ld = tty_ldisc_ref_wait(tty);
353 349
354 /* FIXME: this is completely unsafe */ 350 /* FIXME: this is completely unsafe */
355 add_wait_queue(&vc->paste_wait, &wait); 351 add_wait_queue(&vc->paste_wait, &wait);
@@ -361,8 +357,7 @@ int paste_selection(struct tty_struct *tty)
361 } 357 }
362 count = sel_buffer_lth - pasted; 358 count = sel_buffer_lth - pasted;
363 count = min(count, tty->receive_room); 359 count = min(count, tty->receive_room);
364 tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted, 360 ld->ops->receive_buf(tty, sel_buffer + pasted, NULL, count);
365 NULL, count);
366 pasted += count; 361 pasted += count;
367 } 362 }
368 remove_wait_queue(&vc->paste_wait, &wait); 363 remove_wait_queue(&vc->paste_wait, &wait);
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 2a4749c3eb3f..23afa06b65a4 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -44,7 +44,7 @@
44#include <asm/unaligned.h> 44#include <asm/unaligned.h>
45#include <asm/mach-types.h> 45#include <asm/mach-types.h>
46 46
47#include <plat/dma.h> 47#include <plat-omap/dma-omap.h>
48 48
49#include <mach/usb.h> 49#include <mach/usb.h>
50 50
@@ -61,6 +61,8 @@
61#define DRIVER_DESC "OMAP UDC driver" 61#define DRIVER_DESC "OMAP UDC driver"
62#define DRIVER_VERSION "4 October 2004" 62#define DRIVER_VERSION "4 October 2004"
63 63
64#define OMAP_DMA_USB_W2FC_TX0 29
65
64/* 66/*
65 * The OMAP UDC needs _very_ early endpoint setup: before enabling the 67 * The OMAP UDC needs _very_ early endpoint setup: before enabling the
66 * D+ pullup to allow enumeration. That's too early for the gadget 68 * D+ pullup to allow enumeration. That's too early for the gadget
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index d7fe287d0678..0d5ac36fdf47 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -39,12 +39,13 @@
39#include <linux/platform_device.h> 39#include <linux/platform_device.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/usb/ulpi.h> 41#include <linux/usb/ulpi.h>
42#include <plat/usb.h>
43#include <linux/regulator/consumer.h> 42#include <linux/regulator/consumer.h>
44#include <linux/pm_runtime.h> 43#include <linux/pm_runtime.h>
45#include <linux/gpio.h> 44#include <linux/gpio.h>
46#include <linux/clk.h> 45#include <linux/clk.h>
47 46
47#include <linux/platform_data/usb-omap.h>
48
48/* EHCI Register Set */ 49/* EHCI Register Set */
49#define EHCI_INSNREG04 (0xA0) 50#define EHCI_INSNREG04 (0xA0)
50#define EHCI_INSNREG04_DISABLE_UNSUSPEND (1 << 5) 51#define EHCI_INSNREG04_DISABLE_UNSUSPEND (1 << 5)
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 4531d03503c3..439e6e4f2d6b 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -25,7 +25,6 @@
25#include <asm/mach-types.h> 25#include <asm/mach-types.h>
26 26
27#include <mach/mux.h> 27#include <mach/mux.h>
28#include <plat/fpga.h>
29 28
30#include <mach/hardware.h> 29#include <mach/hardware.h>
31#include <mach/irqs.h> 30#include <mach/irqs.h>
@@ -93,14 +92,14 @@ static int omap_ohci_transceiver_power(int on)
93{ 92{
94 if (on) { 93 if (on) {
95 if (machine_is_omap_innovator() && cpu_is_omap1510()) 94 if (machine_is_omap_innovator() && cpu_is_omap1510())
96 fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) 95 __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL)
97 | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), 96 | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)),
98 INNOVATOR_FPGA_CAM_USB_CONTROL); 97 INNOVATOR_FPGA_CAM_USB_CONTROL);
99 else if (machine_is_omap_osk()) 98 else if (machine_is_omap_osk())
100 tps65010_set_gpio_out_value(GPIO1, LOW); 99 tps65010_set_gpio_out_value(GPIO1, LOW);
101 } else { 100 } else {
102 if (machine_is_omap_innovator() && cpu_is_omap1510()) 101 if (machine_is_omap_innovator() && cpu_is_omap1510())
103 fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) 102 __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL)
104 & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), 103 & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)),
105 INNOVATOR_FPGA_CAM_USB_CONTROL); 104 INNOVATOR_FPGA_CAM_USB_CONTROL);
106 else if (machine_is_omap_osk()) 105 else if (machine_is_omap_osk())
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index 1b8133b6e451..bd7803dce9be 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -30,7 +30,6 @@
30 */ 30 */
31 31
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <plat/usb.h>
34#include <linux/pm_runtime.h> 33#include <linux/pm_runtime.h>
35 34
36/*-------------------------------------------------------------------------*/ 35/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index c964d6af178b..a87cdd2387cf 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -34,8 +34,7 @@
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
36#include <linux/usb/nop-usb-xceiv.h> 36#include <linux/usb/nop-usb-xceiv.h>
37 37#include <linux/platform_data/usb-omap.h>
38#include <plat/usb.h>
39 38
40#include "musb_core.h" 39#include "musb_core.h"
41 40
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index ff5f112053d2..aa34f22181c1 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -38,13 +38,12 @@
38#include <linux/pm_runtime.h> 38#include <linux/pm_runtime.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/usb/nop-usb-xceiv.h> 40#include <linux/usb/nop-usb-xceiv.h>
41#include <linux/platform_data/usb-omap.h>
41 42
42#include <linux/of.h> 43#include <linux/of.h>
43#include <linux/of_device.h> 44#include <linux/of_device.h>
44#include <linux/of_address.h> 45#include <linux/of_address.h>
45 46
46#include <plat/usb.h>
47
48#include "musb_core.h" 47#include "musb_core.h"
49 48
50#ifdef CONFIG_OF 49#ifdef CONFIG_OF
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h
index b85f3973e78c..8ef656659fcb 100644
--- a/drivers/usb/musb/omap2430.h
+++ b/drivers/usb/musb/omap2430.h
@@ -10,7 +10,7 @@
10#ifndef __MUSB_OMAP243X_H__ 10#ifndef __MUSB_OMAP243X_H__
11#define __MUSB_OMAP243X_H__ 11#define __MUSB_OMAP243X_H__
12 12
13#include <plat/usb.h> 13#include <linux/platform_data/usb-omap.h>
14 14
15/* 15/*
16 * OMAP2430-specific definitions 16 * OMAP2430-specific definitions
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 7a62b95dac24..bfca114f7c56 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -16,7 +16,7 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <plat/dma.h> 19#include <plat-omap/dma-omap.h>
20 20
21#include "musb_core.h" 21#include "musb_core.h"
22#include "tusb6010.h" 22#include "tusb6010.h"
@@ -25,6 +25,13 @@
25 25
26#define MAX_DMAREQ 5 /* REVISIT: Really 6, but req5 not OK */ 26#define MAX_DMAREQ 5 /* REVISIT: Really 6, but req5 not OK */
27 27
28#define OMAP24XX_DMA_EXT_DMAREQ0 2
29#define OMAP24XX_DMA_EXT_DMAREQ1 3
30#define OMAP242X_DMA_EXT_DMAREQ2 14
31#define OMAP242X_DMA_EXT_DMAREQ3 15
32#define OMAP242X_DMA_EXT_DMAREQ4 16
33#define OMAP242X_DMA_EXT_DMAREQ5 64
34
28struct tusb_omap_dma_ch { 35struct tusb_omap_dma_ch {
29 struct musb *musb; 36 struct musb *musb;
30 void __iomem *tbase; 37 void __iomem *tbase;
diff --git a/drivers/video/omap/lcd_inn1510.c b/drivers/video/omap/lcd_inn1510.c
index b38b1dd15ce3..2ee423279e35 100644
--- a/drivers/video/omap/lcd_inn1510.c
+++ b/drivers/video/omap/lcd_inn1510.c
@@ -23,7 +23,8 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/io.h> 24#include <linux/io.h>
25 25
26#include <plat/fpga.h> 26#include <mach/hardware.h>
27
27#include "omapfb.h" 28#include "omapfb.h"
28 29
29static int innovator1510_panel_init(struct lcd_panel *panel, 30static int innovator1510_panel_init(struct lcd_panel *panel,
@@ -38,13 +39,13 @@ static void innovator1510_panel_cleanup(struct lcd_panel *panel)
38 39
39static int innovator1510_panel_enable(struct lcd_panel *panel) 40static int innovator1510_panel_enable(struct lcd_panel *panel)
40{ 41{
41 fpga_write(0x7, OMAP1510_FPGA_LCD_PANEL_CONTROL); 42 __raw_writeb(0x7, OMAP1510_FPGA_LCD_PANEL_CONTROL);
42 return 0; 43 return 0;
43} 44}
44 45
45static void innovator1510_panel_disable(struct lcd_panel *panel) 46static void innovator1510_panel_disable(struct lcd_panel *panel)
46{ 47{
47 fpga_write(0x0, OMAP1510_FPGA_LCD_PANEL_CONTROL); 48 __raw_writeb(0x0, OMAP1510_FPGA_LCD_PANEL_CONTROL);
48} 49}
49 50
50static unsigned long innovator1510_panel_get_caps(struct lcd_panel *panel) 51static unsigned long innovator1510_panel_get_caps(struct lcd_panel *panel)
diff --git a/drivers/video/omap/lcdc.c b/drivers/video/omap/lcdc.c
index 7767338f8b14..c39d6e46f8c5 100644
--- a/drivers/video/omap/lcdc.c
+++ b/drivers/video/omap/lcdc.c
@@ -31,7 +31,7 @@
31#include <linux/gfp.h> 31#include <linux/gfp.h>
32 32
33#include <mach/lcdc.h> 33#include <mach/lcdc.h>
34#include <plat/dma.h> 34#include <plat-omap/dma-omap.h>
35 35
36#include <asm/mach-types.h> 36#include <asm/mach-types.h>
37 37
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
index 4351c438b76f..1b5ee8ec192a 100644
--- a/drivers/video/omap/omapfb_main.c
+++ b/drivers/video/omap/omapfb_main.c
@@ -30,7 +30,7 @@
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/module.h> 31#include <linux/module.h>
32 32
33#include <plat/dma.h> 33#include <plat-omap/dma-omap.h>
34 34
35#include "omapfb.h" 35#include "omapfb.h"
36#include "lcdc.h" 36#include "lcdc.h"
diff --git a/drivers/video/omap/sossi.c b/drivers/video/omap/sossi.c
index f79c137753d7..c510a4457398 100644
--- a/drivers/video/omap/sossi.c
+++ b/drivers/video/omap/sossi.c
@@ -25,7 +25,7 @@
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27 27
28#include <plat/dma.h> 28#include <plat-omap/dma-omap.h>
29 29
30#include "omapfb.h" 30#include "omapfb.h"
31#include "lcdc.h" 31#include "lcdc.h"
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index b2af72dc20bd..d94ef9e31a35 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -237,7 +237,7 @@ static int __init omap_dss_probe(struct platform_device *pdev)
237 237
238 core.pdev = pdev; 238 core.pdev = pdev;
239 239
240 dss_features_init(); 240 dss_features_init(pdata->version);
241 241
242 dss_apply_init(); 242 dss_apply_init();
243 243
diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
index b43477a5fae8..a5ab354f267a 100644
--- a/drivers/video/omap2/dss/dispc.c
+++ b/drivers/video/omap2/dss/dispc.c
@@ -37,8 +37,6 @@
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/pm_runtime.h> 38#include <linux/pm_runtime.h>
39 39
40#include <plat/cpu.h>
41
42#include <video/omapdss.h> 40#include <video/omapdss.h>
43 41
44#include "dss.h" 42#include "dss.h"
@@ -4042,29 +4040,44 @@ static const struct dispc_features omap44xx_dispc_feats __initconst = {
4042 .gfx_fifo_workaround = true, 4040 .gfx_fifo_workaround = true,
4043}; 4041};
4044 4042
4045static int __init dispc_init_features(struct device *dev) 4043static int __init dispc_init_features(struct platform_device *pdev)
4046{ 4044{
4045 struct omap_dss_board_info *pdata = pdev->dev.platform_data;
4047 const struct dispc_features *src; 4046 const struct dispc_features *src;
4048 struct dispc_features *dst; 4047 struct dispc_features *dst;
4049 4048
4050 dst = devm_kzalloc(dev, sizeof(*dst), GFP_KERNEL); 4049 dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL);
4051 if (!dst) { 4050 if (!dst) {
4052 dev_err(dev, "Failed to allocate DISPC Features\n"); 4051 dev_err(&pdev->dev, "Failed to allocate DISPC Features\n");
4053 return -ENOMEM; 4052 return -ENOMEM;
4054 } 4053 }
4055 4054
4056 if (cpu_is_omap24xx()) { 4055 switch (pdata->version) {
4056 case OMAPDSS_VER_OMAP24xx:
4057 src = &omap24xx_dispc_feats; 4057 src = &omap24xx_dispc_feats;
4058 } else if (cpu_is_omap34xx()) { 4058 break;
4059 if (omap_rev() < OMAP3430_REV_ES3_0) 4059
4060 src = &omap34xx_rev1_0_dispc_feats; 4060 case OMAPDSS_VER_OMAP34xx_ES1:
4061 else 4061 src = &omap34xx_rev1_0_dispc_feats;
4062 src = &omap34xx_rev3_0_dispc_feats; 4062 break;
4063 } else if (cpu_is_omap44xx()) { 4063
4064 case OMAPDSS_VER_OMAP34xx_ES3:
4065 case OMAPDSS_VER_OMAP3630:
4066 case OMAPDSS_VER_AM35xx:
4067 src = &omap34xx_rev3_0_dispc_feats;
4068 break;
4069
4070 case OMAPDSS_VER_OMAP4430_ES1:
4071 case OMAPDSS_VER_OMAP4430_ES2:
4072 case OMAPDSS_VER_OMAP4:
4064 src = &omap44xx_dispc_feats; 4073 src = &omap44xx_dispc_feats;
4065 } else if (soc_is_omap54xx()) { 4074 break;
4075
4076 case OMAPDSS_VER_OMAP5:
4066 src = &omap44xx_dispc_feats; 4077 src = &omap44xx_dispc_feats;
4067 } else { 4078 break;
4079
4080 default:
4068 return -ENODEV; 4081 return -ENODEV;
4069 } 4082 }
4070 4083
@@ -4084,7 +4097,7 @@ static int __init omap_dispchw_probe(struct platform_device *pdev)
4084 4097
4085 dispc.pdev = pdev; 4098 dispc.pdev = pdev;
4086 4099
4087 r = dispc_init_features(&dispc.pdev->dev); 4100 r = dispc_init_features(dispc.pdev);
4088 if (r) 4101 if (r)
4089 return r; 4102 return r;
4090 4103
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 2ab1c3e96553..363852a0f764 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -35,8 +35,6 @@
35 35
36#include <video/omapdss.h> 36#include <video/omapdss.h>
37 37
38#include <plat/cpu.h>
39
40#include "dss.h" 38#include "dss.h"
41#include "dss_features.h" 39#include "dss_features.h"
42 40
@@ -792,29 +790,46 @@ static const struct dss_features omap54xx_dss_feats __initconst = {
792 .dpi_select_source = &dss_dpi_select_source_omap5, 790 .dpi_select_source = &dss_dpi_select_source_omap5,
793}; 791};
794 792
795static int __init dss_init_features(struct device *dev) 793static int __init dss_init_features(struct platform_device *pdev)
796{ 794{
795 struct omap_dss_board_info *pdata = pdev->dev.platform_data;
797 const struct dss_features *src; 796 const struct dss_features *src;
798 struct dss_features *dst; 797 struct dss_features *dst;
799 798
800 dst = devm_kzalloc(dev, sizeof(*dst), GFP_KERNEL); 799 dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL);
801 if (!dst) { 800 if (!dst) {
802 dev_err(dev, "Failed to allocate local DSS Features\n"); 801 dev_err(&pdev->dev, "Failed to allocate local DSS Features\n");
803 return -ENOMEM; 802 return -ENOMEM;
804 } 803 }
805 804
806 if (cpu_is_omap24xx()) 805 switch (pdata->version) {
806 case OMAPDSS_VER_OMAP24xx:
807 src = &omap24xx_dss_feats; 807 src = &omap24xx_dss_feats;
808 else if (cpu_is_omap34xx()) 808 break;
809
810 case OMAPDSS_VER_OMAP34xx_ES1:
811 case OMAPDSS_VER_OMAP34xx_ES3:
812 case OMAPDSS_VER_AM35xx:
809 src = &omap34xx_dss_feats; 813 src = &omap34xx_dss_feats;
810 else if (cpu_is_omap3630()) 814 break;
815
816 case OMAPDSS_VER_OMAP3630:
811 src = &omap3630_dss_feats; 817 src = &omap3630_dss_feats;
812 else if (cpu_is_omap44xx()) 818 break;
819
820 case OMAPDSS_VER_OMAP4430_ES1:
821 case OMAPDSS_VER_OMAP4430_ES2:
822 case OMAPDSS_VER_OMAP4:
813 src = &omap44xx_dss_feats; 823 src = &omap44xx_dss_feats;
814 else if (soc_is_omap54xx()) 824 break;
825
826 case OMAPDSS_VER_OMAP5:
815 src = &omap54xx_dss_feats; 827 src = &omap54xx_dss_feats;
816 else 828 break;
829
830 default:
817 return -ENODEV; 831 return -ENODEV;
832 }
818 833
819 memcpy(dst, src, sizeof(*dst)); 834 memcpy(dst, src, sizeof(*dst));
820 dss.feat = dst; 835 dss.feat = dst;
@@ -831,7 +846,7 @@ static int __init omap_dsshw_probe(struct platform_device *pdev)
831 846
832 dss.pdev = pdev; 847 dss.pdev = pdev;
833 848
834 r = dss_init_features(&dss.pdev->dev); 849 r = dss_init_features(dss.pdev);
835 if (r) 850 if (r)
836 return r; 851 return r;
837 852
diff --git a/drivers/video/omap2/dss/dss_features.c b/drivers/video/omap2/dss/dss_features.c
index acbc1e1efba3..3e8287c8709d 100644
--- a/drivers/video/omap2/dss/dss_features.c
+++ b/drivers/video/omap2/dss/dss_features.c
@@ -23,7 +23,6 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24 24
25#include <video/omapdss.h> 25#include <video/omapdss.h>
26#include <plat/cpu.h>
27 26
28#include "dss.h" 27#include "dss.h"
29#include "dss_features.h" 28#include "dss_features.h"
@@ -825,10 +824,20 @@ static const struct ti_hdmi_ip_ops omap4_hdmi_functions = {
825 824
826}; 825};
827 826
828void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data) 827void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data,
828 enum omapdss_version version)
829{ 829{
830 if (cpu_is_omap44xx()) 830 switch (version) {
831 case OMAPDSS_VER_OMAP4430_ES1:
832 case OMAPDSS_VER_OMAP4430_ES2:
833 case OMAPDSS_VER_OMAP4:
831 ip_data->ops = &omap4_hdmi_functions; 834 ip_data->ops = &omap4_hdmi_functions;
835 break;
836 default:
837 ip_data->ops = NULL;
838 }
839
840 WARN_ON(ip_data->ops == NULL);
832} 841}
833#endif 842#endif
834 843
@@ -929,29 +938,44 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type)
929 return omap_current_dss_features->supported_rotation_types & rot_type; 938 return omap_current_dss_features->supported_rotation_types & rot_type;
930} 939}
931 940
932void dss_features_init(void) 941void dss_features_init(enum omapdss_version version)
933{ 942{
934 if (cpu_is_omap24xx()) 943 switch (version) {
944 case OMAPDSS_VER_OMAP24xx:
935 omap_current_dss_features = &omap2_dss_features; 945 omap_current_dss_features = &omap2_dss_features;
936 else if (cpu_is_omap3630()) 946 break;
947
948 case OMAPDSS_VER_OMAP34xx_ES1:
949 case OMAPDSS_VER_OMAP34xx_ES3:
950 omap_current_dss_features = &omap3430_dss_features;
951 break;
952
953 case OMAPDSS_VER_OMAP3630:
937 omap_current_dss_features = &omap3630_dss_features; 954 omap_current_dss_features = &omap3630_dss_features;
938 else if (cpu_is_omap34xx()) { 955 break;
939 if (soc_is_am35xx()) { 956
940 omap_current_dss_features = &am35xx_dss_features; 957 case OMAPDSS_VER_OMAP4430_ES1:
941 } else {
942 omap_current_dss_features = &omap3430_dss_features;
943 }
944 }
945 else if (omap_rev() == OMAP4430_REV_ES1_0)
946 omap_current_dss_features = &omap4430_es1_0_dss_features; 958 omap_current_dss_features = &omap4430_es1_0_dss_features;
947 else if (omap_rev() == OMAP4430_REV_ES2_0 || 959 break;
948 omap_rev() == OMAP4430_REV_ES2_1 || 960
949 omap_rev() == OMAP4430_REV_ES2_2) 961 case OMAPDSS_VER_OMAP4430_ES2:
950 omap_current_dss_features = &omap4430_es2_0_1_2_dss_features; 962 omap_current_dss_features = &omap4430_es2_0_1_2_dss_features;
951 else if (cpu_is_omap44xx()) 963 break;
964
965 case OMAPDSS_VER_OMAP4:
952 omap_current_dss_features = &omap4_dss_features; 966 omap_current_dss_features = &omap4_dss_features;
953 else if (soc_is_omap54xx()) 967 break;
968
969 case OMAPDSS_VER_OMAP5:
954 omap_current_dss_features = &omap5_dss_features; 970 omap_current_dss_features = &omap5_dss_features;
955 else 971 break;
972
973 case OMAPDSS_VER_AM35xx:
974 omap_current_dss_features = &am35xx_dss_features;
975 break;
976
977 default:
956 DSSWARN("Unsupported OMAP version"); 978 DSSWARN("Unsupported OMAP version");
979 break;
980 }
957} 981}
diff --git a/drivers/video/omap2/dss/dss_features.h b/drivers/video/omap2/dss/dss_features.h
index 9218113b5e88..fc492ef72a51 100644
--- a/drivers/video/omap2/dss/dss_features.h
+++ b/drivers/video/omap2/dss/dss_features.h
@@ -123,8 +123,9 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type);
123 123
124bool dss_has_feature(enum dss_feat_id id); 124bool dss_has_feature(enum dss_feat_id id);
125void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end); 125void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end);
126void dss_features_init(void); 126void dss_features_init(enum omapdss_version version);
127#if defined(CONFIG_OMAP4_DSS_HDMI) 127#if defined(CONFIG_OMAP4_DSS_HDMI)
128void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data); 128void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data,
129 enum omapdss_version version);
129#endif 130#endif
130#endif 131#endif
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index a48a7dd75b33..adcc906d12f8 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -323,6 +323,7 @@ static void hdmi_runtime_put(void)
323 323
324static int __init hdmi_init_display(struct omap_dss_device *dssdev) 324static int __init hdmi_init_display(struct omap_dss_device *dssdev)
325{ 325{
326 struct omap_dss_board_info *pdata = hdmi.pdev->dev.platform_data;
326 int r; 327 int r;
327 328
328 struct gpio gpios[] = { 329 struct gpio gpios[] = {
@@ -333,7 +334,7 @@ static int __init hdmi_init_display(struct omap_dss_device *dssdev)
333 334
334 DSSDBG("init_display\n"); 335 DSSDBG("init_display\n");
335 336
336 dss_init_hdmi_ip_ops(&hdmi.ip_data); 337 dss_init_hdmi_ip_ops(&hdmi.ip_data, pdata->version);
337 338
338 if (hdmi.vdda_hdmi_dac_reg == NULL) { 339 if (hdmi.vdda_hdmi_dac_reg == NULL) {
339 struct regulator *reg; 340 struct regulator *reg;
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index 606b89f12351..55a39be694a5 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -30,7 +30,7 @@
30#include <linux/export.h> 30#include <linux/export.h>
31 31
32#include <video/omapdss.h> 32#include <video/omapdss.h>
33#include <plat/vrfb.h> 33#include <video/omapvrfb.h>
34#include <plat/vram.h> 34#include <plat/vram.h>
35 35
36#include "omapfb.h" 36#include "omapfb.h"
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index 16db1589bd91..bc225e46fdd2 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -31,9 +31,8 @@
31#include <linux/omapfb.h> 31#include <linux/omapfb.h>
32 32
33#include <video/omapdss.h> 33#include <video/omapdss.h>
34#include <plat/cpu.h>
35#include <plat/vram.h> 34#include <plat/vram.h>
36#include <plat/vrfb.h> 35#include <video/omapvrfb.h>
37 36
38#include "omapfb.h" 37#include "omapfb.h"
39 38
@@ -2396,10 +2395,7 @@ static int __init omapfb_probe(struct platform_device *pdev)
2396 goto err0; 2395 goto err0;
2397 } 2396 }
2398 2397
2399 /* TODO : Replace cpu check with omap_has_vrfb once HAS_FEATURE 2398 if (def_vrfb && !omap_vrfb_supported()) {
2400 * available for OMAP2 and OMAP3
2401 */
2402 if (def_vrfb && !cpu_is_omap24xx() && !cpu_is_omap34xx()) {
2403 def_vrfb = 0; 2399 def_vrfb = 0;
2404 dev_warn(&pdev->dev, "VRFB is not supported on this hardware, " 2400 dev_warn(&pdev->dev, "VRFB is not supported on this hardware, "
2405 "ignoring the module parameter vrfb=y\n"); 2401 "ignoring the module parameter vrfb=y\n");
diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c
index e8d8cc76a435..17aa174e187c 100644
--- a/drivers/video/omap2/omapfb/omapfb-sysfs.c
+++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c
@@ -30,7 +30,7 @@
30#include <linux/omapfb.h> 30#include <linux/omapfb.h>
31 31
32#include <video/omapdss.h> 32#include <video/omapdss.h>
33#include <plat/vrfb.h> 33#include <video/omapvrfb.h>
34 34
35#include "omapfb.h" 35#include "omapfb.h"
36 36
diff --git a/drivers/video/omap2/vrfb.c b/drivers/video/omap2/vrfb.c
index 7e990220ad2a..5d8fdac3b800 100644
--- a/drivers/video/omap2/vrfb.c
+++ b/drivers/video/omap2/vrfb.c
@@ -26,9 +26,9 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/bitops.h> 27#include <linux/bitops.h>
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/platform_device.h>
29 30
30#include <plat/vrfb.h> 31#include <video/omapvrfb.h>
31#include <plat/sdrc.h>
32 32
33#ifdef DEBUG 33#ifdef DEBUG
34#define DBG(format, ...) pr_debug("VRFB: " format, ## __VA_ARGS__) 34#define DBG(format, ...) pr_debug("VRFB: " format, ## __VA_ARGS__)
@@ -36,10 +36,10 @@
36#define DBG(format, ...) 36#define DBG(format, ...)
37#endif 37#endif
38 38
39#define SMS_ROT_VIRT_BASE(context, rot) \ 39#define SMS_ROT_CONTROL(context) (0x0 + 0x10 * context)
40 (((context >= 4) ? 0xD0000000 : 0x70000000) \ 40#define SMS_ROT_SIZE(context) (0x4 + 0x10 * context)
41 + (0x4000000 * (context)) \ 41#define SMS_ROT_PHYSICAL_BA(context) (0x8 + 0x10 * context)
42 + (0x1000000 * (rot))) 42#define SMS_ROT_VIRT_BASE(rot) (0x1000000 * (rot))
43 43
44#define OMAP_VRFB_SIZE (2048 * 2048 * 4) 44#define OMAP_VRFB_SIZE (2048 * 2048 * 4)
45 45
@@ -53,10 +53,16 @@
53#define SMS_PW_OFFSET 4 53#define SMS_PW_OFFSET 4
54#define SMS_PS_OFFSET 0 54#define SMS_PS_OFFSET 0
55 55
56#define VRFB_NUM_CTXS 12
57/* bitmap of reserved contexts */ 56/* bitmap of reserved contexts */
58static unsigned long ctx_map; 57static unsigned long ctx_map;
59 58
59struct vrfb_ctx {
60 u32 base;
61 u32 physical_ba;
62 u32 control;
63 u32 size;
64};
65
60static DEFINE_MUTEX(ctx_lock); 66static DEFINE_MUTEX(ctx_lock);
61 67
62/* 68/*
@@ -65,17 +71,34 @@ static DEFINE_MUTEX(ctx_lock);
65 * we don't need locking, since no drivers will run until after the wake-up 71 * we don't need locking, since no drivers will run until after the wake-up
66 * has finished. 72 * has finished.
67 */ 73 */
68static struct { 74
69 u32 physical_ba; 75static void __iomem *vrfb_base;
70 u32 control; 76
71 u32 size; 77static int num_ctxs;
72} vrfb_hw_context[VRFB_NUM_CTXS]; 78static struct vrfb_ctx *ctxs;
79
80static bool vrfb_loaded;
81
82static void omap2_sms_write_rot_control(u32 val, unsigned ctx)
83{
84 __raw_writel(val, vrfb_base + SMS_ROT_CONTROL(ctx));
85}
86
87static void omap2_sms_write_rot_size(u32 val, unsigned ctx)
88{
89 __raw_writel(val, vrfb_base + SMS_ROT_SIZE(ctx));
90}
91
92static void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx)
93{
94 __raw_writel(val, vrfb_base + SMS_ROT_PHYSICAL_BA(ctx));
95}
73 96
74static inline void restore_hw_context(int ctx) 97static inline void restore_hw_context(int ctx)
75{ 98{
76 omap2_sms_write_rot_control(vrfb_hw_context[ctx].control, ctx); 99 omap2_sms_write_rot_control(ctxs[ctx].control, ctx);
77 omap2_sms_write_rot_size(vrfb_hw_context[ctx].size, ctx); 100 omap2_sms_write_rot_size(ctxs[ctx].size, ctx);
78 omap2_sms_write_rot_physical_ba(vrfb_hw_context[ctx].physical_ba, ctx); 101 omap2_sms_write_rot_physical_ba(ctxs[ctx].physical_ba, ctx);
79} 102}
80 103
81static u32 get_image_width_roundup(u16 width, u8 bytespp) 104static u32 get_image_width_roundup(u16 width, u8 bytespp)
@@ -196,9 +219,9 @@ void omap_vrfb_setup(struct vrfb *vrfb, unsigned long paddr,
196 control |= VRFB_PAGE_WIDTH_EXP << SMS_PW_OFFSET; 219 control |= VRFB_PAGE_WIDTH_EXP << SMS_PW_OFFSET;
197 control |= VRFB_PAGE_HEIGHT_EXP << SMS_PH_OFFSET; 220 control |= VRFB_PAGE_HEIGHT_EXP << SMS_PH_OFFSET;
198 221
199 vrfb_hw_context[ctx].physical_ba = paddr; 222 ctxs[ctx].physical_ba = paddr;
200 vrfb_hw_context[ctx].size = size; 223 ctxs[ctx].size = size;
201 vrfb_hw_context[ctx].control = control; 224 ctxs[ctx].control = control;
202 225
203 omap2_sms_write_rot_physical_ba(paddr, ctx); 226 omap2_sms_write_rot_physical_ba(paddr, ctx);
204 omap2_sms_write_rot_size(size, ctx); 227 omap2_sms_write_rot_size(size, ctx);
@@ -274,11 +297,11 @@ int omap_vrfb_request_ctx(struct vrfb *vrfb)
274 297
275 mutex_lock(&ctx_lock); 298 mutex_lock(&ctx_lock);
276 299
277 for (ctx = 0; ctx < VRFB_NUM_CTXS; ++ctx) 300 for (ctx = 0; ctx < num_ctxs; ++ctx)
278 if ((ctx_map & (1 << ctx)) == 0) 301 if ((ctx_map & (1 << ctx)) == 0)
279 break; 302 break;
280 303
281 if (ctx == VRFB_NUM_CTXS) { 304 if (ctx == num_ctxs) {
282 pr_err("vrfb: no free contexts\n"); 305 pr_err("vrfb: no free contexts\n");
283 r = -EBUSY; 306 r = -EBUSY;
284 goto out; 307 goto out;
@@ -293,7 +316,7 @@ int omap_vrfb_request_ctx(struct vrfb *vrfb)
293 vrfb->context = ctx; 316 vrfb->context = ctx;
294 317
295 for (rot = 0; rot < 4; ++rot) { 318 for (rot = 0; rot < 4; ++rot) {
296 paddr = SMS_ROT_VIRT_BASE(ctx, rot); 319 paddr = ctxs[ctx].base + SMS_ROT_VIRT_BASE(rot);
297 if (!request_mem_region(paddr, OMAP_VRFB_SIZE, "vrfb")) { 320 if (!request_mem_region(paddr, OMAP_VRFB_SIZE, "vrfb")) {
298 pr_err("vrfb: failed to reserve VRFB " 321 pr_err("vrfb: failed to reserve VRFB "
299 "area for ctx %d, rotation %d\n", 322 "area for ctx %d, rotation %d\n",
@@ -314,3 +337,80 @@ out:
314 return r; 337 return r;
315} 338}
316EXPORT_SYMBOL(omap_vrfb_request_ctx); 339EXPORT_SYMBOL(omap_vrfb_request_ctx);
340
341bool omap_vrfb_supported(void)
342{
343 return vrfb_loaded;
344}
345EXPORT_SYMBOL(omap_vrfb_supported);
346
347static int __init vrfb_probe(struct platform_device *pdev)
348{
349 struct resource *mem;
350 int i;
351
352 /* first resource is the register res, the rest are vrfb contexts */
353
354 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
355 if (!mem) {
356 dev_err(&pdev->dev, "can't get vrfb base address\n");
357 return -EINVAL;
358 }
359
360 vrfb_base = devm_request_and_ioremap(&pdev->dev, mem);
361 if (!vrfb_base) {
362 dev_err(&pdev->dev, "can't ioremap vrfb memory\n");
363 return -ENOMEM;
364 }
365
366 num_ctxs = pdev->num_resources - 1;
367
368 ctxs = devm_kzalloc(&pdev->dev,
369 sizeof(struct vrfb_ctx) * num_ctxs,
370 GFP_KERNEL);
371
372 if (!ctxs)
373 return -ENOMEM;
374
375 for (i = 0; i < num_ctxs; ++i) {
376 mem = platform_get_resource(pdev, IORESOURCE_MEM, 1 + i);
377 if (!mem) {
378 dev_err(&pdev->dev, "can't get vrfb ctx %d address\n",
379 i);
380 return -EINVAL;
381 }
382
383 ctxs[i].base = mem->start;
384 }
385
386 vrfb_loaded = true;
387
388 return 0;
389}
390
391static void __exit vrfb_remove(struct platform_device *pdev)
392{
393 vrfb_loaded = false;
394}
395
396static struct platform_driver vrfb_driver = {
397 .driver.name = "omapvrfb",
398 .remove = __exit_p(vrfb_remove),
399};
400
401static int __init vrfb_init(void)
402{
403 return platform_driver_probe(&vrfb_driver, &vrfb_probe);
404}
405
406static void __exit vrfb_exit(void)
407{
408 platform_driver_unregister(&vrfb_driver);
409}
410
411module_init(vrfb_init);
412module_exit(vrfb_exit);
413
414MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
415MODULE_DESCRIPTION("OMAP VRFB");
416MODULE_LICENSE("GPL v2");