Linux 5.6 compat: proc_ops

This commit is contained in:
Rin Cat 2020-04-07 15:38:14 -04:00
parent 254bf7b657
commit 9136edaaca

View File

@ -81,17 +81,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,
#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)
#endif
{
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);
#else
entry = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUGO, parent);
if (entry) {
entry->data = data;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
entry->proc_ops = proc_ops;
#else
entry->proc_fops = fops;
#endif
}
#endif
@ -261,6 +271,15 @@ static ssize_t rtw_drv_proc_write(struct file *file, const char __user *buffer,
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 = {
.owner = THIS_MODULE,
.open = rtw_drv_proc_open,
@ -269,7 +288,17 @@ static const struct file_operations rtw_drv_proc_seq_fops = {
.release = seq_release,
.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 = {
.owner = THIS_MODULE,
.open = rtw_drv_proc_open,
@ -278,6 +307,7 @@ static const struct file_operations rtw_drv_proc_sseq_fops = {
.release = single_release,
.write = rtw_drv_proc_write,
};
#endif
int rtw_drv_proc_init(void)
{
@ -4778,6 +4808,15 @@ static ssize_t rtw_adapter_proc_write(struct file *file, const char __user *buff
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 = {
.owner = THIS_MODULE,
.open = rtw_adapter_proc_open,
@ -4786,7 +4825,17 @@ static const struct file_operations rtw_adapter_proc_seq_fops = {
.release = seq_release,
.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 = {
.owner = THIS_MODULE,
.open = rtw_adapter_proc_open,
@ -4795,6 +4844,7 @@ static const struct file_operations rtw_adapter_proc_sseq_fops = {
.release = single_release,
.write = rtw_adapter_proc_write,
};
#endif
int proc_get_odm_adaptivity(struct seq_file *m, void *v)
{
@ -4951,6 +5001,15 @@ static ssize_t rtw_odm_proc_write(struct file *file, const char __user *buffer,
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 = {
.owner = THIS_MODULE,
.open = rtw_odm_proc_open,
@ -4959,7 +5018,17 @@ static const struct file_operations rtw_odm_proc_seq_fops = {
.release = seq_release,
.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 = {
.owner = THIS_MODULE,
.open = rtw_odm_proc_open,
@ -4968,6 +5037,7 @@ static const struct file_operations rtw_odm_proc_sseq_fops = {
.release = single_release,
.write = rtw_odm_proc_write,
};
#endif
struct proc_dir_entry *rtw_odm_proc_init(struct net_device *dev)
{