From a5516b88a6ecd1408a6879f184be4cb8dbc37f18 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 16 Sep 2009 01:06:43 -0700 Subject: [PATCH] --- yaml --- r: 165587 b: refs/heads/master c: ffd0db97196c1057f09c2ab42dd5b30e94e511d9 h: refs/heads/master i: 165585: d1ffc4ffa3efc4ad98bc3a098d201c9cbd6e0ceb 165583: 317f36dfdb9b501adb634fc3b465e84d5712da4c v: v3 --- [refs] | 2 +- trunk/drivers/input/input.c | 64 ++++++++++++++++++++++++++++++++++++- trunk/include/linux/input.h | 2 +- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 2e1d7408f7e1..1a8f77268365 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 181d683d752c432635eda0f182ee71548c1f1820 +refs/heads/master: ffd0db97196c1057f09c2ab42dd5b30e94e511d9 diff --git a/trunk/drivers/input/input.c b/trunk/drivers/input/input.c index 7c237e6ac711..b8ed4294fccd 100644 --- a/trunk/drivers/input/input.c +++ b/trunk/drivers/input/input.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -514,7 +515,7 @@ static void input_disconnect_device(struct input_dev *dev) * that there are no threads in the middle of input_open_device() */ mutex_lock(&dev->mutex); - dev->going_away = 1; + dev->going_away = true; mutex_unlock(&dev->mutex); spin_lock_irq(&dev->event_lock); @@ -1259,10 +1260,71 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) return 0; } +#define INPUT_DO_TOGGLE(dev, type, bits, on) \ + do { \ + int i; \ + if (!test_bit(EV_##type, dev->evbit)) \ + break; \ + for (i = 0; i < type##_MAX; i++) { \ + if (!test_bit(i, dev->bits##bit) || \ + !test_bit(i, dev->bits)) \ + continue; \ + dev->event(dev, EV_##type, i, on); \ + } \ + } while (0) + +static void input_dev_reset(struct input_dev *dev, bool activate) +{ + if (!dev->event) + return; + + INPUT_DO_TOGGLE(dev, LED, led, activate); + INPUT_DO_TOGGLE(dev, SND, snd, activate); + + if (activate && test_bit(EV_REP, dev->evbit)) { + dev->event(dev, EV_REP, REP_PERIOD, dev->rep[REP_PERIOD]); + dev->event(dev, EV_REP, REP_DELAY, dev->rep[REP_DELAY]); + } +} + +#ifdef CONFIG_PM +static int input_dev_suspend(struct device *dev) +{ + struct input_dev *input_dev = to_input_dev(dev); + + mutex_lock(&input_dev->mutex); + input_dev_reset(input_dev, false); + mutex_unlock(&input_dev->mutex); + + return 0; +} + +static int input_dev_resume(struct device *dev) +{ + struct input_dev *input_dev = to_input_dev(dev); + + mutex_lock(&input_dev->mutex); + input_dev_reset(input_dev, true); + mutex_unlock(&input_dev->mutex); + + return 0; +} + +static const struct dev_pm_ops input_dev_pm_ops = { + .suspend = input_dev_suspend, + .resume = input_dev_resume, + .poweroff = input_dev_suspend, + .restore = input_dev_resume, +}; +#endif /* CONFIG_PM */ + static struct device_type input_dev_type = { .groups = input_dev_attr_groups, .release = input_dev_release, .uevent = input_dev_uevent, +#ifdef CONFIG_PM + .pm = &input_dev_pm_ops, +#endif }; static char *input_nodename(struct device *dev) diff --git a/trunk/include/linux/input.h b/trunk/include/linux/input.h index 8b3bc3e0d146..0ccfc30cd40f 100644 --- a/trunk/include/linux/input.h +++ b/trunk/include/linux/input.h @@ -1123,7 +1123,7 @@ struct input_dev { struct mutex mutex; unsigned int users; - int going_away; + bool going_away; struct device dev;