Linux 5.6 compat: proc_ops

This commit is contained in:
Rin Cat 2020-04-07 15:38:14 -04:00
parent 5745458012
commit dcd70bfeaa

View File

@ -62,17 +62,27 @@ inline struct proc_dir_entry *rtw_proc_create_dir(const char *name, struct proc_
} }
inline struct proc_dir_entry *rtw_proc_create_entry(const char *name, struct proc_dir_entry *parent, inline struct proc_dir_entry *rtw_proc_create_entry(const char *name, struct proc_dir_entry *parent,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
const struct proc_ops *proc_ops, void * data)
#else
const struct file_operations *fops, void * data) const struct file_operations *fops, void * data)
#endif
{ {
struct proc_dir_entry *entry; struct proc_dir_entry *entry;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUGO, parent, proc_ops, data);
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26))
entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUGO, parent, fops, data); entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUGO, parent, fops, data);
#else #else
entry = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUGO, parent); entry = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUGO, parent);
if (entry) { if (entry) {
entry->data = data; entry->data = data;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
entry->proc_ops = proc_ops;
#else
entry->proc_fops = fops; entry->proc_fops = fops;
#endif
} }
#endif #endif
@ -238,6 +248,15 @@ static ssize_t rtw_drv_proc_write(struct file *file, const char __user *buffer,
return -EROFS; return -EROFS;
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
static const struct proc_ops rtw_drv_proc_seq_fops = {
.proc_open = rtw_drv_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = seq_release,
.proc_write = rtw_drv_proc_write,
};
#else
static const struct file_operations rtw_drv_proc_seq_fops = { static const struct file_operations rtw_drv_proc_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rtw_drv_proc_open, .open = rtw_drv_proc_open,
@ -246,7 +265,17 @@ static const struct file_operations rtw_drv_proc_seq_fops = {
.release = seq_release, .release = seq_release,
.write = rtw_drv_proc_write, .write = rtw_drv_proc_write,
}; };
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
static const struct proc_ops rtw_drv_proc_sseq_fops = {
.proc_open = rtw_drv_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
.proc_write = rtw_drv_proc_write,
};
#else
static const struct file_operations rtw_drv_proc_sseq_fops = { static const struct file_operations rtw_drv_proc_sseq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rtw_drv_proc_open, .open = rtw_drv_proc_open,
@ -255,6 +284,7 @@ static const struct file_operations rtw_drv_proc_sseq_fops = {
.release = single_release, .release = single_release,
.write = rtw_drv_proc_write, .write = rtw_drv_proc_write,
}; };
#endif
int rtw_drv_proc_init(void) int rtw_drv_proc_init(void)
{ {
@ -4139,6 +4169,15 @@ static ssize_t rtw_adapter_proc_write(struct file *file, const char __user *buff
return -EROFS; return -EROFS;
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
static const struct proc_ops rtw_adapter_proc_seq_fops = {
.proc_open = rtw_adapter_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = seq_release,
.proc_write = rtw_adapter_proc_write,
};
#else
static const struct file_operations rtw_adapter_proc_seq_fops = { static const struct file_operations rtw_adapter_proc_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rtw_adapter_proc_open, .open = rtw_adapter_proc_open,
@ -4147,7 +4186,17 @@ static const struct file_operations rtw_adapter_proc_seq_fops = {
.release = seq_release, .release = seq_release,
.write = rtw_adapter_proc_write, .write = rtw_adapter_proc_write,
}; };
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
static const struct proc_ops rtw_adapter_proc_sseq_fops = {
.proc_open = rtw_adapter_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
.proc_write = rtw_adapter_proc_write,
};
#else
static const struct file_operations rtw_adapter_proc_sseq_fops = { static const struct file_operations rtw_adapter_proc_sseq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rtw_adapter_proc_open, .open = rtw_adapter_proc_open,
@ -4156,6 +4205,7 @@ static const struct file_operations rtw_adapter_proc_sseq_fops = {
.release = single_release, .release = single_release,
.write = rtw_adapter_proc_write, .write = rtw_adapter_proc_write,
}; };
#endif
int proc_get_odm_adaptivity(struct seq_file *m, void *v) int proc_get_odm_adaptivity(struct seq_file *m, void *v)
{ {
@ -4308,6 +4358,15 @@ static ssize_t rtw_odm_proc_write(struct file *file, const char __user *buffer,
return -EROFS; return -EROFS;
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
static const struct proc_ops rtw_odm_proc_seq_fops = {
.proc_open = rtw_odm_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = seq_release,
.proc_write = rtw_odm_proc_write,
};
#else
static const struct file_operations rtw_odm_proc_seq_fops = { static const struct file_operations rtw_odm_proc_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rtw_odm_proc_open, .open = rtw_odm_proc_open,
@ -4316,7 +4375,17 @@ static const struct file_operations rtw_odm_proc_seq_fops = {
.release = seq_release, .release = seq_release,
.write = rtw_odm_proc_write, .write = rtw_odm_proc_write,
}; };
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
static const struct proc_ops rtw_odm_proc_sseq_fops = {
.proc_open = rtw_odm_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
.proc_write = rtw_odm_proc_write,
};
#else
static const struct file_operations rtw_odm_proc_sseq_fops = { static const struct file_operations rtw_odm_proc_sseq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rtw_odm_proc_open, .open = rtw_odm_proc_open,
@ -4325,6 +4394,7 @@ static const struct file_operations rtw_odm_proc_sseq_fops = {
.release = single_release, .release = single_release,
.write = rtw_odm_proc_write, .write = rtw_odm_proc_write,
}; };
#endif
struct proc_dir_entry *rtw_odm_proc_init(struct net_device *dev) struct proc_dir_entry *rtw_odm_proc_init(struct net_device *dev)
{ {