Skip to content

Commit 9d339fe

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Refactor touch input mute checks into a common function
We perform this same set of tests to see if touch input is muted in several places. We might as well replace these independent copies with an inline function. Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent ccb51c2 commit 9d339fe

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

drivers/hid/wacom_wac.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,13 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
824824
return 0;
825825
}
826826

827+
static inline bool touch_is_muted(struct wacom_wac *wacom_wac)
828+
{
829+
return wacom_wac->probe_complete &&
830+
wacom_wac->shared->has_mute_touch_switch &&
831+
!wacom_wac->shared->is_touch_on;
832+
}
833+
827834
static inline bool report_touch_events(struct wacom_wac *wacom)
828835
{
829836
return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
@@ -1525,11 +1532,8 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
15251532
int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
15261533
int y_offset = 2;
15271534

1528-
if (wacom->shared->has_mute_touch_switch &&
1529-
!wacom->shared->is_touch_on) {
1530-
if (!wacom->shared->touch_down)
1531-
return 0;
1532-
}
1535+
if (touch_is_muted(wacom) && !wacom->shared->touch_down)
1536+
return 0;
15331537

15341538
if (wacom->features.type == WACOM_27QHDT) {
15351539
current_num_contacts = data[63];
@@ -2536,8 +2540,7 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
25362540
bool prox = hid_data->tipswitch &&
25372541
report_touch_events(wacom_wac);
25382542

2539-
if (wacom_wac->shared->has_mute_touch_switch &&
2540-
!wacom_wac->shared->is_touch_on) {
2543+
if (touch_is_muted(wacom_wac)) {
25412544
if (!wacom_wac->shared->touch_down)
25422545
return;
25432546
prox = false;
@@ -2593,10 +2596,7 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
25932596
unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
25942597
struct wacom_features *features = &wacom->wacom_wac.features;
25952598

2596-
/* don't process touch events when touch is off */
2597-
if (wacom_wac->probe_complete &&
2598-
!wacom_wac->shared->is_touch_on &&
2599-
!wacom_wac->shared->touch_down)
2599+
if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
26002600
return;
26012601

26022602
if (wacom_wac->is_invalid_bt_frame)
@@ -2648,10 +2648,7 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev,
26482648
struct hid_data* hid_data = &wacom_wac->hid_data;
26492649
int i;
26502650

2651-
/* don't process touch events when touch is off */
2652-
if (wacom_wac->probe_complete &&
2653-
!wacom_wac->shared->is_touch_on &&
2654-
!wacom_wac->shared->touch_down)
2651+
if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
26552652
return;
26562653

26572654
wacom_wac->is_invalid_bt_frame = false;

0 commit comments

Comments
 (0)