Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7476
b: refs/heads/master
c: 8240a4a
h: refs/heads/master
v: v3
  • Loading branch information
Richard Purdie authored and Linus Torvalds committed Sep 7, 2005
1 parent 0ae6477 commit f4fc83d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aba5a4c055dde13a3cece53e1b4b060294d631ed
refs/heads/master: 8240a4a4bc95814502da522d5ee929fe0f0dc679
42 changes: 41 additions & 1 deletion trunk/drivers/input/keyboard/corgikbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/init.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <asm/irq.h>
Expand Down Expand Up @@ -78,15 +79,21 @@ 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)
{
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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f4fc83d

Please sign in to comment.