aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/class.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 22:47:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 22:47:50 -0400
commit56847d857cb0c3ee78c22ce776a26f88d9ffd4d4 (patch)
treea85bcf204a53e45d26f6a3984f16ddd525eef3e7 /drivers/rtc/class.c
parent191a712090bb8a10e6f129360eeed2d68f3d4c9a (diff)
parent8d564368a9a3197f43e56dadf4a18c5738849f94 (diff)
Merge branch 'akpm' (incoming from Andrew)
Merge second batch of fixes from Andrew Morton: - various misc bits - some printk updates - a new "SRAM" driver. - MAINTAINERS updates - the backlight driver queue - checkpatch updates - a few init/ changes - a huge number of drivers/rtc changes - fatfs updates - some lib/idr.c work - some renaming of the random driver interfaces * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (285 commits) net: rename random32 to prandom net/core: remove duplicate statements by do-while loop net/core: rename random32() to prandom_u32() net/netfilter: rename random32() to prandom_u32() net/sched: rename random32() to prandom_u32() net/sunrpc: rename random32() to prandom_u32() scsi: rename random32() to prandom_u32() lguest: rename random32() to prandom_u32() uwb: rename random32() to prandom_u32() video/uvesafb: rename random32() to prandom_u32() mmc: rename random32() to prandom_u32() drbd: rename random32() to prandom_u32() kernel/: rename random32() to prandom_u32() mm/: rename random32() to prandom_u32() lib/: rename random32() to prandom_u32() x86: rename random32() to prandom_u32() x86: pageattr-test: remove srandom32 call uuid: use prandom_bytes() raid6test: use prandom_bytes() sctp: convert sctp_assoc_set_id() to use idr_alloc_cyclic() ...
Diffstat (limited to 'drivers/rtc/class.c')
-rw-r--r--drivers/rtc/class.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 9b742d3ffb94..66385402d20e 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -259,6 +259,76 @@ void rtc_device_unregister(struct rtc_device *rtc)
259} 259}
260EXPORT_SYMBOL_GPL(rtc_device_unregister); 260EXPORT_SYMBOL_GPL(rtc_device_unregister);
261 261
262static void devm_rtc_device_release(struct device *dev, void *res)
263{
264 struct rtc_device *rtc = *(struct rtc_device **)res;
265
266 rtc_device_unregister(rtc);
267}
268
269static int devm_rtc_device_match(struct device *dev, void *res, void *data)
270{
271 struct rtc **r = res;
272
273 return *r == data;
274}
275
276/**
277 * devm_rtc_device_register - resource managed rtc_device_register()
278 * @dev: the device to register
279 * @name: the name of the device
280 * @ops: the rtc operations structure
281 * @owner: the module owner
282 *
283 * @return a struct rtc on success, or an ERR_PTR on error
284 *
285 * Managed rtc_device_register(). The rtc_device returned from this function
286 * are automatically freed on driver detach. See rtc_device_register()
287 * for more information.
288 */
289
290struct rtc_device *devm_rtc_device_register(struct device *dev,
291 const char *name,
292 const struct rtc_class_ops *ops,
293 struct module *owner)
294{
295 struct rtc_device **ptr, *rtc;
296
297 ptr = devres_alloc(devm_rtc_device_release, sizeof(*ptr), GFP_KERNEL);
298 if (!ptr)
299 return ERR_PTR(-ENOMEM);
300
301 rtc = rtc_device_register(name, dev, ops, owner);
302 if (!IS_ERR(rtc)) {
303 *ptr = rtc;
304 devres_add(dev, ptr);
305 } else {
306 devres_free(ptr);
307 }
308
309 return rtc;
310}
311EXPORT_SYMBOL_GPL(devm_rtc_device_register);
312
313/**
314 * devm_rtc_device_unregister - resource managed devm_rtc_device_unregister()
315 * @dev: the device to unregister
316 * @rtc: the RTC class device to unregister
317 *
318 * Deallocated a rtc allocated with devm_rtc_device_register(). Normally this
319 * function will not need to be called and the resource management code will
320 * ensure that the resource is freed.
321 */
322void devm_rtc_device_unregister(struct device *dev, struct rtc_device *rtc)
323{
324 int rc;
325
326 rc = devres_release(dev, devm_rtc_device_release,
327 devm_rtc_device_match, rtc);
328 WARN_ON(rc);
329}
330EXPORT_SYMBOL_GPL(devm_rtc_device_unregister);
331
262static int __init rtc_init(void) 332static int __init rtc_init(void)
263{ 333{
264 rtc_class = class_create(THIS_MODULE, "rtc"); 334 rtc_class = class_create(THIS_MODULE, "rtc");