diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:36 -0400 |
commit | 26c5f7d93adbe440bc7db95c1e4f1b1820e403a1 (patch) | |
tree | cece445ff54d8f58ef2cc789b8549cad6583a60b | |
parent | 87e7d520edba936fe6d1102e9fcc7530a478c07c (diff) |
rtc: rtc-bq4802: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/rtc/rtc-bq4802.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c index 693be71b5b18..af2886784a7b 100644 --- a/drivers/rtc/rtc-bq4802.c +++ b/drivers/rtc/rtc-bq4802.c | |||
@@ -142,7 +142,7 @@ static const struct rtc_class_ops bq4802_ops = { | |||
142 | 142 | ||
143 | static int bq4802_probe(struct platform_device *pdev) | 143 | static int bq4802_probe(struct platform_device *pdev) |
144 | { | 144 | { |
145 | struct bq4802 *p = kzalloc(sizeof(*p), GFP_KERNEL); | 145 | struct bq4802 *p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); |
146 | int err = -ENOMEM; | 146 | int err = -ENOMEM; |
147 | 147 | ||
148 | if (!p) | 148 | if (!p) |
@@ -155,54 +155,41 @@ static int bq4802_probe(struct platform_device *pdev) | |||
155 | p->r = platform_get_resource(pdev, IORESOURCE_IO, 0); | 155 | p->r = platform_get_resource(pdev, IORESOURCE_IO, 0); |
156 | err = -EINVAL; | 156 | err = -EINVAL; |
157 | if (!p->r) | 157 | if (!p->r) |
158 | goto out_free; | 158 | goto out; |
159 | } | 159 | } |
160 | if (p->r->flags & IORESOURCE_IO) { | 160 | if (p->r->flags & IORESOURCE_IO) { |
161 | p->ioport = p->r->start; | 161 | p->ioport = p->r->start; |
162 | p->read = bq4802_read_io; | 162 | p->read = bq4802_read_io; |
163 | p->write = bq4802_write_io; | 163 | p->write = bq4802_write_io; |
164 | } else if (p->r->flags & IORESOURCE_MEM) { | 164 | } else if (p->r->flags & IORESOURCE_MEM) { |
165 | p->regs = ioremap(p->r->start, resource_size(p->r)); | 165 | p->regs = devm_ioremap(&pdev->dev, p->r->start, |
166 | resource_size(p->r)); | ||
166 | p->read = bq4802_read_mem; | 167 | p->read = bq4802_read_mem; |
167 | p->write = bq4802_write_mem; | 168 | p->write = bq4802_write_mem; |
168 | } else { | 169 | } else { |
169 | err = -EINVAL; | 170 | err = -EINVAL; |
170 | goto out_free; | 171 | goto out; |
171 | } | 172 | } |
172 | 173 | ||
173 | platform_set_drvdata(pdev, p); | 174 | platform_set_drvdata(pdev, p); |
174 | 175 | ||
175 | p->rtc = rtc_device_register("bq4802", &pdev->dev, | 176 | p->rtc = devm_rtc_device_register(&pdev->dev, "bq4802", |
176 | &bq4802_ops, THIS_MODULE); | 177 | &bq4802_ops, THIS_MODULE); |
177 | if (IS_ERR(p->rtc)) { | 178 | if (IS_ERR(p->rtc)) { |
178 | err = PTR_ERR(p->rtc); | 179 | err = PTR_ERR(p->rtc); |
179 | goto out_iounmap; | 180 | goto out; |
180 | } | 181 | } |
181 | 182 | ||
182 | err = 0; | 183 | err = 0; |
183 | out: | 184 | out: |
184 | return err; | 185 | return err; |
185 | 186 | ||
186 | out_iounmap: | ||
187 | if (p->r->flags & IORESOURCE_MEM) | ||
188 | iounmap(p->regs); | ||
189 | out_free: | ||
190 | kfree(p); | ||
191 | goto out; | ||
192 | } | 187 | } |
193 | 188 | ||
194 | static int bq4802_remove(struct platform_device *pdev) | 189 | static int bq4802_remove(struct platform_device *pdev) |
195 | { | 190 | { |
196 | struct bq4802 *p = platform_get_drvdata(pdev); | ||
197 | |||
198 | rtc_device_unregister(p->rtc); | ||
199 | if (p->r->flags & IORESOURCE_MEM) | ||
200 | iounmap(p->regs); | ||
201 | |||
202 | platform_set_drvdata(pdev, NULL); | 191 | platform_set_drvdata(pdev, NULL); |
203 | 192 | ||
204 | kfree(p); | ||
205 | |||
206 | return 0; | 193 | return 0; |
207 | } | 194 | } |
208 | 195 | ||