aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 15:21:18 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-05 17:59:02 -0500
commit98e4c28b7ec390c2dad6a4c69d69629c0f7e8b10 (patch)
treeb3d46f0643352e541d6a39e6da09059687cf713d /drivers/scsi/pcmcia
parent63e7ebd06402951bc8863ba5b7bc9b9f42044849 (diff)
[PATCH] pcmcia: new suspend core
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 <akpm@osdl.org> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/scsi/pcmcia')
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c48
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c42
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c102
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c59
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c69
5 files changed, 186 insertions, 134 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 7c5306499832..82988a3e35ec 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -272,11 +272,37 @@ static void aha152x_release_cs(dev_link_t *link)
272 link->state &= ~DEV_CONFIG; 272 link->state &= ~DEV_CONFIG;
273} 273}
274 274
275static int aha152x_suspend(struct pcmcia_device *dev)
276{
277 dev_link_t *link = dev_to_instance(dev);
278
279 link->state |= DEV_SUSPEND;
280 if (link->state & DEV_CONFIG)
281 pcmcia_release_configuration(link->handle);
282
283 return 0;
284}
285
286static int aha152x_resume(struct pcmcia_device *dev)
287{
288 dev_link_t *link = dev_to_instance(dev);
289 scsi_info_t *info = link->priv;
290
291 link->state &= ~DEV_SUSPEND;
292 if (link->state & DEV_CONFIG) {
293 Scsi_Cmnd tmp;
294 pcmcia_request_configuration(link->handle, &link->conf);
295 tmp.device->host = info->host;
296 aha152x_host_reset(&tmp);
297 }
298
299 return 0;
300}
301
275static int aha152x_event(event_t event, int priority, 302static int aha152x_event(event_t event, int priority,
276 event_callback_args_t *args) 303 event_callback_args_t *args)
277{ 304{
278 dev_link_t *link = args->client_data; 305 dev_link_t *link = args->client_data;
279 scsi_info_t *info = link->priv;
280 306
281 DEBUG(0, "aha152x_event(0x%06x)\n", event); 307 DEBUG(0, "aha152x_event(0x%06x)\n", event);
282 308
@@ -290,24 +316,6 @@ static int aha152x_event(event_t event, int priority,
290 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 316 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
291 aha152x_config_cs(link); 317 aha152x_config_cs(link);
292 break; 318 break;
293 case CS_EVENT_PM_SUSPEND:
294 link->state |= DEV_SUSPEND;
295 /* Fall through... */
296 case CS_EVENT_RESET_PHYSICAL:
297 if (link->state & DEV_CONFIG)
298 pcmcia_release_configuration(link->handle);
299 break;
300 case CS_EVENT_PM_RESUME:
301 link->state &= ~DEV_SUSPEND;
302 /* Fall through... */
303 case CS_EVENT_CARD_RESET:
304 if (link->state & DEV_CONFIG) {
305 Scsi_Cmnd tmp;
306 pcmcia_request_configuration(link->handle, &link->conf);
307 tmp.device->host = info->host;
308 aha152x_host_reset(&tmp);
309 }
310 break;
311 } 319 }
312 return 0; 320 return 0;
313} 321}
@@ -331,6 +339,8 @@ static struct pcmcia_driver aha152x_cs_driver = {
331 .event = aha152x_event, 339 .event = aha152x_event,
332 .detach = aha152x_detach, 340 .detach = aha152x_detach,
333 .id_table = aha152x_ids, 341 .id_table = aha152x_ids,
342 .suspend = aha152x_suspend,
343 .resume = aha152x_resume,
334}; 344};
335 345
336static int __init init_aha152x_cs(void) 346static int __init init_aha152x_cs(void)
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index db8f5cd85ffe..9e1d68c14694 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -256,6 +256,30 @@ static void fdomain_release(dev_link_t *link)
256 256
257/*====================================================================*/ 257/*====================================================================*/
258 258
259static int fdomain_suspend(struct pcmcia_device *dev)
260{
261 dev_link_t *link = dev_to_instance(dev);
262
263 link->state |= DEV_SUSPEND;
264 if (link->state & DEV_CONFIG)
265 pcmcia_release_configuration(link->handle);
266
267 return 0;
268}
269
270static int fdomain_resume(struct pcmcia_device *dev)
271{
272 dev_link_t *link = dev_to_instance(dev);
273
274 link->state &= ~DEV_SUSPEND;
275 if (link->state & DEV_CONFIG) {
276 pcmcia_request_configuration(link->handle, &link->conf);
277 fdomain_16x0_bus_reset(NULL);
278 }
279
280 return 0;
281}
282
259static int fdomain_event(event_t event, int priority, 283static int fdomain_event(event_t event, int priority,
260 event_callback_args_t *args) 284 event_callback_args_t *args)
261{ 285{
@@ -273,22 +297,6 @@ static int fdomain_event(event_t event, int priority,
273 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 297 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
274 fdomain_config(link); 298 fdomain_config(link);
275 break; 299 break;
276 case CS_EVENT_PM_SUSPEND:
277 link->state |= DEV_SUSPEND;
278 /* Fall through... */
279 case CS_EVENT_RESET_PHYSICAL:
280 if (link->state & DEV_CONFIG)
281 pcmcia_release_configuration(link->handle);
282 break;
283 case CS_EVENT_PM_RESUME:
284 link->state &= ~DEV_SUSPEND;
285 /* Fall through... */
286 case CS_EVENT_CARD_RESET:
287 if (link->state & DEV_CONFIG) {
288 pcmcia_request_configuration(link->handle, &link->conf);
289 fdomain_16x0_bus_reset(NULL);
290 }
291 break;
292 } 300 }
293 return 0; 301 return 0;
294} /* fdomain_event */ 302} /* fdomain_event */
@@ -311,6 +319,8 @@ static struct pcmcia_driver fdomain_cs_driver = {
311 .event = fdomain_event, 319 .event = fdomain_event,
312 .detach = fdomain_detach, 320 .detach = fdomain_detach,
313 .id_table = fdomain_ids, 321 .id_table = fdomain_ids,
322 .suspend = fdomain_suspend,
323 .resume = fdomain_resume,
314}; 324};
315 325
316static int __init init_fdomain_cs(void) 326static int __init init_fdomain_cs(void)
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 050ea13ff80b..870e87180d12 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -2021,6 +2021,59 @@ static void nsp_cs_release(dev_link_t *link)
2021#endif 2021#endif
2022} /* nsp_cs_release */ 2022} /* nsp_cs_release */
2023 2023
2024static int nsp_cs_suspend(struct pcmcia_device *dev)
2025{
2026 dev_link_t *link = dev_to_instance(dev);
2027 scsi_info_t *info = link->priv;
2028 nsp_hw_data *data;
2029
2030 link->state |= DEV_SUSPEND;
2031
2032 nsp_dbg(NSP_DEBUG_INIT, "event: suspend");
2033
2034 if (info->host != NULL) {
2035 nsp_msg(KERN_INFO, "clear SDTR status");
2036
2037 data = (nsp_hw_data *)info->host->hostdata;
2038
2039 nsphw_init_sync(data);
2040 }
2041
2042 info->stop = 1;
2043
2044 if (link->state & DEV_CONFIG)
2045 pcmcia_release_configuration(link->handle);
2046
2047 return 0;
2048}
2049
2050static int nsp_cs_resume(struct pcmcia_device *dev)
2051{
2052 dev_link_t *link = dev_to_instance(dev);
2053 scsi_info_t *info = link->priv;
2054 nsp_hw_data *data;
2055
2056 nsp_dbg(NSP_DEBUG_INIT, "event: resume");
2057
2058 link->state &= ~DEV_SUSPEND;
2059
2060 if (link->state & DEV_CONFIG)
2061 pcmcia_request_configuration(link->handle, &link->conf);
2062
2063 info->stop = 0;
2064
2065 if (info->host != NULL) {
2066 nsp_msg(KERN_INFO, "reset host and bus");
2067
2068 data = (nsp_hw_data *)info->host->hostdata;
2069
2070 nsphw_init (data);
2071 nsp_bus_reset(data);
2072 }
2073
2074 return 0;
2075}
2076
2024/*====================================================================== 2077/*======================================================================
2025 2078
2026 The card status event handler. Mostly, this schedules other 2079 The card status event handler. Mostly, this schedules other
@@ -2039,8 +2092,6 @@ static int nsp_cs_event(event_t event,
2039 event_callback_args_t *args) 2092 event_callback_args_t *args)
2040{ 2093{
2041 dev_link_t *link = args->client_data; 2094 dev_link_t *link = args->client_data;
2042 scsi_info_t *info = link->priv;
2043 nsp_hw_data *data;
2044 2095
2045 nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); 2096 nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event);
2046 2097
@@ -2062,51 +2113,6 @@ static int nsp_cs_event(event_t event,
2062#endif 2113#endif
2063 nsp_cs_config(link); 2114 nsp_cs_config(link);
2064 break; 2115 break;
2065
2066 case CS_EVENT_PM_SUSPEND:
2067 nsp_dbg(NSP_DEBUG_INIT, "event: suspend");
2068 link->state |= DEV_SUSPEND;
2069 /* Fall through... */
2070 case CS_EVENT_RESET_PHYSICAL:
2071 /* Mark the device as stopped, to block IO until later */
2072 nsp_dbg(NSP_DEBUG_INIT, "event: reset physical");
2073
2074 if (info->host != NULL) {
2075 nsp_msg(KERN_INFO, "clear SDTR status");
2076
2077 data = (nsp_hw_data *)info->host->hostdata;
2078
2079 nsphw_init_sync(data);
2080 }
2081
2082 info->stop = 1;
2083 if (link->state & DEV_CONFIG) {
2084 pcmcia_release_configuration(link->handle);
2085 }
2086 break;
2087
2088 case CS_EVENT_PM_RESUME:
2089 nsp_dbg(NSP_DEBUG_INIT, "event: resume");
2090 link->state &= ~DEV_SUSPEND;
2091 /* Fall through... */
2092 case CS_EVENT_CARD_RESET:
2093 nsp_dbg(NSP_DEBUG_INIT, "event: reset");
2094 if (link->state & DEV_CONFIG) {
2095 pcmcia_request_configuration(link->handle, &link->conf);
2096 }
2097 info->stop = 0;
2098
2099 if (info->host != NULL) {
2100 nsp_msg(KERN_INFO, "reset host and bus");
2101
2102 data = (nsp_hw_data *)info->host->hostdata;
2103
2104 nsphw_init (data);
2105 nsp_bus_reset(data);
2106 }
2107
2108 break;
2109
2110 default: 2116 default:
2111 nsp_dbg(NSP_DEBUG_INIT, "event: unknown"); 2117 nsp_dbg(NSP_DEBUG_INIT, "event: unknown");
2112 break; 2118 break;
@@ -2140,6 +2146,8 @@ static struct pcmcia_driver nsp_driver = {
2140 .event = nsp_cs_event, 2146 .event = nsp_cs_event,
2141 .detach = nsp_cs_detach, 2147 .detach = nsp_cs_detach,
2142 .id_table = nsp_cs_ids, 2148 .id_table = nsp_cs_ids,
2149 .suspend = nsp_cs_suspend,
2150 .resume = nsp_cs_resume,
2143}; 2151};
2144#endif 2152#endif
2145 2153
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index bb091a45a880..2541a999a0e5 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -349,6 +349,40 @@ static void qlogic_release(dev_link_t *link)
349 349
350/*====================================================================*/ 350/*====================================================================*/
351 351
352static int qlogic_suspend(struct pcmcia_device *dev)
353{
354 dev_link_t *link = dev_to_instance(dev);
355
356 link->state |= DEV_SUSPEND;
357 if (link->state & DEV_CONFIG)
358 pcmcia_release_configuration(link->handle);
359
360 return 0;
361}
362
363static int qlogic_resume(struct pcmcia_device *dev)
364{
365 dev_link_t *link = dev_to_instance(dev);
366
367 link->state &= ~DEV_SUSPEND;
368 if (link->state & DEV_CONFIG) {
369 scsi_info_t *info = link->priv;
370
371 pcmcia_request_configuration(link->handle, &link->conf);
372 if ((info->manf_id == MANFID_MACNICA) ||
373 (info->manf_id == MANFID_PIONEER) ||
374 (info->manf_id == 0x0098)) {
375 outb(0x80, link->io.BasePort1 + 0xd);
376 outb(0x24, link->io.BasePort1 + 0x9);
377 outb(0x04, link->io.BasePort1 + 0xd);
378 }
379 /* Ugggglllyyyy!!! */
380 qlogicfas408_bus_reset(NULL);
381 }
382
383 return 0;
384}
385
352static int qlogic_event(event_t event, int priority, event_callback_args_t * args) 386static int qlogic_event(event_t event, int priority, event_callback_args_t * args)
353{ 387{
354 dev_link_t *link = args->client_data; 388 dev_link_t *link = args->client_data;
@@ -365,29 +399,6 @@ static int qlogic_event(event_t event, int priority, event_callback_args_t * arg
365 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 399 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
366 qlogic_config(link); 400 qlogic_config(link);
367 break; 401 break;
368 case CS_EVENT_PM_SUSPEND:
369 link->state |= DEV_SUSPEND;
370 /* Fall through... */
371 case CS_EVENT_RESET_PHYSICAL:
372 if (link->state & DEV_CONFIG)
373 pcmcia_release_configuration(link->handle);
374 break;
375 case CS_EVENT_PM_RESUME:
376 link->state &= ~DEV_SUSPEND;
377 /* Fall through... */
378 case CS_EVENT_CARD_RESET:
379 if (link->state & DEV_CONFIG) {
380 scsi_info_t *info = link->priv;
381 pcmcia_request_configuration(link->handle, &link->conf);
382 if ((info->manf_id == MANFID_MACNICA) || (info->manf_id == MANFID_PIONEER) || (info->manf_id == 0x0098)) {
383 outb(0x80, link->io.BasePort1 + 0xd);
384 outb(0x24, link->io.BasePort1 + 0x9);
385 outb(0x04, link->io.BasePort1 + 0xd);
386 }
387 /* Ugggglllyyyy!!! */
388 qlogicfas408_bus_reset(NULL);
389 }
390 break;
391 } 402 }
392 return 0; 403 return 0;
393} /* qlogic_event */ 404} /* qlogic_event */
@@ -423,6 +434,8 @@ static struct pcmcia_driver qlogic_cs_driver = {
423 .event = qlogic_event, 434 .event = qlogic_event,
424 .detach = qlogic_detach, 435 .detach = qlogic_detach,
425 .id_table = qlogic_ids, 436 .id_table = qlogic_ids,
437 .suspend = qlogic_suspend,
438 .resume = qlogic_resume,
426}; 439};
427 440
428static int __init init_qlogic_cs(void) 441static int __init init_qlogic_cs(void)
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 98b64b2aa8ee..c4e3e2294c66 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -872,11 +872,48 @@ cs_failed:
872 return; 872 return;
873} /* SYM53C500_config */ 873} /* SYM53C500_config */
874 874
875static int sym53c500_suspend(struct pcmcia_device *dev)
876{
877 dev_link_t *link = dev_to_instance(dev);
878
879 link->state |= DEV_SUSPEND;
880 if (link->state & DEV_CONFIG)
881 pcmcia_release_configuration(link->handle);
882
883 return 0;
884}
885
886static int sym53c500_resume(struct pcmcia_device *dev)
887{
888 dev_link_t *link = dev_to_instance(dev);
889 struct scsi_info_t *info = link->priv;
890
891 link->state &= ~DEV_SUSPEND;
892 if (link->state & DEV_CONFIG) {
893 pcmcia_request_configuration(link->handle, &link->conf);
894
895 /* See earlier comment about manufacturer IDs. */
896 if ((info->manf_id == MANFID_MACNICA) ||
897 (info->manf_id == MANFID_PIONEER) ||
898 (info->manf_id == 0x0098)) {
899 outb(0x80, link->io.BasePort1 + 0xd);
900 outb(0x24, link->io.BasePort1 + 0x9);
901 outb(0x04, link->io.BasePort1 + 0xd);
902 }
903 /*
904 * If things don't work after a "resume",
905 * this is a good place to start looking.
906 */
907 SYM53C500_int_host_reset(link->io.BasePort1);
908 }
909
910 return 0;
911}
912
875static int 913static int
876SYM53C500_event(event_t event, int priority, event_callback_args_t *args) 914SYM53C500_event(event_t event, int priority, event_callback_args_t *args)
877{ 915{
878 dev_link_t *link = args->client_data; 916 dev_link_t *link = args->client_data;
879 struct scsi_info_t *info = link->priv;
880 917
881 DEBUG(1, "SYM53C500_event(0x%06x)\n", event); 918 DEBUG(1, "SYM53C500_event(0x%06x)\n", event);
882 919
@@ -890,34 +927,6 @@ SYM53C500_event(event_t event, int priority, event_callback_args_t *args)
890 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 927 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
891 SYM53C500_config(link); 928 SYM53C500_config(link);
892 break; 929 break;
893 case CS_EVENT_PM_SUSPEND:
894 link->state |= DEV_SUSPEND;
895 /* Fall through... */
896 case CS_EVENT_RESET_PHYSICAL:
897 if (link->state & DEV_CONFIG)
898 pcmcia_release_configuration(link->handle);
899 break;
900 case CS_EVENT_PM_RESUME:
901 link->state &= ~DEV_SUSPEND;
902 /* Fall through... */
903 case CS_EVENT_CARD_RESET:
904 if (link->state & DEV_CONFIG) {
905 pcmcia_request_configuration(link->handle, &link->conf);
906 /* See earlier comment about manufacturer IDs. */
907 if ((info->manf_id == MANFID_MACNICA) ||
908 (info->manf_id == MANFID_PIONEER) ||
909 (info->manf_id == 0x0098)) {
910 outb(0x80, link->io.BasePort1 + 0xd);
911 outb(0x24, link->io.BasePort1 + 0x9);
912 outb(0x04, link->io.BasePort1 + 0xd);
913 }
914 /*
915 * If things don't work after a "resume",
916 * this is a good place to start looking.
917 */
918 SYM53C500_int_host_reset(link->io.BasePort1);
919 }
920 break;
921 } 930 }
922 return 0; 931 return 0;
923} /* SYM53C500_event */ 932} /* SYM53C500_event */
@@ -1012,6 +1021,8 @@ static struct pcmcia_driver sym53c500_cs_driver = {
1012 .event = SYM53C500_event, 1021 .event = SYM53C500_event,
1013 .detach = SYM53C500_detach, 1022 .detach = SYM53C500_detach,
1014 .id_table = sym53c500_ids, 1023 .id_table = sym53c500_ids,
1024 .suspend = sym53c500_suspend,
1025 .resume = sym53c500_resume,
1015}; 1026};
1016 1027
1017static int __init 1028static int __init