aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-m48t35.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-04-29 19:20:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:36 -0400
commit4f58cd9b4663ac52c8b019e78b0f4eae37da297e (patch)
tree26458cf90c6d75989d2d6e4fa7a71422d219b3f8 /drivers/rtc/rtc-m48t35.c
parent66714612783525bf3fd389f886822d89d1be2cbf (diff)
drivers/rtc/rtc-m48t35.c: use devm_* APIs
devm_* functions are device managed and make cleanup code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-m48t35.c')
-rw-r--r--drivers/rtc/rtc-m48t35.c42
1 files changed, 10 insertions, 32 deletions
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c
index 31c9190a1fcb..37444246e5e4 100644
--- a/drivers/rtc/rtc-m48t35.c
+++ b/drivers/rtc/rtc-m48t35.c
@@ -145,12 +145,11 @@ static int m48t35_probe(struct platform_device *pdev)
145{ 145{
146 struct resource *res; 146 struct resource *res;
147 struct m48t35_priv *priv; 147 struct m48t35_priv *priv;
148 int ret = 0;
149 148
150 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 149 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
151 if (!res) 150 if (!res)
152 return -ENODEV; 151 return -ENODEV;
153 priv = kzalloc(sizeof(struct m48t35_priv), GFP_KERNEL); 152 priv = devm_kzalloc(&pdev->dev, sizeof(struct m48t35_priv), GFP_KERNEL);
154 if (!priv) 153 if (!priv)
155 return -ENOMEM; 154 return -ENOMEM;
156 155
@@ -160,50 +159,29 @@ static int m48t35_probe(struct platform_device *pdev)
160 * conflicts are resolved 159 * conflicts are resolved
161 */ 160 */
162#ifndef CONFIG_SGI_IP27 161#ifndef CONFIG_SGI_IP27
163 if (!request_mem_region(res->start, priv->size, pdev->name)) { 162 if (!devm_request_mem_region(&pdev->dev, res->start, priv->size,
164 ret = -EBUSY; 163 pdev->name))
165 goto out; 164 return -EBUSY;
166 }
167#endif 165#endif
168 priv->baseaddr = res->start; 166 priv->baseaddr = res->start;
169 priv->reg = ioremap(priv->baseaddr, priv->size); 167 priv->reg = devm_ioremap(&pdev->dev, priv->baseaddr, priv->size);
170 if (!priv->reg) { 168 if (!priv->reg)
171 ret = -ENOMEM; 169 return -ENOMEM;
172 goto out;
173 }
174 170
175 spin_lock_init(&priv->lock); 171 spin_lock_init(&priv->lock);
176 172
177 platform_set_drvdata(pdev, priv); 173 platform_set_drvdata(pdev, priv);
178 174
179 priv->rtc = rtc_device_register("m48t35", &pdev->dev, 175 priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35",
180 &m48t35_ops, THIS_MODULE); 176 &m48t35_ops, THIS_MODULE);
181 if (IS_ERR(priv->rtc)) { 177 if (IS_ERR(priv->rtc))
182 ret = PTR_ERR(priv->rtc); 178 return PTR_ERR(priv->rtc);
183 goto out;
184 }
185 179
186 return 0; 180 return 0;
187
188out:
189 if (priv->reg)
190 iounmap(priv->reg);
191 if (priv->baseaddr)
192 release_mem_region(priv->baseaddr, priv->size);
193 kfree(priv);
194 return ret;
195} 181}
196 182
197static int m48t35_remove(struct platform_device *pdev) 183static int m48t35_remove(struct platform_device *pdev)
198{ 184{
199 struct m48t35_priv *priv = platform_get_drvdata(pdev);
200
201 rtc_device_unregister(priv->rtc);
202 iounmap(priv->reg);
203#ifndef CONFIG_SGI_IP27
204 release_mem_region(priv->baseaddr, priv->size);
205#endif
206 kfree(priv);
207 return 0; 185 return 0;
208} 186}
209 187