From 93fa9a8d72f9f38b4f6e517e669b3770419f42b5 Mon Sep 17 00:00:00 2001 From: "Matthew N. Dodd" Date: Tue, 12 Apr 2005 20:49:31 +0000 Subject: [PATCH] Replace spl protection in rtcin() and writertc() with spinlocks using the existing clock_lock mutex. --- sys/i386/isa/clock.c | 12 ++++++------ sys/isa/atrtc.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 36644830e7db..eb8f2826d4d6 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -111,6 +111,8 @@ u_int timer_freq = TIMER_FREQ; int timer0_max_count; int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ struct mtx clock_lock; +#define RTC_LOCK mtx_lock_spin(&clock_lock) +#define RTC_UNLOCK mtx_unlock_spin(&clock_lock) static int beeping = 0; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; @@ -415,30 +417,28 @@ int rtcin(reg) int reg; { - int s; u_char val; - s = splhigh(); + RTC_LOCK; outb(IO_RTC, reg); inb(0x84); val = inb(IO_RTC + 1); inb(0x84); - splx(s); + RTC_UNLOCK; return (val); } static __inline void writertc(u_char reg, u_char val) { - int s; - s = splhigh(); + RTC_LOCK; inb(0x84); outb(IO_RTC, reg); inb(0x84); outb(IO_RTC + 1, val); inb(0x84); /* XXX work around wrong order in rtcin() */ - splx(s); + RTC_UNLOCK; } static __inline int diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 36644830e7db..eb8f2826d4d6 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -111,6 +111,8 @@ u_int timer_freq = TIMER_FREQ; int timer0_max_count; int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ struct mtx clock_lock; +#define RTC_LOCK mtx_lock_spin(&clock_lock) +#define RTC_UNLOCK mtx_unlock_spin(&clock_lock) static int beeping = 0; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; @@ -415,30 +417,28 @@ int rtcin(reg) int reg; { - int s; u_char val; - s = splhigh(); + RTC_LOCK; outb(IO_RTC, reg); inb(0x84); val = inb(IO_RTC + 1); inb(0x84); - splx(s); + RTC_UNLOCK; return (val); } static __inline void writertc(u_char reg, u_char val) { - int s; - s = splhigh(); + RTC_LOCK; inb(0x84); outb(IO_RTC, reg); inb(0x84); outb(IO_RTC + 1, val); inb(0x84); /* XXX work around wrong order in rtcin() */ - splx(s); + RTC_UNLOCK; } static __inline int