Commit 37034c1b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

staging: dgnc: remove crazy "management" device node

There's no need for a special character device just to get some random
information out of a single serial port driver.  So remove the
dgnc_mgmt.c file, and some structures and ioctl definitions that only it
was using.

Cc: Lidza Louina <lidza.louina@gmail.com>
Cc: Mark Hounschell <markh@compro.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f75c1b29
obj-$(CONFIG_DGNC) += dgnc.o obj-$(CONFIG_DGNC) += dgnc.o
dgnc-objs := dgnc_cls.o dgnc_driver.o\ dgnc-objs := dgnc_cls.o dgnc_driver.o\
dgnc_mgmt.o dgnc_neo.o\ dgnc_neo.o\
dgnc_tty.o dgnc_tty.o
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include "dgnc_driver.h" #include "dgnc_driver.h"
#include "dgnc_pci.h" #include "dgnc_pci.h"
#include "dgnc_mgmt.h"
#include "dgnc_tty.h" #include "dgnc_tty.h"
#include "dgnc_cls.h" #include "dgnc_cls.h"
#include "dgnc_neo.h" #include "dgnc_neo.h"
...@@ -21,22 +20,12 @@ MODULE_AUTHOR("Digi International, http://www.digi.com"); ...@@ -21,22 +20,12 @@ MODULE_AUTHOR("Digi International, http://www.digi.com");
MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line"); MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line");
MODULE_SUPPORTED_DEVICE("dgnc"); MODULE_SUPPORTED_DEVICE("dgnc");
static const struct file_operations dgnc_board_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = dgnc_mgmt_ioctl,
.open = dgnc_mgmt_open,
.release = dgnc_mgmt_close
};
uint dgnc_num_boards; uint dgnc_num_boards;
struct dgnc_board *dgnc_board[MAXBOARDS]; struct dgnc_board *dgnc_board[MAXBOARDS];
DEFINE_SPINLOCK(dgnc_global_lock); DEFINE_SPINLOCK(dgnc_global_lock);
DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */ DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
uint dgnc_major;
int dgnc_poll_tick = 20; /* Poll interval - 20 ms */ int dgnc_poll_tick = 20; /* Poll interval - 20 ms */
static struct class *dgnc_class;
static ulong dgnc_poll_time; /* Time of next poll */ static ulong dgnc_poll_time; /* Time of next poll */
static uint dgnc_poll_stop; /* Used to tell poller to stop */ static uint dgnc_poll_stop; /* Used to tell poller to stop */
static struct timer_list dgnc_poll_timer; static struct timer_list dgnc_poll_timer;
...@@ -379,32 +368,7 @@ static struct pci_driver dgnc_driver = { ...@@ -379,32 +368,7 @@ static struct pci_driver dgnc_driver = {
static int dgnc_start(void) static int dgnc_start(void)
{ {
int rc = 0;
unsigned long flags; unsigned long flags;
struct device *dev;
rc = register_chrdev(0, "dgnc", &dgnc_board_fops);
if (rc < 0) {
pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
return rc;
}
dgnc_major = rc;
dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
if (IS_ERR(dgnc_class)) {
rc = PTR_ERR(dgnc_class);
pr_err(DRVSTR ": Can't create dgnc_mgmt class (%d)\n", rc);
goto failed_class;
}
dev = device_create(dgnc_class, NULL,
MKDEV(dgnc_major, 0),
NULL, "dgnc_mgmt");
if (IS_ERR(dev)) {
rc = PTR_ERR(dev);
pr_err(DRVSTR ": Can't create device (%d)\n", rc);
goto failed_device;
}
/* Start the poller */ /* Start the poller */
spin_lock_irqsave(&dgnc_poll_lock, flags); spin_lock_irqsave(&dgnc_poll_lock, flags);
...@@ -416,13 +380,6 @@ static int dgnc_start(void) ...@@ -416,13 +380,6 @@ static int dgnc_start(void)
add_timer(&dgnc_poll_timer); add_timer(&dgnc_poll_timer);
return 0; return 0;
failed_device:
class_destroy(dgnc_class);
failed_class:
unregister_chrdev(dgnc_major, "dgnc");
return rc;
} }
/* Free all the memory associated with a board */ /* Free all the memory associated with a board */
...@@ -486,10 +443,6 @@ static void cleanup(void) ...@@ -486,10 +443,6 @@ static void cleanup(void)
/* Turn off poller right away. */ /* Turn off poller right away. */
del_timer_sync(&dgnc_poll_timer); del_timer_sync(&dgnc_poll_timer);
device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
class_destroy(dgnc_class);
unregister_chrdev(dgnc_major, "dgnc");
for (i = 0; i < dgnc_num_boards; ++i) { for (i = 0; i < dgnc_num_boards; ++i) {
dgnc_cleanup_tty(dgnc_board[i]); dgnc_cleanup_tty(dgnc_board[i]);
dgnc_cleanup_board(dgnc_board[i]); dgnc_cleanup_board(dgnc_board[i]);
......
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*/
/*
* This file implements the mgmt functionality for the
* Neo and ClassicBoard based product lines.
*/
#include <linux/kernel.h>
#include <linux/ctype.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/serial_reg.h>
#include <linux/termios.h>
#include <linux/uaccess.h>
#include "dgnc_driver.h"
#include "dgnc_pci.h"
#include "dgnc_mgmt.h"
/* Our "in use" variables, to enforce 1 open only */
static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
/**
* dgnc_mgmt_open() - Open the mgmt/downld/dpa device.
*/
int dgnc_mgmt_open(struct inode *inode, struct file *file)
{
unsigned long flags;
unsigned int minor = iminor(inode);
int rc = 0;
spin_lock_irqsave(&dgnc_global_lock, flags);
if (minor >= MAXMGMTDEVICES) {
rc = -ENXIO;
goto out;
}
/* Only allow 1 open at a time on mgmt device */
if (dgnc_mgmt_in_use[minor]) {
rc = -EBUSY;
goto out;
}
dgnc_mgmt_in_use[minor]++;
out:
spin_unlock_irqrestore(&dgnc_global_lock, flags);
return rc;
}
/**
* dgnc_mgmt_close() - Close the mgmt/dpa device
*/
int dgnc_mgmt_close(struct inode *inode, struct file *file)
{
unsigned long flags;
unsigned int minor = iminor(inode);
int rc = 0;
spin_lock_irqsave(&dgnc_global_lock, flags);
if (minor >= MAXMGMTDEVICES) {
rc = -ENXIO;
goto out;
}
dgnc_mgmt_in_use[minor] = 0;
out:
spin_unlock_irqrestore(&dgnc_global_lock, flags);
return rc;
}
/**
* dgnc_mgmt_ioctl() - Ioctl the mgmt/dpa device.
*/
long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
unsigned long flags;
void __user *uarg = (void __user *)arg;
switch (cmd) {
case DIGI_GETDD:
{
/*
* This returns the total number of boards
* in the system, as well as driver version
* and has space for a reserved entry
*/
struct digi_dinfo ddi;
spin_lock_irqsave(&dgnc_global_lock, flags);
memset(&ddi, 0, sizeof(ddi));
ddi.dinfo_nboards = dgnc_num_boards;
sprintf(ddi.dinfo_version, "%s", DG_PART);
spin_unlock_irqrestore(&dgnc_global_lock, flags);
if (copy_to_user(uarg, &ddi, sizeof(ddi)))
return -EFAULT;
break;
}
case DIGI_GETBD:
{
int brd;
struct digi_info di;
if (copy_from_user(&brd, uarg, sizeof(int)))
return -EFAULT;
if (brd < 0 || brd >= dgnc_num_boards)
return -ENODEV;
memset(&di, 0, sizeof(di));
di.info_bdnum = brd;
spin_lock_irqsave(&dgnc_board[brd]->bd_lock, flags);
di.info_bdtype = dgnc_board[brd]->dpatype;
di.info_bdstate = dgnc_board[brd]->dpastatus;
di.info_ioport = 0;
di.info_physaddr = (ulong)dgnc_board[brd]->membase;
di.info_physsize = (ulong)dgnc_board[brd]->membase
- dgnc_board[brd]->membase_end;
if (dgnc_board[brd]->state != BOARD_FAILED)
di.info_nports = dgnc_board[brd]->nasync;
else
di.info_nports = 0;
spin_unlock_irqrestore(&dgnc_board[brd]->bd_lock, flags);
if (copy_to_user(uarg, &di, sizeof(di)))
return -EFAULT;
break;
}
case DIGI_GET_NI_INFO:
{
struct channel_t *ch;
struct ni_info ni;
unsigned char mstat = 0;
uint board = 0;
uint channel = 0;
if (copy_from_user(&ni, uarg, sizeof(ni)))
return -EFAULT;
board = ni.board;
channel = ni.channel;
if (board >= dgnc_num_boards)
return -ENODEV;
if (channel >= dgnc_board[board]->nasync)
return -ENODEV;
ch = dgnc_board[board]->channels[channel];
if (!ch)
return -ENODEV;
memset(&ni, 0, sizeof(ni));
ni.board = board;
ni.channel = channel;
spin_lock_irqsave(&ch->ch_lock, flags);
mstat = ch->ch_mostat | ch->ch_mistat;
if (mstat & UART_MCR_DTR) {
ni.mstat |= TIOCM_DTR;
ni.dtr = TIOCM_DTR;
}
if (mstat & UART_MCR_RTS) {
ni.mstat |= TIOCM_RTS;
ni.rts = TIOCM_RTS;
}
if (mstat & UART_MSR_CTS) {
ni.mstat |= TIOCM_CTS;
ni.cts = TIOCM_CTS;
}
if (mstat & UART_MSR_RI) {
ni.mstat |= TIOCM_RI;
ni.ri = TIOCM_RI;
}
if (mstat & UART_MSR_DCD) {
ni.mstat |= TIOCM_CD;
ni.dcd = TIOCM_CD;
}
if (mstat & UART_MSR_DSR)
ni.mstat |= TIOCM_DSR;
ni.iflag = ch->ch_c_iflag;
ni.oflag = ch->ch_c_oflag;
ni.cflag = ch->ch_c_cflag;
ni.lflag = ch->ch_c_lflag;
if (ch->ch_digi.digi_flags & CTSPACE ||
ch->ch_c_cflag & CRTSCTS)
ni.hflow = 1;
else
ni.hflow = 0;
if ((ch->ch_flags & CH_STOPI) ||
(ch->ch_flags & CH_FORCED_STOPI))
ni.recv_stopped = 1;
else
ni.recv_stopped = 0;
if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP))
ni.xmit_stopped = 1;
else
ni.xmit_stopped = 0;
ni.curtx = ch->ch_txcount;
ni.currx = ch->ch_rxcount;
ni.baud = ch->ch_old_baud;
spin_unlock_irqrestore(&ch->ch_lock, flags);
if (copy_to_user(uarg, &ni, sizeof(ni)))
return -EFAULT;
break;
}
}
return 0;
}
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*/
#ifndef _DGNC_MGMT_H
#define _DGNC_MGMT_H
#define MAXMGMTDEVICES 8
int dgnc_mgmt_open(struct inode *inode, struct file *file);
int dgnc_mgmt_close(struct inode *inode, struct file *file);
long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
#endif /* _DGNC_MGMT_H */
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#define DIGI_SETA (('e' << 8) | 95) /* Set params */ #define DIGI_SETA (('e' << 8) | 95) /* Set params */
#define DIGI_SETAW (('e' << 8) | 96) /* Drain & set params */ #define DIGI_SETAW (('e' << 8) | 96) /* Drain & set params */
#define DIGI_SETAF (('e' << 8) | 97) /* Drain, flush & set params */ #define DIGI_SETAF (('e' << 8) | 97) /* Drain, flush & set params */
#define DIGI_GET_NI_INFO (('d' << 8) | 250) /* Non-intelligent state info */
#define DIGI_LOOPBACK (('d' << 8) | 252) /* Enable/disable UART #define DIGI_LOOPBACK (('d' << 8) | 252) /* Enable/disable UART
* internal loopback * internal loopback
*/ */
...@@ -78,49 +77,6 @@ struct digi_t { ...@@ -78,49 +77,6 @@ struct digi_t {
char digi_term[DIGI_TSIZ]; char digi_term[DIGI_TSIZ];
}; };
/**
* struct digi_dinfo - Driver status information.
* @dinfo_nboards: Number of boards configured.
* @dinfo_reserved: Not used, for future expansion.
* @dinfio_version: Driver version.
*/
struct digi_dinfo {
unsigned int dinfo_nboards;
char dinfo_reserved[12];
char dinfo_version[16];
};
#define DIGI_GETDD (('d' << 8) | 248) /* get driver info */
/**
* struct digi_info - Ioctl commands for per board information.
*
* Physsize and memsize differ when board has "windowed" memory.
*
* @info_bdnum: Board number (0 based).
* @info_ioport: IO port address.
* @indo_physaddr: Memory address.
* @info_physize: Size of host memory window.
* @info_memsize: Amount of dual-port memory on board.
* @info_bdtype: Board type.
* @info_nports: Number of ports.
* @info_bdstate: Board state.
* @info_reserved: Not used, for future expansion.
*/
struct digi_info {
unsigned int info_bdnum;
unsigned int info_ioport;
unsigned int info_physaddr;
unsigned int info_physsize;
unsigned int info_memsize;
unsigned short info_bdtype;
unsigned short info_nports;
char info_bdstate;
char info_reserved[7];
};
#define DIGI_GETBD (('d' << 8) | 249) /* get board info */
/** /**
* struct digi_getbuffer - Holds buffer use counts. * struct digi_getbuffer - Holds buffer use counts.
*/ */
......
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