Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Brownell and committed by
Linus Torvalds
cb3a58d2 61a7c36a

+11 -1
+2
drivers/rtc/class.c
··· 156 156 strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE); 157 157 snprintf(rtc->dev.bus_id, BUS_ID_SIZE, "rtc%d", id); 158 158 159 + rtc_dev_prepare(rtc); 160 + 159 161 err = device_register(&rtc->dev); 160 162 if (err) 161 163 goto exit_kfree;
+5
drivers/rtc/rtc-core.h
··· 2 2 3 3 extern void __init rtc_dev_init(void); 4 4 extern void __exit rtc_dev_exit(void); 5 + extern void rtc_dev_prepare(struct rtc_device *rtc); 5 6 extern void rtc_dev_add_device(struct rtc_device *rtc); 6 7 extern void rtc_dev_del_device(struct rtc_device *rtc); 7 8 ··· 13 12 } 14 13 15 14 static inline void rtc_dev_exit(void) 15 + { 16 + } 17 + 18 + static inline void rtc_dev_prepare(struct rtc_device *rtc) 16 19 { 17 20 } 18 21
+4 -1
drivers/rtc/rtc-dev.c
··· 396 396 397 397 /* insertion/removal hooks */ 398 398 399 - void rtc_dev_add_device(struct rtc_device *rtc) 399 + void rtc_dev_prepare(struct rtc_device *rtc) 400 400 { 401 401 if (!rtc_devt) 402 402 return; ··· 418 418 419 419 cdev_init(&rtc->char_dev, &rtc_dev_fops); 420 420 rtc->char_dev.owner = rtc->owner; 421 + } 421 422 423 + void rtc_dev_add_device(struct rtc_device *rtc) 424 + { 422 425 if (cdev_add(&rtc->char_dev, rtc->dev.devt, 1)) 423 426 printk(KERN_WARNING "%s: failed to add char device %d:%d\n", 424 427 rtc->name, MAJOR(rtc_devt), rtc->id);