* Re: [PATCH] Input: ads7877: Remove bitrotted comment
From: Dmitry Torokhov @ 2014-04-25 6:38 UTC (permalink / raw)
To: Mark Brown; +Cc: Michael Hennerich, linux-input, linaro-kernel
In-Reply-To: <20140423101623.GL12304@sirena.org.uk>
On Wed, Apr 23, 2014 at 11:16:23AM +0100, Mark Brown wrote:
> On Tue, Apr 22, 2014 at 05:39:28PM -0700, Dmitry Torokhov wrote:
> > On Tue, Apr 22, 2014 at 10:18:21PM +0100, Mark Brown wrote:
>
> > > Remove the bitrotted comment, though in actual fact the use case mentioned
> > > is a great use for spi_async() since it would cut down on latency handling
> > > the interrupt by saving us a context switch before we start SPI.
>
> > > This was previously implemented, it was removed in commit b534422b2d11
> > > (Input: ad7877 - switch to using threaded IRQ) for code complexity reasons.
> > > It may be better to revert that commit instead.
>
> > Hmm, maybe.. although I think original would cause device 'stuck' if
> > call to spi_async() fails, so probably not a straight revert...
>
> Probably best just to apply this, then - someone can always reimplement
> if they need to.
OK, applied.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: Add support for newer elantech touchpads
From: Dmitry Torokhov @ 2014-04-25 6:39 UTC (permalink / raw)
To: Jordan Rife; +Cc: linux-kernel, linux-input
In-Reply-To: <CALxcDfxOXM5FqjN9UB4MLVKtAjEJt7DD=EgcrJ-Hb_D-3mkciA@mail.gmail.com>
On Tue, Apr 22, 2014 at 01:40:51PM -0500, Jordan Rife wrote:
> From: Jordan Rife <jrife0@gmail.com>
>
> Newer elantech touchpads are not recognized by the current driver, since it
> fails to detect their firmware version number. This prevents more advanced
> touchpad features from being usable such as two-finger scrolling. This
> patch allows newer touchpads to be detected and be fully functional. Tested
> on Sony Vaio SVF13N17PXB.
>
> Signed-off-by: Jordan Rife <jrife0@gmail.com>
Applied, thank you.
> ---
> diff -pruN linux-master.orig/drivers/input/mouse/elantech.c
> linux-master.modified/drivers/input/mouse/elantech.c
> --- linux-master.orig/drivers/input/mouse/elantech.c 2014-04-22
> 12:57:57.597186781 -0500
> +++ linux-master.modified/drivers/input/mouse/elantech.c 2014-04-22
> 12:59:57.257191243 -0500
> @@ -1353,6 +1353,7 @@ static int elantech_set_properties(struc
> case 6:
> case 7:
> case 8:
> + case 9:
> etd->hw_version = 4;
> break;
> default:
--
Dmitry
^ permalink raw reply
* Re: [PATCH] bma150: extend chip detection for bma180
From: Dmitry Torokhov @ 2014-04-25 6:52 UTC (permalink / raw)
To: Dr. H. Nikolaus Schaller
Cc: Jingoo Han, Fugang Duan, linux-input, LKML, Marek Belisko
In-Reply-To: <D682743C-E578-420D-A9DD-8B90673F8393@goldelico.com>
On Thu, Apr 10, 2014 at 11:30:02AM +0200, Dr. H. Nikolaus Schaller wrote:
> This driver has been used while on the OpenPhoenux GTA04 with
> a BMA180.
>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Applied, thank you.
> ---
> drivers/input/misc/bma150.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c
> index 52d3a9b..b36831c 100644
> --- a/drivers/input/misc/bma150.c
> +++ b/drivers/input/misc/bma150.c
> @@ -70,6 +70,7 @@
> #define BMA150_CFG_5_REG 0x11
>
> #define BMA150_CHIP_ID 2
> +#define BMA180_CHIP_ID 3
> #define BMA150_CHIP_ID_REG BMA150_DATA_0_REG
>
> #define BMA150_ACC_X_LSB_REG BMA150_DATA_2_REG
> @@ -539,7 +540,7 @@ static int bma150_probe(struct i2c_client *client,
> }
>
> chip_id = i2c_smbus_read_byte_data(client, BMA150_CHIP_ID_REG);
> - if (chip_id != BMA150_CHIP_ID) {
> + if (chip_id != BMA150_CHIP_ID && chip_id != BMA180_CHIP_ID) {
> dev_err(&client->dev, "BMA150 chip id error: %d\n", chip_id);
> return -EINVAL;
> }
> @@ -643,6 +644,7 @@ static UNIVERSAL_DEV_PM_OPS(bma150_pm, bma150_suspend, bma150_resume, NULL);
>
> static const struct i2c_device_id bma150_id[] = {
> { "bma150", 0 },
> + { "bma180", 0 },
> { "smb380", 0 },
> { "bma023", 0 },
> { }
> --
> 1.9.1
>
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH] tca8418: fix loading this driver as a module from a device tree
From: Dmitry Torokhov @ 2014-04-25 6:52 UTC (permalink / raw)
To: Dr. H. Nikolaus Schaller; +Cc: linux-input, LKML, Marek Belisko
In-Reply-To: <8CC80032-D358-4643-B3AD-95C280525EAC@goldelico.com>
On Thu, Apr 10, 2014 at 11:29:58AM +0200, Dr. H. Nikolaus Schaller wrote:
> Loading the tca8418 driver as a module on a device tree based system needs
> a MODULE_ALIAS because the driver name does not match the automatic
> name generation rules of a 'compatible' entry on i2c bus.
>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Applied, thank you.
> ---
> drivers/input/keyboard/tca8418_keypad.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
> index 55c1530..3556360 100644
> --- a/drivers/input/keyboard/tca8418_keypad.c
> +++ b/drivers/input/keyboard/tca8418_keypad.c
> @@ -392,6 +392,11 @@ static const struct of_device_id tca8418_dt_ids[] = {
> { }
> };
> MODULE_DEVICE_TABLE(of, tca8418_dt_ids);
> +/* the device tree based i2c loader looks for
> + * "i2c:" + second_component_of(property("compatible"))
> + * and therefore we need an alias to be found.
> + */
> +MODULE_ALIAS("i2c:tca8418");
> #endif
>
> static struct i2c_driver tca8418_keypad_driver = {
> --
> 1.9.1
>
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH] HID: add missing hid usages
From: Olivier Gay @ 2014-04-25 8:10 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jiri Kosina, linux-input, Nestor Lopez Casado, Mathieu Meisser
In-Reply-To: <20140424232624.GA3782@core.coreip.homeip.net>
On Fri, Apr 25, 2014 at 1:26 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Wed, Apr 23, 2014 at 11:37:17AM +0200, Olivier Gay wrote:
>> On Wed, Apr 23, 2014 at 2:04 AM, Dmitry Torokhov
>> <dmitry.torokhov@gmail.com> wrote:
>> > On Mon, Apr 07, 2014 at 09:49:52AM +0200, Jiri Kosina wrote:
>> >> > +#define KEY_BRIGHTNESS 0x250 /* Display Brightness */
> Then it does not make sense to expose it as a key - how system should
> respond to such event? Pick a random value?
Yes, I also noticed that after sending v2. We would also need to
pass/use the linear control value.
> If we really need to support this we need ABS_BRIGHTNESS, like we have
> ABS_VOLUME.
This is not absolutely needed and the other display brightness usages
are more important (like increment, decrement or toggle). I'm sending
a new v3 without this usage.
Best regards,
Olivier
^ permalink raw reply
* [PATCH v3] HID: add missing hid usages
From: Olivier Gay @ 2014-04-25 8:13 UTC (permalink / raw)
To: linux-input
Cc: Dmitry Torokhov, Jiri Kosina, Nestor Lopez Casado, Olivier Gay,
Mathieu Meisser
Add some missing hid usages from consumer page, add
some display brightness control usages from approved hid usage
table request HUTTR41:
http://www.usb.org/developers/hidpage/HUTRR41.pdf
and add voice command usage from approved request HUTTR45:
http://www.usb.org/developers/hidpage/Voice_Command_Usage.pdf
Signed-off-by: Olivier Gay <ogay@logitech.com>
Signed-off-by: Mathieu Meisser <mmeisser@logitech.com>
---
drivers/hid/hid-debug.c | 13 +++++++++++++
drivers/hid/hid-input.c | 14 ++++++++++++++
include/uapi/linux/input.h | 15 +++++++++++++++
3 files changed, 42 insertions(+)
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 53b771d..08b95ef 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -855,6 +855,19 @@ static const char *keys[KEY_MAX + 1] = {
[KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
[KEY_KBDILLUMUP] = "KbdIlluminationUp",
[KEY_SWITCHVIDEOMODE] = "SwitchVideoMode",
+ [KEY_BUTTONCONFIG] = "ButtonConfig",
+ [KEY_TASKMANAGER] = "TaskManager",
+ [KEY_JOURNAL] = "Journal",
+ [KEY_CONTROLPANEL] = "ControlPanel",
+ [KEY_APPSELECT] = "AppSelect",
+ [KEY_SCREENSAVER] = "ScreenSaver",
+ [KEY_VOICECOMMAND] = "VoiceCommand",
+ [KEY_BRIGHTNESS_INC] = "BrightnessInc",
+ [KEY_BRIGHTNESS_DEC] = "BrightnessDec",
+ [KEY_BRIGHTNESS_TOGGLE] = "BrightnessToggle",
+ [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
+ [KEY_BRIGHTNESS_MAX] = "BrightnessMax",
+ [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
};
static const char *relatives[REL_MAX + 1] = {
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index e7e8b19..a32fc5e 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -721,6 +721,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x06c: map_key_clear(KEY_YELLOW); break;
case 0x06d: map_key_clear(KEY_ZOOM); break;
+ case 0x06f: map_key_clear(KEY_BRIGHTNESS_INC); break;
+ case 0x070: map_key_clear(KEY_BRIGHTNESS_DEC); break;
+ case 0x072: map_key_clear(KEY_BRIGHTNESS_TOGGLE); break;
+ case 0x073: map_key_clear(KEY_BRIGHTNESS_MIN); break;
+ case 0x074: map_key_clear(KEY_BRIGHTNESS_MAX); break;
+ case 0x075: map_key_clear(KEY_BRIGHTNESS_AUTO); break;
+
case 0x082: map_key_clear(KEY_VIDEO_NEXT); break;
case 0x083: map_key_clear(KEY_LAST); break;
case 0x084: map_key_clear(KEY_ENTER); break;
@@ -761,6 +768,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x0bf: map_key_clear(KEY_SLOW); break;
case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break;
+ case 0x0cf: map_key_clear(KEY_VOICECOMMAND); break;
case 0x0e0: map_abs_clear(ABS_VOLUME); break;
case 0x0e2: map_key_clear(KEY_MUTE); break;
case 0x0e5: map_key_clear(KEY_BASSBOOST); break;
@@ -768,6 +776,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x0ea: map_key_clear(KEY_VOLUMEDOWN); break;
case 0x0f5: map_key_clear(KEY_SLOW); break;
+ case 0x181: map_key_clear(KEY_BUTTONCONFIG); break;
case 0x182: map_key_clear(KEY_BOOKMARKS); break;
case 0x183: map_key_clear(KEY_CONFIG); break;
case 0x184: map_key_clear(KEY_WORDPROCESSOR); break;
@@ -781,6 +790,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x18c: map_key_clear(KEY_VOICEMAIL); break;
case 0x18d: map_key_clear(KEY_ADDRESSBOOK); break;
case 0x18e: map_key_clear(KEY_CALENDAR); break;
+ case 0x18f: map_key_clear(KEY_TASKMANAGER); break;
+ case 0x190: map_key_clear(KEY_JOURNAL); break;
case 0x191: map_key_clear(KEY_FINANCE); break;
case 0x192: map_key_clear(KEY_CALC); break;
case 0x193: map_key_clear(KEY_PLAYER); break;
@@ -789,12 +800,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x199: map_key_clear(KEY_CHAT); break;
case 0x19c: map_key_clear(KEY_LOGOFF); break;
case 0x19e: map_key_clear(KEY_COFFEE); break;
+ case 0x19f: map_key_clear(KEY_CONTROLPANEL); break;
+ case 0x1a2: map_key_clear(KEY_APPSELECT); break;
case 0x1a3: map_key_clear(KEY_NEXT); break;
case 0x1a4: map_key_clear(KEY_PREVIOUS); break;
case 0x1a6: map_key_clear(KEY_HELP); break;
case 0x1a7: map_key_clear(KEY_DOCUMENTS); break;
case 0x1ab: map_key_clear(KEY_SPELLCHECK); break;
case 0x1ae: map_key_clear(KEY_KEYBOARD); break;
+ case 0x1b1: map_key_clear(KEY_SCREENSAVER); break;
case 0x1b4: map_key_clear(KEY_FILE); break;
case 0x1b6: map_key_clear(KEY_IMAGES); break;
case 0x1b7: map_key_clear(KEY_AUDIO); break;
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index bd24470..9dcbc4b 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -722,6 +722,21 @@ struct input_keymap_entry {
#define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */
+#define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */
+#define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */
+#define KEY_JOURNAL 0x242 /* AL Log/Journal/Timecard */
+#define KEY_CONTROLPANEL 0x243 /* AL Control Panel */
+#define KEY_APPSELECT 0x244 /* AL Select Task/Application */
+#define KEY_SCREENSAVER 0x245 /* AL Screen Saver */
+#define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */
+
+#define KEY_BRIGHTNESS_INC KEY_BRIGHTNESSUP
+#define KEY_BRIGHTNESS_DEC KEY_BRIGHTNESSDOWN
+#define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE
+#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
+#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
+#define KEY_BRIGHTNESS_AUTO 0x252 /* Set Auto Brightness */
+
#define BTN_TRIGGER_HAPPY 0x2c0
#define BTN_TRIGGER_HAPPY1 0x2c0
#define BTN_TRIGGER_HAPPY2 0x2c1
--
1.9.0
^ permalink raw reply related
* [PATCH v2] Input: twl6040-vibra - use devm functions
From: Fabio Estevam @ 2014-04-25 14:38 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: peter.ujfalusi, linux-input, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
Using devm_regulator_bulk_get() and devm_input_allocate_device() can make the
code cleaner and smaller as we do not need to call regulator_bulk_free() in the
error and remove paths.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Also use devm_input_allocate_device()
drivers/input/misc/twl6040-vibra.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 77dc23b..76aa602 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -323,8 +323,9 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
* When booted with Device tree the regulators are attached to the
* parent device (twl6040 MFD core)
*/
- ret = regulator_bulk_get(twl6040_core_dev, ARRAY_SIZE(info->supplies),
- info->supplies);
+ ret = devm_regulator_bulk_get(twl6040_core_dev,
+ ARRAY_SIZE(info->supplies),
+ info->supplies);
if (ret) {
dev_err(info->dev, "couldn't get regulators %d\n", ret);
return ret;
@@ -336,7 +337,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
if (ret) {
dev_err(info->dev, "failed to set VDDVIBL volt %d\n",
ret);
- goto err_regulator;
+ return ret;
}
}
@@ -346,17 +347,16 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
if (ret) {
dev_err(info->dev, "failed to set VDDVIBR volt %d\n",
ret);
- goto err_regulator;
+ return ret;
}
}
INIT_WORK(&info->play_work, vibra_play_work);
- info->input_dev = input_allocate_device();
+ info->input_dev = devm_input_allocate_device(&pdev->dev);
if (info->input_dev == NULL) {
dev_err(info->dev, "couldn't allocate input device\n");
- ret = -ENOMEM;
- goto err_regulator;
+ return -ENOMEM;
}
input_set_drvdata(info->input_dev, info);
@@ -370,7 +370,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
ret = input_ff_create_memless(info->input_dev, NULL, vibra_play);
if (ret < 0) {
dev_err(info->dev, "couldn't register vibrator to FF\n");
- goto err_ialloc;
+ return ret;
}
ret = input_register_device(info->input_dev);
@@ -385,10 +385,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
err_iff:
input_ff_destroy(info->input_dev);
-err_ialloc:
- input_free_device(info->input_dev);
-err_regulator:
- regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies);
return ret;
}
@@ -397,7 +393,6 @@ static int twl6040_vibra_remove(struct platform_device *pdev)
struct vibra_info *info = platform_get_drvdata(pdev);
input_unregister_device(info->input_dev);
- regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies);
return 0;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH v3 1/3] Input: gpio_keys - use dev instead of pdev in gpio_keys_setup_key()
From: Andy Shevchenko @ 2014-04-25 16:22 UTC (permalink / raw)
To: Linus Walleij, Dmitry Torokhov, linux-input, linux-kernel; +Cc: Andy Shevchenko
In-Reply-To: <1398442937-15309-1-git-send-email-andriy.shevchenko@linux.intel.com>
The platform device is not used in gpio_keys_setup_key(). This patch
substitutes it by struct device.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/input/keyboard/gpio_keys.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 2db1324..209d4c6 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -424,13 +424,12 @@ out:
return IRQ_HANDLED;
}
-static int gpio_keys_setup_key(struct platform_device *pdev,
+static int gpio_keys_setup_key(struct device *dev,
struct input_dev *input,
struct gpio_button_data *bdata,
const struct gpio_keys_button *button)
{
const char *desc = button->desc ? button->desc : "gpio_keys";
- struct device *dev = &pdev->dev;
irq_handler_t isr;
unsigned long irqflags;
int irq, error;
@@ -719,7 +718,7 @@ static int gpio_keys_probe(struct platform_device *pdev)
input->name = pdata->name ? : pdev->name;
input->phys = "gpio-keys/input0";
- input->dev.parent = &pdev->dev;
+ input->dev.parent = dev;
input->open = gpio_keys_open;
input->close = gpio_keys_close;
@@ -736,7 +735,7 @@ static int gpio_keys_probe(struct platform_device *pdev)
const struct gpio_keys_button *button = &pdata->buttons[i];
struct gpio_button_data *bdata = &ddata->data[i];
- error = gpio_keys_setup_key(pdev, input, bdata, button);
+ error = gpio_keys_setup_key(dev, input, bdata, button);
if (error)
goto fail2;
--
1.9.2
^ permalink raw reply related
* [PATCH v3 2/3] Input: gpio_keys - convert to use devm_*
From: Andy Shevchenko @ 2014-04-25 16:22 UTC (permalink / raw)
To: Linus Walleij, Dmitry Torokhov, linux-input, linux-kernel; +Cc: Andy Shevchenko
In-Reply-To: <1398442937-15309-1-git-send-email-andriy.shevchenko@linux.intel.com>
This makes the error handling much more simpler than open-coding everything and
in addition makes the probe function smaller an tidier.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/input/keyboard/gpio_keys.c | 75 +++++++++++++-------------------------
1 file changed, 25 insertions(+), 50 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 209d4c6..8791d94 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -47,7 +47,7 @@ struct gpio_keys_drvdata {
const struct gpio_keys_platform_data *pdata;
struct input_dev *input;
struct mutex disable_lock;
- struct gpio_button_data data[0];
+ struct gpio_button_data *data;
};
/*
@@ -577,25 +577,22 @@ gpio_keys_get_devtree_pdata(struct device *dev)
int i;
node = dev->of_node;
- if (!node) {
- error = -ENODEV;
- goto err_out;
- }
+ if (!node)
+ return ERR_PTR(-ENODEV);
nbuttons = of_get_child_count(node);
- if (nbuttons == 0) {
- error = -ENODEV;
- goto err_out;
- }
+ if (nbuttons == 0)
+ return ERR_PTR(-ENODEV);
- pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
- GFP_KERNEL);
- if (!pdata) {
- error = -ENOMEM;
- goto err_out;
- }
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ pdata->buttons = devm_kcalloc(dev, nbuttons, sizeof (*button),
+ GFP_KERNEL);
+ if (!pdata->buttons)
+ return ERR_PTR(-ENOMEM);
- pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
pdata->nbuttons = nbuttons;
pdata->rep = !!of_get_property(node, "autorepeat", NULL);
@@ -618,7 +615,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
dev_err(dev,
"Failed to get gpio flags, error: %d\n",
error);
- goto err_free_pdata;
+ return ERR_PTR(error);
}
button = &pdata->buttons[i++];
@@ -629,8 +626,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
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;
+ return ERR_PTR(-EINVAL);
}
button->desc = of_get_property(pp, "label", NULL);
@@ -645,17 +641,10 @@ gpio_keys_get_devtree_pdata(struct device *dev)
button->debounce_interval = 5;
}
- if (pdata->nbuttons == 0) {
- error = -EINVAL;
- goto err_free_pdata;
- }
+ if (pdata->nbuttons == 0)
+ return ERR_PTR(-EINVAL);
return pdata;
-
-err_free_pdata:
- kfree(pdata);
-err_out:
- return ERR_PTR(error);
}
static struct of_device_id gpio_keys_of_match[] = {
@@ -699,16 +688,18 @@ static int gpio_keys_probe(struct platform_device *pdev)
return PTR_ERR(pdata);
}
- ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
- pdata->nbuttons * sizeof(struct gpio_button_data),
- GFP_KERNEL);
- input = input_allocate_device();
+ ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+ input = devm_input_allocate_device(dev);
if (!ddata || !input) {
dev_err(dev, "failed to allocate state\n");
- error = -ENOMEM;
- goto fail1;
+ return -ENOMEM;
}
+ ddata->data = devm_kcalloc(dev, pdata->nbuttons, sizeof(*ddata->data),
+ GFP_KERNEL);
+ if (!ddata->data)
+ return -ENOMEM;
+
ddata->pdata = pdata;
ddata->input = input;
mutex_init(&ddata->disable_lock);
@@ -767,20 +758,12 @@ static int gpio_keys_probe(struct platform_device *pdev)
while (--i >= 0)
gpio_remove_key(&ddata->data[i]);
- fail1:
- input_free_device(input);
- kfree(ddata);
- /* If we have no platform data, we allocated pdata dynamically. */
- if (!dev_get_platdata(&pdev->dev))
- kfree(pdata);
-
return error;
}
static int gpio_keys_remove(struct platform_device *pdev)
{
struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev);
- struct input_dev *input = ddata->input;
int i;
sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
@@ -790,14 +773,6 @@ static int gpio_keys_remove(struct platform_device *pdev)
for (i = 0; i < ddata->pdata->nbuttons; i++)
gpio_remove_key(&ddata->data[i]);
- input_unregister_device(input);
-
- /* If we have no platform data, we allocated pdata dynamically. */
- if (!dev_get_platdata(&pdev->dev))
- kfree(ddata->pdata);
-
- kfree(ddata);
-
return 0;
}
--
1.9.2
^ permalink raw reply related
* [PATCH v3 3/3] Input: gpio_keys - convert struct descriptions to kernel-doc
From: Andy Shevchenko @ 2014-04-25 16:22 UTC (permalink / raw)
To: Linus Walleij, Dmitry Torokhov, linux-input, linux-kernel; +Cc: Andy Shevchenko
In-Reply-To: <1398442937-15309-1-git-send-email-andriy.shevchenko@linux.intel.com>
This patch converts descriptions of the structures defined in linux/gpio_keys.h
to follow kernel-doc format.
There is no functional change.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
include/linux/gpio_keys.h | 45 +++++++++++++++++++++++++++++++++------------
1 file changed, 33 insertions(+), 12 deletions(-)
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index a7e977f..997134a 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -3,29 +3,50 @@
struct device;
+/**
+ * struct gpio_keys_button - configuration parameters
+ * @code: input event code (KEY_*, SW_*)
+ * @gpio: %-1 if this key does not support gpio
+ * @active_low:
+ * @desc:
+ * @type: input event type (%EV_KEY, %EV_SW, %EV_ABS)
+ * @wakeup: configure the button as a wake-up source
+ * @debounce_interval: debounce ticks interval in msecs
+ * @can_disable:
+ * @value: axis value for %EV_ABS
+ * @irq: Irq number in case of interrupt keys
+ */
struct gpio_keys_button {
- /* Configuration parameters */
- unsigned int code; /* input event code (KEY_*, SW_*) */
- int gpio; /* -1 if this key does not support gpio */
+ unsigned int code;
+ int gpio;
int active_low;
const char *desc;
- unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */
- int wakeup; /* configure the button as a wake-up source */
- int debounce_interval; /* debounce ticks interval in msecs */
+ unsigned int type;
+ int wakeup;
+ int debounce_interval;
bool can_disable;
- int value; /* axis value for EV_ABS */
- unsigned int irq; /* Irq number in case of interrupt keys */
+ int value;
+ unsigned int irq;
};
+/**
+ * struct gpio_keys_platform_data - platform data for gpio_keys driver
+ * @buttons:
+ * @nbuttons:
+ * @poll_interval: polling interval in msecs - for polling driver only
+ * @rep: enable input subsystem auto repeat
+ * @enable:
+ * @disable:
+ * @name: input device name
+ */
struct gpio_keys_platform_data {
struct gpio_keys_button *buttons;
int nbuttons;
- unsigned int poll_interval; /* polling interval in msecs -
- for polling driver only */
- unsigned int rep:1; /* enable input subsystem auto repeat */
+ unsigned int poll_interval;
+ unsigned int rep:1;
int (*enable)(struct device *dev);
void (*disable)(struct device *dev);
- const char *name; /* input device name */
+ const char *name;
};
#endif
--
1.9.2
^ permalink raw reply related
* [PATCH v3 0/3] Input: gpio-keys - clean up series
From: Andy Shevchenko @ 2014-04-25 16:22 UTC (permalink / raw)
To: Linus Walleij, Dmitry Torokhov, linux-input, linux-kernel; +Cc: Andy Shevchenko
This is a 3rd iteration of the small cleanup against gpio-keys driver.
Changes since v2:
- append received Acks
- rebase against recent linux-next
- test on Intel Medfield based product
Andy Shevchenko (3):
Input: gpio_keys - use dev instead of pdev in gpio_keys_setup_key()
Input: gpio_keys - convert to use devm_*
Input: gpio_keys - convert struct descriptions to kernel-doc
drivers/input/keyboard/gpio_keys.c | 82 +++++++++++++-------------------------
include/linux/gpio_keys.h | 45 +++++++++++++++------
2 files changed, 61 insertions(+), 66 deletions(-)
--
1.9.2
^ permalink raw reply
* Re: [PATCH v3] HID: add missing hid usages
From: Dmitry Torokhov @ 2014-04-25 16:38 UTC (permalink / raw)
To: Olivier Gay
Cc: linux-input, Jiri Kosina, Nestor Lopez Casado, Mathieu Meisser
In-Reply-To: <1398413623-19233-1-git-send-email-ogay@logitech.com>
On Fri, Apr 25, 2014 at 10:13:43AM +0200, Olivier Gay wrote:
> Add some missing hid usages from consumer page, add
> some display brightness control usages from approved hid usage
> table request HUTTR41:
> http://www.usb.org/developers/hidpage/HUTRR41.pdf
> and add voice command usage from approved request HUTTR45:
> http://www.usb.org/developers/hidpage/Voice_Command_Usage.pdf
>
> Signed-off-by: Olivier Gay <ogay@logitech.com>
> Signed-off-by: Mathieu Meisser <mmeisser@logitech.com>
> ---
> drivers/hid/hid-debug.c | 13 +++++++++++++
> drivers/hid/hid-input.c | 14 ++++++++++++++
> include/uapi/linux/input.h | 15 +++++++++++++++
> 3 files changed, 42 insertions(+)
>
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> index 53b771d..08b95ef 100644
> --- a/drivers/hid/hid-debug.c
> +++ b/drivers/hid/hid-debug.c
> @@ -855,6 +855,19 @@ static const char *keys[KEY_MAX + 1] = {
> [KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
> [KEY_KBDILLUMUP] = "KbdIlluminationUp",
> [KEY_SWITCHVIDEOMODE] = "SwitchVideoMode",
> + [KEY_BUTTONCONFIG] = "ButtonConfig",
> + [KEY_TASKMANAGER] = "TaskManager",
> + [KEY_JOURNAL] = "Journal",
> + [KEY_CONTROLPANEL] = "ControlPanel",
> + [KEY_APPSELECT] = "AppSelect",
> + [KEY_SCREENSAVER] = "ScreenSaver",
> + [KEY_VOICECOMMAND] = "VoiceCommand",
> + [KEY_BRIGHTNESS_INC] = "BrightnessInc",
> + [KEY_BRIGHTNESS_DEC] = "BrightnessDec",
This table already has entries for KEY_BRIGHTNESS_UP/DOWN, you are
overriding them. I'd rather we did not define gratuitous aliases
(sometimes aliasing is necessary when we got the name wrong, but UP/DOWN
vs INC/DEC for brightness is not the case here).
...
> +
> +#define KEY_BRIGHTNESS_INC KEY_BRIGHTNESSUP
> +#define KEY_BRIGHTNESS_DEC KEY_BRIGHTNESSDOWN
> +#define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE
> +#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
> +#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
> +#define KEY_BRIGHTNESS_AUTO 0x252 /* Set Auto Brightness */
I was looking through keycodes again and we have:
#define KEY_BRIGHTNESS_ZERO|----244|----/* brightness off, use ambient */
which seems to be exactly the same as KEY_BRIGHTNESS_AUTO, but here I
agree that old name is not the best. Could you please change its
definition earlier in the file to:
#define KEY_BRIGHTNESS_AUTO 224 /* Set Auto Brightness: manual
brightness control is off,
rely on ambient */
#define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO
Sorry it takes so long...
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2] Input: twl6040-vibra - use devm functions
From: Dmitry Torokhov @ 2014-04-25 16:41 UTC (permalink / raw)
To: Fabio Estevam; +Cc: peter.ujfalusi, linux-input, Fabio Estevam
In-Reply-To: <1398436708-3903-1-git-send-email-festevam@gmail.com>
Hi Fabio,
On Fri, Apr 25, 2014 at 11:38:28AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Using devm_regulator_bulk_get() and devm_input_allocate_device() can make the
> code cleaner and smaller as we do not need to call regulator_bulk_free() in the
> error and remove paths.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Also use devm_input_allocate_device()
>
> drivers/input/misc/twl6040-vibra.c | 21 ++++++++-------------
> 1 file changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
> index 77dc23b..76aa602 100644
> --- a/drivers/input/misc/twl6040-vibra.c
> +++ b/drivers/input/misc/twl6040-vibra.c
> @@ -323,8 +323,9 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
> * When booted with Device tree the regulators are attached to the
> * parent device (twl6040 MFD core)
> */
> - ret = regulator_bulk_get(twl6040_core_dev, ARRAY_SIZE(info->supplies),
> - info->supplies);
> + ret = devm_regulator_bulk_get(twl6040_core_dev,
> + ARRAY_SIZE(info->supplies),
> + info->supplies);
> if (ret) {
> dev_err(info->dev, "couldn't get regulators %d\n", ret);
> return ret;
> @@ -336,7 +337,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
> if (ret) {
> dev_err(info->dev, "failed to set VDDVIBL volt %d\n",
> ret);
> - goto err_regulator;
> + return ret;
> }
> }
>
> @@ -346,17 +347,16 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
> if (ret) {
> dev_err(info->dev, "failed to set VDDVIBR volt %d\n",
> ret);
> - goto err_regulator;
> + return ret;
> }
> }
>
> INIT_WORK(&info->play_work, vibra_play_work);
>
> - info->input_dev = input_allocate_device();
> + info->input_dev = devm_input_allocate_device(&pdev->dev);
> if (info->input_dev == NULL) {
> dev_err(info->dev, "couldn't allocate input device\n");
> - ret = -ENOMEM;
> - goto err_regulator;
> + return -ENOMEM;
> }
>
> input_set_drvdata(info->input_dev, info);
> @@ -370,7 +370,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
> ret = input_ff_create_memless(info->input_dev, NULL, vibra_play);
> if (ret < 0) {
> dev_err(info->dev, "couldn't register vibrator to FF\n");
> - goto err_ialloc;
> + return ret;
> }
>
> ret = input_register_device(info->input_dev);
> @@ -385,10 +385,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
>
> err_iff:
> input_ff_destroy(info->input_dev);
This is not strictly needed (input_dev_release will clean it up
automatically).
> -err_ialloc:
> - input_free_device(info->input_dev);
> -err_regulator:
> - regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies);
> return ret;
> }
>
> @@ -397,7 +393,6 @@ static int twl6040_vibra_remove(struct platform_device *pdev)
> struct vibra_info *info = platform_get_drvdata(pdev);
>
> input_unregister_device(info->input_dev);
You do not need to call input_unregister_device() for managed input
devices.
I edited the patch a bit and applied it.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v4] HID: add missing hid usages
From: Dmitry Torokhov @ 2014-04-25 18:30 UTC (permalink / raw)
To: Olivier Gay
Cc: linux-input, Jiri Kosina, Nestor Lopez Casado, Mathieu Meisser
In-Reply-To: <1398450404-20484-1-git-send-email-ogay@logitech.com>
On Fri, Apr 25, 2014 at 08:26:44PM +0200, Olivier Gay wrote:
> Add some missing hid usages from consumer page, add
> some display brightness control usages from approved hid usage
> table request HUTTR41:
> http://www.usb.org/developers/hidpage/HUTRR41.pdf
> and add voice command usage from approved request HUTTR45:
> http://www.usb.org/developers/hidpage/Voice_Command_Usage.pdf
>
> Signed-off-by: Olivier Gay <ogay@logitech.com>
> Signed-off-by: Mathieu Meisser <mmeisser@logitech.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
with a small nit below. Probably Jiri can fix it up without resubmitting.
> ---
> drivers/hid/hid-debug.c | 11 +++++++++++
> drivers/hid/hid-input.c | 14 ++++++++++++++
> include/uapi/linux/input.h | 17 ++++++++++++++++-
> 3 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> index 53b771d..826c847 100644
> --- a/drivers/hid/hid-debug.c
> +++ b/drivers/hid/hid-debug.c
> @@ -855,6 +855,17 @@ static const char *keys[KEY_MAX + 1] = {
> [KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
> [KEY_KBDILLUMUP] = "KbdIlluminationUp",
> [KEY_SWITCHVIDEOMODE] = "SwitchVideoMode",
> + [KEY_BUTTONCONFIG] = "ButtonConfig",
> + [KEY_TASKMANAGER] = "TaskManager",
> + [KEY_JOURNAL] = "Journal",
> + [KEY_CONTROLPANEL] = "ControlPanel",
> + [KEY_APPSELECT] = "AppSelect",
> + [KEY_SCREENSAVER] = "ScreenSaver",
> + [KEY_VOICECOMMAND] = "VoiceCommand",
> + [KEY_BRIGHTNESS_TOGGLE] = "BrightnessToggle",
This needs to go as it smashes KEY_DISPLAYTOGGLE.
Thanks.
> + [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
> + [KEY_BRIGHTNESS_MAX] = "BrightnessMax",
> + [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
> };
>
> static const char *relatives[REL_MAX + 1] = {
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index e7e8b19..9f2076a 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -721,6 +721,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> case 0x06c: map_key_clear(KEY_YELLOW); break;
> case 0x06d: map_key_clear(KEY_ZOOM); break;
>
> + case 0x06f: map_key_clear(KEY_BRIGHTNESSUP); break;
> + case 0x070: map_key_clear(KEY_BRIGHTNESSDOWN); break;
> + case 0x072: map_key_clear(KEY_BRIGHTNESS_TOGGLE); break;
> + case 0x073: map_key_clear(KEY_BRIGHTNESS_MIN); break;
> + case 0x074: map_key_clear(KEY_BRIGHTNESS_MAX); break;
> + case 0x075: map_key_clear(KEY_BRIGHTNESS_AUTO); break;
> +
> case 0x082: map_key_clear(KEY_VIDEO_NEXT); break;
> case 0x083: map_key_clear(KEY_LAST); break;
> case 0x084: map_key_clear(KEY_ENTER); break;
> @@ -761,6 +768,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> case 0x0bf: map_key_clear(KEY_SLOW); break;
>
> case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break;
> + case 0x0cf: map_key_clear(KEY_VOICECOMMAND); break;
> case 0x0e0: map_abs_clear(ABS_VOLUME); break;
> case 0x0e2: map_key_clear(KEY_MUTE); break;
> case 0x0e5: map_key_clear(KEY_BASSBOOST); break;
> @@ -768,6 +776,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> case 0x0ea: map_key_clear(KEY_VOLUMEDOWN); break;
> case 0x0f5: map_key_clear(KEY_SLOW); break;
>
> + case 0x181: map_key_clear(KEY_BUTTONCONFIG); break;
> case 0x182: map_key_clear(KEY_BOOKMARKS); break;
> case 0x183: map_key_clear(KEY_CONFIG); break;
> case 0x184: map_key_clear(KEY_WORDPROCESSOR); break;
> @@ -781,6 +790,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> case 0x18c: map_key_clear(KEY_VOICEMAIL); break;
> case 0x18d: map_key_clear(KEY_ADDRESSBOOK); break;
> case 0x18e: map_key_clear(KEY_CALENDAR); break;
> + case 0x18f: map_key_clear(KEY_TASKMANAGER); break;
> + case 0x190: map_key_clear(KEY_JOURNAL); break;
> case 0x191: map_key_clear(KEY_FINANCE); break;
> case 0x192: map_key_clear(KEY_CALC); break;
> case 0x193: map_key_clear(KEY_PLAYER); break;
> @@ -789,12 +800,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> case 0x199: map_key_clear(KEY_CHAT); break;
> case 0x19c: map_key_clear(KEY_LOGOFF); break;
> case 0x19e: map_key_clear(KEY_COFFEE); break;
> + case 0x19f: map_key_clear(KEY_CONTROLPANEL); break;
> + case 0x1a2: map_key_clear(KEY_APPSELECT); break;
> case 0x1a3: map_key_clear(KEY_NEXT); break;
> case 0x1a4: map_key_clear(KEY_PREVIOUS); break;
> case 0x1a6: map_key_clear(KEY_HELP); break;
> case 0x1a7: map_key_clear(KEY_DOCUMENTS); break;
> case 0x1ab: map_key_clear(KEY_SPELLCHECK); break;
> case 0x1ae: map_key_clear(KEY_KEYBOARD); break;
> + case 0x1b1: map_key_clear(KEY_SCREENSAVER); break;
> case 0x1b4: map_key_clear(KEY_FILE); break;
> case 0x1b6: map_key_clear(KEY_IMAGES); break;
> case 0x1b7: map_key_clear(KEY_AUDIO); break;
> diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
> index bd24470..b75b5d6 100644
> --- a/include/uapi/linux/input.h
> +++ b/include/uapi/linux/input.h
> @@ -461,7 +461,10 @@ struct input_keymap_entry {
> #define KEY_VIDEO_NEXT 241 /* drive next video source */
> #define KEY_VIDEO_PREV 242 /* drive previous video source */
> #define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */
> -#define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */
> +#define KEY_BRIGHTNESS_AUTO 244 /* Set Auto Brightness: manual
> + brightness control is off,
> + rely on ambient */
> +#define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO
> #define KEY_DISPLAY_OFF 245 /* display device to off state */
>
> #define KEY_WWAN 246 /* Wireless WAN (LTE, UMTS, GSM, etc.) */
> @@ -631,6 +634,7 @@ struct input_keymap_entry {
> #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */
> #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */
> #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
> +#define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE
> #define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */
> #define KEY_LOGOFF 0x1b1 /* AL Logoff */
>
> @@ -722,6 +726,17 @@ struct input_keymap_entry {
>
> #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */
>
> +#define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */
> +#define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */
> +#define KEY_JOURNAL 0x242 /* AL Log/Journal/Timecard */
> +#define KEY_CONTROLPANEL 0x243 /* AL Control Panel */
> +#define KEY_APPSELECT 0x244 /* AL Select Task/Application */
> +#define KEY_SCREENSAVER 0x245 /* AL Screen Saver */
> +#define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */
> +
> +#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
> +#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
> +
> #define BTN_TRIGGER_HAPPY 0x2c0
> #define BTN_TRIGGER_HAPPY1 0x2c0
> #define BTN_TRIGGER_HAPPY2 0x2c1
> --
> 1.9.0
>
--
Dmitry
^ permalink raw reply
* [PATCH v4] HID: add missing hid usages
From: Olivier Gay @ 2014-04-25 18:26 UTC (permalink / raw)
To: linux-input
Cc: Dmitry Torokhov, Jiri Kosina, Nestor Lopez Casado, Olivier Gay,
Mathieu Meisser
Add some missing hid usages from consumer page, add
some display brightness control usages from approved hid usage
table request HUTTR41:
http://www.usb.org/developers/hidpage/HUTRR41.pdf
and add voice command usage from approved request HUTTR45:
http://www.usb.org/developers/hidpage/Voice_Command_Usage.pdf
Signed-off-by: Olivier Gay <ogay@logitech.com>
Signed-off-by: Mathieu Meisser <mmeisser@logitech.com>
---
drivers/hid/hid-debug.c | 11 +++++++++++
drivers/hid/hid-input.c | 14 ++++++++++++++
include/uapi/linux/input.h | 17 ++++++++++++++++-
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 53b771d..826c847 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -855,6 +855,17 @@ static const char *keys[KEY_MAX + 1] = {
[KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
[KEY_KBDILLUMUP] = "KbdIlluminationUp",
[KEY_SWITCHVIDEOMODE] = "SwitchVideoMode",
+ [KEY_BUTTONCONFIG] = "ButtonConfig",
+ [KEY_TASKMANAGER] = "TaskManager",
+ [KEY_JOURNAL] = "Journal",
+ [KEY_CONTROLPANEL] = "ControlPanel",
+ [KEY_APPSELECT] = "AppSelect",
+ [KEY_SCREENSAVER] = "ScreenSaver",
+ [KEY_VOICECOMMAND] = "VoiceCommand",
+ [KEY_BRIGHTNESS_TOGGLE] = "BrightnessToggle",
+ [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
+ [KEY_BRIGHTNESS_MAX] = "BrightnessMax",
+ [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
};
static const char *relatives[REL_MAX + 1] = {
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index e7e8b19..9f2076a 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -721,6 +721,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x06c: map_key_clear(KEY_YELLOW); break;
case 0x06d: map_key_clear(KEY_ZOOM); break;
+ case 0x06f: map_key_clear(KEY_BRIGHTNESSUP); break;
+ case 0x070: map_key_clear(KEY_BRIGHTNESSDOWN); break;
+ case 0x072: map_key_clear(KEY_BRIGHTNESS_TOGGLE); break;
+ case 0x073: map_key_clear(KEY_BRIGHTNESS_MIN); break;
+ case 0x074: map_key_clear(KEY_BRIGHTNESS_MAX); break;
+ case 0x075: map_key_clear(KEY_BRIGHTNESS_AUTO); break;
+
case 0x082: map_key_clear(KEY_VIDEO_NEXT); break;
case 0x083: map_key_clear(KEY_LAST); break;
case 0x084: map_key_clear(KEY_ENTER); break;
@@ -761,6 +768,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x0bf: map_key_clear(KEY_SLOW); break;
case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break;
+ case 0x0cf: map_key_clear(KEY_VOICECOMMAND); break;
case 0x0e0: map_abs_clear(ABS_VOLUME); break;
case 0x0e2: map_key_clear(KEY_MUTE); break;
case 0x0e5: map_key_clear(KEY_BASSBOOST); break;
@@ -768,6 +776,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x0ea: map_key_clear(KEY_VOLUMEDOWN); break;
case 0x0f5: map_key_clear(KEY_SLOW); break;
+ case 0x181: map_key_clear(KEY_BUTTONCONFIG); break;
case 0x182: map_key_clear(KEY_BOOKMARKS); break;
case 0x183: map_key_clear(KEY_CONFIG); break;
case 0x184: map_key_clear(KEY_WORDPROCESSOR); break;
@@ -781,6 +790,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x18c: map_key_clear(KEY_VOICEMAIL); break;
case 0x18d: map_key_clear(KEY_ADDRESSBOOK); break;
case 0x18e: map_key_clear(KEY_CALENDAR); break;
+ case 0x18f: map_key_clear(KEY_TASKMANAGER); break;
+ case 0x190: map_key_clear(KEY_JOURNAL); break;
case 0x191: map_key_clear(KEY_FINANCE); break;
case 0x192: map_key_clear(KEY_CALC); break;
case 0x193: map_key_clear(KEY_PLAYER); break;
@@ -789,12 +800,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x199: map_key_clear(KEY_CHAT); break;
case 0x19c: map_key_clear(KEY_LOGOFF); break;
case 0x19e: map_key_clear(KEY_COFFEE); break;
+ case 0x19f: map_key_clear(KEY_CONTROLPANEL); break;
+ case 0x1a2: map_key_clear(KEY_APPSELECT); break;
case 0x1a3: map_key_clear(KEY_NEXT); break;
case 0x1a4: map_key_clear(KEY_PREVIOUS); break;
case 0x1a6: map_key_clear(KEY_HELP); break;
case 0x1a7: map_key_clear(KEY_DOCUMENTS); break;
case 0x1ab: map_key_clear(KEY_SPELLCHECK); break;
case 0x1ae: map_key_clear(KEY_KEYBOARD); break;
+ case 0x1b1: map_key_clear(KEY_SCREENSAVER); break;
case 0x1b4: map_key_clear(KEY_FILE); break;
case 0x1b6: map_key_clear(KEY_IMAGES); break;
case 0x1b7: map_key_clear(KEY_AUDIO); break;
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index bd24470..b75b5d6 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -461,7 +461,10 @@ struct input_keymap_entry {
#define KEY_VIDEO_NEXT 241 /* drive next video source */
#define KEY_VIDEO_PREV 242 /* drive previous video source */
#define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */
-#define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */
+#define KEY_BRIGHTNESS_AUTO 244 /* Set Auto Brightness: manual
+ brightness control is off,
+ rely on ambient */
+#define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO
#define KEY_DISPLAY_OFF 245 /* display device to off state */
#define KEY_WWAN 246 /* Wireless WAN (LTE, UMTS, GSM, etc.) */
@@ -631,6 +634,7 @@ struct input_keymap_entry {
#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */
#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */
#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
+#define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE
#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */
#define KEY_LOGOFF 0x1b1 /* AL Logoff */
@@ -722,6 +726,17 @@ struct input_keymap_entry {
#define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */
+#define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */
+#define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */
+#define KEY_JOURNAL 0x242 /* AL Log/Journal/Timecard */
+#define KEY_CONTROLPANEL 0x243 /* AL Control Panel */
+#define KEY_APPSELECT 0x244 /* AL Select Task/Application */
+#define KEY_SCREENSAVER 0x245 /* AL Screen Saver */
+#define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */
+
+#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
+#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
+
#define BTN_TRIGGER_HAPPY 0x2c0
#define BTN_TRIGGER_HAPPY1 0x2c0
#define BTN_TRIGGER_HAPPY2 0x2c1
--
1.9.0
^ permalink raw reply related
* Re: [PATCH v3] HID: add missing hid usages
From: Olivier Gay @ 2014-04-25 18:25 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Jiri Kosina, Nestor Lopez Casado, Mathieu Meisser
In-Reply-To: <20140425163828.GA12355@core.coreip.homeip.net>
On Fri, Apr 25, 2014 at 6:38 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Fri, Apr 25, 2014 at 10:13:43AM +0200, Olivier Gay wrote:
> This table already has entries for KEY_BRIGHTNESS_UP/DOWN, you are
> overriding them. I'd rather we did not define gratuitous aliases
> (sometimes aliasing is necessary when we got the name wrong, but UP/DOWN
> vs INC/DEC for brightness is not the case here).
Done. You didn't mention KEY_BRIGHTNESS_TOGGLE so I kept it.
> I was looking through keycodes again and we have:
>
> #define KEY_BRIGHTNESS_ZERO|----244|----/* brightness off, use ambient */
>
> which seems to be exactly the same as KEY_BRIGHTNESS_AUTO, but here I
> agree that old name is not the best. Could you please change its
> definition earlier in the file to:
>
> #define KEY_BRIGHTNESS_AUTO 224 /* Set Auto Brightness: manual
> brightness control is off,
> rely on ambient */
> #define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO
Changes done. I'm sending v4 right now.
Best regards,
Olivier
^ permalink raw reply
* Re: [PATCH v3 1/3] Input: gpio_keys - use dev instead of pdev in gpio_keys_setup_key()
From: Dmitry Torokhov @ 2014-04-25 21:21 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Linus Walleij, linux-input, linux-kernel
In-Reply-To: <1398442937-15309-2-git-send-email-andriy.shevchenko@linux.intel.com>
On Fri, Apr 25, 2014 at 07:22:15PM +0300, Andy Shevchenko wrote:
> The platform device is not used in gpio_keys_setup_key(). This patch
> substitutes it by struct device.
And the benefit of this is...?
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/input/keyboard/gpio_keys.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 2db1324..209d4c6 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -424,13 +424,12 @@ out:
> return IRQ_HANDLED;
> }
>
> -static int gpio_keys_setup_key(struct platform_device *pdev,
> +static int gpio_keys_setup_key(struct device *dev,
> struct input_dev *input,
> struct gpio_button_data *bdata,
> const struct gpio_keys_button *button)
> {
> const char *desc = button->desc ? button->desc : "gpio_keys";
> - struct device *dev = &pdev->dev;
> irq_handler_t isr;
> unsigned long irqflags;
> int irq, error;
> @@ -719,7 +718,7 @@ static int gpio_keys_probe(struct platform_device *pdev)
>
> input->name = pdata->name ? : pdev->name;
> input->phys = "gpio-keys/input0";
> - input->dev.parent = &pdev->dev;
> + input->dev.parent = dev;
> input->open = gpio_keys_open;
> input->close = gpio_keys_close;
>
> @@ -736,7 +735,7 @@ static int gpio_keys_probe(struct platform_device *pdev)
> const struct gpio_keys_button *button = &pdata->buttons[i];
> struct gpio_button_data *bdata = &ddata->data[i];
>
> - error = gpio_keys_setup_key(pdev, input, bdata, button);
> + error = gpio_keys_setup_key(dev, input, bdata, button);
> if (error)
> goto fail2;
>
> --
> 1.9.2
>
Thanks.
--
Dmitry
^ permalink raw reply
* [PATCHv3 0/5] tsc2005 DT binding
From: Sebastian Reichel @ 2014-04-25 23:56 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov,
linux-input-u79uwXL29TY76Z2rM5mHXA, Tony Lindgren, Rob Herring
Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sebastian Reichel
Hi,
This adds device tree support for the tsc2005 touchscreen
controller, which is currently only used by the Nokia N900
board.
The patch does not update the reset pin handling for platform
data based probe to avoid merge conflicts. The n900 platform
code will be removed in the near future (3.16?) and the driver
can be simplified once that has happened.
Changes since v2 [0]:
* rename "ti,x-plate-resistance" to "ti,x-plate-ohms", so that
the same property name is used for tsc2005 and tsc2007
* document "x-size" and "y-size" as deprecated form of
touchscreen-size-x and touchscreen-size-y
* add documentation for "touchscreen-inverted-x" and
"touchscreen-inverted-y" to the common touchscreen binding
and mark "x-invert" and "y-invert" as deprecated.
* add units to the property descriptions in the common
touchscreen binding Documentation
* document "moving-threshold" as deprecated form of
"touchscreen-fuzz-x" and "touchscreen-fuzz-y" combination
* document "contact-threshold" as deprecated form of
"touchscreen-fuzz-pressure"
[0] https://lkml.org/lkml/2014/4/5/103
-- Sebastian
Sebastian Reichel (5):
Input: add common DT binding for touchscreens
Input: tsc2005: use dev_err for error messages
Input: tsc2005: convert driver to use devm_*
Input: tsc2005: add DT support
Documentation: dt: Document TSC2005 DT binding
.../bindings/input/touchscreen/touchscreen.txt | 27 +++++
.../bindings/input/touchscreen/tsc2005.txt | 39 +++++++
drivers/input/input.c | 34 ++++++
drivers/input/touchscreen/tsc2005.c | 130 ++++++++++++++-------
include/linux/input.h | 8 ++
5 files changed, 197 insertions(+), 41 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
--
1.9.2
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCHv3 1/5] Input: add common DT binding for touchscreens
From: Sebastian Reichel @ 2014-04-25 23:56 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input,
Tony Lindgren, Rob Herring
Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree,
linux-omap, linux-kernel, Sebastian Reichel
In-Reply-To: <1398470179-20880-1-git-send-email-sre@kernel.org>
Add common DT binding documentation for touchscreen devices and
implement input_parse_touchscreen_of_params, which parses the common
properties and configures the input device accordingly.
The method currently does not interpret the axis inversion properties,
since there is no matching flag in the generic linux input device.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
.../bindings/input/touchscreen/touchscreen.txt | 27 +++++++++++++++++
drivers/input/input.c | 34 ++++++++++++++++++++++
include/linux/input.h | 8 +++++
3 files changed, 69 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
new file mode 100644
index 0000000..d8e0616
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
@@ -0,0 +1,27 @@
+General Touchscreen Properties:
+
+Optional properties for Touchscreens:
+ - touchscreen-size-x : horizontal resolution of touchscreen
+ (in pixels)
+ - touchscreen-size-y : vertical resolution of touchscreen
+ (in pixels)
+ - touchscreen-max-pressure : maximum reported pressure (arbitrary range
+ dependent on the controller)
+ - touchscreen-fuzz-x : horizontal noise value of the absolute input
+ device (in pixels)
+ - touchscreen-fuzz-y : vertical noise value of the absolute input
+ device (in pixels)
+ - touchscreen-fuzz-pressure : pressure noise value of the absolute input
+ device (arbitrary range dependent on the
+ controller)
+ - touchscreen-inverted-x : X axis is inverted (boolean)
+ - touchscreen-inverted-y : Y axis is inverted (boolean)
+
+Deprecated properties for Touchscreens:
+ - x-size : deprecated name for touchscreen-size-x
+ - y-size : deprecated name for touchscreen-size-y
+ - moving-threshold : deprecated name for a combination of
+ touchscreen-fuzz-x and touchscreen-fuzz-y
+ - contact-threshold : deprecated name for touchscreen-fuzz-pressure
+ - x-invert : deprecated name for touchscreen-inverted-x
+ - y-invert : deprecated name for touchscreen-inverted-y
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1c4c0db..97966d93 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -27,6 +27,7 @@
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/rcupdate.h>
+#include <linux/of.h>
#include "input-compat.h"
MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
@@ -2398,6 +2399,39 @@ void input_free_minor(unsigned int minor)
}
EXPORT_SYMBOL(input_free_minor);
+#if defined(CONFIG_OF)
+/**
+ * input_parse_touchscreen_of_params - parse common touchscreen DT properties
+ * @dev: device that should be parsed
+ *
+ * This function parses common DT properties for touchscreens and setups the
+ * input device accordingly. The function keeps previously setuped default
+ * values if no value is specified via DT.
+ */
+void input_parse_touchscreen_of_params(struct input_dev *dev)
+{
+ struct device_node *np = dev->dev.parent->of_node;
+ struct input_absinfo *absinfo;
+
+ input_alloc_absinfo(dev);
+ if (!dev->absinfo)
+ return;
+
+ absinfo = &dev->absinfo[ABS_X];
+ of_property_read_u32(np, "touchscreen-size-x", &absinfo->maximum);
+ of_property_read_u32(np, "touchscreen-fuzz-x", &absinfo->fuzz);
+
+ absinfo = &dev->absinfo[ABS_Y];
+ of_property_read_u32(np, "touchscreen-size-y", &absinfo->maximum);
+ of_property_read_u32(np, "touchscreen-fuzz-y", &absinfo->fuzz);
+
+ absinfo = &dev->absinfo[ABS_PRESSURE];
+ of_property_read_u32(np, "touchscreen-max-pressure", &absinfo->maximum);
+ of_property_read_u32(np, "touchscreen-fuzz-pressure", &absinfo->fuzz);
+}
+EXPORT_SYMBOL(input_parse_touchscreen_of_params);
+#endif
+
static int __init input_init(void)
{
int err;
diff --git a/include/linux/input.h b/include/linux/input.h
index 82ce323..3dc3b1e 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -531,4 +531,12 @@ int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
int input_ff_create_memless(struct input_dev *dev, void *data,
int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
+#if defined(CONFIG_OF)
+void input_parse_touchscreen_of_params(struct input_dev *dev);
+#else
+static inline void input_parse_touchscreen_of_params(struct input_dev *dev) {
+ return;
+}
+#endif
+
#endif
--
1.9.2
^ permalink raw reply related
* [PATCHv3 2/5] Input: tsc2005: use dev_err for error messages
From: Sebastian Reichel @ 2014-04-25 23:56 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input,
Tony Lindgren, Rob Herring
Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree,
linux-omap, linux-kernel, Sebastian Reichel
In-Reply-To: <1398470179-20880-1-git-send-email-sre@kernel.org>
Change some dev_dbg() invocations to dev_err() ones, because they
are supposed to output error messages.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
drivers/input/touchscreen/tsc2005.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 550adcb..520e673 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -579,7 +579,7 @@ static int tsc2005_probe(struct spi_device *spi)
int error;
if (!pdata) {
- dev_dbg(&spi->dev, "no platform data\n");
+ dev_err(&spi->dev, "no platform data\n");
return -ENODEV;
}
@@ -591,7 +591,7 @@ static int tsc2005_probe(struct spi_device *spi)
max_p = pdata->ts_pressure_max ? : MAX_12BIT;
if (spi->irq <= 0) {
- dev_dbg(&spi->dev, "no irq\n");
+ dev_err(&spi->dev, "no irq\n");
return -ENODEV;
}
--
1.9.2
^ permalink raw reply related
* [PATCHv3 3/5] Input: tsc2005: convert driver to use devm_*
From: Sebastian Reichel @ 2014-04-25 23:56 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input,
Tony Lindgren, Rob Herring
Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree,
linux-omap, linux-kernel, Sebastian Reichel
In-Reply-To: <1398470179-20880-1-git-send-email-sre@kernel.org>
Simplify the driver by using managed resources for memory allocation of
internal struct, input device allocation and irq request.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
drivers/input/touchscreen/tsc2005.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 520e673..9daaddd 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -604,12 +604,10 @@ static int tsc2005_probe(struct spi_device *spi)
if (error)
return error;
- ts = kzalloc(sizeof(*ts), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!ts || !input_dev) {
- error = -ENOMEM;
- goto err_free_mem;
- }
+ ts = devm_kzalloc(&spi->dev, sizeof(*ts), GFP_KERNEL);
+ input_dev = devm_input_allocate_device(&spi->dev);
+ if (!ts || !input_dev)
+ return -ENOMEM;
ts->spi = spi;
ts->idev = input_dev;
@@ -649,12 +647,13 @@ static int tsc2005_probe(struct spi_device *spi)
/* Ensure the touchscreen is off */
tsc2005_stop_scan(ts);
- error = request_threaded_irq(spi->irq, NULL, tsc2005_irq_thread,
- IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- "tsc2005", ts);
+ error = devm_request_threaded_irq(&spi->dev, spi->irq, NULL,
+ tsc2005_irq_thread,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ "tsc2005", ts);
if (error) {
dev_err(&spi->dev, "Failed to request irq, err: %d\n", error);
- goto err_free_mem;
+ return error;
}
spi_set_drvdata(spi, ts);
@@ -662,7 +661,7 @@ static int tsc2005_probe(struct spi_device *spi)
if (error) {
dev_err(&spi->dev,
"Failed to create sysfs attributes, err: %d\n", error);
- goto err_clear_drvdata;
+ return error;
}
error = input_register_device(ts->idev);
@@ -677,11 +676,6 @@ static int tsc2005_probe(struct spi_device *spi)
err_remove_sysfs:
sysfs_remove_group(&spi->dev.kobj, &tsc2005_attr_group);
-err_clear_drvdata:
- free_irq(spi->irq, ts);
-err_free_mem:
- input_free_device(input_dev);
- kfree(ts);
return error;
}
@@ -691,10 +685,6 @@ static int tsc2005_remove(struct spi_device *spi)
sysfs_remove_group(&ts->spi->dev.kobj, &tsc2005_attr_group);
- free_irq(ts->spi->irq, ts);
- input_unregister_device(ts->idev);
- kfree(ts);
-
return 0;
}
--
1.9.2
^ permalink raw reply related
* [PATCHv3 4/5] Input: tsc2005: add DT support
From: Sebastian Reichel @ 2014-04-25 23:56 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input,
Tony Lindgren, Rob Herring
Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree,
linux-omap, linux-kernel, Sebastian Reichel
In-Reply-To: <1398470179-20880-1-git-send-email-sre@kernel.org>
This adds DT support to the tsc2005 touchscreen
driver.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
drivers/input/touchscreen/tsc2005.c | 96 +++++++++++++++++++++++++++++--------
1 file changed, 77 insertions(+), 19 deletions(-)
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 9daaddd..a83d1be 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -28,6 +28,8 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <linux/spi/spi.h>
#include <linux/spi/tsc2005.h>
@@ -100,6 +102,11 @@
TSC2005_CFR2_AVG_7)
#define MAX_12BIT 0xfff
+#define TSC2005_DEF_X_FUZZ 4
+#define TSC2005_DEF_Y_FUZZ 8
+#define TSC2005_DEF_P_FUZZ 2
+#define TSC2005_DEF_RESISTOR 280
+
#define TSC2005_SPI_MAX_SPEED_HZ 10000000
#define TSC2005_PENUP_TIME_MS 40
@@ -143,6 +150,7 @@ struct tsc2005 {
bool pen_down;
+ int reset_gpio;
void (*set_reset)(bool enable);
};
@@ -337,6 +345,14 @@ static void tsc2005_stop_scan(struct tsc2005 *ts)
tsc2005_cmd(ts, TSC2005_CMD_STOP);
}
+static void tsc2005_set_reset(struct tsc2005 *ts, bool enable)
+{
+ if (ts->reset_gpio >= 0)
+ gpio_set_value(ts->reset_gpio, enable);
+ else if (ts->set_reset)
+ ts->set_reset(enable);
+}
+
/* must be called with ts->mutex held */
static void __tsc2005_disable(struct tsc2005 *ts)
{
@@ -355,7 +371,7 @@ static void __tsc2005_enable(struct tsc2005 *ts)
{
tsc2005_start_scan(ts);
- if (ts->esd_timeout && ts->set_reset) {
+ if (ts->esd_timeout && (ts->set_reset || ts->reset_gpio)) {
ts->last_valid_interrupt = jiffies;
schedule_delayed_work(&ts->esd_work,
round_jiffies_relative(
@@ -414,9 +430,9 @@ static ssize_t tsc2005_selftest_show(struct device *dev,
}
/* hardware reset */
- ts->set_reset(false);
+ tsc2005_set_reset(ts, false);
usleep_range(100, 500); /* only 10us required */
- ts->set_reset(true);
+ tsc2005_set_reset(ts, true);
if (!success)
goto out;
@@ -459,7 +475,7 @@ static umode_t tsc2005_attr_is_visible(struct kobject *kobj,
umode_t mode = attr->mode;
if (attr == &dev_attr_selftest.attr) {
- if (!ts->set_reset)
+ if (!ts->set_reset && !ts->reset_gpio)
mode = 0;
}
@@ -509,9 +525,9 @@ static void tsc2005_esd_work(struct work_struct *work)
tsc2005_update_pen_state(ts, 0, 0, 0);
- ts->set_reset(false);
+ tsc2005_set_reset(ts, false);
usleep_range(100, 500); /* only 10us required */
- ts->set_reset(true);
+ tsc2005_set_reset(ts, true);
enable_irq(ts->spi->irq);
tsc2005_start_scan(ts);
@@ -572,29 +588,47 @@ static void tsc2005_setup_spi_xfer(struct tsc2005 *ts)
static int tsc2005_probe(struct spi_device *spi)
{
const struct tsc2005_platform_data *pdata = dev_get_platdata(&spi->dev);
+ struct device_node *np = spi->dev.of_node;
+
struct tsc2005 *ts;
struct input_dev *input_dev;
- unsigned int max_x, max_y, max_p;
- unsigned int fudge_x, fudge_y, fudge_p;
+ unsigned int max_x = MAX_12BIT;
+ unsigned int max_y = MAX_12BIT;
+ unsigned int max_p = MAX_12BIT;
+ unsigned int fudge_x = TSC2005_DEF_X_FUZZ;
+ unsigned int fudge_y = TSC2005_DEF_Y_FUZZ;
+ unsigned int fudge_p = TSC2005_DEF_P_FUZZ;
+ unsigned int x_plate_ohm = TSC2005_DEF_RESISTOR;
+ unsigned int esd_timeout;
int error;
- if (!pdata) {
+ if (!np && !pdata) {
dev_err(&spi->dev, "no platform data\n");
return -ENODEV;
}
- fudge_x = pdata->ts_x_fudge ? : 4;
- fudge_y = pdata->ts_y_fudge ? : 8;
- fudge_p = pdata->ts_pressure_fudge ? : 2;
- max_x = pdata->ts_x_max ? : MAX_12BIT;
- max_y = pdata->ts_y_max ? : MAX_12BIT;
- max_p = pdata->ts_pressure_max ? : MAX_12BIT;
-
if (spi->irq <= 0) {
dev_err(&spi->dev, "no irq\n");
return -ENODEV;
}
+ if (pdata) {
+ fudge_x = pdata->ts_x_fudge;
+ fudge_y = pdata->ts_y_fudge;
+ fudge_p = pdata->ts_pressure_fudge;
+ max_x = pdata->ts_x_max;
+ max_y = pdata->ts_y_max;
+ max_p = pdata->ts_pressure_max;
+ x_plate_ohm = pdata->ts_x_plate_ohm;
+ esd_timeout = pdata->esd_timeout_ms;
+ } else {
+ x_plate_ohm = TSC2005_DEF_RESISTOR;
+ of_property_read_u32(np, "ti,x-plate-ohms", &x_plate_ohm);
+ esd_timeout = 0;
+ of_property_read_u32(np, "ti,esd-recovery-timeout-ms",
+ &esd_timeout);
+ }
+
spi->mode = SPI_MODE_0;
spi->bits_per_word = 8;
if (!spi->max_speed_hz)
@@ -612,9 +646,30 @@ static int tsc2005_probe(struct spi_device *spi)
ts->spi = spi;
ts->idev = input_dev;
- ts->x_plate_ohm = pdata->ts_x_plate_ohm ? : 280;
- ts->esd_timeout = pdata->esd_timeout_ms;
- ts->set_reset = pdata->set_reset;
+ ts->x_plate_ohm = x_plate_ohm;
+ ts->esd_timeout = esd_timeout;
+
+ if (np) {
+ ts->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
+ if (ts->reset_gpio == -EPROBE_DEFER)
+ return ts->reset_gpio;
+ if (ts->reset_gpio < 0) {
+ dev_err(&spi->dev, "error acquiring reset gpio: %d\n",
+ ts->reset_gpio);
+ return ts->reset_gpio;
+ }
+
+ error = devm_gpio_request_one(&spi->dev, ts->reset_gpio, 0,
+ "reset-gpios");
+ if (error) {
+ dev_err(&spi->dev, "error requesting reset gpio: %d\n",
+ error);
+ return error;
+ }
+ } else {
+ ts->reset_gpio = -1;
+ ts->set_reset = pdata->set_reset;
+ }
mutex_init(&ts->mutex);
@@ -639,6 +694,9 @@ static int tsc2005_probe(struct spi_device *spi)
input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
+ if (np)
+ input_parse_touchscreen_of_params(input_dev);
+
input_dev->open = tsc2005_open;
input_dev->close = tsc2005_close;
--
1.9.2
^ permalink raw reply related
* [PATCHv3 5/5] Documentation: dt: Document TSC2005 DT binding
From: Sebastian Reichel @ 2014-04-25 23:56 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input,
Tony Lindgren, Rob Herring
Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree,
linux-omap, linux-kernel, Sebastian Reichel
In-Reply-To: <1398470179-20880-1-git-send-email-sre@kernel.org>
Add devicetree binding documentation for TSC2005 touchscreen.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
.../bindings/input/touchscreen/tsc2005.txt | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
new file mode 100644
index 0000000..663f8ab
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
@@ -0,0 +1,39 @@
+* Texas Instruments tsc2005 touchscreen controller
+
+Required properties:
+ - compatible : "ti,tsc2005"
+ - reg : SPI device address
+ - spi-max-frequency : Maximal SPI speed
+ - interrupts : IRQ specifier
+ - reset-gpios : GPIO specifier
+
+Optional properties:
+ - ti,x-plate-ohms : integer, resistance of the touchscreen's X plates
+ in ohm (defaults to 280)
+ - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond after
+ the configured time (in milli seconds), the driver
+ will reset it. This is disabled by default.
+ - properties defined in touchscreen.txt
+
+Example:
+
+&mcspi1 {
+ tsc2005@0 {
+ compatible = "ti,tsc2005";
+ spi-max-frequency = <6000000>;
+ reg = <0>;
+
+ reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */
+ interrupts-extended = <&gpio4 4 IRQ_TYPE_NONE>; /* 100 */
+
+ touchscreen-fuzz-x = <4>;
+ touchscreen-fuzz-y = <7>;
+ touchscreen-fuzz-pressure = <2>;
+ touchscreen-max-x = <4096>;
+ touchscreen-max-y = <4096>;
+ touchscreen-max-pressure = <2048>;
+
+ ti,x-plate-ohms = <280>;
+ ti,esd-recovery-timeout-ms = <8000>;
+ };
+}
--
1.9.2
^ permalink raw reply related
* Re: [PATCH v3 3/3] Input: gpio_keys - convert struct descriptions to kernel-doc
From: Dmitry Torokhov @ 2014-04-26 4:41 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Linus Walleij, linux-input, linux-kernel
In-Reply-To: <1398442937-15309-4-git-send-email-andriy.shevchenko@linux.intel.com>
On Fri, Apr 25, 2014 at 07:22:17PM +0300, Andy Shevchenko wrote:
> This patch converts descriptions of the structures defined in linux/gpio_keys.h
> to follow kernel-doc format.
>
> There is no functional change.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Applied, thank you.
> ---
> include/linux/gpio_keys.h | 45 +++++++++++++++++++++++++++++++++------------
> 1 file changed, 33 insertions(+), 12 deletions(-)
>
> diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
> index a7e977f..997134a 100644
> --- a/include/linux/gpio_keys.h
> +++ b/include/linux/gpio_keys.h
> @@ -3,29 +3,50 @@
>
> struct device;
>
> +/**
> + * struct gpio_keys_button - configuration parameters
> + * @code: input event code (KEY_*, SW_*)
> + * @gpio: %-1 if this key does not support gpio
> + * @active_low:
> + * @desc:
> + * @type: input event type (%EV_KEY, %EV_SW, %EV_ABS)
> + * @wakeup: configure the button as a wake-up source
> + * @debounce_interval: debounce ticks interval in msecs
> + * @can_disable:
> + * @value: axis value for %EV_ABS
> + * @irq: Irq number in case of interrupt keys
> + */
> struct gpio_keys_button {
> - /* Configuration parameters */
> - unsigned int code; /* input event code (KEY_*, SW_*) */
> - int gpio; /* -1 if this key does not support gpio */
> + unsigned int code;
> + int gpio;
> int active_low;
> const char *desc;
> - unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */
> - int wakeup; /* configure the button as a wake-up source */
> - int debounce_interval; /* debounce ticks interval in msecs */
> + unsigned int type;
> + int wakeup;
> + int debounce_interval;
> bool can_disable;
> - int value; /* axis value for EV_ABS */
> - unsigned int irq; /* Irq number in case of interrupt keys */
> + int value;
> + unsigned int irq;
> };
>
> +/**
> + * struct gpio_keys_platform_data - platform data for gpio_keys driver
> + * @buttons:
> + * @nbuttons:
> + * @poll_interval: polling interval in msecs - for polling driver only
> + * @rep: enable input subsystem auto repeat
> + * @enable:
> + * @disable:
> + * @name: input device name
> + */
> struct gpio_keys_platform_data {
> struct gpio_keys_button *buttons;
> int nbuttons;
> - unsigned int poll_interval; /* polling interval in msecs -
> - for polling driver only */
> - unsigned int rep:1; /* enable input subsystem auto repeat */
> + unsigned int poll_interval;
> + unsigned int rep:1;
> int (*enable)(struct device *dev);
> void (*disable)(struct device *dev);
> - const char *name; /* input device name */
> + const char *name;
> };
>
> #endif
> --
> 1.9.2
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3 2/3] Input: gpio_keys - convert to use devm_*
From: Dmitry Torokhov @ 2014-04-26 4:43 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Linus Walleij, linux-input, linux-kernel
In-Reply-To: <1398442937-15309-3-git-send-email-andriy.shevchenko@linux.intel.com>
On Fri, Apr 25, 2014 at 07:22:16PM +0300, Andy Shevchenko wrote:
> This makes the error handling much more simpler than open-coding everything and
> in addition makes the probe function smaller an tidier.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/input/keyboard/gpio_keys.c | 75 +++++++++++++-------------------------
> 1 file changed, 25 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 209d4c6..8791d94 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -47,7 +47,7 @@ struct gpio_keys_drvdata {
> const struct gpio_keys_platform_data *pdata;
> struct input_dev *input;
> struct mutex disable_lock;
> - struct gpio_button_data data[0];
> + struct gpio_button_data *data;
> };
>
> /*
> @@ -577,25 +577,22 @@ gpio_keys_get_devtree_pdata(struct device *dev)
> int i;
>
> node = dev->of_node;
> - if (!node) {
> - error = -ENODEV;
> - goto err_out;
> - }
> + if (!node)
> + return ERR_PTR(-ENODEV);
>
> nbuttons = of_get_child_count(node);
> - if (nbuttons == 0) {
> - error = -ENODEV;
> - goto err_out;
> - }
> + if (nbuttons == 0)
> + return ERR_PTR(-ENODEV);
>
> - pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
> - GFP_KERNEL);
> - if (!pdata) {
> - error = -ENOMEM;
> - goto err_out;
> - }
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + pdata->buttons = devm_kcalloc(dev, nbuttons, sizeof (*button),
> + GFP_KERNEL);
> + if (!pdata->buttons)
> + return ERR_PTR(-ENOMEM);
Why are we splitting the allocation in 2?
>
> - pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
> pdata->nbuttons = nbuttons;
>
> pdata->rep = !!of_get_property(node, "autorepeat", NULL);
> @@ -618,7 +615,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
> dev_err(dev,
> "Failed to get gpio flags, error: %d\n",
> error);
> - goto err_free_pdata;
> + return ERR_PTR(error);
> }
>
> button = &pdata->buttons[i++];
> @@ -629,8 +626,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
> 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;
> + return ERR_PTR(-EINVAL);
> }
>
> button->desc = of_get_property(pp, "label", NULL);
> @@ -645,17 +641,10 @@ gpio_keys_get_devtree_pdata(struct device *dev)
> button->debounce_interval = 5;
> }
>
> - if (pdata->nbuttons == 0) {
> - error = -EINVAL;
> - goto err_free_pdata;
> - }
> + if (pdata->nbuttons == 0)
> + return ERR_PTR(-EINVAL);
>
> return pdata;
> -
> -err_free_pdata:
> - kfree(pdata);
> -err_out:
> - return ERR_PTR(error);
> }
>
> static struct of_device_id gpio_keys_of_match[] = {
> @@ -699,16 +688,18 @@ static int gpio_keys_probe(struct platform_device *pdev)
> return PTR_ERR(pdata);
> }
>
> - ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
> - pdata->nbuttons * sizeof(struct gpio_button_data),
> - GFP_KERNEL);
> - input = input_allocate_device();
> + ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
> + input = devm_input_allocate_device(dev);
> if (!ddata || !input) {
> dev_err(dev, "failed to allocate state\n");
> - error = -ENOMEM;
> - goto fail1;
> + return -ENOMEM;
> }
>
> + ddata->data = devm_kcalloc(dev, pdata->nbuttons, sizeof(*ddata->data),
> + GFP_KERNEL);
> + if (!ddata->data)
> + return -ENOMEM;
> +
Same here. I dropped the separate allocations and applied.
Thanks.
--
Dmitry
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox