]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/char/rtc.c
[PATCH] lockdep: better lock debugging
[karo-tx-linux.git] / drivers / char / rtc.c
index a7f099fb7dfed7b86d3d386baa85018215d07b35..cc7bd1a3095b799fba093bee386bcdfe805529fb 100644 (file)
  *      1.11a   Daniele Bellucci: Audit create_proc_read_entry in rtc_init
  *     1.12    Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer
  *             CONFIG_HPET_EMULATE_RTC
- *
+ *     1.12ac  Alan Cox: Allow read access to the day of week register
  */
 
-#define RTC_VERSION            "1.12"
+#define RTC_VERSION            "1.12ac"
 
 #define RTC_IO_EXTENT  0x8
 
@@ -61,7 +61,6 @@
  *     this driver.)
  */
 
-#include <linux/config.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -221,7 +220,7 @@ static inline unsigned char rtc_is_updating(void)
 
 #ifdef RTC_IRQ
 /*
- *     A very tiny interrupt handler. It runs with SA_INTERRUPT set,
+ *     A very tiny interrupt handler. It runs with IRQF_DISABLED set,
  *     but there is possibility of conflicting with the set_rtc_mmss()
  *     call (the rtc irq and the timer irq can easily run at the same
  *     time in two different CPUs). So we need to serialize
@@ -878,7 +877,7 @@ int rtc_control(rtc_task_t *task, unsigned int cmd, unsigned long arg)
  *     The various file operations we support.
  */
 
-static struct file_operations rtc_fops = {
+static const struct file_operations rtc_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = rtc_read,
@@ -897,7 +896,7 @@ static struct miscdevice rtc_dev = {
        .fops           = &rtc_fops,
 };
 
-static struct file_operations rtc_proc_fops = {
+static const struct file_operations rtc_proc_fops = {
        .owner = THIS_MODULE,
        .open = rtc_proc_open,
        .read  = seq_read,
@@ -928,7 +927,7 @@ static int __init rtc_init(void)
 #ifdef __sparc__
        for_each_ebus(ebus) {
                for_each_ebusdev(edev, ebus) {
-                       if(strcmp(edev->prom_name, "rtc") == 0) {
+                       if(strcmp(edev->prom_node->name, "rtc") == 0) {
                                rtc_port = edev->resource[0].start;
                                rtc_irq = edev->irqs[0];
                                goto found;
@@ -938,7 +937,7 @@ static int __init rtc_init(void)
 #ifdef __sparc_v9__
        for_each_isa(isa_br) {
                for_each_isadev(isa_dev, isa_br) {
-                       if (strcmp(isa_dev->prom_name, "rtc") == 0) {
+                       if (strcmp(isa_dev->prom_node->name, "rtc") == 0) {
                                rtc_port = isa_dev->resource.start;
                                rtc_irq = isa_dev->irq;
                                goto found;
@@ -959,11 +958,7 @@ found:
         * XXX Interrupt pin #7 in Espresso is shared between RTC and
         * PCI Slot 2 INTA# (and some INTx# in Slot 1).
         */
-       if (request_irq(rtc_irq, rtc_interrupt, SA_SHIRQ, "rtc", (void *)&rtc_port)) {
-               /*
-                * Standard way for sparc to print irq's is to use
-                * __irq_itoa(). I think for EBus it's ok to use %d.
-                */
+       if (request_irq(rtc_irq, rtc_interrupt, IRQF_SHARED, "rtc", (void *)&rtc_port)) {
                printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq);
                return -EIO;
        }
@@ -981,7 +976,7 @@ no_irq:
                rtc_int_handler_ptr = rtc_interrupt;
        }
 
-       if(request_irq(RTC_IRQ, rtc_int_handler_ptr, SA_INTERRUPT, "rtc", NULL)) {
+       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. */
                printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
                release_region(RTC_PORT(0), RTC_IO_EXTENT);
@@ -1250,9 +1245,9 @@ void rtc_get_rtc_time(struct rtc_time *rtc_tm)
 
        /*
         * Only the values that we read from the RTC are set. We leave
-        * tm_wday, tm_yday and tm_isdst untouched. Even though the
-        * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
-        * by the RTC when initially set to a non-zero value.
+        * tm_wday, tm_yday and tm_isdst untouched. Note that while the
+        * RTC has RTC_DAY_OF_WEEK, we should usually ignore it, as it is
+        * only updated by the RTC when initially set to a non-zero value.
         */
        spin_lock_irq(&rtc_lock);
        rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
@@ -1261,6 +1256,9 @@ void rtc_get_rtc_time(struct rtc_time *rtc_tm)
        rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
        rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);
        rtc_tm->tm_year = CMOS_READ(RTC_YEAR);
+       /* Only set from 2.6.16 onwards */
+       rtc_tm->tm_wday = CMOS_READ(RTC_DAY_OF_WEEK);
+
 #ifdef CONFIG_MACH_DECSTATION
        real_year = CMOS_READ(RTC_DEC_YEAR);
 #endif
@@ -1275,6 +1273,7 @@ void rtc_get_rtc_time(struct rtc_time *rtc_tm)
                BCD_TO_BIN(rtc_tm->tm_mday);
                BCD_TO_BIN(rtc_tm->tm_mon);
                BCD_TO_BIN(rtc_tm->tm_year);
+               BCD_TO_BIN(rtc_tm->tm_wday);
        }
 
 #ifdef CONFIG_MACH_DECSTATION