Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[datapipe] Use macro for making tklock requests. JB#22475
Using datapipe_exec_full() to making tklock requests leads to repetitive
and hard to read multiline function calls scattered around code base.

Define and use mce_datapipe_request_tklock() macro to improve readability.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 15, 2018
1 parent 2d041b7 commit 4f558cd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .depend
Expand Up @@ -599,6 +599,7 @@ modules/camera.o:\
datapipe.h\
mce-conf.h\
mce-io.h\
mce-log.h\
mce.h\
tklock.h\
modules/camera.h\
Expand All @@ -608,6 +609,7 @@ modules/camera.pic.o:\
datapipe.h\
mce-conf.h\
mce-io.h\
mce-log.h\
mce.h\
tklock.h\
modules/camera.h\
Expand Down
12 changes: 12 additions & 0 deletions datapipe.h
Expand Up @@ -276,3 +276,15 @@ void mce_datapipe_quit(void);
} while(0)

#endif /* _DATAPIPE_H_ */

/** Execute tklock request
*
* @param tklock_request Value from tklock_request_t
*/
#define mce_datapipe_request_tklock(tklock_request) do {\
mce_log(LL_DEBUG, "Requesting tklock=%s",\
tklock_request_repr(tklock_request));\
datapipe_exec_full(&tklock_request_pipe,\
GINT_TO_POINTER(tklock_request),\
USE_INDATA, CACHE_INDATA);\
}while(0)
5 changes: 2 additions & 3 deletions modules/camera.c
Expand Up @@ -21,6 +21,7 @@

#include "camera.h"

#include "../mce-log.h"
#include "../mce-io.h"
#include "../mce-conf.h"
#include "../tklock.h"
Expand Down Expand Up @@ -132,9 +133,7 @@ static gboolean camera_popout_state_iomon_input_cb(mce_io_mon_t *iomon, gpointer
if (!strncmp(data, MCE_CAMERA_POPPED_OUT,
strlen(MCE_CAMERA_POPPED_OUT))) {
/* Request delayed unlock of touchscreen/keypad lock */
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_OFF_DELAYED),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF_DELAYED);
}

EXIT:
Expand Down
8 changes: 2 additions & 6 deletions modules/display.c
Expand Up @@ -8734,9 +8734,7 @@ static gboolean mdy_dbus_handle_display_off_req(DBusMessage *const msg)
if( !dbus_message_get_no_reply(msg) )
dbus_send_message(dbus_new_method_reply(msg));

datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);

mdy_dbus_handle_display_state_req(MCE_DISPLAY_OFF);

Expand Down Expand Up @@ -8795,9 +8793,7 @@ static gboolean mdy_dbus_handle_display_lpm_req(DBusMessage *const msg)
}

if( lock_ui ) {
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
}

mdy_dbus_handle_display_state_req(request);
Expand Down
10 changes: 2 additions & 8 deletions powerkey.c
Expand Up @@ -764,10 +764,7 @@ static void
pwrkey_action_tklock(void)
{
tklock_request_t request = TKLOCK_REQUEST_ON;
mce_log(LL_DEBUG, "Requesting tklock=%s", tklock_request_repr(request));
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(request),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(request);
}

static void
Expand All @@ -794,10 +791,7 @@ pwrkey_action_tkunlock(void)
goto EXIT;
}

mce_log(LL_DEBUG, "Requesting tklock=%s", tklock_request_repr(request));
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(request),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(request);
EXIT:
return;
}
Expand Down
37 changes: 9 additions & 28 deletions tklock.c
Expand Up @@ -776,9 +776,7 @@ static void tklock_datapipe_osupdate_running_cb(gconstpointer data)

if( osupdate_running ) {
/* undo tklock when update mode starts */
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF);
}

EXIT:
Expand Down Expand Up @@ -1569,10 +1567,7 @@ static void tklock_datapipe_lockkey_state_cb(gconstpointer const data)
* The tklock requests get ignored in act dead
* etc, so we can just blindly request it.
*/
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);

mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
break;

Expand Down Expand Up @@ -2273,9 +2268,7 @@ static void tklock_autolock_on_devlock_trigger(void)
*/

mce_log(LL_DEBUG, "autolock after devicelock: triggered");
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
EXIT:
return;
}
Expand Down Expand Up @@ -2850,9 +2843,7 @@ static void tklock_lidpolicy_rethink(void)

if( tklock_lid_close_actions == LID_CLOSE_ACTION_TKLOCK ) {
mce_log(LL_DEBUG, "lid closed - tklock");
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
}
break;

Expand All @@ -2865,9 +2856,7 @@ static void tklock_lidpolicy_rethink(void)

if( tklock_lid_open_actions == LID_OPEN_ACTION_TKUNLOCK ) {
mce_log(LL_DEBUG, "lid open - untklock");
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF);
}
break;

Expand Down Expand Up @@ -2928,9 +2917,7 @@ static void tklock_keyboard_slide_opened(void)

if( tklock_kbd_open_actions == LID_OPEN_ACTION_TKUNLOCK ) {
mce_log(LL_DEBUG, "kbd slide open - untklock");
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF);
}

/* Mark down we unblanked due to keyboard open */
Expand Down Expand Up @@ -2973,9 +2960,7 @@ static void tklock_keyboard_slide_closed(void)

if( tklock_kbd_close_actions == LID_CLOSE_ACTION_TKLOCK ) {
mce_log(LL_DEBUG, "kbd slide closed - tklock");
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
}

EXIT:
Expand Down Expand Up @@ -3642,9 +3627,7 @@ static void tklock_uiexception_finish(void)
/* then flip the tklock back on? Note that we
* we do not unlock no matter what. */
if( exx.tklock ) {
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
}

/* and finally the display data pipe */
Expand Down Expand Up @@ -3835,9 +3818,7 @@ static void tklock_lpmui_set_state(bool enable)
* display modes, the dbus signaling happens after some
* delay.
*/
datapipe_exec_full(&tklock_request_pipe,
GINT_TO_POINTER(TKLOCK_REQUEST_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
}
else {
/* Do delayed signaling in sync with possible tklock
Expand Down

0 comments on commit 4f558cd

Please sign in to comment.