Input: synaptics-rmi4 - store the attn data in the driver
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Sat, 3 Dec 2016 01:49:10 +0000 (17:49 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 3 Dec 2016 01:51:32 +0000 (17:51 -0800)
Now that we have a proper API to set the attention data, there is
no point in keeping it in the transport driver.

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>
drivers/input/rmi4/rmi_driver.c
drivers/input/rmi4/rmi_f03.c
drivers/input/rmi4/rmi_f11.c
drivers/input/rmi4/rmi_f12.c
drivers/input/rmi4/rmi_f30.c
include/linux/rmi.h

index 85062e414e7348a5351c77e9d4910b6b848ebee4..05a3c4bc977805cda279ca10dfc0e2365b7f584f 100644 (file)
@@ -155,7 +155,7 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
        if (!data)
                return 0;
 
-       if (!rmi_dev->xport->attn_data) {
+       if (!data->attn_data.data) {
                error = rmi_read_block(rmi_dev,
                                data->f01_container->fd.data_base_addr + 1,
                                data->irq_status, data->num_of_irq_regs);
@@ -223,8 +223,7 @@ static irqreturn_t rmi_irq_fn(int irq, void *dev_id)
        count = kfifo_get(&drvdata->attn_fifo, &attn_data);
        if (count) {
                *(drvdata->irq_status) = attn_data.irq_status;
-               rmi_dev->xport->attn_data = attn_data.data;
-               rmi_dev->xport->attn_size = attn_data.size;
+               drvdata->attn_data = attn_data;
        }
 
        ret = rmi_process_interrupt_requests(rmi_dev);
index 7a3ec0ed0c275510e2864f6b6e6b590007f0c250..8a7ca3e2f95e62448cc2ecfcf910f767b9337bfa 100644 (file)
@@ -164,6 +164,7 @@ static int rmi_f03_config(struct rmi_function *fn)
 static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
 {
        struct rmi_device *rmi_dev = fn->rmi_dev;
+       struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
        struct f03_data *f03 = dev_get_drvdata(&fn->dev);
        u16 data_addr = fn->fd.data_base_addr;
        const u8 ob_len = f03->rx_queue_length * RMI_F03_OB_SIZE;
@@ -174,20 +175,20 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
        int i;
        int error;
 
-       if (!rmi_dev || !rmi_dev->xport)
+       if (!rmi_dev)
                return -ENODEV;
 
-       if (rmi_dev->xport->attn_data) {
+       if (drvdata->attn_data.data) {
                /* First grab the data passed by the transport device */
-               if (rmi_dev->xport->attn_size < ob_len) {
+               if (drvdata->attn_data.size < ob_len) {
                        dev_warn(&fn->dev, "F03 interrupted, but data is missing!\n");
                        return 0;
                }
 
-               memcpy(obs, rmi_dev->xport->attn_data, ob_len);
+               memcpy(obs, drvdata->attn_data.data, ob_len);
 
-               rmi_dev->xport->attn_data += ob_len;
-               rmi_dev->xport->attn_size -= ob_len;
+               drvdata->attn_data.data += ob_len;
+               drvdata->attn_data.size -= ob_len;
        } else {
                /* Grab all of the data registers, and check them for data */
                error = rmi_read_block(fn->rmi_dev, data_addr + RMI_F03_OB_OFFSET,
index ffcbbc1745de8756cc0e151c2c9bb3e11c9ff2d4..68279f3c513054ba40f170ef46a203d440a085e2 100644 (file)
@@ -1285,19 +1285,19 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits)
        int error;
        int valid_bytes = f11->sensor.pkt_size;
 
-       if (rmi_dev->xport->attn_data) {
+       if (drvdata->attn_data.data) {
                /*
                 * The valid data in the attention report is less then
                 * expected. Only process the complete fingers.
                 */
-               if (f11->sensor.attn_size > rmi_dev->xport->attn_size)
-                       valid_bytes = rmi_dev->xport->attn_size;
+               if (f11->sensor.attn_size > drvdata->attn_data.size)
+                       valid_bytes = drvdata->attn_data.size;
                else
                        valid_bytes = f11->sensor.attn_size;
-               memcpy(f11->sensor.data_pkt, rmi_dev->xport->attn_data,
+               memcpy(f11->sensor.data_pkt, drvdata->attn_data.data,
                        valid_bytes);
-               rmi_dev->xport->attn_data += f11->sensor.attn_size;
-               rmi_dev->xport->attn_size -= f11->sensor.attn_size;
+               drvdata->attn_data.data += f11->sensor.attn_size;
+               drvdata->attn_data.size -= f11->sensor.attn_size;
        } else {
                error = rmi_read_block(rmi_dev,
                                data_base_addr, f11->sensor.data_pkt,
index 82a4964e5eb9103837883a5b9594d32a01555cef..8c5360c25266a17c2e917bf658dc3256e10e2026 100644 (file)
@@ -208,19 +208,20 @@ static int rmi_f12_attention(struct rmi_function *fn,
 {
        int retval;
        struct rmi_device *rmi_dev = fn->rmi_dev;
+       struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
        struct f12_data *f12 = dev_get_drvdata(&fn->dev);
        struct rmi_2d_sensor *sensor = &f12->sensor;
        int valid_bytes = sensor->pkt_size;
 
-       if (rmi_dev->xport->attn_data) {
-               if (sensor->attn_size > rmi_dev->xport->attn_size)
-                       valid_bytes = rmi_dev->xport->attn_size;
+       if (drvdata->attn_data.data) {
+               if (sensor->attn_size > drvdata->attn_data.size)
+                       valid_bytes = drvdata->attn_data.size;
                else
                        valid_bytes = sensor->attn_size;
-               memcpy(sensor->data_pkt, rmi_dev->xport->attn_data,
+               memcpy(sensor->data_pkt, drvdata->attn_data.data,
                        valid_bytes);
-               rmi_dev->xport->attn_data += sensor->attn_size;
-               rmi_dev->xport->attn_size -= sensor->attn_size;
+               drvdata->attn_data.data += sensor->attn_size;
+               drvdata->attn_data.size -= sensor->attn_size;
        } else {
                retval = rmi_read_block(rmi_dev, f12->data_addr,
                                        sensor->data_pkt, sensor->pkt_size);
@@ -323,7 +324,7 @@ static int rmi_f12_probe(struct rmi_function *fn)
        const struct rmi_register_desc_item *item;
        struct rmi_2d_sensor *sensor;
        struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev);
-       struct rmi_transport_dev *xport = rmi_dev->xport;
+       struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
        u16 data_offset = 0;
 
        rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s\n", __func__);
@@ -422,7 +423,7 @@ static int rmi_f12_probe(struct rmi_function *fn)
         * HID attention reports.
         */
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 0);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 1);
@@ -436,15 +437,15 @@ static int rmi_f12_probe(struct rmi_function *fn)
        }
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 2);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 3);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 4);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 5);
@@ -456,22 +457,22 @@ static int rmi_f12_probe(struct rmi_function *fn)
        }
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 6);
-       if (item && !xport->attn_data) {
+       if (item && !drvdata->attn_data.data) {
                f12->data6 = item;
                f12->data6_offset = data_offset;
                data_offset += item->reg_size;
        }
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 7);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 8);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 9);
-       if (item && !xport->attn_data) {
+       if (item && !drvdata->attn_data.data) {
                f12->data9 = item;
                f12->data9_offset = data_offset;
                data_offset += item->reg_size;
@@ -480,27 +481,27 @@ static int rmi_f12_probe(struct rmi_function *fn)
        }
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 10);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 11);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 12);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 13);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 14);
-       if (item && !xport->attn_data)
+       if (item && !drvdata->attn_data.data)
                data_offset += item->reg_size;
 
        item = rmi_get_register_desc_item(&f12->data_reg_desc, 15);
-       if (item && !xport->attn_data) {
+       if (item && !drvdata->attn_data.data) {
                f12->data15 = item;
                f12->data15_offset = data_offset;
                data_offset += item->reg_size;
index f696137a56f52a709ba73180486b51b54e0b80bb..f4b491e3e0fd4486c2680fab77515d91abaec4aa 100644 (file)
@@ -99,6 +99,7 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
 {
        struct f30_data *f30 = dev_get_drvdata(&fn->dev);
        struct rmi_device *rmi_dev = fn->rmi_dev;
+       struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
        int retval;
        int gpiled = 0;
        int value = 0;
@@ -109,15 +110,15 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
                return 0;
 
        /* Read the gpi led data. */
-       if (rmi_dev->xport->attn_data) {
-               if (rmi_dev->xport->attn_size < f30->register_count) {
+       if (drvdata->attn_data.data) {
+               if (drvdata->attn_data.size < f30->register_count) {
                        dev_warn(&fn->dev, "F30 interrupted, but data is missing\n");
                        return 0;
                }
-               memcpy(f30->data_regs, rmi_dev->xport->attn_data,
+               memcpy(f30->data_regs, drvdata->attn_data.data,
                        f30->register_count);
-               rmi_dev->xport->attn_data += f30->register_count;
-               rmi_dev->xport->attn_size -= f30->register_count;
+               drvdata->attn_data.data += f30->register_count;
+               drvdata->attn_data.size -= f30->register_count;
        } else {
                retval = rmi_read_block(rmi_dev, fn->fd.data_base_addr,
                        f30->data_regs, f30->register_count);
index 1d4865621493f8affa4e6b402d096069d892b8b2..ac910f7306888e83ccfdbf474223928306eaa05d 100644 (file)
@@ -272,9 +272,6 @@ struct rmi_transport_dev {
        struct rmi_device_platform_data pdata;
 
        struct input_dev *input;
-
-       void *attn_data;
-       int attn_size;
 };
 
 /**
@@ -364,6 +361,8 @@ struct rmi_driver_data {
 
        bool enabled;
        struct mutex enabled_mutex;
+
+       struct rmi4_attn_data attn_data;
        DECLARE_KFIFO(attn_fifo, struct rmi4_attn_data, 16);
 };