Skip to content

Commit cb3a58d

Browse files
David BrownellLinus Torvalds
authored andcommitted
rtc: update to class device removal patches
Fix a goof in the revised classdev support for RTCs: make sure the /dev node info is ready before the device is registered, not after. Otherwise the /sys/class/rtc/rtcN/dev attribute won't be created and then udev won't have the information it needs to create the /dev/rtcN node. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 61a7c36 commit cb3a58d

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎drivers/rtc/class.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
156156
strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
157157
snprintf(rtc->dev.bus_id, BUS_ID_SIZE, "rtc%d", id);
158158

159+
rtc_dev_prepare(rtc);
160+
159161
err = device_register(&rtc->dev);
160162
if (err)
161163
goto exit_kfree;

‎drivers/rtc/rtc-core.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
extern void __init rtc_dev_init(void);
44
extern void __exit rtc_dev_exit(void);
5+
extern void rtc_dev_prepare(struct rtc_device *rtc);
56
extern void rtc_dev_add_device(struct rtc_device *rtc);
67
extern void rtc_dev_del_device(struct rtc_device *rtc);
78

@@ -15,6 +16,10 @@ static inline void rtc_dev_exit(void)
1516
{
1617
}
1718

19+
static inline void rtc_dev_prepare(struct rtc_device *rtc)
20+
{
21+
}
22+
1823
static inline void rtc_dev_add_device(struct rtc_device *rtc)
1924
{
2025
}

‎drivers/rtc/rtc-dev.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static const struct file_operations rtc_dev_fops = {
396396

397397
/* insertion/removal hooks */
398398

399-
void rtc_dev_add_device(struct rtc_device *rtc)
399+
void rtc_dev_prepare(struct rtc_device *rtc)
400400
{
401401
if (!rtc_devt)
402402
return;
@@ -418,7 +418,10 @@ void rtc_dev_add_device(struct rtc_device *rtc)
418418

419419
cdev_init(&rtc->char_dev, &rtc_dev_fops);
420420
rtc->char_dev.owner = rtc->owner;
421+
}
421422

423+
void rtc_dev_add_device(struct rtc_device *rtc)
424+
{
422425
if (cdev_add(&rtc->char_dev, rtc->dev.devt, 1))
423426
printk(KERN_WARNING "%s: failed to add char device %d:%d\n",
424427
rtc->name, MAJOR(rtc_devt), rtc->id);

0 commit comments

Comments
 (0)