diff options
author | Mark Brown <broonie@linaro.org> | 2013-08-07 17:02:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-12 15:16:51 -0400 |
commit | cffedd6794bb32c4fbc03600fac61beca7950f08 (patch) | |
tree | 9c33c56bea1e7eceee1aa1ae42eaa81cc221e387 /drivers/usb/misc | |
parent | 42416cc81f4990ad8d425b41a0fc8cd985eb5fa5 (diff) |
usb: misc: usb3503: Convert to devm_ APIs
Saves us a bit of code.
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/usb3503.c | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index 4e3a2d2fc450..41b422824c87 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c | |||
@@ -187,7 +187,7 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
187 | const u32 *property; | 187 | const u32 *property; |
188 | int len; | 188 | int len; |
189 | 189 | ||
190 | hub = kzalloc(sizeof(struct usb3503), GFP_KERNEL); | 190 | hub = devm_kzalloc(&i2c->dev, sizeof(struct usb3503), GFP_KERNEL); |
191 | if (!hub) { | 191 | if (!hub) { |
192 | dev_err(&i2c->dev, "private data alloc fail\n"); | 192 | dev_err(&i2c->dev, "private data alloc fail\n"); |
193 | return err; | 193 | return err; |
@@ -229,35 +229,35 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
229 | } | 229 | } |
230 | 230 | ||
231 | if (gpio_is_valid(hub->gpio_intn)) { | 231 | if (gpio_is_valid(hub->gpio_intn)) { |
232 | err = gpio_request_one(hub->gpio_intn, | 232 | err = devm_gpio_request_one(&i2c->dev, hub->gpio_intn, |
233 | GPIOF_OUT_INIT_HIGH, "usb3503 intn"); | 233 | GPIOF_OUT_INIT_HIGH, "usb3503 intn"); |
234 | if (err) { | 234 | if (err) { |
235 | dev_err(&i2c->dev, | 235 | dev_err(&i2c->dev, |
236 | "unable to request GPIO %d as connect pin (%d)\n", | 236 | "unable to request GPIO %d as connect pin (%d)\n", |
237 | hub->gpio_intn, err); | 237 | hub->gpio_intn, err); |
238 | goto err_out; | 238 | return err; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | if (gpio_is_valid(hub->gpio_connect)) { | 242 | if (gpio_is_valid(hub->gpio_connect)) { |
243 | err = gpio_request_one(hub->gpio_connect, | 243 | err = devm_gpio_request_one(&i2c->dev, hub->gpio_connect, |
244 | GPIOF_OUT_INIT_HIGH, "usb3503 connect"); | 244 | GPIOF_OUT_INIT_HIGH, "usb3503 connect"); |
245 | if (err) { | 245 | if (err) { |
246 | dev_err(&i2c->dev, | 246 | dev_err(&i2c->dev, |
247 | "unable to request GPIO %d as connect pin (%d)\n", | 247 | "unable to request GPIO %d as connect pin (%d)\n", |
248 | hub->gpio_connect, err); | 248 | hub->gpio_connect, err); |
249 | goto err_gpio_connect; | 249 | return err; |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | if (gpio_is_valid(hub->gpio_reset)) { | 253 | if (gpio_is_valid(hub->gpio_reset)) { |
254 | err = gpio_request_one(hub->gpio_reset, | 254 | err = devm_gpio_request_one(&i2c->dev, hub->gpio_reset, |
255 | GPIOF_OUT_INIT_LOW, "usb3503 reset"); | 255 | GPIOF_OUT_INIT_LOW, "usb3503 reset"); |
256 | if (err) { | 256 | if (err) { |
257 | dev_err(&i2c->dev, | 257 | dev_err(&i2c->dev, |
258 | "unable to request GPIO %d as reset pin (%d)\n", | 258 | "unable to request GPIO %d as reset pin (%d)\n", |
259 | hub->gpio_reset, err); | 259 | hub->gpio_reset, err); |
260 | goto err_gpio_reset; | 260 | return err; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
@@ -267,33 +267,6 @@ static int usb3503_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
267 | (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby"); | 267 | (hub->mode == USB3503_MODE_HUB) ? "hub" : "standby"); |
268 | 268 | ||
269 | return 0; | 269 | return 0; |
270 | |||
271 | err_gpio_reset: | ||
272 | if (gpio_is_valid(hub->gpio_connect)) | ||
273 | gpio_free(hub->gpio_connect); | ||
274 | err_gpio_connect: | ||
275 | if (gpio_is_valid(hub->gpio_intn)) | ||
276 | gpio_free(hub->gpio_intn); | ||
277 | err_out: | ||
278 | kfree(hub); | ||
279 | |||
280 | return err; | ||
281 | } | ||
282 | |||
283 | static int usb3503_remove(struct i2c_client *i2c) | ||
284 | { | ||
285 | struct usb3503 *hub = i2c_get_clientdata(i2c); | ||
286 | |||
287 | if (gpio_is_valid(hub->gpio_intn)) | ||
288 | gpio_free(hub->gpio_intn); | ||
289 | if (gpio_is_valid(hub->gpio_connect)) | ||
290 | gpio_free(hub->gpio_connect); | ||
291 | if (gpio_is_valid(hub->gpio_reset)) | ||
292 | gpio_free(hub->gpio_reset); | ||
293 | |||
294 | kfree(hub); | ||
295 | |||
296 | return 0; | ||
297 | } | 270 | } |
298 | 271 | ||
299 | static const struct i2c_device_id usb3503_id[] = { | 272 | static const struct i2c_device_id usb3503_id[] = { |
@@ -316,7 +289,6 @@ static struct i2c_driver usb3503_driver = { | |||
316 | .of_match_table = of_match_ptr(usb3503_of_match), | 289 | .of_match_table = of_match_ptr(usb3503_of_match), |
317 | }, | 290 | }, |
318 | .probe = usb3503_probe, | 291 | .probe = usb3503_probe, |
319 | .remove = usb3503_remove, | ||
320 | .id_table = usb3503_id, | 292 | .id_table = usb3503_id, |
321 | }; | 293 | }; |
322 | 294 | ||