diff options
Diffstat (limited to 'drivers/input/serio')
| -rw-r--r-- | drivers/input/serio/ams_delta_serio.c | 1 | ||||
| -rw-r--r-- | drivers/input/serio/ct82c710.c | 8 | ||||
| -rw-r--r-- | drivers/input/serio/hil_mlc.c | 5 | ||||
| -rw-r--r-- | drivers/input/serio/hp_sdc_mlc.c | 18 | ||||
| -rw-r--r-- | drivers/input/serio/i8042-x86ia64io.h | 37 | ||||
| -rw-r--r-- | drivers/input/serio/i8042.c | 92 | ||||
| -rw-r--r-- | drivers/input/serio/i8042.h | 14 | ||||
| -rw-r--r-- | drivers/input/serio/ps2mult.c | 2 | ||||
| -rw-r--r-- | drivers/input/serio/serio.c | 155 |
9 files changed, 157 insertions, 175 deletions
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 8f1770e1e08b..ebe955325677 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c | |||
| @@ -172,6 +172,5 @@ static void __exit ams_delta_serio_exit(void) | |||
| 172 | free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); | 172 | free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); |
| 173 | gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK); | 173 | gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK); |
| 174 | gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA); | 174 | gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA); |
| 175 | kfree(ams_delta_serio); | ||
| 176 | } | 175 | } |
| 177 | module_exit(ams_delta_serio_exit); | 176 | module_exit(ams_delta_serio_exit); |
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c index 4a3084695c00..448c7724beb9 100644 --- a/drivers/input/serio/ct82c710.c +++ b/drivers/input/serio/ct82c710.c | |||
| @@ -191,6 +191,9 @@ static int __devinit ct82c710_probe(struct platform_device *dev) | |||
| 191 | 191 | ||
| 192 | serio_register_port(ct82c710_port); | 192 | serio_register_port(ct82c710_port); |
| 193 | 193 | ||
| 194 | printk(KERN_INFO "serio: C&T 82c710 mouse port at %#llx irq %d\n", | ||
| 195 | (unsigned long long)CT82C710_DATA, CT82C710_IRQ); | ||
| 196 | |||
| 194 | return 0; | 197 | return 0; |
| 195 | } | 198 | } |
| 196 | 199 | ||
| @@ -237,11 +240,6 @@ static int __init ct82c710_init(void) | |||
| 237 | if (error) | 240 | if (error) |
| 238 | goto err_free_device; | 241 | goto err_free_device; |
| 239 | 242 | ||
| 240 | serio_register_port(ct82c710_port); | ||
| 241 | |||
| 242 | printk(KERN_INFO "serio: C&T 82c710 mouse port at %#llx irq %d\n", | ||
| 243 | (unsigned long long)CT82C710_DATA, CT82C710_IRQ); | ||
| 244 | |||
| 245 | return 0; | 243 | return 0; |
| 246 | 244 | ||
| 247 | err_free_device: | 245 | err_free_device: |
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c index e5624d8f1709..bfd3865d886b 100644 --- a/drivers/input/serio/hil_mlc.c +++ b/drivers/input/serio/hil_mlc.c | |||
| @@ -932,6 +932,11 @@ int hil_mlc_register(hil_mlc *mlc) | |||
| 932 | hil_mlc_copy_di_scratch(mlc, i); | 932 | hil_mlc_copy_di_scratch(mlc, i); |
| 933 | mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL); | 933 | mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL); |
| 934 | mlc->serio[i] = mlc_serio; | 934 | mlc->serio[i] = mlc_serio; |
| 935 | if (!mlc->serio[i]) { | ||
| 936 | for (; i >= 0; i--) | ||
| 937 | kfree(mlc->serio[i]); | ||
| 938 | return -ENOMEM; | ||
| 939 | } | ||
| 935 | snprintf(mlc_serio->name, sizeof(mlc_serio->name)-1, "HIL_SERIO%d", i); | 940 | snprintf(mlc_serio->name, sizeof(mlc_serio->name)-1, "HIL_SERIO%d", i); |
| 936 | snprintf(mlc_serio->phys, sizeof(mlc_serio->phys)-1, "HIL%d", i); | 941 | snprintf(mlc_serio->phys, sizeof(mlc_serio->phys)-1, "HIL%d", i); |
| 937 | mlc_serio->id = hil_mlc_serio_id; | 942 | mlc_serio->id = hil_mlc_serio_id; |
diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c index 7d2b820ef58d..d50f0678bf47 100644 --- a/drivers/input/serio/hp_sdc_mlc.c +++ b/drivers/input/serio/hp_sdc_mlc.c | |||
| @@ -305,6 +305,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc) | |||
| 305 | static int __init hp_sdc_mlc_init(void) | 305 | static int __init hp_sdc_mlc_init(void) |
| 306 | { | 306 | { |
| 307 | hil_mlc *mlc = &hp_sdc_mlc; | 307 | hil_mlc *mlc = &hp_sdc_mlc; |
| 308 | int err; | ||
| 308 | 309 | ||
| 309 | #ifdef __mc68000__ | 310 | #ifdef __mc68000__ |
| 310 | if (!MACH_IS_HP300) | 311 | if (!MACH_IS_HP300) |
| @@ -323,22 +324,21 @@ static int __init hp_sdc_mlc_init(void) | |||
| 323 | mlc->out = &hp_sdc_mlc_out; | 324 | mlc->out = &hp_sdc_mlc_out; |
| 324 | mlc->priv = &hp_sdc_mlc_priv; | 325 | mlc->priv = &hp_sdc_mlc_priv; |
| 325 | 326 | ||
| 326 | if (hil_mlc_register(mlc)) { | 327 | err = hil_mlc_register(mlc); |
| 328 | if (err) { | ||
| 327 | printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n"); | 329 | printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n"); |
| 328 | goto err0; | 330 | return err; |
| 329 | } | 331 | } |
| 330 | 332 | ||
| 331 | if (hp_sdc_request_hil_irq(&hp_sdc_mlc_isr)) { | 333 | if (hp_sdc_request_hil_irq(&hp_sdc_mlc_isr)) { |
| 332 | printk(KERN_WARNING PREFIX "Request for raw HIL ISR hook denied\n"); | 334 | printk(KERN_WARNING PREFIX "Request for raw HIL ISR hook denied\n"); |
| 333 | goto err1; | 335 | if (hil_mlc_unregister(mlc)) |
| 336 | printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" | ||
| 337 | "This is bad. Could cause an oops.\n"); | ||
| 338 | return -EBUSY; | ||
| 334 | } | 339 | } |
| 340 | |||
| 335 | return 0; | 341 | return 0; |
| 336 | err1: | ||
| 337 | if (hil_mlc_unregister(mlc)) | ||
| 338 | printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" | ||
| 339 | "This is bad. Could cause an oops.\n"); | ||
| 340 | err0: | ||
| 341 | return -EBUSY; | ||
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | static void __exit hp_sdc_mlc_exit(void) | 344 | static void __exit hp_sdc_mlc_exit(void) |
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index a5475b577086..5ae0fc4578fe 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h | |||
| @@ -553,6 +553,13 @@ static const struct dmi_system_id __initconst i8042_dmi_laptop_table[] = { | |||
| 553 | */ | 553 | */ |
| 554 | static const struct dmi_system_id __initconst i8042_dmi_dritek_table[] = { | 554 | static const struct dmi_system_id __initconst i8042_dmi_dritek_table[] = { |
| 555 | { | 555 | { |
| 556 | /* Acer Aspire 5100 */ | ||
| 557 | .matches = { | ||
| 558 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
| 559 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"), | ||
| 560 | }, | ||
| 561 | }, | ||
| 562 | { | ||
| 556 | /* Acer Aspire 5610 */ | 563 | /* Acer Aspire 5610 */ |
| 557 | .matches = { | 564 | .matches = { |
| 558 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | 565 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| @@ -752,7 +759,7 @@ static int __init i8042_pnp_init(void) | |||
| 752 | #endif | 759 | #endif |
| 753 | 760 | ||
| 754 | if (i8042_nopnp) { | 761 | if (i8042_nopnp) { |
| 755 | printk(KERN_INFO "i8042: PNP detection disabled\n"); | 762 | pr_info("PNP detection disabled\n"); |
| 756 | return 0; | 763 | return 0; |
| 757 | } | 764 | } |
| 758 | 765 | ||
| @@ -769,7 +776,7 @@ static int __init i8042_pnp_init(void) | |||
| 769 | #if defined(__ia64__) | 776 | #if defined(__ia64__) |
| 770 | return -ENODEV; | 777 | return -ENODEV; |
| 771 | #else | 778 | #else |
| 772 | printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n"); | 779 | pr_info("PNP: No PS/2 controller found. Probing ports directly.\n"); |
| 773 | return 0; | 780 | return 0; |
| 774 | #endif | 781 | #endif |
| 775 | } | 782 | } |
| @@ -781,7 +788,7 @@ static int __init i8042_pnp_init(void) | |||
| 781 | snprintf(aux_irq_str, sizeof(aux_irq_str), | 788 | snprintf(aux_irq_str, sizeof(aux_irq_str), |
| 782 | "%d", i8042_pnp_aux_irq); | 789 | "%d", i8042_pnp_aux_irq); |
| 783 | 790 | ||
| 784 | printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n", | 791 | pr_info("PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n", |
| 785 | i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "", | 792 | i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "", |
| 786 | i8042_pnp_aux_name, | 793 | i8042_pnp_aux_name, |
| 787 | i8042_pnp_data_reg, i8042_pnp_command_reg, | 794 | i8042_pnp_data_reg, i8042_pnp_command_reg, |
| @@ -798,9 +805,7 @@ static int __init i8042_pnp_init(void) | |||
| 798 | if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) && | 805 | if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) && |
| 799 | i8042_pnp_data_reg != i8042_data_reg) || | 806 | i8042_pnp_data_reg != i8042_data_reg) || |
| 800 | !i8042_pnp_data_reg) { | 807 | !i8042_pnp_data_reg) { |
| 801 | printk(KERN_WARNING | 808 | pr_warn("PNP: PS/2 controller has invalid data port %#x; using default %#x\n", |
| 802 | "PNP: PS/2 controller has invalid data port %#x; " | ||
| 803 | "using default %#x\n", | ||
| 804 | i8042_pnp_data_reg, i8042_data_reg); | 809 | i8042_pnp_data_reg, i8042_data_reg); |
| 805 | i8042_pnp_data_reg = i8042_data_reg; | 810 | i8042_pnp_data_reg = i8042_data_reg; |
| 806 | pnp_data_busted = true; | 811 | pnp_data_busted = true; |
| @@ -809,33 +814,27 @@ static int __init i8042_pnp_init(void) | |||
| 809 | if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) && | 814 | if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) && |
| 810 | i8042_pnp_command_reg != i8042_command_reg) || | 815 | i8042_pnp_command_reg != i8042_command_reg) || |
| 811 | !i8042_pnp_command_reg) { | 816 | !i8042_pnp_command_reg) { |
| 812 | printk(KERN_WARNING | 817 | pr_warn("PNP: PS/2 controller has invalid command port %#x; using default %#x\n", |
| 813 | "PNP: PS/2 controller has invalid command port %#x; " | ||
| 814 | "using default %#x\n", | ||
| 815 | i8042_pnp_command_reg, i8042_command_reg); | 818 | i8042_pnp_command_reg, i8042_command_reg); |
| 816 | i8042_pnp_command_reg = i8042_command_reg; | 819 | i8042_pnp_command_reg = i8042_command_reg; |
| 817 | pnp_data_busted = true; | 820 | pnp_data_busted = true; |
| 818 | } | 821 | } |
| 819 | 822 | ||
| 820 | if (!i8042_nokbd && !i8042_pnp_kbd_irq) { | 823 | if (!i8042_nokbd && !i8042_pnp_kbd_irq) { |
| 821 | printk(KERN_WARNING | 824 | pr_warn("PNP: PS/2 controller doesn't have KBD irq; using default %d\n", |
| 822 | "PNP: PS/2 controller doesn't have KBD irq; " | 825 | i8042_kbd_irq); |
| 823 | "using default %d\n", i8042_kbd_irq); | ||
| 824 | i8042_pnp_kbd_irq = i8042_kbd_irq; | 826 | i8042_pnp_kbd_irq = i8042_kbd_irq; |
| 825 | pnp_data_busted = true; | 827 | pnp_data_busted = true; |
| 826 | } | 828 | } |
| 827 | 829 | ||
| 828 | if (!i8042_noaux && !i8042_pnp_aux_irq) { | 830 | if (!i8042_noaux && !i8042_pnp_aux_irq) { |
| 829 | if (!pnp_data_busted && i8042_pnp_kbd_irq) { | 831 | if (!pnp_data_busted && i8042_pnp_kbd_irq) { |
| 830 | printk(KERN_WARNING | 832 | pr_warn("PNP: PS/2 appears to have AUX port disabled, " |
| 831 | "PNP: PS/2 appears to have AUX port disabled, " | 833 | "if this is incorrect please boot with i8042.nopnp\n"); |
| 832 | "if this is incorrect please boot with " | ||
| 833 | "i8042.nopnp\n"); | ||
| 834 | i8042_noaux = true; | 834 | i8042_noaux = true; |
| 835 | } else { | 835 | } else { |
| 836 | printk(KERN_WARNING | 836 | pr_warn("PNP: PS/2 controller doesn't have AUX irq; using default %d\n", |
| 837 | "PNP: PS/2 controller doesn't have AUX irq; " | 837 | i8042_aux_irq); |
| 838 | "using default %d\n", i8042_aux_irq); | ||
| 839 | i8042_pnp_aux_irq = i8042_aux_irq; | 838 | i8042_pnp_aux_irq = i8042_aux_irq; |
| 840 | } | 839 | } |
| 841 | } | 840 | } |
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 18db5a8c7478..c04ff00a3663 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | * the Free Software Foundation. | 10 | * the Free Software Foundation. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 14 | |||
| 13 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 14 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
| 15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| @@ -225,8 +227,8 @@ static int i8042_flush(void) | |||
| 225 | udelay(50); | 227 | udelay(50); |
| 226 | data = i8042_read_data(); | 228 | data = i8042_read_data(); |
| 227 | i++; | 229 | i++; |
| 228 | dbg("%02x <- i8042 (flush, %s)", data, | 230 | dbg("%02x <- i8042 (flush, %s)\n", |
| 229 | str & I8042_STR_AUXDATA ? "aux" : "kbd"); | 231 | data, str & I8042_STR_AUXDATA ? "aux" : "kbd"); |
| 230 | } | 232 | } |
| 231 | 233 | ||
| 232 | spin_unlock_irqrestore(&i8042_lock, flags); | 234 | spin_unlock_irqrestore(&i8042_lock, flags); |
| @@ -253,32 +255,32 @@ static int __i8042_command(unsigned char *param, int command) | |||
| 253 | if (error) | 255 | if (error) |
| 254 | return error; | 256 | return error; |
| 255 | 257 | ||
| 256 | dbg("%02x -> i8042 (command)", command & 0xff); | 258 | dbg("%02x -> i8042 (command)\n", command & 0xff); |
| 257 | i8042_write_command(command & 0xff); | 259 | i8042_write_command(command & 0xff); |
| 258 | 260 | ||
| 259 | for (i = 0; i < ((command >> 12) & 0xf); i++) { | 261 | for (i = 0; i < ((command >> 12) & 0xf); i++) { |
| 260 | error = i8042_wait_write(); | 262 | error = i8042_wait_write(); |
| 261 | if (error) | 263 | if (error) |
| 262 | return error; | 264 | return error; |
| 263 | dbg("%02x -> i8042 (parameter)", param[i]); | 265 | dbg("%02x -> i8042 (parameter)\n", param[i]); |
| 264 | i8042_write_data(param[i]); | 266 | i8042_write_data(param[i]); |
| 265 | } | 267 | } |
| 266 | 268 | ||
| 267 | for (i = 0; i < ((command >> 8) & 0xf); i++) { | 269 | for (i = 0; i < ((command >> 8) & 0xf); i++) { |
| 268 | error = i8042_wait_read(); | 270 | error = i8042_wait_read(); |
| 269 | if (error) { | 271 | if (error) { |
| 270 | dbg(" -- i8042 (timeout)"); | 272 | dbg(" -- i8042 (timeout)\n"); |
| 271 | return error; | 273 | return error; |
| 272 | } | 274 | } |
| 273 | 275 | ||
| 274 | if (command == I8042_CMD_AUX_LOOP && | 276 | if (command == I8042_CMD_AUX_LOOP && |
| 275 | !(i8042_read_status() & I8042_STR_AUXDATA)) { | 277 | !(i8042_read_status() & I8042_STR_AUXDATA)) { |
| 276 | dbg(" -- i8042 (auxerr)"); | 278 | dbg(" -- i8042 (auxerr)\n"); |
| 277 | return -1; | 279 | return -1; |
| 278 | } | 280 | } |
| 279 | 281 | ||
| 280 | param[i] = i8042_read_data(); | 282 | param[i] = i8042_read_data(); |
| 281 | dbg("%02x <- i8042 (return)", param[i]); | 283 | dbg("%02x <- i8042 (return)\n", param[i]); |
| 282 | } | 284 | } |
| 283 | 285 | ||
| 284 | return 0; | 286 | return 0; |
| @@ -309,7 +311,7 @@ static int i8042_kbd_write(struct serio *port, unsigned char c) | |||
| 309 | spin_lock_irqsave(&i8042_lock, flags); | 311 | spin_lock_irqsave(&i8042_lock, flags); |
| 310 | 312 | ||
| 311 | if (!(retval = i8042_wait_write())) { | 313 | if (!(retval = i8042_wait_write())) { |
| 312 | dbg("%02x -> i8042 (kbd-data)", c); | 314 | dbg("%02x -> i8042 (kbd-data)\n", c); |
| 313 | i8042_write_data(c); | 315 | i8042_write_data(c); |
| 314 | } | 316 | } |
| 315 | 317 | ||
| @@ -355,17 +357,14 @@ static void i8042_port_close(struct serio *serio) | |||
| 355 | 357 | ||
| 356 | i8042_ctr &= ~irq_bit; | 358 | i8042_ctr &= ~irq_bit; |
| 357 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) | 359 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) |
| 358 | printk(KERN_WARNING | 360 | pr_warn("Can't write CTR while closing %s port\n", port_name); |
| 359 | "i8042.c: Can't write CTR while closing %s port.\n", | ||
| 360 | port_name); | ||
| 361 | 361 | ||
| 362 | udelay(50); | 362 | udelay(50); |
| 363 | 363 | ||
| 364 | i8042_ctr &= ~disable_bit; | 364 | i8042_ctr &= ~disable_bit; |
| 365 | i8042_ctr |= irq_bit; | 365 | i8042_ctr |= irq_bit; |
| 366 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) | 366 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) |
| 367 | printk(KERN_ERR "i8042.c: Can't reactivate %s port.\n", | 367 | pr_err("Can't reactivate %s port\n", port_name); |
| 368 | port_name); | ||
| 369 | 368 | ||
| 370 | /* | 369 | /* |
| 371 | * See if there is any data appeared while we were messing with | 370 | * See if there is any data appeared while we were messing with |
| @@ -456,7 +455,8 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id) | |||
| 456 | str = i8042_read_status(); | 455 | str = i8042_read_status(); |
| 457 | if (unlikely(~str & I8042_STR_OBF)) { | 456 | if (unlikely(~str & I8042_STR_OBF)) { |
| 458 | spin_unlock_irqrestore(&i8042_lock, flags); | 457 | spin_unlock_irqrestore(&i8042_lock, flags); |
| 459 | if (irq) dbg("Interrupt %d, without any data", irq); | 458 | if (irq) |
| 459 | dbg("Interrupt %d, without any data\n", irq); | ||
| 460 | ret = 0; | 460 | ret = 0; |
| 461 | goto out; | 461 | goto out; |
| 462 | } | 462 | } |
| @@ -469,7 +469,8 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id) | |||
| 469 | 469 | ||
| 470 | dfl = 0; | 470 | dfl = 0; |
| 471 | if (str & I8042_STR_MUXERR) { | 471 | if (str & I8042_STR_MUXERR) { |
| 472 | dbg("MUX error, status is %02x, data is %02x", str, data); | 472 | dbg("MUX error, status is %02x, data is %02x\n", |
| 473 | str, data); | ||
| 473 | /* | 474 | /* |
| 474 | * When MUXERR condition is signalled the data register can only contain | 475 | * When MUXERR condition is signalled the data register can only contain |
| 475 | * 0xfd, 0xfe or 0xff if implementation follows the spec. Unfortunately | 476 | * 0xfd, 0xfe or 0xff if implementation follows the spec. Unfortunately |
| @@ -512,7 +513,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id) | |||
| 512 | port = &i8042_ports[port_no]; | 513 | port = &i8042_ports[port_no]; |
| 513 | serio = port->exists ? port->serio : NULL; | 514 | serio = port->exists ? port->serio : NULL; |
| 514 | 515 | ||
| 515 | dbg("%02x <- i8042 (interrupt, %d, %d%s%s)", | 516 | dbg("%02x <- i8042 (interrupt, %d, %d%s%s)\n", |
| 516 | data, port_no, irq, | 517 | data, port_no, irq, |
| 517 | dfl & SERIO_PARITY ? ", bad parity" : "", | 518 | dfl & SERIO_PARITY ? ", bad parity" : "", |
| 518 | dfl & SERIO_TIMEOUT ? ", timeout" : ""); | 519 | dfl & SERIO_TIMEOUT ? ", timeout" : ""); |
| @@ -540,7 +541,7 @@ static int i8042_enable_kbd_port(void) | |||
| 540 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | 541 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { |
| 541 | i8042_ctr &= ~I8042_CTR_KBDINT; | 542 | i8042_ctr &= ~I8042_CTR_KBDINT; |
| 542 | i8042_ctr |= I8042_CTR_KBDDIS; | 543 | i8042_ctr |= I8042_CTR_KBDDIS; |
| 543 | printk(KERN_ERR "i8042.c: Failed to enable KBD port.\n"); | 544 | pr_err("Failed to enable KBD port\n"); |
| 544 | return -EIO; | 545 | return -EIO; |
| 545 | } | 546 | } |
| 546 | 547 | ||
| @@ -559,7 +560,7 @@ static int i8042_enable_aux_port(void) | |||
| 559 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | 560 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { |
| 560 | i8042_ctr &= ~I8042_CTR_AUXINT; | 561 | i8042_ctr &= ~I8042_CTR_AUXINT; |
| 561 | i8042_ctr |= I8042_CTR_AUXDIS; | 562 | i8042_ctr |= I8042_CTR_AUXDIS; |
| 562 | printk(KERN_ERR "i8042.c: Failed to enable AUX port.\n"); | 563 | pr_err("Failed to enable AUX port\n"); |
| 563 | return -EIO; | 564 | return -EIO; |
| 564 | } | 565 | } |
| 565 | 566 | ||
| @@ -641,7 +642,7 @@ static int __init i8042_check_mux(void) | |||
| 641 | if (i8042_set_mux_mode(true, &mux_version)) | 642 | if (i8042_set_mux_mode(true, &mux_version)) |
| 642 | return -1; | 643 | return -1; |
| 643 | 644 | ||
| 644 | printk(KERN_INFO "i8042.c: Detected active multiplexing controller, rev %d.%d.\n", | 645 | pr_info("Detected active multiplexing controller, rev %d.%d\n", |
| 645 | (mux_version >> 4) & 0xf, mux_version & 0xf); | 646 | (mux_version >> 4) & 0xf, mux_version & 0xf); |
| 646 | 647 | ||
| 647 | /* | 648 | /* |
| @@ -651,7 +652,7 @@ static int __init i8042_check_mux(void) | |||
| 651 | i8042_ctr &= ~I8042_CTR_AUXINT; | 652 | i8042_ctr &= ~I8042_CTR_AUXINT; |
| 652 | 653 | ||
| 653 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | 654 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { |
| 654 | printk(KERN_ERR "i8042.c: Failed to disable AUX port, can't use MUX.\n"); | 655 | pr_err("Failed to disable AUX port, can't use MUX\n"); |
| 655 | return -EIO; | 656 | return -EIO; |
| 656 | } | 657 | } |
| 657 | 658 | ||
| @@ -676,8 +677,8 @@ static irqreturn_t __init i8042_aux_test_irq(int irq, void *dev_id) | |||
| 676 | str = i8042_read_status(); | 677 | str = i8042_read_status(); |
| 677 | if (str & I8042_STR_OBF) { | 678 | if (str & I8042_STR_OBF) { |
| 678 | data = i8042_read_data(); | 679 | data = i8042_read_data(); |
| 679 | dbg("%02x <- i8042 (aux_test_irq, %s)", | 680 | dbg("%02x <- i8042 (aux_test_irq, %s)\n", |
| 680 | data, str & I8042_STR_AUXDATA ? "aux" : "kbd"); | 681 | data, str & I8042_STR_AUXDATA ? "aux" : "kbd"); |
| 681 | if (i8042_irq_being_tested && | 682 | if (i8042_irq_being_tested && |
| 682 | data == 0xa5 && (str & I8042_STR_AUXDATA)) | 683 | data == 0xa5 && (str & I8042_STR_AUXDATA)) |
| 683 | complete(&i8042_aux_irq_delivered); | 684 | complete(&i8042_aux_irq_delivered); |
| @@ -770,8 +771,8 @@ static int __init i8042_check_aux(void) | |||
| 770 | */ | 771 | */ |
| 771 | 772 | ||
| 772 | if (i8042_toggle_aux(false)) { | 773 | if (i8042_toggle_aux(false)) { |
| 773 | printk(KERN_WARNING "Failed to disable AUX port, but continuing anyway... Is this a SiS?\n"); | 774 | pr_warn("Failed to disable AUX port, but continuing anyway... Is this a SiS?\n"); |
| 774 | printk(KERN_WARNING "If AUX port is really absent please use the 'i8042.noaux' option.\n"); | 775 | pr_warn("If AUX port is really absent please use the 'i8042.noaux' option\n"); |
| 775 | } | 776 | } |
| 776 | 777 | ||
| 777 | if (i8042_toggle_aux(true)) | 778 | if (i8042_toggle_aux(true)) |
| @@ -819,7 +820,7 @@ static int __init i8042_check_aux(void) | |||
| 819 | * AUX IRQ was never delivered so we need to flush the controller to | 820 | * AUX IRQ was never delivered so we need to flush the controller to |
| 820 | * get rid of the byte we put there; otherwise keyboard may not work. | 821 | * get rid of the byte we put there; otherwise keyboard may not work. |
| 821 | */ | 822 | */ |
| 822 | dbg(" -- i8042 (aux irq test timeout)"); | 823 | dbg(" -- i8042 (aux irq test timeout)\n"); |
| 823 | i8042_flush(); | 824 | i8042_flush(); |
| 824 | retval = -1; | 825 | retval = -1; |
| 825 | } | 826 | } |
| @@ -845,7 +846,7 @@ static int __init i8042_check_aux(void) | |||
| 845 | static int i8042_controller_check(void) | 846 | static int i8042_controller_check(void) |
| 846 | { | 847 | { |
| 847 | if (i8042_flush() == I8042_BUFFER_SIZE) { | 848 | if (i8042_flush() == I8042_BUFFER_SIZE) { |
| 848 | printk(KERN_ERR "i8042.c: No controller found.\n"); | 849 | pr_err("No controller found\n"); |
| 849 | return -ENODEV; | 850 | return -ENODEV; |
| 850 | } | 851 | } |
| 851 | 852 | ||
| @@ -864,15 +865,15 @@ static int i8042_controller_selftest(void) | |||
| 864 | do { | 865 | do { |
| 865 | 866 | ||
| 866 | if (i8042_command(¶m, I8042_CMD_CTL_TEST)) { | 867 | if (i8042_command(¶m, I8042_CMD_CTL_TEST)) { |
| 867 | printk(KERN_ERR "i8042.c: i8042 controller self test timeout.\n"); | 868 | pr_err("i8042 controller self test timeout\n"); |
| 868 | return -ENODEV; | 869 | return -ENODEV; |
| 869 | } | 870 | } |
| 870 | 871 | ||
| 871 | if (param == I8042_RET_CTL_TEST) | 872 | if (param == I8042_RET_CTL_TEST) |
| 872 | return 0; | 873 | return 0; |
| 873 | 874 | ||
| 874 | printk(KERN_ERR "i8042.c: i8042 controller selftest failed. (%#x != %#x)\n", | 875 | pr_err("i8042 controller selftest failed. (%#x != %#x)\n", |
| 875 | param, I8042_RET_CTL_TEST); | 876 | param, I8042_RET_CTL_TEST); |
| 876 | msleep(50); | 877 | msleep(50); |
| 877 | } while (i++ < 5); | 878 | } while (i++ < 5); |
| 878 | 879 | ||
| @@ -883,8 +884,7 @@ static int i8042_controller_selftest(void) | |||
| 883 | * and user will still get a working keyboard. This is especially | 884 | * and user will still get a working keyboard. This is especially |
| 884 | * important on netbooks. On other arches we trust hardware more. | 885 | * important on netbooks. On other arches we trust hardware more. |
| 885 | */ | 886 | */ |
| 886 | printk(KERN_INFO | 887 | pr_info("giving up on controller selftest, continuing anyway...\n"); |
| 887 | "i8042: giving up on controller selftest, continuing anyway...\n"); | ||
| 888 | return 0; | 888 | return 0; |
| 889 | #else | 889 | #else |
| 890 | return -EIO; | 890 | return -EIO; |
| @@ -909,8 +909,7 @@ static int i8042_controller_init(void) | |||
| 909 | 909 | ||
| 910 | do { | 910 | do { |
| 911 | if (n >= 10) { | 911 | if (n >= 10) { |
| 912 | printk(KERN_ERR | 912 | pr_err("Unable to get stable CTR read\n"); |
| 913 | "i8042.c: Unable to get stable CTR read.\n"); | ||
| 914 | return -EIO; | 913 | return -EIO; |
| 915 | } | 914 | } |
| 916 | 915 | ||
| @@ -918,8 +917,7 @@ static int i8042_controller_init(void) | |||
| 918 | udelay(50); | 917 | udelay(50); |
| 919 | 918 | ||
| 920 | if (i8042_command(&ctr[n++ % 2], I8042_CMD_CTL_RCTR)) { | 919 | if (i8042_command(&ctr[n++ % 2], I8042_CMD_CTL_RCTR)) { |
| 921 | printk(KERN_ERR | 920 | pr_err("Can't read CTR while initializing i8042\n"); |
| 922 | "i8042.c: Can't read CTR while initializing i8042.\n"); | ||
| 923 | return -EIO; | 921 | return -EIO; |
| 924 | } | 922 | } |
| 925 | 923 | ||
| @@ -943,7 +941,7 @@ static int i8042_controller_init(void) | |||
| 943 | if (i8042_unlock) | 941 | if (i8042_unlock) |
| 944 | i8042_ctr |= I8042_CTR_IGNKEYLOCK; | 942 | i8042_ctr |= I8042_CTR_IGNKEYLOCK; |
| 945 | else | 943 | else |
| 946 | printk(KERN_WARNING "i8042.c: Warning: Keylock active.\n"); | 944 | pr_warn("Warning: Keylock active\n"); |
| 947 | } | 945 | } |
| 948 | spin_unlock_irqrestore(&i8042_lock, flags); | 946 | spin_unlock_irqrestore(&i8042_lock, flags); |
| 949 | 947 | ||
| @@ -970,7 +968,7 @@ static int i8042_controller_init(void) | |||
| 970 | */ | 968 | */ |
| 971 | 969 | ||
| 972 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | 970 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { |
| 973 | printk(KERN_ERR "i8042.c: Can't write CTR while initializing i8042.\n"); | 971 | pr_err("Can't write CTR while initializing i8042\n"); |
| 974 | return -EIO; | 972 | return -EIO; |
| 975 | } | 973 | } |
| 976 | 974 | ||
| @@ -1000,7 +998,7 @@ static void i8042_controller_reset(void) | |||
| 1000 | i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT); | 998 | i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT); |
| 1001 | 999 | ||
| 1002 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) | 1000 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) |
| 1003 | printk(KERN_WARNING "i8042.c: Can't write CTR while resetting.\n"); | 1001 | pr_warn("Can't write CTR while resetting\n"); |
| 1004 | 1002 | ||
| 1005 | /* | 1003 | /* |
| 1006 | * Disable MUX mode if present. | 1004 | * Disable MUX mode if present. |
| @@ -1021,7 +1019,7 @@ static void i8042_controller_reset(void) | |||
| 1021 | */ | 1019 | */ |
| 1022 | 1020 | ||
| 1023 | if (i8042_command(&i8042_initial_ctr, I8042_CMD_CTL_WCTR)) | 1021 | if (i8042_command(&i8042_initial_ctr, I8042_CMD_CTL_WCTR)) |
| 1024 | printk(KERN_WARNING "i8042.c: Can't restore CTR.\n"); | 1022 | pr_warn("Can't restore CTR\n"); |
| 1025 | } | 1023 | } |
| 1026 | 1024 | ||
| 1027 | 1025 | ||
| @@ -1045,14 +1043,14 @@ static long i8042_panic_blink(int state) | |||
| 1045 | led = (state) ? 0x01 | 0x04 : 0; | 1043 | led = (state) ? 0x01 | 0x04 : 0; |
| 1046 | while (i8042_read_status() & I8042_STR_IBF) | 1044 | while (i8042_read_status() & I8042_STR_IBF) |
| 1047 | DELAY; | 1045 | DELAY; |
| 1048 | dbg("%02x -> i8042 (panic blink)", 0xed); | 1046 | dbg("%02x -> i8042 (panic blink)\n", 0xed); |
| 1049 | i8042_suppress_kbd_ack = 2; | 1047 | i8042_suppress_kbd_ack = 2; |
| 1050 | i8042_write_data(0xed); /* set leds */ | 1048 | i8042_write_data(0xed); /* set leds */ |
| 1051 | DELAY; | 1049 | DELAY; |
| 1052 | while (i8042_read_status() & I8042_STR_IBF) | 1050 | while (i8042_read_status() & I8042_STR_IBF) |
| 1053 | DELAY; | 1051 | DELAY; |
| 1054 | DELAY; | 1052 | DELAY; |
| 1055 | dbg("%02x -> i8042 (panic blink)", led); | 1053 | dbg("%02x -> i8042 (panic blink)\n", led); |
| 1056 | i8042_write_data(led); | 1054 | i8042_write_data(led); |
| 1057 | DELAY; | 1055 | DELAY; |
| 1058 | return delay; | 1056 | return delay; |
| @@ -1068,9 +1066,7 @@ static void i8042_dritek_enable(void) | |||
| 1068 | 1066 | ||
| 1069 | error = i8042_command(¶m, 0x1059); | 1067 | error = i8042_command(¶m, 0x1059); |
| 1070 | if (error) | 1068 | if (error) |
| 1071 | printk(KERN_WARNING | 1069 | pr_warn("Failed to enable DRITEK extension: %d\n", error); |
| 1072 | "Failed to enable DRITEK extension: %d\n", | ||
| 1073 | error); | ||
| 1074 | } | 1070 | } |
| 1075 | #endif | 1071 | #endif |
| 1076 | 1072 | ||
| @@ -1105,10 +1101,10 @@ static int i8042_controller_resume(bool force_reset) | |||
| 1105 | i8042_ctr |= I8042_CTR_AUXDIS | I8042_CTR_KBDDIS; | 1101 | i8042_ctr |= I8042_CTR_AUXDIS | I8042_CTR_KBDDIS; |
| 1106 | i8042_ctr &= ~(I8042_CTR_AUXINT | I8042_CTR_KBDINT); | 1102 | i8042_ctr &= ~(I8042_CTR_AUXINT | I8042_CTR_KBDINT); |
| 1107 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | 1103 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { |
| 1108 | printk(KERN_WARNING "i8042: Can't write CTR to resume, retrying...\n"); | 1104 | pr_warn("Can't write CTR to resume, retrying...\n"); |
| 1109 | msleep(50); | 1105 | msleep(50); |
| 1110 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | 1106 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { |
| 1111 | printk(KERN_ERR "i8042: CTR write retry failed\n"); | 1107 | pr_err("CTR write retry failed\n"); |
| 1112 | return -EIO; | 1108 | return -EIO; |
| 1113 | } | 1109 | } |
| 1114 | } | 1110 | } |
| @@ -1121,9 +1117,7 @@ static int i8042_controller_resume(bool force_reset) | |||
| 1121 | 1117 | ||
| 1122 | if (i8042_mux_present) { | 1118 | if (i8042_mux_present) { |
| 1123 | if (i8042_set_mux_mode(true, NULL) || i8042_enable_mux_ports()) | 1119 | if (i8042_set_mux_mode(true, NULL) || i8042_enable_mux_ports()) |
| 1124 | printk(KERN_WARNING | 1120 | pr_warn("failed to resume active multiplexor, mouse won't work\n"); |
| 1125 | "i8042: failed to resume active multiplexor, " | ||
| 1126 | "mouse won't work.\n"); | ||
| 1127 | } else if (i8042_ports[I8042_AUX_PORT_NO].serio) | 1121 | } else if (i8042_ports[I8042_AUX_PORT_NO].serio) |
| 1128 | i8042_enable_aux_port(); | 1122 | i8042_enable_aux_port(); |
| 1129 | 1123 | ||
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h index cbc1beb66574..ac1d759d0f55 100644 --- a/drivers/input/serio/i8042.h +++ b/drivers/input/serio/i8042.h | |||
| @@ -89,15 +89,19 @@ | |||
| 89 | #ifdef DEBUG | 89 | #ifdef DEBUG |
| 90 | static unsigned long i8042_start_time; | 90 | static unsigned long i8042_start_time; |
| 91 | #define dbg_init() do { i8042_start_time = jiffies; } while (0) | 91 | #define dbg_init() do { i8042_start_time = jiffies; } while (0) |
| 92 | #define dbg(format, arg...) \ | 92 | #define dbg(format, arg...) \ |
| 93 | do { \ | 93 | do { \ |
| 94 | if (i8042_debug) \ | 94 | if (i8042_debug) \ |
| 95 | printk(KERN_DEBUG __FILE__ ": " format " [%d]\n" , \ | 95 | printk(KERN_DEBUG KBUILD_MODNAME ": [%d] " format, \ |
| 96 | ## arg, (int) (jiffies - i8042_start_time)); \ | 96 | (int) (jiffies - i8042_start_time), ##arg); \ |
| 97 | } while (0) | 97 | } while (0) |
| 98 | #else | 98 | #else |
| 99 | #define dbg_init() do { } while (0) | 99 | #define dbg_init() do { } while (0) |
| 100 | #define dbg(format, arg...) do {} while (0) | 100 | #define dbg(format, arg...) \ |
| 101 | do { \ | ||
| 102 | if (0) \ | ||
| 103 | printk(KERN_DEBUG pr_fmt(format), ##arg); \ | ||
| 104 | } while (0) | ||
| 101 | #endif | 105 | #endif |
| 102 | 106 | ||
| 103 | #endif /* _I8042_H */ | 107 | #endif /* _I8042_H */ |
diff --git a/drivers/input/serio/ps2mult.c b/drivers/input/serio/ps2mult.c index 6bce22e4e495..15aa81c9f1fb 100644 --- a/drivers/input/serio/ps2mult.c +++ b/drivers/input/serio/ps2mult.c | |||
| @@ -207,7 +207,7 @@ static int ps2mult_connect(struct serio *serio, struct serio_driver *drv) | |||
| 207 | err_out: | 207 | err_out: |
| 208 | while (--i >= 0) | 208 | while (--i >= 0) |
| 209 | kfree(psm->ports[i].serio); | 209 | kfree(psm->ports[i].serio); |
| 210 | kfree(serio); | 210 | kfree(psm); |
| 211 | return error; | 211 | return error; |
| 212 | } | 212 | } |
| 213 | 213 | ||
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 405bf214527c..db5b0bca1a1a 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
| @@ -32,10 +32,9 @@ | |||
| 32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
| 33 | #include <linux/serio.h> | 33 | #include <linux/serio.h> |
| 34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
| 35 | #include <linux/wait.h> | ||
| 36 | #include <linux/sched.h> | 35 | #include <linux/sched.h> |
| 37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
| 38 | #include <linux/kthread.h> | 37 | #include <linux/workqueue.h> |
| 39 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
| 40 | 39 | ||
| 41 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 40 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
| @@ -44,7 +43,7 @@ MODULE_LICENSE("GPL"); | |||
| 44 | 43 | ||
| 45 | /* | 44 | /* |
| 46 | * serio_mutex protects entire serio subsystem and is taken every time | 45 | * serio_mutex protects entire serio subsystem and is taken every time |
| 47 | * serio port or driver registrered or unregistered. | 46 | * serio port or driver registered or unregistered. |
| 48 | */ | 47 | */ |
| 49 | static DEFINE_MUTEX(serio_mutex); | 48 | static DEFINE_MUTEX(serio_mutex); |
| 50 | 49 | ||
| @@ -165,58 +164,22 @@ struct serio_event { | |||
| 165 | 164 | ||
| 166 | static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */ | 165 | static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */ |
| 167 | static LIST_HEAD(serio_event_list); | 166 | static LIST_HEAD(serio_event_list); |
| 168 | static DECLARE_WAIT_QUEUE_HEAD(serio_wait); | ||
| 169 | static struct task_struct *serio_task; | ||
| 170 | 167 | ||
| 171 | static int serio_queue_event(void *object, struct module *owner, | 168 | static struct serio_event *serio_get_event(void) |
| 172 | enum serio_event_type event_type) | ||
| 173 | { | 169 | { |
| 170 | struct serio_event *event = NULL; | ||
| 174 | unsigned long flags; | 171 | unsigned long flags; |
| 175 | struct serio_event *event; | ||
| 176 | int retval = 0; | ||
| 177 | 172 | ||
| 178 | spin_lock_irqsave(&serio_event_lock, flags); | 173 | spin_lock_irqsave(&serio_event_lock, flags); |
| 179 | 174 | ||
| 180 | /* | 175 | if (!list_empty(&serio_event_list)) { |
| 181 | * Scan event list for the other events for the same serio port, | 176 | event = list_first_entry(&serio_event_list, |
| 182 | * starting with the most recent one. If event is the same we | 177 | struct serio_event, node); |
| 183 | * do not need add new one. If event is of different type we | 178 | list_del_init(&event->node); |
| 184 | * need to add this event and should not look further because | ||
| 185 | * we need to preseve sequence of distinct events. | ||
| 186 | */ | ||
| 187 | list_for_each_entry_reverse(event, &serio_event_list, node) { | ||
| 188 | if (event->object == object) { | ||
| 189 | if (event->type == event_type) | ||
| 190 | goto out; | ||
| 191 | break; | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC); | ||
| 196 | if (!event) { | ||
| 197 | pr_err("Not enough memory to queue event %d\n", event_type); | ||
| 198 | retval = -ENOMEM; | ||
| 199 | goto out; | ||
| 200 | } | ||
| 201 | |||
| 202 | if (!try_module_get(owner)) { | ||
| 203 | pr_warning("Can't get module reference, dropping event %d\n", | ||
| 204 | event_type); | ||
| 205 | kfree(event); | ||
| 206 | retval = -EINVAL; | ||
| 207 | goto out; | ||
| 208 | } | 179 | } |
| 209 | 180 | ||
| 210 | event->type = event_type; | ||
| 211 | event->object = object; | ||
| 212 | event->owner = owner; | ||
| 213 | |||
| 214 | list_add_tail(&event->node, &serio_event_list); | ||
| 215 | wake_up(&serio_wait); | ||
| 216 | |||
| 217 | out: | ||
| 218 | spin_unlock_irqrestore(&serio_event_lock, flags); | 181 | spin_unlock_irqrestore(&serio_event_lock, flags); |
| 219 | return retval; | 182 | return event; |
| 220 | } | 183 | } |
| 221 | 184 | ||
| 222 | static void serio_free_event(struct serio_event *event) | 185 | static void serio_free_event(struct serio_event *event) |
| @@ -250,25 +213,7 @@ static void serio_remove_duplicate_events(struct serio_event *event) | |||
| 250 | spin_unlock_irqrestore(&serio_event_lock, flags); | 213 | spin_unlock_irqrestore(&serio_event_lock, flags); |
| 251 | } | 214 | } |
| 252 | 215 | ||
| 253 | 216 | static void serio_handle_event(struct work_struct *work) | |
| 254 | static struct serio_event *serio_get_event(void) | ||
| 255 | { | ||
| 256 | struct serio_event *event = NULL; | ||
| 257 | unsigned long flags; | ||
| 258 | |||
| 259 | spin_lock_irqsave(&serio_event_lock, flags); | ||
| 260 | |||
| 261 | if (!list_empty(&serio_event_list)) { | ||
| 262 | event = list_first_entry(&serio_event_list, | ||
| 263 | struct serio_event, node); | ||
| 264 | list_del_init(&event->node); | ||
| 265 | } | ||
| 266 | |||
| 267 | spin_unlock_irqrestore(&serio_event_lock, flags); | ||
| 268 | return event; | ||
| 269 | } | ||
| 270 | |||
| 271 | static void serio_handle_event(void) | ||
| 272 | { | 217 | { |
| 273 | struct serio_event *event; | 218 | struct serio_event *event; |
| 274 | 219 | ||
| @@ -307,6 +252,59 @@ static void serio_handle_event(void) | |||
| 307 | mutex_unlock(&serio_mutex); | 252 | mutex_unlock(&serio_mutex); |
| 308 | } | 253 | } |
| 309 | 254 | ||
| 255 | static DECLARE_WORK(serio_event_work, serio_handle_event); | ||
| 256 | |||
| 257 | static int serio_queue_event(void *object, struct module *owner, | ||
| 258 | enum serio_event_type event_type) | ||
| 259 | { | ||
| 260 | unsigned long flags; | ||
| 261 | struct serio_event *event; | ||
| 262 | int retval = 0; | ||
| 263 | |||
| 264 | spin_lock_irqsave(&serio_event_lock, flags); | ||
| 265 | |||
| 266 | /* | ||
| 267 | * Scan event list for the other events for the same serio port, | ||
| 268 | * starting with the most recent one. If event is the same we | ||
| 269 | * do not need add new one. If event is of different type we | ||
| 270 | * need to add this event and should not look further because | ||
| 271 | * we need to preseve sequence of distinct events. | ||
| 272 | */ | ||
| 273 | list_for_each_entry_reverse(event, &serio_event_list, node) { | ||
| 274 | if (event->object == object) { | ||
| 275 | if (event->type == event_type) | ||
| 276 | goto out; | ||
| 277 | break; | ||
| 278 | } | ||
| 279 | } | ||
| 280 | |||
| 281 | event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC); | ||
| 282 | if (!event) { | ||
| 283 | pr_err("Not enough memory to queue event %d\n", event_type); | ||
| 284 | retval = -ENOMEM; | ||
| 285 | goto out; | ||
| 286 | } | ||
| 287 | |||
| 288 | if (!try_module_get(owner)) { | ||
| 289 | pr_warning("Can't get module reference, dropping event %d\n", | ||
| 290 | event_type); | ||
| 291 | kfree(event); | ||
| 292 | retval = -EINVAL; | ||
| 293 | goto out; | ||
| 294 | } | ||
| 295 | |||
| 296 | event->type = event_type; | ||
| 297 | event->object = object; | ||
| 298 | event->owner = owner; | ||
| 299 | |||
| 300 | list_add_tail(&event->node, &serio_event_list); | ||
| 301 | schedule_work(&serio_event_work); | ||
| 302 | |||
| 303 | out: | ||
| 304 | spin_unlock_irqrestore(&serio_event_lock, flags); | ||
| 305 | return retval; | ||
| 306 | } | ||
| 307 | |||
| 310 | /* | 308 | /* |
| 311 | * Remove all events that have been submitted for a given | 309 | * Remove all events that have been submitted for a given |
| 312 | * object, be it serio port or driver. | 310 | * object, be it serio port or driver. |
| @@ -356,18 +354,6 @@ static struct serio *serio_get_pending_child(struct serio *parent) | |||
| 356 | return child; | 354 | return child; |
| 357 | } | 355 | } |
| 358 | 356 | ||
| 359 | static int serio_thread(void *nothing) | ||
| 360 | { | ||
| 361 | do { | ||
| 362 | serio_handle_event(); | ||
| 363 | wait_event_interruptible(serio_wait, | ||
| 364 | kthread_should_stop() || !list_empty(&serio_event_list)); | ||
| 365 | } while (!kthread_should_stop()); | ||
| 366 | |||
| 367 | return 0; | ||
| 368 | } | ||
| 369 | |||
| 370 | |||
| 371 | /* | 357 | /* |
| 372 | * Serio port operations | 358 | * Serio port operations |
| 373 | */ | 359 | */ |
| @@ -1040,21 +1026,18 @@ static int __init serio_init(void) | |||
| 1040 | return error; | 1026 | return error; |
| 1041 | } | 1027 | } |
| 1042 | 1028 | ||
| 1043 | serio_task = kthread_run(serio_thread, NULL, "kseriod"); | ||
| 1044 | if (IS_ERR(serio_task)) { | ||
| 1045 | bus_unregister(&serio_bus); | ||
| 1046 | error = PTR_ERR(serio_task); | ||
| 1047 | pr_err("Failed to start kseriod, error: %d\n", error); | ||
| 1048 | return error; | ||
| 1049 | } | ||
| 1050 | |||
| 1051 | return 0; | 1029 | return 0; |
| 1052 | } | 1030 | } |
| 1053 | 1031 | ||
| 1054 | static void __exit serio_exit(void) | 1032 | static void __exit serio_exit(void) |
| 1055 | { | 1033 | { |
| 1056 | bus_unregister(&serio_bus); | 1034 | bus_unregister(&serio_bus); |
| 1057 | kthread_stop(serio_task); | 1035 | |
| 1036 | /* | ||
| 1037 | * There should not be any outstanding events but work may | ||
| 1038 | * still be scheduled so simply cancel it. | ||
| 1039 | */ | ||
| 1040 | cancel_work_sync(&serio_event_work); | ||
| 1058 | } | 1041 | } |
| 1059 | 1042 | ||
| 1060 | subsys_initcall(serio_init); | 1043 | subsys_initcall(serio_init); |
