53 #include <linux/string.h>
54 #include <linux/slab.h>
55 #include "../comedi.h"
56 #include "../comedilib.h"
57 #include "../comedidev.h"
77 # define MAX_BOARD_NAME 256
95 #define LSAMPL_BITS (sizeof(unsigned int)*8)
98 if (devpriv->
nchans < nchans)
103 for (
i = 0; num_done < nchans &&
i < devpriv->
ndevs; ++
i) {
109 unsigned int subdevMask = ((1 << bdev->
nchans) - 1);
110 unsigned int writeMask, dataBits;
114 subdevMask = (
unsigned int)(-1);
116 writeMask = (data[0] >> num_done) & subdevMask;
117 dataBits = (data[1] >> num_done) & subdevMask;
125 data[1] &= ~(subdevMask << num_done);
127 data[1] |= (dataBits & subdevMask) << num_done;
157 io_bits |= 1 << chan;
161 io_bits &= ~(1 << chan);
183 static void *Realloc(
const void *oldmem,
size_t newlen,
size_t oldlen)
187 if (newmem && oldmem)
188 memcpy(newmem, oldmem,
min(oldlen, newlen));
199 memset(devs_opened, 0,
sizeof(devs_opened));
200 devpriv->
name[0] = 0;
204 char file[] =
"/dev/comediXXXXXX";
207 int sdev = -1, nchans,
tmp;
212 "Minor %d is invalid!\n", minor);
215 if (minor == dev->
minor) {
217 "Cannot bond this driver to itself!\n");
220 if (devs_opened[minor]) {
222 "Minor %d specified more than once!\n", minor);
226 snprintf(file,
sizeof(file),
"/dev/comedi%u", minor);
227 file[
sizeof(
file) - 1] = 0;
233 "Minor %u could not be opened\n", minor);
243 "comedi_get_n_channels() returned %d on minor %u subdev %d!\n",
267 tmp = devpriv->
ndevs *
sizeof(bdev);
269 Realloc(devpriv->
devs,
270 ++devpriv->
ndevs *
sizeof(bdev), tmp);
271 if (!devpriv->
devs) {
273 "Could not allocate memory. Out of memory?\n");
277 devpriv->
devs[devpriv->
ndevs - 1] = bdev;
285 buf[
sizeof(
buf) - 1] = 0;
307 ret = alloc_private(dev,
sizeof(*devpriv));
315 if (!doDevConfig(dev, it))
334 "%s: %s attached, %u channels from %u devices\n",
344 unsigned long devs_closed = 0;
347 while (devpriv->
ndevs-- && devpriv->
devs) {
353 if (!(devs_closed & (0x1 << bdev->
minor))) {
355 devs_closed |= (0x1 << bdev->
minor);
367 .driver_name =
"comedi_bond",
369 .attach = bonding_attach,
370 .detach = bonding_detach,
376 "devices together as one. In the words of John Lennon: "
377 "'And the world will live as one...'");