aboutsummaryrefslogtreecommitdiff
path: root/sys/pccard/pccard.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2001-07-27 07:21:42 +0000
committerWarner Losh <imp@FreeBSD.org>2001-07-27 07:21:42 +0000
commitc1c1a23f53a5b8b9f42ff9e44be3b88049853e62 (patch)
tree5b691587f87ab221ca6af7189cb77ce890ed6ca1 /sys/pccard/pccard.c
parent7d978ff75415cf8d51d4709233b2729cc8a0b664 (diff)
Attempt to fix and document interactions between suspend/resume and pccardc
power x 0. pccardc power x 0 used to disable the slot. But a suspend/resume would reactivate the pccard. It no longer does that. Now the disabling of the slot is sticy until it is reset with power x 1 or the card is ejected. This seems closer to correct behavior to me. o Process all card state changes the same using pccard_do_stat_change(). o Cleanup disabling the card so that we can preserve the state after the change. Basically, don't set it to empty as often as we do. o On suspend, the new state is "empty" and the laststate is "suspend" o Document state machine with a diagram of states and edges. The edges are labeld to tell the reader what event causes the external state changes. o "machdep.pccard.pcic_resume_reset" may be obsolete now. We always call the bridge driver's resume method on resume now. Otherwise cards won't automatically show up. If it needs to stay, I'll add it back.
Notes
Notes: svn path=/head/; revision=80438
Diffstat (limited to 'sys/pccard/pccard.c')
-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 49c492cf3762..274918d5aae3 100644
--- a/sys/pccard/pccard.c
+++ b/sys/pccard/pccard.c
@@ -55,6 +55,7 @@
SYSCTL_NODE(_machdep, OID_AUTO, pccard, CTLFLAG_RW, 0, "pccard");
+/* The following might now be obsolete */
static int pcic_resume_reset = 1;
SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
@@ -165,9 +166,13 @@ disable_slot(struct slot *slt)
static void
disable_slot_to(struct slot *slt)
{
- slt->state = empty;
+ int wasinactive;
+
disable_slot(slt);
- printf("pccard: card removed, slot %d\n", slt->slotnum);
+ if (slt->state == empty)
+ printf("pccard: card removed, slot %d\n", slt->slotnum);
+ else
+ printf("pccard: card deactivated, slot %d\n", slt->slotnum);
pccard_remove_beep();
selwakeup(&slt->selp);
}
@@ -300,12 +305,12 @@ pccard_event(struct slot *slt, enum card_event event)
switch(event) {
case card_removed:
- /*
- * The slot and devices are disabled, but the
- * data structures are not unlinked.
- */
+ case card_deactivated:
if (slt->state == filled || slt->state == inactive) {
- slt->state = empty;
+ if (event == card_removed)
+ slt->state = empty;
+ else
+ slt->state = inactive;
disable_slot_to(slt);
}
break;
@@ -616,8 +621,7 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p)
if (!pwval) {
if (slt->state != filled)
return (EINVAL);
- pccard_event(slt, card_removed);
- slt->state = inactive;
+ pccard_event(slt, card_deactivated);
} else {
if (slt->state != empty && slt->state != inactive)
return (EINVAL);
@@ -678,10 +682,10 @@ pccard_suspend(device_t dev)
/* This code stolen from pccard_event:card_removed */
if (slt->state == filled) {
- int s = splhigh();
+ int s = splhigh(); /* nop on current */
disable_slot(slt);
- slt->laststate = filled;
- slt->state = suspend;
+ slt->laststate = suspend; /* for pccardd */
+ slt->state = empty;
splx(s);
printf("pccard: card disabled, slot %d\n", slt->slotnum);
}
@@ -699,16 +703,5 @@ pccard_resume(device_t dev)
{
struct slot *slt = PCCARD_DEVICE2SOFTC(dev);
- if (pcic_resume_reset)
- slt->ctrl->resume(slt);
- /* This code stolen from pccard_event:card_inserted */
- if (slt->state == suspend) {
- slt->laststate = suspend;
- slt->state = empty;
- slt->insert_seq = 1;
- untimeout(inserted, (void *)slt, slt->insert_ch);
- inserted((void *) slt);
- selwakeup(&slt->selp);
- }
- return (0);
+ slt->ctrl->resume(slt);
}