Skip to content

Commit 6b44d1e

Browse files
committed
Merge tag 'phy-for-4.5-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy into usb-linus
Kishon writes: phy: for 4.5-rc *) Fix error handling code in phy core [phy_power_on()] *) phy-twl4030-usb fixes for unloading the module *) Restrict phy-hi6220-usb to HiSilicon arm64 Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2 parents 89140fd + 58a66db commit 6b44d1e

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

drivers/phy/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ config PHY_MT65XX_USB3
224224

225225
config PHY_HI6220_USB
226226
tristate "hi6220 USB PHY support"
227+
depends on (ARCH_HISI && ARM64) || COMPILE_TEST
227228
select GENERIC_PHY
228229
select MFD_SYSCON
229230
help

drivers/phy/phy-core.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,40 +275,42 @@ EXPORT_SYMBOL_GPL(phy_exit);
275275

276276
int phy_power_on(struct phy *phy)
277277
{
278-
int ret;
278+
int ret = 0;
279279

280280
if (!phy)
281-
return 0;
281+
goto out;
282282

283283
if (phy->pwr) {
284284
ret = regulator_enable(phy->pwr);
285285
if (ret)
286-
return ret;
286+
goto out;
287287
}
288288

289289
ret = phy_pm_runtime_get_sync(phy);
290290
if (ret < 0 && ret != -ENOTSUPP)
291-
return ret;
291+
goto err_pm_sync;
292+
292293
ret = 0; /* Override possible ret == -ENOTSUPP */
293294

294295
mutex_lock(&phy->mutex);
295296
if (phy->power_count == 0 && phy->ops->power_on) {
296297
ret = phy->ops->power_on(phy);
297298
if (ret < 0) {
298299
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
299-
goto out;
300+
goto err_pwr_on;
300301
}
301302
}
302303
++phy->power_count;
303304
mutex_unlock(&phy->mutex);
304305
return 0;
305306

306-
out:
307+
err_pwr_on:
307308
mutex_unlock(&phy->mutex);
308309
phy_pm_runtime_put_sync(phy);
310+
err_pm_sync:
309311
if (phy->pwr)
310312
regulator_disable(phy->pwr);
311-
313+
out:
312314
return ret;
313315
}
314316
EXPORT_SYMBOL_GPL(phy_power_on);

drivers/phy/phy-twl4030-usb.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
715715
pm_runtime_use_autosuspend(&pdev->dev);
716716
pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
717717
pm_runtime_enable(&pdev->dev);
718+
pm_runtime_get_sync(&pdev->dev);
718719

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

754+
usb_remove_phy(&twl->phy);
753755
pm_runtime_get_sync(twl->dev);
754756
cancel_delayed_work(&twl->id_workaround_work);
755757
device_remove_file(twl->dev, &dev_attr_vbus);
756758

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

762+
/* idle ulpi before powering off */
763+
if (cable_present(twl->linkstat))
764+
pm_runtime_put_noidle(twl->dev);
765+
pm_runtime_mark_last_busy(twl->dev);
766+
pm_runtime_put_sync_suspend(twl->dev);
767+
pm_runtime_disable(twl->dev);
768+
760769
/* autogate 60MHz ULPI clock,
761770
* clear dpll clock request for i2c access,
762771
* disable 32KHz
@@ -771,11 +780,6 @@ static int twl4030_usb_remove(struct platform_device *pdev)
771780
/* disable complete OTG block */
772781
twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
773782

774-
if (cable_present(twl->linkstat))
775-
pm_runtime_put_noidle(twl->dev);
776-
pm_runtime_mark_last_busy(twl->dev);
777-
pm_runtime_put(twl->dev);
778-
779783
return 0;
780784
}
781785

0 commit comments

Comments
 (0)