summaryrefslogtreecommitdiff
path: root/drivers/input/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index a500e1e276c2..39d9d2b1e3ca 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -439,7 +439,7 @@ void input_alloc_absinfo(struct input_dev *dev)
if (dev->absinfo)
return;
- dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo), GFP_KERNEL);
+ dev->absinfo = kzalloc_objs(*dev->absinfo, ABS_CNT);
if (!dev->absinfo) {
dev_err(dev->dev.parent ?: &dev->dev,
"%s: unable to allocate memory\n", __func__);
@@ -800,14 +800,30 @@ static int input_default_getkeycode(struct input_dev *dev,
return 0;
}
-static int input_default_setkeycode(struct input_dev *dev,
- const struct input_keymap_entry *ke,
- unsigned int *old_keycode)
+/**
+ * input_default_setkeycode - default setkeycode method
+ * @dev: input device which keymap is being updated.
+ * @ke: new keymap entry.
+ * @old_keycode: pointer to the location where old keycode should be stored.
+ *
+ * This function is the default implementation of &input_dev.setkeycode()
+ * method. It is typically used when a driver does not provide its own
+ * implementation, but it is also exported so drivers can extend it.
+ *
+ * The function must be called with &input_dev.event_lock held.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int input_default_setkeycode(struct input_dev *dev,
+ const struct input_keymap_entry *ke,
+ unsigned int *old_keycode)
{
unsigned int index;
int error;
int i;
+ lockdep_assert_held(&dev->event_lock);
+
if (!dev->keycodesize)
return -EINVAL;
@@ -861,6 +877,7 @@ static int input_default_setkeycode(struct input_dev *dev,
__set_bit(ke->keycode, dev->keybit);
return 0;
}
+EXPORT_SYMBOL(input_default_setkeycode);
/**
* input_get_keycode - retrieve keycode currently mapped to a given scancode
@@ -1887,7 +1904,7 @@ struct input_dev *input_allocate_device(void)
static atomic_t input_no = ATOMIC_INIT(-1);
struct input_dev *dev;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev);
if (!dev)
return NULL;
@@ -1897,7 +1914,7 @@ struct input_dev *input_allocate_device(void)
* when we register the device.
*/
dev->max_vals = 10;
- dev->vals = kcalloc(dev->max_vals, sizeof(*dev->vals), GFP_KERNEL);
+ dev->vals = kzalloc_objs(*dev->vals, dev->max_vals);
if (!dev->vals) {
kfree(dev);
return NULL;