Patchwork [2/3] rtc: pcf8563: Convert to use devm_* API

login
register
mail settings
Submitter Axel Lin
Date April 14, 2013, 2:19 p.m.
Message ID <1365949170.16287.1.camel@phoenix>
Download mbox | patch
Permalink /patch/236444/
State New
Headers show

Comments

Axel Lin - April 14, 2013, 2:19 p.m.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/rtc/rtc-pcf8563.c |   29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)
Jingoo Han - April 15, 2013, 12:18 a.m.
On Sunday, April 14, 2013 11:20 PM, Axel Lin wrote:
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Hi Axel Lin,

The similar patch was already submitted and will be 
merged to mm-tree.

http://lkml.org/lkml/2013/4/1/117


Best regards,
Jingoo Han

> ---
>  drivers/rtc/rtc-pcf8563.c |   29 +++++++----------------------
>  1 file changed, 7 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
> index f7daf18..31295a8 100644
> --- a/drivers/rtc/rtc-pcf8563.c
> +++ b/drivers/rtc/rtc-pcf8563.c
> @@ -245,14 +245,13 @@ static int pcf8563_probe(struct i2c_client *client,
>  {
>  	struct pcf8563 *pcf8563;
> 
> -	int err = 0;
> -
>  	dev_dbg(&client->dev, "%s\n", __func__);
> 
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
>  		return -ENODEV;
> 
> -	pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL);
> +	pcf8563 = devm_kzalloc(&client->dev, sizeof(struct pcf8563),
> +			       GFP_KERNEL);
>  	if (!pcf8563)
>  		return -ENOMEM;
> 
> @@ -260,31 +259,17 @@ static int pcf8563_probe(struct i2c_client *client,
> 
>  	i2c_set_clientdata(client, pcf8563);
> 
> -	pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name,
> -				&client->dev, &pcf8563_rtc_ops, THIS_MODULE);
> -
> -	if (IS_ERR(pcf8563->rtc)) {
> -		err = PTR_ERR(pcf8563->rtc);
> -		goto exit_kfree;
> -	}
> +	pcf8563->rtc = devm_rtc_device_register(&client->dev,
> +						pcf8563_driver.driver.name,
> +						&pcf8563_rtc_ops, THIS_MODULE);
> +	if (IS_ERR(pcf8563->rtc))
> +		return PTR_ERR(pcf8563->rtc);
> 
>  	return 0;
> -
> -exit_kfree:
> -	kfree(pcf8563);
> -
> -	return err;
>  }
> 
>  static int pcf8563_remove(struct i2c_client *client)
>  {
> -	struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
> -
> -	if (pcf8563->rtc)
> -		rtc_device_unregister(pcf8563->rtc);
> -
> -	kfree(pcf8563);
> -
>  	return 0;
>  }
> 
> --
> 1.7.10.4
>

Patch

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index f7daf18..31295a8 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -245,14 +245,13 @@  static int pcf8563_probe(struct i2c_client *client,
 {
 	struct pcf8563 *pcf8563;
 
-	int err = 0;
-
 	dev_dbg(&client->dev, "%s\n", __func__);
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -ENODEV;
 
-	pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL);
+	pcf8563 = devm_kzalloc(&client->dev, sizeof(struct pcf8563),
+			       GFP_KERNEL);
 	if (!pcf8563)
 		return -ENOMEM;
 
@@ -260,31 +259,17 @@  static int pcf8563_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, pcf8563);
 
-	pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name,
-				&client->dev, &pcf8563_rtc_ops, THIS_MODULE);
-
-	if (IS_ERR(pcf8563->rtc)) {
-		err = PTR_ERR(pcf8563->rtc);
-		goto exit_kfree;
-	}
+	pcf8563->rtc = devm_rtc_device_register(&client->dev,
+						pcf8563_driver.driver.name,
+						&pcf8563_rtc_ops, THIS_MODULE);
+	if (IS_ERR(pcf8563->rtc))
+		return PTR_ERR(pcf8563->rtc);
 
 	return 0;
-
-exit_kfree:
-	kfree(pcf8563);
-
-	return err;
 }
 
 static int pcf8563_remove(struct i2c_client *client)
 {
-	struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
-
-	if (pcf8563->rtc)
-		rtc_device_unregister(pcf8563->rtc);
-
-	kfree(pcf8563);
-
 	return 0;
 }