summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhosokawa <hosokawa@FreeBSD.org>2000-01-16 06:44:48 +0000
committerhosokawa <hosokawa@FreeBSD.org>2000-01-16 06:44:48 +0000
commit721d34c8d9cc1ca1480315326ea71269f671217d (patch)
tree10b960c7cc7e3fbf82a53de66e0c8b428cbbd6ab
parentb0d0e9404a1f0c003f8cc2e5860cf6c551000367 (diff)
downloadFreeBSD-src-721d34c8d9cc1ca1480315326ea71269f671217d.zip
FreeBSD-src-721d34c8d9cc1ca1480315326ea71269f671217d.tar.gz
This fixes a bug that /etc/pccard_ether did not work without DHCP.
For example, when /etc/pccard.conf had ed0 in config line, but kernel refused this name and said devclass_alloc_unit: ed0 already exists, using next availale unit number Kernel used ed1 as device name and it did not match with config and insert/remove lines. Fortunately, dhclient was called without args, and it works, but if we wanted to use static IP address for PC-card, it did not work. This modification makes pccardd to execute insert/remove lines with the true device name that returns from kernel. (Last change to etc/pccard.conf.sample eliminated all hardwired device name from insert/remove lines in /etc/pccard.conf)
-rw-r--r--sys/pccard/cardinfo.h2
-rw-r--r--sys/pccard/pccard.c2
-rw-r--r--usr.sbin/pccard/pccardd/cardd.c13
3 files changed, 15 insertions, 2 deletions
diff --git a/sys/pccard/cardinfo.h b/sys/pccard/cardinfo.h
index 425810b..06c6f4d 100644
--- a/sys/pccard/cardinfo.h
+++ b/sys/pccard/cardinfo.h
@@ -43,7 +43,7 @@
#define PIOCSMEM _IOW('P', 3, struct mem_desc) /* Set memory map */
#define PIOCGIO _IOWR('P', 4, struct io_desc) /* Get I/O map */
#define PIOCSIO _IOW('P', 5, struct io_desc) /* Set I/O map */
-#define PIOCSDRV _IOW('P', 6, struct dev_desc) /* Set driver */
+#define PIOCSDRV _IOWR('P', 6, struct dev_desc) /* Set driver */
#define PIOCRWFLAG _IOW('P', 7, int) /* Set flags for drv use */
#define PIOCRWMEM _IOWR('P', 8, unsigned long) /* Set mem for drv use */
#define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */
diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c
index 9b4a61d..abc1195 100644
--- a/sys/pccard/pccard.c
+++ b/sys/pccard/pccard.c
@@ -278,6 +278,8 @@ allocate_driver(struct slot *slt, struct dev_desc *desc)
goto err;
}
err = device_probe_and_attach(child);
+ snprintf(desc->name, sizeof(desc->name), "%s",
+ device_get_nameunit(child));
err:
if (err)
device_delete_child(pccarddev, child);
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c
index aae658f..f542d60 100644
--- a/usr.sbin/pccard/pccardd/cardd.c
+++ b/usr.sbin/pccard/pccardd/cardd.c
@@ -484,6 +484,7 @@ setup_slot(struct slot *sp)
struct io_desc io;
struct dev_desc drv;
struct driver *drvp = sp->config->driver;
+ char *p;
char c;
off_t offs;
int rw_flags;
@@ -584,7 +585,6 @@ setup_slot(struct slot *sp)
drv.iobase + sp->io.size - 1, drv.mem, drv.memsize,
sp->irq, drv.flags);
}
-
/*
* If the driver fails to be connected to the device,
* then it may mean that the driver did not recognise it.
@@ -595,5 +595,16 @@ setup_slot(struct slot *sp)
sp->card->manuf, sp->card->version, strerror(errno));
return (0);
}
+ drv.name[sizeof(drv.name) - 1] = '\0';
+ if (strncmp(drv.name, drvp->kernel, sizeof(drv.name))) {
+ drvp->kernel = newstr(drv.name);
+ p = drvp->kernel;
+ while (*p++)
+ if (*p >= '0' && *p <= '9') {
+ drvp->unit = atoi(p);
+ *p = '\0';
+ break;
+ }
+ }
return (1);
}
OpenPOWER on IntegriCloud