aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2001-08-02 07:06:32 +0000
committerWarner Losh <imp@FreeBSD.org>2001-08-02 07:06:32 +0000
commite61693305c2c93303edb32c2782188e86c61e661 (patch)
tree4ec4db0e8a8da4cb1f7d67c1688b0acf713629bf /usr.sbin
parent8e6d7b291d7dc5aff6628e67fdb7e5c11298e479 (diff)
downloadsrc-e61693305c2c93303edb32c2782188e86c61e661.tar.gz
src-e61693305c2c93303edb32c2782188e86c61e661.zip
Only try to allocated properly aligned I/O segments. This should stop
some of the config problems that we've been seeing (where wi0 tries to allocate 0x138-0x198, for example). Use err(1,"foo") rather than perror + exit while I'm here.
Notes
Notes: svn path=/head/; revision=81028
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pccard/pccardd/cardd.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c
index a5e5d7552b21..09a51bc25226 100644
--- a/usr.sbin/pccard/pccardd/cardd.c
+++ b/usr.sbin/pccard/pccardd/cardd.c
@@ -33,6 +33,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
@@ -534,10 +535,8 @@ assign_driver(struct slot *sp, struct card *cp)
}
res.min = i;
res.max = i;
- if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0) {
- perror("ioctl (PIOCSRESOURCE)");
- exit(1);
- }
+ if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0)
+ err(1, "ioctl (PIOCSRESOURCE)");
if (res.resource_addr == ~0ul)
continue;
conf->irq = res.resource_addr;
@@ -550,10 +549,8 @@ assign_driver(struct slot *sp, struct card *cp)
}
} else {
res.min = res.max = conf->irq;
- if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0) {
- perror("ioctl (PIOCSRESOURCE)");
- exit(1);
- }
+ if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0)
+ err(1, "ioctl (PIOCSRESOURCE)");
if (res.resource_addr == ~0ul) {
logmsg("Failed to verify IRQ for %s\n", cp->manuf);
return (NULL);
@@ -591,12 +588,10 @@ assign_card_index(struct slot *sp, struct cis * cis)
res.size = cio->size;
res.min = cio->addr;
res.max = res.min + cio->size - 1;
- if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0) {
- perror("ioctl (PIOCSRESOURCE)");
- exit(1);
- }
+ if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0)
+ err(1, "ioctl (PIOCSRESOURCE)");
if (res.resource_addr != cio->addr)
- goto next;
+ goto next;
for (i = cio->addr; i < cio->addr + cio->size - 1; i++)
if (!bit_test(io_avail, i))
goto next;
@@ -761,12 +756,12 @@ memskip:
for (i = 0; i < IOPORTS; i++) {
j = bit_fns(io_avail, IOPORTS, i,
sio->size, sio->size);
+ if ((j & (sio->size - 1)) != 0)
+ continue;
res.min = j;
res.max = j + sio->size - 1;
- if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0) {
- perror("ioctl (PIOCSRESOURCE)");
- exit(1);
- }
+ if (ioctl(sp->fd, PIOCSRESOURCE, &res) < 0)
+ err(1, "ioctl (PIOCSRESOURCE)");
if (res.resource_addr == j)
break;
}