struct i2c_client *client;
struct input_dev *input_dev;
struct input_dev *key_input_dev;
- struct work_struct work;
struct max11871_finger_data finger[MAX_TOUCHES_LIMIT];
struct early_suspend early_suspend;
- struct device dev;
- int irq_flags;
char phys[32];
char key_phys[32];
};
#define DEBUG_ENABLE 0
#define DRIVER_MSG_DEBUG_ENABLE 0
#define MAX_TOUCHES_ALLOWED 2
-static struct workqueue_struct *maxim_wq;
#ifdef CONFIG_HAS_EARLYSUSPEND
static void max11871_early_suspend(struct early_suspend *h);
return ret;
}
-static void maxim_ts_work_func(struct work_struct *work)
-{
- int result = 0;
- u16 reportType = 0;
- struct max11871_data *ts = container_of(work,
- struct max11871_data, work);
-
- /* Read the entire report in from i2c */
- reportType = maxim_read_report(ts, ReportBuffer);
-
- result = maxim_process_report(ts, reportType, ReportBuffer);
-
- /* Wipe the buffer if we got a packet we didn't process */
- if (result < 0)
- memset(ReportBuffer, 0, SIZE_OF_RPT_BUFFER);
-
- enable_irq(ts->client->irq);
-
- return;
-}
-
/*
* Finds the part on the i2c bus. If found, maxim_ts_data->client will have
* the correct address stored.
static irqreturn_t max11871_irq_handler(int irq, void *dev_id)
{
struct max11871_data *ts = dev_id;
- disable_irq_nosync(ts->client->irq);
- queue_work(maxim_wq, &ts->work);
+ int result = 0;
+ u16 reportType = 0;
+
+ /* Read the entire report in from i2c */
+ reportType = maxim_read_report(ts, ReportBuffer);
+
+ result = maxim_process_report(ts, reportType, ReportBuffer);
+
+ /* Wipe the buffer if we got a packet we didn't process */
+ if (result < 0)
+ memset(ReportBuffer, 0, SIZE_OF_RPT_BUFFER);
+
return IRQ_HANDLED;
}
const struct i2c_device_id *id)
{
struct max11871_data *ts = NULL;
- struct max11871_platform_data *pdata = pdata =
+ struct max11871_platform_data *pdata =
client->dev.platform_data;
-
int ret = 0;
- /*struct i2c_data *pdata = NULL;*/
int i = 0;
- /*maxinfo(":....\n");*/
- pr_info("max11871: offset to 30\n");
-
ReportBuffer = kmalloc(SIZE_OF_RPT_BUFFER, GFP_KERNEL);
if (ReportBuffer == NULL) {
maxerr("kmalloc failed!\n");
goto err_alloc_data_failed;
}
- maxim_wq = create_singlethread_workqueue("maxim_wq");
- if (!maxim_wq) {
- ret = -ENOMEM;
- goto err_alloc_data_failed;
- }
-
-
if (!pdata) {
dev_err(&client->dev, "platform data is required!\n");
maxerr("platform data is required\n");
goto err_alloc_data_failed;
}
- /* Setup work queue and setup i2c client data */
- INIT_WORK(&ts->work, maxim_ts_work_func);
+ /* setup i2c client data */
ts->client = client;
i2c_set_clientdata(client, ts);
/* Setup the IRQ and irq_handler to use */
client->irq = gpio_to_irq(pdata->gpio_irq);
if (client->irq > 0) {
- ret = request_irq(client->irq,
- max11871_irq_handler,
- IRQ_TYPE_EDGE_FALLING,
- client->name, ts);
-
- if (ret == 0) {
- maxinfo(" max11871 using irq:%i", client->irq);
- } else {
+ ret = request_threaded_irq(client->irq, NULL,
+ max11871_irq_handler,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ client->name, ts);
+
+ if (ret < 0) {
dev_err(&ts->client->dev, "request_irq failed\n");
- maxerr("request_irq %i failed\n", client->irq);
- ret = -ENODEV;
goto err_input_register_device_failed;
}
}
err_input_dev_alloc_failed:
err_power_failed:
-/* destroy_workqueue(maxim_wq); */
err_detect_failed:
if (ts != NULL)
kfree(ts);
#endif
free_irq(client->irq, ts);
- if (maxim_wq)
- destroy_workqueue(maxim_wq);
-
input_unregister_device(ts->input_dev);
kfree(ReportBuffer);
kfree(ts);
static int max11871_suspend(struct i2c_client *client, pm_message_t mesg)
{
- struct max11871_data *ts = i2c_get_clientdata(client);
uint8_t data[16];
int ret = 0;
maxinfo("Enter max11871_suspend\n");
disable_irq_nosync(client->irq);
- ret = cancel_work_sync(&ts->work);
- if (ret)
- enable_irq(client->irq);
memset(data , 0x00 , sizeof(data));
data[9] = 0x00;
ret = i2c_master_send(client, data, 10);
- if (ret < 0) {
- maxerr("Maxim 11871 I2C failure on Suspend: %d. Exiting\n",
- ret);
- }
+ if (ret < 0)
+ maxerr("max11871 I2C failure on Suspend: %d. Exiting\n", ret);
return ret;
}