aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-dev.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-07-20 19:02:51 -0400
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-09-05 07:19:07 -0400
commit1e4cd62558c293bc51cc179d676b708683a29c12 (patch)
treeecb6dc749be74b387877b177fa74cf03569197d4 /drivers/rtc/rtc-dev.c
parentc3b399a4b6703a04ef6eb3efe35ff12163e409e0 (diff)
rtc: dev: properly manage lifetime of dev and cdev in rtc device
struct rtc embeds both struct dev and struct cdev. Unfortunately character device structure may outlive the parent rtc structure unless we set it up as parent of character device so that it will stay pinned until character device is freed. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc/rtc-dev.c')
-rw-r--r--drivers/rtc/rtc-dev.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 799c34bcb26f..a6d9434addf6 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -477,6 +477,7 @@ void rtc_dev_prepare(struct rtc_device *rtc)
477 477
478 cdev_init(&rtc->char_dev, &rtc_dev_fops); 478 cdev_init(&rtc->char_dev, &rtc_dev_fops);
479 rtc->char_dev.owner = rtc->owner; 479 rtc->char_dev.owner = rtc->owner;
480 rtc->char_dev.kobj.parent = &rtc->dev.kobj;
480} 481}
481 482
482void rtc_dev_add_device(struct rtc_device *rtc) 483void rtc_dev_add_device(struct rtc_device *rtc)