Skip to content

Commit dd8df28

Browse files
aduggan-synaJiri Kosina
authored andcommitted
HID: rmi: Add functions for writing to registers
Writing to registers is needed for setting configuration parameters. Signed-off-by: Andrew Duggan <[email protected]> Tested-by: Gabriele Mazzotta <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 70e003f commit dd8df28

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

drivers/hid/hid-rmi.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,46 @@ static inline int rmi_read(struct hid_device *hdev, u16 addr, void *buf)
274274
return rmi_read_block(hdev, addr, buf, 1);
275275
}
276276

277+
static int rmi_write_block(struct hid_device *hdev, u16 addr, void *buf,
278+
const int len)
279+
{
280+
struct rmi_data *data = hid_get_drvdata(hdev);
281+
int ret;
282+
283+
mutex_lock(&data->page_mutex);
284+
285+
if (RMI_PAGE(addr) != data->page) {
286+
ret = rmi_set_page(hdev, RMI_PAGE(addr));
287+
if (ret < 0)
288+
goto exit;
289+
}
290+
291+
data->writeReport[0] = RMI_WRITE_REPORT_ID;
292+
data->writeReport[1] = len;
293+
data->writeReport[2] = addr & 0xFF;
294+
data->writeReport[3] = (addr >> 8) & 0xFF;
295+
memcpy(&data->writeReport[4], buf, len);
296+
297+
ret = rmi_write_report(hdev, data->writeReport,
298+
data->output_report_size);
299+
if (ret < 0) {
300+
dev_err(&hdev->dev,
301+
"failed to write request output report (%d)\n",
302+
ret);
303+
goto exit;
304+
}
305+
ret = 0;
306+
307+
exit:
308+
mutex_unlock(&data->page_mutex);
309+
return ret;
310+
}
311+
312+
static inline int rmi_write(struct hid_device *hdev, u16 addr, void *buf)
313+
{
314+
return rmi_write_block(hdev, addr, buf, 1);
315+
}
316+
277317
static void rmi_f11_process_touch(struct rmi_data *hdata, int slot,
278318
u8 finger_state, u8 *touch_data)
279319
{

0 commit comments

Comments
 (0)