Skip to content

Commit

Permalink
Merge tag 'usb-4.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/gregkh/usb

Pull PHY fixes from Greg KH:
 "Here are a couple of PHY driver fixes for 4.5-rc4.

  A few small phy issues.  All have been in linux-next with no reported
  issues"

* tag 'usb-4.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload
  phy: twl4030-usb: Relase usb phy on unload
  phy: core: fix wrong err handle for phy_power_on
  phy: Restrict phy-hi6220-usb to HiSilicon arm64
  • Loading branch information
torvalds committed Feb 14, 2016
2 parents 102a92c + 6b44d1e commit 9db8cc1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions drivers/phy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ config PHY_MT65XX_USB3

config PHY_HI6220_USB
tristate "hi6220 USB PHY support"
depends on (ARCH_HISI && ARM64) || COMPILE_TEST
select GENERIC_PHY
select MFD_SYSCON
help
Expand Down
16 changes: 9 additions & 7 deletions drivers/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,40 +275,42 @@ EXPORT_SYMBOL_GPL(phy_exit);

int phy_power_on(struct phy *phy)
{
int ret;
int ret = 0;

if (!phy)
return 0;
goto out;

if (phy->pwr) {
ret = regulator_enable(phy->pwr);
if (ret)
return ret;
goto out;
}

ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP)
return ret;
goto err_pm_sync;

ret = 0; /* Override possible ret == -ENOTSUPP */

mutex_lock(&phy->mutex);
if (phy->power_count == 0 && phy->ops->power_on) {
ret = phy->ops->power_on(phy);
if (ret < 0) {
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
goto out;
goto err_pwr_on;
}
}
++phy->power_count;
mutex_unlock(&phy->mutex);
return 0;

out:
err_pwr_on:
mutex_unlock(&phy->mutex);
phy_pm_runtime_put_sync(phy);
err_pm_sync:
if (phy->pwr)
regulator_disable(phy->pwr);

out:
return ret;
}
EXPORT_SYMBOL_GPL(phy_power_on);
Expand Down
14 changes: 9 additions & 5 deletions drivers/phy/phy-twl4030-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

/* Our job is to use irqs and status from the power module
* to keep the transceiver disabled when nothing's connected.
Expand Down Expand Up @@ -750,13 +751,21 @@ static int twl4030_usb_remove(struct platform_device *pdev)
struct twl4030_usb *twl = platform_get_drvdata(pdev);
int val;

usb_remove_phy(&twl->phy);
pm_runtime_get_sync(twl->dev);
cancel_delayed_work(&twl->id_workaround_work);
device_remove_file(twl->dev, &dev_attr_vbus);

/* set transceiver mode to power on defaults */
twl4030_usb_set_mode(twl, -1);

/* idle ulpi before powering off */
if (cable_present(twl->linkstat))
pm_runtime_put_noidle(twl->dev);
pm_runtime_mark_last_busy(twl->dev);
pm_runtime_put_sync_suspend(twl->dev);
pm_runtime_disable(twl->dev);

/* autogate 60MHz ULPI clock,
* clear dpll clock request for i2c access,
* disable 32KHz
Expand All @@ -771,11 +780,6 @@ static int twl4030_usb_remove(struct platform_device *pdev)
/* disable complete OTG block */
twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);

if (cable_present(twl->linkstat))
pm_runtime_put_noidle(twl->dev);
pm_runtime_mark_last_busy(twl->dev);
pm_runtime_put(twl->dev);

return 0;
}

Expand Down

0 comments on commit 9db8cc1

Please sign in to comment.