diff options
author | Felipe Balbi <balbi@ti.com> | 2014-04-16 17:16:33 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-04-21 15:07:25 -0400 |
commit | 2f36ff6915c6c00df8b9962d9c6c7992befcf8ce (patch) | |
tree | 86659a77a445a849073032e9b74fdfad828d147c | |
parent | e741e637a85a802a93125dca1ecf324bc414101b (diff) |
usb: phy: generic: allow multiples calls to usb_phy_generic_register()
it's now very easy to return a platform_device pointer
and have the caller pass it as argument when calling
usb_phy_generic_unregister().
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/musb/am35x.c | 12 | ||||
-rw-r--r-- | drivers/usb/musb/blackfin.c | 10 | ||||
-rw-r--r-- | drivers/usb/musb/da8xx.c | 14 | ||||
-rw-r--r-- | drivers/usb/musb/tusb6010.c | 3 | ||||
-rw-r--r-- | drivers/usb/phy/phy-generic.c | 19 | ||||
-rw-r--r-- | include/linux/usb/usb_phy_generic.h | 9 |
6 files changed, 40 insertions, 27 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 05459b56b2a8..0a34dd859555 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -85,6 +85,7 @@ | |||
85 | struct am35x_glue { | 85 | struct am35x_glue { |
86 | struct device *dev; | 86 | struct device *dev; |
87 | struct platform_device *musb; | 87 | struct platform_device *musb; |
88 | struct platform_device *phy; | ||
88 | struct clk *phy_clk; | 89 | struct clk *phy_clk; |
89 | struct clk *clk; | 90 | struct clk *clk; |
90 | }; | 91 | }; |
@@ -503,7 +504,9 @@ static int am35x_probe(struct platform_device *pdev) | |||
503 | 504 | ||
504 | pdata->platform_ops = &am35x_ops; | 505 | pdata->platform_ops = &am35x_ops; |
505 | 506 | ||
506 | usb_phy_generic_register(); | 507 | glue->phy = usb_phy_generic_register(); |
508 | if (IS_ERR(glue->phy)) | ||
509 | goto err7; | ||
507 | platform_set_drvdata(pdev, glue); | 510 | platform_set_drvdata(pdev, glue); |
508 | 511 | ||
509 | pinfo = am35x_dev_info; | 512 | pinfo = am35x_dev_info; |
@@ -517,11 +520,14 @@ static int am35x_probe(struct platform_device *pdev) | |||
517 | if (IS_ERR(musb)) { | 520 | if (IS_ERR(musb)) { |
518 | ret = PTR_ERR(musb); | 521 | ret = PTR_ERR(musb); |
519 | dev_err(&pdev->dev, "failed to register musb device: %d\n", ret); | 522 | dev_err(&pdev->dev, "failed to register musb device: %d\n", ret); |
520 | goto err7; | 523 | goto err8; |
521 | } | 524 | } |
522 | 525 | ||
523 | return 0; | 526 | return 0; |
524 | 527 | ||
528 | err8: | ||
529 | usb_phy_generic_unregister(glue->phy); | ||
530 | |||
525 | err7: | 531 | err7: |
526 | clk_disable(clk); | 532 | clk_disable(clk); |
527 | 533 | ||
@@ -546,7 +552,7 @@ static int am35x_remove(struct platform_device *pdev) | |||
546 | struct am35x_glue *glue = platform_get_drvdata(pdev); | 552 | struct am35x_glue *glue = platform_get_drvdata(pdev); |
547 | 553 | ||
548 | platform_device_unregister(glue->musb); | 554 | platform_device_unregister(glue->musb); |
549 | usb_phy_generic_unregister(); | 555 | usb_phy_generic_unregister(glue->phy); |
550 | clk_disable(glue->clk); | 556 | clk_disable(glue->clk); |
551 | clk_disable(glue->phy_clk); | 557 | clk_disable(glue->phy_clk); |
552 | clk_put(glue->clk); | 558 | clk_put(glue->clk); |
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 53acffe9a858..d40d5f0b5528 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -29,6 +29,7 @@ | |||
29 | struct bfin_glue { | 29 | struct bfin_glue { |
30 | struct device *dev; | 30 | struct device *dev; |
31 | struct platform_device *musb; | 31 | struct platform_device *musb; |
32 | struct platform_device *phy; | ||
32 | }; | 33 | }; |
33 | #define glue_to_musb(g) platform_get_drvdata(g->musb) | 34 | #define glue_to_musb(g) platform_get_drvdata(g->musb) |
34 | 35 | ||
@@ -475,7 +476,9 @@ static int bfin_probe(struct platform_device *pdev) | |||
475 | 476 | ||
476 | pdata->platform_ops = &bfin_ops; | 477 | pdata->platform_ops = &bfin_ops; |
477 | 478 | ||
478 | usb_phy_generic_register(); | 479 | glue->phy = usb_phy_generic_register(); |
480 | if (IS_ERR(glue->phy)) | ||
481 | goto err2; | ||
479 | platform_set_drvdata(pdev, glue); | 482 | platform_set_drvdata(pdev, glue); |
480 | 483 | ||
481 | memset(musb_resources, 0x00, sizeof(*musb_resources) * | 484 | memset(musb_resources, 0x00, sizeof(*musb_resources) * |
@@ -513,6 +516,9 @@ static int bfin_probe(struct platform_device *pdev) | |||
513 | return 0; | 516 | return 0; |
514 | 517 | ||
515 | err3: | 518 | err3: |
519 | usb_phy_generic_unregister(glue->phy); | ||
520 | |||
521 | err2: | ||
516 | platform_device_put(musb); | 522 | platform_device_put(musb); |
517 | 523 | ||
518 | err1: | 524 | err1: |
@@ -527,7 +533,7 @@ static int bfin_remove(struct platform_device *pdev) | |||
527 | struct bfin_glue *glue = platform_get_drvdata(pdev); | 533 | struct bfin_glue *glue = platform_get_drvdata(pdev); |
528 | 534 | ||
529 | platform_device_unregister(glue->musb); | 535 | platform_device_unregister(glue->musb); |
530 | usb_phy_generic_unregister(); | 536 | usb_phy_generic_unregister(glue->phy); |
531 | kfree(glue); | 537 | kfree(glue); |
532 | 538 | ||
533 | return 0; | 539 | return 0; |
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 024751f9b31d..058775e647ad 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -85,6 +85,7 @@ | |||
85 | struct da8xx_glue { | 85 | struct da8xx_glue { |
86 | struct device *dev; | 86 | struct device *dev; |
87 | struct platform_device *musb; | 87 | struct platform_device *musb; |
88 | struct platform_device *phy; | ||
88 | struct clk *clk; | 89 | struct clk *clk; |
89 | }; | 90 | }; |
90 | 91 | ||
@@ -510,7 +511,11 @@ static int da8xx_probe(struct platform_device *pdev) | |||
510 | 511 | ||
511 | pdata->platform_ops = &da8xx_ops; | 512 | pdata->platform_ops = &da8xx_ops; |
512 | 513 | ||
513 | usb_phy_generic_register(); | 514 | glue->phy = usb_phy_generic_register(); |
515 | if (IS_ERR(glue->phy)) { | ||
516 | ret = PTR_ERR(glue->phy); | ||
517 | goto err5; | ||
518 | } | ||
514 | platform_set_drvdata(pdev, glue); | 519 | platform_set_drvdata(pdev, glue); |
515 | 520 | ||
516 | memset(musb_resources, 0x00, sizeof(*musb_resources) * | 521 | memset(musb_resources, 0x00, sizeof(*musb_resources) * |
@@ -537,11 +542,14 @@ static int da8xx_probe(struct platform_device *pdev) | |||
537 | if (IS_ERR(musb)) { | 542 | if (IS_ERR(musb)) { |
538 | ret = PTR_ERR(musb); | 543 | ret = PTR_ERR(musb); |
539 | dev_err(&pdev->dev, "failed to register musb device: %d\n", ret); | 544 | dev_err(&pdev->dev, "failed to register musb device: %d\n", ret); |
540 | goto err5; | 545 | goto err6; |
541 | } | 546 | } |
542 | 547 | ||
543 | return 0; | 548 | return 0; |
544 | 549 | ||
550 | err6: | ||
551 | usb_phy_generic_unregister(glue->phy); | ||
552 | |||
545 | err5: | 553 | err5: |
546 | clk_disable(clk); | 554 | clk_disable(clk); |
547 | 555 | ||
@@ -560,7 +568,7 @@ static int da8xx_remove(struct platform_device *pdev) | |||
560 | struct da8xx_glue *glue = platform_get_drvdata(pdev); | 568 | struct da8xx_glue *glue = platform_get_drvdata(pdev); |
561 | 569 | ||
562 | platform_device_unregister(glue->musb); | 570 | platform_device_unregister(glue->musb); |
563 | usb_phy_generic_unregister(); | 571 | usb_phy_generic_unregister(glue->phy); |
564 | clk_disable(glue->clk); | 572 | clk_disable(glue->clk); |
565 | clk_put(glue->clk); | 573 | clk_put(glue->clk); |
566 | kfree(glue); | 574 | kfree(glue); |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index e1da199c6f21..f38a8dbd6075 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -31,6 +31,7 @@ | |||
31 | struct tusb6010_glue { | 31 | struct tusb6010_glue { |
32 | struct device *dev; | 32 | struct device *dev; |
33 | struct platform_device *musb; | 33 | struct platform_device *musb; |
34 | struct platform_device *phy; | ||
34 | }; | 35 | }; |
35 | 36 | ||
36 | static void tusb_musb_set_vbus(struct musb *musb, int is_on); | 37 | static void tusb_musb_set_vbus(struct musb *musb, int is_on); |
@@ -1222,7 +1223,7 @@ static int tusb_remove(struct platform_device *pdev) | |||
1222 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); | 1223 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); |
1223 | 1224 | ||
1224 | platform_device_unregister(glue->musb); | 1225 | platform_device_unregister(glue->musb); |
1225 | usb_phy_generic_unregister(); | 1226 | usb_phy_generic_unregister(glue->phy); |
1226 | kfree(glue); | 1227 | kfree(glue); |
1227 | 1228 | ||
1228 | return 0; | 1229 | return 0; |
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 2c49cd8f6d25..7594e5069ae5 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c | |||
@@ -41,25 +41,16 @@ | |||
41 | 41 | ||
42 | #include "phy-generic.h" | 42 | #include "phy-generic.h" |
43 | 43 | ||
44 | static struct platform_device *pd; | 44 | struct platform_device *usb_phy_generic_register(void) |
45 | |||
46 | void usb_phy_generic_register(void) | ||
47 | { | 45 | { |
48 | if (pd) | 46 | return platform_device_register_simple("usb_phy_generic", |
49 | return; | 47 | PLATFORM_DEVID_AUTO, NULL, 0); |
50 | pd = platform_device_register_simple("usb_phy_generic", -1, NULL, 0); | ||
51 | if (IS_ERR(pd)) { | ||
52 | pr_err("Unable to register generic usb transceiver\n"); | ||
53 | pd = NULL; | ||
54 | return; | ||
55 | } | ||
56 | } | 48 | } |
57 | EXPORT_SYMBOL_GPL(usb_phy_generic_register); | 49 | EXPORT_SYMBOL_GPL(usb_phy_generic_register); |
58 | 50 | ||
59 | void usb_phy_generic_unregister(void) | 51 | void usb_phy_generic_unregister(struct platform_device *pdev) |
60 | { | 52 | { |
61 | platform_device_unregister(pd); | 53 | platform_device_unregister(pdev); |
62 | pd = NULL; | ||
63 | } | 54 | } |
64 | EXPORT_SYMBOL_GPL(usb_phy_generic_unregister); | 55 | EXPORT_SYMBOL_GPL(usb_phy_generic_unregister); |
65 | 56 | ||
diff --git a/include/linux/usb/usb_phy_generic.h b/include/linux/usb/usb_phy_generic.h index c00176d48625..8346bcc50c2f 100644 --- a/include/linux/usb/usb_phy_generic.h +++ b/include/linux/usb/usb_phy_generic.h | |||
@@ -15,14 +15,15 @@ struct usb_phy_generic_platform_data { | |||
15 | 15 | ||
16 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | 16 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) |
17 | /* sometimes transceivers are accessed only through e.g. ULPI */ | 17 | /* sometimes transceivers are accessed only through e.g. ULPI */ |
18 | extern void usb_phy_generic_register(void); | 18 | extern struct platform_device *usb_phy_generic_register(void); |
19 | extern void usb_phy_generic_unregister(void); | 19 | extern void usb_phy_generic_unregister(struct platform_device *); |
20 | #else | 20 | #else |
21 | static inline void usb_phy_generic_register(void) | 21 | static inline struct platform_device *usb_phy_generic_register(void) |
22 | { | 22 | { |
23 | return NULL; | ||
23 | } | 24 | } |
24 | 25 | ||
25 | static inline void usb_phy_generic_unregister(void) | 26 | static inline void usb_phy_generic_unregister(struct platform_device *pdev) |
26 | { | 27 | { |
27 | } | 28 | } |
28 | #endif | 29 | #endif |