Skip to contentSkip to conversation

hwmon: (asc7621) Convert to use devm_ functions

PATCH Superseded Guenter Roeck 2 participants 2 messages Jun 15, 2012 – Jun 16, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 23/95 hwmon: (asc7621) Convert to use devm_ functions

Convert to use devm_ functions to reduce code size and simplify the code.

---
 drivers/hwmon/asc7621.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hwmon/asc7621.c +2 -3
index 7caa242..b867aab7 100644
@@ -1109,7 +1109,8 @@ asc7621_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
 		return -EIO;
 
-	data = kzalloc(sizeof(struct asc7621_data), GFP_KERNEL);
+	data = devm_kzalloc(&client->dev, sizeof(struct asc7621_data),
+			    GFP_KERNEL);
 	if (data = NULL)
 		return -ENOMEM;
 
@@ -1143,7 +1144,6 @@ exit_remove:
 				   &(asc7621_params[i].sda.dev_attr));
 	}
 
-	kfree(data);
 	return err;
 }
 
@@ -1192,7 +1192,6 @@ static int asc7621_remove(struct i2c_client *client)
 				   &(asc7621_params[i].sda.dev_attr));
 	}
 
-	kfree(data);
 	return 0;
 }
 
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
maintainer Acked-by on v1 23/95
#1 lore raw
Quoted 5 lines · Guenter Roeck

Convert to use devm_ functions to reduce code size and simplify the code.

Thanks Guenter!

Quoted 37 lines

---
 drivers/hwmon/asc7621.c |    5 ++---

 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hwmon/asc7621.c +2 -1
index 7caa242..b867aab7 100644
@@ -1109,7 +1109,8 @@ asc7621_probe(struct i2c_client *client, const
 struct i2c_device_id *id)
        if (!i2c_check_functionality(client->adapter,
 I2C_FUNC_SMBUS_BYTE_DATA))
                return -EIO;
 
-       data = kzalloc(sizeof(struct asc7621_data), GFP_KERNEL);
+       data = devm_kzalloc(&client->dev, sizeof(struct asc7621_data),
+                           GFP_KERNEL);
        if (data == NULL)

               return -ENOMEM;

drivers/hwmon/asc7621.c +0 -3
@@ -1143,7 +1144,6 @@ exit_remove:
                                   &(asc7621_params[i].sda.dev_attr));
        }
 
-       kfree(data);
        return err;
  }
 
@@ -1192,7 +1192,6 @@ static int asc7621_remove(struct i2c_client *client)
                                   &(asc7621_params[i].sda.dev_attr));
        }
 
-       kfree(data);
        return 0;
  }
 
--
Quoted 2 lines

1.7.9.7

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors