Skip to content

Commit

Permalink
touchscreen: avoid unnecessary heap allocations
Browse files Browse the repository at this point in the history
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
  • Loading branch information
arter97 authored and acuicultor committed Sep 15, 2021
1 parent 26b893d commit e8e6f79
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/oneplus/input/touchscreen/touchpanel_common_driver.c
Expand Up @@ -616,7 +616,7 @@ static void tp_touch_handle(struct touchpanel_data *ts)
int i = 0;
uint8_t finger_num = 0, touch_near_edge = 0;
int obj_attention = 0;
struct point_info *points;
struct point_info points[10];
struct corner_info corner[4];
static bool up_status = false;
static struct point_info last_point = {.x = 0, .y = 0};
Expand All @@ -627,11 +627,7 @@ static void tp_touch_handle(struct touchpanel_data *ts)
return;
}

points= kzalloc(sizeof(struct point_info)*ts->max_num, GFP_KERNEL);
if (!points) {
TPD_INFO("points kzalloc failed\n");
return;
}
memset(points, 0, sizeof(points));
memset(corner, 0, sizeof(corner));
if (ts->reject_point) { //sensor will reject point when call mode.
if (ts->touch_count) {
Expand All @@ -648,7 +644,6 @@ static void tp_touch_handle(struct touchpanel_data *ts)
#endif
input_sync(ts->input_dev);
}
kfree(points);
return;
}
obj_attention = ts->ts_ops->get_touch_points(ts->chip_data, points, ts->max_num);
Expand Down Expand Up @@ -727,7 +722,6 @@ static void tp_touch_handle(struct touchpanel_data *ts)
}
input_sync(ts->input_dev);
ts->touch_count = finger_num;
kfree(points);
mutex_unlock(&ts->report_mutex);
}

Expand Down

0 comments on commit e8e6f79

Please sign in to comment.