Linux Input/HID development
 help / color / mirror / Atom feed
* Re: [PATCH 3/3] IO: hid-sensor-magn-3d: Add in support for True/Magnetic North HID usages
From: Srinivas Pandruvada @ 2014-05-28 21:25 UTC (permalink / raw)
  To: Reyad Attiyat; +Cc: linux-kernel, linux-iio, jic23, linux-input, Jiri Kosina
In-Reply-To: <CA+BWVUQEsprV1jEzD9D0hidR0jvYeSRVGT=ESzstR4apa+nV1A@mail.gmail.com>

On 05/28/2014 02:15 PM, Reyad Attiyat wrote:
>> +static void sensor_hub_fill_attr_info(
>> +               struct hid_sensor_hub_attribute_info *info,
>> +               s32 index, s32 report_id, struct hid_field *field)
>> +{
>> +       info->index = index;
>> +       info->report_id = report_id;
>> +       info->units = field->unit;
>> +       info->unit_expo = field->unit_exponent;
>> +       info->size = (field->report_size * field->report_count)/8;
>> +       info->logical_minimum = field->logical_minimum;
>> +       info->logical_maximum = field->logical_maximum;
>>   }
> I copied this function from hid/hid-sensor-hub.c as it is marked
> static in that file. I use it to fill attributes as I find them.
> Should I create an another patch to make it non-static?

I didn't check your implementation. But 
sensor_hub_input_get_attribute_info()
function is not enough? We are already using to get other attributes for 
x, y and Z.

Thanks,
Srinivas


>> +       list_for_each_entry(report, &report_enum->report_list, list) {
>> +               for (i = 0; i < report->maxfield; ++i) {
>> +                       field = report->field[i];
>> +
>> +                       for (j = 0; j < field->maxusage; j++) {
>> +                               usage = &(field->usage[j]);
>> +
> This is how I mange to find all possible hid reports in the parse
> reports function. I noticed that in the other function that was used,
> sensor_hub_input_get_attribute_info(),  it only uses field->usage[0].
> Is there a reason for this and should I change my current
> implementation?
>


^ permalink raw reply

* Re: [PATCH 3/3] IO: hid-sensor-magn-3d: Add in support for True/Magnetic North HID usages
From: Reyad Attiyat @ 2014-05-28 21:35 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: linux-kernel, linux-iio, jic23, linux-input, Jiri Kosina
In-Reply-To: <53865438.2030901@linux.intel.com>

Hey Srinivas,

Well I could use sensor_hub_input_get_attribute_info() for each usage
attribute. I was just thinking that since each usage attribute is
found in a row, one for each field I think, it'd be easier to create
iio channels that way. This would eliminate running the for loop
search for usage id each time.

I realize that my parse_report function is quite ugly espically ending
in four closing parenthesis and copying code from
sensor_hub_input_get_attribute_info(). I will change it if you don't
think it will slow down the driver or have any negative effects.

Thanks,
Reyad



On Wed, May 28, 2014 at 4:25 PM, Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
> On 05/28/2014 02:15 PM, Reyad Attiyat wrote:
>>>
>>> +static void sensor_hub_fill_attr_info(
>>> +               struct hid_sensor_hub_attribute_info *info,
>>> +               s32 index, s32 report_id, struct hid_field *field)
>>> +{
>>> +       info->index = index;
>>> +       info->report_id = report_id;
>>> +       info->units = field->unit;
>>> +       info->unit_expo = field->unit_exponent;
>>> +       info->size = (field->report_size * field->report_count)/8;
>>> +       info->logical_minimum = field->logical_minimum;
>>> +       info->logical_maximum = field->logical_maximum;
>>>   }
>>
>> I copied this function from hid/hid-sensor-hub.c as it is marked
>> static in that file. I use it to fill attributes as I find them.
>> Should I create an another patch to make it non-static?
>
>
> I didn't check your implementation. But
> sensor_hub_input_get_attribute_info()
> function is not enough? We are already using to get other attributes for x,
> y and Z.
>
> Thanks,
> Srinivas
>
>
>
>>> +       list_for_each_entry(report, &report_enum->report_list, list) {
>>> +               for (i = 0; i < report->maxfield; ++i) {
>>> +                       field = report->field[i];
>>> +
>>> +                       for (j = 0; j < field->maxusage; j++) {
>>> +                               usage = &(field->usage[j]);
>>> +
>>
>> This is how I mange to find all possible hid reports in the parse
>> reports function. I noticed that in the other function that was used,
>> sensor_hub_input_get_attribute_info(),  it only uses field->usage[0].
>> Is there a reason for this and should I change my current
>> implementation?
>>
>

^ permalink raw reply

* Re: [PATCH 3/3] IO: hid-sensor-magn-3d: Add in support for True/Magnetic North HID usages
From: Srinivas Pandruvada @ 2014-05-28 21:56 UTC (permalink / raw)
  To: Reyad Attiyat; +Cc: linux-kernel, linux-iio, jic23, linux-input, Jiri Kosina
In-Reply-To: <CA+BWVUT6tC5nn--zUJ83+FvtQ-AAtZ+CmyUN0bnTEuffpTRD2Q@mail.gmail.com>

Hi Reyad,

  On 05/28/2014 02:35 PM, Reyad Attiyat wrote:
> Hey Srinivas,
>
> Well I could use sensor_hub_input_get_attribute_info() for each usage
> attribute. I was just thinking that since each usage attribute is
> found in a row, one for each field I think, it'd be easier to create
> iio channels that way. This would eliminate running the for loop
> search for usage id each time.
It shouldn't be an issue for few more attributes. The idea is that
we don't expose the report level parsing information to the client drivers.
The client shouldn't worry about which collection or report it belongs to.

In this way if we have to enhance the parse function for newer
FW changes or quirks, it is only done at one place. Clients are not
affected at all.

Alternatively
we can enhance API, which takes multiple usage ids and fills information
in a single call. What do you think about this?

Thanks,
Srinivas

>
> I realize that my parse_report function is quite ugly espically ending
> in four closing parenthesis and copying code from
> sensor_hub_input_get_attribute_info(). I will change it if you don't
> think it will slow down the driver or have any negative effects.
>
> Thanks,
> Reyad
>
>
>
> On Wed, May 28, 2014 at 4:25 PM, Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
>> On 05/28/2014 02:15 PM, Reyad Attiyat wrote:
>>>> +static void sensor_hub_fill_attr_info(
>>>> +               struct hid_sensor_hub_attribute_info *info,
>>>> +               s32 index, s32 report_id, struct hid_field *field)
>>>> +{
>>>> +       info->index = index;
>>>> +       info->report_id = report_id;
>>>> +       info->units = field->unit;
>>>> +       info->unit_expo = field->unit_exponent;
>>>> +       info->size = (field->report_size * field->report_count)/8;
>>>> +       info->logical_minimum = field->logical_minimum;
>>>> +       info->logical_maximum = field->logical_maximum;
>>>>    }
>>> I copied this function from hid/hid-sensor-hub.c as it is marked
>>> static in that file. I use it to fill attributes as I find them.
>>> Should I create an another patch to make it non-static?
>>
>> I didn't check your implementation. But
>> sensor_hub_input_get_attribute_info()
>> function is not enough? We are already using to get other attributes for x,
>> y and Z.
>>
>> Thanks,
>> Srinivas
>>
>>
>>
>>>> +       list_for_each_entry(report, &report_enum->report_list, list) {
>>>> +               for (i = 0; i < report->maxfield; ++i) {
>>>> +                       field = report->field[i];
>>>> +
>>>> +                       for (j = 0; j < field->maxusage; j++) {
>>>> +                               usage = &(field->usage[j]);
>>>> +
>>> This is how I mange to find all possible hid reports in the parse
>>> reports function. I noticed that in the other function that was used,
>>> sensor_hub_input_get_attribute_info(),  it only uses field->usage[0].
>>> Is there a reason for this and should I change my current
>>> implementation?
>>>


^ permalink raw reply

* Fwd: [PATCH 3/3] IO: hid-sensor-magn-3d: Add in support for True/Magnetic North HID usages
From: Reyad Attiyat @ 2014-05-28 21:59 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-input,
	linux-iio-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CA+BWVURydjyrnC9ec-POtn5A8gL7C93MH6pObcmmAqD4V=p0Zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Forgot to forward to list


---------- Forwarded message ----------
From: Reyad Attiyat <reyad.attiyat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Wed, May 28, 2014 at 4:57 PM
Subject: Re: [PATCH 3/3] IO: hid-sensor-magn-3d: Add in support for
True/Magnetic North HID usages
To: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>


Hey Srinivas,

> It shouldn't be an issue for few more attributes. The idea is that
> we don't expose the report level parsing information to the client drivers.
> The client shouldn't worry about which collection or report it belongs to.
>
Makes sense.

> In this way if we have to enhance the parse function for newer
> FW changes or quirks, it is only done at one place. Clients are not
> affected at all.
>
> Alternatively
> we can enhance API, which takes multiple usage ids and fills information
> in a single call. What do you think about this?

Yes this seems like a great idea. I will try and implement this and
resubmit these patches.

Thank You,
Reyad Attiyat

^ permalink raw reply

* Re: [PATCH v2 0/3] Input: fix typo error in MELFAS touch device driver
From: Dmitry Torokhov @ 2014-05-29  7:05 UTC (permalink / raw)
  To: Beomho Seo
  Cc: linux-input, Joonyoung Shim, Myungjoo Ham, Jaehoon Chung,
	Chanwoo Choi
In-Reply-To: <537D3E90.1020805@samsung.com>

On Thu, May 22, 2014 at 09:02:24AM +0900, Beomho Seo wrote:
> This patchset fix typo error in MELFAS touch device drivers.
> 
> Changes in v2:
> - Add patch set for mms114 and mcs5000_ts drivers.
> 
> Beomho Seo (3):
>   Input: mcs_touchkey: fix incorrect input device name
>   Input: mms114: fix incorrect input device name
>   Input: mcs5000_ts: fix incorrect input device name

Applied all 3, thank you.

> 
>  drivers/input/keyboard/mcs_touchkey.c  |    2 +-
>  drivers/input/touchscreen/mcs5000_ts.c |    2 +-
>  drivers/input/touchscreen/mms114.c     |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> -- 
> 1.7.9.5

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 2/3] Input: wacom - Don't declare ABS_X/Y for multitouch
From: Dmitry Torokhov @ 2014-05-29  7:08 UTC (permalink / raw)
  To: Ping Cheng; +Cc: linux-input, Ping Cheng
In-Reply-To: <1401232687-9738-1-git-send-email-pingc@wacom.com>

On Tue, May 27, 2014 at 04:18:07PM -0700, Ping Cheng wrote:
> 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.

This will make legacy clients, such as GPM on text console, very sad.

Thanks.

> 
> 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
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 3/3] Input: wacom - process outbound for newer Cintiqs
From: Dmitry Torokhov @ 2014-05-29  7:09 UTC (permalink / raw)
  To: Ping Cheng; +Cc: linux-input, Ping Cheng
In-Reply-To: <1401232783-9816-1-git-send-email-pingc@wacom.com>

On Tue, May 27, 2014 at 04:19:43PM -0700, Ping Cheng wrote:
> 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>

Applied, thank you.

> ---
>  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
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 1/3] Input: wacom - set stylus_in_proximity when pen is in range
From: Dmitry Torokhov @ 2014-05-29  7:09 UTC (permalink / raw)
  To: Ping Cheng; +Cc: linux-input, Ping Cheng
In-Reply-To: <1401232664-9699-1-git-send-email-pingc@wacom.com>

On Tue, May 27, 2014 at 04:17:44PM -0700, Ping Cheng wrote:
> Signed-off-by: Ping Cheng <pingc@wacom.com>
> Reviewed-by: Jason Gerecke <killertofu@gmail.com>
> Tested-by: Jason Gerecke <killertofu@gmail.com>

Applied, thank you.

> ---
>  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
> 

-- 
Dmitry

^ permalink raw reply

* Re: [RESEND PATCH v4 2/2] Input: mcs5000_ts: use devm_* functions
From: Dmitry Torokhov @ 2014-05-29  7:10 UTC (permalink / raw)
  To: Beomho Seo
  Cc: linux-input, jy0922.shim, sachin.kamat, myungjoo.ham, jh80.chung,
	cw00.choi
In-Reply-To: <1401268396-23072-3-git-send-email-beomho.seo@samsung.com>

On Wed, May 28, 2014 at 06:13:16PM +0900, Beomho Seo wrote:
> This patch use devm_* functions in mcs5000_ts driver.
> As, a result, error patch and remove() function is simplified.

Applied, thank you.

> 
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> ---
> Changes in v4:
> - None.
> 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
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] Input: touchscreen : Introduce the use of the managed version of kzalloc
From: Dmitry Torokhov @ 2014-05-29  7:15 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-input, linux-kernel, julia.lawall
In-Reply-To: <20140528180214.GA5957@himangi-Dell>

On Wed, May 28, 2014 at 11:32:14PM +0530, Himangi Saraogi wrote:
> This patch moves most data allocated in the probe function from
> unmanaged interfaces to managed interfaces. The kfrees and error
> handling code is done away with. Also, the unnecesary labels are
> removed and the function mrstouch_remove is removed as it becomes
> empty after removing the no longer required function calls. Also,
> linux/device.h include is added to make sure the devm_*() routine
> declarations are unambiguously available.
> 
> The following Coccinelle semantic patch was used for making a part of
> the change:
> 
> @platform@
> identifier p, probefn, removefn;
> @@
> struct platform_driver p = {
>   .probe = probefn,
>   .remove = removefn,
> };
> 
> @prb@
> identifier platform.probefn, pdev;
> expression e, e1, e2;
> @@
> probefn(struct platform_device *pdev, ...) {
>   <+...
> - e = kzalloc(e1, e2)
> + e = devm_kzalloc(&pdev->dev, e1, e2)
>   ...
> ?-kfree(e);
>   ...+>
> }
> 
> @rem depends on prb@
> identifier platform.removefn;
> expression e;
> @@
> removefn(...) {
>   <...
> - kfree(e);
>   ...>
> }
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
>  drivers/input/touchscreen/intel-mid-touch.c | 39 ++++++++---------------------
>  1 file changed, 11 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c
> index 4f6b156..b1b1e8b 100644
> --- a/drivers/input/touchscreen/intel-mid-touch.c
> +++ b/drivers/input/touchscreen/intel-mid-touch.c
> @@ -36,6 +36,7 @@
>  #include <linux/irq.h>
>  #include <linux/delay.h>
>  #include <asm/intel_scu_ipc.h>
> +#include <linux/device.h>
>  
>  /* PMIC Interrupt registers */
>  #define PMIC_REG_ID1		0x00 /* PMIC ID1 register */
> @@ -580,12 +581,12 @@ static int mrstouch_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	tsdev = kzalloc(sizeof(struct mrstouch_dev), GFP_KERNEL);
> -	input = input_allocate_device();
> +	tsdev = devm_kzalloc(&pdev->dev, sizeof(struct mrstouch_dev),
> +			     GFP_KERNEL);
> +	input = devm_input_allocate_device(&pdev->dev);
>  	if (!tsdev || !input) {
>  		dev_err(&pdev->dev, "unable to allocate memory\n");
> -		err = -ENOMEM;
> -		goto err_free_mem;
> +		return -ENOMEM;
>  	}
>  
>  	tsdev->dev = &pdev->dev;
> @@ -598,7 +599,7 @@ static int mrstouch_probe(struct platform_device *pdev)
>  	err = mrstouch_adc_init(tsdev);
>  	if (err) {
>  		dev_err(&pdev->dev, "ADC initialization failed\n");
> -		goto err_free_mem;
> +		return -ENOMEM;
>  	}
>  
>  	input->name = "mrst_touchscreen";
> @@ -618,39 +619,22 @@ static int mrstouch_probe(struct platform_device *pdev)
>  	input_set_abs_params(tsdev->input, ABS_PRESSURE,
>  			     MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0);
>  
> -	err = request_threaded_irq(tsdev->irq, NULL, mrstouch_pendet_irq,
> -				   IRQF_ONESHOT, "mrstouch", tsdev);
> +	err = devm_request_threaded_irq(&pdev->dev, tsdev->irq, NULL,
> +					mrstouch_pendet_irq, IRQF_ONESHOT,
> +					"mrstouch", tsdev);
>  	if (err) {
>  		dev_err(tsdev->dev, "unable to allocate irq\n");
> -		goto err_free_mem;
> +		return -ENOMEM;

This is bad conversion. We used to report 'err' returned by
request_threaded_irq, but now we always report -ENOMEM. I fixed it up
here and in other places and applied.

>  	}
>  
>  	err = input_register_device(tsdev->input);
>  	if (err) {
>  		dev_err(tsdev->dev, "unable to register input device\n");
> -		goto err_free_irq;
> +		return -ENOMEM;
>  	}
>  
>  	platform_set_drvdata(pdev, tsdev);
>  	return 0;
> -
> -err_free_irq:
> -	free_irq(tsdev->irq, tsdev);
> -err_free_mem:
> -	input_free_device(input);
> -	kfree(tsdev);
> -	return err;
> -}
> -
> -static int mrstouch_remove(struct platform_device *pdev)
> -{
> -	struct mrstouch_dev *tsdev = platform_get_drvdata(pdev);
> -
> -	free_irq(tsdev->irq, tsdev);
> -	input_unregister_device(tsdev->input);
> -	kfree(tsdev);
> -
> -	return 0;
>  }
>  
>  static struct platform_driver mrstouch_driver = {
> @@ -659,7 +643,6 @@ static struct platform_driver mrstouch_driver = {
>  		.owner	= THIS_MODULE,
>  	},
>  	.probe		= mrstouch_probe,
> -	.remove		= mrstouch_remove,
>  };
>  module_platform_driver(mrstouch_driver);
>  
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] Input: touchscreen : Introduce the use of the managed version of kzalloc
From: Julia Lawall @ 2014-05-29  7:20 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Himangi Saraogi, linux-input, linux-kernel
In-Reply-To: <20140529071510.GF11817@core.coreip.homeip.net>

> > @@ -618,39 +619,22 @@ static int mrstouch_probe(struct platform_device *pdev)
> >  	input_set_abs_params(tsdev->input, ABS_PRESSURE,
> >  			     MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0);
> >  
> > -	err = request_threaded_irq(tsdev->irq, NULL, mrstouch_pendet_irq,
> > -				   IRQF_ONESHOT, "mrstouch", tsdev);
> > +	err = devm_request_threaded_irq(&pdev->dev, tsdev->irq, NULL,
> > +					mrstouch_pendet_irq, IRQF_ONESHOT,
> > +					"mrstouch", tsdev);
> >  	if (err) {
> >  		dev_err(tsdev->dev, "unable to allocate irq\n");
> > -		goto err_free_mem;
> > +		return -ENOMEM;
> 
> This is bad conversion. We used to report 'err' returned by
> request_threaded_irq, but now we always report -ENOMEM. I fixed it up
> here and in other places and applied.

Sorry to have missed that.  I guess you got the one on the call to 
mrstouch_adc_init as well?

thanks,
julia

^ permalink raw reply

* Re: [PATCH] Input: 88pm860x_onkey : Introduce the use of the managed version of  kzalloc
From: Dmitry Torokhov @ 2014-05-29  7:25 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-input, linux-kernel, julia.lawall
In-Reply-To: <20140528200123.GA9946@himangi-Dell>

On Thu, May 29, 2014 at 01:31:23AM +0530, Himangi Saraogi wrote:
> This patch moves most data allocated in the probe function from
> unmanaged interfaces to managed interfaces. The kfrees and error
> handling code is done away with. Also, the unnecesary labels are
> removed and the function pm860x_onkey_remove is removed as it becomes
> empty after removing the no longer required function calls. Also,
> linux/device.h include is added to make sure the devm_*() routine
> declarations are unambiguously available.
> 
> The following Coccinelle semantic patch was used for making a part of
> the change:
> 
> @platform@
> identifier p, probefn, removefn;
> @@
> struct platform_driver p = {
>   .probe = probefn,
>   .remove = removefn,
> };
> 
> @prb@
> identifier platform.probefn, pdev;
> expression e, e1, e2;
> @@
> probefn(struct platform_device *pdev, ...) {
>   <+...
> - e = kzalloc(e1, e2)
> + e = devm_kzalloc(&pdev->dev, e1, e2)
>   ...
> ?-kfree(e);
>   ...+>
> }
> 
> @rem depends on prb@
> identifier platform.removefn;
> expression e;
> @@
> removefn(...) {
>   <...
> - kfree(e);
>   ...>
> }
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Applied, thank you.

> ---
>  drivers/input/misc/88pm860x_onkey.c | 40 ++++++++++---------------------------
>  1 file changed, 10 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c
> index abd8453..220ce0f 100644
> --- a/drivers/input/misc/88pm860x_onkey.c
> +++ b/drivers/input/misc/88pm860x_onkey.c
> @@ -26,6 +26,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/mfd/88pm860x.h>
>  #include <linux/slab.h>
> +#include <linux/device.h>
>  
>  #define PM8607_WAKEUP		0x0b
>  
> @@ -68,7 +69,8 @@ static int pm860x_onkey_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	info = kzalloc(sizeof(struct pm860x_onkey_info), GFP_KERNEL);
> +	info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_onkey_info),
> +			    GFP_KERNEL);
>  	if (!info)
>  		return -ENOMEM;
>  	info->chip = chip;
> @@ -76,11 +78,10 @@ static int pm860x_onkey_probe(struct platform_device *pdev)
>  	info->dev = &pdev->dev;
>  	info->irq = irq;
>  
> -	info->idev = input_allocate_device();
> +	info->idev = devm_input_allocate_device(&pdev->dev);
>  	if (!info->idev) {
>  		dev_err(chip->dev, "Failed to allocate input dev\n");
> -		ret = -ENOMEM;
> -		goto out;
> +		return -ENOMEM;
>  	}
>  
>  	info->idev->name = "88pm860x_on";
> @@ -93,42 +94,22 @@ static int pm860x_onkey_probe(struct platform_device *pdev)
>  	ret = input_register_device(info->idev);
>  	if (ret) {
>  		dev_err(chip->dev, "Can't register input device: %d\n", ret);
> -		goto out_reg;
> +		return ret;
>  	}
>  
> -	ret = request_threaded_irq(info->irq, NULL, pm860x_onkey_handler,
> -				   IRQF_ONESHOT, "onkey", info);
> +	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
> +					pm860x_onkey_handler, IRQF_ONESHOT,
> +					"onkey", info);
>  	if (ret < 0) {
>  		dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
>  			info->irq, ret);
> -		goto out_irq;
> +		return ret;
>  	}
>  
>  	platform_set_drvdata(pdev, info);
>  	device_init_wakeup(&pdev->dev, 1);
>  
>  	return 0;
> -
> -out_irq:
> -	input_unregister_device(info->idev);
> -	kfree(info);
> -	return ret;
> -
> -out_reg:
> -	input_free_device(info->idev);
> -out:
> -	kfree(info);
> -	return ret;
> -}
> -
> -static int pm860x_onkey_remove(struct platform_device *pdev)
> -{
> -	struct pm860x_onkey_info *info = platform_get_drvdata(pdev);
> -
> -	free_irq(info->irq, info);
> -	input_unregister_device(info->idev);
> -	kfree(info);
> -	return 0;
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> @@ -161,7 +142,6 @@ static struct platform_driver pm860x_onkey_driver = {
>  		.pm	= &pm860x_onkey_pm_ops,
>  	},
>  	.probe		= pm860x_onkey_probe,
> -	.remove		= pm860x_onkey_remove,
>  };
>  module_platform_driver(pm860x_onkey_driver);
>  
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] Input: 88pm860x-ts: Introduce the use of the managed version of kzalloc
From: Dmitry Torokhov @ 2014-05-29  7:25 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-input, linux-kernel, julia.lawall
In-Reply-To: <20140528200603.GA10566@himangi-Dell>

On Thu, May 29, 2014 at 01:36:03AM +0530, Himangi Saraogi wrote:
> This patch moves most data allocated in the probe function from
> unmanaged interfaces to managed interfaces. The kfrees and error
> handling code is done away with. Also, the unnecesary labels are
> removed and the function pm860x_touch_remove is removed as it becomes
> empty after removing the no longer required function calls. 
> 
> This changes the order of the freeing operations in the remove
> function, putting the free_irq first, and that this may resolve a 
> potential race condition.
> 
> The following Coccinelle semantic patch was used for making a part of
> the change:
> 
> @platform@
> identifier p, probefn, removefn;
> @@
> struct platform_driver p = {
>   .probe = probefn,
>   .remove = removefn,
> };
> 
> @prb@
> identifier platform.probefn, pdev;
> expression e, e1, e2;
> @@
> probefn(struct platform_device *pdev, ...) {
>   <+...
> - e = kzalloc(e1, e2)
> + e = devm_kzalloc(&pdev->dev, e1, e2)
>   ...
> ?-kfree(e);
>   ...+>
> }
> 
> @rem depends on prb@
> identifier platform.removefn;
> expression e;
> @@
> removefn(...) {
>   <...
> - kfree(e);
>   ...>
> }
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>


Applied, thank you.

> ---
>  drivers/input/touchscreen/88pm860x-ts.c | 36 +++++++++------------------------
>  1 file changed, 10 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
> index 544e20c..30c8cc1 100644
> --- a/drivers/input/touchscreen/88pm860x-ts.c
> +++ b/drivers/input/touchscreen/88pm860x-ts.c
> @@ -16,6 +16,7 @@
>  #include <linux/input.h>
>  #include <linux/mfd/88pm860x.h>
>  #include <linux/slab.h>
> +#include <linux/device.h>
>  
>  #define MEAS_LEN		(8)
>  #define ACCURATE_BIT		(12)
> @@ -234,16 +235,16 @@ static int pm860x_touch_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL);
> +	touch = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_touch),
> +			     GFP_KERNEL);
>  	if (touch == NULL)
>  		return -ENOMEM;
>  	platform_set_drvdata(pdev, touch);
>  
> -	touch->idev = input_allocate_device();
> +	touch->idev = devm_input_allocate_device(&pdev->dev);
>  	if (touch->idev == NULL) {
>  		dev_err(&pdev->dev, "Failed to allocate input device!\n");
> -		ret = -ENOMEM;
> -		goto out;
> +		return -ENOMEM;
>  	}
>  
>  	touch->idev->name = "88pm860x-touch";
> @@ -258,10 +259,11 @@ static int pm860x_touch_probe(struct platform_device *pdev)
>  	touch->res_x = res_x;
>  	input_set_drvdata(touch->idev, touch);
>  
> -	ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler,
> -				   IRQF_ONESHOT, "touch", touch);
> +	ret = devm_request_threaded_irq(&pdev->dev, touch->irq, NULL,
> +					pm860x_touch_handler, IRQF_ONESHOT,
> +					"touch", touch);
>  	if (ret < 0)
> -		goto out_irq;
> +		return ret;
>  
>  	__set_bit(EV_ABS, touch->idev->evbit);
>  	__set_bit(ABS_X, touch->idev->absbit);
> @@ -279,28 +281,11 @@ static int pm860x_touch_probe(struct platform_device *pdev)
>  	ret = input_register_device(touch->idev);
>  	if (ret < 0) {
>  		dev_err(chip->dev, "Failed to register touch!\n");
> -		goto out_rg;
> +		return ret;
>  	}
>  
>  	platform_set_drvdata(pdev, touch);
>  	return 0;
> -out_rg:
> -	free_irq(touch->irq, touch);
> -out_irq:
> -	input_free_device(touch->idev);
> -out:
> -	kfree(touch);
> -	return ret;
> -}
> -
> -static int pm860x_touch_remove(struct platform_device *pdev)
> -{
> -	struct pm860x_touch *touch = platform_get_drvdata(pdev);
> -
> -	input_unregister_device(touch->idev);
> -	free_irq(touch->irq, touch);
> -	kfree(touch);
> -	return 0;
>  }
>  
>  static struct platform_driver pm860x_touch_driver = {
> @@ -309,7 +294,6 @@ static struct platform_driver pm860x_touch_driver = {
>  		.owner	= THIS_MODULE,
>  	},
>  	.probe	= pm860x_touch_probe,
> -	.remove	= pm860x_touch_remove,
>  };
>  module_platform_driver(pm860x_touch_driver);
>  
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] Input: max8925_onkey :Allocate resources using managed interfaces
From: Dmitry Torokhov @ 2014-05-29  7:25 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-input, linux-kernel, julia.lawall
In-Reply-To: <20140528201014.GA10607@himangi-Dell>

On Thu, May 29, 2014 at 01:40:14AM +0530, Himangi Saraogi wrote:
> This patch moves most data allocated in the probe function from
> unmanaged interfaces to managed interfaces. The kfrees and error
> handling code is done away with. The unnecesary labels are removed
> and the function max8925_onkey_remove is removed as it becomes empty
> after removing the no longer required function calls. Also,
> linux/device.h is added to make sure the devm_*() routine declarations
> are unambiguously available.
> 
> The following Coccinelle semantic patch was used for making a part of
> the change:
> 
> @platform@
> identifier p, probefn, removefn;
> @@
> struct platform_driver p = {
>   .probe = probefn,
>   .remove = removefn,
> };
> 
> @prb@
> identifier platform.probefn, pdev;
> expression e, e1, e2;
> @@
> probefn(struct platform_device *pdev, ...) {
>   <+...
> - e = kzalloc(e1, e2)
> + e = devm_kzalloc(&pdev->dev, e1, e2)
>   ...
> ?-kfree(e);
>   ...+>
> }
> 
> @rem depends on prb@
> identifier platform.removefn;
> expression e;
> @@
> removefn(...) {
>   <...
> - kfree(e);
>   ...>
> }
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Applied, thank you.

> ---
> To send to: Dmitry Torokhov <dmitry.torokhov@gmail.com>,linux-input@vger.kernel.org,linux-kernel@vger.kernel.org
>  drivers/input/misc/max8925_onkey.c | 52 +++++++++++---------------------------
>  1 file changed, 15 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c
> index eef41cf..62899e5 100644
> --- a/drivers/input/misc/max8925_onkey.c
> +++ b/drivers/input/misc/max8925_onkey.c
> @@ -26,6 +26,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/mfd/max8925.h>
>  #include <linux/slab.h>
> +#include <linux/device.h>
>  
>  #define SW_INPUT		(1 << 7)	/* 0/1 -- up/down */
>  #define HARDRESET_EN		(1 << 7)
> @@ -81,12 +82,11 @@ static int max8925_onkey_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	info = kzalloc(sizeof(struct max8925_onkey_info), GFP_KERNEL);
> -	input = input_allocate_device();
> -	if (!info || !input) {
> -		error = -ENOMEM;
> -		goto err_free_mem;
> -	}
> +	info = devm_kzalloc(&pdev->dev, sizeof(struct max8925_onkey_info),
> +			    GFP_KERNEL);
> +	input = devm_input_allocate_device(&pdev->dev);
> +	if (!info || !input)
> +		return -ENOMEM;
>  
>  	info->idev = input;
>  	info->i2c = chip->i2c;
> @@ -100,55 +100,34 @@ static int max8925_onkey_probe(struct platform_device *pdev)
>  	input->dev.parent = &pdev->dev;
>  	input_set_capability(input, EV_KEY, KEY_POWER);
>  
> -	error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler,
> -				     IRQF_ONESHOT, "onkey-down", info);
> +	error = devm_request_threaded_irq(&pdev->dev, irq[0], NULL,
> +					  max8925_onkey_handler, IRQF_ONESHOT,
> +					  "onkey-down", info);
>  	if (error < 0) {
>  		dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
>  			irq[0], error);
> -		goto err_free_mem;
> +		return error;
>  	}
>  
> -	error = request_threaded_irq(irq[1], NULL, max8925_onkey_handler,
> -				     IRQF_ONESHOT, "onkey-up", info);
> +	error = devm_request_threaded_irq(&pdev->dev, irq[1], NULL,
> +					  max8925_onkey_handler, IRQF_ONESHOT,
> +					  "onkey-up", info);
>  	if (error < 0) {
>  		dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
>  			irq[1], error);
> -		goto err_free_irq0;
> +		return error;
>  	}
>  
>  	error = input_register_device(info->idev);
>  	if (error) {
>  		dev_err(chip->dev, "Can't register input device: %d\n", error);
> -		goto err_free_irq1;
> +		return error;
>  	}
>  
>  	platform_set_drvdata(pdev, info);
>  	device_init_wakeup(&pdev->dev, 1);
>  
>  	return 0;
> -
> -err_free_irq1:
> -	free_irq(irq[1], info);
> -err_free_irq0:
> -	free_irq(irq[0], info);
> -err_free_mem:
> -	input_free_device(input);
> -	kfree(info);
> -
> -	return error;
> -}
> -
> -static int max8925_onkey_remove(struct platform_device *pdev)
> -{
> -	struct max8925_onkey_info *info = platform_get_drvdata(pdev);
> -	struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
> -
> -	free_irq(info->irq[0] + chip->irq_base, info);
> -	free_irq(info->irq[1] + chip->irq_base, info);
> -	input_unregister_device(info->idev);
> -	kfree(info);
> -
> -	return 0;
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> @@ -190,7 +169,6 @@ static struct platform_driver max8925_onkey_driver = {
>  		.pm	= &max8925_onkey_pm_ops,
>  	},
>  	.probe		= max8925_onkey_probe,
> -	.remove		= max8925_onkey_remove,
>  };
>  module_platform_driver(max8925_onkey_driver);
>  
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] input: ab8500-ponkey: Allocate resources using managed interfaces
From: Dmitry Torokhov @ 2014-05-29  7:26 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-input, linux-kernel, julia.lawall
In-Reply-To: <20140528201200.GA10661@himangi-Dell>

On Thu, May 29, 2014 at 01:42:00AM +0530, Himangi Saraogi wrote:
> This patch moves most data allocated in the probe function from
> unmanaged interfaces to managed interfaces. The kfrees and error
> handling code is done away with. Also, the unnecesary labels are
> removed and the function ab8500_ponkey_remove is removed as it becomes
> empty after removing the no longer required function calls. Also,
> linux/device.h is added to make sure the devm_*() routine declarations
> are unambiguously available.
> 
> The following Coccinelle semantic patch was used for making a part of
> the change:
> 
> @platform@
> identifier p, probefn, removefn;
> @@
> struct platform_driver p = {
>   .probe = probefn,
>   .remove = removefn,
> };
> 
> @prb@
> identifier platform.probefn, pdev;
> expression e, e1, e2;
> @@
> probefn(struct platform_device *pdev, ...) {
>   <+...
> - e = kzalloc(e1, e2)
> + e = devm_kzalloc(&pdev->dev, e1, e2)
>   ...
> ?-kfree(e);
>   ...+>
> }
> 
> @rem depends on prb@
> identifier platform.removefn;
> expression e;
> @@
> removefn(...) {
>   <...
> - kfree(e);
>   ...>
> }
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Applied, thank you.

> ---
> To send to: Dmitry Torokhov <dmitry.torokhov@gmail.com>,linux-input@vger.kernel.org,linux-kernel@vger.kernel.org
> 
>  drivers/input/misc/ab8500-ponkey.c | 51 +++++++++++---------------------------
>  1 file changed, 15 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c
> index f2fbdd8..89fb1c6 100644
> --- a/drivers/input/misc/ab8500-ponkey.c
> +++ b/drivers/input/misc/ab8500-ponkey.c
> @@ -7,6 +7,7 @@
>   * AB8500 Power-On Key handler
>   */
>  
> +#include <linux/device.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> @@ -65,12 +66,11 @@ static int ab8500_ponkey_probe(struct platform_device *pdev)
>  		return irq_dbr;
>  	}
>  
> -	ponkey = kzalloc(sizeof(struct ab8500_ponkey), GFP_KERNEL);
> -	input = input_allocate_device();
> -	if (!ponkey || !input) {
> -		error = -ENOMEM;
> -		goto err_free_mem;
> -	}
> +	ponkey = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_ponkey),
> +			      GFP_KERNEL);
> +	input = devm_input_allocate_device(&pdev->dev);
> +	if (!ponkey || !input)
> +		return -ENOMEM;
>  
>  	ponkey->idev = input;
>  	ponkey->ab8500 = ab8500;
> @@ -82,52 +82,32 @@ static int ab8500_ponkey_probe(struct platform_device *pdev)
>  
>  	input_set_capability(input, EV_KEY, KEY_POWER);
>  
> -	error = request_any_context_irq(ponkey->irq_dbf, ab8500_ponkey_handler,
> -					0, "ab8500-ponkey-dbf", ponkey);
> +	error = devm_request_any_context_irq(&pdev->dev, ponkey->irq_dbf,
> +					     ab8500_ponkey_handler, 0,
> +					     "ab8500-ponkey-dbf", ponkey);
>  	if (error < 0) {
>  		dev_err(ab8500->dev, "Failed to request dbf IRQ#%d: %d\n",
>  			ponkey->irq_dbf, error);
> -		goto err_free_mem;
> +		return error;
>  	}
>  
> -	error = request_any_context_irq(ponkey->irq_dbr, ab8500_ponkey_handler,
> -					0, "ab8500-ponkey-dbr", ponkey);
> +	error = devm_request_any_context_irq(&pdev->dev, ponkey->irq_dbr,
> +					     ab8500_ponkey_handler, 0,
> +					     "ab8500-ponkey-dbr", ponkey);
>  	if (error < 0) {
>  		dev_err(ab8500->dev, "Failed to request dbr IRQ#%d: %d\n",
>  			ponkey->irq_dbr, error);
> -		goto err_free_dbf_irq;
> +		return error;
>  	}
>  
>  	error = input_register_device(ponkey->idev);
>  	if (error) {
>  		dev_err(ab8500->dev, "Can't register input device: %d\n", error);
> -		goto err_free_dbr_irq;
> +		return error;
>  	}
>  
>  	platform_set_drvdata(pdev, ponkey);
>  	return 0;
> -
> -err_free_dbr_irq:
> -	free_irq(ponkey->irq_dbr, ponkey);
> -err_free_dbf_irq:
> -	free_irq(ponkey->irq_dbf, ponkey);
> -err_free_mem:
> -	input_free_device(input);
> -	kfree(ponkey);
> -
> -	return error;
> -}
> -
> -static int ab8500_ponkey_remove(struct platform_device *pdev)
> -{
> -	struct ab8500_ponkey *ponkey = platform_get_drvdata(pdev);
> -
> -	free_irq(ponkey->irq_dbf, ponkey);
> -	free_irq(ponkey->irq_dbr, ponkey);
> -	input_unregister_device(ponkey->idev);
> -	kfree(ponkey);
> -
> -	return 0;
>  }
>  
>  #ifdef CONFIG_OF
> @@ -144,7 +124,6 @@ static struct platform_driver ab8500_ponkey_driver = {
>  		.of_match_table = of_match_ptr(ab8500_ponkey_match),
>  	},
>  	.probe		= ab8500_ponkey_probe,
> -	.remove		= ab8500_ponkey_remove,
>  };
>  module_platform_driver(ab8500_ponkey_driver);
>  
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] Input: touchscreen : Introduce the use of the managed version of kzalloc
From: Dmitry Torokhov @ 2014-05-29  7:28 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Himangi Saraogi, linux-input, linux-kernel
In-Reply-To: <alpine.DEB.2.02.1405290919110.1996@localhost6.localdomain6>

On Thu, May 29, 2014 at 09:20:20AM +0200, Julia Lawall wrote:
> > > @@ -618,39 +619,22 @@ static int mrstouch_probe(struct platform_device *pdev)
> > >  	input_set_abs_params(tsdev->input, ABS_PRESSURE,
> > >  			     MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0);
> > >  
> > > -	err = request_threaded_irq(tsdev->irq, NULL, mrstouch_pendet_irq,
> > > -				   IRQF_ONESHOT, "mrstouch", tsdev);
> > > +	err = devm_request_threaded_irq(&pdev->dev, tsdev->irq, NULL,
> > > +					mrstouch_pendet_irq, IRQF_ONESHOT,
> > > +					"mrstouch", tsdev);
> > >  	if (err) {
> > >  		dev_err(tsdev->dev, "unable to allocate irq\n");
> > > -		goto err_free_mem;
> > > +		return -ENOMEM;
> > 
> > This is bad conversion. We used to report 'err' returned by
> > request_threaded_irq, but now we always report -ENOMEM. I fixed it up
> > here and in other places and applied.
> 
> Sorry to have missed that.  I guess you got the one on the call to 
> mrstouch_adc_init as well?

Yeah, I fixed them all up.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 1/2] ARM: OMAP2+: remove unused omap4-keypad file and code
From: Dmitry Torokhov @ 2014-05-29  7:33 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Joachim Eastwood, illia.smyrnov, linux-omap, linux-input
In-Reply-To: <20140519161814.GE4849@atomide.com>

On Mon, May 19, 2014 at 09:18:15AM -0700, Tony Lindgren wrote:
> * Dmitry Torokhov <dmitry.torokhov@gmail.com> [140518 22:38]:
> > On Sat, May 17, 2014 at 11:24:10PM +0200, Joachim Eastwood wrote:
> > > This has been unused since omap4 board files went away.
> > > 
> > > Signed-off-by: Joachim Eastwood <manabian@gmail.com>
> > 
> > Tony, can I merge both through my tree?
> 
> Yes I don't have anything touching the omap4_keyboard_init
> areas that I can think of:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
>  

Applied both, thank you.

-- 
Dmitry

^ permalink raw reply

* joydev devices are world readable
From: Floris @ 2014-05-29  8:11 UTC (permalink / raw)
  To: linux-input

Hey,

after asking the systemd mailing list [1] I will try this list. Maybe  
someone can help me to solve this issue or point me to someone/ some list.

The short version of the problem:

I have created a multiseat setup with systemd. And used "loginctl attach"  
to attach devices to an other seat. The input from the mouse and keyboard  
are working as expected. They both only work on the seat they are attached  
to. Nevertheless, the joysticks ignore the seat rules and works on every  
seat. So a user from seat0 can interact with seat1. Maybe this is not  
directly a security problem as it is annoying.

Please read the systemd-devel mailing list [1] for more information or ask  
me if you need more information about my system or the problem.

tia,

floris

[1]  
http://lists.freedesktop.org/archives/systemd-devel/2014-May/019551.html

^ permalink raw reply

* Re: joydev devices are world readable
From: David Herrmann @ 2014-05-29  8:44 UTC (permalink / raw)
  To: Floris; +Cc: open list:HID CORE LAYER
In-Reply-To: <op.xgl3pdtz5k9y7g@alice.jkfloris.demon.nl>

Hi

On Thu, May 29, 2014 at 10:11 AM, Floris <jkfloris@dds.nl> wrote:
> Hey,
>
> after asking the systemd mailing list [1] I will try this list. Maybe
> someone can help me to solve this issue or point me to someone/ some list.
>
> The short version of the problem:
>
> I have created a multiseat setup with systemd. And used "loginctl attach" to
> attach devices to an other seat. The input from the mouse and keyboard are
> working as expected. They both only work on the seat they are attached to.
> Nevertheless, the joysticks ignore the seat rules and works on every seat.
> So a user from seat0 can interact with seat1. Maybe this is not directly a
> security problem as it is annoying.
>
> Please read the systemd-devel mailing list [1] for more information or ask
> me if you need more information about my system or the problem.

I posted an explanation on systemd-devel [1] this morning. Please note
that this is a policy-issue created in user-space. The kernel-side
cannot help you there. Furthermore, the kernel recommends using evdev
instead of joydev and friends. Therefore, I cannot see what you expect
from us.

If you want to get this solved, simply change the udev rules on your
system to prevent joydev devices from being world-readable.

Thanks
David

[1] http://lists.freedesktop.org/archives/systemd-devel/2014-May/019566.html

^ permalink raw reply

* Re: joydev devices are world readable
From: Floris @ 2014-05-29  9:44 UTC (permalink / raw)
  To: linux-input
In-Reply-To: <CANq1E4QOOimhZ9pDLkRMvPYZBko8sWZiugHKgYwBR1gb7CKW5w@mail.gmail.com>

> I posted an explanation on systemd-devel [1] this morning. Please note
> that this is a policy-issue created in user-space. The kernel-side
> cannot help you there. Furthermore, the kernel recommends using evdev
> instead of joydev and friends. Therefore, I cannot see what you expect
> from us.

just curious. If the joydev module is not recommended, why is it still
available and used?

> If you want to get this solved, simply change the udev rules on your
> system to prevent joydev devices from being world-readable.
>
> Thanks
> David

Thank for your explanations. I will try to modify or add udev rules and
see if I can solve this behavior.

Thanks,

floris

^ permalink raw reply

* Re: joydev devices are world readable
From: David Herrmann @ 2014-05-29  9:46 UTC (permalink / raw)
  To: Floris; +Cc: open list:HID CORE LAYER
In-Reply-To: <op.xgl708il5k9y7g@alice.jkfloris.demon.nl>

Hi

On Thu, May 29, 2014 at 11:44 AM, Floris <jkfloris@dds.nl> wrote:
>> I posted an explanation on systemd-devel [1] this morning. Please note
>> that this is a policy-issue created in user-space. The kernel-side
>> cannot help you there. Furthermore, the kernel recommends using evdev
>> instead of joydev and friends. Therefore, I cannot see what you expect
>> from us.
>
>
> just curious. If the joydev module is not recommended, why is it still
> available and used?

Linux has strict backwards-compatibility rules. Therefore, we cannot
remove joydev. However, we can decide to mark it obsolete, which means
we will not extend it anymore. Furthermore, we cannot force anyone to
stop using joydev, so we have to continue supporting it.

Thanks
David

^ permalink raw reply

* [PATCH] Input: atmel_mxt_ts - fix invalid return from mxt_get_bootloader_version
From: nick.dyer @ 2014-05-29 12:34 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dan Carpenter, linux-input, Nick Dyer
In-Reply-To: <20140521122624.GB23396@mwanda>

From: Nick Dyer <nick.dyer@itdev.co.uk>

The patch e57a66aa8534: "Input: atmel_mxt_ts - read and report
bootloader version" from May 18, 2014, leads to the following static
checker warning:

	drivers/input/touchscreen/atmel_mxt_ts.c:437 mxt_get_bootloader_version()
	warn: signedness bug returning '(-5)'

drivers/input/touchscreen/atmel_mxt_ts.c
   429  static u8 mxt_get_bootloader_version(struct mxt_data *data, u8 val)
   430  {
   431          struct device *dev = &data->client->dev;
   432          u8 buf[3];
   433
   434          if (val & MXT_BOOT_EXTENDED_ID) {
   435                  if (mxt_bootloader_read(data, &buf[0], 3) != 0) {
   436                          dev_err(dev, "%s: i2c failure\n", __func__);
   437                          return -EIO;
                                       ^^^^
This gets truncated into a number from 0-255 and anyway the caller
doesn't check for errors.

(reported by Dan Carpenter)

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index fb0e006..693b163 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -435,7 +435,7 @@ static u8 mxt_get_bootloader_version(struct mxt_data *data, u8 val)
 	if (val & MXT_BOOT_EXTENDED_ID) {
 		if (mxt_bootloader_read(data, &buf[0], 3) != 0) {
 			dev_err(dev, "%s: i2c failure\n", __func__);
-			return -EIO;
+			return val;
 		}
 
 		dev_dbg(dev, "Bootloader ID:%d Version:%d\n", buf[1], buf[2]);
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCHv4 0/4] tsc2005 DT binding
From: Sebastian Reichel @ 2014-05-29 13:33 UTC (permalink / raw)
  To: Dmitry Torokhov, Dmitry Torokhov, linux-input; +Cc: linux-kernel
In-Reply-To: <1400693774-21306-1-git-send-email-sre@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

On Wed, May 21, 2014 at 07:36:10PM +0200, Sebastian Reichel wrote:
> This adds device tree support for the tsc2005 touchscreen
> controller, which is currently only used by the Nokia N900
> board.
> 
> The patch does not update the reset pin handling for platform
> data based probe to avoid merge conflicts. The n900 platform
> code will be removed in the near future (3.17?) and the driver
> can be simplified once that has happened.
> 
> Changes since v3 [0]:
>  * Move common touchscreen DT handling code into its own file
>  * Add regulator support to tsc2005 driver
>  * Added N900 DTS patch for completeness. It should go via
>    Tony's Tree of course.

ping! It would be nice to have this in 3.16, since it makes
the N900 usable with the mainline kernel when booted in DT
mode. The DT bindings haven't changed for more than 3 weeks,
so we don't need to wait longer for feedback from the DT
maintainers AFAIK.

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* [PATCH V5 1/1] Input: mcs_touchkey: use devm_* functions
From: Beomho Seo @ 2014-05-29 14:15 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, jy0922.shim, sachin.kamat
  Cc: myungjoo.ham, jh80.chung, cw00.choi, Beomho Seo
In-Reply-To: <1401372948-13900-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 v5:
- Remove mcs_touchkey_remove function again.
- Add devm_add_action for use action touchkey power off.
Changes in v4:
- free_irq are back again for equivalent transformation.
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 |   60 ++++++++++++++-------------------
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 1da8e0b..be7fe3d 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -96,6 +96,13 @@ static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static void mcs_touchkey_power_off(void *mcs_data)
+{
+	struct mcs_touchkey_data *data = mcs_data;
+
+	data->poweron(false);
+}
+
 static int mcs_touchkey_probe(struct i2c_client *client,
 		const struct i2c_device_id *id)
 {
@@ -113,14 +120,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 +147,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);
 
@@ -173,43 +177,32 @@ static int mcs_touchkey_probe(struct i2c_client *client,
 
 	if (pdata->poweron) {
 		data->poweron = pdata->poweron;
+		error = devm_add_action(&client->dev,
+					mcs_touchkey_power_off, data);
+		if (error) {
+			dev_err(&client->dev,
+				"Failed to register  action, %d\n", error);
+			return error;
+		}
 		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;
+	if (error) {
+		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 +262,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 v5 0/1] Use devm_* functions for Melfas touch device
From: Beomho Seo @ 2014-05-29 14:15 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 v5:
- mcs_touchkey: use devm_add_action.
- mcs5000_ts: applied.

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.

*** BLURB HERE ***

Beomho Seo (1):
  Input: mcs_touchkey: use devm_* functions

 drivers/input/keyboard/mcs_touchkey.c |   60 ++++++++++++++-------------------
 1 file changed, 26 insertions(+), 34 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