* [PATCH] touchscreen: elants: fix a missing check of return values
From: Kangjie Lu @ 2018-12-21 6:59 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Dmitry Torokhov, Greg Kroah-Hartman, Stephen Boyd,
Joe Perches, linux-input, linux-kernel
elants_i2c_send() may fail, let's check its return values. The fix does
the check and reports an error message upon the failure.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/input/touchscreen/elants_i2c.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index f2cb23121833..cb3c1470bb68 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -245,8 +245,14 @@ static int elants_i2c_calibrate(struct elants_data *ts)
ts->state = ELAN_WAIT_RECALIBRATION;
reinit_completion(&ts->cmd_done);
- elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
- elants_i2c_send(client, rek, sizeof(rek));
+ error = elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
+ error |= elants_i2c_send(client, rek, sizeof(rek));
+ if (error) {
+ dev_err(&client->dev,
+ "error in sending I2C messages for calibration: %d\n",
+ error);
+ return error;
+ }
enable_irq(client->irq);
--
2.17.2 (Apple Git-113)
^ permalink raw reply related
* Re: [PATCH] touchscreen: elants: fix a missing check of return values
From: Dmitry Torokhov @ 2018-12-21 8:27 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Greg Kroah-Hartman, Stephen Boyd, Joe Perches,
linux-input, linux-kernel
In-Reply-To: <20181221065919.60129-1-kjlu@umn.edu>
Hi Kangjie,
On Fri, Dec 21, 2018 at 12:59:16AM -0600, Kangjie Lu wrote:
> elants_i2c_send() may fail, let's check its return values. The fix does
> the check and reports an error message upon the failure.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/input/touchscreen/elants_i2c.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index f2cb23121833..cb3c1470bb68 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -245,8 +245,14 @@ static int elants_i2c_calibrate(struct elants_data *ts)
> ts->state = ELAN_WAIT_RECALIBRATION;
> reinit_completion(&ts->cmd_done);
>
> - elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
> - elants_i2c_send(client, rek, sizeof(rek));
> + error = elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
> + error |= elants_i2c_send(client, rek, sizeof(rek));
I dislike this kind of error handling as this may result in invalid
error code being reported, in case 2 commands produce different results.
> + if (error) {
> + dev_err(&client->dev,
> + "error in sending I2C messages for calibration: %d\n",
> + error);
> + return error;
If we just return like you do it here, interrupts will stay disabled and
touchscreen will be completely dead. With the old code we'd report
timeout on calibration, and touchscreen would have chance of working. We
would also be able to retry calibration.
> + }
>
> enable_irq(client->irq);
>
> --
> 2.17.2 (Apple Git-113)
>
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v5] Input: i8042 add i8042_is_mr_coffee() helper to avoid refconut leak
From: Dmitry Torokhov @ 2018-12-21 8:42 UTC (permalink / raw)
To: Yangtao Li; +Cc: linux-input, linux-kernel
In-Reply-To: <20181215090846.28009-1-tiny.windzz@gmail.com>
On Sat, Dec 15, 2018 at 04:08:46AM -0500, Yangtao Li wrote:
> of_find_node_by_path() acquires a reference to the node returned by
> it and that reference needs to be dropped by its caller. Add
> i8042_is_mr_coffee() helper to avoid refconut leak.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
> changes in v5:
> -fix typo
Has this at least been actually compiled by you?
>
> changes in v4:
> -fix typo
>
> changes in v3:
> -add i8042_is_mr_coffee
> ---
> drivers/input/serio/i8042-sparcio.h | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
> index 796289846204..9e9e512bc432 100644
> --- a/drivers/input/serio/i8042-sparcio.h
> +++ b/drivers/input/serio/i8042-sparcio.h
> @@ -106,11 +106,23 @@ static struct platform_driver sparc_i8042_driver = {
> .remove = sparc_i8042_remove,
> };
>
> +static inline bool i8042_is_mr_coffee(void)
> +{
> + struct device_node *root;
> + bool is_mr_coffee;
> +
> + root = of_find_node_by_path("/");
> + is_mr_coffee = !strcmp(root->name, "SUNW,JavaStation-1");
> + of_node_put(root);
> +
> + return is_mr_coffee;
> +}
> +
> static int __init i8042_platform_init(void)
> {
> - struct device_node *root = of_find_node_by_path("/");
> + bool match = i8042_is_mr_coffee();
>
> - if (!strcmp(root->name, "SUNW,JavaStation-1")) {
> + if (match) {
> /* Hardcoded values for MrCoffee. */
> i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
> kbd_iobase = ioremap(0x71300060, 8);
> @@ -138,9 +150,9 @@ static int __init i8042_platform_init(void)
>
> static inline void i8042_platform_exit(void)
> {
> - struct device_node *root = of_find_node_by_path("/");
> + bool match = i8042_is_mr_coffee();
>
> - if (strcmp(root->name, "SUNW,JavaStation-1"))
> + if (!match)
> platform_driver_unregister(&sparc_i8042_driver);
> }
>
> --
> 2.17.0
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: elantech - Disable elan-i2c for P52 and P72
From: Dmitry Torokhov @ 2018-12-21 8:43 UTC (permalink / raw)
To: Peter Hutterer
Cc: Benjamin Tissoires, kt.liao, Aaron Ma, Kai Heng Feng, linux-input,
linux-kernel, stable
In-Reply-To: <20181218081343.GA4701@jelly>
On Tue, Dec 18, 2018 at 06:13:43PM +1000, Peter Hutterer wrote:
> On Wed, Dec 12, 2018 at 04:42:05PM +0100, Benjamin Tissoires wrote:
> > The current implementation of elan_i2c is known to not support those
> > 2 laptops.
> >
> > A proper fix is to tweak both elantech and elan_i2c to transmit the
> > correct information from PS/2, which would make a bad candidate for
> > stable.
> >
> > So to give us some time for fixing the root of the problem, disable
> > elan_i2c for the devices we know are not behaving properly.
> >
> > Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1803600
> > Link: https://bugs.archlinux.org/task/59714
> > Fixes: df077237cf55 Input: elantech - detect new ICs and setup Host Notify for them
> >
> > Cc: stable@vger.kernel.org # v4.18+
> > Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>
> Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Applied, thank you.
>
> Cheers,
> Peter
>
> > ---
> > drivers/input/mouse/elantech.c | 18 ++++++++++++++++--
> > 1 file changed, 16 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
> > index 2d95e8d93cc7..830ae9f07045 100644
> > --- a/drivers/input/mouse/elantech.c
> > +++ b/drivers/input/mouse/elantech.c
> > @@ -1767,6 +1767,18 @@ static int elantech_smbus = IS_ENABLED(CONFIG_MOUSE_ELAN_I2C_SMBUS) ?
> > module_param_named(elantech_smbus, elantech_smbus, int, 0644);
> > MODULE_PARM_DESC(elantech_smbus, "Use a secondary bus for the Elantech device.");
> >
> > +static const char * const i2c_blacklist_pnp_ids[] = {
> > + /*
> > + * these are known to not be working properly as bits are missing
> > + * in elan_i2c
> > + */
> > + "LEN2131", /* ThinkPad P52 w/ NFC */
> > + "LEN2132", /* ThinkPad P52 */
> > + "LEN2133", /* ThinkPad P72 w/ NFC */
> > + "LEN2134", /* ThinkPad P72 */
> > + NULL
> > +};
> > +
> > static int elantech_create_smbus(struct psmouse *psmouse,
> > struct elantech_device_info *info,
> > bool leave_breadcrumbs)
> > @@ -1802,10 +1814,12 @@ static int elantech_setup_smbus(struct psmouse *psmouse,
> >
> > if (elantech_smbus == ELANTECH_SMBUS_NOT_SET) {
> > /*
> > - * New ICs are enabled by default.
> > + * New ICs are enabled by default, unless mentioned in
> > + * i2c_blacklist_pnp_ids.
> > * Old ICs are up to the user to decide.
> > */
> > - if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version))
> > + if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version) ||
> > + psmouse_matches_pnp_id(psmouse, i2c_blacklist_pnp_ids))
> > return -ENXIO;
> > }
> >
> > --
> > 2.19.2
> >
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2 -next] input: keyboard: remove duplicated include from mtk-pmic-keys.c
From: Dmitry Torokhov @ 2018-12-21 8:46 UTC (permalink / raw)
To: YueHaibing
Cc: matthias.bgg, lee.jones, chen.zhong, linux-kernel, linux-mediatek,
linux-arm-kernel, linux-input
In-Reply-To: <20181211093200.18140-1-yuehaibing@huawei.com>
On Tue, Dec 11, 2018 at 05:32:00PM +0800, YueHaibing wrote:
> alphabetise the header files and remove duplicated include
> file linux/kernel.h
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Applied, thank you.
> ---
> v2: alphabetise the header files
> ---
> drivers/input/keyboard/mtk-pmic-keys.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index 02c67a1..8e6ebab 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -14,18 +14,17 @@
> *
> */
>
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> #include <linux/input.h>
> #include <linux/interrupt.h>
> -#include <linux/platform_device.h>
> #include <linux/kernel.h>
> -#include <linux/of.h>
> -#include <linux/of_device.h>
> -#include <linux/regmap.h>
> #include <linux/mfd/mt6323/registers.h>
> -#include <linux/mfd/mt6397/registers.h>
> #include <linux/mfd/mt6397/core.h>
> +#include <linux/mfd/mt6397/registers.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
>
> #define MTK_PMIC_PWRKEY_RST_EN_MASK 0x1
> #define MTK_PMIC_PWRKEY_RST_EN_SHIFT 6
> --
> 2.7.4
>
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2 2/2] input: add official Raspberry Pi's touchscreen driver
From: Dmitry Torokhov @ 2018-12-21 8:49 UTC (permalink / raw)
To: Nicolas Saenz Julienne
Cc: Eric Anholt, Henrik Rydberg, linux-rpi-kernel, stefan.wahren,
agraf, afaerber, Corentin Labbe, Mark Jonas, Masanari Iida,
Heiko Schocher, Hans de Goede, Eugen Hristev, Zhu Yi,
Jonathan Cameron, linux-kernel, linux-input
In-Reply-To: <2c433e120c2cf375b7d431f79ce6bfbace803c7e.camel@suse.de>
On Thu, Dec 20, 2018 at 08:12:23PM +0100, Nicolas Saenz Julienne wrote:
> On Thu, 2018-12-20 at 10:39 -0800, Eric Anholt wrote:
> > Nicolas Saenz Julienne <nsaenzjulienne@suse.de> writes:
> >
> > > Add's support to Raspberry Pi's 7" Touch device. Instead of using a
> > > conventional bus all information is copied into a memory mapped
> > > area by
> > > RPi's firmware.
> > >
> > > Based on the driver found in RPi's kernel repository.
> > >
> > > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> >
> > While I wish we could just have a native driver instead, it does make
> > sense to have this driver upstream given the constraints.
> >
> > Acked-by: Eric Anholt <eric@anholt.net>
>
> Thanks Eric.
>
> FYI I did manage to access the touchscreen after altering the native
> driver (edt-ft5x06). That said, as commented in the cover letter, it's
> not good enough as it breaks the camera. I plan on posting the patch
> and an overlay. I'm just waiting to see how these first patches are
> received.
Applied, thank you.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3] Input: touchscreen: Fix coding style issue
From: Dmitry Torokhov @ 2018-12-21 9:07 UTC (permalink / raw)
To: Hardik Singh Rathore; +Cc: michael.hennerich, linux-input, linux-kernel, joe
In-Reply-To: <20181211130332.27781-1-hardiksingh.k@gmail.com>
On Tue, Dec 11, 2018 at 06:33:32PM +0530, Hardik Singh Rathore wrote:
> This patch fixes the coding style problem reported
> by checkpatch.pl as below:
>
> ERROR: foo* bar should be "foo *bar"
>
> Signed-off-by: Hardik Singh Rathore <hardiksingh.k@gmail.com>
Applied, thank you.
> ---
> v3:
> - v2 was depends on v1 so it didn't solve the issue.
>
> drivers/input/touchscreen/ad7879.c | 2 +-
> drivers/input/touchscreen/ektf2127.c | 2 +-
> drivers/input/touchscreen/gunze.c | 4 ++--
> drivers/input/touchscreen/inexio.c | 4 ++--
> drivers/input/touchscreen/mtouch.c | 4 ++--
> 5 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index 6bad23ee47a1..b68902c17f2e 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -290,7 +290,7 @@ static int ad7879_open(struct input_dev *input)
> return 0;
> }
>
> -static void ad7879_close(struct input_dev* input)
> +static void ad7879_close(struct input_dev *input)
> {
> struct ad7879 *ts = input_get_drvdata(input);
>
> diff --git a/drivers/input/touchscreen/ektf2127.c b/drivers/input/touchscreen/ektf2127.c
> index 0ed34ff787ce..28fa1b36f7a5 100644
> --- a/drivers/input/touchscreen/ektf2127.c
> +++ b/drivers/input/touchscreen/ektf2127.c
> @@ -51,7 +51,7 @@ struct ektf2127_ts {
> struct touchscreen_properties prop;
> };
>
> -static void ektf2127_parse_coordinates(const u8* buf, unsigned int touch_count,
> +static void ektf2127_parse_coordinates(const u8 *buf, unsigned int touch_count,
> struct input_mt_pos *touches)
> {
> int index = 0;
> diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
> index 054c2537b392..56cf1a1ea3ea 100644
> --- a/drivers/input/touchscreen/gunze.c
> +++ b/drivers/input/touchscreen/gunze.c
> @@ -53,7 +53,7 @@ struct gunze {
> char phys[32];
> };
>
> -static void gunze_process_packet(struct gunze* gunze)
> +static void gunze_process_packet(struct gunze *gunze)
> {
> struct input_dev *dev = gunze->dev;
>
> @@ -72,7 +72,7 @@ static void gunze_process_packet(struct gunze* gunze)
> static irqreturn_t gunze_interrupt(struct serio *serio,
> unsigned char data, unsigned int flags)
> {
> - struct gunze* gunze = serio_get_drvdata(serio);
> + struct gunze *gunze = serio_get_drvdata(serio);
>
> if (data == '\r') {
> gunze_process_packet(gunze);
> diff --git a/drivers/input/touchscreen/inexio.c b/drivers/input/touchscreen/inexio.c
> index b9bc56233ccc..13bd0bf580a7 100644
> --- a/drivers/input/touchscreen/inexio.c
> +++ b/drivers/input/touchscreen/inexio.c
> @@ -79,7 +79,7 @@ static void inexio_process_data(struct inexio *pinexio)
> static irqreturn_t inexio_interrupt(struct serio *serio,
> unsigned char data, unsigned int flags)
> {
> - struct inexio* pinexio = serio_get_drvdata(serio);
> + struct inexio *pinexio = serio_get_drvdata(serio);
>
> pinexio->data[pinexio->idx] = data;
>
> @@ -97,7 +97,7 @@ static irqreturn_t inexio_interrupt(struct serio *serio,
>
> static void inexio_disconnect(struct serio *serio)
> {
> - struct inexio* pinexio = serio_get_drvdata(serio);
> + struct inexio *pinexio = serio_get_drvdata(serio);
>
> input_get_device(pinexio->dev);
> input_unregister_device(pinexio->dev);
> diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c
> index a3707fad4d1c..8278a9058640 100644
> --- a/drivers/input/touchscreen/mtouch.c
> +++ b/drivers/input/touchscreen/mtouch.c
> @@ -90,7 +90,7 @@ static void mtouch_process_response(struct mtouch *mtouch)
> static irqreturn_t mtouch_interrupt(struct serio *serio,
> unsigned char data, unsigned int flags)
> {
> - struct mtouch* mtouch = serio_get_drvdata(serio);
> + struct mtouch *mtouch = serio_get_drvdata(serio);
>
> mtouch->data[mtouch->idx] = data;
>
> @@ -110,7 +110,7 @@ static irqreturn_t mtouch_interrupt(struct serio *serio,
>
> static void mtouch_disconnect(struct serio *serio)
> {
> - struct mtouch* mtouch = serio_get_drvdata(serio);
> + struct mtouch *mtouch = serio_get_drvdata(serio);
>
> input_get_device(mtouch->dev);
> input_unregister_device(mtouch->dev);
> --
> 2.17.1
>
--
Dmitry
^ permalink raw reply
* [git pull] Input updates for v4.20-rc7
From: Dmitry Torokhov @ 2018-12-21 9:12 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel, linux-input
Hi Linus,
Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git for-linus
to receive updates for the input subsystem. Switching a few devices with
Synaptics over to SMbus and disabling SMbus on a couple devices with
Elan touchpads as they need more plumbing on PS/2 side.
Changelog:
---------
Benjamin Tissoires (1):
Input: elantech - disable elan-i2c for P52 and P72
Mantas Mikulėnas (1):
Input: synaptics - enable SMBus for HP EliteBook 840 G4
Tony Lindgren (1):
Input: omap-keypad - fix idle configuration to not block SoC idle states
Yussuf Khalil (1):
Input: synaptics - enable RMI on ThinkPad T560
Diffstat:
--------
drivers/input/keyboard/omap4-keypad.c | 16 ++++------------
drivers/input/mouse/elantech.c | 18 ++++++++++++++++--
drivers/input/mouse/synaptics.c | 2 ++
3 files changed, 22 insertions(+), 14 deletions(-)
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v4 1/8] dt-bindings: stmpe: reformatting parameter list and use tabs only
From: Lee Jones @ 2018-12-21 10:42 UTC (permalink / raw)
To: Philippe Schenker
Cc: jic23, marcel.ziswiler, stefan, thierry.reding, Philippe Schenker,
devicetree, Max Krummenacher, Alexandre Torgue, linux-input,
linux-kernel, Rob Herring, Dmitry Torokhov, Maxime Coquelin,
Mark Rutland, linux-stm32, linux-arm-kernel
In-Reply-To: <20181212130649.15146-1-dev@pschenker.ch>
On Wed, 12 Dec 2018, Philippe Schenker wrote:
> This patch reformats the parameter list for stmpe device in a
> table-style so it is more clear to read.
>
> Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
> ---
>
> Changes in v4:
> - New separate precursor patch for holding reformatting
>
> Changes in v3: None
> Changes in v2: None
>
> .../bindings/input/touchscreen/stmpe.txt | 52 ++++++++++++-------
> .../devicetree/bindings/mfd/stmpe.txt | 14 ++---
> 2 files changed, 41 insertions(+), 25 deletions(-)
For my own reference:
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply
* Re: [PATCH v4 1/8] dt-bindings: stmpe: reformatting parameter list and use tabs only
From: Lee Jones @ 2018-12-21 10:44 UTC (permalink / raw)
To: Philippe Schenker
Cc: jic23, marcel.ziswiler, stefan, thierry.reding, Philippe Schenker,
devicetree, Max Krummenacher, Alexandre Torgue, linux-input,
linux-kernel, Rob Herring, Dmitry Torokhov, Maxime Coquelin,
Mark Rutland, linux-stm32, linux-arm-kernel
In-Reply-To: <20181212130649.15146-1-dev@pschenker.ch>
On Wed, 12 Dec 2018, Philippe Schenker wrote:
> This patch reformats the parameter list for stmpe device in a
> table-style so it is more clear to read.
>
> Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
> ---
>
> Changes in v4:
> - New separate precursor patch for holding reformatting
>
> Changes in v3: None
> Changes in v2: None
>
> .../bindings/input/touchscreen/stmpe.txt | 52 ++++++++++++-------
> .../devicetree/bindings/mfd/stmpe.txt | 14 ++---
> 2 files changed, 41 insertions(+), 25 deletions(-)
Set looks okay.
Please submit a [RESEND] with all the Acks you've collected.
And next time, please make sure you author a 0th (cover-letter) patch.
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply
* [PATCH v5 0/8] Adding support for STMPE811 ADC
From: Philippe Schenker @ 2018-12-21 13:46 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
digetx, lee.jones, coquelin.stm32, Philippe Schenker,
Arnd Bergmann, Arnaud Pouliquen, linux-iio, Mark Brown,
Pengutronix Kernel Team, Rob Herring, Geert Uytterhoeven,
William Breathitt Gray, linux-stm32, Fabio Estevam, Randy Dunlap,
Jonathan Cameron, Freeman Liu, linux-input
From: Philippe Schenker <philippe.schenker@toradex.com>
Hello everyone,
This patchset is adding an ADC driver for STMPE811. The STMPE811 is a
Multi-Frontend-Device that supports a touchscreen, ADC, GPIO and a
temperature sensor.
For Touchscreen and GPIO there are already existing drivers in
mainline. This patchset will add support, to read out the ADC and
temperature sensor.
This patchset is also reformatting device tree bindings, so they are
easier to read (PATCH 1/1).
To be able to add this ADC driver it is necessary to move some defines
from the touchscreen driver to the mfd device (PATCH 2/8) so they are
also accessible by mfd and adc driver.
Because the touchscreen driver is also using the internal ADC it makes
sense to put the common adc settings of stmpe-ts.c and stmpe_adc.c to
the MFD. In the MFD there is then also an initialisation for the common
settings of ADC done. The existing initialisation in touchscreen driver
is kept for backwards-compatibility. All of this MFD related changes
are in PATCH 3/8.
In PATCH 4/8 then these settings are removed from stmpe-ts and grabbed
from MFD.
PATCH 5/8 is actually adding the ADC driver that also supports the
built-in temperature sensor.
PATCH 6/8 is then adding the needed devicetree bindings.
PATCH 7/8 and 8/8 is lastly adding the stmpe_adc DT-nodes as found on
Toradex boards.
Changes in v5:
- Made a one column list
- Added lee's Acked-for-MFD
- Changed author of commit to use correct email.
- Changed author of commit to use correct email
- Added Lee Jone's Ack
- Changed author of commit. Previous patch versions author was wrong
by mistake.
- Changed author of commit to use correct email.
- Removed devm_add_action_or_reset
- Changed iio_device_register to devm_iio_device_register
- Added Jonathan Cameron's Reviewed-by
- Added correct author of commit, as this changed by accident
- Made a one column list
- Cleared note about precedence
- Changed example to a full STMPE811 device with MFD, touchscreen, and the new
stmpe_adc driver.
- Added Jonathan Cameron's Reviewed-by
Changes in v4:
- New separate precursor patch for holding reformatting
- Added Lee Jone's Ack
- Added Dmitry Torokhov's Ack
- New patch: split mfd changes into this precursor patch
- Export the added stmpe811_adc_commmon_init function
- Disabling adc when mfd is removed
- New patch: Split changes in stmpe-ts.c to a separate commit
- Remove common adc settings from init and call the
stmpe811_adc_common_init function
- Moved MFD changes to a precursor patch
- Moved stmpe-ts changes to a precursor patch
- Created stmpe_read_temp and stmpe_read_voltage functions to make
read_raw more readable
- Added local lock instead of using indio_dev's mlock
- Use be16_to_cpu() macro instead of bitshifting
- Added stmpe_enable again to stmpe_adc_init_hw
- Use devm_add_action_or_reset to get rid of the remove function
(I tested if that actually works)
- Put reformatting in a separate precursor patch.
- Moved T30 devicetree settings to separate commit
- New separate commit to hold T30 devicetree changes
Changes in v3:
- Undo ADC-settings related code-deletions in stmpe-ts.c that the code
is backwards-compatible to older devicetrees.
- Removed COMPILE_TEST from dependings in Kconfig
- Removed stmpe_adc_get_platform_info() function and integrated the
few code lines in the other function
- Reformatted documentation for touchscreen to use tabs and have a better
overview of the settings.
- Added note which adc-settings will take precedence.
- changed typo in sample-time setting from 144 clocks to 124 clocks, as stated
in the datasheet.
- None
Changes in v2:
- This is a new added commit. Separate commit for moving the defines
out of drivers/input/touchscreen/stmpe-ts.c to overlying mfd-device
drivers/mfd/stmpe.c
- Pre-fix defines with STMPE_
- Move code to setup ADC to MFD device, as it is used by both drivers
adc and touchscreen
- Code formatting
- Removed unused includes
- Defined the macro STMPE_START_ONE_TEMP_CONV with other macros.
- Added new macro that defines the channel of the temperature sensor.
Took new name for STMPE_MAX_ADC->STMPE_ADC_LAST_NR and used it
throughout the code for better readability.
- Added mutex_unlock where missing.
- Moved the bindings for ADC to the overlying mfd.
- Reformatted for better readability
- Put common ADC settings in mfd
Philippe Schenker (5):
dt-bindings: stmpe: reformatting parameter list and use tabs only
mfd: stmpe: Move ADC related defines to header of mfd
Input: stmpe-ts: preparations for STMPE ADC driver
ARM: dts: Add stmpe-adc DT node to Toradex iMX6 modules
ARM: dts: Add stmpe-adc DT node to Toradex T30 modules
Stefan Agner (3):
mfd: stmpe: preparations for STMPE ADC driver
iio: adc: add STMPE ADC driver using IIO framework
iio: adc: add STMPE ADC devicetree bindings
.../devicetree/bindings/iio/adc/stmpe-adc.txt | 21 +
.../bindings/input/touchscreen/stmpe.txt | 116 ++++--
.../devicetree/bindings/mfd/stmpe.txt | 28 +-
arch/arm/boot/dts/imx6qdl-apalis.dtsi | 22 +-
arch/arm/boot/dts/imx6qdl-colibri.dtsi | 23 +-
arch/arm/boot/dts/tegra30-apalis.dtsi | 22 +-
arch/arm/boot/dts/tegra30-colibri.dtsi | 22 +-
drivers/iio/adc/Kconfig | 7 +
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/stmpe-adc.c | 363 ++++++++++++++++++
drivers/input/touchscreen/stmpe-ts.c | 66 +---
drivers/mfd/Kconfig | 3 +-
drivers/mfd/stmpe.c | 68 ++++
include/linux/mfd/stmpe.h | 21 +
14 files changed, 667 insertions(+), 116 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
create mode 100644 drivers/iio/adc/stmpe-adc.c
--
2.19.2
^ permalink raw reply
* [PATCH v5 1/8] dt-bindings: stmpe: reformatting parameter list and use tabs only
From: Philippe Schenker @ 2018-12-21 13:46 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
digetx, lee.jones, coquelin.stm32, Philippe Schenker, devicetree,
Max Krummenacher, Jonathan Cameron, linux-input, linux-kernel,
Rob Herring, Maxime Coquelin, Mark Rutland, linux-stm32,
linux-arm-kernel
In-Reply-To: <20181221134638.20600-1-dev@pschenker.ch>
From: Philippe Schenker <philippe.schenker@toradex.com>
This patch reformats the parameter list for stmpe device in a
table-style so it is more clear to read.
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
Changes in v5:
- Made a one column list
- Added lee's Acked-for-MFD
- Changed author of commit to use correct email.
Changes in v4:
- New separate precursor patch for holding reformatting
Changes in v3: None
Changes in v2: None
.../bindings/input/touchscreen/stmpe.txt | 64 +++++++++++++------
.../devicetree/bindings/mfd/stmpe.txt | 14 ++--
2 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index 127baa31a77a..bf66a55a7de5 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -5,24 +5,52 @@ Required properties:
- compatible: "st,stmpe-ts"
Optional properties:
-- st,sample-time: ADC converstion time in number of clock. (0 -> 36 clocks, 1 ->
- 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks, 4 -> 80 clocks, 5 -> 96 clocks, 6
- -> 144 clocks), recommended is 4.
-- st,mod-12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC)
-- st,ref-sel: ADC reference source (0 -> internal reference, 1 -> external
- reference)
-- st,adc-freq: ADC Clock speed (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz)
-- st,ave-ctrl: Sample average control (0 -> 1 sample, 1 -> 2 samples, 2 -> 4
- samples, 3 -> 8 samples)
-- st,touch-det-delay: Touch detect interrupt delay (0 -> 10 us, 1 -> 50 us, 2 ->
- 100 us, 3 -> 500 us, 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms) recommended
- is 3
-- st,settling: Panel driver settling time (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3
- -> 1 ms, 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms) recommended is 2
-- st,fraction-z: Length of the fractional part in z (fraction-z ([0..7]) = Count of
- the fractional part) recommended is 7
-- st,i-drive: current limit value of the touchscreen drivers (0 -> 20 mA typical 35
- mA max, 1 -> 50 mA typical 80 mA max)
+- st,sample-time : ADC conversion time in number of clock.
+ 0 -> 36 clocks
+ 1 -> 44 clocks
+ 2 -> 56 clocks
+ 3 -> 64 clocks
+ 4 -> 80 clocks (recommended)
+ 5 -> 96 clocks
+ 6 -> 144 clocks
+- st,mod-12b : ADC Bit mode
+ 0 -> 10bit ADC
+ 1 -> 12bit ADC
+- st,ref-sel : ADC reference source
+ 0 -> internal
+ 1 -> external
+- st,adc-freq : ADC Clock speed
+ 0 -> 1.625 MHz
+ 1 -> 3.25 MHz
+ 2 || 3 -> 6.5 MHz
+- st,ave-ctrl : Sample average control
+ 0 -> 1 sample
+ 1 -> 2 samples
+ 2 -> 4 samples
+ 3 -> 8 samples
+- st,touch-det-delay : Touch detect interrupt delay (recommended is 3)
+ 0 -> 10 us
+ 1 -> 50 us
+ 2 -> 100 us
+ 3 -> 500 us
+ 4 -> 1 ms
+ 5 -> 5 ms
+ 6 -> 10 ms
+ 7 -> 50 ms
+- st,settling : Panel driver settling time (recommended is 2)
+ 0 -> 10 us
+ 1 -> 100 us
+ 2 -> 500 us
+ 3 -> 1 ms
+ 4 -> 5 ms
+ 5 -> 10 ms
+ 6 -> 50 ms
+ 7 -> 100 ms
+- st,fraction-z : Length of the fractional part in z (recommended is 7)
+ (fraction-z ([0..7]) = Count of the fractional part)
+- st,i-drive : current limit value of the touchscreen drivers
+ 0 -> 20 mA (typical 35mA max)
+ 1 -> 50 mA (typical 80 mA max)
Node name must be stmpe_touchscreen and should be child node of stmpe node to
which it belongs.
diff --git a/Documentation/devicetree/bindings/mfd/stmpe.txt b/Documentation/devicetree/bindings/mfd/stmpe.txt
index c797c05cd3c2..a46e7177195d 100644
--- a/Documentation/devicetree/bindings/mfd/stmpe.txt
+++ b/Documentation/devicetree/bindings/mfd/stmpe.txt
@@ -4,15 +4,15 @@ STMPE is an MFD device which may expose the following inbuilt devices: gpio,
keypad, touchscreen, adc, pwm, rotator.
Required properties:
- - compatible : "st,stmpe[610|801|811|1600|1601|2401|2403]"
- - reg : I2C/SPI address of the device
+ - compatible : "st,stmpe[610|801|811|1600|1601|2401|2403]"
+ - reg : I2C/SPI address of the device
Optional properties:
- - interrupts : The interrupt outputs from the controller
- - interrupt-controller : Marks the device node as an interrupt controller
- - wakeup-source : Marks the input device as wakable
- - st,autosleep-timeout : Valid entries (ms); 4, 16, 32, 64, 128, 256, 512 and 1024
- - irq-gpio : If present, which GPIO to use for event IRQ
+ - interrupts : The interrupt outputs from the controller
+ - interrupt-controller : Marks the device node as an interrupt controller
+ - wakeup-source : Marks the input device as wakable
+ - st,autosleep-timeout : Valid entries (ms); 4, 16, 32, 64, 128, 256, 512 and 1024
+ - irq-gpio : If present, which GPIO to use for event IRQ
Example:
--
2.19.2
^ permalink raw reply related
* [PATCH v5 2/8] mfd: stmpe: Move ADC related defines to header of mfd
From: Philippe Schenker @ 2018-12-21 13:46 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
digetx, lee.jones, coquelin.stm32, Philippe Schenker,
linux-kernel, linux-input, Maxime Coquelin, linux-stm32,
linux-arm-kernel
In-Reply-To: <20181221134638.20600-1-dev@pschenker.ch>
From: Philippe Schenker <philippe.schenker@toradex.com>
Move defines that are ADC related to the header of the overlying mfd,
so they can be used from multiple sub-devices.
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v5:
- Changed author of commit to use correct email
Changes in v4:
- Added Lee Jone's Ack
- Added Dmitry Torokhov's Ack
Changes in v3: None
Changes in v2:
- This is a new added commit. Separate commit for moving the defines
out of drivers/input/touchscreen/stmpe-ts.c to overlying mfd-device
drivers/mfd/stmpe.c
- Pre-fix defines with STMPE_
drivers/input/touchscreen/stmpe-ts.c | 34 +++++++++++-----------------
include/linux/mfd/stmpe.h | 11 +++++++++
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 2a78e27b4495..c5d9006588a2 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -49,17 +49,6 @@
#define STMPE_IRQ_TOUCH_DET 0
-#define SAMPLE_TIME(x) ((x & 0xf) << 4)
-#define MOD_12B(x) ((x & 0x1) << 3)
-#define REF_SEL(x) ((x & 0x1) << 1)
-#define ADC_FREQ(x) (x & 0x3)
-#define AVE_CTRL(x) ((x & 0x3) << 6)
-#define DET_DELAY(x) ((x & 0x7) << 3)
-#define SETTLING(x) (x & 0x7)
-#define FRACTION_Z(x) (x & 0x7)
-#define I_DRIVE(x) (x & 0x1)
-#define OP_MODE(x) ((x & 0x7) << 1)
-
#define STMPE_TS_NAME "stmpe-ts"
#define XY_MASK 0xfff
@@ -213,9 +202,10 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
return ret;
}
- adc_ctrl1 = SAMPLE_TIME(ts->sample_time) | MOD_12B(ts->mod_12b) |
- REF_SEL(ts->ref_sel);
- adc_ctrl1_mask = SAMPLE_TIME(0xff) | MOD_12B(0xff) | REF_SEL(0xff);
+ adc_ctrl1 = STMPE_SAMPLE_TIME(ts->sample_time) |
+ STMPE_MOD_12B(ts->mod_12b) | STMPE_REF_SEL(ts->ref_sel);
+ adc_ctrl1_mask = STMPE_SAMPLE_TIME(0xff) | STMPE_MOD_12B(0xff) |
+ STMPE_REF_SEL(0xff);
ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL1,
adc_ctrl1_mask, adc_ctrl1);
@@ -225,15 +215,17 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
}
ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL2,
- ADC_FREQ(0xff), ADC_FREQ(ts->adc_freq));
+ STMPE_ADC_FREQ(0xff), STMPE_ADC_FREQ(ts->adc_freq));
if (ret) {
dev_err(dev, "Could not setup ADC\n");
return ret;
}
- tsc_cfg = AVE_CTRL(ts->ave_ctrl) | DET_DELAY(ts->touch_det_delay) |
- SETTLING(ts->settling);
- tsc_cfg_mask = AVE_CTRL(0xff) | DET_DELAY(0xff) | SETTLING(0xff);
+ tsc_cfg = STMPE_AVE_CTRL(ts->ave_ctrl) |
+ STMPE_DET_DELAY(ts->touch_det_delay) |
+ STMPE_SETTLING(ts->settling);
+ tsc_cfg_mask = STMPE_AVE_CTRL(0xff) | STMPE_DET_DELAY(0xff) |
+ STMPE_SETTLING(0xff);
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CFG, tsc_cfg_mask, tsc_cfg);
if (ret) {
@@ -242,14 +234,14 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
}
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_FRACTION_Z,
- FRACTION_Z(0xff), FRACTION_Z(ts->fraction_z));
+ STMPE_FRACTION_Z(0xff), STMPE_FRACTION_Z(ts->fraction_z));
if (ret) {
dev_err(dev, "Could not config touch\n");
return ret;
}
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_I_DRIVE,
- I_DRIVE(0xff), I_DRIVE(ts->i_drive));
+ STMPE_I_DRIVE(0xff), STMPE_I_DRIVE(ts->i_drive));
if (ret) {
dev_err(dev, "Could not config touch\n");
return ret;
@@ -263,7 +255,7 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
}
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CTRL,
- OP_MODE(0xff), OP_MODE(OP_MOD_XYZ));
+ STMPE_OP_MODE(0xff), STMPE_OP_MODE(OP_MOD_XYZ));
if (ret) {
dev_err(dev, "Could not set mode\n");
return ret;
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 4a827af17e59..c0353f6431f9 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -10,6 +10,17 @@
#include <linux/mutex.h>
+#define STMPE_SAMPLE_TIME(x) ((x & 0xf) << 4)
+#define STMPE_MOD_12B(x) ((x & 0x1) << 3)
+#define STMPE_REF_SEL(x) ((x & 0x1) << 1)
+#define STMPE_ADC_FREQ(x) (x & 0x3)
+#define STMPE_AVE_CTRL(x) ((x & 0x3) << 6)
+#define STMPE_DET_DELAY(x) ((x & 0x7) << 3)
+#define STMPE_SETTLING(x) (x & 0x7)
+#define STMPE_FRACTION_Z(x) (x & 0x7)
+#define STMPE_I_DRIVE(x) (x & 0x1)
+#define STMPE_OP_MODE(x) ((x & 0x7) << 1)
+
struct device;
struct regulator;
--
2.19.2
^ permalink raw reply related
* [PATCH v5 4/8] Input: stmpe-ts: preparations for STMPE ADC driver
From: Philippe Schenker @ 2018-12-21 13:46 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, lee.jones, dmitry.torokhov, linux-kernel,
Philippe Schenker, thierry.reding, linux-arm-kernel,
Maxime Coquelin, linux-input, digetx, shawnguo, linux-stm32
In-Reply-To: <20181221134638.20600-1-dev@pschenker.ch>
From: Philippe Schenker <philippe.schenker@toradex.com>
This patch removes common ADC settings in favor to use
stmpe811_adc_common_init that is present in MFD. This is necessary in
preparation for the stmpe-adc driver, because those two drivers have
common settings for the ADC.
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
---
Changes in v5:
- Changed author of commit to use correct email.
Changes in v4:
- New patch: Split changes in stmpe-ts.c to a separate commit
- Remove common adc settings from init and call the
stmpe811_adc_common_init function
Changes in v3:
- Undo ADC-settings related code-deletions in stmpe-ts.c that the code
is backwards-compatible to older devicetrees.
Changes in v2: None
drivers/input/touchscreen/stmpe-ts.c | 42 +++++-----------------------
1 file changed, 7 insertions(+), 35 deletions(-)
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index c5d9006588a2..cf9c9aa39f6e 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -30,8 +30,6 @@
* with touchscreen controller
*/
#define STMPE_REG_INT_STA 0x0B
-#define STMPE_REG_ADC_CTRL1 0x20
-#define STMPE_REG_ADC_CTRL2 0x21
#define STMPE_REG_TSC_CTRL 0x40
#define STMPE_REG_TSC_CFG 0x41
#define STMPE_REG_FIFO_TH 0x4A
@@ -58,15 +56,6 @@
* @idev: registered input device
* @work: a work item used to scan the device
* @dev: a pointer back to the MFD cell struct device*
- * @sample_time: ADC converstion time in number of clock.
- * (0 -> 36 clocks, 1 -> 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks,
- * 4 -> 80 clocks, 5 -> 96 clocks, 6 -> 144 clocks),
- * recommended is 4.
- * @mod_12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC)
- * @ref_sel: ADC reference source
- * (0 -> internal reference, 1 -> external reference)
- * @adc_freq: ADC Clock speed
- * (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz)
* @ave_ctrl: Sample average control
* (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples)
* @touch_det_delay: Touch detect interrupt delay
@@ -88,10 +77,6 @@ struct stmpe_touch {
struct input_dev *idev;
struct delayed_work work;
struct device *dev;
- u8 sample_time;
- u8 mod_12b;
- u8 ref_sel;
- u8 adc_freq;
u8 ave_ctrl;
u8 touch_det_delay;
u8 settling;
@@ -192,7 +177,7 @@ static irqreturn_t stmpe_ts_handler(int irq, void *data)
static int stmpe_init_hw(struct stmpe_touch *ts)
{
int ret;
- u8 adc_ctrl1, adc_ctrl1_mask, tsc_cfg, tsc_cfg_mask;
+ u8 tsc_cfg, tsc_cfg_mask;
struct stmpe *stmpe = ts->stmpe;
struct device *dev = ts->dev;
@@ -202,22 +187,9 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
return ret;
}
- adc_ctrl1 = STMPE_SAMPLE_TIME(ts->sample_time) |
- STMPE_MOD_12B(ts->mod_12b) | STMPE_REF_SEL(ts->ref_sel);
- adc_ctrl1_mask = STMPE_SAMPLE_TIME(0xff) | STMPE_MOD_12B(0xff) |
- STMPE_REF_SEL(0xff);
-
- ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL1,
- adc_ctrl1_mask, adc_ctrl1);
- if (ret) {
- dev_err(dev, "Could not setup ADC\n");
- return ret;
- }
-
- ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL2,
- STMPE_ADC_FREQ(0xff), STMPE_ADC_FREQ(ts->adc_freq));
+ ret = stmpe811_adc_common_init(stmpe);
if (ret) {
- dev_err(dev, "Could not setup ADC\n");
+ stmpe_disable(stmpe, STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_ADC);
return ret;
}
@@ -295,13 +267,13 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev,
if (np) {
if (!of_property_read_u32(np, "st,sample-time", &val))
- ts->sample_time = val;
+ ts->stmpe->sample_time = val;
if (!of_property_read_u32(np, "st,mod-12b", &val))
- ts->mod_12b = val;
+ ts->stmpe->mod_12b = val;
if (!of_property_read_u32(np, "st,ref-sel", &val))
- ts->ref_sel = val;
+ ts->stmpe->ref_sel = val;
if (!of_property_read_u32(np, "st,adc-freq", &val))
- ts->adc_freq = val;
+ ts->stmpe->adc_freq = val;
if (!of_property_read_u32(np, "st,ave-ctrl", &val))
ts->ave_ctrl = val;
if (!of_property_read_u32(np, "st,touch-det-delay", &val))
--
2.19.2
^ permalink raw reply related
* [PATCH v5 6/8] iio: adc: add STMPE ADC devicetree bindings
From: Philippe Schenker @ 2018-12-21 13:46 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
digetx, lee.jones, coquelin.stm32, Max Krummenacher,
Philippe Schenker, devicetree, linux-iio, Hartmut Knaack,
linux-input, linux-kernel, Rob Herring, Maxime Coquelin,
Mark Rutland, Peter Meerwald-Stadler, linux-stm32,
linux-arm-kernel, Lars-Peter Clausen
In-Reply-To: <20181221134638.20600-1-dev@pschenker.ch>
From: Stefan Agner <stefan@agner.ch>
This adds the devicetree bindings for the STMPE ADC. This also corrects
a typo in st,sample-time it is rather "6 -> 124 clocks" according
to the datasheet and not 144.
We need to use the naming stmpe_adc in devicetree because this is given
by the mfd device.
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
Changes in v5:
- Made a one column list
- Cleared note about precedence
- Changed example to a full STMPE811 device with MFD, touchscreen, and the new
stmpe_adc driver.
- Added Jonathan Cameron's Reviewed-by
Changes in v4:
- Put reformatting in a separate precursor patch.
Changes in v3:
- Reformatted documentation for touchscreen to use tabs and have a better
overview of the settings.
- Added note which adc-settings will take precedence.
- changed typo in sample-time setting from 144 clocks to 124 clocks, as stated
in the datasheet.
Changes in v2:
- Moved the bindings for ADC to the overlying mfd.
- Reformatted for better readability
.../devicetree/bindings/iio/adc/stmpe-adc.txt | 21 +++++
.../bindings/input/touchscreen/stmpe.txt | 88 +++++++++++++------
.../devicetree/bindings/mfd/stmpe.txt | 14 +++
3 files changed, 98 insertions(+), 25 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
diff --git a/Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt b/Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
new file mode 100644
index 000000000000..480e66422625
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
@@ -0,0 +1,21 @@
+STMPE ADC driver
+----------------
+
+Required properties:
+ - compatible: "st,stmpe-adc"
+
+Optional properties:
+Note that the ADC is shared with the STMPE touchscreen. ADC related settings
+have to be done in the mfd.
+- st,norequest-mask: bitmask specifying which ADC channels should _not_ be
+ requestable due to different usage (e.g. touch)
+
+Node name must be stmpe_adc and should be child node of stmpe node to
+which it belongs.
+
+Example:
+
+ stmpe_adc {
+ compatible = "st,stmpe-adc";
+ st,norequest-mask = <0x0F>; /* dont use ADC CH3-0 */
+ };
diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index bf66a55a7de5..c549924603d2 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -5,24 +5,6 @@ Required properties:
- compatible: "st,stmpe-ts"
Optional properties:
-- st,sample-time : ADC conversion time in number of clock.
- 0 -> 36 clocks
- 1 -> 44 clocks
- 2 -> 56 clocks
- 3 -> 64 clocks
- 4 -> 80 clocks (recommended)
- 5 -> 96 clocks
- 6 -> 144 clocks
-- st,mod-12b : ADC Bit mode
- 0 -> 10bit ADC
- 1 -> 12bit ADC
-- st,ref-sel : ADC reference source
- 0 -> internal
- 1 -> external
-- st,adc-freq : ADC Clock speed
- 0 -> 1.625 MHz
- 1 -> 3.25 MHz
- 2 || 3 -> 6.5 MHz
- st,ave-ctrl : Sample average control
0 -> 1 sample
1 -> 2 samples
@@ -52,20 +34,76 @@ Optional properties:
0 -> 20 mA (typical 35mA max)
1 -> 50 mA (typical 80 mA max)
+Optional properties common with MFD (deprecated):
+ - st,sample-time : ADC conversion time in number of clock.
+ 0 -> 36 clocks
+ 1 -> 44 clocks
+ 2 -> 56 clocks
+ 3 -> 64 clocks
+ 4 -> 80 clocks (recommended)
+ 5 -> 96 clocks
+ 6 -> 124 clocks
+ - st,mod-12b : ADC Bit mode
+ 0 -> 10bit ADC
+ 1 -> 12bit ADC
+ - st,ref-sel : ADC reference source
+ 0 -> internal
+ 1 -> external
+ - st,adc-freq : ADC Clock speed
+ 0 -> 1.625 MHz
+ 1 -> 3.25 MHz
+ 2 || 3 -> 6.5 MHz
+
Node name must be stmpe_touchscreen and should be child node of stmpe node to
which it belongs.
+Note that common ADC settings of stmpe_touchscreen (child) will take precedence
+over the settings done in MFD.
+
Example:
+stmpe811@41 {
+ compatible = "st,stmpe811";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_touch_int>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x41>;
+ interrupts = <10 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-parent = <&gpio4>;
+ interrupt-controller;
+ id = <0>;
+ blocks = <0x5>;
+ irq-trigger = <0x1>;
+ /* Common ADC settings */
+ /* 3.25 MHz ADC clock speed */
+ st,adc-freq = <1>;
+ /* 12-bit ADC */
+ st,mod-12b = <1>;
+ /* internal ADC reference */
+ st,ref-sel = <0>;
+ /* ADC converstion time: 80 clocks */
+ st,sample-time = <4>;
+
stmpe_touchscreen {
compatible = "st,stmpe-ts";
- st,sample-time = <4>;
- st,mod-12b = <1>;
- st,ref-sel = <0>;
- st,adc-freq = <1>;
- st,ave-ctrl = <1>;
- st,touch-det-delay = <2>;
- st,settling = <2>;
+ reg = <0>;
+ /* 8 sample average control */
+ st,ave-ctrl = <3>;
+ /* 5 ms touch detect interrupt delay */
+ st,touch-det-delay = <5>;
+ /* 1 ms panel driver settling time */
+ st,settling = <3>;
+ /* 7 length fractional part in z */
st,fraction-z = <7>;
+ /*
+ * 50 mA typical 80 mA max touchscreen drivers
+ * current limit value
+ */
st,i-drive = <1>;
};
+ stmpe_adc {
+ compatible = "st,stmpe-adc";
+ st,norequest-mask = <0x0F>;
+ };
+};
diff --git a/Documentation/devicetree/bindings/mfd/stmpe.txt b/Documentation/devicetree/bindings/mfd/stmpe.txt
index a46e7177195d..d4408a417193 100644
--- a/Documentation/devicetree/bindings/mfd/stmpe.txt
+++ b/Documentation/devicetree/bindings/mfd/stmpe.txt
@@ -14,6 +14,20 @@ Optional properties:
- st,autosleep-timeout : Valid entries (ms); 4, 16, 32, 64, 128, 256, 512 and 1024
- irq-gpio : If present, which GPIO to use for event IRQ
+Optional properties for devices with touch and ADC (STMPE811|STMPE610):
+ - st,sample-time : ADC conversion time in number of clock.
+ 0 -> 36 clocks 4 -> 80 clocks (recommended)
+ 1 -> 44 clocks 5 -> 96 clocks
+ 2 -> 56 clocks 6 -> 124 clocks
+ 3 -> 64 clocks
+ - st,mod-12b : ADC Bit mode
+ 0 -> 10bit ADC 1 -> 12bit ADC
+ - st,ref-sel : ADC reference source
+ 0 -> internal 1 -> external
+ - st,adc-freq : ADC Clock speed
+ 0 -> 1.625 MHz 2 || 3 -> 6.5 MHz
+ 1 -> 3.25 MHz
+
Example:
stmpe1601: stmpe1601@40 {
--
2.19.2
^ permalink raw reply related
* Re: [PATCH v5] Input: i8042 add i8042_is_mr_coffee() helper to avoid refconut leak
From: Frank Lee @ 2018-12-21 14:45 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Linux Kernel Mailing List
In-Reply-To: <20181221084212.GG211587@dtor-ws>
On Fri, Dec 21, 2018 at 4:42 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Sat, Dec 15, 2018 at 04:08:46AM -0500, Yangtao Li wrote:
> > of_find_node_by_path() acquires a reference to the node returned by
> > it and that reference needs to be dropped by its caller. Add
> > i8042_is_mr_coffee() helper to avoid refconut leak.
> >
> > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> > ---
> > changes in v5:
> > -fix typo
>
> Has this at least been actually compiled by you?
Sure!!!
On ubuntu 18 machine.
MBR,
Yangtao
^ permalink raw reply
* Re: [PATCH v5 1/8] dt-bindings: stmpe: reformatting parameter list and use tabs only
From: Rob Herring @ 2018-12-21 18:23 UTC (permalink / raw)
To: Philippe Schenker
Cc: jic23, marcel.ziswiler, stefan, robh, alexandre.torgue, shawnguo,
dmitry.torokhov, thierry.reding, digetx, lee.jones,
coquelin.stm32, Philippe Schenker, devicetree, Max Krummenacher,
Jonathan Cameron, linux-input, linux-kernel, Maxime Coquelin,
Mark Rutland, linux-stm32, linux-arm-kernel
In-Reply-To: <20181221134638.20600-2-dev@pschenker.ch>
On Fri, 21 Dec 2018 14:46:30 +0100, Philippe Schenker wrote:
> From: Philippe Schenker <philippe.schenker@toradex.com>
>
> This patch reformats the parameter list for stmpe device in a
> table-style so it is more clear to read.
>
> Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
> Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
>
> ---
>
> Changes in v5:
> - Made a one column list
> - Added lee's Acked-for-MFD
> - Changed author of commit to use correct email.
>
> Changes in v4:
> - New separate precursor patch for holding reformatting
>
> Changes in v3: None
> Changes in v2: None
>
> .../bindings/input/touchscreen/stmpe.txt | 64 +++++++++++++------
> .../devicetree/bindings/mfd/stmpe.txt | 14 ++--
> 2 files changed, 53 insertions(+), 25 deletions(-)
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH v5 6/8] iio: adc: add STMPE ADC devicetree bindings
From: Rob Herring @ 2018-12-21 18:25 UTC (permalink / raw)
To: Philippe Schenker
Cc: jic23, marcel.ziswiler, stefan, robh, alexandre.torgue, shawnguo,
dmitry.torokhov, thierry.reding, digetx, lee.jones,
coquelin.stm32, Max Krummenacher, Philippe Schenker, devicetree,
linux-iio, Hartmut Knaack, linux-input, linux-kernel,
Maxime Coquelin, Mark Rutland, Peter Meerwald-Stadler,
linux-stm32, linux-arm-kernel, Lars-Peter Clausen
In-Reply-To: <20181221134638.20600-7-dev@pschenker.ch>
On Fri, 21 Dec 2018 14:46:35 +0100, Philippe Schenker wrote:
> From: Stefan Agner <stefan@agner.ch>
>
> This adds the devicetree bindings for the STMPE ADC. This also corrects
> a typo in st,sample-time it is rather "6 -> 124 clocks" according
> to the datasheet and not 144.
> We need to use the naming stmpe_adc in devicetree because this is given
> by the mfd device.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
> Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> ---
>
> Changes in v5:
> - Made a one column list
> - Cleared note about precedence
> - Changed example to a full STMPE811 device with MFD, touchscreen, and the new
> stmpe_adc driver.
> - Added Jonathan Cameron's Reviewed-by
>
> Changes in v4:
> - Put reformatting in a separate precursor patch.
>
> Changes in v3:
> - Reformatted documentation for touchscreen to use tabs and have a better
> overview of the settings.
> - Added note which adc-settings will take precedence.
> - changed typo in sample-time setting from 144 clocks to 124 clocks, as stated
> in the datasheet.
>
> Changes in v2:
> - Moved the bindings for ADC to the overlying mfd.
> - Reformatted for better readability
>
> .../devicetree/bindings/iio/adc/stmpe-adc.txt | 21 +++++
> .../bindings/input/touchscreen/stmpe.txt | 88 +++++++++++++------
> .../devicetree/bindings/mfd/stmpe.txt | 14 +++
> 3 files changed, 98 insertions(+), 25 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [git pull] Input updates for v4.20-rc7
From: pr-tracker-bot @ 2018-12-21 19:30 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Linus Torvalds, linux-kernel, linux-input
In-Reply-To: <20181221091258.GA63423@dtor-ws>
The pull request you sent on Fri, 21 Dec 2018 01:12:58 -0800:
> git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git for-linus
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/0b517333721c1b7a740e54b1cbe78a14884d51e7
Thank you!
--
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker
^ permalink raw reply
* [PATCH] input: drv2667: fix indentation issues, remove extra tabs
From: Colin King @ 2018-12-21 23:12 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
There are some statements that are indented incorrectly, fix this by
removinf the extra tabs.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/input/misc/drv2667.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/input/misc/drv2667.c b/drivers/input/misc/drv2667.c
index 2849bb6906a8..6091f0490e8f 100644
--- a/drivers/input/misc/drv2667.c
+++ b/drivers/input/misc/drv2667.c
@@ -177,9 +177,9 @@ static int drv2667_set_waveform_freq(struct drv2667_data *haptics)
error = regmap_write(haptics->regmap, DRV2667_PAGE, read_buf);
if (error) {
dev_err(&haptics->client->dev,
- "Failed to set the page: %d\n", error);
- return -EIO;
- }
+ "Failed to set the page: %d\n", error);
+ return -EIO;
+ }
}
return error;
--
2.19.1
^ permalink raw reply related
* Re: [PATCH] touchscreen: elants: fix a missing check of return values
From: Dmitry Torokhov @ 2018-12-22 1:00 UTC (permalink / raw)
To: Kangjie Lu
Cc: Aditya Pakki, Greg Kroah-Hartman, Stephen Boyd, Joe Perches,
linux-input, open list
In-Reply-To: <CAK8KejrnOwVmjUGTtx5oBQ2QAWTy1-_2QMHTLSNs2Vy=a=mQCQ@mail.gmail.com>
On Fri, Dec 21, 2018 at 03:05:29PM -0600, Kangjie Lu wrote:
> Hi Dmitry,
>
> Thanks for the feedback.
>
> On Fri, Dec 21, 2018 at 2:27 AM Dmitry Torokhov <dmitry.torokhov@gmail.com>
> wrote:
>
> > Hi Kangjie,
> >
> > On Fri, Dec 21, 2018 at 12:59:16AM -0600, Kangjie Lu wrote:
> > > elants_i2c_send() may fail, let's check its return values. The fix does
> > > the check and reports an error message upon the failure.
> > >
> > > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > > ---
> > > drivers/input/touchscreen/elants_i2c.c | 10 ++++++++--
> > > 1 file changed, 8 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/input/touchscreen/elants_i2c.c
> > b/drivers/input/touchscreen/elants_i2c.c
> > > index f2cb23121833..cb3c1470bb68 100644
> > > --- a/drivers/input/touchscreen/elants_i2c.c
> > > +++ b/drivers/input/touchscreen/elants_i2c.c
> > > @@ -245,8 +245,14 @@ static int elants_i2c_calibrate(struct elants_data
> > *ts)
> > > ts->state = ELAN_WAIT_RECALIBRATION;
> > > reinit_completion(&ts->cmd_done);
> > >
> > > - elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
> > > - elants_i2c_send(client, rek, sizeof(rek));
> > > + error = elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
> > > + error |= elants_i2c_send(client, rek, sizeof(rek));
> >
> > I dislike this kind of error handling as this may result in invalid
> > error code being reported, in case 2 commands produce different results.
> >
>
> I will fix this.
>
>
> > > + if (error) {
> > > + dev_err(&client->dev,
> > > + "error in sending I2C messages for
> > calibration: %d\n",
> > > + error);
> > > + return error;
> >
> > If we just return like you do it here, interrupts will stay disabled and
> > touchscreen will be completely dead. With the old code we'd report
> > timeout on calibration, and touchscreen would have chance of working. We
> > would also be able to retry calibration.
> >
>
> How about this: we print out the error message but still continue the
> following execution?
Yes, we could do dev_warn() here, but elants_i2c_send() already logs
errors, so I do not see much benefit from doing this.
> Also, if elants_i2c_send() fails,
> would wait_for_completion_interruptible_timeout() always capture a timeout?
Well, if controller does not get the calibration command(s) it will not
do anything and at worst in <timeout> time
wait_for_completion_interruptible_timeout() will return and we will
properly report this condition.
Another option is to rearrange the code to ensure we are not leaving
interrupts disabled on error.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH] input: drv2667: fix indentation issues, remove extra tabs
From: Dmitry Torokhov @ 2018-12-22 1:01 UTC (permalink / raw)
To: Colin King; +Cc: linux-input, kernel-janitors, linux-kernel
In-Reply-To: <20181221231241.15925-1-colin.king@canonical.com>
On Fri, Dec 21, 2018 at 11:12:41PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> There are some statements that are indented incorrectly, fix this by
> removinf the extra tabs.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied, thank you.
> ---
> drivers/input/misc/drv2667.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/misc/drv2667.c b/drivers/input/misc/drv2667.c
> index 2849bb6906a8..6091f0490e8f 100644
> --- a/drivers/input/misc/drv2667.c
> +++ b/drivers/input/misc/drv2667.c
> @@ -177,9 +177,9 @@ static int drv2667_set_waveform_freq(struct drv2667_data *haptics)
> error = regmap_write(haptics->regmap, DRV2667_PAGE, read_buf);
> if (error) {
> dev_err(&haptics->client->dev,
> - "Failed to set the page: %d\n", error);
> - return -EIO;
> - }
> + "Failed to set the page: %d\n", error);
> + return -EIO;
> + }
> }
>
> return error;
> --
> 2.19.1
>
--
Dmitry
^ permalink raw reply
* [PATCH] input/touchscreen: Fix a missing check on regmap_bulk_read
From: Aditya Pakki @ 2018-12-24 18:37 UTC (permalink / raw)
To: pakki001
Cc: kjlu, Michael Hennerich, Dmitry Torokhov, linux-input,
linux-kernel
regmap_bulk_read() can return a non zero value on failure. The fix
checks if the function call succeeded before calling mod_timer.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
drivers/input/touchscreen/ad7879.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index 6bad23ee47a1..735cb4c0d913 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -247,11 +247,12 @@ static void ad7879_timer(struct timer_list *t)
static irqreturn_t ad7879_irq(int irq, void *handle)
{
struct ad7879 *ts = handle;
+ int ret;
- regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
- ts->conversion_data, AD7879_NR_SENSE);
+ ret = regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
+ ts->conversion_data, AD7879_NR_SENSE);
- if (!ad7879_report(ts))
+ if (!ret && !ad7879_report(ts))
mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
return IRQ_HANDLED;
--
2.17.1
^ permalink raw reply related
* [PATCH] hid: Add checks to fix of_led_classdev_register
From: Aditya Pakki @ 2018-12-24 21:39 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel
In lenovo_probe_tpkbd(), the function of_led_classdev_register() could
return an error value that is unchecked. The fix adds these checks.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
drivers/hid/hid-lenovo.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 643b6eb54442..eacc76d2ab96 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -743,7 +743,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
data_pointer->led_mute.brightness_get = lenovo_led_brightness_get_tpkbd;
data_pointer->led_mute.brightness_set = lenovo_led_brightness_set_tpkbd;
data_pointer->led_mute.dev = dev;
- led_classdev_register(dev, &data_pointer->led_mute);
+ ret = led_classdev_register(dev, &data_pointer->led_mute);
+ if (ret < 0)
+ goto err;
data_pointer->led_micmute.name = name_micmute;
data_pointer->led_micmute.brightness_get =
@@ -751,7 +753,11 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
data_pointer->led_micmute.brightness_set =
lenovo_led_brightness_set_tpkbd;
data_pointer->led_micmute.dev = dev;
- led_classdev_register(dev, &data_pointer->led_micmute);
+ ret = led_classdev_register(dev, &data_pointer->led_micmute);
+ if (ret < 0) {
+ led_classdev_unregister(&data_pointer->led_mute);
+ goto err;
+ }
lenovo_features_set_tpkbd(hdev);
--
2.17.1
^ permalink raw reply related
* [PATCH v2] touchscreen: elants: fix a missing check of return values
From: Kangjie Lu @ 2018-12-25 4:36 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Dmitry Torokhov, Greg Kroah-Hartman, Stephen Boyd,
Joe Perches, linux-input, linux-kernel
elants_i2c_send() may fail, let's check its return values. The fix does
the check and reports an error message upon the failure.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/input/touchscreen/elants_i2c.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index f2cb23121833..8ccba4ccee37 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -245,8 +245,22 @@ static int elants_i2c_calibrate(struct elants_data *ts)
ts->state = ELAN_WAIT_RECALIBRATION;
reinit_completion(&ts->cmd_done);
- elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
- elants_i2c_send(client, rek, sizeof(rek));
+ error = elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
+ if (error) {
+ dev_err(&client->dev,
+ "error in sending the w_flashkey command for calibration: %d\n",
+ error);
+ enable_irq(client->irq);
+ return error;
+ }
+ error = elants_i2c_send(client, rek, sizeof(rek));
+ if (error) {
+ dev_err(&client->dev,
+ "error in sending the rek command for calibration: %d\n",
+ error);
+ enable_irq(client->irq);
+ return error;
+ }
enable_irq(client->irq);
--
2.17.2 (Apple Git-113)
^ permalink raw reply related
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