From 8eb7898a9129cadee3bb93438d43ea6e6621eb8c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 8 Apr 2016 17:44:24 -0600 Subject: [PATCH] RTC driver: A PID of zero should mean to notify the calling task --- drivers/timers/rtc.c | 24 ++++++++++++++++++++++-- include/nuttx/timers/rtc.h | 4 ++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/timers/rtc.c b/drivers/timers/rtc.c index 62453c1c20..0b467fde2f 100644 --- a/drivers/timers/rtc.c +++ b/drivers/timers/rtc.c @@ -384,13 +384,23 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) if (ops->setalarm) { + pid_t pid; + + /* A PID of zero means to signal the calling task */ + + pid = alarminfo->pid; + if (pid == 0) + { + pid = getpid(); + } + /* Save the signal info to be used to notify the caller when the * alarm expires. */ upperinfo->active = true; upperinfo->signo = alarminfo->signo; - upperinfo->pid = alarminfo->pid; + upperinfo->pid = pid; upperinfo->sigvalue = alarminfo->sigvalue; /* Format the alarm info needed by the lower half driver */ @@ -447,13 +457,23 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) if (ops->setrelative) { + pid_t pid; + + /* A PID of zero means to signal the calling task */ + + pid = alarminfo->pid; + if (pid == 0) + { + pid = getpid(); + } + /* Save the signal info to be used to notify the caller when the * alarm expires. */ upperinfo->active = true; upperinfo->signo = alarminfo->signo; - upperinfo->pid = alarminfo->pid; + upperinfo->pid = pid; upperinfo->sigvalue = alarminfo->sigvalue; /* Format the alarm info needed by the lower half driver */ diff --git a/include/nuttx/timers/rtc.h b/include/nuttx/timers/rtc.h index 179779a213..d2345a4dc1 100644 --- a/include/nuttx/timers/rtc.h +++ b/include/nuttx/timers/rtc.h @@ -223,7 +223,7 @@ struct rtc_setalarm_s { uint8_t id; /* Indicates the alarm to be set */ uint8_t signo; /* Signal number for alarm notification */ - pid_t pid; /* Identifies task to be notified */ + pid_t pid; /* Identifies task to be notified (0=caller) */ union sigval sigvalue; /* Data passed with notification */ struct rtc_time time; /* Alarm time */ }; @@ -234,7 +234,7 @@ struct rtc_setrelative_s { uint8_t id; /* Indicates the alarm to be set */ uint8_t signo; /* Signal number for alarm notification */ - pid_t pid; /* Identifies task to be notified */ + pid_t pid; /* Identifies task to be notified (0=caller) */ union sigval sigvalue; /* Data passed with notification */ time_t reltime; /* Relative time in seconds */ };