Lines Matching refs:fs
428 static inline int swim_track(struct floppy_state *fs, int track) in swim_track() argument
430 struct swim __iomem *base = fs->swd->base; in swim_track()
433 ret = swim_seek(base, track - fs->track); in swim_track()
436 fs->track = track; in swim_track()
439 fs->track = 0; in swim_track()
445 static int floppy_eject(struct floppy_state *fs) in floppy_eject() argument
447 struct swim __iomem *base = fs->swd->base; in floppy_eject()
449 swim_drive(base, fs->location); in floppy_eject()
453 fs->disk_in = 0; in floppy_eject()
454 fs->ejected = 1; in floppy_eject()
459 static inline int swim_read_sector(struct floppy_state *fs, in swim_read_sector() argument
463 struct swim __iomem *base = fs->swd->base; in swim_read_sector()
469 swim_track(fs, track); in swim_read_sector()
496 static int floppy_read_sectors(struct floppy_state *fs, in floppy_read_sectors() argument
500 struct swim __iomem *base = fs->swd->base; in floppy_read_sectors()
506 swim_drive(base, fs->location); in floppy_read_sectors()
509 track = i / fs->secpercyl; in floppy_read_sectors()
510 x = i % fs->secpercyl; in floppy_read_sectors()
511 side = x / fs->secpertrack; in floppy_read_sectors()
512 sector = x % fs->secpertrack + 1; in floppy_read_sectors()
516 ret = swim_read_sector(fs, side, track, sector, in floppy_read_sectors()
531 struct floppy_state *fs; in redo_fd_request() local
537 fs = req->rq_disk->private_data; in redo_fd_request()
538 if (blk_rq_pos(req) >= fs->total_secs) in redo_fd_request()
540 if (!fs->disk_in) in redo_fd_request()
542 if (rq_data_dir(req) == WRITE && fs->write_protected) in redo_fd_request()
550 err = floppy_read_sectors(fs, blk_rq_pos(req), in redo_fd_request()
573 static int get_floppy_geometry(struct floppy_state *fs, int type, in get_floppy_geometry() argument
581 else if (fs->type == HD_MEDIA) /* High-Density media */ in get_floppy_geometry()
583 else if (fs->head_number == 2) /* double-sided */ in get_floppy_geometry()
591 static void setup_medium(struct floppy_state *fs) in setup_medium() argument
593 struct swim __iomem *base = fs->swd->base; in setup_medium()
597 fs->disk_in = 1; in setup_medium()
598 fs->write_protected = swim_readbit(base, WRITE_PROT); in setup_medium()
599 fs->type = swim_readbit(base, ONEMEG_MEDIA); in setup_medium()
607 get_floppy_geometry(fs, 0, &g); in setup_medium()
608 fs->total_secs = g->size; in setup_medium()
609 fs->secpercyl = g->head * g->sect; in setup_medium()
610 fs->secpertrack = g->sect; in setup_medium()
611 fs->track = 0; in setup_medium()
613 fs->disk_in = 0; in setup_medium()
619 struct floppy_state *fs = bdev->bd_disk->private_data; in floppy_open() local
620 struct swim __iomem *base = fs->swd->base; in floppy_open()
623 if (fs->ref_count == -1 || (fs->ref_count && mode & FMODE_EXCL)) in floppy_open()
627 fs->ref_count = -1; in floppy_open()
629 fs->ref_count++; in floppy_open()
636 if (fs->ejected) in floppy_open()
637 setup_medium(fs); in floppy_open()
638 if (!fs->disk_in) { in floppy_open()
648 if ((mode & FMODE_WRITE) && fs->write_protected) { in floppy_open()
655 if (fs->ref_count < 0) in floppy_open()
656 fs->ref_count = 0; in floppy_open()
657 else if (fs->ref_count > 0) in floppy_open()
658 --fs->ref_count; in floppy_open()
660 if (fs->ref_count == 0) in floppy_open()
678 struct floppy_state *fs = disk->private_data; in floppy_release() local
679 struct swim __iomem *base = fs->swd->base; in floppy_release()
682 if (fs->ref_count < 0) in floppy_release()
683 fs->ref_count = 0; in floppy_release()
684 else if (fs->ref_count > 0) in floppy_release()
685 --fs->ref_count; in floppy_release()
687 if (fs->ref_count == 0) in floppy_release()
695 struct floppy_state *fs = bdev->bd_disk->private_data; in floppy_ioctl() local
703 if (fs->ref_count != 1) in floppy_ioctl()
706 err = floppy_eject(fs); in floppy_ioctl()
726 struct floppy_state *fs = bdev->bd_disk->private_data; in floppy_getgeo() local
730 ret = get_floppy_geometry(fs, 0, &g); in floppy_getgeo()
744 struct floppy_state *fs = disk->private_data; in floppy_check_events() local
746 return fs->ejected ? DISK_EVENT_MEDIA_CHANGE : 0; in floppy_check_events()
751 struct floppy_state *fs = disk->private_data; in floppy_revalidate() local
752 struct swim __iomem *base = fs->swd->base; in floppy_revalidate()
754 swim_drive(base, fs->location); in floppy_revalidate()
756 if (fs->ejected) in floppy_revalidate()
757 setup_medium(fs); in floppy_revalidate()
759 if (!fs->disk_in) in floppy_revalidate()
762 fs->ejected = 0; in floppy_revalidate()
764 return !fs->disk_in; in floppy_revalidate()
791 struct floppy_state *fs = &swd->unit[swd->floppy_count]; in swim_add_floppy() local
794 fs->location = location; in swim_add_floppy()
801 fs->head_number = 1; in swim_add_floppy()
803 fs->head_number = 2; in swim_add_floppy()
804 fs->ref_count = 0; in swim_add_floppy()
805 fs->ejected = 1; in swim_add_floppy()