diff mbox

[1/3] rtc: isl12022: Convert to use devm_* API

Message ID 1365949109.16287.0.camel@phoenix
State Rejected
Headers show

Commit Message

Axel Lin April 14, 2013, 2:18 p.m. UTC
Also cleanup a few unnecessary empty lines.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/rtc/rtc-isl12022.c |   34 ++++++++--------------------------
 1 file changed, 8 insertions(+), 26 deletions(-)

Comments

Jingoo Han April 15, 2013, 12:16 a.m. UTC | #1
On Sunday, April 14, 2013 11:18 PM, Axel Lin wrote:
> 
> Also cleanup a few unnecessary empty lines.
> 
> 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/116


Best regards,
Jingoo Han

> ---
>  drivers/rtc/rtc-isl12022.c |   34 ++++++++--------------------------
>  1 file changed, 8 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c
> index 6b4298e..a367e5e 100644
> --- a/drivers/rtc/rtc-isl12022.c
> +++ b/drivers/rtc/rtc-isl12022.c
> @@ -39,7 +39,6 @@
> 
>  #define ISL12022_INT_WRTC	(1 << 6)
> 
> -
>  static struct i2c_driver isl12022_driver;
> 
>  struct isl12022 {
> @@ -48,7 +47,6 @@ struct isl12022 {
>  	bool write_enabled;	/* true if write enable is set */
>  };
> 
> -
>  static int isl12022_read_regs(struct i2c_client *client, uint8_t reg,
>  			      uint8_t *data, size_t n)
>  {
> @@ -80,7 +78,6 @@ static int isl12022_read_regs(struct i2c_client *client, uint8_t reg,
>  	return 0;
>  }
> 
> -
>  static int isl12022_write_reg(struct i2c_client *client,
>  			      uint8_t reg, uint8_t val)
>  {
> @@ -98,7 +95,6 @@ static int isl12022_write_reg(struct i2c_client *client,
>  	return 0;
>  }
> 
> -
>  /*
>   * In the routines that deal directly with the isl12022 hardware, we use
>   * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
> @@ -252,12 +248,11 @@ static int isl12022_probe(struct i2c_client *client,
>  {
>  	struct isl12022 *isl12022;
> 
> -	int ret = 0;
> -
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
>  		return -ENODEV;
> 
> -	isl12022 = kzalloc(sizeof(struct isl12022), GFP_KERNEL);
> +	isl12022 = devm_kzalloc(&client->dev, sizeof(struct isl12022),
> +				GFP_KERNEL);
>  	if (!isl12022)
>  		return -ENOMEM;
> 
> @@ -265,31 +260,18 @@ static int isl12022_probe(struct i2c_client *client,
> 
>  	i2c_set_clientdata(client, isl12022);
> 
> -	isl12022->rtc = rtc_device_register(isl12022_driver.driver.name,
> -					    &client->dev,
> -					    &isl12022_rtc_ops,
> -					    THIS_MODULE);
> -
> -	if (IS_ERR(isl12022->rtc)) {
> -		ret = PTR_ERR(isl12022->rtc);
> -		goto exit_kfree;
> -	}
> +	isl12022->rtc = devm_rtc_device_register(&client->dev,
> +						 isl12022_driver.driver.name,
> +						 &isl12022_rtc_ops,
> +						 THIS_MODULE);
> +	if (IS_ERR(isl12022->rtc))
> +		return PTR_ERR(isl12022->rtc);
> 
>  	return 0;
> -
> -exit_kfree:
> -	kfree(isl12022);
> -
> -	return ret;
>  }
> 
>  static int isl12022_remove(struct i2c_client *client)
>  {
> -	struct isl12022 *isl12022 = i2c_get_clientdata(client);
> -
> -	rtc_device_unregister(isl12022->rtc);
> -	kfree(isl12022);
> -
>  	return 0;
>  }
> 
> --
> 1.7.10.4
>
diff mbox

Patch

diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c
index 6b4298e..a367e5e 100644
--- a/drivers/rtc/rtc-isl12022.c
+++ b/drivers/rtc/rtc-isl12022.c
@@ -39,7 +39,6 @@ 
 
 #define ISL12022_INT_WRTC	(1 << 6)
 
-
 static struct i2c_driver isl12022_driver;
 
 struct isl12022 {
@@ -48,7 +47,6 @@  struct isl12022 {
 	bool write_enabled;	/* true if write enable is set */
 };
 
-
 static int isl12022_read_regs(struct i2c_client *client, uint8_t reg,
 			      uint8_t *data, size_t n)
 {
@@ -80,7 +78,6 @@  static int isl12022_read_regs(struct i2c_client *client, uint8_t reg,
 	return 0;
 }
 
-
 static int isl12022_write_reg(struct i2c_client *client,
 			      uint8_t reg, uint8_t val)
 {
@@ -98,7 +95,6 @@  static int isl12022_write_reg(struct i2c_client *client,
 	return 0;
 }
 
-
 /*
  * In the routines that deal directly with the isl12022 hardware, we use
  * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -252,12 +248,11 @@  static int isl12022_probe(struct i2c_client *client,
 {
 	struct isl12022 *isl12022;
 
-	int ret = 0;
-
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -ENODEV;
 
-	isl12022 = kzalloc(sizeof(struct isl12022), GFP_KERNEL);
+	isl12022 = devm_kzalloc(&client->dev, sizeof(struct isl12022),
+				GFP_KERNEL);
 	if (!isl12022)
 		return -ENOMEM;
 
@@ -265,31 +260,18 @@  static int isl12022_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, isl12022);
 
-	isl12022->rtc = rtc_device_register(isl12022_driver.driver.name,
-					    &client->dev,
-					    &isl12022_rtc_ops,
-					    THIS_MODULE);
-
-	if (IS_ERR(isl12022->rtc)) {
-		ret = PTR_ERR(isl12022->rtc);
-		goto exit_kfree;
-	}
+	isl12022->rtc = devm_rtc_device_register(&client->dev,
+						 isl12022_driver.driver.name,
+						 &isl12022_rtc_ops,
+						 THIS_MODULE);
+	if (IS_ERR(isl12022->rtc))
+		return PTR_ERR(isl12022->rtc);
 
 	return 0;
-
-exit_kfree:
-	kfree(isl12022);
-
-	return ret;
 }
 
 static int isl12022_remove(struct i2c_client *client)
 {
-	struct isl12022 *isl12022 = i2c_get_clientdata(client);
-
-	rtc_device_unregister(isl12022->rtc);
-	kfree(isl12022);
-
 	return 0;
 }