Linux Input/HID development
 help / color / mirror / Atom feed
* Re: [PATCH] HID: Debug: Add labels for HID Sensor Usages
From: Jiri Kosina @ 2014-05-26  8:37 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Reyad Attiyat, linux-iio, linux-kernel, linux-input,
	Srinivas Pandruvada
In-Reply-To: <53807397.9080807@kernel.org>

On Sat, 24 May 2014, Jonathan Cameron wrote:

> This looks reasonable to me, but I haven't checked every entry.  Also 
> Reyad, you need to sign off on the patch if you expect anyone to pick it 
> up.
> 
> Jiri, this is one for you. (note Jiri should probably have been cc'd in the
> first place as the HID maintainer - unless he specifically asked not to be).

I definitely want (and need) to be CCed on such patches, thanks for 
letting me know, Jonathan.

Reyad, please add you signoff as Jonathan said, and resend the patch 
properly to me.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: [PATCH 3/3] synaptics: Change min/max quirk table to pnp-id matching
From: Hans de Goede @ 2014-05-26 11:47 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Peter Hutterer, Benjamin Tissoires, linux-input, stable
In-Reply-To: <5379C5FD.1040401@redhat.com>

Hi Dmitry,

On 05/19/2014 10:51 AM, Hans de Goede wrote:
> Hi,
> 
> On 05/18/2014 10:35 PM, Dmitry Torokhov wrote:
>> On Fri, May 16, 2014 at 08:46:49PM +0200, Hans de Goede wrote:
>>> Most of the affected models share pnp-ids for the touchpad. So switching
>>> to pnp-ids give us 2 advantages:
>>> 1) It shrinks the quirk list
>>> 2) It will lower the new quirk addition frequency, ie the recently added W540
>>>    quirk would not have been necessary since it uses the same LEN0034 pnp ids
>>>    as other models already added before it
>>>
>>> As an added bonus it actually puts the quirk on the actual psmouse, rather then
>>> on the machine, which is technically more correct.
>>>
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>>  drivers/input/mouse/synaptics.c | 149 ++++++++++------------------------------
>>>  1 file changed, 36 insertions(+), 113 deletions(-)
>>>
>>> diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
>>> index 395ec9c..c5ec703 100644
>>> --- a/drivers/input/mouse/synaptics.c
>>> +++ b/drivers/input/mouse/synaptics.c
>>> @@ -117,6 +117,31 @@ void synaptics_reset(struct psmouse *psmouse)
>>>  }
>>>  
>>>  #ifdef CONFIG_MOUSE_PS2_SYNAPTICS
>>> +struct min_max_quirk {
>>> +	const char * const *pnp_ids;
>>> +	int x_min, x_max, y_min, y_max;
>>> +};
>>
>>
>> Why don't we define this as 1 quirk per PNP id?
>>
>> struct min_max_quirk {
>> 	const char *pnp_id;
>> 	int x_min, x_max, y_min, y_max;
>> };
>>
>> ?
> 
> 1) I thought it would be better to allow multiple ids for one min/max quad,
> since there seem to only be a few types of touchpads out there, which are
> sometimes referenced to by multiple ids. IE LEN0034 and LEN2004 refer to the
> exact same touchpad (exact same firmware and board id). Also this way we avoid
> people adding entries with values which are slightly off since determining
> the min/max range on a single model will give some noise.
> 
> 2) This way we can use one helper function for the matching for both the
> INPUT_PROP_TOPBUTTONPAD quirks and for the min/max quirks.

I've not heard back from you on this, does that mean that you are ok with
taking this patch-set as is ?

Regards,

Hans

^ permalink raw reply

* PenMount 6000 usb touch controller
From: Christian Gmeiner @ 2014-05-26 13:18 UTC (permalink / raw)
  To: linux-input

Hi.


I am using the following usb touch controller:

lsusb -s 6:2 -vvv

Bus 006 Device 002: ID 14e1:6000 Dialogue Technology Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x14e1 Dialogue Technology Corp.
  idProduct          0x6000
  bcdDevice           a4.b4
  iManufacturer           1 DIALOGUE INC
  iProduct                2 PenMount USB
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          4 full speed
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              3 EndPoint1 Interrupt Pipe
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.01
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      76
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0005  1x 5 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0005  1x 5 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)


I can successfully use this device as a hid-generic usb mouse, but I need to get
BTN_TOUCH events. What would be the best way to support this device? Shall
I extend usbtouchscreen driver?

thanks
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner

^ permalink raw reply

* [PATCH v2 0/2] Use devm_* functions for Melfas touch device.
From: Beomho Seo @ 2014-05-26 13:29 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo

This patch set devm_* functions in Melfas touche device driver.
As a result, error path and remove() function is simplified.

Changes in v2:
- Additionally use devm_kzalloc mcs_[touchkey/ts]_data struct.

Beomho Seo (2):
  Input: mcs_touchkey: use devm_* functions
  Input: mcs5000_ts: use devm_* functions.

 drivers/input/keyboard/mcs_touchkey.c  |   53 +++++++++-----------------------
 drivers/input/touchscreen/mcs5000_ts.c |   42 ++++++++-----------------
 2 files changed, 26 insertions(+), 69 deletions(-)

-- 
1.7.9.5


^ permalink raw reply

* [PATCH v2 2/2] Input: mcs5000_ts: use devm_* functions.
From: Beomho Seo @ 2014-05-26 13:29 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo
In-Reply-To: <1401110952-25602-1-git-send-email-beomho.seo@samsung.com>

This patch use devm_* functions in mcs5000_ts driver.
As, a result, error patch and remove() function is simplified.

Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
Changes in v2:
- Additionally use devm_kzalloc for mcs_ts_data struct.
---
 drivers/input/touchscreen/mcs5000_ts.c |   42 +++++++++-----------------------
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/drivers/input/touchscreen/mcs5000_ts.c b/drivers/input/touchscreen/mcs5000_ts.c
index 647e36f..6b57e28 100644
--- a/drivers/input/touchscreen/mcs5000_ts.c
+++ b/drivers/input/touchscreen/mcs5000_ts.c
@@ -196,12 +196,11 @@ static int mcs5000_ts_probe(struct i2c_client *client,
 	if (!dev_get_platdata(&client->dev))
 		return -EINVAL;
 
-	data = kzalloc(sizeof(struct mcs5000_ts_data), GFP_KERNEL);
-	input_dev = input_allocate_device();
+	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+	input_dev = devm_input_allocate_device(&client->dev);
 	if (!data || !input_dev) {
 		dev_err(&client->dev, "Failed to allocate memory\n");
-		ret = -ENOMEM;
-		goto err_free_mem;
+		return -ENOMEM;
 	}
 
 	data->client = client;
@@ -223,40 +222,24 @@ static int mcs5000_ts_probe(struct i2c_client *client,
 	if (data->platform_data->cfg_pin)
 		data->platform_data->cfg_pin();
 
-	ret = request_threaded_irq(client->irq, NULL, mcs5000_ts_interrupt,
-			IRQF_TRIGGER_LOW | IRQF_ONESHOT, "mcs5000_ts", data);
-
-	if (ret < 0) {
+	ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+			mcs5000_ts_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+			"mcs5000_ts", data);
+	if (ret) {
 		dev_err(&client->dev, "Failed to register interrupt\n");
-		goto err_free_mem;
+		return ret;
 	}
 
 	ret = input_register_device(data->input_dev);
-	if (ret < 0)
-		goto err_free_irq;
+	if (ret < 0) {
+		dev_err(&client->dev, "Failed to register input device\n");
+		return ret;
+	}
 
 	mcs5000_ts_phys_init(data);
 	i2c_set_clientdata(client, data);
 
 	return 0;
-
-err_free_irq:
-	free_irq(client->irq, data);
-err_free_mem:
-	input_free_device(input_dev);
-	kfree(data);
-	return ret;
-}
-
-static int mcs5000_ts_remove(struct i2c_client *client)
-{
-	struct mcs5000_ts_data *data = i2c_get_clientdata(client);
-
-	free_irq(client->irq, data);
-	input_unregister_device(data->input_dev);
-	kfree(data);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM
@@ -291,7 +274,6 @@ MODULE_DEVICE_TABLE(i2c, mcs5000_ts_id);
 
 static struct i2c_driver mcs5000_ts_driver = {
 	.probe		= mcs5000_ts_probe,
-	.remove		= mcs5000_ts_remove,
 	.driver = {
 		.name = "mcs5000_ts",
 #ifdef CONFIG_PM
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 1/2] Input: mcs_touchkey: use devm_* functions
From: Beomho Seo @ 2014-05-26 13:29 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo
In-Reply-To: <1401110952-25602-1-git-send-email-beomho.seo@samsung.com>

This patch use devm_* funtions in mcs_touchkey driver.
As a result, error path and remove() funtion is simplified.

Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
Changes in v2:
- Additionally use devm_kzalloc for mcs_touchkey_data struct.
---
 drivers/input/keyboard/mcs_touchkey.c |   53 +++++++++------------------------
 1 file changed, 14 insertions(+), 39 deletions(-)

diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 1da8e0b..455bd62 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -103,7 +103,6 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 	struct mcs_touchkey_data *data;
 	struct input_dev *input_dev;
 	unsigned int fw_reg;
-	int fw_ver;
 	int error;
 	int i;
 
@@ -113,14 +112,11 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	data = kzalloc(sizeof(struct mcs_touchkey_data) +
-			sizeof(data->keycodes[0]) * (pdata->key_maxval + 1),
-			GFP_KERNEL);
-	input_dev = input_allocate_device();
+	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+	input_dev = devm_input_allocate_device(&client->dev);
 	if (!data || !input_dev) {
 		dev_err(&client->dev, "Failed to allocate memory\n");
-		error = -ENOMEM;
-		goto err_free_mem;
+		return -ENOMEM;
 	}
 
 	data->client = client;
@@ -139,13 +135,12 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 		fw_reg = MCS5080_TOUCHKEY_FW;
 	}
 
-	fw_ver = i2c_smbus_read_byte_data(client, fw_reg);
-	if (fw_ver < 0) {
-		error = fw_ver;
+	error = i2c_smbus_read_byte_data(client, fw_reg);
+	if (error < 0) {
 		dev_err(&client->dev, "i2c read error[%d]\n", error);
-		goto err_free_mem;
-	}
-	dev_info(&client->dev, "Firmware version: %d\n", fw_ver);
+		return error;
+	} else
+		dev_info(&client->dev, "Firmware version: %d\n", error);
 
 	input_dev->name = "MELPAS MCS Touchkey";
 	input_dev->id.bustype = BUS_I2C;
@@ -176,40 +171,21 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 		data->poweron(true);
 	}
 
-	error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
-				     IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
-				     client->dev.driver->name, data);
+	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+			mcs_touchkey_interrupt,	IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+			dev_name(&client->dev), data);
 	if (error) {
 		dev_err(&client->dev, "Failed to register interrupt\n");
-		goto err_free_mem;
+		return error;
 	}
 
 	error = input_register_device(input_dev);
 	if (error)
-		goto err_free_irq;
+		dev_err(&client->dev, "Failed to register input device\n");
+		return error;
 
 	i2c_set_clientdata(client, data);
 	return 0;
-
-err_free_irq:
-	free_irq(client->irq, data);
-err_free_mem:
-	input_free_device(input_dev);
-	kfree(data);
-	return error;
-}
-
-static int mcs_touchkey_remove(struct i2c_client *client)
-{
-	struct mcs_touchkey_data *data = i2c_get_clientdata(client);
-
-	free_irq(client->irq, data);
-	if (data->poweron)
-		data->poweron(false);
-	input_unregister_device(data->input_dev);
-	kfree(data);
-
-	return 0;
 }
 
 static void mcs_touchkey_shutdown(struct i2c_client *client)
@@ -269,7 +245,6 @@ static struct i2c_driver mcs_touchkey_driver = {
 		.pm	= &mcs_touchkey_pm_ops,
 	},
 	.probe		= mcs_touchkey_probe,
-	.remove		= mcs_touchkey_remove,
 	.shutdown       = mcs_touchkey_shutdown,
 	.id_table	= mcs_touchkey_id,
 };
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
  To: linux-media
  Cc: benoit.taine, dri-devel, devel, netdev, linux-wireless, wcn36xx,
	linux-kernel, linux-usb, usb-storage, linux-scsi,
	DL-MPTFusionLinux, linux-input, kernel-janitors

These patches enhance kernel style usage, and allows smaller code while
preventing accidental code edits to produce overflows.

The semantic patch at scripts/coccinelle/api/memdup.cocci was used to
detect and edit this situation.

^ permalink raw reply

* [PATCH 16/18] HID: uhid: Use kmemdup instead of kmalloc + memcpy
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
  To: David Herrmann
  Cc: benoit.taine, Jiri Kosina, linux-input, linux-kernel,
	kernel-janitors
In-Reply-To: <1401117687-28911-1-git-send-email-benoit.taine@lip6.fr>

This issue was reported by coccicheck using the semantic patch 
at scripts/coccinelle/api/memdup.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.

 drivers/hid/uhid.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 0d078c3..0cb92e3 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -441,12 +441,11 @@ static int uhid_dev_create2(struct uhid_device *uhid,
 	if (uhid->rd_size <= 0 || uhid->rd_size > HID_MAX_DESCRIPTOR_SIZE)
 		return -EINVAL;
 
-	uhid->rd_data = kmalloc(uhid->rd_size, GFP_KERNEL);
+	uhid->rd_data = kmemdup(ev->u.create2.rd_data, uhid->rd_size,
+				GFP_KERNEL);
 	if (!uhid->rd_data)
 		return -ENOMEM;
 
-	memcpy(uhid->rd_data, ev->u.create2.rd_data, uhid->rd_size);
-
 	hid = hid_allocate_device();
 	if (IS_ERR(hid)) {
 		ret = PTR_ERR(hid);


^ permalink raw reply related

* Re: [PATCH 16/18] HID: uhid: Use kmemdup instead of kmalloc + memcpy
From: David Herrmann @ 2014-05-26 15:33 UTC (permalink / raw)
  To: Benoit Taine
  Cc: David Herrmann, Jiri Kosina, open list:HID CORE LAYER,
	linux-kernel, kernel-janitors@vger.kernel.org
In-Reply-To: <1401117687-28911-17-git-send-email-benoit.taine@lip6.fr>

Hi

On Mon, May 26, 2014 at 5:21 PM, Benoit Taine <benoit.taine@lip6.fr> wrote:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Thanks
David

> ---
> Tested by compilation without errors.
>
>  drivers/hid/uhid.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> index 0d078c3..0cb92e3 100644
> --- a/drivers/hid/uhid.c
> +++ b/drivers/hid/uhid.c
> @@ -441,12 +441,11 @@ static int uhid_dev_create2(struct uhid_device *uhid,
>         if (uhid->rd_size <= 0 || uhid->rd_size > HID_MAX_DESCRIPTOR_SIZE)
>                 return -EINVAL;
>
> -       uhid->rd_data = kmalloc(uhid->rd_size, GFP_KERNEL);
> +       uhid->rd_data = kmemdup(ev->u.create2.rd_data, uhid->rd_size,
> +                               GFP_KERNEL);
>         if (!uhid->rd_data)
>                 return -ENOMEM;
>
> -       memcpy(uhid->rd_data, ev->u.create2.rd_data, uhid->rd_size);
> -
>         hid = hid_allocate_device();
>         if (IS_ERR(hid)) {
>                 ret = PTR_ERR(hid);
>

^ permalink raw reply

* Your Urgent reply.
From: HUSAM AL SAYED @ 2014-05-26 17:58 UTC (permalink / raw)


Dear Friend,


Compliments of the day.This mail May be a surprise to you Because you
did not give me the permission to do so and Neither do you know me but
before I tell you about myself I want you to please forgive me for
sending this mail without your permission I have been in search of
someone with this last name so when I saw you online, I was pushed to
contact you and see how best we can assist each other. I am Mr. Husam
Al Sayed, a Bank Officer here in U.A.E. I believe it is the wish of
God for me to come across you now. I am having an important business
discussion I wish to share with you which I  believe will interest
you, because it is in connection with your last name and you are going
to benefit from it.

One Late peter who was among the death victims in the May 27 2006
Earthquake disaster in Java, Indonesia that killed over 5,000 people.
He was in Indonesia on a business trip and that was how he met his
end. My bank management is yet to know about his death, I knew about
it because he was my friend and I am his account officer.he did not
mention any Next of Kin/ Heir when the account was opened, and he was
not married and no children. Last week my Bank Management requested
that he should give instructions on what to do about his funds,I know
this will happen and that is why I have been looking for a means to
handle the situation,

If you are interested send me your private Email Address so that i can
send you more details of the transaction,
Thanks for your understanding

I am waiting for your reply.

Best regards,

Mr. Husam Al Sayed

^ permalink raw reply

* Re: [PATCH 20/51] Input: atmel_mxt_ts - Set default irqflags when there is no pdata
From: Yufeng Shen @ 2014-05-26 18:13 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Nick Dyer, Benson Leung, Henrik Rydberg, Daniel Kurtz,
	Joonyoung Shim, Alan Bowens, linux-input,
	linux-kernel@vger.kernel.org, Peter Meerwald, Olof Johansson
In-Reply-To: <20140526052320.GA12890@core.coreip.homeip.net>

On Mon, May 26, 2014 at 1:23 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Fri, May 23, 2014 at 12:37:46PM -0400, Yufeng Shen wrote:
> > On Thu, May 22, 2014 at 10:29 AM, Nick Dyer <nick.dyer@itdev.co.uk> wrote:
> > >
> > > Dmitry Torokhov wrote:
> > > > On Thu, Jul 18, 2013 at 07:17:44PM +0200, rydberg@euromail.se wrote:
> > > >>> From: Yufeng Shen <miletus@chromium.org>
> > > >>> This is the preparation for supporting the code path when there is
> > > >>> platform data provided and still boot the device into a sane state
> > > >>> with backup NVRAM config.
> > > >>>
> > > >>> Make the irqflags default to be IRQF_TRIGGER_FALLING if no platform data is
> > > >>> provided.
> > > >
> > > > I think if there is no platform data we should use 0 as IRQ falgs and
> > > > assume that IRQ line is properly configured by the board code or via
> > > > device tree.
> > >
> > > Beson/Yufeng - do you still have a requirement to probe without platform
> > > data or device tree? I'm just merging in some changes to add device tree
> > > support, and it would simplify things a bit if I can drop this patch.
> >
> >
> > It has been working for quite a while for boards/devices that don't
> > provide platform
> > data. If we drop the default IRQ flags, sure we can add code for each
> > board to configure
> > the IRQ separately, but that's just adding extra work. Is there strong
> > reason why we
> > should not do the default setting in the driver if it is not already
> > configured in platform
> > data ?
>
>
> I am not saying that board code needs to add platform data. I am saying
> that the board code needs to set up interrupt properly (via
> irq_set_irq_type() or similar) and then the driver can use 0 as irqflags
> argument in request_irq() in absence of DT/platform data.
>
> Thanks.
>

So my argument is mainly based on that the existing code is working (boards
that do not have platform data are relying on the driver to set the
default irq),
and change the default value would need extra work to setup the irq, say as you
suggested through irq_set_irq_type(). I am no expert in irq so it could be true
that your suggested way is indeed better. I am in favor of keeping
this patch is only
because it requires no extra change for existing code that are using it.



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

^ permalink raw reply

* Re: [PATCH 20/51] Input: atmel_mxt_ts - Set default irqflags when there is no pdata
From: Yufeng Shen @ 2014-05-26 18:17 UTC (permalink / raw)
  To: Nick Dyer
  Cc: Benson Leung, Dmitry Torokhov, Henrik Rydberg, Daniel Kurtz,
	Joonyoung Shim, Alan Bowens, linux-input,
	linux-kernel@vger.kernel.org, Peter Meerwald, Olof Johansson
In-Reply-To: <5380938E.5010408@itdev.co.uk>

On Sat, May 24, 2014 at 8:41 AM, Nick Dyer <nick.dyer@itdev.co.uk> wrote:
> Yufeng Shen wrote:
>> On Thu, May 22, 2014 at 10:29 AM, Nick Dyer <nick.dyer@itdev.co.uk> wrote:
>>> Dmitry Torokhov wrote:
>>>>>> Make the irqflags default to be IRQF_TRIGGER_FALLING if no platform data is
>>>>>> provided.
>>>>
>>>> I think if there is no platform data we should use 0 as IRQ falgs and
>>>> assume that IRQ line is properly configured by the board code or via
>>>> device tree.
>>>
>>> Benson/Yufeng - do you still have a requirement to probe without platform
>>> data or device tree? I'm just merging in some changes to add device tree
>>> support, and it would simplify things a bit if I can drop this patch.
>>
>> It has been working for quite a while for boards/devices that don't
>> provide platform data. If we drop the default IRQ flags, sure we can add
>> code for each board to configure the IRQ separately, but that's just
>> adding extra work. Is there strong reason why we should not do the
>> default setting in the driver if it is not already configured in
>> platform data?
>
> OK, I will keep it in my tree for the moment, since you are using it.
>
> The reason I checked is that in general, I would like to be conservative
> about what is pushed upstream, because it will need maintaining for a long
> time.
>
> The other reason is that in fact Atmel recommend IRQF_TRIGGER_LOW for these
> chips, not IRQF_TRIGGER_FALLING, so there is a bit of an inconsistency here.

I think I chose IRQF_TRIGGER_FALLING is because when I do a search in
the upstream
code where platform is configured, the irq is always set to be
IRQF_TRIGGER_FALLING
so I was assuming  IRQF_TRIGGER_FALLING is a safe bet.

But you would definitely know better than me on this since the atmel
chips that I have
access to are quite limited.

^ permalink raw reply

* Re: [PATCH v2 1/2] Input: mcs_touchkey: use devm_* functions
From: Dmitry Torokhov @ 2014-05-26 20:36 UTC (permalink / raw)
  To: Beomho Seo
  Cc: linux-input, jy0922.shim, sachin.kamat, myungjoo.ham, jh80.chung,
	cw00.choi
In-Reply-To: <1401110952-25602-2-git-send-email-beomho.seo@samsung.com>

Hi Beomho,

On Mon, May 26, 2014 at 10:29:11PM +0900, Beomho Seo wrote:
> This patch use devm_* funtions in mcs_touchkey driver.
> As a result, error path and remove() funtion is simplified.
> 
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> ---
> Changes in v2:
> - Additionally use devm_kzalloc for mcs_touchkey_data struct.
> ---
>  drivers/input/keyboard/mcs_touchkey.c |   53 +++++++++------------------------
>  1 file changed, 14 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
> index 1da8e0b..455bd62 100644
> --- a/drivers/input/keyboard/mcs_touchkey.c
> +++ b/drivers/input/keyboard/mcs_touchkey.c
> @@ -103,7 +103,6 @@ static int mcs_touchkey_probe(struct i2c_client *client,
>  	struct mcs_touchkey_data *data;
>  	struct input_dev *input_dev;
>  	unsigned int fw_reg;
> -	int fw_ver;
>  	int error;
>  	int i;
>  
> @@ -113,14 +112,11 @@ static int mcs_touchkey_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> -	data = kzalloc(sizeof(struct mcs_touchkey_data) +
> -			sizeof(data->keycodes[0]) * (pdata->key_maxval + 1),
> -			GFP_KERNEL);
> -	input_dev = input_allocate_device();
> +	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> +	input_dev = devm_input_allocate_device(&client->dev);
>  	if (!data || !input_dev) {
>  		dev_err(&client->dev, "Failed to allocate memory\n");
> -		error = -ENOMEM;
> -		goto err_free_mem;
> +		return -ENOMEM;
>  	}
>  
>  	data->client = client;
> @@ -139,13 +135,12 @@ static int mcs_touchkey_probe(struct i2c_client *client,
>  		fw_reg = MCS5080_TOUCHKEY_FW;
>  	}
>  
> -	fw_ver = i2c_smbus_read_byte_data(client, fw_reg);
> -	if (fw_ver < 0) {
> -		error = fw_ver;
> +	error = i2c_smbus_read_byte_data(client, fw_reg);

You are not reading error code, you are reading firmware version. I am
not sure why you are changing this code.

> +	if (error < 0) {
>  		dev_err(&client->dev, "i2c read error[%d]\n", error);
> -		goto err_free_mem;
> -	}
> -	dev_info(&client->dev, "Firmware version: %d\n", fw_ver);
> +		return error;
> +	} else
> +		dev_info(&client->dev, "Firmware version: %d\n", error);
>  
>  	input_dev->name = "MELPAS MCS Touchkey";
>  	input_dev->id.bustype = BUS_I2C;
> @@ -176,40 +171,21 @@ static int mcs_touchkey_probe(struct i2c_client *client,
>  		data->poweron(true);
>  	}
>  
> -	error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
> -				     IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> -				     client->dev.driver->name, data);
> +	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
> +			mcs_touchkey_interrupt,	IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> +			dev_name(&client->dev), data);

The original code was attaching driver name to the IRQ, now you are
attaching device name. Why? I am not against it per se, but it needs to
be a separate patch with its own justification.

>  	if (error) {
>  		dev_err(&client->dev, "Failed to register interrupt\n");
> -		goto err_free_mem;
> +		return error;
>  	}
>  
>  	error = input_register_device(input_dev);
>  	if (error)
> -		goto err_free_irq;
> +		dev_err(&client->dev, "Failed to register input device\n");
> +		return error;
>  
>  	i2c_set_clientdata(client, data);
>  	return 0;
> -
> -err_free_irq:
> -	free_irq(client->irq, data);
> -err_free_mem:
> -	input_free_device(input_dev);
> -	kfree(data);
> -	return error;
> -}
> -
> -static int mcs_touchkey_remove(struct i2c_client *client)
> -{
> -	struct mcs_touchkey_data *data = i2c_get_clientdata(client);
> -
> -	free_irq(client->irq, data);
> -	if (data->poweron)
> -		data->poweron(false);

Why aren't you powering down the chip anymore?

> -	input_unregister_device(data->input_dev);
> -	kfree(data);
> -
> -	return 0;
>  }
>  
>  static void mcs_touchkey_shutdown(struct i2c_client *client)
> @@ -269,7 +245,6 @@ static struct i2c_driver mcs_touchkey_driver = {
>  		.pm	= &mcs_touchkey_pm_ops,
>  	},
>  	.probe		= mcs_touchkey_probe,
> -	.remove		= mcs_touchkey_remove,
>  	.shutdown       = mcs_touchkey_shutdown,
>  	.id_table	= mcs_touchkey_id,
>  };
> -- 
> 1.7.9.5
> 

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 16/18] HID: uhid: Use kmemdup instead of kmalloc + memcpy
From: Jiri Kosina @ 2014-05-26 22:42 UTC (permalink / raw)
  To: Benoit Taine; +Cc: David Herrmann, linux-input, linux-kernel, kernel-janitors
In-Reply-To: <1401117687-28911-17-git-send-email-benoit.taine@lip6.fr>

On Mon, 26 May 2014, Benoit Taine wrote:

> This issue was reported by coccicheck using the semantic patch 
> at scripts/coccinelle/api/memdup.cocci
> 
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>

Applied, thanks Benoit.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply

* [PATCHv2] HID: Debug: Add labels for HID Sensor Usages
From: Reyad Attiyat @ 2014-05-27  7:10 UTC (permalink / raw)
  To: linux-kernel, jic23, linux-input, jkosina; +Cc: Reyad Attiyat

Add in debugfs report descriptor labels for HID Sensor Usages.

Signed-off-by: Reyad Attiyat <reyad.attiyat@gmail.com>
---
 drivers/hid/hid-debug.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 53b771d..25cc71c 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -272,6 +272,85 @@ static const struct hid_usage_entry hid_usage_table[] = {
     {0, 0xAA, "Shared_Parameter_Blocks"},
     {0, 0xAB, "Create_New_Effect_Report"},
     {0, 0xAC, "RAM_Pool_Available"},
+  {  0x20, 0, "Sensor" },
+    { 0x20, 0x01, "Sensor" },
+    { 0x20, 0x10, "Biometric" },
+      { 0x20, 0x11, "BiometricHumanPresence" },
+      { 0x20, 0x12, "BiometricHumanProximity" },
+      { 0x20, 0x13, "BiometricHumanTouch" },
+    { 0x20, 0x20, "Electrical" },
+      { 0x20, 0x21, "ElectricalCapacitance" },
+      { 0x20, 0x22, "ElectricalCurrent" },
+      { 0x20, 0x23, "ElectricalPower" },
+      { 0x20, 0x24, "ElectricalInductance" },
+      { 0x20, 0x25, "ElectricalResistance" },
+      { 0x20, 0x26, "ElectricalVoltage" },
+      { 0x20, 0x27, "ElectricalPoteniometer" },
+      { 0x20, 0x28, "ElectricalFrequency" },
+      { 0x20, 0x29, "ElectricalPeriod" },
+    { 0x20, 0x30, "Environmental" },
+      { 0x20, 0x31, "EnvironmentalAtmosphericPressure" },
+      { 0x20, 0x32, "EnvironmentalHumidity" },
+      { 0x20, 0x33, "EnvironmentalTemperature" },
+      { 0x20, 0x34, "EnvironmentalWindDirection" },
+      { 0x20, 0x35, "EnvironmentalWindSpeed" },
+    { 0x20, 0x40, "Light" },
+      { 0x20, 0x41, "LightAmbientLight" },
+      { 0x20, 0x42, "LightConsumerInfrared" },
+    { 0x20, 0x50, "Location" },
+      { 0x20, 0x51, "LocationBroadcast" },
+      { 0x20, 0x52, "LocationDeadReckoning" },
+      { 0x20, 0x53, "LocationGPS" },
+      { 0x20, 0x54, "LocationLookup" },
+      { 0x20, 0x55, "LocationOther" },
+      { 0x20, 0x56, "LocationStatic" },
+      { 0x20, 0x57, "LocationTriangulation" },
+    { 0x20, 0x60, "Mechanical" },
+      { 0x20, 0x61, "MechanicalBooleanSwitch" },
+      { 0x20, 0x62, "MechanicalBooleanSwitchArray" },
+      { 0x20, 0x63, "MechanicalMultivalueSwitch" },
+      { 0x20, 0x64, "MechanicalForce" },
+      { 0x20, 0x65, "MechanicalPressure" },
+      { 0x20, 0x66, "MechanicalStrain" },
+      { 0x20, 0x67, "MechanicalWeight" },
+      { 0x20, 0x68, "MechanicalHapticVibrator" },
+      { 0x20, 0x69, "MechanicalHallEffectSwitch" },
+    { 0x20, 0x70, "Motion" },
+      { 0x20, 0x71, "MotionAccelerometer1D" },
+      { 0x20, 0x72, "MotionAccelerometer2D" },
+      { 0x20, 0x73, "MotionAccelerometer3D" },
+      { 0x20, 0x74, "MotionGyrometer1D" },
+      { 0x20, 0x75, "MotionGyrometer2D" },
+      { 0x20, 0x76, "MotionGyrometer3D" },
+      { 0x20, 0x77, "MotionMotionDetector" },
+      { 0x20, 0x78, "MotionSpeedometer" },
+      { 0x20, 0x79, "MotionAccelerometer" },
+      { 0x20, 0x7A, "MotionGyrometer" },
+    { 0x20, 0x80, "Orientation" },
+      { 0x20, 0x81, "OrientationCompass1D" },
+      { 0x20, 0x82, "OrientationCompass2D" },
+      { 0x20, 0x83, "OrientationCompass3D" },
+      { 0x20, 0x84, "OrientationInclinometer1D" },
+      { 0x20, 0x85, "OrientationInclinometer2D" },
+      { 0x20, 0x86, "OrientationInclinometer3D" },
+      { 0x20, 0x87, "OrientationDistance1D" },
+      { 0x20, 0x88, "OrientationDistance2D" },
+      { 0x20, 0x89, "OrientationDistance3D" },
+      { 0x20, 0x8A, "OrientationDeviceOrientation" },
+      { 0x20, 0x8B, "OrientationCompass" },
+      { 0x20, 0x8C, "OrientationInclinometer" },
+      { 0x20, 0x8D, "OrientationDistance" },
+    { 0x20, 0x90, "Scanner" },
+      { 0x20, 0x91, "ScannerBarcode" },
+      { 0x20, 0x91, "ScannerRFID" },
+      { 0x20, 0x91, "ScannerNFC" },
+    { 0x20, 0xA0, "Time" },
+      { 0x20, 0xA1, "TimeAlarmTimer" },
+      { 0x20, 0xA2, "TimeRealTimeClock" },
+    { 0x20, 0xE0, "Other" },
+      { 0x20, 0xE1, "OtherCustom" },
+      { 0x20, 0xE2, "OtherGeneric" },
+      { 0x20, 0xE3, "OtherGenericEnumerator" },
   { 0x84, 0, "Power Device" },
     { 0x84, 0x02, "PresentStatus" },
     { 0x84, 0x03, "ChangeStatus" },
-- 
1.9.0


^ permalink raw reply related

* [PATCH] HID: hid-sensor-hub: Set report quirk for Microsoft Surface
From: Reyad Attiyat @ 2014-05-27  7:29 UTC (permalink / raw)
  To: linux-kernel, linux-input, jkosina; +Cc: Reyad Attiyat

Add the Microsoft Surface Pro 2 Type/Touch and default device hardware ID's
Set report quirk for the device in hid-sensor-hub

Signed-off-by: Reyad Attiyat <reyad.attiyat@gmail.com>
---
 drivers/hid/hid-ids.h        | 3 +++
 drivers/hid/hid-sensor-hub.c | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 34bb220..18e2099 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -633,6 +633,9 @@
 #define USB_DEVICE_ID_MS_PRESENTER_8K_USB	0x0713
 #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K	0x0730
 #define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500	0x076c
+#define USB_DEVICE_ID_MS_SURFACE_PRO_2   0x0799
+#define USB_DEVICE_ID_MS_TOUCH_COVER_2   0x07a7
+#define USB_DEVICE_ID_MS_TYPE_COVER_2    0x07a9
 
 #define USB_VENDOR_ID_MOJO		0x8282
 #define USB_DEVICE_ID_RETRO_ADAPTER	0x3201
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index be14b56..eefaaf6 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -711,6 +711,15 @@ static const struct hid_device_id sensor_hub_devices[] = {
 	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_TEXAS_INSTRUMENTS,
 			USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA),
 			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
+	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
+			USB_DEVICE_ID_MS_SURFACE_PRO_2),
+			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
+	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
+			USB_DEVICE_ID_MS_TOUCH_COVER_2),
+			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
+	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
+			USB_DEVICE_ID_MS_TYPE_COVER_2),
+			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
 	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID,
 		     HID_ANY_ID) },
 	{ }
-- 
1.9.0


^ permalink raw reply related

* [PATCH v3 0/2] Use devm_* functions for Melfas touch device.
From: Beomho Seo @ 2014-05-27 11:06 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo

This patch set devm_* functions in Melfas touche device driver.
As a result, error path and remove() function is simplified.

Changes in v3:
- mcs_touchkey: Some codes are back again.

Changes in v2:
- Additionally use devm_kzalloc mcs_[touchkey/ts]_data struct.

Beomho Seo (2):
  Input: mcs_touchkey: use devm_* functions
  Input: mcs5000_ts: use devm_* functions.

 drivers/input/keyboard/mcs_touchkey.c  |   32 ++++++++----------------
 drivers/input/touchscreen/mcs5000_ts.c |   42 +++++++++-----------------------
 2 files changed, 22 insertions(+), 52 deletions(-)

-- 
1.7.9.5


^ permalink raw reply

* [PATCH v3 1/2] Input: mcs_touchkey: use devm_* functions
From: Beomho Seo @ 2014-05-27 11:06 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo
In-Reply-To: <1401188787-32173-1-git-send-email-beomho.seo@samsung.com>

This patch use devm_* funtions in mcs_touchkey driver.
As a result, error path and remove() funtion is simplified.

Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
Changes in v3:
- Some codes are back again. use fw_version, driver name and poweron.
Changes in v2:
- Additionally use devm_kzalloc for mcs_touchkey_data struct.
---
 drivers/input/keyboard/mcs_touchkey.c |   32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 1da8e0b..bf2f785 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -113,14 +113,11 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	data = kzalloc(sizeof(struct mcs_touchkey_data) +
-			sizeof(data->keycodes[0]) * (pdata->key_maxval + 1),
-			GFP_KERNEL);
-	input_dev = input_allocate_device();
+	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+	input_dev = devm_input_allocate_device(&client->dev);
 	if (!data || !input_dev) {
 		dev_err(&client->dev, "Failed to allocate memory\n");
-		error = -ENOMEM;
-		goto err_free_mem;
+		return -ENOMEM;
 	}
 
 	data->client = client;
@@ -143,7 +140,7 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 	if (fw_ver < 0) {
 		error = fw_ver;
 		dev_err(&client->dev, "i2c read error[%d]\n", error);
-		goto err_free_mem;
+		return error;
 	}
 	dev_info(&client->dev, "Firmware version: %d\n", fw_ver);
 
@@ -176,38 +173,29 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 		data->poweron(true);
 	}
 
-	error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
-				     IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
-				     client->dev.driver->name, data);
+	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+				mcs_touchkey_interrupt,	IRQF_TRIGGER_FALLING |
+				IRQF_ONESHOT, client->dev.driver->name, data);
 	if (error) {
 		dev_err(&client->dev, "Failed to register interrupt\n");
-		goto err_free_mem;
+		return error;
 	}
 
 	error = input_register_device(input_dev);
 	if (error)
-		goto err_free_irq;
+		dev_err(&client->dev, "Failed to register input device\n");
+		return error;
 
 	i2c_set_clientdata(client, data);
 	return 0;
-
-err_free_irq:
-	free_irq(client->irq, data);
-err_free_mem:
-	input_free_device(input_dev);
-	kfree(data);
-	return error;
 }
 
 static int mcs_touchkey_remove(struct i2c_client *client)
 {
 	struct mcs_touchkey_data *data = i2c_get_clientdata(client);
 
-	free_irq(client->irq, data);
 	if (data->poweron)
 		data->poweron(false);
-	input_unregister_device(data->input_dev);
-	kfree(data);
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v3 2/2] Input: mcs5000_ts: use devm_* functions.
From: Beomho Seo @ 2014-05-27 11:06 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo
In-Reply-To: <1401188787-32173-1-git-send-email-beomho.seo@samsung.com>

This patch use devm_* functions in mcs5000_ts driver.
As, a result, error patch and remove() function is simplified.

Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
Changes in v3:
- None.
Changes in v2:
- Additionally use devm_kzalloc for mcs_ts_data struct.
---

 drivers/input/touchscreen/mcs5000_ts.c |   42 +++++++++-----------------------
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/drivers/input/touchscreen/mcs5000_ts.c b/drivers/input/touchscreen/mcs5000_ts.c
index 647e36f..6b57e28 100644
--- a/drivers/input/touchscreen/mcs5000_ts.c
+++ b/drivers/input/touchscreen/mcs5000_ts.c
@@ -196,12 +196,11 @@ static int mcs5000_ts_probe(struct i2c_client *client,
 	if (!dev_get_platdata(&client->dev))
 		return -EINVAL;
 
-	data = kzalloc(sizeof(struct mcs5000_ts_data), GFP_KERNEL);
-	input_dev = input_allocate_device();
+	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+	input_dev = devm_input_allocate_device(&client->dev);
 	if (!data || !input_dev) {
 		dev_err(&client->dev, "Failed to allocate memory\n");
-		ret = -ENOMEM;
-		goto err_free_mem;
+		return -ENOMEM;
 	}
 
 	data->client = client;
@@ -223,40 +222,24 @@ static int mcs5000_ts_probe(struct i2c_client *client,
 	if (data->platform_data->cfg_pin)
 		data->platform_data->cfg_pin();
 
-	ret = request_threaded_irq(client->irq, NULL, mcs5000_ts_interrupt,
-			IRQF_TRIGGER_LOW | IRQF_ONESHOT, "mcs5000_ts", data);
-
-	if (ret < 0) {
+	ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+			mcs5000_ts_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+			"mcs5000_ts", data);
+	if (ret) {
 		dev_err(&client->dev, "Failed to register interrupt\n");
-		goto err_free_mem;
+		return ret;
 	}
 
 	ret = input_register_device(data->input_dev);
-	if (ret < 0)
-		goto err_free_irq;
+	if (ret < 0) {
+		dev_err(&client->dev, "Failed to register input device\n");
+		return ret;
+	}
 
 	mcs5000_ts_phys_init(data);
 	i2c_set_clientdata(client, data);
 
 	return 0;
-
-err_free_irq:
-	free_irq(client->irq, data);
-err_free_mem:
-	input_free_device(input_dev);
-	kfree(data);
-	return ret;
-}
-
-static int mcs5000_ts_remove(struct i2c_client *client)
-{
-	struct mcs5000_ts_data *data = i2c_get_clientdata(client);
-
-	free_irq(client->irq, data);
-	input_unregister_device(data->input_dev);
-	kfree(data);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM
@@ -291,7 +274,6 @@ MODULE_DEVICE_TABLE(i2c, mcs5000_ts_id);
 
 static struct i2c_driver mcs5000_ts_driver = {
 	.probe		= mcs5000_ts_probe,
-	.remove		= mcs5000_ts_remove,
 	.driver = {
 		.name = "mcs5000_ts",
 #ifdef CONFIG_PM
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH v3 1/2] Input: mcs_touchkey: use devm_* functions
From: Dmitry Torokhov @ 2014-05-27 15:31 UTC (permalink / raw)
  To: Beomho Seo
  Cc: linux-input, jy0922.shim, sachin.kamat, myungjoo.ham, jh80.chung,
	cw00.choi
In-Reply-To: <1401188787-32173-2-git-send-email-beomho.seo@samsung.com>

On Tue, May 27, 2014 at 08:06:25PM +0900, Beomho Seo wrote:
> This patch use devm_* funtions in mcs_touchkey driver.
> As a result, error path and remove() funtion is simplified.
> 
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> ---
> Changes in v3:
> - Some codes are back again. use fw_version, driver name and poweron.
> Changes in v2:
> - Additionally use devm_kzalloc for mcs_touchkey_data struct.
> ---
>  drivers/input/keyboard/mcs_touchkey.c |   32 ++++++++++----------------------
>  1 file changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
> index 1da8e0b..bf2f785 100644
> --- a/drivers/input/keyboard/mcs_touchkey.c
> +++ b/drivers/input/keyboard/mcs_touchkey.c
> @@ -113,14 +113,11 @@ static int mcs_touchkey_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> -	data = kzalloc(sizeof(struct mcs_touchkey_data) +
> -			sizeof(data->keycodes[0]) * (pdata->key_maxval + 1),
> -			GFP_KERNEL);
> -	input_dev = input_allocate_device();
> +	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> +	input_dev = devm_input_allocate_device(&client->dev);
>  	if (!data || !input_dev) {
>  		dev_err(&client->dev, "Failed to allocate memory\n");
> -		error = -ENOMEM;
> -		goto err_free_mem;
> +		return -ENOMEM;
>  	}
>  
>  	data->client = client;
> @@ -143,7 +140,7 @@ static int mcs_touchkey_probe(struct i2c_client *client,
>  	if (fw_ver < 0) {
>  		error = fw_ver;
>  		dev_err(&client->dev, "i2c read error[%d]\n", error);
> -		goto err_free_mem;
> +		return error;
>  	}
>  	dev_info(&client->dev, "Firmware version: %d\n", fw_ver);
>  
> @@ -176,38 +173,29 @@ static int mcs_touchkey_probe(struct i2c_client *client,
>  		data->poweron(true);
>  	}
>  
> -	error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
> -				     IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> -				     client->dev.driver->name, data);
> +	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
> +				mcs_touchkey_interrupt,	IRQF_TRIGGER_FALLING |
> +				IRQF_ONESHOT, client->dev.driver->name, data);
>  	if (error) {
>  		dev_err(&client->dev, "Failed to register interrupt\n");
> -		goto err_free_mem;
> +		return error;
>  	}
>  
>  	error = input_register_device(input_dev);
>  	if (error)
> -		goto err_free_irq;
> +		dev_err(&client->dev, "Failed to register input device\n");
> +		return error;
>  
>  	i2c_set_clientdata(client, data);
>  	return 0;
> -
> -err_free_irq:
> -	free_irq(client->irq, data);
> -err_free_mem:
> -	input_free_device(input_dev);
> -	kfree(data);
> -	return error;
>  }
>  
>  static int mcs_touchkey_remove(struct i2c_client *client)
>  {
>  	struct mcs_touchkey_data *data = i2c_get_clientdata(client);
>  
> -	free_irq(client->irq, data);
>  	if (data->poweron)
>  		data->poweron(false);

This is not an equivalent transformation - in the original code IRQ was
freed first and then platform-specific power off action was taken. Now
the order is reversed.

> -	input_unregister_device(data->input_dev);
> -	kfree(data);
>  
>  	return 0;
>  }
> -- 
> 1.7.9.5
> 

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 3/3] synaptics: Change min/max quirk table to pnp-id matching
From: Dmitry Torokhov @ 2014-05-27 16:25 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Peter Hutterer, Benjamin Tissoires, linux-input, stable
In-Reply-To: <538329D3.1090902@redhat.com>

On Mon, May 26, 2014 at 01:47:31PM +0200, Hans de Goede wrote:
> Hi Dmitry,
> 
> On 05/19/2014 10:51 AM, Hans de Goede wrote:
> > Hi,
> > 
> > On 05/18/2014 10:35 PM, Dmitry Torokhov wrote:
> >> On Fri, May 16, 2014 at 08:46:49PM +0200, Hans de Goede wrote:
> >>> Most of the affected models share pnp-ids for the touchpad. So switching
> >>> to pnp-ids give us 2 advantages:
> >>> 1) It shrinks the quirk list
> >>> 2) It will lower the new quirk addition frequency, ie the recently added W540
> >>>    quirk would not have been necessary since it uses the same LEN0034 pnp ids
> >>>    as other models already added before it
> >>>
> >>> As an added bonus it actually puts the quirk on the actual psmouse, rather then
> >>> on the machine, which is technically more correct.
> >>>
> >>> Cc: stable@vger.kernel.org
> >>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> >>> ---
> >>>  drivers/input/mouse/synaptics.c | 149 ++++++++++------------------------------
> >>>  1 file changed, 36 insertions(+), 113 deletions(-)
> >>>
> >>> diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
> >>> index 395ec9c..c5ec703 100644
> >>> --- a/drivers/input/mouse/synaptics.c
> >>> +++ b/drivers/input/mouse/synaptics.c
> >>> @@ -117,6 +117,31 @@ void synaptics_reset(struct psmouse *psmouse)
> >>>  }
> >>>  
> >>>  #ifdef CONFIG_MOUSE_PS2_SYNAPTICS
> >>> +struct min_max_quirk {
> >>> +	const char * const *pnp_ids;
> >>> +	int x_min, x_max, y_min, y_max;
> >>> +};
> >>
> >>
> >> Why don't we define this as 1 quirk per PNP id?
> >>
> >> struct min_max_quirk {
> >> 	const char *pnp_id;
> >> 	int x_min, x_max, y_min, y_max;
> >> };
> >>
> >> ?
> > 
> > 1) I thought it would be better to allow multiple ids for one min/max quad,
> > since there seem to only be a few types of touchpads out there, which are
> > sometimes referenced to by multiple ids. IE LEN0034 and LEN2004 refer to the
> > exact same touchpad (exact same firmware and board id). Also this way we avoid
> > people adding entries with values which are slightly off since determining
> > the min/max range on a single model will give some noise.
> > 
> > 2) This way we can use one helper function for the matching for both the
> > INPUT_PROP_TOPBUTTONPAD quirks and for the min/max quirks.
> 
> I've not heard back from you on this, does that mean that you are ok with
> taking this patch-set as is ?

Hans,

Yes, I applied it.

Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH 1/3] Input: wacom - set stylus_in_proximity when pen is in range
From: Ping Cheng @ 2014-05-27 23:17 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, Ping Cheng

Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Tested-by: Jason Gerecke <killertofu@gmail.com>
---
 drivers/input/tablet/wacom_wac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 24c0733..c98e51c 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -484,6 +484,8 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
 		input_report_key(input, BTN_TOUCH, 0);
 		input_report_abs(input, ABS_PRESSURE, 0);
 		input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
+		if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
+			wacom->shared->stylus_in_proximity = true;
 	}
 
 	/* Exit report */
-- 
1.9.1


^ permalink raw reply related

* [PATCH 2/3] Input: wacom - Don't declare ABS_X/Y for multitouch
From: Ping Cheng @ 2014-05-27 23:18 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, Ping Cheng

We use ABS_MT_POSITION_X/Y for multitouch (touch_max > 1) events now.
No need to declare ABS_X/Y for touch_max == 2 any more.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Tested-by: Jason Gerecke <killertofu@gmail.com>
---
 drivers/input/tablet/wacom_wac.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index c98e51c..0eb9960 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1217,8 +1217,8 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
 			 * a=(pi*r^2)/C.
 			 */
 			int a = data[5];
-			int x_res  = input_abs_get_res(input, ABS_X);
-			int y_res  = input_abs_get_res(input, ABS_Y);
+			int x_res  = input_abs_get_res(input, ABS_MT_POSITION_X);
+			int y_res  = input_abs_get_res(input, ABS_MT_POSITION_Y);
 			width  = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
 			height = width * y_res / x_res;
 		}
@@ -1587,7 +1587,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,
 		input_abs_set_res(input_dev, ABS_X, features->x_resolution);
 		input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
 	} else {
-		if (features->touch_max <= 2) {
+		if (features->touch_max == 1) {
 			input_set_abs_params(input_dev, ABS_X, 0,
 				features->x_max, features->x_fuzz, 0);
 			input_set_abs_params(input_dev, ABS_Y, 0,
-- 
1.9.1


^ permalink raw reply related

* [PATCH 3/3] Input: wacom - process outbound for newer Cintiqs
From: Ping Cheng @ 2014-05-27 23:19 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, Ping Cheng

New Cintiq tablets have a 200 tablet counts outside of screen area.
Add x/y_min for ABS_X/Y to pass this information to userland.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Tested-by: Jason Gerecke <killertofu@gmail.com>
---
 drivers/input/tablet/wacom_wac.c | 44 ++++++++++++++++++++--------------------
 drivers/input/tablet/wacom_wac.h |  2 ++
 2 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 0eb9960..9c0f22b 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1576,10 +1576,10 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,
 	struct wacom_features *features = &wacom_wac->features;
 
 	if (features->device_type == BTN_TOOL_PEN) {
-		input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
-				     features->x_fuzz, 0);
-		input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
-				     features->y_fuzz, 0);
+		input_set_abs_params(input_dev, ABS_X, features->x_min,
+				     features->x_max, features->x_fuzz, 0);
+		input_set_abs_params(input_dev, ABS_Y, features->y_min,
+				     features->y_max, features->y_fuzz, 0);
 		input_set_abs_params(input_dev, ABS_PRESSURE, 0,
 			features->pressure_max, features->pressure_fuzz, 0);
 
@@ -2135,11 +2135,11 @@ static const struct wacom_features wacom_features_0x317 =
 	  63, INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
 	  .touch_max = 16 };
 static const struct wacom_features wacom_features_0xF4 =
-	{ "Wacom Cintiq 24HD",       WACOM_PKGLEN_INTUOS,   104480, 65600, 2047,
-	  63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+	{ "Wacom Cintiq 24HD",       WACOM_PKGLEN_INTUOS,   104280, 65400, 2047,
+	  63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0xF8 =
-	{ "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS,   104480, 65600, 2047, /* Pen */
-	  63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+	{ "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS,   104280, 65400, 2047, /* Pen */
+	  63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
 	  .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
 static const struct wacom_features wacom_features_0xF6 =
 	{ "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
@@ -2154,8 +2154,8 @@ static const struct wacom_features wacom_features_0xC6 =
 	{ "Wacom Cintiq 12WX",    WACOM_PKGLEN_INTUOS,    53020, 33440, 1023,
 	  63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
 static const struct wacom_features wacom_features_0x304 =
-	{ "Wacom Cintiq 13HD",    WACOM_PKGLEN_INTUOS,    59552, 33848, 1023,
-	  63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+	{ "Wacom Cintiq 13HD",    WACOM_PKGLEN_INTUOS,    59352, 33648, 1023,
+	  63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0xC7 =
 	{ "Wacom DTU1931",        WACOM_PKGLEN_GRAPHIRE,  37832, 30305,  511,
 	  0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2169,24 +2169,24 @@ static const struct wacom_features wacom_features_0xFB =
 	{ "Wacom DTU1031",        WACOM_PKGLEN_DTUS,      22096, 13960,  511,
 	  0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x57 =
-	{ "Wacom DTK2241",        WACOM_PKGLEN_INTUOS,    95840, 54260, 2047,
-	  63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES};
+	{ "Wacom DTK2241",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
+	  63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0x59 = /* Pen */
-	{ "Wacom DTH2242",        WACOM_PKGLEN_INTUOS,    95840, 54260, 2047,
-	  63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+	{ "Wacom DTH2242",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
+	  63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
 	  .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
 static const struct wacom_features wacom_features_0x5D = /* Touch */
 	{ "Wacom DTH2242",       .type = WACOM_24HDT,
 	  .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10 };
 static const struct wacom_features wacom_features_0xCC =
-	{ "Wacom Cintiq 21UX2",   WACOM_PKGLEN_INTUOS,    87200, 65600, 2047,
-	  63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+	{ "Wacom Cintiq 21UX2",   WACOM_PKGLEN_INTUOS,    87000, 65400, 2047,
+	  63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0xFA =
-	{ "Wacom Cintiq 22HD",    WACOM_PKGLEN_INTUOS,    95840, 54260, 2047,
-	  63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+	{ "Wacom Cintiq 22HD",    WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
+	  63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0x5B =
-	{ "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS,      95840, 54260, 2047,
-	  63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+	{ "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS,      95640, 54060, 2047,
+	  63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
 	  .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
 static const struct wacom_features wacom_features_0x5E =
 	{ "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
@@ -2340,8 +2340,8 @@ static const struct wacom_features wacom_features_0x6004 =
 	{ "ISD-V4",               WACOM_PKGLEN_GRAPHIRE,  12800,  8000,  255,
 	  0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x0307 =
-	{ "Wacom ISDv5 307", WACOM_PKGLEN_INTUOS,  59552,  33848, 2047,
-	  63, CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+	{ "Wacom ISDv5 307", WACOM_PKGLEN_INTUOS,  59352,  33648, 2047,
+	  63, CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
 	  .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
 static const struct wacom_features wacom_features_0x0309 =
 	{ "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 29774ca..b2c9a9c 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -122,6 +122,8 @@ struct wacom_features {
 	int type;
 	int x_resolution;
 	int y_resolution;
+	int x_min;
+	int y_min;
 	int device_type;
 	int x_phy;
 	int y_phy;
-- 
1.9.1


^ permalink raw reply related

* [PATCH v4 0/2] Use devm_* functions for Melfas touch device
From: Beomho Seo @ 2014-05-28  8:41 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo

This patch set devm_* functions in Melfas touche device driver.
As a result, error path and remove() function is simplified.

Changes in v4:
- mcs_touchkey: add free_irq for equivalent transformation.

Changes in v3:
- mcs_touchkey: Some codes are back again.

Changes in v2:
- Additionally use devm_kzalloc mcs_[touchkey/ts]_data struct.


Beomho Seo (2):
  Input: mcs_touchkey: use devm_* functions
  Input: mcs5000_ts: use devm_* functions

 drivers/input/keyboard/mcs_touchkey.c  |   31 ++++++++---------------
 drivers/input/touchscreen/mcs5000_ts.c |   42 +++++++++-----------------------
 2 files changed, 22 insertions(+), 51 deletions(-)

-- 
1.7.9.5


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox