From 59df6bbf386d8f26870b28307d0e4f06d631685f Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sat, 3 Sep 2005 15:56:23 -0700 Subject: [PATCH] mips: kludge envdev to build for 64-bit MIPS with 32-bit compat Extend the compat mode kludgeology in envdev to cover MIPS as well. Or why we should need something like is_compat_task() ... Signed-off-by: Ralf Baechle Cc: Vojtech Pavlik Signed-off-by: Dmitry Torokhov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/evdev.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/input') diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 20e3a165989f..f8b278d3559b 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -160,6 +160,8 @@ struct input_event_compat { # define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current)) #elif defined(CONFIG_ARCH_S390) # define COMPAT_TEST test_thread_flag(TIF_31BIT) +#elif defined(CONFIG_MIPS) +# define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR) #else # define COMPAT_TEST test_thread_flag(TIF_32BIT) #endif -- cgit v1.2.3 From a97e148a8b8da8b04bc3e18ceb824a8f5f56d567 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Tue, 6 Sep 2005 15:18:33 -0700 Subject: [PATCH] input: convert kcalloc to kzalloc This patch converts kcalloc(1, ...) calls to use the new kzalloc() function. Signed-off-by: Pekka Enberg Cc: Vojtech Pavlik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/gameport/emu10k1-gp.c | 2 +- drivers/input/gameport/fm801-gp.c | 2 +- drivers/input/gameport/ns558.c | 4 ++-- drivers/input/joystick/a3d.c | 2 +- drivers/input/joystick/adi.c | 2 +- drivers/input/joystick/analog.c | 2 +- drivers/input/joystick/cobra.c | 2 +- drivers/input/joystick/db9.c | 2 +- drivers/input/joystick/gamecon.c | 2 +- drivers/input/joystick/gf2k.c | 2 +- drivers/input/joystick/grip.c | 2 +- drivers/input/joystick/grip_mp.c | 2 +- drivers/input/joystick/guillemot.c | 2 +- drivers/input/joystick/interact.c | 2 +- drivers/input/joystick/sidewinder.c | 2 +- drivers/input/joystick/tmdc.c | 2 +- drivers/input/joystick/turbografx.c | 2 +- drivers/input/keyboard/corgikbd.c | 2 +- drivers/input/mouse/psmouse-base.c | 2 +- drivers/input/serio/serport.c | 4 ++-- 20 files changed, 22 insertions(+), 22 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/gameport/emu10k1-gp.c b/drivers/input/gameport/emu10k1-gp.c index a0118038330a..462f8d300aae 100644 --- a/drivers/input/gameport/emu10k1-gp.c +++ b/drivers/input/gameport/emu10k1-gp.c @@ -75,7 +75,7 @@ static int __devinit emu_probe(struct pci_dev *pdev, const struct pci_device_id if (!request_region(ioport, iolen, "emu10k1-gp")) return -EBUSY; - emu = kcalloc(1, sizeof(struct emu), GFP_KERNEL); + emu = kzalloc(sizeof(struct emu), GFP_KERNEL); port = gameport_allocate_port(); if (!emu || !port) { printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n"); diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c index 57615bc63906..47e93daa0fa7 100644 --- a/drivers/input/gameport/fm801-gp.c +++ b/drivers/input/gameport/fm801-gp.c @@ -83,7 +83,7 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device struct fm801_gp *gp; struct gameport *port; - gp = kcalloc(1, sizeof(struct fm801_gp), GFP_KERNEL); + gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); port = gameport_allocate_port(); if (!gp || !port) { printk(KERN_ERR "fm801-gp: Memory allocation failed\n"); diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c index 70f051894a3c..d2e55dc956ba 100644 --- a/drivers/input/gameport/ns558.c +++ b/drivers/input/gameport/ns558.c @@ -142,7 +142,7 @@ static int ns558_isa_probe(int io) return -EBUSY; } - ns558 = kcalloc(1, sizeof(struct ns558), GFP_KERNEL); + ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL); port = gameport_allocate_port(); if (!ns558 || !port) { printk(KERN_ERR "ns558: Memory allocation failed.\n"); @@ -215,7 +215,7 @@ static int ns558_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *did) if (!request_region(ioport, iolen, "ns558-pnp")) return -EBUSY; - ns558 = kcalloc(1, sizeof(struct ns558), GFP_KERNEL); + ns558 = kzalloc(sizeof(struct ns558), GFP_KERNEL); port = gameport_allocate_port(); if (!ns558 || !port) { printk(KERN_ERR "ns558: Memory allocation failed\n"); diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index bf34f75b9467..bf65430181fa 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c @@ -269,7 +269,7 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) int i; int err; - if (!(a3d = kcalloc(1, sizeof(struct a3d), GFP_KERNEL))) + if (!(a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL))) return -ENOMEM; a3d->gameport = gameport; diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c index 265962956c63..cf35ae638a0d 100644 --- a/drivers/input/joystick/adi.c +++ b/drivers/input/joystick/adi.c @@ -469,7 +469,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv) int i; int err; - if (!(port = kcalloc(1, sizeof(struct adi_port), GFP_KERNEL))) + if (!(port = kzalloc(sizeof(struct adi_port), GFP_KERNEL))) return -ENOMEM; port->gameport = gameport; diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c index c3a5739030c3..64b1313a3c66 100644 --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c @@ -655,7 +655,7 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv int i; int err; - if (!(port = kcalloc(1, sizeof(struct analog_port), GFP_KERNEL))) + if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL))) return - ENOMEM; err = analog_init_port(gameport, drv, port); diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c index a6002205328f..0b2e9fa26579 100644 --- a/drivers/input/joystick/cobra.c +++ b/drivers/input/joystick/cobra.c @@ -163,7 +163,7 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv) int i, j; int err; - if (!(cobra = kcalloc(1, sizeof(struct cobra), GFP_KERNEL))) + if (!(cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL))) return -ENOMEM; cobra->gameport = gameport; diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index fbd3eed07f90..2a3e4bb2da50 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c @@ -572,7 +572,7 @@ static struct db9 __init *db9_probe(int *config, int nargs) } } - if (!(db9 = kcalloc(1, sizeof(struct db9), GFP_KERNEL))) { + if (!(db9 = kzalloc(sizeof(struct db9), GFP_KERNEL))) { parport_put_port(pp); return NULL; } diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index 95bbdd302aad..5427bf9fc862 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c @@ -554,7 +554,7 @@ static struct gc __init *gc_probe(int *config, int nargs) return NULL; } - if (!(gc = kcalloc(1, sizeof(struct gc), GFP_KERNEL))) { + if (!(gc = kzalloc(sizeof(struct gc), GFP_KERNEL))) { parport_put_port(pp); return NULL; } diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c index 7d969420066c..8e4f92b115e6 100644 --- a/drivers/input/joystick/gf2k.c +++ b/drivers/input/joystick/gf2k.c @@ -242,7 +242,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) unsigned char data[GF2K_LENGTH]; int i, err; - if (!(gf2k = kcalloc(1, sizeof(struct gf2k), GFP_KERNEL))) + if (!(gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL))) return -ENOMEM; gf2k->gameport = gameport; diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index d1500d2562d6..9d3f910dd568 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c @@ -301,7 +301,7 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) int i, j, t; int err; - if (!(grip = kcalloc(1, sizeof(struct grip), GFP_KERNEL))) + if (!(grip = kzalloc(sizeof(struct grip), GFP_KERNEL))) return -ENOMEM; grip->gameport = gameport; diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c index 0da7bd133ccf..da17eee6f574 100644 --- a/drivers/input/joystick/grip_mp.c +++ b/drivers/input/joystick/grip_mp.c @@ -607,7 +607,7 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) struct grip_mp *grip; int err; - if (!(grip = kcalloc(1, sizeof(struct grip_mp), GFP_KERNEL))) + if (!(grip = kzalloc(sizeof(struct grip_mp), GFP_KERNEL))) return -ENOMEM; grip->gameport = gameport; diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c index f93da7bc082d..6a70ec429f06 100644 --- a/drivers/input/joystick/guillemot.c +++ b/drivers/input/joystick/guillemot.c @@ -183,7 +183,7 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver * int i, t; int err; - if (!(guillemot = kcalloc(1, sizeof(struct guillemot), GFP_KERNEL))) + if (!(guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL))) return -ENOMEM; guillemot->gameport = gameport; diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c index 9d3f8c38cb09..d7b3472bd686 100644 --- a/drivers/input/joystick/interact.c +++ b/drivers/input/joystick/interact.c @@ -212,7 +212,7 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d int i, t; int err; - if (!(interact = kcalloc(1, sizeof(struct interact), GFP_KERNEL))) + if (!(interact = kzalloc(sizeof(struct interact), GFP_KERNEL))) return -ENOMEM; interact->gameport = gameport; diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 47144a7ed9e7..9e0353721a35 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c @@ -590,7 +590,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) comment[0] = 0; - sw = kcalloc(1, sizeof(struct sw), GFP_KERNEL); + sw = kzalloc(sizeof(struct sw), GFP_KERNEL); buf = kmalloc(SW_LENGTH, GFP_KERNEL); idbuf = kmalloc(SW_LENGTH, GFP_KERNEL); if (!sw || !buf || !idbuf) { diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c index 9eb9954cac6e..7431efc4330e 100644 --- a/drivers/input/joystick/tmdc.c +++ b/drivers/input/joystick/tmdc.c @@ -262,7 +262,7 @@ static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv) int i, j, k, l, m; int err; - if (!(tmdc = kcalloc(1, sizeof(struct tmdc), GFP_KERNEL))) + if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL))) return -ENOMEM; tmdc->gameport = gameport; diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index 28100d461cb7..0c5b9c8297cd 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c @@ -178,7 +178,7 @@ static struct tgfx __init *tgfx_probe(int *config, int nargs) return NULL; } - if (!(tgfx = kcalloc(1, sizeof(struct tgfx), GFP_KERNEL))) { + if (!(tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL))) { parport_put_port(pp); return NULL; } diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index a8551711e8d6..7719bdfa9eea 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -260,7 +260,7 @@ static int __init corgikbd_probe(struct device *dev) int i; struct corgikbd *corgikbd; - corgikbd = kcalloc(1, sizeof(struct corgikbd), GFP_KERNEL); + corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); if (!corgikbd) return -ENOMEM; diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 2bb2fe78bdca..12bdd3eff923 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -883,7 +883,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) psmouse_deactivate(parent); } - if (!(psmouse = kcalloc(1, sizeof(struct psmouse), GFP_KERNEL))) { + if (!(psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL))) { retval = -ENOMEM; goto out; } diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c index 79ca38469159..1bd88fca0542 100644 --- a/drivers/input/serio/serport.c +++ b/drivers/input/serio/serport.c @@ -87,7 +87,7 @@ static int serport_ldisc_open(struct tty_struct *tty) if (!capable(CAP_SYS_ADMIN)) return -EPERM; - serport = kcalloc(1, sizeof(struct serport), GFP_KERNEL); + serport = kzalloc(sizeof(struct serport), GFP_KERNEL); if (!serport) return -ENOMEM; @@ -165,7 +165,7 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u if (test_and_set_bit(SERPORT_BUSY, &serport->flags)) return -EBUSY; - serport->serio = serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL); + serport->serio = serio = kzalloc(sizeof(struct serio), GFP_KERNEL); if (!serio) return -ENOMEM; -- cgit v1.2.3 From aba5a4c055dde13a3cece53e1b4b060294d631ed Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:18:59 -0700 Subject: [PATCH] Corgi Keyboard: Fix a couple of compile errors Fix a couple of compile errors in the corgi keyboard driver. Signed-off-by: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/keyboard/corgikbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 7719bdfa9eea..a31c3d64af32 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -235,7 +235,7 @@ static void corgikbd_hinge_timer(unsigned long data) unsigned long gprr; unsigned long flags; - gprr = read_scoop_reg(SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB); + gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB); if (gprr != sharpsl_hinge_state) { hinge_count = 0; sharpsl_hinge_state = gprr; @@ -267,7 +267,7 @@ static int __init corgikbd_probe(struct device *dev) dev_set_drvdata(dev,corgikbd); strcpy(corgikbd->phys, "corgikbd/input0"); - spin_lock_init(corgikbd->lock); + spin_lock_init(&corgikbd->lock); /* Init Keyboard rescan timer */ init_timer(&corgikbd->timer); -- cgit v1.2.3 From 8240a4a4bc95814502da522d5ee929fe0f0dc679 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:18:59 -0700 Subject: [PATCH] Corgi Keyboard: Add some power management code Add some power management code to the corgi keyboard driver so that only one power event gets reported within any reasonable time frame and the driver doesn't enter an infinte loop due to key repeat. Signed-off-by: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/keyboard/corgikbd.c | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index a31c3d64af32..43d6edb3cf09 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -78,6 +79,9 @@ struct corgikbd { struct timer_list timer; struct timer_list htimer; + + unsigned int suspended; + unsigned long suspend_jiffies; }; static void handle_scancode(unsigned int pressed,unsigned int scancode, struct corgikbd *corgikbd_data) @@ -85,8 +89,11 @@ static void handle_scancode(unsigned int pressed,unsigned int scancode, struct c if (pressed && !(corgikbd_data->state[scancode] & CORGIKBD_PRESSED)) { corgikbd_data->state[scancode] |= CORGIKBD_PRESSED; input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], 1); - if (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) + if ((corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) + && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); + corgikbd_data->suspend_jiffies=jiffies; + } } else if (!pressed && corgikbd_data->state[scancode] & CORGIKBD_PRESSED) { corgikbd_data->state[scancode] &= ~CORGIKBD_PRESSED; input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], 0); @@ -153,6 +160,9 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs unsigned long flags; unsigned int num_pressed; + if (corgikbd_data->suspended) + return; + spin_lock_irqsave(&corgikbd_data->lock, flags); if (regs) @@ -255,6 +265,32 @@ static void corgikbd_hinge_timer(unsigned long data) mod_timer(&corgikbd_data->htimer, jiffies + HINGE_SCAN_INTERVAL); } +#ifdef CONFIG_PM +static int corgikbd_suspend(struct device *dev, pm_message_t state, uint32_t level) +{ + if (level == SUSPEND_POWER_DOWN) { + struct corgikbd *corgikbd = dev_get_drvdata(dev); + corgikbd->suspended = 1; + } + return 0; +} + +static int corgikbd_resume(struct device *dev, uint32_t level) +{ + if (level == RESUME_POWER_ON) { + struct corgikbd *corgikbd = dev_get_drvdata(dev); + + /* Upon resume, ignore the suspend key for a short while */ + corgikbd->suspend_jiffies=jiffies; + corgikbd->suspended = 0; + } + return 0; +} +#else +#define corgikbd_suspend NULL +#define corgikbd_resume NULL +#endif + static int __init corgikbd_probe(struct device *dev) { int i; @@ -279,6 +315,8 @@ static int __init corgikbd_probe(struct device *dev) corgikbd->htimer.function = corgikbd_hinge_timer; corgikbd->htimer.data = (unsigned long) corgikbd; + corgikbd->suspend_jiffies=jiffies; + init_input_dev(&corgikbd->input); corgikbd->input.private = corgikbd; corgikbd->input.name = "Corgi Keyboard"; @@ -343,6 +381,8 @@ static struct device_driver corgikbd_driver = { .bus = &platform_bus_type, .probe = corgikbd_probe, .remove = corgikbd_remove, + .suspend = corgikbd_suspend, + .resume = corgikbd_resume, }; static int __devinit corgikbd_init(void) -- cgit v1.2.3 From 948e12f0bd51db439659fed857971e22fbdd7527 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:19:00 -0700 Subject: [PATCH] Corgi Keyboard: Code tidying The input system handles key state tracking so there's no need for the driver to do so as well. Also tidy up some comment formatting and remove a now unneeded function. Signed-off-by: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/keyboard/corgikbd.c | 61 ++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 33 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 43d6edb3cf09..767e853dd766 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -33,7 +33,6 @@ /* zero code, 124 scancodes + 3 hinge combinations */ #define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 +3 ) #define SCAN_INTERVAL (HZ/10) -#define CORGIKBD_PRESSED 1 #define HINGE_SCAN_INTERVAL (HZ/4) @@ -74,9 +73,7 @@ struct corgikbd { struct input_dev input; char phys[32]; - unsigned char state[ARRAY_SIZE(corgikbd_keycode)]; spinlock_t lock; - struct timer_list timer; struct timer_list htimer; @@ -84,22 +81,6 @@ struct corgikbd { unsigned long suspend_jiffies; }; -static void handle_scancode(unsigned int pressed,unsigned int scancode, struct corgikbd *corgikbd_data) -{ - if (pressed && !(corgikbd_data->state[scancode] & CORGIKBD_PRESSED)) { - corgikbd_data->state[scancode] |= CORGIKBD_PRESSED; - input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], 1); - if ((corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) - && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { - input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); - corgikbd_data->suspend_jiffies=jiffies; - } - } else if (!pressed && corgikbd_data->state[scancode] & CORGIKBD_PRESSED) { - corgikbd_data->state[scancode] &= ~CORGIKBD_PRESSED; - input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], 0); - } -} - #define KB_DISCHARGE_DELAY 10 #define KB_ACTIVATE_DELAY 10 @@ -112,36 +93,36 @@ static void handle_scancode(unsigned int pressed,unsigned int scancode, struct c */ static inline void corgikbd_discharge_all(void) { - // STROBE All HiZ + /* STROBE All HiZ */ GPCR2 = CORGI_GPIO_ALL_STROBE_BIT; GPDR2 &= ~CORGI_GPIO_ALL_STROBE_BIT; } static inline void corgikbd_activate_all(void) { - // STROBE ALL -> High + /* STROBE ALL -> High */ GPSR2 = CORGI_GPIO_ALL_STROBE_BIT; GPDR2 |= CORGI_GPIO_ALL_STROBE_BIT; udelay(KB_DISCHARGE_DELAY); - // Clear any interrupts we may have triggered when altering the GPIO lines + /* Clear any interrupts we may have triggered when altering the GPIO lines */ GEDR1 = CORGI_GPIO_HIGH_SENSE_BIT; GEDR2 = CORGI_GPIO_LOW_SENSE_BIT; } static inline void corgikbd_activate_col(int col) { - // STROBE col -> High, not col -> HiZ + /* STROBE col -> High, not col -> HiZ */ GPSR2 = CORGI_GPIO_STROBE_BIT(col); GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col); } static inline void corgikbd_reset_col(int col) { - // STROBE col -> Low + /* STROBE col -> Low */ GPCR2 = CORGI_GPIO_STROBE_BIT(col); - // STROBE col -> out, not col -> HiZ + /* STROBE col -> out, not col -> HiZ */ GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col); } @@ -156,7 +137,7 @@ static inline void corgikbd_reset_col(int col) /* Scan the hardware keyboard and push any changes up through the input layer */ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs *regs) { - unsigned int row, col, rowd, scancode; + unsigned int row, col, rowd; unsigned long flags; unsigned int num_pressed; @@ -183,10 +164,21 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs rowd = GET_ROWS_STATUS(col); for (row = 0; row < KB_ROWS; row++) { + unsigned int scancode, pressed; + scancode = SCANCODE(row, col); - handle_scancode((rowd & KB_ROWMASK(row)), scancode, corgikbd_data); - if (rowd & KB_ROWMASK(row)) + pressed = rowd & KB_ROWMASK(row); + + input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); + + if (pressed) num_pressed++; + + if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) + && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { + input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); + corgikbd_data->suspend_jiffies=jiffies; + } } corgikbd_reset_col(col); } @@ -231,8 +223,11 @@ static void corgikbd_timer_callback(unsigned long data) * The hinge switches generate no interrupt so they need to be * monitored by a timer. * - * When we detect changes, we debounce it and then pass the three - * positions the system can take as keypresses to the input system. + * We debounce the switches and pass them to the input system. + * + * gprr == 0x00 - Keyboard with Landscape Screen + * 0x08 - No Keyboard with Portrait Screen + * 0x0c - Keyboard and Screen Closed */ #define HINGE_STABLE_COUNT 2 @@ -254,9 +249,9 @@ static void corgikbd_hinge_timer(unsigned long data) if (hinge_count >= HINGE_STABLE_COUNT) { spin_lock_irqsave(&corgikbd_data->lock, flags); - handle_scancode((sharpsl_hinge_state == 0x00), 125, corgikbd_data); /* Keyboard with Landscape Screen */ - handle_scancode((sharpsl_hinge_state == 0x08), 126, corgikbd_data); /* No Keyboard with Portrait Screen */ - handle_scancode((sharpsl_hinge_state == 0x0c), 127, corgikbd_data); /* Keyboard and Screen Closed */ + input_report_key(&corgikbd_data->input, corgikbd_data->keycode[125], (sharpsl_hinge_state == 0x00)); + input_report_key(&corgikbd_data->input, corgikbd_data->keycode[126], (sharpsl_hinge_state == 0x08)); + input_report_key(&corgikbd_data->input, corgikbd_data->keycode[127], (sharpsl_hinge_state == 0x0c)); input_sync(&corgikbd_data->input); spin_unlock_irqrestore(&corgikbd_data->lock, flags); -- cgit v1.2.3 From 347e4843fa1fc21bf542c6f086fcf5ef1ab5f58e Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:19:01 -0700 Subject: [PATCH] Corgi Touchscreen: Allow the driver to share the PMU The Corgi Touchscreen driver uses the PMU as an accurate timing source which conflicts with its usage for performance monitoring. This patch allows it to be shared with other users such as oprofile. Signed-off-by: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/touchscreen/corgi_ts.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 3f8b61cfbc37..9fcc7ca2c208 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c @@ -53,8 +53,8 @@ struct corgi_ts { #define SyncHS() while((STATUS_HSYNC) == 0); while((STATUS_HSYNC) != 0); #define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a)) -#define CCNT_ON() {int pmnc = 1; asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(pmnc));} -#define CCNT_OFF() {int pmnc = 0; asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(pmnc));} +#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) +#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) #define WAIT_HS_400_VGA 7013U // 17.615us #define WAIT_HS_400_QVGA 16622U // 41.750us @@ -96,14 +96,17 @@ static unsigned long calc_waittime(void) static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int address, unsigned long wait_time) { + unsigned long timer1 = 0, timer2, pmnc = 0; int pos = 0; - unsigned long timer1 = 0, timer2; int dosleep; dosleep = !w100fb_get_blanking(); if (dosleep && doSend) { - CCNT_ON(); + PMNC_GET(pmnc); + if (!(pmnc & 0x01)) + PMNC_SET(pmnc | 0x01); + /* polling HSync */ SyncHS(); /* get CCNT */ @@ -134,8 +137,8 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add CCNT(timer2); } corgi_ssp_ads7846_put(cmd); - if (dosleep) - CCNT_OFF(); + if (dosleep && !(pmnc & 0x01)) + PMNC_SET(pmnc); } return pos; } -- cgit v1.2.3 From 74b74890bc23b8c6f5b0c0d99f6e1b3d39cb3dae Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:19:02 -0700 Subject: [PATCH] Corgi Touchscreen: Code cleanup / fixes Clean up some Corgi Touchscreen logic and merge the repeat calls to w100fb_blanking() in anticipation of the w100fb patch. Fix a pm_message_t reference. Signed-off-by: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/touchscreen/corgi_ts.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 9fcc7ca2c208..768ab4a55630 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c @@ -79,6 +79,9 @@ static unsigned long calc_waittime(void) int w100fb_xres = w100fb_get_xres(); unsigned int waittime = 0; + if (w100fb_get_blanking()) + return 0; + if (w100fb_xres == 480 || w100fb_xres == 640) { waittime = WAIT_HS_400_VGA * get_clk_frequency_khz(0) / 398131U; @@ -98,11 +101,8 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add { unsigned long timer1 = 0, timer2, pmnc = 0; int pos = 0; - int dosleep; - - dosleep = !w100fb_get_blanking(); - if (dosleep && doSend) { + if (wait_time && doSend) { PMNC_GET(pmnc); if (!(pmnc & 0x01)) PMNC_SET(pmnc | 0x01); @@ -122,11 +122,11 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add corgi_ssp_ads7846_put(cmd); corgi_ssp_ads7846_get(); - if (dosleep) { + if (wait_time) { /* Wait after HSync */ CCNT(timer2); if (timer2-timer1 > wait_time) { - /* timeout */ + /* too slow - timeout, try again */ SyncHS(); /* get OSCR */ CCNT(timer1); @@ -137,7 +137,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add CCNT(timer2); } corgi_ssp_ads7846_put(cmd); - if (dosleep && !(pmnc & 0x01)) + if (wait_time && !(pmnc & 0x01)) PMNC_SET(pmnc); } return pos; @@ -247,7 +247,7 @@ static irqreturn_t ts_interrupt(int irq, void *dev_id, struct pt_regs *regs) } #ifdef CONFIG_PM -static int corgits_suspend(struct device *dev, uint32_t state, uint32_t level) +static int corgits_suspend(struct device *dev, pm_message_t state, uint32_t level) { if (level == SUSPEND_POWER_DOWN) { struct corgi_ts *corgi_ts = dev_get_drvdata(dev); -- cgit v1.2.3 From 8cc3c7af42aa826d413e3134628d85f3920457d8 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:19:02 -0700 Subject: [PATCH] Corgi touchscreen: Fix a pmu bug Corgi Touchscreen bugfix. If the PMU isn't running, the register needs to be set to a sane value rather than reusing some random value. Signed-off-by: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/touchscreen/corgi_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 768ab4a55630..512940ecb357 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c @@ -105,7 +105,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add if (wait_time && doSend) { PMNC_GET(pmnc); if (!(pmnc & 0x01)) - PMNC_SET(pmnc | 0x01); + PMNC_SET(0x01); /* polling HSync */ SyncHS(); -- cgit v1.2.3 From 41b1bce80b43f7c6a6c64006b2abe3a8d52ab120 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:19:05 -0700 Subject: [PATCH] w100fb: Update corgi platform code to match new driver This patch moves the platform specific Sharp SL-C7x0 LCD code from the w100fb driver into a more appropriate place and updates the Corgi code to match the new w100fb driver. It also updates the corgi touchscreen code to match the new simplified interface available from w100fb. Signed-off-by: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/touchscreen/corgi_ts.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 512940ecb357..5d19261b884f 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c @@ -56,9 +56,6 @@ struct corgi_ts { #define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) #define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) -#define WAIT_HS_400_VGA 7013U // 17.615us -#define WAIT_HS_400_QVGA 16622U // 41.750us - /* ADS7846 Touch Screen Controller bit definitions */ #define ADSCTRL_PD0 (1u << 0) /* PD0 */ @@ -69,32 +66,17 @@ struct corgi_ts { #define ADSCTRL_STS (1u << 7) /* Start Bit */ /* External Functions */ -extern int w100fb_get_xres(void); -extern int w100fb_get_blanking(void); -extern int w100fb_get_fastsysclk(void); +extern unsigned long w100fb_get_hsynclen(struct device *dev); extern unsigned int get_clk_frequency_khz(int info); static unsigned long calc_waittime(void) { - int w100fb_xres = w100fb_get_xres(); - unsigned int waittime = 0; + unsigned long hsync_len = w100fb_get_hsynclen(&corgifb_device.dev); - if (w100fb_get_blanking()) + if (hsync_len) + return get_clk_frequency_khz(0)*1000/hsync_len; + else return 0; - - if (w100fb_xres == 480 || w100fb_xres == 640) { - waittime = WAIT_HS_400_VGA * get_clk_frequency_khz(0) / 398131U; - - if (w100fb_get_fastsysclk() == 100) - waittime = waittime * 75 / 100; - - if (w100fb_xres == 640) - waittime *= 3; - - return waittime; - } - - return WAIT_HS_400_QVGA * get_clk_frequency_khz(0) / 398131U; } static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int address, unsigned long wait_time) -- cgit v1.2.3 From 3158106685acac8f8d4e74a17b974f160fe77c0b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 6 Sep 2005 15:19:06 -0700 Subject: [PATCH] Input: Add a new switch event type The corgi keyboard has need of a switch event type with slightly type to the input system as recommended by the input maintainer. Signed-off-by: Richard Purdie Cc: Vojtech Pavlik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/input/evdev.c | 8 ++++++++ drivers/input/input.c | 11 +++++++++++ drivers/input/keyboard/corgikbd.c | 9 +++++---- 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index f8b278d3559b..19c14c4beb44 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -393,6 +393,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case EV_LED: bits = dev->ledbit; len = LED_MAX; break; case EV_SND: bits = dev->sndbit; len = SND_MAX; break; case EV_FF: bits = dev->ffbit; len = FF_MAX; break; + case EV_SW: bits = dev->swbit; len = SW_MAX; break; default: return -EINVAL; } len = NBITS(len) * sizeof(long); @@ -421,6 +422,13 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return copy_to_user(p, dev->snd, len) ? -EFAULT : len; } + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSW(0))) { + int len; + len = NBITS(SW_MAX) * sizeof(long); + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); + return copy_to_user(p, dev->sw, len) ? -EFAULT : len; + } + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { int len; if (!dev->name) return -ENOENT; diff --git a/drivers/input/input.c b/drivers/input/input.c index a275211c8e1e..88636a204525 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -89,6 +89,15 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in break; + case EV_SW: + + if (code > SW_MAX || !test_bit(code, dev->swbit) || !!test_bit(code, dev->sw) == value) + return; + + change_bit(code, dev->sw); + + break; + case EV_ABS: if (code > ABS_MAX || !test_bit(code, dev->absbit)) @@ -402,6 +411,7 @@ static void input_call_hotplug(char *verb, struct input_dev *dev) SPRINTF_BIT_A2(ledbit, "LED=", LED_MAX, EV_LED); SPRINTF_BIT_A2(sndbit, "SND=", SND_MAX, EV_SND); SPRINTF_BIT_A2(ffbit, "FF=", FF_MAX, EV_FF); + SPRINTF_BIT_A2(swbit, "SW=", SW_MAX, EV_SW); envp[i++] = NULL; @@ -490,6 +500,7 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED); SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND); SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF); + SPRINTF_BIT_B2(swbit, "SW=", SW_MAX, EV_SW); len += sprintf(buf + len, "\n"); diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 767e853dd766..cd4b6e795013 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -249,9 +249,8 @@ static void corgikbd_hinge_timer(unsigned long data) if (hinge_count >= HINGE_STABLE_COUNT) { spin_lock_irqsave(&corgikbd_data->lock, flags); - input_report_key(&corgikbd_data->input, corgikbd_data->keycode[125], (sharpsl_hinge_state == 0x00)); - input_report_key(&corgikbd_data->input, corgikbd_data->keycode[126], (sharpsl_hinge_state == 0x08)); - input_report_key(&corgikbd_data->input, corgikbd_data->keycode[127], (sharpsl_hinge_state == 0x0c)); + input_report_switch(&corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); + input_report_switch(&corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); input_sync(&corgikbd_data->input); spin_unlock_irqrestore(&corgikbd_data->lock, flags); @@ -321,7 +320,7 @@ static int __init corgikbd_probe(struct device *dev) corgikbd->input.id.vendor = 0x0001; corgikbd->input.id.product = 0x0001; corgikbd->input.id.version = 0x0100; - corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR); + corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); corgikbd->input.keycode = corgikbd->keycode; corgikbd->input.keycodesize = sizeof(unsigned char); corgikbd->input.keycodemax = ARRAY_SIZE(corgikbd_keycode); @@ -330,6 +329,8 @@ static int __init corgikbd_probe(struct device *dev) for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) set_bit(corgikbd->keycode[i], corgikbd->input.keybit); clear_bit(0, corgikbd->input.keybit); + set_bit(SW_0, corgikbd->input.swbit); + set_bit(SW_1, corgikbd->input.swbit); input_register_device(&corgikbd->input); mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); -- cgit v1.2.3 From 01703597ead8194b46932ba2bcda897e872e91e0 Mon Sep 17 00:00:00 2001 From: "viro@ZenIV.linux.org.uk" Date: Fri, 9 Sep 2005 20:29:12 +0100 Subject: [PATCH] trivial __user annotations (evdev) Signed-off-by: Al Viro Signed-off-by: Linus Torvalds --- drivers/input/evdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input') diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 19c14c4beb44..60b696e9336b 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -509,7 +509,7 @@ do { \ int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ for (i = 0; i < len / sizeof(compat_long_t); i++) \ - if (copy_to_user((compat_long_t*) p + i, \ + if (copy_to_user((compat_long_t __user *) p + i, \ (compat_long_t*) (bit) + i + 1 - ((i % 2) << 1), \ sizeof(compat_long_t))) \ return -EFAULT; \ -- cgit v1.2.3