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

[PATCH] RTC driver init adjustment

- conditionalizes procfs code upon CONFIG_PROC_FS (to reduce code size when
that option is not enabled)

- make initialization no longer fail when the procfs entry can't be
allocated (namely would initialization always have failed when
CONFIG_PROC_FS was not set)

- move the formerly file-scope static variable rtc_int_handler_ptr into
the only function using it, and makes it automatic.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jan Beulich and committed by
Linus Torvalds
9cef779e f3e92d35

+17 -15
+17 -15
drivers/char/rtc.c
··· 113 113 #define hpet_set_rtc_irq_bit(arg) 0 114 114 #define hpet_rtc_timer_init() do { } while (0) 115 115 #define hpet_rtc_dropped_irq() 0 116 - static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;} 116 + static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;} 117 117 #else 118 118 extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); 119 119 #endif ··· 165 165 } 166 166 #endif 167 167 168 + #ifdef CONFIG_PROC_FS 168 169 static int rtc_proc_open(struct inode *inode, struct file *file); 170 + #endif 169 171 170 172 /* 171 173 * Bits in rtc_status. (6 bits of room for future expansion) ··· 908 906 .fops = &rtc_fops, 909 907 }; 910 908 909 + #ifdef CONFIG_PROC_FS 911 910 static const struct file_operations rtc_proc_fops = { 912 911 .owner = THIS_MODULE, 913 912 .open = rtc_proc_open, ··· 916 913 .llseek = seq_lseek, 917 914 .release = single_release, 918 915 }; 919 - 920 - #if defined(RTC_IRQ) && !defined(__sparc__) 921 - static irq_handler_t rtc_int_handler_ptr; 922 916 #endif 923 917 924 918 static int __init rtc_init(void) 925 919 { 920 + #ifdef CONFIG_PROC_FS 926 921 struct proc_dir_entry *ent; 922 + #endif 927 923 #if defined(__alpha__) || defined(__mips__) 928 924 unsigned int year, ctrl; 929 925 char *guess = NULL; ··· 934 932 struct sparc_isa_bridge *isa_br; 935 933 struct sparc_isa_device *isa_dev; 936 934 #endif 937 - #endif 938 - #ifndef __sparc__ 935 + #else 939 936 void *r; 937 + #ifdef RTC_IRQ 938 + irq_handler_t rtc_int_handler_ptr; 939 + #endif 940 940 #endif 941 941 942 942 #ifdef __sparc__ ··· 1028 1024 return -ENODEV; 1029 1025 } 1030 1026 1027 + #ifdef CONFIG_PROC_FS 1031 1028 ent = create_proc_entry("driver/rtc", 0, NULL); 1032 - if (!ent) { 1033 - #ifdef RTC_IRQ 1034 - free_irq(RTC_IRQ, NULL); 1035 - rtc_has_irq = 0; 1029 + if (ent) 1030 + ent->proc_fops = &rtc_proc_fops; 1031 + else 1032 + printk(KERN_WARNING "rtc: Failed to register with procfs.\n"); 1036 1033 #endif 1037 - release_region(RTC_PORT(0), RTC_IO_EXTENT); 1038 - misc_deregister(&rtc_dev); 1039 - return -ENOMEM; 1040 - } 1041 - ent->proc_fops = &rtc_proc_fops; 1042 1034 1043 1035 #if defined(__alpha__) || defined(__mips__) 1044 1036 rtc_freq = HZ; ··· 1167 1167 } 1168 1168 #endif 1169 1169 1170 + #ifdef CONFIG_PROC_FS 1170 1171 /* 1171 1172 * Info exported via "/proc/driver/rtc". 1172 1173 */ ··· 1252 1251 { 1253 1252 return single_open(file, rtc_proc_show, NULL); 1254 1253 } 1254 + #endif 1255 1255 1256 1256 void rtc_get_rtc_time(struct rtc_time *rtc_tm) 1257 1257 {