summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/usb_phy.c
diff options
context:
space:
mode:
authorVenu Byravarasu <vbyravarasu@nvidia.com>2012-07-13 11:38:04 +0530
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-07-19 00:50:12 -0700
commit871f9eb32a6717f595340d95a56c6530f7b1798a (patch)
tree7d68ced375f9b49878ffd2149c337082b3d84223 /arch/arm/mach-tegra/usb_phy.c
parent9d4eeb8ee6eba84d932ab05b7eb6a5b4ddedb288 (diff)
arm: tegra: usb: phy code clean up
Code clean up of usb phy driver Change-Id: If951ed461b096be76938504d9e1073a70f59860a Signed-off-by: Venu Byravarasu <vbyravarasu@nvidia.com> Reviewed-on: http://git-master/r/115339 (cherry picked from commit 6d4046a6f2170dadaf5647f0bf47aa546dd705b0) Reviewed-on: http://git-master/r/104055 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/usb_phy.c')
-rw-r--r--arch/arm/mach-tegra/usb_phy.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/arch/arm/mach-tegra/usb_phy.c b/arch/arm/mach-tegra/usb_phy.c
index a83f04a7656c..62884df14269 100644
--- a/arch/arm/mach-tegra/usb_phy.c
+++ b/arch/arm/mach-tegra/usb_phy.c
@@ -173,8 +173,7 @@ static int tegra_usb_phy_get_clocks(struct tegra_usb_phy *phy)
phy->pllu_clk = clk_get_sys(NULL, "pll_u");
if (IS_ERR(phy->pllu_clk)) {
ERR("inst:[%d] Can't get pllu_clk clock\n", phy->inst);
- err = PTR_ERR(phy->pllu_clk);
- goto fail_pll;
+ return PTR_ERR(phy->pllu_clk);
}
clk_enable(phy->pllu_clk);
@@ -222,8 +221,6 @@ fail_ctrlr_clk:
clk_disable(phy->pllu_clk);
clk_put(phy->pllu_clk);
-fail_pll:
-
return err;
}
@@ -233,6 +230,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct platform_device *pdev)
struct tegra_usb_platform_data *pdata;
struct resource *res;
int err;
+ int plat_data_size = sizeof(struct tegra_usb_platform_data);
DBG("%s(%d) inst:[%d]\n", __func__, __LINE__, pdev->id);
pdata = dev_get_platdata(&pdev->dev);
@@ -242,20 +240,21 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct platform_device *pdev)
return ERR_PTR(-EINVAL);
}
- phy = kzalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL);
+ phy = devm_kzalloc(&pdev->dev, sizeof(struct tegra_usb_phy), GFP_KERNEL);
if (!phy) {
ERR("inst:[%d] malloc usb phy failed\n", pdev->id);
return ERR_PTR(-ENOMEM);
}
- phy->pdata = kzalloc(sizeof(struct tegra_usb_platform_data), GFP_KERNEL);
+ phy->pdata = devm_kzalloc(&pdev->dev, plat_data_size, GFP_KERNEL);
if (!phy->pdata) {
ERR("inst:[%d] malloc usb phy pdata failed\n", pdev->id);
kfree(phy);
return ERR_PTR(-ENOMEM);
}
- memcpy(phy->pdata, pdata, sizeof(struct tegra_usb_platform_data));
+ memcpy(phy->pdata, pdata, plat_data_size);
+
phy->pdev = pdev;
phy->inst = pdev->id;
@@ -264,15 +263,13 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ERR("inst:[%d] failed to get I/O memory\n", phy->inst);
- err = -ENXIO;
- goto fail_io;
+ return ERR_PTR(-ENXIO);
}
phy->regs = ioremap(res->start, resource_size(res));
if (!phy->regs) {
ERR("inst:[%d] Failed to remap I/O memory\n", phy->inst);
- err = -ENOMEM;
- goto fail_io;
+ return ERR_PTR(-ENOMEM);
}
phy->vdd_reg = regulator_get(NULL, "avdd_usb");
@@ -375,14 +372,9 @@ fail_init:
fail_clk:
regulator_put(phy->vdd_reg);
iounmap(phy->regs);
-fail_io:
- kfree(phy);
-
return ERR_PTR(err);
}
-
-
void tegra_usb_phy_close(struct tegra_usb_phy *phy)
{
DBG("%s(%d) inst:[%d]\n", __func__, __LINE__, phy->inst);
@@ -418,9 +410,6 @@ void tegra_usb_phy_close(struct tegra_usb_phy *phy)
tegra_usb_phy_release_clocks(phy);
-
- kfree(phy->pdata);
- kfree(phy);
}
irqreturn_t tegra_usb_phy_irq(struct tegra_usb_phy *phy)
@@ -432,6 +421,7 @@ irqreturn_t tegra_usb_phy_irq(struct tegra_usb_phy *phy)
return status;
}
+
int tegra_usb_phy_init(struct tegra_usb_phy *phy)
{
int status = 0;
@@ -551,6 +541,7 @@ int tegra_usb_phy_reset(struct tegra_usb_phy *phy)
return status;
}
+
int tegra_usb_phy_pre_suspend(struct tegra_usb_phy *phy)
{
int status = 0;
@@ -565,6 +556,7 @@ int tegra_usb_phy_pre_suspend(struct tegra_usb_phy *phy)
return status;
}
+
int tegra_usb_phy_suspend(struct tegra_usb_phy *phy)
{
int err = 0;
@@ -580,6 +572,7 @@ int tegra_usb_phy_suspend(struct tegra_usb_phy *phy)
return err;
}
+
int tegra_usb_phy_post_suspend(struct tegra_usb_phy *phy)
{
int status = 0;
@@ -594,6 +587,7 @@ int tegra_usb_phy_post_suspend(struct tegra_usb_phy *phy)
return status;
}
+
int tegra_usb_phy_pre_resume(struct tegra_usb_phy *phy, bool remote_wakeup)
{
int status = 0;
@@ -608,6 +602,7 @@ int tegra_usb_phy_pre_resume(struct tegra_usb_phy *phy, bool remote_wakeup)
return status;
}
+
int tegra_usb_phy_resume(struct tegra_usb_phy *phy)
{
int err = 0;
@@ -624,6 +619,7 @@ int tegra_usb_phy_resume(struct tegra_usb_phy *phy)
return err;
}
+
int tegra_usb_phy_post_resume(struct tegra_usb_phy *phy)
{
int status = 0;
@@ -638,6 +634,7 @@ int tegra_usb_phy_post_resume(struct tegra_usb_phy *phy)
return status;
}
+
int tegra_usb_phy_port_power(struct tegra_usb_phy *phy)
{
int status = 0;
@@ -649,6 +646,7 @@ int tegra_usb_phy_port_power(struct tegra_usb_phy *phy)
return status;
}
+
int tegra_usb_phy_bus_reset(struct tegra_usb_phy *phy)
{
int status = 0;