fs: use kmem_cache_zalloc instead
[pv_ops_mirror.git] / drivers / net / irda / esi-sir.c
bloba908df7c4b9dcada826e9da35e3ecfe17b0febe8
1 /*********************************************************************
2 *
3 * Filename: esi.c
4 * Version: 1.6
5 * Description: Driver for the Extended Systems JetEye PC dongle
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Sat Feb 21 18:54:38 1998
9 * Modified at: Sun Oct 27 22:01:04 2002
10 * Modified by: Martin Diehl <mad@mdiehl.de>
12 * Copyright (c) 1999 Dag Brattli, <dagb@cs.uit.no>,
13 * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
14 * Copyright (c) 2002 Martin Diehl, <mad@mdiehl.de>,
15 * All Rights Reserved.
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
32 ********************************************************************/
34 #include <linux/module.h>
35 #include <linux/delay.h>
36 #include <linux/init.h>
38 #include <net/irda/irda.h>
40 #include "sir-dev.h"
42 static int esi_open(struct sir_dev *);
43 static int esi_close(struct sir_dev *);
44 static int esi_change_speed(struct sir_dev *, unsigned);
45 static int esi_reset(struct sir_dev *);
47 static struct dongle_driver esi = {
48 .owner = THIS_MODULE,
49 .driver_name = "JetEye PC ESI-9680 PC",
50 .type = IRDA_ESI_DONGLE,
51 .open = esi_open,
52 .close = esi_close,
53 .reset = esi_reset,
54 .set_speed = esi_change_speed,
57 static int __init esi_sir_init(void)
59 return irda_register_dongle(&esi);
62 static void __exit esi_sir_cleanup(void)
64 irda_unregister_dongle(&esi);
67 static int esi_open(struct sir_dev *dev)
69 struct qos_info *qos = &dev->qos;
71 /* Power up and set dongle to 9600 baud */
72 sirdev_set_dtr_rts(dev, FALSE, TRUE);
74 qos->baud_rate.bits &= IR_9600|IR_19200|IR_115200;
75 qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
76 irda_qos_bits_to_value(qos);
78 /* irda thread waits 50 msec for power settling */
80 return 0;
83 static int esi_close(struct sir_dev *dev)
85 /* Power off dongle */
86 sirdev_set_dtr_rts(dev, FALSE, FALSE);
88 return 0;
92 * Function esi_change_speed (task)
94 * Set the speed for the Extended Systems JetEye PC ESI-9680 type dongle
95 * Apparently (see old esi-driver) no delays are needed here...
98 static int esi_change_speed(struct sir_dev *dev, unsigned speed)
100 int ret = 0;
101 int dtr, rts;
103 switch (speed) {
104 case 19200:
105 dtr = TRUE;
106 rts = FALSE;
107 break;
108 case 115200:
109 dtr = rts = TRUE;
110 break;
111 default:
112 ret = -EINVAL;
113 speed = 9600;
114 /* fall through */
115 case 9600:
116 dtr = FALSE;
117 rts = TRUE;
118 break;
121 /* Change speed of dongle */
122 sirdev_set_dtr_rts(dev, dtr, rts);
123 dev->speed = speed;
125 return ret;
129 * Function esi_reset (task)
131 * Reset dongle;
134 static int esi_reset(struct sir_dev *dev)
136 sirdev_set_dtr_rts(dev, FALSE, FALSE);
138 /* Hm, the old esi-driver left the dongle unpowered relying on
139 * the following speed change to repower. This might work for
140 * the esi because we only need the modem lines. However, now the
141 * general rule is reset must bring the dongle to some working
142 * well-known state because speed change might write to registers.
143 * The old esi-driver didn't any delay here - let's hope it' fine.
146 sirdev_set_dtr_rts(dev, FALSE, TRUE);
147 dev->speed = 9600;
149 return 0;
152 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
153 MODULE_DESCRIPTION("Extended Systems JetEye PC dongle driver");
154 MODULE_LICENSE("GPL");
155 MODULE_ALIAS("irda-dongle-1"); /* IRDA_ESI_DONGLE */
157 module_init(esi_sir_init);
158 module_exit(esi_sir_cleanup);