Commit d851f7a6 authored by Federico Vaga's avatar Federico Vaga

sw:drv: checkpatch fixes

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent b47e6edf
...@@ -46,6 +46,7 @@ static int fpga_mgr_dev_match(struct device *dev, const void *data) ...@@ -46,6 +46,7 @@ static int fpga_mgr_dev_match(struct device *dev, const void *data)
return dev->parent == data; return dev->parent == data;
} }
#define FPGA_CLASS "fpga_mgr_class"
/** /**
* fpga_mgr_get - get an exclusive reference to a fpga mgr * fpga_mgr_get - get an exclusive reference to a fpga mgr
* @dev:parent device that fpga mgr was registered with * @dev:parent device that fpga mgr was registered with
...@@ -56,10 +57,12 @@ static int fpga_mgr_dev_match(struct device *dev, const void *data) ...@@ -56,10 +57,12 @@ static int fpga_mgr_dev_match(struct device *dev, const void *data)
*/ */
struct fpga_manager *fpga_mgr_get(struct device *dev) struct fpga_manager *fpga_mgr_get(struct device *dev)
{ {
struct class *fpga_mgr_class = (struct class *) kallsyms_lookup_name("fpga_mgr_class"); struct class *fpga_mgr_class;
struct device *mgr_dev; struct device *mgr_dev;
mgr_dev = class_find_device(fpga_mgr_class, NULL, dev, fpga_mgr_dev_match); fpga_mgr_class = (struct class *) kallsyms_lookup_name(FPGA_CLASS);
mgr_dev = class_find_device(fpga_mgr_class, NULL, dev,
fpga_mgr_dev_match);
if (!mgr_dev) if (!mgr_dev)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
......
...@@ -93,7 +93,7 @@ static int spec_fpga_dbg_bld_info(struct seq_file *s, void *offset) ...@@ -93,7 +93,7 @@ static int spec_fpga_dbg_bld_info(struct seq_file *s, void *offset)
} }
for (off = SPEC_BASE_REGS_BUILDINFO; for (off = SPEC_BASE_REGS_BUILDINFO;
off < SPEC_BASE_REGS_BUILDINFO + SPEC_BASE_REGS_BUILDINFO_SIZE -1; off < SPEC_BASE_REGS_BUILDINFO + SPEC_BASE_REGS_BUILDINFO_SIZE - 1;
off++) { off++) {
char tmp = ioread8(spec_fpga->fpga + off); char tmp = ioread8(spec_fpga->fpga + off);
...@@ -113,7 +113,7 @@ static int spec_fpga_dbg_bld_info_open(struct inode *inode, ...@@ -113,7 +113,7 @@ static int spec_fpga_dbg_bld_info_open(struct inode *inode,
return single_open(file, spec_fpga_dbg_bld_info, spec); return single_open(file, spec_fpga_dbg_bld_info, spec);
} }
static const struct file_operations spec_fpga_dbg_bld_info_ops = { static const struct file_operations spec_fpga_dbg_bld_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = spec_fpga_dbg_bld_info_open, .open = spec_fpga_dbg_bld_info_open,
.read = seq_read, .read = seq_read,
...@@ -151,12 +151,13 @@ static int spec_fpga_dbg_init(struct spec_fpga *spec_fpga) ...@@ -151,12 +151,13 @@ static int spec_fpga_dbg_init(struct spec_fpga *spec_fpga)
goto err; goto err;
} }
spec_fpga->dbg_bld_info = debugfs_create_file(SPEC_DBG_BLD_INFO_NAME, 0444, spec_fpga->dbg_bld = debugfs_create_file(SPEC_DBG_BLD_INFO_NAME,
spec_fpga->dbg_dir_fpga, 0444,
spec_fpga, spec_fpga->dbg_dir_fpga,
&spec_fpga_dbg_bld_info_ops); spec_fpga,
if (IS_ERR_OR_NULL(spec_fpga->dbg_bld_info)) { &spec_fpga_dbg_bld_ops);
err = PTR_ERR(spec_fpga->dbg_bld_info); if (IS_ERR_OR_NULL(spec_fpga->dbg_bld)) {
err = PTR_ERR(spec_fpga->dbg_bld);
dev_err(&spec_fpga->dev, dev_err(&spec_fpga->dev,
"Cannot create debugfs file \"%s\" (%d)\n", "Cannot create debugfs file \"%s\" (%d)\n",
SPEC_DBG_BLD_INFO_NAME, err); SPEC_DBG_BLD_INFO_NAME, err);
...@@ -190,7 +191,7 @@ static struct resource spec_fpga_vic_res[] = { ...@@ -190,7 +191,7 @@ static struct resource spec_fpga_vic_res[] = {
.name = "htvic-mem", .name = "htvic-mem",
.flags = IORESOURCE_MEM, .flags = IORESOURCE_MEM,
.start = SPEC_BASE_REGS_VIC, .start = SPEC_BASE_REGS_VIC,
.end = SPEC_BASE_REGS_VIC + SPEC_BASE_REGS_VIC_SIZE -1, .end = SPEC_BASE_REGS_VIC + SPEC_BASE_REGS_VIC_SIZE - 1,
}, { }, {
.name = "htvic-irq", .name = "htvic-irq",
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
...@@ -276,7 +277,7 @@ static int spec_fpga_dma_init(struct spec_fpga *spec_fpga) ...@@ -276,7 +277,7 @@ static int spec_fpga_dma_init(struct spec_fpga *spec_fpga)
vic_domain = irq_find_host((void *)&spec_fpga->vic_pdev->dev); vic_domain = irq_find_host((void *)&spec_fpga->vic_pdev->dev);
if (!vic_domain) { if (!vic_domain) {
dev_err(&spec_fpga->dev, dev_err(&spec_fpga->dev,
"Failed to load DMA engine: missing can't find VIC.\n"); "Failed to load DMA engine: can't find VIC\n");
return -ENODEV; return -ENODEV;
} }
...@@ -314,7 +315,8 @@ static struct resource spec_fpga_fmc_i2c_res[] = { ...@@ -314,7 +315,8 @@ static struct resource spec_fpga_fmc_i2c_res[] = {
.name = "i2c-ocores-mem", .name = "i2c-ocores-mem",
.flags = IORESOURCE_MEM, .flags = IORESOURCE_MEM,
.start = SPEC_BASE_REGS_FMC_I2C, .start = SPEC_BASE_REGS_FMC_I2C,
.end = SPEC_BASE_REGS_FMC_I2C + SPEC_BASE_REGS_FMC_I2C_SIZE -1, .end = SPEC_BASE_REGS_FMC_I2C +
SPEC_BASE_REGS_FMC_I2C_SIZE - 1,
}, { }, {
.name = "i2c-ocores-irq", .name = "i2c-ocores-irq",
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
...@@ -339,7 +341,8 @@ static struct resource spec_fpga_spi_res[] = { ...@@ -339,7 +341,8 @@ static struct resource spec_fpga_spi_res[] = {
.name = "spi-ocores-mem", .name = "spi-ocores-mem",
.flags = IORESOURCE_MEM, .flags = IORESOURCE_MEM,
.start = SPEC_BASE_REGS_FLASH_SPI, .start = SPEC_BASE_REGS_FLASH_SPI,
.end = SPEC_BASE_REGS_FLASH_SPI + SPEC_BASE_REGS_FLASH_SPI_SIZE - 1, .end = SPEC_BASE_REGS_FLASH_SPI +
SPEC_BASE_REGS_FLASH_SPI_SIZE - 1,
}, { }, {
.name = "spi-ocores-irq", .name = "spi-ocores-irq",
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
...@@ -461,14 +464,14 @@ static ssize_t temperature_show(struct device *dev, ...@@ -461,14 +464,14 @@ static ssize_t temperature_show(struct device *dev,
struct spec_fpga *spec_fpga = to_spec_fpga(dev); struct spec_fpga *spec_fpga = to_spec_fpga(dev);
if (spec_fpga->meta->cap & SPEC_META_CAP_THERM) { if (spec_fpga->meta->cap & SPEC_META_CAP_THERM) {
uint32_t temp = ioread32(spec_fpga->fpga + SPEC_FPGA_THERM_TEMP); uint32_t temp;
temp = ioread32(spec_fpga->fpga + SPEC_FPGA_THERM_TEMP);
return snprintf(buf, PAGE_SIZE, "%d.%d C\n", return snprintf(buf, PAGE_SIZE, "%d.%d C\n",
temp / 16, (temp & 0xF) * 1000 / 16); temp / 16, (temp & 0xF) * 1000 / 16);
} else {
return snprintf(buf, PAGE_SIZE, "-.- C\n");
} }
return snprintf(buf, PAGE_SIZE, "-.- C\n");
} }
static DEVICE_ATTR_RO(temperature); static DEVICE_ATTR_RO(temperature);
...@@ -479,14 +482,14 @@ static ssize_t serial_number_show(struct device *dev, ...@@ -479,14 +482,14 @@ static ssize_t serial_number_show(struct device *dev,
struct spec_fpga *spec_fpga = to_spec_fpga(dev); struct spec_fpga *spec_fpga = to_spec_fpga(dev);
if (spec_fpga->meta->cap & SPEC_META_CAP_THERM) { if (spec_fpga->meta->cap & SPEC_META_CAP_THERM) {
uint32_t msb = ioread32(spec_fpga->fpga + SPEC_FPGA_THERM_SERID_MSB); uint32_t msb, lsb;
uint32_t lsb = ioread32(spec_fpga->fpga + SPEC_FPGA_THERM_SERID_LSB);
msb = ioread32(spec_fpga->fpga + SPEC_FPGA_THERM_SERID_MSB);
lsb = ioread32(spec_fpga->fpga + SPEC_FPGA_THERM_SERID_LSB);
return snprintf(buf, PAGE_SIZE, "0x%08x%08x\n", msb, lsb); return snprintf(buf, PAGE_SIZE, "0x%08x%08x\n", msb, lsb);
} else {
return snprintf(buf, PAGE_SIZE, "0x----------------\n");
} }
return snprintf(buf, PAGE_SIZE, "0x----------------\n");
} }
static DEVICE_ATTR_RO(serial_number); static DEVICE_ATTR_RO(serial_number);
...@@ -575,7 +578,7 @@ static ssize_t reset_app_store(struct device *dev, ...@@ -575,7 +578,7 @@ static ssize_t reset_app_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR(reset_app, 0644, reset_app_show, reset_app_store); static DEVICE_ATTR_RW(reset_app);
static struct attribute *spec_fpga_csr_attrs[] = { static struct attribute *spec_fpga_csr_attrs[] = {
&dev_attr_pcb_rev.attr, &dev_attr_pcb_rev.attr,
...@@ -689,16 +692,17 @@ static int spec_fpga_app_id_build(struct spec_fpga *spec_fpga, ...@@ -689,16 +692,17 @@ static int spec_fpga_app_id_build(struct spec_fpga *spec_fpga,
unsigned long app_off, unsigned long app_off,
char *id, unsigned int size) char *id, unsigned int size)
{ {
uint32_t vendor = ioread32be(spec_fpga->fpga + app_off + FPGA_META_VENDOR); uint32_t vendor, device;
uint32_t device = ioread32be(spec_fpga->fpga + app_off + FPGA_META_DEVICE);
vendor = ioread32be(spec_fpga->fpga + app_off + FPGA_META_VENDOR);
device = ioread32be(spec_fpga->fpga + app_off + FPGA_META_DEVICE);
memset(id, 0, size); memset(id, 0, size);
if (vendor == 0xFF000000) { if (vendor == 0xFF000000) {
dev_warn(&spec_fpga->dev, "Vendor UUID not supported yet\n"); dev_warn(&spec_fpga->dev, "Vendor UUID not supported yet\n");
return -ENODEV; return -ENODEV;
} else {
snprintf(id, size, "id:%4phN%4phN", &vendor, &device);
} }
snprintf(id, size, "id:%4phN%4phN", &vendor, &device);
return 0; return 0;
} }
......
...@@ -625,7 +625,7 @@ static ssize_t bootselect_show(struct device *dev, ...@@ -625,7 +625,7 @@ static ssize_t bootselect_show(struct device *dev,
return -EINVAL; return -EINVAL;
} }
} }
static DEVICE_ATTR(bootselect, 0644, bootselect_show, bootselect_store); static DEVICE_ATTR_RW(bootselect);
/** /**
* Load golden bitstream on FGPA * Load golden bitstream on FGPA
......
// SPDX-License-Identifier: GPL-2.0-or-later
/** /**
* Copyright (C) 2017 CERN (www.cern.ch) * Copyright (C) 2017 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@vaga.pv.it> * Author: Federico Vaga <federico.vaga@vaga.pv.it>
...@@ -20,17 +21,6 @@ ...@@ -20,17 +21,6 @@
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
/* Kernel functions not exported */
#if 0
/*
* Take it from the sources, like if this driver was part
* of that directory
*/
#include <../drivers/dma/dmaengine.h>
#else
/** /**
* dma_cookie_complete - complete a descriptor * dma_cookie_complete - complete a descriptor
* @tx: descriptor to complete * @tx: descriptor to complete
...@@ -102,7 +92,6 @@ static inline enum dma_status dma_cookie_status(struct dma_chan *chan, ...@@ -102,7 +92,6 @@ static inline enum dma_status dma_cookie_status(struct dma_chan *chan,
} }
return dma_async_is_complete(cookie, complete, used); return dma_async_is_complete(cookie, complete, used);
} }
#endif
enum gn412x_dma_regs { enum gn412x_dma_regs {
...@@ -514,12 +503,13 @@ static struct dma_async_tx_descriptor *gn412x_dma_prep_slave_sg( ...@@ -514,12 +503,13 @@ static struct dma_async_tx_descriptor *gn412x_dma_prep_slave_sg(
tx_hw->attribute); tx_hw->attribute);
} }
dev_dbg(&chan->dev->device, "%s prepared %p\n", __func__, &gn412x_dma_tx->tx); dev_dbg(&chan->dev->device, "%s prepared %p\n", __func__,
&gn412x_dma_tx->tx);
return &gn412x_dma_tx->tx; return &gn412x_dma_tx->tx;
err_alloc_pool: err_alloc_pool:
while(--i >= 0) while (--i >= 0)
dma_pool_free(gn412x_dma->pool, dma_pool_free(gn412x_dma->pool,
gn412x_dma_tx->sgl_hw[i], gn412x_dma_tx->sgl_hw[i],
gn412x_dma_tx->tx.phys); gn412x_dma_tx->tx.phys);
...@@ -551,9 +541,10 @@ static void gn412x_dma_issue_pending(struct dma_chan *chan) ...@@ -551,9 +541,10 @@ static void gn412x_dma_issue_pending(struct dma_chan *chan)
static void gn412x_dma_start_task(unsigned long arg) static void gn412x_dma_start_task(unsigned long arg)
{ {
struct gn412x_dma_chan *chan = (struct gn412x_dma_chan *)arg; struct gn412x_dma_chan *chan = (struct gn412x_dma_chan *)arg;
struct gn412x_dma_device *gn412x_dma = to_gn412x_dma_device(chan->chan.device); struct gn412x_dma_device *gn412x_dma;
unsigned long flags; unsigned long flags;
gn412x_dma = to_gn412x_dma_device(chan->chan.device);
if (unlikely(gn412x_dma_is_busy(gn412x_dma))) { if (unlikely(gn412x_dma_is_busy(gn412x_dma))) {
dev_err(&gn412x_dma->pdev->dev, dev_err(&gn412x_dma->pdev->dev,
"Failed to start DMA transfer: channel busy\n"); "Failed to start DMA transfer: channel busy\n");
...@@ -600,8 +591,9 @@ static int gn412x_dma_slave_config(struct dma_chan *chan, ...@@ -600,8 +591,9 @@ static int gn412x_dma_slave_config(struct dma_chan *chan,
static int gn412x_dma_terminate_all(struct dma_chan *chan) static int gn412x_dma_terminate_all(struct dma_chan *chan)
{ {
struct gn412x_dma_device *gn412x_dma = to_gn412x_dma_device(chan->device); struct gn412x_dma_device *gn412x_dma;
gn412x_dma = to_gn412x_dma_device(chan->device);
gn412x_dma_ctrl_abort(gn412x_dma); gn412x_dma_ctrl_abort(gn412x_dma);
/* FIXME remove all pending */ /* FIXME remove all pending */
if (!gn412x_dma_is_abort(gn412x_dma)) { if (!gn412x_dma_is_abort(gn412x_dma)) {
...@@ -847,7 +839,7 @@ err_res_mem: ...@@ -847,7 +839,7 @@ err_res_mem:
/** /**
* It removes an instance of the GN4124 DMA engine * It removes an instance of the GN4124 DMA engine
* @pdev: platform device * @pdev: platform device
* *
* @return: 0 on success otherwise a negative error code * @return: 0 on success otherwise a negative error code
......
...@@ -124,7 +124,7 @@ struct spec_fpga { ...@@ -124,7 +124,7 @@ struct spec_fpga {
struct dentry *dbg_csr; struct dentry *dbg_csr;
struct debugfs_regset32 dbg_csr_reg; struct debugfs_regset32 dbg_csr_reg;
#define SPEC_DBG_BLD_INFO_NAME "build_info" #define SPEC_DBG_BLD_INFO_NAME "build_info"
struct dentry *dbg_bld_info; struct dentry *dbg_bld;
}; };
/** /**
......
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