[PATCH 5/7] phy: qcom-ufs: Cleanup clock and regulator initialization

2016-10-17 Thread Vivek Gautam
Different methods pass around generic phy pointer to
extract device pointer. Instead, pass the device pointer
directly between function calls.

Signed-off-by: Vivek Gautam 
Reviewed-by: Subhash Jadavani 
---
 drivers/phy/phy-qcom-ufs-i.h|  6 +--
 drivers/phy/phy-qcom-ufs-qmp-14nm.c |  4 +-
 drivers/phy/phy-qcom-ufs-qmp-20nm.c |  4 +-
 drivers/phy/phy-qcom-ufs.c  | 79 -
 4 files changed, 39 insertions(+), 54 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs-i.h b/drivers/phy/phy-qcom-ufs-i.h
index 2bd5ce4..69e836d 100644
--- a/drivers/phy/phy-qcom-ufs-i.h
+++ b/drivers/phy/phy-qcom-ufs-i.h
@@ -142,10 +142,8 @@ struct ufs_qcom_phy *get_ufs_qcom_phy(struct phy 
*generic_phy);
 int ufs_qcom_phy_power_on(struct phy *generic_phy);
 int ufs_qcom_phy_power_off(struct phy *generic_phy);
 int ufs_qcom_phy_exit(struct phy *generic_phy);
-int ufs_qcom_phy_init_clks(struct phy *generic_phy,
-   struct ufs_qcom_phy *phy_common);
-int ufs_qcom_phy_init_vregulators(struct phy *generic_phy,
-   struct ufs_qcom_phy *phy_common);
+int ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common);
+int ufs_qcom_phy_init_vregulators(struct ufs_qcom_phy *phy_common);
 int ufs_qcom_phy_remove(struct phy *generic_phy,
   struct ufs_qcom_phy *ufs_qcom_phy);
 struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c 
b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index a305016..55fecbb 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -48,14 +48,14 @@ static int ufs_qcom_phy_qmp_14nm_init(struct phy 
*generic_phy)
struct ufs_qcom_phy *phy_common = >common_cfg;
int err;
 
-   err = ufs_qcom_phy_init_clks(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_clks(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed 
%d\n",
__func__, err);
goto out;
}
 
-   err = ufs_qcom_phy_init_vregulators(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_vregulators(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() 
failed %d\n",
__func__, err);
diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c 
b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
index 2db1fbb..9a2f53d 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -67,14 +67,14 @@ static int ufs_qcom_phy_qmp_20nm_init(struct phy 
*generic_phy)
struct ufs_qcom_phy *phy_common = >common_cfg;
int err = 0;
 
-   err = ufs_qcom_phy_init_clks(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_clks(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed 
%d\n",
__func__, err);
goto out;
}
 
-   err = ufs_qcom_phy_init_vregulators(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_vregulators(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() 
failed %d\n",
__func__, err);
diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index b8f9286..3a87e88 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,9 +22,9 @@
 #define VDDP_REF_CLK_MIN_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-static int __ufs_qcom_phy_init_vreg(struct phy *, struct ufs_qcom_phy_vreg *,
+static int __ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg 
*,
const char *, bool);
-static int ufs_qcom_phy_init_vreg(struct phy *, struct ufs_qcom_phy_vreg *,
+static int ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg *,
  const char *);
 static int ufs_qcom_phy_base_init(struct platform_device *pdev,
  struct ufs_qcom_phy *phy_common);
@@ -154,13 +154,11 @@ int ufs_qcom_phy_base_init(struct platform_device *pdev,
return 0;
 }
 
-static int __ufs_qcom_phy_clk_get(struct phy *phy,
+static int __ufs_qcom_phy_clk_get(struct device *dev,
 const char *name, struct clk **clk_out, bool err_print)
 {
struct clk *clk;
int err = 0;
-   struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
-   struct device *dev = ufs_qcom_phy->dev;
 
clk = devm_clk_get(dev, name);
if (IS_ERR(clk)) {
@@ -175,40 +173,38 @@ static int __ufs_qcom_phy_clk_get(struct phy *phy,
 }
 
 static
-int ufs_qcom_phy_clk_get(struct phy *phy,
+int ufs_qcom_phy_clk_get(struct device *dev,
 const char *name, struct clk **clk_out)
 {
-   return __ufs_qcom_phy_clk_get(phy, 

[PATCH 5/7] phy: qcom-ufs: Cleanup clock and regulator initialization

2016-10-17 Thread Vivek Gautam
Different methods pass around generic phy pointer to
extract device pointer. Instead, pass the device pointer
directly between function calls.

Signed-off-by: Vivek Gautam 
Reviewed-by: Subhash Jadavani 
---
 drivers/phy/phy-qcom-ufs-i.h|  6 +--
 drivers/phy/phy-qcom-ufs-qmp-14nm.c |  4 +-
 drivers/phy/phy-qcom-ufs-qmp-20nm.c |  4 +-
 drivers/phy/phy-qcom-ufs.c  | 79 -
 4 files changed, 39 insertions(+), 54 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs-i.h b/drivers/phy/phy-qcom-ufs-i.h
index 2bd5ce4..69e836d 100644
--- a/drivers/phy/phy-qcom-ufs-i.h
+++ b/drivers/phy/phy-qcom-ufs-i.h
@@ -142,10 +142,8 @@ struct ufs_qcom_phy *get_ufs_qcom_phy(struct phy 
*generic_phy);
 int ufs_qcom_phy_power_on(struct phy *generic_phy);
 int ufs_qcom_phy_power_off(struct phy *generic_phy);
 int ufs_qcom_phy_exit(struct phy *generic_phy);
-int ufs_qcom_phy_init_clks(struct phy *generic_phy,
-   struct ufs_qcom_phy *phy_common);
-int ufs_qcom_phy_init_vregulators(struct phy *generic_phy,
-   struct ufs_qcom_phy *phy_common);
+int ufs_qcom_phy_init_clks(struct ufs_qcom_phy *phy_common);
+int ufs_qcom_phy_init_vregulators(struct ufs_qcom_phy *phy_common);
 int ufs_qcom_phy_remove(struct phy *generic_phy,
   struct ufs_qcom_phy *ufs_qcom_phy);
 struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c 
b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
index a305016..55fecbb 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
@@ -48,14 +48,14 @@ static int ufs_qcom_phy_qmp_14nm_init(struct phy 
*generic_phy)
struct ufs_qcom_phy *phy_common = >common_cfg;
int err;
 
-   err = ufs_qcom_phy_init_clks(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_clks(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed 
%d\n",
__func__, err);
goto out;
}
 
-   err = ufs_qcom_phy_init_vregulators(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_vregulators(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() 
failed %d\n",
__func__, err);
diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c 
b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
index 2db1fbb..9a2f53d 100644
--- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
+++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
@@ -67,14 +67,14 @@ static int ufs_qcom_phy_qmp_20nm_init(struct phy 
*generic_phy)
struct ufs_qcom_phy *phy_common = >common_cfg;
int err = 0;
 
-   err = ufs_qcom_phy_init_clks(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_clks(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_clks() failed 
%d\n",
__func__, err);
goto out;
}
 
-   err = ufs_qcom_phy_init_vregulators(generic_phy, phy_common);
+   err = ufs_qcom_phy_init_vregulators(phy_common);
if (err) {
dev_err(phy_common->dev, "%s: ufs_qcom_phy_init_vregulators() 
failed %d\n",
__func__, err);
diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index b8f9286..3a87e88 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -22,9 +22,9 @@
 #define VDDP_REF_CLK_MIN_UV120
 #define VDDP_REF_CLK_MAX_UV120
 
-static int __ufs_qcom_phy_init_vreg(struct phy *, struct ufs_qcom_phy_vreg *,
+static int __ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg 
*,
const char *, bool);
-static int ufs_qcom_phy_init_vreg(struct phy *, struct ufs_qcom_phy_vreg *,
+static int ufs_qcom_phy_init_vreg(struct device *, struct ufs_qcom_phy_vreg *,
  const char *);
 static int ufs_qcom_phy_base_init(struct platform_device *pdev,
  struct ufs_qcom_phy *phy_common);
@@ -154,13 +154,11 @@ int ufs_qcom_phy_base_init(struct platform_device *pdev,
return 0;
 }
 
-static int __ufs_qcom_phy_clk_get(struct phy *phy,
+static int __ufs_qcom_phy_clk_get(struct device *dev,
 const char *name, struct clk **clk_out, bool err_print)
 {
struct clk *clk;
int err = 0;
-   struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy);
-   struct device *dev = ufs_qcom_phy->dev;
 
clk = devm_clk_get(dev, name);
if (IS_ERR(clk)) {
@@ -175,40 +173,38 @@ static int __ufs_qcom_phy_clk_get(struct phy *phy,
 }
 
 static
-int ufs_qcom_phy_clk_get(struct phy *phy,
+int ufs_qcom_phy_clk_get(struct device *dev,
 const char *name, struct clk **clk_out)
 {
-   return __ufs_qcom_phy_clk_get(phy, name, clk_out, true);
+   return