Skip to content

Commit

Permalink
[PATCH] pcmcia: new suspend core
Browse files Browse the repository at this point in the history
Move the suspend and resume methods out of the event handler, and into
special functions. Also use these functions for pre- and post-reset, as
almost all drivers already do, and the remaining ones can easily be
converted.

Bugfix to include/pcmcia/ds.c
Signed-off-by: Andrew Morton <[email protected]>

Signed-off-by: Dominik Brodowski <[email protected]>
  • Loading branch information
Dominik Brodowski committed Jan 5, 2006
1 parent 63e7ebd commit 98e4c28
Show file tree
Hide file tree
Showing 45 changed files with 1,431 additions and 991 deletions.
6 changes: 6 additions & 0 deletions Documentation/pcmcia/driver-changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
This file details changes in 2.6 which affect PCMCIA card driver authors:

* Move suspend, resume and reset out of event handler (as of 2.6.16)
int (*suspend) (struct pcmcia_device *dev);
int (*resume) (struct pcmcia_device *dev);
should be initialized in struct pcmcia_driver, and handle
(SUSPEND == RESET_PHYSICAL) and (RESUME == CARD_RESET) events

* event handler initialization in struct pcmcia_driver (as of 2.6.13)
The event handler is notified of all events, and must be initialized
as the event() callback in the driver's struct pcmcia_driver.
Expand Down
37 changes: 23 additions & 14 deletions drivers/bluetooth/bluecard_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,27 @@ static void bluecard_release(dev_link_t *link)
link->state &= ~DEV_CONFIG;
}

static int bluecard_suspend(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);

return 0;
}

static int bluecard_resume(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state &= ~DEV_SUSPEND;
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);

return 0;
}

static int bluecard_event(event_t event, int priority, event_callback_args_t *args)
{
Expand All @@ -1063,20 +1084,6 @@ static int bluecard_event(event_t event, int priority, event_callback_args_t *ar
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bluecard_config(link);
break;
case CS_EVENT_PM_SUSPEND:
link->state |= DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_RESET_PHYSICAL:
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
break;
case CS_EVENT_PM_RESUME:
link->state &= ~DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_CARD_RESET:
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
break;
}

return 0;
Expand All @@ -1099,6 +1106,8 @@ static struct pcmcia_driver bluecard_driver = {
.event = bluecard_event,
.detach = bluecard_detach,
.id_table = bluecard_ids,
.suspend = bluecard_suspend,
.resume = bluecard_resume,
};

static int __init init_bluecard_cs(void)
Expand Down
37 changes: 23 additions & 14 deletions drivers/bluetooth/bt3c_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,27 @@ static void bt3c_release(dev_link_t *link)
link->state &= ~DEV_CONFIG;
}

static int bt3c_suspend(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);

return 0;
}

static int bt3c_resume(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state &= ~DEV_SUSPEND;
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);

return 0;
}

static int bt3c_event(event_t event, int priority, event_callback_args_t *args)
{
Expand All @@ -909,20 +930,6 @@ static int bt3c_event(event_t event, int priority, event_callback_args_t *args)
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bt3c_config(link);
break;
case CS_EVENT_PM_SUSPEND:
link->state |= DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_RESET_PHYSICAL:
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
break;
case CS_EVENT_PM_RESUME:
link->state &= ~DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_CARD_RESET:
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
break;
}

return 0;
Expand All @@ -943,6 +950,8 @@ static struct pcmcia_driver bt3c_driver = {
.event = bt3c_event,
.detach = bt3c_detach,
.id_table = bt3c_ids,
.suspend = bt3c_suspend,
.resume = bt3c_resume,
};

static int __init init_bt3c_cs(void)
Expand Down
38 changes: 24 additions & 14 deletions drivers/bluetooth/btuart_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,28 @@ static void btuart_release(dev_link_t *link)
link->state &= ~DEV_CONFIG;
}

static int btuart_suspend(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);

return 0;
}

static int btuart_resume(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state &= ~DEV_SUSPEND;
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);

return 0;
}


static int btuart_event(event_t event, int priority, event_callback_args_t *args)
{
Expand All @@ -829,20 +851,6 @@ static int btuart_event(event_t event, int priority, event_callback_args_t *args
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
btuart_config(link);
break;
case CS_EVENT_PM_SUSPEND:
link->state |= DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_RESET_PHYSICAL:
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
break;
case CS_EVENT_PM_RESUME:
link->state &= ~DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_CARD_RESET:
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
break;
}

return 0;
Expand All @@ -863,6 +871,8 @@ static struct pcmcia_driver btuart_driver = {
.event = btuart_event,
.detach = btuart_detach,
.id_table = btuart_ids,
.suspend = btuart_suspend,
.resume = btuart_resume,
};

static int __init init_btuart_cs(void)
Expand Down
37 changes: 23 additions & 14 deletions drivers/bluetooth/dtl1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,27 @@ static void dtl1_release(dev_link_t *link)
link->state &= ~DEV_CONFIG;
}

static int dtl1_suspend(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);

return 0;
}

static int dtl1_resume(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);

link->state &= ~DEV_SUSPEND;
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);

return 0;
}

static int dtl1_event(event_t event, int priority, event_callback_args_t *args)
{
Expand All @@ -781,20 +802,6 @@ static int dtl1_event(event_t event, int priority, event_callback_args_t *args)
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
dtl1_config(link);
break;
case CS_EVENT_PM_SUSPEND:
link->state |= DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_RESET_PHYSICAL:
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
break;
case CS_EVENT_PM_RESUME:
link->state &= ~DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_CARD_RESET:
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
break;
}

return 0;
Expand All @@ -816,6 +823,8 @@ static struct pcmcia_driver dtl1_driver = {
.event = dtl1_event,
.detach = dtl1_detach,
.id_table = dtl1_ids,
.suspend = dtl1_suspend,
.resume = dtl1_resume,
};

static int __init init_dtl1_cs(void)
Expand Down
61 changes: 34 additions & 27 deletions drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1893,33 +1893,6 @@ static int cm4000_event(event_t event, int priority,
link->state &= ~DEV_PRESENT;
stop_monitor(dev);
break;
case CS_EVENT_PM_SUSPEND:
DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
"(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
link->state |= DEV_SUSPEND;
/* fall-through */
case CS_EVENT_RESET_PHYSICAL:
DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
if (link->state & DEV_CONFIG) {
DEBUGP(5, dev, "ReleaseConfiguration\n");
pcmcia_release_configuration(link->handle);
}
stop_monitor(dev);
break;
case CS_EVENT_PM_RESUME:
DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
"(fall-through to CS_EVENT_CARD_RESET)\n");
link->state &= ~DEV_SUSPEND;
/* fall-through */
case CS_EVENT_CARD_RESET:
DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
if ((link->state & DEV_CONFIG)) {
DEBUGP(5, dev, "RequestConfiguration\n");
pcmcia_request_configuration(link->handle, &link->conf);
}
if (link->open)
start_monitor(dev);
break;
default:
DEBUGP(5, dev, "unknown event %.2x\n", event);
break;
Expand All @@ -1928,6 +1901,38 @@ static int cm4000_event(event_t event, int priority,
return CS_SUCCESS;
}

static int cm4000_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
struct cm4000_dev *dev;

dev = link->priv;

link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
stop_monitor(dev);

return 0;
}

static int cm4000_resume(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
struct cm4000_dev *dev;

dev = link->priv;

link->state &= ~DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_request_configuration(link->handle, &link->conf);

if (link->open)
start_monitor(dev);

return 0;
}

static void cm4000_release(dev_link_t *link)
{
cmm_cm4000_release(link->priv); /* delay release until device closed */
Expand Down Expand Up @@ -2044,6 +2049,8 @@ static struct pcmcia_driver cm4000_driver = {
},
.attach = cm4000_attach,
.detach = cm4000_detach,
.suspend = cm4000_suspend,
.resume = cm4000_resume,
.event = cm4000_event,
.id_table = cm4000_ids,
};
Expand Down
50 changes: 25 additions & 25 deletions drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,31 +656,7 @@ static int reader_event(event_t event, int priority,
DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
link->state &= ~DEV_PRESENT;
break;
case CS_EVENT_PM_SUSPEND:
DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
"(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
link->state |= DEV_SUSPEND;

case CS_EVENT_RESET_PHYSICAL:
DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
if (link->state & DEV_CONFIG) {
DEBUGP(5, dev, "ReleaseConfiguration\n");
pcmcia_release_configuration(link->handle);
}
break;
case CS_EVENT_PM_RESUME:
DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
"(fall-through to CS_EVENT_CARD_RESET)\n");
link->state &= ~DEV_SUSPEND;

case CS_EVENT_CARD_RESET:
DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
if ((link->state & DEV_CONFIG)) {
DEBUGP(5, dev, "RequestConfiguration\n");
pcmcia_request_configuration(link->handle,
&link->conf);
}
break;

default:
DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
event);
Expand All @@ -690,6 +666,28 @@ static int reader_event(event_t event, int priority,
return CS_SUCCESS;
}

static int reader_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);

link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);

return 0;
}

static int reader_resume(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);

link->state &= ~DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_request_configuration(link->handle, &link->conf);

return 0;
}

static void reader_release(dev_link_t *link)
{
cm4040_reader_release(link->priv);
Expand Down Expand Up @@ -806,6 +804,8 @@ static struct pcmcia_driver reader_driver = {
},
.attach = reader_attach,
.detach = reader_detach,
.suspend = reader_suspend,
.resume = reader_resume,
.event = reader_event,
.id_table = cm4040_ids,
};
Expand Down
Loading

0 comments on commit 98e4c28

Please sign in to comment.