提交 64adf398 编写于 作者: G Guenter Roeck

hwmon: (asb100) Convert to use devm_ functions

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

Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 f9286434
...@@ -787,12 +787,10 @@ static int asb100_probe(struct i2c_client *client, ...@@ -787,12 +787,10 @@ static int asb100_probe(struct i2c_client *client,
int err; int err;
struct asb100_data *data; struct asb100_data *data;
data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL); data = devm_kzalloc(&client->dev, sizeof(struct asb100_data),
if (!data) { GFP_KERNEL);
pr_debug("probe failed, kzalloc failed!\n"); if (!data)
err = -ENOMEM; return -ENOMEM;
goto ERROR0;
}
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
mutex_init(&data->lock); mutex_init(&data->lock);
...@@ -801,7 +799,7 @@ static int asb100_probe(struct i2c_client *client, ...@@ -801,7 +799,7 @@ static int asb100_probe(struct i2c_client *client,
/* Attach secondary lm75 clients */ /* Attach secondary lm75 clients */
err = asb100_detect_subclients(client); err = asb100_detect_subclients(client);
if (err) if (err)
goto ERROR1; return err;
/* Initialize the chip */ /* Initialize the chip */
asb100_init_client(client); asb100_init_client(client);
...@@ -829,9 +827,6 @@ static int asb100_probe(struct i2c_client *client, ...@@ -829,9 +827,6 @@ static int asb100_probe(struct i2c_client *client,
ERROR3: ERROR3:
i2c_unregister_device(data->lm75[1]); i2c_unregister_device(data->lm75[1]);
i2c_unregister_device(data->lm75[0]); i2c_unregister_device(data->lm75[0]);
ERROR1:
kfree(data);
ERROR0:
return err; return err;
} }
...@@ -845,8 +840,6 @@ static int asb100_remove(struct i2c_client *client) ...@@ -845,8 +840,6 @@ static int asb100_remove(struct i2c_client *client)
i2c_unregister_device(data->lm75[1]); i2c_unregister_device(data->lm75[1]);
i2c_unregister_device(data->lm75[0]); i2c_unregister_device(data->lm75[0]);
kfree(data);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册