aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/drm/drm_vm.c2
-rw-r--r--drivers/char/mspec.c2
-rw-r--r--drivers/char/nozomi.c172
3 files changed, 63 insertions, 113 deletions
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index e8d50af58201..ef5e6b130c48 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -506,6 +506,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
506 vma->vm_ops = &drm_vm_dma_ops; 506 vma->vm_ops = &drm_vm_dma_ops;
507 507
508 vma->vm_flags |= VM_RESERVED; /* Don't swap */ 508 vma->vm_flags |= VM_RESERVED; /* Don't swap */
509 vma->vm_flags |= VM_DONTEXPAND;
509 510
510 vma->vm_file = filp; /* Needed for drm_vm_open() */ 511 vma->vm_file = filp; /* Needed for drm_vm_open() */
511 drm_vm_open_locked(vma); 512 drm_vm_open_locked(vma);
@@ -655,6 +656,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
655 return -EINVAL; /* This should never happen. */ 656 return -EINVAL; /* This should never happen. */
656 } 657 }
657 vma->vm_flags |= VM_RESERVED; /* Don't swap */ 658 vma->vm_flags |= VM_RESERVED; /* Don't swap */
659 vma->vm_flags |= VM_DONTEXPAND;
658 660
659 vma->vm_file = filp; /* Needed for drm_vm_open() */ 661 vma->vm_file = filp; /* Needed for drm_vm_open() */
660 drm_vm_open_locked(vma); 662 drm_vm_open_locked(vma);
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index 82f2e27dca7d..ff146c2b08fd 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -283,7 +283,7 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
283 vdata->refcnt = ATOMIC_INIT(1); 283 vdata->refcnt = ATOMIC_INIT(1);
284 vma->vm_private_data = vdata; 284 vma->vm_private_data = vdata;
285 285
286 vma->vm_flags |= (VM_IO | VM_RESERVED | VM_PFNMAP); 286 vma->vm_flags |= (VM_IO | VM_RESERVED | VM_PFNMAP | VM_DONTEXPAND);
287 if (vdata->type == MSPEC_FETCHOP || vdata->type == MSPEC_UNCACHED) 287 if (vdata->type == MSPEC_FETCHOP || vdata->type == MSPEC_UNCACHED)
288 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 288 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
289 vma->vm_ops = &mspec_vm_ops; 289 vma->vm_ops = &mspec_vm_ops;
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 6076e662886a..dfaab2322de3 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -2,7 +2,7 @@
2 * nozomi.c -- HSDPA driver Broadband Wireless Data Card - Globe Trotter 2 * nozomi.c -- HSDPA driver Broadband Wireless Data Card - Globe Trotter
3 * 3 *
4 * Written by: Ulf Jakobsson, 4 * Written by: Ulf Jakobsson,
5 * Jan erfeldt, 5 * Jan Åkerfeldt,
6 * Stefan Thomasson, 6 * Stefan Thomasson,
7 * 7 *
8 * Maintained by: Paul Hardwick (p.hardwick@option.com) 8 * Maintained by: Paul Hardwick (p.hardwick@option.com)
@@ -38,60 +38,6 @@
38 * -------------------------------------------------------------------------- 38 * --------------------------------------------------------------------------
39 */ 39 */
40 40
41/*
42 * CHANGELOG
43 * Version 2.1d
44 * 11-November-2007 Jiri Slaby, Frank Seidel
45 * - Big rework of multicard support by Jiri
46 * - Major cleanups (semaphore to mutex, endianess, no major reservation)
47 * - Optimizations
48 *
49 * Version 2.1c
50 * 30-October-2007 Frank Seidel
51 * - Completed multicard support
52 * - Minor cleanups
53 *
54 * Version 2.1b
55 * 07-August-2007 Frank Seidel
56 * - Minor cleanups
57 * - theoretical multicard support
58 *
59 * Version 2.1
60 * 03-July-2006 Paul Hardwick
61 *
62 * - Stability Improvements. Incorporated spinlock wraps patch.
63 * - Updated for newer 2.6.14+ kernels (tty_buffer_request_room)
64 * - using __devexit macro for tty
65 *
66 *
67 * Version 2.0
68 * 08-feb-2006 15:34:10:Ulf
69 *
70 * -Fixed issue when not waking up line disipine layer, could probably result
71 * in better uplink performance for 2.4.
72 *
73 * -Fixed issue with big endian during initalization, now proper toggle flags
74 * are handled between preloader and maincode.
75 *
76 * -Fixed flow control issue.
77 *
78 * -Added support for setting DTR.
79 *
80 * -For 2.4 kernels, removing temporary buffer that's not needed.
81 *
82 * -Reading CTS only for modem port (only port that supports it).
83 *
84 * -Return 0 in write_room instead of netative value, it's not handled in
85 * upper layer.
86 *
87 * --------------------------------------------------------------------------
88 * Version 1.0
89 *
90 * First version of driver, only tested with card of type F32_2.
91 * Works fine with 2.4 and 2.6 kernels.
92 * Driver also support big endian architecture.
93 */
94
95/* Enable this to have a lot of debug printouts */ 41/* Enable this to have a lot of debug printouts */
96#define DEBUG 42#define DEBUG
97 43
@@ -143,8 +89,9 @@ do { \
143/* Do we need this settable at runtime? */ 89/* Do we need this settable at runtime? */
144static int debug = NOZOMI_DEBUG_LEVEL; 90static int debug = NOZOMI_DEBUG_LEVEL;
145 91
146#define D(lvl, args...) do {if (lvl & debug) NFO(KERN_DEBUG, ##args); } \ 92#define D(lvl, args...) do \
147 while (0) 93 {if (lvl & debug) NFO(KERN_DEBUG, ##args); } \
94 while (0)
148#define D_(lvl, args...) D(lvl, ##args) 95#define D_(lvl, args...) D(lvl, ##args)
149 96
150/* These printouts are always printed */ 97/* These printouts are always printed */
@@ -273,13 +220,13 @@ enum port_type {
273/* Big endian */ 220/* Big endian */
274 221
275struct toggles { 222struct toggles {
276 unsigned enabled:5; /* 223 unsigned int enabled:5; /*
277 * Toggle fields are valid if enabled is 0, 224 * Toggle fields are valid if enabled is 0,
278 * else A-channels must always be used. 225 * else A-channels must always be used.
279 */ 226 */
280 unsigned diag_dl:1; 227 unsigned int diag_dl:1;
281 unsigned mdm_dl:1; 228 unsigned int mdm_dl:1;
282 unsigned mdm_ul:1; 229 unsigned int mdm_ul:1;
283} __attribute__ ((packed)); 230} __attribute__ ((packed));
284 231
285/* Configuration table to read at startup of card */ 232/* Configuration table to read at startup of card */
@@ -320,19 +267,19 @@ struct config_table {
320/* This stores all control downlink flags */ 267/* This stores all control downlink flags */
321struct ctrl_dl { 268struct ctrl_dl {
322 u8 port; 269 u8 port;
323 unsigned reserved:4; 270 unsigned int reserved:4;
324 unsigned CTS:1; 271 unsigned int CTS:1;
325 unsigned RI:1; 272 unsigned int RI:1;
326 unsigned DCD:1; 273 unsigned int DCD:1;
327 unsigned DSR:1; 274 unsigned int DSR:1;
328} __attribute__ ((packed)); 275} __attribute__ ((packed));
329 276
330/* This stores all control uplink flags */ 277/* This stores all control uplink flags */
331struct ctrl_ul { 278struct ctrl_ul {
332 u8 port; 279 u8 port;
333 unsigned reserved:6; 280 unsigned int reserved:6;
334 unsigned RTS:1; 281 unsigned int RTS:1;
335 unsigned DTR:1; 282 unsigned int DTR:1;
336} __attribute__ ((packed)); 283} __attribute__ ((packed));
337 284
338#else 285#else
@@ -340,10 +287,10 @@ struct ctrl_ul {
340 287
341/* This represents the toggle information */ 288/* This represents the toggle information */
342struct toggles { 289struct toggles {
343 unsigned mdm_ul:1; 290 unsigned int mdm_ul:1;
344 unsigned mdm_dl:1; 291 unsigned int mdm_dl:1;
345 unsigned diag_dl:1; 292 unsigned int diag_dl:1;
346 unsigned enabled:5; /* 293 unsigned int enabled:5; /*
347 * Toggle fields are valid if enabled is 0, 294 * Toggle fields are valid if enabled is 0,
348 * else A-channels must always be used. 295 * else A-channels must always be used.
349 */ 296 */
@@ -379,19 +326,19 @@ struct config_table {
379 326
380/* This stores all control downlink flags */ 327/* This stores all control downlink flags */
381struct ctrl_dl { 328struct ctrl_dl {
382 unsigned DSR:1; 329 unsigned int DSR:1;
383 unsigned DCD:1; 330 unsigned int DCD:1;
384 unsigned RI:1; 331 unsigned int RI:1;
385 unsigned CTS:1; 332 unsigned int CTS:1;
386 unsigned reserverd:4; 333 unsigned int reserverd:4;
387 u8 port; 334 u8 port;
388} __attribute__ ((packed)); 335} __attribute__ ((packed));
389 336
390/* This stores all control uplink flags */ 337/* This stores all control uplink flags */
391struct ctrl_ul { 338struct ctrl_ul {
392 unsigned DTR:1; 339 unsigned int DTR:1;
393 unsigned RTS:1; 340 unsigned int RTS:1;
394 unsigned reserved:6; 341 unsigned int reserved:6;
395 u8 port; 342 u8 port;
396} __attribute__ ((packed)); 343} __attribute__ ((packed));
397#endif 344#endif
@@ -448,7 +395,7 @@ struct buffer {
448} __attribute__ ((packed)); 395} __attribute__ ((packed));
449 396
450/* Global variables */ 397/* Global variables */
451static struct pci_device_id nozomi_pci_tbl[] = { 398static const struct pci_device_id nozomi_pci_tbl[] __devinitconst = {
452 {PCI_DEVICE(VENDOR1, DEVICE1)}, 399 {PCI_DEVICE(VENDOR1, DEVICE1)},
453 {}, 400 {},
454}; 401};
@@ -524,12 +471,12 @@ out:
524 * -Optimize 471 * -Optimize
525 * -Rewrite cleaner 472 * -Rewrite cleaner
526 */ 473 */
527static u32 write_mem32(void __iomem *mem_addr_start, u32 *buf, 474static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
528 u32 size_bytes) 475 u32 size_bytes)
529{ 476{
530 u32 i = 0; 477 u32 i = 0;
531 u32 *ptr = (__force u32 *) mem_addr_start; 478 u32 *ptr = (__force u32 *) mem_addr_start;
532 u16 *buf16; 479 const u16 *buf16;
533 480
534 if (unlikely(!ptr || !buf)) 481 if (unlikely(!ptr || !buf))
535 return 0; 482 return 0;
@@ -537,7 +484,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, u32 *buf,
537 /* shortcut for extremely often used cases */ 484 /* shortcut for extremely often used cases */
538 switch (size_bytes) { 485 switch (size_bytes) {
539 case 2: /* 2 bytes */ 486 case 2: /* 2 bytes */
540 buf16 = (u16 *) buf; 487 buf16 = (const u16 *)buf;
541 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr); 488 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr);
542 return 2; 489 return 2;
543 break; 490 break;
@@ -554,7 +501,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, u32 *buf,
554 while (i < size_bytes) { 501 while (i < size_bytes) {
555 if (size_bytes - i == 2) { 502 if (size_bytes - i == 2) {
556 /* 2 bytes */ 503 /* 2 bytes */
557 buf16 = (u16 *) buf; 504 buf16 = (const u16 *)buf;
558 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr); 505 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr);
559 i += 2; 506 i += 2;
560 } else { 507 } else {
@@ -694,7 +641,7 @@ static void dump_table(const struct nozomi *dc)
694 dc->config_table.ul_ctrl_len); 641 dc->config_table.ul_ctrl_len);
695} 642}
696#else 643#else
697static __inline__ void dump_table(const struct nozomi *dc) { } 644static inline void dump_table(const struct nozomi *dc) { }
698#endif 645#endif
699 646
700/* 647/*
@@ -776,8 +723,7 @@ static int nozomi_read_config_table(struct nozomi *dc)
776/* Enable uplink interrupts */ 723/* Enable uplink interrupts */
777static void enable_transmit_ul(enum port_type port, struct nozomi *dc) 724static void enable_transmit_ul(enum port_type port, struct nozomi *dc)
778{ 725{
779 u16 mask[NOZOMI_MAX_PORTS] = \ 726 static const u16 mask[] = {MDM_UL, DIAG_UL, APP1_UL, APP2_UL, CTRL_UL};
780 {MDM_UL, DIAG_UL, APP1_UL, APP2_UL, CTRL_UL};
781 727
782 if (port < NOZOMI_MAX_PORTS) { 728 if (port < NOZOMI_MAX_PORTS) {
783 dc->last_ier |= mask[port]; 729 dc->last_ier |= mask[port];
@@ -790,8 +736,8 @@ static void enable_transmit_ul(enum port_type port, struct nozomi *dc)
790/* Disable uplink interrupts */ 736/* Disable uplink interrupts */
791static void disable_transmit_ul(enum port_type port, struct nozomi *dc) 737static void disable_transmit_ul(enum port_type port, struct nozomi *dc)
792{ 738{
793 u16 mask[NOZOMI_MAX_PORTS] = \ 739 static const u16 mask[] =
794 {~MDM_UL, ~DIAG_UL, ~APP1_UL, ~APP2_UL, ~CTRL_UL}; 740 {~MDM_UL, ~DIAG_UL, ~APP1_UL, ~APP2_UL, ~CTRL_UL};
795 741
796 if (port < NOZOMI_MAX_PORTS) { 742 if (port < NOZOMI_MAX_PORTS) {
797 dc->last_ier &= mask[port]; 743 dc->last_ier &= mask[port];
@@ -804,8 +750,7 @@ static void disable_transmit_ul(enum port_type port, struct nozomi *dc)
804/* Enable downlink interrupts */ 750/* Enable downlink interrupts */
805static void enable_transmit_dl(enum port_type port, struct nozomi *dc) 751static void enable_transmit_dl(enum port_type port, struct nozomi *dc)
806{ 752{
807 u16 mask[NOZOMI_MAX_PORTS] = \ 753 static const u16 mask[] = {MDM_DL, DIAG_DL, APP1_DL, APP2_DL, CTRL_DL};
808 {MDM_DL, DIAG_DL, APP1_DL, APP2_DL, CTRL_DL};
809 754
810 if (port < NOZOMI_MAX_PORTS) { 755 if (port < NOZOMI_MAX_PORTS) {
811 dc->last_ier |= mask[port]; 756 dc->last_ier |= mask[port];
@@ -818,8 +763,8 @@ static void enable_transmit_dl(enum port_type port, struct nozomi *dc)
818/* Disable downlink interrupts */ 763/* Disable downlink interrupts */
819static void disable_transmit_dl(enum port_type port, struct nozomi *dc) 764static void disable_transmit_dl(enum port_type port, struct nozomi *dc)
820{ 765{
821 u16 mask[NOZOMI_MAX_PORTS] = \ 766 static const u16 mask[] =
822 {~MDM_DL, ~DIAG_DL, ~APP1_DL, ~APP2_DL, ~CTRL_DL}; 767 {~MDM_DL, ~DIAG_DL, ~APP1_DL, ~APP2_DL, ~CTRL_DL};
823 768
824 if (port < NOZOMI_MAX_PORTS) { 769 if (port < NOZOMI_MAX_PORTS) {
825 dc->last_ier &= mask[port]; 770 dc->last_ier &= mask[port];
@@ -833,13 +778,13 @@ static void disable_transmit_dl(enum port_type port, struct nozomi *dc)
833 * Return 1 - send buffer to card and ack. 778 * Return 1 - send buffer to card and ack.
834 * Return 0 - don't ack, don't send buffer to card. 779 * Return 0 - don't ack, don't send buffer to card.
835 */ 780 */
836static int send_data(enum port_type index, struct nozomi *dc) 781static int send_data(enum port_type index, const struct nozomi *dc)
837{ 782{
838 u32 size = 0; 783 u32 size = 0;
839 struct port *port = &dc->port[index]; 784 const struct port *port = &dc->port[index];
840 u8 toggle = port->toggle_ul; 785 const u8 toggle = port->toggle_ul;
841 void __iomem *addr = port->ul_addr[toggle]; 786 void __iomem *addr = port->ul_addr[toggle];
842 u32 ul_size = port->ul_size[toggle]; 787 const u32 ul_size = port->ul_size[toggle];
843 struct tty_struct *tty = port->tty; 788 struct tty_struct *tty = port->tty;
844 789
845 /* Get data from tty and place in buf for now */ 790 /* Get data from tty and place in buf for now */
@@ -1102,7 +1047,7 @@ static int send_flow_control(struct nozomi *dc)
1102} 1047}
1103 1048
1104/* 1049/*
1105 * Handle donlink data, ports that are handled are modem and diagnostics 1050 * Handle downlink data, ports that are handled are modem and diagnostics
1106 * Return 1 - ok 1051 * Return 1 - ok
1107 * Return 0 - toggle fields are out of sync 1052 * Return 0 - toggle fields are out of sync
1108 */ 1053 */
@@ -1359,20 +1304,20 @@ static void nozomi_setup_private_data(struct nozomi *dc)
1359static ssize_t card_type_show(struct device *dev, struct device_attribute *attr, 1304static ssize_t card_type_show(struct device *dev, struct device_attribute *attr,
1360 char *buf) 1305 char *buf)
1361{ 1306{
1362 struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev)); 1307 const struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev));
1363 1308
1364 return sprintf(buf, "%d\n", dc->card_type); 1309 return sprintf(buf, "%d\n", dc->card_type);
1365} 1310}
1366static DEVICE_ATTR(card_type, 0444, card_type_show, NULL); 1311static DEVICE_ATTR(card_type, S_IRUGO, card_type_show, NULL);
1367 1312
1368static ssize_t open_ttys_show(struct device *dev, struct device_attribute *attr, 1313static ssize_t open_ttys_show(struct device *dev, struct device_attribute *attr,
1369 char *buf) 1314 char *buf)
1370{ 1315{
1371 struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev)); 1316 const struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev));
1372 1317
1373 return sprintf(buf, "%u\n", dc->open_ttys); 1318 return sprintf(buf, "%u\n", dc->open_ttys);
1374} 1319}
1375static DEVICE_ATTR(open_ttys, 0444, open_ttys_show, NULL); 1320static DEVICE_ATTR(open_ttys, S_IRUGO, open_ttys_show, NULL);
1376 1321
1377static void make_sysfs_files(struct nozomi *dc) 1322static void make_sysfs_files(struct nozomi *dc)
1378{ 1323{
@@ -1735,7 +1680,7 @@ static int ntty_write_room(struct tty_struct *tty)
1735{ 1680{
1736 struct port *port = tty->driver_data; 1681 struct port *port = tty->driver_data;
1737 int room = 0; 1682 int room = 0;
1738 struct nozomi *dc = get_dc_by_tty(tty); 1683 const struct nozomi *dc = get_dc_by_tty(tty);
1739 1684
1740 if (!dc || !port) 1685 if (!dc || !port)
1741 return 0; 1686 return 0;
@@ -1755,9 +1700,9 @@ exit:
1755/* Gets io control parameters */ 1700/* Gets io control parameters */
1756static int ntty_tiocmget(struct tty_struct *tty, struct file *file) 1701static int ntty_tiocmget(struct tty_struct *tty, struct file *file)
1757{ 1702{
1758 struct port *port = tty->driver_data; 1703 const struct port *port = tty->driver_data;
1759 struct ctrl_dl *ctrl_dl = &port->ctrl_dl; 1704 const struct ctrl_dl *ctrl_dl = &port->ctrl_dl;
1760 struct ctrl_ul *ctrl_ul = &port->ctrl_ul; 1705 const struct ctrl_ul *ctrl_ul = &port->ctrl_ul;
1761 1706
1762 return (ctrl_ul->RTS ? TIOCM_RTS : 0) | 1707 return (ctrl_ul->RTS ? TIOCM_RTS : 0) |
1763 (ctrl_ul->DTR ? TIOCM_DTR : 0) | 1708 (ctrl_ul->DTR ? TIOCM_DTR : 0) |
@@ -1787,7 +1732,7 @@ static int ntty_tiocmset(struct tty_struct *tty, struct file *file,
1787static int ntty_cflags_changed(struct port *port, unsigned long flags, 1732static int ntty_cflags_changed(struct port *port, unsigned long flags,
1788 struct async_icount *cprev) 1733 struct async_icount *cprev)
1789{ 1734{
1790 struct async_icount cnow = port->tty_icount; 1735 const struct async_icount cnow = port->tty_icount;
1791 int ret; 1736 int ret;
1792 1737
1793 ret = ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng)) || 1738 ret = ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
@@ -1802,7 +1747,7 @@ static int ntty_cflags_changed(struct port *port, unsigned long flags,
1802 1747
1803static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp) 1748static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp)
1804{ 1749{
1805 struct async_icount cnow = port->tty_icount; 1750 const struct async_icount cnow = port->tty_icount;
1806 struct serial_icounter_struct icount; 1751 struct serial_icounter_struct icount;
1807 1752
1808 icount.cts = cnow.cts; 1753 icount.cts = cnow.cts;
@@ -1882,7 +1827,10 @@ static void ntty_throttle(struct tty_struct *tty)
1882/* just to discard single character writes */ 1827/* just to discard single character writes */
1883static void ntty_put_char(struct tty_struct *tty, unsigned char c) 1828static void ntty_put_char(struct tty_struct *tty, unsigned char c)
1884{ 1829{
1885 /* FIXME !!! */ 1830 /*
1831 * card does not react correct when we write single chars
1832 * to the card, so we discard them
1833 */
1886 DBG2("PUT CHAR Function: %c", c); 1834 DBG2("PUT CHAR Function: %c", c);
1887} 1835}
1888 1836
@@ -1910,7 +1858,7 @@ exit_in_buffer:
1910 return rval; 1858 return rval;
1911} 1859}
1912 1860
1913static struct tty_operations tty_ops = { 1861static const struct tty_operations tty_ops = {
1914 .ioctl = ntty_ioctl, 1862 .ioctl = ntty_ioctl,
1915 .open = ntty_open, 1863 .open = ntty_open,
1916 .close = ntty_close, 1864 .close = ntty_close,