Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 364091
b: refs/heads/master
c: dba89b1
h: refs/heads/master
i:
  364089: 3b57572
  364087: a58ea4c
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Apr 11, 2013
1 parent 73892a6 commit b46b6a4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8bee2dead8326f4144eab10126448fb58b4b2ac3
refs/heads/master: dba89b14d44d463c33c3f49384475bd1316fe28a
61 changes: 29 additions & 32 deletions trunk/drivers/staging/comedi/drivers/unioxx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,39 +367,37 @@ static int unioxx5_insn_config(struct comedi_device *dev,
}

/* initializing subdevice with given address */
static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
int subdev_iobase, int minor)
static int __unioxx5_subdev_init(struct comedi_device *dev,
struct comedi_subdevice *s,
int iobase)
{
struct unioxx5_subd_priv *usp;
int i, to, ndef_flag = 0;
int ret;

if (!request_region(subdev_iobase, UNIOXX5_SIZE, DRIVER_NAME)) {
dev_err(subdev->class_dev,
"comedi%d: I/O port conflict\n", minor);
return -EIO;
}
ret = __comedi_request_region(dev, iobase, UNIOXX5_SIZE);
if (ret)
return ret;
usp->usp_iobase = iobase;

usp = kzalloc(sizeof(*usp), GFP_KERNEL);
if (usp == NULL)
return -1;

usp->usp_iobase = subdev_iobase;
dev_info(subdev->class_dev, "comedi%d: |", minor);
return -ENOMEM;

/* defining modules types */
for (i = 0; i < 12; i++) {
to = 10000;

__unioxx5_analog_config(usp, i * 2);
/* sends channel number to card */
outb(i + 1, subdev_iobase + 5);
outb('H', subdev_iobase + 6); /* requests EEPROM world */
while (!(inb(subdev_iobase + 0) & TxBE))
outb(i + 1, iobase + 5);
outb('H', iobase + 6); /* requests EEPROM world */
while (!(inb(iobase + 0) & TxBE))
; /* waits while writting will be allowed */
outb(0, subdev_iobase + 6);
outb(0, iobase + 6);

/* waits while reading of two bytes will be allowed */
while (!(inb(subdev_iobase + 0) & Rx2CA)) {
while (!(inb(iobase + 0) & Rx2CA)) {
if (--to <= 0) {
ndef_flag = 1;
break;
Expand All @@ -410,32 +408,30 @@ static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
usp->usp_module_type[i] = 0;
ndef_flag = 0;
} else
usp->usp_module_type[i] = inb(subdev_iobase + 6);
usp->usp_module_type[i] = inb(iobase + 6);

printk(" [%d] 0x%02x |", i, usp->usp_module_type[i]);
udelay(1);
}

printk("\n");

/* initial subdevice for digital or analog i/o */
subdev->type = COMEDI_SUBD_DIO;
subdev->private = usp;
subdev->subdev_flags = SDF_READABLE | SDF_WRITABLE;
subdev->n_chan = UNIOXX5_NUM_OF_CHANS;
subdev->maxdata = 0xFFF;
subdev->range_table = &range_digital;
subdev->insn_read = unioxx5_subdev_read;
subdev->insn_write = unioxx5_subdev_write;
s->type = COMEDI_SUBD_DIO;
s->private = usp;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = UNIOXX5_NUM_OF_CHANS;
s->maxdata = 0xFFF;
s->range_table = &range_digital;
s->insn_read = unioxx5_subdev_read;
s->insn_write = unioxx5_subdev_write;
/* for digital modules only!!! */
subdev->insn_config = unioxx5_insn_config;
s->insn_config = unioxx5_insn_config;

return 0;
}

static int unioxx5_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int iobase, i, n_subd;
int id, num, ba;
int ret;
Expand Down Expand Up @@ -469,9 +465,10 @@ static int unioxx5_attach(struct comedi_device *dev,

/* initializing each of for same subdevices */
for (i = 0; i < n_subd; i++, iobase += UNIOXX5_SUBDEV_ODDS) {
if (__unioxx5_subdev_init(&dev->subdevices[i], iobase,
dev->minor) < 0)
return -1;
s = &dev->subdevices[i];
ret = __unioxx5_subdev_init(dev, s, iobase);
if (ret)
return ret;
}

return 0;
Expand Down

0 comments on commit b46b6a4

Please sign in to comment.