12 #include <linux/i2c.h>
14 #include <linux/slab.h>
15 #include <linux/input.h>
16 #include <linux/module.h>
42 static int gp2a_report(
struct gp2a_data *dt)
47 input_sync(dt->
input);
61 static int gp2a_enable(
struct gp2a_data *dt)
67 static int gp2a_disable(
struct gp2a_data *dt)
73 static int gp2a_device_open(
struct input_dev *
dev)
75 struct gp2a_data *dt = input_get_drvdata(dev);
78 error = gp2a_enable(dt);
81 "unable to activate, err %d\n", error);
90 static void gp2a_device_close(
struct input_dev *dev)
92 struct gp2a_data *dt = input_get_drvdata(dev);
95 error = gp2a_disable(dt);
98 "unable to deactivate, err %d\n", error);
120 error = gp2a_disable(dt);
143 goto err_hw_shutdown;
154 error = gp2a_initialize(dt);
158 dt->
input = input_allocate_device();
164 input_set_drvdata(dt->
input, dt);
166 dt->
input->open = gp2a_device_open;
167 dt->
input->close = gp2a_device_close;
170 dt->
input->dev.parent = &client->
dev;
179 dev_err(&client->
dev,
"irq request failed\n");
180 goto err_free_input_dev;
183 error = input_register_device(dt->
input);
185 dev_err(&client->
dev,
"device registration failed\n");
190 i2c_set_clientdata(client, dt);
197 input_free_device(dt->
input);
210 struct gp2a_data *dt = i2c_get_clientdata(client);
217 input_unregister_device(dt->
input);
228 #ifdef CONFIG_PM_SLEEP
229 static int gp2a_suspend(
struct device *dev)
232 struct gp2a_data *dt = i2c_get_clientdata(client);
235 if (device_may_wakeup(&client->
dev)) {
236 enable_irq_wake(client->
irq);
239 if (dt->
input->users)
240 retval = gp2a_disable(dt);
247 static int gp2a_resume(
struct device *dev)
250 struct gp2a_data *dt = i2c_get_clientdata(client);
253 if (device_may_wakeup(&client->
dev)) {
254 disable_irq_wake(client->
irq);
257 if (dt->
input->users)
258 retval = gp2a_enable(dt);
281 .id_table = gp2a_i2c_id,