Skip to content

Commit 8aa45b5

Browse files
westeribentiss
authored andcommitted
HID: Add map_msc() to avoid boilerplate code
Since we are going to have more MSC events too, add map_msc() that can be used to fill in necessary fields and avoid boilerplate code. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Tero Kristo <tero.kristo@linux.intel.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20211210111138.1248187-2-tero.kristo@linux.intel.com
1 parent f65a0b1 commit 8aa45b5

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/hid/hid-input.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static const struct {
5252
#define map_rel(c) hid_map_usage(hidinput, usage, &bit, &max, EV_REL, (c))
5353
#define map_key(c) hid_map_usage(hidinput, usage, &bit, &max, EV_KEY, (c))
5454
#define map_led(c) hid_map_usage(hidinput, usage, &bit, &max, EV_LED, (c))
55+
#define map_msc(c) hid_map_usage(hidinput, usage, &bit, &max, EV_MSC, (c))
5556

5657
#define map_abs_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
5758
&max, EV_ABS, (c))
@@ -874,10 +875,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
874875

875876
case 0x5b: /* TransducerSerialNumber */
876877
case 0x6e: /* TransducerSerialNumber2 */
877-
usage->type = EV_MSC;
878-
usage->code = MSC_SERIAL;
879-
bit = input->mscbit;
880-
max = MSC_MAX;
878+
map_msc(MSC_SERIAL);
881879
break;
882880

883881
default: goto unknown;

include/linux/hid.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,10 @@ static inline void hid_map_usage(struct hid_input *hidinput,
10101010
bmap = input->ledbit;
10111011
limit = LED_MAX;
10121012
break;
1013+
case EV_MSC:
1014+
bmap = input->mscbit;
1015+
limit = MSC_MAX;
1016+
break;
10131017
}
10141018

10151019
if (unlikely(c > limit || !bmap)) {

0 commit comments

Comments
 (0)