* [PATCH 1/2] RTC driver init adjustment
@ 2006-12-08 12:18 Jan Beulich
0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2006-12-08 12:18 UTC (permalink / raw)
To: a.zummo, p_gortmaker; +Cc: linux-kernel
This patch
- conditionalizes procfs code upon CONFIG_PROC_FS (to reduce code size when
that option is not enabled)
- makes 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)
- moves 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>
--- linux-2.6.19/drivers/char/rtc.c 2006-12-08 13:03:35.000000000 +0100
+++ 2.6.19-rtc-cleanup/drivers/char/rtc.c 2006-12-08 13:07:42.000000000 +0100
@@ -113,7 +113,7 @@ static int rtc_has_irq = 1;
#define hpet_set_rtc_irq_bit(arg) 0
#define hpet_rtc_timer_init() do { } while (0)
#define hpet_rtc_dropped_irq() 0
-static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;}
+static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;}
#else
extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
#endif
@@ -165,7 +165,9 @@ static void mask_rtc_irq_bit(unsigned ch
}
#endif
+#ifdef CONFIG_PROC_FS
static int rtc_proc_open(struct inode *inode, struct file *file);
+#endif
/*
* Bits in rtc_status. (6 bits of room for future expansion)
@@ -906,6 +908,7 @@ static struct miscdevice rtc_dev = {
.fops = &rtc_fops,
};
+#ifdef CONFIG_PROC_FS
static const struct file_operations rtc_proc_fops = {
.owner = THIS_MODULE,
.open = rtc_proc_open,
@@ -913,14 +916,13 @@ static const struct file_operations rtc_
.llseek = seq_lseek,
.release = single_release,
};
-
-#if defined(RTC_IRQ) && !defined(__sparc__)
-static irq_handler_t rtc_int_handler_ptr;
#endif
static int __init rtc_init(void)
{
+#ifdef CONFIG_PROC_FS
struct proc_dir_entry *ent;
+#endif
#if defined(__alpha__) || defined(__mips__)
unsigned int year, ctrl;
char *guess = NULL;
@@ -932,9 +934,11 @@ static int __init rtc_init(void)
struct sparc_isa_bridge *isa_br;
struct sparc_isa_device *isa_dev;
#endif
-#endif
-#ifndef __sparc__
+#else
void *r;
+#ifdef RTC_IRQ
+ irq_handler_t rtc_int_handler_ptr;
+#endif
#endif
#ifdef __sparc__
@@ -1024,17 +1028,13 @@ no_irq:
return -ENODEV;
}
+#ifdef CONFIG_PROC_FS
ent = create_proc_entry("driver/rtc", 0, NULL);
- if (!ent) {
-#ifdef RTC_IRQ
- free_irq(RTC_IRQ, NULL);
- rtc_has_irq = 0;
+ if (ent)
+ ent->proc_fops = &rtc_proc_fops;
+ else
+ printk(KERN_WARNING "rtc: Failed to register with procfs.\n");
#endif
- release_region(RTC_PORT(0), RTC_IO_EXTENT);
- misc_deregister(&rtc_dev);
- return -ENOMEM;
- }
- ent->proc_fops = &rtc_proc_fops;
#if defined(__alpha__) || defined(__mips__)
rtc_freq = HZ;
@@ -1167,6 +1167,7 @@ static void rtc_dropped_irq(unsigned lon
}
#endif
+#ifdef CONFIG_PROC_FS
/*
* Info exported via "/proc/driver/rtc".
*/
@@ -1251,6 +1252,7 @@ static int rtc_proc_open(struct inode *i
{
return single_open(file, rtc_proc_show, NULL);
}
+#endif
void rtc_get_rtc_time(struct rtc_time *rtc_tm)
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/2] RTC driver init adjustment
@ 2006-12-08 12:17 Jan Beulich
0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2006-12-08 12:17 UTC (permalink / raw)
To: a.zummo, p_gortmaker; +Cc: linux-kernel
Ensure RTC driver doesn't use its timer when it doesn't get to set it up (as
it cannot currently prevent other of its functions to be called from outside
when not built as a module - probably this should also be addressed).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
--- linux-2.6.19/drivers/char/rtc.c 2006-11-29 22:57:37.000000000 +0100
+++ 2.6.19-rtc-no-irq/drivers/char/rtc.c 2006-12-08 13:03:35.000000000 +0100
@@ -958,6 +958,7 @@ static int __init rtc_init(void)
}
}
#endif
+ rtc_has_irq = 0;
printk(KERN_ERR "rtc_init: no PC rtc found\n");
return -EIO;
@@ -972,6 +973,7 @@ found:
* PCI Slot 2 INTA# (and some INTx# in Slot 1).
*/
if (request_irq(rtc_irq, rtc_interrupt, IRQF_SHARED, "rtc", (void *)&rtc_port)) {
+ rtc_has_irq = 0;
printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq);
return -EIO;
}
@@ -982,6 +984,9 @@ no_irq:
else
r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc");
if (!r) {
+#ifdef RTC_IRQ
+ rtc_has_irq = 0;
+#endif
printk(KERN_ERR "rtc: I/O resource %lx is not free.\n",
(long)(RTC_PORT(0)));
return -EIO;
@@ -996,6 +1001,7 @@ no_irq:
if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) {
/* Yeah right, seeing as irq 8 doesn't even hit the bus. */
+ rtc_has_irq = 0;
printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
if (RTC_IOMAPPED)
release_region(RTC_PORT(0), RTC_IO_EXTENT);
@@ -1012,6 +1018,7 @@ no_irq:
if (misc_register(&rtc_dev)) {
#ifdef RTC_IRQ
free_irq(RTC_IRQ, NULL);
+ rtc_has_irq = 0;
#endif
release_region(RTC_PORT(0), RTC_IO_EXTENT);
return -ENODEV;
@@ -1021,6 +1028,7 @@ no_irq:
if (!ent) {
#ifdef RTC_IRQ
free_irq(RTC_IRQ, NULL);
+ rtc_has_irq = 0;
#endif
release_region(RTC_PORT(0), RTC_IO_EXTENT);
misc_deregister(&rtc_dev);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-12-08 12:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-08 12:18 [PATCH 1/2] RTC driver init adjustment Jan Beulich
-- strict thread matches above, loose matches on Subject: below --
2006-12-08 12:17 Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®