[PATCH] hid-core: Avoid uninitialized buffer access

2015-09-18 Thread Darren Hart
From: Richard Purdie 

hid_connect adds various strings to the buffer but they're all
conditional. You can find circumstances where nothing would be written
to it but the kernel will still print the supposedly empty buffer with
printk. This leads to corruption on the console/in the logs.

Ensure buf is initialized to an empty string.

Signed-off-by: Richard Purdie 
[dvhart: Initialize string to "" rather than assign buf[0] = NULL;]
Cc: Jiri Kosina 
Cc: linux-input@vger.kernel.org
Cc: sta...@vger.kernel.org
Signed-off-by: Darren Hart 
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 70a11ac..c0fbf4e 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1611,7 +1611,7 @@ int hid_connect(struct hid_device *hdev, unsigned int 
connect_mask)
"Multi-Axis Controller"
};
const char *type, *bus;
-   char buf[64];
+   char buf[64] = "";
unsigned int i;
int len;
int ret;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v3] Add generic driver for Silead tochscreens

2015-09-18 Thread Tirdea, Irina


> -Original Message-
> From: linux-input-ow...@vger.kernel.org 
> [mailto:linux-input-ow...@vger.kernel.org] On Behalf Of Robert Dolca
> Sent: 26 August, 2015 0:32
> To: linux-input@vger.kernel.org
> Cc: linux-ker...@vger.kernel.org; Dmitry Torokhov; Henrik Rydberg; Gregor 
> Riepl; Dolca, Robert
> Subject: [PATCH v3] Add generic driver for Silead tochscreens
> 
> This driver adds support for Silead touchscreens. It has been tested
> with GSL1680 and GSL3680 touch panels.
> 
> It supports ACPI and device tree enumeration. Screen resolution,
> the maximum number of fingers supported and firmware name are
> configurable using ACPI/DT properties.
> 
> If the device properties are not present it falls back to using defaults:
>  - x 4095
>  - y 4095
>  - max fingers 10
>  - firmware name [HID/name].fw
> 
> If there is no named GPIO for power it falls back to using an indexed GPIO
> and it requests the GPIO pin with index 1. If there isn't one it disables
> PM support.
> 
> All the hardware variants tested report finger id 0 for all fingers so
> the finger tracking is done using the input subsystem's slot assignment.
> 
> Signed-off-by: Robert Dolca 

Hi Robert,

The code looks good, just a couple of comments below.

> ---
> Changes since v2
> - removed device properties requirements
> - max x and y default to 4095
> - max fingers default to 10
> - firmware name uses the HID / device name
> - power named GPIO optional with fallback to indexed GPIO
>   (without it there is no pm support in the driver)
> - finger tracking in the kernel using slot assignment
> - add device property for x/y inverting and xy swaping
> 
> Changes since v1
> - changed device tree properties names
> - removed cast for `void *id`
> - removed ifdef from suspend and resume and use __maybe_unused
> - remove ifdef from ACPI_PTR
> - renamed ret to error
> - removed input_set_capability for EV_ABS
> - fixed endianess issues
> - added mask for y in order to use only 12 bits
> - using the 4 MSb for touch ID instead of LSb (bug)
> - using the 4 LSB for X instead of MSb (bug)
> 
> 
> 
>  drivers/input/touchscreen/Kconfig  |  12 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/silead.c | 635 
> +
>  3 files changed, 648 insertions(+)
>  create mode 100644 drivers/input/touchscreen/silead.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 80f6386..05fda4a 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -1027,4 +1027,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
> 
> +config TOUCHSCREEN_SILEAD
> + tristate "Silead I2C touchscreen"
> + depends on I2C
> + help
> +   Say Y here if you have the Silead touchscreen connected to
> +   your system.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called silead.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 44deea7..2c6beaa 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -84,3 +84,4 @@ obj-$(CONFIG_TOUCHSCREEN_W90X900)   += w90p910_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o
>  obj-$(CONFIG_TOUCHSCREEN_TPS6507X)   += tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_SILEAD) += silead.o
> diff --git a/drivers/input/touchscreen/silead.c 
> b/drivers/input/touchscreen/silead.c
> new file mode 100644
> index 000..5339f93
> --- /dev/null
> +++ b/drivers/input/touchscreen/silead.c
> @@ -0,0 +1,635 @@
> +/* -
> + * Copyright (C) 2014-2015, Intel Corporation
> + *
> + * Derived from:
> + *  gslX68X.c
> + *  Copyright (C) 2010-2015, Shanghai Sileadinc Co.Ltd
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + * - 
> */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define SILEAD_TS_NAME "silead_ts"
> +
> +#define SILEAD_REG_RESET 0xE0
> +#define SILEAD_REG_DATA  0x80
> +#define SILEAD_REG_TOUCH_N

[PATCH v6] input: Add ROHM BU21023/24 Dual touch support resistive touchscreens

2015-09-18 Thread Yoichi Yuasa
v6 Changes:
- fix touch contact counts
- fix race condition in firmware load
- add IRQF_ONESHOT
- fix inv_y sysfs attribute

 Dmitry Torokhov 
- brush up error handling
- add const to threshold arrays
- brush up firmware load
- fix race condition in sysfs attributes
- separate power_off function
- module license to "GPL v2"

v5 Changes:
- contact count variables move to array
- remove unneeded u16 casts in #define
- remove module parameters
- handle "no fingers" as same as others
- move devm_request_thread_irq() from open() to probe()
- move "power off" from remove() to close()

v4 Changes:
- remove inline
- master_xfer checks in probe()
- rewrite rohm_i2c_burst_read()
- rohm_i2c_burst_read() transfer error returns -EIO
- remove unused module parameters
- fix prev_touch_report update
- pass NULL to hard_irq
- per-device parameters use sysfs
- fix errno
- header file is taken in .c

v3 Changes:
- fix multi touch slots initialization
- fix set_bit BTN_TOUCH
- remove input_unregister_device()
- switch to __set_bit()

v2 Changes:
- remove polling mode
- switch to threaded interrupt
- switch to managed resources
- use MT-B protocol with input_mt_assign_slots
- provide ST emulation
- firmware load and device initialization are shifted at opening the
  device
- add error handling for IO operations

Signed-off-by: Yoichi Yuasa 
---
 drivers/input/touchscreen/Kconfig|   11 +
 drivers/input/touchscreen/Makefile   |1 +
 drivers/input/touchscreen/rohm_bu21023.c | 1211 ++
 3 files changed, 1223 insertions(+)
 create mode 100644 drivers/input/touchscreen/rohm_bu21023.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 600dcce..db8a923 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -1064,4 +1064,15 @@ config TOUCHSCREEN_COLIBRI_VF50
  To compile this driver as a module, choose M here: the
  module will be called colibri_vf50_ts.
 
+config TOUCHSCREEN_ROHM_BU21023
+   tristate "ROHM BU21023/24 Dual touch support resistive touchscreens"
+   depends on I2C
+   help
+ Say Y here if you have a touchscreen using ROHM BU21023/24.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called bu21023_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 1b79cc0..9a3c961 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -87,3 +87,4 @@ obj-$(CONFIG_TOUCHSCREEN_SX8654)  += sx8654.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
 obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50) += colibri-vf50-ts.o
+obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o
diff --git a/drivers/input/touchscreen/rohm_bu21023.c 
b/drivers/input/touchscreen/rohm_bu21023.c
new file mode 100644
index 000..9a509c0
--- /dev/null
+++ b/drivers/input/touchscreen/rohm_bu21023.c
@@ -0,0 +1,1211 @@
+/*
+ * ROHM BU21023/24 Dual touch support resistive touch screen driver
+ * Copyright (C) 2012 ROHM CO.,LTD.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define BU21023_NAME   "bu21023_ts"
+#define BU21023_FIRMWARE_NAME  "bu21023.bin"
+
+#define MAX_CONTACTS   2
+
+#define AXIS_ADJUST4
+#define AXIS_OFFSET8
+
+#define FIRMWARE_BLOCK_SIZE32U
+#define FIRMWARE_RETRY_MAX 4
+
+#define SAMPLING_DELAY 12  /* msec */
+
+#define CALIBRATION_RETRY_MAX  6
+
+#define ROHM_TS_ABS_X_MIN  40
+#define ROHM_TS_ABS_X_MAX  990
+#define ROHM_TS_ABS_Y_MIN  160
+#define ROHM_TS_ABS_Y_MAX  920
+#define ROHM_TS_DISPLACEMENT_MAX   0   /* zero for infinite */
+
+/*
+ * BU21023GUL/BU21023MUV/BU21024FV-M registers map
+ */
+#define VADOUT_YP_H0x00
+#define VADOUT_YP_L0x01
+#define VADOUT_XP_H0x02
+#define VADOUT_XP_L0x03
+#define VADOUT_YN_H0x04
+#define VADOUT_YN_L0x05
+#define VADOUT_XN_H0x06
+#define VADOUT_XN_L0x07
+
+#define PRM1_X_H   0x08
+#define PRM1_X_L   0x09
+#define PRM1_Y_H   0x0a
+#define PRM1_Y_L   0x0b
+#define PRM2_X_H   0x0c
+#define PRM2_X_L

[PATCH v2] elan_i2c - Don't require known iap version

2015-09-18 Thread Daniel Drake
The Asus X456UA has an ELAN1000 touchpad with IAP version 0xe.
This is unknown to elan_get_fwinfo() so driver probe fails and I
am left with an unusable touchpad.

However, the fwinfo is not required for general driver usage,
it is only needed if the user decides to upload new firmware.

Adjust the driver so that fwinfo is only calculated and used
when it is really needed.

Signed-off-by: Daniel Drake 
---
 drivers/input/mouse/elan_i2c_core.c | 33 +
 1 file changed, 17 insertions(+), 16 deletions(-)

v2: simplified dev_err call

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index fa94530..bababfe 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -84,8 +84,6 @@ struct elan_tp_data {
int pressure_adjustment;
u8  mode;
u8  ic_type;
-   u16 fw_validpage_count;
-   u16 fw_signature_address;
 
boolirq_wake;
 
@@ -264,14 +262,6 @@ static int elan_query_device_info(struct elan_tp_data 
*data)
if (error)
return error;
 
-   error = elan_get_fwinfo(data->iap_version, &data->fw_validpage_count,
-   &data->fw_signature_address);
-   if (error) {
-   dev_err(&data->client->dev,
-   "unknown iap version %d\n", data->iap_version);
-   return error;
-   }
-
return 0;
 }
 
@@ -339,7 +329,8 @@ static int elan_write_fw_block(struct elan_tp_data *data,
 }
 
 static int __elan_update_firmware(struct elan_tp_data *data,
- const struct firmware *fw)
+ const struct firmware *fw,
+ u16 fw_validpage_count)
 {
struct i2c_client *client = data->client;
struct device *dev = &client->dev;
@@ -356,7 +347,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
iap_start_addr = get_unaligned_le16(&fw->data[ETP_IAP_START_ADDR * 2]);
 
boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
-   for (i = boot_page_count; i < data->fw_validpage_count; i++) {
+   for (i = boot_page_count; i < fw_validpage_count; i++) {
u16 checksum = 0;
const u8 *page = &fw->data[i * ETP_FW_PAGE_SIZE];
 
@@ -393,7 +384,8 @@ static int __elan_update_firmware(struct elan_tp_data *data,
 }
 
 static int elan_update_firmware(struct elan_tp_data *data,
-   const struct firmware *fw)
+   const struct firmware *fw,
+   u16 fw_validpage_count)
 {
struct i2c_client *client = data->client;
int retval;
@@ -403,7 +395,7 @@ static int elan_update_firmware(struct elan_tp_data *data,
disable_irq(client->irq);
data->in_fw_update = true;
 
-   retval = __elan_update_firmware(data, fw);
+   retval = __elan_update_firmware(data, fw, fw_validpage_count);
if (retval) {
dev_err(&client->dev, "firmware update failed: %d\n", retval);
data->ops->iap_reset(client);
@@ -485,6 +477,15 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
int error;
const u8 *fw_signature;
static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF};
+   u16 fw_validpage_count;
+   u16 fw_signature_address;
+
+   error = elan_get_fwinfo(data->iap_version, &fw_validpage_count,
+   &fw_signature_address);
+   if (error) {
+   dev_err(dev, "unknown iap version %d\n", data->iap_version);
+   return error;
+   }
 
/* Look for a firmware with the product id appended. */
fw_name = kasprintf(GFP_KERNEL, ETP_FW_NAME, data->product_id);
@@ -502,7 +503,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
}
 
/* Firmware file must match signature data */
-   fw_signature = &fw->data[data->fw_signature_address];
+   fw_signature = &fw->data[fw_signature_address];
if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {
dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n",
(int)sizeof(signature), signature,
@@ -515,7 +516,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
if (error)
goto out_release_fw;
 
-   error = elan_update_firmware(data, fw);
+   error = elan_update_firmware(data, fw, fw_validpage_count);
 
mutex_unlock(&data->sysfs_mutex);
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] HID: multitouch: Add quirk for N-trig (1b96:1B05)

2015-09-18 Thread Benjamin Tissoires
[re-adding the lists, I went off-list to clarify]

On Fri, Sep 18, 2015 at 9:12 AM, Daniel Martin  wrote:
> On 18 September 2015 at 13:54, Benjamin Tissoires
>  wrote:
>> On Fri, Sep 18, 2015 at 7:50 AM, Daniel Martin  
>> wrote:
>>> What's the problem with last minute fixes, which look so simple that
>>> they can't cause any harm?
>>> ... This patch is discarded! :/
>>
>> Either I am missing something, either you misinterpret me. I never
>> said that your patch should be discarded.
>>
>> Could you elaborate a little bit more (by setting the context) please?
>
> With this patch (including my last minute changes) we may end up with
> stuck ghost touches.
>
> - We have to increase num_received in mt_complete_slot() if we see and
> skip a suspicious contact. Otherwise we don't send the sync report
> when necessary. Atm. we just return.
> - But, then I noticed that even this is not sufficient. I had to add
> MT_QUIRK_NOT_SEEN_MEANS_UP. Which bugs me, cause the reports looked
> okay - I always saw a tipswitch=0. Either I didn't saw it or there's
> another problem in the slot number computation.
>
> For now, I'm going home and take some homework with me.
>
> Cheers,
> Daniel
>
> PS: With my last minute changes I removed an obvious facepalm, which
> looked okay at the beginning, though ...
> slotnum = contactid % maxcontacts can't be right. ;)

OK thanks for the explanations. Jiri, please note not to pull this one :)

Cheers,
Benjamin
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] HID: multitouch: Add quirk for N-trig (1b96:1B05)

2015-09-18 Thread Donavan Lance
On Fri, Sep 18, 2015 at 7:50 AM, Daniel Martin  wrote:
> What's the problem with last minute fixes, which look so simple that
> they can't cause any harm?
> ... This patch is discarded! :/

Can you expand on this? I have a Surface Pro 3 and maintain a custom
patched kernel for Fedora users that use Surface Pro 3's. Is the patch
no longer beneficial?
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] HID: multitouch: Add quirk for N-trig (1b96:1B05)

2015-09-18 Thread Daniel Martin
What's the problem with last minute fixes, which look so simple that
they can't cause any harm?
... This patch is discarded! :/
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Input: omap-keypad: fix memory leak

2015-09-18 Thread Sudip Mukherjee
If omap4_keypad_parse_dt() fails we returned the error code but we
missed releasing keypad_data.

Signed-off-by: Sudip Mukherjee 
---
 drivers/input/keyboard/omap4-keypad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/omap4-keypad.c 
b/drivers/input/keyboard/omap4-keypad.c
index b052afe..6639b2b 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -266,7 +266,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
 
error = omap4_keypad_parse_dt(&pdev->dev, keypad_data);
if (error)
-   return error;
+   goto err_free_keypad;
 
res = request_mem_region(res->start, resource_size(res), pdev->name);
if (!res) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] input: Add new sun4i-keypad driver

2015-09-18 Thread Maxime Ripard
Hi Yassin,

On Fri, Sep 18, 2015 at 10:19:55AM +1000, Yassin Jaffer wrote:
> Hi Maxime
> 
> I appreciate your time and efforts .
> 
> Do you need that rate to be enforced, or is it some leftover from the
> > allwinner BSP?
> 
> 
> I've found that clock rate works fine with the default denounce and scan
> cycle.

It was not really my point. My point was do you *need* it to operate.

And so your properties were in clock cycles?

Please use a unit indenpendant of the clock rate, like seconds or Hz
(or any multiple of them).

> By the way do you have any dev board which expose the keypad pins?

I don't think I have any.

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature