This source file includes following definitions.
- dev_8255_attach
- dev_8255_detach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 #include <linux/module.h>
43 #include "../comedidev.h"
44
45 #include "8255.h"
46
47 static int dev_8255_attach(struct comedi_device *dev,
48 struct comedi_devconfig *it)
49 {
50 struct comedi_subdevice *s;
51 unsigned long iobase;
52 int ret;
53 int i;
54
55 for (i = 0; i < COMEDI_NDEVCONFOPTS; i++) {
56 iobase = it->options[i];
57 if (!iobase)
58 break;
59 }
60 if (i == 0) {
61 dev_warn(dev->class_dev, "no devices specified\n");
62 return -EINVAL;
63 }
64
65 ret = comedi_alloc_subdevices(dev, i);
66 if (ret)
67 return ret;
68
69 for (i = 0; i < dev->n_subdevices; i++) {
70 s = &dev->subdevices[i];
71 iobase = it->options[i];
72
73
74
75
76
77
78
79
80 ret = __comedi_request_region(dev, iobase, I8255_SIZE);
81 if (ret) {
82 s->type = COMEDI_SUBD_UNUSED;
83 } else {
84 ret = subdev_8255_init(dev, s, NULL, iobase);
85 if (ret) {
86
87
88
89
90 release_region(iobase, I8255_SIZE);
91 s->type = COMEDI_SUBD_UNUSED;
92 return ret;
93 }
94 }
95 }
96
97 return 0;
98 }
99
100 static void dev_8255_detach(struct comedi_device *dev)
101 {
102 struct comedi_subdevice *s;
103 int i;
104
105 for (i = 0; i < dev->n_subdevices; i++) {
106 s = &dev->subdevices[i];
107 if (s->type != COMEDI_SUBD_UNUSED) {
108 unsigned long regbase = subdev_8255_regbase(s);
109
110 release_region(regbase, I8255_SIZE);
111 }
112 }
113 }
114
115 static struct comedi_driver dev_8255_driver = {
116 .driver_name = "8255",
117 .module = THIS_MODULE,
118 .attach = dev_8255_attach,
119 .detach = dev_8255_detach,
120 };
121 module_comedi_driver(dev_8255_driver);
122
123 MODULE_AUTHOR("Comedi http://www.comedi.org");
124 MODULE_DESCRIPTION("Comedi driver for standalone 8255 devices");
125 MODULE_LICENSE("GPL");