Commit e24273e4 authored by Federico Vaga's avatar Federico Vaga

sw:drv: move sysfs attr for firmware name to debugfs

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 5f60fed9
......@@ -27,4 +27,5 @@ obj-m := spec.o
spec-objs := spec-core.o
spec-objs += spec-fpga.o
spec-objs += spec-irq.o
spec-objs += spec-dbg.o
spec-objs += spec-compat.o
......@@ -85,32 +85,6 @@ static int spec_fw_load_init(struct spec_dev *spec)
return spec_fw_load(spec, spec_fw_name_init_get(spec));
}
static ssize_t fpga_load_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int err;
err = spec_fw_load(to_spec_dev(dev), buf);
return err ? err : count;
}
static DEVICE_ATTR_WO(fpga_load);
static struct attribute *spec_attrs[] = {
&dev_attr_fpga_load.attr,
NULL,
};
static struct attribute_group spec_attr_group = {
.attrs = spec_attrs,
};
static const struct attribute_group *spec_attr_groups[] = {
&spec_attr_group,
NULL,
};
static void spec_release(struct device *dev)
{
......@@ -124,7 +98,6 @@ static int spec_uevent(struct device *dev, struct kobj_uevent_env *env)
static const struct device_type spec_dev_type = {
.name = "spec",
.release = spec_release,
.groups = spec_attr_groups,
.uevent = spec_uevent,
};
......@@ -187,6 +160,8 @@ static int spec_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, spec);
dev_info(spec->dev.parent, "Spec registered devptr=0x%p\n", spec->dev.parent);
spec_dbg_init(spec);
return 0;
err_fw:
......@@ -214,7 +189,7 @@ static void spec_remove(struct pci_dev *pdev)
struct spec_dev *spec = pci_get_drvdata(pdev);
int i;
spec_dbg_exit(spec);
spec_irq_exit(spec);
spec_fpga_exit(spec);
......
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2019 CERN
* Author: Federico Vaga <federico.vaga@cern.ch>
*/
#include <linux/module.h>
#include <linux/fs.h>
#include "spec.h"
#include "spec-compat.h"
static int spec_irq_dbg_info(struct seq_file *s, void *offset)
{
struct spec_dev *spec = s->private;
int i;
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, " irq-mapping:\n");
for (i = 0; i < GN4124_GPIO_IRQ_MAX; ++i) {
seq_printf(s, " - hardware: %d\n", i);
seq_printf(s, " linux: %d\n",
irq_find_mapping(spec->gpio_domain, i));
}
return 0;
}
static int spec_irq_dbg_info_open(struct inode *inode, struct file *file)
{
struct spec_dev *spec = inode->i_private;
return single_open(file, spec_irq_dbg_info, spec);
}
static const struct file_operations spec_irq_dbg_info_ops = {
.owner = THIS_MODULE,
.open = spec_irq_dbg_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static ssize_t spec_dbg_fw_write(struct file *file,
const char __user *buf,
size_t count, loff_t *ppos)
{
struct spec_dev *spec = file->private_data;
int err;
err = compat_spec_fw_load(spec, buf);
if (err)
return err;
return count;
}
static int spec_dbg_fw_open(struct inode *inode, struct file *file)
{
struct htvic_device *htvic = inode->i_private;
file->private_data = htvic;
return 0;
}
static const struct file_operations spec_dbg_fw_ops = {
.owner = THIS_MODULE,
.open = spec_dbg_fw_open,
.write = spec_dbg_fw_write,
};
/**
* It initializes the debugfs interface
* @spec: SPEC device instance
*
* Return: 0 on success, otherwise a negative error number
*/
int spec_dbg_init(struct spec_dev *spec)
{
spec->dbg_dir = debugfs_create_dir(dev_name(&spec->dev), NULL);
if (IS_ERR_OR_NULL(spec->dbg_dir)) {
dev_err(&spec->dev,
"Cannot create debugfs directory (%ld)\n",
PTR_ERR(spec->dbg_dir));
return PTR_ERR(spec->dbg_dir);
}
spec->dbg_info = debugfs_create_file(SPEC_DBG_INFO_NAME, 0444,
spec->dbg_dir, spec,
&spec_irq_dbg_info_ops);
if (IS_ERR_OR_NULL(spec->dbg_info)) {
dev_err(&spec->dev,
"Cannot create debugfs file \"%s\" (%ld)\n",
SPEC_DBG_INFO_NAME, PTR_ERR(spec->dbg_info));
return PTR_ERR(spec->dbg_info);
}
spec->dbg_fw = debugfs_create_file(SPEC_DBG_FW_NAME, 0200,
spec->dbg_dir, spec,
&spec_dbg_fw_ops);
if (IS_ERR_OR_NULL(spec->dbg_fw)) {
dev_err(&spec->dev,
"Cannot create debugfs file \"%s\" (%ld)\n",
SPEC_DBG_FW_NAME, PTR_ERR(spec->dbg_fw));
return PTR_ERR(spec->dbg_fw);
}
return 0;
}
/**
* It removes the debugfs interface
* @spec: SPEC device instance
*/
void spec_dbg_exit(struct spec_dev *spec)
{
if (spec->dbg_dir)
debugfs_remove_recursive(spec->dbg_dir);
}
......@@ -17,8 +17,6 @@
#define CHAIN 0
#define GN4124_GPIO_IRQ_MAX 16
static int spec_use_msi = 0;
module_param_named(use_msi, spec_use_msi, int, 0444);
......@@ -31,80 +29,6 @@ module_param_named(test_irq, spec_test_irq, int, 0444);
*/
static int spec_gpio_int = 0x00000300;
static int spec_irq_dbg_info(struct seq_file *s, void *offset)
{
struct spec_dev *spec = s->private;
int i;
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, " irq-mapping:\n");
for (i = 0; i < GN4124_GPIO_IRQ_MAX; ++i) {
seq_printf(s, " - hardware: %d\n", i);
seq_printf(s, " linux: %d\n",
irq_find_mapping(spec->gpio_domain, i));
}
return 0;
}
static int spec_irq_dbg_info_open(struct inode *inode, struct file *file)
{
struct spec_dev *spec = inode->i_private;
return single_open(file, spec_irq_dbg_info, spec);
}
static const struct file_operations spec_irq_dbg_info_ops = {
.owner = THIS_MODULE,
.open = spec_irq_dbg_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/**
* It initializes the debugfs interface
* @spec: SPEC instance
*
* Return: 0 on success, otherwise a negative error number
*/
static int spec_irq_debug_init(struct spec_dev *spec)
{
spec->dbg_dir = debugfs_create_dir(dev_name(&spec->dev), NULL);
if (IS_ERR_OR_NULL(spec->dbg_dir)) {
dev_err(&spec->dev,
"Cannot create debugfs directory (%ld)\n",
PTR_ERR(spec->dbg_dir));
return PTR_ERR(spec->dbg_dir);
}
spec->dbg_info = debugfs_create_file(SPEC_DBG_INFO_NAME, 0444,
spec->dbg_dir, spec,
&spec_irq_dbg_info_ops);
if (IS_ERR_OR_NULL(spec->dbg_info)) {
dev_err(&spec->dev,
"Cannot create debugfs file \"%s\" (%ld)\n",
SPEC_DBG_INFO_NAME, PTR_ERR(spec->dbg_info));
return PTR_ERR(spec->dbg_info);
}
return 0;
}
/**
* It removes the debugfs interface
* @spec: SPEC instance
*/
static void spec_irq_debug_exit(struct spec_dev *spec)
{
debugfs_remove_recursive(spec->dbg_dir);
}
/**
* (disable)
*/
......@@ -478,7 +402,6 @@ int spec_irq_init(struct spec_dev *spec)
goto err_req;
}
#endif
spec_irq_debug_init(spec);
err = spec_irq_sw_test(spec);
if (err)
......@@ -487,7 +410,6 @@ int spec_irq_init(struct spec_dev *spec)
return 0;
err_test:
spec_irq_debug_exit(spec);
free_irq(irq, spec);
err_req:
spec_irq_sw_exit(spec);
......@@ -509,7 +431,6 @@ void spec_irq_exit(struct spec_dev *spec)
for (i = 0; i < 7; i++)
gennum_writel(spec, 0, GNINT_CFG(i));
spec_irq_debug_exit(spec);
free_irq(irq, spec);
spec_irq_sw_exit(spec);
spec_irq_gpio_exit(spec);
......
......@@ -38,6 +38,7 @@
#define SPEC_FLAG_BITS (8)
#define SPEC_FLAG_UNLOCK BIT(0)
#define GN4124_GPIO_IRQ_MAX 16
/* Registers for GN4124 access */
enum {
......@@ -130,6 +131,8 @@ struct spec_dev {
struct dentry *dbg_dir;
#define SPEC_DBG_INFO_NAME "info"
struct dentry *dbg_info;
#define SPEC_DBG_FW_NAME "fpga_firmware"
struct dentry *dbg_fw;
struct completion compl;
};
......@@ -187,4 +190,7 @@ extern void spec_fpga_exit(struct spec_dev *spec);
extern int spec_irq_init(struct spec_dev *spec);
extern void spec_irq_exit(struct spec_dev *spec);
extern int spec_dbg_init(struct spec_dev *spec);
extern void spec_dbg_exit(struct spec_dev *spec);
#endif /* __SPEC_H__ */
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