Skip to content

Commit e621132

Browse files
dwassenbergdtor
authored andcommitted
Input: synaptics-rmi4 - f03 - grab data passed by transport device
First check if there are data available passed by the transport device. If data available use these data. If there are no data available try to read the rmi block if dsata are passed this way. This is the way the other rmi function handlers will do this. This patch is needed on HID devices because the firmware reads F03 data registers and adds them to the HID attention report. Reading those registers from the driver after the firmware read them will result in invalid data. Reviewed-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Dennis Wassenberg <dennis.wassenberg@secunet.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent c5e8848 commit e621132

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

‎drivers/input/rmi4/rmi_f03.c‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static int rmi_f03_config(struct rmi_function *fn)
163163

164164
static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
165165
{
166+
struct rmi_device *rmi_dev = fn->rmi_dev;
166167
struct f03_data *f03 = dev_get_drvdata(&fn->dev);
167168
u16 data_addr = fn->fd.data_base_addr;
168169
const u8 ob_len = f03->rx_queue_length * RMI_F03_OB_SIZE;
@@ -173,15 +174,31 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
173174
int i;
174175
int error;
175176

176-
/* Grab all of the data registers, and check them for data */
177-
error = rmi_read_block(fn->rmi_dev, data_addr + RMI_F03_OB_OFFSET,
178-
&obs, ob_len);
179-
if (error) {
180-
dev_err(&fn->dev,
181-
"%s: Failed to read F03 output buffers: %d\n",
182-
__func__, error);
183-
serio_interrupt(f03->serio, 0, SERIO_TIMEOUT);
184-
return error;
177+
if (!rmi_dev || !rmi_dev->xport)
178+
return -ENODEV;
179+
180+
if (rmi_dev->xport->attn_data) {
181+
/* First grab the data passed by the transport device */
182+
if (rmi_dev->xport->attn_size < ob_len) {
183+
dev_warn(&fn->dev, "F03 interrupted, but data is missing!\n");
184+
return 0;
185+
}
186+
187+
memcpy(obs, rmi_dev->xport->attn_data, ob_len);
188+
189+
rmi_dev->xport->attn_data += ob_len;
190+
rmi_dev->xport->attn_size -= ob_len;
191+
} else {
192+
/* Grab all of the data registers, and check them for data */
193+
error = rmi_read_block(fn->rmi_dev, data_addr + RMI_F03_OB_OFFSET,
194+
&obs, ob_len);
195+
if (error) {
196+
dev_err(&fn->dev,
197+
"%s: Failed to read F03 output buffers: %d\n",
198+
__func__, error);
199+
serio_interrupt(f03->serio, 0, SERIO_TIMEOUT);
200+
return error;
201+
}
185202
}
186203

187204
for (i = 0; i < ob_len; i += RMI_F03_OB_SIZE) {

0 commit comments

Comments
 (0)