diff options
author | imp <imp@FreeBSD.org> | 2000-10-09 03:40:15 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2000-10-09 03:40:15 +0000 |
commit | 7c2a756e2cb81c10ae40f8eab11f4d050b1b4e05 (patch) | |
tree | a898e009b69e5c4dfa1d4e7d20fd9a5c20e821cd /sys/dev/pccard | |
parent | 04442ea304505df9fd1948294deea8a6f3a91f4e (diff) | |
download | FreeBSD-src-7c2a756e2cb81c10ae40f8eab11f4d050b1b4e05.zip FreeBSD-src-7c2a756e2cb81c10ae40f8eab11f4d050b1b4e05.tar.gz |
o Record the pccard_function in the ivar.
o Use a macro function to get the ivar for the child rather than the casting
directly. This should be a little safer and easier to read.
Diffstat (limited to 'sys/dev/pccard')
-rw-r--r-- | sys/dev/pccard/pccard.c | 19 | ||||
-rw-r--r-- | sys/dev/pccard/pccardvar.h | 1 |
2 files changed, 12 insertions, 8 deletions
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 20d9254..df943b8 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -163,6 +163,7 @@ pccard_attach_card(device_t dev) ivar = malloc(sizeof(struct pccard_ivar), M_DEVBUF, M_WAITOK); child = device_add_child(dev, NULL, -1); device_set_ivars(child, ivar); + ivar->fcn = pf; pccard_function_init(pf); pccard_function_enable(pf); device_printf(dev, "pf %p pf->sc %p\n", pf, pf->sc); @@ -641,7 +642,7 @@ pccard_print_resources(struct resource_list *rl, const char *name, int type, static int pccard_print_child(device_t dev, device_t child) { - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); + struct pccard_ivar *devi = PCCARD_IVAR(child); struct resource_list *rl = &devi->resources; int retval = 0; @@ -669,7 +670,7 @@ static int pccard_set_resource(device_t dev, device_t child, int type, int rid, u_long start, u_long count) { - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); + struct pccard_ivar *devi = PCCARD_IVAR(child); struct resource_list *rl = &devi->resources; if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY @@ -695,7 +696,7 @@ static int pccard_get_resource(device_t dev, device_t child, int type, int rid, u_long *startp, u_long *countp) { - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); + struct pccard_ivar *devi = PCCARD_IVAR(child); struct resource_list *rl = &devi->resources; struct resource_list_entry *rle; @@ -714,7 +715,7 @@ pccard_get_resource(device_t dev, device_t child, int type, int rid, static void pccard_delete_resource(device_t dev, device_t child, int type, int rid) { - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); + struct pccard_ivar *devi = PCCARD_IVAR(child); struct resource_list *rl = &devi->resources; resource_list_delete(rl, type, rid); } @@ -738,7 +739,7 @@ pccard_set_memory_offset(device_t dev, device_t child, int rid, static int pccard_read_ivar(device_t bus, device_t child, int which, u_char *result) { - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); + struct pccard_ivar *devi = PCCARD_IVAR(child); struct pccard_function *func = devi->fcn; struct pccard_softc *sc = PCCARD_SOFTC(bus); @@ -755,9 +756,11 @@ pccard_read_ivar(device_t bus, device_t child, int which, u_char *result) *(u_int32_t *) result = sc->card.product; break; case PCCARD_IVAR_FUNCTION_NUMBER: - /* XXX imp XXX */ - /* *(u_int32_t *) result = func->number; */ - *(u_int32_t *) result = 0; + if (!func) { + device_printf(bus, "No function number, bug!\n"); + return (ENOENT); + } + *(u_int32_t *) result = func->number; break; case PCCARD_IVAR_VENDOR_STR: *(char **) result = sc->card.cis1_info[0]; diff --git a/sys/dev/pccard/pccardvar.h b/sys/dev/pccard/pccardvar.h index 8b40c55..f2ee3d4 100644 --- a/sys/dev/pccard/pccardvar.h +++ b/sys/dev/pccard/pccardvar.h @@ -323,3 +323,4 @@ enum { }; #define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) +#define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) |