treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / misc / ibmasm / dot_command.h
blobe03399ebe23971d63cf861f9efafa52e892fdd47
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * IBM ASM Service Processor Device Driver
5 * Copyright (C) IBM Corporation, 2004
7 * Author: Max Asböck <amax@us.ibm.com>
8 */
10 #ifndef __DOT_COMMAND_H__
11 #define __DOT_COMMAND_H__
14 * dot commands are the protocol used to communicate with the service
15 * processor.
16 * They consist of header, a command of variable length and data of
17 * variable length.
20 /* dot command types */
21 #define sp_write 0
22 #define sp_write_next 1
23 #define sp_read 2
24 #define sp_read_next 3
25 #define sp_command_response 4
26 #define sp_event 5
27 #define sp_heartbeat 6
29 #pragma pack(1)
30 struct dot_command_header {
31 u8 type;
32 u8 command_size;
33 u16 data_size;
34 u8 status;
35 u8 reserved;
37 #pragma pack()
39 static inline size_t get_dot_command_size(void *buffer)
41 struct dot_command_header *cmd = (struct dot_command_header *)buffer;
42 return sizeof(struct dot_command_header) + cmd->command_size + cmd->data_size;
45 static inline unsigned int get_dot_command_timeout(void *buffer)
47 struct dot_command_header *header = (struct dot_command_header *)buffer;
48 unsigned char *cmd = buffer + sizeof(struct dot_command_header);
50 /* dot commands 6.3.1, 7.1 and 8.x need a longer timeout */
52 if (header->command_size == 3) {
53 if ((cmd[0] == 6) && (cmd[1] == 3) && (cmd[2] == 1))
54 return IBMASM_CMD_TIMEOUT_EXTRA;
55 } else if (header->command_size == 2) {
56 if ((cmd[0] == 7) && (cmd[1] == 1))
57 return IBMASM_CMD_TIMEOUT_EXTRA;
58 if (cmd[0] == 8)
59 return IBMASM_CMD_TIMEOUT_EXTRA;
61 return IBMASM_CMD_TIMEOUT_NORMAL;
64 #endif /* __DOT_COMMAND_H__ */