patch-2.2.19 linux/drivers/char/synclink.c
Next file: linux/drivers/char/toshiba.c
Previous file: linux/drivers/char/sx.c
Back to the patch index
Back to the overall index
- Lines: 629
- Date:
Sun Mar 25 11:37:31 2001
- Orig file:
v2.2.18/drivers/char/synclink.c
- Orig date:
Sun Mar 25 11:28:23 2001
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/drivers/char/synclink.c linux/drivers/char/synclink.c
@@ -1,7 +1,7 @@
/*
* linux/drivers/char/synclink.c
*
- * ==FILEDATE 20000821==
+ * $Id: synclink.c,v 2.4 2000/12/11 20:08:18 paul Exp $
*
* Device driver for Microgate SyncLink ISA and PCI
* high speed multiprotocol serial adapters.
@@ -79,17 +79,10 @@
#include <linux/ioport.h>
#include <linux/mm.h>
#include <linux/malloc.h>
-
#include <linux/netdevice.h>
-
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <asm/serial.h>
-#else
-#include <linux/bios32.h>
-#endif
-
#include <linux/delay.h>
#include <linux/ioctl.h>
@@ -102,90 +95,34 @@
#include <linux/termios.h>
#include <linux/tqueue.h>
+#if LINUX_VERSION_CODE < VERSION(2,2,18)
+typedef struct wait_queue *wait_queue_head_t;
+#define DECLARE_WAITQUEUE(name,task) struct wait_queue (name) = {(task),NULL}
+#define init_waitqueue_head(head) *(head) = NULL
+#define DECLARE_MUTEX(name) struct semaphore (name) = MUTEX
+#define set_current_state(a) current->state = (a)
+#endif
+
#ifdef CONFIG_SYNCLINK_SYNCPPP_MODULE
#define CONFIG_SYNCLINK_SYNCPPP 1
#endif
#ifdef CONFIG_SYNCLINK_SYNCPPP
-#if LINUX_VERSION_CODE < VERSION(2,3,43)
#include "../net/syncppp.h"
#define net_device device
#define netif_stop_queue(a) (a)->tbusy = 1
#define netif_start_queue(a) (a)->tbusy = 0
#define netif_wake_queue(a) (a)->tbusy = 0; mark_bh(NET_BH)
#define netif_queue_stopped(a) ((a)->tbusy)
-#else
-#include "../net/wan/syncppp.h"
-#endif
#endif
-#if LINUX_VERSION_CODE >= VERSION(2,1,4)
#include <asm/segment.h>
#define GET_USER(error,value,addr) error = get_user(value,addr)
#define COPY_FROM_USER(error,dest,src,size) error = copy_from_user(dest,src,size) ? -EFAULT : 0
#define PUT_USER(error,value,addr) error = put_user(value,addr)
#define COPY_TO_USER(error,dest,src,size) error = copy_to_user(dest,src,size) ? -EFAULT : 0
-#if LINUX_VERSION_CODE >= VERSION(2,1,5)
#include <asm/uaccess.h>
-#endif
-
-#else /* 2.0.x and 2.1.x before 2.1.4 */
-
-#define GET_USER(error,value,addr) \
-do { \
- error = verify_area (VERIFY_READ, (void *) addr, sizeof (value)); \
- if (error == 0) \
- value = get_user(addr); \
-} while (0)
-
-#define COPY_FROM_USER(error,dest,src,size) \
-do { \
- error = verify_area (VERIFY_READ, (void *) src, size); \
- if (error == 0) \
- memcpy_fromfs (dest, src, size); \
-} while (0)
-
-#define PUT_USER(error,value,addr) \
-do { \
- error = verify_area (VERIFY_WRITE, (void *) addr, sizeof (value)); \
- if (error == 0) \
- put_user (value, addr); \
-} while (0)
-
-#define COPY_TO_USER(error,dest,src,size) \
-do { \
- error = verify_area (VERIFY_WRITE, (void *) dest, size); \
- if (error == 0) \
- memcpy_tofs (dest, src, size); \
-} while (0)
-
-#endif
-
-#if LINUX_VERSION_CODE < VERSION(2,1,0)
-/*
- * This is used to figure out the divisor speeds and the timeouts
- */
-static int baud_table[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
- 9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 };
-
-#define __init
-#define ioremap(a,b) vremap((a),(b))
-#define iounmap(a) vfree((a))
-#define SERIAL_TYPE_NORMAL 1
-#define SERIAL_TYPE_CALLOUT 2
-typedef int spinlock_t;
-#define spin_lock_init(a)
-#define spin_lock_irqsave(a,b) {save_flags((b));cli();}
-#define spin_unlock_irqrestore(a,b) {restore_flags((b));}
-#define spin_lock(a)
-#define spin_unlock(a)
-#define schedule_timeout(a){current->timeout = jiffies + (a); schedule();}
-#define signal_pending(a) ((a)->signal & ~(a)->blocked)
-#endif
-
-
#include "linux/synclink.h"
@@ -944,7 +881,6 @@
static int maxframe[MAX_TOTAL_DEVICES] = {0,};
static int dosyncppp[MAX_TOTAL_DEVICES] = {0,};
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
MODULE_PARM(break_on_load,"i");
MODULE_PARM(ttymajor,"i");
MODULE_PARM(cuamajor,"i");
@@ -954,10 +890,9 @@
MODULE_PARM(debug_level,"i");
MODULE_PARM(maxframe,"1-" __MODULE_STRING(MAX_TOTAL_DEVICES) "i");
MODULE_PARM(dosyncppp,"1-" __MODULE_STRING(MAX_TOTAL_DEVICES) "i");
-#endif
static char *driver_name = "SyncLink serial driver";
-static char *driver_version = "1.22";
+static char *driver_version = "2.3";
static struct tty_driver serial_driver, callout_driver;
static int serial_refcount;
@@ -969,9 +904,9 @@
static void mgsl_change_params(struct mgsl_struct *info);
static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout);
-static struct tty_struct **serial_table = NULL;
-static struct termios **serial_termios = NULL;
-static struct termios **serial_termios_locked = NULL;
+static struct tty_struct *serial_table[MAX_TOTAL_DEVICES];
+static struct termios *serial_termios[MAX_TOTAL_DEVICES];
+static struct termios *serial_termios_locked[MAX_TOTAL_DEVICES];
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -1372,11 +1307,6 @@
#endif
} else
info->input_signal_events.dcd_down++;
-#ifdef CONFIG_HARD_PPS
- if ((info->flags & ASYNC_HARDPPS_CD) &&
- (status & MISCSTATUS_DCD_LATCHED))
- hardpps();
-#endif
}
if (status & MISCSTATUS_CTS_LATCHED)
{
@@ -1583,14 +1513,8 @@
icount->parity,icount->frame,icount->overrun);
}
- if ( tty->flip.count ) {
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
+ if ( tty->flip.count )
tty_flip_buffer_push(tty);
-#else
- queue_task(&tty->flip.tqueue, &tq_timer);
-#endif
- }
-
} /* end of mgsl_isr_receive_data() */
@@ -1787,11 +1711,7 @@
retval = mgsl_adapter_test(info);
if ( retval ) {
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
if (capable(CAP_SYS_ADMIN) && info->tty)
-#else
- if (suser() && info->tty)
-#endif
set_bit(TTY_IO_ERROR, &info->tty->flags);
mgsl_release_resources(info);
return retval;
@@ -1967,19 +1887,7 @@
* current data rate.
*/
if (info->params.data_rate <= 460800) {
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
info->params.data_rate = tty_get_baud_rate(info->tty);
-#else
- int i = cflag & CBAUD;
- if (i & CBAUDEX) {
- i &= ~CBAUDEX;
- if (i < 1 || i > 4)
- info->tty->termios->c_cflag &= ~CBAUDEX;
- else
- i += 15;
- }
- info->params.data_rate = baud_table[i];
-#endif
}
if ( info->params.data_rate ) {
@@ -2942,7 +2850,6 @@
} /* end of set_modem_info() */
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
/* mgsl_break() Set or clear transmit break condition
*
* Arguments: tty pointer to tty instance data
@@ -2969,7 +2876,6 @@
spin_unlock_irqrestore(&info->irq_spinlock,flags);
} /* end of mgsl_break() */
-#endif
/* mgsl_ioctl() Service an IOCTL request
*
@@ -3092,7 +2998,6 @@
if (error) return error;
PUT_USER(error,cnow.dcd, &p_cuser->dcd);
if (error) return error;
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
PUT_USER(error,cnow.rx, &p_cuser->rx);
if (error) return error;
PUT_USER(error,cnow.tx, &p_cuser->tx);
@@ -3107,7 +3012,6 @@
if (error) return error;
PUT_USER(error,cnow.buf_overrun, &p_cuser->buf_overrun);
if (error) return error;
-#endif
return 0;
default:
return -ENOIOCTLCMD;
@@ -3346,7 +3250,6 @@
}
}
- set_current_state(TASK_RUNNING);
exit:
if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgsl_wait_until_sent(%s) exit\n",
@@ -3589,9 +3492,7 @@
tmp_buf = (unsigned char *) page;
}
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
-#endif
spin_lock_irqsave(&info->netlock, flags);
if (info->netcount) {
@@ -3978,27 +3879,19 @@
} /* end of mgsl_alloc_buffer_list_memory() */
-/*
- * mgsl_free_buffer_list_memory()
- *
- * Free the common DMA buffer allocated for use as the
- * receive and transmit buffer lists. The associated Memory
- * Descriptor List (MDL) is also freed.
- *
+/* Free DMA buffers allocated for use as the
+ * receive and transmit buffer lists.
* Warning:
*
* The data transfer buffers associated with the buffer list
* MUST be freed before freeing the buffer list itself because
* the buffer list contains the information necessary to free
* the individual buffers!
- *
- * Arguments: info pointer to device extension
- * Return Value: None
*/
void mgsl_free_buffer_list_memory( struct mgsl_struct *info )
{
if ( info->buffer_list && info->bus_type != MGSL_BUS_TYPE_PCI )
- kfree_s(info->buffer_list, BUFFERLISTSIZE);
+ kfree(info->buffer_list);
info->buffer_list = NULL;
info->rx_buffer_list = NULL;
@@ -4072,7 +3965,7 @@
for ( i = 0 ; i < Buffercount ; i++ ) {
if ( BufferList[i].virt_addr ) {
if ( info->bus_type != MGSL_BUS_TYPE_PCI )
- kfree_s(BufferList[i].virt_addr, DMABUFFERSIZE);
+ kfree(BufferList[i].virt_addr);
BufferList[i].virt_addr = NULL;
}
}
@@ -4131,19 +4024,12 @@
void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info)
{
if ( info->intermediate_rxbuffer )
- kfree_s( info->intermediate_rxbuffer, info->max_frame_size);
+ kfree(info->intermediate_rxbuffer);
info->intermediate_rxbuffer = NULL;
} /* end of mgsl_free_intermediate_rxbuffer_memory() */
-/* mgsl_claim_resources()
- *
- * Claim all resources used by a device
- *
- * Arguments: info pointer to device instance data
- * Return Value: 0 if success, otherwise -ENODEV
- */
int mgsl_claim_resources(struct mgsl_struct *info)
{
/* claim 16C32 I/O base address */
@@ -4168,7 +4054,7 @@
info->irq_requested = 1;
if ( info->bus_type == MGSL_BUS_TYPE_PCI ) {
- /* claim shared memory range */
+
info->memory_base = ioremap(info->phys_memory_base,0x40000);
if (!info->memory_base) {
printk( "%s(%d):Cant map shared memory on device %s MemAddr=%08X\n",
@@ -4177,7 +4063,6 @@
return -ENODEV;
}
- /* test the shared memory range */
if ( !mgsl_memory_test(info) ) {
printk( "%s(%d):Failed shared memory test %s MemAddr=%08X\n",
__FILE__,__LINE__,info->device_name, info->phys_memory_base );
@@ -4185,7 +4070,6 @@
return -ENODEV;
}
- /* claim LCR memory range */
info->lcr_base = ioremap(info->phys_lcr_base,PAGE_SIZE) + info->lcr_offset;
if (!info->lcr_base) {
printk( "%s(%d):Cant map LCR memory on device %s MemAddr=%08X\n",
@@ -4221,13 +4105,6 @@
} /* end of mgsl_claim_resources() */
-/* mgsl_release_resources()
- *
- * Release all resources used by a device
- *
- * Arguments: info pointer to device instance data
- * Return Value: None
- */
void mgsl_release_resources(struct mgsl_struct *info)
{
if ( debug_level >= DEBUG_LEVEL_INFO )
@@ -4380,9 +4257,7 @@
printk("ISA device specified io=%04X,irq=%d,dma=%d\n",
io[i], irq[i], dma[i] );
- info = mgsl_allocate_device();
- if ( !info ) {
- /* error allocating device instance data */
+ if (!(info = mgsl_allocate_device())) {
if ( debug_level >= DEBUG_LEVEL_ERROR )
printk( "can't allocate device instance data.\n");
continue;
@@ -4391,12 +4266,7 @@
/* Copy user configuration info to device instance data */
info->io_base = (unsigned int)io[i];
info->irq_level = (unsigned int)irq[i];
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
info->irq_level = irq_cannonicalize(info->irq_level);
-#else
- if (info->irq_level == 2)
- info->irq_level = 9;
-#endif
info->dma_level = (unsigned int)dma[i];
info->bus_type = MGSL_BUS_TYPE_ISA;
info->io_addr_size = 16;
@@ -4412,73 +4282,29 @@
if ( pcibios_present() ) {
unsigned char bus;
unsigned char func;
- unsigned int shared_mem_base;
- unsigned int lcr_mem_base;
- unsigned int io_base;
- unsigned char irq_line;
for(i=0;;i++){
if ( PCIBIOS_SUCCESSFUL == pcibios_find_device(
MICROGATE_VENDOR_ID, SYNCLINK_DEVICE_ID, i, &bus, &func) ) {
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
struct pci_dev *pdev = pci_find_slot(bus,func);
- irq_line = pdev->irq;
-#else
- if (pcibios_read_config_byte(bus,func,
- PCI_INTERRUPT_LINE,&irq_line) ) {
- printk( "%s(%d):USC I/O addr not set.\n",
- __FILE__,__LINE__);
- continue;
- }
-#endif
-
- if (pcibios_read_config_dword(bus,func,
- PCI_BASE_ADDRESS_3,&shared_mem_base) ) {
- printk( "%s(%d):Shared mem addr not set.\n",
- __FILE__,__LINE__);
- continue;
- }
-
- if (pcibios_read_config_dword(bus,func,
- PCI_BASE_ADDRESS_0,&lcr_mem_base) ) {
- printk( "%s(%d):LCR mem addr not set.\n",
- __FILE__,__LINE__);
- continue;
- }
- if (pcibios_read_config_dword(bus,func,
- PCI_BASE_ADDRESS_2,&io_base) ) {
- printk( "%s(%d):USC I/O addr not set.\n",
- __FILE__,__LINE__);
- continue;
- }
-
- info = mgsl_allocate_device();
- if ( !info ) {
- /* error allocating device instance data */
+ if (!(info = mgsl_allocate_device())) {
if ( debug_level >= DEBUG_LEVEL_ERROR )
printk( "can't allocate device instance data.\n");
continue;
}
/* Copy user configuration info to device instance data */
+ info->irq_level = pdev->irq;
+ info->phys_lcr_base = pdev->base_address[0] & PCI_BASE_ADDRESS_MEM_MASK;
+ info->io_base = pdev->base_address[2] & PCI_BASE_ADDRESS_IO_MASK;
+ info->phys_memory_base = pdev->base_address[3] & PCI_BASE_ADDRESS_MEM_MASK;
- info->io_base = io_base & PCI_BASE_ADDRESS_IO_MASK;
- info->irq_level = (unsigned int)irq_line;
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
- info->irq_level = irq_cannonicalize(info->irq_level);
-#else
- if (info->irq_level == 2)
- info->irq_level = 9;
-#endif
- info->phys_memory_base = shared_mem_base & PCI_BASE_ADDRESS_MEM_MASK;
-
/* Because veremap only works on page boundaries we must map
* a larger area than is actually implemented for the LCR
* memory range. We map a full page starting at the page boundary.
*/
- info->phys_lcr_base = lcr_mem_base & PCI_BASE_ADDRESS_MEM_MASK;
info->lcr_offset = info->phys_lcr_base & (PAGE_SIZE-1);
info->phys_lcr_base &= ~(PAGE_SIZE-1);
@@ -4508,30 +4334,9 @@
}
#endif
- /*
- * Allocate memory to hold the following tty/termios arrays
- * with an element for each enumerated device.
- */
-
- serial_table = (struct tty_struct**)kmalloc(sizeof(struct tty_struct*)*mgsl_device_count, GFP_KERNEL);
- serial_termios = (struct termios**)kmalloc(sizeof(struct termios*)*mgsl_device_count, GFP_KERNEL);
- serial_termios_locked = (struct termios**)kmalloc(sizeof(struct termios*)*mgsl_device_count, GFP_KERNEL);
-
- if (!serial_table || !serial_termios || !serial_termios_locked){
- printk("%s(%d):Can't allocate tty/termios arrays.\n",
- __FILE__,__LINE__);
- if (serial_table)
- kfree(serial_table);
- if (serial_termios)
- kfree(serial_termios);
- if (serial_termios_locked)
- kfree(serial_termios_locked);
- return -ENOMEM;
- }
-
- memset(serial_table,0,sizeof(struct tty_struct*)*mgsl_device_count);
- memset(serial_termios,0,sizeof(struct termios*)*mgsl_device_count);
- memset(serial_termios_locked,0,sizeof(struct termios*)*mgsl_device_count);
+ memset(serial_table,0,sizeof(struct tty_struct*)*MAX_TOTAL_DEVICES);
+ memset(serial_termios,0,sizeof(struct termios*)*MAX_TOTAL_DEVICES);
+ memset(serial_termios_locked,0,sizeof(struct termios*)*MAX_TOTAL_DEVICES);
return 0;
@@ -4548,11 +4353,7 @@
{
struct mgsl_struct *info;
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
EXPORT_NO_SYMBOLS;
-#else
- register_symtab(NULL);
-#endif
printk("%s version %s\n", driver_name, driver_version);
@@ -4567,9 +4368,7 @@
memset(&serial_driver, 0, sizeof(struct tty_driver));
serial_driver.magic = TTY_DRIVER_MAGIC;
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
serial_driver.driver_name = "synclink";
-#endif
serial_driver.name = "ttySL";
serial_driver.major = ttymajor;
serial_driver.minor_start = 64;
@@ -4596,12 +4395,10 @@
serial_driver.ioctl = mgsl_ioctl;
serial_driver.throttle = mgsl_throttle;
serial_driver.unthrottle = mgsl_unthrottle;
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
serial_driver.send_xchar = mgsl_send_xchar;
serial_driver.break_ctl = mgsl_break;
serial_driver.wait_until_sent = mgsl_wait_until_sent;
serial_driver.read_proc = mgsl_read_proc;
-#endif
serial_driver.set_termios = mgsl_set_termios;
serial_driver.stop = mgsl_stop;
serial_driver.start = mgsl_start;
@@ -4615,10 +4412,8 @@
callout_driver.name = "cuaSL";
callout_driver.major = cuamajor;
callout_driver.subtype = SERIAL_TYPE_CALLOUT;
-#if LINUX_VERSION_CODE >= VERSION(2,1,0)
callout_driver.read_proc = 0;
callout_driver.proc_entry = 0;
-#endif
if (tty_register_driver(&serial_driver) < 0)
printk("%s(%d):Couldn't register serial driver\n",
@@ -4645,8 +4440,7 @@
} /* end of mgsl_init() */
-#ifdef MODULE
-int init_module(void)
+int __init init_module(void)
{
/* Uncomment this to kernel debug module.
* mgsl_get_text_ptr() leaves the .text address in eax
@@ -4692,20 +4486,8 @@
tmp_buf = NULL;
}
- if (serial_table)
- kfree_s(serial_table,sizeof(struct tty_struct*)*mgsl_device_count);
-
- if (serial_termios)
- kfree_s(serial_termios,sizeof(struct termios*)*mgsl_device_count);
-
- if (serial_termios_locked)
- kfree_s(serial_termios_locked,sizeof(struct termios*)*mgsl_device_count);
-
} /* end of cleanup_module() */
-#endif /* MODULE */
-
-
/*
* usc_RTCmd()
*
@@ -6952,7 +6734,6 @@
while( EndTime-- && !info->irq_occurred ) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(jiffies_from_ms(10));
- set_current_state(TASK_RUNNING);
}
spin_lock_irqsave(&info->irq_spinlock,flags);
@@ -7575,7 +7356,7 @@
sppp_attach(&info->pppdev);
d = info->netdev;
- strcpy(d->name, info->netname);
+ d->name = info->netname;
d->base_addr = info->io_base;
d->irq = info->irq_level;
d->dma = info->dma_level;
@@ -7586,10 +7367,6 @@
d->hard_start_xmit = mgsl_sppp_tx;
d->do_ioctl = mgsl_sppp_ioctl;
d->get_stats = mgsl_net_stats;
-#if LINUX_VERSION_CODE >= VERSION(2,3,43)
- d->tx_timeout = mgsl_sppp_tx_timeout;
- d->watchdog_timeo = 10*HZ;
-#endif
dev_init_buffers(d);
if (register_netdev(d) == -1) {
@@ -7679,7 +7456,6 @@
if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgsl_sppp_tx(%s)\n",info->netname);
-#if LINUX_VERSION_CODE < VERSION(2,3,43)
if (dev->tbusy) {
if (time_before(jiffies, dev->trans_start+10*HZ))
return -EBUSY; /* 10 seconds timeout */
@@ -7687,9 +7463,6 @@
}
if (test_and_set_bit(0, (void*)&dev->tbusy) != 0)
return -EBUSY;
-#else
- netif_stop_queue(dev);
-#endif
info->xmit_cnt = skb->len;
mgsl_load_tx_dma_buffer(info, skb->data, skb->len);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)