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 PRIVATE
int is_read_pending
;
9 PRIVATE
int is_select_callback_pending
;
10 PRIVATE
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_proc_nr
) {
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 PUBLIC
void 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. */
70 /*===========================================================================*
71 * sef_cb_lu_state_isvalid *
72 *===========================================================================*/
73 PUBLIC
int sef_cb_lu_state_isvalid(int state
)
75 return SEF_LU_STATE_IS_STANDARD(state
) || LOG_STATE_IS_CUSTOM(state
);
78 /*===========================================================================*
79 * sef_cb_lu_state_dump *
80 *===========================================================================*/
81 PUBLIC
void sef_cb_lu_state_dump(int state
)
83 /* Load state information. */
86 sef_lu_dprint("log: live update state = %d\n", state
);
87 sef_lu_dprint("log: is_read_pending = %d\n", is_read_pending
);
88 sef_lu_dprint("log: is_select_callback_pending = %d\n",
89 is_select_callback_pending
);
91 sef_lu_dprint("log: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
92 SEF_LU_STATE_WORK_FREE
, TRUE
);
93 sef_lu_dprint("log: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
94 SEF_LU_STATE_REQUEST_FREE
, (!is_read_pending
));
95 sef_lu_dprint("log: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
96 SEF_LU_STATE_PROTOCOL_FREE
, (!is_read_pending
97 && !is_select_callback_pending
));
98 sef_lu_dprint("log: LOG_STATE_SELECT_PROTOCOL_FREE(%d) reached = %d\n",
99 LOG_STATE_SELECT_PROTOCOL_FREE
, (!is_select_callback_pending
));