lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 8 Aug 2014 09:26:10 -0700
From:	Dmitry Torokhov <dmitry.torokhov@...il.com>
To:	Kiran Padwal <kiran.padwal@...rtplayin.com>
Cc:	support.opensource@...semi.com,
	anthony.olech.opensource@...semi.com, david.chen@...semi.com,
	kiran.padwal21@...il.com, linux-input@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Input: da9052_onkey: convert to use devm_*

Hi Kiran,

On Fri, Aug 08, 2014 at 12:48:44PM +0530, Kiran Padwal wrote:
> Converting to devm functions can make the code smaller and cleaner.

I'd rather not mix use of managed and non-managed resources in one
driver.

Thanks.

> 
> Signed-off-by: Kiran Padwal <kiran.padwal@...rtplayin.com>
> ---
>  drivers/input/misc/da9052_onkey.c |   20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
> index 184c8f2..909441e 100644
> --- a/drivers/input/misc/da9052_onkey.c
> +++ b/drivers/input/misc/da9052_onkey.c
> @@ -84,12 +84,14 @@ static int da9052_onkey_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
> -	input_dev = input_allocate_device();
> -	if (!onkey || !input_dev) {
> -		dev_err(&pdev->dev, "Failed to allocate memory\n");
> -		error = -ENOMEM;
> -		goto err_free_mem;
> +	onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
> +	if (!onkey)
> +		return -ENOMEM;
> +
> +	input_dev = devm_input_allocate_device(&pdev->dev);
> +	if (!input_dev) {
> +		dev_err(&pdev->dev, "Failed to allocate input device\n");
> +		return -ENOMEM;
>  	}
>  
>  	onkey->input = input_dev;
> @@ -108,7 +110,7 @@ static int da9052_onkey_probe(struct platform_device *pdev)
>  	if (error < 0) {
>  		dev_err(onkey->da9052->dev,
>  			"Failed to register ONKEY IRQ: %d\n", error);
> -		goto err_free_mem;
> +		return error;
>  	}
>  
>  	error = input_register_device(onkey->input);
> @@ -124,9 +126,6 @@ static int da9052_onkey_probe(struct platform_device *pdev)
>  err_free_irq:
>  	da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
>  	cancel_delayed_work_sync(&onkey->work);
> -err_free_mem:
> -	input_free_device(input_dev);
> -	kfree(onkey);
>  
>  	return error;
>  }
> @@ -139,7 +138,6 @@ static int da9052_onkey_remove(struct platform_device *pdev)
>  	cancel_delayed_work_sync(&onkey->work);
>  
>  	input_unregister_device(onkey->input);
> -	kfree(onkey);
>  
>  	return 0;
>  }
> -- 
> 1.7.9.5
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists