878 spin_lock(chip->mutex);
879
880 if (ret == -EAGAIN) {
881 spin_unlock(contender->mutex);
882 goto retry;
883 }
884 if (ret) {
885 spin_unlock(contender->mutex);
886 return ret;
887 }
888 spin_lock(&shared->lock);
889
890
891
892 if (chip->state == FL_SYNCING) {
893 put_chip(map, contender, contender->start);
894 spin_unlock(contender->mutex);
895 goto retry;
896 }
897 spin_unlock(contender->mutex);
898 }
899
900
901
902 if (mode == FL_ERASING && shared->erasing
903 && shared->erasing->oldstate == FL_ERASING) {
904 spin_unlock(&shared->lock);
905 set_current_state(TASK_UNINTERRUPTIBLE);
906 add_wait_queue(&chip->wq, &wait);
907 spin_unlock(chip->mutex);
908 schedule();
909 remove_wait_queue(&chip->wq, &wait);
910 spin_lock(chip->mutex);
911 goto retry;
912 }
913
914
915 shared->writing = chip;
916 if (mode == FL_ERASING)
917 shared->erasing = chip;
918 spin_unlock(&shared->lock);