794 spin_unlock(chip->mutex);
795 cfi_udelay(1);
796 spin_lock(chip->mutex);
797
798
799 }
800 chip->state = FL_STATUS;
801 return 0;
802
803 case FL_XIP_WHILE_ERASING:
804 if (mode != FL_READY && mode != FL_POINT &&
805 (mode != FL_WRITING || !cfip || !(cfip->SuspendCmdSupport&1)))
806 goto sleep;
807 chip->oldstate = chip->state;
808 chip->state = FL_READY;
809 return 0;
810
811 case FL_SHUTDOWN:
812
813 return -EIO;
814 case FL_POINT:
815
816 if (mode == FL_READY && chip->oldstate == FL_READY)
817 return 0;
818
819 default:
820 sleep:
821 set_current_state(TASK_UNINTERRUPTIBLE);
822 add_wait_queue(&chip->wq, &wait);
823 spin_unlock(chip->mutex);
824 schedule();
825 remove_wait_queue(&chip->wq, &wait);
826 spin_lock(chip->mutex);
827 return -EAGAIN;
828 }
829}
830
831static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
832{
833 int ret;
834 DECLARE_WAITQUEUE(wait, current);