aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-11-26 18:41:59 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-03 12:20:21 -0500
commit06551fda7e0f07250884c0cf47d1286da0a5651c (patch)
treea570007ef70aa5065637836bd0cf33f1d302b847
parent5b7b0eb2b208d3ecdaf946876f6c0f9cf292ddf2 (diff)
staging: comedi: dt282x: tidy up the irq support in dt282x_attach()
An irq is only needed by this driver in order to support async commands. Since it is optional, modify the attach so that if the request_irq() fails the attach does not fail. Remove the printk noise about the irq. Only hookup the async command support if the request_irq() was successful. Also, only call dt282x_grab_dma() if we have an irq since interrupt support is needed to support dma. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c84
1 files changed, 30 insertions, 54 deletions
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index c4ffedbdde21..d2f95bf94f44 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -1118,9 +1118,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1118{ 1118{
1119 const struct dt282x_board *board = comedi_board(dev); 1119 const struct dt282x_board *board = comedi_board(dev);
1120 struct dt282x_private *devpriv; 1120 struct dt282x_private *devpriv;
1121 int i, irq;
1122 int ret;
1123 struct comedi_subdevice *s; 1121 struct comedi_subdevice *s;
1122 int ret;
1123 int i;
1124 1124
1125 ret = comedi_request_region(dev, it->options[0], DT2821_SIZE); 1125 ret = comedi_request_region(dev, it->options[0], DT2821_SIZE);
1126 if (ret) 1126 if (ret)
@@ -1144,53 +1144,23 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1144 } 1144 }
1145 /* should do board test */ 1145 /* should do board test */
1146 1146
1147 irq = it->options[opt_irq]; 1147 if (it->options[opt_irq] > 0) {
1148#if 0 1148 ret = request_irq(it->options[opt_irq], dt282x_interrupt, 0,
1149 if (irq < 0) {
1150 unsigned long flags;
1151 int irqs;
1152
1153 save_flags(flags);
1154 sti();
1155 irqs = probe_irq_on();
1156
1157 /* trigger interrupt */
1158
1159 udelay(100);
1160
1161 irq = probe_irq_off(irqs);
1162 restore_flags(flags);
1163 if (0 /* error */)
1164 printk(KERN_ERR " error probing irq (bad)");
1165 }
1166#endif
1167 if (irq > 0) {
1168 printk(KERN_INFO " ( irq = %d )", irq);
1169 ret = request_irq(irq, dt282x_interrupt, 0,
1170 dev->board_name, dev); 1149 dev->board_name, dev);
1171 if (ret < 0) { 1150 if (ret == 0)
1172 printk(KERN_ERR " failed to get irq\n"); 1151 dev->irq = it->options[opt_irq];
1173 return -EIO;
1174 }
1175 dev->irq = irq;
1176 } else if (irq == 0) {
1177 printk(KERN_INFO " (no irq)");
1178 } else {
1179#if 0
1180 printk(KERN_INFO " (probe returned multiple irqs--bad)");
1181#else
1182 printk(KERN_INFO " (irq probe not implemented)");
1183#endif
1184 } 1152 }
1185 1153
1186 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); 1154 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
1187 if (!devpriv) 1155 if (!devpriv)
1188 return -ENOMEM; 1156 return -ENOMEM;
1189 1157
1190 ret = dt282x_grab_dma(dev, it->options[opt_dma1], 1158 if (dev->irq) {
1191 it->options[opt_dma2]); 1159 ret = dt282x_grab_dma(dev, it->options[opt_dma1],
1192 if (ret < 0) 1160 it->options[opt_dma2]);
1193 return ret; 1161 if (ret < 0)
1162 return ret;
1163 }
1194 1164
1195 ret = comedi_alloc_subdevices(dev, 3); 1165 ret = comedi_alloc_subdevices(dev, 3);
1196 if (ret) 1166 if (ret)
@@ -1198,22 +1168,25 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1198 1168
1199 s = &dev->subdevices[0]; 1169 s = &dev->subdevices[0];
1200 1170
1201 dev->read_subdev = s;
1202 /* ai subdevice */ 1171 /* ai subdevice */
1203 s->type = COMEDI_SUBD_AI; 1172 s->type = COMEDI_SUBD_AI;
1204 s->subdev_flags = SDF_READABLE | SDF_CMD_READ | 1173 s->subdev_flags = SDF_READABLE |
1205 ((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON); 1174 ((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON);
1206 s->n_chan = 1175 s->n_chan =
1207 (it->options[opt_diff]) ? board->adchan_di : board->adchan_se; 1176 (it->options[opt_diff]) ? board->adchan_di : board->adchan_se;
1208 s->insn_read = dt282x_ai_insn_read; 1177 s->insn_read = dt282x_ai_insn_read;
1209 s->do_cmdtest = dt282x_ai_cmdtest;
1210 s->do_cmd = dt282x_ai_cmd;
1211 s->cancel = dt282x_ai_cancel;
1212 s->maxdata = (1 << board->adbits) - 1; 1178 s->maxdata = (1 << board->adbits) - 1;
1213 s->len_chanlist = 16;
1214 s->range_table = 1179 s->range_table =
1215 opt_ai_range_lkup(board->ispgl, it->options[opt_ai_range]); 1180 opt_ai_range_lkup(board->ispgl, it->options[opt_ai_range]);
1216 devpriv->ad_2scomp = it->options[opt_ai_twos]; 1181 devpriv->ad_2scomp = it->options[opt_ai_twos];
1182 if (dev->irq) {
1183 dev->read_subdev = s;
1184 s->subdev_flags |= SDF_CMD_READ;
1185 s->len_chanlist = 16;
1186 s->do_cmdtest = dt282x_ai_cmdtest;
1187 s->do_cmd = dt282x_ai_cmd;
1188 s->cancel = dt282x_ai_cancel;
1189 }
1217 1190
1218 s = &dev->subdevices[1]; 1191 s = &dev->subdevices[1];
1219 1192
@@ -1221,15 +1194,10 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1221 if (s->n_chan) { 1194 if (s->n_chan) {
1222 /* ao subsystem */ 1195 /* ao subsystem */
1223 s->type = COMEDI_SUBD_AO; 1196 s->type = COMEDI_SUBD_AO;
1224 dev->write_subdev = s; 1197 s->subdev_flags = SDF_WRITABLE;
1225 s->subdev_flags = SDF_WRITABLE | SDF_CMD_WRITE;
1226 s->insn_read = dt282x_ao_insn_read; 1198 s->insn_read = dt282x_ao_insn_read;
1227 s->insn_write = dt282x_ao_insn_write; 1199 s->insn_write = dt282x_ao_insn_write;
1228 s->do_cmdtest = dt282x_ao_cmdtest;
1229 s->do_cmd = dt282x_ao_cmd;
1230 s->cancel = dt282x_ao_cancel;
1231 s->maxdata = (1 << board->dabits) - 1; 1200 s->maxdata = (1 << board->dabits) - 1;
1232 s->len_chanlist = 2;
1233 s->range_table_list = devpriv->darangelist; 1201 s->range_table_list = devpriv->darangelist;
1234 devpriv->darangelist[0] = 1202 devpriv->darangelist[0] =
1235 opt_ao_range_lkup(it->options[opt_ao0_range]); 1203 opt_ao_range_lkup(it->options[opt_ao0_range]);
@@ -1237,6 +1205,14 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1237 opt_ao_range_lkup(it->options[opt_ao1_range]); 1205 opt_ao_range_lkup(it->options[opt_ao1_range]);
1238 devpriv->da0_2scomp = it->options[opt_ao0_twos]; 1206 devpriv->da0_2scomp = it->options[opt_ao0_twos];
1239 devpriv->da1_2scomp = it->options[opt_ao1_twos]; 1207 devpriv->da1_2scomp = it->options[opt_ao1_twos];
1208 if (dev->irq) {
1209 dev->write_subdev = s;
1210 s->subdev_flags |= SDF_CMD_WRITE;
1211 s->len_chanlist = 2;
1212 s->do_cmdtest = dt282x_ao_cmdtest;
1213 s->do_cmd = dt282x_ao_cmd;
1214 s->cancel = dt282x_ao_cancel;
1215 }
1240 } else { 1216 } else {
1241 s->type = COMEDI_SUBD_UNUSED; 1217 s->type = COMEDI_SUBD_UNUSED;
1242 } 1218 }