Beispiel #1
0
static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
{
    struct Scsi_Host *shost;
    int error = -ENXIO;

    shost = scsi_host_lookup(host);
    if (IS_ERR(shost))
        return PTR_ERR(shost);

    if (shost->transportt->user_scan)
        error = shost->transportt->user_scan(shost, channel, id, lun);
    else
        error = scsi_scan_host_selected(shost, channel, id, lun, 1);
    scsi_host_put(shost);
    return error;
}
Beispiel #2
0
/**
 * scsi_remove_single_device - Respond to user request to remove a device
 * @host: user-supplied decimal integer
 * @channel: user-supplied decimal integer
 * @id: user-supplied decimal integer
 * @lun: user-supplied decimal integer
 *
 * Description: called by writing "scsi remove-single-device" to
 * /proc/scsi/scsi.  Does a scsi_device_lookup() and scsi_remove_device()
 */
static int scsi_remove_single_device(uint host, uint channel, uint id, uint lun)
{
    struct scsi_device *sdev;
    struct Scsi_Host *shost;
    int error = -ENXIO;

    shost = scsi_host_lookup(host);
    if (IS_ERR(shost))
        return PTR_ERR(shost);
    sdev = scsi_device_lookup(shost, channel, id, lun);
    if (sdev) {
        scsi_remove_device(sdev);
        scsi_device_put(sdev);
        error = 0;
    }

    scsi_host_put(shost);
    return error;
}
static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
{
	struct pscsi_hba_virt *phv = hba->hba_ptr;
	struct Scsi_Host *sh = phv->phv_lld_host;
	/*
	 * Release the struct Scsi_Host
	 */
	if (!mode_flag) {
		if (!sh)
			return 0;

		phv->phv_lld_host = NULL;
		phv->phv_mode = PHV_VIRTUAL_HOST_ID;

		pr_debug("CORE_HBA[%d] - Disabled pSCSI HBA Passthrough"
			" %s\n", hba->hba_id, (sh->hostt->name) ?
			(sh->hostt->name) : "Unknown");

		scsi_host_put(sh);
		return 0;
	}
	/*
	 * Otherwise, locate struct Scsi_Host from the original passed
	 * pSCSI Host ID and enable for phba mode
	 */
	sh = scsi_host_lookup(phv->phv_host_id);
	if (!sh) {
		pr_err("pSCSI: Unable to locate SCSI Host for"
			" phv_host_id: %d\n", phv->phv_host_id);
		return -EINVAL;
	}

	phv->phv_lld_host = sh;
	phv->phv_mode = PHV_LLD_SCSI_HOST_NO;

	pr_debug("CORE_HBA[%d] - Enabled pSCSI HBA Passthrough %s\n",
		hba->hba_id, (sh->hostt->name) ? (sh->hostt->name) : "Unknown");

	return 1;
}