* [PATCH] usb: host: tegra: make use of PHY pointer of HCD
@ 2012-12-18 6:55 Venu Byravarasu
2012-12-18 16:05 ` Alan Stern
0 siblings, 1 reply; 2+ messages in thread
From: Venu Byravarasu @ 2012-12-18 6:55 UTC (permalink / raw)
To: swarren, stern; +Cc: linux-kernel, linux-usb, Venu Byravarasu
As pointer to PHY structure can be stored in struct usb_hcd
making use of it, to call PHY APIs.
Call to usb_phy_shutdown() is moved up in tegra_ehci_remove(),
so that to avoid dereferencing of hcd after its freed up.
Signed-off-by: Venu Byravarasu <vbyravarasu@nvidia.com>
---
This patch depends on patch http://marc.info/?l=linux-kernel&m=135581274019690&w=2.
Without above patch applied, phy->notify_connect & phy->notify_disconnect are
set to some unknown values, which need not be NULL.
This creates problem when hcd->phy pointer is initialized hub_port_init() in hub.c
calls usb_phy_notify_connect().
Stephen,
Can you plz take this patch through tegra tree, so as to take care of the dependencies?
drivers/usb/host/ehci-tegra.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index aca6606..5b2c48d 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -53,7 +53,7 @@ static void tegra_ehci_power_up(struct usb_hcd *hcd)
clk_prepare_enable(tegra->emc_clk);
clk_prepare_enable(tegra->clk);
- usb_phy_set_suspend(&tegra->phy->u_phy, 0);
+ usb_phy_set_suspend(hcd->phy, 0);
tegra->host_resumed = 1;
}
@@ -62,7 +62,7 @@ static void tegra_ehci_power_down(struct usb_hcd *hcd)
struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
tegra->host_resumed = 0;
- usb_phy_set_suspend(&tegra->phy->u_phy, 1);
+ usb_phy_set_suspend(hcd->phy, 1);
clk_disable_unprepare(tegra->clk);
clk_disable_unprepare(tegra->emc_clk);
}
@@ -716,9 +716,14 @@ static int tegra_ehci_probe(struct platform_device *pdev)
goto fail_io;
}
- usb_phy_init(&tegra->phy->u_phy);
+ hcd->phy = &tegra->phy->u_phy;
+ err = usb_phy_init(hcd->phy);
+ if (err) {
+ dev_err(&pdev->dev, "Failed to initialize phy\n");
+ goto fail;
+ }
- err = usb_phy_set_suspend(&tegra->phy->u_phy, 0);
+ err = usb_phy_set_suspend(hcd->phy, 0);
if (err) {
dev_err(&pdev->dev, "Failed to power on the phy\n");
goto fail;
@@ -764,7 +769,7 @@ fail:
if (!IS_ERR_OR_NULL(tegra->transceiver))
otg_set_host(tegra->transceiver->otg, NULL);
#endif
- usb_phy_shutdown(&tegra->phy->u_phy);
+ usb_phy_shutdown(hcd->phy);
fail_io:
clk_disable_unprepare(tegra->emc_clk);
fail_emc_clk:
@@ -787,12 +792,10 @@ static int tegra_ehci_remove(struct platform_device *pdev)
if (!IS_ERR_OR_NULL(tegra->transceiver))
otg_set_host(tegra->transceiver->otg, NULL);
#endif
-
+ usb_phy_shutdown(hcd->phy);
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
- usb_phy_shutdown(&tegra->phy->u_phy);
-
clk_disable_unprepare(tegra->clk);
clk_disable_unprepare(tegra->emc_clk);
--
1.7.0.4
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] usb: host: tegra: make use of PHY pointer of HCD
2012-12-18 6:55 [PATCH] usb: host: tegra: make use of PHY pointer of HCD Venu Byravarasu
@ 2012-12-18 16:05 ` Alan Stern
0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2012-12-18 16:05 UTC (permalink / raw)
To: Venu Byravarasu; +Cc: swarren, linux-kernel, linux-usb
On Tue, 18 Dec 2012, Venu Byravarasu wrote:
> As pointer to PHY structure can be stored in struct usb_hcd
> making use of it, to call PHY APIs.
>
> Call to usb_phy_shutdown() is moved up in tegra_ehci_remove(),
> so that to avoid dereferencing of hcd after its freed up.
>
> Signed-off-by: Venu Byravarasu <vbyravarasu@nvidia.com>
> ---
> This patch depends on patch http://marc.info/?l=linux-kernel&m=135581274019690&w=2.
> Without above patch applied, phy->notify_connect & phy->notify_disconnect are
> set to some unknown values, which need not be NULL.
> This creates problem when hcd->phy pointer is initialized hub_port_init() in hub.c
> calls usb_phy_notify_connect().
>
> Stephen,
> Can you plz take this patch through tegra tree, so as to take care of the dependencies?
Acked-by: Alan Stern <stern@rowland.harvard.edu>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-12-18 16:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-18 6:55 [PATCH] usb: host: tegra: make use of PHY pointer of HCD Venu Byravarasu
2012-12-18 16:05 ` Alan Stern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®