diff mbox series

[V2,04/10] input: touchscreen: ili210x: Convert to devm_ functions

Message ID 20181220204305.28807-5-marex@denx.de (mailing list archive)
State Superseded
Headers show
Series input: touchscreen: ili210x: Add ILI2511 support | expand

Commit Message

Marek Vasut Dec. 20, 2018, 8:42 p.m. UTC
Convert the driver to dev-managed allocations.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Henrik Rydberg <rydberg@bitmath.org>
Cc: Olivier Sobrie <olivier@sobrie.be>
Cc: Philipp Puschmann <pp@emlix.com>
To: linux-input@vger.kernel.org
---
V2: No change
---
 drivers/input/touchscreen/ili210x.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Dmitry Torokhov Dec. 21, 2018, 1:46 a.m. UTC | #1
Hi Marek,

On Thu, Dec 20, 2018 at 09:42:59PM +0100, Marek Vasut wrote:
> Convert the driver to dev-managed allocations.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Henrik Rydberg <rydberg@bitmath.org>
> Cc: Olivier Sobrie <olivier@sobrie.be>
> Cc: Philipp Puschmann <pp@emlix.com>
> To: linux-input@vger.kernel.org
> ---
> V2: No change
> ---
>  drivers/input/touchscreen/ili210x.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index 11007bf8113c..322241472b9f 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c
> @@ -206,12 +206,10 @@ static int ili210x_i2c_probe(struct i2c_client *client,
>  	xmax = panel.finger_max.x_low | (panel.finger_max.x_high << 8);
>  	ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8);
>  
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	input = input_allocate_device();
> -	if (!priv || !input) {
> -		error = -ENOMEM;
> -		goto err_free_mem;
> -	}
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	input = devm_input_allocate_device(dev);
> +	if (!priv || !input)

With devm prefer allocation and test go together:

	priv = devm_kzalloc(...);
	if (!priv)
		return -ENOMEM;

	input = devm_input_allocate_device(dev);
	if (!input)
		return -ENOMEM;


> +		return -ENOMEM;
>  
>  	priv->client = client;
>  	priv->input = input;
> @@ -273,8 +271,6 @@ static int ili210x_i2c_probe(struct i2c_client *client,
>  err_free_irq:
>  	free_irq(client->irq, priv);
>  err_free_mem:
> -	input_free_device(input);
> -	kfree(priv);
>  	return error;
>  }
>  
> @@ -286,7 +282,6 @@ static int ili210x_i2c_remove(struct i2c_client *client)
>  	free_irq(priv->client->irq, priv);
>  	cancel_delayed_work_sync(&priv->dwork);
>  	input_unregister_device(priv->input);

Not needed, will be handled by devm.

> -	kfree(priv);
>  
>  	return 0;
>  }
> -- 
> 2.19.2
> 

Thanks.
Marek Vasut Dec. 21, 2018, 2:08 a.m. UTC | #2
On 12/21/2018 02:46 AM, Dmitry Torokhov wrote:
> Hi Marek,
> 
> On Thu, Dec 20, 2018 at 09:42:59PM +0100, Marek Vasut wrote:
>> Convert the driver to dev-managed allocations.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Cc: Henrik Rydberg <rydberg@bitmath.org>
>> Cc: Olivier Sobrie <olivier@sobrie.be>
>> Cc: Philipp Puschmann <pp@emlix.com>
>> To: linux-input@vger.kernel.org
>> ---
>> V2: No change
>> ---
>>  drivers/input/touchscreen/ili210x.c | 13 ++++---------
>>  1 file changed, 4 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
>> index 11007bf8113c..322241472b9f 100644
>> --- a/drivers/input/touchscreen/ili210x.c
>> +++ b/drivers/input/touchscreen/ili210x.c
>> @@ -206,12 +206,10 @@ static int ili210x_i2c_probe(struct i2c_client *client,
>>  	xmax = panel.finger_max.x_low | (panel.finger_max.x_high << 8);
>>  	ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8);
>>  
>> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
>> -	input = input_allocate_device();
>> -	if (!priv || !input) {
>> -		error = -ENOMEM;
>> -		goto err_free_mem;
>> -	}
>> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>> +	input = devm_input_allocate_device(dev);
>> +	if (!priv || !input)
> 
> With devm prefer allocation and test go together:
> 
> 	priv = devm_kzalloc(...);
> 	if (!priv)
> 		return -ENOMEM;
> 
> 	input = devm_input_allocate_device(dev);
> 	if (!input)
> 		return -ENOMEM;
> 
> 
>> +		return -ENOMEM;
>>  
>>  	priv->client = client;
>>  	priv->input = input;
>> @@ -273,8 +271,6 @@ static int ili210x_i2c_probe(struct i2c_client *client,
>>  err_free_irq:
>>  	free_irq(client->irq, priv);
>>  err_free_mem:
>> -	input_free_device(input);
>> -	kfree(priv);
>>  	return error;
>>  }
>>  
>> @@ -286,7 +282,6 @@ static int ili210x_i2c_remove(struct i2c_client *client)
>>  	free_irq(priv->client->irq, priv);
>>  	cancel_delayed_work_sync(&priv->dwork);
>>  	input_unregister_device(priv->input);
> 
> Not needed, will be handled by devm.

All fixed in V3
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 11007bf8113c..322241472b9f 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -206,12 +206,10 @@  static int ili210x_i2c_probe(struct i2c_client *client,
 	xmax = panel.finger_max.x_low | (panel.finger_max.x_high << 8);
 	ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8);
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	input = input_allocate_device();
-	if (!priv || !input) {
-		error = -ENOMEM;
-		goto err_free_mem;
-	}
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	input = devm_input_allocate_device(dev);
+	if (!priv || !input)
+		return -ENOMEM;
 
 	priv->client = client;
 	priv->input = input;
@@ -273,8 +271,6 @@  static int ili210x_i2c_probe(struct i2c_client *client,
 err_free_irq:
 	free_irq(client->irq, priv);
 err_free_mem:
-	input_free_device(input);
-	kfree(priv);
 	return error;
 }
 
@@ -286,7 +282,6 @@  static int ili210x_i2c_remove(struct i2c_client *client)
 	free_irq(priv->client->irq, priv);
 	cancel_delayed_work_sync(&priv->dwork);
 	input_unregister_device(priv->input);
-	kfree(priv);
 
 	return 0;
 }