From a6c68d233d76b5ba21e4bad1625edf9eb3572b29 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 24 Aug 2018 10:16:17 -0600 Subject: [PATCH] drivers/timers: Add maxtimeout method to the struct timer_ops_s interface --- drivers/timers/timer.c | 20 ++++++++++++++++++++ include/nuttx/timers/timer.h | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/timers/timer.c b/drivers/timers/timer.c index 6bb4edeb19..5c828873df 100644 --- a/drivers/timers/timer.c +++ b/drivers/timers/timer.c @@ -390,6 +390,26 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; + /* cmd: TCIOC_MAXTIMEOUT + * Description: Get the maximum supported timeout value + * Argument: A 32-bit timeout value in microseconds. + */ + + case TCIOC_MAXTIMEOUT: + { + /* Get the maximum supported timeout value */ + + if (lower->ops->maxtimeout) /* Optional */ + { + ret = lower->ops->maxtimeout(lower, (uint32_t *)arg); + } + else + { + ret = -ENOSYS; + } + } + break; + /* Any unrecognized IOCTL commands might be platform-specific ioctl commands */ default: diff --git a/include/nuttx/timers/timer.h b/include/nuttx/timers/timer.h index db59e81819..420e8dfbb2 100644 --- a/include/nuttx/timers/timer.h +++ b/include/nuttx/timers/timer.h @@ -74,6 +74,8 @@ * the timer expires. * Argument: A read-only pointer to an instance of * stuct timer_notify_s. + * TCIOC_MAXTIMEOUT - Get the maximum supported timeout value + * Argument: A 32-bit timeout value in microseconds. * * WARNING: May change TCIOC_SETTIMEOUT to pass pointer to 64bit nanoseconds * or timespec structure. @@ -93,6 +95,7 @@ #define TCIOC_GETSTATUS _TCIOC(0x0003) #define TCIOC_SETTIMEOUT _TCIOC(0x0004) #define TCIOC_NOTIFICATION _TCIOC(0x0005) +#define TCIOC_MAXTIMEOUT _TCIOC(0x0006) /* Bit Settings *************************************************************/ /* Bit settings for the struct timer_status_s flags field */ @@ -172,6 +175,11 @@ struct timer_ops_s CODE int (*ioctl)(FAR struct timer_lowerhalf_s *lower, int cmd, unsigned long arg); + + /* Get the maximum supported timeout value */ + + CODE int (*maxtimeout)(FAR struct timer_lowerhalf_s *lower, + FAR uint32_t *maxtimeout); }; /* This structure provides the publicly visible representation of the