Lines Matching refs:fs
426 static inline int swim_track(struct floppy_state *fs, int track)
428 struct swim __iomem *base = fs->swd->base;
431 ret = swim_seek(base, track - fs->track);
434 fs->track = track;
437 fs->track = 0;
443 static int floppy_eject(struct floppy_state *fs)
445 struct swim __iomem *base = fs->swd->base;
447 swim_drive(base, fs->location);
451 fs->disk_in = 0;
452 fs->ejected = 1;
457 static inline int swim_read_sector(struct floppy_state *fs,
461 struct swim __iomem *base = fs->swd->base;
467 swim_track(fs, track);
494 static blk_status_t floppy_read_sectors(struct floppy_state *fs,
498 struct swim __iomem *base = fs->swd->base;
504 swim_drive(base, fs->location);
507 track = i / fs->secpercyl;
508 x = i % fs->secpercyl;
509 side = x / fs->secpertrack;
510 sector = x % fs->secpertrack + 1;
514 ret = swim_read_sector(fs, side, track, sector,
529 struct floppy_state *fs = hctx->queue->queuedata;
530 struct swim_priv *swd = fs->swd;
539 if (!fs->disk_in || rq_data_dir(req) == WRITE) {
545 err = floppy_read_sectors(fs, blk_rq_pos(req),
565 static int get_floppy_geometry(struct floppy_state *fs, int type,
573 else if (fs->type == HD_MEDIA) /* High-Density media */
575 else if (fs->head_number == 2) /* double-sided */
583 static void setup_medium(struct floppy_state *fs)
585 struct swim __iomem *base = fs->swd->base;
589 fs->disk_in = 1;
590 fs->write_protected = swim_readbit(base, WRITE_PROT);
598 fs->type = swim_readbit(base, TWOMEG_MEDIA) ?
600 fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2;
601 get_floppy_geometry(fs, 0, &g);
602 fs->total_secs = g->size;
603 fs->secpercyl = g->head * g->sect;
604 fs->secpertrack = g->sect;
605 fs->track = 0;
607 fs->disk_in = 0;
613 struct floppy_state *fs = disk->private_data;
614 struct swim __iomem *base = fs->swd->base;
617 if (fs->ref_count == -1 || (fs->ref_count && mode & BLK_OPEN_EXCL))
620 fs->ref_count = -1;
622 fs->ref_count++;
625 swim_drive(base, fs->location);
628 if (fs->ejected)
629 setup_medium(fs);
630 if (!fs->disk_in) {
635 set_capacity(fs->disk, fs->total_secs);
641 if (disk_check_media_change(disk) && fs->disk_in)
642 fs->ejected = 0;
643 if ((mode & BLK_OPEN_WRITE) && fs->write_protected) {
650 if (fs->ref_count < 0)
651 fs->ref_count = 0;
652 else if (fs->ref_count > 0)
653 --fs->ref_count;
655 if (fs->ref_count == 0)
673 struct floppy_state *fs = disk->private_data;
674 struct swim __iomem *base = fs->swd->base;
677 if (fs->ref_count < 0)
678 fs->ref_count = 0;
679 else if (fs->ref_count > 0)
680 --fs->ref_count;
682 if (fs->ref_count == 0)
690 struct floppy_state *fs = bdev->bd_disk->private_data;
698 if (fs->ref_count != 1)
701 err = floppy_eject(fs);
716 struct floppy_state *fs = bdev->bd_disk->private_data;
720 ret = get_floppy_geometry(fs, 0, &g);
734 struct floppy_state *fs = disk->private_data;
736 return fs->ejected ? DISK_EVENT_MEDIA_CHANGE : 0;
750 struct floppy_state *fs = &swd->unit[swd->floppy_count];
753 fs->location = location;
759 fs->type = HD_MEDIA;
760 fs->head_number = 2;
762 fs->ref_count = 0;
763 fs->ejected = 1;
774 static void swim_cleanup_floppy_disk(struct floppy_state *fs)
776 struct gendisk *disk = fs->disk;
781 if (fs->registered)
782 del_gendisk(fs->disk);
785 blk_mq_free_tag_set(&fs->tag_set);