From 9e4cc255e6e18418ddbeea447efa506bb43d57a2 Mon Sep 17 00:00:00 2001 From: "H. Nikolaus Schaller" Date: Mon, 25 Apr 2016 14:02:16 -0700 Subject: Input: twl6040-vibra - remove mutex The mutex does not seem to be needed. twl4030-vibra doesn't use one either. Signed-off-by: H. Nikolaus Schaller Signed-off-by: Dmitry Torokhov --- drivers/input/misc/twl6040-vibra.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index ea63fad48de6..36c8182b7bd2 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c @@ -47,7 +47,7 @@ struct vibra_info { struct input_dev *input_dev; struct workqueue_struct *workqueue; struct work_struct play_work; - struct mutex mutex; + int irq; bool enabled; @@ -183,8 +183,6 @@ static void vibra_play_work(struct work_struct *work) struct vibra_info *info = container_of(work, struct vibra_info, play_work); - mutex_lock(&info->mutex); - if (info->weak_speed || info->strong_speed) { if (!info->enabled) twl6040_vibra_enable(info); @@ -193,7 +191,6 @@ static void vibra_play_work(struct work_struct *work) } else if (info->enabled) twl6040_vibra_disable(info); - mutex_unlock(&info->mutex); } static int vibra_play(struct input_dev *input, void *data, @@ -228,12 +225,8 @@ static void twl6040_vibra_close(struct input_dev *input) cancel_work_sync(&info->play_work); - mutex_lock(&info->mutex); - if (info->enabled) twl6040_vibra_disable(info); - - mutex_unlock(&info->mutex); } static int __maybe_unused twl6040_vibra_suspend(struct device *dev) @@ -241,13 +234,11 @@ static int __maybe_unused twl6040_vibra_suspend(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct vibra_info *info = platform_get_drvdata(pdev); - mutex_lock(&info->mutex); + cancel_work_sync(&info->play_work); if (info->enabled) twl6040_vibra_disable(info); - mutex_unlock(&info->mutex); - return 0; } @@ -305,8 +296,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev) return -EINVAL; } - mutex_init(&info->mutex); - error = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, twl6040_vib_irq_handler, IRQF_ONESHOT, -- cgit v1.2.3 From c90a0f08fedc57e2b8ff871cc036cdbdde683de4 Mon Sep 17 00:00:00 2001 From: Florian Euchner Date: Wed, 4 May 2016 15:59:18 -0700 Subject: Input: cm109 - fix handling of volume and mute buttons The CM109 driver reported key press events of volume up / down and record / playback mute buttons, but no release events. Report those events properly by handling volume and mute keys seperately. For the record and playback mute buttons, only presses are registered by the CM109, therefore simulate press-n-release. This fixes the volume control buttons of various USB headsets. Signed-off-by: Florian Euchner Signed-off-by: Dmitry Torokhov --- drivers/input/misc/cm109.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c index 9365535ba7f1..ee1bedd7c54c 100644 --- a/drivers/input/misc/cm109.c +++ b/drivers/input/misc/cm109.c @@ -76,8 +76,8 @@ enum { BUZZER_ON = 1 << 5, - /* up to 256 normal keys, up to 16 special keys */ - KEYMAP_SIZE = 256 + 16, + /* up to 256 normal keys, up to 15 special key combinations */ + KEYMAP_SIZE = 256 + 15, }; /* CM109 protocol packet */ @@ -139,7 +139,7 @@ static unsigned short special_keymap(int code) { if (code > 0xff) { switch (code - 0xff) { - case RECORD_MUTE: return KEY_MUTE; + case RECORD_MUTE: return KEY_MICMUTE; case PLAYBACK_MUTE: return KEY_MUTE; case VOLUME_DOWN: return KEY_VOLUMEDOWN; case VOLUME_UP: return KEY_VOLUMEUP; @@ -312,6 +312,32 @@ static void report_key(struct cm109_dev *dev, int key) input_sync(idev); } +/* + * Converts data of special key presses (volume, mute) into events + * for the input subsystem, sends press-n-release for mute keys. + */ +static void cm109_report_special(struct cm109_dev *dev) +{ + static const u8 autorelease = RECORD_MUTE | PLAYBACK_MUTE; + struct input_dev *idev = dev->idev; + u8 data = dev->irq_data->byte[HID_IR0]; + unsigned short keycode; + int i; + + for (i = 0; i < 4; i++) { + keycode = dev->keymap[0xff + BIT(i)]; + if (keycode == KEY_RESERVED) + continue; + + input_report_key(idev, keycode, data & BIT(i)); + if (data & autorelease & BIT(i)) { + input_sync(idev); + input_report_key(idev, keycode, 0); + } + } + input_sync(idev); +} + /****************************************************************************** * CM109 usb communication interface *****************************************************************************/ @@ -357,10 +383,7 @@ static void cm109_urb_irq_callback(struct urb *urb) } /* Special keys */ - if (dev->irq_data->byte[HID_IR0] & 0x0f) { - const int code = (dev->irq_data->byte[HID_IR0] & 0x0f); - report_key(dev, dev->keymap[0xff + code]); - } + cm109_report_special(dev); /* Scan key column */ if (dev->keybit == 0xf) { -- cgit v1.2.3 From d144cf42eee0eabdb2e76ea67a9b0437c5070751 Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Mon, 2 May 2016 11:15:01 -0700 Subject: Input: cm109 - spin_lock in complete() cleanup Complete() will be run with interrupt enabled, so change to spin_lock_irqsave(). Signed-off-by: Ming Lei Signed-off-by: Dmitry Torokhov --- drivers/input/misc/cm109.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c index ee1bedd7c54c..9cc6d057c302 100644 --- a/drivers/input/misc/cm109.c +++ b/drivers/input/misc/cm109.c @@ -366,6 +366,7 @@ static void cm109_urb_irq_callback(struct urb *urb) struct cm109_dev *dev = urb->context; const int status = urb->status; int error; + unsigned long flags; dev_dbg(&dev->intf->dev, "### URB IRQ: [0x%02x 0x%02x 0x%02x 0x%02x] keybit=0x%02x\n", dev->irq_data->byte[0], @@ -404,7 +405,7 @@ static void cm109_urb_irq_callback(struct urb *urb) out: - spin_lock(&dev->ctl_submit_lock); + spin_lock_irqsave(&dev->ctl_submit_lock, flags); dev->irq_urb_pending = 0; @@ -428,7 +429,7 @@ static void cm109_urb_irq_callback(struct urb *urb) __func__, error); } - spin_unlock(&dev->ctl_submit_lock); + spin_unlock_irqrestore(&dev->ctl_submit_lock, flags); } static void cm109_urb_ctl_callback(struct urb *urb) @@ -436,6 +437,7 @@ static void cm109_urb_ctl_callback(struct urb *urb) struct cm109_dev *dev = urb->context; const int status = urb->status; int error; + unsigned long flags; dev_dbg(&dev->intf->dev, "### URB CTL: [0x%02x 0x%02x 0x%02x 0x%02x]\n", dev->ctl_data->byte[0], @@ -450,7 +452,7 @@ static void cm109_urb_ctl_callback(struct urb *urb) __func__, status); } - spin_lock(&dev->ctl_submit_lock); + spin_lock_irqsave(&dev->ctl_submit_lock, flags); dev->ctl_urb_pending = 0; @@ -471,7 +473,7 @@ static void cm109_urb_ctl_callback(struct urb *urb) } } - spin_unlock(&dev->ctl_submit_lock); + spin_unlock_irqrestore(&dev->ctl_submit_lock, flags); } static void cm109_toggle_buzzer_async(struct cm109_dev *dev) -- cgit v1.2.3 From d96caf8c33cad42b5eabcf1b686dd91581e306f4 Mon Sep 17 00:00:00 2001 From: Clifton Barnes Date: Mon, 9 May 2016 17:00:22 -0700 Subject: Input: rotary-encoder - fix bare use of 'unsigned' fix checkpatch.pl warning about 'Prefer 'unsigned int' to bare use of 'unsigned'' Signed-off-by: Clifton Barnes Signed-off-by: Dmitry Torokhov --- drivers/input/misc/rotary_encoder.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/input/misc') diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 96c486de49e0..c7fc8d4fb080 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c @@ -47,13 +47,13 @@ struct rotary_encoder { bool armed; signed char dir; /* 1 - clockwise, -1 - CCW */ - unsigned last_stable; + unsigned int last_stable; }; -static unsigned rotary_encoder_get_state(struct rotary_encoder *encoder) +static unsigned int rotary_encoder_get_state(struct rotary_encoder *encoder) { int i; - unsigned ret = 0; + unsigned int ret = 0; for (i = 0; i < encoder->gpios->ndescs; ++i) { int val = gpiod_get_value_cansleep(encoder->gpios->desc[i]); @@ -100,7 +100,7 @@ static void rotary_encoder_report_event(struct rotary_encoder *encoder) static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) { struct rotary_encoder *encoder = dev_id; - unsigned state; + unsigned int state; mutex_lock(&encoder->access_mutex); -- cgit v1.2.3