diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2010-04-29 03:36:24 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2010-04-29 03:36:24 -0400 |
commit | 7407cf355fdf5500430be966dbbde84a27293bad (patch) | |
tree | 922861288ff38558ed721a79653f52b17b13bb95 /drivers/pcmcia/ds.c | |
parent | 6a47dc1418682c83d603b491df1d048f73aa973e (diff) | |
parent | 79dba2eaa771c3173957eccfd288e0e0d12e4d3f (diff) |
Merge branch 'master' into for-2.6.35
Conflicts:
fs/block_dev.c
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r-- | drivers/pcmcia/ds.c | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index cb6036d89e59..508f94a2a78d 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -335,7 +335,6 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le | |||
335 | 335 | ||
336 | mutex_lock(&s->ops_mutex); | 336 | mutex_lock(&s->ops_mutex); |
337 | list_del(&p_dev->socket_device_list); | 337 | list_del(&p_dev->socket_device_list); |
338 | p_dev->_removed = 1; | ||
339 | mutex_unlock(&s->ops_mutex); | 338 | mutex_unlock(&s->ops_mutex); |
340 | 339 | ||
341 | dev_dbg(&p_dev->dev, "unregistering device\n"); | 340 | dev_dbg(&p_dev->dev, "unregistering device\n"); |
@@ -654,14 +653,7 @@ static int pcmcia_requery_callback(struct device *dev, void * _data) | |||
654 | 653 | ||
655 | static void pcmcia_requery(struct pcmcia_socket *s) | 654 | static void pcmcia_requery(struct pcmcia_socket *s) |
656 | { | 655 | { |
657 | int present, has_pfc; | 656 | int has_pfc; |
658 | |||
659 | mutex_lock(&s->ops_mutex); | ||
660 | present = s->pcmcia_state.present; | ||
661 | mutex_unlock(&s->ops_mutex); | ||
662 | |||
663 | if (!present) | ||
664 | return; | ||
665 | 657 | ||
666 | if (s->functions == 0) { | 658 | if (s->functions == 0) { |
667 | pcmcia_card_add(s); | 659 | pcmcia_card_add(s); |
@@ -687,12 +679,10 @@ static void pcmcia_requery(struct pcmcia_socket *s) | |||
687 | new_funcs = mfc.nfn; | 679 | new_funcs = mfc.nfn; |
688 | else | 680 | else |
689 | new_funcs = 1; | 681 | new_funcs = 1; |
690 | if (old_funcs > new_funcs) { | 682 | if (old_funcs != new_funcs) { |
683 | /* we need to re-start */ | ||
691 | pcmcia_card_remove(s, NULL); | 684 | pcmcia_card_remove(s, NULL); |
692 | pcmcia_card_add(s); | 685 | pcmcia_card_add(s); |
693 | } else if (new_funcs > old_funcs) { | ||
694 | s->functions = new_funcs; | ||
695 | pcmcia_device_add(s, 1); | ||
696 | } | 686 | } |
697 | } | 687 | } |
698 | 688 | ||
@@ -728,6 +718,8 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) | |||
728 | struct pcmcia_socket *s = dev->socket; | 718 | struct pcmcia_socket *s = dev->socket; |
729 | const struct firmware *fw; | 719 | const struct firmware *fw; |
730 | int ret = -ENOMEM; | 720 | int ret = -ENOMEM; |
721 | cistpl_longlink_mfc_t mfc; | ||
722 | int old_funcs, new_funcs = 1; | ||
731 | 723 | ||
732 | if (!filename) | 724 | if (!filename) |
733 | return -EINVAL; | 725 | return -EINVAL; |
@@ -750,6 +742,14 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) | |||
750 | goto release; | 742 | goto release; |
751 | } | 743 | } |
752 | 744 | ||
745 | /* we need to re-start if the number of functions changed */ | ||
746 | old_funcs = s->functions; | ||
747 | if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, | ||
748 | &mfc)) | ||
749 | new_funcs = mfc.nfn; | ||
750 | |||
751 | if (old_funcs != new_funcs) | ||
752 | ret = -EBUSY; | ||
753 | 753 | ||
754 | /* update information */ | 754 | /* update information */ |
755 | pcmcia_device_query(dev); | 755 | pcmcia_device_query(dev); |
@@ -820,11 +820,12 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
820 | } | 820 | } |
821 | 821 | ||
822 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { | 822 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { |
823 | if (dev->device_no != did->device_no) | 823 | dev_dbg(&dev->dev, "this is a pseudo-multi-function device\n"); |
824 | return 0; | ||
825 | mutex_lock(&dev->socket->ops_mutex); | 824 | mutex_lock(&dev->socket->ops_mutex); |
826 | dev->socket->pcmcia_state.has_pfc = 1; | 825 | dev->socket->pcmcia_state.has_pfc = 1; |
827 | mutex_unlock(&dev->socket->ops_mutex); | 826 | mutex_unlock(&dev->socket->ops_mutex); |
827 | if (dev->device_no != did->device_no) | ||
828 | return 0; | ||
828 | } | 829 | } |
829 | 830 | ||
830 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { | 831 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { |
@@ -835,7 +836,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
835 | 836 | ||
836 | /* if this is a pseudo-multi-function device, | 837 | /* if this is a pseudo-multi-function device, |
837 | * we need explicit matches */ | 838 | * we need explicit matches */ |
838 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) | 839 | if (dev->socket->pcmcia_state.has_pfc) |
839 | return 0; | 840 | return 0; |
840 | if (dev->device_no) | 841 | if (dev->device_no) |
841 | return 0; | 842 | return 0; |
@@ -858,10 +859,8 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
858 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { | 859 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { |
859 | dev_dbg(&dev->dev, "device needs a fake CIS\n"); | 860 | dev_dbg(&dev->dev, "device needs a fake CIS\n"); |
860 | if (!dev->socket->fake_cis) | 861 | if (!dev->socket->fake_cis) |
861 | pcmcia_load_firmware(dev, did->cisfile); | 862 | if (pcmcia_load_firmware(dev, did->cisfile)) |
862 | 863 | return 0; | |
863 | if (!dev->socket->fake_cis) | ||
864 | return 0; | ||
865 | } | 864 | } |
866 | 865 | ||
867 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) { | 866 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) { |
@@ -1254,9 +1253,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) | |||
1254 | 1253 | ||
1255 | switch (event) { | 1254 | switch (event) { |
1256 | case CS_EVENT_CARD_REMOVAL: | 1255 | case CS_EVENT_CARD_REMOVAL: |
1257 | mutex_lock(&s->ops_mutex); | 1256 | atomic_set(&skt->present, 0); |
1258 | s->pcmcia_state.present = 0; | ||
1259 | mutex_unlock(&s->ops_mutex); | ||
1260 | pcmcia_card_remove(skt, NULL); | 1257 | pcmcia_card_remove(skt, NULL); |
1261 | handle_event(skt, event); | 1258 | handle_event(skt, event); |
1262 | mutex_lock(&s->ops_mutex); | 1259 | mutex_lock(&s->ops_mutex); |
@@ -1265,9 +1262,9 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) | |||
1265 | break; | 1262 | break; |
1266 | 1263 | ||
1267 | case CS_EVENT_CARD_INSERTION: | 1264 | case CS_EVENT_CARD_INSERTION: |
1265 | atomic_set(&skt->present, 1); | ||
1268 | mutex_lock(&s->ops_mutex); | 1266 | mutex_lock(&s->ops_mutex); |
1269 | s->pcmcia_state.has_pfc = 0; | 1267 | s->pcmcia_state.has_pfc = 0; |
1270 | s->pcmcia_state.present = 1; | ||
1271 | destroy_cis_cache(s); /* to be on the safe side... */ | 1268 | destroy_cis_cache(s); /* to be on the safe side... */ |
1272 | mutex_unlock(&s->ops_mutex); | 1269 | mutex_unlock(&s->ops_mutex); |
1273 | pcmcia_card_add(skt); | 1270 | pcmcia_card_add(skt); |
@@ -1307,7 +1304,13 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) | |||
1307 | return 0; | 1304 | return 0; |
1308 | } /* ds_event */ | 1305 | } /* ds_event */ |
1309 | 1306 | ||
1310 | 1307 | /* | |
1308 | * NOTE: This is racy. There's no guarantee the card will still be | ||
1309 | * physically present, even if the call to this function returns | ||
1310 | * non-NULL. Furthermore, the device driver most likely is unbound | ||
1311 | * almost immediately, so the timeframe where pcmcia_dev_present | ||
1312 | * returns NULL is probably really really small. | ||
1313 | */ | ||
1311 | struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) | 1314 | struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) |
1312 | { | 1315 | { |
1313 | struct pcmcia_device *p_dev; | 1316 | struct pcmcia_device *p_dev; |
@@ -1317,22 +1320,9 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) | |||
1317 | if (!p_dev) | 1320 | if (!p_dev) |
1318 | return NULL; | 1321 | return NULL; |
1319 | 1322 | ||
1320 | mutex_lock(&p_dev->socket->ops_mutex); | 1323 | if (atomic_read(&p_dev->socket->present) != 0) |
1321 | if (!p_dev->socket->pcmcia_state.present) | 1324 | ret = p_dev; |
1322 | goto out; | ||
1323 | |||
1324 | if (p_dev->socket->pcmcia_state.dead) | ||
1325 | goto out; | ||
1326 | |||
1327 | if (p_dev->_removed) | ||
1328 | goto out; | ||
1329 | |||
1330 | if (p_dev->suspended) | ||
1331 | goto out; | ||
1332 | 1325 | ||
1333 | ret = p_dev; | ||
1334 | out: | ||
1335 | mutex_unlock(&p_dev->socket->ops_mutex); | ||
1336 | pcmcia_put_dev(p_dev); | 1326 | pcmcia_put_dev(p_dev); |
1337 | return ret; | 1327 | return ret; |
1338 | } | 1328 | } |
@@ -1382,6 +1372,8 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev, | |||
1382 | return ret; | 1372 | return ret; |
1383 | } | 1373 | } |
1384 | 1374 | ||
1375 | atomic_set(&socket->present, 0); | ||
1376 | |||
1385 | return 0; | 1377 | return 0; |
1386 | } | 1378 | } |
1387 | 1379 | ||
@@ -1393,10 +1385,6 @@ static void pcmcia_bus_remove_socket(struct device *dev, | |||
1393 | if (!socket) | 1385 | if (!socket) |
1394 | return; | 1386 | return; |
1395 | 1387 | ||
1396 | mutex_lock(&socket->ops_mutex); | ||
1397 | socket->pcmcia_state.dead = 1; | ||
1398 | mutex_unlock(&socket->ops_mutex); | ||
1399 | |||
1400 | pccard_register_pcmcia(socket, NULL); | 1388 | pccard_register_pcmcia(socket, NULL); |
1401 | 1389 | ||
1402 | /* unregister any unbound devices */ | 1390 | /* unregister any unbound devices */ |