diff options
Diffstat (limited to 'drivers/staging/comedi/drivers/serial2002.c')
-rw-r--r-- | drivers/staging/comedi/drivers/serial2002.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index ebfce33f0b4f..ade2202b6231 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -38,7 +38,7 @@ Status: in development #include <linux/sched.h> #include <linux/slab.h> -#include <asm/termios.h> +#include <linux/termios.h> #include <asm/ioctls.h> #include <linux/serial.h> #include <linux/poll.h> @@ -192,9 +192,8 @@ static int tty_read(struct file *f, int timeout) elapsed = (1000000 * (now.tv_sec - start.tv_sec) + now.tv_usec - start.tv_usec); - if (elapsed > timeout) { + if (elapsed > timeout) break; - } set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(((timeout - elapsed) * HZ) / 10000); @@ -204,9 +203,8 @@ static int tty_read(struct file *f, int timeout) unsigned char ch; f->f_pos = 0; - if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) { + if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) result = ch; - } } } else { /* Device does not support poll, busy wait */ @@ -215,9 +213,8 @@ static int tty_read(struct file *f, int timeout) unsigned char ch; retries++; - if (retries >= timeout) { + if (retries >= timeout) break; - } f->f_pos = 0; if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) { @@ -329,7 +326,7 @@ static struct serial_data serial_read(struct file *f, int timeout) length++; if (data < 0) { - printk("serial2002 error\n"); + printk(KERN_ERR "serial2002 error\n"); break; } else if (data & 0x80) { result.value = (result.value << 7) | (data & 0x7f); @@ -402,7 +399,7 @@ static int serial_2002_open(struct comedi_device *dev) devpriv->tty = filp_open(port, O_RDWR, 0); if (IS_ERR(devpriv->tty)) { result = (int)PTR_ERR(devpriv->tty); - printk("serial_2002: file open error = %d\n", result); + printk(KERN_ERR "serial_2002: file open error = %d\n", result); } else { struct config_t { @@ -516,9 +513,8 @@ static int serial_2002_open(struct comedi_device *dev) } break; } - if (sign) { + if (sign) min = -min; - } cur_config[channel].min = min; } @@ -557,9 +553,8 @@ static int serial_2002_open(struct comedi_device *dev) } break; } - if (sign) { + if (sign) max = -max; - } cur_config[channel].max = max; } @@ -622,9 +617,8 @@ static int serial_2002_open(struct comedi_device *dev) int j, chan; for (chan = 0, j = 0; j < 32; j++) { - if (c[j].kind == kind) { + if (c[j].kind == kind) chan++; - } } s = &dev->subdevices[i]; s->n_chan = chan; @@ -649,9 +643,8 @@ static int serial_2002_open(struct comedi_device *dev) } for (chan = 0, j = 0; j < 32; j++) { if (c[j].kind == kind) { - if (mapping) { + if (mapping) mapping[chan] = j; - } if (range) { range[j].length = 1; range[j].range.min = @@ -704,9 +697,8 @@ err_alloc_configs: static void serial_2002_close(struct comedi_device *dev) { - if (!IS_ERR(devpriv->tty) && (devpriv->tty != 0)) { + if (!IS_ERR(devpriv->tty) && (devpriv->tty != 0)) filp_close(devpriv->tty, 0); - } } static int serial2002_di_rinsn(struct comedi_device *dev, @@ -723,9 +715,8 @@ static int serial2002_di_rinsn(struct comedi_device *dev, poll_digital(devpriv->tty, chan); while (1) { read = serial_read(devpriv->tty, 1000); - if (read.kind != is_digital || read.index == chan) { + if (read.kind != is_digital || read.index == chan) break; - } } data[n] = read.value; } @@ -765,9 +756,8 @@ static int serial2002_ai_rinsn(struct comedi_device *dev, poll_channel(devpriv->tty, chan); while (1) { read = serial_read(devpriv->tty, 1000); - if (read.kind != is_channel || read.index == chan) { + if (read.kind != is_channel || read.index == chan) break; - } } data[n] = read.value; } @@ -801,9 +791,8 @@ static int serial2002_ao_rinsn(struct comedi_device *dev, int n; int chan = CR_CHAN(insn->chanspec); - for (n = 0; n < insn->n; n++) { + for (n = 0; n < insn->n; n++) data[n] = devpriv->ao_readback[chan]; - } return n; } @@ -822,9 +811,8 @@ static int serial2002_ei_rinsn(struct comedi_device *dev, poll_channel(devpriv->tty, chan); while (1) { read = serial_read(devpriv->tty, 1000); - if (read.kind != is_channel || read.index == chan) { + if (read.kind != is_channel || read.index == chan) break; - } } data[n] = read.value; } @@ -838,9 +826,8 @@ static int serial2002_attach(struct comedi_device *dev, printk("comedi%d: serial2002: ", dev->minor); dev->board_name = thisboard->name; - if (alloc_private(dev, sizeof(struct serial2002_private)) < 0) { + if (alloc_private(dev, sizeof(struct serial2002_private)) < 0) return -ENOMEM; - } dev->open = serial_2002_open; dev->close = serial_2002_close; devpriv->port = it->options[0]; |