cardslot.c revision 1.5 1 1.5 haya /* $NetBSD: cardslot.c,v 1.5 1999/11/15 06:08:02 haya Exp $ */
2 1.5 haya
3 1.1 haya /*
4 1.1 haya * Copyright (c) 1999
5 1.1 haya * HAYAKAWA Koichi. All rights reserved.
6 1.1 haya *
7 1.1 haya * Redistribution and use in source and binary forms, with or without
8 1.1 haya * modification, are permitted provided that the following conditions
9 1.1 haya * are met:
10 1.1 haya * 1. Redistributions of source code must retain the above copyright
11 1.1 haya * notice, this list of conditions and the following disclaimer.
12 1.1 haya * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 haya * notice, this list of conditions and the following disclaimer in the
14 1.1 haya * documentation and/or other materials provided with the distribution.
15 1.1 haya * 3. All advertising materials mentioning features or use of this software
16 1.1 haya * must display the following acknowledgement:
17 1.1 haya * This product includes software developed by HAYAKAWA Koichi.
18 1.1 haya * 4. The name of the author may not be used to endorse or promote products
19 1.1 haya * derived from this software without specific prior written permission.
20 1.1 haya *
21 1.1 haya *
22 1.1 haya * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 haya * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 1.1 haya * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 1.1 haya * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26 1.1 haya * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 1.1 haya * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 1.1 haya * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 haya * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 1.1 haya * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 1.1 haya * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 1.1 haya * POSSIBILITY OF SUCH DAMAGE.
33 1.1 haya */
34 1.1 haya
35 1.3 haya #include "opt_cardslot.h"
36 1.1 haya
37 1.1 haya #include <sys/types.h>
38 1.1 haya #include <sys/param.h>
39 1.1 haya #include <sys/systm.h>
40 1.1 haya #include <sys/device.h>
41 1.1 haya #include <sys/malloc.h>
42 1.1 haya #include <sys/kernel.h>
43 1.1 haya #include <sys/syslog.h>
44 1.1 haya #include <sys/kthread.h>
45 1.1 haya
46 1.1 haya #include <machine/bus.h>
47 1.1 haya
48 1.1 haya #include <dev/cardbus/cardslotvar.h>
49 1.1 haya #include <dev/cardbus/cardbusvar.h>
50 1.1 haya #include <dev/pcmcia/pcmciavar.h>
51 1.1 haya #include <dev/pcmcia/pcmciachip.h>
52 1.1 haya #include <dev/ic/i82365var.h>
53 1.1 haya
54 1.1 haya
55 1.1 haya #if defined CARDSLOT_DEBUG
56 1.1 haya #define STATIC
57 1.1 haya #define DPRINTF(a) printf a
58 1.1 haya #define DDELAY(x) delay((x)*1000*1000)
59 1.1 haya #else
60 1.1 haya #define STATIC static
61 1.1 haya #define DPRINTF(a)
62 1.1 haya #endif
63 1.1 haya
64 1.1 haya
65 1.1 haya
66 1.1 haya STATIC void cardslotattach __P((struct device *, struct device *, void *));
67 1.1 haya
68 1.1 haya #if !defined __BROKEN_INDIRECT_CONFIG
69 1.1 haya STATIC int cardslotmatch __P((struct device *, struct cfdata *, void *));
70 1.1 haya #else
71 1.1 haya STATIC int cardslotmatch __P((struct device *, void *, void *));
72 1.1 haya #endif
73 1.1 haya static void create_slot_manager __P((void *));
74 1.1 haya static void cardslot_event_thread __P((void *arg));
75 1.1 haya
76 1.1 haya STATIC int cardslot_cb_print __P((void *aux, const char *pcic));
77 1.1 haya static int cardslot_16_print __P((void *, const char *));
78 1.1 haya static int cardslot_16_submatch __P((struct device *, struct cfdata *,void *));
79 1.1 haya
80 1.1 haya struct cfattach cardslot_ca = {
81 1.1 haya sizeof(struct cardslot_softc), cardslotmatch, cardslotattach
82 1.1 haya };
83 1.1 haya
84 1.1 haya #ifndef __NetBSD_Version__
85 1.1 haya struct cfdriver cardslot_cd = {
86 1.1 haya NULL, "cardslot", DV_DULL
87 1.1 haya };
88 1.1 haya #endif
89 1.1 haya
90 1.1 haya
91 1.1 haya STATIC int
92 1.1 haya #if defined __BROKEN_INDIRECT_CONFIG
93 1.1 haya cardslotmatch(parent, match, aux)
94 1.1 haya struct device *parent;
95 1.1 haya void *match;
96 1.1 haya void *aux;
97 1.1 haya #else
98 1.1 haya cardslotmatch(parent, cf, aux)
99 1.1 haya struct device *parent;
100 1.1 haya struct cfdata *cf;
101 1.1 haya void *aux;
102 1.1 haya #endif
103 1.1 haya {
104 1.1 haya #if defined __BROKEN_INDIRECT_CONFIG
105 1.1 haya struct cfdata *cf = match;
106 1.1 haya #endif
107 1.1 haya struct cardslot_attach_args *caa = aux;
108 1.1 haya
109 1.1 haya if (caa->caa_cb_attach == NULL && caa->caa_16_attach == NULL) {
110 1.1 haya /* Neither CardBus nor 16-bit PCMCIA are defined. */
111 1.1 haya return 0;
112 1.1 haya }
113 1.1 haya
114 1.1 haya return 1;
115 1.1 haya }
116 1.1 haya
117 1.1 haya
118 1.1 haya
119 1.1 haya STATIC void
120 1.1 haya cardslotattach(parent, self, aux)
121 1.1 haya struct device *parent;
122 1.1 haya struct device *self;
123 1.1 haya void *aux;
124 1.1 haya {
125 1.1 haya struct cardslot_softc *sc = (struct cardslot_softc *)self;
126 1.1 haya struct cardslot_attach_args *caa = aux;
127 1.1 haya
128 1.1 haya struct cbslot_attach_args *cba = caa->caa_cb_attach;
129 1.1 haya struct pcmciabus_attach_args *pa = caa->caa_16_attach;
130 1.1 haya
131 1.1 haya struct cardbus_softc *csc;
132 1.1 haya struct pcmcia_softc *psc;
133 1.1 haya
134 1.1 haya int card_attach_now;
135 1.1 haya
136 1.1 haya sc->sc_slot = sc->sc_dev.dv_unit;
137 1.1 haya sc->sc_cb_softc = NULL;
138 1.1 haya sc->sc_16_softc = NULL;
139 1.1 haya SIMPLEQ_INIT(&sc->sc_events);
140 1.1 haya sc->sc_th_enable = 0;
141 1.1 haya
142 1.1 haya printf(" slot %d flags %x\n", sc->sc_slot, sc->sc_dev.dv_cfdata->cf_flags);
143 1.1 haya
144 1.1 haya DPRINTF(("%s attaching CardBus bus...\n", sc->sc_dev.dv_xname));
145 1.1 haya if (cba != NULL) {
146 1.1 haya if (NULL != (csc = (void *)config_found(self, cba, cardslot_cb_print))) {
147 1.1 haya /* cardbus found */
148 1.1 haya DPRINTF(("cardslotattach: found cardbus on %s\n", sc->sc_dev.dv_xname));
149 1.1 haya sc->sc_cb_softc = csc;
150 1.1 haya }
151 1.1 haya }
152 1.1 haya
153 1.1 haya if (pa != NULL) {
154 1.1 haya if (NULL != (psc = (void *)config_found_sm(self, pa, cardslot_16_print,
155 1.1 haya cardslot_16_submatch))) {
156 1.1 haya /* pcmcia 16-bit bus found */
157 1.1 haya DPRINTF(("cardslotattach: found 16-bit pcmcia bus\n"));
158 1.1 haya sc->sc_16_softc = psc;
159 1.1 haya /* XXX: dirty. This code should be removed to achieve MI */
160 1.1 haya caa->caa_ph->pcmcia = (struct device *)psc;
161 1.1 haya }
162 1.1 haya }
163 1.1 haya
164 1.1 haya if (csc != NULL || psc != NULL) {
165 1.1 haya #if __NetBSD_Version__ > 104060000
166 1.1 haya kthread_create(create_slot_manager, (void *)sc);
167 1.1 haya #else
168 1.1 haya kthread_create_deferred(create_slot_manager, (void *)sc);
169 1.1 haya #endif
170 1.1 haya }
171 1.1 haya
172 1.1 haya card_attach_now = sc->sc_dev.dv_cfdata->cf_flags & 0x01;
173 1.1 haya
174 1.1 haya if (csc && (csc->sc_cf->cardbus_ctrl)(csc->sc_cc, CARDBUS_CD)) {
175 1.1 haya DPRINTF(("cardslotattach: CardBus card found\n"));
176 1.1 haya if (card_attach_now) {
177 1.5 haya if (cardbus_attach_card(sc->sc_cb_softc) > 0) {
178 1.5 haya /* at least one function works */
179 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_WORKING);
180 1.5 haya } else {
181 1.5 haya /* no functions work or this card is not known */
182 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_NOTWORK);
183 1.5 haya }
184 1.1 haya CARDSLOT_SET_CARDTYPE(sc->sc_status, CARDSLOT_STATUS_CARD_CB);
185 1.1 haya } else {
186 1.1 haya /* attach deffered */
187 1.1 haya cardslot_event_throw(sc, CARDSLOT_EVENT_INSERTION_CB);
188 1.1 haya }
189 1.1 haya }
190 1.1 haya
191 1.1 haya if (psc && (psc->pct->card_detect)(psc->pch)) {
192 1.1 haya DPRINTF(("cardbusattach: 16-bit card found\n"));
193 1.1 haya if (card_attach_now) {
194 1.1 haya /* attach now */
195 1.1 haya pcmcia_card_attach((struct device *)sc->sc_16_softc);
196 1.1 haya CARDSLOT_SET_CARDTYPE(sc->sc_status, CARDSLOT_STATUS_CARD_16);
197 1.1 haya } else {
198 1.1 haya /* attach deffered */
199 1.1 haya cardslot_event_throw(sc, CARDSLOT_EVENT_INSERTION_16);
200 1.1 haya }
201 1.1 haya }
202 1.1 haya }
203 1.1 haya
204 1.1 haya
205 1.1 haya
206 1.1 haya STATIC int
207 1.4 haya cardslot_cb_print(aux, pnp)
208 1.1 haya void *aux;
209 1.4 haya const char *pnp;
210 1.1 haya {
211 1.4 haya struct cbslot_attach_args *cba = aux;
212 1.4 haya
213 1.4 haya if (pnp) {
214 1.4 haya printf("cardbus at %s", pnp);
215 1.4 haya printf(" function %d subordinate bus %d", cba->cba_function, cba->cba_bus);
216 1.4 haya }
217 1.4 haya
218 1.1 haya return UNCONF;
219 1.1 haya }
220 1.1 haya
221 1.1 haya
222 1.1 haya static int
223 1.1 haya cardslot_16_submatch(parent, cf, aux)
224 1.1 haya struct device *parent;
225 1.1 haya struct cfdata *cf;
226 1.1 haya void *aux;
227 1.1 haya {
228 1.1 haya if (cf->cf_loc[PCMCIABUSCF_CONTROLLER] != PCMCIABUSCF_CONTROLLER_DEFAULT
229 1.1 haya && cf->cf_loc[PCMCIABUSCF_CONTROLLER] != 0) {
230 1.1 haya return 0;
231 1.1 haya }
232 1.1 haya
233 1.1 haya if ((cf->cf_loc[PCMCIABUSCF_CONTROLLER] == PCMCIABUSCF_CONTROLLER_DEFAULT)) {
234 1.1 haya return ((*cf->cf_attach->ca_match)(parent, cf, aux));
235 1.1 haya }
236 1.1 haya
237 1.1 haya return 0;
238 1.1 haya }
239 1.1 haya
240 1.1 haya
241 1.1 haya
242 1.1 haya static int
243 1.1 haya cardslot_16_print(arg, pnp)
244 1.1 haya void *arg;
245 1.1 haya const char *pnp;
246 1.1 haya {
247 1.4 haya
248 1.1 haya if (pnp) {
249 1.4 haya printf("pcmciabus at %s", pnp);
250 1.1 haya }
251 1.1 haya
252 1.1 haya return UNCONF;
253 1.1 haya }
254 1.1 haya
255 1.1 haya
256 1.1 haya
257 1.1 haya
258 1.1 haya static void
259 1.1 haya create_slot_manager(arg)
260 1.1 haya void *arg;
261 1.1 haya {
262 1.1 haya struct cardslot_softc *sc = (struct cardslot_softc *)arg;
263 1.1 haya
264 1.1 haya sc->sc_th_enable = 1;
265 1.1 haya
266 1.1 haya #if __NetBSD_Version__ > 104060000
267 1.1 haya if (kthread_create1(cardslot_event_thread, sc, &sc->sc_event_thread, "%s",
268 1.1 haya sc->sc_dev.dv_xname)) {
269 1.1 haya #else
270 1.1 haya if (kthread_create(cardslot_event_thread, sc, &sc->sc_event_thread, "%s",
271 1.1 haya sc->sc_dev.dv_xname)) {
272 1.1 haya #endif
273 1.1 haya printf("%s: unable to create event thread for slot %d\n",
274 1.1 haya sc->sc_dev.dv_xname, sc->sc_slot);
275 1.1 haya panic("create_slot_manager");
276 1.1 haya }
277 1.1 haya }
278 1.1 haya
279 1.1 haya
280 1.1 haya
281 1.1 haya
282 1.1 haya /*
283 1.1 haya * void cardslot_event_throw(struct cardslot_softc *sc, int ev)
284 1.1 haya *
285 1.1 haya * This function throws an event to the event handler. If the state
286 1.1 haya * of a slot is changed, it should be noticed using this function.
287 1.1 haya */
288 1.1 haya void
289 1.1 haya cardslot_event_throw(sc, ev)
290 1.1 haya struct cardslot_softc *sc;
291 1.1 haya int ev;
292 1.1 haya {
293 1.1 haya struct cardslot_event *ce;
294 1.1 haya
295 1.1 haya DPRINTF(("cardslot_event_throw: an event %s comes\n",
296 1.1 haya ev == CARDSLOT_EVENT_INSERTION_CB ? "CardBus Card inserted" :
297 1.1 haya ev == CARDSLOT_EVENT_INSERTION_16 ? "16-bit Card inserted" :
298 1.1 haya ev == CARDSLOT_EVENT_REMOVAL_CB ? "CardBus Card removed" :
299 1.1 haya ev == CARDSLOT_EVENT_REMOVAL_16 ? "16-bit Card removed" : "???"));
300 1.1 haya
301 1.1 haya if (NULL == (ce = (struct cardslot_event *)malloc(sizeof (struct cardslot_event), M_TEMP, M_NOWAIT))) {
302 1.1 haya panic("cardslot_enevt");
303 1.1 haya }
304 1.1 haya
305 1.1 haya ce->ce_type = ev;
306 1.1 haya
307 1.1 haya {
308 1.1 haya int s = spltty();
309 1.1 haya SIMPLEQ_INSERT_TAIL(&sc->sc_events, ce, ce_q);
310 1.1 haya splx(s);
311 1.1 haya }
312 1.1 haya
313 1.1 haya wakeup(&sc->sc_events);
314 1.1 haya
315 1.1 haya return;
316 1.1 haya }
317 1.1 haya
318 1.1 haya
319 1.1 haya /*
320 1.1 haya * static void cardslot_event_thread(void *arg)
321 1.1 haya *
322 1.1 haya * This function is the main routine handing cardslot events such as
323 1.1 haya * insertions and removals.
324 1.1 haya *
325 1.1 haya */
326 1.1 haya static void
327 1.1 haya cardslot_event_thread(arg)
328 1.1 haya void *arg;
329 1.1 haya {
330 1.1 haya struct cardslot_softc *sc = arg;
331 1.1 haya struct cardslot_event *ce;
332 1.1 haya int s;
333 1.1 haya static int antonym_ev[4] = {
334 1.1 haya CARDSLOT_EVENT_REMOVAL_16, CARDSLOT_EVENT_INSERTION_16,
335 1.1 haya CARDSLOT_EVENT_REMOVAL_CB, CARDSLOT_EVENT_INSERTION_CB
336 1.1 haya };
337 1.1 haya
338 1.1 haya while (sc->sc_th_enable) {
339 1.1 haya s = spltty();
340 1.1 haya if ((ce = SIMPLEQ_FIRST(&sc->sc_events)) == NULL) {
341 1.1 haya splx(s);
342 1.1 haya (void) tsleep(&sc->sc_events, PWAIT, "cardslotev", 0);
343 1.1 haya continue;
344 1.1 haya }
345 1.1 haya SIMPLEQ_REMOVE_HEAD(&sc->sc_events, ce, ce_q);
346 1.1 haya splx(s);
347 1.1 haya
348 1.1 haya if (IS_CARDSLOT_INSERT_REMOVE_EV(ce->ce_type)) {
349 1.1 haya /* Chattering supression */
350 1.1 haya s = spltty();
351 1.1 haya while (1) {
352 1.1 haya struct cardslot_event *ce1, *ce2;
353 1.1 haya
354 1.1 haya if ((ce1 = SIMPLEQ_FIRST(&sc->sc_events)) == NULL) {
355 1.1 haya break;
356 1.1 haya }
357 1.1 haya if (ce1->ce_type != antonym_ev[ce->ce_type]) {
358 1.1 haya break;
359 1.1 haya }
360 1.1 haya if ((ce2 = SIMPLEQ_NEXT(ce1, ce_q)) == NULL) {
361 1.1 haya break;
362 1.1 haya }
363 1.1 haya if (ce2->ce_type == ce->ce_type) {
364 1.1 haya SIMPLEQ_REMOVE_HEAD(&sc->sc_events, ce1, ce_q);
365 1.1 haya free(ce1, M_TEMP);
366 1.1 haya SIMPLEQ_REMOVE_HEAD(&sc->sc_events, ce2, ce_q);
367 1.1 haya free(ce2, M_TEMP);
368 1.1 haya }
369 1.1 haya }
370 1.1 haya splx(s);
371 1.1 haya }
372 1.1 haya
373 1.1 haya switch (ce->ce_type) {
374 1.1 haya case CARDSLOT_EVENT_INSERTION_CB:
375 1.5 haya if ((CARDSLOT_CARDTYPE(sc->sc_status) == CARDSLOT_STATUS_CARD_CB)
376 1.5 haya || (CARDSLOT_CARDTYPE(sc->sc_status) == CARDSLOT_STATUS_CARD_16)) {
377 1.5 haya if (CARDSLOT_WORK(sc->sc_status) == CARDSLOT_STATUS_WORKING) {
378 1.5 haya /* A card has already been inserted and work. */
379 1.5 haya break;
380 1.5 haya }
381 1.1 haya }
382 1.5 haya
383 1.1 haya if (sc->sc_cb_softc) {
384 1.1 haya CARDSLOT_SET_CARDTYPE(sc->sc_status, CARDSLOT_STATUS_CARD_CB);
385 1.5 haya if (cardbus_attach_card(sc->sc_cb_softc) > 0) {
386 1.5 haya /* at least one function works */
387 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_WORKING);
388 1.5 haya } else {
389 1.5 haya /* no functions work or this card is not known */
390 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_NOTWORK);
391 1.5 haya }
392 1.1 haya } else {
393 1.1 haya panic("no cardbus on %s", sc->sc_dev.dv_xname);
394 1.1 haya }
395 1.1 haya
396 1.1 haya break;
397 1.1 haya
398 1.1 haya case CARDSLOT_EVENT_INSERTION_16:
399 1.5 haya if ((CARDSLOT_CARDTYPE(sc->sc_status) == CARDSLOT_STATUS_CARD_CB)
400 1.5 haya || (CARDSLOT_CARDTYPE(sc->sc_status) == CARDSLOT_STATUS_CARD_16)) {
401 1.5 haya if (CARDSLOT_WORK(sc->sc_status) == CARDSLOT_STATUS_WORKING) {
402 1.5 haya /* A card has already been inserted and work. */
403 1.5 haya break;
404 1.5 haya }
405 1.1 haya }
406 1.1 haya if (sc->sc_16_softc) {
407 1.1 haya CARDSLOT_SET_CARDTYPE(sc->sc_status, CARDSLOT_STATUS_CARD_16);
408 1.5 haya if (pcmcia_card_attach((struct device *)sc->sc_16_softc)) {
409 1.5 haya /* Do not attach */
410 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_NOTWORK);
411 1.5 haya } else {
412 1.5 haya /* working */
413 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_WORKING);
414 1.5 haya }
415 1.1 haya } else {
416 1.1 haya panic("no 16-bit pcmcia on %s", sc->sc_dev.dv_xname);
417 1.1 haya }
418 1.1 haya
419 1.1 haya break;
420 1.1 haya
421 1.1 haya case CARDSLOT_EVENT_REMOVAL_CB:
422 1.5 haya if (CARDSLOT_CARDTYPE(sc->sc_status) == CARDSLOT_STATUS_CARD_CB) {
423 1.1 haya /* CardBus card has not been inserted. */
424 1.5 haya #if notyet
425 1.5 haya if (CARDSLOT_WORK(sc->sc_status) == CARDSLOT_STATUS_WORKING) {
426 1.5 haya cardbus_detach_card(sc->sc_cb_softc);
427 1.5 haya }
428 1.5 haya #endif
429 1.5 haya CARDSLOT_SET_CARDTYPE(sc->sc_status, CARDSLOT_STATUS_CARD_NONE);
430 1.5 haya } else if (CARDSLOT_CARDTYPE(sc->sc_status) != CARDSLOT_STATUS_CARD_16) {
431 1.5 haya /* Unknown card... */
432 1.5 haya CARDSLOT_SET_CARDTYPE(sc->sc_status, CARDSLOT_STATUS_CARD_NONE);
433 1.1 haya }
434 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_NOTWORK);
435 1.1 haya break;
436 1.1 haya
437 1.1 haya case CARDSLOT_EVENT_REMOVAL_16:
438 1.1 haya DPRINTF(("%s: removal event\n", sc->sc_dev.dv_xname));
439 1.1 haya if (CARDSLOT_CARDTYPE(sc->sc_status) != CARDSLOT_STATUS_CARD_16) {
440 1.1 haya /* 16-bit card has not been inserted. */
441 1.1 haya break;
442 1.1 haya }
443 1.5 haya if ((sc->sc_16_softc != NULL)
444 1.5 haya && (CARDSLOT_WORK(sc->sc_status) == CARDSLOT_STATUS_WORKING)) {
445 1.1 haya struct pcmcia_softc *psc = sc->sc_16_softc;
446 1.1 haya
447 1.1 haya pcmcia_card_deactivate((struct device *)psc);
448 1.1 haya pcmcia_chip_socket_disable(psc->pct, psc->pch);
449 1.1 haya pcmcia_card_detach((struct device *)psc, DETACH_FORCE);
450 1.1 haya }
451 1.5 haya CARDSLOT_SET_CARDTYPE(sc->sc_status, CARDSLOT_STATUS_CARD_NONE);
452 1.5 haya CARDSLOT_SET_WORK(sc->sc_status, CARDSLOT_STATUS_NOTWORK);
453 1.1 haya break;
454 1.1 haya
455 1.1 haya default:
456 1.1 haya panic("cardslot_event_thread: unknown event %d", ce->ce_type);
457 1.1 haya }
458 1.1 haya free(ce, M_TEMP);
459 1.1 haya }
460 1.1 haya
461 1.1 haya sc->sc_event_thread = NULL;
462 1.1 haya
463 1.1 haya /* In case parent is waiting for us to exit. */
464 1.1 haya wakeup(sc);
465 1.1 haya
466 1.1 haya kthread_exit(0);
467 1.1 haya }
468