diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-04-09 19:15:55 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-11 15:47:39 -0400 |
commit | 7c0bad23e5d7011d1d350080fcbda4bec525521d (patch) | |
tree | 9167a6fe2cf0120c49923729aeaabc1d97fbeb4e /drivers/staging | |
parent | 8234d51a280290a23e9c21d5f1a5988d984cbdc9 (diff) |
staging: comedi: das16: use comedi_request_region()
Use comedi_request_region() to request the I/O region used by this
driver.
Remove the noise when the board is first attached as well as the
error message when the request_region() fails, comedi_request_reqion()
will output the error message if necessary.
This driver does a second request_region() for the I/O space needed
by the 8255 chip. Modify the error message if that request fails so
it matches to format of the comedi_request_region() message.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/drivers/das16.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index c84f7795994e..01fe078f3914 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c | |||
@@ -1079,13 +1079,11 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
1079 | struct comedi_subdevice *s; | 1079 | struct comedi_subdevice *s; |
1080 | int ret; | 1080 | int ret; |
1081 | unsigned int irq; | 1081 | unsigned int irq; |
1082 | unsigned long iobase; | ||
1083 | unsigned int dma_chan; | 1082 | unsigned int dma_chan; |
1084 | int timer_mode; | 1083 | int timer_mode; |
1085 | unsigned long flags; | 1084 | unsigned long flags; |
1086 | struct comedi_krange *user_ai_range, *user_ao_range; | 1085 | struct comedi_krange *user_ai_range, *user_ao_range; |
1087 | 1086 | ||
1088 | iobase = it->options[0]; | ||
1089 | #if 0 | 1087 | #if 0 |
1090 | irq = it->options[1]; | 1088 | irq = it->options[1]; |
1091 | timer_mode = it->options[8]; | 1089 | timer_mode = it->options[8]; |
@@ -1097,8 +1095,6 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
1097 | if (timer_mode) | 1095 | if (timer_mode) |
1098 | irq = 0; | 1096 | irq = 0; |
1099 | 1097 | ||
1100 | printk(KERN_INFO "comedi%d: das16:", dev->minor); | ||
1101 | |||
1102 | /* check that clock setting is valid */ | 1098 | /* check that clock setting is valid */ |
1103 | if (it->options[3]) { | 1099 | if (it->options[3]) { |
1104 | if (it->options[3] != 0 && | 1100 | if (it->options[3] != 0 && |
@@ -1116,33 +1112,26 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
1116 | dev->private = devpriv; | 1112 | dev->private = devpriv; |
1117 | 1113 | ||
1118 | if (board->size < 0x400) { | 1114 | if (board->size < 0x400) { |
1119 | printk(" 0x%04lx-0x%04lx\n", iobase, iobase + board->size); | 1115 | ret = comedi_request_region(dev, it->options[0], board->size); |
1120 | if (!request_region(iobase, board->size, dev->board_name)) { | 1116 | if (ret) |
1121 | printk(KERN_ERR " I/O port conflict\n"); | 1117 | return ret; |
1122 | return -EIO; | ||
1123 | } | ||
1124 | } else { | 1118 | } else { |
1125 | printk(KERN_INFO " 0x%04lx-0x%04lx 0x%04lx-0x%04lx\n", | 1119 | ret = comedi_request_region(dev, it->options[0], 0x10); |
1126 | iobase, iobase + 0x0f, | 1120 | if (ret) |
1127 | iobase + 0x400, | 1121 | return ret; |
1128 | iobase + 0x400 + (board->size & 0x3ff)); | 1122 | /* Request an additional region for the 8255 */ |
1129 | if (!request_region(iobase, 0x10, dev->board_name)) { | 1123 | if (!request_region(dev->iobase + 0x400, board->size & 0x3ff, |
1130 | printk(KERN_ERR " I/O port conflict: 0x%04lx-0x%04lx\n", | ||
1131 | iobase, iobase + 0x0f); | ||
1132 | return -EIO; | ||
1133 | } | ||
1134 | if (!request_region(iobase + 0x400, board->size & 0x3ff, | ||
1135 | dev->board_name)) { | 1124 | dev->board_name)) { |
1136 | release_region(iobase, 0x10); | 1125 | release_region(dev->iobase, 0x10); |
1137 | printk(KERN_ERR " I/O port conflict: 0x%04lx-0x%04lx\n", | 1126 | dev_warn(dev->class_dev, |
1138 | iobase + 0x400, | 1127 | "%s: I/O port conflict (%#lx,%d)\n", |
1139 | iobase + 0x400 + (board->size & 0x3ff)); | 1128 | dev->board_name, |
1129 | dev->iobase + 0x400, board->size & 0x3ff); | ||
1130 | dev->iobase = 0; | ||
1140 | return -EIO; | 1131 | return -EIO; |
1141 | } | 1132 | } |
1142 | } | 1133 | } |
1143 | 1134 | ||
1144 | dev->iobase = iobase; | ||
1145 | |||
1146 | /* probe id bits to make sure they are consistent */ | 1135 | /* probe id bits to make sure they are consistent */ |
1147 | if (das16_probe(dev, it)) { | 1136 | if (das16_probe(dev, it)) { |
1148 | printk(KERN_ERR " id bits do not match selected board, aborting\n"); | 1137 | printk(KERN_ERR " id bits do not match selected board, aborting\n"); |