]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/scsi/pcmcia/nsp_cs.c
[PATCH] pcmcia: new suspend core
[mirror_ubuntu-bionic-kernel.git] / drivers / scsi / pcmcia / nsp_cs.c
index 050ea13ff80b3d4ef86bd9e238cf62478ed65f53..870e87180d12e3c9b0875b8b49c01d86c37eff6d 100644 (file)
@@ -2021,6 +2021,59 @@ static void nsp_cs_release(dev_link_t *link)
 #endif
 } /* nsp_cs_release */
 
+static int nsp_cs_suspend(struct pcmcia_device *dev)
+{
+       dev_link_t *link = dev_to_instance(dev);
+       scsi_info_t *info = link->priv;
+       nsp_hw_data *data;
+
+       link->state |= DEV_SUSPEND;
+
+       nsp_dbg(NSP_DEBUG_INIT, "event: suspend");
+
+       if (info->host != NULL) {
+               nsp_msg(KERN_INFO, "clear SDTR status");
+
+               data = (nsp_hw_data *)info->host->hostdata;
+
+               nsphw_init_sync(data);
+       }
+
+       info->stop = 1;
+
+       if (link->state & DEV_CONFIG)
+               pcmcia_release_configuration(link->handle);
+
+       return 0;
+}
+
+static int nsp_cs_resume(struct pcmcia_device *dev)
+{
+       dev_link_t *link = dev_to_instance(dev);
+       scsi_info_t *info = link->priv;
+       nsp_hw_data *data;
+
+       nsp_dbg(NSP_DEBUG_INIT, "event: resume");
+
+       link->state &= ~DEV_SUSPEND;
+
+       if (link->state & DEV_CONFIG)
+               pcmcia_request_configuration(link->handle, &link->conf);
+
+       info->stop = 0;
+
+       if (info->host != NULL) {
+               nsp_msg(KERN_INFO, "reset host and bus");
+
+               data = (nsp_hw_data *)info->host->hostdata;
+
+               nsphw_init   (data);
+               nsp_bus_reset(data);
+       }
+
+       return 0;
+}
+
 /*======================================================================
 
     The card status event handler.  Mostly, this schedules other
@@ -2039,8 +2092,6 @@ static int nsp_cs_event(event_t                  event,
                        event_callback_args_t *args)
 {
        dev_link_t  *link = args->client_data;
-       scsi_info_t *info = link->priv;
-       nsp_hw_data *data;
 
        nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event);
 
@@ -2062,51 +2113,6 @@ static int nsp_cs_event(event_t                 event,
 #endif
                nsp_cs_config(link);
                break;
-
-       case CS_EVENT_PM_SUSPEND:
-               nsp_dbg(NSP_DEBUG_INIT, "event: suspend");
-               link->state |= DEV_SUSPEND;
-               /* Fall through... */
-       case CS_EVENT_RESET_PHYSICAL:
-               /* Mark the device as stopped, to block IO until later */
-               nsp_dbg(NSP_DEBUG_INIT, "event: reset physical");
-
-               if (info->host != NULL) {
-                       nsp_msg(KERN_INFO, "clear SDTR status");
-
-                       data = (nsp_hw_data *)info->host->hostdata;
-
-                       nsphw_init_sync(data);
-               }
-
-               info->stop = 1;
-               if (link->state & DEV_CONFIG) {
-                       pcmcia_release_configuration(link->handle);
-               }
-               break;
-
-       case CS_EVENT_PM_RESUME:
-               nsp_dbg(NSP_DEBUG_INIT, "event: resume");
-               link->state &= ~DEV_SUSPEND;
-               /* Fall through... */
-       case CS_EVENT_CARD_RESET:
-               nsp_dbg(NSP_DEBUG_INIT, "event: reset");
-               if (link->state & DEV_CONFIG) {
-                       pcmcia_request_configuration(link->handle, &link->conf);
-               }
-               info->stop = 0;
-
-               if (info->host != NULL) {
-                       nsp_msg(KERN_INFO, "reset host and bus");
-
-                       data = (nsp_hw_data *)info->host->hostdata;
-
-                       nsphw_init   (data);
-                       nsp_bus_reset(data);
-               }
-
-               break;
-
        default:
                nsp_dbg(NSP_DEBUG_INIT, "event: unknown");
                break;
@@ -2140,6 +2146,8 @@ static struct pcmcia_driver nsp_driver = {
        .event          = nsp_cs_event,
        .detach         = nsp_cs_detach,
        .id_table       = nsp_cs_ids,
+       .suspend        = nsp_cs_suspend,
+       .resume         = nsp_cs_resume,
 };
 #endif