Lines Matching full:fs
424 static inline int swim_track(struct floppy_state *fs, int track) in swim_track() argument
426 struct swim __iomem *base = fs->swd->base; in swim_track()
429 ret = swim_seek(base, track - fs->track); in swim_track()
432 fs->track = track; in swim_track()
435 fs->track = 0; in swim_track()
441 static int floppy_eject(struct floppy_state *fs) in floppy_eject() argument
443 struct swim __iomem *base = fs->swd->base; in floppy_eject()
445 swim_drive(base, fs->location); in floppy_eject()
449 fs->disk_in = 0; in floppy_eject()
450 fs->ejected = 1; in floppy_eject()
455 static inline int swim_read_sector(struct floppy_state *fs, in swim_read_sector() argument
459 struct swim __iomem *base = fs->swd->base; in swim_read_sector()
465 swim_track(fs, track); in swim_read_sector()
492 static blk_status_t floppy_read_sectors(struct floppy_state *fs, in floppy_read_sectors() argument
496 struct swim __iomem *base = fs->swd->base; in floppy_read_sectors()
502 swim_drive(base, fs->location); in floppy_read_sectors()
505 track = i / fs->secpercyl; in floppy_read_sectors()
506 x = i % fs->secpercyl; in floppy_read_sectors()
507 side = x / fs->secpertrack; in floppy_read_sectors()
508 sector = x % fs->secpertrack + 1; in floppy_read_sectors()
512 ret = swim_read_sector(fs, side, track, sector, in floppy_read_sectors()
527 struct floppy_state *fs = hctx->queue->queuedata; in swim_queue_rq() local
528 struct swim_priv *swd = fs->swd; in swim_queue_rq()
537 if (!fs->disk_in || rq_data_dir(req) == WRITE) { in swim_queue_rq()
543 err = floppy_read_sectors(fs, blk_rq_pos(req), in swim_queue_rq()
563 static int get_floppy_geometry(struct floppy_state *fs, int type, in get_floppy_geometry() argument
571 else if (fs->type == HD_MEDIA) /* High-Density media */ in get_floppy_geometry()
573 else if (fs->head_number == 2) /* double-sided */ in get_floppy_geometry()
581 static void setup_medium(struct floppy_state *fs) in setup_medium() argument
583 struct swim __iomem *base = fs->swd->base; in setup_medium()
587 fs->disk_in = 1; in setup_medium()
588 fs->write_protected = swim_readbit(base, WRITE_PROT); in setup_medium()
596 fs->type = swim_readbit(base, TWOMEG_MEDIA) ? in setup_medium()
598 fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2; in setup_medium()
599 get_floppy_geometry(fs, 0, &g); in setup_medium()
600 fs->total_secs = g->size; in setup_medium()
601 fs->secpercyl = g->head * g->sect; in setup_medium()
602 fs->secpertrack = g->sect; in setup_medium()
603 fs->track = 0; in setup_medium()
605 fs->disk_in = 0; in setup_medium()
611 struct floppy_state *fs = bdev->bd_disk->private_data; in floppy_open() local
612 struct swim __iomem *base = fs->swd->base; in floppy_open()
615 if (fs->ref_count == -1 || (fs->ref_count && mode & FMODE_EXCL)) in floppy_open()
619 fs->ref_count = -1; in floppy_open()
621 fs->ref_count++; in floppy_open()
625 swim_drive(base, fs->location); in floppy_open()
628 if (fs->ejected) in floppy_open()
629 setup_medium(fs); in floppy_open()
630 if (!fs->disk_in) { in floppy_open()
635 set_capacity(fs->disk, fs->total_secs); in floppy_open()
641 if (bdev_check_media_change(bdev) && fs->disk_in) in floppy_open()
642 fs->ejected = 0; in floppy_open()
643 if ((mode & FMODE_WRITE) && fs->write_protected) { in floppy_open()
650 if (fs->ref_count < 0) in floppy_open()
651 fs->ref_count = 0; in floppy_open()
652 else if (fs->ref_count > 0) in floppy_open()
653 --fs->ref_count; in floppy_open()
655 if (fs->ref_count == 0) in floppy_open()
673 struct floppy_state *fs = disk->private_data; in floppy_release() local
674 struct swim __iomem *base = fs->swd->base; in floppy_release()
677 if (fs->ref_count < 0) in floppy_release()
678 fs->ref_count = 0; in floppy_release()
679 else if (fs->ref_count > 0) in floppy_release()
680 --fs->ref_count; in floppy_release()
682 if (fs->ref_count == 0) in floppy_release()
690 struct floppy_state *fs = bdev->bd_disk->private_data; in floppy_ioctl() local
698 if (fs->ref_count != 1) in floppy_ioctl()
701 err = floppy_eject(fs); in floppy_ioctl()
716 struct floppy_state *fs = bdev->bd_disk->private_data; in floppy_getgeo() local
720 ret = get_floppy_geometry(fs, 0, &g); in floppy_getgeo()
734 struct floppy_state *fs = disk->private_data; in floppy_check_events() local
736 return fs->ejected ? DISK_EVENT_MEDIA_CHANGE : 0; in floppy_check_events()
762 struct floppy_state *fs = &swd->unit[swd->floppy_count]; in swim_add_floppy() local
765 fs->location = location; in swim_add_floppy()
771 fs->type = HD_MEDIA; in swim_add_floppy()
772 fs->head_number = 2; in swim_add_floppy()
774 fs->ref_count = 0; in swim_add_floppy()
775 fs->ejected = 1; in swim_add_floppy()