[PATCH] ARM: RTC: allow driver methods to return error
Allow RTC drivers to return error codes from their read_time or read_alarm methods. Signed-off-by: Russell King <rmk@arm.linux.org.uk>
This commit is contained in:
parent
a6ad57fb4b
commit
d5aa207e46
@ -141,10 +141,10 @@ void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc
|
|||||||
next->tm_sec = alrm->tm_sec;
|
next->tm_sec = alrm->tm_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm)
|
static inline int rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
memset(tm, 0, sizeof(struct rtc_time));
|
memset(tm, 0, sizeof(struct rtc_time));
|
||||||
ops->read_time(tm);
|
return ops->read_time(tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm)
|
static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm)
|
||||||
@ -163,8 +163,7 @@ static inline int rtc_read_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm)
|
|||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
if (ops->read_alarm) {
|
if (ops->read_alarm) {
|
||||||
memset(alrm, 0, sizeof(struct rtc_wkalrm));
|
memset(alrm, 0, sizeof(struct rtc_wkalrm));
|
||||||
ops->read_alarm(alrm);
|
ret = ops->read_alarm(alrm);
|
||||||
ret = 0;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -283,7 +282,9 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTC_RD_TIME:
|
case RTC_RD_TIME:
|
||||||
rtc_read_time(ops, &tm);
|
ret = rtc_read_time(ops, &tm);
|
||||||
|
if (ret)
|
||||||
|
break;
|
||||||
ret = copy_to_user(uarg, &tm, sizeof(tm));
|
ret = copy_to_user(uarg, &tm, sizeof(tm));
|
||||||
if (ret)
|
if (ret)
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
@ -424,15 +425,15 @@ static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eo
|
|||||||
struct rtc_time tm;
|
struct rtc_time tm;
|
||||||
char *p = page;
|
char *p = page;
|
||||||
|
|
||||||
rtc_read_time(ops, &tm);
|
if (rtc_read_time(ops, &tm) == 0) {
|
||||||
|
p += sprintf(p,
|
||||||
p += sprintf(p,
|
"rtc_time\t: %02d:%02d:%02d\n"
|
||||||
"rtc_time\t: %02d:%02d:%02d\n"
|
"rtc_date\t: %04d-%02d-%02d\n"
|
||||||
"rtc_date\t: %04d-%02d-%02d\n"
|
"rtc_epoch\t: %04lu\n",
|
||||||
"rtc_epoch\t: %04lu\n",
|
tm.tm_hour, tm.tm_min, tm.tm_sec,
|
||||||
tm.tm_hour, tm.tm_min, tm.tm_sec,
|
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
|
||||||
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
|
rtc_epoch);
|
||||||
rtc_epoch);
|
}
|
||||||
|
|
||||||
if (rtc_read_alarm(ops, &alrm) == 0) {
|
if (rtc_read_alarm(ops, &alrm) == 0) {
|
||||||
p += sprintf(p, "alrm_time\t: ");
|
p += sprintf(p, "alrm_time\t: ");
|
||||||
|
@ -40,25 +40,32 @@ static int integrator_set_rtc(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtc_read_alarm(struct rtc_wkalrm *alrm)
|
static int rtc_read_alarm(struct rtc_wkalrm *alrm)
|
||||||
{
|
{
|
||||||
rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time);
|
rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rtc_set_alarm(struct rtc_wkalrm *alrm)
|
static inline int rtc_set_alarm(struct rtc_wkalrm *alrm)
|
||||||
{
|
{
|
||||||
unsigned long time;
|
unsigned long time;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = rtc_tm_to_time(&alrm->time, &time);
|
/*
|
||||||
|
* At the moment, we can only deal with non-wildcarded alarm times.
|
||||||
|
*/
|
||||||
|
ret = rtc_valid_tm(&alrm->time);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = rtc_tm_to_time(&alrm->time, &time);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
writel(time, rtc_base + RTC_MR);
|
writel(time, rtc_base + RTC_MR);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtc_read_time(struct rtc_time *tm)
|
static int rtc_read_time(struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
rtc_time_to_tm(readl(rtc_base + RTC_DR), tm);
|
rtc_time_to_tm(readl(rtc_base + RTC_DR), tm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -69,7 +76,7 @@ static void rtc_read_time(struct rtc_time *tm)
|
|||||||
* edge of the 1Hz clock, we must write the time one second
|
* edge of the 1Hz clock, we must write the time one second
|
||||||
* in advance.
|
* in advance.
|
||||||
*/
|
*/
|
||||||
static int rtc_set_time(struct rtc_time *tm)
|
static inline int rtc_set_time(struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
unsigned long time;
|
unsigned long time;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -116,7 +116,7 @@ static void s3c2410_rtc_setfreq(int freq)
|
|||||||
|
|
||||||
/* Time read/write */
|
/* Time read/write */
|
||||||
|
|
||||||
static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
|
static int s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
|
||||||
{
|
{
|
||||||
unsigned int have_retried = 0;
|
unsigned int have_retried = 0;
|
||||||
|
|
||||||
@ -151,6 +151,8 @@ static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
|
|||||||
|
|
||||||
rtc_tm->tm_year += 100;
|
rtc_tm->tm_year += 100;
|
||||||
rtc_tm->tm_mon -= 1;
|
rtc_tm->tm_mon -= 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,7 +173,7 @@ static int s3c2410_rtc_settime(struct rtc_time *tm)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
|
static int s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
|
||||||
{
|
{
|
||||||
struct rtc_time *alm_tm = &alrm->time;
|
struct rtc_time *alm_tm = &alrm->time;
|
||||||
unsigned int alm_en;
|
unsigned int alm_en;
|
||||||
@ -231,6 +233,8 @@ static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* todo - set alrm->enabled ? */
|
/* todo - set alrm->enabled ? */
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm)
|
static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm)
|
||||||
|
@ -18,9 +18,9 @@ struct rtc_ops {
|
|||||||
void (*release)(void);
|
void (*release)(void);
|
||||||
int (*ioctl)(unsigned int, unsigned long);
|
int (*ioctl)(unsigned int, unsigned long);
|
||||||
|
|
||||||
void (*read_time)(struct rtc_time *);
|
int (*read_time)(struct rtc_time *);
|
||||||
int (*set_time)(struct rtc_time *);
|
int (*set_time)(struct rtc_time *);
|
||||||
void (*read_alarm)(struct rtc_wkalrm *);
|
int (*read_alarm)(struct rtc_wkalrm *);
|
||||||
int (*set_alarm)(struct rtc_wkalrm *);
|
int (*set_alarm)(struct rtc_wkalrm *);
|
||||||
int (*proc)(char *buf);
|
int (*proc)(char *buf);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user