Lines Matching defs:sdev

178  * @sdev:	scsi device to send command to
185 static void scsi_unlock_floptical(struct scsi_device *sdev,
190 sdev_printk(KERN_NOTICE, sdev, "unlocking floptical drive\n");
197 scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL,
218 struct scsi_device *sdev;
222 sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
224 if (!sdev)
227 sdev->vendor = scsi_null_device_strs;
228 sdev->model = scsi_null_device_strs;
229 sdev->rev = scsi_null_device_strs;
230 sdev->host = shost;
231 sdev->queue_ramp_up_period = SCSI_DEFAULT_RAMP_UP_PERIOD;
232 sdev->id = starget->id;
233 sdev->lun = lun;
234 sdev->channel = starget->channel;
235 mutex_init(&sdev->state_mutex);
236 sdev->sdev_state = SDEV_CREATED;
237 INIT_LIST_HEAD(&sdev->siblings);
238 INIT_LIST_HEAD(&sdev->same_target_siblings);
239 INIT_LIST_HEAD(&sdev->starved_entry);
240 INIT_LIST_HEAD(&sdev->event_list);
241 spin_lock_init(&sdev->list_lock);
242 mutex_init(&sdev->inquiry_mutex);
243 INIT_WORK(&sdev->event_work, scsi_evt_thread);
244 INIT_WORK(&sdev->requeue_work, scsi_requeue_run_queue);
246 sdev->sdev_gendev.parent = get_device(&starget->dev);
247 sdev->sdev_target = starget;
250 sdev->hostdata = hostdata;
254 sdev->max_device_blocked = SCSI_DEFAULT_DEVICE_BLOCKED;
259 sdev->type = -1;
266 sdev->borken = 1;
268 sdev->request_queue = scsi_mq_alloc_queue(sdev);
269 if (!sdev->request_queue) {
273 kfree(sdev);
276 WARN_ON_ONCE(!blk_get_queue(sdev->request_queue));
277 sdev->request_queue->queuedata = sdev;
279 scsi_change_queue_depth(sdev, sdev->host->cmd_per_lun ?
280 sdev->host->cmd_per_lun : 1);
282 scsi_sysfs_device_initialize(sdev);
285 ret = shost->hostt->slave_alloc(sdev);
297 return sdev;
300 __scsi_remove_device(sdev);
350 * Search for an existing target for this sdev.
548 * @sdev: scsi_device to probe
560 static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
572 * transfer length of 36 unless sdev->inquiry_len specifies a
574 first_inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;
579 SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
593 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
598 SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
645 *bflags = scsi_get_device_flags(sdev, &inq_result[8],
653 else if (sdev->inquiry_len)
654 next_inquiry_len = sdev->inquiry_len;
667 sdev_printk(KERN_INFO, sdev,
685 sdev->inquiry_len = min(try_inquiry_len, response_len);
702 if (sdev->inquiry_len < 36) {
703 if (!sdev->host->short_inquiry) {
704 shost_printk(KERN_INFO, sdev->host,
706 " using 36\n", sdev->inquiry_len);
707 sdev->host->short_inquiry = 1;
709 sdev->inquiry_len = 36;
730 sdev->scsi_level = inq_result[2] & 0x07;
731 if (sdev->scsi_level >= 2 ||
732 (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1))
733 sdev->scsi_level++;
734 sdev->sdev_target->scsi_level = sdev->scsi_level;
740 sdev->lun_in_cdb = 0;
741 if (sdev->scsi_level <= SCSI_2 &&
742 sdev->scsi_level != SCSI_UNKNOWN &&
743 !sdev->host->no_scsi2_lun_in_cdb)
744 sdev->lun_in_cdb = 1;
751 * @sdev: holds information to be stored in the new scsi_device
757 * Initialize the scsi_device @sdev. Optionally set fields based
764 static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
789 sdev->inquiry = kmemdup(inq_result,
790 max_t(size_t, sdev->inquiry_len, 36),
792 if (sdev->inquiry == NULL)
795 sdev->vendor = (char *) (sdev->inquiry + 8);
796 sdev->model = (char *) (sdev->inquiry + 16);
797 sdev->rev = (char *) (sdev->inquiry + 32);
799 if (strncmp(sdev->vendor, "ATA ", 8) == 0) {
806 sdev->allow_restart = 1;
810 sdev->type = TYPE_ROM;
811 sdev->removable = 1;
813 sdev->type = (inq_result[0] & 0x1f);
814 sdev->removable = (inq_result[1] & 0x80) >> 7;
821 if (scsi_is_wlun(sdev->lun) && sdev->type != TYPE_WLUN) {
822 sdev_printk(KERN_WARNING, sdev,
824 __func__, sdev->type, (unsigned int)sdev->lun);
825 sdev->type = TYPE_WLUN;
830 if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
855 sdev->inq_periph_qual = (inq_result[0] >> 5) & 7;
856 sdev->lockable = sdev->removable;
857 sdev->soft_reset = (inq_result[7] & 1) && ((inq_result[3] & 7) == 2);
859 if (sdev->scsi_level >= SCSI_3 ||
860 (sdev->inquiry_len > 56 && inq_result[56] & 0x04))
861 sdev->ppr = 1;
863 sdev->wdtr = 1;
865 sdev->sdtr = 1;
867 sdev_printk(KERN_NOTICE, sdev, "%s %.8s %.16s %.4s PQ: %d "
868 "ANSI: %d%s\n", scsi_device_type(sdev->type),
869 sdev->vendor, sdev->model, sdev->rev,
870 sdev->inq_periph_qual, inq_result[2] & 0x07,
873 if ((sdev->scsi_level >= SCSI_2) && (inq_result[7] & 2) &&
875 sdev->tagged_supported = 1;
876 sdev->simple_tags = 1;
885 sdev->borken = 0;
888 sdev->no_uld_attach = 1;
895 sdev->select_no_atn = 1;
902 blk_queue_max_hw_sectors(sdev->request_queue, 512);
908 blk_queue_max_hw_sectors(sdev->request_queue, 1024);
915 sdev->no_start_on_add = 1;
918 scsi_target(sdev)->single_lun = 1;
920 sdev->use_10_for_rw = 1;
926 sdev->no_report_opcodes = 1;
930 mutex_lock(&sdev->state_mutex);
931 ret = scsi_device_set_state(sdev, SDEV_RUNNING);
933 ret = scsi_device_set_state(sdev, SDEV_BLOCK);
934 mutex_unlock(&sdev->state_mutex);
937 sdev_printk(KERN_ERR, sdev,
939 scsi_device_state_name(sdev->sdev_state));
944 sdev->lockable = 0;
947 sdev->retry_hwerror = 1;
950 sdev->no_dif = 1;
953 sdev->unmap_limit_for_ws = 1;
955 sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
958 sdev->try_vpd_pages = 1;
960 sdev->skip_vpd_pages = 1;
962 transport_configure_device(&sdev->sdev_gendev);
964 if (sdev->host->hostt->slave_configure) {
965 ret = sdev->host->hostt->slave_configure(sdev);
972 sdev_printk(KERN_ERR, sdev,
979 if (sdev->scsi_level >= SCSI_3)
980 scsi_attach_vpd(sdev);
982 sdev->max_queue_depth = sdev->queue_depth;
983 sdev->sdev_bflags = *bflags;
990 if (!async && scsi_sysfs_add_sdev(sdev) != 0)
1049 struct scsi_device *sdev;
1059 sdev = scsi_device_lookup_by_target(starget, lun);
1060 if (sdev) {
1061 if (rescan != SCSI_SCAN_INITIAL || !scsi_device_created(sdev)) {
1062 SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
1064 dev_name(&sdev->sdev_gendev)));
1066 *sdevp = sdev;
1068 scsi_device_put(sdev);
1071 *bflagsp = scsi_get_device_flags(sdev,
1072 sdev->vendor,
1073 sdev->model);
1076 scsi_device_put(sdev);
1078 sdev = scsi_alloc_sdev(starget, lun, hostdata);
1079 if (!sdev)
1087 if (scsi_probe_lun(sdev, result, result_len, &bflags))
1103 * logical disk configured at sdev->lun, but there
1106 SCSI_LOG_SCAN_BUS(2, sdev_printk(KERN_INFO, sdev, "scsi scan:"
1114 sdev_printk(KERN_INFO, sdev,
1129 * that no LUN is present, so don't add sdev in these cases.
1149 SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
1156 res = scsi_add_lun(sdev, result, &bflags, shost->async_scan);
1159 sdev->lockable = 0;
1160 scsi_unlock_floptical(sdev, result);
1169 if (scsi_device_get(sdev) == 0) {
1170 *sdevp = sdev;
1172 __scsi_remove_device(sdev);
1177 __scsi_remove_device(sdev);
1229 * to alloc an sdev for lun > 0 on an already found SCSI_1 device.
1299 struct scsi_device *sdev;
1322 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) {
1323 sdev = scsi_alloc_sdev(starget, 0, NULL);
1324 if (!sdev)
1326 if (scsi_device_get(sdev)) {
1327 __scsi_remove_device(sdev);
1340 (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
1372 SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
1376 result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
1380 SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
1415 SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
1425 if (lun > sdev->host->max_lun) {
1426 sdev_printk(KERN_WARNING, sdev,
1438 sdev_printk(KERN_ERR, sdev,
1450 if (scsi_device_created(sdev))
1452 * the sdev we used didn't appear in the report luns scan
1454 __scsi_remove_device(sdev);
1455 scsi_device_put(sdev);
1462 struct scsi_device *sdev = ERR_PTR(-ENODEV);
1479 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
1491 return sdev;
1498 struct scsi_device *sdev =
1500 if (IS_ERR(sdev))
1501 return PTR_ERR(sdev);
1503 scsi_device_put(sdev);
1510 struct scsi_device *sdev = to_scsi_device(dev);
1514 scsi_attach_vpd(sdev);
1516 if (sdev->handler && sdev->handler->rescan)
1517 sdev->handler->rescan(sdev);
1691 struct scsi_device *sdev;
1692 shost_for_each_device(sdev, shost) {
1694 if (sdev->sdev_state == SDEV_DEL)
1697 if (sdev->is_visible)
1700 scsi_sysfs_add_sdev(sdev) != 0)
1701 __scsi_remove_device(sdev);
1863 struct scsi_device *sdev;
1868 list_for_each_entry(sdev, &shost->__devices, siblings) {
1869 if (sdev->sdev_state == SDEV_DEL)
1872 __scsi_remove_device(sdev);
1897 struct scsi_device *sdev = NULL;
1907 sdev = scsi_alloc_sdev(starget, 0, NULL);
1908 if (sdev)
1909 sdev->borken = 0;
1915 return sdev;
1921 * @sdev: Host device to be freed
1927 void scsi_free_host_dev(struct scsi_device *sdev)
1929 BUG_ON(sdev->id != sdev->host->this_id);
1931 __scsi_remove_device(sdev);