import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / input / touchscreen / mediatek / synaptics3408 / synaptics_dsx_rmi_dev.c
1 /*
2 * Synaptics DSX touchscreen driver
3 *
4 * Copyright (C) 2012 Synaptics Incorporated
5 *
6 * Copyright (C) 2012 Alexandra Chin <alexandra.chin@tw.synaptics.com>
7 * Copyright (C) 2012 Scott Lin <scott.lin@tw.synaptics.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/slab.h>
22 #include <linux/i2c.h>
23 #include <linux/interrupt.h>
24 #include <linux/delay.h>
25 #include <linux/input.h>
26 #include <linux/gpio.h>
27 #include <linux/uaccess.h>
28 #include <linux/cdev.h>
29 #include "synaptics_dsx.h"
30 #include "synaptics_dsx_i2c.h"
31
32 #define CHAR_DEVICE_NAME "rmi"
33 #define DEVICE_CLASS_NAME "rmidev"
34 #define SYSFS_FOLDER_NAME "rmidev"
35 #define DEV_NUMBER 1
36 #define REG_ADDR_LIMIT 0xFFFF
37
38 static ssize_t rmidev_sysfs_data_show(struct file *data_file,
39 struct kobject *kobj, struct bin_attribute *attributes,
40 char *buf, loff_t pos, size_t count);
41
42 static ssize_t rmidev_sysfs_data_store(struct file *data_file,
43 struct kobject *kobj, struct bin_attribute *attributes,
44 char *buf, loff_t pos, size_t count);
45
46 static ssize_t rmidev_sysfs_open_store(struct device *dev,
47 struct device_attribute *attr, const char *buf, size_t count);
48
49 static ssize_t rmidev_sysfs_release_store(struct device *dev,
50 struct device_attribute *attr, const char *buf, size_t count);
51
52 static ssize_t rmidev_sysfs_attn_state_show(struct device *dev,
53 struct device_attribute *attr, char *buf);
54
55 struct rmidev_handle {
56 dev_t dev_no;
57 struct device dev;
58 struct synaptics_rmi4_data *rmi4_data;
59 struct synaptics_rmi4_access_ptr *fn_ptr;
60 struct kobject *sysfs_dir;
61 void *data;
62 bool irq_enabled;
63 };
64
65 struct rmidev_data {
66 int ref_count;
67 struct cdev main_dev;
68 struct class *device_class;
69 struct mutex file_mutex;
70 struct rmidev_handle *rmi_dev;
71 };
72
73 static struct bin_attribute attr_data = {
74 .attr = {
75 .name = "data",
76 .mode = (S_IRUGO | S_IWUGO),
77 },
78 .size = 0,
79 .read = rmidev_sysfs_data_show,
80 .write = rmidev_sysfs_data_store,
81 };
82
83 static struct device_attribute attrs[] = {
84 __ATTR(open, S_IWUGO,
85 synaptics_rmi4_show_error,
86 rmidev_sysfs_open_store),
87 __ATTR(release, S_IWUGO,
88 synaptics_rmi4_show_error,
89 rmidev_sysfs_release_store),
90 __ATTR(attn_state, S_IRUGO,
91 rmidev_sysfs_attn_state_show,
92 synaptics_rmi4_store_error),
93 };
94
95 static int rmidev_major_num;
96
97 static struct class *rmidev_device_class;
98
99 static struct rmidev_handle *rmidev;
100
101 DECLARE_COMPLETION(rmidev_remove_complete);
102
103 static irqreturn_t rmidev_sysfs_irq(int irq, void *data)
104 {
105 struct synaptics_rmi4_data *rmi4_data = data;
106
107 sysfs_notify(&rmi4_data->input_dev->dev.kobj,
108 SYSFS_FOLDER_NAME, "attn_state");
109
110 return IRQ_HANDLED;
111 }
112
113 static int rmidev_sysfs_irq_enable(struct synaptics_rmi4_data *rmi4_data,
114 bool enable)
115 {
116 int retval = 0;
117 unsigned char intr_status[MAX_INTR_REGISTERS];
118 unsigned long irq_flags = IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING;
119
120 if (enable) {
121 if (rmidev->irq_enabled)
122 return retval;
123
124 /* Clear interrupts first */
125 retval = rmidev->fn_ptr->read(rmi4_data,
126 rmi4_data->f01_data_base_addr + 1,
127 intr_status,
128 rmi4_data->num_of_intr_regs);
129 if (retval < 0)
130 return retval;
131
132 retval = request_threaded_irq(rmi4_data->irq, NULL,
133 rmidev_sysfs_irq, irq_flags,
134 "synaptics_dsx_rmidev", rmi4_data);
135 if (retval < 0) {
136 dev_err(&rmi4_data->i2c_client->dev,
137 "%s: Failed to create irq thread\n",
138 __func__);
139 return retval;
140 }
141
142 rmidev->irq_enabled = true;
143 } else {
144 if (rmidev->irq_enabled) {
145 disable_irq(rmi4_data->irq);
146 free_irq(rmi4_data->irq, rmi4_data);
147 rmidev->irq_enabled = false;
148 }
149 }
150
151 return retval;
152 }
153
154 static ssize_t rmidev_sysfs_data_show(struct file *data_file,
155 struct kobject *kobj, struct bin_attribute *attributes,
156 char *buf, loff_t pos, size_t count)
157 {
158 int retval;
159 unsigned int length = (unsigned int)count;
160 unsigned short address = (unsigned short)pos;
161
162 if (length > (REG_ADDR_LIMIT - address)) {
163 dev_err(&rmidev->rmi4_data->i2c_client->dev,
164 "%s: Out of register map limit\n",
165 __func__);
166 return -EINVAL;
167 }
168
169 if (length) {
170 retval = rmidev->fn_ptr->read(rmidev->rmi4_data,
171 address,
172 (unsigned char *)buf,
173 length);
174 if (retval < 0) {
175 dev_err(&rmidev->rmi4_data->i2c_client->dev,
176 "%s: Failed to read data\n",
177 __func__);
178 return retval;
179 }
180 } else {
181 return -EINVAL;
182 }
183
184 return length;
185 }
186
187 static ssize_t rmidev_sysfs_data_store(struct file *data_file,
188 struct kobject *kobj, struct bin_attribute *attributes,
189 char *buf, loff_t pos, size_t count)
190 {
191 int retval;
192 unsigned int length = (unsigned int)count;
193 unsigned short address = (unsigned short)pos;
194
195 if (length > (REG_ADDR_LIMIT - address)) {
196 dev_err(&rmidev->rmi4_data->i2c_client->dev,
197 "%s: Out of register map limit\n",
198 __func__);
199 return -EINVAL;
200 }
201
202 if (length) {
203 retval = rmidev->fn_ptr->write(rmidev->rmi4_data,
204 address,
205 (unsigned char *)buf,
206 length);
207 if (retval < 0) {
208 dev_err(&rmidev->rmi4_data->i2c_client->dev,
209 "%s: Failed to write data\n",
210 __func__);
211 return retval;
212 }
213 } else {
214 return -EINVAL;
215 }
216
217 return length;
218 }
219
220 static ssize_t rmidev_sysfs_open_store(struct device *dev,
221 struct device_attribute *attr, const char *buf, size_t count)
222 {
223 unsigned int input;
224 struct synaptics_rmi4_data *rmi4_data = rmidev->rmi4_data;
225
226 if (sscanf(buf, "%u", &input) != 1)
227 return -EINVAL;
228
229 if (input != 1)
230 return -EINVAL;
231
232 rmidev->fn_ptr->enable(rmi4_data, false);
233 rmidev_sysfs_irq_enable(rmi4_data, true);
234
235 dev_dbg(&rmi4_data->i2c_client->dev,
236 "%s: Attention interrupt disabled\n",
237 __func__);
238
239 return count;
240 }
241
242 static ssize_t rmidev_sysfs_release_store(struct device *dev,
243 struct device_attribute *attr, const char *buf, size_t count)
244 {
245 unsigned int input;
246 struct synaptics_rmi4_data *rmi4_data = rmidev->rmi4_data;
247
248 if (sscanf(buf, "%u", &input) != 1)
249 return -EINVAL;
250
251 if (input != 1)
252 return -EINVAL;
253
254 rmi4_data->reset_device(rmi4_data);
255
256 rmidev_sysfs_irq_enable(rmi4_data, false);
257 rmidev->fn_ptr->enable(rmi4_data, true);
258
259 dev_dbg(&rmi4_data->i2c_client->dev,
260 "%s: Attention interrupt enabled\n",
261 __func__);
262
263 return count;
264 }
265
266 static ssize_t rmidev_sysfs_attn_state_show(struct device *dev,
267 struct device_attribute *attr, char *buf)
268 {
269 int attn_state;
270 const struct synaptics_dsx_platform_data *platform_data =
271 rmidev->rmi4_data->board;
272
273 attn_state = gpio_get_value(platform_data->irq_gpio);
274
275 return snprintf(buf, PAGE_SIZE, "%u\n", attn_state);
276 }
277
278 /*
279 * rmidev_llseek - used to set up register address
280 *
281 * @filp: file structure for seek
282 * @off: offset
283 * if whence == SEEK_SET,
284 * high 16 bits: page address
285 * low 16 bits: register address
286 * if whence == SEEK_CUR,
287 * offset from current position
288 * if whence == SEEK_END,
289 * offset from end position (0xFFFF)
290 * @whence: SEEK_SET, SEEK_CUR, or SEEK_END
291 */
292 static loff_t rmidev_llseek(struct file *filp, loff_t off, int whence)
293 {
294 loff_t newpos;
295 struct rmidev_data *dev_data = filp->private_data;
296
297 if (IS_ERR(dev_data)) {
298 pr_err("%s: Pointer of char device data is invalid", __func__);
299 return -EBADF;
300 }
301
302 mutex_lock(&(dev_data->file_mutex));
303
304 switch (whence) {
305 case SEEK_SET:
306 newpos = off;
307 break;
308 case SEEK_CUR:
309 newpos = filp->f_pos + off;
310 break;
311 case SEEK_END:
312 newpos = REG_ADDR_LIMIT + off;
313 break;
314 default:
315 newpos = -EINVAL;
316 goto clean_up;
317 }
318
319 if (newpos < 0 || newpos > REG_ADDR_LIMIT) {
320 dev_err(&rmidev->rmi4_data->i2c_client->dev,
321 "%s: New position 0x%04x is invalid\n",
322 __func__, (unsigned int)newpos);
323 newpos = -EINVAL;
324 goto clean_up;
325 }
326
327 filp->f_pos = newpos;
328
329 clean_up:
330 mutex_unlock(&(dev_data->file_mutex));
331
332 return newpos;
333 }
334
335 /*
336 * rmidev_read: - use to read data from rmi device
337 *
338 * @filp: file structure for read
339 * @buf: user space buffer pointer
340 * @count: number of bytes to read
341 * @f_pos: offset (starting register address)
342 */
343 static ssize_t rmidev_read(struct file *filp, char __user *buf,
344 size_t count, loff_t *f_pos)
345 {
346 ssize_t retval;
347 unsigned char tmpbuf[count + 1];
348 struct rmidev_data *dev_data = filp->private_data;
349
350 if (IS_ERR(dev_data)) {
351 pr_err("%s: Pointer of char device data is invalid", __func__);
352 return -EBADF;
353 }
354
355 if (count == 0)
356 return 0;
357
358 if (count > (REG_ADDR_LIMIT - *f_pos))
359 count = REG_ADDR_LIMIT - *f_pos;
360
361 mutex_lock(&(dev_data->file_mutex));
362
363 retval = rmidev->fn_ptr->read(rmidev->rmi4_data,
364 *f_pos,
365 tmpbuf,
366 count);
367 if (retval < 0)
368 goto clean_up;
369
370 if (copy_to_user(buf, tmpbuf, count))
371 retval = -EFAULT;
372 else
373 *f_pos += retval;
374
375 clean_up:
376 mutex_unlock(&(dev_data->file_mutex));
377
378 return retval;
379 }
380
381 /*
382 * rmidev_write: - used to write data to rmi device
383 *
384 * @filep: file structure for write
385 * @buf: user space buffer pointer
386 * @count: number of bytes to write
387 * @f_pos: offset (starting register address)
388 */
389 static ssize_t rmidev_write(struct file *filp, const char __user *buf,
390 size_t count, loff_t *f_pos)
391 {
392 ssize_t retval;
393 unsigned char tmpbuf[count + 1];
394 struct rmidev_data *dev_data = filp->private_data;
395
396 if (IS_ERR(dev_data)) {
397 pr_err("%s: Pointer of char device data is invalid", __func__);
398 return -EBADF;
399 }
400
401 if (count == 0)
402 return 0;
403
404 if (count > (REG_ADDR_LIMIT - *f_pos))
405 count = REG_ADDR_LIMIT - *f_pos;
406
407 if (copy_from_user(tmpbuf, buf, count))
408 return -EFAULT;
409
410 mutex_lock(&(dev_data->file_mutex));
411
412 retval = rmidev->fn_ptr->write(rmidev->rmi4_data,
413 *f_pos,
414 tmpbuf,
415 count);
416 if (retval >= 0)
417 *f_pos += retval;
418
419 mutex_unlock(&(dev_data->file_mutex));
420
421 return retval;
422 }
423
424 /*
425 * rmidev_open: enable access to rmi device
426 * @inp: inode struture
427 * @filp: file structure
428 */
429 static int rmidev_open(struct inode *inp, struct file *filp)
430 {
431 int retval = 0;
432 struct rmidev_data *dev_data =
433 container_of(inp->i_cdev, struct rmidev_data, main_dev);
434
435 if (!dev_data)
436 return -EACCES;
437
438 filp->private_data = dev_data;
439
440 mutex_lock(&(dev_data->file_mutex));
441
442 rmidev->fn_ptr->enable(rmidev->rmi4_data, false);
443 dev_dbg(&rmidev->rmi4_data->i2c_client->dev,
444 "%s: Attention interrupt disabled\n",
445 __func__);
446
447 if (dev_data->ref_count < 1)
448 dev_data->ref_count++;
449 else
450 retval = -EACCES;
451
452 mutex_unlock(&(dev_data->file_mutex));
453
454 return retval;
455 }
456
457 /*
458 * rmidev_release: - release access to rmi device
459 * @inp: inode structure
460 * @filp: file structure
461 */
462 static int rmidev_release(struct inode *inp, struct file *filp)
463 {
464 struct synaptics_rmi4_data *rmi4_data = rmidev->rmi4_data;
465 struct rmidev_data *dev_data =
466 container_of(inp->i_cdev, struct rmidev_data, main_dev);
467
468 if (!dev_data)
469 return -EACCES;
470
471 rmi4_data->reset_device(rmi4_data);
472
473 mutex_lock(&(dev_data->file_mutex));
474
475 dev_data->ref_count--;
476 if (dev_data->ref_count < 0)
477 dev_data->ref_count = 0;
478
479 rmidev->fn_ptr->enable(rmi4_data, true);
480 dev_dbg(&rmi4_data->i2c_client->dev,
481 "%s: Attention interrupt enabled\n",
482 __func__);
483
484 mutex_unlock(&(dev_data->file_mutex));
485
486 return 0;
487 }
488
489 static const struct file_operations rmidev_fops = {
490 .owner = THIS_MODULE,
491 .llseek = rmidev_llseek,
492 .read = rmidev_read,
493 .write = rmidev_write,
494 .open = rmidev_open,
495 .release = rmidev_release,
496 };
497
498 static void rmidev_device_cleanup(struct rmidev_data *dev_data)
499 {
500 dev_t devno;
501
502 if (dev_data) {
503 devno = dev_data->main_dev.dev;
504
505 if (dev_data->device_class)
506 device_destroy(dev_data->device_class, devno);
507
508 cdev_del(&dev_data->main_dev);
509
510 unregister_chrdev_region(devno, 1);
511
512 dev_dbg(&rmidev->rmi4_data->i2c_client->dev,
513 "%s: rmidev device removed\n",
514 __func__);
515 }
516
517 return;
518 }
519
520 static char *rmi_char_devnode(struct device *dev, mode_t *mode)
521 {
522 if (!mode)
523 return NULL;
524
525 *mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
526
527 return kasprintf(GFP_KERNEL, "rmi/%s", dev_name(dev));
528 }
529
530 static int rmidev_create_device_class(void)
531 {
532 rmidev_device_class = class_create(THIS_MODULE, DEVICE_CLASS_NAME);
533
534 if (IS_ERR(rmidev_device_class)) {
535 pr_err("%s: Failed to create /dev/%s\n",
536 __func__, CHAR_DEVICE_NAME);
537 return -ENODEV;
538 }
539
540 rmidev_device_class->devnode = rmi_char_devnode;
541
542 return 0;
543 }
544
545 static int rmidev_init_device(struct synaptics_rmi4_data *rmi4_data)
546 {
547 int retval;
548 dev_t dev_no;
549 unsigned char attr_count;
550 struct rmidev_data *dev_data;
551 struct device *device_ptr;
552
553 rmidev = kzalloc(sizeof(*rmidev), GFP_KERNEL);
554 if (!rmidev) {
555 dev_err(&rmi4_data->i2c_client->dev,
556 "%s: Failed to alloc mem for rmidev\n",
557 __func__);
558 retval = -ENOMEM;
559 goto err_rmidev;
560 }
561
562 rmidev->fn_ptr = kzalloc(sizeof(*(rmidev->fn_ptr)), GFP_KERNEL);
563 if (!rmidev) {
564 dev_err(&rmi4_data->i2c_client->dev,
565 "%s: Failed to alloc mem for fn_ptr\n",
566 __func__);
567 retval = -ENOMEM;
568 goto err_fn_ptr;
569 }
570
571 rmidev->fn_ptr->read = rmi4_data->i2c_read;
572 rmidev->fn_ptr->write = rmi4_data->i2c_write;
573 rmidev->fn_ptr->enable = rmi4_data->irq_enable;
574 rmidev->rmi4_data = rmi4_data;
575
576 retval = rmidev_create_device_class();
577 if (retval < 0) {
578 dev_err(&rmi4_data->i2c_client->dev,
579 "%s: Failed to create device class\n",
580 __func__);
581 goto err_device_class;
582 }
583
584 if (rmidev_major_num) {
585 dev_no = MKDEV(rmidev_major_num, DEV_NUMBER);
586 retval = register_chrdev_region(dev_no, 1, CHAR_DEVICE_NAME);
587 } else {
588 retval = alloc_chrdev_region(&dev_no, 0, 1, CHAR_DEVICE_NAME);
589 if (retval < 0) {
590 dev_err(&rmi4_data->i2c_client->dev,
591 "%s: Failed to allocate char device region\n",
592 __func__);
593 goto err_device_region;
594 }
595
596 rmidev_major_num = MAJOR(dev_no);
597 dev_dbg(&rmi4_data->i2c_client->dev,
598 "%s: Major number of rmidev = %d\n",
599 __func__, rmidev_major_num);
600 }
601
602 dev_data = kzalloc(sizeof(*dev_data), GFP_KERNEL);
603 if (!dev_data) {
604 dev_err(&rmi4_data->i2c_client->dev,
605 "%s: Failed to alloc mem for dev_data\n",
606 __func__);
607 retval = -ENOMEM;
608 goto err_dev_data;
609 }
610
611 mutex_init(&dev_data->file_mutex);
612 dev_data->rmi_dev = rmidev;
613 rmidev->data = dev_data;
614
615 cdev_init(&dev_data->main_dev, &rmidev_fops);
616
617 retval = cdev_add(&dev_data->main_dev, dev_no, 1);
618 if (retval < 0) {
619 dev_err(&rmi4_data->i2c_client->dev,
620 "%s: Failed to add rmi char device\n",
621 __func__);
622 goto err_char_device;
623 }
624
625 dev_set_name(&rmidev->dev, "rmidev%d", MINOR(dev_no));
626 dev_data->device_class = rmidev_device_class;
627
628 device_ptr = device_create(dev_data->device_class, NULL, dev_no,
629 NULL, CHAR_DEVICE_NAME"%d", MINOR(dev_no));
630 if (IS_ERR(device_ptr)) {
631 dev_err(&rmi4_data->i2c_client->dev,
632 "%s: Failed to create rmi char device\n",
633 __func__);
634 retval = -ENODEV;
635 goto err_char_device;
636 }
637
638 retval = gpio_export(rmi4_data->board->irq_gpio, false);
639 if (retval < 0) {
640 dev_err(&rmi4_data->i2c_client->dev,
641 "%s: Failed to export attention gpio\n",
642 __func__);
643 } else {
644 retval = gpio_export_link(&(rmi4_data->input_dev->dev),
645 "attn", rmi4_data->board->irq_gpio);
646 if (retval < 0) {
647 dev_err(&rmi4_data->input_dev->dev,
648 "%s Failed to create gpio symlink\n",
649 __func__);
650 } else {
651 dev_dbg(&rmi4_data->input_dev->dev,
652 "%s: Exported attention gpio %d\n",
653 __func__, rmi4_data->board->irq_gpio);
654 }
655 }
656
657 rmidev->sysfs_dir = kobject_create_and_add(SYSFS_FOLDER_NAME,
658 &rmi4_data->input_dev->dev.kobj);
659 if (!rmidev->sysfs_dir) {
660 dev_err(&rmi4_data->i2c_client->dev,
661 "%s: Failed to create sysfs directory\n",
662 __func__);
663 retval = -ENODEV;
664 goto err_sysfs_dir;
665 }
666
667 retval = sysfs_create_bin_file(rmidev->sysfs_dir,
668 &attr_data);
669 if (retval < 0) {
670 dev_err(&rmi4_data->i2c_client->dev,
671 "%s: Failed to create sysfs bin file\n",
672 __func__);
673 goto err_sysfs_bin;
674 }
675
676 for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) {
677 retval = sysfs_create_file(rmidev->sysfs_dir,
678 &attrs[attr_count].attr);
679 if (retval < 0) {
680 dev_err(&rmi4_data->input_dev->dev,
681 "%s: Failed to create sysfs attributes\n",
682 __func__);
683 retval = -ENODEV;
684 goto err_sysfs_attrs;
685 }
686 }
687
688 return 0;
689
690 err_sysfs_attrs:
691 for (attr_count--; attr_count >= 0; attr_count--)
692 sysfs_remove_file(rmidev->sysfs_dir, &attrs[attr_count].attr);
693
694 sysfs_remove_bin_file(rmidev->sysfs_dir, &attr_data);
695
696 err_sysfs_bin:
697 kobject_put(rmidev->sysfs_dir);
698
699 err_sysfs_dir:
700 err_char_device:
701 rmidev_device_cleanup(dev_data);
702 kfree(dev_data);
703
704 err_dev_data:
705 unregister_chrdev_region(dev_no, 1);
706
707 err_device_region:
708 class_destroy(rmidev_device_class);
709
710 err_device_class:
711 kfree(rmidev->fn_ptr);
712
713 err_fn_ptr:
714 kfree(rmidev);
715 rmidev = NULL;
716
717 err_rmidev:
718 return retval;
719 }
720
721 static void rmidev_remove_device(struct synaptics_rmi4_data *rmi4_data)
722 {
723 unsigned char attr_count;
724 struct rmidev_data *dev_data;
725
726 if (!rmidev)
727 goto exit;
728
729 for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++)
730 sysfs_remove_file(rmidev->sysfs_dir, &attrs[attr_count].attr);
731
732 sysfs_remove_bin_file(rmidev->sysfs_dir, &attr_data);
733
734 kobject_put(rmidev->sysfs_dir);
735
736 dev_data = rmidev->data;
737 if (dev_data) {
738 rmidev_device_cleanup(dev_data);
739 kfree(dev_data);
740 }
741
742 unregister_chrdev_region(rmidev->dev_no, 1);
743
744 class_destroy(rmidev_device_class);
745
746 kfree(rmidev->fn_ptr);
747 kfree(rmidev);
748 rmidev = NULL;
749
750 exit:
751 complete(&rmidev_remove_complete);
752
753 return;
754 }
755
756 static struct synaptics_rmi4_exp_fn rmidev_module = {
757 .fn_type = RMI_DEV,
758 .init = rmidev_init_device,
759 .remove = rmidev_remove_device,
760 .reset = NULL,
761 .reinit = NULL,
762 .early_suspend = NULL,
763 .suspend = NULL,
764 .resume = NULL,
765 .late_resume = NULL,
766 .attn = NULL,
767 };
768
769 static int __init rmidev_module_init(void)
770 {
771 synaptics_rmi4_new_function(&rmidev_module, true);
772
773 return 0;
774 }
775
776 static void __exit rmidev_module_exit(void)
777 {
778 synaptics_rmi4_new_function(&rmidev_module, false);
779
780 wait_for_completion(&rmidev_remove_complete);
781
782 return;
783 }
784
785 module_init(rmidev_module_init);
786 module_exit(rmidev_module_exit);
787
788 MODULE_AUTHOR("Synaptics, Inc.");
789 MODULE_DESCRIPTION("Synaptics DSX RMI Dev Module");
790 MODULE_LICENSE("GPL v2");