#include <linux/pci.h>
#include <linux/delay.h> /* For udelay */
#include <linux/slab.h>
-#include <asm/uaccess.h> /* For copy_from_user/copy_to_user */
+#include <linux/uaccess.h>
#include <linux/sched.h>
#include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/serial_reg.h>
-#include <asm/io.h> /* For read[bwl]/write[bwl] */
+#include <linux/io.h> /* For read[bwl]/write[bwl] */
#include <linux/string.h>
#include <linux/device.h>
#define init_MUTEX(sem) sema_init(sem, 1)
#define DECLARE_MUTEX(name) \
- struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Digi International, http://www.digi.com");
MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line");
MODULE_SUPPORTED_DEVICE("dgap");
-/*
- * insmod command line overrideable parameters
- *
- * NOTE: we use a set of macros to create the variables, which allows
- * us to specify the variable type, name, initial value, and description.
- */
-PARM_INT(debug, 0x00, 0644, "Driver debugging level");
-PARM_INT(rawreadok, 1, 0644, "Bypass flip buffers on input");
-PARM_INT(trcbuf_size, 0x100000, 0644, "Debugging trace buffer size.");
-
-
/**************************************************************************
*
* protos for this file
*
*/
-static int dgap_start(void);
-static void dgap_init_globals(void);
-static int dgap_found_board(struct pci_dev *pdev, int id);
-static void dgap_cleanup_board(struct board_t *brd);
-static void dgap_poll_handler(ulong dummy);
-static int dgap_init_pci(void);
-static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static void dgap_remove_one(struct pci_dev *dev);
-static int dgap_probe1(struct pci_dev *pdev, int card_type);
-static void dgap_mbuf(struct board_t *brd, const char *fmt, ...);
-static int dgap_do_remap(struct board_t *brd);
-static irqreturn_t dgap_intr(int irq, void *voidbrd);
+static int dgap_start(void);
+static void dgap_init_globals(void);
+static int dgap_found_board(struct pci_dev *pdev, int id);
+static void dgap_cleanup_board(struct board_t *brd);
+static void dgap_poll_handler(ulong dummy);
+static int dgap_init_pci(void);
+static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
+static void dgap_remove_one(struct pci_dev *dev);
+static int dgap_probe1(struct pci_dev *pdev, int card_type);
+static int dgap_do_remap(struct board_t *brd);
+static irqreturn_t dgap_intr(int irq, void *voidbrd);
/* Our function prototypes */
static int dgap_tty_open(struct tty_struct *tty, struct file *file);
static void dgap_tty_close(struct tty_struct *tty, struct file *file);
-static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch);
-static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
-static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo);
-static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info);
+static int dgap_block_til_ready(struct tty_struct *tty, struct file *file,
+ struct channel_t *ch);
+static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
+ unsigned long arg);
+static int dgap_tty_digigeta(struct tty_struct *tty,
+ struct digi_t __user *retinfo);
+static int dgap_tty_digiseta(struct tty_struct *tty,
+ struct digi_t __user *new_info);
static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo);
static int dgap_tty_digisetedelay(struct tty_struct *tty, int __user *new_info);
-static int dgap_tty_write_room(struct tty_struct* tty);
-static int dgap_tty_chars_in_buffer(struct tty_struct* tty);
+static int dgap_tty_write_room(struct tty_struct *tty);
+static int dgap_tty_chars_in_buffer(struct tty_struct *tty);
static void dgap_tty_start(struct tty_struct *tty);
static void dgap_tty_stop(struct tty_struct *tty);
static void dgap_tty_throttle(struct tty_struct *tty);
static void dgap_tty_flush_buffer(struct tty_struct *tty);
static void dgap_tty_hangup(struct tty_struct *tty);
static int dgap_wait_for_drain(struct tty_struct *tty);
-static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value);
-static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value);
-static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info);
-static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo);
+static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command,
+ unsigned int __user *value);
+static int dgap_get_modem_info(struct channel_t *ch,
+ unsigned int __user *value);
+static int dgap_tty_digisetcustombaud(struct tty_struct *tty,
+ int __user *new_info);
+static int dgap_tty_digigetcustombaud(struct tty_struct *tty,
+ int __user *retinfo);
static int dgap_tty_tiocmget(struct tty_struct *tty);
-static int dgap_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear);
+static int dgap_tty_tiocmset(struct tty_struct *tty, unsigned int set,
+ unsigned int clear);
static int dgap_tty_send_break(struct tty_struct *tty, int msec);
static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout);
-static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count);
-static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios);
+static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf,
+ int count);
+static void dgap_tty_set_termios(struct tty_struct *tty,
+ struct ktermios *old_termios);
static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c);
static void dgap_tty_send_xchar(struct tty_struct *tty, char ch);
-static int dgap_tty_register(struct board_t *brd);
-static int dgap_tty_preinit(void);
-static int dgap_tty_init(struct board_t *);
-static void dgap_tty_post_uninit(void);
-static void dgap_tty_uninit(struct board_t *);
-static void dgap_carrier(struct channel_t *ch);
-static void dgap_input(struct channel_t *ch);
+static int dgap_tty_register(struct board_t *brd);
+static int dgap_tty_preinit(void);
+static int dgap_tty_init(struct board_t *);
+static void dgap_tty_post_uninit(void);
+static void dgap_tty_uninit(struct board_t *);
+static void dgap_carrier(struct channel_t *ch);
+static void dgap_input(struct channel_t *ch);
/*
* Our function prototypes from dgap_fep5
static int dgap_event(struct board_t *bd);
static void dgap_poll_tasklet(unsigned long data);
-static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds);
+static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1,
+ uchar byte2, uint ncmds);
static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds);
static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt);
static int dgap_param(struct tty_struct *tty);
-static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len);
+static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf,
+ unsigned char *fbuf, int *len);
static uint dgap_get_custom_baud(struct channel_t *ch);
static void dgap_firmware_reset_port(struct channel_t *ch);
static void dgap_err(char *s);
/*
- * Function prototypes from dgap_sysfs.h
- */
+ * Function prototypes from dgap_sysfs.h
+ */
struct board_t;
struct channel_t;
struct un_t;
static uint dgap_config_get_useintr(struct board_t *bd);
static uint dgap_config_get_altpin(struct board_t *bd);
-static int dgap_ms_sleep(ulong ms);
-static void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len);
-static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len);
+static int dgap_ms_sleep(ulong ms);
+static void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios,
+ int len);
+static void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len);
#ifdef DIGI_CONCENTRATORS_SUPPORTED
-static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len);
+static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len);
#endif
-static int dgap_after_config_loaded(int board);
-static int dgap_finalize_board_init(struct board_t *brd);
+static int dgap_after_config_loaded(int board);
+static int dgap_finalize_board_init(struct board_t *brd);
static void dgap_get_vpd(struct board_t *brd);
static void dgap_do_reset_board(struct board_t *brd);
static void dgap_do_wait_for_bios(struct board_t *brd);
static void dgap_do_wait_for_fep(struct board_t *brd);
-static void dgap_sysfs_create(struct board_t *brd);
+static int dgap_tty_register_ports(struct board_t *brd);
static int dgap_firmware_load(struct pci_dev *pdev, int card_type);
-/* Driver load/unload functions */
-int dgap_init_module(void);
-void dgap_cleanup_module(void);
+/* Driver unload function */
+static void dgap_cleanup_module(void);
-module_init(dgap_init_module);
module_exit(dgap_cleanup_module);
-
/*
* File operations permitted on Control/Management major.
*/
-static struct file_operations DgapBoardFops =
-{
- .owner = THIS_MODULE,
+static const struct file_operations DgapBoardFops = {
+ .owner = THIS_MODULE,
};
-
/*
* Globals
*/
-static uint dgap_NumBoards;
-static struct board_t *dgap_Board[MAXBOARDS];
-DEFINE_SPINLOCK(dgap_global_lock);
-static ulong dgap_poll_counter;
-static char *dgap_config_buf;
-static int dgap_driver_state = DRIVER_INITIALIZED;
+static uint dgap_NumBoards;
+static struct board_t *dgap_Board[MAXBOARDS];
+static ulong dgap_poll_counter;
+static char *dgap_config_buf;
+static int dgap_driver_state = DRIVER_INITIALIZED;
DEFINE_SPINLOCK(dgap_dl_lock);
-static wait_queue_head_t dgap_dl_wait;
-static int dgap_dl_action;
-static int dgap_poll_tick = 20; /* Poll interval - 20 ms */
+static wait_queue_head_t dgap_dl_wait;
+static int dgap_dl_action;
+static int dgap_poll_tick = 20; /* Poll interval - 20 ms */
/*
* Static vars.
*/
-static int dgap_Major_Control_Registered = FALSE;
-static uint dgap_driver_start = FALSE;
+static int dgap_Major_Control_Registered = FALSE;
+static uint dgap_driver_start = FALSE;
-static struct class * dgap_class;
+static struct class *dgap_class;
-static struct board_t *dgap_BoardsByMajor[256];
-static uchar *dgap_TmpWriteBuf = NULL;
+static struct board_t *dgap_BoardsByMajor[256];
+static uchar *dgap_TmpWriteBuf;
DECLARE_MUTEX(dgap_TmpWriteSem);
static uint dgap_count = 500;
* Poller stuff
*/
DEFINE_SPINLOCK(dgap_poll_lock); /* Poll scheduling lock */
-static ulong dgap_poll_time; /* Time of next poll */
-static uint dgap_poll_stop; /* Used to tell poller to stop */
+static ulong dgap_poll_time; /* Time of next poll */
+static uint dgap_poll_stop; /* Used to tell poller to stop */
static struct timer_list dgap_poll_timer;
/*
*/
static struct pci_device_id dgap_pci_tbl[] = {
- { DIGI_VID, PCI_DEVICE_XEM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
- { DIGI_VID, PCI_DEVICE_CX_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
- { DIGI_VID, PCI_DEVICE_CX_IBM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
- { DIGI_VID, PCI_DEVICE_EPCJ_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 },
- { DIGI_VID, PCI_DEVICE_920_2_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
- { DIGI_VID, PCI_DEVICE_920_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 },
- { DIGI_VID, PCI_DEVICE_920_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 },
- { DIGI_VID, PCI_DEVICE_XR_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 },
- { DIGI_VID, PCI_DEVICE_XRJ_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
- { DIGI_VID, PCI_DEVICE_XR_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 },
- { DIGI_VID, PCI_DEVICE_XR_IBM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 },
- { DIGI_VID, PCI_DEVICE_XR_SAIP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 },
- { DIGI_VID, PCI_DEVICE_XR_BULL_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 },
- { DIGI_VID, PCI_DEVICE_920_8_HP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 },
- { DIGI_VID, PCI_DEVICE_XEM_HP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 },
+ { DIGI_VID, PCI_DEV_XEM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+ { DIGI_VID, PCI_DEV_CX_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
+ { DIGI_VID, PCI_DEV_CX_IBM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
+ { DIGI_VID, PCI_DEV_EPCJ_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 },
+ { DIGI_VID, PCI_DEV_920_2_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
+ { DIGI_VID, PCI_DEV_920_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 },
+ { DIGI_VID, PCI_DEV_920_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 },
+ { DIGI_VID, PCI_DEV_XR_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 },
+ { DIGI_VID, PCI_DEV_XRJ_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
+ { DIGI_VID, PCI_DEV_XR_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 },
+ { DIGI_VID, PCI_DEV_XR_IBM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 },
+ { DIGI_VID, PCI_DEV_XR_SAIP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 },
+ { DIGI_VID, PCI_DEV_XR_BULL_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 },
+ { DIGI_VID, PCI_DEV_920_8_HP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 },
+ { DIGI_VID, PCI_DEV_XEM_HP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 },
{0,} /* 0 terminated list. */
};
MODULE_DEVICE_TABLE(pci, dgap_pci_tbl);
-
/*
* A generic list of Product names, PCI Vendor ID, and PCI Device ID.
*/
uint dpatype;
};
-static struct board_id dgap_Ids[] =
-{
- { PPCM, PCI_DEVICE_XEM_NAME, 64, (T_PCXM | T_PCLITE | T_PCIBUS) },
- { PCX, PCI_DEVICE_CX_NAME, 128, (T_CX | T_PCIBUS) },
- { PCX, PCI_DEVICE_CX_IBM_NAME, 128, (T_CX | T_PCIBUS) },
- { PEPC, PCI_DEVICE_EPCJ_NAME, 224, (T_EPC | T_PCIBUS) },
- { APORT2_920P, PCI_DEVICE_920_2_NAME, 2, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { APORT4_920P, PCI_DEVICE_920_4_NAME, 4, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { APORT8_920P, PCI_DEVICE_920_8_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { PAPORT8, PCI_DEVICE_XR_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { PAPORT8, PCI_DEVICE_XRJ_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { PAPORT8, PCI_DEVICE_XR_422_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { PAPORT8, PCI_DEVICE_XR_IBM_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { PAPORT8, PCI_DEVICE_XR_SAIP_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { PAPORT8, PCI_DEVICE_XR_BULL_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { APORT8_920P, PCI_DEVICE_920_8_HP_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) },
- { PPCM, PCI_DEVICE_XEM_HP_NAME, 64, (T_PCXM | T_PCLITE | T_PCIBUS) },
+static struct board_id dgap_Ids[] = {
+ { PPCM, PCI_DEV_XEM_NAME, 64, (T_PCXM|T_PCLITE|T_PCIBUS) },
+ { PCX, PCI_DEV_CX_NAME, 128, (T_CX|T_PCIBUS) },
+ { PCX, PCI_DEV_CX_IBM_NAME, 128, (T_CX|T_PCIBUS) },
+ { PEPC, PCI_DEV_EPCJ_NAME, 224, (T_EPC|T_PCIBUS) },
+ { APORT2_920P, PCI_DEV_920_2_NAME, 2, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { APORT4_920P, PCI_DEV_920_4_NAME, 4, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { APORT8_920P, PCI_DEV_920_8_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { PAPORT8, PCI_DEV_XR_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { PAPORT8, PCI_DEV_XRJ_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { PAPORT8, PCI_DEV_XR_422_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { PAPORT8, PCI_DEV_XR_IBM_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { PAPORT8, PCI_DEV_XR_SAIP_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { PAPORT8, PCI_DEV_XR_BULL_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { APORT8_920P, PCI_DEV_920_8_HP_NAME, 8, (T_PCXR|T_PCLITE|T_PCIBUS) },
+ { PPCM, PCI_DEV_XEM_HP_NAME, 64, (T_PCXM|T_PCLITE|T_PCIBUS) },
{0,} /* 0 terminated list. */
};
{0,}
};
-
static char *dgap_driver_state_text[] = {
"Driver Initialized",
"Driver needs configuration load.",
.digi_term = "ansi" /* default terminal type */
};
-
/*
* Define a local default termios struct. All ports will be created
* with this termios initially.
* 1 stop bit.
*/
-static struct ktermios DgapDefaultTermios =
-{
+static struct ktermios DgapDefaultTermios = {
.c_iflag = (DEFAULT_IFLAGS), /* iflags */
.c_oflag = (DEFAULT_OFLAGS), /* oflags */
.c_cflag = (DEFAULT_CFLAGS), /* cflags */
.c_lflag = (DEFAULT_LFLAGS), /* lflags */
.c_cc = INIT_C_CC,
- .c_line = 0,
+ .c_line = 0,
};
static const struct tty_operations dgap_tty_ops = {
};
static struct toklist dgap_tlist[] = {
- { BEGIN, "config_begin" },
- { END, "config_end" },
- { BOARD, "board" },
- { PCX, "Digi_AccelePort_C/X_PCI" }, /* C/X_PCI */
- { PEPC, "Digi_AccelePort_EPC/X_PCI" }, /* EPC/X_PCI */
- { PPCM, "Digi_AccelePort_Xem_PCI" }, /* PCI/Xem */
- { APORT2_920P, "Digi_AccelePort_2r_920_PCI" },
- { APORT4_920P, "Digi_AccelePort_4r_920_PCI" },
- { APORT8_920P, "Digi_AccelePort_8r_920_PCI" },
- { PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" },
- { PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" },
- { IO, "io" },
- { PCIINFO, "pciinfo" },
- { LINE, "line" },
- { CONC, "conc" },
- { CONC, "concentrator" },
- { CX, "cx" },
- { CX, "ccon" },
- { EPC, "epccon" },
- { EPC, "epc" },
- { MOD, "module" },
- { ID, "id" },
- { STARTO, "start" },
- { SPEED, "speed" },
- { CABLE, "cable" },
- { CONNECT, "connect" },
- { METHOD, "method" },
- { STATUS, "status" },
- { CUSTOM, "Custom" },
- { BASIC, "Basic" },
- { MEM, "mem" },
- { MEM, "memory" },
- { PORTS, "ports" },
- { MODEM, "modem" },
- { NPORTS, "nports" },
- { TTYN, "ttyname" },
- { CU, "cuname" },
- { PRINT, "prname" },
- { CMAJOR, "major" },
- { ALTPIN, "altpin" },
- { USEINTR, "useintr" },
- { TTSIZ, "ttysize" },
- { CHSIZ, "chsize" },
- { BSSIZ, "boardsize" },
- { UNTSIZ, "schedsize" },
- { F2SIZ, "f2200size" },
- { VPSIZ, "vpixsize" },
- { 0, NULL }
+ { BEGIN, "config_begin" },
+ { END, "config_end" },
+ { BOARD, "board" },
+ { PCX, "Digi_AccelePort_C/X_PCI" },
+ { PEPC, "Digi_AccelePort_EPC/X_PCI" },
+ { PPCM, "Digi_AccelePort_Xem_PCI" },
+ { APORT2_920P, "Digi_AccelePort_2r_920_PCI" },
+ { APORT4_920P, "Digi_AccelePort_4r_920_PCI" },
+ { APORT8_920P, "Digi_AccelePort_8r_920_PCI" },
+ { PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" },
+ { PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" },
+ { IO, "io" },
+ { PCIINFO, "pciinfo" },
+ { LINE, "line" },
+ { CONC, "conc" },
+ { CONC, "concentrator" },
+ { CX, "cx" },
+ { CX, "ccon" },
+ { EPC, "epccon" },
+ { EPC, "epc" },
+ { MOD, "module" },
+ { ID, "id" },
+ { STARTO, "start" },
+ { SPEED, "speed" },
+ { CABLE, "cable" },
+ { CONNECT, "connect" },
+ { METHOD, "method" },
+ { STATUS, "status" },
+ { CUSTOM, "Custom" },
+ { BASIC, "Basic" },
+ { MEM, "mem" },
+ { MEM, "memory" },
+ { PORTS, "ports" },
+ { MODEM, "modem" },
+ { NPORTS, "nports" },
+ { TTYN, "ttyname" },
+ { CU, "cuname" },
+ { PRINT, "prname" },
+ { CMAJOR, "major" },
+ { ALTPIN, "altpin" },
+ { USEINTR, "useintr" },
+ { TTSIZ, "ttysize" },
+ { CHSIZ, "chsize" },
+ { BSSIZ, "boardsize" },
+ { UNTSIZ, "schedsize" },
+ { F2SIZ, "f2200size" },
+ { VPSIZ, "vpixsize" },
+ { 0, NULL }
};
/************************************************************************
*
* Module load. This is where it all starts.
*/
-int dgap_init_module(void)
+static int dgap_init_module(void)
{
int rc = 0;
- APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART));
+ pr_info("%s, Digi International Part Number %s\n", DG_NAME, DG_PART);
dgap_driver_state = DRIVER_NEED_CONFIG_LOAD;
*/
rc = dgap_start();
- if (rc < 0) {
- return(rc);
- }
+ if (rc < 0)
+ return rc;
/*
* Find and configure all the cards
if (dgap_NumBoards)
pci_unregister_driver(&dgap_driver);
else
- printk("WARNING: dgap driver load failed. No DGAP boards found.\n");
+ pr_err("dgap: driver load failed. No boards found.\n");
dgap_cleanup_module();
- }
- else {
+ } else {
dgap_create_driver_sysfiles(&dgap_driver);
dgap_driver_state = DRIVER_READY;
}
- DPR_INIT(("Finished init_module. Returning %d\n", rc));
- return (rc);
+ return rc;
}
-
+module_init(dgap_init_module);
/*
* Start of driver.
dgap_driver_start = TRUE;
- /* make sure that the globals are init'd before we do anything else */
- dgap_init_globals();
+ /*
+ * make sure that the globals are
+ * init'd before we do anything else
+ */
+ dgap_init_globals();
dgap_NumBoards = 0;
- APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
+ pr_info("For the tools package please visit http://www.digi.com\n");
/*
* Register our base character device into the kernel.
- * This allows the download daemon to connect to the downld device
- * before any of the boards are init'ed.
*/
if (!dgap_Major_Control_Registered) {
/*
* Register management/dpa devices
*/
- rc = register_chrdev(DIGI_DGAP_MAJOR, "dgap", &DgapBoardFops);
- if (rc < 0) {
- APR(("Can't register dgap driver device (%d)\n", rc));
- return (rc);
- }
+ rc = register_chrdev(DIGI_DGAP_MAJOR, "dgap",
+ &DgapBoardFops);
+ if (rc < 0)
+ return rc;
dgap_class = class_create(THIS_MODULE, "dgap_mgmt");
device_create(dgap_class, NULL,
*/
rc = dgap_tty_preinit();
- if (rc < 0) {
- APR(("tty preinit - not enough memory (%d)\n", rc));
- return(rc);
- }
+ if (rc < 0)
+ return rc;
/* Start the poller */
DGAP_LOCK(dgap_poll_lock, flags);
dgap_driver_state = DRIVER_NEED_CONFIG_LOAD;
}
- return (rc);
+ return rc;
}
-
/*
* Register pci driver, and return how many boards we have.
*/
return pci_register_driver(&dgap_driver);
}
-
/* returns count (>= 0), or negative on error */
static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
rc = dgap_probe1(pdev, ent->driver_data);
if (rc == 0) {
dgap_NumBoards++;
- DPR_INIT(("Incrementing numboards to %d\n", dgap_NumBoards));
rc = dgap_firmware_load(pdev, ent->driver_data);
}
}
return rc;
}
-
static int dgap_probe1(struct pci_dev *pdev, int card_type)
{
return dgap_found_board(pdev, card_type);
}
-
static void dgap_remove_one(struct pci_dev *dev)
{
/* Do Nothing */
}
-
/*
* dgap_cleanup_module()
*
* Module unload. This is where it all ends.
*/
-void dgap_cleanup_module(void)
+static void dgap_cleanup_module(void)
{
int i;
ulong lock_flags;
DGAP_UNLOCK(dgap_poll_lock, lock_flags);
/* Turn off poller right away. */
- del_timer_sync( &dgap_poll_timer);
+ del_timer_sync(&dgap_poll_timer);
dgap_remove_driver_sysfiles(&dgap_driver);
pci_unregister_driver(&dgap_driver);
}
-
/*
* dgap_cleanup_board()
*
{
int i = 0;
- if(!brd || brd->magic != DGAP_BOARD_MAGIC)
- return;
+ if (!brd || brd->magic != DGAP_BOARD_MAGIC)
+ return;
if (brd->intr_used && brd->irq)
free_irq(brd->irq, brd);
brd->re_map_membase = NULL;
}
- if (brd->msgbuf_head) {
- unsigned long flags;
-
- DGAP_LOCK(dgap_global_lock, flags);
- brd->msgbuf = NULL;
- printk("%s", brd->msgbuf_head);
- kfree(brd->msgbuf_head);
- brd->msgbuf_head = NULL;
- DGAP_UNLOCK(dgap_global_lock, flags);
- }
-
/* Free all allocated channels structs */
- for (i = 0; i < MAXPORTS ; i++) {
- if (brd->channels[i]) {
- kfree(brd->channels[i]);
- brd->channels[i] = NULL;
- }
- }
+ for (i = 0; i < MAXPORTS ; i++)
+ kfree(brd->channels[i]);
kfree(brd->flipbuf);
kfree(brd->flipflagbuf);
dgap_Board[brd->boardnum] = NULL;
- kfree(brd);
+ kfree(brd);
}
-
/*
* dgap_found_board()
*
struct board_t *brd;
unsigned int pci_irq;
int i = 0;
- unsigned long flags;
/* get the board structure and prep it */
- brd = dgap_Board[dgap_NumBoards] =
- (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
- if (!brd) {
- APR(("memory allocation for board structure failed\n"));
- return(-ENOMEM);
- }
+ brd = kzalloc(sizeof(struct board_t), GFP_KERNEL);
+ if (!brd)
+ return -ENOMEM;
- /* make a temporary message buffer for the boot messages */
- brd->msgbuf = brd->msgbuf_head =
- (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
- if(!brd->msgbuf) {
- kfree(brd);
- APR(("memory allocation for board msgbuf failed\n"));
- return(-ENOMEM);
- }
+ dgap_Board[dgap_NumBoards] = brd;
/* store the info for the board we've found */
brd->magic = DGAP_BOARD_MAGIC;
brd->wait_for_bios = 0;
brd->wait_for_fep = 0;
- for (i = 0; i < MAXPORTS; i++) {
+ for (i = 0; i < MAXPORTS; i++)
brd->channels[i] = NULL;
- }
/* store which card & revision we have */
pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
/* get the PCI Base Address Registers */
/* Xr Jupiter and EPC use BAR 2 */
- if (brd->device == PCI_DEVICE_XRJ_DID || brd->device == PCI_DEVICE_EPCJ_DID) {
+ if (brd->device == PCI_DEV_XRJ_DID || brd->device == PCI_DEV_EPCJ_DID) {
brd->membase = pci_resource_start(pdev, 2);
brd->membase_end = pci_resource_end(pdev, 2);
}
brd->membase_end = pci_resource_end(pdev, 0);
}
- if (!brd->membase) {
- APR(("card has no PCI IO resources, failing board.\n"));
+ if (!brd->membase)
return -ENODEV;
- }
if (brd->membase & 1)
brd->membase &= ~3;
brd->port = brd->membase + PCI_IO_OFFSET;
brd->port_end = brd->port + PCI_IO_SIZE;
-
/*
* Special initialization for non-PLX boards
*/
- if (brd->device != PCI_DEVICE_XRJ_DID && brd->device != PCI_DEVICE_EPCJ_DID) {
+ if (brd->device != PCI_DEV_XRJ_DID && brd->device != PCI_DEV_EPCJ_DID) {
unsigned short cmd;
pci_write_config_byte(pdev, 0x40, 0);
}
/* init our poll helper tasklet */
- tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet, (unsigned long) brd);
-
- /* Log the information about the board */
- dgap_mbuf(brd, DRVSTR": board %d: %s (rev %d), irq %d\n",
- dgap_NumBoards, brd->name, brd->rev, brd->irq);
-
- DPR_INIT(("dgap_scan(%d) - printing out the msgbuf\n", i));
- DGAP_LOCK(dgap_global_lock, flags);
- brd->msgbuf = NULL;
- printk("%s", brd->msgbuf_head);
- kfree(brd->msgbuf_head);
- brd->msgbuf_head = NULL;
- DGAP_UNLOCK(dgap_global_lock, flags);
+ tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet,
+ (unsigned long) brd);
i = dgap_do_remap(brd);
if (i)
else
brd->state = NEED_RESET;
- return(0);
+ return 0;
}
-static int dgap_finalize_board_init(struct board_t *brd) {
-
- int rc;
-
- DPR_INIT(("dgap_finalize_board_init() - start\n"));
+static int dgap_finalize_board_init(struct board_t *brd)
+{
+ int rc;
if (!brd || brd->magic != DGAP_BOARD_MAGIC)
- return(-ENODEV);
-
- DPR_INIT(("dgap_finalize_board_init() - start #2\n"));
+ return -ENODEV;
brd->use_interrupts = dgap_config_get_useintr(brd);
rc = request_irq(brd->irq, dgap_intr, IRQF_SHARED, "DGAP", brd);
- if (rc) {
- dgap_mbuf(brd, DRVSTR": Failed to hook IRQ %d. Board will work in poll mode.\n",
- brd->irq);
+ if (rc)
brd->intr_used = 0;
- }
else
brd->intr_used = 1;
} else {
brd->intr_used = 0;
}
- return(0);
+ return 0;
}
static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
ret = dgap_tty_init(brd);
if (ret < 0) {
dgap_tty_uninit(brd);
- pr_err("dgap: Can't init tty devices (%d)\n", ret);
return ret;
}
- dgap_sysfs_create(brd);
+ ret = dgap_tty_register_ports(brd);
+ if (ret)
+ return ret;
brd->state = BOARD_READY;
brd->dpastatus = BD_RUNNING;
if (!brd || brd->magic != DGAP_BOARD_MAGIC)
return -ENXIO;
- if (!request_mem_region(brd->membase, 0x200000, "dgap")) {
- APR(("dgap: mem_region %lx already in use.\n", brd->membase));
+ if (!request_mem_region(brd->membase, 0x200000, "dgap"))
return -ENOMEM;
- }
- if (!request_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000, "dgap")) {
- APR(("dgap: mem_region IO %lx already in use.\n",
- brd->membase + PCI_IO_OFFSET));
+ if (!request_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000,
+ "dgap")) {
release_mem_region(brd->membase, 0x200000);
return -ENOMEM;
- }
+ }
brd->re_map_membase = ioremap(brd->membase, 0x200000);
if (!brd->re_map_membase) {
- APR(("dgap: ioremap mem %lx cannot be mapped.\n", brd->membase));
release_mem_region(brd->membase, 0x200000);
release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000);
return -ENOMEM;
release_mem_region(brd->membase, 0x200000);
release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000);
iounmap(brd->re_map_membase);
- APR(("dgap: ioremap IO mem %lx cannot be mapped.\n",
- brd->membase + PCI_IO_OFFSET));
return -ENOMEM;
}
- DPR_INIT(("remapped io: 0x%p remapped mem: 0x%p\n",
- brd->re_map_port, brd->re_map_membase));
return 0;
}
-
/*****************************************************************************
*
* Function:
static void dgap_poll_handler(ulong dummy)
{
int i;
- struct board_t *brd;
- unsigned long lock_flags;
+ struct board_t *brd;
+ unsigned long lock_flags;
ulong new_time;
dgap_poll_counter++;
-
/*
* Do not start the board state machine until
* driver tells us its up and running, and has
* Otherwise, use our new tasklet based poller, which should
* speed things up for multiple boards.
*/
- if ( (dgap_NumBoards == 1) || (num_online_cpus() <= 1) ) {
+ if ((dgap_NumBoards == 1) || (num_online_cpus() <= 1)) {
for (i = 0; i < dgap_NumBoards; i++) {
brd = dgap_Board[i];
- if (brd->state == BOARD_FAILED) {
+ if (brd->state == BOARD_FAILED)
continue;
- }
- if (!brd->intr_running) {
+ if (!brd->intr_running)
/* Call the real board poller directly */
dgap_poll_tasklet((unsigned long) brd);
- }
}
- }
- else {
- /* Go thru each board, kicking off a tasklet for each if needed */
+ } else {
+ /*
+ * Go thru each board, kicking off a
+ * tasklet for each if needed
+ */
for (i = 0; i < dgap_NumBoards; i++) {
brd = dgap_Board[i];
/*
* Attempt to grab the board lock.
*
- * If we can't get it, no big deal, the next poll will get it.
- * Basically, I just really don't want to spin in here, because I want
- * to kick off my tasklets as fast as I can, and then get out the poller.
+ * If we can't get it, no big deal, the next poll
+ * will get it. Basically, I just really don't want
+ * to spin in here, because I want to kick off my
+ * tasklets as fast as I can, and then get out the
+ * poller.
*/
- if (!spin_trylock(&brd->bd_lock)) {
+ if (!spin_trylock(&brd->bd_lock))
continue;
- }
- /* If board is in a failed state, don't bother scheduling a tasklet */
+ /*
+ * If board is in a failed state, don't bother
+ * scheduling a tasklet
+ */
if (brd->state == BOARD_FAILED) {
spin_unlock(&brd->bd_lock);
continue;
}
/* Schedule a poll helper task */
- if (!brd->intr_running) {
+ if (!brd->intr_running)
tasklet_schedule(&brd->helper_tasklet);
- }
/*
* Can't do DGAP_UNLOCK here, as we don't have
/*
* Schedule ourself back at the nominal wakeup interval.
*/
- DGAP_LOCK(dgap_poll_lock, lock_flags );
+ DGAP_LOCK(dgap_poll_lock, lock_flags);
dgap_poll_time += dgap_jiffies_from_ms(dgap_poll_tick);
new_time = dgap_poll_time - jiffies;
if ((ulong) new_time >= 2 * dgap_poll_tick) {
- dgap_poll_time = jiffies + dgap_jiffies_from_ms(dgap_poll_tick);
+ dgap_poll_time =
+ jiffies + dgap_jiffies_from_ms(dgap_poll_tick);
}
dgap_poll_timer.function = dgap_poll_handler;
dgap_poll_timer.data = 0;
dgap_poll_timer.expires = dgap_poll_time;
- DGAP_UNLOCK(dgap_poll_lock, lock_flags );
+ DGAP_UNLOCK(dgap_poll_lock, lock_flags);
if (!dgap_poll_stop)
add_timer(&dgap_poll_timer);
}
-
-
-
/*
* dgap_intr()
*
{
struct board_t *brd = (struct board_t *) voidbrd;
- if (!brd) {
- APR(("Received interrupt (%d) with null board associated\n", irq));
+ if (!brd)
return IRQ_NONE;
- }
/*
* Check to make sure its for us.
*/
- if (brd->magic != DGAP_BOARD_MAGIC) {
- APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n", irq));
+ if (brd->magic != DGAP_BOARD_MAGIC)
return IRQ_NONE;
- }
brd->intr_count++;
return IRQ_HANDLED;
}
-
/*
* dgap_init_globals()
*
{
int i = 0;
- dgap_rawreadok = rawreadok;
- dgap_trcbuf_size = trcbuf_size;
- dgap_debug = debug;
-
- for (i = 0; i < MAXBOARDS; i++) {
+ for (i = 0; i < MAXBOARDS; i++)
dgap_Board[i] = NULL;
- }
- init_timer( &dgap_poll_timer );
+ init_timer(&dgap_poll_timer);
init_waitqueue_head(&dgap_dl_wait);
dgap_dl_action = 0;
}
-
/************************************************************************
*
* Utility functions
*
************************************************************************/
-
-/*
- * dgap_mbuf()
- *
- * Used to print to the message buffer during board init.
- */
-static void dgap_mbuf(struct board_t *brd, const char *fmt, ...) {
- va_list ap;
- char buf[1024];
- int i;
- unsigned long flags;
- size_t length;
-
- DGAP_LOCK(dgap_global_lock, flags);
-
- /* Format buf using fmt and arguments contained in ap. */
- va_start(ap, fmt);
- i = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- DPR((buf));
-
- if (!brd || !brd->msgbuf) {
- printk("%s", buf);
- DGAP_UNLOCK(dgap_global_lock, flags);
- return;
- }
-
- length = strlen(buf) + 1;
- if (brd->msgbuf - brd->msgbuf_head < length)
- length = brd->msgbuf - brd->msgbuf_head;
- memcpy(brd->msgbuf, buf, length);
- brd->msgbuf += length;
-
- DGAP_UNLOCK(dgap_global_lock, flags);
-}
-
-
/*
* dgap_ms_sleep()
*
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout((ms * HZ) / 1000);
- return (signal_pending(current));
+ return signal_pending(current);
}
-
-
-
/************************************************************************
*
* TTY Initialization/Cleanup Functions
*/
static int dgap_tty_preinit(void)
{
- unsigned long flags;
-
- DGAP_LOCK(dgap_global_lock, flags);
-
/*
* Allocate a buffer for doing the copy from user space to
* kernel space in dgap_input(). We only use one buffer and
*/
dgap_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_ATOMIC);
- if (!dgap_TmpWriteBuf) {
- DGAP_UNLOCK(dgap_global_lock, flags);
- DPR_INIT(("unable to allocate tmp write buf"));
- return (-ENOMEM);
- }
+ if (!dgap_TmpWriteBuf)
+ return -ENOMEM;
- DGAP_UNLOCK(dgap_global_lock, flags);
- return(0);
+ return 0;
}
-
/*
* dgap_tty_register()
*
{
int rc = 0;
- DPR_INIT(("tty_register start"));
-
brd->SerialDriver = alloc_tty_driver(MAXPORTS);
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgap_%d_", brd->boardnum);
brd->SerialDriver->subtype = SERIAL_TYPE_NORMAL;
brd->SerialDriver->init_termios = DgapDefaultTermios;
brd->SerialDriver->driver_name = DRVSTR;
- brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
+ brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
/* The kernel wants space to store pointers to tty_structs */
- brd->SerialDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
+ brd->SerialDriver->ttys =
+ kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
if (!brd->SerialDriver->ttys)
- return(-ENOMEM);
+ return -ENOMEM;
/*
* Entry points for driver. Called by the kernel from
brd->PrintDriver->subtype = SERIAL_TYPE_NORMAL;
brd->PrintDriver->init_termios = DgapDefaultTermios;
brd->PrintDriver->driver_name = DRVSTR;
- brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
+ brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);
/* The kernel wants space to store pointers to tty_structs */
- brd->PrintDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
+ brd->PrintDriver->ttys =
+ kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
if (!brd->PrintDriver->ttys)
- return(-ENOMEM);
+ return -ENOMEM;
/*
* Entry points for driver. Called by the kernel from
if (!brd->dgap_Major_Serial_Registered) {
/* Register tty devices */
rc = tty_register_driver(brd->SerialDriver);
- if (rc < 0) {
- APR(("Can't register tty device (%d)\n", rc));
- return(rc);
- }
+ if (rc < 0)
+ return rc;
brd->dgap_Major_Serial_Registered = TRUE;
dgap_BoardsByMajor[brd->SerialDriver->major] = brd;
brd->dgap_Serial_Major = brd->SerialDriver->major;
if (!brd->dgap_Major_TransparentPrint_Registered) {
/* Register Transparent Print devices */
- rc = tty_register_driver(brd->PrintDriver);
- if (rc < 0) {
- APR(("Can't register Transparent Print device (%d)\n", rc));
- return(rc);
- }
+ rc = tty_register_driver(brd->PrintDriver);
+ if (rc < 0)
+ return rc;
brd->dgap_Major_TransparentPrint_Registered = TRUE;
dgap_BoardsByMajor[brd->PrintDriver->major] = brd;
brd->dgap_TransparentPrint_Major = brd->PrintDriver->major;
}
- DPR_INIT(("DGAP REGISTER TTY: MAJORS: %d %d\n", brd->SerialDriver->major,
- brd->PrintDriver->major));
-
- return (rc);
+ return rc;
}
-
/*
* dgap_tty_init()
*
struct cm_t *cm;
if (!brd)
- return (-ENXIO);
-
- DPR_INIT(("dgap_tty_init start\n"));
+ return -ENXIO;
/*
* Initialize board structure elements.
brd->nasync = dgap_config_get_number_of_ports(brd);
- if (!brd->nasync) {
+ if (!brd->nasync)
brd->nasync = brd->maxports;
- }
- if (brd->nasync > brd->maxports) {
+ if (brd->nasync > brd->maxports)
brd->nasync = brd->maxports;
- }
if (true_count != brd->nasync) {
if ((brd->type == PPCM) && (true_count == 64)) {
- APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n",
- brd->name, brd->nasync, true_count));
- }
- else if ((brd->type == PPCM) && (true_count == 0)) {
- APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n",
- brd->name, brd->nasync, true_count));
- }
- else {
- APR(("***WARNING**** %s configured for %d ports, has %d ports.\n",
- brd->name, brd->nasync, true_count));
- }
+ pr_warn("dgap: %s configured for %d ports, has %d ports.\n",
+ brd->name, brd->nasync, true_count);
+ pr_warn("dgap: Please make SURE the EBI cable running from the card\n");
+ pr_warn("dgap: to each EM module is plugged into EBI IN!\n");
+ } else if ((brd->type == PPCM) && (true_count == 0)) {
+ pr_warn("dgap: %s configured for %d ports, has %d ports.\n",
+ brd->name, brd->nasync, true_count);
+ pr_warn("dgap: Please make SURE the EBI cable running from the card\n");
+ pr_warn("dgap: to each EM module is plugged into EBI IN!\n");
+ } else
+ pr_warn("dgap: %s configured for %d ports, has %d ports.\n",
+ brd->name, brd->nasync, true_count);
brd->nasync = true_count;
if (!brd->nasync) {
brd->state = BOARD_FAILED;
brd->dpastatus = BD_NOFEP;
- return(-ENXIO);
+ return -ENXIO;
}
}
*/
for (i = 0; i < brd->nasync; i++) {
if (!brd->channels[i]) {
- brd->channels[i] = kzalloc(sizeof(struct channel_t), GFP_ATOMIC);
- if (!brd->channels[i]) {
- DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n",
- __FILE__, __LINE__));
- }
+ brd->channels[i] =
+ kzalloc(sizeof(struct channel_t), GFP_ATOMIC);
+ if (!brd->channels[i])
+ return -ENOMEM;
}
}
ch->ch_dsr = DM_CD;
ch->ch_cd = DM_DSR;
ch->ch_digi.digi_flags |= DIGI_ALTPIN;
- }
- else {
+ } else {
ch->ch_cd = DM_CD;
ch->ch_dsr = DM_DSR;
}
* Set queue water marks, interrupt mask,
* and general tty parameters.
*/
- ch->ch_tlw = tlw = ch->ch_tsize >= 2000 ? ((ch->ch_tsize * 5) / 8) : ch->ch_tsize / 2;
+ tlw = ch->ch_tsize >= 2000 ? ((ch->ch_tsize * 5) / 8) :
+ ch->ch_tsize / 2;
+ ch->ch_tlw = tlw;
dgap_cmdw(ch, STLOW, tlw, 0);
writeb(1, &(ch->ch_bs->idata));
}
-
- DPR_INIT(("dgap_tty_init finish\n"));
-
- return (0);
+ return 0;
}
-
/*
* dgap_tty_post_uninit()
*
dgap_TmpWriteBuf = NULL;
}
-
/*
* dgap_tty_uninit()
*
dgap_BoardsByMajor[brd->SerialDriver->major] = NULL;
brd->dgap_Serial_Major = 0;
for (i = 0; i < brd->nasync; i++) {
+ tty_port_destroy(&brd->SerialPorts[i]);
dgap_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs);
tty_unregister_device(brd->SerialDriver, i);
}
kfree(brd->SerialDriver->ttys);
brd->SerialDriver->ttys = NULL;
put_tty_driver(brd->SerialDriver);
+ kfree(brd->SerialPorts);
brd->dgap_Major_Serial_Registered = FALSE;
}
dgap_BoardsByMajor[brd->PrintDriver->major] = NULL;
brd->dgap_TransparentPrint_Major = 0;
for (i = 0; i < brd->nasync; i++) {
+ tty_port_destroy(&brd->PrinterPorts[i]);
dgap_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs);
tty_unregister_device(brd->PrintDriver, i);
}
kfree(brd->PrintDriver->ttys);
brd->PrintDriver->ttys = NULL;
put_tty_driver(brd->PrintDriver);
+ kfree(brd->PrinterPorts);
brd->dgap_Major_TransparentPrint_Registered = FALSE;
}
}
-
#define TMPBUFLEN (1024)
-
/*
* dgap_sniff - Dump data out to the "sniff" buffer if the
* proc sniff file is opened...
* We *cannot* sleep here waiting for space, because this
* function was probably called by the interrupt/timer routines!
*/
- if (n == 0) {
+ if (n == 0)
return;
- }
/*
* Copy as much data as will fit.
} while (too_much_data);
}
-
/*=======================================================================
*
* dgap_input - Process received data.
tp = ch->ch_tun.un_tty;
bs = ch->ch_bs;
- if (!bs) {
+ if (!bs)
return;
- }
bd = ch->ch_bd;
- if(!bd || bd->magic != DGAP_BOARD_MAGIC)
+ if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_READ(("dgap_input start\n"));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
writeb(1, &(bs->idata));
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_READ(("No data on port %d\n", ch->ch_portnum));
return;
}
* If the device is not open, or CREAD is off, flush
* input data and return immediately.
*/
- if ((bd->state != BOARD_READY) || !tp || (tp->magic != TTY_MAGIC) ||
- !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios.c_cflag & CREAD) ||
+ if ((bd->state != BOARD_READY) || !tp ||
+ (tp->magic != TTY_MAGIC) ||
+ !(ch->ch_tun.un_flags & UN_ISOPEN) ||
+ !(tp->termios.c_cflag & CREAD) ||
(ch->ch_tun.un_flags & UN_CLOSING)) {
- DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum));
- DPR_READ(("input. tp: %p tp->magic: %x MAGIC:%x ch flags: %x\n",
- tp, tp ? tp->magic : 0, TTY_MAGIC, ch->ch_tun.un_flags));
writew(head, &(bs->rx_tail));
writeb(1, &(bs->idata));
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
writeb(1, &(bs->idata));
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_READ(("Port %d throttled, not reading any data. head: %x tail: %x\n",
- ch->ch_portnum, head, tail));
return;
}
writeb(0, &(bs->orun));
}
- DPR_READ(("dgap_input start 2\n"));
-
/* Decide how much data we can send into the tty layer */
flip_len = TTY_FLIPBUF_SIZE;
writeb(1, &(bs->idata));
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_READ(("dgap_input 1 - finish\n"));
if (ld)
tty_ldisc_deref(ld);
return;
len = tty_buffer_request_room(tp->port, len);
tty_insert_flip_string_flags(tp->port, ch->ch_bd->flipbuf,
ch->ch_bd->flipflagbuf, len);
- }
- else {
+ } else {
len = tty_buffer_request_room(tp->port, len);
tty_insert_flip_string(tp->port, ch->ch_bd->flipbuf, len);
}
if (ld)
tty_ldisc_deref(ld);
- DPR_READ(("dgap_input - finish\n"));
}
-
/************************************************************************
* Determines when CARRIER changes state and takes appropriate
* action.
{
struct board_t *bd;
- int virt_carrier = 0;
- int phys_carrier = 0;
-
- DPR_CARR(("dgap_carrier called...\n"));
+ int virt_carrier = 0;
+ int phys_carrier = 0;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
return;
if (ch->ch_digi.digi_flags & DIGI_ALTPIN) {
ch->ch_dsr = DM_CD;
ch->ch_cd = DM_DSR;
- }
- else {
+ } else {
ch->ch_dsr = DM_DSR;
ch->ch_cd = DM_CD;
}
- if (ch->ch_mistat & D_CD(ch)) {
- DPR_CARR(("mistat: %x D_CD: %x\n", ch->ch_mistat, D_CD(ch)));
+ if (ch->ch_mistat & D_CD(ch))
phys_carrier = 1;
- }
- if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) {
+ if (ch->ch_digi.digi_flags & DIGI_FORCEDCD)
virt_carrier = 1;
- }
- if (ch->ch_c_cflag & CLOCAL) {
+ if (ch->ch_c_cflag & CLOCAL)
virt_carrier = 1;
- }
-
-
- DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier));
/*
* Test for a VIRTUAL carrier transition to HIGH.
* for carrier in the open routine.
*/
- DPR_CARR(("carrier: virt DCD rose\n"));
-
if (waitqueue_active(&(ch->ch_flags_wait)))
wake_up_interruptible(&ch->ch_flags_wait);
}
* for carrier in the open routine.
*/
- DPR_CARR(("carrier: physical DCD rose\n"));
-
if (waitqueue_active(&(ch->ch_flags_wait)))
wake_up_interruptible(&ch->ch_flags_wait);
}
* matter... it really only means "ignore carrier state", not
* "make pretend that carrier is there".
*/
- if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) &&
- (phys_carrier == 0))
- {
+ if ((virt_carrier == 0) &&
+ ((ch->ch_flags & CH_CD) != 0) &&
+ (phys_carrier == 0)) {
/*
* When carrier drops:
if (waitqueue_active(&(ch->ch_flags_wait)))
wake_up_interruptible(&ch->ch_flags_wait);
- if (ch->ch_tun.un_open_count > 0) {
- DPR_CARR(("Sending tty hangup\n"));
+ if (ch->ch_tun.un_open_count > 0)
tty_hangup(ch->ch_tun.un_tty);
- }
- if (ch->ch_pun.un_open_count > 0) {
- DPR_CARR(("Sending pr hangup\n"));
+ if (ch->ch_pun.un_open_count > 0)
tty_hangup(ch->ch_pun.un_tty);
- }
}
/*
ch->ch_flags &= ~CH_CD;
}
-
/************************************************************************
*
* TTY Entry points and helper functions
major = MAJOR(tty_devnum(tty));
minor = MINOR(tty_devnum(tty));
- if (major > 255) {
+ if (major > 255)
return -ENXIO;
- }
/* Get board pointer from our array of majors we have allocated */
brd = dgap_BoardsByMajor[major];
- if (!brd) {
+ if (!brd)
return -ENXIO;
- }
/*
* If board is not yet up to a state of READY, go to
rc = wait_event_interruptible(brd->state_wait,
(brd->state & BOARD_READY));
- if (rc) {
+ if (rc)
return rc;
- }
DGAP_LOCK(brd->bd_lock, lock_flags);
if (major == brd->dgap_Serial_Major) {
un = &brd->channels[minor]->ch_tun;
un->un_type = DGAP_SERIAL;
- }
- else if (major == brd->dgap_TransparentPrint_Major) {
+ } else if (major == brd->dgap_TransparentPrint_Major) {
un = &brd->channels[minor]->ch_pun;
un->un_type = DGAP_PRINT;
- }
- else {
+ } else {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(brd->bd_lock, lock_flags);
- DPR_OPEN(("%d Unknown TYPE!\n", __LINE__));
return -ENXIO;
}
/* Store our unit into driver_data, so we always have it available. */
tty->driver_data = un;
- DPR_OPEN(("Open called. MAJOR: %d MINOR:%d unit: %p NAME: %s\n",
- MAJOR(tty_devnum(tty)), MINOR(tty_devnum(tty)), un, brd->name));
-
/*
* Error if channel info pointer is NULL.
*/
if (!bs) {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(brd->bd_lock, lock_flags);
- DPR_OPEN(("%d BS is 0!\n", __LINE__));
return -ENXIO;
- }
-
- DPR_OPEN(("%d: tflag=%x pflag=%x\n", __LINE__, ch->ch_tun.un_flags, ch->ch_pun.un_flags));
+ }
/*
* Initialize tty's
*/
if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) {
- DPR_OPEN(("dgap_open: initializing channel in open...\n"));
-
ch->ch_mforce = 0;
ch->ch_mval = 0;
rc = dgap_block_til_ready(tty, file, ch);
- if (!un->un_tty) {
+ if (!un->un_tty)
return -ENODEV;
- }
-
- if (rc) {
- DPR_OPEN(("dgap_tty_open returning after dgap_block_til_ready "
- "with %d\n", rc));
- }
/* No going back now, increment our unit and channel counters */
DGAP_LOCK(ch->ch_lock, lock_flags);
un->un_flags |= (UN_ISOPEN);
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- DPR_OPEN(("dgap_tty_open finished\n"));
- return (rc);
+ return rc;
}
-
/*
* dgap_block_til_ready()
*
uint old_flags = 0;
int sleep_on_un_flags = 0;
- if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGAP_CHANNEL_MAGIC) {
- return (-ENXIO);
- }
+ if (!tty || tty->magic != TTY_MAGIC || !file || !ch ||
+ ch->magic != DGAP_CHANNEL_MAGIC)
+ return -ENXIO;
un = tty->driver_data;
- if (!un || un->magic != DGAP_UNIT_MAGIC) {
- return (-ENXIO);
- }
-
- DPR_OPEN(("dgap_block_til_ready - before block.\n"));
+ if (!un || un->magic != DGAP_UNIT_MAGIC)
+ return -ENXIO;
DGAP_LOCK(ch->ch_lock, lock_flags);
* 3) DCD (fake or real) is active.
*/
- if (file->f_flags & O_NONBLOCK) {
+ if (file->f_flags & O_NONBLOCK)
break;
- }
- if (tty->flags & (1 << TTY_IO_ERROR)) {
+ if (tty->flags & (1 << TTY_IO_ERROR))
break;
- }
- if (ch->ch_flags & CH_CD) {
- DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags));
+ if (ch->ch_flags & CH_CD)
break;
- }
- if (ch->ch_flags & CH_FCAR) {
- DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags));
+ if (ch->ch_flags & CH_FCAR)
break;
- }
- }
- else {
+ } else {
sleep_on_un_flags = 1;
}
* Leave loop with error set.
*/
if (signal_pending(current)) {
- DPR_OPEN(("%d: signal pending...\n", __LINE__));
retval = -ERESTARTSYS;
break;
}
- DPR_OPEN(("dgap_block_til_ready - blocking.\n"));
-
/*
* Store the flags before we let go of channel lock
*/
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- DPR_OPEN(("Going to sleep on %s flags...\n",
- (sleep_on_un_flags ? "un" : "ch")));
-
/*
* Wait for something in the flags to change from the current value.
*/
if (sleep_on_un_flags) {
retval = wait_event_interruptible(un->un_flags_wait,
(old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags)));
- }
- else {
+ } else {
retval = wait_event_interruptible(ch->ch_flags_wait,
(old_flags != ch->ch_flags));
}
- DPR_OPEN(("After sleep... retval: %x\n", retval));
-
/*
* We got woken up for some reason.
* Before looping around, grab our channel lock.
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- DPR_OPEN(("dgap_block_til_ready - after blocking.\n"));
-
- if (retval) {
- DPR_OPEN(("dgap_block_til_ready - done. error. retval: %x\n", retval));
- return(retval);
- }
-
- DPR_OPEN(("dgap_block_til_ready - done no error. jiffies: %lu\n", jiffies));
+ if (retval)
+ return retval;
- return(0);
+ return 0;
}
-
/*
* dgap_tty_hangup()
*
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_CLOSE(("dgap_hangup called. ch->ch_open_count: %d un->un_open_count: %d\n",
- ch->ch_open_count, un->un_open_count));
-
/* flush the transmit queues */
dgap_tty_flush_buffer(tty);
- DPR_CLOSE(("dgap_hangup finished. ch->ch_open_count: %d un->un_open_count: %d\n",
- ch->ch_open_count, un->un_open_count));
}
-
-
/*
* dgap_tty_close()
*
ts = &tty->termios;
- DPR_CLOSE(("Close called\n"));
-
DGAP_LOCK(ch->ch_lock, lock_flags);
/*
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/
- APR(("tty->count is 1, un open count is %d\n", un->un_open_count));
un->un_open_count = 1;
}
- if (--un->un_open_count < 0) {
- APR(("bad serial port open count of %d\n", un->un_open_count));
+ if (--un->un_open_count < 0)
un->un_open_count = 0;
- }
ch->ch_open_count--;
if (ch->ch_open_count && un->un_open_count) {
- DPR_CLOSE(("dgap_tty_close: not last close ch: %d un:%d\n",
- ch->ch_open_count, un->un_open_count));
-
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- return;
- }
+ return;
+ }
/* OK, its the last close on the unit */
- DPR_CLOSE(("dgap_tty_close - last close on unit procedures\n"));
un->un_flags |= UN_CLOSING;
/*
* Only officially close channel if count is 0 and
- * DIGI_PRINTER bit is not set.
+ * DIGI_PRINTER bit is not set.
*/
if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) {
/* wait for output to drain */
/* This will also return if we take an interrupt */
- DPR_CLOSE(("Calling wait_for_drain\n"));
rc = dgap_wait_for_drain(tty);
- DPR_CLOSE(("After calling wait_for_drain\n"));
-
- if (rc) {
- DPR_BASIC(("dgap_tty_close - bad return: %d ", rc));
- }
dgap_tty_flush_buffer(tty);
tty_ldisc_flush(tty);
/*
* If we have HUPCL set, lower DTR and RTS
*/
- if (ch->ch_c_cflag & HUPCL ) {
- DPR_CLOSE(("Close. HUPCL set, dropping DTR/RTS\n"));
+ if (ch->ch_c_cflag & HUPCL) {
ch->ch_mostat &= ~(D_RTS(ch)|D_DTR(ch));
- dgap_cmdb( ch, SMODEM, 0, D_DTR(ch)|D_RTS(ch), 0 );
+ dgap_cmdb(ch, SMODEM, 0, D_DTR(ch)|D_RTS(ch), 0);
/*
* Go to sleep to ensure RTS/DTR
* have been dropped for modems to see it.
*/
if (ch->ch_close_delay) {
- DPR_CLOSE(("Close. Sleeping for RTS/DTR drop\n"));
-
DGAP_UNLOCK(ch->ch_lock, lock_flags);
dgap_ms_sleep(ch->ch_close_delay);
DGAP_LOCK(ch->ch_lock, lock_flags);
-
- DPR_CLOSE(("Close. After sleeping for RTS/DTR drop\n"));
}
}
/*
* turn off print device when closing print device.
*/
- if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON) ) {
+ if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON)) {
dgap_wmove(ch, ch->ch_digi.digi_offstr,
(int) ch->ch_digi.digi_offlen);
ch->ch_flags &= ~CH_PRON;
un->un_flags &= ~(UN_ISOPEN | UN_CLOSING);
tty->driver_data = NULL;
- DPR_CLOSE(("Close. Doing wakeups\n"));
wake_up_interruptible(&ch->ch_flags_wait);
wake_up_interruptible(&un->un_flags_wait);
DGAP_UNLOCK(ch->ch_lock, lock_flags);
-
- DPR_BASIC(("dgap_tty_close - complete\n"));
}
-
/*
* dgap_tty_chars_in_buffer()
*
ulong lock_flags2 = 0;
if (tty == NULL)
- return(0);
+ return 0;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
- bs = ch->ch_bs;
+ bs = ch->ch_bs;
if (!bs)
- return (0);
+ return 0;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
* 1) Transmit head and tail are equal (empty).
* 2) Command queue head and tail are equal (empty).
* 3) The "TBUSY" flag is 0. (Transmitter not busy).
- */
+ */
if ((ttail == thead) && (tbusy == 0) && (chead == ctail)) {
chars = 0;
- }
- else {
+ } else {
if (thead >= ttail)
chars = thead - ttail;
else
}
}
- DPR_WRITE(("dgap_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d tsize: %d)\n",
- ch->ch_portnum, chars, thead, ttail, ch->ch_tsize));
- return(chars);
+ return chars;
}
-
static int dgap_wait_for_drain(struct tty_struct *tty)
{
struct channel_t *ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
return ret;
- bs = ch->ch_bs;
+ bs = ch->ch_bs;
if (!bs)
return ret;
ret = 0;
- DPR_DRAIN(("dgap_wait_for_drain start\n"));
-
/* Loop until data is drained */
while (count != 0) {
/* Go to sleep till we get woken up */
ret = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & UN_EMPTY) == 0));
/* If ret is non-zero, user ctrl-c'ed us */
- if (ret) {
+ if (ret)
break;
- }
}
DGAP_LOCK(ch->ch_lock, lock_flags);
un->un_flags &= ~(UN_EMPTY);
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- DPR_DRAIN(("dgap_wait_for_drain finish\n"));
- return (ret);
+ return ret;
}
-
/*
* dgap_maxcps_room
*
struct un_t *un = NULL;
if (tty == NULL)
- return (bytes_available);
+ return bytes_available;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (bytes_available);
+ return bytes_available;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (bytes_available);
+ return bytes_available;
/*
* If its not the Transparent print device, return
* the full data amount.
*/
if (un->un_type != DGAP_PRINT)
- return (bytes_available);
+ return bytes_available;
- if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0 ) {
+ if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0) {
int cps_limit = 0;
unsigned long current_time = jiffies;
unsigned long buffer_time = current_time +
/* buffer is empty */
ch->ch_cpstime = current_time; /* reset ch_cpstime */
cps_limit = ch->ch_digi.digi_bufsize;
- }
- else if (ch->ch_cpstime < buffer_time) {
+ } else if (ch->ch_cpstime < buffer_time) {
/* still room in the buffer */
cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ;
- }
- else {
+ } else {
/* no room in the buffer */
cps_limit = 0;
}
bytes_available = min(cps_limit, bytes_available);
}
- return (bytes_available);
+ return bytes_available;
}
-
static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event)
{
struct channel_t *ch = NULL;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
return;
- bs = ch->ch_bs;
+ bs = ch->ch_bs;
if (!bs)
return;
}
}
-
/*
* dgap_tty_write_room()
*
ulong lock_flags = 0;
if (tty == NULL || dgap_TmpWriteBuf == NULL)
- return(0);
+ return 0;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
- bs = ch->ch_bs;
+ bs = ch->ch_bs;
if (!bs)
- return (0);
+ return 0;
DGAP_LOCK(ch->ch_lock, lock_flags);
head = readw(&(bs->tx_head)) & tmask;
tail = readw(&(bs->tx_tail)) & tmask;
- if ((ret = tail - head - 1) < 0)
- ret += ch->ch_tsize;
+ ret = tail - head - 1;
+ if (ret < 0)
+ ret += ch->ch_tsize;
/* Limit printer to maxcps */
ret = dgap_maxcps_room(tty, ret);
if (!(ch->ch_flags & CH_PRON))
ret -= ch->ch_digi.digi_onlen;
ret -= ch->ch_digi.digi_offlen;
- }
- else {
+ } else {
if (ch->ch_flags & CH_PRON)
ret -= ch->ch_digi.digi_offlen;
}
dgap_set_firmware_event(un, UN_LOW | UN_EMPTY);
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- DPR_WRITE(("dgap_tty_write_room - %d tail: %d head: %d\n", ret, tail, head));
-
- return(ret);
+ return ret;
}
-
/*
* dgap_tty_put_char()
*
/*
* Simply call tty_write.
*/
- DPR_WRITE(("dgap_tty_put_char called\n"));
dgap_tty_write(tty, &c, 1);
return 1;
}
-
/*
* dgap_tty_write()
*
int from_user = 0;
if (tty == NULL || dgap_TmpWriteBuf == NULL)
- return(0);
+ return 0;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return(0);
+ return 0;
- bs = ch->ch_bs;
+ bs = ch->ch_bs;
if (!bs)
- return(0);
+ return 0;
if (!count)
- return(0);
-
- DPR_WRITE(("dgap_tty_write: Port: %x tty=%p user=%d len=%d\n",
- ch->ch_portnum, tty, from_user, count));
+ return 0;
/*
* Store original amount of characters passed in.
head = readw(&(bs->tx_head)) & tmask;
tail = readw(&(bs->tx_tail)) & tmask;
- if ((bufcount = tail - head - 1) < 0)
+ bufcount = tail - head - 1;
+ if (bufcount < 0)
bufcount += ch->ch_tsize;
- DPR_WRITE(("%d: bufcount: %x count: %x tail: %x head: %x tmask: %x\n",
- __LINE__, bufcount, count, tail, head, tmask));
-
/*
* Limit printer output to maxcps overall, with bursts allowed
* up to bufsize characters.
if (count <= 0) {
dgap_set_firmware_event(un, UN_LOW | UN_EMPTY);
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- return(0);
+ return 0;
}
/*
if (count <= 0) {
dgap_set_firmware_event(un, UN_LOW | UN_EMPTY);
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- return(0);
+ return 0;
}
if (from_user) {
* the board.
*/
/* we're allowed to block if it's from_user */
- if (down_interruptible(&dgap_TmpWriteSem)) {
- return (-EINTR);
- }
+ if (down_interruptible(&dgap_TmpWriteSem))
+ return -EINTR;
if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) {
up(&dgap_TmpWriteSem);
- printk("Write: Copy from user failed!\n");
return -EFAULT;
}
writew(head, &(bs->tx_head));
}
-
dgap_set_firmware_event(un, UN_LOW | UN_EMPTY);
/*
if (tail != head) {
un->un_flags |= UN_EMPTY;
writeb(1, &(bs->iempty));
- }
- else {
+ } else {
dgap_wmove(ch, ch->ch_digi.digi_offstr,
(int) ch->ch_digi.digi_offlen);
head = readw(&(bs->tx_head)) & tmask;
/* Update printer buffer empty time. */
if ((un->un_type == DGAP_PRINT) && (ch->ch_digi.digi_maxcps > 0)
&& (ch->ch_digi.digi_bufsize > 0)) {
- ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
+ ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
}
if (from_user) {
DGAP_UNLOCK(ch->ch_lock, lock_flags);
up(&dgap_TmpWriteSem);
- }
- else {
+ } else
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- }
- DPR_WRITE(("Write finished - Write %d bytes of %d.\n", count, orig_count));
-
- return (count);
+ return count;
}
-
-
/*
* Return modem signals to ld.
*/
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
return result;
- DPR_IOCTL(("dgap_tty_tiocmget start\n"));
-
DGAP_LOCK(ch->ch_lock, lock_flags);
mstat = readb(&(ch->ch_bs->m_stat));
- /* Append any outbound signals that might be pending... */
- mstat |= ch->ch_mostat;
+ /* Append any outbound signals that might be pending... */
+ mstat |= ch->ch_mostat;
DGAP_UNLOCK(ch->ch_lock, lock_flags);
if (mstat & D_CD(ch))
result |= TIOCM_CD;
- DPR_IOCTL(("dgap_tty_tiocmget finish\n"));
-
return result;
}
-
/*
* dgap_tty_tiocmset()
*
* Set modem signals, called by ld.
*/
-
static int dgap_tty_tiocmset(struct tty_struct *tty,
- unsigned int set, unsigned int clear)
+ unsigned int set, unsigned int clear)
{
struct board_t *bd;
struct channel_t *ch;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return ret;
- DPR_IOCTL(("dgap_tty_tiocmset start\n"));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
if (set & TIOCM_RTS) {
ch->ch_mforce |= D_RTS(ch);
ch->ch_mval |= D_RTS(ch);
- }
+ }
if (set & TIOCM_DTR) {
ch->ch_mforce |= D_DTR(ch);
ch->ch_mval |= D_DTR(ch);
- }
+ }
if (clear & TIOCM_RTS) {
ch->ch_mforce |= D_RTS(ch);
ch->ch_mval &= ~(D_RTS(ch));
- }
+ }
if (clear & TIOCM_DTR) {
ch->ch_mforce |= D_DTR(ch);
ch->ch_mval &= ~(D_DTR(ch));
- }
+ }
dgap_param(tty);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_tiocmset finish\n"));
-
- return (0);
+ return 0;
}
-
-
/*
* dgap_tty_send_break()
*
break;
}
- DPR_IOCTL(("dgap_tty_send_break start 1. %lx\n", jiffies));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
#if 0
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_send_break finish\n"));
-
- return (0);
+ return 0;
}
-
-
-
/*
* dgap_tty_wait_until_sent()
*
*/
static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout)
{
- int rc;
- rc = dgap_wait_for_drain(tty);
- if (rc) {
- DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc));
- return;
- }
- return;
+ dgap_wait_for_drain(tty);
}
-
-
/*
* dgap_send_xchar()
*
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_IOCTL(("dgap_tty_send_xchar start 1. %lx\n", jiffies));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
* by hand...
*/
#if 0
- if (c == STOP_CHAR(tty)) {
+ if (c == STOP_CHAR(tty))
dgap_cmdw(ch, RPAUSE, 0, 0);
- }
- else if (c == START_CHAR(tty)) {
+ else if (c == START_CHAR(tty))
dgap_cmdw(ch, RRESUME, 0, 0);
- }
- else {
+ else
dgap_wmove(ch, &c, 1);
- }
#else
dgap_wmove(ch, &c, 1);
#endif
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_send_xchar finish\n"));
-
return;
}
-
-
-
/*
* Return modem signals to ld.
*/
ulong lock_flags;
int rc = 0;
- DPR_IOCTL(("dgap_get_modem_info start\n"));
-
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return(-ENXIO);
+ return -ENXIO;
DGAP_LOCK(ch->ch_lock, lock_flags);
rc = put_user(result, value);
- DPR_IOCTL(("dgap_get_modem_info finish\n"));
- return(rc);
+ return rc;
}
-
/*
* dgap_set_modem_info()
*
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return ret;
- DPR_IOCTL(("dgap_set_modem_info() start\n"));
-
ret = get_user(arg, value);
- if (ret) {
- DPR_IOCTL(("dgap_set_modem_info %d ret: %x. finished.\n", __LINE__, ret));
- return(ret);
- }
-
- DPR_IOCTL(("dgap_set_modem_info: command: %x arg: %x\n", command, arg));
+ if (ret)
+ return ret;
switch (command) {
case TIOCMBIS:
if (arg & TIOCM_RTS) {
ch->ch_mforce |= D_RTS(ch);
ch->ch_mval |= D_RTS(ch);
- }
+ }
if (arg & TIOCM_DTR) {
ch->ch_mforce |= D_DTR(ch);
ch->ch_mval |= D_DTR(ch);
- }
+ }
break;
if (arg & TIOCM_RTS) {
ch->ch_mforce |= D_RTS(ch);
ch->ch_mval &= ~(D_RTS(ch));
- }
+ }
if (arg & TIOCM_DTR) {
ch->ch_mforce |= D_DTR(ch);
ch->ch_mval &= ~(D_DTR(ch));
- }
+ }
break;
- case TIOCMSET:
+ case TIOCMSET:
ch->ch_mforce = D_DTR(ch)|D_RTS(ch);
- if (arg & TIOCM_RTS) {
+ if (arg & TIOCM_RTS)
ch->ch_mval |= D_RTS(ch);
- }
- else {
+ else
ch->ch_mval &= ~(D_RTS(ch));
- }
- if (arg & TIOCM_DTR) {
+ if (arg & TIOCM_DTR)
ch->ch_mval |= (D_DTR(ch));
- }
- else {
+ else
ch->ch_mval &= ~(D_DTR(ch));
- }
break;
default:
- return(-EINVAL);
+ return -EINVAL;
}
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_set_modem_info finish\n"));
-
- return (0);
+ return 0;
}
-
/*
* dgap_tty_digigeta()
*
ulong lock_flags;
if (!retinfo)
- return (-EFAULT);
+ return -EFAULT;
if (!tty || tty->magic != TTY_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
memset(&tmp, 0, sizeof(tmp));
DGAP_UNLOCK(ch->ch_lock, lock_flags);
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
- return (-EFAULT);
+ return -EFAULT;
- return (0);
+ return 0;
}
-
/*
* dgap_tty_digiseta()
*
ulong lock_flags = 0;
unsigned long lock_flags2;
- DPR_IOCTL(("DIGI_SETA start\n"));
-
if (!tty || tty->magic != TTY_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
- if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) {
- DPR_IOCTL(("DIGI_SETA failed copy_from_user\n"));
- return(-EFAULT);
- }
+ if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t)))
+ return -EFAULT;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("DIGI_SETA finish\n"));
-
- return(0);
+ return 0;
}
-
/*
* dgap_tty_digigetedelay()
*
ulong lock_flags;
if (!retinfo)
- return (-EFAULT);
+ return -EFAULT;
if (!tty || tty->magic != TTY_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
memset(&tmp, 0, sizeof(tmp));
DGAP_UNLOCK(ch->ch_lock, lock_flags);
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
- return (-EFAULT);
+ return -EFAULT;
- return (0);
+ return 0;
}
-
/*
* dgap_tty_digisetedelay()
*
ulong lock_flags;
ulong lock_flags2;
- DPR_IOCTL(("DIGI_SETA start\n"));
-
if (!tty || tty->magic != TTY_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
- if (copy_from_user(&new_digi, new_info, sizeof(int))) {
- DPR_IOCTL(("DIGI_SETEDELAY failed copy_from_user\n"));
- return(-EFAULT);
- }
+ if (copy_from_user(&new_digi, new_info, sizeof(int)))
+ return -EFAULT;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("DIGI_SETA finish\n"));
-
- return(0);
+ return 0;
}
-
/*
* dgap_tty_digigetcustombaud()
*
ulong lock_flags;
if (!retinfo)
- return (-EFAULT);
+ return -EFAULT;
if (!tty || tty->magic != TTY_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
memset(&tmp, 0, sizeof(tmp));
tmp = dgap_get_custom_baud(ch);
DGAP_UNLOCK(ch->ch_lock, lock_flags);
- DPR_IOCTL(("DIGI_GETCUSTOMBAUD. Returning %d\n", tmp));
-
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
- return (-EFAULT);
+ return -EFAULT;
- return (0);
+ return 0;
}
-
/*
* dgap_tty_digisetcustombaud()
*
ulong lock_flags;
ulong lock_flags2;
- DPR_IOCTL(("DIGI_SETCUSTOMBAUD start\n"));
-
if (!tty || tty->magic != TTY_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (-EFAULT);
+ return -EFAULT;
- if (copy_from_user(&new_rate, new_info, sizeof(unsigned int))) {
- DPR_IOCTL(("DIGI_SETCUSTOMBAUD failed copy_from_user\n"));
- return(-EFAULT);
- }
+ if (copy_from_user(&new_rate, new_info, sizeof(unsigned int)))
+ return -EFAULT;
if (bd->bd_flags & BD_FEP5PLUS) {
- DPR_IOCTL(("DIGI_SETCUSTOMBAUD. Setting %d\n", new_rate));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
}
- DPR_IOCTL(("DIGI_SETCUSTOMBAUD finish\n"));
-
- return(0);
+ return 0;
}
-
/*
* dgap_set_termios()
*/
DGAP_UNLOCK(bd->bd_lock, lock_flags);
}
-
static void dgap_tty_throttle(struct tty_struct *tty)
{
struct board_t *bd;
if (!un || un->magic != DGAP_UNIT_MAGIC)
return;
- ch = un->un_ch;
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return;
+ ch = un->un_ch;
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
+ return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_IOCTL(("dgap_tty_throttle start\n"));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_throttle finish\n"));
}
-
static void dgap_tty_unthrottle(struct tty_struct *tty)
{
struct board_t *bd;
if (!un || un->magic != DGAP_UNIT_MAGIC)
return;
- ch = un->un_ch;
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return;
+ ch = un->un_ch;
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
+ return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_IOCTL(("dgap_tty_unthrottle start\n"));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
-
- DPR_IOCTL(("dgap_tty_unthrottle finish\n"));
}
-
static void dgap_tty_start(struct tty_struct *tty)
{
struct board_t *bd;
if (!un || un->magic != DGAP_UNIT_MAGIC)
return;
- ch = un->un_ch;
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return;
+ ch = un->un_ch;
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
+ return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_IOCTL(("dgap_tty_start start\n"));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_start finish\n"));
}
-
static void dgap_tty_stop(struct tty_struct *tty)
{
struct board_t *bd;
if (!un || un->magic != DGAP_UNIT_MAGIC)
return;
- ch = un->un_ch;
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return;
+ ch = un->un_ch;
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
+ return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_IOCTL(("dgap_tty_stop start\n"));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_stop finish\n"));
}
-
/*
* dgap_tty_flush_chars()
*
if (!un || un->magic != DGAP_UNIT_MAGIC)
return;
- ch = un->un_ch;
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return;
+ ch = un->un_ch;
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
+ return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_IOCTL(("dgap_tty_flush_chars start\n"));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
-
- DPR_IOCTL(("dgap_tty_flush_chars finish\n"));
}
-
-
/*
* dgap_tty_flush_buffer()
*
if (!un || un->magic != DGAP_UNIT_MAGIC)
return;
- ch = un->un_ch;
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return;
+ ch = un->un_ch;
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
+ return;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
return;
- DPR_IOCTL(("dgap_tty_flush_buffer on port: %d start\n", ch->ch_portnum));
-
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
if (waitqueue_active(&tty->write_wait))
wake_up_interruptible(&tty->write_wait);
tty_wakeup(tty);
-
- DPR_IOCTL(("dgap_tty_flush_buffer finish\n"));
}
-
-
/*****************************************************************************
*
* The IOCTL function and all of its helpers
void __user *uarg = (void __user *) arg;
if (!tty || tty->magic != TTY_MAGIC)
- return (-ENODEV);
+ return -ENODEV;
un = tty->driver_data;
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (-ENODEV);
+ return -ENODEV;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (-ENODEV);
+ return -ENODEV;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (-ENODEV);
-
- DPR_IOCTL(("dgap_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n",
- ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg));
+ return -ENODEV;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
if (un->un_open_count <= 0) {
- DPR_BASIC(("dgap_tty_ioctl - unit not open.\n"));
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(-EIO);
+ return -EIO;
}
switch (cmd) {
rc = tty_check_change(tty);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- if (rc) {
- return(rc);
- }
+ if (rc)
+ return rc;
rc = dgap_wait_for_drain(tty);
- if (rc) {
- DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc));
- return(-EINTR);
- }
+ if (rc)
+ return -EINTR;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
- if(((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) {
+ if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP))
dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0);
- }
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n",
- ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg));
-
- return(0);
-
+ return 0;
case TCSBRKP:
- /* support for POSIX tcsendbreak()
+ /* support for POSIX tcsendbreak()
* According to POSIX.1 spec (7.2.2.1.2) breaks should be
* between 0.25 and 0.5 seconds so we'll ask for something
rc = tty_check_change(tty);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- if (rc) {
- return(rc);
- }
+ if (rc)
+ return rc;
rc = dgap_wait_for_drain(tty);
- if (rc) {
- DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc));
- return(-EINTR);
- }
+ if (rc)
+ return -EINTR;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n",
- ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg));
-
- return(0);
+ return 0;
- case TIOCSBRK:
+ case TIOCSBRK:
/*
* FEP5 doesn't support turning on a break unconditionally.
* The FEP5 device will stop sending a break automatically
rc = tty_check_change(tty);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- if (rc) {
- return(rc);
- }
+ if (rc)
+ return rc;
rc = dgap_wait_for_drain(tty);
- if (rc) {
- DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc));
- return(-EINTR);
- }
+ if (rc)
+ return -EINTR;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n",
- ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg));
-
return 0;
- case TIOCCBRK:
+ case TIOCCBRK:
/*
* FEP5 doesn't support turning off a break unconditionally.
* The FEP5 device will stop sending a break automatically
DGAP_UNLOCK(bd->bd_lock, lock_flags);
rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg);
- return(rc);
+ return rc;
case TIOCSSOFTCAR:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
rc = get_user(arg, (unsigned long __user *) arg);
if (rc)
- return(rc);
+ return rc;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(0);
+ return 0;
case TIOCMGET:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_get_modem_info(ch, uarg));
+ return dgap_get_modem_info(ch, uarg);
case TIOCMBIS:
case TIOCMBIC:
case TIOCMSET:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_set_modem_info(tty, cmd, uarg));
+ return dgap_set_modem_info(tty, cmd, uarg);
/*
* Here are any additional ioctl's that we want to implement
if (rc) {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(rc);
+ return rc;
}
if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) {
if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) {
ch->ch_flags &= ~CH_STOP;
head = readw(&(ch->ch_bs->tx_head));
- dgap_cmdw(ch, FLUSHTX, (u16) head, 0 );
+ dgap_cmdw(ch, FLUSHTX, (u16) head, 0);
dgap_cmdw(ch, RESUMETX, 0, 0);
if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) {
ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n",
- __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg));
-
- return(-ENOIOCTLCMD);
+ return -ENOIOCTLCMD;
case TCSETSF:
case TCSETSW:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
rc = dgap_wait_for_drain(tty);
- if (rc) {
- DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc));
- return(-EINTR);
- }
-
- DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n",
- ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg));
+ if (rc)
+ return -EINTR;
/* pretend we didn't recognize this */
- return(-ENOIOCTLCMD);
+ return -ENOIOCTLCMD;
case TCSETAW:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
rc = dgap_wait_for_drain(tty);
- if (rc) {
- DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc));
- return(-EINTR);
- }
+ if (rc)
+ return -EINTR;
/* pretend we didn't recognize this */
- return(-ENOIOCTLCMD);
+ return -ENOIOCTLCMD;
case TCXONC:
/*
if (rc) {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(rc);
+ return rc;
}
- DPR_IOCTL(("dgap_ioctl - in TCXONC - %d\n", cmd));
switch (arg) {
case TCOON:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
dgap_tty_start(tty);
- return(0);
+ return 0;
case TCOOFF:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
dgap_tty_stop(tty);
- return(0);
+ return 0;
case TCION:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
/* Make the ld do it */
- return(-ENOIOCTLCMD);
+ return -ENOIOCTLCMD;
case TCIOFF:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
/* Make the ld do it */
- return(-ENOIOCTLCMD);
+ return -ENOIOCTLCMD;
default:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(-EINVAL);
+ return -EINVAL;
}
case DIGI_GETA:
/* get information for ditty */
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_tty_digigeta(tty, uarg));
+ return dgap_tty_digigeta(tty, uarg);
case DIGI_SETAW:
case DIGI_SETAF:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
rc = dgap_wait_for_drain(tty);
- if (rc) {
- DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc));
- return(-EINTR);
- }
+ if (rc)
+ return -EINTR;
DGAP_LOCK(bd->bd_lock, lock_flags);
DGAP_LOCK(ch->ch_lock, lock_flags2);
- }
- else {
+ } else
tty_ldisc_flush(tty);
- }
/* fall thru */
case DIGI_SETA:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_tty_digiseta(tty, uarg));
+ return dgap_tty_digiseta(tty, uarg);
case DIGI_GEDELAY:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_tty_digigetedelay(tty, uarg));
+ return dgap_tty_digigetedelay(tty, uarg);
case DIGI_SEDELAY:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_tty_digisetedelay(tty, uarg));
+ return dgap_tty_digisetedelay(tty, uarg);
case DIGI_GETCUSTOMBAUD:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_tty_digigetcustombaud(tty, uarg));
+ return dgap_tty_digigetcustombaud(tty, uarg);
case DIGI_SETCUSTOMBAUD:
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- return(dgap_tty_digisetcustombaud(tty, uarg));
+ return dgap_tty_digisetcustombaud(tty, uarg);
case DIGI_RESET_PORT:
dgap_firmware_reset_port(ch);
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
- DPR_IOCTL(("dgap_tty_ioctl - in default\n"));
- DPR_IOCTL(("dgap_tty_ioctl end - cmd %s (%x), arg %lx\n",
- dgap_ioctl_name(cmd), cmd, arg));
-
- return(-ENOIOCTLCMD);
+ return -ENOIOCTLCMD;
}
}
return 0;
}
-
-
/*
* Create pr and tty device entries
*/
-static void dgap_sysfs_create(struct board_t *brd)
+static int dgap_tty_register_ports(struct board_t *brd)
{
struct channel_t *ch;
- int j = 0;
+ int i;
+
+ brd->SerialPorts = kcalloc(brd->nasync, sizeof(*brd->SerialPorts),
+ GFP_KERNEL);
+ if (brd->SerialPorts == NULL)
+ return -ENOMEM;
+ for (i = 0; i < brd->nasync; i++)
+ tty_port_init(&brd->SerialPorts[i]);
+
+ brd->PrinterPorts = kcalloc(brd->nasync, sizeof(*brd->PrinterPorts),
+ GFP_KERNEL);
+ if (brd->PrinterPorts == NULL) {
+ kfree(brd->SerialPorts);
+ return -ENOMEM;
+ }
+ for (i = 0; i < brd->nasync; i++)
+ tty_port_init(&brd->PrinterPorts[i]);
ch = brd->channels[0];
- for (j = 0; j < brd->nasync; j++, ch = brd->channels[j]) {
+ for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) {
+
struct device *classp;
- classp = tty_register_device(brd->SerialDriver, j,
- &(ch->ch_bd->pdev->dev));
- ch->ch_tun.un_sysfs = classp;
+
+ classp = tty_port_register_device(&brd->SerialPorts[i],
+ brd->SerialDriver,
+ brd->firstminor + i, NULL);
+
dgap_create_tty_sysfs(&ch->ch_tun, classp);
+ ch->ch_tun.un_sysfs = classp;
+
+ classp = tty_port_register_device(&brd->PrinterPorts[i],
+ brd->PrintDriver,
+ brd->firstminor + i, NULL);
- classp = tty_register_device(brd->PrintDriver, j,
- &(ch->ch_bd->pdev->dev));
- ch->ch_pun.un_sysfs = classp;
dgap_create_tty_sysfs(&ch->ch_pun, classp);
+ ch->ch_pun.un_sysfs = classp;
}
dgap_create_ports_sysfiles(brd);
-}
+ return 0;
+}
/*
* Copies the BIOS code from the user to the board,
if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase)
return;
- DPR_INIT(("dgap_do_bios_load() start\n"));
-
addr = brd->re_map_membase;
/*
writeb(FEPCLR, brd->re_map_port);
}
-
/*
* Checks to see if the BIOS completed running on the card.
*/
while (brd->wait_for_bios < 1000) {
/* Check to see if BIOS thinks board is good. (GD). */
if (word == *(u16 *) "GD") {
- DPR_INIT(("GOT GD in memory, moving states.\n"));
brd->state = FINISHED_BIOS_LOAD;
return;
}
/* Gave up on board after too long of time taken */
err1 = readw(addr + SEQUENCE);
err2 = readw(addr + ERROR);
- APR(("***WARNING*** %s failed diagnostics. Error #(%x,%x).\n",
- brd->name, err1, err2));
+ pr_warn("dgap: %s failed diagnostics. Error #(%x,%x).\n",
+ brd->name, err1, err2);
brd->state = BOARD_FAILED;
brd->dpastatus = BD_NOBIOS;
}
-
/*
* Copies the FEP code from the user to the board,
* and starts the FEP running.
addr = brd->re_map_membase;
- DPR_INIT(("dgap_do_fep_load() for board %s : start\n", brd->name));
-
/*
* Download FEP
*/
writel(0xbfc01004, (addr + 0xc34));
writel(0x3, (addr + 0xc30));
- DPR_INIT(("dgap_do_fep_load() for board %s : finish\n", brd->name));
-
}
-
/*
* Waits for the FEP to report thats its ready for us to use.
*/
/* Gave up on board after too long of time taken */
err1 = readw(addr + SEQUENCE);
err2 = readw(addr + ERROR);
- APR(("***WARNING*** FEPOS for %s not functioning. Error #(%x,%x).\n",
- brd->name, err1, err2));
+ pr_warn("dgap: FEPOS for %s not functioning. Error #(%x,%x).\n",
+ brd->name, err1, err2);
brd->state = BOARD_FAILED;
brd->dpastatus = BD_NOFEP;
-
- DPR_INIT(("dgap_do_wait_for_fep() for board %s : finish\n", brd->name));
}
-
/*
* Physically forces the FEP5 card to reset itself.
*/
u32 check2;
int i = 0;
- if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase || !brd->re_map_port) {
- DPR_INIT(("dgap_do_reset_board() start. bad values. brd: %p mem: %p io: %p\n",
- brd, brd ? brd->re_map_membase : 0, brd ? brd->re_map_port : 0));
+ if (!brd || (brd->magic != DGAP_BOARD_MAGIC) ||
+ !brd->re_map_membase || !brd->re_map_port)
return;
- }
-
- DPR_INIT(("dgap_do_reset_board() start. io: %p\n", brd->re_map_port));
/* FEPRST does not vary among supported boards */
writeb(FEPRST, brd->re_map_port);
}
if (i > 1000) {
- APR(("*** WARNING *** Board not resetting... Failing board.\n"));
+ pr_warn("dgap: Board not resetting... Failing board.\n");
brd->state = BOARD_FAILED;
brd->dpastatus = BD_NOFEP;
- goto failed;
+ return;
}
/*
check2 = readl(brd->re_map_membase + HIGHMEM);
if ((check1 != 0xa55a3cc3) || (check2 != 0x5aa5c33c)) {
- APR(("*** Warning *** No memory at %p for board.\n", brd->re_map_membase));
+ pr_warn("dgap: No memory at %p for board.\n",
+ brd->re_map_membase);
brd->state = BOARD_FAILED;
brd->dpastatus = BD_NOFEP;
- goto failed;
+ return;
}
if (brd->state != BOARD_FAILED)
brd->state = FINISHED_RESET;
-
-failed:
- DPR_INIT(("dgap_do_reset_board() finish\n"));
}
-
#ifdef DIGI_CONCENTRATORS_SUPPORTED
/*
* Sends a concentrator image into the FEP5 board.
pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic);
}
-
/*
* Our board poller function.
*/
char *vaddr;
u16 head, tail;
- if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) {
- APR(("dgap_poll_tasklet() - NULL or bad bd.\n"));
+ if (!bd || (bd->magic != DGAP_BOARD_MAGIC))
return;
- }
if (bd->inhibit_poller)
return;
return;
}
- if (!bd->nasync) {
+ if (!bd->nasync)
goto out;
- }
eaddr = (struct ev_t *) (vaddr + EVBUF);
/*
* If board is doing interrupts, ACK the interrupt.
*/
- if (bd && bd->intr_running) {
+ if (bd && bd->intr_running)
readb(bd->re_map_port + 2);
- }
DGAP_UNLOCK(bd->bd_lock, lock_flags);
return;
}
/* Move to next state */
- if (bd->state == FINISHED_RESET) {
+ if (bd->state == FINISHED_RESET)
bd->state = NEED_CONFIG;
- }
if (bd->state == NEED_CONFIG) {
/*
* back, and this is a PAPORT8 board, retry with a
* PAPORT4 attempt as well.
*/
- if (bd->type == PAPORT8 && !bd->bd_config) {
+ if (bd->type == PAPORT8 && !bd->bd_config)
bd->bd_config = dgap_find_config(PAPORT4, bd->pci_bus, bd->pci_slot);
- }
/*
* Register the ttys (if any) into the kernel.
*/
- if (bd->bd_config) {
+ if (bd->bd_config)
bd->state = FINISHED_CONFIG;
- }
- else {
+ else
bd->state = CONFIG_NOT_FOUND;
- }
}
/* Move to next state */
- if (bd->state == FINISHED_CONFIG) {
+ if (bd->state == FINISHED_CONFIG)
bd->state = NEED_DEVICE_CREATION;
- }
/* Move to next state */
if (bd->state == NEED_DEVICE_CREATION) {
}
/* Move to next state */
- if (bd->state == FINISHED_DEVICE_CREATION) {
+ if (bd->state == FINISHED_DEVICE_CREATION)
bd->state = NEED_BIOS_LOAD;
- }
/* Move to next state */
if (bd->state == NEED_BIOS_LOAD) {
}
/* Wait for BIOS to test board... */
- if (bd->state == WAIT_BIOS_LOAD) {
+ if (bd->state == WAIT_BIOS_LOAD)
dgap_do_wait_for_bios(bd);
- }
/* Move to next state */
if (bd->state == FINISHED_BIOS_LOAD) {
}
/* Wait for FEP to load on board... */
- if (bd->state == WAIT_FEP_LOAD) {
+ if (bd->state == WAIT_FEP_LOAD)
dgap_do_wait_for_fep(bd);
- }
-
/* Move to next state */
if (bd->state == FINISHED_FEP_LOAD) {
if (rc < 0) {
dgap_tty_uninit(bd);
- APR(("Can't init tty devices (%d)\n", rc));
bd->state = BOARD_FAILED;
bd->dpastatus = BD_NOFEP;
- }
- else {
+ } else {
bd->state = NEED_PROC_CREATION;
/*
DGAP_UNLOCK(bd->bd_lock, lock_flags);
}
-
/*=======================================================================
*
* dgap_cmdb - Sends a 2 byte command to the FEP.
/*
* Check if board is still alive.
*/
- if (ch->ch_bd->state == BOARD_FAILED) {
- DPR_CORE(("%s:%d board is in failed state.\n", __FILE__, __LINE__));
+ if (ch->ch_bd->state == BOARD_FAILED)
return;
- }
/*
* Make sure the pointers are in range before
* Forget it if pointers out of range.
*/
if (head >= (CMDMAX - CMDSTART) || (head & 03)) {
- DPR_CORE(("%s:%d pointers out of range, failing board!\n", __FILE__, __LINE__));
ch->ch_bd->state = BOARD_FAILED;
return;
}
break;
if (--count == 0) {
- DPR_CORE(("%s:%d failing board.\n",__FILE__, __LINE__));
ch->ch_bd->state = BOARD_FAILED;
return;
}
}
}
-
/*=======================================================================
*
* dgap_cmdw - Sends a 1 word command to the FEP.
/*
* Check if board is still alive.
*/
- if (ch->ch_bd->state == BOARD_FAILED) {
- DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__));
+ if (ch->ch_bd->state == BOARD_FAILED)
return;
- }
/*
* Make sure the pointers are in range before
* Forget it if pointers out of range.
*/
if (head >= (CMDMAX - CMDSTART) || (head & 03)) {
- DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__));
ch->ch_bd->state = BOARD_FAILED;
return;
}
break;
if (--count == 0) {
- DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__));
ch->ch_bd->state = BOARD_FAILED;
return;
}
}
}
-
-
/*=======================================================================
*
* dgap_cmdw_ext - Sends a extended word command to the FEP.
/*
* Check if board is still alive.
*/
- if (ch->ch_bd->state == BOARD_FAILED) {
- DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__));
+ if (ch->ch_bd->state == BOARD_FAILED)
return;
- }
/*
* Make sure the pointers are in range before
* Forget it if pointers out of range.
*/
if (head >= (CMDMAX - CMDSTART) || (head & 03)) {
- DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__));
ch->ch_bd->state = BOARD_FAILED;
return;
}
* If the second part of the command won't fit,
* put it at the beginning of the circular buffer.
*/
- if (((head + 4) >= ((CMDMAX - CMDSTART)) || (head & 03))) {
+ if (((head + 4) >= ((CMDMAX - CMDSTART)) || (head & 03)))
writew((u16) word, (char *) (vaddr + CMDSTART));
- } else {
+ else
writew((u16) word, (char *) (vaddr + head + CMDSTART + 4));
- }
head = (head + 8) & (CMDMAX - CMDSTART - 4);
break;
if (--count == 0) {
- DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__));
ch->ch_bd->state = BOARD_FAILED;
return;
}
}
}
-
/*=======================================================================
*
* dgap_wmove - Write data to FEP buffer.
/*
* If pointers are out of range, just return.
*/
- if ((cnt > ch->ch_tsize) || (unsigned)(head - ch->ch_tstart) >= ch->ch_tsize) {
- DPR_CORE(("%s:%d pointer out of range", __FILE__, __LINE__));
+ if ((cnt > ch->ch_tsize) ||
+ (unsigned)(head - ch->ch_tstart) >= ch->ch_tsize)
return;
- }
/*
* If the write wraps over the top of the circular buffer,
ulong offset = 0;
uint value = 0;
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) {
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
return 0;
- }
- if (!ch->ch_bd || ch->ch_bd->magic != DGAP_BOARD_MAGIC) {
+ if (!ch->ch_bd || ch->ch_bd->magic != DGAP_BOARD_MAGIC)
return 0;
- }
if (!(ch->ch_bd->bd_flags & BD_FEP5PLUS))
return 0;
return value;
}
-
/*
* Calls the firmware to reset this channel.
*/
ch->ch_hflow = 0;
}
-
/*=======================================================================
*
* dgap_param - Set Digi parameters.
if (!bs)
return -ENXIO;
- DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n",
- ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag));
-
ts = &tty->termios;
/*
* Tell the fep to do the command
*/
- DPR_PARAM(("param: Want %d speed\n", ch->ch_custom_speed));
-
dgap_cmdw_ext(ch, 0xff01, ch->ch_custom_speed, 0);
/*
*/
ch->ch_baud_info = ch->ch_custom_speed = dgap_get_custom_baud(ch);
- DPR_PARAM(("param: Got %d speed\n", ch->ch_custom_speed));
-
/* Handle transition from B0 */
if (ch->ch_flags & CH_BAUD0) {
ch->ch_flags &= ~(CH_BAUD0);
jindex = baud;
- if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) {
+ if ((iindex >= 0) && (iindex < 4) &&
+ (jindex >= 0) && (jindex < 16))
baud = bauds[iindex][jindex];
- } else {
- DPR_IOCTL(("baud indices were out of range (%d)(%d)",
- iindex, jindex));
+ else
baud = 0;
- }
if (baud == 0)
baud = 9600;
ch->ch_baud_info = baud;
-
/*
* CBAUD has bit position 0x1000 set these days to indicate Linux
* baud rate remap.
if ((ch->ch_digi.digi_flags & DIGI_FAST) || (ch->ch_c_cflag & CBAUDEX))
cflag |= HUPCL;
-
- if ((ch->ch_c_cflag & CBAUDEX) && !(ch->ch_digi.digi_flags & DIGI_FAST)) {
- /*
- * The below code is trying to guarantee that only baud rates
- * 115200, 230400, 460800, 921600 are remapped. We use exclusive or
- * because the various baud rates share common bit positions
- * and therefore can't be tested for easily.
- */
+ if ((ch->ch_c_cflag & CBAUDEX) &&
+ !(ch->ch_digi.digi_flags & DIGI_FAST)) {
+ /*
+ * The below code is trying to guarantee that only
+ * baud rates 115200, 230400, 460800, 921600 are
+ * remapped. We use exclusive or because the various
+ * baud rates share common bit positions and therefore
+ * can't be tested for easily.
+ */
tcflag_t tcflag = (ch->ch_c_cflag & CBAUD) | CBAUDEX;
int baudpart = 0;
/* Map high speed requests to index into FEP's baud table */
switch (tcflag) {
- case B57600 :
+ case B57600:
baudpart = 1;
break;
#ifdef B76800
- case B76800 :
+ case B76800:
baudpart = 2;
break;
#endif
- case B115200 :
+ case B115200:
baudpart = 3;
break;
- case B230400 :
+ case B230400:
baudpart = 9;
break;
- case B460800 :
+ case B460800:
baudpart = 11;
break;
#ifdef B921600
- case B921600 :
+ case B921600:
baudpart = 12;
break;
#endif
* Only the IBM Xr card can switch between
* 232 and 422 modes on the fly
*/
- if (bd->device == PCI_DEVICE_XR_IBM_DID) {
+ if (bd->device == PCI_DEV_XR_IBM_DID) {
if (ch->ch_digi.digi_flags & DIGI_422)
dgap_cmdb(ch, SCOMMODE, MODE_422, 0, 0);
else
}
if (ch->ch_digi.digi_flags & DIGI_ALTPIN)
- iflag |= IALTPIN ;
+ iflag |= IALTPIN;
if (iflag != ch->ch_fepiflag) {
ch->ch_fepiflag = iflag;
*/
hflow = 0;
- if (ch->ch_c_cflag & CRTSCTS) {
+ if (ch->ch_c_cflag & CRTSCTS)
hflow |= (D_RTS(ch) | D_CTS(ch));
- }
if (ch->ch_digi.digi_flags & RTSPACE)
hflow |= D_RTS(ch);
if (ch->ch_digi.digi_flags & DTRPACE)
*/
if (bd->bd_flags & BD_FEP5PLUS) {
u16 hflow2 = 0;
- if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) {
+ if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)
hflow2 |= (D_RTS(ch));
- }
- if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) {
+ if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)
hflow2 |= (D_DTR(ch));
- }
dgap_cmdw_ext(ch, 0xff03, hflow2, 0);
}
mval ^= ch->ch_mforce & (mval ^ ch->ch_mval);
- DPR_PARAM(("dgap_param: mval: %x ch_mforce: %x ch_mval: %x ch_mostat: %x\n",
- mval, ch->ch_mforce, ch->ch_mval, ch->ch_mostat));
-
if (ch->ch_mostat ^ mval) {
ch->ch_mostat = mval;
/* Okay to have channel and board locks held calling this */
- DPR_PARAM(("dgap_param: Sending SMODEM mval: %x\n", mval));
dgap_cmdb(ch, SMODEM, (uchar) mval, D_RTS(ch)|D_DTR(ch), 0);
}
dgap_cmdb(ch, SAFLOWC, ch->ch_fepastartc, ch->ch_fepastopc, 0);
}
- DPR_PARAM(("param finish\n"));
-
return 0;
}
-
/*
* dgap_parity_scan()
*
cout = cbuf;
fout = fbuf;
- DPR_PSCAN(("dgap_parity_scan start\n"));
-
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
return;
case 0:
/* No FF seen yet */
- if (c == (unsigned char) '\377') {
+ if (c == (unsigned char) '\377')
/* delete this character from stream */
ch->pscan_state = 1;
- } else {
+ else {
*cout++ = c;
*fout++ = TTY_NORMAL;
count += 1;
if (ch->pscan_savechar == 0x0) {
if (c == 0x0) {
- DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting break.\n", c));
ch->ch_err_break++;
*fout++ = TTY_BREAK;
- }
- else {
- DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting parity.\n", c));
+ } else {
ch->ch_err_parity++;
*fout++ = TTY_PARITY;
}
}
- else {
- DPR_PSCAN(("%s:%d Logic Error.\n", __FILE__, __LINE__));
- }
count += 1;
ch->pscan_state = 0;
}
}
*len = count;
- DPR_PSCAN(("dgap_parity_scan finish\n"));
}
-
-
-
/*=======================================================================
*
* dgap_event - FEP to host event processing routine.
if (head >= EVMAX - EVSTART || tail >= EVMAX - EVSTART ||
(head | tail) & 03) {
- DPR_EVENT(("should be calling xxfail %d\n", __LINE__));
/* Let go of board lock */
DGAP_UNLOCK(bd->bd_lock, lock_flags);
return -ENXIO;
modem = event[2];
b1 = event[3];
- DPR_EVENT(("event: jiffies: %ld port: %d reason: %x modem: %x\n",
- jiffies, port, reason, modem));
-
/*
* Make sure the interrupt is valid.
*/
if (port >= bd->nasync)
goto next;
- if (!(reason & (IFMODEM | IFBREAK | IFTLW | IFTEM | IFDATA))) {
+ if (!(reason & (IFMODEM | IFBREAK | IFTLW | IFTEM | IFDATA)))
goto next;
- }
ch = bd->channels[port];
- if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) {
+ if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
goto next;
- }
/*
* If we have made it here, the event was valid.
*/
if (reason & IFBREAK) {
- DPR_EVENT(("got IFBREAK\n"));
-
if (ch->ch_tun.un_tty) {
/* A break has been indicated */
ch->ch_err_break++;
*/
if (reason & IFTLW) {
- DPR_EVENT(("event: got low event\n"));
-
if (ch->ch_tun.un_flags & UN_LOW) {
ch->ch_tun.un_flags &= ~UN_LOW;
if (ch->ch_tun.un_flags & UN_ISOPEN) {
if ((ch->ch_tun.un_tty->flags &
(1 << TTY_DO_WRITE_WAKEUP)) &&
- ch->ch_tun.un_tty->ldisc->ops->write_wakeup)
- {
+ ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
(ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
}
wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
-
- DPR_EVENT(("event: Got low event. jiffies: %lu\n", jiffies));
}
}
if (ch->ch_pun.un_flags & UN_ISOPEN) {
if ((ch->ch_pun.un_tty->flags &
(1 << TTY_DO_WRITE_WAKEUP)) &&
- ch->ch_pun.un_tty->ldisc->ops->write_wakeup)
- {
+ ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
* Process Transmit empty.
*/
if (reason & IFTEM) {
- DPR_EVENT(("event: got empty event\n"));
-
if (ch->ch_tun.un_flags & UN_EMPTY) {
ch->ch_tun.un_flags &= ~UN_EMPTY;
if (ch->ch_tun.un_flags & UN_ISOPEN) {
if ((ch->ch_tun.un_tty->flags &
(1 << TTY_DO_WRITE_WAKEUP)) &&
- ch->ch_tun.un_tty->ldisc->ops->write_wakeup)
- {
+ ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
if (ch->ch_pun.un_flags & UN_ISOPEN) {
if ((ch->ch_pun.un_tty->flags &
(1 << TTY_DO_WRITE_WAKEUP)) &&
- ch->ch_pun.un_tty->ldisc->ops->write_wakeup)
- {
+ ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
DGAP_UNLOCK(ch->ch_lock, lock_flags2);
DGAP_UNLOCK(bd->bd_lock, lock_flags);
(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
}
static DRIVER_ATTR(state, S_IRUSR, dgap_driver_state_show, NULL);
-
-static ssize_t dgap_driver_debug_show(struct device_driver *ddp, char *buf)
-{
- return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_debug);
-}
-
-static ssize_t dgap_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count)
-{
- sscanf(buf, "0x%x\n", &dgap_debug);
- return count;
-}
-static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgap_driver_debug_show, dgap_driver_debug_store);
-
-
-static ssize_t dgap_driver_rawreadok_show(struct device_driver *ddp, char *buf)
-{
- return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_rawreadok);
-}
-
-static ssize_t dgap_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count)
-{
- sscanf(buf, "0x%x\n", &dgap_rawreadok);
- return count;
-}
-static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgap_driver_rawreadok_show, dgap_driver_rawreadok_store);
-
-
static ssize_t dgap_driver_pollrate_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%dms\n", dgap_poll_tick);
static ssize_t dgap_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count)
{
- sscanf(buf, "%d\n", &dgap_poll_tick);
+ if (sscanf(buf, "%d\n", &dgap_poll_tick) != 1)
+ return -EINVAL;
return count;
}
static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgap_driver_pollrate_show, dgap_driver_pollrate_store);
-
static void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver)
{
int rc = 0;
rc |= driver_create_file(driverfs, &driver_attr_version);
rc |= driver_create_file(driverfs, &driver_attr_boards);
rc |= driver_create_file(driverfs, &driver_attr_maxboards);
- rc |= driver_create_file(driverfs, &driver_attr_debug);
- rc |= driver_create_file(driverfs, &driver_attr_rawreadok);
rc |= driver_create_file(driverfs, &driver_attr_pollrate);
rc |= driver_create_file(driverfs, &driver_attr_pollcounter);
rc |= driver_create_file(driverfs, &driver_attr_state);
- if (rc) {
+ if (rc)
printk(KERN_ERR "DGAP: sysfs driver_create_file failed!\n");
- }
}
-
static void dgap_remove_driver_sysfiles(struct pci_driver *dgap_driver)
{
struct device_driver *driverfs = &dgap_driver->driver;
driver_remove_file(driverfs, &driver_attr_version);
driver_remove_file(driverfs, &driver_attr_boards);
driver_remove_file(driverfs, &driver_attr_maxboards);
- driver_remove_file(driverfs, &driver_attr_debug);
- driver_remove_file(driverfs, &driver_attr_rawreadok);
driver_remove_file(driverfs, &driver_attr_pollrate);
driver_remove_file(driverfs, &driver_attr_pollcounter);
driver_remove_file(driverfs, &driver_attr_state);
}
+static struct board_t *dgap_verify_board(struct device *p)
+{
+ struct board_t *bd;
+
+ if (!p)
+ return NULL;
-#define DGAP_VERIFY_BOARD(p, bd) \
- if (!p) \
- return (0); \
- \
- bd = dev_get_drvdata(p); \
- if (!bd || bd->magic != DGAP_BOARD_MAGIC) \
- return (0); \
- if (bd->state != BOARD_READY) \
- return (0); \
+ bd = dev_get_drvdata(p);
+ if (!bd || bd->magic != DGAP_BOARD_MAGIC || bd->state != BOARD_READY)
+ return NULL;
+ return bd;
+}
static ssize_t dgap_ports_state_show(struct device *p, struct device_attribute *attr, char *buf)
{
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count,
}
static DEVICE_ATTR(ports_state, S_IRUSR, dgap_ports_state_show, NULL);
-
static ssize_t dgap_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count,
}
static DEVICE_ATTR(ports_baud, S_IRUSR, dgap_ports_baud_show, NULL);
-
static ssize_t dgap_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
for (i = 0; i < bd->nasync; i++) {
- if (bd->channels[i]->ch_open_count) {
+ if (bd->channels[i]->ch_open_count)
count += snprintf(buf + count, PAGE_SIZE - count,
"%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum,
(bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "",
(bd->channels[i]->ch_mistat & UART_MSR_DSR) ? "DSR" : "",
(bd->channels[i]->ch_mistat & UART_MSR_DCD) ? "DCD" : "",
(bd->channels[i]->ch_mistat & UART_MSR_RI) ? "RI" : "");
- } else {
+ else
count += snprintf(buf + count, PAGE_SIZE - count,
"%d\n", bd->channels[i]->ch_portnum);
- }
}
return count;
}
static DEVICE_ATTR(ports_msignals, S_IRUSR, dgap_ports_msignals_show, NULL);
-
static ssize_t dgap_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
- for (i = 0; i < bd->nasync; i++) {
+ for (i = 0; i < bd->nasync; i++)
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag);
- }
return count;
}
static DEVICE_ATTR(ports_iflag, S_IRUSR, dgap_ports_iflag_show, NULL);
-
static ssize_t dgap_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
- for (i = 0; i < bd->nasync; i++) {
+ for (i = 0; i < bd->nasync; i++)
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag);
- }
return count;
}
static DEVICE_ATTR(ports_cflag, S_IRUSR, dgap_ports_cflag_show, NULL);
-
static ssize_t dgap_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
- for (i = 0; i < bd->nasync; i++) {
+ for (i = 0; i < bd->nasync; i++)
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag);
- }
return count;
}
static DEVICE_ATTR(ports_oflag, S_IRUSR, dgap_ports_oflag_show, NULL);
-
static ssize_t dgap_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
- for (i = 0; i < bd->nasync; i++) {
+ for (i = 0; i < bd->nasync; i++)
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag);
- }
return count;
}
static DEVICE_ATTR(ports_lflag, S_IRUSR, dgap_ports_lflag_show, NULL);
-
static ssize_t dgap_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
- for (i = 0; i < bd->nasync; i++) {
+ for (i = 0; i < bd->nasync; i++)
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags);
- }
return count;
}
static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgap_ports_digi_flag_show, NULL);
-
static ssize_t dgap_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
- for (i = 0; i < bd->nasync; i++) {
+ for (i = 0; i < bd->nasync; i++)
count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount);
- }
return count;
}
static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgap_ports_rxcount_show, NULL);
-
static ssize_t dgap_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
- DGAP_VERIFY_BOARD(p, bd);
+ bd = dgap_verify_board(p);
+ if (!bd)
+ return 0;
- for (i = 0; i < bd->nasync; i++) {
+ for (i = 0; i < bd->nasync; i++)
count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount);
- }
return count;
}
static DEVICE_ATTR(ports_txcount, S_IRUSR, dgap_ports_txcount_show, NULL);
-
/* this function creates the sys files that will export each signal status
* to sysfs each value will be put in a separate filename
*/
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount);
- if (rc) {
+ if (rc)
printk(KERN_ERR "DGAP: sysfs device_create_file failed!\n");
- }
}
-
/* removes all the sys files created for that port */
static void dgap_remove_ports_sysfiles(struct board_t *bd)
{
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount);
}
-
static ssize_t dgap_tty_state_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed");
}
static DEVICE_ATTR(state, S_IRUSR, dgap_tty_state_show, NULL);
-
static ssize_t dgap_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_baud_info);
}
static DEVICE_ATTR(baud, S_IRUSR, dgap_tty_baud_show, NULL);
-
static ssize_t dgap_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
if (ch->ch_open_count) {
return snprintf(buf, PAGE_SIZE, "%s %s %s %s %s %s\n",
}
static DEVICE_ATTR(msignals, S_IRUSR, dgap_tty_msignals_show, NULL);
-
static ssize_t dgap_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag);
}
static DEVICE_ATTR(iflag, S_IRUSR, dgap_tty_iflag_show, NULL);
-
static ssize_t dgap_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag);
}
static DEVICE_ATTR(cflag, S_IRUSR, dgap_tty_cflag_show, NULL);
-
static ssize_t dgap_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_oflag);
}
static DEVICE_ATTR(oflag, S_IRUSR, dgap_tty_oflag_show, NULL);
-
static ssize_t dgap_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag);
}
static DEVICE_ATTR(lflag, S_IRUSR, dgap_tty_lflag_show, NULL);
-
static ssize_t dgap_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags);
}
static DEVICE_ATTR(digi_flag, S_IRUSR, dgap_tty_digi_flag_show, NULL);
-
static ssize_t dgap_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount);
}
static DEVICE_ATTR(rxcount, S_IRUSR, dgap_tty_rxcount_show, NULL);
-
static ssize_t dgap_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct un_t *un;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount);
}
static DEVICE_ATTR(txcount, S_IRUSR, dgap_tty_txcount_show, NULL);
-
static ssize_t dgap_tty_name_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int i = 0;
if (!d)
- return (0);
+ return 0;
un = dev_get_drvdata(d);
if (!un || un->magic != DGAP_UNIT_MAGIC)
- return (0);
+ return 0;
ch = un->un_ch;
if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
- return (0);
+ return 0;
bd = ch->ch_bd;
if (!bd || bd->magic != DGAP_BOARD_MAGIC)
- return (0);
+ return 0;
if (bd->state != BOARD_READY)
- return (0);
+ return 0;
- bn = bd->boardnum;
+ bn = bd->boardnum;
cn = ch->ch_portnum;
for (cptr = bd->bd_config; cptr; cptr = cptr->next) {
if (strstr(cptr->u.ttyname, "tty")) {
ptr1 = cptr->u.ttyname;
ptr1 += 3;
- }
- else {
+ } else
ptr1 = cptr->u.ttyname;
- }
for (i = 0; i < dgap_config_get_number_of_ports(bd); i++) {
- if (cn == i) {
+ if (cn == i)
return snprintf(buf, PAGE_SIZE, "%s%s%02d\n",
(un->un_type == DGAP_PRINT) ? "pr" : "tty",
ptr1, i + starto);
- }
}
}
if (cptr->type == CNODE) {
for (i = 0; i < cptr->u.conc.nport; i++) {
- if (cn == (i + ncount)) {
+ if (cn == (i + ncount))
return snprintf(buf, PAGE_SIZE, "%s%s%02d\n",
(un->un_type == DGAP_PRINT) ? "pr" : "tty",
cptr->u.conc.id,
i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1));
- }
}
ncount += cptr->u.conc.nport;
if (cptr->type == MNODE) {
for (i = 0; i < cptr->u.module.nport; i++) {
- if (cn == (i + ncount)) {
+ if (cn == (i + ncount))
return snprintf(buf, PAGE_SIZE, "%s%s%02d\n",
(un->un_type == DGAP_PRINT) ? "pr" : "tty",
cptr->u.module.id,
i + (cptr->u.module.v_start ? cptr->u.module.start : 1));
- }
}
ncount += cptr->u.module.nport;
}
static DEVICE_ATTR(custom_name, S_IRUSR, dgap_tty_name_show, NULL);
-
static struct attribute *dgap_sysfs_tty_entries[] = {
&dev_attr_state.attr,
&dev_attr_baud.attr,
NULL
};
-
static struct attribute_group dgap_tty_attribute_group = {
.name = NULL,
.attrs = dgap_sysfs_tty_entries,
};
-
-
-
static void dgap_create_tty_sysfs(struct un_t *un, struct device *c)
{
int ret;
ret = sysfs_create_group(&c->kobj, &dgap_tty_attribute_group);
- if (ret) {
- printk(KERN_ERR "dgap: failed to create sysfs tty device attributes.\n");
- sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group);
+ if (ret)
return;
- }
dev_set_drvdata(c, un);
}
-
static void dgap_remove_tty_sysfs(struct device *c)
{
sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group);
brd = line = conc = NULL;
/* perhaps we are adding to an existing list? */
- while (p->next != NULL) {
+ while (p->next != NULL)
p = p->next;
- }
/* file must start with a BEGIN */
- while ( (rc = dgap_gettok(in,p)) != BEGIN ) {
+ while ((rc = dgap_gettok(in, p)) != BEGIN) {
if (rc == 0) {
dgap_err("unexpected EOF");
- return(-1);
+ return -1;
}
}
- for (; ; ) {
- rc = dgap_gettok(in,p);
+ for (; ;) {
+ rc = dgap_gettok(in, p);
if (rc == 0) {
dgap_err("unexpected EOF");
- return(-1);
+ return -1;
}
switch (rc) {
case 0:
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
case BEGIN: /* should only be 1 begin */
dgap_err("unexpected config_begin\n");
- return(-1);
+ return -1;
case END:
- return(0);
+ return 0;
case BOARD: /* board info */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(BNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(BNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
case APORT2_920P: /* AccelePort_4 */
if (p->type != BNODE) {
dgap_err("unexpected Digi_2r_920 string");
- return(-1);
+ return -1;
}
p->u.board.type = APORT2_920P;
p->u.board.v_type = 1;
- DPR_INIT(("Adding Digi_2r_920 PCI to config...\n"));
break;
case APORT4_920P: /* AccelePort_4 */
if (p->type != BNODE) {
dgap_err("unexpected Digi_4r_920 string");
- return(-1);
+ return -1;
}
p->u.board.type = APORT4_920P;
p->u.board.v_type = 1;
- DPR_INIT(("Adding Digi_4r_920 PCI to config...\n"));
break;
case APORT8_920P: /* AccelePort_8 */
if (p->type != BNODE) {
dgap_err("unexpected Digi_8r_920 string");
- return(-1);
+ return -1;
}
p->u.board.type = APORT8_920P;
p->u.board.v_type = 1;
- DPR_INIT(("Adding Digi_8r_920 PCI to config...\n"));
break;
case PAPORT4: /* AccelePort_4 PCI */
if (p->type != BNODE) {
dgap_err("unexpected Digi_4r(PCI) string");
- return(-1);
+ return -1;
}
p->u.board.type = PAPORT4;
p->u.board.v_type = 1;
- DPR_INIT(("Adding Digi_4r PCI to config...\n"));
break;
case PAPORT8: /* AccelePort_8 PCI */
if (p->type != BNODE) {
dgap_err("unexpected Digi_8r string");
- return(-1);
+ return -1;
}
p->u.board.type = PAPORT8;
p->u.board.v_type = 1;
- DPR_INIT(("Adding Digi_8r PCI to config...\n"));
break;
case PCX: /* PCI C/X */
if (p->type != BNODE) {
dgap_err("unexpected Digi_C/X_(PCI) string");
- return(-1);
+ return -1;
}
p->u.board.type = PCX;
p->u.board.v_type = 1;
p->u.board.conc2 = 0;
p->u.board.module1 = 0;
p->u.board.module2 = 0;
- DPR_INIT(("Adding PCI C/X to config...\n"));
break;
case PEPC: /* PCI EPC/X */
if (p->type != BNODE) {
dgap_err("unexpected \"Digi_EPC/X_(PCI)\" string");
- return(-1);
+ return -1;
}
p->u.board.type = PEPC;
p->u.board.v_type = 1;
p->u.board.conc2 = 0;
p->u.board.module1 = 0;
p->u.board.module2 = 0;
- DPR_INIT(("Adding PCI EPC/X to config...\n"));
break;
case PPCM: /* PCI/Xem */
if (p->type != BNODE) {
dgap_err("unexpected PCI/Xem string");
- return(-1);
+ return -1;
}
p->u.board.type = PPCM;
p->u.board.v_type = 1;
p->u.board.conc1 = 0;
p->u.board.conc2 = 0;
- DPR_INIT(("Adding PCI XEM to config...\n"));
break;
case IO: /* i/o port */
if (p->type != BNODE) {
dgap_err("IO port only vaild for boards");
- return(-1);
+ return -1;
}
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.portstr = dgap_savestring(s);
p->u.board.port = (short)simple_strtol(s, &s2, 0);
if ((short)strlen(s) > (short)(s2 - s)) {
dgap_err("bad number for IO port");
- return(-1);
+ return -1;
}
p->u.board.v_port = 1;
- DPR_INIT(("Adding IO (%s) to config...\n", s));
break;
case MEM: /* memory address */
if (p->type != BNODE) {
dgap_err("memory address only vaild for boards");
- return(-1);
+ return -1;
}
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.addrstr = dgap_savestring(s);
p->u.board.addr = simple_strtoul(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for memory address");
- return(-1);
+ return -1;
}
p->u.board.v_addr = 1;
- DPR_INIT(("Adding MEM (%s) to config...\n", s));
break;
case PCIINFO: /* pci information */
if (p->type != BNODE) {
dgap_err("memory address only vaild for boards");
- return(-1);
+ return -1;
}
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.pcibusstr = dgap_savestring(s);
p->u.board.pcibus = simple_strtoul(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for pci bus");
- return(-1);
+ return -1;
}
p->u.board.v_pcibus = 1;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.pcislotstr = dgap_savestring(s);
p->u.board.pcislot = simple_strtoul(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for pci slot");
- return(-1);
+ return -1;
}
p->u.board.v_pcislot = 1;
-
- DPR_INIT(("Adding PCIINFO (%s %s) to config...\n", p->u.board.pcibusstr,
- p->u.board.pcislotstr));
break;
case METHOD:
if (p->type != BNODE) {
dgap_err("install method only vaild for boards");
- return(-1);
+ return -1;
}
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.method = dgap_savestring(s);
p->u.board.v_method = 1;
- DPR_INIT(("Adding METHOD (%s) to config...\n", s));
break;
case STATUS:
if (p->type != BNODE) {
dgap_err("config status only vaild for boards");
- return(-1);
+ return -1;
}
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.status = dgap_savestring(s);
- DPR_INIT(("Adding STATUS (%s) to config...\n", s));
break;
case NPORTS: /* number of ports */
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.nport = (char)simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for number of ports");
- return(-1);
+ return -1;
}
p->u.board.v_nport = 1;
} else if (p->type == CNODE) {
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.conc.nport = (char)simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for number of ports");
- return(-1);
+ return -1;
}
p->u.conc.v_nport = 1;
} else if (p->type == MNODE) {
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.module.nport = (char)simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for number of ports");
- return(-1);
+ return -1;
}
p->u.module.v_nport = 1;
} else {
dgap_err("nports only valid for concentrators or modules");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding NPORTS (%s) to config...\n", s));
break;
case ID: /* letter ID used in tty name */
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.status = dgap_savestring(s);
p->u.module.v_id = 1;
} else {
dgap_err("id only valid for concentrators or modules");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding ID (%s) to config...\n", s));
break;
case STARTO: /* start offset of ID */
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.board.start = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for start of tty count");
- return(-1);
+ return -1;
}
p->u.board.v_start = 1;
} else if (p->type == CNODE) {
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.conc.start = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for start of tty count");
- return(-1);
+ return -1;
}
p->u.conc.v_start = 1;
} else if (p->type == MNODE) {
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.module.start = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for start of tty count");
- return(-1);
+ return -1;
}
p->u.module.v_start = 1;
} else {
dgap_err("start only valid for concentrators or modules");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding START (%s) to config...\n", s));
break;
case TTYN: /* tty name prefix */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(TNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(TNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
- if ( (s = dgap_getword(in)) == NULL ) {
+ s = dgap_getword(in);
+ if (!s) {
dgap_err("unexpeced end of file");
- return(-1);
+ return -1;
}
- if ( (p->u.ttyname = dgap_savestring(s)) == NULL ) {
+ p->u.ttyname = dgap_savestring(s);
+ if (!p->u.ttyname) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding TTY (%s) to config...\n", s));
break;
case CU: /* cu name prefix */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(CUNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(CUNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
- if ( (s = dgap_getword(in)) == NULL ) {
+ s = dgap_getword(in);
+ if (!s) {
dgap_err("unexpeced end of file");
- return(-1);
+ return -1;
}
- if ( (p->u.cuname = dgap_savestring(s)) == NULL ) {
+ p->u.cuname = dgap_savestring(s);
+ if (!p->u.cuname) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding CU (%s) to config...\n", s));
break;
case LINE: /* line information */
if (dgap_checknode(p))
- return(-1);
+ return -1;
if (brd == NULL) {
dgap_err("must specify board before line info");
- return(-1);
+ return -1;
}
switch (brd->u.board.type) {
case PPCM:
dgap_err("line not vaild for PC/em");
- return(-1);
+ return -1;
}
- if ( (p->next = dgap_newnode(LNODE)) == NULL ) {
+ p->next = dgap_newnode(LNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
conc = NULL;
line = p;
linecnt++;
- DPR_INIT(("Adding LINE to config...\n"));
break;
case CONC: /* concentrator information */
if (dgap_checknode(p))
- return(-1);
+ return -1;
if (line == NULL) {
dgap_err("must specify line info before concentrator");
- return(-1);
+ return -1;
}
- if ( (p->next = dgap_newnode(CNODE)) == NULL ) {
+ p->next = dgap_newnode(CNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
conc = p;
else
brd->u.board.conc1++;
- DPR_INIT(("Adding CONC to config...\n"));
break;
case CX: /* c/x type concentrator */
if (p->type != CNODE) {
dgap_err("cx only valid for concentrators");
- return(-1);
+ return -1;
}
p->u.conc.type = CX;
p->u.conc.v_type = 1;
- DPR_INIT(("Adding CX to config...\n"));
break;
case EPC: /* epc type concentrator */
if (p->type != CNODE) {
dgap_err("cx only valid for concentrators");
- return(-1);
+ return -1;
}
p->u.conc.type = EPC;
p->u.conc.v_type = 1;
- DPR_INIT(("Adding EPC to config...\n"));
break;
case MOD: /* EBI module */
if (dgap_checknode(p))
- return(-1);
+ return -1;
if (brd == NULL) {
dgap_err("must specify board info before EBI modules");
- return(-1);
+ return -1;
}
switch (brd->u.board.type) {
case PPCM:
default:
if (conc == NULL) {
dgap_err("must specify concentrator info before EBI module");
- return(-1);
+ return -1;
}
}
- if ( (p->next = dgap_newnode(MNODE)) == NULL ) {
+ p->next = dgap_newnode(MNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
if (linecnt)
else
brd->u.board.module1++;
- DPR_INIT(("Adding MOD to config...\n"));
break;
case PORTS: /* ports type EBI module */
if (p->type != MNODE) {
dgap_err("ports only valid for EBI modules");
- return(-1);
+ return -1;
}
p->u.module.type = PORTS;
p->u.module.v_type = 1;
- DPR_INIT(("Adding PORTS to config...\n"));
break;
case MODEM: /* ports type EBI module */
if (p->type != MNODE) {
dgap_err("modem only valid for modem modules");
- return(-1);
+ return -1;
}
p->u.module.type = MODEM;
p->u.module.v_type = 1;
- DPR_INIT(("Adding MODEM to config...\n"));
break;
case CABLE:
if (p->type == LNODE) {
- if ((s = dgap_getword(in)) == NULL) {
+ s = dgap_getword(in);
+ if (!s) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.line.cable = dgap_savestring(s);
p->u.line.v_cable = 1;
}
- DPR_INIT(("Adding CABLE (%s) to config...\n", s));
break;
case SPEED: /* sync line speed indication */
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.line.speed = (char)simple_strtol(s, &s2, 0);
if ((short)strlen(s) > (short)(s2 - s)) {
dgap_err("bad number for line speed");
- return(-1);
+ return -1;
}
p->u.line.v_speed = 1;
} else if (p->type == CNODE) {
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.conc.speed = (char)simple_strtol(s, &s2, 0);
if ((short)strlen(s) > (short)(s2 - s)) {
dgap_err("bad number for line speed");
- return(-1);
+ return -1;
}
p->u.conc.v_speed = 1;
} else {
dgap_err("speed valid only for lines or concentrators.");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding SPEED (%s) to config...\n", s));
break;
case CONNECT:
if (p->type == CNODE) {
- if ((s = dgap_getword(in)) == NULL) {
+ s = dgap_getword(in);
+ if (!s) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.conc.connect = dgap_savestring(s);
p->u.conc.v_connect = 1;
}
- DPR_INIT(("Adding CONNECT (%s) to config...\n", s));
break;
case PRINT: /* transparent print name prefix */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(PNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(PNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
- if ( (s = dgap_getword(in)) == NULL ) {
+ s = dgap_getword(in);
+ if (!s) {
dgap_err("unexpeced end of file");
- return(-1);
+ return -1;
}
- if ( (p->u.printname = dgap_savestring(s)) == NULL ) {
+ p->u.printname = dgap_savestring(s);
+ if (!p->u.printname) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding PRINT (%s) to config...\n", s));
break;
case CMAJOR: /* major number */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(JNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(JNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.majornumber = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for major number");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding CMAJOR (%s) to config...\n", s));
break;
case ALTPIN: /* altpin setting */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(ANODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(ANODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.altpin = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for altpin");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding ALTPIN (%s) to config...\n", s));
break;
case USEINTR: /* enable interrupt setting */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(INTRNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(INTRNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.useintr = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for useintr");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding USEINTR (%s) to config...\n", s));
break;
case TTSIZ: /* size of tty structure */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(TSNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(TSNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.ttysize = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for ttysize");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding TTSIZ (%s) to config...\n", s));
break;
case CHSIZ: /* channel structure size */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(CSNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(CSNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.chsize = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for chsize");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding CHSIZE (%s) to config...\n", s));
break;
case BSSIZ: /* board structure size */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(BSNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(BSNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.bssize = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for bssize");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding BSSIZ (%s) to config...\n", s));
break;
case UNTSIZ: /* sched structure size */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(USNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(USNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.unsize = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for schedsize");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding UNTSIZ (%s) to config...\n", s));
break;
case F2SIZ: /* f2200 structure size */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(FSNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(FSNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.f2size = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for f2200size");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding F2SIZ (%s) to config...\n", s));
break;
case VPSIZ: /* vpix structure size */
if (dgap_checknode(p))
- return(-1);
- if ( (p->next = dgap_newnode(VSNODE)) == NULL ) {
+ return -1;
+ p->next = dgap_newnode(VSNODE);
+ if (!p->next) {
dgap_err("out of memory");
- return(-1);
+ return -1;
}
p = p->next;
s = dgap_getword(in);
if (s == NULL) {
dgap_err("unexpected end of file");
- return(-1);
+ return -1;
}
p->u.vpixsize = simple_strtol(s, &s2, 0);
if ((int)strlen(s) > (int)(s2 - s)) {
dgap_err("bad number for vpixsize");
- return(-1);
+ return -1;
}
- DPR_INIT(("Adding VPSIZ (%s) to config...\n", s));
break;
}
}
}
-
/*
* dgap_sindex: much like index(), but it looks for a match of any character in
* the group, and returns that position. If the first character is a ^, then
* this will match the first occurrence not in that group.
*/
-static char *dgap_sindex (char *string, char *group)
+static char *dgap_sindex(char *string, char *group)
{
char *ptr;
if (*ptr == '\0')
return string;
}
- }
- else {
+ } else {
for (; *string; string++) {
for (ptr = group; *ptr; ptr++) {
if (*ptr == *string)
return (char *) NULL;
}
-
/*
* Get a token from the input file; return 0 if end of file is reached
*/
w = dgap_getword(in);
snprintf(dgap_cword, MAXCWORD, "%s", w);
for (t = dgap_tlist; t->token != 0; t++) {
- if ( !strcmp(w, t->string)) {
- return(t->token);
- }
+ if (!strcmp(w, t->string))
+ return t->token;
}
dgap_err("board !!type not specified");
- return(1);
- }
- else {
- while ( (w = dgap_getword(in)) != NULL ) {
+ return 1;
+ } else {
+ while ((w = dgap_getword(in))) {
snprintf(dgap_cword, MAXCWORD, "%s", w);
for (t = dgap_tlist; t->token != 0; t++) {
- if ( !strcmp(w, t->string) )
- return(t->token);
+ if (!strcmp(w, t->string))
+ return t->token;
}
}
- return(0);
+ return 0;
}
}
-
/*
* get a word from the input stream, also keep track of current line number.
* words are separated by whitespace.
{
char *ret_ptr = *in;
- char *ptr = dgap_sindex(*in, " \t\n");
+ char *ptr = dgap_sindex(*in, " \t\n");
/* If no word found, return null */
if (!ptr)
return ret_ptr;
}
-
/*
* print an error message, giving the line number in the file where
* the error occurred.
*/
static void dgap_err(char *s)
{
- printk("DGAP: parse: %s\n", s);
+ pr_err("dgap: parse: %s\n", s);
}
-
/*
* allocate a new configuration node of type t
*/
memset((char *)n, 0, sizeof(struct cnode));
n->type = t;
}
- return(n);
+ return n;
}
-
/*
* dgap_checknode: see if all the necessary info has been supplied for a node
* before creating the next node.
case BNODE:
if (p->u.board.v_type == 0) {
dgap_err("board type !not specified");
- return(1);
+ return 1;
}
- return(0);
+ return 0;
case LNODE:
if (p->u.line.v_speed == 0) {
dgap_err("line speed not specified");
- return(1);
+ return 1;
}
- return(0);
+ return 0;
case CNODE:
if (p->u.conc.v_type == 0) {
dgap_err("concentrator type not specified");
- return(1);
+ return 1;
}
if (p->u.conc.v_speed == 0) {
dgap_err("concentrator line speed not specified");
- return(1);
+ return 1;
}
if (p->u.conc.v_nport == 0) {
dgap_err("number of ports on concentrator not specified");
- return(1);
+ return 1;
}
if (p->u.conc.v_id == 0) {
dgap_err("concentrator id letter not specified");
- return(1);
+ return 1;
}
- return(0);
+ return 0;
case MNODE:
if (p->u.module.v_type == 0) {
dgap_err("EBI module type not specified");
- return(1);
+ return 1;
}
if (p->u.module.v_nport == 0) {
dgap_err("number of ports on EBI module not specified");
- return(1);
+ return 1;
}
if (p->u.module.v_id == 0) {
dgap_err("EBI module id letter not specified");
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
- return(0);
+ return 0;
}
/*
static char *dgap_savestring(char *s)
{
char *p;
- if ( (p = kmalloc(strlen(s) + 1, GFP_ATOMIC) ) != NULL) {
+
+ p = kmalloc(strlen(s) + 1, GFP_ATOMIC);
+ if (p)
strcpy(p, s);
- }
- return(p);
+ return p;
}
-
/*
* Given a board pointer, returns whether we should use interrupts or not.
*/
struct cnode *p = NULL;
if (!bd)
- return(0);
+ return 0;
for (p = bd->bd_config; p; p = p->next) {
switch (p->type) {
return 0;
}
-
/*
* Given a board pointer, returns whether we turn on altpin or not.
*/
struct cnode *p = NULL;
if (!bd)
- return(0);
+ return 0;
for (p = bd->bd_config; p; p = p->next) {
switch (p->type) {
return 0;
}
-
-
/*
* Given a specific type of board, if found, detached link and
* returns the first occurrence in the list.
if (p->u.board.type == type) {
- if (p->u.board.v_pcibus && p->u.board.pcibus != bus) {
- DPR(("Found matching board, but wrong bus position. System says bus %d, we want bus %ld\n",
- bus, p->u.board.pcibus));
+ if (p->u.board.v_pcibus &&
+ p->u.board.pcibus != bus)
continue;
- }
- if (p->u.board.v_pcislot && p->u.board.pcislot != slot) {
- DPR_INIT(("Found matching board, but wrong slot position. System says slot %d, we want slot %ld\n",
- slot, p->u.board.pcislot));
+ if (p->u.board.v_pcislot &&
+ p->u.board.pcislot != slot)
continue;
- }
-
- DPR_INIT(("Matched type in config file\n"));
found = p;
/*
struct cnode *p = NULL;
if (!bd)
- return(0);
+ return 0;
for (p = bd->bd_config; p; p = p->next) {
break;
}
}
- return (count);
+ return count;
}
static char *dgap_create_config_string(struct board_t *bd, char *string)
*/
speed = p->u.conc.speed;
q = p->next;
- if ((q != NULL) && (q->type == MNODE) ) {
+ if ((q != NULL) && (q->type == MNODE)) {
*ptr = (p->u.conc.nport + 0x80);
ptr++;
p = q;