diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-02-22 11:56:43 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:27:45 -0400 |
commit | 8b313ca7f1b98263ce22519b25a9c2a362eeb898 (patch) | |
tree | 36c4e576662996be3fcac1f34d339dcd53e569e3 /drivers/hwmon/pmbus/ucd9200.c | |
parent | 07404aab52f5106ec436692474cf8f40978f5dac (diff) |
hwmon: (pmbus) Convert pmbus drivers to use devm_kzalloc
Marginally less code and eliminate the possibility of memory leaks.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/pmbus/ucd9200.c')
-rw-r--r-- | drivers/hwmon/pmbus/ucd9200.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c index 629d0c93cac6..c0d41b993a53 100644 --- a/drivers/hwmon/pmbus/ucd9200.c +++ b/drivers/hwmon/pmbus/ucd9200.c | |||
@@ -81,7 +81,8 @@ static int ucd9200_probe(struct i2c_client *client, | |||
81 | "Device mismatch: Configured %s, detected %s\n", | 81 | "Device mismatch: Configured %s, detected %s\n", |
82 | id->name, mid->name); | 82 | id->name, mid->name); |
83 | 83 | ||
84 | info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL); | 84 | info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), |
85 | GFP_KERNEL); | ||
85 | if (!info) | 86 | if (!info) |
86 | return -ENOMEM; | 87 | return -ENOMEM; |
87 | 88 | ||
@@ -89,7 +90,7 @@ static int ucd9200_probe(struct i2c_client *client, | |||
89 | block_buffer); | 90 | block_buffer); |
90 | if (ret < 0) { | 91 | if (ret < 0) { |
91 | dev_err(&client->dev, "Failed to read phase information\n"); | 92 | dev_err(&client->dev, "Failed to read phase information\n"); |
92 | goto out; | 93 | return ret; |
93 | } | 94 | } |
94 | 95 | ||
95 | /* | 96 | /* |
@@ -106,8 +107,7 @@ static int ucd9200_probe(struct i2c_client *client, | |||
106 | } | 107 | } |
107 | if (!info->pages) { | 108 | if (!info->pages) { |
108 | dev_err(&client->dev, "No rails configured\n"); | 109 | dev_err(&client->dev, "No rails configured\n"); |
109 | ret = -ENODEV; | 110 | return -ENODEV; |
110 | goto out; | ||
111 | } | 111 | } |
112 | dev_info(&client->dev, "%d rails configured\n", info->pages); | 112 | dev_info(&client->dev, "%d rails configured\n", info->pages); |
113 | 113 | ||
@@ -137,7 +137,7 @@ static int ucd9200_probe(struct i2c_client *client, | |||
137 | if (ret < 0) { | 137 | if (ret < 0) { |
138 | dev_err(&client->dev, | 138 | dev_err(&client->dev, |
139 | "Failed to initialize PHASE registers\n"); | 139 | "Failed to initialize PHASE registers\n"); |
140 | goto out; | 140 | return ret; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | if (info->pages > 1) | 143 | if (info->pages > 1) |
@@ -160,22 +160,12 @@ static int ucd9200_probe(struct i2c_client *client, | |||
160 | if (mid->driver_data == ucd9240) | 160 | if (mid->driver_data == ucd9240) |
161 | info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12; | 161 | info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12; |
162 | 162 | ||
163 | ret = pmbus_do_probe(client, mid, info); | 163 | return pmbus_do_probe(client, mid, info); |
164 | if (ret < 0) | ||
165 | goto out; | ||
166 | return 0; | ||
167 | out: | ||
168 | kfree(info); | ||
169 | return ret; | ||
170 | } | 164 | } |
171 | 165 | ||
172 | static int ucd9200_remove(struct i2c_client *client) | 166 | static int ucd9200_remove(struct i2c_client *client) |
173 | { | 167 | { |
174 | const struct pmbus_driver_info *info; | ||
175 | |||
176 | info = pmbus_get_driver_info(client); | ||
177 | pmbus_do_remove(client); | 168 | pmbus_do_remove(client); |
178 | kfree(info); | ||
179 | return 0; | 169 | return 0; |
180 | } | 170 | } |
181 | 171 | ||