diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-01-17 12:31:34 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-02-17 11:48:22 -0500 |
commit | 94a819f80297e1f635a7cde4ed5317612e512ba7 (patch) | |
tree | 9bbb1eab3a0f0c722fe40295fb512d99cc0190d9 /drivers/pcmcia/ds.c | |
parent | 3d068261854b00c930df4516cd617900935e7706 (diff) |
pcmcia: assert locking to struct pcmcia_device
Tested-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r-- | drivers/pcmcia/ds.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 4c40db8889d9..83b51ddd3da3 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -835,6 +835,8 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
835 | } | 835 | } |
836 | 836 | ||
837 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { | 837 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { |
838 | int ret; | ||
839 | |||
838 | if ((!dev->has_func_id) || (dev->func_id != did->func_id)) | 840 | if ((!dev->has_func_id) || (dev->func_id != did->func_id)) |
839 | return 0; | 841 | return 0; |
840 | 842 | ||
@@ -849,10 +851,15 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
849 | * after it has re-checked that there is no possible module | 851 | * after it has re-checked that there is no possible module |
850 | * with a prod_id/manf_id/card_id match. | 852 | * with a prod_id/manf_id/card_id match. |
851 | */ | 853 | */ |
852 | dev_dbg(&dev->dev, | 854 | mutex_lock(&dev->socket->ops_mutex); |
853 | "skipping FUNC_ID match until userspace interaction\n"); | 855 | ret = dev->allow_func_id_match; |
854 | if (!dev->allow_func_id_match) | 856 | mutex_unlock(&dev->socket->ops_mutex); |
857 | |||
858 | if (!ret) { | ||
859 | dev_dbg(&dev->dev, | ||
860 | "skipping FUNC_ID match until userspace ACK\n"); | ||
855 | return 0; | 861 | return 0; |
862 | } | ||
856 | } | 863 | } |
857 | 864 | ||
858 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { | 865 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { |
@@ -1079,9 +1086,9 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev, | |||
1079 | if (!count) | 1086 | if (!count) |
1080 | return -EINVAL; | 1087 | return -EINVAL; |
1081 | 1088 | ||
1082 | mutex_lock(&p_dev->socket->skt_mutex); | 1089 | mutex_lock(&p_dev->socket->ops_mutex); |
1083 | p_dev->allow_func_id_match = 1; | 1090 | p_dev->allow_func_id_match = 1; |
1084 | mutex_unlock(&p_dev->socket->skt_mutex); | 1091 | mutex_unlock(&p_dev->socket->ops_mutex); |
1085 | 1092 | ||
1086 | ret = bus_rescan_devices(&pcmcia_bus_type); | 1093 | ret = bus_rescan_devices(&pcmcia_bus_type); |
1087 | if (ret) | 1094 | if (ret) |
@@ -1114,8 +1121,13 @@ static int pcmcia_dev_suspend(struct device *dev, pm_message_t state) | |||
1114 | struct pcmcia_driver *p_drv = NULL; | 1121 | struct pcmcia_driver *p_drv = NULL; |
1115 | int ret = 0; | 1122 | int ret = 0; |
1116 | 1123 | ||
1117 | if (p_dev->suspended) | 1124 | mutex_lock(&p_dev->socket->ops_mutex); |
1125 | if (p_dev->suspended) { | ||
1126 | mutex_unlock(&p_dev->socket->ops_mutex); | ||
1118 | return 0; | 1127 | return 0; |
1128 | } | ||
1129 | p_dev->suspended = 1; | ||
1130 | mutex_unlock(&p_dev->socket->ops_mutex); | ||
1119 | 1131 | ||
1120 | dev_dbg(dev, "suspending\n"); | 1132 | dev_dbg(dev, "suspending\n"); |
1121 | 1133 | ||
@@ -1132,6 +1144,9 @@ static int pcmcia_dev_suspend(struct device *dev, pm_message_t state) | |||
1132 | "pcmcia: device %s (driver %s) did " | 1144 | "pcmcia: device %s (driver %s) did " |
1133 | "not want to go to sleep (%d)\n", | 1145 | "not want to go to sleep (%d)\n", |
1134 | p_dev->devname, p_drv->drv.name, ret); | 1146 | p_dev->devname, p_drv->drv.name, ret); |
1147 | mutex_lock(&p_dev->socket->ops_mutex); | ||
1148 | p_dev->suspended = 0; | ||
1149 | mutex_unlock(&p_dev->socket->ops_mutex); | ||
1135 | goto out; | 1150 | goto out; |
1136 | } | 1151 | } |
1137 | } | 1152 | } |
@@ -1142,8 +1157,6 @@ static int pcmcia_dev_suspend(struct device *dev, pm_message_t state) | |||
1142 | } | 1157 | } |
1143 | 1158 | ||
1144 | out: | 1159 | out: |
1145 | if (!ret) | ||
1146 | p_dev->suspended = 1; | ||
1147 | return ret; | 1160 | return ret; |
1148 | } | 1161 | } |
1149 | 1162 | ||
@@ -1154,8 +1167,13 @@ static int pcmcia_dev_resume(struct device *dev) | |||
1154 | struct pcmcia_driver *p_drv = NULL; | 1167 | struct pcmcia_driver *p_drv = NULL; |
1155 | int ret = 0; | 1168 | int ret = 0; |
1156 | 1169 | ||
1157 | if (!p_dev->suspended) | 1170 | mutex_lock(&p_dev->socket->ops_mutex); |
1171 | if (!p_dev->suspended) { | ||
1172 | mutex_unlock(&p_dev->socket->ops_mutex); | ||
1158 | return 0; | 1173 | return 0; |
1174 | } | ||
1175 | p_dev->suspended = 0; | ||
1176 | mutex_unlock(&p_dev->socket->ops_mutex); | ||
1159 | 1177 | ||
1160 | dev_dbg(dev, "resuming\n"); | 1178 | dev_dbg(dev, "resuming\n"); |
1161 | 1179 | ||
@@ -1176,8 +1194,6 @@ static int pcmcia_dev_resume(struct device *dev) | |||
1176 | ret = p_drv->resume(p_dev); | 1194 | ret = p_drv->resume(p_dev); |
1177 | 1195 | ||
1178 | out: | 1196 | out: |
1179 | if (!ret) | ||
1180 | p_dev->suspended = 0; | ||
1181 | return ret; | 1197 | return ret; |
1182 | } | 1198 | } |
1183 | 1199 | ||