diff options
| author | Stephen Warren <swarren@nvidia.com> | 2013-06-13 13:24:13 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-17 16:54:48 -0400 |
| commit | c19d14d6d0120e73418294e6a30db0566e5daf02 (patch) | |
| tree | f17f4d40a6784d11c1e85ef89fa9b02f81489701 | |
| parent | 9fc5f24e43da17df75af75d446c9d89a4bcfce8c (diff) | |
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: Stephen Warren <swarren@nvidia.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/usb/host/ehci-tegra.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 338c8a56118d..8dac5e41a741 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
| @@ -56,7 +56,6 @@ static int (*orig_hub_control)(struct usb_hcd *hcd, | |||
| 56 | char *buf, u16 wLength); | 56 | char *buf, u16 wLength); |
| 57 | 57 | ||
| 58 | struct tegra_ehci_hcd { | 58 | struct tegra_ehci_hcd { |
| 59 | struct ehci_hcd *ehci; | ||
| 60 | struct tegra_usb_phy *phy; | 59 | struct tegra_usb_phy *phy; |
| 61 | struct clk *clk; | 60 | struct clk *clk; |
| 62 | struct usb_phy *transceiver; | 61 | struct usb_phy *transceiver; |
| @@ -139,8 +138,8 @@ static int tegra_ehci_hub_control( | |||
| 139 | u16 wLength | 138 | u16 wLength |
| 140 | ) | 139 | ) |
| 141 | { | 140 | { |
| 142 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 141 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 143 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | 142 | struct tegra_ehci_hcd *tegra = (struct tegra_ehci_hcd *)ehci->priv; |
| 144 | u32 __iomem *status_reg; | 143 | u32 __iomem *status_reg; |
| 145 | u32 temp; | 144 | u32 temp; |
| 146 | unsigned long flags; | 145 | unsigned long flags; |
| @@ -354,6 +353,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
| 354 | { | 353 | { |
| 355 | struct resource *res; | 354 | struct resource *res; |
| 356 | struct usb_hcd *hcd; | 355 | struct usb_hcd *hcd; |
| 356 | struct ehci_hcd *ehci; | ||
| 357 | struct tegra_ehci_hcd *tegra; | 357 | struct tegra_ehci_hcd *tegra; |
| 358 | struct tegra_ehci_platform_data *pdata; | 358 | struct tegra_ehci_platform_data *pdata; |
| 359 | int err = 0; | 359 | int err = 0; |
| @@ -378,20 +378,29 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
| 378 | 378 | ||
| 379 | setup_vbus_gpio(pdev, pdata); | 379 | setup_vbus_gpio(pdev, pdata); |
| 380 | 380 | ||
| 381 | tegra = devm_kzalloc(&pdev->dev, sizeof(struct tegra_ehci_hcd), | 381 | hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev, |
| 382 | GFP_KERNEL); | 382 | dev_name(&pdev->dev)); |
| 383 | if (!tegra) | 383 | if (!hcd) { |
| 384 | return -ENOMEM; | 384 | dev_err(&pdev->dev, "Unable to create HCD\n"); |
| 385 | err = -ENOMEM; | ||
| 386 | goto cleanup_vbus_gpio; | ||
| 387 | } | ||
| 388 | platform_set_drvdata(pdev, hcd); | ||
| 389 | ehci = hcd_to_ehci(hcd); | ||
| 390 | tegra = (struct tegra_ehci_hcd *)ehci->priv; | ||
| 391 | |||
| 392 | hcd->has_tt = 1; | ||
| 385 | 393 | ||
| 386 | tegra->clk = devm_clk_get(&pdev->dev, NULL); | 394 | tegra->clk = devm_clk_get(&pdev->dev, NULL); |
| 387 | if (IS_ERR(tegra->clk)) { | 395 | if (IS_ERR(tegra->clk)) { |
| 388 | dev_err(&pdev->dev, "Can't get ehci clock\n"); | 396 | dev_err(&pdev->dev, "Can't get ehci clock\n"); |
| 389 | return PTR_ERR(tegra->clk); | 397 | err = PTR_ERR(tegra->clk); |
| 398 | goto cleanup_hcd_create; | ||
| 390 | } | 399 | } |
| 391 | 400 | ||
| 392 | err = clk_prepare_enable(tegra->clk); | 401 | err = clk_prepare_enable(tegra->clk); |
| 393 | if (err) | 402 | if (err) |
| 394 | return err; | 403 | goto cleanup_clk_get; |
| 395 | 404 | ||
| 396 | tegra_periph_reset_assert(tegra->clk); | 405 | tegra_periph_reset_assert(tegra->clk); |
| 397 | udelay(1); | 406 | udelay(1); |
| @@ -400,35 +409,24 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
| 400 | np_phy = of_parse_phandle(pdev->dev.of_node, "nvidia,phy", 0); | 409 | np_phy = of_parse_phandle(pdev->dev.of_node, "nvidia,phy", 0); |
| 401 | if (!np_phy) { | 410 | if (!np_phy) { |
| 402 | err = -ENODEV; | 411 | err = -ENODEV; |
| 403 | goto cleanup_clk; | 412 | goto cleanup_clk_en; |
| 404 | } | 413 | } |
| 405 | 414 | ||
| 406 | u_phy = tegra_usb_get_phy(np_phy); | 415 | u_phy = tegra_usb_get_phy(np_phy); |
| 407 | if (IS_ERR(u_phy)) { | 416 | if (IS_ERR(u_phy)) { |
| 408 | err = PTR_ERR(u_phy); | 417 | err = PTR_ERR(u_phy); |
| 409 | goto cleanup_clk; | 418 | goto cleanup_clk_en; |
| 410 | } | 419 | } |
| 420 | hcd->phy = u_phy; | ||
| 411 | 421 | ||
| 412 | tegra->needs_double_reset = of_property_read_bool(pdev->dev.of_node, | 422 | tegra->needs_double_reset = of_property_read_bool(pdev->dev.of_node, |
| 413 | "nvidia,needs-double-reset"); | 423 | "nvidia,needs-double-reset"); |
| 414 | 424 | ||
| 415 | hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev, | ||
| 416 | dev_name(&pdev->dev)); | ||
| 417 | if (!hcd) { | ||
| 418 | dev_err(&pdev->dev, "Unable to create HCD\n"); | ||
| 419 | err = -ENOMEM; | ||
| 420 | goto cleanup_clk; | ||
| 421 | } | ||
| 422 | tegra->ehci = hcd_to_ehci(hcd); | ||
| 423 | |||
| 424 | hcd->has_tt = 1; | ||
| 425 | hcd->phy = u_phy; | ||
| 426 | |||
| 427 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 425 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 428 | if (!res) { | 426 | if (!res) { |
| 429 | dev_err(&pdev->dev, "Failed to get I/O memory\n"); | 427 | dev_err(&pdev->dev, "Failed to get I/O memory\n"); |
| 430 | err = -ENXIO; | 428 | err = -ENXIO; |
| 431 | goto cleanup_hcd_create; | 429 | goto cleanup_clk_en; |
| 432 | } | 430 | } |
| 433 | hcd->rsrc_start = res->start; | 431 | hcd->rsrc_start = res->start; |
| 434 | hcd->rsrc_len = resource_size(res); | 432 | hcd->rsrc_len = resource_size(res); |
| @@ -436,14 +434,14 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
| 436 | if (!hcd->regs) { | 434 | if (!hcd->regs) { |
| 437 | dev_err(&pdev->dev, "Failed to remap I/O memory\n"); | 435 | dev_err(&pdev->dev, "Failed to remap I/O memory\n"); |
| 438 | err = -ENOMEM; | 436 | err = -ENOMEM; |
| 439 | goto cleanup_hcd_create; | 437 | goto cleanup_clk_en; |
| 440 | } | 438 | } |
| 441 | tegra->ehci->caps = hcd->regs + 0x100; | 439 | ehci->caps = hcd->regs + 0x100; |
| 442 | 440 | ||
| 443 | err = usb_phy_init(hcd->phy); | 441 | err = usb_phy_init(hcd->phy); |
| 444 | if (err) { | 442 | if (err) { |
| 445 | dev_err(&pdev->dev, "Failed to initialize phy\n"); | 443 | dev_err(&pdev->dev, "Failed to initialize phy\n"); |
| 446 | goto cleanup_hcd_create; | 444 | goto cleanup_clk_en; |
| 447 | } | 445 | } |
| 448 | 446 | ||
| 449 | u_phy->otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), | 447 | 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 | tegra->transceiver = ERR_PTR(-ENODEV); | 475 | tegra->transceiver = ERR_PTR(-ENODEV); |
| 478 | } | 476 | } |
| 479 | 477 | ||
| 480 | platform_set_drvdata(pdev, tegra); | ||
| 481 | |||
| 482 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 478 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
| 483 | if (err) { | 479 | if (err) { |
| 484 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); | 480 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); |
| @@ -492,17 +488,22 @@ cleanup_phy: | |||
| 492 | otg_set_host(tegra->transceiver->otg, NULL); | 488 | otg_set_host(tegra->transceiver->otg, NULL); |
| 493 | 489 | ||
| 494 | usb_phy_shutdown(hcd->phy); | 490 | usb_phy_shutdown(hcd->phy); |
| 491 | cleanup_clk_en: | ||
| 492 | clk_disable_unprepare(tegra->clk); | ||
| 493 | cleanup_clk_get: | ||
| 494 | clk_put(tegra->clk); | ||
| 495 | cleanup_hcd_create: | 495 | cleanup_hcd_create: |
| 496 | usb_put_hcd(hcd); | 496 | usb_put_hcd(hcd); |
| 497 | cleanup_clk: | 497 | cleanup_vbus_gpio: |
| 498 | clk_disable_unprepare(tegra->clk); | 498 | /* FIXME: Undo setup_vbus_gpio() here */ |
| 499 | return err; | 499 | return err; |
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | static int tegra_ehci_remove(struct platform_device *pdev) | 502 | static int tegra_ehci_remove(struct platform_device *pdev) |
| 503 | { | 503 | { |
| 504 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | 504 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 505 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | 505 | struct tegra_ehci_hcd *tegra = |
| 506 | (struct tegra_ehci_hcd *)hcd_to_ehci(hcd)->priv; | ||
| 506 | 507 | ||
| 507 | if (!IS_ERR(tegra->transceiver)) | 508 | if (!IS_ERR(tegra->transceiver)) |
| 508 | otg_set_host(tegra->transceiver->otg, NULL); | 509 | otg_set_host(tegra->transceiver->otg, NULL); |
| @@ -518,8 +519,7 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
| 518 | 519 | ||
| 519 | static void tegra_ehci_hcd_shutdown(struct platform_device *pdev) | 520 | static void tegra_ehci_hcd_shutdown(struct platform_device *pdev) |
| 520 | { | 521 | { |
| 521 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | 522 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 522 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | ||
| 523 | 523 | ||
| 524 | if (hcd->driver->shutdown) | 524 | if (hcd->driver->shutdown) |
| 525 | hcd->driver->shutdown(hcd); | 525 | hcd->driver->shutdown(hcd); |
