3 /* State management variables. */
4 #define NR_DEVS 1 /* number of minor devices */
5 EXTERN
struct logdevice logdevices
[NR_DEVS
];
7 /* State management helpers. */
8 static int is_read_pending
;
9 static int is_select_callback_pending
;
10 static void load_state_info(void)
13 struct logdevice
*log
;
15 /* Check if reads or select callbacks are pending. */
16 is_read_pending
= FALSE
;
17 is_select_callback_pending
= FALSE
;
18 found_pending
= FALSE
;
19 for (i
= 0; i
< NR_DEVS
&& !found_pending
; i
++) {
21 if(log
->log_source
!= NONE
) {
22 is_read_pending
= TRUE
;
24 if(log
->log_selected
) {
25 is_select_callback_pending
= TRUE
;
28 found_pending
= (is_read_pending
&& is_select_callback_pending
);
32 /* Custom states definition. */
33 #define LOG_STATE_SELECT_PROTOCOL_FREE (SEF_LU_STATE_CUSTOM_BASE + 0)
34 #define LOG_STATE_IS_CUSTOM(s) ((s) == LOG_STATE_SELECT_PROTOCOL_FREE)
36 /*===========================================================================*
38 *===========================================================================*/
39 int sef_cb_lu_prepare(int state
)
43 /* Load state information. */
46 /* Check if we are ready for the target state. */
49 /* Standard states. */
50 case SEF_LU_STATE_REQUEST_FREE
:
51 is_ready
= (!is_read_pending
);
54 case SEF_LU_STATE_PROTOCOL_FREE
:
55 is_ready
= (!is_read_pending
&& !is_select_callback_pending
);
59 case LOG_STATE_SELECT_PROTOCOL_FREE
:
60 is_ready
= (!is_select_callback_pending
);
64 /* Tell SEF if we are ready. */
65 return is_ready
? OK
: ENOTREADY
;
68 /*===========================================================================*
69 * sef_cb_lu_state_isvalid *
70 *===========================================================================*/
71 int sef_cb_lu_state_isvalid(int state
)
73 return SEF_LU_STATE_IS_STANDARD(state
) || LOG_STATE_IS_CUSTOM(state
);
76 /*===========================================================================*
77 * sef_cb_lu_state_dump *
78 *===========================================================================*/
79 void sef_cb_lu_state_dump(int state
)
81 /* Load state information. */
84 sef_lu_dprint("log: live update state = %d\n", state
);
85 sef_lu_dprint("log: is_read_pending = %d\n", is_read_pending
);
86 sef_lu_dprint("log: is_select_callback_pending = %d\n",
87 is_select_callback_pending
);
89 sef_lu_dprint("log: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
90 SEF_LU_STATE_WORK_FREE
, TRUE
);
91 sef_lu_dprint("log: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
92 SEF_LU_STATE_REQUEST_FREE
, (!is_read_pending
));
93 sef_lu_dprint("log: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
94 SEF_LU_STATE_PROTOCOL_FREE
, (!is_read_pending
95 && !is_select_callback_pending
));
96 sef_lu_dprint("log: LOG_STATE_SELECT_PROTOCOL_FREE(%d) reached = %d\n",
97 LOG_STATE_SELECT_PROTOCOL_FREE
, (!is_select_callback_pending
));