aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2015-07-01 00:11:32 -0400
committerFelipe Balbi <balbi@ti.com>2015-07-29 10:59:18 -0400
commit860d2686fda7e4dceaa4e676e62adcdbfc7f7a2c (patch)
treec7acb246ddfb6d0650ea40903e5c6b900d191d67 /drivers/usb/phy
parenta2fd2423240fe1abd7a154a1cc0fd1624c339bff (diff)
usb: phy: tahvo: Use devm_extcon_dev_[allocate|register]() and replace deprecated API
This patch uses the devm_extcon_dev_[allocate|register]() to manage the resource automatically and replace deprecated API as following: - extcon_[set|get]_cable_state(*edev, char *) -> extcon_[set|get]_cable_state_(*edev, id) Cc: Felipe Balbi <balbi@ti.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy')
-rw-r--r--drivers/usb/phy/phy-tahvo.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index b40d6a87d694..ab5d364f6e8c 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -57,7 +57,7 @@ struct tahvo_usb {
57 struct clk *ick; 57 struct clk *ick;
58 int irq; 58 int irq;
59 int tahvo_mode; 59 int tahvo_mode;
60 struct extcon_dev extcon; 60 struct extcon_dev *extcon;
61}; 61};
62 62
63static const unsigned int tahvo_cable[] = { 63static const unsigned int tahvo_cable[] = {
@@ -121,7 +121,7 @@ static void check_vbus_state(struct tahvo_usb *tu)
121 prev_state = tu->vbus_state; 121 prev_state = tu->vbus_state;
122 tu->vbus_state = reg & TAHVO_STAT_VBUS; 122 tu->vbus_state = reg & TAHVO_STAT_VBUS;
123 if (prev_state != tu->vbus_state) { 123 if (prev_state != tu->vbus_state) {
124 extcon_set_cable_state(&tu->extcon, "USB", tu->vbus_state); 124 extcon_set_cable_state_(tu->extcon, EXTCON_USB, tu->vbus_state);
125 sysfs_notify(&tu->pt_dev->dev.kobj, NULL, "vbus_state"); 125 sysfs_notify(&tu->pt_dev->dev.kobj, NULL, "vbus_state");
126 } 126 }
127} 127}
@@ -130,7 +130,7 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
130{ 130{
131 struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); 131 struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent);
132 132
133 extcon_set_cable_state(&tu->extcon, "USB-HOST", true); 133 extcon_set_cable_state_(tu->extcon, EXTCON_USB_HOST, true);
134 134
135 /* Power up the transceiver in USB host mode */ 135 /* Power up the transceiver in USB host mode */
136 retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | 136 retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
@@ -149,7 +149,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
149{ 149{
150 struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); 150 struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent);
151 151
152 extcon_set_cable_state(&tu->extcon, "USB-HOST", false); 152 extcon_set_cable_state_(tu->extcon, EXTCON_USB_HOST, false);
153 153
154 /* Power up transceiver and set it in USB peripheral mode */ 154 /* Power up transceiver and set it in USB peripheral mode */
155 retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | 155 retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT |
@@ -365,11 +365,13 @@ static int tahvo_usb_probe(struct platform_device *pdev)
365 */ 365 */
366 tu->vbus_state = retu_read(rdev, TAHVO_REG_IDSR) & TAHVO_STAT_VBUS; 366 tu->vbus_state = retu_read(rdev, TAHVO_REG_IDSR) & TAHVO_STAT_VBUS;
367 367
368 tu->extcon.name = DRIVER_NAME; 368 tu->extcon = devm_extcon_dev_allocate(&pdev->dev, tahvo_cable);
369 tu->extcon.supported_cable = tahvo_cable; 369 if (IS_ERR(tu->extcon)) {
370 tu->extcon.dev.parent = &pdev->dev; 370 dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
371 return -ENOMEM;
372 }
371 373
372 ret = extcon_dev_register(&tu->extcon); 374 ret = devm_extcon_dev_register(&pdev->dev, tu->extcon);
373 if (ret) { 375 if (ret) {
374 dev_err(&pdev->dev, "could not register extcon device: %d\n", 376 dev_err(&pdev->dev, "could not register extcon device: %d\n",
375 ret); 377 ret);
@@ -377,9 +379,9 @@ static int tahvo_usb_probe(struct platform_device *pdev)
377 } 379 }
378 380
379 /* Set the initial cable state. */ 381 /* Set the initial cable state. */
380 extcon_set_cable_state(&tu->extcon, "USB-HOST", 382 extcon_set_cable_state_(tu->extcon, EXTCON_USB_HOST,
381 tu->tahvo_mode == TAHVO_MODE_HOST); 383 tu->tahvo_mode == TAHVO_MODE_HOST);
382 extcon_set_cable_state(&tu->extcon, "USB", tu->vbus_state); 384 extcon_set_cable_state_(tu->extcon, EXTCON_USB, tu->vbus_state);
383 385
384 /* Create OTG interface */ 386 /* Create OTG interface */
385 tahvo_usb_power_off(tu); 387 tahvo_usb_power_off(tu);
@@ -396,7 +398,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
396 if (ret < 0) { 398 if (ret < 0) {
397 dev_err(&pdev->dev, "cannot register USB transceiver: %d\n", 399 dev_err(&pdev->dev, "cannot register USB transceiver: %d\n",
398 ret); 400 ret);
399 goto err_extcon_unreg; 401 goto err_disable_clk;
400 } 402 }
401 403
402 dev_set_drvdata(&pdev->dev, tu); 404 dev_set_drvdata(&pdev->dev, tu);
@@ -424,8 +426,6 @@ err_free_irq:
424 free_irq(tu->irq, tu); 426 free_irq(tu->irq, tu);
425err_remove_phy: 427err_remove_phy:
426 usb_remove_phy(&tu->phy); 428 usb_remove_phy(&tu->phy);
427err_extcon_unreg:
428 extcon_dev_unregister(&tu->extcon);
429err_disable_clk: 429err_disable_clk:
430 if (!IS_ERR(tu->ick)) 430 if (!IS_ERR(tu->ick))
431 clk_disable(tu->ick); 431 clk_disable(tu->ick);
@@ -440,7 +440,6 @@ static int tahvo_usb_remove(struct platform_device *pdev)
440 sysfs_remove_group(&pdev->dev.kobj, &tahvo_attr_group); 440 sysfs_remove_group(&pdev->dev.kobj, &tahvo_attr_group);
441 free_irq(tu->irq, tu); 441 free_irq(tu->irq, tu);
442 usb_remove_phy(&tu->phy); 442 usb_remove_phy(&tu->phy);
443 extcon_dev_unregister(&tu->extcon);
444 if (!IS_ERR(tu->ick)) 443 if (!IS_ERR(tu->ick))
445 clk_disable(tu->ick); 444 clk_disable(tu->ick);
446 445