aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-mxs.c
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-06-26 04:58:10 -0400
committerThierry Reding <thierry.reding@avionic-design.de>2012-07-23 07:23:55 -0400
commit22d260bd88452ae81c80514810434d4cc98b7978 (patch)
tree140608da1bb4111bfa84a88e12961b49d38e99db /drivers/pwm/pwm-mxs.c
parent01bf32e94968fd13804062859cfd935efebc11e9 (diff)
pwm: pwm-mxs: use devm_* managed functions
Use devm_* managed functions to have a clean fail-out. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Diffstat (limited to 'drivers/pwm/pwm-mxs.c')
-rw-r--r--drivers/pwm/pwm-mxs.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
index 23e524bbee03..3b7f3ab116e3 100644
--- a/drivers/pwm/pwm-mxs.c
+++ b/drivers/pwm/pwm-mxs.c
@@ -129,21 +129,21 @@ static int mxs_pwm_probe(struct platform_device *pdev)
129{ 129{
130 struct device_node *np = pdev->dev.of_node; 130 struct device_node *np = pdev->dev.of_node;
131 struct mxs_pwm_chip *mxs; 131 struct mxs_pwm_chip *mxs;
132 struct resource *res;
132 int ret; 133 int ret;
133 134
134 mxs = devm_kzalloc(&pdev->dev, sizeof(*mxs), GFP_KERNEL); 135 mxs = devm_kzalloc(&pdev->dev, sizeof(*mxs), GFP_KERNEL);
135 if (!mxs) 136 if (!mxs)
136 return -ENOMEM; 137 return -ENOMEM;
137 138
138 mxs->base = of_iomap(np, 0); 139 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
140 mxs->base = devm_request_and_ioremap(&pdev->dev, res);
139 if (!mxs->base) 141 if (!mxs->base)
140 return -EADDRNOTAVAIL; 142 return -EADDRNOTAVAIL;
141 143
142 mxs->clk = clk_get(&pdev->dev, NULL); 144 mxs->clk = devm_clk_get(&pdev->dev, NULL);
143 if (IS_ERR(mxs->clk)) { 145 if (IS_ERR(mxs->clk))
144 ret = PTR_ERR(mxs->clk); 146 return PTR_ERR(mxs->clk);
145 goto iounmap;
146 }
147 147
148 mxs->chip.dev = &pdev->dev; 148 mxs->chip.dev = &pdev->dev;
149 mxs->chip.ops = &mxs_pwm_ops; 149 mxs->chip.ops = &mxs_pwm_ops;
@@ -151,13 +151,13 @@ static int mxs_pwm_probe(struct platform_device *pdev)
151 ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm); 151 ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm);
152 if (ret < 0) { 152 if (ret < 0) {
153 dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret); 153 dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret);
154 goto clk_put; 154 return ret;
155 } 155 }
156 156
157 ret = pwmchip_add(&mxs->chip); 157 ret = pwmchip_add(&mxs->chip);
158 if (ret < 0) { 158 if (ret < 0) {
159 dev_err(&pdev->dev, "failed to add pwm chip %d\n", ret); 159 dev_err(&pdev->dev, "failed to add pwm chip %d\n", ret);
160 goto clk_put; 160 return ret;
161 } 161 }
162 162
163 mxs->dev = &pdev->dev; 163 mxs->dev = &pdev->dev;
@@ -166,12 +166,6 @@ static int mxs_pwm_probe(struct platform_device *pdev)
166 stmp_reset_block(mxs->base); 166 stmp_reset_block(mxs->base);
167 167
168 return 0; 168 return 0;
169
170clk_put:
171 clk_put(mxs->clk);
172iounmap:
173 iounmap(mxs->base);
174 return ret;
175} 169}
176 170
177static int __devexit mxs_pwm_remove(struct platform_device *pdev) 171static int __devexit mxs_pwm_remove(struct platform_device *pdev)
@@ -179,8 +173,6 @@ static int __devexit mxs_pwm_remove(struct platform_device *pdev)
179 struct mxs_pwm_chip *mxs = platform_get_drvdata(pdev); 173 struct mxs_pwm_chip *mxs = platform_get_drvdata(pdev);
180 174
181 pwmchip_remove(&mxs->chip); 175 pwmchip_remove(&mxs->chip);
182 clk_put(mxs->clk);
183 iounmap(mxs->base);
184 176
185 return 0; 177 return 0;
186} 178}