Commit cf7acfab authored by Denis V. Lunev's avatar Denis V. Lunev Committed by Linus Torvalds

acpi: use non-racy method for proc entries creation

Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.

Add correct ->owner to proc_fops to fix reading/module unloading race.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 66747138
...@@ -92,6 +92,7 @@ struct acpi_ac { ...@@ -92,6 +92,7 @@ struct acpi_ac {
#ifdef CONFIG_ACPI_PROCFS_POWER #ifdef CONFIG_ACPI_PROCFS_POWER
static const struct file_operations acpi_ac_fops = { static const struct file_operations acpi_ac_fops = {
.owner = THIS_MODULE,
.open = acpi_ac_open_fs, .open = acpi_ac_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -195,16 +196,11 @@ static int acpi_ac_add_fs(struct acpi_device *device) ...@@ -195,16 +196,11 @@ static int acpi_ac_add_fs(struct acpi_device *device)
} }
/* 'state' [R] */ /* 'state' [R] */
entry = create_proc_entry(ACPI_AC_FILE_STATE, entry = proc_create_data(ACPI_AC_FILE_STATE,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_ac_fops, acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_ac_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
......
...@@ -741,15 +741,13 @@ static int acpi_battery_add_fs(struct acpi_device *device) ...@@ -741,15 +741,13 @@ static int acpi_battery_add_fs(struct acpi_device *device)
} }
for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) { for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
entry = create_proc_entry(acpi_battery_file[i].name, entry = proc_create_data(acpi_battery_file[i].name,
acpi_battery_file[i].mode, acpi_device_dir(device)); acpi_battery_file[i].mode,
acpi_device_dir(device),
&acpi_battery_file[i].ops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_battery_file[i].ops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
} }
return 0; return 0;
} }
......
...@@ -102,6 +102,7 @@ struct acpi_button { ...@@ -102,6 +102,7 @@ struct acpi_button {
}; };
static const struct file_operations acpi_button_info_fops = { static const struct file_operations acpi_button_info_fops = {
.owner = THIS_MODULE,
.open = acpi_button_info_open_fs, .open = acpi_button_info_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -109,6 +110,7 @@ static const struct file_operations acpi_button_info_fops = { ...@@ -109,6 +110,7 @@ static const struct file_operations acpi_button_info_fops = {
}; };
static const struct file_operations acpi_button_state_fops = { static const struct file_operations acpi_button_state_fops = {
.owner = THIS_MODULE,
.open = acpi_button_state_open_fs, .open = acpi_button_state_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -207,27 +209,21 @@ static int acpi_button_add_fs(struct acpi_device *device) ...@@ -207,27 +209,21 @@ static int acpi_button_add_fs(struct acpi_device *device)
acpi_device_dir(device)->owner = THIS_MODULE; acpi_device_dir(device)->owner = THIS_MODULE;
/* 'info' [R] */ /* 'info' [R] */
entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, entry = proc_create_data(ACPI_BUTTON_FILE_INFO,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_button_info_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_button_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* show lid state [R] */ /* show lid state [R] */
if (button->type == ACPI_BUTTON_TYPE_LID) { if (button->type == ACPI_BUTTON_TYPE_LID) {
entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, entry = proc_create_data(ACPI_BUTTON_FILE_STATE,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_button_state_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_button_state_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
} }
return 0; return 0;
......
...@@ -669,16 +669,11 @@ static int acpi_ec_add_fs(struct acpi_device *device) ...@@ -669,16 +669,11 @@ static int acpi_ec_add_fs(struct acpi_device *device)
return -ENODEV; return -ENODEV;
} }
entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, entry = proc_create_data(ACPI_EC_FILE_INFO, S_IRUGO,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_ec_info_ops, acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_ec_info_ops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
......
...@@ -102,6 +102,7 @@ static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait) ...@@ -102,6 +102,7 @@ static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait)
} }
static const struct file_operations acpi_system_event_ops = { static const struct file_operations acpi_system_event_ops = {
.owner = THIS_MODULE,
.open = acpi_system_open_event, .open = acpi_system_open_event,
.read = acpi_system_read_event, .read = acpi_system_read_event,
.release = acpi_system_close_event, .release = acpi_system_close_event,
...@@ -294,10 +295,9 @@ static int __init acpi_event_init(void) ...@@ -294,10 +295,9 @@ static int __init acpi_event_init(void)
#ifdef CONFIG_ACPI_PROC_EVENT #ifdef CONFIG_ACPI_PROC_EVENT
/* 'event' [R] */ /* 'event' [R] */
entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); entry = proc_create("event", S_IRUSR, acpi_root_dir,
if (entry) &acpi_system_event_ops);
entry->proc_fops = &acpi_system_event_ops; if (!entry)
else
return -ENODEV; return -ENODEV;
#endif #endif
......
...@@ -192,17 +192,13 @@ static int acpi_fan_add_fs(struct acpi_device *device) ...@@ -192,17 +192,13 @@ static int acpi_fan_add_fs(struct acpi_device *device)
} }
/* 'status' [R/W] */ /* 'status' [R/W] */
entry = create_proc_entry(ACPI_FAN_FILE_STATE, entry = proc_create_data(ACPI_FAN_FILE_STATE,
S_IFREG | S_IRUGO | S_IWUSR, S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_fan_state_ops,
device);
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_fan_state_ops;
entry->data = device;
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
......
...@@ -93,6 +93,7 @@ struct acpi_power_resource { ...@@ -93,6 +93,7 @@ struct acpi_power_resource {
static struct list_head acpi_power_resource_list; static struct list_head acpi_power_resource_list;
static const struct file_operations acpi_power_fops = { static const struct file_operations acpi_power_fops = {
.owner = THIS_MODULE,
.open = acpi_power_open_fs, .open = acpi_power_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -543,15 +544,11 @@ static int acpi_power_add_fs(struct acpi_device *device) ...@@ -543,15 +544,11 @@ static int acpi_power_add_fs(struct acpi_device *device)
} }
/* 'status' [R] */ /* 'status' [R] */
entry = create_proc_entry(ACPI_POWER_FILE_STATUS, entry = proc_create_data(ACPI_POWER_FILE_STATUS,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_power_fops, acpi_driver_data(device));
if (!entry) if (!entry)
return -EIO; return -EIO;
else {
entry->proc_fops = &acpi_power_fops;
entry->data = acpi_driver_data(device);
}
return 0; return 0;
} }
......
...@@ -112,6 +112,7 @@ static struct acpi_driver acpi_processor_driver = { ...@@ -112,6 +112,7 @@ static struct acpi_driver acpi_processor_driver = {
#define UNINSTALL_NOTIFY_HANDLER 2 #define UNINSTALL_NOTIFY_HANDLER 2
static const struct file_operations acpi_processor_info_fops = { static const struct file_operations acpi_processor_info_fops = {
.owner = THIS_MODULE,
.open = acpi_processor_info_open_fs, .open = acpi_processor_info_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -326,40 +327,30 @@ static int acpi_processor_add_fs(struct acpi_device *device) ...@@ -326,40 +327,30 @@ static int acpi_processor_add_fs(struct acpi_device *device)
acpi_device_dir(device)->owner = THIS_MODULE; acpi_device_dir(device)->owner = THIS_MODULE;
/* 'info' [R] */ /* 'info' [R] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_processor_info_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -EIO; return -EIO;
else {
entry->proc_fops = &acpi_processor_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'throttling' [R/W] */ /* 'throttling' [R/W] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING,
S_IFREG | S_IRUGO | S_IWUSR, S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_processor_throttling_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -EIO; return -EIO;
else {
entry->proc_fops = &acpi_processor_throttling_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'limit' [R/W] */ /* 'limit' [R/W] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT,
S_IFREG | S_IRUGO | S_IWUSR, S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_processor_limit_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -EIO; return -EIO;
else {
entry->proc_fops = &acpi_processor_limit_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
......
...@@ -1282,6 +1282,7 @@ static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) ...@@ -1282,6 +1282,7 @@ static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
} }
static const struct file_operations acpi_processor_power_fops = { static const struct file_operations acpi_processor_power_fops = {
.owner = THIS_MODULE,
.open = acpi_processor_power_open_fs, .open = acpi_processor_power_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -1822,16 +1823,12 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, ...@@ -1822,16 +1823,12 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
} }
/* 'power' [R] */ /* 'power' [R] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, entry = proc_create_data(ACPI_PROCESSOR_FILE_POWER,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_processor_power_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -EIO; return -EIO;
else {
entry->proc_fops = &acpi_processor_power_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
......
...@@ -411,6 +411,7 @@ EXPORT_SYMBOL(acpi_processor_notify_smm); ...@@ -411,6 +411,7 @@ EXPORT_SYMBOL(acpi_processor_notify_smm);
static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file); static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_processor_perf_fops = { static struct file_operations acpi_processor_perf_fops = {
.owner = THIS_MODULE,
.open = acpi_processor_perf_open_fs, .open = acpi_processor_perf_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -456,7 +457,6 @@ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) ...@@ -456,7 +457,6 @@ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
static void acpi_cpufreq_add_file(struct acpi_processor *pr) static void acpi_cpufreq_add_file(struct acpi_processor *pr)
{ {
struct proc_dir_entry *entry = NULL;
struct acpi_device *device = NULL; struct acpi_device *device = NULL;
...@@ -464,14 +464,9 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr) ...@@ -464,14 +464,9 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
return; return;
/* add file 'performance' [R/W] */ /* add file 'performance' [R/W] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO,
S_IFREG | S_IRUGO, acpi_device_dir(device),
acpi_device_dir(device)); &acpi_processor_perf_fops, acpi_driver_data(device));
if (entry){
entry->proc_fops = &acpi_processor_perf_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return; return;
} }
......
...@@ -509,6 +509,7 @@ static ssize_t acpi_processor_write_limit(struct file * file, ...@@ -509,6 +509,7 @@ static ssize_t acpi_processor_write_limit(struct file * file,
} }
struct file_operations acpi_processor_limit_fops = { struct file_operations acpi_processor_limit_fops = {
.owner = THIS_MODULE,
.open = acpi_processor_limit_open_fs, .open = acpi_processor_limit_open_fs,
.read = seq_read, .read = seq_read,
.write = acpi_processor_write_limit, .write = acpi_processor_write_limit,
......
...@@ -1252,6 +1252,7 @@ static ssize_t acpi_processor_write_throttling(struct file *file, ...@@ -1252,6 +1252,7 @@ static ssize_t acpi_processor_write_throttling(struct file *file,
} }
struct file_operations acpi_processor_throttling_fops = { struct file_operations acpi_processor_throttling_fops = {
.owner = THIS_MODULE,
.open = acpi_processor_throttling_open_fs, .open = acpi_processor_throttling_open_fs,
.read = seq_read, .read = seq_read,
.write = acpi_processor_write_throttling, .write = acpi_processor_write_throttling,
......
...@@ -483,8 +483,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, ...@@ -483,8 +483,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
struct file_operations *state_fops, struct file_operations *state_fops,
struct file_operations *alarm_fops, void *data) struct file_operations *alarm_fops, void *data)
{ {
struct proc_dir_entry *entry = NULL;
if (!*dir) { if (!*dir) {
*dir = proc_mkdir(dir_name, parent_dir); *dir = proc_mkdir(dir_name, parent_dir);
if (!*dir) { if (!*dir) {
...@@ -494,34 +492,19 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, ...@@ -494,34 +492,19 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
} }
/* 'info' [R] */ /* 'info' [R] */
if (info_fops) { if (info_fops)
entry = create_proc_entry(ACPI_SBS_FILE_INFO, S_IRUGO, *dir); proc_create_data(ACPI_SBS_FILE_INFO, S_IRUGO, *dir,
if (entry) { info_fops, data);
entry->proc_fops = info_fops;
entry->data = data;
entry->owner = THIS_MODULE;
}
}
/* 'state' [R] */ /* 'state' [R] */
if (state_fops) { if (state_fops)
entry = create_proc_entry(ACPI_SBS_FILE_STATE, S_IRUGO, *dir); proc_create_data(ACPI_SBS_FILE_STATE, S_IRUGO, *dir,
if (entry) { state_fops, data);
entry->proc_fops = state_fops;
entry->data = data;
entry->owner = THIS_MODULE;
}
}
/* 'alarm' [R/W] */ /* 'alarm' [R/W] */
if (alarm_fops) { if (alarm_fops)
entry = create_proc_entry(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir); proc_create_data(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir,
if (entry) { alarm_fops, data);
entry->proc_fops = alarm_fops;
entry->data = data;
entry->owner = THIS_MODULE;
}
}
return 0; return 0;
} }
......
...@@ -440,6 +440,7 @@ acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) ...@@ -440,6 +440,7 @@ acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
} }
static const struct file_operations acpi_system_wakeup_device_fops = { static const struct file_operations acpi_system_wakeup_device_fops = {
.owner = THIS_MODULE,
.open = acpi_system_wakeup_device_open_fs, .open = acpi_system_wakeup_device_open_fs,
.read = seq_read, .read = seq_read,
.write = acpi_system_write_wakeup_device, .write = acpi_system_write_wakeup_device,
...@@ -449,6 +450,7 @@ static const struct file_operations acpi_system_wakeup_device_fops = { ...@@ -449,6 +450,7 @@ static const struct file_operations acpi_system_wakeup_device_fops = {
#ifdef CONFIG_ACPI_PROCFS #ifdef CONFIG_ACPI_PROCFS
static const struct file_operations acpi_system_sleep_fops = { static const struct file_operations acpi_system_sleep_fops = {
.owner = THIS_MODULE,
.open = acpi_system_sleep_open_fs, .open = acpi_system_sleep_open_fs,
.read = seq_read, .read = seq_read,
.write = acpi_system_write_sleep, .write = acpi_system_write_sleep,
...@@ -459,6 +461,7 @@ static const struct file_operations acpi_system_sleep_fops = { ...@@ -459,6 +461,7 @@ static const struct file_operations acpi_system_sleep_fops = {
#ifdef HAVE_ACPI_LEGACY_ALARM #ifdef HAVE_ACPI_LEGACY_ALARM
static const struct file_operations acpi_system_alarm_fops = { static const struct file_operations acpi_system_alarm_fops = {
.owner = THIS_MODULE,
.open = acpi_system_alarm_open_fs, .open = acpi_system_alarm_open_fs,
.read = seq_read, .read = seq_read,
.write = acpi_system_write_alarm, .write = acpi_system_write_alarm,
...@@ -477,37 +480,26 @@ static u32 rtc_handler(void *context) ...@@ -477,37 +480,26 @@ static u32 rtc_handler(void *context)
static int __init acpi_sleep_proc_init(void) static int __init acpi_sleep_proc_init(void)
{ {
struct proc_dir_entry *entry = NULL;
if (acpi_disabled) if (acpi_disabled)
return 0; return 0;
#ifdef CONFIG_ACPI_PROCFS #ifdef CONFIG_ACPI_PROCFS
/* 'sleep' [R/W] */ /* 'sleep' [R/W] */
entry = proc_create("sleep", S_IFREG | S_IRUGO | S_IWUSR,
create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR, acpi_root_dir, &acpi_system_sleep_fops);
acpi_root_dir);
if (entry)
entry->proc_fops = &acpi_system_sleep_fops;
#endif /* CONFIG_ACPI_PROCFS */ #endif /* CONFIG_ACPI_PROCFS */
#ifdef HAVE_ACPI_LEGACY_ALARM #ifdef HAVE_ACPI_LEGACY_ALARM
/* 'alarm' [R/W] */ /* 'alarm' [R/W] */
entry = proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR,
create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR, acpi_root_dir, &acpi_system_alarm_fops);
acpi_root_dir);
if (entry)
entry->proc_fops = &acpi_system_alarm_fops;
acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL); acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
#endif /* HAVE_ACPI_LEGACY_ALARM */ #endif /* HAVE_ACPI_LEGACY_ALARM */
/* 'wakeup device' [R/W] */ /* 'wakeup device' [R/W] */
entry = proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR, acpi_root_dir, &acpi_system_wakeup_device_fops);
acpi_root_dir);
if (entry)
entry->proc_fops = &acpi_system_wakeup_device_fops;
return 0; return 0;
} }
......
...@@ -396,6 +396,7 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file) ...@@ -396,6 +396,7 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
} }
static const struct file_operations acpi_system_info_ops = { static const struct file_operations acpi_system_info_ops = {
.owner = THIS_MODULE,
.open = acpi_system_info_open_fs, .open = acpi_system_info_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -406,6 +407,7 @@ static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, ...@@ -406,6 +407,7 @@ static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
loff_t *); loff_t *);
static const struct file_operations acpi_system_dsdt_ops = { static const struct file_operations acpi_system_dsdt_ops = {
.owner = THIS_MODULE,
.read = acpi_system_read_dsdt, .read = acpi_system_read_dsdt,
}; };
...@@ -430,6 +432,7 @@ static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, ...@@ -430,6 +432,7 @@ static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
loff_t *); loff_t *);
static const struct file_operations acpi_system_fadt_ops = { static const struct file_operations acpi_system_fadt_ops = {
.owner = THIS_MODULE,
.read = acpi_system_read_fadt, .read = acpi_system_read_fadt,
}; };
...@@ -454,31 +457,23 @@ static int acpi_system_procfs_init(void) ...@@ -454,31 +457,23 @@ static int acpi_system_procfs_init(void)
{ {
struct proc_dir_entry *entry; struct proc_dir_entry *entry;
int error = 0; int error = 0;
char *name;
/* 'info' [R] */ /* 'info' [R] */
name = ACPI_SYSTEM_FILE_INFO; entry = proc_create(ACPI_SYSTEM_FILE_INFO, S_IRUGO, acpi_root_dir,
entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); &acpi_system_info_ops);
if (!entry) if (!entry)
goto Error; goto Error;
else {
entry->proc_fops = &acpi_system_info_ops;
}
/* 'dsdt' [R] */ /* 'dsdt' [R] */
name = ACPI_SYSTEM_FILE_DSDT; entry = proc_create(ACPI_SYSTEM_FILE_DSDT, S_IRUSR, acpi_root_dir,
entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); &acpi_system_dsdt_ops);
if (entry) if (!entry)
entry->proc_fops = &acpi_system_dsdt_ops;
else
goto Error; goto Error;
/* 'fadt' [R] */ /* 'fadt' [R] */
name = ACPI_SYSTEM_FILE_FADT; entry = proc_create(ACPI_SYSTEM_FILE_FADT, S_IRUSR, acpi_root_dir,
entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); &acpi_system_fadt_ops);
if (entry) if (!entry)
entry->proc_fops = &acpi_system_fadt_ops;
else
goto Error; goto Error;
Done: Done:
......
...@@ -198,6 +198,7 @@ struct acpi_thermal { ...@@ -198,6 +198,7 @@ struct acpi_thermal {
}; };
static const struct file_operations acpi_thermal_state_fops = { static const struct file_operations acpi_thermal_state_fops = {
.owner = THIS_MODULE,
.open = acpi_thermal_state_open_fs, .open = acpi_thermal_state_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -205,6 +206,7 @@ static const struct file_operations acpi_thermal_state_fops = { ...@@ -205,6 +206,7 @@ static const struct file_operations acpi_thermal_state_fops = {
}; };
static const struct file_operations acpi_thermal_temp_fops = { static const struct file_operations acpi_thermal_temp_fops = {
.owner = THIS_MODULE,
.open = acpi_thermal_temp_open_fs, .open = acpi_thermal_temp_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -212,6 +214,7 @@ static const struct file_operations acpi_thermal_temp_fops = { ...@@ -212,6 +214,7 @@ static const struct file_operations acpi_thermal_temp_fops = {
}; };
static const struct file_operations acpi_thermal_trip_fops = { static const struct file_operations acpi_thermal_trip_fops = {
.owner = THIS_MODULE,
.open = acpi_thermal_trip_open_fs, .open = acpi_thermal_trip_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -219,6 +222,7 @@ static const struct file_operations acpi_thermal_trip_fops = { ...@@ -219,6 +222,7 @@ static const struct file_operations acpi_thermal_trip_fops = {
}; };
static const struct file_operations acpi_thermal_cooling_fops = { static const struct file_operations acpi_thermal_cooling_fops = {
.owner = THIS_MODULE,
.open = acpi_thermal_cooling_open_fs, .open = acpi_thermal_cooling_open_fs,
.read = seq_read, .read = seq_read,
.write = acpi_thermal_write_cooling_mode, .write = acpi_thermal_write_cooling_mode,
...@@ -227,6 +231,7 @@ static const struct file_operations acpi_thermal_cooling_fops = { ...@@ -227,6 +231,7 @@ static const struct file_operations acpi_thermal_cooling_fops = {
}; };
static const struct file_operations acpi_thermal_polling_fops = { static const struct file_operations acpi_thermal_polling_fops = {
.owner = THIS_MODULE,
.open = acpi_thermal_polling_open_fs, .open = acpi_thermal_polling_open_fs,
.read = seq_read, .read = seq_read,
.write = acpi_thermal_write_polling, .write = acpi_thermal_write_polling,
...@@ -1419,63 +1424,47 @@ static int acpi_thermal_add_fs(struct acpi_device *device) ...@@ -1419,63 +1424,47 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
} }
/* 'state' [R] */ /* 'state' [R] */
entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, entry = proc_create_data(ACPI_THERMAL_FILE_STATE,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_thermal_state_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_thermal_state_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'temperature' [R] */ /* 'temperature' [R] */
entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, entry = proc_create_data(ACPI_THERMAL_FILE_TEMPERATURE,
S_IRUGO, acpi_device_dir(device)); S_IRUGO, acpi_device_dir(device),
&acpi_thermal_temp_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_thermal_temp_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'trip_points' [R] */ /* 'trip_points' [R] */
entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, entry = proc_create_data(ACPI_THERMAL_FILE_TRIP_POINTS,
S_IRUGO, S_IRUGO,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_thermal_trip_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_thermal_trip_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'cooling_mode' [R/W] */ /* 'cooling_mode' [R/W] */
entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, entry = proc_create_data(ACPI_THERMAL_FILE_COOLING_MODE,
S_IFREG | S_IRUGO | S_IWUSR, S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_thermal_cooling_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_thermal_cooling_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'polling_frequency' [R/W] */ /* 'polling_frequency' [R/W] */
entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, entry = proc_create_data(ACPI_THERMAL_FILE_POLLING_FREQ,
S_IFREG | S_IRUGO | S_IWUSR, S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_thermal_polling_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_thermal_polling_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
......
...@@ -192,6 +192,7 @@ struct acpi_video_device { ...@@ -192,6 +192,7 @@ struct acpi_video_device {
/* bus */ /* bus */
static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_info_fops = { static struct file_operations acpi_video_bus_info_fops = {
.owner = THIS_MODULE,
.open = acpi_video_bus_info_open_fs, .open = acpi_video_bus_info_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -200,6 +201,7 @@ static struct file_operations acpi_video_bus_info_fops = { ...@@ -200,6 +201,7 @@ static struct file_operations acpi_video_bus_info_fops = {
static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file); static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_ROM_fops = { static struct file_operations acpi_video_bus_ROM_fops = {
.owner = THIS_MODULE,
.open = acpi_video_bus_ROM_open_fs, .open = acpi_video_bus_ROM_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -209,6 +211,7 @@ static struct file_operations acpi_video_bus_ROM_fops = { ...@@ -209,6 +211,7 @@ static struct file_operations acpi_video_bus_ROM_fops = {
static int acpi_video_bus_POST_info_open_fs(struct inode *inode, static int acpi_video_bus_POST_info_open_fs(struct inode *inode,
struct file *file); struct file *file);
static struct file_operations acpi_video_bus_POST_info_fops = { static struct file_operations acpi_video_bus_POST_info_fops = {
.owner = THIS_MODULE,
.open = acpi_video_bus_POST_info_open_fs, .open = acpi_video_bus_POST_info_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -217,6 +220,7 @@ static struct file_operations acpi_video_bus_POST_info_fops = { ...@@ -217,6 +220,7 @@ static struct file_operations acpi_video_bus_POST_info_fops = {
static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file); static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_POST_fops = { static struct file_operations acpi_video_bus_POST_fops = {
.owner = THIS_MODULE,
.open = acpi_video_bus_POST_open_fs, .open = acpi_video_bus_POST_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -225,6 +229,7 @@ static struct file_operations acpi_video_bus_POST_fops = { ...@@ -225,6 +229,7 @@ static struct file_operations acpi_video_bus_POST_fops = {
static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file); static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
static struct file_operations acpi_video_bus_DOS_fops = { static struct file_operations acpi_video_bus_DOS_fops = {
.owner = THIS_MODULE,
.open = acpi_video_bus_DOS_open_fs, .open = acpi_video_bus_DOS_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -235,6 +240,7 @@ static struct file_operations acpi_video_bus_DOS_fops = { ...@@ -235,6 +240,7 @@ static struct file_operations acpi_video_bus_DOS_fops = {
static int acpi_video_device_info_open_fs(struct inode *inode, static int acpi_video_device_info_open_fs(struct inode *inode,
struct file *file); struct file *file);
static struct file_operations acpi_video_device_info_fops = { static struct file_operations acpi_video_device_info_fops = {
.owner = THIS_MODULE,
.open = acpi_video_device_info_open_fs, .open = acpi_video_device_info_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -244,6 +250,7 @@ static struct file_operations acpi_video_device_info_fops = { ...@@ -244,6 +250,7 @@ static struct file_operations acpi_video_device_info_fops = {
static int acpi_video_device_state_open_fs(struct inode *inode, static int acpi_video_device_state_open_fs(struct inode *inode,
struct file *file); struct file *file);
static struct file_operations acpi_video_device_state_fops = { static struct file_operations acpi_video_device_state_fops = {
.owner = THIS_MODULE,
.open = acpi_video_device_state_open_fs, .open = acpi_video_device_state_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -253,6 +260,7 @@ static struct file_operations acpi_video_device_state_fops = { ...@@ -253,6 +260,7 @@ static struct file_operations acpi_video_device_state_fops = {
static int acpi_video_device_brightness_open_fs(struct inode *inode, static int acpi_video_device_brightness_open_fs(struct inode *inode,
struct file *file); struct file *file);
static struct file_operations acpi_video_device_brightness_fops = { static struct file_operations acpi_video_device_brightness_fops = {
.owner = THIS_MODULE,
.open = acpi_video_device_brightness_open_fs, .open = acpi_video_device_brightness_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -262,6 +270,7 @@ static struct file_operations acpi_video_device_brightness_fops = { ...@@ -262,6 +270,7 @@ static struct file_operations acpi_video_device_brightness_fops = {
static int acpi_video_device_EDID_open_fs(struct inode *inode, static int acpi_video_device_EDID_open_fs(struct inode *inode,
struct file *file); struct file *file);
static struct file_operations acpi_video_device_EDID_fops = { static struct file_operations acpi_video_device_EDID_fops = {
.owner = THIS_MODULE,
.open = acpi_video_device_EDID_open_fs, .open = acpi_video_device_EDID_open_fs,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
...@@ -1070,51 +1079,36 @@ static int acpi_video_device_add_fs(struct acpi_device *device) ...@@ -1070,51 +1079,36 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
} }
/* 'info' [R] */ /* 'info' [R] */
entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device),
&acpi_video_device_info_fops, acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_video_device_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'state' [R/W] */ /* 'state' [R/W] */
entry = acpi_video_device_state_fops.write = acpi_video_device_write_state;
create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, entry = proc_create_data("state", S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_video_device_state_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
acpi_video_device_state_fops.write = acpi_video_device_write_state;
entry->proc_fops = &acpi_video_device_state_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'brightness' [R/W] */ /* 'brightness' [R/W] */
entry = acpi_video_device_brightness_fops.write =
create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, acpi_video_device_write_brightness;
acpi_device_dir(device)); entry = proc_create_data("brightness", S_IFREG | S_IRUGO | S_IWUSR,
acpi_device_dir(device),
&acpi_video_device_brightness_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
entry->proc_fops = &acpi_video_device_brightness_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'EDID' [R] */ /* 'EDID' [R] */
entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); entry = proc_create_data("EDID", S_IRUGO, acpi_device_dir(device),
&acpi_video_device_EDID_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_video_device_EDID_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
...@@ -1353,61 +1347,43 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) ...@@ -1353,61 +1347,43 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
} }
/* 'info' [R] */ /* 'info' [R] */
entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device),
&acpi_video_bus_info_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_video_bus_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'ROM' [R] */ /* 'ROM' [R] */
entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); entry = proc_create_data("ROM", S_IRUGO, acpi_device_dir(device),
&acpi_video_bus_ROM_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_video_bus_ROM_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'POST_info' [R] */ /* 'POST_info' [R] */
entry = entry = proc_create_data("POST_info", S_IRUGO, acpi_device_dir(device),
create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); &acpi_video_bus_POST_info_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
entry->proc_fops = &acpi_video_bus_POST_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'POST' [R/W] */ /* 'POST' [R/W] */
entry = acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, entry = proc_create_data("POST", S_IFREG | S_IRUGO | S_IRUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_video_bus_POST_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
entry->proc_fops = &acpi_video_bus_POST_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'DOS' [R/W] */ /* 'DOS' [R/W] */
entry = acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, entry = proc_create_data("DOS", S_IFREG | S_IRUGO | S_IRUSR,
acpi_device_dir(device)); acpi_device_dir(device),
&acpi_video_bus_DOS_fops,
acpi_driver_data(device));
if (!entry) if (!entry)
return -ENODEV; return -ENODEV;
else {
acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
entry->proc_fops = &acpi_video_bus_DOS_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment