diff options
author | Vaishali Thakkar <vthakkar1994@gmail.com> | 2015-09-14 13:49:35 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2015-09-29 04:58:42 -0400 |
commit | 4bf27b7038c23fe789aa9bd553a6391cc33ccfa1 (patch) | |
tree | 32f0b47fc16d375c37b3822eead097ff2fee2ad1 | |
parent | ff612f9170eaa9ca7ade357b270f582b0c44ed70 (diff) |
extcon: axp288: Convert to using managed resources
Use resource managed functions devm_usb_get_phy and
devm_gpio_request to make error path simpler. To be
compatible the change, various gotos are replaced
with direct returns and unnecessary label
gpio_req_failed is dropped.
Also, remove function axp288_extcon_remove as it is
now redundant.
Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r-- | drivers/extcon/extcon-axp288.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c index ea962bc547b8..9668d6a94e38 100644 --- a/drivers/extcon/extcon-axp288.c +++ b/drivers/extcon/extcon-axp288.c | |||
@@ -309,7 +309,7 @@ static int axp288_extcon_probe(struct platform_device *pdev) | |||
309 | } | 309 | } |
310 | 310 | ||
311 | /* Get otg transceiver phy */ | 311 | /* Get otg transceiver phy */ |
312 | info->otg = usb_get_phy(USB_PHY_TYPE_USB2); | 312 | info->otg = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); |
313 | if (IS_ERR(info->otg)) { | 313 | if (IS_ERR(info->otg)) { |
314 | dev_err(&pdev->dev, "failed to get otg transceiver\n"); | 314 | dev_err(&pdev->dev, "failed to get otg transceiver\n"); |
315 | return PTR_ERR(info->otg); | 315 | return PTR_ERR(info->otg); |
@@ -318,11 +318,11 @@ static int axp288_extcon_probe(struct platform_device *pdev) | |||
318 | /* Set up gpio control for USB Mux */ | 318 | /* Set up gpio control for USB Mux */ |
319 | if (info->pdata->gpio_mux_cntl) { | 319 | if (info->pdata->gpio_mux_cntl) { |
320 | gpio = desc_to_gpio(info->pdata->gpio_mux_cntl); | 320 | gpio = desc_to_gpio(info->pdata->gpio_mux_cntl); |
321 | ret = gpio_request(gpio, "USB_MUX"); | 321 | ret = devm_gpio_request(&pdev->dev, gpio, "USB_MUX"); |
322 | if (ret < 0) { | 322 | if (ret < 0) { |
323 | dev_err(&pdev->dev, | 323 | dev_err(&pdev->dev, |
324 | "failed to request the gpio=%d\n", gpio); | 324 | "failed to request the gpio=%d\n", gpio); |
325 | goto gpio_req_failed; | 325 | return ret; |
326 | } | 326 | } |
327 | gpiod_direction_output(info->pdata->gpio_mux_cntl, | 327 | gpiod_direction_output(info->pdata->gpio_mux_cntl, |
328 | EXTCON_GPIO_MUX_SEL_PMIC); | 328 | EXTCON_GPIO_MUX_SEL_PMIC); |
@@ -335,7 +335,7 @@ static int axp288_extcon_probe(struct platform_device *pdev) | |||
335 | dev_err(&pdev->dev, | 335 | dev_err(&pdev->dev, |
336 | "failed to get virtual interrupt=%d\n", pirq); | 336 | "failed to get virtual interrupt=%d\n", pirq); |
337 | ret = info->irq[i]; | 337 | ret = info->irq[i]; |
338 | goto gpio_req_failed; | 338 | return ret; |
339 | } | 339 | } |
340 | 340 | ||
341 | ret = devm_request_threaded_irq(&pdev->dev, info->irq[i], | 341 | ret = devm_request_threaded_irq(&pdev->dev, info->irq[i], |
@@ -345,7 +345,7 @@ static int axp288_extcon_probe(struct platform_device *pdev) | |||
345 | if (ret) { | 345 | if (ret) { |
346 | dev_err(&pdev->dev, "failed to request interrupt=%d\n", | 346 | dev_err(&pdev->dev, "failed to request interrupt=%d\n", |
347 | info->irq[i]); | 347 | info->irq[i]); |
348 | goto gpio_req_failed; | 348 | return ret; |
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
@@ -353,23 +353,10 @@ static int axp288_extcon_probe(struct platform_device *pdev) | |||
353 | axp288_extcon_enable_irq(info); | 353 | axp288_extcon_enable_irq(info); |
354 | 354 | ||
355 | return 0; | 355 | return 0; |
356 | |||
357 | gpio_req_failed: | ||
358 | usb_put_phy(info->otg); | ||
359 | return ret; | ||
360 | } | ||
361 | |||
362 | static int axp288_extcon_remove(struct platform_device *pdev) | ||
363 | { | ||
364 | struct axp288_extcon_info *info = platform_get_drvdata(pdev); | ||
365 | |||
366 | usb_put_phy(info->otg); | ||
367 | return 0; | ||
368 | } | 356 | } |
369 | 357 | ||
370 | static struct platform_driver axp288_extcon_driver = { | 358 | static struct platform_driver axp288_extcon_driver = { |
371 | .probe = axp288_extcon_probe, | 359 | .probe = axp288_extcon_probe, |
372 | .remove = axp288_extcon_remove, | ||
373 | .driver = { | 360 | .driver = { |
374 | .name = "axp288_extcon", | 361 | .name = "axp288_extcon", |
375 | }, | 362 | }, |