staging: kpc2000: removed misc device.

Now that all the card information is available via sysfs, the misc
device is no longer necessary.  Removed it.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jeremy Sowden 2019-05-31 11:52:31 +01:00 committed by Greg Kroah-Hartman
parent eb1a5c6472
commit a31f13af7d
2 changed files with 2 additions and 127 deletions

View File

@ -300,111 +300,6 @@ static irqreturn_t kp2000_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED;
}
static int kp2000_cdev_open(struct inode *inode, struct file *filp)
{
struct kp2000_device *pcard = container_of(filp->private_data, struct kp2000_device, miscdev);
dev_dbg(&pcard->pdev->dev, "kp2000_cdev_open(filp = [%p], pcard = [%p])\n", filp, pcard);
filp->private_data = pcard; /* so other methods can access it */
return 0;
}
static int kp2000_cdev_close(struct inode *inode, struct file *filp)
{
struct kp2000_device *pcard = filp->private_data;
dev_dbg(&pcard->pdev->dev, "kp2000_cdev_close(filp = [%p], pcard = [%p])\n", filp, pcard);
return 0;
}
static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf,
size_t count, loff_t *f_pos)
{
struct kp2000_device *pcard = filp->private_data;
int cnt = 0;
int ret;
#define BUFF_CNT 1024
char buff[BUFF_CNT] = {0}; //NOTE: Increase this so it is at least as large as all the scnprintfs. And don't use unbounded strings. "%s"
//NOTE: also, this is a really shitty way to implement the read() call, but it will work for any size 'count'.
if (WARN(NULL == buf, "kp2000_cdev_read: buf is a NULL pointer!\n"))
return -EINVAL;
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Card ID : 0x%08x\n", pcard->card_id);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Version : 0x%08x\n", pcard->build_version);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Date : 0x%08x\n", pcard->build_datestamp);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Time : 0x%08x\n", pcard->build_timestamp);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Offset : 0x%08x\n", pcard->core_table_offset);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Length : 0x%08x\n", pcard->core_table_length);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Hardware Revision : 0x%08x\n", pcard->hardware_revision);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "SSID : 0x%016llx\n", pcard->ssid);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "DDNA : 0x%016llx\n", pcard->ddna);
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Mask : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK));
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Active : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE));
cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "CPLD : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG));
if (*f_pos >= cnt)
return 0;
if (count > cnt)
count = cnt;
ret = copy_to_user(buf, buff + *f_pos, count);
if (ret)
return -EFAULT;
*f_pos += count;
return count;
}
static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num,
unsigned long ioctl_param)
{
struct kp2000_device *pcard = filp->private_data;
dev_dbg(&pcard->pdev->dev, "kp2000_cdev_ioctl(filp = [%p], ioctl_num = 0x%08x, ioctl_param = 0x%016lx) pcard = [%p]\n", filp, ioctl_num, ioctl_param, pcard);
switch (ioctl_num){
case KP2000_IOCTL_GET_CPLD_REG: return readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
case KP2000_IOCTL_GET_PCIE_ERROR_REG: return readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT);
case KP2000_IOCTL_GET_EVERYTHING: {
struct kp2000_regs regs;
int ret;
memset(&regs, 0, sizeof(regs));
regs.card_id = pcard->card_id;
regs.build_version = pcard->build_version;
regs.build_datestamp = pcard->build_datestamp;
regs.build_timestamp = pcard->build_timestamp;
regs.hw_rev = pcard->hardware_revision;
regs.ssid = pcard->ssid;
regs.ddna = pcard->ddna;
regs.cpld_reg = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
ret = copy_to_user((void*)ioctl_param, (void*)&regs, sizeof(regs));
if (ret)
return -EFAULT;
return sizeof(regs);
}
default:
return -ENOTTY;
}
return -ENOTTY;
}
static struct file_operations kp2000_fops = {
.owner = THIS_MODULE,
.open = kp2000_cdev_open,
.release = kp2000_cdev_close,
.read = kp2000_cdev_read,
.llseek = noop_llseek,
.unlocked_ioctl = kp2000_cdev_ioctl,
};
static int kp2000_pcie_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
@ -603,26 +498,11 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
}
/*
* Step 10: Setup misc device
*/
pcard->miscdev.minor = MISC_DYNAMIC_MINOR;
pcard->miscdev.fops = &kp2000_fops;
pcard->miscdev.parent = &pcard->pdev->dev;
pcard->miscdev.name = pcard->name;
err = misc_register(&pcard->miscdev);
if (err) {
dev_err(&pcard->pdev->dev,
"kp2000_pcie_probe: misc_register failed: %d\n", err);
goto out10;
}
/*
* Step 11: Probe cores
* Step 10: Probe cores
*/
err = kp2000_probe_cores(pcard);
if (err)
goto out11;
goto out10;
/*
* Step 12: Enable IRQs in HW
@ -634,8 +514,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
mutex_unlock(&pcard->sem);
return 0;
out11:
misc_deregister(&pcard->miscdev);
out10:
sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list);
out9:
@ -674,7 +552,6 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
mutex_lock(&pcard->sem);
kp2000_remove_cores(pcard);
mfd_remove_devices(PCARD_TO_DEV(pcard));
misc_deregister(&pcard->miscdev);
sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list);
free_irq(pcard->pdev->irq, pcard);
pci_disable_msi(pcard->pdev);

View File

@ -2,7 +2,6 @@
#ifndef KP2000_PCIE_H
#define KP2000_PCIE_H
#include <linux/types.h>
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include "../kpc.h"
#include "dma_common_defs.h"
@ -50,7 +49,6 @@
struct kp2000_device {
struct pci_dev *pdev;
struct miscdevice miscdev;
char name[16];
unsigned int card_num;