From: Ian Abbott <abbotti@mev.co.uk>
To: linux-input@vger.kernel.org
Cc: David Rheinsberg <david.rheinsberg@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Ian Abbott <abbotti@mev.co.uk>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] HID: wiimote: narrow spinlock range in wiimote_hid_event()
Date: Fri, 4 Sep 2020 14:21:43 +0100 [thread overview]
Message-ID: <20200904132143.9496-3-abbotti@mev.co.uk> (raw)
In-Reply-To: <20200904132143.9496-1-abbotti@mev.co.uk>
In `wiimote_hid_event()`, the `wdata->state.lock` spinlock does not need
to be held while searching `handlers[]` for a suitable handler function.
Change it so the spinlock is only held during the call to the handler
function itself.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
drivers/hid/hid-wiimote-core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index e03a0ba5611a..41012681cafd 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1625,12 +1625,12 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
if (size < 1)
return -EINVAL;
- spin_lock_irqsave(&wdata->state.lock, flags);
-
for (i = 0; handlers[i].id; ++i) {
h = &handlers[i];
if (h->id == raw_data[0] && h->size < size) {
+ spin_lock_irqsave(&wdata->state.lock, flags);
h->func(wdata, &raw_data[1]);
+ spin_unlock_irqrestore(&wdata->state.lock, flags);
break;
}
}
@@ -1639,8 +1639,6 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
hid_warn(hdev, "Unhandled report %hhu size %d\n", raw_data[0],
size);
- spin_unlock_irqrestore(&wdata->state.lock, flags);
-
return 0;
}
--
2.28.0
next prev parent reply other threads:[~2020-09-04 13:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 13:21 {PATCH 0/2] HID: wiimote: Minor change to spinlock usage Ian Abbott
2020-09-04 13:21 ` [PATCH 1/2] HID: wiimote: make handlers[] const Ian Abbott
2020-09-04 13:21 ` Ian Abbott [this message]
2020-09-07 7:37 ` {PATCH 0/2] HID: wiimote: Minor change to spinlock usage David Rheinsberg
2020-09-07 14:05 ` Jiri Kosina
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=20200904132143.9496-3-abbotti@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=benjamin.tissoires@redhat.com \
--cc=david.rheinsberg@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).