Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304579
b: refs/heads/master
c: 40e7f51
h: refs/heads/master
i:
  304577: 09a5c71
  304575: ee10115
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed May 9, 2012
1 parent 463950a commit ae6bd40
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 88 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: 98b08941b20e41fcbd3aaa577381e656e1c41291
refs/heads/master: 40e7f510ef24e8455c15201b07d0b691caac5254
157 changes: 70 additions & 87 deletions trunk/drivers/staging/comedi/drivers/unioxx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ struct unioxx5_subd_priv {
unsigned char usp_prev_cn_val[3]; /* previous channel value */
};

static int unioxx5_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int unioxx5_subdev_write(struct comedi_device *dev,
struct comedi_subdevice *subdev,
struct comedi_insn *insn, unsigned int *data);
Expand All @@ -94,9 +92,6 @@ static int unioxx5_subdev_read(struct comedi_device *dev,
static int unioxx5_insn_config(struct comedi_device *dev,
struct comedi_subdevice *subdev,
struct comedi_insn *insn, unsigned int *data);
static int unioxx5_detach(struct comedi_device *dev);
static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
int subdev_iobase, int minor);
static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp,
unsigned int *data, int channel, int minor);
static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp,
Expand All @@ -109,72 +104,6 @@ static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp,
static int __unioxx5_define_chan_offset(int chan_num);
static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel);

static struct comedi_driver unioxx5_driver = {
.driver_name = DRIVER_NAME,
.module = THIS_MODULE,
.attach = unioxx5_attach,
.detach = unioxx5_detach
};

static int __init unioxx5_driver_init_module(void)
{
return comedi_driver_register(&unioxx5_driver);
}

static void __exit unioxx5_driver_cleanup_module(void)
{
comedi_driver_unregister(&unioxx5_driver);
}

module_init(unioxx5_driver_init_module);
module_exit(unioxx5_driver_cleanup_module);

static int unioxx5_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
int iobase, i, n_subd;
int id, num, ba;

iobase = it->options[0];

dev->board_name = DRIVER_NAME;
dev->iobase = iobase;
iobase += UNIOXX5_SUBDEV_BASE;

/* defining number of subdevices and getting they types (it must be 'g01') */
for (i = n_subd = 0, ba = iobase; i < 4; i++, ba += UNIOXX5_SUBDEV_ODDS) {
id = inb(ba + 0xE);
num = inb(ba + 0xF);

if (id != 'g' || num != 1)
continue;

n_subd++;
}

/* unioxx5 can has from two to four subdevices */
if (n_subd < 2) {
printk(KERN_ERR
"your card must has at least 2 'g01' subdevices\n");
return -1;
}

if (alloc_subdevices(dev, n_subd) < 0) {
printk(KERN_ERR "out of memory\n");
return -ENOMEM;
}

/* 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;
}

printk(KERN_INFO "attached\n");
return 0;
}

static int unioxx5_subdev_read(struct comedi_device *dev,
struct comedi_subdevice *subdev,
struct comedi_insn *insn, unsigned int *data)
Expand Down Expand Up @@ -275,22 +204,6 @@ static int unioxx5_insn_config(struct comedi_device *dev,
return 0;
}

static int unioxx5_detach(struct comedi_device *dev)
{
int i;
struct comedi_subdevice *subdev;
struct unioxx5_subd_priv *usp;

for (i = 0; i < dev->n_subdevices; i++) {
subdev = &dev->subdevices[i];
usp = subdev->private;
release_region(usp->usp_iobase, UNIOXX5_SIZE);
kfree(subdev->private);
}

return 0;
}

/* initializing subdevice with given address */
static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
int subdev_iobase, int minor)
Expand Down Expand Up @@ -553,6 +466,76 @@ static int __unioxx5_define_chan_offset(int chan_num)
return (chan_num >> 3) + 1;
}

static int unioxx5_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
int iobase, i, n_subd;
int id, num, ba;

iobase = it->options[0];

dev->board_name = DRIVER_NAME;
dev->iobase = iobase;
iobase += UNIOXX5_SUBDEV_BASE;

/* defining number of subdevices and getting they types (it must be 'g01') */
for (i = n_subd = 0, ba = iobase; i < 4; i++, ba += UNIOXX5_SUBDEV_ODDS) {
id = inb(ba + 0xE);
num = inb(ba + 0xF);

if (id != 'g' || num != 1)
continue;

n_subd++;
}

/* unioxx5 can has from two to four subdevices */
if (n_subd < 2) {
printk(KERN_ERR
"your card must has at least 2 'g01' subdevices\n");
return -1;
}

if (alloc_subdevices(dev, n_subd) < 0) {
printk(KERN_ERR "out of memory\n");
return -ENOMEM;
}

/* 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;
}

printk(KERN_INFO "attached\n");
return 0;
}

static int unioxx5_detach(struct comedi_device *dev)
{
int i;
struct comedi_subdevice *subdev;
struct unioxx5_subd_priv *usp;

for (i = 0; i < dev->n_subdevices; i++) {
subdev = &dev->subdevices[i];
usp = subdev->private;
release_region(usp->usp_iobase, UNIOXX5_SIZE);
kfree(subdev->private);
}

return 0;
}

static struct comedi_driver unioxx5_driver = {
.driver_name = DRIVER_NAME,
.module = THIS_MODULE,
.attach = unioxx5_attach,
.detach = unioxx5_detach,
};
module_comedi_driver(unioxx5_driver);

MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");

0 comments on commit ae6bd40

Please sign in to comment.