Skip to content

Commit 50c5249

Browse files
dtorJiri Kosina
authored andcommitted
HID: i2c-hid: convert i2c_hid_execute_reset() to use i2c_hid_xfer()
This will allow us to drop i2c_hid_command() wrapper and get close to removing __i2c_hid_command(). Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent acb8dd9 commit 50c5249

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

drivers/hid/i2c-hid/i2c-hid-core.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ struct i2c_hid_cmd {
105105
.registerIndex = offsetof(struct i2c_hid_desc, wCommandRegister)
106106

107107
/* commands */
108-
static const struct i2c_hid_cmd hid_reset_cmd = { I2C_HID_CMD(0x01) };
109108
static const struct i2c_hid_cmd hid_get_report_cmd = { I2C_HID_CMD(0x02) };
110109

111110
/*
@@ -283,14 +282,6 @@ static int __i2c_hid_command(struct i2c_hid *ihid,
283282
return i2c_hid_xfer(ihid, ihid->cmdbuf, length, buf_recv, data_len);
284283
}
285284

286-
static int i2c_hid_command(struct i2c_hid *ihid,
287-
const struct i2c_hid_cmd *command,
288-
unsigned char *buf_recv, int data_len)
289-
{
290-
return __i2c_hid_command(ihid, command, 0, 0, NULL, 0,
291-
buf_recv, data_len);
292-
}
293-
294285
static int i2c_hid_get_report(struct i2c_hid *ihid, u8 reportType,
295286
u8 reportID, unsigned char *buf_recv, int data_len)
296287
{
@@ -455,13 +446,21 @@ static int i2c_hid_set_power(struct i2c_hid *ihid, int power_state)
455446

456447
static int i2c_hid_execute_reset(struct i2c_hid *ihid)
457448
{
449+
size_t length = 0;
458450
int ret;
459451

460452
i2c_hid_dbg(ihid, "resetting...\n");
461453

454+
/* Prepare reset command. Command register goes first. */
455+
*(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister;
456+
length += sizeof(__le16);
457+
/* Next is RESET command itself */
458+
length += i2c_hid_encode_command(ihid->cmdbuf + length,
459+
I2C_HID_OPCODE_RESET, 0, 0);
460+
462461
set_bit(I2C_HID_RESET_PENDING, &ihid->flags);
463462

464-
ret = i2c_hid_command(ihid, &hid_reset_cmd, NULL, 0);
463+
ret = i2c_hid_xfer(ihid, ihid->cmdbuf, length, NULL, 0);
465464
if (ret) {
466465
dev_err(&ihid->client->dev, "failed to reset device.\n");
467466
goto out;

0 commit comments

Comments
 (0)