Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/sys/dev/pcmcia Pullup to rev 1.31 (requested in ticket ...
details: https://anonhg.NetBSD.org/src/rev/e332f4c91f38
branches: netbsd-1-6
changeset: 530908:e332f4c91f38
user: jmc <jmc%NetBSD.org@localhost>
date: Tue Oct 21 03:43:18 2003 +0000
description:
Pullup to rev 1.31 (requested in ticket #699)
Enable support for multi-function pcmcia cards.
diffstat:
sys/dev/pcmcia/pcmcia_cis.c | 91 ++++++++++++++++++++++++++------------------
1 files changed, 53 insertions(+), 38 deletions(-)
diffs (157 lines):
diff -r e0ef2e69e059 -r e332f4c91f38 sys/dev/pcmcia/pcmcia_cis.c
--- a/sys/dev/pcmcia/pcmcia_cis.c Mon Oct 20 07:31:52 2003 +0000
+++ b/sys/dev/pcmcia/pcmcia_cis.c Tue Oct 21 03:43:18 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcmcia_cis.c,v 1.29 2002/01/12 16:25:15 tsutsui Exp $ */
+/* $NetBSD: pcmcia_cis.c,v 1.29.10.1 2003/10/21 03:43:18 jmc Exp $ */
/*
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcmcia_cis.c,v 1.29 2002/01/12 16:25:15 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcmcia_cis.c,v 1.29.10.1 2003/10/21 03:43:18 jmc Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -61,8 +61,45 @@
int pcmcia_parse_cis_tuple __P((struct pcmcia_tuple *, void *));
static int decode_funce __P((struct pcmcia_tuple *, struct pcmcia_function *));
+static void create_pf __P((struct cis_state *));
+static void
+create_pf(struct cis_state *state)
+{
+ state->pf = malloc(sizeof(*state->pf), M_DEVBUF, M_NOWAIT|M_ZERO);
+ state->pf->number = state->count++;
+ state->pf->last_config_index = -1;
+ SIMPLEQ_INIT(&state->pf->cfe_head);
+ SIMPLEQ_INSERT_TAIL(&state->card->pf_head, state->pf, pf_list);
+}
+
+void
+pcmcia_free_pf(struct pcmcia_function_head *pfhead)
+{
+ struct pcmcia_function *pf, *opf = NULL;
+ struct pcmcia_config_entry *cfe, *ocfe = NULL;
+
+ SIMPLEQ_FOREACH(pf, pfhead, pf_list) {
+ SIMPLEQ_FOREACH(cfe, &pf->cfe_head, cfe_list) {
+ if (ocfe)
+ free(ocfe, M_DEVBUF);
+ ocfe = cfe;
+ }
+ if (ocfe) {
+ free(ocfe, M_DEVBUF);
+ ocfe = NULL;
+ }
+ if (opf)
+ free(opf, M_DEVBUF);
+ opf = pf;
+ }
+ if (opf)
+ free(opf, M_DEVBUF);
+
+ SIMPLEQ_INIT(pfhead);
+}
+
void
pcmcia_read_cis(sc)
struct pcmcia_softc *sc;
@@ -527,8 +564,7 @@
printf("%s: Manufacturer code 0x%x, product 0x%x\n",
sc->dev.dv_xname, card->manufacturer, card->product);
- for (pf = card->pf_head.sqh_first; pf != NULL;
- pf = pf->pf_list.sqe_next) {
+ SIMPLEQ_FOREACH(pf, &card->pf_head, pf_list) {
printf("%s: function %d: ", sc->dev.dv_xname, pf->number);
switch (pf->function) {
@@ -582,8 +618,7 @@
printf(", ccr addr %lx mask %lx\n", pf->ccr_base, pf->ccr_mask);
- for (cfe = pf->cfe_head.sqh_first; cfe != NULL;
- cfe = cfe->cfe_list.sqe_next) {
+ SIMPLEQ_FOREACH(cfe, &pf->cfe_head, cfe_list) {
printf("%s: function %d, config table entry %d: ",
sc->dev.dv_xname, pf->number, cfe->number);
@@ -692,19 +727,11 @@
* rather not change it.
*/
if (state->gotmfc == 1) {
- struct pcmcia_function *pf, *pfnext;
+ state->gotmfc = 2;
+ state->count = 0;
+ state->pf = NULL;
- for (pf = state->card->pf_head.sqh_first; pf != NULL;
- pf = pfnext) {
- pfnext = pf->pf_list.sqe_next;
- free(pf, M_DEVBUF);
- }
-
- SIMPLEQ_INIT(&state->card->pf_head);
-
- state->count = 0;
- state->gotmfc = 2;
- state->pf = NULL;
+ pcmcia_free_pf(&state->card->pf_head);
}
break;
case PCMCIA_CISTPL_LONGLINK_MFC:
@@ -714,7 +741,11 @@
* functions declared before the MFC link can be cleaned
* up.
*/
- state->gotmfc = 1;
+ if (state->gotmfc == 0) {
+ state->gotmfc = 1;
+ } else {
+ DPRINTF(("got LONGLINK_MFC again!"));
+ }
break;
#ifdef PCMCIACISDEBUG
case PCMCIA_CISTPL_DEVICE:
@@ -853,16 +884,8 @@
state->pf = NULL;
}
}
- if (state->pf == NULL) {
- state->pf = malloc(sizeof(*state->pf), M_DEVBUF,
- M_NOWAIT|M_ZERO);
- state->pf->number = state->count++;
- state->pf->last_config_index = -1;
- SIMPLEQ_INIT(&state->pf->cfe_head);
-
- SIMPLEQ_INSERT_TAIL(&state->card->pf_head, state->pf,
- pf_list);
- }
+ if (state->pf == NULL)
+ create_pf(state);
state->pf->function = pcmcia_tuple_read_1(tuple, 0);
DPRINTF(("CISTPL_FUNCID\n"));
@@ -901,15 +924,7 @@
break;
}
if (state->pf == NULL) {
- state->pf = malloc(sizeof(*state->pf),
- M_DEVBUF, M_NOWAIT|M_ZERO);
- state->pf->number = state->count++;
- state->pf->last_config_index = -1;
- SIMPLEQ_INIT(&state->pf->cfe_head);
-
- SIMPLEQ_INSERT_TAIL(&state->card->pf_head,
- state->pf, pf_list);
-
+ create_pf(state);
state->pf->function = PCMCIA_FUNCTION_UNSPEC;
}
state->pf->last_config_index =
Home |
Main Index |
Thread Index |
Old Index