917 shared->erasing = chip;
918 spin_unlock(&shared->lock);
919 }
920 ret = chip_ready(map, chip, adr, mode);
921 if (ret == -EAGAIN)
922 goto retry;
923
924 return ret;
925}
926
927static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr)
928{
929 struct cfi_private *cfi = map->fldrv_priv;
930
931 if (chip->priv) {
932 struct flchip_shared *shared = chip->priv;
933 spin_lock(&shared->lock);
934 if (shared->writing == chip && chip->oldstate == FL_READY) {
935
936 shared->writing = shared->erasing;
937 if (shared->writing && shared->writing != chip) {
938
939 struct flchip *loaner = shared->writing;
940 spin_lock(loaner->mutex);
941 spin_unlock(&shared->lock);
942 spin_unlock(chip->mutex);
943 put_chip(map, loaner, loaner->start);
944 spin_lock(chip->mutex);
945 spin_unlock(loaner->mutex);
946 wake_up(&chip->wq);
947 return;
948 }
949 shared->erasing = NULL;
950 shared->writing = NULL;
951 } else if (shared->erasing == chip && shared->writing != chip) {
952
953
954
955
956
957