aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-29 19:20:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:38 -0400
commit6b5f486225f6a4ec052209a466d580a1d1d92ce5 (patch)
treef764034f2d02edce124cd607ca7403e3e95e2abc /drivers/rtc
parenta63794fefd850a97fe07cfc017f52ea1bb777e75 (diff)
rtc: rtc-pcap: 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>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-pcap.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index ce0982490e8c..539a90b98bc5 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -145,7 +145,8 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
145 int timer_irq, alarm_irq; 145 int timer_irq, alarm_irq;
146 int err = -ENOMEM; 146 int err = -ENOMEM;
147 147
148 pcap_rtc = kmalloc(sizeof(struct pcap_rtc), GFP_KERNEL); 148 pcap_rtc = devm_kzalloc(&pdev->dev, sizeof(struct pcap_rtc),
149 GFP_KERNEL);
149 if (!pcap_rtc) 150 if (!pcap_rtc)
150 return err; 151 return err;
151 152
@@ -153,45 +154,34 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
153 154
154 platform_set_drvdata(pdev, pcap_rtc); 155 platform_set_drvdata(pdev, pcap_rtc);
155 156
156 pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev, 157 pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap",
157 &pcap_rtc_ops, THIS_MODULE); 158 &pcap_rtc_ops, THIS_MODULE);
158 if (IS_ERR(pcap_rtc->rtc)) { 159 if (IS_ERR(pcap_rtc->rtc)) {
159 err = PTR_ERR(pcap_rtc->rtc); 160 err = PTR_ERR(pcap_rtc->rtc);
160 goto fail_rtc; 161 goto fail;
161 } 162 }
162 163
163
164 timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); 164 timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ);
165 alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); 165 alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA);
166 166
167 err = request_irq(timer_irq, pcap_rtc_irq, 0, "RTC Timer", pcap_rtc); 167 err = devm_request_irq(&pdev->dev, timer_irq, pcap_rtc_irq, 0,
168 "RTC Timer", pcap_rtc);
168 if (err) 169 if (err)
169 goto fail_timer; 170 goto fail;
170 171
171 err = request_irq(alarm_irq, pcap_rtc_irq, 0, "RTC Alarm", pcap_rtc); 172 err = devm_request_irq(&pdev->dev, alarm_irq, pcap_rtc_irq, 0,
173 "RTC Alarm", pcap_rtc);
172 if (err) 174 if (err)
173 goto fail_alarm; 175 goto fail;
174 176
175 return 0; 177 return 0;
176fail_alarm: 178fail:
177 free_irq(timer_irq, pcap_rtc);
178fail_timer:
179 rtc_device_unregister(pcap_rtc->rtc);
180fail_rtc:
181 platform_set_drvdata(pdev, NULL); 179 platform_set_drvdata(pdev, NULL);
182 kfree(pcap_rtc);
183 return err; 180 return err;
184} 181}
185 182
186static int __exit pcap_rtc_remove(struct platform_device *pdev) 183static int __exit pcap_rtc_remove(struct platform_device *pdev)
187{ 184{
188 struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
189
190 free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ), pcap_rtc);
191 free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA), pcap_rtc);
192 rtc_device_unregister(pcap_rtc->rtc);
193 kfree(pcap_rtc);
194
195 return 0; 185 return 0;
196} 186}
197 187