aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-03 11:34:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-03 11:34:00 -0400
commit5142c33ed86acbcef5c63a63d2b7384b9210d39f (patch)
tree6a0a36207ab436e1ef03bfefa7dac8f3a0cdfae5 /drivers/tty
parent5da77761e6fd51f633b4f31051c4f839e01c29c0 (diff)
parent7eb843aa5050a395bc922db1b41b7237f238d2ba (diff)
Merge tag 'staging-3.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging into next
Pull staging driver updates from Greg KH: "Here is the big staging driver pull request for 3.16-rc1. Lots of stuff here, tons of cleanup patches, a few new drivers, and some removed as well, but I think we are still adding a few thousand more lines than we remove, due to the new drivers being bigger than the ones deleted. One notible bit of work did stand out, Jes Sorensen has gone on a tear, fixing up a wireless driver to be "more sane" than it originally was from the vendor, with over 500 patches merged here. Good stuff, and a number of users laptops are better off for it. All of this has been in linux-next for a while" * tag 'staging-3.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1703 commits) staging: skein: fix sparse warning for static declarations staging/mt29f_spinand: coding style fixes staging: silicom: fix sparse warning for static variable staging: lustre: Fix coding style staging: android: binder.c: Use more appropriate functions for euid retrieval staging: lustre: fix integer as NULL pointer warnings Revert "staging: dgap: remove unneeded kfree() in dgap_tty_register_ports()" Staging: rtl8192u: r8192U_wx.c Fixed a misplaced brace staging: ion: shrink highmem pages on kswapd staging: ion: use compound pages on high order pages for system heap staging: ion: remove struct ion_page_pool_item staging: ion: simplify ion_page_pool_total() staging: ion: tidy up a bit staging: rtl8723au: Remove redundant casting in usb_ops_linux.c staging: rtl8723au: Remove redundant casting in rtl8723a_hal_init.c staging: rtl8723au: Remove redundant casting in rtw_xmit.c staging: rtl8723au: Remove redundant casting in rtw_wlan_util.c staging: rtl8723au: Remove redundant casting in rtw_sta_mgt.c staging: rtl8723au: Remove redundant casting in rtw_recv.c staging: rtl8723au: Remove redundant casting in rtw_mlme.c ...
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/goldfish.c68
1 files changed, 40 insertions, 28 deletions
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 75dc9d25f326..09495f515fa9 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -21,6 +21,7 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/goldfish.h>
24 25
25enum { 26enum {
26 GOLDFISH_TTY_PUT_CHAR = 0x00, 27 GOLDFISH_TTY_PUT_CHAR = 0x00,
@@ -29,6 +30,7 @@ enum {
29 30
30 GOLDFISH_TTY_DATA_PTR = 0x10, 31 GOLDFISH_TTY_DATA_PTR = 0x10,
31 GOLDFISH_TTY_DATA_LEN = 0x14, 32 GOLDFISH_TTY_DATA_LEN = 0x14,
33 GOLDFISH_TTY_DATA_PTR_HIGH = 0x18,
32 34
33 GOLDFISH_TTY_CMD_INT_DISABLE = 0, 35 GOLDFISH_TTY_CMD_INT_DISABLE = 0,
34 GOLDFISH_TTY_CMD_INT_ENABLE = 1, 36 GOLDFISH_TTY_CMD_INT_ENABLE = 1,
@@ -57,7 +59,8 @@ static void goldfish_tty_do_write(int line, const char *buf, unsigned count)
57 struct goldfish_tty *qtty = &goldfish_ttys[line]; 59 struct goldfish_tty *qtty = &goldfish_ttys[line];
58 void __iomem *base = qtty->base; 60 void __iomem *base = qtty->base;
59 spin_lock_irqsave(&qtty->lock, irq_flags); 61 spin_lock_irqsave(&qtty->lock, irq_flags);
60 writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); 62 gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR,
63 base + GOLDFISH_TTY_DATA_PTR_HIGH);
61 writel(count, base + GOLDFISH_TTY_DATA_LEN); 64 writel(count, base + GOLDFISH_TTY_DATA_LEN);
62 writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD); 65 writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD);
63 spin_unlock_irqrestore(&qtty->lock, irq_flags); 66 spin_unlock_irqrestore(&qtty->lock, irq_flags);
@@ -73,12 +76,13 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id)
73 u32 count; 76 u32 count;
74 77
75 count = readl(base + GOLDFISH_TTY_BYTES_READY); 78 count = readl(base + GOLDFISH_TTY_BYTES_READY);
76 if(count == 0) 79 if (count == 0)
77 return IRQ_NONE; 80 return IRQ_NONE;
78 81
79 count = tty_prepare_flip_string(&qtty->port, &buf, count); 82 count = tty_prepare_flip_string(&qtty->port, &buf, count);
80 spin_lock_irqsave(&qtty->lock, irq_flags); 83 spin_lock_irqsave(&qtty->lock, irq_flags);
81 writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); 84 gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR,
85 base + GOLDFISH_TTY_DATA_PTR_HIGH);
82 writel(count, base + GOLDFISH_TTY_DATA_LEN); 86 writel(count, base + GOLDFISH_TTY_DATA_LEN);
83 writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); 87 writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD);
84 spin_unlock_irqrestore(&qtty->lock, irq_flags); 88 spin_unlock_irqrestore(&qtty->lock, irq_flags);
@@ -88,24 +92,26 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id)
88 92
89static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty) 93static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty)
90{ 94{
91 struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, port); 95 struct goldfish_tty *qtty = container_of(port, struct goldfish_tty,
96 port);
92 writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_CMD); 97 writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_CMD);
93 return 0; 98 return 0;
94} 99}
95 100
96static void goldfish_tty_shutdown(struct tty_port *port) 101static void goldfish_tty_shutdown(struct tty_port *port)
97{ 102{
98 struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, port); 103 struct goldfish_tty *qtty = container_of(port, struct goldfish_tty,
104 port);
99 writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_CMD); 105 writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_CMD);
100} 106}
101 107
102static int goldfish_tty_open(struct tty_struct * tty, struct file * filp) 108static int goldfish_tty_open(struct tty_struct *tty, struct file *filp)
103{ 109{
104 struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; 110 struct goldfish_tty *qtty = &goldfish_ttys[tty->index];
105 return tty_port_open(&qtty->port, tty, filp); 111 return tty_port_open(&qtty->port, tty, filp);
106} 112}
107 113
108static void goldfish_tty_close(struct tty_struct * tty, struct file * filp) 114static void goldfish_tty_close(struct tty_struct *tty, struct file *filp)
109{ 115{
110 tty_port_close(tty->port, tty, filp); 116 tty_port_close(tty->port, tty, filp);
111} 117}
@@ -115,7 +121,8 @@ static void goldfish_tty_hangup(struct tty_struct *tty)
115 tty_port_hangup(tty->port); 121 tty_port_hangup(tty->port);
116} 122}
117 123
118static int goldfish_tty_write(struct tty_struct * tty, const unsigned char *buf, int count) 124static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf,
125 int count)
119{ 126{
120 goldfish_tty_do_write(tty->index, buf, count); 127 goldfish_tty_do_write(tty->index, buf, count);
121 return count; 128 return count;
@@ -133,12 +140,14 @@ static int goldfish_tty_chars_in_buffer(struct tty_struct *tty)
133 return readl(base + GOLDFISH_TTY_BYTES_READY); 140 return readl(base + GOLDFISH_TTY_BYTES_READY);
134} 141}
135 142
136static void goldfish_tty_console_write(struct console *co, const char *b, unsigned count) 143static void goldfish_tty_console_write(struct console *co, const char *b,
144 unsigned count)
137{ 145{
138 goldfish_tty_do_write(co->index, b, count); 146 goldfish_tty_do_write(co->index, b, count);
139} 147}
140 148
141static struct tty_driver *goldfish_tty_console_device(struct console *c, int *index) 149static struct tty_driver *goldfish_tty_console_device(struct console *c,
150 int *index)
142{ 151{
143 *index = c->index; 152 *index = c->index;
144 return goldfish_tty_driver; 153 return goldfish_tty_driver;
@@ -146,9 +155,9 @@ static struct tty_driver *goldfish_tty_console_device(struct console *c, int *in
146 155
147static int goldfish_tty_console_setup(struct console *co, char *options) 156static int goldfish_tty_console_setup(struct console *co, char *options)
148{ 157{
149 if((unsigned)co->index > goldfish_tty_line_count) 158 if ((unsigned)co->index > goldfish_tty_line_count)
150 return -ENODEV; 159 return -ENODEV;
151 if(goldfish_ttys[co->index].base == 0) 160 if (goldfish_ttys[co->index].base == 0)
152 return -ENODEV; 161 return -ENODEV;
153 return 0; 162 return 0;
154} 163}
@@ -158,7 +167,7 @@ static struct tty_port_operations goldfish_port_ops = {
158 .shutdown = goldfish_tty_shutdown 167 .shutdown = goldfish_tty_shutdown
159}; 168};
160 169
161static struct tty_operations goldfish_tty_ops = { 170static const struct tty_operations goldfish_tty_ops = {
162 .open = goldfish_tty_open, 171 .open = goldfish_tty_open,
163 .close = goldfish_tty_close, 172 .close = goldfish_tty_close,
164 .hangup = goldfish_tty_hangup, 173 .hangup = goldfish_tty_hangup,
@@ -172,13 +181,14 @@ static int goldfish_tty_create_driver(void)
172 int ret; 181 int ret;
173 struct tty_driver *tty; 182 struct tty_driver *tty;
174 183
175 goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) * goldfish_tty_line_count, GFP_KERNEL); 184 goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) *
176 if(goldfish_ttys == NULL) { 185 goldfish_tty_line_count, GFP_KERNEL);
186 if (goldfish_ttys == NULL) {
177 ret = -ENOMEM; 187 ret = -ENOMEM;
178 goto err_alloc_goldfish_ttys_failed; 188 goto err_alloc_goldfish_ttys_failed;
179 } 189 }
180 tty = alloc_tty_driver(goldfish_tty_line_count); 190 tty = alloc_tty_driver(goldfish_tty_line_count);
181 if(tty == NULL) { 191 if (tty == NULL) {
182 ret = -ENOMEM; 192 ret = -ENOMEM;
183 goto err_alloc_tty_driver_failed; 193 goto err_alloc_tty_driver_failed;
184 } 194 }
@@ -187,10 +197,11 @@ static int goldfish_tty_create_driver(void)
187 tty->type = TTY_DRIVER_TYPE_SERIAL; 197 tty->type = TTY_DRIVER_TYPE_SERIAL;
188 tty->subtype = SERIAL_TYPE_NORMAL; 198 tty->subtype = SERIAL_TYPE_NORMAL;
189 tty->init_termios = tty_std_termios; 199 tty->init_termios = tty_std_termios;
190 tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 200 tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
201 TTY_DRIVER_DYNAMIC_DEV;
191 tty_set_operations(tty, &goldfish_tty_ops); 202 tty_set_operations(tty, &goldfish_tty_ops);
192 ret = tty_register_driver(tty); 203 ret = tty_register_driver(tty);
193 if(ret) 204 if (ret)
194 goto err_tty_register_driver_failed; 205 goto err_tty_register_driver_failed;
195 206
196 goldfish_tty_driver = tty; 207 goldfish_tty_driver = tty;
@@ -225,7 +236,7 @@ static int goldfish_tty_probe(struct platform_device *pdev)
225 u32 irq; 236 u32 irq;
226 237
227 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 238 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
228 if(r == NULL) 239 if (r == NULL)
229 return -EINVAL; 240 return -EINVAL;
230 241
231 base = ioremap(r->start, 0x1000); 242 base = ioremap(r->start, 0x1000);
@@ -233,18 +244,18 @@ static int goldfish_tty_probe(struct platform_device *pdev)
233 pr_err("goldfish_tty: unable to remap base\n"); 244 pr_err("goldfish_tty: unable to remap base\n");
234 245
235 r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 246 r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
236 if(r == NULL) 247 if (r == NULL)
237 goto err_unmap; 248 goto err_unmap;
238 249
239 irq = r->start; 250 irq = r->start;
240 251
241 if(pdev->id >= goldfish_tty_line_count) 252 if (pdev->id >= goldfish_tty_line_count)
242 goto err_unmap; 253 goto err_unmap;
243 254
244 mutex_lock(&goldfish_tty_lock); 255 mutex_lock(&goldfish_tty_lock);
245 if(goldfish_tty_current_line_count == 0) { 256 if (goldfish_tty_current_line_count == 0) {
246 ret = goldfish_tty_create_driver(); 257 ret = goldfish_tty_create_driver();
247 if(ret) 258 if (ret)
248 goto err_create_driver_failed; 259 goto err_create_driver_failed;
249 } 260 }
250 goldfish_tty_current_line_count++; 261 goldfish_tty_current_line_count++;
@@ -258,14 +269,15 @@ static int goldfish_tty_probe(struct platform_device *pdev)
258 269
259 writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_CMD); 270 writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_CMD);
260 271
261 ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED, "goldfish_tty", pdev); 272 ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED,
262 if(ret) 273 "goldfish_tty", pdev);
274 if (ret)
263 goto err_request_irq_failed; 275 goto err_request_irq_failed;
264 276
265 277
266 ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver, 278 ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver,
267 pdev->id, &pdev->dev); 279 pdev->id, &pdev->dev);
268 if(IS_ERR(ttydev)) { 280 if (IS_ERR(ttydev)) {
269 ret = PTR_ERR(ttydev); 281 ret = PTR_ERR(ttydev);
270 goto err_tty_register_device_failed; 282 goto err_tty_register_device_failed;
271 } 283 }
@@ -286,7 +298,7 @@ err_tty_register_device_failed:
286 free_irq(irq, pdev); 298 free_irq(irq, pdev);
287err_request_irq_failed: 299err_request_irq_failed:
288 goldfish_tty_current_line_count--; 300 goldfish_tty_current_line_count--;
289 if(goldfish_tty_current_line_count == 0) 301 if (goldfish_tty_current_line_count == 0)
290 goldfish_tty_delete_driver(); 302 goldfish_tty_delete_driver();
291err_create_driver_failed: 303err_create_driver_failed:
292 mutex_unlock(&goldfish_tty_lock); 304 mutex_unlock(&goldfish_tty_lock);
@@ -308,7 +320,7 @@ static int goldfish_tty_remove(struct platform_device *pdev)
308 qtty->base = 0; 320 qtty->base = 0;
309 free_irq(qtty->irq, pdev); 321 free_irq(qtty->irq, pdev);
310 goldfish_tty_current_line_count--; 322 goldfish_tty_current_line_count--;
311 if(goldfish_tty_current_line_count == 0) 323 if (goldfish_tty_current_line_count == 0)
312 goldfish_tty_delete_driver(); 324 goldfish_tty_delete_driver();
313 mutex_unlock(&goldfish_tty_lock); 325 mutex_unlock(&goldfish_tty_lock);
314 return 0; 326 return 0;