static int efi_set_time(struct device *dev, struct rtc_time *tm) { efi_status_t status; efi_time_t eft; convert_to_efi_time(tm, &eft); status = efi.set_time(&eft); return status == EFI_SUCCESS ? 0 : -EINVAL; }
static int efi_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) { efi_time_t eft; efi_status_t status; convert_to_efi_time(&wkalrm->time, &eft); status = efi.set_wakeup_time((efi_bool_t)wkalrm->enabled, &eft); printk(KERN_WARNING "write status is %d\n", (int)status); return status == EFI_SUCCESS ? 0 : -EINVAL; }
static int efi_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) { efi_time_t eft; efi_status_t status; convert_to_efi_time(&wkalrm->time, &eft); /* * XXX Fixme: * As of EFI 0.92 with the firmware I have on my * machine this call does not seem to work quite * right * * As of v1.10, this call always returns an unsupported status */ status = efi.set_wakeup_time((efi_bool_t)wkalrm->enabled, &eft); dev_warn(dev, "write status is %d\n", (int)status); return status == EFI_SUCCESS ? 0 : -EINVAL; }
static long efi_rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { efi_status_t status; unsigned long flags; efi_time_t eft; efi_time_cap_t cap; struct rtc_time wtime; struct rtc_wkalrm __user *ewp; unsigned char enabled, pending; switch (cmd) { case RTC_UIE_ON: case RTC_UIE_OFF: case RTC_PIE_ON: case RTC_PIE_OFF: case RTC_AIE_ON: case RTC_AIE_OFF: case RTC_ALM_SET: case RTC_ALM_READ: case RTC_IRQP_READ: case RTC_IRQP_SET: case RTC_EPOCH_READ: case RTC_EPOCH_SET: return -EINVAL; case RTC_RD_TIME: spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.get_time(&eft, &cap); spin_unlock_irqrestore(&efi_rtc_lock,flags); if (status != EFI_SUCCESS) { /* should never happen */ printk(KERN_ERR "efitime: can't read time\n"); return -EINVAL; } convert_from_efi_time(&eft, &wtime); return copy_to_user((void __user *)arg, &wtime, sizeof (struct rtc_time)) ? - EFAULT : 0; case RTC_SET_TIME: if (!capable(CAP_SYS_TIME)) return -EACCES; if (copy_from_user(&wtime, (struct rtc_time __user *)arg, sizeof(struct rtc_time)) ) return -EFAULT; convert_to_efi_time(&wtime, &eft); spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.set_time(&eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); return status == EFI_SUCCESS ? 0 : -EINVAL; case RTC_WKALM_SET: if (!capable(CAP_SYS_TIME)) return -EACCES; ewp = (struct rtc_wkalrm __user *)arg; if ( get_user(enabled, &ewp->enabled) || copy_from_user(&wtime, &ewp->time, sizeof(struct rtc_time)) ) return -EFAULT; convert_to_efi_time(&wtime, &eft); spin_lock_irqsave(&efi_rtc_lock, flags); /* * XXX Fixme: * As of EFI 0.92 with the firmware I have on my * machine this call does not seem to work quite * right */ status = efi.set_wakeup_time((efi_bool_t)enabled, &eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); return status == EFI_SUCCESS ? 0 : -EINVAL; case RTC_WKALM_RD: spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); if (status != EFI_SUCCESS) return -EINVAL; ewp = (struct rtc_wkalrm __user *)arg; if ( put_user(enabled, &ewp->enabled) || put_user(pending, &ewp->pending)) return -EFAULT; convert_from_efi_time(&eft, &wtime); return copy_to_user(&ewp->time, &wtime, sizeof(struct rtc_time)) ? -EFAULT : 0; } return -ENOTTY; }