patch-2.2.10 linux/drivers/net/irda/actisys.c
Next file: linux/drivers/net/irda/esi.c
Previous file: linux/drivers/net/irda/Makefile
Back to the patch index
Back to the overall index
- Lines: 273
- Date:
Mon Jun 7 16:19:58 1999
- Orig file:
v2.2.9/linux/drivers/net/irda/actisys.c
- Orig date:
Wed Apr 28 11:37:30 1999
diff -u --recursive --new-file v2.2.9/linux/drivers/net/irda/actisys.c linux/drivers/net/irda/actisys.c
@@ -1,16 +1,16 @@
/*********************************************************************
*
* Filename: actisys.c
- * Version: 0.5
+ * Version: 0.8
* Description: Implementation for the ACTiSYS IR-220L and IR-220L+
* dongles
* Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Wed Oct 21 20:02:35 1998
- * Modified at: Mon Apr 12 11:56:35 1999
+ * Modified at: Sun May 16 14:35:11 1999
* Modified by: Dag Brattli <dagb@cs.uit.no>
*
- * Copyright (c) 1998 Dag Brattli, All Rights Reserved.
+ * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -29,22 +29,16 @@
#include <linux/sched.h>
#include <linux/init.h>
-#include <asm/ioctls.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-
#include <net/irda/irda.h>
#include <net/irda/irmod.h>
#include <net/irda/irda_device.h>
-#include <net/irda/irtty.h>
#include <net/irda/dongle.h>
-static void actisys_reset( struct irda_device *dev, int unused);
-static void actisys_open( struct irda_device *idev, int type);
-static void actisys_close( struct irda_device *dev);
+static void actisys_reset(struct irda_device *dev);
+static void actisys_open(struct irda_device *idev, int type);
+static void actisys_close(struct irda_device *dev);
static void actisys_change_speed( struct irda_device *dev, int baudrate);
-static void actisys_reset( struct irda_device *dev, int unused);
-static void actisys_init_qos( struct irda_device *idev, struct qos_info *qos);
+static void actisys_init_qos(struct irda_device *idev, struct qos_info *qos);
/* These are the baudrates supported */
static int baud_rates[] = { 9600, 19200, 57600, 115200, 38400};
@@ -58,17 +52,37 @@
actisys_init_qos,
};
-__initfunc(void actisys_init(void))
+static struct dongle dongle_plus = {
+ ACTISYS_PLUS_DONGLE,
+ actisys_open,
+ actisys_close,
+ actisys_reset,
+ actisys_change_speed,
+ actisys_init_qos,
+};
+
+__initfunc(int actisys_init(void))
{
- irtty_register_dongle(&dongle);
+ int ret;
+
+ ret = irda_device_register_dongle(&dongle);
+ if (ret < 0)
+ return ret;
+ ret = irda_device_register_dongle(&dongle_plus);
+ if (ret < 0) {
+ irda_device_unregister_dongle(&dongle);
+ return ret;
+ }
+ return 0;
}
void actisys_cleanup(void)
{
- irtty_unregister_dongle(&dongle);
+ irda_device_unregister_dongle(&dongle);
+ irda_device_unregister_dongle(&dongle_plus);
}
-static void actisys_open( struct irda_device *idev, int type)
+static void actisys_open(struct irda_device *idev, int type)
{
strcat(idev->description, " <-> actisys");
@@ -78,8 +92,11 @@
MOD_INC_USE_COUNT;
}
-static void actisys_close( struct irda_device *dev)
+static void actisys_close(struct irda_device *idev)
{
+ /* Power off dongle */
+ irda_device_set_dtr_rts(idev, FALSE, FALSE);
+
MOD_DEC_USE_COUNT;
}
@@ -90,25 +107,16 @@
* To cycle through the available baud rates, pulse RTS low for a few
* ms.
*/
-static void actisys_change_speed( struct irda_device *idev, int baudrate)
+static void actisys_change_speed(struct irda_device *idev, int baudrate)
{
- struct irtty_cb *self;
- struct tty_struct *tty;
- struct termios old_termios;
- int cflag;
int current_baudrate;
int index = 0;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(4, __FUNCTION__ "()\n");
- ASSERT( idev != NULL, return;);
- ASSERT( idev->magic == IRDA_DEVICE_MAGIC, return;);
+ ASSERT(idev != NULL, return;);
+ ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return;);
- self = (struct irtty_cb *) idev->priv;
-
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRTTY_MAGIC, return;);
-
current_baudrate = idev->qos.baud_rate.value;
/* Find the correct baudrate index for the currently used baudrate */
@@ -117,69 +125,34 @@
DEBUG( 4, __FUNCTION__ "(), index=%d\n", index);
- if ( !self->tty)
- return;
-
- tty = self->tty;
-
/* Cycle through avaiable baudrates until we reach the correct one */
- while ( current_baudrate != baudrate) {
- DEBUG( 4, __FUNCTION__ "(), current baudrate = %d\n",
- baud_rates[index]);
+ while (current_baudrate != baudrate) {
+ DEBUG(4, __FUNCTION__ "(), current baudrate = %d\n",
+ baud_rates[index]);
/* Set DTR, clear RTS */
- irtty_set_dtr_rts(tty, TRUE, FALSE);
+ irda_device_set_dtr_rts(idev, TRUE, FALSE);
/* Wait at a few ms */
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(2);
/* Set DTR, Set RTS */
- irtty_set_dtr_rts(tty, TRUE, TRUE);
+ irda_device_set_dtr_rts(idev, TRUE, TRUE);
/* Wait at a few ms again */
current->state = TASK_INTERRUPTIBLE;
- schedule_timeout( 2);
+ schedule_timeout(2);
/* Go to next baudrate */
- if ( idev->io.dongle_id == ACTISYS_DONGLE)
+ if (idev->io.dongle_id == ACTISYS_DONGLE)
index = (index+1) % 4; /* IR-220L */
else
index = (index+1) % 5; /* IR-220L+ */
current_baudrate = baud_rates[index];
}
- DEBUG(4, __FUNCTION__ "(), current baudrate = %d\n",
- baud_rates[index]);
-
- /* Now change the speed of the serial port */
- old_termios = *(tty->termios);
- cflag = tty->termios->c_cflag;
-
- cflag &= ~CBAUD;
-
- switch ( baudrate) {
- case 9600:
- default:
- cflag |= B9600;
- break;
- case 19200:
- cflag |= B19200;
- break;
- case 38400:
- cflag |= B38400;
- break;
- case 57600:
- cflag |= B57600;
- break;
- case 115200:
- cflag |= B115200;
- break;
- }
-
- /* Change speed of serial port */
- tty->termios->c_cflag = cflag;
- tty->driver.set_termios( tty, &old_termios);
+ DEBUG(4, __FUNCTION__ "(), current baudrate = %d\n",baud_rates[index]);
}
/*
@@ -191,32 +164,20 @@
* 1. Clear DTR for a few ms.
*
*/
-static void actisys_reset( struct irda_device *idev, int unused)
+static void actisys_reset(struct irda_device *idev)
{
- struct irtty_cb *self;
- struct tty_struct *tty;
-
- ASSERT( idev != NULL, return;);
- ASSERT( idev->magic == IRDA_DEVICE_MAGIC, return;);
-
- self = (struct irtty_cb *) idev->priv;
+ ASSERT(idev != NULL, return;);
+ ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return;);
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRTTY_MAGIC, return;);
-
- tty = self->tty;
- if ( !tty)
- return;
-
/* Clear DTR */
- irtty_set_dtr_rts(tty, FALSE, TRUE);
+ irda_device_set_dtr_rts(idev, FALSE, TRUE);
/* Sleep 10-20 ms*/
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(2);
/* Go back to normal mode */
- irtty_set_dtr_rts(tty, TRUE, TRUE);
+ irda_device_set_dtr_rts(idev, TRUE, TRUE);
idev->qos.baud_rate.value = 9600;
}
@@ -227,12 +188,12 @@
* Initialize QoS capabilities
*
*/
-static void actisys_init_qos( struct irda_device *idev, struct qos_info *qos)
+static void actisys_init_qos(struct irda_device *idev, struct qos_info *qos)
{
qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
/* Remove support for 38400 if this is not a 220L+ dongle */
- if ( idev->io.dongle_id == ACTISYS_DONGLE)
+ if (idev->io.dongle_id == ACTISYS_DONGLE)
qos->baud_rate.bits &= ~IR_38400;
qos->min_turn_time.bits &= 0x40; /* Needs 0.01 ms */
@@ -251,8 +212,7 @@
*/
int init_module(void)
{
- actisys_init();
- return(0);
+ return actisys_init();
}
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)