mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 09:02:06 +00:00
efirtc: Don't use create_proc_read_entry()
Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells <dhowells@redhat.com> cc: Arnd Bergmann <arnd@arndb.de> cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
a6d935a5b1
commit
788416bcee
1 changed files with 40 additions and 43 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/rtc.h>
|
#include <linux/rtc.h>
|
||||||
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/seq_file.h>
|
||||||
#include <linux/efi.h>
|
#include <linux/efi.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
|
@ -296,12 +297,10 @@ static struct miscdevice efi_rtc_dev= {
|
||||||
/*
|
/*
|
||||||
* We export RAW EFI information to /proc/driver/efirtc
|
* We export RAW EFI information to /proc/driver/efirtc
|
||||||
*/
|
*/
|
||||||
static int
|
static int efi_rtc_proc_show(struct seq_file *m, void *v)
|
||||||
efi_rtc_get_status(char *buf)
|
|
||||||
{
|
{
|
||||||
efi_time_t eft, alm;
|
efi_time_t eft, alm;
|
||||||
efi_time_cap_t cap;
|
efi_time_cap_t cap;
|
||||||
char *p = buf;
|
|
||||||
efi_bool_t enabled, pending;
|
efi_bool_t enabled, pending;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
@ -316,64 +315,63 @@ efi_rtc_get_status(char *buf)
|
||||||
|
|
||||||
spin_unlock_irqrestore(&efi_rtc_lock,flags);
|
spin_unlock_irqrestore(&efi_rtc_lock,flags);
|
||||||
|
|
||||||
p += sprintf(p,
|
seq_printf(m,
|
||||||
"Time : %u:%u:%u.%09u\n"
|
"Time : %u:%u:%u.%09u\n"
|
||||||
"Date : %u-%u-%u\n"
|
"Date : %u-%u-%u\n"
|
||||||
"Daylight : %u\n",
|
"Daylight : %u\n",
|
||||||
eft.hour, eft.minute, eft.second, eft.nanosecond,
|
eft.hour, eft.minute, eft.second, eft.nanosecond,
|
||||||
eft.year, eft.month, eft.day,
|
eft.year, eft.month, eft.day,
|
||||||
eft.daylight);
|
eft.daylight);
|
||||||
|
|
||||||
if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
|
if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
|
||||||
p += sprintf(p, "Timezone : unspecified\n");
|
seq_puts(m, "Timezone : unspecified\n");
|
||||||
else
|
else
|
||||||
/* XXX fixme: convert to string? */
|
/* XXX fixme: convert to string? */
|
||||||
p += sprintf(p, "Timezone : %u\n", eft.timezone);
|
seq_printf(m, "Timezone : %u\n", eft.timezone);
|
||||||
|
|
||||||
|
|
||||||
p += sprintf(p,
|
seq_printf(m,
|
||||||
"Alarm Time : %u:%u:%u.%09u\n"
|
"Alarm Time : %u:%u:%u.%09u\n"
|
||||||
"Alarm Date : %u-%u-%u\n"
|
"Alarm Date : %u-%u-%u\n"
|
||||||
"Alarm Daylight : %u\n"
|
"Alarm Daylight : %u\n"
|
||||||
"Enabled : %s\n"
|
"Enabled : %s\n"
|
||||||
"Pending : %s\n",
|
"Pending : %s\n",
|
||||||
alm.hour, alm.minute, alm.second, alm.nanosecond,
|
alm.hour, alm.minute, alm.second, alm.nanosecond,
|
||||||
alm.year, alm.month, alm.day,
|
alm.year, alm.month, alm.day,
|
||||||
alm.daylight,
|
alm.daylight,
|
||||||
enabled == 1 ? "yes" : "no",
|
enabled == 1 ? "yes" : "no",
|
||||||
pending == 1 ? "yes" : "no");
|
pending == 1 ? "yes" : "no");
|
||||||
|
|
||||||
if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
|
if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
|
||||||
p += sprintf(p, "Timezone : unspecified\n");
|
seq_puts(m, "Timezone : unspecified\n");
|
||||||
else
|
else
|
||||||
/* XXX fixme: convert to string? */
|
/* XXX fixme: convert to string? */
|
||||||
p += sprintf(p, "Timezone : %u\n", alm.timezone);
|
seq_printf(m, "Timezone : %u\n", alm.timezone);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* now prints the capabilities
|
* now prints the capabilities
|
||||||
*/
|
*/
|
||||||
p += sprintf(p,
|
seq_printf(m,
|
||||||
"Resolution : %u\n"
|
"Resolution : %u\n"
|
||||||
"Accuracy : %u\n"
|
"Accuracy : %u\n"
|
||||||
"SetstoZero : %u\n",
|
"SetstoZero : %u\n",
|
||||||
cap.resolution, cap.accuracy, cap.sets_to_zero);
|
cap.resolution, cap.accuracy, cap.sets_to_zero);
|
||||||
|
|
||||||
return p - buf;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int efi_rtc_proc_open(struct inode *inode, struct file *file)
|
||||||
efi_rtc_read_proc(char *page, char **start, off_t off,
|
|
||||||
int count, int *eof, void *data)
|
|
||||||
{
|
{
|
||||||
int len = efi_rtc_get_status(page);
|
return single_open(file, efi_rtc_proc_show, NULL);
|
||||||
if (len <= off+count) *eof = 1;
|
|
||||||
*start = page + off;
|
|
||||||
len -= off;
|
|
||||||
if (len>count) len = count;
|
|
||||||
if (len<0) len = 0;
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct file_operations efi_rtc_proc_fops = {
|
||||||
|
.open = efi_rtc_proc_open,
|
||||||
|
.read = seq_read,
|
||||||
|
.llseek = seq_lseek,
|
||||||
|
.release = seq_release,
|
||||||
|
};
|
||||||
|
|
||||||
static int __init
|
static int __init
|
||||||
efi_rtc_init(void)
|
efi_rtc_init(void)
|
||||||
{
|
{
|
||||||
|
@ -389,8 +387,7 @@ efi_rtc_init(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = create_proc_read_entry ("driver/efirtc", 0, NULL,
|
dir = proc_create("driver/efirtc", 0, NULL, &efi_rtc_proc_fops);
|
||||||
efi_rtc_read_proc, NULL);
|
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n");
|
printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n");
|
||||||
misc_deregister(&efi_rtc_dev);
|
misc_deregister(&efi_rtc_dev);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue