aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/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/char/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/char/pcmcia')
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c61
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c50
-rw-r--r--drivers/char/pcmcia/synclink_cs.c47
3 files changed, 88 insertions, 70 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 61681c9f3f72..05e93054c98c 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1893,33 +1893,6 @@ static int cm4000_event(event_t event, int priority,
1893 link->state &= ~DEV_PRESENT; 1893 link->state &= ~DEV_PRESENT;
1894 stop_monitor(dev); 1894 stop_monitor(dev);
1895 break; 1895 break;
1896 case CS_EVENT_PM_SUSPEND:
1897 DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
1898 "(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
1899 link->state |= DEV_SUSPEND;
1900 /* fall-through */
1901 case CS_EVENT_RESET_PHYSICAL:
1902 DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
1903 if (link->state & DEV_CONFIG) {
1904 DEBUGP(5, dev, "ReleaseConfiguration\n");
1905 pcmcia_release_configuration(link->handle);
1906 }
1907 stop_monitor(dev);
1908 break;
1909 case CS_EVENT_PM_RESUME:
1910 DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
1911 "(fall-through to CS_EVENT_CARD_RESET)\n");
1912 link->state &= ~DEV_SUSPEND;
1913 /* fall-through */
1914 case CS_EVENT_CARD_RESET:
1915 DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
1916 if ((link->state & DEV_CONFIG)) {
1917 DEBUGP(5, dev, "RequestConfiguration\n");
1918 pcmcia_request_configuration(link->handle, &link->conf);
1919 }
1920 if (link->open)
1921 start_monitor(dev);
1922 break;
1923 default: 1896 default:
1924 DEBUGP(5, dev, "unknown event %.2x\n", event); 1897 DEBUGP(5, dev, "unknown event %.2x\n", event);
1925 break; 1898 break;
@@ -1928,6 +1901,38 @@ static int cm4000_event(event_t event, int priority,
1928 return CS_SUCCESS; 1901 return CS_SUCCESS;
1929} 1902}
1930 1903
1904static int cm4000_suspend(struct pcmcia_device *p_dev)
1905{
1906 dev_link_t *link = dev_to_instance(p_dev);
1907 struct cm4000_dev *dev;
1908
1909 dev = link->priv;
1910
1911 link->state |= DEV_SUSPEND;
1912 if (link->state & DEV_CONFIG)
1913 pcmcia_release_configuration(link->handle);
1914 stop_monitor(dev);
1915
1916 return 0;
1917}
1918
1919static int cm4000_resume(struct pcmcia_device *p_dev)
1920{
1921 dev_link_t *link = dev_to_instance(p_dev);
1922 struct cm4000_dev *dev;
1923
1924 dev = link->priv;
1925
1926 link->state &= ~DEV_SUSPEND;
1927 if (link->state & DEV_CONFIG)
1928 pcmcia_request_configuration(link->handle, &link->conf);
1929
1930 if (link->open)
1931 start_monitor(dev);
1932
1933 return 0;
1934}
1935
1931static void cm4000_release(dev_link_t *link) 1936static void cm4000_release(dev_link_t *link)
1932{ 1937{
1933 cmm_cm4000_release(link->priv); /* delay release until device closed */ 1938 cmm_cm4000_release(link->priv); /* delay release until device closed */
@@ -2044,6 +2049,8 @@ static struct pcmcia_driver cm4000_driver = {
2044 }, 2049 },
2045 .attach = cm4000_attach, 2050 .attach = cm4000_attach,
2046 .detach = cm4000_detach, 2051 .detach = cm4000_detach,
2052 .suspend = cm4000_suspend,
2053 .resume = cm4000_resume,
2047 .event = cm4000_event, 2054 .event = cm4000_event,
2048 .id_table = cm4000_ids, 2055 .id_table = cm4000_ids,
2049}; 2056};
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 4c698d908ffa..3622fd39c47b 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -656,31 +656,7 @@ static int reader_event(event_t event, int priority,
656 DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n"); 656 DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
657 link->state &= ~DEV_PRESENT; 657 link->state &= ~DEV_PRESENT;
658 break; 658 break;
659 case CS_EVENT_PM_SUSPEND: 659
660 DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
661 "(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
662 link->state |= DEV_SUSPEND;
663
664 case CS_EVENT_RESET_PHYSICAL:
665 DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
666 if (link->state & DEV_CONFIG) {
667 DEBUGP(5, dev, "ReleaseConfiguration\n");
668 pcmcia_release_configuration(link->handle);
669 }
670 break;
671 case CS_EVENT_PM_RESUME:
672 DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
673 "(fall-through to CS_EVENT_CARD_RESET)\n");
674 link->state &= ~DEV_SUSPEND;
675
676 case CS_EVENT_CARD_RESET:
677 DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
678 if ((link->state & DEV_CONFIG)) {
679 DEBUGP(5, dev, "RequestConfiguration\n");
680 pcmcia_request_configuration(link->handle,
681 &link->conf);
682 }
683 break;
684 default: 660 default:
685 DEBUGP(5, dev, "reader_event: unknown event %.2x\n", 661 DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
686 event); 662 event);
@@ -690,6 +666,28 @@ static int reader_event(event_t event, int priority,
690 return CS_SUCCESS; 666 return CS_SUCCESS;
691} 667}
692 668
669static int reader_suspend(struct pcmcia_device *p_dev)
670{
671 dev_link_t *link = dev_to_instance(p_dev);
672
673 link->state |= DEV_SUSPEND;
674 if (link->state & DEV_CONFIG)
675 pcmcia_release_configuration(link->handle);
676
677 return 0;
678}
679
680static int reader_resume(struct pcmcia_device *p_dev)
681{
682 dev_link_t *link = dev_to_instance(p_dev);
683
684 link->state &= ~DEV_SUSPEND;
685 if (link->state & DEV_CONFIG)
686 pcmcia_request_configuration(link->handle, &link->conf);
687
688 return 0;
689}
690
693static void reader_release(dev_link_t *link) 691static void reader_release(dev_link_t *link)
694{ 692{
695 cm4040_reader_release(link->priv); 693 cm4040_reader_release(link->priv);
@@ -806,6 +804,8 @@ static struct pcmcia_driver reader_driver = {
806 }, 804 },
807 .attach = reader_attach, 805 .attach = reader_attach,
808 .detach = reader_detach, 806 .detach = reader_detach,
807 .suspend = reader_suspend,
808 .resume = reader_resume,
809 .event = reader_event, 809 .event = reader_event,
810 .id_table = cm4040_ids, 810 .id_table = cm4040_ids,
811}; 811};
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 2c326ea53421..776103e56042 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -773,11 +773,37 @@ static void mgslpc_detach(dev_link_t *link)
773 mgslpc_remove_device((MGSLPC_INFO *)link->priv); 773 mgslpc_remove_device((MGSLPC_INFO *)link->priv);
774} 774}
775 775
776static int mgslpc_suspend(struct pcmcia_device *dev)
777{
778 dev_link_t *link = dev_to_instance(dev);
779 MGSLPC_INFO *info = link->priv;
780
781 link->state |= DEV_SUSPEND;
782 info->stop = 1;
783 if (link->state & DEV_CONFIG)
784 pcmcia_release_configuration(link->handle);
785
786 return 0;
787}
788
789static int mgslpc_resume(struct pcmcia_device *dev)
790{
791 dev_link_t *link = dev_to_instance(dev);
792 MGSLPC_INFO *info = link->priv;
793
794 link->state &= ~DEV_SUSPEND;
795 if (link->state & DEV_CONFIG)
796 pcmcia_request_configuration(link->handle, &link->conf);
797 info->stop = 0;
798
799 return 0;
800}
801
802
776static int mgslpc_event(event_t event, int priority, 803static int mgslpc_event(event_t event, int priority,
777 event_callback_args_t *args) 804 event_callback_args_t *args)
778{ 805{
779 dev_link_t *link = args->client_data; 806 dev_link_t *link = args->client_data;
780 MGSLPC_INFO *info = link->priv;
781 807
782 if (debug_level >= DEBUG_LEVEL_INFO) 808 if (debug_level >= DEBUG_LEVEL_INFO)
783 printk("mgslpc_event(0x%06x)\n", event); 809 printk("mgslpc_event(0x%06x)\n", event);
@@ -794,23 +820,6 @@ static int mgslpc_event(event_t event, int priority,
794 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 820 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
795 mgslpc_config(link); 821 mgslpc_config(link);
796 break; 822 break;
797 case CS_EVENT_PM_SUSPEND:
798 link->state |= DEV_SUSPEND;
799 /* Fall through... */
800 case CS_EVENT_RESET_PHYSICAL:
801 /* Mark the device as stopped, to block IO until later */
802 info->stop = 1;
803 if (link->state & DEV_CONFIG)
804 pcmcia_release_configuration(link->handle);
805 break;
806 case CS_EVENT_PM_RESUME:
807 link->state &= ~DEV_SUSPEND;
808 /* Fall through... */
809 case CS_EVENT_CARD_RESET:
810 if (link->state & DEV_CONFIG)
811 pcmcia_request_configuration(link->handle, &link->conf);
812 info->stop = 0;
813 break;
814 } 823 }
815 return 0; 824 return 0;
816} 825}
@@ -3095,6 +3104,8 @@ static struct pcmcia_driver mgslpc_driver = {
3095 .event = mgslpc_event, 3104 .event = mgslpc_event,
3096 .detach = mgslpc_detach, 3105 .detach = mgslpc_detach,
3097 .id_table = mgslpc_ids, 3106 .id_table = mgslpc_ids,
3107 .suspend = mgslpc_suspend,
3108 .resume = mgslpc_resume,
3098}; 3109};
3099 3110
3100static struct tty_operations mgslpc_ops = { 3111static struct tty_operations mgslpc_ops = {