17 #include <linux/kernel.h>
18 #include <linux/module.h>
20 #include <linux/slab.h>
21 #include <linux/input.h>
28 #define DRV_NAME "gpio-tilt-polled"
41 static void gpio_tilt_polled_poll(
struct input_polled_dev *
dev)
45 struct input_dev *
input = dev->input;
53 for (i = 0; i < pdata->
nr_gpios; i++)
58 if (pdata->
states[i].gpios == state)
62 for (i = 0; i < pdata->
nr_axes; i++)
63 input_report_abs(input,
76 static void gpio_tilt_polled_open(
struct input_polled_dev *dev)
87 gpio_tilt_polled_poll(tdev->
poll_dev);
90 static void gpio_tilt_polled_close(
struct input_polled_dev *dev)
104 struct input_polled_dev *poll_dev;
105 struct input_dev *
input;
113 dev_err(dev,
"no memory for private data\n");
120 "Could not request tilt GPIOs: %d\n", error);
126 dev_err(dev,
"no memory for polled device\n");
131 poll_dev->private = tdev;
132 poll_dev->poll = gpio_tilt_polled_poll;
134 poll_dev->open = gpio_tilt_polled_open;
135 poll_dev->close = gpio_tilt_polled_close;
137 input = poll_dev->input;
139 input->name = pdev->
name;
141 input->dev.parent = &pdev->
dev;
144 input->id.vendor = 0x0001;
145 input->id.product = 0x0001;
146 input->id.version = 0x0100;
149 for (i = 0; i < pdata->
nr_axes; i++)
150 input_set_abs_params(input, pdata->
axes[i].axis,
151 pdata->
axes[i].min, pdata->
axes[i].max,
152 pdata->
axes[i].fuzz, pdata->
axes[i].flat);
163 dev_err(dev,
"unable to register polled device, err=%d\n",
165 goto err_free_polldev;
168 platform_set_drvdata(pdev, tdev);
187 platform_set_drvdata(pdev,
NULL);
200 .probe = gpio_tilt_polled_probe,