#include <linux/module.h>
#include <linux/completion.h>
#include <linux/platform_device.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include "cbus.h"
#include "retu.h"
-static struct semaphore retu_rtc_sem;
+static struct mutex retu_rtc_mutex;
static u16 retu_rtc_alarm_expired;
static u16 retu_rtc_reset_occurred;
{
u16 dsr, hmr, dsr2;
- down(&retu_rtc_sem);
+ mutex_lock(&retu_rtc_mutex);
do {
u16 dummy;
dsr2 = retu_read_reg(RETU_REG_RTCDSR);
} while ((dsr != dsr2));
- up(&retu_rtc_sem);
+ mutex_unlock(&retu_rtc_mutex);
/*
* Format a 32-bit date-string for userspace
static ssize_t retu_rtc_time_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- down(&retu_rtc_sem);
+ mutex_lock(&retu_rtc_mutex);
/*
* Writing anything to the day counter forces it to 0
* The seconds counter would be cleared by resetting the minutes counter,
retu_write_reg(RETU_REG_RTCDSR,
retu_read_reg(RETU_REG_RTCDSR) & (1 << 6));
- up(&retu_rtc_sem);
+ mutex_unlock(&retu_rtc_mutex);
return count;
}
if(sscanf(buf, "%u", &choice) != 1)
return count;
- down(&retu_rtc_sem);
+ mutex_lock(&retu_rtc_mutex);
if (choice == 0)
retu_rtc_reset_occurred = 0;
else if (choice == 1)
retu_rtc_do_reset();
- up(&retu_rtc_sem);
+ mutex_unlock(&retu_rtc_mutex);
return count;
}
u16 chmar;
ssize_t retval;
- down(&retu_rtc_sem);
+ mutex_lock(&retu_rtc_mutex);
/*
* Format a 16-bit date-string for userspace
*
chmar = retu_read_reg(RETU_REG_RTCHMAR);
/* No shifting needed, only masking unrelated bits */
retval = sprintf(buf, "0x%04x\n", chmar & 0x1f3f);
- up(&retu_rtc_sem);
+ mutex_unlock(&retu_rtc_mutex);
return retval;
}
unsigned hours;
unsigned minutes;
- down(&retu_rtc_sem);
+ mutex_lock(&retu_rtc_mutex);
if(sscanf(buf, "%x", &alrm) != 1)
return count;
/* enable the interrupt */
retu_enable_irq(RETU_INT_RTCA);
}
- up(&retu_rtc_sem);
+ mutex_unlock(&retu_rtc_mutex);
return count;
}
{
u16 rtccalr1;
- down(&retu_rtc_sem);
+ mutex_lock(&retu_rtc_mutex);
rtccalr1 = retu_read_reg(RETU_REG_RTCCALR);
- up(&retu_rtc_sem);
+ mutex_unlock(&retu_rtc_mutex);
/*
* Shows the status of the Calibration Register.
if (sscanf(buf, "%x", &calibration_value) != 1)
return count;
- down(&retu_rtc_sem);
+ mutex_lock(&retu_rtc_mutex);
retu_rtc_barrier();
retu_write_reg(RETU_REG_RTCCALR, calibration_value & 0x00ff);
- up(&retu_rtc_sem);
+ mutex_unlock(&retu_rtc_mutex);
return count;
}
if ((r = retu_rtc_init_irq()) != 0)
return r;
- init_MUTEX(&retu_rtc_sem);
+ mutex_init(&retu_rtc_mutex);
/* If the calibration register is zero, we've probably lost
* power */