summaryrefslogtreecommitdiffstats
path: root/sys/pccard
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2001-05-14 06:04:29 +0000
committerimp <imp@FreeBSD.org>2001-05-14 06:04:29 +0000
commit6f79a8046d27777e18551946510e2746a752a527 (patch)
treee956269a3c03ea3fd47134709d3680a3293942f7 /sys/pccard
parent331f033ddcae257485f7fcfb692e03071287a526 (diff)
downloadFreeBSD-src-6f79a8046d27777e18551946510e2746a752a527.zip
FreeBSD-src-6f79a8046d27777e18551946510e2746a752a527.tar.gz
Take a stab at making this less dependent on having pcic as a parent.
For memory for the pccard attribute/common memory mapping allocate on the pccard. For other allocations, use whatever is the parent of this device. There's no doubt other issues lurking, but this should make things closer to being independent.
Diffstat (limited to 'sys/pccard')
-rw-r--r--sys/pccard/pccard.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c
index c317b02..3d8edc6 100644
--- a/sys/pccard/pccard.c
+++ b/sys/pccard/pccard.c
@@ -47,7 +47,6 @@
#include <pccard/cardinfo.h>
#include <pccard/driver.h>
-#include <pccard/pcic.h>
#include <pccard/slot.h>
#include <pccard/pccard_nbk.h>
@@ -145,7 +144,7 @@ disable_slot(struct slot *slt)
* driver is accessing the device and it is removed, then
* all bets are off...
*/
- pccarddev = devclass_get_device(pccard_devclass, slt->slotnum);
+ pccarddev = slt->dev;
device_get_children(pccarddev, &kids, &nkids);
for (i = 0; i < nkids; i++) {
if ((ret = device_delete_child(pccarddev, kids[i])) != 0)
@@ -205,7 +204,7 @@ allocate_driver(struct slot *slt, struct dev_desc *desc)
int err, irq = 0;
device_t child;
- pccarddev = devclass_get_device(pccard_devclass, slt->slotnum);
+ pccarddev = slt->dev;
irq = ffs(desc->irqmask) - 1;
MALLOC(devi, struct pccard_devinfo *, sizeof(*devi), M_DEVBUF,
M_WAITOK | M_ZERO);
@@ -434,18 +433,14 @@ crdioctl_sresource(dev_t dev, caddr_t data)
{
struct pccard_resource *pr;
struct resource *r;
- device_t pcicdev;
int i;
int rid = 1;
int err;
+ device_t bridgedev;
pr = (struct pccard_resource *)data;
pr->resource_addr = ~0ul;
- /*
- * pccard_devclass does not have soft_c
- * so we use pcic_devclass
- */
- pcicdev = devclass_get_device(pcic_devclass, 0);
+ bridgedev = device_get_parent(PCCARD_DEV2SOFTC(dev)->dev);
switch(pr->type) {
default:
return (EINVAL);
@@ -455,18 +450,15 @@ crdioctl_sresource(dev_t dev, caddr_t data)
break;
}
for (i = pr->min; i + pr->size - 1 <= pr->max; i++) {
- /* already allocated to pcic? */
- if (bus_get_resource_start(pcicdev, pr->type, 0) == i)
- continue;
- err = bus_set_resource(pcicdev, pr->type, rid, i, pr->size);
+ err = bus_set_resource(bridgedev, pr->type, rid, i, pr->size);
if (err != 0)
continue;
- r = bus_alloc_resource(pcicdev, pr->type, &rid, 0ul, ~0ul,
+ r = bus_alloc_resource(bridgedev, pr->type, &rid, 0ul, ~0ul,
pr->size, 0);
if (r == NULL)
continue;
pr->resource_addr = (u_long)rman_get_start(r);
- bus_release_resource(pcicdev, pr->type, rid, r);
+ bus_release_resource(bridgedev, pr->type, rid, r);
return (0);
}
return (0);
@@ -479,13 +471,14 @@ crdioctl_sresource(dev_t dev, caddr_t data)
static int
crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p)
{
- struct slot *slt = PCCARD_DEV2SOFTC(dev);
+ u_int32_t addr;
+ int err;
+ struct io_desc *ip;
struct mem_desc *mp;
- struct io_desc *ip;
- device_t pcicdev;
- int s, err;
- int pwval;
- u_int32_t addr;
+ device_t pccarddev;
+ int pwval;
+ int s;
+ struct slot *slt = PCCARD_DEV2SOFTC(dev);
if (slt == 0 && cmd != PIOCRWMEM)
return(ENXIO);
@@ -585,13 +578,13 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p)
*/
if (*(unsigned long *)data & (PCCARD_MEMSIZE-1))
return(EINVAL);
- pcicdev = devclass_get_device(pcic_devclass, 0);
+ pccarddev = PCCARD_DEV2SOFTC(dev)->dev;
pccard_mem_rid = 0;
addr = *(unsigned long *)data;
if (pccard_mem_res)
- bus_release_resource(pcicdev, SYS_RES_MEMORY,
+ bus_release_resource(pccarddev, SYS_RES_MEMORY,
pccard_mem_rid, pccard_mem_res);
- pccard_mem_res = bus_alloc_resource(pcicdev, SYS_RES_MEMORY,
+ pccard_mem_res = bus_alloc_resource(pccarddev, SYS_RES_MEMORY,
&pccard_mem_rid, addr, addr, PCCARD_MEMSIZE,
RF_ACTIVE | rman_make_alignment_flags(PCCARD_MEMSIZE));
if (pccard_mem_res == NULL)
OpenPOWER on IntegriCloud