gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / misc / ibmasm / i2o.h
blob468fa84a3257f396da7d859060c6af936fbeb967
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 #pragma pack(1)
11 struct i2o_header {
12 u8 version;
13 u8 message_flags;
14 u16 message_size;
15 u8 target;
16 u8 initiator_and_target;
17 u8 initiator;
18 u8 function;
19 u32 initiator_context;
21 #pragma pack()
23 #define I2O_HEADER_TEMPLATE \
24 { .version = 0x01, \
25 .message_flags = 0x00, \
26 .function = 0xFF, \
27 .initiator = 0x00, \
28 .initiator_and_target = 0x40, \
29 .target = 0x00, \
30 .initiator_context = 0x0 }
32 #define I2O_MESSAGE_SIZE 0x1000
33 #define I2O_COMMAND_SIZE (I2O_MESSAGE_SIZE - sizeof(struct i2o_header))
35 #pragma pack(1)
36 struct i2o_message {
37 struct i2o_header header;
38 void *data;
40 #pragma pack()
42 static inline unsigned short outgoing_message_size(unsigned int data_size)
44 unsigned int size;
45 unsigned short i2o_size;
47 if (data_size > I2O_COMMAND_SIZE)
48 data_size = I2O_COMMAND_SIZE;
50 size = sizeof(struct i2o_header) + data_size;
52 i2o_size = size / sizeof(u32);
54 if (size % sizeof(u32))
55 i2o_size++;
57 return i2o_size;
60 static inline u32 incoming_data_size(struct i2o_message *i2o_message)
62 return (sizeof(u32) * i2o_message->header.message_size);