Skip to content

Commit

Permalink
procfs: new helper - PDE_DATA(inode)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Al Viro committed Apr 9, 2013
1 parent 8510e30 commit d9dda78
Show file tree
Hide file tree
Showing 95 changed files with 243 additions and 302 deletions.
4 changes: 2 additions & 2 deletions arch/alpha/kernel/srm_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/atags_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 1 addition & 3 deletions arch/blackfin/kernel/cplbinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 5 additions & 13 deletions arch/ia64/kernel/salinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -463,9 +459,7 @@ salinfo_log_new_read(int cpu, struct salinfo_data *data)
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;

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/lasat/picvue_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 8 additions & 11 deletions arch/powerpc/kernel/proc_powerpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,32 +40,31 @@ 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);
}

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;
}

Expand Down
9 changes: 3 additions & 6 deletions arch/powerpc/platforms/pseries/scanlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion arch/sh/mm/alignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/kernel/ioport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion arch/tile/kernel/hardwall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions arch/xtensa/platforms/iss/simdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions drivers/acpi/sbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions drivers/block/DAC960.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/cpqarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,7 @@ static int pkt_seq_show(struct seq_file *m, void *p)

static int pkt_seq_open(struct inode *inode, struct file *file)
{
return single_open(file, pkt_seq_show, PDE(inode)->data);
return single_open(file, pkt_seq_show, PDE_DATA(inode));
}

static const struct file_operations pkt_proc_fops = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/ps3vram.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ static int ps3vram_proc_show(struct seq_file *m, void *v)

static int ps3vram_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, ps3vram_proc_show, PDE(inode)->data);
return single_open(file, ps3vram_proc_show, PDE_DATA(inode));
}

static const struct file_operations ps3vram_proc_fops = {
Expand Down
Loading

0 comments on commit d9dda78

Please sign in to comment.