Skip to content

Commit 0d8633b

Browse files
vijaykhemkacminyard
authored andcommitted
drivers: ipmi: Support for both IPMB Req and Resp
Removed check for request or response in IPMB packets coming from device as well as from host. Now it supports both way communication to device via IPMB. Both request and response will be passed to application. Signed-off-by: Vijay Khemka <[email protected]> Message-Id: <[email protected]> Reviewed-by: Asmaa Mnebhi <[email protected]> Signed-off-by: Corey Minyard <[email protected]>
1 parent 4aa7afb commit 0d8633b

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

drivers/char/ipmi/ipmb_dev_int.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ static ssize_t ipmb_write(struct file *file, const char __user *buf,
133133
rq_sa = GET_7BIT_ADDR(msg[RQ_SA_8BIT_IDX]);
134134
netf_rq_lun = msg[NETFN_LUN_IDX];
135135

136-
if (!(netf_rq_lun & NETFN_RSP_BIT_MASK))
137-
return -EINVAL;
138-
139136
/*
140137
* subtract rq_sa and netf_rq_lun from the length of the msg passed to
141138
* i2c_smbus_xfer
@@ -203,25 +200,16 @@ static u8 ipmb_verify_checksum1(struct ipmb_dev *ipmb_dev, u8 rs_sa)
203200
ipmb_dev->request.checksum1);
204201
}
205202

206-
static bool is_ipmb_request(struct ipmb_dev *ipmb_dev, u8 rs_sa)
203+
/*
204+
* Verify if message has proper ipmb header with minimum length
205+
* and correct checksum byte.
206+
*/
207+
static bool is_ipmb_msg(struct ipmb_dev *ipmb_dev, u8 rs_sa)
207208
{
208-
if (ipmb_dev->msg_idx >= IPMB_REQUEST_LEN_MIN) {
209-
if (ipmb_verify_checksum1(ipmb_dev, rs_sa))
210-
return false;
209+
if ((ipmb_dev->msg_idx >= IPMB_REQUEST_LEN_MIN) &&
210+
(!ipmb_verify_checksum1(ipmb_dev, rs_sa)))
211+
return true;
211212

212-
/*
213-
* Check whether this is an IPMB request or
214-
* response.
215-
* The 6 MSB of netfn_rs_lun are dedicated to the netfn
216-
* while the remaining bits are dedicated to the lun.
217-
* If the LSB of the netfn is cleared, it is associated
218-
* with an IPMB request.
219-
* If the LSB of the netfn is set, it is associated with
220-
* an IPMB response.
221-
*/
222-
if (!(ipmb_dev->request.netfn_rs_lun & NETFN_RSP_BIT_MASK))
223-
return true;
224-
}
225213
return false;
226214
}
227215

@@ -273,8 +261,7 @@ static int ipmb_slave_cb(struct i2c_client *client,
273261

274262
case I2C_SLAVE_STOP:
275263
ipmb_dev->request.len = ipmb_dev->msg_idx;
276-
277-
if (is_ipmb_request(ipmb_dev, GET_8BIT_ADDR(client->addr)))
264+
if (is_ipmb_msg(ipmb_dev, GET_8BIT_ADDR(client->addr)))
278265
ipmb_handle_request(ipmb_dev);
279266
break;
280267

0 commit comments

Comments
 (0)