Skip to contentSkip to conversation

usb: host: tegra: make use of PHY pointer of HCD

PATCH Superseded Venu Byravarasu 2 participants 2 messages Dec 18, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: host: tegra: make use of PHY pointer of HCD

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.

---
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(-)
drivers/usb/host/ehci-tegra.c +11 -8
index aca6606..5b2c48d 100644
@@ -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);
Signature · 1 line
1.7.0.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · 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.

---
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().

Quoted 2 lines

Stephen,
Can you plz take this patch through tegra tree, so as to take care of the dependencies?