Lines Matching refs:sdev
439 struct scsi_device *sdev; in scsi_device_cls_release() local
441 sdev = class_to_sdev(class_dev); in scsi_device_cls_release()
442 put_device(&sdev->sdev_gendev); in scsi_device_cls_release()
447 struct scsi_device *sdev; in scsi_device_dev_release_usercontext() local
455 sdev = container_of(work, struct scsi_device, ew.work); in scsi_device_dev_release_usercontext()
457 mod = sdev->host->hostt->module; in scsi_device_dev_release_usercontext()
459 scsi_dh_release_device(sdev); in scsi_device_dev_release_usercontext()
461 parent = sdev->sdev_gendev.parent; in scsi_device_dev_release_usercontext()
463 spin_lock_irqsave(sdev->host->host_lock, flags); in scsi_device_dev_release_usercontext()
464 list_del(&sdev->siblings); in scsi_device_dev_release_usercontext()
465 list_del(&sdev->same_target_siblings); in scsi_device_dev_release_usercontext()
466 list_del(&sdev->starved_entry); in scsi_device_dev_release_usercontext()
467 spin_unlock_irqrestore(sdev->host->host_lock, flags); in scsi_device_dev_release_usercontext()
469 cancel_work_sync(&sdev->event_work); in scsi_device_dev_release_usercontext()
471 list_for_each_safe(this, tmp, &sdev->event_list) { in scsi_device_dev_release_usercontext()
479 blk_put_queue(sdev->request_queue); in scsi_device_dev_release_usercontext()
481 sdev->request_queue = NULL; in scsi_device_dev_release_usercontext()
483 mutex_lock(&sdev->inquiry_mutex); in scsi_device_dev_release_usercontext()
484 vpd_pg0 = rcu_replace_pointer(sdev->vpd_pg0, vpd_pg0, in scsi_device_dev_release_usercontext()
485 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_device_dev_release_usercontext()
486 vpd_pg80 = rcu_replace_pointer(sdev->vpd_pg80, vpd_pg80, in scsi_device_dev_release_usercontext()
487 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_device_dev_release_usercontext()
488 vpd_pg83 = rcu_replace_pointer(sdev->vpd_pg83, vpd_pg83, in scsi_device_dev_release_usercontext()
489 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_device_dev_release_usercontext()
490 vpd_pg89 = rcu_replace_pointer(sdev->vpd_pg89, vpd_pg89, in scsi_device_dev_release_usercontext()
491 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_device_dev_release_usercontext()
492 mutex_unlock(&sdev->inquiry_mutex); in scsi_device_dev_release_usercontext()
502 kfree(sdev->inquiry); in scsi_device_dev_release_usercontext()
503 kfree(sdev); in scsi_device_dev_release_usercontext()
543 struct scsi_device *sdev; in scsi_bus_uevent() local
548 sdev = to_scsi_device(dev); in scsi_bus_uevent()
550 add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type); in scsi_bus_uevent()
593 struct scsi_device *sdev; \
594 sdev = to_scsi_device(dev); \
595 return snprintf (buf, 20, format_string, sdev->field); \
618 struct scsi_device *sdev; \
619 sdev = to_scsi_device(dev); \
620 sscanf (buf, format_string, &sdev->field); \
640 struct scsi_device *sdev; \
643 sdev = to_scsi_device(dev); \
644 sdev->field = ret; \
681 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_device_busy() local
682 return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_busy)); in sdev_show_device_busy()
690 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_device_blocked() local
691 return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_blocked)); in sdev_show_device_blocked()
701 struct scsi_device *sdev; in sdev_show_timeout() local
702 sdev = to_scsi_device(dev); in sdev_show_timeout()
703 return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ); in sdev_show_timeout()
710 struct scsi_device *sdev; in sdev_store_timeout() local
712 sdev = to_scsi_device(dev); in sdev_store_timeout()
714 blk_queue_rq_timeout(sdev->request_queue, timeout * HZ); in sdev_store_timeout()
722 struct scsi_device *sdev; in sdev_show_eh_timeout() local
723 sdev = to_scsi_device(dev); in sdev_show_eh_timeout()
724 return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ); in sdev_show_eh_timeout()
731 struct scsi_device *sdev; in sdev_store_eh_timeout() local
738 sdev = to_scsi_device(dev); in sdev_store_eh_timeout()
742 sdev->eh_timeout = eh_timeout * HZ; in sdev_store_eh_timeout()
762 struct scsi_device *sdev = to_scsi_device(dev); in sdev_store_delete() local
768 if (scsi_device_get(sdev)) in sdev_store_delete()
784 scsi_remove_device(sdev); in sdev_store_delete()
787 scsi_device_put(sdev); in sdev_store_delete()
797 struct scsi_device *sdev = to_scsi_device(dev); in store_state_field() local
817 mutex_lock(&sdev->state_mutex); in store_state_field()
818 switch (sdev->sdev_state) { in store_state_field()
823 mutex_unlock(&sdev->state_mutex); in store_state_field()
826 if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) { in store_state_field()
829 ret = scsi_device_set_state(sdev, state); in store_state_field()
833 mutex_unlock(&sdev->state_mutex); in store_state_field()
844 blk_mq_run_hw_queues(sdev->request_queue, true); in store_state_field()
854 struct scsi_device *sdev = to_scsi_device(dev); in show_state_field() local
855 const char *name = scsi_device_state_name(sdev->sdev_state); in show_state_field()
869 struct scsi_device *sdev = to_scsi_device(dev); in show_queue_type_field() local
872 if (sdev->simple_tags) in show_queue_type_field()
882 struct scsi_device *sdev = to_scsi_device(dev); in store_queue_type_field() local
884 if (!sdev->tagged_supported) in store_queue_type_field()
887 sdev_printk(KERN_INFO, sdev, in store_queue_type_field()
902 struct scsi_device *sdev = to_scsi_device(dev); \
907 vpd_page = rcu_dereference(sdev->vpd_##_page); \
930 struct scsi_device *sdev = to_scsi_device(dev); in show_inquiry() local
932 if (!sdev->inquiry) in show_inquiry()
935 return memory_read_from_buffer(buf, count, &off, sdev->inquiry, in show_inquiry()
936 sdev->inquiry_len); in show_inquiry()
962 struct scsi_device *sdev = to_scsi_device(dev); \
963 unsigned long long count = atomic_read(&sdev->field); \
975 struct scsi_device *sdev; in sdev_show_modalias() local
976 sdev = to_scsi_device(dev); in sdev_show_modalias()
977 return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type); in sdev_show_modalias()
986 struct scsi_device *sdev = to_scsi_device(dev); \
987 int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
996 struct scsi_device *sdev = to_scsi_device(dev); \
999 clear_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
1001 set_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
1026 struct scsi_device *sdev = to_scsi_device(dev); in DECLARE_EVT() local
1027 struct scsi_host_template *sht = sdev->host->hostt; in DECLARE_EVT()
1034 if (depth < 1 || depth > sdev->host->can_queue) in DECLARE_EVT()
1037 retval = sht->change_queue_depth(sdev, depth); in DECLARE_EVT()
1041 sdev->max_queue_depth = sdev->queue_depth; in DECLARE_EVT()
1054 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_wwid() local
1057 count = scsi_vpd_lun_id(sdev, buf, PAGE_SIZE); in sdev_show_wwid()
1077 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_blacklist() local
1081 for (i = 0; i < sizeof(sdev->sdev_bflags) * BITS_PER_BYTE; i++) { in sdev_show_blacklist()
1084 if (!(sdev->sdev_bflags & (__force blist_flags_t)BIT(i))) in sdev_show_blacklist()
1107 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_dh_state() local
1109 if (!sdev->handler) in sdev_show_dh_state()
1112 return snprintf(buf, 20, "%s\n", sdev->handler->name); in sdev_show_dh_state()
1119 struct scsi_device *sdev = to_scsi_device(dev); in sdev_store_dh_state() local
1122 if (sdev->sdev_state == SDEV_CANCEL || in sdev_store_dh_state()
1123 sdev->sdev_state == SDEV_DEL) in sdev_store_dh_state()
1126 if (!sdev->handler) { in sdev_store_dh_state()
1130 err = scsi_dh_attach(sdev->request_queue, buf); in sdev_store_dh_state()
1135 if (sdev->handler->activate) in sdev_store_dh_state()
1136 err = sdev->handler->activate(sdev, NULL, NULL); in sdev_store_dh_state()
1143 sdev_printk(KERN_WARNING, sdev, in sdev_store_dh_state()
1145 sdev->handler->name); in sdev_store_dh_state()
1160 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_access_state() local
1164 if (!sdev->handler) in sdev_show_access_state()
1167 access_state = (sdev->access_state & SCSI_ACCESS_STATE_MASK); in sdev_show_access_state()
1180 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_preferred_path() local
1182 if (!sdev->handler) in sdev_show_preferred_path()
1185 if (sdev->access_state & SCSI_ACCESS_STATE_PREFERRED) in sdev_show_preferred_path()
1198 struct scsi_device *sdev; in sdev_show_queue_ramp_up_period() local
1199 sdev = to_scsi_device(dev); in sdev_show_queue_ramp_up_period()
1201 jiffies_to_msecs(sdev->queue_ramp_up_period)); in sdev_show_queue_ramp_up_period()
1209 struct scsi_device *sdev = to_scsi_device(dev); in sdev_store_queue_ramp_up_period() local
1215 sdev->queue_ramp_up_period = msecs_to_jiffies(period); in sdev_store_queue_ramp_up_period()
1227 struct scsi_device *sdev = to_scsi_device(dev); in scsi_sdev_attr_is_visible() local
1231 !sdev->host->hostt->change_queue_depth) in scsi_sdev_attr_is_visible()
1235 !sdev->host->hostt->change_queue_depth) in scsi_sdev_attr_is_visible()
1240 !sdev->handler) in scsi_sdev_attr_is_visible()
1243 !sdev->handler) in scsi_sdev_attr_is_visible()
1253 struct scsi_device *sdev = to_scsi_device(dev); in scsi_sdev_bin_attr_is_visible() local
1256 if (attr == &dev_attr_vpd_pg0 && !sdev->vpd_pg0) in scsi_sdev_bin_attr_is_visible()
1259 if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80) in scsi_sdev_bin_attr_is_visible()
1262 if (attr == &dev_attr_vpd_pg83 && !sdev->vpd_pg83) in scsi_sdev_bin_attr_is_visible()
1265 if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89) in scsi_sdev_bin_attr_is_visible()
1358 int scsi_sysfs_add_sdev(struct scsi_device *sdev) in scsi_sysfs_add_sdev() argument
1361 struct request_queue *rq = sdev->request_queue; in scsi_sysfs_add_sdev()
1362 struct scsi_target *starget = sdev->sdev_target; in scsi_sysfs_add_sdev()
1370 device_enable_async_suspend(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1372 pm_runtime_set_active(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1373 if (!sdev->rpm_autosuspend) in scsi_sysfs_add_sdev()
1374 pm_runtime_forbid(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1375 pm_runtime_enable(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1378 scsi_autopm_get_device(sdev); in scsi_sysfs_add_sdev()
1380 scsi_dh_add_device(sdev); in scsi_sysfs_add_sdev()
1382 error = device_add(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1384 sdev_printk(KERN_INFO, sdev, in scsi_sysfs_add_sdev()
1389 device_enable_async_suspend(&sdev->sdev_dev); in scsi_sysfs_add_sdev()
1390 error = device_add(&sdev->sdev_dev); in scsi_sysfs_add_sdev()
1392 sdev_printk(KERN_INFO, sdev, in scsi_sysfs_add_sdev()
1394 device_del(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1397 transport_add_device(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1398 sdev->is_visible = 1; in scsi_sysfs_add_sdev()
1400 error = bsg_scsi_register_queue(rq, &sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1404 sdev_printk(KERN_INFO, sdev, in scsi_sysfs_add_sdev()
1408 if (sdev->host->hostt->sdev_attrs) { in scsi_sysfs_add_sdev()
1409 for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) { in scsi_sysfs_add_sdev()
1410 error = device_create_file(&sdev->sdev_gendev, in scsi_sysfs_add_sdev()
1411 sdev->host->hostt->sdev_attrs[i]); in scsi_sysfs_add_sdev()
1417 if (sdev->host->hostt->sdev_groups) { in scsi_sysfs_add_sdev()
1418 error = sysfs_create_groups(&sdev->sdev_gendev.kobj, in scsi_sysfs_add_sdev()
1419 sdev->host->hostt->sdev_groups); in scsi_sysfs_add_sdev()
1424 scsi_autopm_put_device(sdev); in scsi_sysfs_add_sdev()
1428 void __scsi_remove_device(struct scsi_device *sdev) in __scsi_remove_device() argument
1430 struct device *dev = &sdev->sdev_gendev; in __scsi_remove_device()
1438 if (sdev->sdev_state == SDEV_DEL) in __scsi_remove_device()
1441 if (sdev->is_visible) { in __scsi_remove_device()
1446 mutex_lock(&sdev->state_mutex); in __scsi_remove_device()
1452 res = scsi_device_set_state(sdev, SDEV_CANCEL); in __scsi_remove_device()
1454 res = scsi_device_set_state(sdev, SDEV_DEL); in __scsi_remove_device()
1456 scsi_start_queue(sdev); in __scsi_remove_device()
1458 mutex_unlock(&sdev->state_mutex); in __scsi_remove_device()
1463 if (sdev->host->hostt->sdev_groups) in __scsi_remove_device()
1464 sysfs_remove_groups(&sdev->sdev_gendev.kobj, in __scsi_remove_device()
1465 sdev->host->hostt->sdev_groups); in __scsi_remove_device()
1467 bsg_unregister_queue(sdev->request_queue); in __scsi_remove_device()
1468 device_unregister(&sdev->sdev_dev); in __scsi_remove_device()
1472 put_device(&sdev->sdev_dev); in __scsi_remove_device()
1479 mutex_lock(&sdev->state_mutex); in __scsi_remove_device()
1480 scsi_device_set_state(sdev, SDEV_DEL); in __scsi_remove_device()
1481 mutex_unlock(&sdev->state_mutex); in __scsi_remove_device()
1483 blk_cleanup_queue(sdev->request_queue); in __scsi_remove_device()
1484 cancel_work_sync(&sdev->requeue_work); in __scsi_remove_device()
1486 if (sdev->host->hostt->slave_destroy) in __scsi_remove_device()
1487 sdev->host->hostt->slave_destroy(sdev); in __scsi_remove_device()
1495 scsi_target_reap(scsi_target(sdev)); in __scsi_remove_device()
1504 void scsi_remove_device(struct scsi_device *sdev) in scsi_remove_device() argument
1506 struct Scsi_Host *shost = sdev->host; in scsi_remove_device()
1509 __scsi_remove_device(sdev); in scsi_remove_device()
1518 struct scsi_device *sdev; in __scsi_remove_target() local
1522 list_for_each_entry(sdev, &shost->__devices, siblings) { in __scsi_remove_target()
1529 if (sdev->channel != starget->channel || in __scsi_remove_target()
1530 sdev->id != starget->id) in __scsi_remove_target()
1532 if (sdev->sdev_state == SDEV_DEL || in __scsi_remove_target()
1533 sdev->sdev_state == SDEV_CANCEL || in __scsi_remove_target()
1534 !get_device(&sdev->sdev_gendev)) in __scsi_remove_target()
1537 scsi_remove_device(sdev); in __scsi_remove_target()
1538 put_device(&sdev->sdev_gendev); in __scsi_remove_target()
1627 void scsi_sysfs_device_initialize(struct scsi_device *sdev) in scsi_sysfs_device_initialize() argument
1630 struct Scsi_Host *shost = sdev->host; in scsi_sysfs_device_initialize()
1631 struct scsi_target *starget = sdev->sdev_target; in scsi_sysfs_device_initialize()
1633 device_initialize(&sdev->sdev_gendev); in scsi_sysfs_device_initialize()
1634 sdev->sdev_gendev.bus = &scsi_bus_type; in scsi_sysfs_device_initialize()
1635 sdev->sdev_gendev.type = &scsi_dev_type; in scsi_sysfs_device_initialize()
1636 dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu", in scsi_sysfs_device_initialize()
1637 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); in scsi_sysfs_device_initialize()
1639 device_initialize(&sdev->sdev_dev); in scsi_sysfs_device_initialize()
1640 sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev); in scsi_sysfs_device_initialize()
1641 sdev->sdev_dev.class = &sdev_class; in scsi_sysfs_device_initialize()
1642 dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%llu", in scsi_sysfs_device_initialize()
1643 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); in scsi_sysfs_device_initialize()
1651 sdev->scsi_level = starget->scsi_level; in scsi_sysfs_device_initialize()
1652 if (sdev->scsi_level <= SCSI_2 && in scsi_sysfs_device_initialize()
1653 sdev->scsi_level != SCSI_UNKNOWN && in scsi_sysfs_device_initialize()
1655 sdev->lun_in_cdb = 1; in scsi_sysfs_device_initialize()
1657 transport_setup_device(&sdev->sdev_gendev); in scsi_sysfs_device_initialize()
1659 list_add_tail(&sdev->same_target_siblings, &starget->devices); in scsi_sysfs_device_initialize()
1660 list_add_tail(&sdev->siblings, &shost->__devices); in scsi_sysfs_device_initialize()