Commit 0053fe0e authored by Tobin C. Harding's avatar Tobin C. Harding Committed by Greg Kroah-Hartman

staging: dgnc: remove struct member magic numbers

Driver uses magic number members within structs, this is an antiquated
method of catching data errors. We don't do things that way any more.

Remove magic number struct members. Remove all checks to magic
numbers.
Signed-off-by: default avatarTobin C. Harding <me@tobin.cc>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 51061652
......@@ -282,7 +282,7 @@ static inline void cls_clear_break(struct channel_t *ch, int force)
{
unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
spin_lock_irqsave(&ch->ch_lock, flags);
......@@ -314,7 +314,7 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
ushort tail;
unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
spin_lock_irqsave(&ch->ch_lock, flags);
......@@ -386,7 +386,7 @@ static void cls_assert_modem_signals(struct channel_t *ch)
{
unsigned char out;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
out = ch->ch_mostat;
......@@ -409,7 +409,7 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
uint len_written = 0;
unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
spin_lock_irqsave(&ch->ch_lock, flags);
......@@ -479,7 +479,7 @@ static void cls_parse_modem(struct channel_t *ch, unsigned char signals)
unsigned char msignals = signals;
unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
/*
......@@ -551,8 +551,6 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
return;
ch = brd->channels[port];
if (ch->magic != DGNC_CHANNEL_MAGIC)
return;
/* Here we try to figure out what caused the interrupt to happen */
while (1) {
......@@ -582,7 +580,7 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
/* Channel lock MUST be held before calling this function! */
static void cls_flush_uart_write(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_XMIT),
......@@ -597,7 +595,7 @@ static void cls_flush_uart_write(struct channel_t *ch)
/* Channel lock MUST be held before calling this function! */
static void cls_flush_uart_read(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
/*
......@@ -627,19 +625,19 @@ static void cls_param(struct tty_struct *tty)
struct channel_t *ch;
struct un_t *un;
if (!tty || tty->magic != TTY_MAGIC)
if (!tty)
return;
un = (struct un_t *)tty->driver_data;
if (!un || un->magic != DGNC_UNIT_MAGIC)
if (!un)
return;
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
if (!bd)
return;
/* If baud rate is zero, flush queues, and set mval to drop DTR. */
......@@ -858,7 +856,7 @@ static void cls_tasklet(unsigned long data)
int state = 0;
int ports = 0;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
if (!bd)
return;
spin_lock_irqsave(&bd->bd_lock, flags);
......@@ -914,7 +912,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
unsigned char poll_reg;
unsigned long flags;
if (!brd || brd->magic != DGNC_BOARD_MAGIC)
if (!brd)
return IRQ_NONE;
spin_lock_irqsave(&brd->bd_intr_lock, flags);
......@@ -961,15 +959,15 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
struct channel_t *ch;
struct un_t *un;
if (!tty || tty->magic != TTY_MAGIC)
if (!tty)
return -ENXIO;
un = (struct un_t *)tty->driver_data;
if (!un || un->magic != DGNC_UNIT_MAGIC)
if (!un)
return -ENXIO;
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return -ENXIO;
spin_lock_irqsave(&ch->ch_lock, flags);
......@@ -986,7 +984,7 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
static void cls_send_start_character(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
if (ch->ch_startc != _POSIX_VDISABLE) {
......@@ -997,7 +995,7 @@ static void cls_send_start_character(struct channel_t *ch)
static void cls_send_stop_character(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
if (ch->ch_stopc != _POSIX_VDISABLE) {
......@@ -1056,7 +1054,7 @@ static uint cls_get_uart_bytes_left(struct channel_t *ch)
unsigned char left = 0;
unsigned char lsr = 0;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return 0;
lsr = readb(&ch->ch_cls_uart->lsr);
......@@ -1080,7 +1078,7 @@ static uint cls_get_uart_bytes_left(struct channel_t *ch)
*/
static void cls_send_break(struct channel_t *ch, int msecs)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
/* If we receive a time of 0, this means turn off the break. */
......@@ -1119,7 +1117,7 @@ static void cls_send_break(struct channel_t *ch, int msecs)
*/
static void cls_send_immediate_char(struct channel_t *ch, unsigned char c)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
writeb(c, &ch->ch_cls_uart->txrx);
......
......@@ -110,7 +110,6 @@ static struct dgnc_board *dgnc_found_board(struct pci_dev *pdev, int id)
return ERR_PTR(-ENOMEM);
/* store the info for the board we've found */
brd->magic = DGNC_BOARD_MAGIC;
brd->boardnum = dgnc_num_boards;
brd->vendor = dgnc_pci_tbl[id].vendor;
brd->device = dgnc_pci_tbl[id].device;
......@@ -444,7 +443,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
{
int i = 0;
if (!brd || brd->magic != DGNC_BOARD_MAGIC)
if (!brd)
return;
switch (brd->device) {
......
......@@ -35,11 +35,6 @@
#define MAXPORTS 8
#define MAXTTYNAMELEN 200
/* Our 3 magic numbers for our board, channel and unit structs */
#define DGNC_BOARD_MAGIC 0x5c6df104
#define DGNC_CHANNEL_MAGIC 0x6c6df104
#define DGNC_UNIT_MAGIC 0x7c6df104
/* Serial port types */
#define DGNC_SERIAL 0
#define DGNC_PRINT 1
......@@ -120,7 +115,6 @@ struct board_ops {
/**
* struct dgnc_board - Per board information.
* @magic: Board magic number.
* @boardnum: Board number (0 - 32).
*
* @type: Type of board.
......@@ -163,7 +157,6 @@ struct board_ops {
* @dgnc_board_table: Proc/<board> entry
*/
struct dgnc_board {
int magic;
int boardnum;
int type;
......@@ -245,7 +238,6 @@ struct device;
/**
* struct un_t - terminal or printer unit
* @magic: Unit magic number.
* @un_open_count: Counter of opens to port.
* @un_tty: Pointer to unit tty structure.
* @un_flags: Unit flags.
......@@ -253,7 +245,6 @@ struct device;
* @un_dev: Minor device number.
*/
struct un_t {
int magic;
struct channel_t *un_ch;
ulong un_time;
uint un_type;
......@@ -295,7 +286,6 @@ struct un_t {
/**
* struct channel_t - Channel information.
* @magic: Channel magic number.
* @dgnc_board: Pointer to board structure.
* @ch_bd: Transparent print structure.
* @ch_tun: Terminal unit information.
......@@ -348,7 +338,6 @@ struct un_t {
* @dgnc_channel_table: Proc/<board>/<channel> entry.
*/
struct channel_t {
int magic;
struct dgnc_board *ch_bd;
struct digi_t ch_digi;
struct un_t ch_tun;
......
......@@ -175,7 +175,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
ch = dgnc_board[board]->channels[channel];
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return -ENODEV;
memset(&ni, 0, sizeof(ni));
......
......@@ -392,7 +392,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
unsigned long flags;
ch = brd->channels[port];
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
/* Here we try to figure out what caused the interrupt to happen */
......@@ -505,14 +505,14 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
int linestatus;
unsigned long flags;
if (!brd || brd->magic != DGNC_BOARD_MAGIC)
if (!brd)
return;
if (port >= brd->maxports)
return;
ch = brd->channels[port];
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
linestatus = readb(&ch->ch_neo_uart->lsr);
......@@ -579,19 +579,19 @@ static void neo_param(struct tty_struct *tty)
struct channel_t *ch;
struct un_t *un;
if (!tty || tty->magic != TTY_MAGIC)
if (!tty)
return;
un = (struct un_t *)tty->driver_data;
if (!un || un->magic != DGNC_UNIT_MAGIC)
if (!un)
return;
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
if (!bd)
return;
/* If baud rate is zero, flush queues, and set mval to drop DTR. */
......@@ -822,7 +822,7 @@ static void neo_tasklet(unsigned long data)
int state = 0;
int ports = 0;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
if (!bd)
return;
spin_lock_irqsave(&bd->bd_lock, flags);
......@@ -839,9 +839,7 @@ static void neo_tasklet(unsigned long data)
if ((state == BOARD_READY) && (ports > 0)) {
for (i = 0; i < ports; i++) {
ch = bd->channels[i];
/* Just being careful... */
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
continue;
/*
......@@ -888,7 +886,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
unsigned long flags;
unsigned long flags2;
if (!brd || brd->magic != DGNC_BOARD_MAGIC)
if (!brd)
return IRQ_NONE;
/* Lock out the slow poller from running on this board. */
......@@ -1023,7 +1021,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
ushort tail;
unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
spin_lock_irqsave(&ch->ch_lock, flags);
......@@ -1195,15 +1193,15 @@ static int neo_drain(struct tty_struct *tty, uint seconds)
struct un_t *un;
int rc = 0;
if (!tty || tty->magic != TTY_MAGIC)
if (!tty)
return -ENXIO;
un = (struct un_t *)tty->driver_data;
if (!un || un->magic != DGNC_UNIT_MAGIC)
if (!un)
return -ENXIO;
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return -ENXIO;
spin_lock_irqsave(&ch->ch_lock, flags);
......@@ -1227,7 +1225,7 @@ static void neo_flush_uart_write(struct channel_t *ch)
unsigned char tmp = 0;
int i = 0;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_XMIT),
......@@ -1258,7 +1256,7 @@ static void neo_flush_uart_read(struct channel_t *ch)
unsigned char tmp = 0;
int i = 0;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
writeb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR,
......@@ -1288,7 +1286,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
uint len_written = 0;
unsigned long flags;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
spin_lock_irqsave(&ch->ch_lock, flags);
......@@ -1425,7 +1423,7 @@ static void neo_parse_modem(struct channel_t *ch, unsigned char signals)
{
unsigned char msignals = signals;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
/*
......@@ -1482,7 +1480,7 @@ static void neo_assert_modem_signals(struct channel_t *ch)
{
unsigned char out;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
out = ch->ch_mostat;
......@@ -1499,7 +1497,7 @@ static void neo_assert_modem_signals(struct channel_t *ch)
static void neo_send_start_character(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
if (ch->ch_startc != _POSIX_VDISABLE) {
......@@ -1512,7 +1510,7 @@ static void neo_send_start_character(struct channel_t *ch)
static void neo_send_stop_character(struct channel_t *ch)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
if (ch->ch_stopc != _POSIX_VDISABLE) {
......@@ -1619,7 +1617,7 @@ static void neo_send_break(struct channel_t *ch, int msecs)
*/
static void neo_send_immediate_char(struct channel_t *ch, unsigned char c)
{
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
if (!ch)
return;
writeb(c, &ch->ch_neo_uart->txrx);
......@@ -1672,7 +1670,7 @@ static void neo_vpd(struct dgnc_board *brd)
unsigned int i = 0;
unsigned int a;
if (!brd || brd->magic != DGNC_BOARD_MAGIC)
if (!brd)
return;
if (!brd->re_map_membase)
......
This diff is collapsed.
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