Commit fc47912d authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:
 "A few drivers were updated with device tree bindings and others got a
  few small cleanups and fixes."

Fix trivial conflict in drivers/input/keyboard/omap-keypad.c due to
changes clashing with a whitespace cleanup.

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (28 commits)
  Input: wacom - mark Intuos5 pad as in-prox when touching buttons
  Input: synaptics - adjust threshold for treating position values as negative
  Input: hgpk - use %*ph to dump small buffer
  Input: gpio_keys_polled - fix dt pdata->nbuttons
  Input: Add KD[GS]KBDIACRUC ioctls to the compatible list
  Input: omap-keypad - fixed formatting
  Input: tegra - move platform data header
  Input: wacom - add support for EMR on Cintiq 24HD touch
  Input: s3c2410_ts - make s3c_ts_pmops const
  Input: samsung-keypad - use of_get_child_count() helper
  Input: samsung-keypad - use of_match_ptr()
  Input: uinput - fix formatting
  Input: uinput - specify exact bit sizes on userspace APIs
  Input: uinput - mark failed submission requests as free
  Input: uinput - fix race that can block nonblocking read
  Input: uinput - return -EINVAL when read buffer size is too small
  Input: uinput - take event lock when fetching events from buffer
  Input: get rid of MATCH_BIT() macro
  Input: rotary-encoder - add DT bindings
  Input: rotary-encoder - constify platform data pointers
  ...
parents 06fe918e dde3ada3
Device-Tree bindings for input/gpio_keys_polled.c keyboard driver
Required properties:
- compatible = "gpio-keys-polled";
- poll-interval: Poll interval time in milliseconds
Optional properties:
- autorepeat: Boolean, Enable auto repeat feature of Linux input
subsystem.
Each button (key) is represented as a sub-node of "gpio-keys-polled":
Subnode properties:
- gpios: OF device-tree gpio specification.
- label: Descriptive name of the key.
- linux,code: Keycode to emit.
Optional subnode-properties:
- linux,input-type: Specify event type this button/key generates.
If not specified defaults to <1> == EV_KEY.
- debounce-interval: Debouncing interval time in milliseconds.
If not specified defaults to 5.
- gpio-key,wakeup: Boolean, button can wake-up the system.
Example nodes:
gpio_keys_polled {
compatible = "gpio-keys-polled";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <100>;
autorepeat;
button@21 {
label = "GPIO Key UP";
linux,code = <103>;
gpios = <&gpio1 0 1>;
};
...
Rotary encoder DT bindings
Required properties:
- gpios: a spec for two GPIOs to be used
Optional properties:
- linux,axis: the input subsystem axis to map to this rotary encoder.
Defaults to 0 (ABS_X / REL_X)
- rotary-encoder,steps: Number of steps in a full turnaround of the
encoder. Only relevant for absolute axis. Defaults to 24 which is a
typical value for such devices.
- rotary-encoder,relative-axis: register a relative axis rather than an
absolute one. Relative axis will only generate +1/-1 events on the input
device, hence no steps need to be passed.
- rotary-encoder,rollover: Automatic rollove when the rotary value becomes
greater than the specified steps or smaller than 0. For absolute axis only.
- rotary-encoder,half-period: Makes the driver work on half-period mode.
See Documentation/input/rotary-encoder.txt for more information.
Example:
rotary@0 {
compatible = "rotary-encoder";
gpios = <&gpio 19 1>, <&gpio 20 0>; /* GPIO19 is inverted */
linux,axis = <0>; /* REL_X */
rotary-encoder,relative-axis;
};
rotary@1 {
compatible = "rotary-encoder";
gpios = <&gpio 21 0>, <&gpio 22 0>;
linux,axis = <1>; /* ABS_Y */
rotary-encoder,steps = <24>;
rotary-encoder,rollover;
};
...@@ -33,7 +33,7 @@ static void system_power_event(unsigned int keycode) ...@@ -33,7 +33,7 @@ static void system_power_event(unsigned int keycode)
} }
static void apmpower_event(struct input_handle *handle, unsigned int type, static void apmpower_event(struct input_handle *handle, unsigned int type,
unsigned int code, int value) unsigned int code, int value)
{ {
/* only react on key down events */ /* only react on key down events */
if (value != 1) if (value != 1)
......
...@@ -138,8 +138,8 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, ...@@ -138,8 +138,8 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect,
if (effect->id == -1) { if (effect->id == -1) {
for (id = 0; id < ff->max_effects; id++) for (id = 0; id < ff->max_effects; id++)
if (!ff->effect_owners[id]) if (!ff->effect_owners[id])
break; break;
if (id >= ff->max_effects) { if (id >= ff->max_effects) {
ret = -ENOSPC; ret = -ENOSPC;
......
...@@ -72,12 +72,14 @@ static const struct ff_envelope *get_envelope(const struct ff_effect *effect) ...@@ -72,12 +72,14 @@ static const struct ff_envelope *get_envelope(const struct ff_effect *effect)
static const struct ff_envelope empty_envelope; static const struct ff_envelope empty_envelope;
switch (effect->type) { switch (effect->type) {
case FF_PERIODIC: case FF_PERIODIC:
return &effect->u.periodic.envelope; return &effect->u.periodic.envelope;
case FF_CONSTANT:
return &effect->u.constant.envelope; case FF_CONSTANT:
default: return &effect->u.constant.envelope;
return &empty_envelope;
default:
return &empty_envelope;
} }
} }
......
...@@ -918,18 +918,10 @@ int input_set_keycode(struct input_dev *dev, ...@@ -918,18 +918,10 @@ int input_set_keycode(struct input_dev *dev,
} }
EXPORT_SYMBOL(input_set_keycode); EXPORT_SYMBOL(input_set_keycode);
#define MATCH_BIT(bit, max) \
for (i = 0; i < BITS_TO_LONGS(max); i++) \
if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \
break; \
if (i != BITS_TO_LONGS(max)) \
continue;
static const struct input_device_id *input_match_device(struct input_handler *handler, static const struct input_device_id *input_match_device(struct input_handler *handler,
struct input_dev *dev) struct input_dev *dev)
{ {
const struct input_device_id *id; const struct input_device_id *id;
int i;
for (id = handler->id_table; id->flags || id->driver_info; id++) { for (id = handler->id_table; id->flags || id->driver_info; id++) {
...@@ -949,15 +941,32 @@ static const struct input_device_id *input_match_device(struct input_handler *ha ...@@ -949,15 +941,32 @@ static const struct input_device_id *input_match_device(struct input_handler *ha
if (id->version != dev->id.version) if (id->version != dev->id.version)
continue; continue;
MATCH_BIT(evbit, EV_MAX); if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX))
MATCH_BIT(keybit, KEY_MAX); continue;
MATCH_BIT(relbit, REL_MAX);
MATCH_BIT(absbit, ABS_MAX); if (!bitmap_subset(id->keybit, dev->keybit, KEY_MAX))
MATCH_BIT(mscbit, MSC_MAX); continue;
MATCH_BIT(ledbit, LED_MAX);
MATCH_BIT(sndbit, SND_MAX); if (!bitmap_subset(id->relbit, dev->relbit, REL_MAX))
MATCH_BIT(ffbit, FF_MAX); continue;
MATCH_BIT(swbit, SW_MAX);
if (!bitmap_subset(id->absbit, dev->absbit, ABS_MAX))
continue;
if (!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX))
continue;
if (!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX))
continue;
if (!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX))
continue;
if (!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX))
continue;
if (!bitmap_subset(id->swbit, dev->swbit, SW_MAX))
continue;
if (!handler->match || handler->match(handler, dev)) if (!handler->match || handler->match(handler, dev))
return id; return id;
......
...@@ -711,7 +711,7 @@ static long joydev_ioctl(struct file *file, ...@@ -711,7 +711,7 @@ static long joydev_ioctl(struct file *file,
case JS_SET_ALL: case JS_SET_ALL:
retval = copy_from_user(&joydev->glue, argp, retval = copy_from_user(&joydev->glue, argp,
sizeof(joydev->glue)) ? -EFAULT: 0; sizeof(joydev->glue)) ? -EFAULT : 0;
break; break;
case JS_GET_ALL: case JS_GET_ALL:
......
...@@ -43,11 +43,9 @@ struct gpio_button_data { ...@@ -43,11 +43,9 @@ struct gpio_button_data {
}; };
struct gpio_keys_drvdata { struct gpio_keys_drvdata {
const struct gpio_keys_platform_data *pdata;
struct input_dev *input; struct input_dev *input;
struct mutex disable_lock; struct mutex disable_lock;
unsigned int n_buttons;
int (*enable)(struct device *dev);
void (*disable)(struct device *dev);
struct gpio_button_data data[0]; struct gpio_button_data data[0];
}; };
...@@ -171,7 +169,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata, ...@@ -171,7 +169,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
if (!bits) if (!bits)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < ddata->n_buttons; i++) { for (i = 0; i < ddata->pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i]; struct gpio_button_data *bdata = &ddata->data[i];
if (bdata->button->type != type) if (bdata->button->type != type)
...@@ -219,7 +217,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, ...@@ -219,7 +217,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
goto out; goto out;
/* First validate */ /* First validate */
for (i = 0; i < ddata->n_buttons; i++) { for (i = 0; i < ddata->pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i]; struct gpio_button_data *bdata = &ddata->data[i];
if (bdata->button->type != type) if (bdata->button->type != type)
...@@ -234,7 +232,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, ...@@ -234,7 +232,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
mutex_lock(&ddata->disable_lock); mutex_lock(&ddata->disable_lock);
for (i = 0; i < ddata->n_buttons; i++) { for (i = 0; i < ddata->pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i]; struct gpio_button_data *bdata = &ddata->data[i];
if (bdata->button->type != type) if (bdata->button->type != type)
...@@ -346,6 +344,9 @@ static void gpio_keys_gpio_work_func(struct work_struct *work) ...@@ -346,6 +344,9 @@ static void gpio_keys_gpio_work_func(struct work_struct *work)
container_of(work, struct gpio_button_data, work); container_of(work, struct gpio_button_data, work);
gpio_keys_gpio_report_event(bdata); gpio_keys_gpio_report_event(bdata);
if (bdata->button->wakeup)
pm_relax(bdata->input->dev.parent);
} }
static void gpio_keys_gpio_timer(unsigned long _data) static void gpio_keys_gpio_timer(unsigned long _data)
...@@ -361,6 +362,8 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) ...@@ -361,6 +362,8 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
BUG_ON(irq != bdata->irq); BUG_ON(irq != bdata->irq);
if (bdata->button->wakeup)
pm_stay_awake(bdata->input->dev.parent);
if (bdata->timer_debounce) if (bdata->timer_debounce)
mod_timer(&bdata->timer, mod_timer(&bdata->timer,
jiffies + msecs_to_jiffies(bdata->timer_debounce)); jiffies + msecs_to_jiffies(bdata->timer_debounce));
...@@ -397,6 +400,9 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) ...@@ -397,6 +400,9 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
spin_lock_irqsave(&bdata->lock, flags); spin_lock_irqsave(&bdata->lock, flags);
if (!bdata->key_pressed) { if (!bdata->key_pressed) {
if (bdata->button->wakeup)
pm_wakeup_event(bdata->input->dev.parent, 0);
input_event(input, EV_KEY, button->code, 1); input_event(input, EV_KEY, button->code, 1);
input_sync(input); input_sync(input);
...@@ -523,56 +529,64 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev, ...@@ -523,56 +529,64 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
static int gpio_keys_open(struct input_dev *input) static int gpio_keys_open(struct input_dev *input)
{ {
struct gpio_keys_drvdata *ddata = input_get_drvdata(input); struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
const struct gpio_keys_platform_data *pdata = ddata->pdata;
return ddata->enable ? ddata->enable(input->dev.parent) : 0; return pdata->enable ? pdata->enable(input->dev.parent) : 0;
} }
static void gpio_keys_close(struct input_dev *input) static void gpio_keys_close(struct input_dev *input)
{ {
struct gpio_keys_drvdata *ddata = input_get_drvdata(input); struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
const struct gpio_keys_platform_data *pdata = ddata->pdata;
if (ddata->disable) if (pdata->disable)
ddata->disable(input->dev.parent); pdata->disable(input->dev.parent);
} }
/* /*
* Handlers for alternative sources of platform_data * Handlers for alternative sources of platform_data
*/ */
#ifdef CONFIG_OF #ifdef CONFIG_OF
/* /*
* Translate OpenFirmware node properties into platform_data * Translate OpenFirmware node properties into platform_data
*/ */
static int gpio_keys_get_devtree_pdata(struct device *dev, static struct gpio_keys_platform_data * __devinit
struct gpio_keys_platform_data *pdata) gpio_keys_get_devtree_pdata(struct device *dev)
{ {
struct device_node *node, *pp; struct device_node *node, *pp;
struct gpio_keys_platform_data *pdata;
struct gpio_keys_button *button;
int error;
int nbuttons;
int i; int i;
struct gpio_keys_button *buttons;
u32 reg;
node = dev->of_node; node = dev->of_node;
if (node == NULL) if (!node) {
return -ENODEV; error = -ENODEV;
goto err_out;
memset(pdata, 0, sizeof *pdata); }
pdata->rep = !!of_get_property(node, "autorepeat", NULL); nbuttons = of_get_child_count(node);
if (nbuttons == 0) {
error = -ENODEV;
goto err_out;
}
/* First count the subnodes */ pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
pp = NULL; GFP_KERNEL);
while ((pp = of_get_next_child(node, pp))) if (!pdata) {
pdata->nbuttons++; error = -ENOMEM;
goto err_out;
}
if (pdata->nbuttons == 0) pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
return -ENODEV; pdata->nbuttons = nbuttons;
buttons = kzalloc(pdata->nbuttons * (sizeof *buttons), GFP_KERNEL); pdata->rep = !!of_get_property(node, "autorepeat", NULL);
if (!buttons)
return -ENOMEM;
pp = NULL;
i = 0; i = 0;
while ((pp = of_get_next_child(node, pp))) { for_each_child_of_node(node, pp) {
enum of_gpio_flags flags; enum of_gpio_flags flags;
if (!of_find_property(pp, "gpios", NULL)) { if (!of_find_property(pp, "gpios", NULL)) {
...@@ -580,39 +594,42 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, ...@@ -580,39 +594,42 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
dev_warn(dev, "Found button without gpios\n"); dev_warn(dev, "Found button without gpios\n");
continue; continue;
} }
buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
if (of_property_read_u32(pp, "linux,code", &reg)) { button = &pdata->buttons[i++];
dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
goto out_fail;
}
buttons[i].code = reg;
buttons[i].desc = of_get_property(pp, "label", NULL); button->gpio = of_get_gpio_flags(pp, 0, &flags);
button->active_low = flags & OF_GPIO_ACTIVE_LOW;
if (of_property_read_u32(pp, "linux,input-type", &reg) == 0) if (of_property_read_u32(pp, "linux,code", &button->code)) {
buttons[i].type = reg; dev_err(dev, "Button without keycode: 0x%x\n",
else button->gpio);
buttons[i].type = EV_KEY; error = -EINVAL;
goto err_free_pdata;
}
buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); button->desc = of_get_property(pp, "label", NULL);
if (of_property_read_u32(pp, "debounce-interval", &reg) == 0) if (of_property_read_u32(pp, "linux,input-type", &button->type))
buttons[i].debounce_interval = reg; button->type = EV_KEY;
else
buttons[i].debounce_interval = 5;
i++; button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
if (of_property_read_u32(pp, "debounce-interval",
&button->debounce_interval))
button->debounce_interval = 5;
} }
pdata->buttons = buttons; if (pdata->nbuttons == 0) {
error = -EINVAL;
goto err_free_pdata;
}
return 0; return pdata;
out_fail: err_free_pdata:
kfree(buttons); kfree(pdata);
return -ENODEV; err_out:
return ERR_PTR(error);
} }
static struct of_device_id gpio_keys_of_match[] = { static struct of_device_id gpio_keys_of_match[] = {
...@@ -623,14 +640,12 @@ MODULE_DEVICE_TABLE(of, gpio_keys_of_match); ...@@ -623,14 +640,12 @@ MODULE_DEVICE_TABLE(of, gpio_keys_of_match);
#else #else
static int gpio_keys_get_devtree_pdata(struct device *dev, static inline struct gpio_keys_platform_data *
struct gpio_keys_platform_data *altp) gpio_keys_get_devtree_pdata(struct device *dev)
{ {
return -ENODEV; return ERR_PTR(-ENODEV);
} }
#define gpio_keys_of_match NULL
#endif #endif
static void gpio_remove_key(struct gpio_button_data *bdata) static void gpio_remove_key(struct gpio_button_data *bdata)
...@@ -645,19 +660,17 @@ static void gpio_remove_key(struct gpio_button_data *bdata) ...@@ -645,19 +660,17 @@ static void gpio_remove_key(struct gpio_button_data *bdata)
static int __devinit gpio_keys_probe(struct platform_device *pdev) static int __devinit gpio_keys_probe(struct platform_device *pdev)
{ {
const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct gpio_keys_drvdata *ddata;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct gpio_keys_platform_data alt_pdata; const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev);
struct gpio_keys_drvdata *ddata;
struct input_dev *input; struct input_dev *input;
int i, error; int i, error;
int wakeup = 0; int wakeup = 0;
if (!pdata) { if (!pdata) {
error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); pdata = gpio_keys_get_devtree_pdata(dev);
if (error) if (IS_ERR(pdata))
return error; return PTR_ERR(pdata);
pdata = &alt_pdata;
} }
ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
...@@ -670,10 +683,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ...@@ -670,10 +683,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
goto fail1; goto fail1;
} }
ddata->pdata = pdata;
ddata->input = input; ddata->input = input;
ddata->n_buttons = pdata->nbuttons;
ddata->enable = pdata->enable;
ddata->disable = pdata->disable;
mutex_init(&ddata->disable_lock); mutex_init(&ddata->disable_lock);
platform_set_drvdata(pdev, ddata); platform_set_drvdata(pdev, ddata);
...@@ -742,9 +753,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ...@@ -742,9 +753,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
fail1: fail1:
input_free_device(input); input_free_device(input);
kfree(ddata); kfree(ddata);
/* If we have no platform_data, we allocated buttons dynamically. */ /* If we have no platform data, we allocated pdata dynamically. */
if (!pdev->dev.platform_data) if (!dev_get_platdata(&pdev->dev))
kfree(pdata->buttons); kfree(pdata);
return error; return error;
} }
...@@ -759,18 +770,14 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) ...@@ -759,18 +770,14 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 0); device_init_wakeup(&pdev->dev, 0);
for (i = 0; i < ddata->n_buttons; i++) for (i = 0; i < ddata->pdata->nbuttons; i++)
gpio_remove_key(&ddata->data[i]); gpio_remove_key(&ddata->data[i]);
input_unregister_device(input); input_unregister_device(input);
/* /* If we have no platform data, we allocated pdata dynamically. */
* If we had no platform_data, we allocated buttons dynamically, and if (!dev_get_platdata(&pdev->dev))
* must free them here. ddata->data[0].button is the pointer to the kfree(ddata->pdata);
* beginning of the allocated array.
*/
if (!pdev->dev.platform_data)
kfree(ddata->data[0].button);
kfree(ddata); kfree(ddata);
...@@ -784,7 +791,7 @@ static int gpio_keys_suspend(struct device *dev) ...@@ -784,7 +791,7 @@ static int gpio_keys_suspend(struct device *dev)
int i; int i;
if (device_may_wakeup(dev)) { if (device_may_wakeup(dev)) {
for (i = 0; i < ddata->n_buttons; i++) { for (i = 0; i < ddata->pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i]; struct gpio_button_data *bdata = &ddata->data[i];
if (bdata->button->wakeup) if (bdata->button->wakeup)
enable_irq_wake(bdata->irq); enable_irq_wake(bdata->irq);
...@@ -799,7 +806,7 @@ static int gpio_keys_resume(struct device *dev) ...@@ -799,7 +806,7 @@ static int gpio_keys_resume(struct device *dev)
struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
int i; int i;
for (i = 0; i < ddata->n_buttons; i++) { for (i = 0; i < ddata->pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i]; struct gpio_button_data *bdata = &ddata->data[i];
if (bdata->button->wakeup && device_may_wakeup(dev)) if (bdata->button->wakeup && device_may_wakeup(dev))
disable_irq_wake(bdata->irq); disable_irq_wake(bdata->irq);
...@@ -822,7 +829,7 @@ static struct platform_driver gpio_keys_device_driver = { ...@@ -822,7 +829,7 @@ static struct platform_driver gpio_keys_device_driver = {
.name = "gpio-keys", .name = "gpio-keys",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.pm = &gpio_keys_pm_ops, .pm = &gpio_keys_pm_ops,
.of_match_table = gpio_keys_of_match, .of_match_table = of_match_ptr(gpio_keys_of_match),
} }
}; };
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
#define DRV_NAME "gpio-keys-polled" #define DRV_NAME "gpio-keys-polled"
...@@ -38,7 +40,7 @@ struct gpio_keys_button_data { ...@@ -38,7 +40,7 @@ struct gpio_keys_button_data {
struct gpio_keys_polled_dev { struct gpio_keys_polled_dev {
struct input_polled_dev *poll_dev; struct input_polled_dev *poll_dev;
struct device *dev; struct device *dev;
struct gpio_keys_platform_data *pdata; const struct gpio_keys_platform_data *pdata;
struct gpio_keys_button_data data[0]; struct gpio_keys_button_data data[0];
}; };
...@@ -67,11 +69,11 @@ static void gpio_keys_polled_check_state(struct input_dev *input, ...@@ -67,11 +69,11 @@ static void gpio_keys_polled_check_state(struct input_dev *input,
static void gpio_keys_polled_poll(struct input_polled_dev *dev) static void gpio_keys_polled_poll(struct input_polled_dev *dev)
{ {
struct gpio_keys_polled_dev *bdev = dev->private; struct gpio_keys_polled_dev *bdev = dev->private;
struct gpio_keys_platform_data *pdata = bdev->pdata; const struct gpio_keys_platform_data *pdata = bdev->pdata;
struct input_dev *input = dev->input; struct input_dev *input = dev->input;
int i; int i;
for (i = 0; i < bdev->pdata->nbuttons; i++) { for (i = 0; i < pdata->nbuttons; i++) {
struct gpio_keys_button_data *bdata = &bdev->data[i]; struct gpio_keys_button_data *bdata = &bdev->data[i];
if (bdata->count < bdata->threshold) if (bdata->count < bdata->threshold)
...@@ -85,7 +87,7 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev) ...@@ -85,7 +87,7 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev)
static void gpio_keys_polled_open(struct input_polled_dev *dev) static void gpio_keys_polled_open(struct input_polled_dev *dev)
{ {
struct gpio_keys_polled_dev *bdev = dev->private; struct gpio_keys_polled_dev *bdev = dev->private;
struct gpio_keys_platform_data *pdata = bdev->pdata; const struct gpio_keys_platform_data *pdata = bdev->pdata;
if (pdata->enable) if (pdata->enable)
pdata->enable(bdev->dev); pdata->enable(bdev->dev);
...@@ -94,31 +96,139 @@ static void gpio_keys_polled_open(struct input_polled_dev *dev) ...@@ -94,31 +96,139 @@ static void gpio_keys_polled_open(struct input_polled_dev *dev)
static void gpio_keys_polled_close(struct input_polled_dev *dev) static void gpio_keys_polled_close(struct input_polled_dev *dev)
{ {
struct gpio_keys_polled_dev *bdev = dev->private; struct gpio_keys_polled_dev *bdev = dev->private;
struct gpio_keys_platform_data *pdata = bdev->pdata; const struct gpio_keys_platform_data *pdata = bdev->pdata;
if (pdata->disable) if (pdata->disable)
pdata->disable(bdev->dev); pdata->disable(bdev->dev);
} }
#ifdef CONFIG_OF
static struct gpio_keys_platform_data * __devinit
gpio_keys_polled_get_devtree_pdata(struct device *dev)
{
struct device_node *node, *pp;
struct gpio_keys_platform_data *pdata;
struct gpio_keys_button *button;
int error;
int nbuttons;
int i;
node = dev->of_node;
if (!node)
return NULL;
nbuttons = of_get_child_count(node);
if (nbuttons == 0)
return NULL;
pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
GFP_KERNEL);
if (!pdata) {
error = -ENOMEM;
goto err_out;
}
pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
pdata->nbuttons = nbuttons;
pdata->rep = !!of_get_property(node, "autorepeat", NULL);
of_property_read_u32(node, "poll-interval", &pdata->poll_interval);
i = 0;
for_each_child_of_node(node, pp) {
enum of_gpio_flags flags;
if (!of_find_property(pp, "gpios", NULL)) {
pdata->nbuttons--;
dev_warn(dev, "Found button without gpios\n");
continue;
}
button = &pdata->buttons[i++];
button->gpio = of_get_gpio_flags(pp, 0, &flags);
button->active_low = flags & OF_GPIO_ACTIVE_LOW;
if (of_property_read_u32(pp, "linux,code", &button->code)) {
dev_err(dev, "Button without keycode: 0x%x\n",
button->gpio);
error = -EINVAL;
goto err_free_pdata;
}
button->desc = of_get_property(pp, "label", NULL);
if (of_property_read_u32(pp, "linux,input-type", &button->type))
button->type = EV_KEY;
button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
if (of_property_read_u32(pp, "debounce-interval",
&button->debounce_interval))
button->debounce_interval = 5;
}
if (pdata->nbuttons == 0) {
error = -EINVAL;
goto err_free_pdata;
}
return pdata;
err_free_pdata:
kfree(pdata);
err_out:
return ERR_PTR(error);
}
static struct of_device_id gpio_keys_polled_of_match[] = {
{ .compatible = "gpio-keys-polled", },
{ },
};
MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match);
#else
static inline struct gpio_keys_platform_data *
gpio_keys_polled_get_devtree_pdata(struct device *dev)
{
return NULL;
}
#endif
static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
{ {
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev);
struct gpio_keys_polled_dev *bdev; struct gpio_keys_polled_dev *bdev;
struct input_polled_dev *poll_dev; struct input_polled_dev *poll_dev;
struct input_dev *input; struct input_dev *input;
int error; int error;
int i; int i;
if (!pdata || !pdata->poll_interval) if (!pdata) {
return -EINVAL; pdata = gpio_keys_polled_get_devtree_pdata(dev);
if (IS_ERR(pdata))
return PTR_ERR(pdata);
if (!pdata) {
dev_err(dev, "missing platform data\n");
return -EINVAL;
}
}
if (!pdata->poll_interval) {
dev_err(dev, "missing poll_interval value\n");
error = -EINVAL;
goto err_free_pdata;
}
bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) + bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
pdata->nbuttons * sizeof(struct gpio_keys_button_data), pdata->nbuttons * sizeof(struct gpio_keys_button_data),
GFP_KERNEL); GFP_KERNEL);
if (!bdev) { if (!bdev) {
dev_err(dev, "no memory for private data\n"); dev_err(dev, "no memory for private data\n");
return -ENOMEM; error = -ENOMEM;
goto err_free_pdata;
} }
poll_dev = input_allocate_polled_device(); poll_dev = input_allocate_polled_device();
...@@ -197,7 +307,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) ...@@ -197,7 +307,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
/* report initial state of the buttons */ /* report initial state of the buttons */
for (i = 0; i < pdata->nbuttons; i++) for (i = 0; i < pdata->nbuttons; i++)
gpio_keys_polled_check_state(input, &pdata->buttons[i], gpio_keys_polled_check_state(input, &pdata->buttons[i],
&bdev->data[i]); &bdev->data[i]);
return 0; return 0;
...@@ -209,15 +319,20 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) ...@@ -209,15 +319,20 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
err_free_bdev: err_free_bdev:
kfree(bdev); kfree(bdev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
err_free_pdata:
/* If we have no platform_data, we allocated pdata dynamically. */
if (!dev_get_platdata(&pdev->dev))
kfree(pdata);
return error; return error;
} }
static int __devexit gpio_keys_polled_remove(struct platform_device *pdev) static int __devexit gpio_keys_polled_remove(struct platform_device *pdev)
{ {
struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev); struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
struct gpio_keys_platform_data *pdata = bdev->pdata; const struct gpio_keys_platform_data *pdata = bdev->pdata;
int i; int i;
input_unregister_polled_device(bdev->poll_dev); input_unregister_polled_device(bdev->poll_dev);
...@@ -227,6 +342,13 @@ static int __devexit gpio_keys_polled_remove(struct platform_device *pdev) ...@@ -227,6 +342,13 @@ static int __devexit gpio_keys_polled_remove(struct platform_device *pdev)
input_free_polled_device(bdev->poll_dev); input_free_polled_device(bdev->poll_dev);
/*
* If we had no platform_data, we allocated pdata dynamically and
* must free it here.
*/
if (!dev_get_platdata(&pdev->dev))
kfree(pdata);
kfree(bdev); kfree(bdev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
...@@ -239,6 +361,7 @@ static struct platform_driver gpio_keys_polled_driver = { ...@@ -239,6 +361,7 @@ static struct platform_driver gpio_keys_polled_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = of_match_ptr(gpio_keys_polled_of_match),
}, },
}; };
module_platform_driver(gpio_keys_polled_driver); module_platform_driver(gpio_keys_polled_driver);
......
...@@ -179,7 +179,7 @@ static void omap_kp_tasklet(unsigned long data) ...@@ -179,7 +179,7 @@ static void omap_kp_tasklet(unsigned long data)
memcpy(keypad_state, new_state, sizeof(keypad_state)); memcpy(keypad_state, new_state, sizeof(keypad_state));
if (key_down) { if (key_down) {
int delay = HZ / 20; int delay = HZ / 20;
/* some key is pressed - keep irq disabled and use timer /* some key is pressed - keep irq disabled and use timer
* to poll the keypad */ * to poll the keypad */
if (spurious) if (spurious)
...@@ -346,9 +346,9 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) ...@@ -346,9 +346,9 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
err3: err3:
device_remove_file(&pdev->dev, &dev_attr_enable); device_remove_file(&pdev->dev, &dev_attr_enable);
err2: err2:
for (i = row_idx - 1; i >=0; i--) for (i = row_idx - 1; i >= 0; i--)
gpio_free(row_gpios[i]); gpio_free(row_gpios[i]);
for (i = col_idx - 1; i >=0; i--) for (i = col_idx - 1; i >= 0; i--)
gpio_free(col_gpios[i]); gpio_free(col_gpios[i]);
kfree(omap_kp); kfree(omap_kp);
......
...@@ -256,7 +256,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( ...@@ -256,7 +256,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt(
struct matrix_keymap_data *keymap_data; struct matrix_keymap_data *keymap_data;
uint32_t *keymap, num_rows = 0, num_cols = 0; uint32_t *keymap, num_rows = 0, num_cols = 0;
struct device_node *np = dev->of_node, *key_np; struct device_node *np = dev->of_node, *key_np;
unsigned int key_count = 0; unsigned int key_count;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) { if (!pdata) {
...@@ -280,9 +280,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( ...@@ -280,9 +280,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt(
} }
pdata->keymap_data = keymap_data; pdata->keymap_data = keymap_data;
for_each_child_of_node(np, key_np) key_count = of_get_child_count(np);
key_count++;
keymap_data->keymap_size = key_count; keymap_data->keymap_size = key_count;
keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL);
if (!keymap) { if (!keymap) {
...@@ -662,8 +660,6 @@ static const struct of_device_id samsung_keypad_dt_match[] = { ...@@ -662,8 +660,6 @@ static const struct of_device_id samsung_keypad_dt_match[] = {
{}, {},
}; };
MODULE_DEVICE_TABLE(of, samsung_keypad_dt_match); MODULE_DEVICE_TABLE(of, samsung_keypad_dt_match);
#else
#define samsung_keypad_dt_match NULL
#endif #endif
static struct platform_device_id samsung_keypad_driver_ids[] = { static struct platform_device_id samsung_keypad_driver_ids[] = {
...@@ -684,7 +680,7 @@ static struct platform_driver samsung_keypad_driver = { ...@@ -684,7 +680,7 @@ static struct platform_driver samsung_keypad_driver = {
.driver = { .driver = {
.name = "samsung-keypad", .name = "samsung-keypad",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = samsung_keypad_dt_match, .of_match_table = of_match_ptr(samsung_keypad_dt_match),
.pm = &samsung_keypad_pm_ops, .pm = &samsung_keypad_pm_ops,
}, },
.id_table = samsung_keypad_driver_ids, .id_table = samsung_keypad_driver_ids,
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/input/tegra_kbc.h>
#include <mach/clk.h> #include <mach/clk.h>
#include <mach/kbc.h>
#define KBC_MAX_DEBOUNCE_CNT 0x3ffu #define KBC_MAX_DEBOUNCE_CNT 0x3ffu
......
...@@ -24,12 +24,14 @@ ...@@ -24,12 +24,14 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/rotary_encoder.h> #include <linux/rotary_encoder.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
#define DRV_NAME "rotary-encoder" #define DRV_NAME "rotary-encoder"
struct rotary_encoder { struct rotary_encoder {
struct input_dev *input; struct input_dev *input;
struct rotary_encoder_platform_data *pdata; const struct rotary_encoder_platform_data *pdata;
unsigned int axis; unsigned int axis;
unsigned int pos; unsigned int pos;
...@@ -43,7 +45,7 @@ struct rotary_encoder { ...@@ -43,7 +45,7 @@ struct rotary_encoder {
char last_stable; char last_stable;
}; };
static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata) static int rotary_encoder_get_state(const struct rotary_encoder_platform_data *pdata)
{ {
int a = !!gpio_get_value(pdata->gpio_a); int a = !!gpio_get_value(pdata->gpio_a);
int b = !!gpio_get_value(pdata->gpio_b); int b = !!gpio_get_value(pdata->gpio_b);
...@@ -56,7 +58,7 @@ static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata) ...@@ -56,7 +58,7 @@ static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata)
static void rotary_encoder_report_event(struct rotary_encoder *encoder) static void rotary_encoder_report_event(struct rotary_encoder *encoder)
{ {
struct rotary_encoder_platform_data *pdata = encoder->pdata; const struct rotary_encoder_platform_data *pdata = encoder->pdata;
if (pdata->relative_axis) { if (pdata->relative_axis) {
input_report_rel(encoder->input, input_report_rel(encoder->input,
...@@ -140,36 +142,89 @@ static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id) ...@@ -140,36 +142,89 @@ static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
#ifdef CONFIG_OF
static struct of_device_id rotary_encoder_of_match[] = {
{ .compatible = "rotary-encoder", },
{ },
};
MODULE_DEVICE_TABLE(of, rotary_encoder_of_match);
static struct rotary_encoder_platform_data * __devinit
rotary_encoder_parse_dt(struct device *dev)
{
const struct of_device_id *of_id =
of_match_device(rotary_encoder_of_match, dev);
struct device_node *np = dev->of_node;
struct rotary_encoder_platform_data *pdata;
enum of_gpio_flags flags;
if (!of_id || !np)
return NULL;
pdata = kzalloc(sizeof(struct rotary_encoder_platform_data),
GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
of_property_read_u32(np, "rotary-encoder,steps", &pdata->steps);
of_property_read_u32(np, "linux,axis", &pdata->axis);
pdata->gpio_a = of_get_gpio_flags(np, 0, &flags);
pdata->inverted_a = flags & OF_GPIO_ACTIVE_LOW;
pdata->gpio_b = of_get_gpio_flags(np, 1, &flags);
pdata->inverted_b = flags & OF_GPIO_ACTIVE_LOW;
pdata->relative_axis = !!of_get_property(np,
"rotary-encoder,relative-axis", NULL);
pdata->rollover = !!of_get_property(np,
"rotary-encoder,rollover", NULL);
pdata->half_period = !!of_get_property(np,
"rotary-encoder,half-period", NULL);
return pdata;
}
#else
static inline struct rotary_encoder_platform_data *
rotary_encoder_parse_dt(struct device *dev)
{
return NULL;
}
#endif
static int __devinit rotary_encoder_probe(struct platform_device *pdev) static int __devinit rotary_encoder_probe(struct platform_device *pdev)
{ {
struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; struct device *dev = &pdev->dev;
const struct rotary_encoder_platform_data *pdata = dev_get_platdata(dev);
struct rotary_encoder *encoder; struct rotary_encoder *encoder;
struct input_dev *input; struct input_dev *input;
irq_handler_t handler; irq_handler_t handler;
int err; int err;
if (!pdata) { if (!pdata) {
dev_err(&pdev->dev, "missing platform data\n"); pdata = rotary_encoder_parse_dt(dev);
return -ENOENT; if (IS_ERR(pdata))
return PTR_ERR(pdata);
if (!pdata) {
dev_err(dev, "missing platform data\n");
return -EINVAL;
}
} }
encoder = kzalloc(sizeof(struct rotary_encoder), GFP_KERNEL); encoder = kzalloc(sizeof(struct rotary_encoder), GFP_KERNEL);
input = input_allocate_device(); input = input_allocate_device();
if (!encoder || !input) { if (!encoder || !input) {
dev_err(&pdev->dev, "failed to allocate memory for device\n");
err = -ENOMEM; err = -ENOMEM;
goto exit_free_mem; goto exit_free_mem;
} }
encoder->input = input; encoder->input = input;
encoder->pdata = pdata; encoder->pdata = pdata;
encoder->irq_a = gpio_to_irq(pdata->gpio_a);
encoder->irq_b = gpio_to_irq(pdata->gpio_b);
/* create and register the input driver */
input->name = pdev->name; input->name = pdev->name;
input->id.bustype = BUS_HOST; input->id.bustype = BUS_HOST;
input->dev.parent = &pdev->dev; input->dev.parent = dev;
if (pdata->relative_axis) { if (pdata->relative_axis) {
input->evbit[0] = BIT_MASK(EV_REL); input->evbit[0] = BIT_MASK(EV_REL);
...@@ -180,40 +235,21 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) ...@@ -180,40 +235,21 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
pdata->axis, 0, pdata->steps, 0, 1); pdata->axis, 0, pdata->steps, 0, 1);
} }
err = input_register_device(input);
if (err) {
dev_err(&pdev->dev, "failed to register input device\n");
goto exit_free_mem;
}
/* request the GPIOs */ /* request the GPIOs */
err = gpio_request(pdata->gpio_a, DRV_NAME); err = gpio_request_one(pdata->gpio_a, GPIOF_IN, dev_name(dev));
if (err) {
dev_err(&pdev->dev, "unable to request GPIO %d\n",
pdata->gpio_a);
goto exit_unregister_input;
}
err = gpio_direction_input(pdata->gpio_a);
if (err) { if (err) {
dev_err(&pdev->dev, "unable to set GPIO %d for input\n", dev_err(dev, "unable to request GPIO %d\n", pdata->gpio_a);
pdata->gpio_a); goto exit_free_mem;
goto exit_unregister_input;
} }
err = gpio_request(pdata->gpio_b, DRV_NAME); err = gpio_request_one(pdata->gpio_b, GPIOF_IN, dev_name(dev));
if (err) { if (err) {
dev_err(&pdev->dev, "unable to request GPIO %d\n", dev_err(dev, "unable to request GPIO %d\n", pdata->gpio_b);
pdata->gpio_b);
goto exit_free_gpio_a; goto exit_free_gpio_a;
} }
err = gpio_direction_input(pdata->gpio_b); encoder->irq_a = gpio_to_irq(pdata->gpio_a);
if (err) { encoder->irq_b = gpio_to_irq(pdata->gpio_b);
dev_err(&pdev->dev, "unable to set GPIO %d for input\n",
pdata->gpio_b);
goto exit_free_gpio_a;
}
/* request the IRQs */ /* request the IRQs */
if (pdata->half_period) { if (pdata->half_period) {
...@@ -227,8 +263,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) ...@@ -227,8 +263,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
DRV_NAME, encoder); DRV_NAME, encoder);
if (err) { if (err) {
dev_err(&pdev->dev, "unable to request IRQ %d\n", dev_err(dev, "unable to request IRQ %d\n", encoder->irq_a);
encoder->irq_a);
goto exit_free_gpio_b; goto exit_free_gpio_b;
} }
...@@ -236,43 +271,55 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) ...@@ -236,43 +271,55 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
DRV_NAME, encoder); DRV_NAME, encoder);
if (err) { if (err) {
dev_err(&pdev->dev, "unable to request IRQ %d\n", dev_err(dev, "unable to request IRQ %d\n", encoder->irq_b);
encoder->irq_b);
goto exit_free_irq_a; goto exit_free_irq_a;
} }
err = input_register_device(input);
if (err) {
dev_err(dev, "failed to register input device\n");
goto exit_free_irq_b;
}
platform_set_drvdata(pdev, encoder); platform_set_drvdata(pdev, encoder);
return 0; return 0;
exit_free_irq_b:
free_irq(encoder->irq_b, encoder);
exit_free_irq_a: exit_free_irq_a:
free_irq(encoder->irq_a, encoder); free_irq(encoder->irq_a, encoder);
exit_free_gpio_b: exit_free_gpio_b:
gpio_free(pdata->gpio_b); gpio_free(pdata->gpio_b);
exit_free_gpio_a: exit_free_gpio_a:
gpio_free(pdata->gpio_a); gpio_free(pdata->gpio_a);
exit_unregister_input:
input_unregister_device(input);
input = NULL; /* so we don't try to free it */
exit_free_mem: exit_free_mem:
input_free_device(input); input_free_device(input);
kfree(encoder); kfree(encoder);
if (!dev_get_platdata(&pdev->dev))
kfree(pdata);
return err; return err;
} }
static int __devexit rotary_encoder_remove(struct platform_device *pdev) static int __devexit rotary_encoder_remove(struct platform_device *pdev)
{ {
struct rotary_encoder *encoder = platform_get_drvdata(pdev); struct rotary_encoder *encoder = platform_get_drvdata(pdev);
struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; const struct rotary_encoder_platform_data *pdata = encoder->pdata;
free_irq(encoder->irq_a, encoder); free_irq(encoder->irq_a, encoder);
free_irq(encoder->irq_b, encoder); free_irq(encoder->irq_b, encoder);
gpio_free(pdata->gpio_a); gpio_free(pdata->gpio_a);
gpio_free(pdata->gpio_b); gpio_free(pdata->gpio_b);
input_unregister_device(encoder->input); input_unregister_device(encoder->input);
platform_set_drvdata(pdev, NULL);
kfree(encoder); kfree(encoder);
if (!dev_get_platdata(&pdev->dev))
kfree(pdata);
platform_set_drvdata(pdev, NULL);
return 0; return 0;
} }
...@@ -282,6 +329,7 @@ static struct platform_driver rotary_encoder_driver = { ...@@ -282,6 +329,7 @@ static struct platform_driver rotary_encoder_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = of_match_ptr(rotary_encoder_of_match),
} }
}; };
module_platform_driver(rotary_encoder_driver); module_platform_driver(rotary_encoder_driver);
......
...@@ -42,6 +42,7 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr) ...@@ -42,6 +42,7 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value, err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,
STS_HW_CONDITIONS); STS_HW_CONDITIONS);
if (!err) { if (!err) {
pm_wakeup_event(pwr->dev.parent, 0);
input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ); input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
input_sync(pwr); input_sync(pwr);
} else { } else {
......
This diff is collapsed.
...@@ -334,11 +334,8 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet) ...@@ -334,11 +334,8 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet)
if (!valid) if (!valid)
psmouse_dbg(psmouse, psmouse_dbg(psmouse,
"bad data, mode %d (%d) %02x %02x %02x %02x %02x %02x\n", "bad data, mode %d (%d) %*ph\n",
priv->mode, pktcnt, priv->mode, pktcnt, 6, psmouse->packet);
psmouse->packet[0], psmouse->packet[1],
psmouse->packet[2], psmouse->packet[3],
psmouse->packet[4], psmouse->packet[5]);
return valid; return valid;
} }
...@@ -1030,7 +1027,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse) ...@@ -1030,7 +1027,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)
return -EIO; return -EIO;
} }
psmouse_dbg(psmouse, "ID: %02x %02x %02x\n", param[0], param[1], param[2]); psmouse_dbg(psmouse, "ID: %*ph\n", 3, param);
/* HGPK signature: 0x67, 0x00, 0x<model> */ /* HGPK signature: 0x67, 0x00, 0x<model> */
if (param[0] != 0x67 || param[1] != 0x00) if (param[0] != 0x67 || param[1] != 0x00)
......
...@@ -53,14 +53,19 @@ ...@@ -53,14 +53,19 @@
#define ABS_POS_BITS 13 #define ABS_POS_BITS 13
/* /*
* Any position values from the hardware above the following limits are * These values should represent the absolute maximum value that will
* treated as "wrapped around negative" values that have been truncated to * be reported for a positive position value. Some Synaptics firmware
* the 13-bit reporting range of the hardware. These are just reasonable * uses this value to indicate a finger near the edge of the touchpad
* guesses and can be adjusted if hardware is found that operates outside * whose precise position cannot be determined.
* of these parameters. *
* At least one touchpad is known to report positions in excess of this
* value which are actually negative values truncated to the 13-bit
* reporting range. These values have never been observed to be lower
* than 8184 (i.e. -8), so we treat all values greater than 8176 as
* negative and any other value as positive.
*/ */
#define X_MAX_POSITIVE (((1 << ABS_POS_BITS) + XMAX) / 2) #define X_MAX_POSITIVE 8176
#define Y_MAX_POSITIVE (((1 << ABS_POS_BITS) + YMAX) / 2) #define Y_MAX_POSITIVE 8176
/***************************************************************************** /*****************************************************************************
* Stuff we need even when we do not want native Synaptics support * Stuff we need even when we do not want native Synaptics support
...@@ -604,11 +609,21 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ...@@ -604,11 +609,21 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
hw->right = (buf[0] & 0x02) ? 1 : 0; hw->right = (buf[0] & 0x02) ? 1 : 0;
} }
/* Convert wrap-around values to negative */ /*
* Convert wrap-around values to negative. (X|Y)_MAX_POSITIVE
* is used by some firmware to indicate a finger at the edge of
* the touchpad whose precise position cannot be determined, so
* convert these values to the maximum axis value.
*/
if (hw->x > X_MAX_POSITIVE) if (hw->x > X_MAX_POSITIVE)
hw->x -= 1 << ABS_POS_BITS; hw->x -= 1 << ABS_POS_BITS;
else if (hw->x == X_MAX_POSITIVE)
hw->x = XMAX;
if (hw->y > Y_MAX_POSITIVE) if (hw->y > Y_MAX_POSITIVE)
hw->y -= 1 << ABS_POS_BITS; hw->y -= 1 << ABS_POS_BITS;
else if (hw->y == Y_MAX_POSITIVE)
hw->y = YMAX;
return 0; return 0;
} }
......
...@@ -551,17 +551,16 @@ static int mousedev_open(struct inode *inode, struct file *file) ...@@ -551,17 +551,16 @@ static int mousedev_open(struct inode *inode, struct file *file)
return -ENODEV; return -ENODEV;
error = mutex_lock_interruptible(&mousedev_table_mutex); error = mutex_lock_interruptible(&mousedev_table_mutex);
if (error) { if (error)
return error; return error;
}
mousedev = mousedev_table[i]; mousedev = mousedev_table[i];
if (mousedev) if (mousedev)
get_device(&mousedev->dev); get_device(&mousedev->dev);
mutex_unlock(&mousedev_table_mutex); mutex_unlock(&mousedev_table_mutex);
if (!mousedev) { if (!mousedev)
return -ENODEV; return -ENODEV;
}
client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL); client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
if (!client) { if (!client) {
...@@ -1088,7 +1087,7 @@ static int __init mousedev_init(void) ...@@ -1088,7 +1087,7 @@ static int __init mousedev_init(void)
#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
error = misc_register(&psaux_mouse); error = misc_register(&psaux_mouse);
if (error) if (error)
pr_warning("could not register psaux device, error: %d\n", pr_warn("could not register psaux device, error: %d\n",
error); error);
else else
psaux_registered = 1; psaux_registered = 1;
......
...@@ -180,11 +180,11 @@ int sparse_keymap_setup(struct input_dev *dev, ...@@ -180,11 +180,11 @@ int sparse_keymap_setup(struct input_dev *dev,
for (e = keymap; e->type != KE_END; e++) for (e = keymap; e->type != KE_END; e++)
map_size++; map_size++;
map = kcalloc(map_size, sizeof (struct key_entry), GFP_KERNEL); map = kcalloc(map_size, sizeof(struct key_entry), GFP_KERNEL);
if (!map) if (!map)
return -ENOMEM; return -ENOMEM;
memcpy(map, keymap, map_size * sizeof (struct key_entry)); memcpy(map, keymap, map_size * sizeof(struct key_entry));
for (i = 0; i < map_size; i++) { for (i = 0; i < map_size; i++) {
entry = &map[i]; entry = &map[i];
......
...@@ -606,7 +606,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) ...@@ -606,7 +606,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
input_report_abs(input, ABS_WHEEL, 0); input_report_abs(input, ABS_WHEEL, 0);
} }
if (data[2] | (data[3] & 0x01) | data[4]) { if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
input_report_key(input, wacom->tool[1], 1); input_report_key(input, wacom->tool[1], 1);
input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
} else { } else {
......
...@@ -406,7 +406,7 @@ static int s3c2410ts_resume(struct device *dev) ...@@ -406,7 +406,7 @@ static int s3c2410ts_resume(struct device *dev)
return 0; return 0;
} }
static struct dev_pm_ops s3c_ts_pmops = { static const struct dev_pm_ops s3c_ts_pmops = {
.suspend = s3c2410ts_suspend, .suspend = s3c2410ts_suspend,
.resume = s3c2410ts_resume, .resume = s3c2410ts_resume,
}; };
......
...@@ -903,6 +903,8 @@ COMPATIBLE_IOCTL(KDGKBSENT) ...@@ -903,6 +903,8 @@ COMPATIBLE_IOCTL(KDGKBSENT)
COMPATIBLE_IOCTL(KDSKBSENT) COMPATIBLE_IOCTL(KDSKBSENT)
COMPATIBLE_IOCTL(KDGKBDIACR) COMPATIBLE_IOCTL(KDGKBDIACR)
COMPATIBLE_IOCTL(KDSKBDIACR) COMPATIBLE_IOCTL(KDSKBDIACR)
COMPATIBLE_IOCTL(KDGKBDIACRUC)
COMPATIBLE_IOCTL(KDSKBDIACRUC)
COMPATIBLE_IOCTL(KDKBDREP) COMPATIBLE_IOCTL(KDKBDREP)
COMPATIBLE_IOCTL(KDGKBLED) COMPATIBLE_IOCTL(KDGKBLED)
COMPATIBLE_IOCTL(KDGETLED) COMPATIBLE_IOCTL(KDGETLED)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
* - first public version * - first public version
*/ */
#include <linux/types.h>
#include <linux/input.h> #include <linux/input.h>
#define UINPUT_VERSION 3 #define UINPUT_VERSION 3
...@@ -44,14 +45,14 @@ ...@@ -44,14 +45,14 @@
enum uinput_state { UIST_NEW_DEVICE, UIST_SETUP_COMPLETE, UIST_CREATED }; enum uinput_state { UIST_NEW_DEVICE, UIST_SETUP_COMPLETE, UIST_CREATED };
struct uinput_request { struct uinput_request {
int id; unsigned int id;
int code; /* UI_FF_UPLOAD, UI_FF_ERASE */ unsigned int code; /* UI_FF_UPLOAD, UI_FF_ERASE */
int retval; int retval;
struct completion done; struct completion done;
union { union {
int effect_id; unsigned int effect_id;
struct { struct {
struct ff_effect *effect; struct ff_effect *effect;
struct ff_effect *old; struct ff_effect *old;
...@@ -77,16 +78,16 @@ struct uinput_device { ...@@ -77,16 +78,16 @@ struct uinput_device {
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
struct uinput_ff_upload { struct uinput_ff_upload {
int request_id; __u32 request_id;
int retval; __s32 retval;
struct ff_effect effect; struct ff_effect effect;
struct ff_effect old; struct ff_effect old;
}; };
struct uinput_ff_erase { struct uinput_ff_erase {
int request_id; __u32 request_id;
int retval; __s32 retval;
int effect_id; __u32 effect_id;
}; };
/* ioctl */ /* ioctl */
...@@ -166,11 +167,11 @@ struct uinput_ff_erase { ...@@ -166,11 +167,11 @@ struct uinput_ff_erase {
struct uinput_user_dev { struct uinput_user_dev {
char name[UINPUT_MAX_NAME_SIZE]; char name[UINPUT_MAX_NAME_SIZE];
struct input_id id; struct input_id id;
int ff_effects_max; __u32 ff_effects_max;
int absmax[ABS_CNT]; __s32 absmax[ABS_CNT];
int absmin[ABS_CNT]; __s32 absmin[ABS_CNT];
int absfuzz[ABS_CNT]; __s32 absfuzz[ABS_CNT];
int absflat[ABS_CNT]; __s32 absflat[ABS_CNT];
}; };
#endif /* __UINPUT_H_ */ #endif /* __UINPUT_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment