aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig36
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/agp/intel-agp.c11
-rw-r--r--drivers/char/apm-emulation.c15
-rw-r--r--drivers/char/cs5535_gpio.c5
-rw-r--r--drivers/char/drm/drm_pciids.h1
-rw-r--r--drivers/char/hvc_console.c80
-rw-r--r--drivers/char/hvcs.c78
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c2
-rw-r--r--drivers/char/nozomi.c1993
-rw-r--r--drivers/char/sonypi.c8
-rw-r--r--drivers/char/tipar.c557
-rw-r--r--drivers/char/tpm/tpm.c12
-rw-r--r--drivers/char/tpm/tpm_tis.c10
-rw-r--r--drivers/char/tty_ioctl.c21
15 files changed, 2125 insertions, 705 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index bf18d757b876..466629594776 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -137,7 +137,7 @@ config CYCLADES
137 your Linux box, for instance in order to become a dial-in server. 137 your Linux box, for instance in order to become a dial-in server.
138 138
139 For information about the Cyclades-Z card, read 139 For information about the Cyclades-Z card, read
140 <file:drivers/char/README.cycladesZ>. 140 <file:Documentation/README.cycladesZ>.
141 141
142 To compile this driver as a module, choose M here: the 142 To compile this driver as a module, choose M here: the
143 module will be called cyclades. 143 module will be called cyclades.
@@ -373,6 +373,16 @@ config ISTALLION
373 To compile this driver as a module, choose M here: the 373 To compile this driver as a module, choose M here: the
374 module will be called istallion. 374 module will be called istallion.
375 375
376config NOZOMI
377 tristate "HSDPA Broadband Wireless Data Card - Globe Trotter"
378 depends on PCI && EXPERIMENTAL
379 help
380 If you have a HSDPA driver Broadband Wireless Data Card -
381 Globe Trotter PCMCIA card, say Y here.
382
383 To compile this driver as a module, choose M here, the module
384 will be called nozomi.
385
376config A2232 386config A2232
377 tristate "Commodore A2232 serial support (EXPERIMENTAL)" 387 tristate "Commodore A2232 serial support (EXPERIMENTAL)"
378 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP 388 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP
@@ -457,7 +467,7 @@ config LEGACY_PTYS
457config LEGACY_PTY_COUNT 467config LEGACY_PTY_COUNT
458 int "Maximum number of legacy PTY in use" 468 int "Maximum number of legacy PTY in use"
459 depends on LEGACY_PTYS 469 depends on LEGACY_PTYS
460 range 1 256 470 range 0 256
461 default "256" 471 default "256"
462 ---help--- 472 ---help---
463 The maximum number of legacy PTYs that can be used at any one time. 473 The maximum number of legacy PTYs that can be used at any one time.
@@ -543,28 +553,6 @@ config PPDEV
543 553
544 If unsure, say N. 554 If unsure, say N.
545 555
546config TIPAR
547 tristate "Texas Instruments parallel link cable support"
548 depends on PARPORT
549 ---help---
550 If you own a Texas Instruments graphing calculator and use a
551 parallel link cable, then you might be interested in this driver.
552
553 If you enable this driver, you will be able to communicate with
554 your calculator through a set of device nodes under /dev. The
555 main advantage of this driver is that you don't have to be root
556 to use this precise link cable (depending on the permissions on
557 the device nodes, though).
558
559 To compile this driver as a module, choose M here: the
560 module will be called tipar.
561
562 If you don't know what a parallel link cable is or what a Texas
563 Instruments graphing calculator is, then you probably don't need this
564 driver.
565
566 If unsure, say N.
567
568config HVC_DRIVER 556config HVC_DRIVER
569 bool 557 bool
570 help 558 help
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 07304d50e0cb..96fc01eddefe 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_SERIAL167) += serial167.o
26obj-$(CONFIG_CYCLADES) += cyclades.o 26obj-$(CONFIG_CYCLADES) += cyclades.o
27obj-$(CONFIG_STALLION) += stallion.o 27obj-$(CONFIG_STALLION) += stallion.o
28obj-$(CONFIG_ISTALLION) += istallion.o 28obj-$(CONFIG_ISTALLION) += istallion.o
29obj-$(CONFIG_NOZOMI) += nozomi.o
29obj-$(CONFIG_DIGIEPCA) += epca.o 30obj-$(CONFIG_DIGIEPCA) += epca.o
30obj-$(CONFIG_SPECIALIX) += specialix.o 31obj-$(CONFIG_SPECIALIX) += specialix.o
31obj-$(CONFIG_MOXA_INTELLIO) += moxa.o 32obj-$(CONFIG_MOXA_INTELLIO) += moxa.o
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index d87961993ccf..03eac1eb8e0f 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -10,6 +10,8 @@
10#include <linux/agp_backend.h> 10#include <linux/agp_backend.h>
11#include "agp.h" 11#include "agp.h"
12 12
13#define PCI_DEVICE_ID_INTEL_E7221_HB 0x2588
14#define PCI_DEVICE_ID_INTEL_E7221_IG 0x258a
13#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970 15#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
14#define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972 16#define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
15#define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980 17#define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980
@@ -526,7 +528,8 @@ static void intel_i830_init_gtt_entries(void)
526 break; 528 break;
527 case I915_GMCH_GMS_STOLEN_48M: 529 case I915_GMCH_GMS_STOLEN_48M:
528 /* Check it's really I915G */ 530 /* Check it's really I915G */
529 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 531 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB ||
532 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
530 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 533 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
531 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 534 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
532 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || 535 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
@@ -538,7 +541,8 @@ static void intel_i830_init_gtt_entries(void)
538 break; 541 break;
539 case I915_GMCH_GMS_STOLEN_64M: 542 case I915_GMCH_GMS_STOLEN_64M:
540 /* Check it's really I915G */ 543 /* Check it's really I915G */
541 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 544 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB ||
545 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
542 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 546 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
543 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 547 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
544 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || 548 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
@@ -1854,6 +1858,8 @@ static const struct intel_driver_description {
1854 { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, 0, "865", 1858 { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, 0, "865",
1855 &intel_845_driver, &intel_830_driver }, 1859 &intel_845_driver, &intel_830_driver },
1856 { PCI_DEVICE_ID_INTEL_82875_HB, 0, 0, "i875", &intel_845_driver, NULL }, 1860 { PCI_DEVICE_ID_INTEL_82875_HB, 0, 0, "i875", &intel_845_driver, NULL },
1861 { PCI_DEVICE_ID_INTEL_E7221_HB, PCI_DEVICE_ID_INTEL_E7221_IG, 0, "E7221 (i915)",
1862 NULL, &intel_915_driver },
1857 { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, 0, "915G", 1863 { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, 0, "915G",
1858 NULL, &intel_915_driver }, 1864 NULL, &intel_915_driver },
1859 { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, 0, "915GM", 1865 { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, 0, "915GM",
@@ -2059,6 +2065,7 @@ static struct pci_device_id agp_intel_pci_table[] = {
2059 ID(PCI_DEVICE_ID_INTEL_82875_HB), 2065 ID(PCI_DEVICE_ID_INTEL_82875_HB),
2060 ID(PCI_DEVICE_ID_INTEL_7505_0), 2066 ID(PCI_DEVICE_ID_INTEL_7505_0),
2061 ID(PCI_DEVICE_ID_INTEL_7205_0), 2067 ID(PCI_DEVICE_ID_INTEL_7205_0),
2068 ID(PCI_DEVICE_ID_INTEL_E7221_HB),
2062 ID(PCI_DEVICE_ID_INTEL_82915G_HB), 2069 ID(PCI_DEVICE_ID_INTEL_82915G_HB),
2063 ID(PCI_DEVICE_ID_INTEL_82915GM_HB), 2070 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
2064 ID(PCI_DEVICE_ID_INTEL_82945G_HB), 2071 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index c99e43b837f5..17d54315e146 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -295,7 +295,6 @@ static int
295apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) 295apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
296{ 296{
297 struct apm_user *as = filp->private_data; 297 struct apm_user *as = filp->private_data;
298 unsigned long flags;
299 int err = -EINVAL; 298 int err = -EINVAL;
300 299
301 if (!as->suser || !as->writer) 300 if (!as->suser || !as->writer)
@@ -331,10 +330,16 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
331 * Wait for the suspend/resume to complete. If there 330 * Wait for the suspend/resume to complete. If there
332 * are pending acknowledges, we wait here for them. 331 * are pending acknowledges, we wait here for them.
333 */ 332 */
334 flags = current->flags; 333 freezer_do_not_count();
335 334
336 wait_event(apm_suspend_waitqueue, 335 wait_event(apm_suspend_waitqueue,
337 as->suspend_state == SUSPEND_DONE); 336 as->suspend_state == SUSPEND_DONE);
337
338 /*
339 * Since we are waiting until the suspend is done, the
340 * try_to_freeze() in freezer_count() will not trigger
341 */
342 freezer_count();
338 } else { 343 } else {
339 as->suspend_state = SUSPEND_WAIT; 344 as->suspend_state = SUSPEND_WAIT;
340 mutex_unlock(&state_lock); 345 mutex_unlock(&state_lock);
@@ -362,14 +367,10 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
362 * Wait for the suspend/resume to complete. If there 367 * Wait for the suspend/resume to complete. If there
363 * are pending acknowledges, we wait here for them. 368 * are pending acknowledges, we wait here for them.
364 */ 369 */
365 flags = current->flags; 370 wait_event_freezable(apm_suspend_waitqueue,
366
367 wait_event_interruptible(apm_suspend_waitqueue,
368 as->suspend_state == SUSPEND_DONE); 371 as->suspend_state == SUSPEND_DONE);
369 } 372 }
370 373
371 current->flags = flags;
372
373 mutex_lock(&state_lock); 374 mutex_lock(&state_lock);
374 err = as->suspend_result; 375 err = as->suspend_result;
375 as->suspend_state = SUSPEND_NONE; 376 as->suspend_state = SUSPEND_NONE;
diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c
index fe6d2407baed..c2d23cae9515 100644
--- a/drivers/char/cs5535_gpio.c
+++ b/drivers/char/cs5535_gpio.c
@@ -104,6 +104,11 @@ static ssize_t cs5535_gpio_write(struct file *file, const char __user *data,
104 for (j = 0; j < ARRAY_SIZE(rm); j++) { 104 for (j = 0; j < ARRAY_SIZE(rm); j++) {
105 if (c == rm[j].on) { 105 if (c == rm[j].on) {
106 outl(m1, base + rm[j].wr_offset); 106 outl(m1, base + rm[j].wr_offset);
107 /* If enabling output, turn off AUX 1 and AUX 2 */
108 if (c == 'O') {
109 outl(m0, base + 0x10);
110 outl(m0, base + 0x14);
111 }
107 break; 112 break;
108 } else if (c == rm[j].off) { 113 } else if (c == rm[j].off) {
109 outl(m0, base + rm[j].wr_offset); 114 outl(m0, base + rm[j].wr_offset);
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index f3593974496c..43d3c42df360 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -297,6 +297,7 @@
297 {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 297 {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
298 {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 298 {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
299 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 299 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
300 {0x8086, 0x258a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
300 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 301 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
301 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 302 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
302 {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 303 {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 8252f8668538..480fae29c9b2 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -27,7 +27,7 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/kbd_kern.h> 28#include <linux/kbd_kern.h>
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/kobject.h> 30#include <linux/kref.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/module.h> 33#include <linux/module.h>
@@ -89,7 +89,7 @@ struct hvc_struct {
89 int irq_requested; 89 int irq_requested;
90 int irq; 90 int irq;
91 struct list_head next; 91 struct list_head next;
92 struct kobject kobj; /* ref count & hvc_struct lifetime */ 92 struct kref kref; /* ref count & hvc_struct lifetime */
93}; 93};
94 94
95/* dynamic list of hvc_struct instances */ 95/* dynamic list of hvc_struct instances */
@@ -110,7 +110,7 @@ static int last_hvc = -1;
110 110
111/* 111/*
112 * Do not call this function with either the hvc_structs_lock or the hvc_struct 112 * Do not call this function with either the hvc_structs_lock or the hvc_struct
113 * lock held. If successful, this function increments the kobject reference 113 * lock held. If successful, this function increments the kref reference
114 * count against the target hvc_struct so it should be released when finished. 114 * count against the target hvc_struct so it should be released when finished.
115 */ 115 */
116static struct hvc_struct *hvc_get_by_index(int index) 116static struct hvc_struct *hvc_get_by_index(int index)
@@ -123,7 +123,7 @@ static struct hvc_struct *hvc_get_by_index(int index)
123 list_for_each_entry(hp, &hvc_structs, next) { 123 list_for_each_entry(hp, &hvc_structs, next) {
124 spin_lock_irqsave(&hp->lock, flags); 124 spin_lock_irqsave(&hp->lock, flags);
125 if (hp->index == index) { 125 if (hp->index == index) {
126 kobject_get(&hp->kobj); 126 kref_get(&hp->kref);
127 spin_unlock_irqrestore(&hp->lock, flags); 127 spin_unlock_irqrestore(&hp->lock, flags);
128 spin_unlock(&hvc_structs_lock); 128 spin_unlock(&hvc_structs_lock);
129 return hp; 129 return hp;
@@ -242,6 +242,23 @@ static int __init hvc_console_init(void)
242} 242}
243console_initcall(hvc_console_init); 243console_initcall(hvc_console_init);
244 244
245/* callback when the kboject ref count reaches zero. */
246static void destroy_hvc_struct(struct kref *kref)
247{
248 struct hvc_struct *hp = container_of(kref, struct hvc_struct, kref);
249 unsigned long flags;
250
251 spin_lock(&hvc_structs_lock);
252
253 spin_lock_irqsave(&hp->lock, flags);
254 list_del(&(hp->next));
255 spin_unlock_irqrestore(&hp->lock, flags);
256
257 spin_unlock(&hvc_structs_lock);
258
259 kfree(hp);
260}
261
245/* 262/*
246 * hvc_instantiate() is an early console discovery method which locates 263 * hvc_instantiate() is an early console discovery method which locates
247 * consoles * prior to the vio subsystem discovering them. Hotplugged 264 * consoles * prior to the vio subsystem discovering them. Hotplugged
@@ -261,7 +278,7 @@ int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
261 /* make sure no no tty has been registered in this index */ 278 /* make sure no no tty has been registered in this index */
262 hp = hvc_get_by_index(index); 279 hp = hvc_get_by_index(index);
263 if (hp) { 280 if (hp) {
264 kobject_put(&hp->kobj); 281 kref_put(&hp->kref, destroy_hvc_struct);
265 return -1; 282 return -1;
266 } 283 }
267 284
@@ -318,9 +335,8 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
318 unsigned long flags; 335 unsigned long flags;
319 int irq = 0; 336 int irq = 0;
320 int rc = 0; 337 int rc = 0;
321 struct kobject *kobjp;
322 338
323 /* Auto increments kobject reference if found. */ 339 /* Auto increments kref reference if found. */
324 if (!(hp = hvc_get_by_index(tty->index))) 340 if (!(hp = hvc_get_by_index(tty->index)))
325 return -ENODEV; 341 return -ENODEV;
326 342
@@ -341,8 +357,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
341 if (irq) 357 if (irq)
342 hp->irq_requested = 1; 358 hp->irq_requested = 1;
343 359
344 kobjp = &hp->kobj;
345
346 spin_unlock_irqrestore(&hp->lock, flags); 360 spin_unlock_irqrestore(&hp->lock, flags);
347 /* check error, fallback to non-irq */ 361 /* check error, fallback to non-irq */
348 if (irq) 362 if (irq)
@@ -352,7 +366,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
352 * If the request_irq() fails and we return an error. The tty layer 366 * If the request_irq() fails and we return an error. The tty layer
353 * will call hvc_close() after a failed open but we don't want to clean 367 * will call hvc_close() after a failed open but we don't want to clean
354 * up there so we'll clean up here and clear out the previously set 368 * up there so we'll clean up here and clear out the previously set
355 * tty fields and return the kobject reference. 369 * tty fields and return the kref reference.
356 */ 370 */
357 if (rc) { 371 if (rc) {
358 spin_lock_irqsave(&hp->lock, flags); 372 spin_lock_irqsave(&hp->lock, flags);
@@ -360,7 +374,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
360 hp->irq_requested = 0; 374 hp->irq_requested = 0;
361 spin_unlock_irqrestore(&hp->lock, flags); 375 spin_unlock_irqrestore(&hp->lock, flags);
362 tty->driver_data = NULL; 376 tty->driver_data = NULL;
363 kobject_put(kobjp); 377 kref_put(&hp->kref, destroy_hvc_struct);
364 printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc); 378 printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc);
365 } 379 }
366 /* Force wakeup of the polling thread */ 380 /* Force wakeup of the polling thread */
@@ -372,7 +386,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
372static void hvc_close(struct tty_struct *tty, struct file * filp) 386static void hvc_close(struct tty_struct *tty, struct file * filp)
373{ 387{
374 struct hvc_struct *hp; 388 struct hvc_struct *hp;
375 struct kobject *kobjp;
376 int irq = 0; 389 int irq = 0;
377 unsigned long flags; 390 unsigned long flags;
378 391
@@ -382,7 +395,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
382 /* 395 /*
383 * No driver_data means that this close was issued after a failed 396 * No driver_data means that this close was issued after a failed
384 * hvc_open by the tty layer's release_dev() function and we can just 397 * hvc_open by the tty layer's release_dev() function and we can just
385 * exit cleanly because the kobject reference wasn't made. 398 * exit cleanly because the kref reference wasn't made.
386 */ 399 */
387 if (!tty->driver_data) 400 if (!tty->driver_data)
388 return; 401 return;
@@ -390,7 +403,6 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
390 hp = tty->driver_data; 403 hp = tty->driver_data;
391 spin_lock_irqsave(&hp->lock, flags); 404 spin_lock_irqsave(&hp->lock, flags);
392 405
393 kobjp = &hp->kobj;
394 if (--hp->count == 0) { 406 if (--hp->count == 0) {
395 if (hp->irq_requested) 407 if (hp->irq_requested)
396 irq = hp->irq; 408 irq = hp->irq;
@@ -417,7 +429,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
417 spin_unlock_irqrestore(&hp->lock, flags); 429 spin_unlock_irqrestore(&hp->lock, flags);
418 } 430 }
419 431
420 kobject_put(kobjp); 432 kref_put(&hp->kref, destroy_hvc_struct);
421} 433}
422 434
423static void hvc_hangup(struct tty_struct *tty) 435static void hvc_hangup(struct tty_struct *tty)
@@ -426,7 +438,6 @@ static void hvc_hangup(struct tty_struct *tty)
426 unsigned long flags; 438 unsigned long flags;
427 int irq = 0; 439 int irq = 0;
428 int temp_open_count; 440 int temp_open_count;
429 struct kobject *kobjp;
430 441
431 if (!hp) 442 if (!hp)
432 return; 443 return;
@@ -443,7 +454,6 @@ static void hvc_hangup(struct tty_struct *tty)
443 return; 454 return;
444 } 455 }
445 456
446 kobjp = &hp->kobj;
447 temp_open_count = hp->count; 457 temp_open_count = hp->count;
448 hp->count = 0; 458 hp->count = 0;
449 hp->n_outbuf = 0; 459 hp->n_outbuf = 0;
@@ -457,7 +467,7 @@ static void hvc_hangup(struct tty_struct *tty)
457 free_irq(irq, hp); 467 free_irq(irq, hp);
458 while(temp_open_count) { 468 while(temp_open_count) {
459 --temp_open_count; 469 --temp_open_count;
460 kobject_put(kobjp); 470 kref_put(&hp->kref, destroy_hvc_struct);
461 } 471 }
462} 472}
463 473
@@ -729,27 +739,6 @@ static const struct tty_operations hvc_ops = {
729 .chars_in_buffer = hvc_chars_in_buffer, 739 .chars_in_buffer = hvc_chars_in_buffer,
730}; 740};
731 741
732/* callback when the kboject ref count reaches zero. */
733static void destroy_hvc_struct(struct kobject *kobj)
734{
735 struct hvc_struct *hp = container_of(kobj, struct hvc_struct, kobj);
736 unsigned long flags;
737
738 spin_lock(&hvc_structs_lock);
739
740 spin_lock_irqsave(&hp->lock, flags);
741 list_del(&(hp->next));
742 spin_unlock_irqrestore(&hp->lock, flags);
743
744 spin_unlock(&hvc_structs_lock);
745
746 kfree(hp);
747}
748
749static struct kobj_type hvc_kobj_type = {
750 .release = destroy_hvc_struct,
751};
752
753struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, 742struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
754 struct hv_ops *ops, int outbuf_size) 743 struct hv_ops *ops, int outbuf_size)
755{ 744{
@@ -776,8 +765,7 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
776 hp->outbuf_size = outbuf_size; 765 hp->outbuf_size = outbuf_size;
777 hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; 766 hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
778 767
779 kobject_init(&hp->kobj); 768 kref_init(&hp->kref);
780 hp->kobj.ktype = &hvc_kobj_type;
781 769
782 spin_lock_init(&hp->lock); 770 spin_lock_init(&hp->lock);
783 spin_lock(&hvc_structs_lock); 771 spin_lock(&hvc_structs_lock);
@@ -806,12 +794,10 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
806int __devexit hvc_remove(struct hvc_struct *hp) 794int __devexit hvc_remove(struct hvc_struct *hp)
807{ 795{
808 unsigned long flags; 796 unsigned long flags;
809 struct kobject *kobjp;
810 struct tty_struct *tty; 797 struct tty_struct *tty;
811 798
812 spin_lock_irqsave(&hp->lock, flags); 799 spin_lock_irqsave(&hp->lock, flags);
813 tty = hp->tty; 800 tty = hp->tty;
814 kobjp = &hp->kobj;
815 801
816 if (hp->index < MAX_NR_HVC_CONSOLES) 802 if (hp->index < MAX_NR_HVC_CONSOLES)
817 vtermnos[hp->index] = -1; 803 vtermnos[hp->index] = -1;
@@ -821,12 +807,12 @@ int __devexit hvc_remove(struct hvc_struct *hp)
821 spin_unlock_irqrestore(&hp->lock, flags); 807 spin_unlock_irqrestore(&hp->lock, flags);
822 808
823 /* 809 /*
824 * We 'put' the instance that was grabbed when the kobject instance 810 * We 'put' the instance that was grabbed when the kref instance
825 * was initialized using kobject_init(). Let the last holder of this 811 * was initialized using kref_init(). Let the last holder of this
826 * kobject cause it to be removed, which will probably be the tty_hangup 812 * kref cause it to be removed, which will probably be the tty_hangup
827 * below. 813 * below.
828 */ 814 */
829 kobject_put(kobjp); 815 kref_put(&hp->kref, destroy_hvc_struct);
830 816
831 /* 817 /*
832 * This function call will auto chain call hvc_hangup. The tty should 818 * This function call will auto chain call hvc_hangup. The tty should
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 69d8866de783..fd7559084b82 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -57,11 +57,7 @@
57 * rescanning partner information upon a user's request. 57 * rescanning partner information upon a user's request.
58 * 58 *
59 * Each vty-server, prior to being exposed to this driver is reference counted 59 * Each vty-server, prior to being exposed to this driver is reference counted
60 * using the 2.6 Linux kernel kobject construct. This kobject is also used by 60 * using the 2.6 Linux kernel kref construct.
61 * the vio bus to provide a vio device sysfs entry that this driver attaches
62 * device specific attributes to, including partner information. The vio bus
63 * framework also provides a sysfs entry for each vio driver. The hvcs driver
64 * provides driver attributes in this entry.
65 * 61 *
66 * For direction on installation and usage of this driver please reference 62 * For direction on installation and usage of this driver please reference
67 * Documentation/powerpc/hvcs.txt. 63 * Documentation/powerpc/hvcs.txt.
@@ -71,7 +67,7 @@
71#include <linux/init.h> 67#include <linux/init.h>
72#include <linux/interrupt.h> 68#include <linux/interrupt.h>
73#include <linux/kernel.h> 69#include <linux/kernel.h>
74#include <linux/kobject.h> 70#include <linux/kref.h>
75#include <linux/kthread.h> 71#include <linux/kthread.h>
76#include <linux/list.h> 72#include <linux/list.h>
77#include <linux/major.h> 73#include <linux/major.h>
@@ -293,12 +289,12 @@ struct hvcs_struct {
293 int chars_in_buffer; 289 int chars_in_buffer;
294 290
295 /* 291 /*
296 * Any variable below the kobject is valid before a tty is connected and 292 * Any variable below the kref is valid before a tty is connected and
297 * stays valid after the tty is disconnected. These shouldn't be 293 * stays valid after the tty is disconnected. These shouldn't be
298 * whacked until the koject refcount reaches zero though some entries 294 * whacked until the koject refcount reaches zero though some entries
299 * may be changed via sysfs initiatives. 295 * may be changed via sysfs initiatives.
300 */ 296 */
301 struct kobject kobj; /* ref count & hvcs_struct lifetime */ 297 struct kref kref; /* ref count & hvcs_struct lifetime */
302 int connected; /* is the vty-server currently connected to a vty? */ 298 int connected; /* is the vty-server currently connected to a vty? */
303 uint32_t p_unit_address; /* partner unit address */ 299 uint32_t p_unit_address; /* partner unit address */
304 uint32_t p_partition_ID; /* partner partition ID */ 300 uint32_t p_partition_ID; /* partner partition ID */
@@ -307,8 +303,8 @@ struct hvcs_struct {
307 struct vio_dev *vdev; 303 struct vio_dev *vdev;
308}; 304};
309 305
310/* Required to back map a kobject to its containing object */ 306/* Required to back map a kref to its containing object */
311#define from_kobj(kobj) container_of(kobj, struct hvcs_struct, kobj) 307#define from_kref(k) container_of(k, struct hvcs_struct, kref)
312 308
313static struct list_head hvcs_structs = LIST_HEAD_INIT(hvcs_structs); 309static struct list_head hvcs_structs = LIST_HEAD_INIT(hvcs_structs);
314static DEFINE_SPINLOCK(hvcs_structs_lock); 310static DEFINE_SPINLOCK(hvcs_structs_lock);
@@ -334,7 +330,6 @@ static void hvcs_partner_free(struct hvcs_struct *hvcsd);
334static int hvcs_enable_device(struct hvcs_struct *hvcsd, 330static int hvcs_enable_device(struct hvcs_struct *hvcsd,
335 uint32_t unit_address, unsigned int irq, struct vio_dev *dev); 331 uint32_t unit_address, unsigned int irq, struct vio_dev *dev);
336 332
337static void destroy_hvcs_struct(struct kobject *kobj);
338static int hvcs_open(struct tty_struct *tty, struct file *filp); 333static int hvcs_open(struct tty_struct *tty, struct file *filp);
339static void hvcs_close(struct tty_struct *tty, struct file *filp); 334static void hvcs_close(struct tty_struct *tty, struct file *filp);
340static void hvcs_hangup(struct tty_struct * tty); 335static void hvcs_hangup(struct tty_struct * tty);
@@ -703,10 +698,10 @@ static void hvcs_return_index(int index)
703 hvcs_index_list[index] = -1; 698 hvcs_index_list[index] = -1;
704} 699}
705 700
706/* callback when the kboject ref count reaches zero */ 701/* callback when the kref ref count reaches zero */
707static void destroy_hvcs_struct(struct kobject *kobj) 702static void destroy_hvcs_struct(struct kref *kref)
708{ 703{
709 struct hvcs_struct *hvcsd = from_kobj(kobj); 704 struct hvcs_struct *hvcsd = from_kref(kref);
710 struct vio_dev *vdev; 705 struct vio_dev *vdev;
711 unsigned long flags; 706 unsigned long flags;
712 707
@@ -743,10 +738,6 @@ static void destroy_hvcs_struct(struct kobject *kobj)
743 kfree(hvcsd); 738 kfree(hvcsd);
744} 739}
745 740
746static struct kobj_type hvcs_kobj_type = {
747 .release = destroy_hvcs_struct,
748};
749
750static int hvcs_get_index(void) 741static int hvcs_get_index(void)
751{ 742{
752 int i; 743 int i;
@@ -791,9 +782,7 @@ static int __devinit hvcs_probe(
791 782
792 spin_lock_init(&hvcsd->lock); 783 spin_lock_init(&hvcsd->lock);
793 /* Automatically incs the refcount the first time */ 784 /* Automatically incs the refcount the first time */
794 kobject_init(&hvcsd->kobj); 785 kref_init(&hvcsd->kref);
795 /* Set up the callback for terminating the hvcs_struct's life */
796 hvcsd->kobj.ktype = &hvcs_kobj_type;
797 786
798 hvcsd->vdev = dev; 787 hvcsd->vdev = dev;
799 dev->dev.driver_data = hvcsd; 788 dev->dev.driver_data = hvcsd;
@@ -844,7 +833,6 @@ static int __devexit hvcs_remove(struct vio_dev *dev)
844{ 833{
845 struct hvcs_struct *hvcsd = dev->dev.driver_data; 834 struct hvcs_struct *hvcsd = dev->dev.driver_data;
846 unsigned long flags; 835 unsigned long flags;
847 struct kobject *kobjp;
848 struct tty_struct *tty; 836 struct tty_struct *tty;
849 837
850 if (!hvcsd) 838 if (!hvcsd)
@@ -856,15 +844,13 @@ static int __devexit hvcs_remove(struct vio_dev *dev)
856 844
857 tty = hvcsd->tty; 845 tty = hvcsd->tty;
858 846
859 kobjp = &hvcsd->kobj;
860
861 spin_unlock_irqrestore(&hvcsd->lock, flags); 847 spin_unlock_irqrestore(&hvcsd->lock, flags);
862 848
863 /* 849 /*
864 * Let the last holder of this object cause it to be removed, which 850 * Let the last holder of this object cause it to be removed, which
865 * would probably be tty_hangup below. 851 * would probably be tty_hangup below.
866 */ 852 */
867 kobject_put (kobjp); 853 kref_put(&hvcsd->kref, destroy_hvcs_struct);
868 854
869 /* 855 /*
870 * The hangup is a scheduled function which will auto chain call 856 * The hangup is a scheduled function which will auto chain call
@@ -1086,7 +1072,7 @@ static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
1086} 1072}
1087 1073
1088/* 1074/*
1089 * This always increments the kobject ref count if the call is successful. 1075 * This always increments the kref ref count if the call is successful.
1090 * Please remember to dec when you are done with the instance. 1076 * Please remember to dec when you are done with the instance.
1091 * 1077 *
1092 * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when 1078 * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when
@@ -1103,7 +1089,7 @@ static struct hvcs_struct *hvcs_get_by_index(int index)
1103 list_for_each_entry(hvcsd, &hvcs_structs, next) { 1089 list_for_each_entry(hvcsd, &hvcs_structs, next) {
1104 spin_lock_irqsave(&hvcsd->lock, flags); 1090 spin_lock_irqsave(&hvcsd->lock, flags);
1105 if (hvcsd->index == index) { 1091 if (hvcsd->index == index) {
1106 kobject_get(&hvcsd->kobj); 1092 kref_get(&hvcsd->kref);
1107 spin_unlock_irqrestore(&hvcsd->lock, flags); 1093 spin_unlock_irqrestore(&hvcsd->lock, flags);
1108 spin_unlock(&hvcs_structs_lock); 1094 spin_unlock(&hvcs_structs_lock);
1109 return hvcsd; 1095 return hvcsd;
@@ -1129,14 +1115,13 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
1129 unsigned int irq; 1115 unsigned int irq;
1130 struct vio_dev *vdev; 1116 struct vio_dev *vdev;
1131 unsigned long unit_address; 1117 unsigned long unit_address;
1132 struct kobject *kobjp;
1133 1118
1134 if (tty->driver_data) 1119 if (tty->driver_data)
1135 goto fast_open; 1120 goto fast_open;
1136 1121
1137 /* 1122 /*
1138 * Is there a vty-server that shares the same index? 1123 * Is there a vty-server that shares the same index?
1139 * This function increments the kobject index. 1124 * This function increments the kref index.
1140 */ 1125 */
1141 if (!(hvcsd = hvcs_get_by_index(tty->index))) { 1126 if (!(hvcsd = hvcs_get_by_index(tty->index))) {
1142 printk(KERN_WARNING "HVCS: open failed, no device associated" 1127 printk(KERN_WARNING "HVCS: open failed, no device associated"
@@ -1181,7 +1166,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
1181 * and will grab the spinlock and free the connection if it fails. 1166 * and will grab the spinlock and free the connection if it fails.
1182 */ 1167 */
1183 if (((rc = hvcs_enable_device(hvcsd, unit_address, irq, vdev)))) { 1168 if (((rc = hvcs_enable_device(hvcsd, unit_address, irq, vdev)))) {
1184 kobject_put(&hvcsd->kobj); 1169 kref_put(&hvcsd->kref, destroy_hvcs_struct);
1185 printk(KERN_WARNING "HVCS: enable device failed.\n"); 1170 printk(KERN_WARNING "HVCS: enable device failed.\n");
1186 return rc; 1171 return rc;
1187 } 1172 }
@@ -1192,17 +1177,11 @@ fast_open:
1192 hvcsd = tty->driver_data; 1177 hvcsd = tty->driver_data;
1193 1178
1194 spin_lock_irqsave(&hvcsd->lock, flags); 1179 spin_lock_irqsave(&hvcsd->lock, flags);
1195 if (!kobject_get(&hvcsd->kobj)) { 1180 kref_get(&hvcsd->kref);
1196 spin_unlock_irqrestore(&hvcsd->lock, flags);
1197 printk(KERN_ERR "HVCS: Kobject of open"
1198 " hvcs doesn't exist.\n");
1199 return -EFAULT; /* Is this the right return value? */
1200 }
1201
1202 hvcsd->open_count++; 1181 hvcsd->open_count++;
1203
1204 hvcsd->todo_mask |= HVCS_SCHED_READ; 1182 hvcsd->todo_mask |= HVCS_SCHED_READ;
1205 spin_unlock_irqrestore(&hvcsd->lock, flags); 1183 spin_unlock_irqrestore(&hvcsd->lock, flags);
1184
1206open_success: 1185open_success:
1207 hvcs_kick(); 1186 hvcs_kick();
1208 1187
@@ -1212,9 +1191,8 @@ open_success:
1212 return 0; 1191 return 0;
1213 1192
1214error_release: 1193error_release:
1215 kobjp = &hvcsd->kobj;
1216 spin_unlock_irqrestore(&hvcsd->lock, flags); 1194 spin_unlock_irqrestore(&hvcsd->lock, flags);
1217 kobject_put(&hvcsd->kobj); 1195 kref_put(&hvcsd->kref, destroy_hvcs_struct);
1218 1196
1219 printk(KERN_WARNING "HVCS: partner connect failed.\n"); 1197 printk(KERN_WARNING "HVCS: partner connect failed.\n");
1220 return retval; 1198 return retval;
@@ -1224,7 +1202,6 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
1224{ 1202{
1225 struct hvcs_struct *hvcsd; 1203 struct hvcs_struct *hvcsd;
1226 unsigned long flags; 1204 unsigned long flags;
1227 struct kobject *kobjp;
1228 int irq = NO_IRQ; 1205 int irq = NO_IRQ;
1229 1206
1230 /* 1207 /*
@@ -1245,7 +1222,6 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
1245 hvcsd = tty->driver_data; 1222 hvcsd = tty->driver_data;
1246 1223
1247 spin_lock_irqsave(&hvcsd->lock, flags); 1224 spin_lock_irqsave(&hvcsd->lock, flags);
1248 kobjp = &hvcsd->kobj;
1249 if (--hvcsd->open_count == 0) { 1225 if (--hvcsd->open_count == 0) {
1250 1226
1251 vio_disable_interrupts(hvcsd->vdev); 1227 vio_disable_interrupts(hvcsd->vdev);
@@ -1270,7 +1246,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
1270 tty->driver_data = NULL; 1246 tty->driver_data = NULL;
1271 1247
1272 free_irq(irq, hvcsd); 1248 free_irq(irq, hvcsd);
1273 kobject_put(kobjp); 1249 kref_put(&hvcsd->kref, destroy_hvcs_struct);
1274 return; 1250 return;
1275 } else if (hvcsd->open_count < 0) { 1251 } else if (hvcsd->open_count < 0) {
1276 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d" 1252 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
@@ -1279,7 +1255,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
1279 } 1255 }
1280 1256
1281 spin_unlock_irqrestore(&hvcsd->lock, flags); 1257 spin_unlock_irqrestore(&hvcsd->lock, flags);
1282 kobject_put(kobjp); 1258 kref_put(&hvcsd->kref, destroy_hvcs_struct);
1283} 1259}
1284 1260
1285static void hvcs_hangup(struct tty_struct * tty) 1261static void hvcs_hangup(struct tty_struct * tty)
@@ -1287,21 +1263,17 @@ static void hvcs_hangup(struct tty_struct * tty)
1287 struct hvcs_struct *hvcsd = tty->driver_data; 1263 struct hvcs_struct *hvcsd = tty->driver_data;
1288 unsigned long flags; 1264 unsigned long flags;
1289 int temp_open_count; 1265 int temp_open_count;
1290 struct kobject *kobjp;
1291 int irq = NO_IRQ; 1266 int irq = NO_IRQ;
1292 1267
1293 spin_lock_irqsave(&hvcsd->lock, flags); 1268 spin_lock_irqsave(&hvcsd->lock, flags);
1294 /* Preserve this so that we know how many kobject refs to put */ 1269 /* Preserve this so that we know how many kref refs to put */
1295 temp_open_count = hvcsd->open_count; 1270 temp_open_count = hvcsd->open_count;
1296 1271
1297 /* 1272 /*
1298 * Don't kobject put inside the spinlock because the destruction 1273 * Don't kref put inside the spinlock because the destruction
1299 * callback may use the spinlock and it may get called before the 1274 * callback may use the spinlock and it may get called before the
1300 * spinlock has been released. Get a pointer to the kobject and 1275 * spinlock has been released.
1301 * kobject_put on that after releasing the spinlock.
1302 */ 1276 */
1303 kobjp = &hvcsd->kobj;
1304
1305 vio_disable_interrupts(hvcsd->vdev); 1277 vio_disable_interrupts(hvcsd->vdev);
1306 1278
1307 hvcsd->todo_mask = 0; 1279 hvcsd->todo_mask = 0;
@@ -1324,7 +1296,7 @@ static void hvcs_hangup(struct tty_struct * tty)
1324 free_irq(irq, hvcsd); 1296 free_irq(irq, hvcsd);
1325 1297
1326 /* 1298 /*
1327 * We need to kobject_put() for every open_count we have since the 1299 * We need to kref_put() for every open_count we have since the
1328 * tty_hangup() function doesn't invoke a close per open connection on a 1300 * tty_hangup() function doesn't invoke a close per open connection on a
1329 * non-console device. 1301 * non-console device.
1330 */ 1302 */
@@ -1335,7 +1307,7 @@ static void hvcs_hangup(struct tty_struct * tty)
1335 * NOTE: If this hangup was signaled from user space then the 1307 * NOTE: If this hangup was signaled from user space then the
1336 * final put will never happen. 1308 * final put will never happen.
1337 */ 1309 */
1338 kobject_put(kobjp); 1310 kref_put(&hvcsd->kref, destroy_hvcs_struct);
1339 } 1311 }
1340} 1312}
1341 1313
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index e686fc925168..8f45ca9235ad 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -669,6 +669,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
669 return 0; 669 return 0;
670 670
671 case WDIOC_SET_PRETIMEOUT: 671 case WDIOC_SET_PRETIMEOUT:
672 case WDIOC_SETPRETIMEOUT:
672 i = copy_from_user(&val, argp, sizeof(int)); 673 i = copy_from_user(&val, argp, sizeof(int));
673 if (i) 674 if (i)
674 return -EFAULT; 675 return -EFAULT;
@@ -676,6 +677,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
676 return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); 677 return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
677 678
678 case WDIOC_GET_PRETIMEOUT: 679 case WDIOC_GET_PRETIMEOUT:
680 case WDIOC_GETPRETIMEOUT:
679 i = copy_to_user(argp, &pretimeout, sizeof(pretimeout)); 681 i = copy_to_user(argp, &pretimeout, sizeof(pretimeout));
680 if (i) 682 if (i)
681 return -EFAULT; 683 return -EFAULT;
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
new file mode 100644
index 000000000000..6076e662886a
--- /dev/null
+++ b/drivers/char/nozomi.c
@@ -0,0 +1,1993 @@
1/*
2 * nozomi.c -- HSDPA driver Broadband Wireless Data Card - Globe Trotter
3 *
4 * Written by: Ulf Jakobsson,
5 * Jan �erfeldt,
6 * Stefan Thomasson,
7 *
8 * Maintained by: Paul Hardwick (p.hardwick@option.com)
9 *
10 * Patches:
11 * Locking code changes for Vodafone by Sphere Systems Ltd,
12 * Andrew Bird (ajb@spheresystems.co.uk )
13 * & Phil Sanderson
14 *
15 * Source has been ported from an implementation made by Filip Aben @ Option
16 *
17 * --------------------------------------------------------------------------
18 *
19 * Copyright (c) 2005,2006 Option Wireless Sweden AB
20 * Copyright (c) 2006 Sphere Systems Ltd
21 * Copyright (c) 2006 Option Wireless n/v
22 * All rights Reserved.
23 *
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
28 *
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
37 *
38 * --------------------------------------------------------------------------
39 */
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 */
96#define DEBUG
97
98#include <linux/kernel.h>
99#include <linux/module.h>
100#include <linux/pci.h>
101#include <linux/ioport.h>
102#include <linux/tty.h>
103#include <linux/tty_driver.h>
104#include <linux/tty_flip.h>
105#include <linux/serial.h>
106#include <linux/interrupt.h>
107#include <linux/kmod.h>
108#include <linux/init.h>
109#include <linux/kfifo.h>
110#include <linux/uaccess.h>
111#include <asm/byteorder.h>
112
113#include <linux/delay.h>
114
115
116#define VERSION_STRING DRIVER_DESC " 2.1d (build date: " \
117 __DATE__ " " __TIME__ ")"
118
119/* Macros definitions */
120
121/* Default debug printout level */
122#define NOZOMI_DEBUG_LEVEL 0x00
123
124#define P_BUF_SIZE 128
125#define NFO(_err_flag_, args...) \
126do { \
127 char tmp[P_BUF_SIZE]; \
128 snprintf(tmp, sizeof(tmp), ##args); \
129 printk(_err_flag_ "[%d] %s(): %s\n", __LINE__, \
130 __FUNCTION__, tmp); \
131} while (0)
132
133#define DBG1(args...) D_(0x01, ##args)
134#define DBG2(args...) D_(0x02, ##args)
135#define DBG3(args...) D_(0x04, ##args)
136#define DBG4(args...) D_(0x08, ##args)
137#define DBG5(args...) D_(0x10, ##args)
138#define DBG6(args...) D_(0x20, ##args)
139#define DBG7(args...) D_(0x40, ##args)
140#define DBG8(args...) D_(0x80, ##args)
141
142#ifdef DEBUG
143/* Do we need this settable at runtime? */
144static int debug = NOZOMI_DEBUG_LEVEL;
145
146#define D(lvl, args...) do {if (lvl & debug) NFO(KERN_DEBUG, ##args); } \
147 while (0)
148#define D_(lvl, args...) D(lvl, ##args)
149
150/* These printouts are always printed */
151
152#else
153static int debug;
154#define D_(lvl, args...)
155#endif
156
157/* TODO: rewrite to optimize macros... */
158
159#define TMP_BUF_MAX 256
160
161#define DUMP(buf__,len__) \
162 do { \
163 char tbuf[TMP_BUF_MAX] = {0};\
164 if (len__ > 1) {\
165 snprintf(tbuf, len__ > TMP_BUF_MAX ? TMP_BUF_MAX : len__, "%s", buf__);\
166 if (tbuf[len__-2] == '\r') {\
167 tbuf[len__-2] = 'r';\
168 } \
169 DBG1("SENDING: '%s' (%d+n)", tbuf, len__);\
170 } else {\
171 DBG1("SENDING: '%s' (%d)", tbuf, len__);\
172 } \
173} while (0)
174
175/* Defines */
176#define NOZOMI_NAME "nozomi"
177#define NOZOMI_NAME_TTY "nozomi_tty"
178#define DRIVER_DESC "Nozomi driver"
179
180#define NTTY_TTY_MAXMINORS 256
181#define NTTY_FIFO_BUFFER_SIZE 8192
182
183/* Must be power of 2 */
184#define FIFO_BUFFER_SIZE_UL 8192
185
186/* Size of tmp send buffer to card */
187#define SEND_BUF_MAX 1024
188#define RECEIVE_BUF_MAX 4
189
190
191/* Define all types of vendors and devices to support */
192#define VENDOR1 0x1931 /* Vendor Option */
193#define DEVICE1 0x000c /* HSDPA card */
194
195#define R_IIR 0x0000 /* Interrupt Identity Register */
196#define R_FCR 0x0000 /* Flow Control Register */
197#define R_IER 0x0004 /* Interrupt Enable Register */
198
199#define CONFIG_MAGIC 0xEFEFFEFE
200#define TOGGLE_VALID 0x0000
201
202/* Definition of interrupt tokens */
203#define MDM_DL1 0x0001
204#define MDM_UL1 0x0002
205#define MDM_DL2 0x0004
206#define MDM_UL2 0x0008
207#define DIAG_DL1 0x0010
208#define DIAG_DL2 0x0020
209#define DIAG_UL 0x0040
210#define APP1_DL 0x0080
211#define APP1_UL 0x0100
212#define APP2_DL 0x0200
213#define APP2_UL 0x0400
214#define CTRL_DL 0x0800
215#define CTRL_UL 0x1000
216#define RESET 0x8000
217
218#define MDM_DL (MDM_DL1 | MDM_DL2)
219#define MDM_UL (MDM_UL1 | MDM_UL2)
220#define DIAG_DL (DIAG_DL1 | DIAG_DL2)
221
222/* modem signal definition */
223#define CTRL_DSR 0x0001
224#define CTRL_DCD 0x0002
225#define CTRL_RI 0x0004
226#define CTRL_CTS 0x0008
227
228#define CTRL_DTR 0x0001
229#define CTRL_RTS 0x0002
230
231#define MAX_PORT 4
232#define NOZOMI_MAX_PORTS 5
233#define NOZOMI_MAX_CARDS (NTTY_TTY_MAXMINORS / MAX_PORT)
234
235/* Type definitions */
236
237/*
238 * There are two types of nozomi cards,
239 * one with 2048 memory and with 8192 memory
240 */
241enum card_type {
242 F32_2 = 2048, /* 512 bytes downlink + uplink * 2 -> 2048 */
243 F32_8 = 8192, /* 3072 bytes downl. + 1024 bytes uplink * 2 -> 8192 */
244};
245
246/* Two different toggle channels exist */
247enum channel_type {
248 CH_A = 0,
249 CH_B = 1,
250};
251
252/* Port definition for the card regarding flow control */
253enum ctrl_port_type {
254 CTRL_CMD = 0,
255 CTRL_MDM = 1,
256 CTRL_DIAG = 2,
257 CTRL_APP1 = 3,
258 CTRL_APP2 = 4,
259 CTRL_ERROR = -1,
260};
261
262/* Ports that the nozomi has */
263enum port_type {
264 PORT_MDM = 0,
265 PORT_DIAG = 1,
266 PORT_APP1 = 2,
267 PORT_APP2 = 3,
268 PORT_CTRL = 4,
269 PORT_ERROR = -1,
270};
271
272#ifdef __BIG_ENDIAN
273/* Big endian */
274
275struct toggles {
276 unsigned enabled:5; /*
277 * Toggle fields are valid if enabled is 0,
278 * else A-channels must always be used.
279 */
280 unsigned diag_dl:1;
281 unsigned mdm_dl:1;
282 unsigned mdm_ul:1;
283} __attribute__ ((packed));
284
285/* Configuration table to read at startup of card */
286/* Is for now only needed during initialization phase */
287struct config_table {
288 u32 signature;
289 u16 product_information;
290 u16 version;
291 u8 pad3[3];
292 struct toggles toggle;
293 u8 pad1[4];
294 u16 dl_mdm_len1; /*
295 * If this is 64, it can hold
296 * 60 bytes + 4 that is length field
297 */
298 u16 dl_start;
299
300 u16 dl_diag_len1;
301 u16 dl_mdm_len2; /*
302 * If this is 64, it can hold
303 * 60 bytes + 4 that is length field
304 */
305 u16 dl_app1_len;
306
307 u16 dl_diag_len2;
308 u16 dl_ctrl_len;
309 u16 dl_app2_len;
310 u8 pad2[16];
311 u16 ul_mdm_len1;
312 u16 ul_start;
313 u16 ul_diag_len;
314 u16 ul_mdm_len2;
315 u16 ul_app1_len;
316 u16 ul_app2_len;
317 u16 ul_ctrl_len;
318} __attribute__ ((packed));
319
320/* This stores all control downlink flags */
321struct ctrl_dl {
322 u8 port;
323 unsigned reserved:4;
324 unsigned CTS:1;
325 unsigned RI:1;
326 unsigned DCD:1;
327 unsigned DSR:1;
328} __attribute__ ((packed));
329
330/* This stores all control uplink flags */
331struct ctrl_ul {
332 u8 port;
333 unsigned reserved:6;
334 unsigned RTS:1;
335 unsigned DTR:1;
336} __attribute__ ((packed));
337
338#else
339/* Little endian */
340
341/* This represents the toggle information */
342struct toggles {
343 unsigned mdm_ul:1;
344 unsigned mdm_dl:1;
345 unsigned diag_dl:1;
346 unsigned enabled:5; /*
347 * Toggle fields are valid if enabled is 0,
348 * else A-channels must always be used.
349 */
350} __attribute__ ((packed));
351
352/* Configuration table to read at startup of card */
353struct config_table {
354 u32 signature;
355 u16 version;
356 u16 product_information;
357 struct toggles toggle;
358 u8 pad1[7];
359 u16 dl_start;
360 u16 dl_mdm_len1; /*
361 * If this is 64, it can hold
362 * 60 bytes + 4 that is length field
363 */
364 u16 dl_mdm_len2;
365 u16 dl_diag_len1;
366 u16 dl_diag_len2;
367 u16 dl_app1_len;
368 u16 dl_app2_len;
369 u16 dl_ctrl_len;
370 u8 pad2[16];
371 u16 ul_start;
372 u16 ul_mdm_len2;
373 u16 ul_mdm_len1;
374 u16 ul_diag_len;
375 u16 ul_app1_len;
376 u16 ul_app2_len;
377 u16 ul_ctrl_len;
378} __attribute__ ((packed));
379
380/* This stores all control downlink flags */
381struct ctrl_dl {
382 unsigned DSR:1;
383 unsigned DCD:1;
384 unsigned RI:1;
385 unsigned CTS:1;
386 unsigned reserverd:4;
387 u8 port;
388} __attribute__ ((packed));
389
390/* This stores all control uplink flags */
391struct ctrl_ul {
392 unsigned DTR:1;
393 unsigned RTS:1;
394 unsigned reserved:6;
395 u8 port;
396} __attribute__ ((packed));
397#endif
398
399/* This holds all information that is needed regarding a port */
400struct port {
401 u8 update_flow_control;
402 struct ctrl_ul ctrl_ul;
403 struct ctrl_dl ctrl_dl;
404 struct kfifo *fifo_ul;
405 void __iomem *dl_addr[2];
406 u32 dl_size[2];
407 u8 toggle_dl;
408 void __iomem *ul_addr[2];
409 u32 ul_size[2];
410 u8 toggle_ul;
411 u16 token_dl;
412
413 struct tty_struct *tty;
414 int tty_open_count;
415 /* mutex to ensure one access patch to this port */
416 struct mutex tty_sem;
417 wait_queue_head_t tty_wait;
418 struct async_icount tty_icount;
419};
420
421/* Private data one for each card in the system */
422struct nozomi {
423 void __iomem *base_addr;
424 unsigned long flip;
425
426 /* Pointers to registers */
427 void __iomem *reg_iir;
428 void __iomem *reg_fcr;
429 void __iomem *reg_ier;
430
431 u16 last_ier;
432 enum card_type card_type;
433 struct config_table config_table; /* Configuration table */
434 struct pci_dev *pdev;
435 struct port port[NOZOMI_MAX_PORTS];
436 u8 *send_buf;
437
438 spinlock_t spin_mutex; /* secures access to registers and tty */
439
440 unsigned int index_start;
441 u32 open_ttys;
442};
443
444/* This is a data packet that is read or written to/from card */
445struct buffer {
446 u32 size; /* size is the length of the data buffer */
447 u8 *data;
448} __attribute__ ((packed));
449
450/* Global variables */
451static struct pci_device_id nozomi_pci_tbl[] = {
452 {PCI_DEVICE(VENDOR1, DEVICE1)},
453 {},
454};
455
456MODULE_DEVICE_TABLE(pci, nozomi_pci_tbl);
457
458static struct nozomi *ndevs[NOZOMI_MAX_CARDS];
459static struct tty_driver *ntty_driver;
460
461/*
462 * find card by tty_index
463 */
464static inline struct nozomi *get_dc_by_tty(const struct tty_struct *tty)
465{
466 return tty ? ndevs[tty->index / MAX_PORT] : NULL;
467}
468
469static inline struct port *get_port_by_tty(const struct tty_struct *tty)
470{
471 struct nozomi *ndev = get_dc_by_tty(tty);
472 return ndev ? &ndev->port[tty->index % MAX_PORT] : NULL;
473}
474
475/*
476 * TODO:
477 * -Optimize
478 * -Rewrite cleaner
479 */
480
481static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
482 u32 size_bytes)
483{
484 u32 i = 0;
485 const u32 *ptr = (__force u32 *) mem_addr_start;
486 u16 *buf16;
487
488 if (unlikely(!ptr || !buf))
489 goto out;
490
491 /* shortcut for extremely often used cases */
492 switch (size_bytes) {
493 case 2: /* 2 bytes */
494 buf16 = (u16 *) buf;
495 *buf16 = __le16_to_cpu(readw((void __iomem *)ptr));
496 goto out;
497 break;
498 case 4: /* 4 bytes */
499 *(buf) = __le32_to_cpu(readl((void __iomem *)ptr));
500 goto out;
501 break;
502 }
503
504 while (i < size_bytes) {
505 if (size_bytes - i == 2) {
506 /* Handle 2 bytes in the end */
507 buf16 = (u16 *) buf;
508 *(buf16) = __le16_to_cpu(readw((void __iomem *)ptr));
509 i += 2;
510 } else {
511 /* Read 4 bytes */
512 *(buf) = __le32_to_cpu(readl((void __iomem *)ptr));
513 i += 4;
514 }
515 buf++;
516 ptr++;
517 }
518out:
519 return;
520}
521
522/*
523 * TODO:
524 * -Optimize
525 * -Rewrite cleaner
526 */
527static u32 write_mem32(void __iomem *mem_addr_start, u32 *buf,
528 u32 size_bytes)
529{
530 u32 i = 0;
531 u32 *ptr = (__force u32 *) mem_addr_start;
532 u16 *buf16;
533
534 if (unlikely(!ptr || !buf))
535 return 0;
536
537 /* shortcut for extremely often used cases */
538 switch (size_bytes) {
539 case 2: /* 2 bytes */
540 buf16 = (u16 *) buf;
541 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr);
542 return 2;
543 break;
544 case 1: /*
545 * also needs to write 4 bytes in this case
546 * so falling through..
547 */
548 case 4: /* 4 bytes */
549 writel(__cpu_to_le32(*buf), (void __iomem *)ptr);
550 return 4;
551 break;
552 }
553
554 while (i < size_bytes) {
555 if (size_bytes - i == 2) {
556 /* 2 bytes */
557 buf16 = (u16 *) buf;
558 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr);
559 i += 2;
560 } else {
561 /* 4 bytes */
562 writel(__cpu_to_le32(*buf), (void __iomem *)ptr);
563 i += 4;
564 }
565 buf++;
566 ptr++;
567 }
568 return i;
569}
570
571/* Setup pointers to different channels and also setup buffer sizes. */
572static void setup_memory(struct nozomi *dc)
573{
574 void __iomem *offset = dc->base_addr + dc->config_table.dl_start;
575 /* The length reported is including the length field of 4 bytes,
576 * hence subtract with 4.
577 */
578 const u16 buff_offset = 4;
579
580 /* Modem port dl configuration */
581 dc->port[PORT_MDM].dl_addr[CH_A] = offset;
582 dc->port[PORT_MDM].dl_addr[CH_B] =
583 (offset += dc->config_table.dl_mdm_len1);
584 dc->port[PORT_MDM].dl_size[CH_A] =
585 dc->config_table.dl_mdm_len1 - buff_offset;
586 dc->port[PORT_MDM].dl_size[CH_B] =
587 dc->config_table.dl_mdm_len2 - buff_offset;
588
589 /* Diag port dl configuration */
590 dc->port[PORT_DIAG].dl_addr[CH_A] =
591 (offset += dc->config_table.dl_mdm_len2);
592 dc->port[PORT_DIAG].dl_size[CH_A] =
593 dc->config_table.dl_diag_len1 - buff_offset;
594 dc->port[PORT_DIAG].dl_addr[CH_B] =
595 (offset += dc->config_table.dl_diag_len1);
596 dc->port[PORT_DIAG].dl_size[CH_B] =
597 dc->config_table.dl_diag_len2 - buff_offset;
598
599 /* App1 port dl configuration */
600 dc->port[PORT_APP1].dl_addr[CH_A] =
601 (offset += dc->config_table.dl_diag_len2);
602 dc->port[PORT_APP1].dl_size[CH_A] =
603 dc->config_table.dl_app1_len - buff_offset;
604
605 /* App2 port dl configuration */
606 dc->port[PORT_APP2].dl_addr[CH_A] =
607 (offset += dc->config_table.dl_app1_len);
608 dc->port[PORT_APP2].dl_size[CH_A] =
609 dc->config_table.dl_app2_len - buff_offset;
610
611 /* Ctrl dl configuration */
612 dc->port[PORT_CTRL].dl_addr[CH_A] =
613 (offset += dc->config_table.dl_app2_len);
614 dc->port[PORT_CTRL].dl_size[CH_A] =
615 dc->config_table.dl_ctrl_len - buff_offset;
616
617 offset = dc->base_addr + dc->config_table.ul_start;
618
619 /* Modem Port ul configuration */
620 dc->port[PORT_MDM].ul_addr[CH_A] = offset;
621 dc->port[PORT_MDM].ul_size[CH_A] =
622 dc->config_table.ul_mdm_len1 - buff_offset;
623 dc->port[PORT_MDM].ul_addr[CH_B] =
624 (offset += dc->config_table.ul_mdm_len1);
625 dc->port[PORT_MDM].ul_size[CH_B] =
626 dc->config_table.ul_mdm_len2 - buff_offset;
627
628 /* Diag port ul configuration */
629 dc->port[PORT_DIAG].ul_addr[CH_A] =
630 (offset += dc->config_table.ul_mdm_len2);
631 dc->port[PORT_DIAG].ul_size[CH_A] =
632 dc->config_table.ul_diag_len - buff_offset;
633
634 /* App1 port ul configuration */
635 dc->port[PORT_APP1].ul_addr[CH_A] =
636 (offset += dc->config_table.ul_diag_len);
637 dc->port[PORT_APP1].ul_size[CH_A] =
638 dc->config_table.ul_app1_len - buff_offset;
639
640 /* App2 port ul configuration */
641 dc->port[PORT_APP2].ul_addr[CH_A] =
642 (offset += dc->config_table.ul_app1_len);
643 dc->port[PORT_APP2].ul_size[CH_A] =
644 dc->config_table.ul_app2_len - buff_offset;
645
646 /* Ctrl ul configuration */
647 dc->port[PORT_CTRL].ul_addr[CH_A] =
648 (offset += dc->config_table.ul_app2_len);
649 dc->port[PORT_CTRL].ul_size[CH_A] =
650 dc->config_table.ul_ctrl_len - buff_offset;
651}
652
653/* Dump config table under initalization phase */
654#ifdef DEBUG
655static void dump_table(const struct nozomi *dc)
656{
657 DBG3("signature: 0x%08X", dc->config_table.signature);
658 DBG3("version: 0x%04X", dc->config_table.version);
659 DBG3("product_information: 0x%04X", \
660 dc->config_table.product_information);
661 DBG3("toggle enabled: %d", dc->config_table.toggle.enabled);
662 DBG3("toggle up_mdm: %d", dc->config_table.toggle.mdm_ul);
663 DBG3("toggle dl_mdm: %d", dc->config_table.toggle.mdm_dl);
664 DBG3("toggle dl_dbg: %d", dc->config_table.toggle.diag_dl);
665
666 DBG3("dl_start: 0x%04X", dc->config_table.dl_start);
667 DBG3("dl_mdm_len0: 0x%04X, %d", dc->config_table.dl_mdm_len1,
668 dc->config_table.dl_mdm_len1);
669 DBG3("dl_mdm_len1: 0x%04X, %d", dc->config_table.dl_mdm_len2,
670 dc->config_table.dl_mdm_len2);
671 DBG3("dl_diag_len0: 0x%04X, %d", dc->config_table.dl_diag_len1,
672 dc->config_table.dl_diag_len1);
673 DBG3("dl_diag_len1: 0x%04X, %d", dc->config_table.dl_diag_len2,
674 dc->config_table.dl_diag_len2);
675 DBG3("dl_app1_len: 0x%04X, %d", dc->config_table.dl_app1_len,
676 dc->config_table.dl_app1_len);
677 DBG3("dl_app2_len: 0x%04X, %d", dc->config_table.dl_app2_len,
678 dc->config_table.dl_app2_len);
679 DBG3("dl_ctrl_len: 0x%04X, %d", dc->config_table.dl_ctrl_len,
680 dc->config_table.dl_ctrl_len);
681 DBG3("ul_start: 0x%04X, %d", dc->config_table.ul_start,
682 dc->config_table.ul_start);
683 DBG3("ul_mdm_len[0]: 0x%04X, %d", dc->config_table.ul_mdm_len1,
684 dc->config_table.ul_mdm_len1);
685 DBG3("ul_mdm_len[1]: 0x%04X, %d", dc->config_table.ul_mdm_len2,
686 dc->config_table.ul_mdm_len2);
687 DBG3("ul_diag_len: 0x%04X, %d", dc->config_table.ul_diag_len,
688 dc->config_table.ul_diag_len);
689 DBG3("ul_app1_len: 0x%04X, %d", dc->config_table.ul_app1_len,
690 dc->config_table.ul_app1_len);
691 DBG3("ul_app2_len: 0x%04X, %d", dc->config_table.ul_app2_len,
692 dc->config_table.ul_app2_len);
693 DBG3("ul_ctrl_len: 0x%04X, %d", dc->config_table.ul_ctrl_len,
694 dc->config_table.ul_ctrl_len);
695}
696#else
697static __inline__ void dump_table(const struct nozomi *dc) { }
698#endif
699
700/*
701 * Read configuration table from card under intalization phase
702 * Returns 1 if ok, else 0
703 */
704static int nozomi_read_config_table(struct nozomi *dc)
705{
706 read_mem32((u32 *) &dc->config_table, dc->base_addr + 0,
707 sizeof(struct config_table));
708
709 if (dc->config_table.signature != CONFIG_MAGIC) {
710 dev_err(&dc->pdev->dev, "ConfigTable Bad! 0x%08X != 0x%08X\n",
711 dc->config_table.signature, CONFIG_MAGIC);
712 return 0;
713 }
714
715 if ((dc->config_table.version == 0)
716 || (dc->config_table.toggle.enabled == TOGGLE_VALID)) {
717 int i;
718 DBG1("Second phase, configuring card");
719
720 setup_memory(dc);
721
722 dc->port[PORT_MDM].toggle_ul = dc->config_table.toggle.mdm_ul;
723 dc->port[PORT_MDM].toggle_dl = dc->config_table.toggle.mdm_dl;
724 dc->port[PORT_DIAG].toggle_dl = dc->config_table.toggle.diag_dl;
725 DBG1("toggle ports: MDM UL:%d MDM DL:%d, DIAG DL:%d",
726 dc->port[PORT_MDM].toggle_ul,
727 dc->port[PORT_MDM].toggle_dl, dc->port[PORT_DIAG].toggle_dl);
728
729 dump_table(dc);
730
731 for (i = PORT_MDM; i < MAX_PORT; i++) {
732 dc->port[i].fifo_ul =
733 kfifo_alloc(FIFO_BUFFER_SIZE_UL, GFP_ATOMIC, NULL);
734 memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl));
735 memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul));
736 }
737
738 /* Enable control channel */
739 dc->last_ier = dc->last_ier | CTRL_DL;
740 writew(dc->last_ier, dc->reg_ier);
741
742 dev_info(&dc->pdev->dev, "Initialization OK!\n");
743 return 1;
744 }
745
746 if ((dc->config_table.version > 0)
747 && (dc->config_table.toggle.enabled != TOGGLE_VALID)) {
748 u32 offset = 0;
749 DBG1("First phase: pushing upload buffers, clearing download");
750
751 dev_info(&dc->pdev->dev, "Version of card: %d\n",
752 dc->config_table.version);
753
754 /* Here we should disable all I/O over F32. */
755 setup_memory(dc);
756
757 /*
758 * We should send ALL channel pair tokens back along
759 * with reset token
760 */
761
762 /* push upload modem buffers */
763 write_mem32(dc->port[PORT_MDM].ul_addr[CH_A],
764 (u32 *) &offset, 4);
765 write_mem32(dc->port[PORT_MDM].ul_addr[CH_B],
766 (u32 *) &offset, 4);
767
768 writew(MDM_UL | DIAG_DL | MDM_DL, dc->reg_fcr);
769
770 DBG1("First phase done");
771 }
772
773 return 1;
774}
775
776/* Enable uplink interrupts */
777static void enable_transmit_ul(enum port_type port, struct nozomi *dc)
778{
779 u16 mask[NOZOMI_MAX_PORTS] = \
780 {MDM_UL, DIAG_UL, APP1_UL, APP2_UL, CTRL_UL};
781
782 if (port < NOZOMI_MAX_PORTS) {
783 dc->last_ier |= mask[port];
784 writew(dc->last_ier, dc->reg_ier);
785 } else {
786 dev_err(&dc->pdev->dev, "Called with wrong port?\n");
787 }
788}
789
790/* Disable uplink interrupts */
791static void disable_transmit_ul(enum port_type port, struct nozomi *dc)
792{
793 u16 mask[NOZOMI_MAX_PORTS] = \
794 {~MDM_UL, ~DIAG_UL, ~APP1_UL, ~APP2_UL, ~CTRL_UL};
795
796 if (port < NOZOMI_MAX_PORTS) {
797 dc->last_ier &= mask[port];
798 writew(dc->last_ier, dc->reg_ier);
799 } else {
800 dev_err(&dc->pdev->dev, "Called with wrong port?\n");
801 }
802}
803
804/* Enable downlink interrupts */
805static void enable_transmit_dl(enum port_type port, struct nozomi *dc)
806{
807 u16 mask[NOZOMI_MAX_PORTS] = \
808 {MDM_DL, DIAG_DL, APP1_DL, APP2_DL, CTRL_DL};
809
810 if (port < NOZOMI_MAX_PORTS) {
811 dc->last_ier |= mask[port];
812 writew(dc->last_ier, dc->reg_ier);
813 } else {
814 dev_err(&dc->pdev->dev, "Called with wrong port?\n");
815 }
816}
817
818/* Disable downlink interrupts */
819static void disable_transmit_dl(enum port_type port, struct nozomi *dc)
820{
821 u16 mask[NOZOMI_MAX_PORTS] = \
822 {~MDM_DL, ~DIAG_DL, ~APP1_DL, ~APP2_DL, ~CTRL_DL};
823
824 if (port < NOZOMI_MAX_PORTS) {
825 dc->last_ier &= mask[port];
826 writew(dc->last_ier, dc->reg_ier);
827 } else {
828 dev_err(&dc->pdev->dev, "Called with wrong port?\n");
829 }
830}
831
832/*
833 * Return 1 - send buffer to card and ack.
834 * Return 0 - don't ack, don't send buffer to card.
835 */
836static int send_data(enum port_type index, struct nozomi *dc)
837{
838 u32 size = 0;
839 struct port *port = &dc->port[index];
840 u8 toggle = port->toggle_ul;
841 void __iomem *addr = port->ul_addr[toggle];
842 u32 ul_size = port->ul_size[toggle];
843 struct tty_struct *tty = port->tty;
844
845 /* Get data from tty and place in buf for now */
846 size = __kfifo_get(port->fifo_ul, dc->send_buf,
847 ul_size < SEND_BUF_MAX ? ul_size : SEND_BUF_MAX);
848
849 if (size == 0) {
850 DBG4("No more data to send, disable link:");
851 return 0;
852 }
853
854 /* DUMP(buf, size); */
855
856 /* Write length + data */
857 write_mem32(addr, (u32 *) &size, 4);
858 write_mem32(addr + 4, (u32 *) dc->send_buf, size);
859
860 if (tty)
861 tty_wakeup(tty);
862
863 return 1;
864}
865
866/* If all data has been read, return 1, else 0 */
867static int receive_data(enum port_type index, struct nozomi *dc)
868{
869 u8 buf[RECEIVE_BUF_MAX] = { 0 };
870 int size;
871 u32 offset = 4;
872 struct port *port = &dc->port[index];
873 void __iomem *addr = port->dl_addr[port->toggle_dl];
874 struct tty_struct *tty = port->tty;
875 int i;
876
877 if (unlikely(!tty)) {
878 DBG1("tty not open for port: %d?", index);
879 return 1;
880 }
881
882 read_mem32((u32 *) &size, addr, 4);
883 /* DBG1( "%d bytes port: %d", size, index); */
884
885 if (test_bit(TTY_THROTTLED, &tty->flags)) {
886 DBG1("No room in tty, don't read data, don't ack interrupt, "
887 "disable interrupt");
888
889 /* disable interrupt in downlink... */
890 disable_transmit_dl(index, dc);
891 return 0;
892 }
893
894 if (unlikely(size == 0)) {
895 dev_err(&dc->pdev->dev, "size == 0?\n");
896 return 1;
897 }
898
899 tty_buffer_request_room(tty, size);
900
901 while (size > 0) {
902 read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX);
903
904 if (size == 1) {
905 tty_insert_flip_char(tty, buf[0], TTY_NORMAL);
906 size = 0;
907 } else if (size < RECEIVE_BUF_MAX) {
908 size -= tty_insert_flip_string(tty, (char *) buf, size);
909 } else {
910 i = tty_insert_flip_string(tty, \
911 (char *) buf, RECEIVE_BUF_MAX);
912 size -= i;
913 offset += i;
914 }
915 }
916
917 set_bit(index, &dc->flip);
918
919 return 1;
920}
921
922/* Debug for interrupts */
923#ifdef DEBUG
924static char *interrupt2str(u16 interrupt)
925{
926 static char buf[TMP_BUF_MAX];
927 char *p = buf;
928
929 interrupt & MDM_DL1 ? p += snprintf(p, TMP_BUF_MAX, "MDM_DL1 ") : NULL;
930 interrupt & MDM_DL2 ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
931 "MDM_DL2 ") : NULL;
932
933 interrupt & MDM_UL1 ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
934 "MDM_UL1 ") : NULL;
935 interrupt & MDM_UL2 ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
936 "MDM_UL2 ") : NULL;
937
938 interrupt & DIAG_DL1 ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
939 "DIAG_DL1 ") : NULL;
940 interrupt & DIAG_DL2 ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
941 "DIAG_DL2 ") : NULL;
942
943 interrupt & DIAG_UL ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
944 "DIAG_UL ") : NULL;
945
946 interrupt & APP1_DL ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
947 "APP1_DL ") : NULL;
948 interrupt & APP2_DL ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
949 "APP2_DL ") : NULL;
950
951 interrupt & APP1_UL ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
952 "APP1_UL ") : NULL;
953 interrupt & APP2_UL ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
954 "APP2_UL ") : NULL;
955
956 interrupt & CTRL_DL ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
957 "CTRL_DL ") : NULL;
958 interrupt & CTRL_UL ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
959 "CTRL_UL ") : NULL;
960
961 interrupt & RESET ? p += snprintf(p, TMP_BUF_MAX - (p - buf),
962 "RESET ") : NULL;
963
964 return buf;
965}
966#endif
967
968/*
969 * Receive flow control
970 * Return 1 - If ok, else 0
971 */
972static int receive_flow_control(struct nozomi *dc)
973{
974 enum port_type port = PORT_MDM;
975 struct ctrl_dl ctrl_dl;
976 struct ctrl_dl old_ctrl;
977 u16 enable_ier = 0;
978
979 read_mem32((u32 *) &ctrl_dl, dc->port[PORT_CTRL].dl_addr[CH_A], 2);
980
981 switch (ctrl_dl.port) {
982 case CTRL_CMD:
983 DBG1("The Base Band sends this value as a response to a "
984 "request for IMSI detach sent over the control "
985 "channel uplink (see section 7.6.1).");
986 break;
987 case CTRL_MDM:
988 port = PORT_MDM;
989 enable_ier = MDM_DL;
990 break;
991 case CTRL_DIAG:
992 port = PORT_DIAG;
993 enable_ier = DIAG_DL;
994 break;
995 case CTRL_APP1:
996 port = PORT_APP1;
997 enable_ier = APP1_DL;
998 break;
999 case CTRL_APP2:
1000 port = PORT_APP2;
1001 enable_ier = APP2_DL;
1002 break;
1003 default:
1004 dev_err(&dc->pdev->dev,
1005 "ERROR: flow control received for non-existing port\n");
1006 return 0;
1007 };
1008
1009 DBG1("0x%04X->0x%04X", *((u16 *)&dc->port[port].ctrl_dl),
1010 *((u16 *)&ctrl_dl));
1011
1012 old_ctrl = dc->port[port].ctrl_dl;
1013 dc->port[port].ctrl_dl = ctrl_dl;
1014
1015 if (old_ctrl.CTS == 1 && ctrl_dl.CTS == 0) {
1016 DBG1("Disable interrupt (0x%04X) on port: %d",
1017 enable_ier, port);
1018 disable_transmit_ul(port, dc);
1019
1020 } else if (old_ctrl.CTS == 0 && ctrl_dl.CTS == 1) {
1021
1022 if (__kfifo_len(dc->port[port].fifo_ul)) {
1023 DBG1("Enable interrupt (0x%04X) on port: %d",
1024 enable_ier, port);
1025 DBG1("Data in buffer [%d], enable transmit! ",
1026 __kfifo_len(dc->port[port].fifo_ul));
1027 enable_transmit_ul(port, dc);
1028 } else {
1029 DBG1("No data in buffer...");
1030 }
1031 }
1032
1033 if (*(u16 *)&old_ctrl == *(u16 *)&ctrl_dl) {
1034 DBG1(" No change in mctrl");
1035 return 1;
1036 }
1037 /* Update statistics */
1038 if (old_ctrl.CTS != ctrl_dl.CTS)
1039 dc->port[port].tty_icount.cts++;
1040 if (old_ctrl.DSR != ctrl_dl.DSR)
1041 dc->port[port].tty_icount.dsr++;
1042 if (old_ctrl.RI != ctrl_dl.RI)
1043 dc->port[port].tty_icount.rng++;
1044 if (old_ctrl.DCD != ctrl_dl.DCD)
1045 dc->port[port].tty_icount.dcd++;
1046
1047 wake_up_interruptible(&dc->port[port].tty_wait);
1048
1049 DBG1("port: %d DCD(%d), CTS(%d), RI(%d), DSR(%d)",
1050 port,
1051 dc->port[port].tty_icount.dcd, dc->port[port].tty_icount.cts,
1052 dc->port[port].tty_icount.rng, dc->port[port].tty_icount.dsr);
1053
1054 return 1;
1055}
1056
1057static enum ctrl_port_type port2ctrl(enum port_type port,
1058 const struct nozomi *dc)
1059{
1060 switch (port) {
1061 case PORT_MDM:
1062 return CTRL_MDM;
1063 case PORT_DIAG:
1064 return CTRL_DIAG;
1065 case PORT_APP1:
1066 return CTRL_APP1;
1067 case PORT_APP2:
1068 return CTRL_APP2;
1069 default:
1070 dev_err(&dc->pdev->dev,
1071 "ERROR: send flow control " \
1072 "received for non-existing port\n");
1073 };
1074 return CTRL_ERROR;
1075}
1076
1077/*
1078 * Send flow control, can only update one channel at a time
1079 * Return 0 - If we have updated all flow control
1080 * Return 1 - If we need to update more flow control, ack current enable more
1081 */
1082static int send_flow_control(struct nozomi *dc)
1083{
1084 u32 i, more_flow_control_to_be_updated = 0;
1085 u16 *ctrl;
1086
1087 for (i = PORT_MDM; i < MAX_PORT; i++) {
1088 if (dc->port[i].update_flow_control) {
1089 if (more_flow_control_to_be_updated) {
1090 /* We have more flow control to be updated */
1091 return 1;
1092 }
1093 dc->port[i].ctrl_ul.port = port2ctrl(i, dc);
1094 ctrl = (u16 *)&dc->port[i].ctrl_ul;
1095 write_mem32(dc->port[PORT_CTRL].ul_addr[0], \
1096 (u32 *) ctrl, 2);
1097 dc->port[i].update_flow_control = 0;
1098 more_flow_control_to_be_updated = 1;
1099 }
1100 }
1101 return 0;
1102}
1103
1104/*
1105 * Handle donlink data, ports that are handled are modem and diagnostics
1106 * Return 1 - ok
1107 * Return 0 - toggle fields are out of sync
1108 */
1109static int handle_data_dl(struct nozomi *dc, enum port_type port, u8 *toggle,
1110 u16 read_iir, u16 mask1, u16 mask2)
1111{
1112 if (*toggle == 0 && read_iir & mask1) {
1113 if (receive_data(port, dc)) {
1114 writew(mask1, dc->reg_fcr);
1115 *toggle = !(*toggle);
1116 }
1117
1118 if (read_iir & mask2) {
1119 if (receive_data(port, dc)) {
1120 writew(mask2, dc->reg_fcr);
1121 *toggle = !(*toggle);
1122 }
1123 }
1124 } else if (*toggle == 1 && read_iir & mask2) {
1125 if (receive_data(port, dc)) {
1126 writew(mask2, dc->reg_fcr);
1127 *toggle = !(*toggle);
1128 }
1129
1130 if (read_iir & mask1) {
1131 if (receive_data(port, dc)) {
1132 writew(mask1, dc->reg_fcr);
1133 *toggle = !(*toggle);
1134 }
1135 }
1136 } else {
1137 dev_err(&dc->pdev->dev, "port out of sync!, toggle:%d\n",
1138 *toggle);
1139 return 0;
1140 }
1141 return 1;
1142}
1143
1144/*
1145 * Handle uplink data, this is currently for the modem port
1146 * Return 1 - ok
1147 * Return 0 - toggle field are out of sync
1148 */
1149static int handle_data_ul(struct nozomi *dc, enum port_type port, u16 read_iir)
1150{
1151 u8 *toggle = &(dc->port[port].toggle_ul);
1152
1153 if (*toggle == 0 && read_iir & MDM_UL1) {
1154 dc->last_ier &= ~MDM_UL;
1155 writew(dc->last_ier, dc->reg_ier);
1156 if (send_data(port, dc)) {
1157 writew(MDM_UL1, dc->reg_fcr);
1158 dc->last_ier = dc->last_ier | MDM_UL;
1159 writew(dc->last_ier, dc->reg_ier);
1160 *toggle = !*toggle;
1161 }
1162
1163 if (read_iir & MDM_UL2) {
1164 dc->last_ier &= ~MDM_UL;
1165 writew(dc->last_ier, dc->reg_ier);
1166 if (send_data(port, dc)) {
1167 writew(MDM_UL2, dc->reg_fcr);
1168 dc->last_ier = dc->last_ier | MDM_UL;
1169 writew(dc->last_ier, dc->reg_ier);
1170 *toggle = !*toggle;
1171 }
1172 }
1173
1174 } else if (*toggle == 1 && read_iir & MDM_UL2) {
1175 dc->last_ier &= ~MDM_UL;
1176 writew(dc->last_ier, dc->reg_ier);
1177 if (send_data(port, dc)) {
1178 writew(MDM_UL2, dc->reg_fcr);
1179 dc->last_ier = dc->last_ier | MDM_UL;
1180 writew(dc->last_ier, dc->reg_ier);
1181 *toggle = !*toggle;
1182 }
1183
1184 if (read_iir & MDM_UL1) {
1185 dc->last_ier &= ~MDM_UL;
1186 writew(dc->last_ier, dc->reg_ier);
1187 if (send_data(port, dc)) {
1188 writew(MDM_UL1, dc->reg_fcr);
1189 dc->last_ier = dc->last_ier | MDM_UL;
1190 writew(dc->last_ier, dc->reg_ier);
1191 *toggle = !*toggle;
1192 }
1193 }
1194 } else {
1195 writew(read_iir & MDM_UL, dc->reg_fcr);
1196 dev_err(&dc->pdev->dev, "port out of sync!\n");
1197 return 0;
1198 }
1199 return 1;
1200}
1201
1202static irqreturn_t interrupt_handler(int irq, void *dev_id)
1203{
1204 struct nozomi *dc = dev_id;
1205 unsigned int a;
1206 u16 read_iir;
1207
1208 if (!dc)
1209 return IRQ_NONE;
1210
1211 spin_lock(&dc->spin_mutex);
1212 read_iir = readw(dc->reg_iir);
1213
1214 /* Card removed */
1215 if (read_iir == (u16)-1)
1216 goto none;
1217 /*
1218 * Just handle interrupt enabled in IER
1219 * (by masking with dc->last_ier)
1220 */
1221 read_iir &= dc->last_ier;
1222
1223 if (read_iir == 0)
1224 goto none;
1225
1226
1227 DBG4("%s irq:0x%04X, prev:0x%04X", interrupt2str(read_iir), read_iir,
1228 dc->last_ier);
1229
1230 if (read_iir & RESET) {
1231 if (unlikely(!nozomi_read_config_table(dc))) {
1232 dc->last_ier = 0x0;
1233 writew(dc->last_ier, dc->reg_ier);
1234 dev_err(&dc->pdev->dev, "Could not read status from "
1235 "card, we should disable interface\n");
1236 } else {
1237 writew(RESET, dc->reg_fcr);
1238 }
1239 /* No more useful info if this was the reset interrupt. */
1240 goto exit_handler;
1241 }
1242 if (read_iir & CTRL_UL) {
1243 DBG1("CTRL_UL");
1244 dc->last_ier &= ~CTRL_UL;
1245 writew(dc->last_ier, dc->reg_ier);
1246 if (send_flow_control(dc)) {
1247 writew(CTRL_UL, dc->reg_fcr);
1248 dc->last_ier = dc->last_ier | CTRL_UL;
1249 writew(dc->last_ier, dc->reg_ier);
1250 }
1251 }
1252 if (read_iir & CTRL_DL) {
1253 receive_flow_control(dc);
1254 writew(CTRL_DL, dc->reg_fcr);
1255 }
1256 if (read_iir & MDM_DL) {
1257 if (!handle_data_dl(dc, PORT_MDM,
1258 &(dc->port[PORT_MDM].toggle_dl), read_iir,
1259 MDM_DL1, MDM_DL2)) {
1260 dev_err(&dc->pdev->dev, "MDM_DL out of sync!\n");
1261 goto exit_handler;
1262 }
1263 }
1264 if (read_iir & MDM_UL) {
1265 if (!handle_data_ul(dc, PORT_MDM, read_iir)) {
1266 dev_err(&dc->pdev->dev, "MDM_UL out of sync!\n");
1267 goto exit_handler;
1268 }
1269 }
1270 if (read_iir & DIAG_DL) {
1271 if (!handle_data_dl(dc, PORT_DIAG,
1272 &(dc->port[PORT_DIAG].toggle_dl), read_iir,
1273 DIAG_DL1, DIAG_DL2)) {
1274 dev_err(&dc->pdev->dev, "DIAG_DL out of sync!\n");
1275 goto exit_handler;
1276 }
1277 }
1278 if (read_iir & DIAG_UL) {
1279 dc->last_ier &= ~DIAG_UL;
1280 writew(dc->last_ier, dc->reg_ier);
1281 if (send_data(PORT_DIAG, dc)) {
1282 writew(DIAG_UL, dc->reg_fcr);
1283 dc->last_ier = dc->last_ier | DIAG_UL;
1284 writew(dc->last_ier, dc->reg_ier);
1285 }
1286 }
1287 if (read_iir & APP1_DL) {
1288 if (receive_data(PORT_APP1, dc))
1289 writew(APP1_DL, dc->reg_fcr);
1290 }
1291 if (read_iir & APP1_UL) {
1292 dc->last_ier &= ~APP1_UL;
1293 writew(dc->last_ier, dc->reg_ier);
1294 if (send_data(PORT_APP1, dc)) {
1295 writew(APP1_UL, dc->reg_fcr);
1296 dc->last_ier = dc->last_ier | APP1_UL;
1297 writew(dc->last_ier, dc->reg_ier);
1298 }
1299 }
1300 if (read_iir & APP2_DL) {
1301 if (receive_data(PORT_APP2, dc))
1302 writew(APP2_DL, dc->reg_fcr);
1303 }
1304 if (read_iir & APP2_UL) {
1305 dc->last_ier &= ~APP2_UL;
1306 writew(dc->last_ier, dc->reg_ier);
1307 if (send_data(PORT_APP2, dc)) {
1308 writew(APP2_UL, dc->reg_fcr);
1309 dc->last_ier = dc->last_ier | APP2_UL;
1310 writew(dc->last_ier, dc->reg_ier);
1311 }
1312 }
1313
1314exit_handler:
1315 spin_unlock(&dc->spin_mutex);
1316 for (a = 0; a < NOZOMI_MAX_PORTS; a++)
1317 if (test_and_clear_bit(a, &dc->flip))
1318 tty_flip_buffer_push(dc->port[a].tty);
1319 return IRQ_HANDLED;
1320none:
1321 spin_unlock(&dc->spin_mutex);
1322 return IRQ_NONE;
1323}
1324
1325static void nozomi_get_card_type(struct nozomi *dc)
1326{
1327 int i;
1328 u32 size = 0;
1329
1330 for (i = 0; i < 6; i++)
1331 size += pci_resource_len(dc->pdev, i);
1332
1333 /* Assume card type F32_8 if no match */
1334 dc->card_type = size == 2048 ? F32_2 : F32_8;
1335
1336 dev_info(&dc->pdev->dev, "Card type is: %d\n", dc->card_type);
1337}
1338
1339static void nozomi_setup_private_data(struct nozomi *dc)
1340{
1341 void __iomem *offset = dc->base_addr + dc->card_type / 2;
1342 unsigned int i;
1343
1344 dc->reg_fcr = (void __iomem *)(offset + R_FCR);
1345 dc->reg_iir = (void __iomem *)(offset + R_IIR);
1346 dc->reg_ier = (void __iomem *)(offset + R_IER);
1347 dc->last_ier = 0;
1348 dc->flip = 0;
1349
1350 dc->port[PORT_MDM].token_dl = MDM_DL;
1351 dc->port[PORT_DIAG].token_dl = DIAG_DL;
1352 dc->port[PORT_APP1].token_dl = APP1_DL;
1353 dc->port[PORT_APP2].token_dl = APP2_DL;
1354
1355 for (i = 0; i < MAX_PORT; i++)
1356 init_waitqueue_head(&dc->port[i].tty_wait);
1357}
1358
1359static ssize_t card_type_show(struct device *dev, struct device_attribute *attr,
1360 char *buf)
1361{
1362 struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev));
1363
1364 return sprintf(buf, "%d\n", dc->card_type);
1365}
1366static DEVICE_ATTR(card_type, 0444, card_type_show, NULL);
1367
1368static ssize_t open_ttys_show(struct device *dev, struct device_attribute *attr,
1369 char *buf)
1370{
1371 struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev));
1372
1373 return sprintf(buf, "%u\n", dc->open_ttys);
1374}
1375static DEVICE_ATTR(open_ttys, 0444, open_ttys_show, NULL);
1376
1377static void make_sysfs_files(struct nozomi *dc)
1378{
1379 if (device_create_file(&dc->pdev->dev, &dev_attr_card_type))
1380 dev_err(&dc->pdev->dev,
1381 "Could not create sysfs file for card_type\n");
1382 if (device_create_file(&dc->pdev->dev, &dev_attr_open_ttys))
1383 dev_err(&dc->pdev->dev,
1384 "Could not create sysfs file for open_ttys\n");
1385}
1386
1387static void remove_sysfs_files(struct nozomi *dc)
1388{
1389 device_remove_file(&dc->pdev->dev, &dev_attr_card_type);
1390 device_remove_file(&dc->pdev->dev, &dev_attr_open_ttys);
1391}
1392
1393/* Allocate memory for one device */
1394static int __devinit nozomi_card_init(struct pci_dev *pdev,
1395 const struct pci_device_id *ent)
1396{
1397 resource_size_t start;
1398 int ret;
1399 struct nozomi *dc = NULL;
1400 int ndev_idx;
1401 int i;
1402
1403 dev_dbg(&pdev->dev, "Init, new card found\n");
1404
1405 for (ndev_idx = 0; ndev_idx < ARRAY_SIZE(ndevs); ndev_idx++)
1406 if (!ndevs[ndev_idx])
1407 break;
1408
1409 if (ndev_idx >= ARRAY_SIZE(ndevs)) {
1410 dev_err(&pdev->dev, "no free tty range for this card left\n");
1411 ret = -EIO;
1412 goto err;
1413 }
1414
1415 dc = kzalloc(sizeof(struct nozomi), GFP_KERNEL);
1416 if (unlikely(!dc)) {
1417 dev_err(&pdev->dev, "Could not allocate memory\n");
1418 ret = -ENOMEM;
1419 goto err_free;
1420 }
1421
1422 dc->pdev = pdev;
1423
1424 /* Find out what card type it is */
1425 nozomi_get_card_type(dc);
1426
1427 ret = pci_enable_device(dc->pdev);
1428 if (ret) {
1429 dev_err(&pdev->dev, "Failed to enable PCI Device\n");
1430 goto err_free;
1431 }
1432
1433 start = pci_resource_start(dc->pdev, 0);
1434 if (start == 0) {
1435 dev_err(&pdev->dev, "No I/O address for card detected\n");
1436 ret = -ENODEV;
1437 goto err_disable_device;
1438 }
1439
1440 ret = pci_request_regions(dc->pdev, NOZOMI_NAME);
1441 if (ret) {
1442 dev_err(&pdev->dev, "I/O address 0x%04x already in use\n",
1443 (int) /* nozomi_private.io_addr */ 0);
1444 goto err_disable_device;
1445 }
1446
1447 dc->base_addr = ioremap(start, dc->card_type);
1448 if (!dc->base_addr) {
1449 dev_err(&pdev->dev, "Unable to map card MMIO\n");
1450 ret = -ENODEV;
1451 goto err_rel_regs;
1452 }
1453
1454 dc->send_buf = kmalloc(SEND_BUF_MAX, GFP_KERNEL);
1455 if (!dc->send_buf) {
1456 dev_err(&pdev->dev, "Could not allocate send buffer?\n");
1457 ret = -ENOMEM;
1458 goto err_free_sbuf;
1459 }
1460
1461 spin_lock_init(&dc->spin_mutex);
1462
1463 nozomi_setup_private_data(dc);
1464
1465 /* Disable all interrupts */
1466 dc->last_ier = 0;
1467 writew(dc->last_ier, dc->reg_ier);
1468
1469 ret = request_irq(pdev->irq, &interrupt_handler, IRQF_SHARED,
1470 NOZOMI_NAME, dc);
1471 if (unlikely(ret)) {
1472 dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq);
1473 goto err_free_sbuf;
1474 }
1475
1476 DBG1("base_addr: %p", dc->base_addr);
1477
1478 make_sysfs_files(dc);
1479
1480 dc->index_start = ndev_idx * MAX_PORT;
1481 ndevs[ndev_idx] = dc;
1482
1483 for (i = 0; i < MAX_PORT; i++) {
1484 mutex_init(&dc->port[i].tty_sem);
1485 dc->port[i].tty_open_count = 0;
1486 dc->port[i].tty = NULL;
1487 tty_register_device(ntty_driver, dc->index_start + i,
1488 &pdev->dev);
1489 }
1490
1491 /* Enable RESET interrupt. */
1492 dc->last_ier = RESET;
1493 writew(dc->last_ier, dc->reg_ier);
1494
1495 pci_set_drvdata(pdev, dc);
1496
1497 return 0;
1498
1499err_free_sbuf:
1500 kfree(dc->send_buf);
1501 iounmap(dc->base_addr);
1502err_rel_regs:
1503 pci_release_regions(pdev);
1504err_disable_device:
1505 pci_disable_device(pdev);
1506err_free:
1507 kfree(dc);
1508err:
1509 return ret;
1510}
1511
1512static void __devexit tty_exit(struct nozomi *dc)
1513{
1514 unsigned int i;
1515
1516 DBG1(" ");
1517
1518 flush_scheduled_work();
1519
1520 for (i = 0; i < MAX_PORT; ++i)
1521 if (dc->port[i].tty && \
1522 list_empty(&dc->port[i].tty->hangup_work.entry))
1523 tty_hangup(dc->port[i].tty);
1524
1525 while (dc->open_ttys)
1526 msleep(1);
1527
1528 for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i)
1529 tty_unregister_device(ntty_driver, i);
1530}
1531
1532/* Deallocate memory for one device */
1533static void __devexit nozomi_card_exit(struct pci_dev *pdev)
1534{
1535 int i;
1536 struct ctrl_ul ctrl;
1537 struct nozomi *dc = pci_get_drvdata(pdev);
1538
1539 /* Disable all interrupts */
1540 dc->last_ier = 0;
1541 writew(dc->last_ier, dc->reg_ier);
1542
1543 tty_exit(dc);
1544
1545 /* Send 0x0001, command card to resend the reset token. */
1546 /* This is to get the reset when the module is reloaded. */
1547 ctrl.port = 0x00;
1548 ctrl.reserved = 0;
1549 ctrl.RTS = 0;
1550 ctrl.DTR = 1;
1551 DBG1("sending flow control 0x%04X", *((u16 *)&ctrl));
1552
1553 /* Setup dc->reg addresses to we can use defines here */
1554 write_mem32(dc->port[PORT_CTRL].ul_addr[0], (u32 *)&ctrl, 2);
1555 writew(CTRL_UL, dc->reg_fcr); /* push the token to the card. */
1556
1557 remove_sysfs_files(dc);
1558
1559 free_irq(pdev->irq, dc);
1560
1561 for (i = 0; i < MAX_PORT; i++)
1562 if (dc->port[i].fifo_ul)
1563 kfifo_free(dc->port[i].fifo_ul);
1564
1565 kfree(dc->send_buf);
1566
1567 iounmap(dc->base_addr);
1568
1569 pci_release_regions(pdev);
1570
1571 pci_disable_device(pdev);
1572
1573 ndevs[dc->index_start / MAX_PORT] = NULL;
1574
1575 kfree(dc);
1576}
1577
1578static void set_rts(const struct tty_struct *tty, int rts)
1579{
1580 struct port *port = get_port_by_tty(tty);
1581
1582 port->ctrl_ul.RTS = rts;
1583 port->update_flow_control = 1;
1584 enable_transmit_ul(PORT_CTRL, get_dc_by_tty(tty));
1585}
1586
1587static void set_dtr(const struct tty_struct *tty, int dtr)
1588{
1589 struct port *port = get_port_by_tty(tty);
1590
1591 DBG1("SETTING DTR index: %d, dtr: %d", tty->index, dtr);
1592
1593 port->ctrl_ul.DTR = dtr;
1594 port->update_flow_control = 1;
1595 enable_transmit_ul(PORT_CTRL, get_dc_by_tty(tty));
1596}
1597
1598/*
1599 * ----------------------------------------------------------------------------
1600 * TTY code
1601 * ----------------------------------------------------------------------------
1602 */
1603
1604/* Called when the userspace process opens the tty, /dev/noz*. */
1605static int ntty_open(struct tty_struct *tty, struct file *file)
1606{
1607 struct port *port = get_port_by_tty(tty);
1608 struct nozomi *dc = get_dc_by_tty(tty);
1609 unsigned long flags;
1610
1611 if (!port || !dc)
1612 return -ENODEV;
1613
1614 if (mutex_lock_interruptible(&port->tty_sem))
1615 return -ERESTARTSYS;
1616
1617 port->tty_open_count++;
1618 dc->open_ttys++;
1619
1620 /* Enable interrupt downlink for channel */
1621 if (port->tty_open_count == 1) {
1622 tty->low_latency = 1;
1623 tty->driver_data = port;
1624 port->tty = tty;
1625 DBG1("open: %d", port->token_dl);
1626 spin_lock_irqsave(&dc->spin_mutex, flags);
1627 dc->last_ier = dc->last_ier | port->token_dl;
1628 writew(dc->last_ier, dc->reg_ier);
1629 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1630 }
1631
1632 mutex_unlock(&port->tty_sem);
1633
1634 return 0;
1635}
1636
1637/* Called when the userspace process close the tty, /dev/noz*. */
1638static void ntty_close(struct tty_struct *tty, struct file *file)
1639{
1640 struct nozomi *dc = get_dc_by_tty(tty);
1641 struct port *port = tty->driver_data;
1642 unsigned long flags;
1643
1644 if (!dc || !port)
1645 return;
1646
1647 if (mutex_lock_interruptible(&port->tty_sem))
1648 return;
1649
1650 if (!port->tty_open_count)
1651 goto exit;
1652
1653 dc->open_ttys--;
1654 port->tty_open_count--;
1655
1656 if (port->tty_open_count == 0) {
1657 DBG1("close: %d", port->token_dl);
1658 spin_lock_irqsave(&dc->spin_mutex, flags);
1659 dc->last_ier &= ~(port->token_dl);
1660 writew(dc->last_ier, dc->reg_ier);
1661 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1662 }
1663
1664exit:
1665 mutex_unlock(&port->tty_sem);
1666}
1667
1668/*
1669 * called when the userspace process writes to the tty (/dev/noz*).
1670 * Data is inserted into a fifo, which is then read and transfered to the modem.
1671 */
1672static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
1673 int count)
1674{
1675 int rval = -EINVAL;
1676 struct nozomi *dc = get_dc_by_tty(tty);
1677 struct port *port = tty->driver_data;
1678 unsigned long flags;
1679
1680 /* DBG1( "WRITEx: %d, index = %d", count, index); */
1681
1682 if (!dc || !port)
1683 return -ENODEV;
1684
1685 if (unlikely(!mutex_trylock(&port->tty_sem))) {
1686 /*
1687 * must test lock as tty layer wraps calls
1688 * to this function with BKL
1689 */
1690 dev_err(&dc->pdev->dev, "Would have deadlocked - "
1691 "return EAGAIN\n");
1692 return -EAGAIN;
1693 }
1694
1695 if (unlikely(!port->tty_open_count)) {
1696 DBG1(" ");
1697 goto exit;
1698 }
1699
1700 rval = __kfifo_put(port->fifo_ul, (unsigned char *)buffer, count);
1701
1702 /* notify card */
1703 if (unlikely(dc == NULL)) {
1704 DBG1("No device context?");
1705 goto exit;
1706 }
1707
1708 spin_lock_irqsave(&dc->spin_mutex, flags);
1709 /* CTS is only valid on the modem channel */
1710 if (port == &(dc->port[PORT_MDM])) {
1711 if (port->ctrl_dl.CTS) {
1712 DBG4("Enable interrupt");
1713 enable_transmit_ul(tty->index % MAX_PORT, dc);
1714 } else {
1715 dev_err(&dc->pdev->dev,
1716 "CTS not active on modem port?\n");
1717 }
1718 } else {
1719 enable_transmit_ul(tty->index % MAX_PORT, dc);
1720 }
1721 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1722
1723exit:
1724 mutex_unlock(&port->tty_sem);
1725 return rval;
1726}
1727
1728/*
1729 * Calculate how much is left in device
1730 * This method is called by the upper tty layer.
1731 * #according to sources N_TTY.c it expects a value >= 0 and
1732 * does not check for negative values.
1733 */
1734static int ntty_write_room(struct tty_struct *tty)
1735{
1736 struct port *port = tty->driver_data;
1737 int room = 0;
1738 struct nozomi *dc = get_dc_by_tty(tty);
1739
1740 if (!dc || !port)
1741 return 0;
1742 if (!mutex_trylock(&port->tty_sem))
1743 return 0;
1744
1745 if (!port->tty_open_count)
1746 goto exit;
1747
1748 room = port->fifo_ul->size - __kfifo_len(port->fifo_ul);
1749
1750exit:
1751 mutex_unlock(&port->tty_sem);
1752 return room;
1753}
1754
1755/* Gets io control parameters */
1756static int ntty_tiocmget(struct tty_struct *tty, struct file *file)
1757{
1758 struct port *port = tty->driver_data;
1759 struct ctrl_dl *ctrl_dl = &port->ctrl_dl;
1760 struct ctrl_ul *ctrl_ul = &port->ctrl_ul;
1761
1762 return (ctrl_ul->RTS ? TIOCM_RTS : 0) |
1763 (ctrl_ul->DTR ? TIOCM_DTR : 0) |
1764 (ctrl_dl->DCD ? TIOCM_CAR : 0) |
1765 (ctrl_dl->RI ? TIOCM_RNG : 0) |
1766 (ctrl_dl->DSR ? TIOCM_DSR : 0) |
1767 (ctrl_dl->CTS ? TIOCM_CTS : 0);
1768}
1769
1770/* Sets io controls parameters */
1771static int ntty_tiocmset(struct tty_struct *tty, struct file *file,
1772 unsigned int set, unsigned int clear)
1773{
1774 if (set & TIOCM_RTS)
1775 set_rts(tty, 1);
1776 else if (clear & TIOCM_RTS)
1777 set_rts(tty, 0);
1778
1779 if (set & TIOCM_DTR)
1780 set_dtr(tty, 1);
1781 else if (clear & TIOCM_DTR)
1782 set_dtr(tty, 0);
1783
1784 return 0;
1785}
1786
1787static int ntty_cflags_changed(struct port *port, unsigned long flags,
1788 struct async_icount *cprev)
1789{
1790 struct async_icount cnow = port->tty_icount;
1791 int ret;
1792
1793 ret = ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
1794 ((flags & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) ||
1795 ((flags & TIOCM_CD) && (cnow.dcd != cprev->dcd)) ||
1796 ((flags & TIOCM_CTS) && (cnow.cts != cprev->cts));
1797
1798 *cprev = cnow;
1799
1800 return ret;
1801}
1802
1803static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp)
1804{
1805 struct async_icount cnow = port->tty_icount;
1806 struct serial_icounter_struct icount;
1807
1808 icount.cts = cnow.cts;
1809 icount.dsr = cnow.dsr;
1810 icount.rng = cnow.rng;
1811 icount.dcd = cnow.dcd;
1812 icount.rx = cnow.rx;
1813 icount.tx = cnow.tx;
1814 icount.frame = cnow.frame;
1815 icount.overrun = cnow.overrun;
1816 icount.parity = cnow.parity;
1817 icount.brk = cnow.brk;
1818 icount.buf_overrun = cnow.buf_overrun;
1819
1820 return copy_to_user(argp, &icount, sizeof(icount));
1821}
1822
1823static int ntty_ioctl(struct tty_struct *tty, struct file *file,
1824 unsigned int cmd, unsigned long arg)
1825{
1826 struct port *port = tty->driver_data;
1827 void __user *argp = (void __user *)arg;
1828 int rval = -ENOIOCTLCMD;
1829
1830 DBG1("******** IOCTL, cmd: %d", cmd);
1831
1832 switch (cmd) {
1833 case TIOCMIWAIT: {
1834 struct async_icount cprev = port->tty_icount;
1835
1836 rval = wait_event_interruptible(port->tty_wait,
1837 ntty_cflags_changed(port, arg, &cprev));
1838 break;
1839 } case TIOCGICOUNT:
1840 rval = ntty_ioctl_tiocgicount(port, argp);
1841 break;
1842 default:
1843 DBG1("ERR: 0x%08X, %d", cmd, cmd);
1844 break;
1845 };
1846
1847 return rval;
1848}
1849
1850/*
1851 * Called by the upper tty layer when tty buffers are ready
1852 * to receive data again after a call to throttle.
1853 */
1854static void ntty_unthrottle(struct tty_struct *tty)
1855{
1856 struct nozomi *dc = get_dc_by_tty(tty);
1857 unsigned long flags;
1858
1859 DBG1("UNTHROTTLE");
1860 spin_lock_irqsave(&dc->spin_mutex, flags);
1861 enable_transmit_dl(tty->index % MAX_PORT, dc);
1862 set_rts(tty, 1);
1863
1864 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1865}
1866
1867/*
1868 * Called by the upper tty layer when the tty buffers are almost full.
1869 * The driver should stop send more data.
1870 */
1871static void ntty_throttle(struct tty_struct *tty)
1872{
1873 struct nozomi *dc = get_dc_by_tty(tty);
1874 unsigned long flags;
1875
1876 DBG1("THROTTLE");
1877 spin_lock_irqsave(&dc->spin_mutex, flags);
1878 set_rts(tty, 0);
1879 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1880}
1881
1882/* just to discard single character writes */
1883static void ntty_put_char(struct tty_struct *tty, unsigned char c)
1884{
1885 /* FIXME !!! */
1886 DBG2("PUT CHAR Function: %c", c);
1887}
1888
1889/* Returns number of chars in buffer, called by tty layer */
1890static s32 ntty_chars_in_buffer(struct tty_struct *tty)
1891{
1892 struct port *port = tty->driver_data;
1893 struct nozomi *dc = get_dc_by_tty(tty);
1894 s32 rval;
1895
1896 if (unlikely(!dc || !port)) {
1897 rval = -ENODEV;
1898 goto exit_in_buffer;
1899 }
1900
1901 if (unlikely(!port->tty_open_count)) {
1902 dev_err(&dc->pdev->dev, "No tty open?\n");
1903 rval = -ENODEV;
1904 goto exit_in_buffer;
1905 }
1906
1907 rval = __kfifo_len(port->fifo_ul);
1908
1909exit_in_buffer:
1910 return rval;
1911}
1912
1913static struct tty_operations tty_ops = {
1914 .ioctl = ntty_ioctl,
1915 .open = ntty_open,
1916 .close = ntty_close,
1917 .write = ntty_write,
1918 .write_room = ntty_write_room,
1919 .unthrottle = ntty_unthrottle,
1920 .throttle = ntty_throttle,
1921 .chars_in_buffer = ntty_chars_in_buffer,
1922 .put_char = ntty_put_char,
1923 .tiocmget = ntty_tiocmget,
1924 .tiocmset = ntty_tiocmset,
1925};
1926
1927/* Module initialization */
1928static struct pci_driver nozomi_driver = {
1929 .name = NOZOMI_NAME,
1930 .id_table = nozomi_pci_tbl,
1931 .probe = nozomi_card_init,
1932 .remove = __devexit_p(nozomi_card_exit),
1933};
1934
1935static __init int nozomi_init(void)
1936{
1937 int ret;
1938
1939 printk(KERN_INFO "Initializing %s\n", VERSION_STRING);
1940
1941 ntty_driver = alloc_tty_driver(NTTY_TTY_MAXMINORS);
1942 if (!ntty_driver)
1943 return -ENOMEM;
1944
1945 ntty_driver->owner = THIS_MODULE;
1946 ntty_driver->driver_name = NOZOMI_NAME_TTY;
1947 ntty_driver->name = "noz";
1948 ntty_driver->major = 0;
1949 ntty_driver->type = TTY_DRIVER_TYPE_SERIAL;
1950 ntty_driver->subtype = SERIAL_TYPE_NORMAL;
1951 ntty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1952 ntty_driver->init_termios = tty_std_termios;
1953 ntty_driver->init_termios.c_cflag = B115200 | CS8 | CREAD | \
1954 HUPCL | CLOCAL;
1955 ntty_driver->init_termios.c_ispeed = 115200;
1956 ntty_driver->init_termios.c_ospeed = 115200;
1957 tty_set_operations(ntty_driver, &tty_ops);
1958
1959 ret = tty_register_driver(ntty_driver);
1960 if (ret) {
1961 printk(KERN_ERR "Nozomi: failed to register ntty driver\n");
1962 goto free_tty;
1963 }
1964
1965 ret = pci_register_driver(&nozomi_driver);
1966 if (ret) {
1967 printk(KERN_ERR "Nozomi: can't register pci driver\n");
1968 goto unr_tty;
1969 }
1970
1971 return 0;
1972unr_tty:
1973 tty_unregister_driver(ntty_driver);
1974free_tty:
1975 put_tty_driver(ntty_driver);
1976 return ret;
1977}
1978
1979static __exit void nozomi_exit(void)
1980{
1981 printk(KERN_INFO "Unloading %s\n", DRIVER_DESC);
1982 pci_unregister_driver(&nozomi_driver);
1983 tty_unregister_driver(ntty_driver);
1984 put_tty_driver(ntty_driver);
1985}
1986
1987module_init(nozomi_init);
1988module_exit(nozomi_exit);
1989
1990module_param(debug, int, S_IRUGO | S_IWUSR);
1991
1992MODULE_LICENSE("Dual BSD/GPL");
1993MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 877e53dcb996..921c6d2bc8fc 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1163,7 +1163,7 @@ static struct acpi_driver sonypi_acpi_driver = {
1163}; 1163};
1164#endif 1164#endif
1165 1165
1166static int __devinit sonypi_create_input_devices(void) 1166static int __devinit sonypi_create_input_devices(struct platform_device *pdev)
1167{ 1167{
1168 struct input_dev *jog_dev; 1168 struct input_dev *jog_dev;
1169 struct input_dev *key_dev; 1169 struct input_dev *key_dev;
@@ -1177,6 +1177,7 @@ static int __devinit sonypi_create_input_devices(void)
1177 jog_dev->name = "Sony Vaio Jogdial"; 1177 jog_dev->name = "Sony Vaio Jogdial";
1178 jog_dev->id.bustype = BUS_ISA; 1178 jog_dev->id.bustype = BUS_ISA;
1179 jog_dev->id.vendor = PCI_VENDOR_ID_SONY; 1179 jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
1180 jog_dev->dev.parent = &pdev->dev;
1180 1181
1181 jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 1182 jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
1182 jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); 1183 jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE);
@@ -1191,6 +1192,7 @@ static int __devinit sonypi_create_input_devices(void)
1191 key_dev->name = "Sony Vaio Keys"; 1192 key_dev->name = "Sony Vaio Keys";
1192 key_dev->id.bustype = BUS_ISA; 1193 key_dev->id.bustype = BUS_ISA;
1193 key_dev->id.vendor = PCI_VENDOR_ID_SONY; 1194 key_dev->id.vendor = PCI_VENDOR_ID_SONY;
1195 key_dev->dev.parent = &pdev->dev;
1194 1196
1195 /* Initialize the Input Drivers: special keys */ 1197 /* Initialize the Input Drivers: special keys */
1196 key_dev->evbit[0] = BIT_MASK(EV_KEY); 1198 key_dev->evbit[0] = BIT_MASK(EV_KEY);
@@ -1385,7 +1387,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1385 1387
1386 if (useinput) { 1388 if (useinput) {
1387 1389
1388 error = sonypi_create_input_devices(); 1390 error = sonypi_create_input_devices(dev);
1389 if (error) { 1391 if (error) {
1390 printk(KERN_ERR 1392 printk(KERN_ERR
1391 "sonypi: failed to create input devices\n"); 1393 "sonypi: failed to create input devices\n");
@@ -1432,7 +1434,7 @@ static int __devexit sonypi_remove(struct platform_device *dev)
1432{ 1434{
1433 sonypi_disable(); 1435 sonypi_disable();
1434 1436
1435 synchronize_sched(); /* Allow sonypi interrupt to complete. */ 1437 synchronize_irq(sonypi_device.irq);
1436 flush_scheduled_work(); 1438 flush_scheduled_work();
1437 1439
1438 if (useinput) { 1440 if (useinput) {
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
deleted file mode 100644
index cef55c40654f..000000000000
--- a/drivers/char/tipar.c
+++ /dev/null
@@ -1,557 +0,0 @@
1/* Hey EMACS -*- linux-c -*-
2 *
3 * tipar - low level driver for handling a parallel link cable designed
4 * for Texas Instruments graphing calculators (http://lpg.ticalc.org).
5 * A part of the TiLP project.
6 *
7 * Copyright (C) 2000-2002, Romain Lievin <roms@lpg.ticalc.org>
8 * under the terms of the GNU General Public License.
9 *
10 * Various fixes & clean-up from the Linux Kernel Mailing List
11 * (Alan Cox, Richard B. Johnson, Christoph Hellwig).
12 */
13
14/* This driver should, in theory, work with any parallel port that has an
15 * appropriate low-level driver; all I/O is done through the parport
16 * abstraction layer.
17 *
18 * If this driver is built into the kernel, you can configure it using the
19 * kernel command-line. For example:
20 *
21 * tipar=timeout,delay (set timeout and delay)
22 *
23 * If the driver is loaded as a module, similar functionality is available
24 * using module parameters. The equivalent of the above commands would be:
25 *
26 * # insmod tipar timeout=15 delay=10
27 */
28
29/* COMPATIBILITY WITH OLD KERNELS
30 *
31 * Usually, parallel cables were bound to ports at
32 * particular I/O addresses, as follows:
33 *
34 * tipar0 0x378
35 * tipar1 0x278
36 * tipar2 0x3bc
37 *
38 *
39 * This driver, by default, binds tipar devices according to parport and
40 * the minor number.
41 *
42 */
43#undef DEBUG /* change to #define to get debugging
44 * output - for pr_debug() */
45#include <linux/module.h>
46#include <linux/types.h>
47#include <linux/errno.h>
48#include <linux/kernel.h>
49#include <linux/sched.h>
50#include <linux/delay.h>
51#include <linux/fcntl.h>
52#include <linux/fs.h>
53#include <linux/init.h>
54#include <asm/uaccess.h>
55#include <linux/ioport.h>
56#include <asm/io.h>
57#include <linux/bitops.h>
58#include <linux/parport.h> /* Our code depend on parport */
59#include <linux/device.h>
60
61/*
62 * TI definitions
63 */
64#include <linux/ticable.h>
65
66/*
67 * Version Information
68 */
69#define DRIVER_VERSION "1.19"
70#define DRIVER_AUTHOR "Romain Lievin <roms@lpg.ticalc.org>"
71#define DRIVER_DESC "Device driver for TI/PC parallel link cables"
72#define DRIVER_LICENSE "GPL"
73
74#define VERSION(ver,rel,seq) (((ver)<<16) | ((rel)<<8) | (seq))
75
76/* ----- global variables --------------------------------------------- */
77
78struct tipar_struct {
79 struct pardevice *dev; /* Parport device entry */
80};
81
82#define PP_NO 3
83static struct tipar_struct table[PP_NO];
84
85static int delay = IO_DELAY; /* inter-bit delay in microseconds */
86static int timeout = TIMAXTIME; /* timeout in tenth of seconds */
87
88static unsigned int tp_count; /* tipar count */
89static unsigned long opened; /* opened devices */
90
91static struct class *tipar_class;
92
93/* --- macros for parport access -------------------------------------- */
94
95#define r_dtr(x) (parport_read_data(table[(x)].dev->port))
96#define r_str(x) (parport_read_status(table[(x)].dev->port))
97#define w_ctr(x,y) (parport_write_control(table[(x)].dev->port, (y)))
98#define w_dtr(x,y) (parport_write_data(table[(x)].dev->port, (y)))
99
100/* --- setting states on the D-bus with the right timing: ------------- */
101
102static inline void
103outbyte(int value, int minor)
104{
105 w_dtr(minor, value);
106}
107
108static inline int
109inbyte(int minor)
110{
111 return (r_str(minor));
112}
113
114static inline void
115init_ti_parallel(int minor)
116{
117 outbyte(3, minor);
118}
119
120/* ----- global defines ----------------------------------------------- */
121
122#define START(x) { x = jiffies + (HZ * timeout) / 10; }
123#define WAIT(x) { \
124 if (time_before((x), jiffies)) return -1; \
125 if (need_resched()) schedule(); }
126
127/* ----- D-bus bit-banging functions ---------------------------------- */
128
129/* D-bus protocol (45kbit/s max):
130 1 0 0
131 _______ ______|______ __________|________ __________
132Red : ________ | ____ | ____
133 _ ____________|________ ______|__________ _____
134White: ________ | ______ | _______
135*/
136
137/* Try to transmit a byte on the specified port (-1 if error). */
138static int
139put_ti_parallel(int minor, unsigned char data)
140{
141 unsigned int bit;
142 unsigned long max;
143
144 for (bit = 0; bit < 8; bit++) {
145 if (data & 1) {
146 outbyte(2, minor);
147 START(max);
148 do {
149 WAIT(max);
150 } while (inbyte(minor) & 0x10);
151
152 outbyte(3, minor);
153 START(max);
154 do {
155 WAIT(max);
156 } while (!(inbyte(minor) & 0x10));
157 } else {
158 outbyte(1, minor);
159 START(max);
160 do {
161 WAIT(max);
162 } while (inbyte(minor) & 0x20);
163
164 outbyte(3, minor);
165 START(max);
166 do {
167 WAIT(max);
168 } while (!(inbyte(minor) & 0x20));
169 }
170
171 data >>= 1;
172 udelay(delay);
173
174 if (need_resched())
175 schedule();
176 }
177
178 return 0;
179}
180
181/* Receive a byte on the specified port or -1 if error. */
182static int
183get_ti_parallel(int minor)
184{
185 unsigned int bit;
186 unsigned char v, data = 0;
187 unsigned long max;
188
189 for (bit = 0; bit < 8; bit++) {
190 START(max);
191 do {
192 WAIT(max);
193 } while ((v = inbyte(minor) & 0x30) == 0x30);
194
195 if (v == 0x10) {
196 data = (data >> 1) | 0x80;
197 outbyte(1, minor);
198 START(max);
199 do {
200 WAIT(max);
201 } while (!(inbyte(minor) & 0x20));
202 outbyte(3, minor);
203 } else {
204 data = data >> 1;
205 outbyte(2, minor);
206 START(max);
207 do {
208 WAIT(max);
209 } while (!(inbyte(minor) & 0x10));
210 outbyte(3, minor);
211 }
212
213 udelay(delay);
214 if (need_resched())
215 schedule();
216 }
217
218 return (int) data;
219}
220
221/* Try to detect a parallel link cable on the specified port */
222static int
223probe_ti_parallel(int minor)
224{
225 int i;
226 int seq[] = { 0x00, 0x20, 0x10, 0x30 };
227 int data;
228
229 for (i = 3; i >= 0; i--) {
230 outbyte(3, minor);
231 outbyte(i, minor);
232 udelay(delay);
233 data = inbyte(minor) & 0x30;
234 pr_debug("tipar: Probing -> %i: 0x%02x 0x%02x\n", i,
235 data, seq[i]);
236 if (data != seq[i]) {
237 outbyte(3, minor);
238 return -1;
239 }
240 }
241
242 outbyte(3, minor);
243 return 0;
244}
245
246/* ----- kernel module functions--------------------------------------- */
247
248static int
249tipar_open(struct inode *inode, struct file *file)
250{
251 unsigned int minor = iminor(inode) - TIPAR_MINOR;
252
253 if (tp_count == 0 || minor > tp_count - 1)
254 return -ENXIO;
255
256 if (test_and_set_bit(minor, &opened))
257 return -EBUSY;
258
259 if (!table[minor].dev) {
260 printk(KERN_ERR "%s: NULL device for minor %u\n",
261 __FUNCTION__, minor);
262 return -ENXIO;
263 }
264 parport_claim_or_block(table[minor].dev);
265 init_ti_parallel(minor);
266 parport_release(table[minor].dev);
267
268 return nonseekable_open(inode, file);
269}
270
271static int
272tipar_close(struct inode *inode, struct file *file)
273{
274 unsigned int minor = iminor(inode) - TIPAR_MINOR;
275
276 if (minor > tp_count - 1)
277 return -ENXIO;
278
279 clear_bit(minor, &opened);
280
281 return 0;
282}
283
284static ssize_t
285tipar_write (struct file *file, const char __user *buf, size_t count,
286 loff_t * ppos)
287{
288 unsigned int minor = iminor(file->f_path.dentry->d_inode) - TIPAR_MINOR;
289 ssize_t n;
290
291 parport_claim_or_block(table[minor].dev);
292
293 for (n = 0; n < count; n++) {
294 unsigned char b;
295
296 if (get_user(b, buf + n)) {
297 n = -EFAULT;
298 goto out;
299 }
300
301 if (put_ti_parallel(minor, b) == -1) {
302 init_ti_parallel(minor);
303 n = -ETIMEDOUT;
304 goto out;
305 }
306 }
307 out:
308 parport_release(table[minor].dev);
309 return n;
310}
311
312static ssize_t
313tipar_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
314{
315 int b = 0;
316 unsigned int minor = iminor(file->f_path.dentry->d_inode) - TIPAR_MINOR;
317 ssize_t retval = 0;
318 ssize_t n = 0;
319
320 if (count == 0)
321 return 0;
322
323 parport_claim_or_block(table[minor].dev);
324
325 while (n < count) {
326 b = get_ti_parallel(minor);
327 if (b == -1) {
328 init_ti_parallel(minor);
329 retval = -ETIMEDOUT;
330 goto out;
331 } else {
332 if (put_user(b, buf + n)) {
333 retval = -EFAULT;
334 break;
335 } else
336 retval = ++n;
337 }
338
339 /* Non-blocking mode : try again ! */
340 if (file->f_flags & O_NONBLOCK) {
341 retval = -EAGAIN;
342 goto out;
343 }
344
345 /* Signal pending, try again ! */
346 if (signal_pending(current)) {
347 retval = -ERESTARTSYS;
348 goto out;
349 }
350
351 if (need_resched())
352 schedule();
353 }
354
355 out:
356 parport_release(table[minor].dev);
357 return retval;
358}
359
360static int
361tipar_ioctl(struct inode *inode, struct file *file,
362 unsigned int cmd, unsigned long arg)
363{
364 int retval = 0;
365
366 switch (cmd) {
367 case IOCTL_TIPAR_DELAY:
368 delay = (int)arg; //get_user(delay, &arg);
369 break;
370 case IOCTL_TIPAR_TIMEOUT:
371 if (arg != 0)
372 timeout = (int)arg;
373 else
374 retval = -EINVAL;
375 break;
376 default:
377 retval = -ENOTTY;
378 break;
379 }
380
381 return retval;
382}
383
384/* ----- kernel module registering ------------------------------------ */
385
386static const struct file_operations tipar_fops = {
387 .owner = THIS_MODULE,
388 .llseek = no_llseek,
389 .read = tipar_read,
390 .write = tipar_write,
391 .ioctl = tipar_ioctl,
392 .open = tipar_open,
393 .release = tipar_close,
394};
395
396/* --- initialisation code ------------------------------------- */
397
398#ifndef MODULE
399/* You must set these - there is no sane way to probe for this cable.
400 * You can use 'tipar=timeout,delay' to set these now. */
401static int __init
402tipar_setup(char *str)
403{
404 int ints[3];
405
406 str = get_options(str, ARRAY_SIZE(ints), ints);
407
408 if (ints[0] > 0) {
409 if (ints[1] != 0)
410 timeout = ints[1];
411 else
412 printk(KERN_WARNING "tipar: bad timeout value (0), "
413 "using default value instead");
414 if (ints[0] > 1) {
415 delay = ints[2];
416 }
417 }
418
419 return 1;
420}
421#endif
422
423/*
424 * Register our module into parport.
425 * Pass also 2 callbacks functions to parport: a pre-emptive function and an
426 * interrupt handler function (unused).
427 * Display a message such "tipar0: using parport0 (polling)".
428 */
429static int
430tipar_register(int nr, struct parport *port)
431{
432 int err = 0;
433
434 /* Register our module into parport */
435 table[nr].dev = parport_register_device(port, "tipar",
436 NULL, NULL, NULL, 0,
437 (void *) &table[nr]);
438
439 if (table[nr].dev == NULL) {
440 err = 1;
441 goto out;
442 }
443
444 device_create(tipar_class, port->dev, MKDEV(TIPAR_MAJOR,
445 TIPAR_MINOR + nr), "par%d", nr);
446
447 /* Display informations */
448 pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq ==
449 PARPORT_IRQ_NONE) ? "polling" : "interrupt-driven");
450
451 if (probe_ti_parallel(nr) != -1)
452 pr_info("tipar%d: link cable found\n", nr);
453 else
454 pr_info("tipar%d: link cable not found\n", nr);
455
456 err = 0;
457
458out:
459 return err;
460}
461
462static void
463tipar_attach(struct parport *port)
464{
465 if (tp_count == PP_NO) {
466 pr_info("tipar: ignoring parallel port (max. %d)\n", PP_NO);
467 return;
468 }
469
470 if (!tipar_register(tp_count, port))
471 tp_count++;
472}
473
474static void
475tipar_detach(struct parport *port)
476{
477 /* Nothing to do */
478}
479
480static struct parport_driver tipar_driver = {
481 .name = "tipar",
482 .attach = tipar_attach,
483 .detach = tipar_detach,
484};
485
486static int __init
487tipar_init_module(void)
488{
489 int err = 0;
490
491 pr_info("tipar: parallel link cable driver, version %s\n",
492 DRIVER_VERSION);
493
494 if (register_chrdev(TIPAR_MAJOR, "tipar", &tipar_fops)) {
495 printk(KERN_ERR "tipar: unable to get major %d\n", TIPAR_MAJOR);
496 err = -EIO;
497 goto out;
498 }
499
500 tipar_class = class_create(THIS_MODULE, "ticables");
501 if (IS_ERR(tipar_class)) {
502 err = PTR_ERR(tipar_class);
503 goto out_chrdev;
504 }
505 if (parport_register_driver(&tipar_driver)) {
506 printk(KERN_ERR "tipar: unable to register with parport\n");
507 err = -EIO;
508 goto out_class;
509 }
510
511 err = 0;
512 goto out;
513
514out_class:
515 class_destroy(tipar_class);
516
517out_chrdev:
518 unregister_chrdev(TIPAR_MAJOR, "tipar");
519out:
520 return err;
521}
522
523static void __exit
524tipar_cleanup_module(void)
525{
526 unsigned int i;
527
528 /* Unregistering module */
529 parport_unregister_driver(&tipar_driver);
530
531 unregister_chrdev(TIPAR_MAJOR, "tipar");
532
533 for (i = 0; i < PP_NO; i++) {
534 if (table[i].dev == NULL)
535 continue;
536 parport_unregister_device(table[i].dev);
537 device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i));
538 }
539 class_destroy(tipar_class);
540
541 pr_info("tipar: module unloaded\n");
542}
543
544/* --------------------------------------------------------------------- */
545
546__setup("tipar=", tipar_setup);
547module_init(tipar_init_module);
548module_exit(tipar_cleanup_module);
549
550MODULE_AUTHOR(DRIVER_AUTHOR);
551MODULE_DESCRIPTION(DRIVER_DESC);
552MODULE_LICENSE(DRIVER_LICENSE);
553
554module_param(timeout, int, 0);
555MODULE_PARM_DESC(timeout, "Timeout (default=1.5 seconds)");
556module_param(delay, int, 0);
557MODULE_PARM_DESC(delay, "Inter-bit delay (default=10 microseconds)");
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 39564b76d4a3..c88424a0c89b 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1046,12 +1046,6 @@ void tpm_remove_hardware(struct device *dev)
1046} 1046}
1047EXPORT_SYMBOL_GPL(tpm_remove_hardware); 1047EXPORT_SYMBOL_GPL(tpm_remove_hardware);
1048 1048
1049static u8 savestate[] = {
1050 0, 193, /* TPM_TAG_RQU_COMMAND */
1051 0, 0, 0, 10, /* blob length (in bytes) */
1052 0, 0, 0, 152 /* TPM_ORD_SaveState */
1053};
1054
1055/* 1049/*
1056 * We are about to suspend. Save the TPM state 1050 * We are about to suspend. Save the TPM state
1057 * so that it can be restored. 1051 * so that it can be restored.
@@ -1059,6 +1053,12 @@ static u8 savestate[] = {
1059int tpm_pm_suspend(struct device *dev, pm_message_t pm_state) 1053int tpm_pm_suspend(struct device *dev, pm_message_t pm_state)
1060{ 1054{
1061 struct tpm_chip *chip = dev_get_drvdata(dev); 1055 struct tpm_chip *chip = dev_get_drvdata(dev);
1056 u8 savestate[] = {
1057 0, 193, /* TPM_TAG_RQU_COMMAND */
1058 0, 0, 0, 10, /* blob length (in bytes) */
1059 0, 0, 0, 152 /* TPM_ORD_SaveState */
1060 };
1061
1062 if (chip == NULL) 1062 if (chip == NULL)
1063 return -ENODEV; 1063 return -ENODEV;
1064 1064
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index fd771a4d6d18..81503d94fecc 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -450,6 +450,11 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
450 goto out_err; 450 goto out_err;
451 } 451 }
452 452
453 if (request_locality(chip, 0) != 0) {
454 rc = -ENODEV;
455 goto out_err;
456 }
457
453 vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); 458 vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
454 459
455 /* Default timeouts */ 460 /* Default timeouts */
@@ -487,11 +492,6 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
487 if (intfcaps & TPM_INTF_DATA_AVAIL_INT) 492 if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
488 dev_dbg(dev, "\tData Avail Int Support\n"); 493 dev_dbg(dev, "\tData Avail Int Support\n");
489 494
490 if (request_locality(chip, 0) != 0) {
491 rc = -ENODEV;
492 goto out_err;
493 }
494
495 /* INTERRUPT Setup */ 495 /* INTERRUPT Setup */
496 init_waitqueue_head(&chip->vendor.read_queue); 496 init_waitqueue_head(&chip->vendor.read_queue);
497 init_waitqueue_head(&chip->vendor.int_queue); 497 init_waitqueue_head(&chip->vendor.int_queue);
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index 1bdd2bf4f37d..d4b6d64e858b 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -62,7 +62,7 @@ void tty_wait_until_sent(struct tty_struct * tty, long timeout)
62 if (!timeout) 62 if (!timeout)
63 timeout = MAX_SCHEDULE_TIMEOUT; 63 timeout = MAX_SCHEDULE_TIMEOUT;
64 if (wait_event_interruptible_timeout(tty->write_wait, 64 if (wait_event_interruptible_timeout(tty->write_wait,
65 !tty->driver->chars_in_buffer(tty), timeout)) 65 !tty->driver->chars_in_buffer(tty), timeout) < 0)
66 return; 66 return;
67 if (tty->driver->wait_until_sent) 67 if (tty->driver->wait_until_sent)
68 tty->driver->wait_until_sent(tty, timeout); 68 tty->driver->wait_until_sent(tty, timeout);
@@ -365,6 +365,25 @@ void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old)
365EXPORT_SYMBOL(tty_termios_copy_hw); 365EXPORT_SYMBOL(tty_termios_copy_hw);
366 366
367/** 367/**
368 * tty_termios_hw_change - check for setting change
369 * @a: termios
370 * @b: termios to compare
371 *
372 * Check if any of the bits that affect a dumb device have changed
373 * between the two termios structures, or a speed change is needed.
374 */
375
376int tty_termios_hw_change(struct ktermios *a, struct ktermios *b)
377{
378 if (a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed)
379 return 1;
380 if ((a->c_cflag ^ b->c_cflag) & ~(HUPCL | CREAD | CLOCAL))
381 return 1;
382 return 0;
383}
384EXPORT_SYMBOL(tty_termios_hw_change);
385
386/**
368 * change_termios - update termios values 387 * change_termios - update termios values
369 * @tty: tty to update 388 * @tty: tty to update
370 * @new_termios: desired new value 389 * @new_termios: desired new value