int afdattach(struct ata_device *atadev) { struct afd_softc *fdp; dev_t dev; fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT | M_ZERO); if (!fdp) { ata_prtdev(atadev, "out of memory\n"); return 0; } fdp->device = atadev; fdp->lun = ata_get_lun(&afd_lun_map); ata_set_name(atadev, "afd", fdp->lun); bufq_init(&fdp->queue); if (afd_sense(fdp)) { free(fdp, M_AFD); return 0; } devstat_add_entry(&fdp->stats, "afd", fdp->lun, DEV_BSIZE, DEVSTAT_NO_ORDERED_TAGS, DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_IDE, DEVSTAT_PRIORITY_WFD); dev = disk_create(fdp->lun, &fdp->disk, 0, &afd_cdevsw, &afddisk_cdevsw); dev->si_drv1 = fdp; fdp->dev = dev; if (!strncmp(atadev->param->model, "IOMEGA ZIP", 10) || !strncmp(atadev->param->model, "IOMEGA Clik!", 12)) fdp->dev->si_iosize_max = 64 * DEV_BSIZE; else fdp->dev->si_iosize_max = 252 * DEV_BSIZE; afd_describe(fdp); atadev->flags |= ATA_D_MEDIA_CHANGED; atadev->driver = fdp; return 1; }
static int afd_attach(device_t dev) { struct ata_channel *ch = device_get_softc(device_get_parent(dev)); struct ata_device *atadev = device_get_softc(dev); struct afd_softc *fdp; if (!(fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT | M_ZERO))) { device_printf(dev, "out of memory\n"); return ENOMEM; } device_set_ivars(dev, fdp); ata_setmode(dev); if (afd_sense(dev)) { device_set_ivars(dev, NULL); free(fdp, M_AFD); return ENXIO; } atadev->flags |= ATA_D_MEDIA_CHANGED; /* announce we are here */ afd_describe(dev); /* create the disk device */ fdp->disk = disk_alloc(); fdp->disk->d_open = afd_open; fdp->disk->d_close = afd_close; fdp->disk->d_strategy = afd_strategy; fdp->disk->d_ioctl = afd_ioctl; fdp->disk->d_name = "afd"; fdp->disk->d_drv1 = dev; fdp->disk->d_maxsize = ch->dma.max_iosize ? ch->dma.max_iosize : DFLTPHYS; fdp->disk->d_unit = device_get_unit(dev); disk_create(fdp->disk, DISK_VERSION); return 0; }
static int afd_attach(device_t dev) { struct ata_channel *ch = device_get_softc(device_get_parent(dev)); struct ata_device *atadev = device_get_softc(dev); struct afd_softc *fdp; cdev_t cdev; fdp = kmalloc(sizeof(struct afd_softc), M_AFD, M_WAITOK | M_ZERO); device_set_ivars(dev, fdp); ATA_SETMODE(device_get_parent(dev), dev); if (afd_sense(dev)) { device_set_ivars(dev, NULL); kfree(fdp, M_AFD); return ENXIO; } atadev->flags |= ATA_D_MEDIA_CHANGED; /* create the disk device */ devstat_add_entry(&fdp->stats, "afd", device_get_unit(dev), DEV_BSIZE, DEVSTAT_NO_ORDERED_TAGS, DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_IDE, DEVSTAT_PRIORITY_WFD); cdev = disk_create(device_get_unit(dev), &fdp->disk, &afd_ops); disk_setdisktype(&fdp->disk, "floppy"); cdev->si_drv1 = dev; if (ch->dma) cdev->si_iosize_max = ch->dma->max_iosize; else cdev->si_iosize_max = min(MAXPHYS,64*1024); fdp->cdev = cdev; /* announce we are here */ afd_describe(dev); return 0; }