Re: [PATCHv3 1/4] phy: phy-core: Make GENERIC_PHY an invisible option

2015-05-26 Thread Arun Ramamurthy

Hi

On 15-05-26 07:19 AM, Felipe Balbi wrote:

HI,

On Mon, May 25, 2015 at 02:19:58PM -0700, Arun Ramamurthy wrote:



On 15-05-14 05:52 PM, Felipe Balbi wrote:

Hi,

On Wed, Apr 22, 2015 at 04:04:10PM -0700, Arun Ramamurthy wrote:

Most of the phy providers use select to enable GENERIC_PHY. Since select
is only recommended when the config is not visible, GENERIC_PHY is changed
an invisible option. To maintain consistency, all phy providers are changed
to select GENERIC_PHY and all non-phy drivers use depends on when the
phy framework is explicity required. USB_MUSB_OMAP2PLUS has a cyclic
dependency, so it is left as select.

Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com
---
  drivers/ata/Kconfig   | 1 -
  drivers/media/platform/exynos4-is/Kconfig | 2 +-
  drivers/phy/Kconfig   | 4 ++--
  drivers/usb/host/Kconfig  | 4 ++--
  drivers/video/fbdev/exynos/Kconfig| 2 +-
  5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 5f60155..6d2e881 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -301,7 +301,6 @@ config SATA_MV
tristate Marvell SATA support
depends on PCI || ARCH_DOVE || ARCH_MV78XX0 || \
   ARCH_MVEBU || ARCH_ORION5X || COMPILE_TEST
-   select GENERIC_PHY
help
  This option enables support for the Marvell Serial ATA family.
  Currently supports 88SX[56]0[48][01] PCI(-X) chips,
diff --git a/drivers/media/platform/exynos4-is/Kconfig 
b/drivers/media/platform/exynos4-is/Kconfig
index b7b2e47..b6f3eaa 100644
--- a/drivers/media/platform/exynos4-is/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -31,7 +31,7 @@ config VIDEO_S5P_FIMC
  config VIDEO_S5P_MIPI_CSIS
tristate S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver
depends on REGULATOR
-   select GENERIC_PHY
+   depends on GENERIC_PHY
help
  This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2
  receiver (MIPI-CSIS) devices.
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 2962de2..edecdb1 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -5,7 +5,7 @@
  menu PHY Subsystem

  config GENERIC_PHY
-   bool PHY Core
+   bool
help
  Generic PHY support.

@@ -72,7 +72,7 @@ config PHY_MIPHY365X
  config PHY_RCAR_GEN2
tristate Renesas R-Car generation 2 USB PHY driver
depends on ARCH_SHMOBILE
-   depends on GENERIC_PHY
+   select GENERIC_PHY


so some you changed from depends to select...


help
  Support for USB PHY found on Renesas R-Car generation 2 SoCs.

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 5ad60e4..e2197e2 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -182,7 +182,7 @@ config USB_EHCI_HCD_SPEAR
  config USB_EHCI_HCD_STI
tristate Support for ST STiHxxx on-chip EHCI USB controller
depends on ARCH_STI  OF
-   select GENERIC_PHY
+   depends on GENERIC_PHY


while others you changed from select to depends.

NAK.


Felipe, I dont understand your concern, could you please explain it more
detail?  The logic behind the changes is that in cases where there was an
explicit dependency, I changed it to depends on and in other cases I
changed it to selects. Thanks


Since GENERIC_PHY is visible from Kconfig, it would be much nicer to
avoid select altogether.

Felipe, after discussion with the maintainers, I have made GENERIC_PHY 
an invisible option as part of this change. Thanks

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 1/4] phy: phy-core: Make GENERIC_PHY an invisible option

2015-05-25 Thread Arun Ramamurthy



On 15-05-14 05:52 PM, Felipe Balbi wrote:

Hi,

On Wed, Apr 22, 2015 at 04:04:10PM -0700, Arun Ramamurthy wrote:

Most of the phy providers use select to enable GENERIC_PHY. Since select
is only recommended when the config is not visible, GENERIC_PHY is changed
an invisible option. To maintain consistency, all phy providers are changed
to select GENERIC_PHY and all non-phy drivers use depends on when the
phy framework is explicity required. USB_MUSB_OMAP2PLUS has a cyclic
dependency, so it is left as select.

Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com
---
  drivers/ata/Kconfig   | 1 -
  drivers/media/platform/exynos4-is/Kconfig | 2 +-
  drivers/phy/Kconfig   | 4 ++--
  drivers/usb/host/Kconfig  | 4 ++--
  drivers/video/fbdev/exynos/Kconfig| 2 +-
  5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 5f60155..6d2e881 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -301,7 +301,6 @@ config SATA_MV
tristate Marvell SATA support
depends on PCI || ARCH_DOVE || ARCH_MV78XX0 || \
   ARCH_MVEBU || ARCH_ORION5X || COMPILE_TEST
-   select GENERIC_PHY
help
  This option enables support for the Marvell Serial ATA family.
  Currently supports 88SX[56]0[48][01] PCI(-X) chips,
diff --git a/drivers/media/platform/exynos4-is/Kconfig 
b/drivers/media/platform/exynos4-is/Kconfig
index b7b2e47..b6f3eaa 100644
--- a/drivers/media/platform/exynos4-is/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -31,7 +31,7 @@ config VIDEO_S5P_FIMC
  config VIDEO_S5P_MIPI_CSIS
tristate S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver
depends on REGULATOR
-   select GENERIC_PHY
+   depends on GENERIC_PHY
help
  This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2
  receiver (MIPI-CSIS) devices.
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 2962de2..edecdb1 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -5,7 +5,7 @@
  menu PHY Subsystem

  config GENERIC_PHY
-   bool PHY Core
+   bool
help
  Generic PHY support.

@@ -72,7 +72,7 @@ config PHY_MIPHY365X
  config PHY_RCAR_GEN2
tristate Renesas R-Car generation 2 USB PHY driver
depends on ARCH_SHMOBILE
-   depends on GENERIC_PHY
+   select GENERIC_PHY


so some you changed from depends to select...


help
  Support for USB PHY found on Renesas R-Car generation 2 SoCs.

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 5ad60e4..e2197e2 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -182,7 +182,7 @@ config USB_EHCI_HCD_SPEAR
  config USB_EHCI_HCD_STI
tristate Support for ST STiHxxx on-chip EHCI USB controller
depends on ARCH_STI  OF
-   select GENERIC_PHY
+   depends on GENERIC_PHY


while others you changed from select to depends.

NAK.

Felipe, I dont understand your concern, could you please explain it more 
detail?  The logic behind the changes is that in cases where there was 
an explicit dependency, I changed it to depends on and in other cases 
I changed it to selects. Thanks

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 2/4] phy: core: Add devm_of_phy_get_by_index to phy-core

2015-04-22 Thread Arun Ramamurthy
Some generic drivers, such as ehci, may use multiple phys and for such
drivers referencing phy(s) by name(s) does not make sense. Instead of
inventing new naming schemes and using custom code to iterate through them,
such drivers are better of using nameless phy bindings and using this newly
introduced API to iterate through them.

Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com
Reviewed-by: Ray Jui r...@broadcom.com
Reviewed-by: Scott Branden sbran...@broadcom.com
---
 Documentation/phy.txt   |  7 ++-
 drivers/phy/phy-core.c  | 32 
 include/linux/phy/phy.h |  8 
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/Documentation/phy.txt b/Documentation/phy.txt
index 371361c..b388c5a 100644
--- a/Documentation/phy.txt
+++ b/Documentation/phy.txt
@@ -76,6 +76,8 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node 
*np,
+int index);
 
 phy_get, phy_optional_get, devm_phy_get and devm_phy_optional_get can
 be used to get the PHY. In the case of dt boot, the string arguments
@@ -86,7 +88,10 @@ successful PHY get. On driver detach, release function is 
invoked on
 the the devres data and devres data is freed. phy_optional_get and
 devm_phy_optional_get should be used when the phy is optional. These
 two functions will never return -ENODEV, but instead returns NULL when
-the phy cannot be found.
+the phy cannot be found.Some generic drivers, such as ehci, may use multiple
+phys and for such drivers referencing phy(s) by name(s) does not make sense. In
+this case, devm_of_phy_get_by_index can be used to get a phy reference based on
+the index.
 
 It should be noted that NULL is a valid phy reference. All phy
 consumer calls on the NULL phy become NOPs. That is the release calls,
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 3791838..964a84d 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -623,6 +623,38 @@ struct phy *devm_of_phy_get(struct device *dev, struct 
device_node *np,
 EXPORT_SYMBOL_GPL(devm_of_phy_get);
 
 /**
+ * devm_of_phy_get_by_index() - lookup and obtain a reference to a phy by 
index.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @index: index of the phy
+ *
+ * Gets the phy using _of_phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ *
+ */
+struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node 
*np,
+int index)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = _of_phy_get(np, index);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @node: device node of the phy
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index a0197fa..978d5af 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -133,6 +133,8 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
const char *con_id);
+struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node 
*np,
+int index);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
@@ -261,6 +263,12 @@ static inline struct phy *devm_of_phy_get(struct device 
*dev,
return ERR_PTR(-ENOSYS);
 }
 
+struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node 
*np,
+int index);
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline void phy_put(struct phy *phy)
 {
 }
-- 
2.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 0/4] add devm_of_phy_get_by_index and update platform drivers

2015-04-22 Thread Arun Ramamurthy
This patch set adds a new API to get phy by index when multiple 
phys are present. This patch is based on discussion with Arnd Bergmann
about dt bindings for multiple phys.

History:
v1:
- Removed null pointers on Dmitry's suggestion
- Improved documentation in commit messages
- Exported new phy api
v2:
- EHCI and OHCI platform Kconfigs select Generic Phy
  to fix build errors in certain configs.
v3:
- Made GENERIC_PHY an invisible option so 
that other configs can select it
- Added stubs for devm_of_phy_get_by_index
- Reformated code

Arun Ramamurthy (4):
  phy: phy-core: Make GENERIC_PHY an invisible option
  phy: core: Add devm_of_phy_get_by_index to phy-core
  usb: ehci-platform: Use devm_of_phy_get_by_index
  usb: ohci-platform: Use devm_of_phy_get_by_index

 Documentation/phy.txt |  7 +++-
 drivers/ata/Kconfig   |  1 -
 drivers/media/platform/exynos4-is/Kconfig |  2 +-
 drivers/phy/Kconfig   |  4 +-
 drivers/phy/phy-core.c| 32 ++
 drivers/usb/host/Kconfig  |  4 +-
 drivers/usb/host/ehci-platform.c  | 69 +++
 drivers/usb/host/ohci-platform.c  | 69 +++
 drivers/video/fbdev/exynos/Kconfig|  2 +-
 include/linux/phy/phy.h   |  8 
 10 files changed, 100 insertions(+), 98 deletions(-)

-- 
2.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 1/4] phy: phy-core: Make GENERIC_PHY an invisible option

2015-04-22 Thread Arun Ramamurthy
Most of the phy providers use select to enable GENERIC_PHY. Since select
is only recommended when the config is not visible, GENERIC_PHY is changed
an invisible option. To maintain consistency, all phy providers are changed
to select GENERIC_PHY and all non-phy drivers use depends on when the
phy framework is explicity required. USB_MUSB_OMAP2PLUS has a cyclic
dependency, so it is left as select.

Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com
---
 drivers/ata/Kconfig   | 1 -
 drivers/media/platform/exynos4-is/Kconfig | 2 +-
 drivers/phy/Kconfig   | 4 ++--
 drivers/usb/host/Kconfig  | 4 ++--
 drivers/video/fbdev/exynos/Kconfig| 2 +-
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 5f60155..6d2e881 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -301,7 +301,6 @@ config SATA_MV
tristate Marvell SATA support
depends on PCI || ARCH_DOVE || ARCH_MV78XX0 || \
   ARCH_MVEBU || ARCH_ORION5X || COMPILE_TEST
-   select GENERIC_PHY
help
  This option enables support for the Marvell Serial ATA family.
  Currently supports 88SX[56]0[48][01] PCI(-X) chips,
diff --git a/drivers/media/platform/exynos4-is/Kconfig 
b/drivers/media/platform/exynos4-is/Kconfig
index b7b2e47..b6f3eaa 100644
--- a/drivers/media/platform/exynos4-is/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -31,7 +31,7 @@ config VIDEO_S5P_FIMC
 config VIDEO_S5P_MIPI_CSIS
tristate S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver
depends on REGULATOR
-   select GENERIC_PHY
+   depends on GENERIC_PHY
help
  This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2
  receiver (MIPI-CSIS) devices.
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 2962de2..edecdb1 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -5,7 +5,7 @@
 menu PHY Subsystem
 
 config GENERIC_PHY
-   bool PHY Core
+   bool
help
  Generic PHY support.
 
@@ -72,7 +72,7 @@ config PHY_MIPHY365X
 config PHY_RCAR_GEN2
tristate Renesas R-Car generation 2 USB PHY driver
depends on ARCH_SHMOBILE
-   depends on GENERIC_PHY
+   select GENERIC_PHY
help
  Support for USB PHY found on Renesas R-Car generation 2 SoCs.
 
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 5ad60e4..e2197e2 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -182,7 +182,7 @@ config USB_EHCI_HCD_SPEAR
 config USB_EHCI_HCD_STI
tristate Support for ST STiHxxx on-chip EHCI USB controller
depends on ARCH_STI  OF
-   select GENERIC_PHY
+   depends on GENERIC_PHY
select USB_EHCI_HCD_PLATFORM
help
  Enable support for the on-chip EHCI controller found on
@@ -409,7 +409,7 @@ config USB_OHCI_HCD_SPEAR
 config USB_OHCI_HCD_STI
tristate Support for ST STiHxxx on-chip OHCI USB controller
depends on ARCH_STI  OF
-   select GENERIC_PHY
+   depends on GENERIC_PHY
select USB_OHCI_HCD_PLATFORM
help
  Enable support for the on-chip OHCI controller found on
diff --git a/drivers/video/fbdev/exynos/Kconfig 
b/drivers/video/fbdev/exynos/Kconfig
index 1f16b46..6c53894 100644
--- a/drivers/video/fbdev/exynos/Kconfig
+++ b/drivers/video/fbdev/exynos/Kconfig
@@ -16,7 +16,7 @@ if EXYNOS_VIDEO
 
 config EXYNOS_MIPI_DSI
bool EXYNOS MIPI DSI driver support.
-   select GENERIC_PHY
+   depends on GENERIC_PHY
help
  This enables support for MIPI-DSI device.
 
-- 
2.3.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 4/4] usb: ohci-platform: Use devm_of_phy_get_by_index

2015-04-22 Thread Arun Ramamurthy
Getting phys by index instead of phy names so that we do
not have to create a naming scheme when multiple phys are present

Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com
Reviewed-by: Ray Jui r...@broadcom.com
Reviewed-by: Scott Branden sbran...@broadcom.com
---
 drivers/usb/host/ohci-platform.c | 69 ++--
 1 file changed, 24 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 185ceee..c2669f18 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -57,15 +57,13 @@ static int ohci_platform_power_on(struct platform_device 
*dev)
}
 
for (phy_num = 0; phy_num  priv-num_phys; phy_num++) {
-   if (priv-phys[phy_num]) {
-   ret = phy_init(priv-phys[phy_num]);
-   if (ret)
-   goto err_exit_phy;
-   ret = phy_power_on(priv-phys[phy_num]);
-   if (ret) {
-   phy_exit(priv-phys[phy_num]);
-   goto err_exit_phy;
-   }
+   ret = phy_init(priv-phys[phy_num]);
+   if (ret)
+   goto err_exit_phy;
+   ret = phy_power_on(priv-phys[phy_num]);
+   if (ret) {
+   phy_exit(priv-phys[phy_num]);
+   goto err_exit_phy;
}
}
 
@@ -73,10 +71,8 @@ static int ohci_platform_power_on(struct platform_device 
*dev)
 
 err_exit_phy:
while (--phy_num = 0) {
-   if (priv-phys[phy_num]) {
-   phy_power_off(priv-phys[phy_num]);
-   phy_exit(priv-phys[phy_num]);
-   }
+   phy_power_off(priv-phys[phy_num]);
+   phy_exit(priv-phys[phy_num]);
}
 err_disable_clks:
while (--clk = 0)
@@ -92,10 +88,8 @@ static void ohci_platform_power_off(struct platform_device 
*dev)
int clk, phy_num;
 
for (phy_num = 0; phy_num  priv-num_phys; phy_num++) {
-   if (priv-phys[phy_num]) {
-   phy_power_off(priv-phys[phy_num]);
-   phy_exit(priv-phys[phy_num]);
-   }
+   phy_power_off(priv-phys[phy_num]);
+   phy_exit(priv-phys[phy_num]);
}
 
for (clk = OHCI_MAX_CLKS - 1; clk = 0; clk--)
@@ -123,7 +117,6 @@ static int ohci_platform_probe(struct platform_device *dev)
struct usb_ohci_pdata *pdata = dev_get_platdata(dev-dev);
struct ohci_platform_priv *priv;
struct ohci_hcd *ohci;
-   const char *phy_name;
int err, irq, phy_num, clk = 0;
 
if (usb_disabled())
@@ -174,36 +167,22 @@ static int ohci_platform_probe(struct platform_device 
*dev)
 
priv-num_phys = of_count_phandle_with_args(dev-dev.of_node,
phys, #phy-cells);
-   priv-num_phys = priv-num_phys  0 ? priv-num_phys : 1;
 
-   priv-phys = devm_kcalloc(dev-dev, priv-num_phys,
-   sizeof(struct phy *), GFP_KERNEL);
-   if (!priv-phys)
-   return -ENOMEM;
+   if (priv-num_phys  0) {
+   priv-phys = devm_kcalloc(dev-dev, priv-num_phys,
+   sizeof(struct phy *), GFP_KERNEL);
+   if (!priv-phys)
+   return -ENOMEM;
+   } else
+   priv-num_phys = 0;
 
for (phy_num = 0; phy_num  priv-num_phys; phy_num++) {
-   err = of_property_read_string_index(
-   dev-dev.of_node,
-   phy-names, phy_num,
-   phy_name);
-
-   if (err  0) {
-   if (priv-num_phys  1) {
-   dev_err(dev-dev, phy-names 
not provided);
-   goto err_put_hcd;
-   } else
-   phy_name = usb;
-   }
-
-   priv-phys[phy_num] = devm_phy_get(dev-dev,
-   phy_name);
-   if (IS_ERR(priv-phys[phy_num])) {
-   err = PTR_ERR(priv-phys[phy_num]);
-   if ((priv-num_phys  1) ||
-   (err == -EPROBE_DEFER))
-   goto err_put_hcd;
-   priv-phys[phy_num] = NULL;
-   }
+   priv-phys

[PATCHv3 3/4] usb: ehci-platform: Use devm_of_phy_get_by_index

2015-04-22 Thread Arun Ramamurthy
Getting phys by index instead of phy names so that we do
not have to create a naming scheme when multiple phys
are present

Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com
Reviewed-by: Ray Jui r...@broadcom.com
Reviewed-by: Scott Branden sbran...@broadcom.com
---
 drivers/usb/host/ehci-platform.c | 69 ++--
 1 file changed, 24 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index d8a75a5..145bf19 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -88,15 +88,13 @@ static int ehci_platform_power_on(struct platform_device 
*dev)
}
 
for (phy_num = 0; phy_num  priv-num_phys; phy_num++) {
-   if (priv-phys[phy_num]) {
-   ret = phy_init(priv-phys[phy_num]);
-   if (ret)
-   goto err_exit_phy;
-   ret = phy_power_on(priv-phys[phy_num]);
-   if (ret) {
-   phy_exit(priv-phys[phy_num]);
-   goto err_exit_phy;
-   }
+   ret = phy_init(priv-phys[phy_num]);
+   if (ret)
+   goto err_exit_phy;
+   ret = phy_power_on(priv-phys[phy_num]);
+   if (ret) {
+   phy_exit(priv-phys[phy_num]);
+   goto err_exit_phy;
}
}
 
@@ -104,10 +102,8 @@ static int ehci_platform_power_on(struct platform_device 
*dev)
 
 err_exit_phy:
while (--phy_num = 0) {
-   if (priv-phys[phy_num]) {
-   phy_power_off(priv-phys[phy_num]);
-   phy_exit(priv-phys[phy_num]);
-   }
+   phy_power_off(priv-phys[phy_num]);
+   phy_exit(priv-phys[phy_num]);
}
 err_disable_clks:
while (--clk = 0)
@@ -123,10 +119,8 @@ static void ehci_platform_power_off(struct platform_device 
*dev)
int clk, phy_num;
 
for (phy_num = 0; phy_num  priv-num_phys; phy_num++) {
-   if (priv-phys[phy_num]) {
-   phy_power_off(priv-phys[phy_num]);
-   phy_exit(priv-phys[phy_num]);
-   }
+   phy_power_off(priv-phys[phy_num]);
+   phy_exit(priv-phys[phy_num]);
}
 
for (clk = EHCI_MAX_CLKS - 1; clk = 0; clk--)
@@ -154,7 +148,6 @@ static int ehci_platform_probe(struct platform_device *dev)
struct usb_ehci_pdata *pdata = dev_get_platdata(dev-dev);
struct ehci_platform_priv *priv;
struct ehci_hcd *ehci;
-   const char *phy_name;
int err, irq, phy_num, clk = 0;
 
if (usb_disabled())
@@ -204,36 +197,22 @@ static int ehci_platform_probe(struct platform_device 
*dev)
 
priv-num_phys = of_count_phandle_with_args(dev-dev.of_node,
phys, #phy-cells);
-   priv-num_phys = priv-num_phys  0 ? priv-num_phys : 1;
 
-   priv-phys = devm_kcalloc(dev-dev, priv-num_phys,
-   sizeof(struct phy *), GFP_KERNEL);
-   if (!priv-phys)
-   return -ENOMEM;
+   if (priv-num_phys  0) {
+   priv-phys = devm_kcalloc(dev-dev, priv-num_phys,
+   sizeof(struct phy *), GFP_KERNEL);
+   if (!priv-phys)
+   return -ENOMEM;
+   } else
+   priv-num_phys = 0;
 
for (phy_num = 0; phy_num  priv-num_phys; phy_num++) {
-   err = of_property_read_string_index(
-   dev-dev.of_node,
-   phy-names, phy_num,
-   phy_name);
-
-   if (err  0) {
-   if (priv-num_phys  1) {
-   dev_err(dev-dev, phy-names 
not provided);
-   goto err_put_hcd;
-   } else
-   phy_name = usb;
-   }
-
-   priv-phys[phy_num] = devm_phy_get(dev-dev,
-   phy_name);
-   if (IS_ERR(priv-phys[phy_num])) {
-   err = PTR_ERR(priv-phys[phy_num]);
-   if ((priv-num_phys  1) ||
-   (err == -EPROBE_DEFER))
-   goto err_put_hcd;
-   priv-phys[phy_num] = NULL;
-   }
+   priv-phys