Skip to content

Commit f81f213

Browse files
committed
Merge tag 'for-linus-5.12-1' of git://github.com/cminyard/linux-ipmi
Pull IPMI update from Corey Minyard: "Only one change, but it's required for other things, so it needs to go in" * tag 'for-linus-5.12-1' of git://github.com/cminyard/linux-ipmi: ipmi: remove open coded version of SMBus block write
2 parents e913a8c + fc26067 commit f81f213

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎drivers/char/ipmi/ipmb_dev_int.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static ssize_t ipmb_write(struct file *file, const char __user *buf,
137137
{
138138
struct ipmb_dev *ipmb_dev = to_ipmb_dev(file);
139139
u8 rq_sa, netf_rq_lun, msg_len;
140-
union i2c_smbus_data data;
140+
struct i2c_client *temp_client;
141141
u8 msg[MAX_MSG_LEN];
142142
ssize_t ret;
143143

@@ -160,21 +160,21 @@ static ssize_t ipmb_write(struct file *file, const char __user *buf,
160160
}
161161

162162
/*
163-
* subtract rq_sa and netf_rq_lun from the length of the msg passed to
164-
* i2c_smbus_xfer
163+
* subtract rq_sa and netf_rq_lun from the length of the msg. Fill the
164+
* temporary client. Note that its use is an exception for IPMI.
165165
*/
166166
msg_len = msg[IPMB_MSG_LEN_IDX] - SMBUS_MSG_HEADER_LENGTH;
167-
if (msg_len > I2C_SMBUS_BLOCK_MAX)
168-
msg_len = I2C_SMBUS_BLOCK_MAX;
167+
temp_client = kmemdup(ipmb_dev->client, sizeof(*temp_client), GFP_KERNEL);
168+
if (!temp_client)
169+
return -ENOMEM;
170+
171+
temp_client->addr = rq_sa;
169172

170-
data.block[0] = msg_len;
171-
memcpy(&data.block[1], msg + SMBUS_MSG_IDX_OFFSET, msg_len);
172-
ret = i2c_smbus_xfer(ipmb_dev->client->adapter, rq_sa,
173-
ipmb_dev->client->flags,
174-
I2C_SMBUS_WRITE, netf_rq_lun,
175-
I2C_SMBUS_BLOCK_DATA, &data);
173+
ret = i2c_smbus_write_block_data(temp_client, netf_rq_lun, msg_len,
174+
msg + SMBUS_MSG_IDX_OFFSET);
175+
kfree(temp_client);
176176

177-
return ret ? : count;
177+
return ret < 0 ? ret : count;
178178
}
179179

180180
static __poll_t ipmb_poll(struct file *file, poll_table *wait)

0 commit comments

Comments
 (0)