aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio
diff options
context:
space:
mode:
author <jgarzik@pretzel.yyz.us>2005-06-04 00:40:40 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-06-04 00:40:40 -0400
commitae20ea8525a80a863f70d332cf47b71bd9f54c1f (patch)
tree9d3cedeb65db521a8436b545bd91641549a18d24 /drivers/input/serio
parentf497ba735fc9ff4e35a19641143708b3be1c7061 (diff)
parent8be3de3fd8469154a2b3e18a4712032dac5b4a53 (diff)
Automatic merge of /spare/repo/linux-2.6/.git branch HEAD
Diffstat (limited to 'drivers/input/serio')
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h32
-rw-r--r--drivers/input/serio/i8042.c50
-rw-r--r--drivers/input/serio/serio.c25
-rw-r--r--drivers/input/serio/serport.c98
4 files changed, 142 insertions, 63 deletions
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index f64867808fea..0487ecbb8a49 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -88,9 +88,11 @@ static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
88}; 88};
89 89
90/* 90/*
91 * Some Fujitsu notebooks are ahving trouble with touhcpads if 91 * Some Fujitsu notebooks are having trouble with touchpads if
92 * active multiplexing mode is activated. Luckily they don't have 92 * active multiplexing mode is activated. Luckily they don't have
93 * external PS/2 ports so we can safely disable it. 93 * external PS/2 ports so we can safely disable it.
94 * ... apparently some Toshibas don't like MUX mode either and
95 * die horrible death on reboot.
94 */ 96 */
95static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = { 97static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
96 { 98 {
@@ -115,12 +117,26 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
115 }, 117 },
116 }, 118 },
117 { 119 {
120 .ident = "Fujitsu Lifebook S6230",
121 .matches = {
122 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
123 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
124 },
125 },
126 {
118 .ident = "Fujitsu T70H", 127 .ident = "Fujitsu T70H",
119 .matches = { 128 .matches = {
120 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), 129 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
121 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"), 130 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
122 }, 131 },
123 }, 132 },
133 {
134 .ident = "Toshiba P10",
135 .matches = {
136 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
137 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
138 },
139 },
124 { } 140 { }
125}; 141};
126 142
@@ -215,11 +231,15 @@ static struct pnp_driver i8042_pnp_aux_driver = {
215 231
216static void i8042_pnp_exit(void) 232static void i8042_pnp_exit(void)
217{ 233{
218 if (i8042_pnp_kbd_registered) 234 if (i8042_pnp_kbd_registered) {
235 i8042_pnp_kbd_registered = 0;
219 pnp_unregister_driver(&i8042_pnp_kbd_driver); 236 pnp_unregister_driver(&i8042_pnp_kbd_driver);
237 }
220 238
221 if (i8042_pnp_aux_registered) 239 if (i8042_pnp_aux_registered) {
240 i8042_pnp_aux_registered = 0;
222 pnp_unregister_driver(&i8042_pnp_aux_driver); 241 pnp_unregister_driver(&i8042_pnp_aux_driver);
242 }
223} 243}
224 244
225static int i8042_pnp_init(void) 245static int i8042_pnp_init(void)
@@ -227,7 +247,7 @@ static int i8042_pnp_init(void)
227 int result_kbd, result_aux; 247 int result_kbd, result_aux;
228 248
229 if (i8042_nopnp) { 249 if (i8042_nopnp) {
230 printk("i8042: PNP detection disabled\n"); 250 printk(KERN_INFO "i8042: PNP detection disabled\n");
231 return 0; 251 return 0;
232 } 252 }
233 253
@@ -241,7 +261,7 @@ static int i8042_pnp_init(void)
241#if defined(__ia64__) 261#if defined(__ia64__)
242 return -ENODEV; 262 return -ENODEV;
243#else 263#else
244 printk(KERN_WARNING "PNP: No PS/2 controller found. Probing ports directly.\n"); 264 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
245 return 0; 265 return 0;
246#endif 266#endif
247 } 267 }
@@ -265,7 +285,7 @@ static int i8042_pnp_init(void)
265 i8042_pnp_kbd_irq = i8042_kbd_irq; 285 i8042_pnp_kbd_irq = i8042_kbd_irq;
266 } 286 }
267 287
268 if (result_aux > 0 && !i8042_pnp_aux_irq) { 288 if (!i8042_pnp_aux_irq) {
269 printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %#x\n", i8042_aux_irq); 289 printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %#x\n", i8042_aux_irq);
270 i8042_pnp_aux_irq = i8042_aux_irq; 290 i8042_pnp_aux_irq = i8042_aux_irq;
271 } 291 }
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 8e63e464d361..5900de3c3f4f 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -698,6 +698,26 @@ static void i8042_timer_func(unsigned long data)
698 i8042_interrupt(0, NULL, NULL); 698 i8042_interrupt(0, NULL, NULL);
699} 699}
700 700
701static int i8042_ctl_test(void)
702{
703 unsigned char param;
704
705 if (!i8042_reset)
706 return 0;
707
708 if (i8042_command(&param, I8042_CMD_CTL_TEST)) {
709 printk(KERN_ERR "i8042.c: i8042 controller self test timeout.\n");
710 return -1;
711 }
712
713 if (param != I8042_RET_CTL_TEST) {
714 printk(KERN_ERR "i8042.c: i8042 controller selftest failed. (%#x != %#x)\n",
715 param, I8042_RET_CTL_TEST);
716 return -1;
717 }
718
719 return 0;
720}
701 721
702/* 722/*
703 * i8042_controller init initializes the i8042 controller, and, 723 * i8042_controller init initializes the i8042 controller, and,
@@ -719,21 +739,8 @@ static int i8042_controller_init(void)
719 return -1; 739 return -1;
720 } 740 }
721 741
722 if (i8042_reset) { 742 if (i8042_ctl_test())
723 743 return -1;
724 unsigned char param;
725
726 if (i8042_command(&param, I8042_CMD_CTL_TEST)) {
727 printk(KERN_ERR "i8042.c: i8042 controller self test timeout.\n");
728 return -1;
729 }
730
731 if (param != I8042_RET_CTL_TEST) {
732 printk(KERN_ERR "i8042.c: i8042 controller selftest failed. (%#x != %#x)\n",
733 param, I8042_RET_CTL_TEST);
734 return -1;
735 }
736 }
737 744
738/* 745/*
739 * Save the CTR for restoral on unload / reboot. 746 * Save the CTR for restoral on unload / reboot.
@@ -802,15 +809,11 @@ static int i8042_controller_init(void)
802 */ 809 */
803static void i8042_controller_reset(void) 810static void i8042_controller_reset(void)
804{ 811{
805 unsigned char param;
806
807/* 812/*
808 * Reset the controller if requested. 813 * Reset the controller if requested.
809 */ 814 */
810 815
811 if (i8042_reset) 816 i8042_ctl_test();
812 if (i8042_command(&param, I8042_CMD_CTL_TEST))
813 printk(KERN_ERR "i8042.c: i8042 controller reset timeout.\n");
814 817
815/* 818/*
816 * Disable MUX mode if present. 819 * Disable MUX mode if present.
@@ -922,8 +925,11 @@ static int i8042_resume(struct device *dev, u32 level)
922 if (level != RESUME_ENABLE) 925 if (level != RESUME_ENABLE)
923 return 0; 926 return 0;
924 927
925 if (i8042_controller_init()) { 928 if (i8042_ctl_test())
926 printk(KERN_ERR "i8042: resume failed\n"); 929 return -1;
930
931 if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) {
932 printk(KERN_ERR "i8042: Can't write CTR\n");
927 return -1; 933 return -1;
928 } 934 }
929 935
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 3313e2daeab0..0beacb77ee18 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -388,6 +388,24 @@ static ssize_t serio_show_id_extra(struct device *dev, char *buf)
388 return sprintf(buf, "%02x\n", serio->id.extra); 388 return sprintf(buf, "%02x\n", serio->id.extra);
389} 389}
390 390
391static DEVICE_ATTR(type, S_IRUGO, serio_show_id_type, NULL);
392static DEVICE_ATTR(proto, S_IRUGO, serio_show_id_proto, NULL);
393static DEVICE_ATTR(id, S_IRUGO, serio_show_id_id, NULL);
394static DEVICE_ATTR(extra, S_IRUGO, serio_show_id_extra, NULL);
395
396static struct attribute *serio_device_id_attrs[] = {
397 &dev_attr_type.attr,
398 &dev_attr_proto.attr,
399 &dev_attr_id.attr,
400 &dev_attr_extra.attr,
401 NULL
402};
403
404static struct attribute_group serio_id_attr_group = {
405 .name = "id",
406 .attrs = serio_device_id_attrs,
407};
408
391static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count) 409static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count)
392{ 410{
393 struct serio *serio = to_serio_port(dev); 411 struct serio *serio = to_serio_port(dev);
@@ -444,10 +462,6 @@ static ssize_t serio_set_bind_mode(struct device *dev, const char *buf, size_t c
444 462
445static struct device_attribute serio_device_attrs[] = { 463static struct device_attribute serio_device_attrs[] = {
446 __ATTR(description, S_IRUGO, serio_show_description, NULL), 464 __ATTR(description, S_IRUGO, serio_show_description, NULL),
447 __ATTR(id_type, S_IRUGO, serio_show_id_type, NULL),
448 __ATTR(id_proto, S_IRUGO, serio_show_id_proto, NULL),
449 __ATTR(id_id, S_IRUGO, serio_show_id_id, NULL),
450 __ATTR(id_extra, S_IRUGO, serio_show_id_extra, NULL),
451 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver), 465 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver),
452 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode), 466 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode),
453 __ATTR_NULL 467 __ATTR_NULL
@@ -498,6 +512,7 @@ static void serio_add_port(struct serio *serio)
498 if (serio->start) 512 if (serio->start)
499 serio->start(serio); 513 serio->start(serio);
500 device_add(&serio->dev); 514 device_add(&serio->dev);
515 sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
501 serio->registered = 1; 516 serio->registered = 1;
502} 517}
503 518
@@ -526,6 +541,7 @@ static void serio_destroy_port(struct serio *serio)
526 } 541 }
527 542
528 if (serio->registered) { 543 if (serio->registered) {
544 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
529 device_del(&serio->dev); 545 device_del(&serio->dev);
530 list_del_init(&serio->node); 546 list_del_init(&serio->node);
531 serio->registered = 0; 547 serio->registered = 0;
@@ -779,7 +795,6 @@ static int serio_resume(struct device *dev)
779 struct serio *serio = to_serio_port(dev); 795 struct serio *serio = to_serio_port(dev);
780 796
781 if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) { 797 if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) {
782 serio_disconnect_port(serio);
783 /* 798 /*
784 * Driver re-probing can take a while, so better let kseriod 799 * Driver re-probing can take a while, so better let kseriod
785 * deal with it. 800 * deal with it.
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 22f73683952b..f6b85222ba3d 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -27,11 +27,15 @@ MODULE_LICENSE("GPL");
27MODULE_ALIAS_LDISC(N_MOUSE); 27MODULE_ALIAS_LDISC(N_MOUSE);
28 28
29#define SERPORT_BUSY 1 29#define SERPORT_BUSY 1
30#define SERPORT_ACTIVE 2
31#define SERPORT_DEAD 3
30 32
31struct serport { 33struct serport {
32 struct tty_struct *tty; 34 struct tty_struct *tty;
33 wait_queue_head_t wait; 35 wait_queue_head_t wait;
34 struct serio *serio; 36 struct serio *serio;
37 struct serio_device_id id;
38 spinlock_t lock;
35 unsigned long flags; 39 unsigned long flags;
36}; 40};
37 41
@@ -45,11 +49,29 @@ static int serport_serio_write(struct serio *serio, unsigned char data)
45 return -(serport->tty->driver->write(serport->tty, &data, 1) != 1); 49 return -(serport->tty->driver->write(serport->tty, &data, 1) != 1);
46} 50}
47 51
52static int serport_serio_open(struct serio *serio)
53{
54 struct serport *serport = serio->port_data;
55 unsigned long flags;
56
57 spin_lock_irqsave(&serport->lock, flags);
58 set_bit(SERPORT_ACTIVE, &serport->flags);
59 spin_unlock_irqrestore(&serport->lock, flags);
60
61 return 0;
62}
63
64
48static void serport_serio_close(struct serio *serio) 65static void serport_serio_close(struct serio *serio)
49{ 66{
50 struct serport *serport = serio->port_data; 67 struct serport *serport = serio->port_data;
68 unsigned long flags;
69
70 spin_lock_irqsave(&serport->lock, flags);
71 clear_bit(SERPORT_ACTIVE, &serport->flags);
72 set_bit(SERPORT_DEAD, &serport->flags);
73 spin_unlock_irqrestore(&serport->lock, flags);
51 74
52 serport->serio->id.type = 0;
53 wake_up_interruptible(&serport->wait); 75 wake_up_interruptible(&serport->wait);
54} 76}
55 77
@@ -61,36 +83,21 @@ static void serport_serio_close(struct serio *serio)
61static int serport_ldisc_open(struct tty_struct *tty) 83static int serport_ldisc_open(struct tty_struct *tty)
62{ 84{
63 struct serport *serport; 85 struct serport *serport;
64 struct serio *serio;
65 char name[64];
66 86
67 if (!capable(CAP_SYS_ADMIN)) 87 if (!capable(CAP_SYS_ADMIN))
68 return -EPERM; 88 return -EPERM;
69 89
70 serport = kmalloc(sizeof(struct serport), GFP_KERNEL); 90 serport = kcalloc(1, sizeof(struct serport), GFP_KERNEL);
71 serio = kmalloc(sizeof(struct serio), GFP_KERNEL); 91 if (!serport)
72 if (unlikely(!serport || !serio)) {
73 kfree(serport);
74 kfree(serio);
75 return -ENOMEM; 92 return -ENOMEM;
76 }
77 93
78 memset(serport, 0, sizeof(struct serport));
79 serport->serio = serio;
80 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
81 serport->tty = tty; 94 serport->tty = tty;
82 tty->disc_data = serport; 95 spin_lock_init(&serport->lock);
83
84 memset(serio, 0, sizeof(struct serio));
85 strlcpy(serio->name, "Serial port", sizeof(serio->name));
86 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty, name));
87 serio->id.type = SERIO_RS232;
88 serio->write = serport_serio_write;
89 serio->close = serport_serio_close;
90 serio->port_data = serport;
91
92 init_waitqueue_head(&serport->wait); 96 init_waitqueue_head(&serport->wait);
93 97
98 tty->disc_data = serport;
99 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
100
94 return 0; 101 return 0;
95} 102}
96 103
@@ -100,7 +107,8 @@ static int serport_ldisc_open(struct tty_struct *tty)
100 107
101static void serport_ldisc_close(struct tty_struct *tty) 108static void serport_ldisc_close(struct tty_struct *tty)
102{ 109{
103 struct serport *serport = (struct serport*) tty->disc_data; 110 struct serport *serport = (struct serport *) tty->disc_data;
111
104 kfree(serport); 112 kfree(serport);
105} 113}
106 114
@@ -116,9 +124,19 @@ static void serport_ldisc_close(struct tty_struct *tty)
116static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 124static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
117{ 125{
118 struct serport *serport = (struct serport*) tty->disc_data; 126 struct serport *serport = (struct serport*) tty->disc_data;
127 unsigned long flags;
119 int i; 128 int i;
129
130 spin_lock_irqsave(&serport->lock, flags);
131
132 if (!test_bit(SERPORT_ACTIVE, &serport->flags))
133 goto out;
134
120 for (i = 0; i < count; i++) 135 for (i = 0; i < count; i++)
121 serio_interrupt(serport->serio, cp[i], 0, NULL); 136 serio_interrupt(serport->serio, cp[i], 0, NULL);
137
138out:
139 spin_unlock_irqrestore(&serport->lock, flags);
122} 140}
123 141
124/* 142/*
@@ -141,16 +159,33 @@ static int serport_ldisc_room(struct tty_struct *tty)
141static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char __user * buf, size_t nr) 159static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char __user * buf, size_t nr)
142{ 160{
143 struct serport *serport = (struct serport*) tty->disc_data; 161 struct serport *serport = (struct serport*) tty->disc_data;
162 struct serio *serio;
144 char name[64]; 163 char name[64];
145 164
146 if (test_and_set_bit(SERPORT_BUSY, &serport->flags)) 165 if (test_and_set_bit(SERPORT_BUSY, &serport->flags))
147 return -EBUSY; 166 return -EBUSY;
148 167
168 serport->serio = serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL);
169 if (!serio)
170 return -ENOMEM;
171
172 strlcpy(serio->name, "Serial port", sizeof(serio->name));
173 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty, name));
174 serio->id = serport->id;
175 serio->id.type = SERIO_RS232;
176 serio->write = serport_serio_write;
177 serio->open = serport_serio_open;
178 serio->close = serport_serio_close;
179 serio->port_data = serport;
180
149 serio_register_port(serport->serio); 181 serio_register_port(serport->serio);
150 printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name)); 182 printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name));
151 wait_event_interruptible(serport->wait, !serport->serio->id.type); 183
184 wait_event_interruptible(serport->wait, test_bit(SERPORT_DEAD, &serport->flags));
152 serio_unregister_port(serport->serio); 185 serio_unregister_port(serport->serio);
186 serport->serio = NULL;
153 187
188 clear_bit(SERPORT_DEAD, &serport->flags);
154 clear_bit(SERPORT_BUSY, &serport->flags); 189 clear_bit(SERPORT_BUSY, &serport->flags);
155 190
156 return 0; 191 return 0;
@@ -163,16 +198,15 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
163static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg) 198static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg)
164{ 199{
165 struct serport *serport = (struct serport*) tty->disc_data; 200 struct serport *serport = (struct serport*) tty->disc_data;
166 struct serio *serio = serport->serio;
167 unsigned long type; 201 unsigned long type;
168 202
169 if (cmd == SPIOCSTYPE) { 203 if (cmd == SPIOCSTYPE) {
170 if (get_user(type, (unsigned long __user *) arg)) 204 if (get_user(type, (unsigned long __user *) arg))
171 return -EFAULT; 205 return -EFAULT;
172 206
173 serio->id.proto = type & 0x000000ff; 207 serport->id.proto = type & 0x000000ff;
174 serio->id.id = (type & 0x0000ff00) >> 8; 208 serport->id.id = (type & 0x0000ff00) >> 8;
175 serio->id.extra = (type & 0x00ff0000) >> 16; 209 serport->id.extra = (type & 0x00ff0000) >> 16;
176 210
177 return 0; 211 return 0;
178 } 212 }
@@ -182,9 +216,13 @@ static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsi
182 216
183static void serport_ldisc_write_wakeup(struct tty_struct * tty) 217static void serport_ldisc_write_wakeup(struct tty_struct * tty)
184{ 218{
185 struct serport *sp = (struct serport *) tty->disc_data; 219 struct serport *serport = (struct serport *) tty->disc_data;
220 unsigned long flags;
186 221
187 serio_drv_write_wakeup(sp->serio); 222 spin_lock_irqsave(&serport->lock, flags);
223 if (test_bit(SERPORT_ACTIVE, &serport->flags))
224 serio_drv_write_wakeup(serport->serio);
225 spin_unlock_irqrestore(&serport->lock, flags);
188} 226}
189 227
190/* 228/*