diff options
Diffstat (limited to 'drivers/pwm/pwm-pxa.c')
-rw-r--r-- | drivers/pwm/pwm-pxa.c | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index d5c6ce513e29..a2be966d550d 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/arch/arm/mach-pxa/pwm.c | 2 | * drivers/pwm/pwm-pxa.c |
3 | * | 3 | * |
4 | * simple driver for PWM (Pulse Width Modulator) controller | 4 | * simple driver for PWM (Pulse Width Modulator) controller |
5 | * | 5 | * |
@@ -145,17 +145,16 @@ static int __devinit pwm_probe(struct platform_device *pdev) | |||
145 | struct resource *r; | 145 | struct resource *r; |
146 | int ret = 0; | 146 | int ret = 0; |
147 | 147 | ||
148 | pwm = kzalloc(sizeof(*pwm), GFP_KERNEL); | 148 | pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); |
149 | if (pwm == NULL) { | 149 | if (pwm == NULL) { |
150 | dev_err(&pdev->dev, "failed to allocate memory\n"); | 150 | dev_err(&pdev->dev, "failed to allocate memory\n"); |
151 | return -ENOMEM; | 151 | return -ENOMEM; |
152 | } | 152 | } |
153 | 153 | ||
154 | pwm->clk = clk_get(&pdev->dev, NULL); | 154 | pwm->clk = devm_clk_get(&pdev->dev, NULL); |
155 | if (IS_ERR(pwm->clk)) { | 155 | if (IS_ERR(pwm->clk)) |
156 | ret = PTR_ERR(pwm->clk); | 156 | return PTR_ERR(pwm->clk); |
157 | goto err_free; | 157 | |
158 | } | ||
159 | pwm->clk_enabled = 0; | 158 | pwm->clk_enabled = 0; |
160 | 159 | ||
161 | pwm->chip.dev = &pdev->dev; | 160 | pwm->chip.dev = &pdev->dev; |
@@ -166,23 +165,12 @@ static int __devinit pwm_probe(struct platform_device *pdev) | |||
166 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 165 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
167 | if (r == NULL) { | 166 | if (r == NULL) { |
168 | dev_err(&pdev->dev, "no memory resource defined\n"); | 167 | dev_err(&pdev->dev, "no memory resource defined\n"); |
169 | ret = -ENODEV; | 168 | return -ENODEV; |
170 | goto err_free_clk; | ||
171 | } | ||
172 | |||
173 | r = request_mem_region(r->start, resource_size(r), pdev->name); | ||
174 | if (r == NULL) { | ||
175 | dev_err(&pdev->dev, "failed to request memory resource\n"); | ||
176 | ret = -EBUSY; | ||
177 | goto err_free_clk; | ||
178 | } | 169 | } |
179 | 170 | ||
180 | pwm->mmio_base = ioremap(r->start, resource_size(r)); | 171 | pwm->mmio_base = devm_request_and_ioremap(&pdev->dev, r); |
181 | if (pwm->mmio_base == NULL) { | 172 | if (pwm->mmio_base == NULL) |
182 | dev_err(&pdev->dev, "failed to ioremap() registers\n"); | 173 | return -EADDRNOTAVAIL; |
183 | ret = -ENODEV; | ||
184 | goto err_free_mem; | ||
185 | } | ||
186 | 174 | ||
187 | ret = pwmchip_add(&pwm->chip); | 175 | ret = pwmchip_add(&pwm->chip); |
188 | if (ret < 0) { | 176 | if (ret < 0) { |
@@ -192,34 +180,17 @@ static int __devinit pwm_probe(struct platform_device *pdev) | |||
192 | 180 | ||
193 | platform_set_drvdata(pdev, pwm); | 181 | platform_set_drvdata(pdev, pwm); |
194 | return 0; | 182 | return 0; |
195 | |||
196 | err_free_mem: | ||
197 | release_mem_region(r->start, resource_size(r)); | ||
198 | err_free_clk: | ||
199 | clk_put(pwm->clk); | ||
200 | err_free: | ||
201 | kfree(pwm); | ||
202 | return ret; | ||
203 | } | 183 | } |
204 | 184 | ||
205 | static int __devexit pwm_remove(struct platform_device *pdev) | 185 | static int __devexit pwm_remove(struct platform_device *pdev) |
206 | { | 186 | { |
207 | struct pxa_pwm_chip *chip; | 187 | struct pxa_pwm_chip *chip; |
208 | struct resource *r; | ||
209 | 188 | ||
210 | chip = platform_get_drvdata(pdev); | 189 | chip = platform_get_drvdata(pdev); |
211 | if (chip == NULL) | 190 | if (chip == NULL) |
212 | return -ENODEV; | 191 | return -ENODEV; |
213 | 192 | ||
214 | pwmchip_remove(&chip->chip); | 193 | pwmchip_remove(&chip->chip); |
215 | |||
216 | iounmap(chip->mmio_base); | ||
217 | |||
218 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
219 | release_mem_region(r->start, resource_size(r)); | ||
220 | |||
221 | clk_put(chip->clk); | ||
222 | kfree(chip); | ||
223 | return 0; | 194 | return 0; |
224 | } | 195 | } |
225 | 196 | ||