OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [char/] [joystick/] [serio.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * $Id: serio.c,v 1.1.1.1 2004-04-15 02:03:25 phoenix Exp $
3
 *
4
 *  Copyright (c) 1999-2000 Vojtech Pavlik
5
 *
6
 *  Sponsored by SuSE
7
 */
8
 
9
/*
10
 *  The Serio abstraction module
11
 */
12
 
13
/*
14
 * This program is free software; you can redistribute it and/or modify
15
 * it under the terms of the GNU General Public License as published by
16
 * the Free Software Foundation; either version 2 of the License, or
17
 * (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
 *
28
 * Should you need to contact me, the author, you can do so either by
29
 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
30
 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
31
 */
32
 
33
#include <linux/stddef.h>
34
#include <linux/module.h>
35
#include <linux/serio.h>
36
 
37
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
38
MODULE_LICENSE("GPL");
39
 
40
EXPORT_SYMBOL(serio_register_port);
41
EXPORT_SYMBOL(serio_unregister_port);
42
EXPORT_SYMBOL(serio_register_device);
43
EXPORT_SYMBOL(serio_unregister_device);
44
EXPORT_SYMBOL(serio_open);
45
EXPORT_SYMBOL(serio_close);
46
EXPORT_SYMBOL(serio_rescan);
47
 
48
static struct serio *serio_list;
49
static struct serio_dev *serio_dev;
50
static int serio_number;
51
 
52
static void serio_find_dev(struct serio *serio)
53
{
54
        struct serio_dev *dev = serio_dev;
55
 
56
        while (dev && !serio->dev) {
57
                if (dev->connect)
58
                        dev->connect(serio, dev);
59
                dev = dev->next;
60
        }
61
}
62
 
63
void serio_rescan(struct serio *serio)
64
{
65
        if (serio->dev && serio->dev->disconnect)
66
                serio->dev->disconnect(serio);
67
        serio_find_dev(serio);
68
}
69
 
70
void serio_register_port(struct serio *serio)
71
{
72
        serio->number = serio_number++;
73
        serio->next = serio_list;
74
        serio_list = serio;
75
        serio_find_dev(serio);
76
}
77
 
78
void serio_unregister_port(struct serio *serio)
79
{
80
        struct serio **serioptr = &serio_list;
81
 
82
        while (*serioptr && (*serioptr != serio)) serioptr = &((*serioptr)->next);
83
        *serioptr = (*serioptr)->next;
84
 
85
        if (serio->dev && serio->dev->disconnect)
86
                serio->dev->disconnect(serio);
87
 
88
        serio_number--;
89
}
90
 
91
void serio_register_device(struct serio_dev *dev)
92
{
93
        struct serio *serio = serio_list;
94
 
95
        dev->next = serio_dev;
96
        serio_dev = dev;
97
 
98
        while (serio) {
99
                if (!serio->dev && dev->connect)
100
                        dev->connect(serio, dev);
101
                serio = serio->next;
102
        }
103
}
104
 
105
void serio_unregister_device(struct serio_dev *dev)
106
{
107
        struct serio_dev **devptr = &serio_dev;
108
        struct serio *serio = serio_list;
109
 
110
        while (*devptr && (*devptr != dev)) devptr = &((*devptr)->next);
111
        *devptr = (*devptr)->next;
112
 
113
        while (serio) {
114
                if (serio->dev == dev && dev->disconnect)
115
                        dev->disconnect(serio);
116
                serio_find_dev(serio);
117
                serio = serio->next;
118
        }
119
}
120
 
121
int serio_open(struct serio *serio, struct serio_dev *dev)
122
{
123
        if (serio->open(serio))
124
                return -1;
125
        serio->dev = dev;
126
        return 0;
127
}
128
 
129
void serio_close(struct serio *serio)
130
{
131
        serio->close(serio);
132
        serio->dev = NULL;
133
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.