Commit abcdc99f authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: jr3_pci: CodingStyle fixes

Follow coding style for whitespace, operator placement, use of braces,
etc.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 10ba619d
...@@ -154,7 +154,6 @@ static void set_transforms(struct jr3_channel __iomem *channel, ...@@ -154,7 +154,6 @@ static void set_transforms(struct jr3_channel __iomem *channel,
num &= 0x000f; /* Make sure that 0 <= num <= 15 */ num &= 0x000f; /* Make sure that 0 <= num <= 15 */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
set_u16(&channel->transforms[num].link[i].link_type, set_u16(&channel->transforms[num].link[i].link_type,
transf.link[i].link_type); transf.link[i].link_type);
udelay(1); udelay(1);
...@@ -266,71 +265,53 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, ...@@ -266,71 +265,53 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev,
} else { } else {
int F = 0; int F = 0;
switch (axis) { switch (axis) {
case 0:{ case 0:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].fx);
[filter].fx);
}
break; break;
case 1:{ case 1:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].fy);
[filter].fy);
}
break; break;
case 2:{ case 2:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].fz);
[filter].fz);
}
break; break;
case 3:{ case 3:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].mx);
[filter].mx);
}
break; break;
case 4:{ case 4:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].my);
[filter].my);
}
break; break;
case 5:{ case 5:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].mz);
[filter].mz);
}
break; break;
case 6:{ case 6:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].v1);
[filter].v1);
}
break; break;
case 7:{ case 7:
F = get_s16 F = get_s16(&p->channel->
(&p->channel->filter filter[filter].v2);
[filter].v2);
}
break; break;
} }
data[i] = F + 0x4000; data[i] = F + 0x4000;
} }
} else if (channel == 56) { } else if (channel == 56) {
if (p->state != state_jr3_done) { if (p->state != state_jr3_done)
data[i] = 0; data[i] = 0;
} else { else
data[i] = data[i] =
get_u16(&p->channel->model_no); get_u16(&p->channel->model_no);
}
} else if (channel == 57) { } else if (channel == 57) {
if (p->state != state_jr3_done) { if (p->state != state_jr3_done)
data[i] = 0; data[i] = 0;
} else { else
data[i] = data[i] =
get_u16(&p->channel->serial_no); get_u16(&p->channel->serial_no);
}
} }
} }
} }
...@@ -361,8 +342,8 @@ static int read_idm_word(const u8 *data, size_t size, int *pos, ...@@ -361,8 +342,8 @@ static int read_idm_word(const u8 *data, size_t size, int *pos,
int result = 0; int result = 0;
if (pos && val) { if (pos && val) {
/* Skip over non hex */ /* Skip over non hex */
for (; *pos < size && !isxdigit(data[*pos]); (*pos)++) { for (; *pos < size && !isxdigit(data[*pos]); (*pos)++)
} ;
/* Collect value */ /* Collect value */
*val = 0; *val = 0;
for (; *pos < size; (*pos)++) { for (; *pos < size; (*pos)++) {
...@@ -371,8 +352,9 @@ static int read_idm_word(const u8 *data, size_t size, int *pos, ...@@ -371,8 +352,9 @@ static int read_idm_word(const u8 *data, size_t size, int *pos,
if (value >= 0) { if (value >= 0) {
result = 1; result = 1;
*val = (*val << 4) + value; *val = (*val << 4) + value;
} else } else {
break; break;
}
} }
} }
return result; return result;
...@@ -422,37 +404,38 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data, ...@@ -422,37 +404,38 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
pos = 0; pos = 0;
while (more) { while (more) {
unsigned int count, addr; unsigned int count, addr;
more = more more = more &&
&& read_idm_word(data, size, &pos, &count); read_idm_word(data, size, &pos, &count);
if (more && count == 0xffff) if (more && count == 0xffff)
break; break;
more = more more = more &&
&& read_idm_word(data, size, &pos, &addr); read_idm_word(data, size, &pos, &addr);
dev_dbg(dev->class_dev, dev_dbg(dev->class_dev,
"Loading#%d %4.4x bytes at %4.4x\n", "Loading#%d %4.4x bytes at %4.4x\n",
i, count, addr); i, count, addr);
while (more && count > 0) { while (more && count > 0) {
if (addr & 0x4000) { if (addr & 0x4000) {
/* 16 bit data, never seen in real life!! */ /* 16 bit data, never seen
* in real life!! */
unsigned int data1; unsigned int data1;
more = more more = more &&
&& read_idm_word(data, read_idm_word(data,
size, &pos, size, &pos,
&data1); &data1);
count--; count--;
/* printk("jr3_data, not tested\n"); */ /* jr3[addr + 0x20000 * pnum] =
/* jr3[addr + 0x20000 * pnum] = data1; */ data1; */
} else { } else {
/* Download 24 bit program */ /* Download 24 bit program */
unsigned int data1, data2; unsigned int data1, data2;
more = more more = more &&
&& read_idm_word(data, read_idm_word(data,
size, &pos, size, &pos,
&data1); &data1);
more = more more = more &&
&& read_idm_word(data, size, read_idm_word(data, size,
&pos, &pos,
&data2); &data2);
count -= 2; count -= 2;
...@@ -467,7 +450,6 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data, ...@@ -467,7 +450,6 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
[i].program_high [i].program_high
[addr], data2); [addr], data2);
udelay(1); udelay(1);
} }
} }
addr++; addr++;
...@@ -497,142 +479,141 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s) ...@@ -497,142 +479,141 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
} }
switch (p->state) { switch (p->state) {
case state_jr3_poll:{ case state_jr3_poll: {
u16 model_no = get_u16(&channel->model_no); u16 model_no = get_u16(&channel->model_no);
u16 serial_no = get_u16(&channel->serial_no); u16 serial_no = get_u16(&channel->serial_no);
if ((errors & (watch_dog | watch_dog2)) || if ((errors & (watch_dog | watch_dog2)) ||
model_no == 0 || serial_no == 0) { model_no == 0 || serial_no == 0) {
/* /*
* Still no sensor, keep on polling. Since it takes up to 10 seconds * Still no sensor, keep on polling.
* for offsets to stabilize, polling each second should suffice. * Since it takes up to 10 seconds
*/ * for offsets to stabilize, polling
* each second should suffice.
*/
result = poll_delay_min_max(1000, 2000); result = poll_delay_min_max(1000, 2000);
} else { } else {
p->retries = 0; p->retries = 0;
p->state = p->state =
state_jr3_init_wait_for_offset; state_jr3_init_wait_for_offset;
result = poll_delay_min_max(1000, 2000); result = poll_delay_min_max(1000, 2000);
} }
} }
break; break;
case state_jr3_init_wait_for_offset:{ case state_jr3_init_wait_for_offset:
p->retries++; p->retries++;
if (p->retries < 10) { if (p->retries < 10) {
/* Wait for offeset to stabilize (< 10 s according to manual) */ /* Wait for offeset to stabilize
result = poll_delay_min_max(1000, 2000); * (< 10 s according to manual) */
} else { result = poll_delay_min_max(1000, 2000);
struct transform_t transf; } else {
struct transform_t transf;
p->model_no =
get_u16(&channel->model_no); p->model_no = get_u16(&channel->model_no);
p->serial_no = p->serial_no = get_u16(&channel->serial_no);
get_u16(&channel->serial_no);
/* Transformation all zeros */
/* Transformation all zeros */ for (i = 0; i < ARRAY_SIZE(transf.link); i++) {
for (i = 0; i < ARRAY_SIZE(transf.link); i++) { transf.link[i].link_type =
transf.link[i].link_type = (enum link_types)0;
(enum link_types)0; transf.link[i].link_amount = 0;
transf.link[i].link_amount = 0;
}
set_transforms(channel, transf, 0);
use_transform(channel, 0);
p->state =
state_jr3_init_transform_complete;
result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */
} }
} break;
case state_jr3_init_transform_complete:{
if (!is_complete(channel)) {
result = poll_delay_min_max(20, 100);
} else {
/* Set full scale */
struct six_axis_t min_full_scale;
struct six_axis_t max_full_scale;
min_full_scale =
get_min_full_scales(channel);
max_full_scale =
get_max_full_scales(channel);
set_full_scales(channel,
max_full_scale);
p->state = set_transforms(channel, transf, 0);
state_jr3_init_set_full_scale_complete; use_transform(channel, 0);
result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */ p->state = state_jr3_init_transform_complete;
} /* Allow 20 ms for completion */
result = poll_delay_min_max(20, 100);
} }
break; break;
case state_jr3_init_set_full_scale_complete:{ case state_jr3_init_transform_complete:
if (!is_complete(channel)) { if (!is_complete(channel)) {
result = poll_delay_min_max(20, 100); result = poll_delay_min_max(20, 100);
} else { } else {
struct force_array __iomem *full_scale; /* Set full scale */
struct six_axis_t min_full_scale;
/* Use ranges in kN or we will overflow arount 2000N! */ struct six_axis_t max_full_scale;
full_scale = &channel->full_scale;
p->range[0].range.min = min_full_scale = get_min_full_scales(channel);
-get_s16(&full_scale->fx) * 1000; max_full_scale = get_max_full_scales(channel);
p->range[0].range.max = set_full_scales(channel, max_full_scale);
get_s16(&full_scale->fx) * 1000;
p->range[1].range.min = p->state =
-get_s16(&full_scale->fy) * 1000; state_jr3_init_set_full_scale_complete;
p->range[1].range.max = /* Allow 20 ms for completion */
get_s16(&full_scale->fy) * 1000; result = poll_delay_min_max(20, 100);
p->range[2].range.min =
-get_s16(&full_scale->fz) * 1000;
p->range[2].range.max =
get_s16(&full_scale->fz) * 1000;
p->range[3].range.min =
-get_s16(&full_scale->mx) * 100;
p->range[3].range.max =
get_s16(&full_scale->mx) * 100;
p->range[4].range.min =
-get_s16(&full_scale->my) * 100;
p->range[4].range.max =
get_s16(&full_scale->my) * 100;
p->range[5].range.min =
-get_s16(&full_scale->mz) * 100;
p->range[5].range.max =
get_s16(&full_scale->mz) * 100;
p->range[6].range.min = -get_s16(&full_scale->v1) * 100; /* ?? */
p->range[6].range.max = get_s16(&full_scale->v1) * 100; /* ?? */
p->range[7].range.min = -get_s16(&full_scale->v2) * 100; /* ?? */
p->range[7].range.max = get_s16(&full_scale->v2) * 100; /* ?? */
p->range[8].range.min = 0;
p->range[8].range.max = 65535;
use_offset(channel, 0);
p->state =
state_jr3_init_use_offset_complete;
result = poll_delay_min_max(40, 100); /* Allow 40 ms for completion */
}
} }
break; break;
case state_jr3_init_use_offset_complete:{ case state_jr3_init_set_full_scale_complete:
if (!is_complete(channel)) { if (!is_complete(channel)) {
result = poll_delay_min_max(20, 100); result = poll_delay_min_max(20, 100);
} else { } else {
set_s16(&channel->offsets.fx, 0); struct force_array __iomem *full_scale;
set_s16(&channel->offsets.fy, 0);
set_s16(&channel->offsets.fz, 0); /* Use ranges in kN or we will
set_s16(&channel->offsets.mx, 0); * overflow around 2000N! */
set_s16(&channel->offsets.my, 0); full_scale = &channel->full_scale;
set_s16(&channel->offsets.mz, 0); p->range[0].range.min =
-get_s16(&full_scale->fx) * 1000;
set_offset(channel); p->range[0].range.max =
get_s16(&full_scale->fx) * 1000;
p->state = state_jr3_done; p->range[1].range.min =
} -get_s16(&full_scale->fy) * 1000;
p->range[1].range.max =
get_s16(&full_scale->fy) * 1000;
p->range[2].range.min =
-get_s16(&full_scale->fz) * 1000;
p->range[2].range.max =
get_s16(&full_scale->fz) * 1000;
p->range[3].range.min =
-get_s16(&full_scale->mx) * 100;
p->range[3].range.max =
get_s16(&full_scale->mx) * 100;
p->range[4].range.min =
-get_s16(&full_scale->my) * 100;
p->range[4].range.max =
get_s16(&full_scale->my) * 100;
p->range[5].range.min =
-get_s16(&full_scale->mz) * 100;
p->range[5].range.max =
get_s16(&full_scale->mz) * 100; /* ?? */
p->range[6].range.min =
-get_s16(&full_scale->v1) * 100;/* ?? */
p->range[6].range.max =
get_s16(&full_scale->v1) * 100; /* ?? */
p->range[7].range.min =
-get_s16(&full_scale->v2) * 100;/* ?? */
p->range[7].range.max =
get_s16(&full_scale->v2) * 100; /* ?? */
p->range[8].range.min = 0;
p->range[8].range.max = 65535;
use_offset(channel, 0);
p->state = state_jr3_init_use_offset_complete;
/* Allow 40 ms for completion */
result = poll_delay_min_max(40, 100);
} }
break; break;
case state_jr3_done:{ case state_jr3_init_use_offset_complete:
poll_delay_min_max(10000, 20000); if (!is_complete(channel)) {
result = poll_delay_min_max(20, 100);
} else {
set_s16(&channel->offsets.fx, 0);
set_s16(&channel->offsets.fy, 0);
set_s16(&channel->offsets.fz, 0);
set_s16(&channel->offsets.mx, 0);
set_s16(&channel->offsets.my, 0);
set_s16(&channel->offsets.mz, 0);
set_offset(channel);
p->state = state_jr3_done;
} }
break; break;
default:{ case state_jr3_done:
poll_delay_min_max(1000, 2000); poll_delay_min_max(10000, 20000);
} break;
default:
poll_delay_min_max(1000, 2000);
break; break;
} }
} }
...@@ -654,22 +635,21 @@ static void jr3_pci_poll_dev(unsigned long data) ...@@ -654,22 +635,21 @@ static void jr3_pci_poll_dev(unsigned long data)
/* Poll all channels that are ready to be polled */ /* Poll all channels that are ready to be polled */
for (i = 0; i < devpriv->n_channels; i++) { for (i = 0; i < devpriv->n_channels; i++) {
struct jr3_pci_subdev_private *subdevpriv = struct jr3_pci_subdev_private *subdevpriv =
dev->subdevices[i].private; dev->subdevices[i].private;
if (now > subdevpriv->next_time_min) { if (now > subdevpriv->next_time_min) {
struct poll_delay_t sub_delay; struct poll_delay_t sub_delay;
sub_delay = jr3_pci_poll_subdevice(&dev->subdevices[i]); sub_delay = jr3_pci_poll_subdevice(&dev->subdevices[i]);
subdevpriv->next_time_min = subdevpriv->next_time_min =
jiffies + msecs_to_jiffies(sub_delay.min); jiffies + msecs_to_jiffies(sub_delay.min);
subdevpriv->next_time_max = subdevpriv->next_time_max =
jiffies + msecs_to_jiffies(sub_delay.max); jiffies + msecs_to_jiffies(sub_delay.max);
if (sub_delay.max && sub_delay.max < delay) { if (sub_delay.max && sub_delay.max < delay)
/* /*
* Wake up as late as possible -> poll as many channels as possible * Wake up as late as possible ->
* at once * poll as many channels as possible at once.
*/ */
delay = sub_delay.max; delay = sub_delay.max;
}
} }
} }
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
...@@ -727,7 +707,8 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -727,7 +707,8 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev,
dev->iobase = 1; /* the "detach" needs this */ dev->iobase = 1; /* the "detach" needs this */
devpriv->iobase = ioremap(pci_resource_start(pcidev, 0), devpriv->iobase = ioremap(pci_resource_start(pcidev, 0),
offsetof(struct jr3_t, channel[devpriv->n_channels])); offsetof(struct jr3_t,
channel[devpriv->n_channels]));
if (!devpriv->iobase) if (!devpriv->iobase)
return -ENOMEM; return -ENOMEM;
...@@ -742,7 +723,8 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -742,7 +723,8 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev,
dev->subdevices[i].n_chan = 8 * 7 + 2; dev->subdevices[i].n_chan = 8 * 7 + 2;
dev->subdevices[i].insn_read = jr3_pci_ai_insn_read; dev->subdevices[i].insn_read = jr3_pci_ai_insn_read;
dev->subdevices[i].private = dev->subdevices[i].private =
kzalloc(sizeof(struct jr3_pci_subdev_private), GFP_KERNEL); kzalloc(sizeof(struct jr3_pci_subdev_private),
GFP_KERNEL);
if (dev->subdevices[i].private) { if (dev->subdevices[i].private) {
struct jr3_pci_subdev_private *p; struct jr3_pci_subdev_private *p;
int j; int j;
...@@ -772,15 +754,15 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -772,15 +754,15 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev,
p->range[8].range.max = 65536; p->range[8].range.max = 65536;
p->range_table_list[56] = p->range_table_list[56] =
(struct comedi_lrange *)&p->range[8]; (struct comedi_lrange *)&p->range[8];
p->range_table_list[57] = p->range_table_list[57] =
(struct comedi_lrange *)&p->range[8]; (struct comedi_lrange *)&p->range[8];
p->maxdata_list[56] = 0xffff; p->maxdata_list[56] = 0xffff;
p->maxdata_list[57] = 0xffff; p->maxdata_list[57] = 0xffff;
/* Channel specific range and maxdata */ /* Channel specific range and maxdata */
dev->subdevices[i].range_table = NULL; dev->subdevices[i].range_table = NULL;
dev->subdevices[i].range_table_list = dev->subdevices[i].range_table_list =
p->range_table_list; p->range_table_list;
dev->subdevices[i].maxdata = 0; dev->subdevices[i].maxdata = 0;
dev->subdevices[i].maxdata_list = p->maxdata_list; dev->subdevices[i].maxdata_list = p->maxdata_list;
} }
...@@ -794,18 +776,19 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev, ...@@ -794,18 +776,19 @@ static int __devinit jr3_pci_auto_attach(struct comedi_device *dev,
if (result < 0) if (result < 0)
return result; return result;
/* /*
* TODO: use firmware to load preferred offset tables. Suggested * TODO: use firmware to load preferred offset tables. Suggested
* format: * format:
* model serial Fx Fy Fz Mx My Mz\n * model serial Fx Fy Fz Mx My Mz\n
* *
* comedi_load_firmware(dev, "jr3_offsets_table", jr3_download_firmware); * comedi_load_firmware(dev, "jr3_offsets_table",
*/ * jr3_download_firmware);
*/
/* /*
* It takes a few milliseconds for software to settle as much as we * It takes a few milliseconds for software to settle as much as we
* can read firmware version * can read firmware version
*/ */
msleep_interruptible(25); msleep_interruptible(25);
for (i = 0; i < 0x18; i++) { for (i = 0; i < 0x18; i++) {
dev_dbg(dev->class_dev, "%c\n", dev_dbg(dev->class_dev, "%c\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment