From: "David Härdeman" <david@hardeman.nu>
To: linux-media@vger.kernel.org
Cc: m.chehab@samsung.com
Subject: [PATCH 35/49] rc-core: remove redundant spinlock
Date: Fri, 04 Apr 2014 01:34:13 +0200 [thread overview]
Message-ID: <20140403233413.27099.9024.stgit@zeus.muc.hardeman.nu> (raw)
In-Reply-To: <20140403232420.27099.94872.stgit@zeus.muc.hardeman.nu>
Remove a redundant spinlock from struct rc_map.
Signed-off-by: David Härdeman <david@hardeman.nu>
---
drivers/media/rc/rc-keytable.c | 43 +++++++++++++++++-----------------------
include/media/rc-core.h | 4 ++--
include/media/rc-map.h | 1 -
3 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/drivers/media/rc/rc-keytable.c b/drivers/media/rc/rc-keytable.c
index 6d04b8f..f4d03d2 100644
--- a/drivers/media/rc/rc-keytable.c
+++ b/drivers/media/rc/rc-keytable.c
@@ -381,7 +381,7 @@ static int ir_setkeycode(struct input_dev *idev,
entry.keycode = ke->keycode;
- spin_lock_irqsave(&rc_map->lock, flags);
+ spin_lock_irqsave(&kt->lock, flags);
if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
index = ke->index;
@@ -430,7 +430,7 @@ static int ir_setkeycode(struct input_dev *idev,
*old_keycode = ir_update_mapping(kt, rc_map, index, ke->keycode);
out:
- spin_unlock_irqrestore(&rc_map->lock, flags);
+ spin_unlock_irqrestore(&kt->lock, flags);
return retval;
}
@@ -537,7 +537,7 @@ int ir_getkeycode(struct input_dev *idev,
unsigned int index;
int retval;
- spin_lock_irqsave(&rc_map->lock, flags);
+ spin_lock_irqsave(&kt->lock, flags);
if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
index = ke->index;
@@ -600,7 +600,7 @@ int ir_getkeycode(struct input_dev *idev,
retval = 0;
out:
- spin_unlock_irqrestore(&rc_map->lock, flags);
+ spin_unlock_irqrestore(&kt->lock, flags);
return retval;
}
@@ -610,25 +610,15 @@ static u32 rc_get_keycode(struct rc_keytable *kt,
struct rc_map *rc_map;
unsigned int keycode = KEY_RESERVED;
unsigned int index;
- unsigned long flags;
rc_map = &kt->rc_map;
if (!rc_map)
return KEY_RESERVED;
- spin_lock_irqsave(&rc_map->lock, flags);
-
index = ir_lookup_by_scancode(rc_map, protocol, scancode);
if (index < rc_map->len)
keycode = rc_map->scan[index].keycode;
- spin_unlock_irqrestore(&rc_map->lock, flags);
-
- if (keycode != KEY_RESERVED)
- IR_dprintk(1, "%s: protocol 0x%04x scancode 0x%08llx keycode 0x%02x\n",
- kt->dev->input_name, protocol,
- (unsigned long long)scancode, keycode);
-
return keycode;
}
@@ -649,13 +639,17 @@ u32 rc_g_keycode_from_table(struct rc_dev *dev,
{
struct rc_keytable *kt;
unsigned int keycode = KEY_RESERVED;
+ unsigned long flags;
/* FIXME: This entire function is a hack. Remove it */
rcu_read_lock();
kt = rcu_dereference(dev->keytables[0]);
if (!kt)
goto out;
+
+ spin_lock_irqsave(&kt->lock, flags);
keycode = rc_get_keycode(kt, protocol, scancode);
+ spin_unlock_irqrestore(&kt->lock, flags);
out:
rcu_read_unlock();
@@ -669,7 +663,7 @@ EXPORT_SYMBOL_GPL(rc_g_keycode_from_table);
* @sync: whether or not to call input_sync
*
* This function is used internally to release a keypress, it must be
- * called with keylock held.
+ * called with kt->lock held.
*/
static void rc_do_keyup(struct rc_keytable *kt, bool sync)
{
@@ -694,9 +688,9 @@ void rc_keytable_keyup(struct rc_keytable *kt)
{
unsigned long flags;
- spin_lock_irqsave(&kt->keylock, flags);
+ spin_lock_irqsave(&kt->lock, flags);
rc_do_keyup(kt, true);
- spin_unlock_irqrestore(&kt->keylock, flags);
+ spin_unlock_irqrestore(&kt->lock, flags);
}
/**
@@ -721,10 +715,10 @@ static void rc_timer_keyup(unsigned long cookie)
* to allow the input subsystem to do its auto-repeat magic or
* a keyup event might follow immediately after the keydown.
*/
- spin_lock_irqsave(&kt->keylock, flags);
+ spin_lock_irqsave(&kt->lock, flags);
if (time_is_before_eq_jiffies(kt->keyup_jiffies))
rc_do_keyup(kt, true);
- spin_unlock_irqrestore(&kt->keylock, flags);
+ spin_unlock_irqrestore(&kt->lock, flags);
}
/**
@@ -739,7 +733,7 @@ void rc_keytable_repeat(struct rc_keytable *kt)
{
unsigned long flags;
- spin_lock_irqsave(&kt->keylock, flags);
+ spin_lock_irqsave(&kt->lock, flags);
input_event(kt->idev, EV_MSC, MSC_SCAN, kt->last_scancode);
input_sync(kt->idev);
@@ -751,7 +745,7 @@ void rc_keytable_repeat(struct rc_keytable *kt)
mod_timer(&kt->timer_keyup, kt->keyup_jiffies);
out:
- spin_unlock_irqrestore(&kt->keylock, flags);
+ spin_unlock_irqrestore(&kt->lock, flags);
}
/**
@@ -772,7 +766,7 @@ void rc_keytable_keydown(struct rc_keytable *kt, enum rc_type protocol,
u32 keycode;
bool new_event;
- spin_lock_irqsave(&kt->keylock, flags);
+ spin_lock_irqsave(&kt->lock, flags);
keycode = rc_get_keycode(kt, protocol, scancode);
new_event = (!kt->keypressed ||
@@ -805,7 +799,7 @@ void rc_keytable_keydown(struct rc_keytable *kt, enum rc_type protocol,
kt->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
mod_timer(&kt->timer_keyup, kt->keyup_jiffies);
}
- spin_unlock_irqrestore(&kt->keylock, flags);
+ spin_unlock_irqrestore(&kt->lock, flags);
}
static int rc_input_open(struct input_dev *idev)
@@ -854,8 +848,7 @@ struct rc_keytable *rc_keytable_create(struct rc_dev *dev, const char *name,
kt->idev = idev;
kt->dev = dev;
- spin_lock_init(&kt->keylock);
- spin_lock_init(&kt->rc_map.lock);
+ spin_lock_init(&kt->lock);
snprintf(kt->name, sizeof(*kt->name), name ? name : "undefined");
idev->getkeycode = ir_getkeycode;
idev->setkeycode = ir_setkeycode;
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 6f282e6..af63188 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -395,7 +395,7 @@ struct rc_dev {
* @keypressed: whether a key is currently pressed or not
* @keyup_jiffies: when the key should be auto-released
* @timer_keyup: responsible for the auto-release of keys
- * @keylock: protects the key state
+ * @lock: protects the key state
* @last_keycode: keycode of the last keypress
* @last_protocol: protocol of the last keypress
* @last_scancode: scancode of the last keypress
@@ -410,7 +410,7 @@ struct rc_keytable {
bool keypressed;
unsigned long keyup_jiffies;
struct timer_list timer_keyup;
- spinlock_t keylock;
+ spinlock_t lock;
u32 last_keycode;
enum rc_type last_protocol;
u32 last_scancode;
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index bfa27fc..34c192f 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -94,7 +94,6 @@ struct rc_map {
unsigned int alloc; /* Size of *scan in bytes */
enum rc_type rc_type; /* For in-kernel keymaps */
const char *name;
- spinlock_t lock;
};
struct rc_map_list {
next prev parent reply other threads:[~2014-04-03 23:34 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 23:31 [PATCH 00/49] rc-core: my current patch queue David Härdeman
2014-04-03 23:31 ` [PATCH 01/49] bt8xx: fixup RC5 decoding David Härdeman
2014-04-03 23:31 ` [PATCH 02/49] rc-core: improve ir-kbd-i2c get_key functions David Härdeman
2014-04-03 23:31 ` [PATCH 03/49] rc-core: document the protocol type David Härdeman
2014-04-03 23:31 ` [PATCH 04/49] rc-core: do not change 32bit NEC scancode format for now David Härdeman
2014-04-04 13:18 ` James Hogan
2014-04-03 23:31 ` [PATCH 05/49] rc-core: split dev->s_filter David Härdeman
2014-04-04 13:08 ` James Hogan
2014-04-03 23:31 ` [PATCH 06/49] rc-core: remove generic scancode filter David Härdeman
2014-04-04 13:30 ` James Hogan
2014-04-03 23:31 ` [PATCH 07/49] dib0700: NEC scancode cleanup David Härdeman
2014-04-03 23:31 ` [PATCH 08/49] lmedm04: " David Härdeman
2014-04-03 23:32 ` [PATCH 09/49] saa7134: NEC scancode fix David Härdeman
2014-04-03 23:32 ` [PATCH 10/49] [RFC] rc-core: use the full 32 bits for NEC scancodes David Härdeman
2014-04-03 23:32 ` [PATCH 11/49] [RFC] rc-core: don't throw away protocol information David Härdeman
2014-04-03 23:32 ` [PATCH 12/49] rc-core: simplify sysfs code David Härdeman
2014-04-03 23:32 ` [PATCH 13/49] rc-core: remove protocol arrays David Härdeman
2014-04-03 23:32 ` [PATCH 14/49] rc-core: rename dev->scanmask to dev->scancode_mask David Härdeman
2014-04-03 23:32 ` [PATCH 15/49] rc-core: merge rc5 and streamzap decoders David Härdeman
2014-04-03 23:32 ` [PATCH 16/49] rc-core: use an IDA rather than a bitmap David Härdeman
2014-07-25 22:39 ` Mauro Carvalho Chehab
2014-04-03 23:32 ` [PATCH 17/49] rc-core: add chardev David Härdeman
2014-04-03 23:32 ` [PATCH 18/49] rc-core: allow chardev to be read David Härdeman
2014-04-03 23:32 ` [PATCH 19/49] rc-core: use a kfifo for TX data David Härdeman
2014-04-03 23:32 ` [PATCH 20/49] rc-core: allow chardev to be written David Härdeman
2014-04-03 23:33 ` [PATCH 21/49] rc-core: add ioctl support to the rc chardev David Härdeman
2014-04-03 23:33 ` [PATCH 22/49] rc-core: add an ioctl for getting IR RX settings David Härdeman
2014-04-03 23:33 ` [PATCH 23/49] rc-loopback: add RCIOCGIRRX ioctl support David Härdeman
2014-04-03 23:33 ` [PATCH 24/49] rc-core: add an ioctl for setting IR RX settings David Härdeman
2014-04-03 23:33 ` [PATCH 25/49] rc-loopback: add RCIOCSIRRX ioctl support David Härdeman
2014-04-03 23:33 ` [PATCH 26/49] rc-core: add an ioctl for getting IR TX settings David Härdeman
2014-04-03 23:33 ` [PATCH 27/49] rc-loopback: add RCIOCGIRTX ioctl support David Härdeman
2014-04-03 23:33 ` [PATCH 28/49] rc-core: add an ioctl for setting IR TX settings David Härdeman
2014-04-03 23:33 ` [PATCH 29/49] rc-loopback: add RCIOCSIRTX ioctl support David Härdeman
2014-04-03 23:33 ` [PATCH 30/49] rc-core: leave the internals of rc_dev alone David Härdeman
2014-07-24 1:50 ` Mauro Carvalho Chehab
2014-04-03 23:33 ` [PATCH 31/49] rc-core: split rc-main.c into rc-main.c and rc-keytable.c David Härdeman
2014-07-25 22:44 ` Mauro Carvalho Chehab
2014-04-03 23:33 ` [PATCH 32/49] rc-core: prepare for multiple keytables David Härdeman
2014-07-25 22:52 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 33/49] rc-core: make the keytable of rc_dev an array David Härdeman
2014-04-03 23:34 ` [PATCH 34/49] rc-core: add ioctls for adding/removing keytables from userspace David Härdeman
2014-04-03 23:34 ` David Härdeman [this message]
2014-04-03 23:34 ` [PATCH 36/49] rc-core: make keytable RCU-friendly David Härdeman
2014-04-03 23:34 ` [PATCH 37/49] rc-core: allow empty keymaps David Härdeman
2014-07-25 22:58 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 38/49] rc-core: rename ir-raw.c David Härdeman
2014-04-03 23:34 ` [PATCH 39/49] rc-core: make IR raw handling a separate module David Härdeman
2014-07-25 23:04 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 40/49] rc-ir-raw: simplify locking David Härdeman
2014-07-25 23:08 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 41/49] rc-core: rename mutex David Härdeman
2014-04-10 21:28 ` James Hogan
2014-07-25 23:12 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 42/49] rc-ir-raw: atomic reads of protocols David Härdeman
2014-07-25 23:13 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 43/49] rc-core: fix various sparse warnings David Härdeman
2014-04-03 23:34 ` [PATCH 44/49] rc-core: don't report scancodes via input devices David Härdeman
2014-07-25 23:16 ` Mauro Carvalho Chehab
2014-04-03 23:35 ` [PATCH 45/49] rc-ir-raw: add various rc_events David Härdeman
2014-07-25 23:16 ` Mauro Carvalho Chehab
2014-04-03 23:35 ` [PATCH 46/49] rc-core: use struct rc_event for all rc communication David Härdeman
2014-07-25 23:19 ` Mauro Carvalho Chehab
2014-04-03 23:35 ` [PATCH 47/49] rc-core: add keytable events David Härdeman
2014-04-03 23:35 ` [PATCH 48/49] rc-core: move remaining keytable functions David Härdeman
2014-04-03 23:35 ` [PATCH 49/49] rc-core: make rc-core.h userspace friendly David Härdeman
2014-04-04 2:05 ` [PATCH 00/49] rc-core: my current patch queue Mauro Carvalho Chehab
2014-06-26 20:07 ` David Härdeman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140403233413.27099.9024.stgit@zeus.muc.hardeman.nu \
--to=david@hardeman.nu \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox