~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/drivers/rtc_user.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Copyright (C) 2020 Intel Corporation
  4  * Author: Johannes Berg <johannes@sipsolutions.net>
  5  */
  6 #include <stdbool.h>
  7 #include <os.h>
  8 #include <errno.h>
  9 #include <sched.h>
 10 #include <unistd.h>
 11 #include <kern_util.h>
 12 #include <sys/select.h>
 13 #include <stdio.h>
 14 #include <sys/timerfd.h>
 15 #include "rtc.h"
 16 
 17 static int uml_rtc_irq_fds[2];
 18 
 19 void uml_rtc_send_timetravel_alarm(void)
 20 {
 21         unsigned long long c = 1;
 22 
 23         CATCH_EINTR(write(uml_rtc_irq_fds[1], &c, sizeof(c)));
 24 }
 25 
 26 int uml_rtc_start(bool timetravel)
 27 {
 28         int err;
 29 
 30         if (timetravel) {
 31                 int err = os_pipe(uml_rtc_irq_fds, 1, 1);
 32                 if (err)
 33                         goto fail;
 34         } else {
 35                 uml_rtc_irq_fds[0] = timerfd_create(CLOCK_REALTIME, TFD_CLOEXEC);
 36                 if (uml_rtc_irq_fds[0] < 0) {
 37                         err = -errno;
 38                         goto fail;
 39                 }
 40 
 41                 /* apparently timerfd won't send SIGIO, use workaround */
 42                 sigio_broken(uml_rtc_irq_fds[0]);
 43                 err = add_sigio_fd(uml_rtc_irq_fds[0]);
 44                 if (err < 0) {
 45                         close(uml_rtc_irq_fds[0]);
 46                         goto fail;
 47                 }
 48         }
 49 
 50         return uml_rtc_irq_fds[0];
 51 fail:
 52         uml_rtc_stop(timetravel);
 53         return err;
 54 }
 55 
 56 int uml_rtc_enable_alarm(unsigned long long delta_seconds)
 57 {
 58         struct itimerspec it = {
 59                 .it_value = {
 60                         .tv_sec = delta_seconds,
 61                 },
 62         };
 63 
 64         if (timerfd_settime(uml_rtc_irq_fds[0], 0, &it, NULL))
 65                 return -errno;
 66         return 0;
 67 }
 68 
 69 void uml_rtc_disable_alarm(void)
 70 {
 71         uml_rtc_enable_alarm(0);
 72 }
 73 
 74 void uml_rtc_stop(bool timetravel)
 75 {
 76         if (timetravel)
 77                 os_close_file(uml_rtc_irq_fds[1]);
 78         else
 79                 ignore_sigio_fd(uml_rtc_irq_fds[0]);
 80         os_close_file(uml_rtc_irq_fds[0]);
 81 }
 82 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php