Commit c19d14d6 authored by Stephen Warren's avatar Stephen Warren Committed by Greg Kroah-Hartman

USB: EHCI: tegra: make use of ehci->priv

Rather than allocating struct tegra_ehci_hcd separately, use struct
ehci_hcd's priv field instead.
Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Tested-by: default avatarThierry Reding <thierry.reding@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9fc5f24e
...@@ -56,7 +56,6 @@ static int (*orig_hub_control)(struct usb_hcd *hcd, ...@@ -56,7 +56,6 @@ static int (*orig_hub_control)(struct usb_hcd *hcd,
char *buf, u16 wLength); char *buf, u16 wLength);
struct tegra_ehci_hcd { struct tegra_ehci_hcd {
struct ehci_hcd *ehci;
struct tegra_usb_phy *phy; struct tegra_usb_phy *phy;
struct clk *clk; struct clk *clk;
struct usb_phy *transceiver; struct usb_phy *transceiver;
...@@ -140,7 +139,7 @@ static int tegra_ehci_hub_control( ...@@ -140,7 +139,7 @@ static int tegra_ehci_hub_control(
) )
{ {
struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct ehci_hcd *ehci = hcd_to_ehci(hcd);
struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); struct tegra_ehci_hcd *tegra = (struct tegra_ehci_hcd *)ehci->priv;
u32 __iomem *status_reg; u32 __iomem *status_reg;
u32 temp; u32 temp;
unsigned long flags; unsigned long flags;
...@@ -354,6 +353,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -354,6 +353,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res;
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct tegra_ehci_hcd *tegra; struct tegra_ehci_hcd *tegra;
struct tegra_ehci_platform_data *pdata; struct tegra_ehci_platform_data *pdata;
int err = 0; int err = 0;
...@@ -378,20 +378,29 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -378,20 +378,29 @@ static int tegra_ehci_probe(struct platform_device *pdev)
setup_vbus_gpio(pdev, pdata); setup_vbus_gpio(pdev, pdata);
tegra = devm_kzalloc(&pdev->dev, sizeof(struct tegra_ehci_hcd), hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev,
GFP_KERNEL); dev_name(&pdev->dev));
if (!tegra) if (!hcd) {
return -ENOMEM; dev_err(&pdev->dev, "Unable to create HCD\n");
err = -ENOMEM;
goto cleanup_vbus_gpio;
}
platform_set_drvdata(pdev, hcd);
ehci = hcd_to_ehci(hcd);
tegra = (struct tegra_ehci_hcd *)ehci->priv;
hcd->has_tt = 1;
tegra->clk = devm_clk_get(&pdev->dev, NULL); tegra->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(tegra->clk)) { if (IS_ERR(tegra->clk)) {
dev_err(&pdev->dev, "Can't get ehci clock\n"); dev_err(&pdev->dev, "Can't get ehci clock\n");
return PTR_ERR(tegra->clk); err = PTR_ERR(tegra->clk);
goto cleanup_hcd_create;
} }
err = clk_prepare_enable(tegra->clk); err = clk_prepare_enable(tegra->clk);
if (err) if (err)
return err; goto cleanup_clk_get;
tegra_periph_reset_assert(tegra->clk); tegra_periph_reset_assert(tegra->clk);
udelay(1); udelay(1);
...@@ -400,35 +409,24 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -400,35 +409,24 @@ static int tegra_ehci_probe(struct platform_device *pdev)
np_phy = of_parse_phandle(pdev->dev.of_node, "nvidia,phy", 0); np_phy = of_parse_phandle(pdev->dev.of_node, "nvidia,phy", 0);
if (!np_phy) { if (!np_phy) {
err = -ENODEV; err = -ENODEV;
goto cleanup_clk; goto cleanup_clk_en;
} }
u_phy = tegra_usb_get_phy(np_phy); u_phy = tegra_usb_get_phy(np_phy);
if (IS_ERR(u_phy)) { if (IS_ERR(u_phy)) {
err = PTR_ERR(u_phy); err = PTR_ERR(u_phy);
goto cleanup_clk; goto cleanup_clk_en;
} }
hcd->phy = u_phy;
tegra->needs_double_reset = of_property_read_bool(pdev->dev.of_node, tegra->needs_double_reset = of_property_read_bool(pdev->dev.of_node,
"nvidia,needs-double-reset"); "nvidia,needs-double-reset");
hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev,
dev_name(&pdev->dev));
if (!hcd) {
dev_err(&pdev->dev, "Unable to create HCD\n");
err = -ENOMEM;
goto cleanup_clk;
}
tegra->ehci = hcd_to_ehci(hcd);
hcd->has_tt = 1;
hcd->phy = u_phy;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(&pdev->dev, "Failed to get I/O memory\n"); dev_err(&pdev->dev, "Failed to get I/O memory\n");
err = -ENXIO; err = -ENXIO;
goto cleanup_hcd_create; goto cleanup_clk_en;
} }
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res); hcd->rsrc_len = resource_size(res);
...@@ -436,14 +434,14 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -436,14 +434,14 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!hcd->regs) { if (!hcd->regs) {
dev_err(&pdev->dev, "Failed to remap I/O memory\n"); dev_err(&pdev->dev, "Failed to remap I/O memory\n");
err = -ENOMEM; err = -ENOMEM;
goto cleanup_hcd_create; goto cleanup_clk_en;
} }
tegra->ehci->caps = hcd->regs + 0x100; ehci->caps = hcd->regs + 0x100;
err = usb_phy_init(hcd->phy); err = usb_phy_init(hcd->phy);
if (err) { if (err) {
dev_err(&pdev->dev, "Failed to initialize phy\n"); dev_err(&pdev->dev, "Failed to initialize phy\n");
goto cleanup_hcd_create; goto cleanup_clk_en;
} }
u_phy->otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), u_phy->otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
...@@ -477,8 +475,6 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -477,8 +475,6 @@ static int tegra_ehci_probe(struct platform_device *pdev)
tegra->transceiver = ERR_PTR(-ENODEV); tegra->transceiver = ERR_PTR(-ENODEV);
} }
platform_set_drvdata(pdev, tegra);
err = usb_add_hcd(hcd, irq, IRQF_SHARED); err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err) { if (err) {
dev_err(&pdev->dev, "Failed to add USB HCD\n"); dev_err(&pdev->dev, "Failed to add USB HCD\n");
...@@ -492,17 +488,22 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -492,17 +488,22 @@ static int tegra_ehci_probe(struct platform_device *pdev)
otg_set_host(tegra->transceiver->otg, NULL); otg_set_host(tegra->transceiver->otg, NULL);
usb_phy_shutdown(hcd->phy); usb_phy_shutdown(hcd->phy);
cleanup_clk_en:
clk_disable_unprepare(tegra->clk);
cleanup_clk_get:
clk_put(tegra->clk);
cleanup_hcd_create: cleanup_hcd_create:
usb_put_hcd(hcd); usb_put_hcd(hcd);
cleanup_clk: cleanup_vbus_gpio:
clk_disable_unprepare(tegra->clk); /* FIXME: Undo setup_vbus_gpio() here */
return err; return err;
} }
static int tegra_ehci_remove(struct platform_device *pdev) static int tegra_ehci_remove(struct platform_device *pdev)
{ {
struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); struct tegra_ehci_hcd *tegra =
(struct tegra_ehci_hcd *)hcd_to_ehci(hcd)->priv;
if (!IS_ERR(tegra->transceiver)) if (!IS_ERR(tegra->transceiver))
otg_set_host(tegra->transceiver->otg, NULL); otg_set_host(tegra->transceiver->otg, NULL);
...@@ -518,8 +519,7 @@ static int tegra_ehci_remove(struct platform_device *pdev) ...@@ -518,8 +519,7 @@ static int tegra_ehci_remove(struct platform_device *pdev)
static void tegra_ehci_hcd_shutdown(struct platform_device *pdev) static void tegra_ehci_hcd_shutdown(struct platform_device *pdev)
{ {
struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
if (hcd->driver->shutdown) if (hcd->driver->shutdown)
hcd->driver->shutdown(hcd); hcd->driver->shutdown(hcd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment