int scsi_detach(struct scsibus_softc *sc, int target, int lun, int flags) { if (target == -1 && lun == -1) return (scsi_detach_bus(sc, flags)); /* specific lun and wildcard target is bad */ if (target == -1) return (EINVAL); if (lun == -1) return (scsi_detach_target(sc, target, flags)); return (scsi_detach_lun(sc, target, lun, flags)); }
int scsibusdetach(struct device *dev, int type) { struct scsibus_softc *sb = (struct scsibus_softc *)dev; int error; #if NBIO > 0 bio_unregister(&sb->sc_dev); #endif error = scsi_detach_bus(sb, type); if (error != 0) return (error); KASSERT(SLIST_EMPTY(&sb->sc_link)); return (0); }
int scsibus_bioctl(struct device *dev, u_long cmd, caddr_t addr) { struct scsibus_softc *sc = (struct scsibus_softc *)dev; struct sbioc_device *sdev; switch (cmd) { case SBIOCPROBE: sdev = (struct sbioc_device *)addr; if (sdev->sd_target == -1 && sdev->sd_lun == -1) return (scsi_probe_bus(sc)); /* specific lun and wildcard target is bad */ if (sdev->sd_target == -1) return (EINVAL); if (sdev->sd_lun == -1) return (scsi_probe_target(sc, sdev->sd_target)); return (scsi_probe_lun(sc, sdev->sd_target, sdev->sd_lun)); case SBIOCDETACH: sdev = (struct sbioc_device *)addr; if (sdev->sd_target == -1 && sdev->sd_lun == -1) return (scsi_detach_bus(sc, 0)); if (sdev->sd_target == -1) return (EINVAL); if (sdev->sd_lun == -1) return (scsi_detach_target(sc, sdev->sd_target, 0)); return (scsi_detach_lun(sc, sdev->sd_target, sdev->sd_lun, 0)); default: return (ENOTTY); } }