3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * Copyright (C) IBM Corporation, 2004
19 * Author: Max Asböck <amax@us.ibm.com>
24 #include "dot_command.h"
27 * Reverse Heartbeat, i.e. heartbeats sent from the driver to the
29 * These heartbeats are initiated by user level programs.
32 /* the reverse heartbeat dot command */
35 struct dot_command_header header
;
36 unsigned char command
[3];
44 .command
= { 4, 3, 6 }
48 void ibmasm_init_reverse_heartbeat(struct service_processor
*sp
, struct reverse_heartbeat
*rhb
)
50 init_waitqueue_head(&rhb
->wait
);
55 * start_reverse_heartbeat
56 * Loop forever, sending a reverse heartbeat dot command to the service
57 * processor, then sleeping. The loop comes to an end if the service
58 * processor fails to respond 3 times or we were interrupted.
60 int ibmasm_start_reverse_heartbeat(struct service_processor
*sp
, struct reverse_heartbeat
*rhb
)
66 cmd
= ibmasm_new_command(sp
, sizeof rhb_dot_cmd
);
70 while (times_failed
< 3) {
71 memcpy(cmd
->buffer
, (void *)&rhb_dot_cmd
, sizeof rhb_dot_cmd
);
72 cmd
->status
= IBMASM_CMD_PENDING
;
73 ibmasm_exec_command(sp
, cmd
);
74 ibmasm_wait_for_response(cmd
, IBMASM_CMD_TIMEOUT_NORMAL
);
76 if (cmd
->status
!= IBMASM_CMD_COMPLETE
)
79 wait_event_interruptible_timeout(rhb
->wait
,
81 REVERSE_HEARTBEAT_TIMEOUT
* HZ
);
83 if (signal_pending(current
) || rhb
->stopped
) {
94 void ibmasm_stop_reverse_heartbeat(struct reverse_heartbeat
*rhb
)
97 wake_up_interruptible(&rhb
->wait
);