Commit 67fb45e4 authored by Federico Vaga's avatar Federico Vaga

sw:drv: checkpatch fixes

It also updates the Copyright year and fix the copyright in LICENSES
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 5db34069
...@@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively ...@@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
fmc-spec spec-fmc-carrier
Copyright (C) 2017 Federico Vaga Copyright (C) 2019 CERN (https://home.cern)
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
......
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2017 CERN (www.cern.ch) * Copyright (C) 2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
*/ */
#include <linux/module.h> #include <linux/module.h>
......
//SPDX-License-Identifier: GPL-2.0-or-later /* SPDX-License-Identifier: GPL-2.0-or-later */
/* /*
* Copyright (C) 2010-2019 CERN (www.cern.ch) * Copyright (C) 2010-2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
......
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*/
#ifndef __GN412X_GPIO_H__ #ifndef __GN412X_GPIO_H__
#define __GN412X_GPIO_H__ #define __GN412X_GPIO_H__
......
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2017 CERN (www.cern.ch) * Copyright (C) 2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
*/ */
#include <linux/kallsyms.h> #include <linux/kallsyms.h>
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
int compat_get_fpga_last_word_size(struct fpga_image_info *info, size_t count) int compat_get_fpga_last_word_size(struct fpga_image_info *info, size_t count)
{ {
#if KERNEL_VERSION(4,16,0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT) #if KERNEL_VERSION(4, 16, 0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT)
return count; return count;
#else #else
return info ? info->count : count; return info ? info->count : count;
#endif #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)
int compat_spec_fpga_write_init(struct fpga_manager *mgr, int compat_spec_fpga_write_init(struct fpga_manager *mgr,
u32 flags, u32 flags,
const char *buf, size_t count) const char *buf, size_t count)
...@@ -45,7 +45,7 @@ int compat_spec_fpga_write_complete(struct fpga_manager *mgr, ...@@ -45,7 +45,7 @@ int compat_spec_fpga_write_complete(struct fpga_manager *mgr,
} }
#endif #endif
#if KERNEL_VERSION(4,18,0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT) #if KERNEL_VERSION(4, 18, 0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT)
struct fpga_manager *compat_fpga_mgr_create(struct device *dev, const char *name, struct fpga_manager *compat_fpga_mgr_create(struct device *dev, const char *name,
const struct fpga_manager_ops *mops, const struct fpga_manager_ops *mops,
void *priv) void *priv)
...@@ -99,7 +99,7 @@ void compat_fpga_mgr_unregister(struct fpga_manager *mgr) ...@@ -99,7 +99,7 @@ void compat_fpga_mgr_unregister(struct fpga_manager *mgr)
#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)
{ {
struct fpga_manager *mgr; struct fpga_manager *mgr;
...@@ -156,8 +156,8 @@ struct fpga_manager *fpga_mgr_get(struct device *dev) ...@@ -156,8 +156,8 @@ struct fpga_manager *fpga_mgr_get(struct device *dev)
static int __compat_spec_fw_load(struct fpga_manager *mgr, const char *name) static int __compat_spec_fw_load(struct fpga_manager *mgr, const char *name)
{ {
#if KERNEL_VERSION(4,16,0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT) #if KERNEL_VERSION(4, 16, 0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT)
#if KERNEL_VERSION(4,10,0) > LINUX_VERSION_CODE #if KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE
return fpga_mgr_firmware_load(mgr, 0, name); return fpga_mgr_firmware_load(mgr, 0, name);
#else #else
struct fpga_image_info image; struct fpga_image_info image;
......
// SPDX-License-Identifier: GPL-2.0-or-later /* SPDX-License-Identifier: GPL-2.0-or-later */
/* /*
* Copyright (C) 2017 CERN (www.cern.ch) * Copyright (C) 2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
*/ */
#include <linux/fpga/fpga-mgr.h> #include <linux/fpga/fpga-mgr.h>
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include "spec.h" #include "spec.h"
#if KERNEL_VERSION(4,10,0) <= LINUX_VERSION_CODE #if KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(4,16,0) > LINUX_VERSION_CODE #if KERNEL_VERSION(4, 16, 0) > LINUX_VERSION_CODE
/* So that we select the buffer size because smaller */ /* So that we select the buffer size because smaller */
#define compat_fpga_ops_initial_header_size .initial_header_size = 0xFFFFFFFF, #define compat_fpga_ops_initial_header_size .initial_header_size = 0xFFFFFFFF,
#else #else
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
#define compat_fpga_ops_initial_header_size #define compat_fpga_ops_initial_header_size
#endif #endif
#if KERNEL_VERSION(4,16,0) > LINUX_VERSION_CODE && ! defined(CONFIG_FPGA_MGR_BACKPORT) #if KERNEL_VERSION(4, 16, 0) > LINUX_VERSION_CODE && !defined(CONFIG_FPGA_MGR_BACKPORT)
#define compat_fpga_ops_groups #define compat_fpga_ops_groups
#else #else
#define compat_fpga_ops_groups .groups = NULL, #define compat_fpga_ops_groups .groups = NULL,
#endif #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_image_info; struct fpga_image_info;
#endif #endif
...@@ -36,7 +36,7 @@ int spec_fpga_write_init(struct fpga_manager *mgr, ...@@ -36,7 +36,7 @@ int spec_fpga_write_init(struct fpga_manager *mgr,
int spec_fpga_write_complete(struct fpga_manager *mgr, int spec_fpga_write_complete(struct fpga_manager *mgr,
struct fpga_image_info *info); struct fpga_image_info *info);
#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)
int compat_spec_fpga_write_init(struct fpga_manager *mgr, u32 flags, int compat_spec_fpga_write_init(struct fpga_manager *mgr, u32 flags,
const char *buf, size_t count); const char *buf, size_t count);
int compat_spec_fpga_write_complete(struct fpga_manager *mgr, u32 flags); int compat_spec_fpga_write_complete(struct fpga_manager *mgr, u32 flags);
......
// SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2017 CERN (www.cern.ch) * Copyright (C) 2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
* *
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Driver for SPEC (Simple PCI FMC carrier) board. * Driver for SPEC (Simple PCI FMC carrier) board.
*/ */
......
...@@ -15,14 +15,14 @@ static int spec_irq_dbg_info(struct seq_file *s, void *offset) ...@@ -15,14 +15,14 @@ static int spec_irq_dbg_info(struct seq_file *s, void *offset)
{ {
struct spec_dev *spec = s->private; struct spec_dev *spec = s->private;
seq_printf(s, "'%s':\n",dev_name(spec->dev.parent)); seq_printf(s, "'%s':\n", dev_name(spec->dev.parent));
seq_printf(s, " redirect: %d\n", to_pci_dev(spec->dev.parent)->irq); seq_printf(s, " redirect: %d\n", to_pci_dev(spec->dev.parent)->irq);
seq_printf(s, " irq-mapping:\n"); seq_puts(s, " irq-mapping:\n");
seq_printf(s, " - hardware: 8\n"); seq_puts(s, " - hardware: 8\n");
seq_printf(s, " linux: %d\n", seq_printf(s, " linux: %d\n",
gpiod_to_irq(spec->gpiod[GN4124_GPIO_IRQ0])); gpiod_to_irq(spec->gpiod[GN4124_GPIO_IRQ0]));
seq_printf(s, " - hardware: 9\n"); seq_puts(s, " - hardware: 9\n");
seq_printf(s, " linux: %d\n", seq_printf(s, " linux: %d\n",
gpiod_to_irq(spec->gpiod[GN4124_GPIO_IRQ1])); gpiod_to_irq(spec->gpiod[GN4124_GPIO_IRQ1]));
...@@ -76,7 +76,7 @@ static int spec_dbg_meta(struct seq_file *s, void *offset) ...@@ -76,7 +76,7 @@ static int spec_dbg_meta(struct seq_file *s, void *offset)
struct spec_dev *spec = s->private; struct spec_dev *spec = s->private;
seq_printf(s, "'%s':\n", dev_name(spec->dev.parent)); seq_printf(s, "'%s':\n", dev_name(spec->dev.parent));
seq_printf(s, "Metadata:\n"); seq_puts(s, "Metadata:\n");
seq_printf(s, " - Vendor: 0x%08x\n", spec->meta->vendor); seq_printf(s, " - Vendor: 0x%08x\n", spec->meta->vendor);
seq_printf(s, " - Device: 0x%08x\n", spec->meta->device); seq_printf(s, " - Device: 0x%08x\n", spec->meta->device);
seq_printf(s, " - Version: 0x%08x\n", spec->meta->version); seq_printf(s, " - Version: 0x%08x\n", spec->meta->version);
...@@ -166,6 +166,5 @@ int spec_dbg_init(struct spec_dev *spec) ...@@ -166,6 +166,5 @@ int spec_dbg_init(struct spec_dev *spec)
*/ */
void spec_dbg_exit(struct spec_dev *spec) void spec_dbg_exit(struct spec_dev *spec)
{ {
if (spec->dbg_dir) debugfs_remove_recursive(spec->dbg_dir);
debugfs_remove_recursive(spec->dbg_dir);
} }
// SPDX-License-Identifier: GPLv2 // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2019 CERN (www.cern.ch) * Copyright (C) 2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
......
// SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2017 CERN (www.cern.ch) * Copyright (C) 2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#include <linux/fpga/fpga-mgr.h> #include <linux/fpga/fpga-mgr.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
...@@ -92,17 +91,25 @@ static int gn4124_fpga_fcl_init(struct spec_dev *spec, int last_word_size) ...@@ -92,17 +91,25 @@ static int gn4124_fpga_fcl_init(struct spec_dev *spec, int last_word_size)
gennum_writel(spec, 0x40, FCL_CTRL); /* Reset */ gennum_writel(spec, 0x40, FCL_CTRL); /* Reset */
i = gennum_readl(spec, FCL_CTRL); i = gennum_readl(spec, FCL_CTRL);
if (i != 0x40) { if (i != 0x40) {
printk(KERN_ERR "%s: %i: error\n", __func__, __LINE__); pr_err("%s: %i: error\n", __func__, __LINE__);
return -EIO; return -EIO;
} }
gennum_writel(spec, 0x00, FCL_CTRL); gennum_writel(spec, 0x00, FCL_CTRL);
gennum_writel(spec, 0x00, FCL_IRQ); /* clear pending irq */ gennum_writel(spec, 0x00, FCL_IRQ); /* clear pending irq */
switch(last_word_size) { switch (last_word_size) {
case 3: ctrl = 0x116; break; case 3:
case 2: ctrl = 0x126; break; ctrl = 0x116;
case 1: ctrl = 0x136; break; break;
case 0: ctrl = 0x106; break; case 2:
ctrl = 0x126;
break;
case 1:
ctrl = 0x136;
break;
case 0:
ctrl = 0x106;
break;
default: return -EINVAL; default: return -EINVAL;
} }
gennum_writel(spec, ctrl, FCL_CTRL); gennum_writel(spec, ctrl, FCL_CTRL);
...@@ -171,16 +178,16 @@ static int gn4124_fpga_load(struct spec_dev *spec, const void *data, int len) ...@@ -171,16 +178,16 @@ static int gn4124_fpga_load(struct spec_dev *spec, const void *data, int len)
int done = 0, wrote = 0; int done = 0, wrote = 0;
const uint32_t *data32 = data; const uint32_t *data32 = data;
while(size32 > 0) while (size32 > 0) {
{
/* Check to see if FPGA configuation has error */ /* Check to see if FPGA configuation has error */
int i = gennum_readl(spec, FCL_IRQ); int i = gennum_readl(spec, FCL_IRQ);
if ( (i & 8) && wrote) {
if ((i & 8) && wrote) {
done = 1; done = 1;
printk("%s: %i: done after %i\n", __func__, __LINE__, pr_err("%s: %i: done after %i\n", __func__, __LINE__,
wrote); wrote);
} else if ( (i & 0x4) && !done) { } else if ((i & 0x4) && !done) {
printk("%s: %i: error after %i\n", __func__, __LINE__, pr_err("%s: %i: error after %i\n", __func__, __LINE__,
wrote); wrote);
return -EIO; return -EIO;
} }
...@@ -237,7 +244,8 @@ err: ...@@ -237,7 +244,8 @@ err:
return err; return err;
} }
static int spec_fpga_write(struct fpga_manager *mgr, const char *buf, size_t count) static int spec_fpga_write(struct fpga_manager *mgr,
const char *buf, size_t count)
{ {
struct spec_dev *spec = mgr->priv; struct spec_dev *spec = mgr->priv;
......
...@@ -60,11 +60,13 @@ static const struct gpiod_lookup_table spec_gpiod_table = { ...@@ -60,11 +60,13 @@ static const struct gpiod_lookup_table spec_gpiod_table = {
static inline size_t spec_gpiod_table_size(void) static inline size_t spec_gpiod_table_size(void)
{ {
return sizeof(struct gpiod_lookup_table) + (sizeof(struct gpiod_lookup) * 9); return sizeof(struct gpiod_lookup_table) +
(sizeof(struct gpiod_lookup) * 9);
} }
int spec_gpio_init(struct spec_dev *spec) int spec_gpio_init(struct spec_dev *spec)
{ {
struct gpio_desc *gpiod;
struct gpiod_lookup_table *lookup; struct gpiod_lookup_table *lookup;
int err = 0; int err = 0;
...@@ -87,17 +89,19 @@ int spec_gpio_init(struct spec_dev *spec) ...@@ -87,17 +89,19 @@ int spec_gpio_init(struct spec_dev *spec)
if (err) if (err)
goto err_lookup; goto err_lookup;
spec->gpiod[GN4124_GPIO_BOOTSEL0] = gpiod_get_index(&spec->dev, gpiod = gpiod_get_index(&spec->dev, "bootsel", 0, GPIOD_OUT_HIGH);
"bootsel", 0, if (IS_ERR(gpiod)) {
GPIOD_OUT_HIGH); err = PTR_ERR(gpiod);
if (IS_ERR(spec->gpiod[GN4124_GPIO_BOOTSEL0]))
goto err_sel0; goto err_sel0;
}
spec->gpiod[GN4124_GPIO_BOOTSEL0] = gpiod;
spec->gpiod[GN4124_GPIO_BOOTSEL1] = gpiod_get_index(&spec->dev, gpiod = gpiod_get_index(&spec->dev, "bootsel", 1, GPIOD_OUT_HIGH);
"bootsel", 1, if (IS_ERR(gpiod)) {
GPIOD_OUT_HIGH); err = PTR_ERR(gpiod);
if (IS_ERR(spec->gpiod[GN4124_GPIO_BOOTSEL1]))
goto err_sel1; goto err_sel1;
}
spec->gpiod[GN4124_GPIO_BOOTSEL1] = gpiod;
/* Because of a BUG in RedHat kernel 3.10 we re-set direction */ /* Because of a BUG in RedHat kernel 3.10 we re-set direction */
err = gpiod_direction_output(spec->gpiod[GN4124_GPIO_BOOTSEL0], 1); err = gpiod_direction_output(spec->gpiod[GN4124_GPIO_BOOTSEL0], 1);
...@@ -108,20 +112,20 @@ int spec_gpio_init(struct spec_dev *spec) ...@@ -108,20 +112,20 @@ int spec_gpio_init(struct spec_dev *spec)
goto err_out1; goto err_out1;
spec->gpiod[GN4124_GPIO_IRQ0] = gpiod_get_index(&spec->dev, gpiod = gpiod_get_index(&spec->dev, "irq", 0, GPIOD_IN);
"irq", 0, if (IS_ERR(gpiod)) {
GPIOD_IN); err = PTR_ERR(gpiod);
if (IS_ERR(spec->gpiod[GN4124_GPIO_IRQ0])) {
err = PTR_ERR(spec->gpiod[GN4124_GPIO_IRQ0]);
goto err_irq0; goto err_irq0;
} }
spec->gpiod[GN4124_GPIO_IRQ1] = gpiod_get_index(&spec->dev, spec->gpiod[GN4124_GPIO_IRQ0] = gpiod;
"irq", 1,
GPIOD_IN); gpiod = gpiod_get_index(&spec->dev, "irq", 1, GPIOD_IN);
if (IS_ERR(spec->gpiod[GN4124_GPIO_IRQ1])) { if (IS_ERR(gpiod)) {
err = PTR_ERR(spec->gpiod[GN4124_GPIO_IRQ1]); err = PTR_ERR(gpiod);
goto err_irq1; goto err_irq1;
} }
spec->gpiod[GN4124_GPIO_IRQ1] = gpiod;
/* Because of a BUG in RedHat kernel 3.10 we re-set direction */ /* Because of a BUG in RedHat kernel 3.10 we re-set direction */
err = gpiod_direction_input(spec->gpiod[GN4124_GPIO_IRQ0]); err = gpiod_direction_input(spec->gpiod[GN4124_GPIO_IRQ0]);
if (err) if (err)
......
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* /*
* Copyright (C) 2010-2018 CERN (www.cern.ch) * Copyright (C) 2010-2019 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch> * Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Alessandro Rubini <rubini@gnudd.com> * Author: Alessandro Rubini <rubini@gnudd.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#ifndef __SPEC_H__ #ifndef __SPEC_H__
#define __SPEC_H__ #define __SPEC_H__
...@@ -53,7 +52,7 @@ ...@@ -53,7 +52,7 @@
* @SPEC_FPGA_SELECT_SPI: the SPI flash is accessible from GN4124 * @SPEC_FPGA_SELECT_SPI: the SPI flash is accessible from GN4124
*/ */
enum spec_fpga_select { enum spec_fpga_select {
SPEC_FPGA_SELECT_FLASH=0, SPEC_FPGA_SELECT_FLASH = 0,
SPEC_FPGA_SELECT_GN4124, SPEC_FPGA_SELECT_GN4124,
SPEC_FPGA_SELECT_SPI, SPEC_FPGA_SELECT_SPI,
}; };
...@@ -176,6 +175,7 @@ static inline void gennum_mask_val(struct spec_dev *spec, ...@@ -176,6 +175,7 @@ static inline void gennum_mask_val(struct spec_dev *spec,
uint32_t mask, uint32_t val, int reg) uint32_t mask, uint32_t val, int reg)
{ {
uint32_t v = gennum_readl(spec, reg); uint32_t v = gennum_readl(spec, reg);
v &= ~mask; v &= ~mask;
v |= val; v |= val;
gennum_writel(spec, v, reg); gennum_writel(spec, v, reg);
......
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