Skip to content

Commit

Permalink
Fixed 3.9 compilation issue stec-inc#107.
Browse files Browse the repository at this point in the history
PDE_DATA is introduced from Kernel 3.10.
create_proc_entry() no more supported from kernel 3.10.

Handled both cases. Now, code will run from Kernel 2.6.32 to 4.2.

Signed-off-by: Deepen Mehta <[email protected]>
  • Loading branch information
deepenmehta85 committed Oct 29, 2015
1 parent dd53a04 commit 03b9d86
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions Driver/enhanceio/eio_procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,24 @@
#define ENHANCEIO_GIT_COMMIT_HASH "unknown-git-version"
#endif /* !ENHANCEIO_GIT_COMMIT_HASH */

int eio_version_query(size_t buf_sz, char *bufp)
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 9, 0))
#define PROC_CREATE(ent, name, mode, parent, fops, data) \
(ent = proc_create_data(name, mode, parent, fops, data))
#define KPDE_DATA(idxnode) PDE_DATA(idxnode)
#else
#define PROC_CREATE(ent, name, mode, parent, fops, data) \
do { \
ent = create_proc_entry(name, mode, parent) \
if (ent) { \
ent->proc_fops = &fops; \
ent->data = data; \
} \
} while (0)
#define KPDE_DATA(idxnode) PDE(idxnode)->data
#endif

int
eio_version_query(size_t buf_sz, char *bufp)
{
if (unlikely(buf_sz == 0) || unlikely(bufp == NULL))
return -EINVAL;
Expand Down Expand Up @@ -1221,8 +1238,8 @@ void eio_module_procfs_init(void)
struct proc_dir_entry *entry;

if (proc_mkdir(PROC_STR, NULL)) {
entry = proc_create_data(PROC_VER_STR, 0, NULL,
&eio_version_operations, NULL);
PROC_CREATE(entry, PROC_VER_STR, 0, NULL,
&eio_version_operations, NULL);
}
eio_sysctl_register_dir();
}
Expand Down Expand Up @@ -1255,19 +1272,19 @@ void eio_procfs_ctr(struct cache_c *dmc)
}

s = eio_cons_procfs_cachename(dmc, PROC_STATS);
entry = proc_create_data(s, 0, NULL, &eio_stats_operations, dmc);
PROC_CREATE(entry, s, 0, NULL, &eio_stats_operations, dmc);
kfree(s);

s = eio_cons_procfs_cachename(dmc, PROC_ERRORS);
entry = proc_create_data(s, 0, NULL, &eio_errors_operations, dmc);
PROC_CREATE(entry, s, 0, NULL, &eio_errors_operations, dmc);
kfree(s);

s = eio_cons_procfs_cachename(dmc, PROC_IOSZ_HIST);
entry = proc_create_data(s, 0, NULL, &eio_iosize_hist_operations, dmc);
PROC_CREATE(entry, s, 0, NULL, &eio_iosize_hist_operations, dmc);
kfree(s);

s = eio_cons_procfs_cachename(dmc, PROC_CONFIG);
entry = proc_create_data(s, 0, NULL, &eio_config_operations, dmc);
PROC_CREATE(entry, s, 0, NULL, &eio_config_operations, dmc);
kfree(s);

eio_sysctl_register_common(dmc);
Expand Down Expand Up @@ -1800,7 +1817,7 @@ static int eio_stats_show(struct seq_file *seq, void *v)
*/
static int eio_stats_open(struct inode *inode, struct file *file)
{
return single_open(file, &eio_stats_show, PDE_DATA(inode));
return single_open(file, &eio_stats_show, KPDE_DATA(inode));
}

/*
Expand Down Expand Up @@ -1833,7 +1850,7 @@ static int eio_errors_show(struct seq_file *seq, void *v)
*/
static int eio_errors_open(struct inode *inode, struct file *file)
{
return single_open(file, &eio_errors_show, PDE_DATA(inode));
return single_open(file, &eio_errors_show, KPDE_DATA(inode));
}

/*
Expand Down Expand Up @@ -1868,7 +1885,7 @@ static int eio_iosize_hist_show(struct seq_file *seq, void *v)
static int eio_iosize_hist_open(struct inode *inode, struct file *file)
{

return single_open(file, &eio_iosize_hist_show, PDE_DATA(inode));
return single_open(file, &eio_iosize_hist_show, KPDE_DATA(inode));
}

/*
Expand All @@ -1890,7 +1907,7 @@ static int eio_version_show(struct seq_file *seq, void *v)
*/
static int eio_version_open(struct inode *inode, struct file *file)
{
return single_open(file, &eio_version_show, PDE_DATA(inode));
return single_open(file, &eio_version_show, KPDE_DATA(inode));
}

/*
Expand Down Expand Up @@ -1927,5 +1944,5 @@ static int eio_config_show(struct seq_file *seq, void *v)
static int eio_config_open(struct inode *inode, struct file *file)
{

return single_open(file, &eio_config_show, PDE_DATA(inode));
return single_open(file, &eio_config_show, KPDE_DATA(inode));
}

0 comments on commit 03b9d86

Please sign in to comment.