From cdb9263aab9cc1a1d6c9584cbf20185215977214 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 8 Jan 2019 14:05:15 +0900 Subject: [PATCH] Check device_handle is the same with current vibration handle on close_device() - Check device_handle - Remove redundant operations Change-Id: If7597c20ace9b43d1bcbfb5017b983c15da00c7d Signed-off-by: pr.jung --- src/haptic/circle.c | 11 ----------- src/haptic/gpio_haptic.c | 11 ----------- src/haptic/standard.c | 16 +++------------- 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/haptic/circle.c b/src/haptic/circle.c index 9c756e7..aa1b7a5 100644 --- a/src/haptic/circle.c +++ b/src/haptic/circle.c @@ -158,17 +158,6 @@ static int close_device(int device_handle) if (r < 0) _I("already stopped or failed to stop effect : %d", r); - /* unregister existing timer */ - if (r >= 0) { - _D("device handle %d is closed and timer deleted", device_handle); - if (stop_timer) { - g_source_remove(stop_timer); - stop_timer = 0; - } - } - - standard_vibrate_close(); - DD_LIST_REMOVE(handle_list, (gpointer)(long)device_handle); /* if it is the last element */ diff --git a/src/haptic/gpio_haptic.c b/src/haptic/gpio_haptic.c index 3d91b5a..c495d6c 100644 --- a/src/haptic/gpio_haptic.c +++ b/src/haptic/gpio_haptic.c @@ -188,17 +188,6 @@ static int gpio_haptic_close_device(int handle) if (r < 0) _I("already stopped or failed to stop effect : %d", r); - /* unregister existing timer */ - if (r >= 0) { - if (stop_timer) { - //ecore_timer_del(stop_timer); - g_source_remove(stop_timer); - stop_timer = 0; - } - } - - standard_vibrate_close(); - _D("handle %d is closed and timer deleted", handle); DD_LIST_REMOVE(handle_list, (gpointer)(long)handle); diff --git a/src/haptic/standard.c b/src/haptic/standard.c index c0436fe..dd162b2 100644 --- a/src/haptic/standard.c +++ b/src/haptic/standard.c @@ -75,6 +75,7 @@ static dd_list *handle_list; static char ff_path[PATH_MAX]; static int unique_number; +static int stop_device(int device_handle); struct ff_info *read_from_list(int handle) { struct ff_info *temp; @@ -358,7 +359,7 @@ static int open_device(int device_index, int *device_handle) static int close_device(int device_handle) { struct ff_info *info; - int r, n; + int n; info = read_from_list(device_handle); if (!info) @@ -371,18 +372,7 @@ static int close_device(int device_handle) return -ENODEV; /* stop vibration */ - r = ff_stop(ff_fd, &info->effect); - if (r < 0) - _I("already stopped or failed to stop effect : %d", r); - - /* unregister existing timer */ - if (r >= 0 && info->timer) { - _D("device handle %d is closed and timer deleted", device_handle); - g_source_remove(info->timer); - info->timer = 0; - } - - standard_vibrate_close(); + stop_device(device_handle); DD_LIST_REMOVE(handle_list, (gpointer)(long)info->handle); -- 2.7.4