mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-18 15:30:21 +00:00
MFP4:
o don't access struct resource members directly. o Set a default device description based on the CIS name.
This commit is contained in:
parent
0540e305b6
commit
6586fa7c43
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113242
@ -147,6 +147,23 @@ pccard_ccr_write(struct pccard_function *pf, int ccr, int val)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
pccard_set_default_descr(device_t dev)
|
||||
{
|
||||
char *vendorstr, *prodstr, *str;
|
||||
|
||||
if (pccard_get_vendor_str(dev, &vendorstr))
|
||||
return (0);
|
||||
if (pccard_get_product_str(dev, &prodstr))
|
||||
return (0);
|
||||
str = malloc(strlen(vendorstr) + strlen(prodstr) + 2, M_DEVBUF,
|
||||
M_WAITOK);
|
||||
sprintf(str, "%s %s", vendorstr, prodstr);
|
||||
device_set_desc_copy(dev, str);
|
||||
free(str, M_DEVBUF);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
pccard_attach_card(device_t dev)
|
||||
{
|
||||
@ -241,6 +258,7 @@ pccard_attach_card(device_t dev)
|
||||
if (sc->sc_enabled_count == 0)
|
||||
POWER_ENABLE_SOCKET(device_get_parent(dev), dev);
|
||||
if (pccard_function_enable(pf) == 0 &&
|
||||
pccard_set_default_descr(child) == 0 &&
|
||||
device_probe_and_attach(child) == 0) {
|
||||
DEVPRINTF((sc->dev, "function %d CCR at %d "
|
||||
"offset %x: %x %x %x %x, %x %x %x %x, %x\n",
|
||||
@ -511,7 +529,7 @@ pccard_function_free(struct pccard_function *pf)
|
||||
|
||||
SLIST_FOREACH(rle, &devi->resources, link) {
|
||||
if (rle->res) {
|
||||
if (rle->res->r_dev != pf->sc->dev)
|
||||
if (rman_get_device(rle->res) != pf->sc->dev)
|
||||
device_printf(pf->sc->dev,
|
||||
"function_free: Resource still owned by "
|
||||
"child, oops. "
|
||||
@ -519,7 +537,7 @@ pccard_function_free(struct pccard_function *pf)
|
||||
rle->type, rle->rid,
|
||||
rman_get_start(rle->res));
|
||||
BUS_RELEASE_RESOURCE(device_get_parent(pf->sc->dev),
|
||||
rle->res->r_dev, rle->type, rle->rid, rle->res);
|
||||
pf->sc->dev, rle->type, rle->rid, rle->res);
|
||||
rle->res = NULL;
|
||||
}
|
||||
}
|
||||
@ -1084,7 +1102,7 @@ pccard_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
}
|
||||
return (rle->res);
|
||||
}
|
||||
if (rle->res->r_dev != dev)
|
||||
if (rman_get_device(rle->res) != dev)
|
||||
return (NULL);
|
||||
bus_release_resource(dev, type, *rid, rle->res);
|
||||
rle->res = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user