Skip to content

Commit b908d3c

Browse files
bentissdtor
authored andcommitted
Input: synaptics-rmi4 - allow to add attention data
The HID implementation of RMI4 provides the data during the interrupt (in the input report). We need to provide a way for this transport driver to provide the attention data while calling an IRQ. We use a fifo in rmi_core to not lose any incoming event. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent e621132 commit b908d3c

2 files changed

Lines changed: 58 additions & 2 deletions

File tree

‎drivers/input/rmi4/rmi_driver.c‎

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,53 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
191191
return 0;
192192
}
193193

194+
void rmi_set_attn_data(struct rmi_device *rmi_dev, unsigned long irq_status,
195+
void *data, size_t size)
196+
{
197+
struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
198+
struct rmi4_attn_data attn_data;
199+
void *fifo_data;
200+
201+
if (!drvdata->enabled)
202+
return;
203+
204+
fifo_data = kmemdup(data, size, GFP_ATOMIC);
205+
if (!fifo_data)
206+
return;
207+
208+
attn_data.irq_status = irq_status;
209+
attn_data.size = size;
210+
attn_data.data = fifo_data;
211+
212+
kfifo_put(&drvdata->attn_fifo, attn_data);
213+
}
214+
EXPORT_SYMBOL_GPL(rmi_set_attn_data);
215+
194216
static irqreturn_t rmi_irq_fn(int irq, void *dev_id)
195217
{
196218
struct rmi_device *rmi_dev = dev_id;
197-
int ret;
219+
struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
220+
struct rmi4_attn_data attn_data = {0};
221+
int ret, count;
222+
223+
count = kfifo_get(&drvdata->attn_fifo, &attn_data);
224+
if (count) {
225+
*(drvdata->irq_status) = attn_data.irq_status;
226+
rmi_dev->xport->attn_data = attn_data.data;
227+
rmi_dev->xport->attn_size = attn_data.size;
228+
}
198229

199230
ret = rmi_process_interrupt_requests(rmi_dev);
200231
if (ret)
201232
rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev,
202233
"Failed to process interrupt request: %d\n", ret);
203234

235+
if (count)
236+
kfree(attn_data.data);
237+
238+
if (!kfifo_is_empty(&drvdata->attn_fifo))
239+
return rmi_irq_fn(irq, dev_id);
240+
204241
return IRQ_HANDLED;
205242
}
206243

@@ -880,8 +917,9 @@ void rmi_disable_irq(struct rmi_device *rmi_dev, bool enable_wake)
880917
{
881918
struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev);
882919
struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
920+
struct rmi4_attn_data attn_data = {0};
883921
int irq = pdata->irq;
884-
int retval;
922+
int retval, count;
885923

886924
mutex_lock(&data->enabled_mutex);
887925

@@ -898,6 +936,13 @@ void rmi_disable_irq(struct rmi_device *rmi_dev, bool enable_wake)
898936
retval);
899937
}
900938

939+
/* make sure the fifo is clean */
940+
while (!kfifo_is_empty(&data->attn_fifo)) {
941+
count = kfifo_get(&data->attn_fifo, &attn_data);
942+
if (count)
943+
kfree(attn_data.data);
944+
}
945+
901946
out:
902947
mutex_unlock(&data->enabled_mutex);
903948
}

‎include/linux/rmi.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/device.h>
1414
#include <linux/interrupt.h>
1515
#include <linux/input.h>
16+
#include <linux/kfifo.h>
1617
#include <linux/list.h>
1718
#include <linux/module.h>
1819
#include <linux/types.h>
@@ -331,6 +332,12 @@ struct rmi_device {
331332

332333
};
333334

335+
struct rmi4_attn_data {
336+
unsigned long irq_status;
337+
size_t size;
338+
void *data;
339+
};
340+
334341
struct rmi_driver_data {
335342
struct list_head function_list;
336343

@@ -357,11 +364,15 @@ struct rmi_driver_data {
357364

358365
bool enabled;
359366
struct mutex enabled_mutex;
367+
DECLARE_KFIFO(attn_fifo, struct rmi4_attn_data, 16);
360368
};
361369

362370
int rmi_register_transport_device(struct rmi_transport_dev *xport);
363371
void rmi_unregister_transport_device(struct rmi_transport_dev *xport);
364372

373+
void rmi_set_attn_data(struct rmi_device *rmi_dev, unsigned long irq_status,
374+
void *data, size_t size);
375+
365376
int rmi_driver_suspend(struct rmi_device *rmi_dev, bool enable_wake);
366377
int rmi_driver_resume(struct rmi_device *rmi_dev, bool clear_wake);
367378
#endif

0 commit comments

Comments
 (0)