diff options
Diffstat (limited to 'drivers/rtc/rtc-pcap.c')
-rw-r--r-- | drivers/rtc/rtc-pcap.c | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index e0019cd0bf71..539a90b98bc5 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c | |||
@@ -139,13 +139,14 @@ static const struct rtc_class_ops pcap_rtc_ops = { | |||
139 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, | 139 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, |
140 | }; | 140 | }; |
141 | 141 | ||
142 | static int pcap_rtc_probe(struct platform_device *pdev) | 142 | static int __init pcap_rtc_probe(struct platform_device *pdev) |
143 | { | 143 | { |
144 | struct pcap_rtc *pcap_rtc; | 144 | struct pcap_rtc *pcap_rtc; |
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,68 +154,46 @@ static int 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; |
176 | fail_alarm: | 178 | fail: |
177 | free_irq(timer_irq, pcap_rtc); | ||
178 | fail_timer: | ||
179 | rtc_device_unregister(pcap_rtc->rtc); | ||
180 | fail_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 | ||
186 | static int pcap_rtc_remove(struct platform_device *pdev) | 183 | static 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 | ||
198 | static struct platform_driver pcap_rtc_driver = { | 188 | static struct platform_driver pcap_rtc_driver = { |
199 | .remove = pcap_rtc_remove, | 189 | .remove = __exit_p(pcap_rtc_remove), |
200 | .driver = { | 190 | .driver = { |
201 | .name = "pcap-rtc", | 191 | .name = "pcap-rtc", |
202 | .owner = THIS_MODULE, | 192 | .owner = THIS_MODULE, |
203 | }, | 193 | }, |
204 | }; | 194 | }; |
205 | 195 | ||
206 | static int __init rtc_pcap_init(void) | 196 | module_platform_driver_probe(pcap_rtc_driver, pcap_rtc_probe); |
207 | { | ||
208 | return platform_driver_probe(&pcap_rtc_driver, pcap_rtc_probe); | ||
209 | } | ||
210 | |||
211 | static void __exit rtc_pcap_exit(void) | ||
212 | { | ||
213 | platform_driver_unregister(&pcap_rtc_driver); | ||
214 | } | ||
215 | |||
216 | module_init(rtc_pcap_init); | ||
217 | module_exit(rtc_pcap_exit); | ||
218 | 197 | ||
219 | MODULE_DESCRIPTION("Motorola pcap rtc driver"); | 198 | MODULE_DESCRIPTION("Motorola pcap rtc driver"); |
220 | MODULE_AUTHOR("guiming zhuo <gmzhuo@gmail.com>"); | 199 | MODULE_AUTHOR("guiming zhuo <gmzhuo@gmail.com>"); |