Lines Matching refs:sdev

234 /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */
438 struct scsi_device *sdev;
440 sdev = class_to_sdev(class_dev);
441 put_device(&sdev->sdev_gendev);
446 struct scsi_device *sdev = to_scsi_device(dev);
457 scsi_dh_release_device(sdev);
459 parent = sdev->sdev_gendev.parent;
461 spin_lock_irqsave(sdev->host->host_lock, flags);
462 list_del(&sdev->siblings);
463 list_del(&sdev->same_target_siblings);
464 list_del(&sdev->starved_entry);
465 spin_unlock_irqrestore(sdev->host->host_lock, flags);
467 cancel_work_sync(&sdev->event_work);
469 list_for_each_safe(this, tmp, &sdev->event_list) {
477 blk_put_queue(sdev->request_queue);
479 sdev->request_queue = NULL;
481 sbitmap_free(&sdev->budget_map);
483 mutex_lock(&sdev->inquiry_mutex);
484 vpd_pg0 = rcu_replace_pointer(sdev->vpd_pg0, vpd_pg0,
485 lockdep_is_held(&sdev->inquiry_mutex));
486 vpd_pg80 = rcu_replace_pointer(sdev->vpd_pg80, vpd_pg80,
487 lockdep_is_held(&sdev->inquiry_mutex));
488 vpd_pg83 = rcu_replace_pointer(sdev->vpd_pg83, vpd_pg83,
489 lockdep_is_held(&sdev->inquiry_mutex));
490 vpd_pg89 = rcu_replace_pointer(sdev->vpd_pg89, vpd_pg89,
491 lockdep_is_held(&sdev->inquiry_mutex));
492 vpd_pgb0 = rcu_replace_pointer(sdev->vpd_pgb0, vpd_pgb0,
493 lockdep_is_held(&sdev->inquiry_mutex));
494 vpd_pgb1 = rcu_replace_pointer(sdev->vpd_pgb1, vpd_pgb1,
495 lockdep_is_held(&sdev->inquiry_mutex));
496 vpd_pgb2 = rcu_replace_pointer(sdev->vpd_pgb2, vpd_pgb2,
497 lockdep_is_held(&sdev->inquiry_mutex));
498 vpd_pgb7 = rcu_replace_pointer(sdev->vpd_pgb7, vpd_pgb7,
499 lockdep_is_held(&sdev->inquiry_mutex));
500 mutex_unlock(&sdev->inquiry_mutex);
518 kfree(sdev->inquiry);
519 kfree(sdev);
546 const struct scsi_device *sdev;
551 sdev = to_scsi_device(dev);
553 add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
595 struct scsi_device *sdev; \
596 sdev = to_scsi_device(dev); \
597 return snprintf (buf, 20, format_string, sdev->field); \
620 struct scsi_device *sdev; \
621 sdev = to_scsi_device(dev); \
622 sscanf (buf, format_string, &sdev->field); \
642 struct scsi_device *sdev; \
645 sdev = to_scsi_device(dev); \
646 sdev->field = ret; \
684 struct scsi_device *sdev = to_scsi_device(dev);
685 return snprintf(buf, 20, "%d\n", scsi_device_busy(sdev));
693 struct scsi_device *sdev = to_scsi_device(dev);
694 return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_blocked));
704 struct scsi_device *sdev;
705 sdev = to_scsi_device(dev);
706 return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ);
713 struct scsi_device *sdev;
715 sdev = to_scsi_device(dev);
717 blk_queue_rq_timeout(sdev->request_queue, timeout * HZ);
725 struct scsi_device *sdev;
726 sdev = to_scsi_device(dev);
727 return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ);
734 struct scsi_device *sdev;
741 sdev = to_scsi_device(dev);
745 sdev->eh_timeout = eh_timeout * HZ;
765 struct scsi_device *sdev = to_scsi_device(dev);
771 if (scsi_device_get(sdev))
787 scsi_remove_device(sdev);
790 scsi_device_put(sdev);
800 struct scsi_device *sdev = to_scsi_device(dev);
820 mutex_lock(&sdev->state_mutex);
821 switch (sdev->sdev_state) {
826 mutex_unlock(&sdev->state_mutex);
829 if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) {
832 ret = scsi_device_set_state(sdev, state);
836 mutex_unlock(&sdev->state_mutex);
847 blk_mq_run_hw_queues(sdev->request_queue, true);
848 scsi_rescan_device(sdev);
857 struct scsi_device *sdev = to_scsi_device(dev);
858 const char *name = scsi_device_state_name(sdev->sdev_state);
872 struct scsi_device *sdev = to_scsi_device(dev);
875 if (sdev->simple_tags)
885 struct scsi_device *sdev = to_scsi_device(dev);
887 if (!sdev->tagged_supported)
890 sdev_printk(KERN_INFO, sdev,
905 struct scsi_device *sdev = to_scsi_device(dev); \
910 vpd_page = rcu_dereference(sdev->vpd_##_page); \
937 struct scsi_device *sdev = to_scsi_device(dev);
939 if (!sdev->inquiry)
942 return memory_read_from_buffer(buf, count, &off, sdev->inquiry,
943 sdev->inquiry_len);
969 struct scsi_device *sdev = to_scsi_device(dev); \
970 unsigned long long count = atomic_read(&sdev->field); \
983 struct scsi_device *sdev;
984 sdev = to_scsi_device(dev);
985 return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type);
994 struct scsi_device *sdev = to_scsi_device(dev); \
995 int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
1004 struct scsi_device *sdev = to_scsi_device(dev); \
1007 clear_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
1009 set_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
1034 struct scsi_device *sdev = to_scsi_device(dev);
1035 const struct scsi_host_template *sht = sdev->host->hostt;
1042 if (depth < 1 || depth > sdev->host->can_queue)
1045 retval = sht->change_queue_depth(sdev, depth);
1049 sdev->max_queue_depth = sdev->queue_depth;
1062 struct scsi_device *sdev = to_scsi_device(dev);
1065 count = scsi_vpd_lun_id(sdev, buf, PAGE_SIZE);
1085 struct scsi_device *sdev = to_scsi_device(dev);
1089 for (i = 0; i < sizeof(sdev->sdev_bflags) * BITS_PER_BYTE; i++) {
1092 if (!(sdev->sdev_bflags & (__force blist_flags_t)BIT(i)))
1115 struct scsi_device *sdev = to_scsi_device(dev);
1117 if (!sdev->handler)
1120 return snprintf(buf, 20, "%s\n", sdev->handler->name);
1127 struct scsi_device *sdev = to_scsi_device(dev);
1130 if (sdev->sdev_state == SDEV_CANCEL ||
1131 sdev->sdev_state == SDEV_DEL)
1134 if (!sdev->handler) {
1138 err = scsi_dh_attach(sdev->request_queue, buf);
1143 if (sdev->handler->activate)
1144 err = sdev->handler->activate(sdev, NULL, NULL);
1151 sdev_printk(KERN_WARNING, sdev,
1153 sdev->handler->name);
1168 struct scsi_device *sdev = to_scsi_device(dev);
1172 if (!sdev->handler)
1175 access_state = (sdev->access_state & SCSI_ACCESS_STATE_MASK);
1188 struct scsi_device *sdev = to_scsi_device(dev);
1190 if (!sdev->handler)
1193 if (sdev->access_state & SCSI_ACCESS_STATE_PREFERRED)
1206 struct scsi_device *sdev;
1207 sdev = to_scsi_device(dev);
1209 jiffies_to_msecs(sdev->queue_ramp_up_period));
1217 struct scsi_device *sdev = to_scsi_device(dev);
1223 sdev->queue_ramp_up_period = msecs_to_jiffies(period);
1234 struct scsi_device *sdev = to_scsi_device(dev);
1236 return sysfs_emit(buf, "%d\n", (int)sdev->cdl_enable);
1262 struct scsi_device *sdev = to_scsi_device(dev);
1266 !sdev->host->hostt->change_queue_depth)
1270 !sdev->host->hostt->change_queue_depth)
1280 struct scsi_device *sdev = to_scsi_device(dev);
1283 if (attr == &dev_attr_vpd_pg0 && !sdev->vpd_pg0)
1286 if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80)
1289 if (attr == &dev_attr_vpd_pg83 && !sdev->vpd_pg83)
1292 if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89)
1295 if (attr == &dev_attr_vpd_pgb0 && !sdev->vpd_pgb0)
1298 if (attr == &dev_attr_vpd_pgb1 && !sdev->vpd_pgb1)
1301 if (attr == &dev_attr_vpd_pgb2 && !sdev->vpd_pgb2)
1304 if (attr == &dev_attr_vpd_pgb7 && !sdev->vpd_pgb7)
1399 * @sdev: scsi_device to add
1404 int scsi_sysfs_add_sdev(struct scsi_device *sdev)
1407 struct scsi_target *starget = sdev->sdev_target;
1415 device_enable_async_suspend(&sdev->sdev_gendev);
1417 pm_runtime_set_active(&sdev->sdev_gendev);
1418 if (!sdev->rpm_autosuspend)
1419 pm_runtime_forbid(&sdev->sdev_gendev);
1420 pm_runtime_enable(&sdev->sdev_gendev);
1423 scsi_autopm_get_device(sdev);
1425 scsi_dh_add_device(sdev);
1427 error = device_add(&sdev->sdev_gendev);
1429 sdev_printk(KERN_INFO, sdev,
1434 device_enable_async_suspend(&sdev->sdev_dev);
1435 error = device_add(&sdev->sdev_dev);
1437 sdev_printk(KERN_INFO, sdev,
1439 device_del(&sdev->sdev_gendev);
1442 transport_add_device(&sdev->sdev_gendev);
1443 sdev->is_visible = 1;
1446 sdev->bsg_dev = scsi_bsg_register_queue(sdev);
1447 if (IS_ERR(sdev->bsg_dev)) {
1448 error = PTR_ERR(sdev->bsg_dev);
1449 sdev_printk(KERN_INFO, sdev,
1452 sdev->bsg_dev = NULL;
1456 scsi_autopm_put_device(sdev);
1460 void __scsi_remove_device(struct scsi_device *sdev)
1462 struct device *dev = &sdev->sdev_gendev;
1470 if (sdev->sdev_state == SDEV_DEL)
1473 if (sdev->is_visible) {
1478 mutex_lock(&sdev->state_mutex);
1484 res = scsi_device_set_state(sdev, SDEV_CANCEL);
1486 res = scsi_device_set_state(sdev, SDEV_DEL);
1488 scsi_start_queue(sdev);
1490 mutex_unlock(&sdev->state_mutex);
1495 if (IS_ENABLED(CONFIG_BLK_DEV_BSG) && sdev->bsg_dev)
1496 bsg_unregister_queue(sdev->bsg_dev);
1497 device_unregister(&sdev->sdev_dev);
1501 put_device(&sdev->sdev_dev);
1508 mutex_lock(&sdev->state_mutex);
1509 scsi_device_set_state(sdev, SDEV_DEL);
1510 mutex_unlock(&sdev->state_mutex);
1512 blk_mq_destroy_queue(sdev->request_queue);
1513 kref_put(&sdev->host->tagset_refcnt, scsi_mq_free_tags);
1514 cancel_work_sync(&sdev->requeue_work);
1516 if (sdev->host->hostt->slave_destroy)
1517 sdev->host->hostt->slave_destroy(sdev);
1525 scsi_target_reap(scsi_target(sdev));
1532 * @sdev: scsi_device to unregister
1534 void scsi_remove_device(struct scsi_device *sdev)
1536 struct Scsi_Host *shost = sdev->host;
1539 __scsi_remove_device(sdev);
1548 struct scsi_device *sdev;
1552 list_for_each_entry(sdev, &shost->__devices, siblings) {
1559 if (sdev->channel != starget->channel ||
1560 sdev->id != starget->id)
1562 if (sdev->sdev_state == SDEV_DEL ||
1563 sdev->sdev_state == SDEV_CANCEL ||
1564 !get_device(&sdev->sdev_gendev))
1567 scsi_remove_device(sdev);
1568 put_device(&sdev->sdev_gendev);
1646 void scsi_sysfs_device_initialize(struct scsi_device *sdev)
1649 struct Scsi_Host *shost = sdev->host;
1651 struct scsi_target *starget = sdev->sdev_target;
1653 device_initialize(&sdev->sdev_gendev);
1654 sdev->sdev_gendev.bus = &scsi_bus_type;
1655 sdev->sdev_gendev.type = &scsi_dev_type;
1656 scsi_enable_async_suspend(&sdev->sdev_gendev);
1657 dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu",
1658 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
1659 sdev->sdev_gendev.groups = hostt->sdev_groups;
1661 device_initialize(&sdev->sdev_dev);
1662 sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev);
1663 sdev->sdev_dev.class = &sdev_class;
1664 dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%llu",
1665 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
1669 * sdev->lun_in_cdb for the initial INQUIRY command. For LUN 0 the
1673 sdev->scsi_level = starget->scsi_level;
1674 if (sdev->scsi_level <= SCSI_2 &&
1675 sdev->scsi_level != SCSI_UNKNOWN &&
1677 sdev->lun_in_cdb = 1;
1679 transport_setup_device(&sdev->sdev_gendev);
1681 list_add_tail(&sdev->same_target_siblings, &starget->devices);
1682 list_add_tail(&sdev->siblings, &shost->__devices);