Re: [PATCH] small rtc.c fix

From: Cesar Eduardo Barros (cesarb@nitnet.com.br)
Date: Sat May 20 2000 - 08:51:52 EST


On Sat, May 20, 2000 at 10:39:21AM -0300, Cesar Eduardo Barros wrote:
> On Fri, May 19, 2000 at 04:34:37PM -0400, Jeff Garzik wrote:
> > Cesar Eduardo Barros wrote:
> > >
> > > This patch fixes a simple thinko in my last rtc patch which could in completely
> > > unlikely situations printk a wrong frequency value in rtc_dropped_irq (harmless
> > > but wrong anyway).
> > >
> > > I'm still a bit wary about putting printk inside a spinlock critical region.
> > > Comments?
> >
> > If you don't want the printk inside a spinlock, you can always grab the
> > spinlock, store to a temporary, release the spinlock, and then do the
> > printk.
>
> OK, done.
>
> > Also, make sure you increase the RTC when you do fixes as well as
> > feature updates...
>
> I think this change is too small to need to put my name on the header again.
>

Forgot to append my patch

This patch fixes a simple thinko in my last rtc patch which could in completely
unlikely situations printk a wrong frequency value in rtc_dropped_irq (harmless
but wrong anyway).

Now I believe it's 100% correct. This patch hasn't been compiled or tested but
I think it is "obviously correct" (famous last words...)

diff -Naur linux-2.3.99-pre9-2/drivers/char/rtc.c linux-2.3.99-pre9-2+rtcfix/drivers/char/rtc.c
--- linux-2.3.99-pre9-2/drivers/char/rtc.c Mon May 15 20:31:33 2000
+++ linux-2.3.99-pre9-2+rtcfix/drivers/char/rtc.c Sat May 20 10:33:42 2000
@@ -760,7 +760,7 @@
 
 static void rtc_dropped_irq(unsigned long data)
 {
- printk(KERN_INFO "rtc: lost some interrupts at %ldHz.\n", rtc_freq);
+ unsigned long freq;
 
         spin_lock_irq (&rtc_lock);
 
@@ -771,7 +771,12 @@
         rtc_irq_data += ((rtc_freq/HZ)<<8);
         rtc_irq_data &= ~0xff;
         rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0); /* restart */
+
+ freq = rtc_freq;
+
         spin_unlock_irq(&rtc_lock);
+
+ printk(KERN_INFO "rtc: lost some interrupts at %ldHz.\n", freq);
 
         /* Now we have new data */
         wake_up_interruptible(&rtc_wait);

-- 
Cesar Eduardo Barros
cesarb@nitnet.com.br
cesarb@dcc.ufrj.br

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:18 EST