Skip to content

Commit bf6247a

Browse files
committed
Input: make input_report_slot_state() return boolean
Let's make input_report_slot_state() return boolean representing whether the contact is active or not. This will allow writing code like: if (input_mt_report_slot_state(input, obj->mt_tool, obj->type != RMI_2D_OBJECT_NONE) { input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x); input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y); ... } instead of: input_mt_report_slot_state(input, obj->mt_tool, obj->type != RMI_2D_OBJECT_NONE); if (obj->type != RMI_2D_OBJECT_NONE) { input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x); input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y); ... } Reviewed-by: Henrik Rydberg <rydberg@bitmath.org> Acked-by: Benjamin Tissoires <benjamin.tissoires@redaht.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 645a397 commit bf6247a

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎drivers/input/input-mt.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,25 @@ EXPORT_SYMBOL(input_mt_destroy_slots);
131131
* inactive, or if the tool type is changed, a new tracking id is
132132
* assigned to the slot. The tool type is only reported if the
133133
* corresponding absbit field is set.
134+
*
135+
* Returns true if contact is active.
134136
*/
135-
void input_mt_report_slot_state(struct input_dev *dev,
137+
bool input_mt_report_slot_state(struct input_dev *dev,
136138
unsigned int tool_type, bool active)
137139
{
138140
struct input_mt *mt = dev->mt;
139141
struct input_mt_slot *slot;
140142
int id;
141143

142144
if (!mt)
143-
return;
145+
return false;
144146

145147
slot = &mt->slots[mt->slot];
146148
slot->frame = mt->frame;
147149

148150
if (!active) {
149151
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
150-
return;
152+
return false;
151153
}
152154

153155
id = input_mt_get_value(slot, ABS_MT_TRACKING_ID);
@@ -156,6 +158,8 @@ void input_mt_report_slot_state(struct input_dev *dev,
156158

157159
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id);
158160
input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type);
161+
162+
return true;
159163
}
160164
EXPORT_SYMBOL(input_mt_report_slot_state);
161165

‎include/linux/input/mt.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static inline bool input_is_mt_axis(int axis)
100100
return axis == ABS_MT_SLOT || input_is_mt_value(axis);
101101
}
102102

103-
void input_mt_report_slot_state(struct input_dev *dev,
103+
bool input_mt_report_slot_state(struct input_dev *dev,
104104
unsigned int tool_type, bool active);
105105

106106
void input_mt_report_finger_count(struct input_dev *dev, int count);

0 commit comments

Comments
 (0)