2015-02-13 18:49:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/timers/rtc.c
|
|
|
|
*
|
2021-03-04 07:10:42 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2015-02-13 18:49:04 +01:00
|
|
|
*
|
2021-03-04 07:10:42 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-02-13 18:49:04 +01:00
|
|
|
*
|
2021-03-04 07:10:42 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2015-02-13 18:49:04 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2015-02-13 18:49:04 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <nuttx/kmalloc.h>
|
2017-10-07 18:57:09 +02:00
|
|
|
#include <nuttx/signal.h>
|
2019-08-26 18:02:48 +02:00
|
|
|
#include <nuttx/clock.h>
|
2015-02-13 18:49:04 +01:00
|
|
|
#include <nuttx/fs/fs.h>
|
2022-09-06 08:18:45 +02:00
|
|
|
#include <nuttx/mutex.h>
|
2015-04-01 20:37:44 +02:00
|
|
|
#include <nuttx/timers/rtc.h>
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-10-20 19:15:17 +02:00
|
|
|
#if defined(CONFIG_RTC_ALARM) || defined(CONFIG_RTC_PERIODIC)
|
2016-04-02 21:01:02 +02:00
|
|
|
struct rtc_alarminfo_s
|
|
|
|
{
|
|
|
|
bool active; /* True: alarm is active */
|
|
|
|
pid_t pid; /* Identifies task to be notified */
|
2019-01-27 15:53:12 +01:00
|
|
|
struct sigevent event; /* Describe the way a task is to be notified */
|
2019-01-27 16:28:59 +01:00
|
|
|
struct sigwork_s work; /* Signal work */
|
2016-04-02 21:01:02 +02:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
struct rtc_upperhalf_s
|
|
|
|
{
|
|
|
|
FAR struct rtc_lowerhalf_s *lower; /* Contained lower half driver */
|
2022-09-06 08:18:45 +02:00
|
|
|
mutex_t lock; /* Supports mutual exclusion */
|
2016-04-02 21:01:02 +02:00
|
|
|
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
uint8_t crefs; /* Number of open references */
|
|
|
|
bool unlinked; /* True if the driver has been unlinked */
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2016-04-02 21:01:02 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_RTC_ALARM
|
|
|
|
/* This is an array, indexed by the alarm ID, that provides information
|
|
|
|
* needed to map an alarm expiration to a signal event.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct rtc_alarminfo_s alarminfo[CONFIG_RTC_NALARMS];
|
|
|
|
#endif
|
2017-10-20 19:15:17 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_RTC_PERIODIC
|
|
|
|
/* Currently only one periodic wakeup is supported. */
|
|
|
|
|
|
|
|
struct rtc_alarminfo_s periodicinfo;
|
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* Internal logic */
|
|
|
|
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
static void rtc_destroy(FAR struct rtc_upperhalf_s *upper);
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
#ifdef CONFIG_RTC_ALARM
|
|
|
|
static void rtc_alarm_callback(FAR void *priv, int id);
|
|
|
|
#endif
|
|
|
|
|
2017-10-20 19:15:17 +02:00
|
|
|
#ifdef CONFIG_RTC_PERIODIC
|
|
|
|
static void rtc_periodic_callback(FAR void *priv, int id);
|
|
|
|
#endif
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
/* Character driver methods */
|
|
|
|
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
static int rtc_open(FAR struct file *filep);
|
|
|
|
static int rtc_close(FAR struct file *filep);
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
|
|
|
|
2015-10-10 18:41:00 +02:00
|
|
|
static ssize_t rtc_read(FAR struct file *filep, FAR char *buffer,
|
|
|
|
size_t buflen);
|
2015-02-13 18:49:04 +01:00
|
|
|
static ssize_t rtc_write(FAR struct file *filep, FAR const char *buffer,
|
|
|
|
size_t buflen);
|
|
|
|
static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
2015-02-18 16:34:58 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
static int rtc_unlink(FAR struct inode *inode);
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-22 16:43:07 +02:00
|
|
|
static const struct file_operations g_rtc_fops =
|
2015-02-13 18:49:04 +01:00
|
|
|
{
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
rtc_open, /* open */
|
|
|
|
rtc_close, /* close */
|
2015-02-18 16:34:58 +01:00
|
|
|
#else
|
2019-05-22 02:57:54 +02:00
|
|
|
NULL, /* open */
|
|
|
|
NULL, /* close */
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
rtc_read, /* read */
|
|
|
|
rtc_write, /* write */
|
2019-05-22 02:57:54 +02:00
|
|
|
NULL, /* seek */
|
2015-02-13 18:49:04 +01:00
|
|
|
rtc_ioctl, /* ioctl */
|
2023-01-02 14:02:51 +01:00
|
|
|
NULL, /* mmap */
|
2023-01-02 18:06:12 +01:00
|
|
|
NULL, /* truncate */
|
2022-01-10 15:51:17 +01:00
|
|
|
NULL /* poll */
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2022-01-10 15:51:17 +01:00
|
|
|
, rtc_unlink /* unlink */
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2016-04-02 21:01:02 +02:00
|
|
|
* Name: rtc_destroy
|
2015-02-13 18:49:04 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
static void rtc_destroy(FAR struct rtc_upperhalf_s *upper)
|
|
|
|
{
|
|
|
|
/* If the lower half driver provided a destroy method, then call that
|
2018-12-22 15:12:34 +01:00
|
|
|
* method now in order to clean up resources used by the lower-half driver.
|
2015-02-13 18:49:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
DEBUGASSERT(upper->lower && upper->lower->ops);
|
|
|
|
if (upper->lower->ops->destroy)
|
|
|
|
{
|
|
|
|
upper->lower->ops->destroy(upper->lower);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And free our container */
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_destroy(&upper->lock);
|
2015-02-13 18:49:04 +01:00
|
|
|
kmm_free(upper);
|
|
|
|
}
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_alarm_callback
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTC_ALARM
|
|
|
|
static void rtc_alarm_callback(FAR void *priv, int alarmid)
|
|
|
|
{
|
|
|
|
FAR struct rtc_upperhalf_s *upper = (FAR struct rtc_upperhalf_s *)priv;
|
|
|
|
FAR struct rtc_alarminfo_s *alarminfo;
|
|
|
|
|
2016-04-03 17:52:25 +02:00
|
|
|
DEBUGASSERT(upper != NULL && alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
2016-04-02 21:01:02 +02:00
|
|
|
alarminfo = &upper->alarminfo[alarmid];
|
|
|
|
|
2017-10-17 18:45:48 +02:00
|
|
|
/* Do we think that the alarm is active? It might be due to some
|
2016-04-02 21:01:02 +02:00
|
|
|
* race condition between a cancellation event and the alarm
|
|
|
|
* expiration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (alarminfo->active)
|
|
|
|
{
|
2024-08-01 14:05:20 +02:00
|
|
|
/* The alarm is no longer active */
|
|
|
|
|
|
|
|
alarminfo->active = false;
|
|
|
|
|
2017-10-17 18:45:48 +02:00
|
|
|
/* Yes.. signal the alarm expiration */
|
2016-04-02 21:01:02 +02:00
|
|
|
|
2019-01-27 16:28:59 +01:00
|
|
|
nxsig_notification(alarminfo->pid, &alarminfo->event,
|
|
|
|
SI_QUEUE, &alarminfo->work);
|
2016-04-02 21:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-10-20 19:15:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_periodic_callback
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTC_PERIODIC
|
|
|
|
static void rtc_periodic_callback(FAR void *priv, int alarmid)
|
|
|
|
{
|
|
|
|
FAR struct rtc_upperhalf_s *upper = (FAR struct rtc_upperhalf_s *)priv;
|
|
|
|
FAR struct rtc_alarminfo_s *alarminfo;
|
|
|
|
|
|
|
|
DEBUGASSERT(upper != NULL && alarmid >= 0);
|
|
|
|
alarminfo = &upper->periodicinfo;
|
|
|
|
|
|
|
|
/* Do we think that the alarm is active? It might be due to some
|
|
|
|
* race condition between a cancellation event and the alarm
|
|
|
|
* expiration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (alarminfo->active)
|
|
|
|
{
|
|
|
|
/* Yes.. signal the alarm expiration */
|
|
|
|
|
2019-01-27 16:28:59 +01:00
|
|
|
nxsig_notification(alarminfo->pid, &alarminfo->event,
|
|
|
|
SI_QUEUE, &alarminfo->work);
|
2017-10-20 19:15:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_open
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
static int rtc_open(FAR struct file *filep)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rtc_upperhalf_s *upper;
|
2019-01-27 17:08:07 +01:00
|
|
|
int ret;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/* Get the reference to our internal state structure from the inode
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inode = filep->f_inode;
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(inode->i_private);
|
2015-02-13 18:49:04 +01:00
|
|
|
upper = inode->i_private;
|
|
|
|
|
2019-01-27 17:08:07 +01:00
|
|
|
/* Get exclusive access to the device structures */
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&upper->lock);
|
2019-01-27 17:08:07 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
/* Increment the count of open references on the RTC driver */
|
|
|
|
|
|
|
|
upper->crefs++;
|
|
|
|
DEBUGASSERT(upper->crefs > 0);
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&upper->lock);
|
2015-02-13 18:49:04 +01:00
|
|
|
return OK;
|
|
|
|
}
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_close
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
static int rtc_close(FAR struct file *filep)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rtc_upperhalf_s *upper;
|
2019-01-27 17:08:07 +01:00
|
|
|
int ret;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/* Get the reference to our internal state structure from the inode
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inode = filep->f_inode;
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(inode->i_private);
|
2015-02-13 18:49:04 +01:00
|
|
|
upper = inode->i_private;
|
|
|
|
|
2019-01-27 17:08:07 +01:00
|
|
|
/* Get exclusive access to the device structures */
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&upper->lock);
|
2019-01-27 17:08:07 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
/* Decrement the count of open references on the RTC driver */
|
|
|
|
|
|
|
|
DEBUGASSERT(upper->crefs > 0);
|
|
|
|
upper->crefs--;
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&upper->lock);
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/* If the count has decremented to zero and the driver has been unlinked,
|
|
|
|
* then commit Hara-Kiri now.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (upper->crefs == 0 && upper->unlinked)
|
|
|
|
{
|
|
|
|
rtc_destroy(upper);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_read
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static ssize_t rtc_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
|
|
|
{
|
|
|
|
return 0; /* Return EOF */
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_write
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-01-27 15:53:12 +01:00
|
|
|
static ssize_t rtc_write(FAR struct file *filep, FAR const char *buffer,
|
|
|
|
size_t len)
|
2015-02-13 18:49:04 +01:00
|
|
|
{
|
|
|
|
return len; /* Say that everything was written */
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_ioctl
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|
|
|
{
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct rtc_upperhalf_s *upper;
|
|
|
|
FAR const struct rtc_ops_s *ops;
|
2023-11-19 16:24:46 +01:00
|
|
|
int ret;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/* Get the reference to our internal state structure from the inode
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inode = filep->f_inode;
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(inode->i_private);
|
2015-02-13 18:49:04 +01:00
|
|
|
upper = inode->i_private;
|
|
|
|
DEBUGASSERT(upper->lower && upper->lower->ops);
|
|
|
|
|
2019-01-27 17:08:07 +01:00
|
|
|
/* Get exclusive access to the device structures */
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&upper->lock);
|
2019-01-27 17:08:07 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
/* We simply forward all ioctl() commands to the lower half. The upper
|
|
|
|
* half is nothing more than a thin driver shell over the lower level
|
|
|
|
* RTC implementation.
|
|
|
|
*/
|
|
|
|
|
2023-11-19 16:24:46 +01:00
|
|
|
ret = -ENOSYS;
|
2015-02-13 18:49:04 +01:00
|
|
|
ops = upper->lower->ops;
|
2023-11-19 16:24:46 +01:00
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
/* RTC_RD_TIME returns the current RTC time.
|
|
|
|
*
|
|
|
|
* Argument: A writeable reference to a struct rtc_time to receive the
|
|
|
|
* RTC's time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
case RTC_RD_TIME:
|
|
|
|
{
|
2019-01-27 15:53:12 +01:00
|
|
|
FAR struct rtc_time *rtctime =
|
|
|
|
(FAR struct rtc_time *)((uintptr_t)arg);
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
if (ops->rdtime)
|
|
|
|
{
|
|
|
|
ret = ops->rdtime(upper->lower, rtctime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* RTC_SET_TIME sets the RTC's time
|
|
|
|
*
|
2017-04-06 17:53:11 +02:00
|
|
|
* Argument: A read-only reference to a struct rtc_time containing
|
2015-02-13 18:49:04 +01:00
|
|
|
* the new time to be set.
|
|
|
|
*/
|
|
|
|
|
|
|
|
case RTC_SET_TIME:
|
|
|
|
{
|
|
|
|
FAR const struct rtc_time *rtctime =
|
|
|
|
(FAR const struct rtc_time *)((uintptr_t)arg);
|
|
|
|
|
|
|
|
if (ops->settime)
|
|
|
|
{
|
|
|
|
ret = ops->settime(upper->lower, rtctime);
|
2023-11-19 16:36:27 +01:00
|
|
|
if (ret == 0)
|
2019-08-26 18:02:48 +02:00
|
|
|
{
|
|
|
|
/* If the RTC time was set successfully, then update the
|
|
|
|
* current system time to match.
|
|
|
|
*/
|
|
|
|
|
2022-01-13 15:01:06 +01:00
|
|
|
clock_synchronize(NULL);
|
2019-08-26 18:02:48 +02:00
|
|
|
}
|
2015-02-13 18:49:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-04-06 17:53:11 +02:00
|
|
|
/* RTC_HAVE_SET_TIME checks if RTC's time had been set
|
|
|
|
*
|
|
|
|
* Argument: A writable reference to a bool to receive true/false return
|
|
|
|
* value of the check.
|
|
|
|
*/
|
|
|
|
|
|
|
|
case RTC_HAVE_SET_TIME:
|
|
|
|
{
|
|
|
|
FAR bool *have_set_time = (FAR bool *)((uintptr_t)arg);
|
|
|
|
|
|
|
|
if (ops->havesettime)
|
|
|
|
{
|
|
|
|
*have_set_time = ops->havesettime(upper->lower);
|
|
|
|
ret = OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-02-15 15:19:23 +01:00
|
|
|
#ifdef CONFIG_RTC_ALARM
|
2016-04-02 21:01:02 +02:00
|
|
|
/* RTC_SET_ALARM sets the alarm time.
|
2015-02-13 18:49:04 +01:00
|
|
|
*
|
2016-04-02 21:01:02 +02:00
|
|
|
* Argument: A read-only reference to a struct rtc_time containing the
|
|
|
|
* new alarm time to be set.
|
2015-02-13 18:49:04 +01:00
|
|
|
*/
|
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
case RTC_SET_ALARM:
|
2015-02-13 18:49:04 +01:00
|
|
|
{
|
2016-04-02 21:01:02 +02:00
|
|
|
FAR const struct rtc_setalarm_s *alarminfo =
|
|
|
|
(FAR const struct rtc_setalarm_s *)((uintptr_t)arg);
|
|
|
|
FAR struct rtc_alarminfo_s *upperinfo;
|
|
|
|
struct lower_setalarm_s lowerinfo;
|
|
|
|
int alarmid;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
DEBUGASSERT(alarminfo != NULL);
|
|
|
|
alarmid = alarminfo->id;
|
2016-04-03 17:52:25 +02:00
|
|
|
DEBUGASSERT(alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
/* Is the alarm active? */
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
upperinfo = &upper->alarminfo[alarmid];
|
|
|
|
if (upperinfo->active)
|
2015-02-13 18:49:04 +01:00
|
|
|
{
|
2016-04-02 21:01:02 +02:00
|
|
|
/* Yes, cancel the alarm */
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
if (ops->cancelalarm)
|
|
|
|
{
|
2020-01-02 17:49:34 +01:00
|
|
|
ops->cancelalarm(upper->lower, alarmid);
|
2016-04-02 21:01:02 +02:00
|
|
|
}
|
2016-04-02 21:55:58 +02:00
|
|
|
|
|
|
|
upperinfo->active = false;
|
2015-02-13 18:49:04 +01:00
|
|
|
}
|
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
if (ops->setalarm)
|
2015-02-13 18:49:04 +01:00
|
|
|
{
|
2016-04-09 01:44:24 +02:00
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
/* A PID of zero means to signal the calling task */
|
|
|
|
|
|
|
|
pid = alarminfo->pid;
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
2023-02-01 11:05:58 +01:00
|
|
|
pid = nxsched_getpid();
|
2016-04-09 01:44:24 +02:00
|
|
|
}
|
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
/* Save the signal info to be used to notify the caller when the
|
|
|
|
* alarm expires.
|
|
|
|
*/
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2023-11-19 16:24:46 +01:00
|
|
|
upperinfo->active = true;
|
|
|
|
upperinfo->pid = pid;
|
|
|
|
upperinfo->event = alarminfo->event;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
/* Format the alarm info needed by the lower half driver */
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2023-11-19 16:24:46 +01:00
|
|
|
lowerinfo.id = alarmid;
|
|
|
|
lowerinfo.cb = rtc_alarm_callback;
|
|
|
|
lowerinfo.priv = (FAR void *)upper;
|
|
|
|
lowerinfo.time = alarminfo->time;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
/* Then set the alarm */
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
ret = ops->setalarm(upper->lower, &lowerinfo);
|
2016-04-02 21:55:58 +02:00
|
|
|
if (ret < 0)
|
2016-04-02 21:01:02 +02:00
|
|
|
{
|
2016-04-02 21:55:58 +02:00
|
|
|
upperinfo->active = false;
|
2016-04-02 21:01:02 +02:00
|
|
|
}
|
2015-02-13 18:49:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-04-03 02:18:48 +02:00
|
|
|
/* RTC_SET_RELATIVE sets the alarm time relative to the current time.
|
|
|
|
*
|
2019-01-27 15:53:12 +01:00
|
|
|
* Argument: A read-only reference to a struct rtc_setrelative_s
|
|
|
|
* containing the new relative alarm time to be set.
|
2016-04-03 02:18:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
case RTC_SET_RELATIVE:
|
|
|
|
{
|
|
|
|
FAR const struct rtc_setrelative_s *alarminfo =
|
|
|
|
(FAR const struct rtc_setrelative_s *)((uintptr_t)arg);
|
|
|
|
FAR struct rtc_alarminfo_s *upperinfo;
|
|
|
|
struct lower_setrelative_s lowerinfo;
|
|
|
|
int alarmid;
|
|
|
|
|
|
|
|
DEBUGASSERT(alarminfo != NULL);
|
|
|
|
alarmid = alarminfo->id;
|
2016-04-03 17:52:25 +02:00
|
|
|
DEBUGASSERT(alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
2016-04-03 02:18:48 +02:00
|
|
|
|
|
|
|
/* Is the alarm active? */
|
|
|
|
|
|
|
|
upperinfo = &upper->alarminfo[alarmid];
|
|
|
|
if (upperinfo->active)
|
|
|
|
{
|
|
|
|
/* Yes, cancel the alarm */
|
|
|
|
|
|
|
|
if (ops->cancelalarm)
|
|
|
|
{
|
2020-01-02 17:49:34 +01:00
|
|
|
ops->cancelalarm(upper->lower, alarmid);
|
2016-04-03 02:18:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
upperinfo->active = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ops->setrelative)
|
|
|
|
{
|
2016-04-09 01:44:24 +02:00
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
/* A PID of zero means to signal the calling task */
|
|
|
|
|
|
|
|
pid = alarminfo->pid;
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
2023-02-01 11:05:58 +01:00
|
|
|
pid = nxsched_getpid();
|
2016-04-09 01:44:24 +02:00
|
|
|
}
|
|
|
|
|
2016-04-03 02:18:48 +02:00
|
|
|
/* Save the signal info to be used to notify the caller when the
|
|
|
|
* alarm expires.
|
|
|
|
*/
|
|
|
|
|
2023-11-19 16:24:46 +01:00
|
|
|
upperinfo->active = true;
|
|
|
|
upperinfo->pid = pid;
|
|
|
|
upperinfo->event = alarminfo->event;
|
2016-04-03 02:18:48 +02:00
|
|
|
|
|
|
|
/* Format the alarm info needed by the lower half driver */
|
|
|
|
|
2023-11-19 16:24:46 +01:00
|
|
|
lowerinfo.id = alarmid;
|
|
|
|
lowerinfo.cb = rtc_alarm_callback;
|
|
|
|
lowerinfo.priv = (FAR void *)upper;
|
|
|
|
lowerinfo.reltime = alarminfo->reltime;
|
2016-04-03 02:18:48 +02:00
|
|
|
|
|
|
|
/* Then set the alarm */
|
|
|
|
|
|
|
|
ret = ops->setrelative(upper->lower, &lowerinfo);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
upperinfo->active = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-10-17 18:45:48 +02:00
|
|
|
/* RTC_CANCEL_ALARM cancel the alarm.
|
2015-02-13 18:49:04 +01:00
|
|
|
*
|
2016-04-02 21:01:02 +02:00
|
|
|
* Argument: An ALARM ID value that indicates which alarm should be
|
|
|
|
* canceled.
|
2015-02-13 18:49:04 +01:00
|
|
|
*/
|
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
case RTC_CANCEL_ALARM:
|
2015-02-13 18:49:04 +01:00
|
|
|
{
|
2017-10-17 18:45:48 +02:00
|
|
|
FAR struct rtc_alarminfo_s *upperinfo;
|
2016-04-02 21:01:02 +02:00
|
|
|
int alarmid = (int)arg;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2016-04-03 17:52:25 +02:00
|
|
|
DEBUGASSERT(alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
2017-10-17 18:45:48 +02:00
|
|
|
|
|
|
|
upperinfo = &upper->alarminfo[alarmid];
|
|
|
|
|
2016-04-02 21:01:02 +02:00
|
|
|
if (ops->cancelalarm)
|
2015-02-13 18:49:04 +01:00
|
|
|
{
|
2016-04-02 21:01:02 +02:00
|
|
|
ret = ops->cancelalarm(upper->lower, alarmid);
|
2017-10-17 18:45:48 +02:00
|
|
|
if (ret == OK)
|
|
|
|
{
|
|
|
|
upperinfo->active = false;
|
2019-01-27 16:28:59 +01:00
|
|
|
nxsig_cancel_notification(&upperinfo->work);
|
2017-10-17 18:45:48 +02:00
|
|
|
}
|
2015-02-13 18:49:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2017-09-03 14:55:38 +02:00
|
|
|
|
|
|
|
/* RTC_RD_ALARM query the alarm.
|
|
|
|
*
|
|
|
|
* Argument: A writable reference to the queried alarm.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
case RTC_RD_ALARM:
|
|
|
|
{
|
|
|
|
FAR struct rtc_rdalarm_s *alarmquery =
|
|
|
|
(FAR struct rtc_rdalarm_s *)((uintptr_t)arg);
|
|
|
|
FAR struct rtc_alarminfo_s *upperinfo;
|
|
|
|
struct lower_rdalarm_s lowerinfo;
|
|
|
|
int alarmid;
|
|
|
|
|
|
|
|
DEBUGASSERT(alarmquery != NULL);
|
|
|
|
alarmid = alarmquery->id;
|
|
|
|
DEBUGASSERT(alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
|
|
|
|
|
|
|
/* Is the alarm active? */
|
|
|
|
|
|
|
|
upperinfo = &upper->alarminfo[alarmid];
|
|
|
|
alarmquery->active = upperinfo->active;
|
|
|
|
|
|
|
|
lowerinfo.id = alarmid;
|
|
|
|
lowerinfo.priv = (FAR void *)upper;
|
|
|
|
lowerinfo.time = (FAR struct rtc_time *)&alarmquery->time;
|
|
|
|
|
|
|
|
if (ops->rdalarm)
|
|
|
|
{
|
|
|
|
ret = ops->rdalarm(upper->lower, &lowerinfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-02-15 15:19:23 +01:00
|
|
|
#endif /* CONFIG_RTC_ALARM */
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2017-10-20 19:15:17 +02:00
|
|
|
#ifdef CONFIG_RTC_PERIODIC
|
|
|
|
/* RTC_SET_PERIODIC set a periodic wakeup.
|
|
|
|
*
|
2019-01-27 15:53:12 +01:00
|
|
|
* Argument: A read-only reference to a struct rtc_setperiodic_s
|
|
|
|
* containing the new wakeup period to be set.
|
2017-10-20 19:15:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
case RTC_SET_PERIODIC:
|
|
|
|
{
|
|
|
|
FAR const struct rtc_setperiodic_s *alarminfo =
|
|
|
|
(FAR const struct rtc_setperiodic_s *)((uintptr_t)arg);
|
|
|
|
FAR struct rtc_alarminfo_s *upperinfo;
|
|
|
|
struct lower_setperiodic_s lowerinfo;
|
|
|
|
int id;
|
|
|
|
|
|
|
|
DEBUGASSERT(alarminfo != NULL);
|
|
|
|
id = alarminfo->id;
|
|
|
|
DEBUGASSERT(id >= 0);
|
|
|
|
|
|
|
|
/* Is the alarm active? */
|
|
|
|
|
|
|
|
upperinfo = &upper->periodicinfo;
|
|
|
|
if (upperinfo->active)
|
|
|
|
{
|
|
|
|
/* Yes, cancel it */
|
|
|
|
|
|
|
|
if (ops->cancelperiodic)
|
|
|
|
{
|
2020-01-02 17:49:34 +01:00
|
|
|
ops->cancelperiodic(upper->lower, id);
|
2017-10-20 19:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
upperinfo->active = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ops->setperiodic)
|
|
|
|
{
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
/* A PID of zero means to signal the calling task */
|
|
|
|
|
|
|
|
pid = alarminfo->pid;
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
2023-02-01 11:05:58 +01:00
|
|
|
pid = nxsched_getpid();
|
2017-10-20 19:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the signal info to be used to notify the caller when the
|
|
|
|
* alarm expires.
|
|
|
|
*/
|
|
|
|
|
2023-11-19 16:24:46 +01:00
|
|
|
upperinfo->active = true;
|
|
|
|
upperinfo->pid = pid;
|
|
|
|
upperinfo->event = alarminfo->event;
|
2017-10-20 19:15:17 +02:00
|
|
|
|
|
|
|
/* Format the alarm info needed by the lower half driver. */
|
|
|
|
|
2023-11-19 16:24:46 +01:00
|
|
|
lowerinfo.id = id;
|
|
|
|
lowerinfo.cb = rtc_periodic_callback;
|
|
|
|
lowerinfo.priv = (FAR void *)upper;
|
|
|
|
lowerinfo.period = alarminfo->period;
|
2017-10-20 19:15:17 +02:00
|
|
|
|
|
|
|
/* Then set the periodic wakeup. */
|
|
|
|
|
|
|
|
ret = ops->setperiodic(upper->lower, &lowerinfo);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
upperinfo->active = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* RTC_CANCEL_PERIODIC cancel the periodic wakeup.
|
|
|
|
*
|
|
|
|
* Argument: An ID value that indicates which wakeup should be canceled.
|
|
|
|
*/
|
|
|
|
|
|
|
|
case RTC_CANCEL_PERIODIC:
|
|
|
|
{
|
|
|
|
FAR struct rtc_alarminfo_s *upperinfo;
|
|
|
|
int id = (int)arg;
|
|
|
|
|
|
|
|
DEBUGASSERT(id >= 0);
|
|
|
|
|
|
|
|
upperinfo = &upper->periodicinfo;
|
|
|
|
|
|
|
|
if (ops->cancelperiodic)
|
|
|
|
{
|
|
|
|
ret = ops->cancelperiodic(upper->lower, id);
|
|
|
|
if (ret == OK)
|
|
|
|
{
|
|
|
|
upperinfo->active = false;
|
2019-01-27 16:28:59 +01:00
|
|
|
nxsig_cancel_notification(&upperinfo->work);
|
2017-10-20 19:15:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif /* CONFIG_RTC_PERIODIC */
|
|
|
|
|
2015-02-18 15:04:25 +01:00
|
|
|
/* Forward any unrecognized IOCTLs to the lower half driver... they
|
|
|
|
* may represent some architecture-specific command.
|
|
|
|
*/
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
default:
|
2015-02-18 15:04:25 +01:00
|
|
|
{
|
2015-02-18 15:23:10 +01:00
|
|
|
#ifdef CONFIG_RTC_IOCTL
|
2015-02-18 15:04:25 +01:00
|
|
|
if (ops->ioctl)
|
|
|
|
{
|
|
|
|
ret = ops->ioctl(upper->lower, cmd, arg);
|
|
|
|
}
|
2015-02-18 15:23:10 +01:00
|
|
|
#endif
|
2015-02-18 15:04:25 +01:00
|
|
|
}
|
2015-02-13 18:49:04 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&upper->lock);
|
2015-02-13 18:49:04 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_unlink
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-02-18 16:34:58 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
static int rtc_unlink(FAR struct inode *inode)
|
|
|
|
{
|
|
|
|
FAR struct rtc_upperhalf_s *upper;
|
2019-01-27 17:08:07 +01:00
|
|
|
int ret;
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/* Get the reference to our internal state structure from the inode
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
|
2023-08-28 11:17:05 +02:00
|
|
|
DEBUGASSERT(inode->i_private);
|
2015-02-13 18:49:04 +01:00
|
|
|
upper = inode->i_private;
|
|
|
|
|
2019-01-27 17:08:07 +01:00
|
|
|
/* Get exclusive access to the device structures */
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
ret = nxmutex_lock(&upper->lock);
|
2019-01-27 17:08:07 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
/* Indicate that the driver has been unlinked */
|
|
|
|
|
|
|
|
upper->unlinked = true;
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&upper->lock);
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/* If there are no further open references to the driver, then commit
|
|
|
|
* Hara-Kiri now.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (upper->crefs == 0)
|
|
|
|
{
|
|
|
|
rtc_destroy(upper);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: rtc_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Create an RTC driver by binding to the lower half RTC driver instance
|
|
|
|
* provided to this function. The resulting RTC driver will be registered
|
|
|
|
* at /dev/rtcN where N is the minor number provided to this function.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2015-02-13 18:49:04 +01:00
|
|
|
* minor - The minor number of the RTC device. The N in /dev/rtcN
|
|
|
|
* lower - The lower half driver instance.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) on success; A negated errno value on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int rtc_initialize(int minor, FAR struct rtc_lowerhalf_s *lower)
|
|
|
|
{
|
|
|
|
FAR struct rtc_upperhalf_s *upper;
|
2023-05-11 12:44:42 +02:00
|
|
|
char devpath[20];
|
2015-02-13 18:49:04 +01:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
DEBUGASSERT(lower && lower->ops && minor >= 0 && minor < 1000);
|
|
|
|
|
|
|
|
/* Allocate an upper half container structure */
|
|
|
|
|
2019-01-27 15:53:12 +01:00
|
|
|
upper = (FAR struct rtc_upperhalf_s *)
|
|
|
|
kmm_zalloc(sizeof(struct rtc_upperhalf_s));
|
|
|
|
|
2015-02-13 18:49:04 +01:00
|
|
|
if (!upper)
|
|
|
|
{
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the upper half container */
|
|
|
|
|
|
|
|
upper->lower = lower; /* Contain lower half driver */
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_init(&upper->lock);
|
2015-02-18 16:34:58 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
2015-02-13 18:49:04 +01:00
|
|
|
upper->crefs = 0; /* No open references */
|
|
|
|
upper->unlinked = false; /* Driver is not unlinked */
|
2015-02-18 16:34:58 +01:00
|
|
|
#endif
|
2015-02-13 18:49:04 +01:00
|
|
|
|
2023-05-11 12:44:42 +02:00
|
|
|
/* Create the driver name. There is space for the a minor number up to 10
|
2015-02-13 18:49:04 +01:00
|
|
|
* characters
|
|
|
|
*/
|
|
|
|
|
2023-05-11 12:44:42 +02:00
|
|
|
snprintf(devpath, sizeof(devpath), "/dev/rtc%d", minor);
|
2015-02-13 18:49:04 +01:00
|
|
|
|
|
|
|
/* And, finally, register the new RTC driver */
|
|
|
|
|
2023-04-22 16:43:07 +02:00
|
|
|
ret = register_driver(devpath, &g_rtc_fops, 0666, upper);
|
2015-02-13 18:49:04 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_destroy(&upper->lock);
|
2015-02-13 18:49:04 +01:00
|
|
|
kmm_free(upper);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|