diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-09-14 04:54:29 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-09-14 04:54:29 -0400 |
commit | 4523f6ada86853750565c68e17126af2e3df9b8a (patch) | |
tree | cf43d425a52ef79b73abbeff07524b77cee48364 /kernel/time | |
parent | 9fb60336253edf73dedc527b2aa2bf32eae0d6da (diff) |
alarmtimers: Fix error handling
commit 8bc0daf (alarmtimers: Rework RTC device selection using class
interface) did not implement required error checks. Add them.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/alarmtimer.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 154d5563ab1b..c436e790b21b 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c | |||
@@ -100,19 +100,25 @@ static struct class_interface alarmtimer_rtc_interface = { | |||
100 | .add_dev = &alarmtimer_rtc_add_device, | 100 | .add_dev = &alarmtimer_rtc_add_device, |
101 | }; | 101 | }; |
102 | 102 | ||
103 | static void alarmtimer_rtc_interface_setup(void) | 103 | static int alarmtimer_rtc_interface_setup(void) |
104 | { | 104 | { |
105 | alarmtimer_rtc_interface.class = rtc_class; | 105 | alarmtimer_rtc_interface.class = rtc_class; |
106 | class_interface_register(&alarmtimer_rtc_interface); | 106 | return class_interface_register(&alarmtimer_rtc_interface); |
107 | } | ||
108 | static void alarmtimer_rtc_interface_remove(void) | ||
109 | { | ||
110 | class_interface_unregister(&alarmtimer_rtc_interface); | ||
107 | } | 111 | } |
108 | #else | 112 | #else |
109 | #define alarmtimer_get_rtcdev() (0) | 113 | static inline struct rtc_device *alarmtimer_get_rtcdev(void) |
110 | #define rtcdev (0) | 114 | { |
111 | #define alarmtimer_rtc_interface_setup() | 115 | return NULL; |
116 | } | ||
117 | #define rtcdev (NULL) | ||
118 | static inline int alarmtimer_rtc_interface_setup(void) { return 0; } | ||
119 | static inline void alarmtimer_rtc_interface_remove(void) { } | ||
112 | #endif | 120 | #endif |
113 | 121 | ||
114 | |||
115 | |||
116 | /** | 122 | /** |
117 | * alarmtimer_enqueue - Adds an alarm timer to an alarm_base timerqueue | 123 | * alarmtimer_enqueue - Adds an alarm timer to an alarm_base timerqueue |
118 | * @base: pointer to the base where the timer is being run | 124 | * @base: pointer to the base where the timer is being run |
@@ -764,6 +770,7 @@ static struct platform_driver alarmtimer_driver = { | |||
764 | */ | 770 | */ |
765 | static int __init alarmtimer_init(void) | 771 | static int __init alarmtimer_init(void) |
766 | { | 772 | { |
773 | struct platform_device *pdev; | ||
767 | int error = 0; | 774 | int error = 0; |
768 | int i; | 775 | int i; |
769 | struct k_clock alarm_clock = { | 776 | struct k_clock alarm_clock = { |
@@ -793,11 +800,25 @@ static int __init alarmtimer_init(void) | |||
793 | alarm_bases[i].timer.function = alarmtimer_fired; | 800 | alarm_bases[i].timer.function = alarmtimer_fired; |
794 | } | 801 | } |
795 | 802 | ||
796 | alarmtimer_rtc_interface_setup(); | 803 | error = alarmtimer_rtc_interface_setup(); |
804 | if (error) | ||
805 | return error; | ||
806 | |||
797 | error = platform_driver_register(&alarmtimer_driver); | 807 | error = platform_driver_register(&alarmtimer_driver); |
798 | platform_device_register_simple("alarmtimer", -1, NULL, 0); | 808 | if (error) |
809 | goto out_if; | ||
799 | 810 | ||
811 | pdev = platform_device_register_simple("alarmtimer", -1, NULL, 0); | ||
812 | if (IS_ERR(pdev)) { | ||
813 | error = PTR_ERR(pdev); | ||
814 | goto out_drv; | ||
815 | } | ||
816 | return 0; | ||
817 | |||
818 | out_drv: | ||
819 | platform_driver_unregister(&alarmtimer_driver); | ||
820 | out_if: | ||
821 | alarmtimer_rtc_interface_remove(); | ||
800 | return error; | 822 | return error; |
801 | } | 823 | } |
802 | device_initcall(alarmtimer_init); | 824 | device_initcall(alarmtimer_init); |
803 | |||