All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: max7359 - Introduce the use of managed interfaces
@ 2014-07-19 10:06 Himangi Saraogi
  2014-07-19 23:20 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-07-19 10:06 UTC (permalink / raw)
  To: Jingoo Han, Dmitry Torokhov, linux-kernel; +Cc: Julia Lawall

This patch introduces the use of managed interfaces like devm_kzalloc,
devm_input_allocate_device, devm_request_threaded_irq etc. and does away
with the calls to free the allocated memory. The remove function is no
longer required and is completely done away with. Also, the labels in
the probe function are removed.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 drivers/input/keyboard/max7359_keypad.c | 38 +++++++++------------------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index 430b545..b0ef607 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -203,12 +203,12 @@ static int max7359_probe(struct i2c_client *client,
 
 	dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
 
-	keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
-	input_dev = input_allocate_device();
+	keypad = devm_kzalloc(&client->dev, sizeof(struct max7359_keypad),
+			      GFP_KERNEL);
+	input_dev = devm_input_allocate_device(&client->dev);
 	if (!keypad || !input_dev) {
 		dev_err(&client->dev, "failed to allocate memory\n");
-		error = -ENOMEM;
-		goto failed_free_mem;
+		return -ENOMEM;
 	}
 
 	keypad->client = client;
@@ -230,19 +230,20 @@ static int max7359_probe(struct i2c_client *client,
 
 	max7359_build_keycode(keypad, keymap_data);
 
-	error = request_threaded_irq(client->irq, NULL, max7359_interrupt,
-				     IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-				     client->name, keypad);
+	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+					  max7359_interrupt,
+					  IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+					  client->name, keypad);
 	if (error) {
 		dev_err(&client->dev, "failed to register interrupt\n");
-		goto failed_free_mem;
+		return error;
 	}
 
 	/* Register the input device */
 	error = input_register_device(input_dev);
 	if (error) {
 		dev_err(&client->dev, "failed to register input device\n");
-		goto failed_free_irq;
+		return error;
 	}
 
 	/* Initialize MAX7359 */
@@ -252,24 +253,6 @@ static int max7359_probe(struct i2c_client *client,
 	device_init_wakeup(&client->dev, 1);
 
 	return 0;
-
-failed_free_irq:
-	free_irq(client->irq, keypad);
-failed_free_mem:
-	input_free_device(input_dev);
-	kfree(keypad);
-	return error;
-}
-
-static int max7359_remove(struct i2c_client *client)
-{
-	struct max7359_keypad *keypad = i2c_get_clientdata(client);
-
-	free_irq(client->irq, keypad);
-	input_unregister_device(keypad->input_dev);
-	kfree(keypad);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -313,7 +296,6 @@ static struct i2c_driver max7359_i2c_driver = {
 		.pm   = &max7359_pm,
 	},
 	.probe		= max7359_probe,
-	.remove		= max7359_remove,
 	.id_table	= max7359_ids,
 };
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Input: max7359 - Introduce the use of managed interfaces
  2014-07-19 10:06 [PATCH] Input: max7359 - Introduce the use of managed interfaces Himangi Saraogi
@ 2014-07-19 23:20 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-07-19 23:20 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: Jingoo Han, linux-kernel, Julia Lawall

On Sat, Jul 19, 2014 at 03:36:54PM +0530, Himangi Saraogi wrote:
> This patch introduces the use of managed interfaces like devm_kzalloc,
> devm_input_allocate_device, devm_request_threaded_irq etc. and does away
> with the calls to free the allocated memory. The remove function is no
> longer required and is completely done away with. Also, the labels in
> the probe function are removed.
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Applied, thank you.

> ---
>  drivers/input/keyboard/max7359_keypad.c | 38 +++++++++------------------------
>  1 file changed, 10 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
> index 430b545..b0ef607 100644
> --- a/drivers/input/keyboard/max7359_keypad.c
> +++ b/drivers/input/keyboard/max7359_keypad.c
> @@ -203,12 +203,12 @@ static int max7359_probe(struct i2c_client *client,
>  
>  	dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
>  
> -	keypad = kzalloc(sizeof(struct max7359_keypad), GFP_KERNEL);
> -	input_dev = input_allocate_device();
> +	keypad = devm_kzalloc(&client->dev, sizeof(struct max7359_keypad),
> +			      GFP_KERNEL);
> +	input_dev = devm_input_allocate_device(&client->dev);
>  	if (!keypad || !input_dev) {
>  		dev_err(&client->dev, "failed to allocate memory\n");
> -		error = -ENOMEM;
> -		goto failed_free_mem;
> +		return -ENOMEM;
>  	}
>  
>  	keypad->client = client;
> @@ -230,19 +230,20 @@ static int max7359_probe(struct i2c_client *client,
>  
>  	max7359_build_keycode(keypad, keymap_data);
>  
> -	error = request_threaded_irq(client->irq, NULL, max7359_interrupt,
> -				     IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> -				     client->name, keypad);
> +	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
> +					  max7359_interrupt,
> +					  IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> +					  client->name, keypad);
>  	if (error) {
>  		dev_err(&client->dev, "failed to register interrupt\n");
> -		goto failed_free_mem;
> +		return error;
>  	}
>  
>  	/* Register the input device */
>  	error = input_register_device(input_dev);
>  	if (error) {
>  		dev_err(&client->dev, "failed to register input device\n");
> -		goto failed_free_irq;
> +		return error;
>  	}
>  
>  	/* Initialize MAX7359 */
> @@ -252,24 +253,6 @@ static int max7359_probe(struct i2c_client *client,
>  	device_init_wakeup(&client->dev, 1);
>  
>  	return 0;
> -
> -failed_free_irq:
> -	free_irq(client->irq, keypad);
> -failed_free_mem:
> -	input_free_device(input_dev);
> -	kfree(keypad);
> -	return error;
> -}
> -
> -static int max7359_remove(struct i2c_client *client)
> -{
> -	struct max7359_keypad *keypad = i2c_get_clientdata(client);
> -
> -	free_irq(client->irq, keypad);
> -	input_unregister_device(keypad->input_dev);
> -	kfree(keypad);
> -
> -	return 0;
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> @@ -313,7 +296,6 @@ static struct i2c_driver max7359_i2c_driver = {
>  		.pm   = &max7359_pm,
>  	},
>  	.probe		= max7359_probe,
> -	.remove		= max7359_remove,
>  	.id_table	= max7359_ids,
>  };
>  
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-19 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-19 10:06 [PATCH] Input: max7359 - Introduce the use of managed interfaces Himangi Saraogi
2014-07-19 23:20 ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.