You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
procfs: new helper - PDE_DATA(inode)
The only part of proc_dir_entry the code outside of fs/proc really cares about is PDE(inode)->data. Provide a helper for that; static inline for now, eventually will be moved to fs/proc, along with the knowledge of struct proc_dir_entry layout. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -104,14 +104,14 @@ static int srm_env_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
static int srm_env_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, srm_env_proc_show, PDE(inode)->data);
|
||||
return single_open(file, srm_env_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
|
||||
size_t count, loff_t *pos)
|
||||
{
|
||||
int res;
|
||||
srm_env_t *entry = PDE(file_inode(file))->data;
|
||||
srm_env_t *entry = PDE_DATA(file_inode(file));
|
||||
char *buf = (char *) __get_free_page(GFP_USER);
|
||||
unsigned long ret1, ret2;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ struct buffer {
|
||||
static ssize_t atags_read(struct file *file, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct buffer *b = PDE(file_inode(file))->data;
|
||||
struct buffer *b = PDE_DATA(file_inode(file));
|
||||
return simple_read_from_buffer(buf, count, ppos, b->data, b->size);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,14 +116,12 @@ static const struct seq_operations cplbinfo_sops = {
|
||||
|
||||
static int cplbinfo_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct proc_dir_entry *pde = PDE(file_inode(file));
|
||||
char cplb_type;
|
||||
unsigned int cpu;
|
||||
unsigned int cpu = (unsigned long)PDE_DATA(file_inode(file));
|
||||
int ret;
|
||||
struct seq_file *m;
|
||||
struct cplbinfo_data *cdata;
|
||||
|
||||
cpu = (unsigned int)pde->data;
|
||||
cplb_type = cpu & CPLBINFO_DCPLB_FLAG ? 'D' : 'I';
|
||||
cpu &= ~CPLBINFO_DCPLB_FLAG;
|
||||
|
||||
|
||||
@@ -301,9 +301,7 @@ salinfo_event_open(struct inode *inode, struct file *file)
|
||||
static ssize_t
|
||||
salinfo_event_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
|
||||
{
|
||||
struct inode *inode = file_inode(file);
|
||||
struct proc_dir_entry *entry = PDE(inode);
|
||||
struct salinfo_data *data = entry->data;
|
||||
struct salinfo_data *data = PDE_DATA(file_inode(file));
|
||||
char cmd[32];
|
||||
size_t size;
|
||||
int i, n, cpu = -1;
|
||||
@@ -360,8 +358,7 @@ static const struct file_operations salinfo_event_fops = {
|
||||
static int
|
||||
salinfo_log_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct proc_dir_entry *entry = PDE(inode);
|
||||
struct salinfo_data *data = entry->data;
|
||||
struct salinfo_data *data = PDE_DATA(inode);
|
||||
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return -EPERM;
|
||||
@@ -386,8 +383,7 @@ salinfo_log_open(struct inode *inode, struct file *file)
|
||||
static int
|
||||
salinfo_log_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct proc_dir_entry *entry = PDE(inode);
|
||||
struct salinfo_data *data = entry->data;
|
||||
struct salinfo_data *data = PDE_DATA(inode);
|
||||
|
||||
if (data->state == STATE_NO_DATA) {
|
||||
vfree(data->log_buffer);
|
||||
@@ -463,9 +459,7 @@ retry:
|
||||
static ssize_t
|
||||
salinfo_log_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
|
||||
{
|
||||
struct inode *inode = file_inode(file);
|
||||
struct proc_dir_entry *entry = PDE(inode);
|
||||
struct salinfo_data *data = entry->data;
|
||||
struct salinfo_data *data = PDE_DATA(file_inode(file));
|
||||
u8 *buf;
|
||||
u64 bufsize;
|
||||
|
||||
@@ -524,9 +518,7 @@ salinfo_log_clear(struct salinfo_data *data, int cpu)
|
||||
static ssize_t
|
||||
salinfo_log_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
|
||||
{
|
||||
struct inode *inode = file_inode(file);
|
||||
struct proc_dir_entry *entry = PDE(inode);
|
||||
struct salinfo_data *data = entry->data;
|
||||
struct salinfo_data *data = PDE_DATA(file_inode(file));
|
||||
char cmd[32];
|
||||
size_t size;
|
||||
u32 offset;
|
||||
|
||||
@@ -58,13 +58,13 @@ static int pvc_line_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
static int pvc_line_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, pvc_line_proc_show, PDE(inode)->data);
|
||||
return single_open(file, pvc_line_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static ssize_t pvc_line_proc_write(struct file *file, const char __user *buf,
|
||||
size_t count, loff_t *pos)
|
||||
{
|
||||
int lineno = *(int *)PDE(file_inode(file))->data;
|
||||
int lineno = *(int *)PDE_DATA(file_inode(file));
|
||||
char kbuf[PVC_LINELEN];
|
||||
size_t len;
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
static loff_t page_map_seek( struct file *file, loff_t off, int whence)
|
||||
{
|
||||
loff_t new;
|
||||
struct proc_dir_entry *dp = PDE(file_inode(file));
|
||||
|
||||
switch(whence) {
|
||||
case 0:
|
||||
new = off;
|
||||
@@ -42,12 +40,12 @@ static loff_t page_map_seek( struct file *file, loff_t off, int whence)
|
||||
new = file->f_pos + off;
|
||||
break;
|
||||
case 2:
|
||||
new = dp->size + off;
|
||||
new = PAGE_SIZE + off;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
if ( new < 0 || new > dp->size )
|
||||
if ( new < 0 || new > PAGE_SIZE )
|
||||
return -EINVAL;
|
||||
return (file->f_pos = new);
|
||||
}
|
||||
@@ -55,19 +53,18 @@ static loff_t page_map_seek( struct file *file, loff_t off, int whence)
|
||||
static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct proc_dir_entry *dp = PDE(file_inode(file));
|
||||
return simple_read_from_buffer(buf, nbytes, ppos, dp->data, dp->size);
|
||||
return simple_read_from_buffer(buf, nbytes, ppos,
|
||||
PDE_DATA(file_inode(file)), PAGE_SIZE);
|
||||
}
|
||||
|
||||
static int page_map_mmap( struct file *file, struct vm_area_struct *vma )
|
||||
{
|
||||
struct proc_dir_entry *dp = PDE(file_inode(file));
|
||||
|
||||
if ((vma->vm_end - vma->vm_start) > dp->size)
|
||||
if ((vma->vm_end - vma->vm_start) > PAGE_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
remap_pfn_range(vma, vma->vm_start, __pa(dp->data) >> PAGE_SHIFT,
|
||||
dp->size, vma->vm_page_prot);
|
||||
remap_pfn_range(vma, vma->vm_start,
|
||||
__pa(PDE_DATA(file_inode(file))) >> PAGE_SHIFT,
|
||||
PAGE_SIZE, vma->vm_page_prot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */
|
||||
static ssize_t scanlog_read(struct file *file, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct proc_dir_entry *dp = PDE(file_inode(file));
|
||||
unsigned int *data = (unsigned int *)dp->data;
|
||||
unsigned int *data = PDE_DATA(file_inode(file));
|
||||
int status;
|
||||
unsigned long len, off;
|
||||
unsigned int wait_time;
|
||||
@@ -135,8 +134,7 @@ static ssize_t scanlog_write(struct file * file, const char __user * buf,
|
||||
|
||||
static int scanlog_open(struct inode * inode, struct file * file)
|
||||
{
|
||||
struct proc_dir_entry *dp = PDE(inode);
|
||||
unsigned int *data = (unsigned int *)dp->data;
|
||||
unsigned int *data = PDE_DATA(file_inode(file));
|
||||
|
||||
if (data[0] != 0) {
|
||||
/* This imperfect test stops a second copy of the
|
||||
@@ -152,8 +150,7 @@ static int scanlog_open(struct inode * inode, struct file * file)
|
||||
|
||||
static int scanlog_release(struct inode * inode, struct file * file)
|
||||
{
|
||||
struct proc_dir_entry *dp = PDE(inode);
|
||||
unsigned int *data = (unsigned int *)dp->data;
|
||||
unsigned int *data = PDE_DATA(file_inode(file));
|
||||
|
||||
data[0] = 0;
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ static int alignment_proc_open(struct inode *inode, struct file *file)
|
||||
static ssize_t alignment_proc_write(struct file *file,
|
||||
const char __user *buffer, size_t count, loff_t *pos)
|
||||
{
|
||||
int *data = PDE(file_inode(file))->data;
|
||||
int *data = PDE_DATA(file_inode(file));
|
||||
char mode;
|
||||
|
||||
if (count > 0) {
|
||||
|
||||
@@ -693,7 +693,7 @@ static int sparc_io_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
static int sparc_io_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, sparc_io_proc_show, PDE(inode)->data);
|
||||
return single_open(file, sparc_io_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations sparc_io_proc_fops = {
|
||||
|
||||
@@ -914,7 +914,7 @@ static int hardwall_proc_show(struct seq_file *sf, void *v)
|
||||
static int hardwall_proc_open(struct inode *inode,
|
||||
struct file *file)
|
||||
{
|
||||
return single_open(file, hardwall_proc_show, PDE(inode)->data);
|
||||
return single_open(file, hardwall_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations hardwall_proc_fops = {
|
||||
|
||||
@@ -217,7 +217,7 @@ static int simdisk_detach(struct simdisk *dev)
|
||||
static ssize_t proc_read_simdisk(struct file *file, char __user *buf,
|
||||
size_t size, loff_t *ppos)
|
||||
{
|
||||
struct simdisk *dev = PDE(file_inode(file))->data;
|
||||
struct simdisk *dev = PDE_DATA(file_inode(file));
|
||||
char *s = dev->filename;
|
||||
if (s) {
|
||||
ssize_t n = simple_read_from_buffer(buf, size, ppos,
|
||||
@@ -234,7 +234,7 @@ static ssize_t proc_write_simdisk(struct file *file, const char __user *buf,
|
||||
size_t size, loff_t *ppos)
|
||||
{
|
||||
char *tmp = kmalloc(count + 1, GFP_KERNEL);
|
||||
struct simdisk *dev = PDE(file_inode(file))->data;
|
||||
struct simdisk *dev = PDE_DATA(file_inode(file));
|
||||
int err;
|
||||
|
||||
if (tmp == NULL)
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
|
||||
|
||||
static int acpi_ac_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_ac_seq_show, PDE(inode)->data);
|
||||
return single_open(file, acpi_ac_seq_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static int acpi_ac_add_fs(struct acpi_device *device)
|
||||
|
||||
@@ -929,7 +929,7 @@ static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \
|
||||
} \
|
||||
static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \
|
||||
{ \
|
||||
return single_open(file, acpi_battery_read_##_name, PDE(inode)->data); \
|
||||
return single_open(file, acpi_battery_read_##_name, PDE_DATA(inode)); \
|
||||
}
|
||||
|
||||
DECLARE_FILE_FUNCTIONS(info);
|
||||
|
||||
@@ -128,7 +128,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
|
||||
|
||||
static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_button_state_seq_show, PDE(inode)->data);
|
||||
return single_open(file, acpi_button_state_seq_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations acpi_button_state_fops = {
|
||||
|
||||
+2
-2
@@ -120,7 +120,7 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
|
||||
|
||||
static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data);
|
||||
return single_open(file, acpi_system_alarm_seq_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static int get_date_field(char **p, u32 * value)
|
||||
@@ -397,7 +397,7 @@ static int
|
||||
acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_system_wakeup_device_seq_show,
|
||||
PDE(inode)->data);
|
||||
PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations acpi_system_wakeup_device_fops = {
|
||||
|
||||
+4
-4
@@ -584,7 +584,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
|
||||
|
||||
static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_battery_read_info, PDE(inode)->data);
|
||||
return single_open(file, acpi_battery_read_info, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static int acpi_battery_read_state(struct seq_file *seq, void *offset)
|
||||
@@ -623,7 +623,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
|
||||
|
||||
static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_battery_read_state, PDE(inode)->data);
|
||||
return single_open(file, acpi_battery_read_state, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
|
||||
@@ -688,7 +688,7 @@ acpi_battery_write_alarm(struct file *file, const char __user * buffer,
|
||||
|
||||
static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
|
||||
return single_open(file, acpi_battery_read_alarm, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations acpi_battery_info_fops = {
|
||||
@@ -736,7 +736,7 @@ static int acpi_ac_read_state(struct seq_file *seq, void *offset)
|
||||
|
||||
static int acpi_ac_state_open_fs(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, acpi_ac_read_state, PDE(inode)->data);
|
||||
return single_open(file, acpi_ac_read_state, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations acpi_ac_state_fops = {
|
||||
|
||||
@@ -6473,7 +6473,7 @@ static int dac960_initial_status_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
static int dac960_initial_status_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, dac960_initial_status_proc_show, PDE(inode)->data);
|
||||
return single_open(file, dac960_initial_status_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations dac960_initial_status_proc_fops = {
|
||||
@@ -6519,7 +6519,7 @@ static int dac960_current_status_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
static int dac960_current_status_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, dac960_current_status_proc_show, PDE(inode)->data);
|
||||
return single_open(file, dac960_current_status_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations dac960_current_status_proc_fops = {
|
||||
@@ -6540,14 +6540,14 @@ static int dac960_user_command_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
static int dac960_user_command_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, dac960_user_command_proc_show, PDE(inode)->data);
|
||||
return single_open(file, dac960_user_command_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static ssize_t dac960_user_command_proc_write(struct file *file,
|
||||
const char __user *Buffer,
|
||||
size_t Count, loff_t *pos)
|
||||
{
|
||||
DAC960_Controller_T *Controller = (DAC960_Controller_T *) PDE(file_inode(file))->data;
|
||||
DAC960_Controller_T *Controller = PDE_DATA(file_inode(file));
|
||||
unsigned char CommandBuffer[80];
|
||||
int Length;
|
||||
if (Count > sizeof(CommandBuffer)-1) return -EINVAL;
|
||||
|
||||
@@ -493,7 +493,7 @@ static int cciss_seq_open(struct inode *inode, struct file *file)
|
||||
struct seq_file *seq = file->private_data;
|
||||
|
||||
if (!ret)
|
||||
seq->private = PDE(inode)->data;
|
||||
seq->private = PDE_DATA(inode);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ static int ida_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
static int ida_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, ida_proc_show, PDE(inode)->data);
|
||||
return single_open(file, ida_proc_show, PDE_DATA(inode));
|
||||
}
|
||||
|
||||
static const struct file_operations ida_proc_fops = {
|
||||
|
||||
@@ -314,7 +314,7 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
|
||||
static int drbd_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
if (try_module_get(THIS_MODULE))
|
||||
return single_open(file, drbd_seq_show, PDE(inode)->data);
|
||||
return single_open(file, drbd_seq_show, PDE_DATA(inode));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user