linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Lothar Waßmann" <LW@KARO-electronics.de>
Cc: linux-input@vger.kernel.org,
	Simon Budig <simon.budig@kernelconcepts.de>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>, Rob Landley <rob@landley.net>,
	Thierry Reding <thierry.reding@gmail.com>,
	Grant Likely <grant.likely@linaro.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Shawn Guo <shawn.guo@linaro.org>,
	Silvio F <silvio.fricke@gmail.com>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Jingoo Han <jg1.han@samsung.com>,
	Fugang Duan <B38611@freescale.com>,
	Sachin Kamat <sachin.kamat@linaro.org>,
	devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2 1/3] Input: edt_ft5x06: use devm_* functions where appropriate
Date: Thu, 16 Jan 2014 16:28:13 -0800	[thread overview]
Message-ID: <20140117002813.GB837@core.coreip.homeip.net> (raw)
In-Reply-To: <1389859338-11685-2-git-send-email-LW@KARO-electronics.de>

On Thu, Jan 16, 2014 at 09:02:16AM +0100, Lothar Waßmann wrote:
> Simplify the error path and remove() function by using devm_*
> functions for requesting gpios and irq and allocating the input
> device.
> 
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>

Applied, thank you.

> ---
>  drivers/input/touchscreen/edt-ft5x06.c |   62 ++++++++++---------------------
>  1 files changed, 20 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index af0d68b..acb6b9f 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -623,8 +623,9 @@ static int edt_ft5x06_ts_reset(struct i2c_client *client,
>  
>  	if (gpio_is_valid(reset_pin)) {
>  		/* this pulls reset down, enabling the low active reset */
> -		error = gpio_request_one(reset_pin, GPIOF_OUT_INIT_LOW,
> -					 "edt-ft5x06 reset");
> +		error = devm_gpio_request_one(&client->dev, reset_pin,
> +					GPIOF_OUT_INIT_LOW,
> +					"edt-ft5x06 reset");
>  		if (error) {
>  			dev_err(&client->dev,
>  				"Failed to request GPIO %d as reset pin, error %d\n",
> @@ -723,7 +724,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  		return error;
>  
>  	if (gpio_is_valid(pdata->irq_pin)) {
> -		error = gpio_request_one(pdata->irq_pin,
> +		error = devm_gpio_request_one(&client->dev, pdata->irq_pin,
>  					 GPIOF_IN, "edt-ft5x06 irq");
>  		if (error) {
>  			dev_err(&client->dev,
> @@ -734,11 +735,10 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  	}
>  
>  	tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL);
> -	input = input_allocate_device();
> -	if (!tsdata || !input) {
> -		dev_err(&client->dev, "failed to allocate driver data.\n");
> -		error = -ENOMEM;
> -		goto err_free_mem;
> +	input = devm_input_allocate_device(&client->dev);
> +	if (!input) {
> +		dev_err(&client->dev, "failed to allocate input device.\n");
> +		return -ENOMEM;
>  	}
>  
>  	mutex_init(&tsdata->mutex);
> @@ -749,7 +749,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  	error = edt_ft5x06_ts_identify(client, tsdata->name, fw_version);
>  	if (error) {
>  		dev_err(&client->dev, "touchscreen probe failed\n");
> -		goto err_free_mem;
> +		return error;
>  	}
>  
>  	edt_ft5x06_ts_get_defaults(tsdata, pdata);
> @@ -776,27 +776,30 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  	error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, 0);
>  	if (error) {
>  		dev_err(&client->dev, "Unable to init MT slots.\n");
> -		goto err_free_mem;
> +		return error;
>  	}
>  
>  	input_set_drvdata(input, tsdata);
>  	i2c_set_clientdata(client, tsdata);
>  
> -	error = request_threaded_irq(client->irq, NULL, edt_ft5x06_ts_isr,
> -				     IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> -				     client->name, tsdata);
> +	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
> +					edt_ft5x06_ts_isr,
> +					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> +					client->name, tsdata);
>  	if (error) {
>  		dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
> -		goto err_free_mem;
> +		return error;
>  	}
>  
>  	error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group);
>  	if (error)
> -		goto err_free_irq;
> +		return error;
>  
>  	error = input_register_device(input);
> -	if (error)
> -		goto err_remove_attrs;
> +	if (error) {
> +		sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
> +		return error;
> +	}
>  
>  	edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev));
>  	device_init_wakeup(&client->dev, 1);
> @@ -806,40 +809,15 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  		pdata->irq_pin, pdata->reset_pin);
>  
>  	return 0;
> -
> -err_remove_attrs:
> -	sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
> -err_free_irq:
> -	free_irq(client->irq, tsdata);
> -err_free_mem:
> -	input_free_device(input);
> -	kfree(tsdata);
> -
> -	if (gpio_is_valid(pdata->irq_pin))
> -		gpio_free(pdata->irq_pin);
> -
> -	return error;
>  }
>  
>  static int edt_ft5x06_ts_remove(struct i2c_client *client)
>  {
> -	const struct edt_ft5x06_platform_data *pdata =
> -						dev_get_platdata(&client->dev);
>  	struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
>  
>  	edt_ft5x06_ts_teardown_debugfs(tsdata);
>  	sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
>  
> -	free_irq(client->irq, tsdata);
> -	input_unregister_device(tsdata->input);
> -
> -	if (gpio_is_valid(pdata->irq_pin))
> -		gpio_free(pdata->irq_pin);
> -	if (gpio_is_valid(pdata->reset_pin))
> -		gpio_free(pdata->reset_pin);
> -
> -	kfree(tsdata);
> -
>  	return 0;
>  }
>  
> -- 
> 1.7.2.5
> 

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

  reply	other threads:[~2014-01-17  0:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-16  8:02 [PATCHv2 0/3] Input: edt-ft5x06: Add DT support Lothar Waßmann
2014-01-16  8:02 ` [PATCHv2 1/3] Input: edt_ft5x06: use devm_* functions where appropriate Lothar Waßmann
2014-01-17  0:28   ` Dmitry Torokhov [this message]
2014-01-16  8:02 ` [PATCHv2 2/3] DT: Add vendor prefix for Emerging Display Technologies Lothar Waßmann
2014-01-16  8:02 ` [PATCHv2 3/3] Input: edt-ft5x06: Add DT support Lothar Waßmann
2014-01-17  0:26   ` Dmitry Torokhov
2014-01-17  1:36     ` Jingoo Han
2014-01-17  1:46     ` Simon Budig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140117002813.GB837@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=B38611@freescale.com \
    --cc=LW@KARO-electronics.de \
    --cc=devicetree@vger.kernel.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=galak@codeaurora.org \
    --cc=grant.likely@linaro.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jg1.han@samsung.com \
    --cc=jic23@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=rob@landley.net \
    --cc=robh+dt@kernel.org \
    --cc=sachin.kamat@linaro.org \
    --cc=shawn.guo@linaro.org \
    --cc=silvio.fricke@gmail.com \
    --cc=simon.budig@kernelconcepts.de \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).