diff options
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/evdev.c | 7 | ||||
-rw-r--r-- | drivers/input/keyboard/cros_ec_keyb.c | 70 | ||||
-rw-r--r-- | drivers/input/keyboard/lm8323.c | 22 | ||||
-rw-r--r-- | drivers/input/misc/sparcspkr.c | 22 |
4 files changed, 66 insertions, 55 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index fd325ec9f064..de055451d1af 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -108,9 +108,8 @@ static void evdev_queue_syn_dropped(struct evdev_client *client) | |||
108 | struct input_event ev; | 108 | struct input_event ev; |
109 | ktime_t time; | 109 | ktime_t time; |
110 | 110 | ||
111 | time = ktime_get(); | 111 | time = (client->clkid == CLOCK_MONOTONIC) ? |
112 | if (client->clkid != CLOCK_MONOTONIC) | 112 | ktime_get() : ktime_get_real(); |
113 | time = ktime_sub(time, ktime_get_monotonic_offset()); | ||
114 | 113 | ||
115 | ev.time = ktime_to_timeval(time); | 114 | ev.time = ktime_to_timeval(time); |
116 | ev.type = EV_SYN; | 115 | ev.type = EV_SYN; |
@@ -202,7 +201,7 @@ static void evdev_events(struct input_handle *handle, | |||
202 | ktime_t time_mono, time_real; | 201 | ktime_t time_mono, time_real; |
203 | 202 | ||
204 | time_mono = ktime_get(); | 203 | time_mono = ktime_get(); |
205 | time_real = ktime_sub(time_mono, ktime_get_monotonic_offset()); | 204 | time_real = ktime_mono_to_real(time_mono); |
206 | 205 | ||
207 | rcu_read_lock(); | 206 | rcu_read_lock(); |
208 | 207 | ||
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index 408379669d3c..791781ade4e7 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c | |||
@@ -24,8 +24,8 @@ | |||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/input.h> | 26 | #include <linux/input.h> |
27 | #include <linux/interrupt.h> | ||
27 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
28 | #include <linux/notifier.h> | ||
29 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/input/matrix_keypad.h> | 31 | #include <linux/input/matrix_keypad.h> |
@@ -42,7 +42,6 @@ | |||
42 | * @dev: Device pointer | 42 | * @dev: Device pointer |
43 | * @idev: Input device | 43 | * @idev: Input device |
44 | * @ec: Top level ChromeOS device to use to talk to EC | 44 | * @ec: Top level ChromeOS device to use to talk to EC |
45 | * @event_notifier: interrupt event notifier for transport devices | ||
46 | */ | 45 | */ |
47 | struct cros_ec_keyb { | 46 | struct cros_ec_keyb { |
48 | unsigned int rows; | 47 | unsigned int rows; |
@@ -55,7 +54,6 @@ struct cros_ec_keyb { | |||
55 | struct device *dev; | 54 | struct device *dev; |
56 | struct input_dev *idev; | 55 | struct input_dev *idev; |
57 | struct cros_ec_device *ec; | 56 | struct cros_ec_device *ec; |
58 | struct notifier_block notifier; | ||
59 | }; | 57 | }; |
60 | 58 | ||
61 | 59 | ||
@@ -173,41 +171,55 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev, | |||
173 | input_sync(ckdev->idev); | 171 | input_sync(ckdev->idev); |
174 | } | 172 | } |
175 | 173 | ||
176 | static int cros_ec_keyb_open(struct input_dev *dev) | ||
177 | { | ||
178 | struct cros_ec_keyb *ckdev = input_get_drvdata(dev); | ||
179 | |||
180 | return blocking_notifier_chain_register(&ckdev->ec->event_notifier, | ||
181 | &ckdev->notifier); | ||
182 | } | ||
183 | |||
184 | static void cros_ec_keyb_close(struct input_dev *dev) | ||
185 | { | ||
186 | struct cros_ec_keyb *ckdev = input_get_drvdata(dev); | ||
187 | |||
188 | blocking_notifier_chain_unregister(&ckdev->ec->event_notifier, | ||
189 | &ckdev->notifier); | ||
190 | } | ||
191 | |||
192 | static int cros_ec_keyb_get_state(struct cros_ec_keyb *ckdev, uint8_t *kb_state) | 174 | static int cros_ec_keyb_get_state(struct cros_ec_keyb *ckdev, uint8_t *kb_state) |
193 | { | 175 | { |
194 | return ckdev->ec->command_recv(ckdev->ec, EC_CMD_MKBP_STATE, | 176 | struct cros_ec_command msg = { |
195 | kb_state, ckdev->cols); | 177 | .version = 0, |
178 | .command = EC_CMD_MKBP_STATE, | ||
179 | .outdata = NULL, | ||
180 | .outsize = 0, | ||
181 | .indata = kb_state, | ||
182 | .insize = ckdev->cols, | ||
183 | }; | ||
184 | |||
185 | return ckdev->ec->cmd_xfer(ckdev->ec, &msg); | ||
196 | } | 186 | } |
197 | 187 | ||
198 | static int cros_ec_keyb_work(struct notifier_block *nb, | 188 | static irqreturn_t cros_ec_keyb_irq(int irq, void *data) |
199 | unsigned long state, void *_notify) | ||
200 | { | 189 | { |
190 | struct cros_ec_keyb *ckdev = data; | ||
191 | struct cros_ec_device *ec = ckdev->ec; | ||
201 | int ret; | 192 | int ret; |
202 | struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb, | ||
203 | notifier); | ||
204 | uint8_t kb_state[ckdev->cols]; | 193 | uint8_t kb_state[ckdev->cols]; |
205 | 194 | ||
195 | if (device_may_wakeup(ec->dev)) | ||
196 | pm_wakeup_event(ec->dev, 0); | ||
197 | |||
206 | ret = cros_ec_keyb_get_state(ckdev, kb_state); | 198 | ret = cros_ec_keyb_get_state(ckdev, kb_state); |
207 | if (ret >= 0) | 199 | if (ret >= 0) |
208 | cros_ec_keyb_process(ckdev, kb_state, ret); | 200 | cros_ec_keyb_process(ckdev, kb_state, ret); |
201 | else | ||
202 | dev_err(ec->dev, "failed to get keyboard state: %d\n", ret); | ||
209 | 203 | ||
210 | return NOTIFY_DONE; | 204 | return IRQ_HANDLED; |
205 | } | ||
206 | |||
207 | static int cros_ec_keyb_open(struct input_dev *dev) | ||
208 | { | ||
209 | struct cros_ec_keyb *ckdev = input_get_drvdata(dev); | ||
210 | struct cros_ec_device *ec = ckdev->ec; | ||
211 | |||
212 | return request_threaded_irq(ec->irq, NULL, cros_ec_keyb_irq, | ||
213 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
214 | "cros_ec_keyb", ckdev); | ||
215 | } | ||
216 | |||
217 | static void cros_ec_keyb_close(struct input_dev *dev) | ||
218 | { | ||
219 | struct cros_ec_keyb *ckdev = input_get_drvdata(dev); | ||
220 | struct cros_ec_device *ec = ckdev->ec; | ||
221 | |||
222 | free_irq(ec->irq, ckdev); | ||
211 | } | 223 | } |
212 | 224 | ||
213 | static int cros_ec_keyb_probe(struct platform_device *pdev) | 225 | static int cros_ec_keyb_probe(struct platform_device *pdev) |
@@ -238,8 +250,12 @@ static int cros_ec_keyb_probe(struct platform_device *pdev) | |||
238 | if (!idev) | 250 | if (!idev) |
239 | return -ENOMEM; | 251 | return -ENOMEM; |
240 | 252 | ||
253 | if (!ec->irq) { | ||
254 | dev_err(dev, "no EC IRQ specified\n"); | ||
255 | return -EINVAL; | ||
256 | } | ||
257 | |||
241 | ckdev->ec = ec; | 258 | ckdev->ec = ec; |
242 | ckdev->notifier.notifier_call = cros_ec_keyb_work; | ||
243 | ckdev->dev = dev; | 259 | ckdev->dev = dev; |
244 | dev_set_drvdata(&pdev->dev, ckdev); | 260 | dev_set_drvdata(&pdev->dev, ckdev); |
245 | 261 | ||
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c index 0b42118cbf8f..cb32e2b506b7 100644 --- a/drivers/input/keyboard/lm8323.c +++ b/drivers/input/keyboard/lm8323.c | |||
@@ -558,6 +558,12 @@ static ssize_t lm8323_pwm_store_time(struct device *dev, | |||
558 | } | 558 | } |
559 | static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time); | 559 | static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time); |
560 | 560 | ||
561 | static struct attribute *lm8323_pwm_attrs[] = { | ||
562 | &dev_attr_time.attr, | ||
563 | NULL | ||
564 | }; | ||
565 | ATTRIBUTE_GROUPS(lm8323_pwm); | ||
566 | |||
561 | static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev, | 567 | static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev, |
562 | const char *name) | 568 | const char *name) |
563 | { | 569 | { |
@@ -580,16 +586,11 @@ static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev, | |||
580 | if (name) { | 586 | if (name) { |
581 | pwm->cdev.name = name; | 587 | pwm->cdev.name = name; |
582 | pwm->cdev.brightness_set = lm8323_pwm_set_brightness; | 588 | pwm->cdev.brightness_set = lm8323_pwm_set_brightness; |
589 | pwm->cdev.groups = lm8323_pwm_groups; | ||
583 | if (led_classdev_register(dev, &pwm->cdev) < 0) { | 590 | if (led_classdev_register(dev, &pwm->cdev) < 0) { |
584 | dev_err(dev, "couldn't register PWM %d\n", id); | 591 | dev_err(dev, "couldn't register PWM %d\n", id); |
585 | return -1; | 592 | return -1; |
586 | } | 593 | } |
587 | if (device_create_file(pwm->cdev.dev, | ||
588 | &dev_attr_time) < 0) { | ||
589 | dev_err(dev, "couldn't register time attribute\n"); | ||
590 | led_classdev_unregister(&pwm->cdev); | ||
591 | return -1; | ||
592 | } | ||
593 | pwm->enabled = true; | 594 | pwm->enabled = true; |
594 | } | 595 | } |
595 | 596 | ||
@@ -753,11 +754,8 @@ fail3: | |||
753 | device_remove_file(&client->dev, &dev_attr_disable_kp); | 754 | device_remove_file(&client->dev, &dev_attr_disable_kp); |
754 | fail2: | 755 | fail2: |
755 | while (--pwm >= 0) | 756 | while (--pwm >= 0) |
756 | if (lm->pwm[pwm].enabled) { | 757 | if (lm->pwm[pwm].enabled) |
757 | device_remove_file(lm->pwm[pwm].cdev.dev, | ||
758 | &dev_attr_time); | ||
759 | led_classdev_unregister(&lm->pwm[pwm].cdev); | 758 | led_classdev_unregister(&lm->pwm[pwm].cdev); |
760 | } | ||
761 | fail1: | 759 | fail1: |
762 | input_free_device(idev); | 760 | input_free_device(idev); |
763 | kfree(lm); | 761 | kfree(lm); |
@@ -777,10 +775,8 @@ static int lm8323_remove(struct i2c_client *client) | |||
777 | device_remove_file(&lm->client->dev, &dev_attr_disable_kp); | 775 | device_remove_file(&lm->client->dev, &dev_attr_disable_kp); |
778 | 776 | ||
779 | for (i = 0; i < 3; i++) | 777 | for (i = 0; i < 3; i++) |
780 | if (lm->pwm[i].enabled) { | 778 | if (lm->pwm[i].enabled) |
781 | device_remove_file(lm->pwm[i].cdev.dev, &dev_attr_time); | ||
782 | led_classdev_unregister(&lm->pwm[i].cdev); | 779 | led_classdev_unregister(&lm->pwm[i].cdev); |
783 | } | ||
784 | 780 | ||
785 | kfree(lm); | 781 | kfree(lm); |
786 | 782 | ||
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index 65fd3150919b..179ff1cd6f6b 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c | |||
@@ -86,13 +86,13 @@ static int bbc_spkr_event(struct input_dev *dev, unsigned int type, unsigned int | |||
86 | spin_lock_irqsave(&state->lock, flags); | 86 | spin_lock_irqsave(&state->lock, flags); |
87 | 87 | ||
88 | if (count) { | 88 | if (count) { |
89 | outb(0x01, info->regs + 0); | 89 | sbus_writeb(0x01, info->regs + 0); |
90 | outb(0x00, info->regs + 2); | 90 | sbus_writeb(0x00, info->regs + 2); |
91 | outb((count >> 16) & 0xff, info->regs + 3); | 91 | sbus_writeb((count >> 16) & 0xff, info->regs + 3); |
92 | outb((count >> 8) & 0xff, info->regs + 4); | 92 | sbus_writeb((count >> 8) & 0xff, info->regs + 4); |
93 | outb(0x00, info->regs + 5); | 93 | sbus_writeb(0x00, info->regs + 5); |
94 | } else { | 94 | } else { |
95 | outb(0x00, info->regs + 0); | 95 | sbus_writeb(0x00, info->regs + 0); |
96 | } | 96 | } |
97 | 97 | ||
98 | spin_unlock_irqrestore(&state->lock, flags); | 98 | spin_unlock_irqrestore(&state->lock, flags); |
@@ -123,15 +123,15 @@ static int grover_spkr_event(struct input_dev *dev, unsigned int type, unsigned | |||
123 | 123 | ||
124 | if (count) { | 124 | if (count) { |
125 | /* enable counter 2 */ | 125 | /* enable counter 2 */ |
126 | outb(inb(info->enable_reg) | 3, info->enable_reg); | 126 | sbus_writeb(sbus_readb(info->enable_reg) | 3, info->enable_reg); |
127 | /* set command for counter 2, 2 byte write */ | 127 | /* set command for counter 2, 2 byte write */ |
128 | outb(0xB6, info->freq_regs + 1); | 128 | sbus_writeb(0xB6, info->freq_regs + 1); |
129 | /* select desired HZ */ | 129 | /* select desired HZ */ |
130 | outb(count & 0xff, info->freq_regs + 0); | 130 | sbus_writeb(count & 0xff, info->freq_regs + 0); |
131 | outb((count >> 8) & 0xff, info->freq_regs + 0); | 131 | sbus_writeb((count >> 8) & 0xff, info->freq_regs + 0); |
132 | } else { | 132 | } else { |
133 | /* disable counter 2 */ | 133 | /* disable counter 2 */ |
134 | outb(inb_p(info->enable_reg) & 0xFC, info->enable_reg); | 134 | sbus_writeb(sbus_readb(info->enable_reg) & 0xFC, info->enable_reg); |
135 | } | 135 | } |
136 | 136 | ||
137 | spin_unlock_irqrestore(&state->lock, flags); | 137 | spin_unlock_irqrestore(&state->lock, flags); |