Commit 483c3fc7 authored by Federico Vaga's avatar Federico Vaga

Merge branch 'hotfix/v2.1.6'

parents fffa8b42 54504913
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
Changelog Changelog
========= =========
2.1.6 - 2021-07-29
==================
Fixed
-----
- sw: improve compatibilty with newer (greater than 3.10) Linux kernel version
2.1.5 - 2021-05-18 2.1.5 - 2021-05-18
================== ==================
Fixed Fixed
......
...@@ -150,7 +150,10 @@ static const struct debugfs_reg32 gn412x_debugfs_reg32[] = { ...@@ -150,7 +150,10 @@ static const struct debugfs_reg32 gn412x_debugfs_reg32[] = {
static int gn4124_dbg_init(struct platform_device *pdev) static int gn4124_dbg_init(struct platform_device *pdev)
{ {
struct gn412x_fcl_dev *gn412x = platform_get_drvdata(pdev); struct gn412x_fcl_dev *gn412x = platform_get_drvdata(pdev);
struct dentry *dir, *file; struct dentry *dir;
#if KERNEL_VERSION(5, 6, 0) > LINUX_VERSION_CODE
struct dentry *file;
#endif
int err; int err;
dir = debugfs_create_dir(dev_name(&pdev->dev), NULL); dir = debugfs_create_dir(dev_name(&pdev->dev), NULL);
...@@ -165,6 +168,10 @@ static int gn4124_dbg_init(struct platform_device *pdev) ...@@ -165,6 +168,10 @@ static int gn4124_dbg_init(struct platform_device *pdev)
gn412x->dbg_reg32.regs = gn412x_debugfs_reg32; gn412x->dbg_reg32.regs = gn412x_debugfs_reg32;
gn412x->dbg_reg32.nregs = ARRAY_SIZE(gn412x_debugfs_reg32); gn412x->dbg_reg32.nregs = ARRAY_SIZE(gn412x_debugfs_reg32);
gn412x->dbg_reg32.base = gn412x->mem; gn412x->dbg_reg32.base = gn412x->mem;
#if KERNEL_VERSION(5, 6, 0) <= LINUX_VERSION_CODE
debugfs_create_regset32(GN412X_DBG_REG_NAME, 0200,
dir, &gn412x->dbg_reg32);
#else
file = debugfs_create_regset32(GN412X_DBG_REG_NAME, 0200, file = debugfs_create_regset32(GN412X_DBG_REG_NAME, 0200,
dir, &gn412x->dbg_reg32); dir, &gn412x->dbg_reg32);
if (IS_ERR_OR_NULL(file)) { if (IS_ERR_OR_NULL(file)) {
...@@ -174,13 +181,16 @@ static int gn4124_dbg_init(struct platform_device *pdev) ...@@ -174,13 +181,16 @@ static int gn4124_dbg_init(struct platform_device *pdev)
GN412X_DBG_REG_NAME, err); GN412X_DBG_REG_NAME, err);
goto err_reg32; goto err_reg32;
} }
gn412x->dbg_reg = file;
#endif
gn412x->dbg_dir = dir; gn412x->dbg_dir = dir;
gn412x->dbg_reg = file;
return 0; return 0;
#if KERNEL_VERSION(5, 6, 0) > LINUX_VERSION_CODE
err_reg32: err_reg32:
debugfs_remove_recursive(dir); debugfs_remove_recursive(dir);
#endif
err_dir: err_dir:
return err; return err;
} }
......
...@@ -75,7 +75,10 @@ static const struct debugfs_reg32 gn412x_debugfs_reg32[] = { ...@@ -75,7 +75,10 @@ static const struct debugfs_reg32 gn412x_debugfs_reg32[] = {
static int gn412x_dbg_init(struct gn412x_gpio_dev *gn412x) static int gn412x_dbg_init(struct gn412x_gpio_dev *gn412x)
{ {
struct dentry *dir, *file; struct dentry *dir;
#if KERNEL_VERSION(5, 6, 0) > LINUX_VERSION_CODE
struct dentry *file;
#endif
int err; int err;
#if KERNEL_VERSION(4, 5, 0) > LINUX_VERSION_CODE #if KERNEL_VERSION(4, 5, 0) > LINUX_VERSION_CODE
...@@ -96,6 +99,10 @@ static int gn412x_dbg_init(struct gn412x_gpio_dev *gn412x) ...@@ -96,6 +99,10 @@ static int gn412x_dbg_init(struct gn412x_gpio_dev *gn412x)
gn412x->dbg_reg32.regs = gn412x_debugfs_reg32; gn412x->dbg_reg32.regs = gn412x_debugfs_reg32;
gn412x->dbg_reg32.nregs = ARRAY_SIZE(gn412x_debugfs_reg32); gn412x->dbg_reg32.nregs = ARRAY_SIZE(gn412x_debugfs_reg32);
gn412x->dbg_reg32.base = gn412x->mem; gn412x->dbg_reg32.base = gn412x->mem;
#if KERNEL_VERSION(5, 6, 0) <= LINUX_VERSION_CODE
debugfs_create_regset32(GN412X_DBG_REG_NAME, 0200,
dir, &gn412x->dbg_reg32);
#else
file = debugfs_create_regset32(GN412X_DBG_REG_NAME, 0200, file = debugfs_create_regset32(GN412X_DBG_REG_NAME, 0200,
dir, &gn412x->dbg_reg32); dir, &gn412x->dbg_reg32);
if (IS_ERR_OR_NULL(file)) { if (IS_ERR_OR_NULL(file)) {
...@@ -105,13 +112,16 @@ static int gn412x_dbg_init(struct gn412x_gpio_dev *gn412x) ...@@ -105,13 +112,16 @@ static int gn412x_dbg_init(struct gn412x_gpio_dev *gn412x)
GN412X_DBG_REG_NAME, err); GN412X_DBG_REG_NAME, err);
goto err_reg32; goto err_reg32;
} }
gn412x->dbg_reg = file;
#endif
gn412x->dbg_dir = dir; gn412x->dbg_dir = dir;
gn412x->dbg_reg = file;
return 0; return 0;
#if KERNEL_VERSION(5, 6, 0) > LINUX_VERSION_CODE
err_reg32: err_reg32:
debugfs_remove_recursive(dir); debugfs_remove_recursive(dir);
#endif
err_dir: err_dir:
return err; return err;
} }
......
...@@ -13,6 +13,15 @@ ...@@ -13,6 +13,15 @@
#if KERNEL_VERSION(5, 7, 0) <= LINUX_VERSION_CODE
#define KPROBE_LOOKUP
#include <linux/kprobes.h>
typedef unsigned long (*kallsyms_lookup_name_t)(const char *name);
static struct kprobe kp = {
.symbol_name = "kallsyms_lookup_name"
};
#endif
#if KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT) #if KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT)
struct fpga_manager *__fpga_mgr_get(struct device *dev) struct fpga_manager *__fpga_mgr_get(struct device *dev)
{ {
...@@ -60,6 +69,13 @@ struct fpga_manager *fpga_mgr_get(struct device *dev) ...@@ -60,6 +69,13 @@ struct fpga_manager *fpga_mgr_get(struct device *dev)
struct class *fpga_mgr_class; struct class *fpga_mgr_class;
struct device *mgr_dev; struct device *mgr_dev;
#ifdef KPROBE_LOOKUP
kallsyms_lookup_name_t kallsyms_lookup_name;
register_kprobe(&kp);
kallsyms_lookup_name = (kallsyms_lookup_name_t) kp.addr;
unregister_kprobe(&kp);
#endif
fpga_mgr_class = (struct class *) kallsyms_lookup_name(FPGA_CLASS); fpga_mgr_class = (struct class *) kallsyms_lookup_name(FPGA_CLASS);
mgr_dev = class_find_device(fpga_mgr_class, NULL, dev, mgr_dev = class_find_device(fpga_mgr_class, NULL, dev,
fpga_mgr_dev_match); fpga_mgr_dev_match);
...@@ -156,6 +172,13 @@ int compat_gpiod_add_lookup_table(struct gpiod_lookup_table *table) ...@@ -156,6 +172,13 @@ int compat_gpiod_add_lookup_table(struct gpiod_lookup_table *table)
{ {
void (*gpiod_add_lookup_table_p)(struct gpiod_lookup_table *table); void (*gpiod_add_lookup_table_p)(struct gpiod_lookup_table *table);
#ifdef KPROBE_LOOKUP
kallsyms_lookup_name_t kallsyms_lookup_name;
register_kprobe(&kp);
kallsyms_lookup_name = (kallsyms_lookup_name_t) kp.addr;
unregister_kprobe(&kp);
#endif
gpiod_add_lookup_table_p = (void *) kallsyms_lookup_name("gpiod_add_lookup_table"); gpiod_add_lookup_table_p = (void *) kallsyms_lookup_name("gpiod_add_lookup_table");
if (gpiod_add_lookup_table_p) if (gpiod_add_lookup_table_p)
...@@ -168,6 +191,13 @@ int compat_gpiod_add_lookup_table(struct gpiod_lookup_table *table) ...@@ -168,6 +191,13 @@ int compat_gpiod_add_lookup_table(struct gpiod_lookup_table *table)
#if KERNEL_VERSION(4, 3, 0) > LINUX_VERSION_CODE #if KERNEL_VERSION(4, 3, 0) > LINUX_VERSION_CODE
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
{ {
#ifdef KPROBE_LOOKUP
kallsyms_lookup_name_t kallsyms_lookup_name;
register_kprobe(&kp);
kallsyms_lookup_name = (kallsyms_lookup_name_t) kp.addr;
unregister_kprobe(&kp);
#endif
struct mutex *gpio_lookup_lock_p = (void *) kallsyms_lookup_name("gpio_lookup_lock"); struct mutex *gpio_lookup_lock_p = (void *) kallsyms_lookup_name("gpio_lookup_lock");
mutex_lock(gpio_lookup_lock_p); mutex_lock(gpio_lookup_lock_p);
......
...@@ -403,6 +403,11 @@ static int spec_fpga_dbg_init(struct spec_fpga *spec_fpga) ...@@ -403,6 +403,11 @@ static int spec_fpga_dbg_init(struct spec_fpga *spec_fpga)
spec_fpga->dbg_csr_reg.regs = spec_fpga_debugfs_reg32; spec_fpga->dbg_csr_reg.regs = spec_fpga_debugfs_reg32;
spec_fpga->dbg_csr_reg.nregs = ARRAY_SIZE(spec_fpga_debugfs_reg32); spec_fpga->dbg_csr_reg.nregs = ARRAY_SIZE(spec_fpga_debugfs_reg32);
spec_fpga->dbg_csr_reg.base = spec_fpga->fpga; spec_fpga->dbg_csr_reg.base = spec_fpga->fpga;
#if KERNEL_VERSION(5, 6, 0) <= LINUX_VERSION_CODE
debugfs_create_regset32(SPEC_DBG_CSR_NAME, 0200,
spec_fpga->dbg_dir_fpga,
&spec_fpga->dbg_csr_reg);
#else
spec_fpga->dbg_csr = debugfs_create_regset32(SPEC_DBG_CSR_NAME, 0200, spec_fpga->dbg_csr = debugfs_create_regset32(SPEC_DBG_CSR_NAME, 0200,
spec_fpga->dbg_dir_fpga, spec_fpga->dbg_dir_fpga,
&spec_fpga->dbg_csr_reg); &spec_fpga->dbg_csr_reg);
...@@ -413,6 +418,7 @@ static int spec_fpga_dbg_init(struct spec_fpga *spec_fpga) ...@@ -413,6 +418,7 @@ static int spec_fpga_dbg_init(struct spec_fpga *spec_fpga)
SPEC_DBG_CSR_NAME, err); SPEC_DBG_CSR_NAME, err);
goto err; goto err;
} }
#endif
spec_fpga->dbg_bld = debugfs_create_file(SPEC_DBG_BLD_INFO_NAME, spec_fpga->dbg_bld = debugfs_create_file(SPEC_DBG_BLD_INFO_NAME,
0444, 0444,
...@@ -478,14 +484,8 @@ static struct resource spec_fpga_vic_res[] = { ...@@ -478,14 +484,8 @@ static struct resource spec_fpga_vic_res[] = {
struct irq_domain *spec_fpga_irq_find_host(struct device *dev) struct irq_domain *spec_fpga_irq_find_host(struct device *dev)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) #if KERNEL_VERSION(4, 4, 0) <= LINUX_VERSION_CODE
struct irq_fwspec fwspec = { return irq_find_matching_fwnode(dev->fwnode, DOMAIN_BUS_ANY);
.fwnode = dev->fwnode,
.param_count = 2,
.param[0] = ((unsigned long)dev >> 32) & 0xffffffff,
.param[1] = ((unsigned long)dev) & 0xffffffff,
};
return irq_find_matching_fwspec(&fwspec, DOMAIN_BUS_ANY);
#else #else
return (irq_find_host((void *)dev)); return (irq_find_host((void *)dev));
#endif #endif
......
...@@ -750,7 +750,10 @@ static irqreturn_t gn412x_dma_irq_handler(int irq, void *arg) ...@@ -750,7 +750,10 @@ static irqreturn_t gn412x_dma_irq_handler(int irq, void *arg)
static int gn412x_dma_dbg_init(struct gn412x_dma_device *gn412x_dma) static int gn412x_dma_dbg_init(struct gn412x_dma_device *gn412x_dma)
{ {
struct dentry *dir, *file; struct dentry *dir;
#if KERNEL_VERSION(5, 6, 0) > LINUX_VERSION_CODE
struct dentry *file;
#endif
int err; int err;
dir = debugfs_create_dir(dev_name(&gn412x_dma->pdev->dev), NULL); dir = debugfs_create_dir(dev_name(&gn412x_dma->pdev->dev), NULL);
...@@ -765,6 +768,10 @@ static int gn412x_dma_dbg_init(struct gn412x_dma_device *gn412x_dma) ...@@ -765,6 +768,10 @@ static int gn412x_dma_dbg_init(struct gn412x_dma_device *gn412x_dma)
gn412x_dma->dbg_reg32.regs = gn412x_dma_debugfs_reg32; gn412x_dma->dbg_reg32.regs = gn412x_dma_debugfs_reg32;
gn412x_dma->dbg_reg32.nregs = ARRAY_SIZE(gn412x_dma_debugfs_reg32); gn412x_dma->dbg_reg32.nregs = ARRAY_SIZE(gn412x_dma_debugfs_reg32);
gn412x_dma->dbg_reg32.base = gn412x_dma->addr; gn412x_dma->dbg_reg32.base = gn412x_dma->addr;
#if KERNEL_VERSION(5, 6, 0) <= LINUX_VERSION_CODE
debugfs_create_regset32(GN412X_DMA_DBG_REG_NAME, 0200,
dir, &gn412x_dma->dbg_reg32);
#else
file = debugfs_create_regset32(GN412X_DMA_DBG_REG_NAME, 0200, file = debugfs_create_regset32(GN412X_DMA_DBG_REG_NAME, 0200,
dir, &gn412x_dma->dbg_reg32); dir, &gn412x_dma->dbg_reg32);
if (IS_ERR_OR_NULL(file)) { if (IS_ERR_OR_NULL(file)) {
...@@ -774,13 +781,16 @@ static int gn412x_dma_dbg_init(struct gn412x_dma_device *gn412x_dma) ...@@ -774,13 +781,16 @@ static int gn412x_dma_dbg_init(struct gn412x_dma_device *gn412x_dma)
GN412X_DMA_DBG_REG_NAME, err); GN412X_DMA_DBG_REG_NAME, err);
goto err_reg32; goto err_reg32;
} }
gn412x_dma->dbg_reg = file;
#endif
gn412x_dma->dbg_dir = dir; gn412x_dma->dbg_dir = dir;
gn412x_dma->dbg_reg = file;
return 0; return 0;
#if KERNEL_VERSION(5, 6, 0) > LINUX_VERSION_CODE
err_reg32: err_reg32:
debugfs_remove_recursive(dir); debugfs_remove_recursive(dir);
#endif
err_dir: err_dir:
return err; return err;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment