Lines Matching refs:sdev

428 	struct scsi_device *sdev;  in scsi_device_cls_release()  local
430 sdev = class_to_sdev(class_dev); in scsi_device_cls_release()
431 put_device(&sdev->sdev_gendev); in scsi_device_cls_release()
436 struct scsi_device *sdev; in scsi_device_dev_release_usercontext() local
442 sdev = container_of(work, struct scsi_device, ew.work); in scsi_device_dev_release_usercontext()
444 scsi_dh_release_device(sdev); in scsi_device_dev_release_usercontext()
446 parent = sdev->sdev_gendev.parent; in scsi_device_dev_release_usercontext()
448 spin_lock_irqsave(sdev->host->host_lock, flags); in scsi_device_dev_release_usercontext()
449 list_del(&sdev->siblings); in scsi_device_dev_release_usercontext()
450 list_del(&sdev->same_target_siblings); in scsi_device_dev_release_usercontext()
451 list_del(&sdev->starved_entry); in scsi_device_dev_release_usercontext()
452 spin_unlock_irqrestore(sdev->host->host_lock, flags); in scsi_device_dev_release_usercontext()
454 cancel_work_sync(&sdev->event_work); in scsi_device_dev_release_usercontext()
456 list_for_each_safe(this, tmp, &sdev->event_list) { in scsi_device_dev_release_usercontext()
464 blk_put_queue(sdev->request_queue); in scsi_device_dev_release_usercontext()
466 sdev->request_queue = NULL; in scsi_device_dev_release_usercontext()
468 mutex_lock(&sdev->inquiry_mutex); in scsi_device_dev_release_usercontext()
469 rcu_swap_protected(sdev->vpd_pg80, vpd_pg80, in scsi_device_dev_release_usercontext()
470 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_device_dev_release_usercontext()
471 rcu_swap_protected(sdev->vpd_pg83, vpd_pg83, in scsi_device_dev_release_usercontext()
472 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_device_dev_release_usercontext()
473 mutex_unlock(&sdev->inquiry_mutex); in scsi_device_dev_release_usercontext()
479 kfree(sdev->inquiry); in scsi_device_dev_release_usercontext()
480 kfree(sdev); in scsi_device_dev_release_usercontext()
514 struct scsi_device *sdev; in scsi_bus_uevent() local
519 sdev = to_scsi_device(dev); in scsi_bus_uevent()
521 add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type); in scsi_bus_uevent()
564 struct scsi_device *sdev; \
565 sdev = to_scsi_device(dev); \
566 return snprintf (buf, 20, format_string, sdev->field); \
589 struct scsi_device *sdev; \
590 sdev = to_scsi_device(dev); \
591 sscanf (buf, format_string, &sdev->field); \
611 struct scsi_device *sdev; \
614 sdev = to_scsi_device(dev); \
615 sdev->field = ret; \
652 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_device_busy() local
653 return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_busy)); in sdev_show_device_busy()
661 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_device_blocked() local
662 return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_blocked)); in sdev_show_device_blocked()
672 struct scsi_device *sdev; in sdev_show_timeout() local
673 sdev = to_scsi_device(dev); in sdev_show_timeout()
674 return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ); in sdev_show_timeout()
681 struct scsi_device *sdev; in sdev_store_timeout() local
683 sdev = to_scsi_device(dev); in sdev_store_timeout()
685 blk_queue_rq_timeout(sdev->request_queue, timeout * HZ); in sdev_store_timeout()
693 struct scsi_device *sdev; in sdev_show_eh_timeout() local
694 sdev = to_scsi_device(dev); in sdev_show_eh_timeout()
695 return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ); in sdev_show_eh_timeout()
702 struct scsi_device *sdev; in sdev_store_eh_timeout() local
709 sdev = to_scsi_device(dev); in sdev_store_eh_timeout()
713 sdev->eh_timeout = eh_timeout * HZ; in sdev_store_eh_timeout()
733 struct scsi_device *sdev = to_scsi_device(dev); in sdev_store_delete() local
739 if (scsi_device_get(sdev)) in sdev_store_delete()
755 scsi_remove_device(sdev); in sdev_store_delete()
758 scsi_device_put(sdev); in sdev_store_delete()
768 struct scsi_device *sdev = to_scsi_device(dev); in store_state_field() local
787 mutex_lock(&sdev->state_mutex); in store_state_field()
788 ret = scsi_device_set_state(sdev, state); in store_state_field()
794 blk_mq_run_hw_queues(sdev->request_queue, true); in store_state_field()
795 mutex_unlock(&sdev->state_mutex); in store_state_field()
803 struct scsi_device *sdev = to_scsi_device(dev); in show_state_field() local
804 const char *name = scsi_device_state_name(sdev->sdev_state); in show_state_field()
818 struct scsi_device *sdev = to_scsi_device(dev); in show_queue_type_field() local
821 if (sdev->simple_tags) in show_queue_type_field()
831 struct scsi_device *sdev = to_scsi_device(dev); in store_queue_type_field() local
833 if (!sdev->tagged_supported) in store_queue_type_field()
836 sdev_printk(KERN_INFO, sdev, in store_queue_type_field()
851 struct scsi_device *sdev = to_scsi_device(dev); \
856 vpd_page = rcu_dereference(sdev->vpd_##_page); \
877 struct scsi_device *sdev = to_scsi_device(dev); in show_inquiry() local
879 if (!sdev->inquiry) in show_inquiry()
882 return memory_read_from_buffer(buf, count, &off, sdev->inquiry, in show_inquiry()
883 sdev->inquiry_len); in show_inquiry()
909 struct scsi_device *sdev = to_scsi_device(dev); \
910 unsigned long long count = atomic_read(&sdev->field); \
922 struct scsi_device *sdev; in sdev_show_modalias() local
923 sdev = to_scsi_device(dev); in sdev_show_modalias()
924 return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type); in sdev_show_modalias()
933 struct scsi_device *sdev = to_scsi_device(dev); \
934 int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
943 struct scsi_device *sdev = to_scsi_device(dev); \
946 clear_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
948 set_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
973 struct scsi_device *sdev = to_scsi_device(dev); in DECLARE_EVT() local
974 struct scsi_host_template *sht = sdev->host->hostt; in DECLARE_EVT()
981 if (depth < 1 || depth > sdev->host->can_queue) in DECLARE_EVT()
984 retval = sht->change_queue_depth(sdev, depth); in DECLARE_EVT()
988 sdev->max_queue_depth = sdev->queue_depth; in DECLARE_EVT()
1001 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_wwid() local
1004 count = scsi_vpd_lun_id(sdev, buf, PAGE_SIZE); in sdev_show_wwid()
1024 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_blacklist() local
1028 for (i = 0; i < sizeof(sdev->sdev_bflags) * BITS_PER_BYTE; i++) { in sdev_show_blacklist()
1031 if (!(sdev->sdev_bflags & (__force blist_flags_t)BIT(i))) in sdev_show_blacklist()
1054 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_dh_state() local
1056 if (!sdev->handler) in sdev_show_dh_state()
1059 return snprintf(buf, 20, "%s\n", sdev->handler->name); in sdev_show_dh_state()
1066 struct scsi_device *sdev = to_scsi_device(dev); in sdev_store_dh_state() local
1069 if (sdev->sdev_state == SDEV_CANCEL || in sdev_store_dh_state()
1070 sdev->sdev_state == SDEV_DEL) in sdev_store_dh_state()
1073 if (!sdev->handler) { in sdev_store_dh_state()
1077 err = scsi_dh_attach(sdev->request_queue, buf); in sdev_store_dh_state()
1082 if (sdev->handler->activate) in sdev_store_dh_state()
1083 err = sdev->handler->activate(sdev, NULL, NULL); in sdev_store_dh_state()
1090 sdev_printk(KERN_WARNING, sdev, in sdev_store_dh_state()
1092 sdev->handler->name); in sdev_store_dh_state()
1107 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_access_state() local
1111 if (!sdev->handler) in sdev_show_access_state()
1114 access_state = (sdev->access_state & SCSI_ACCESS_STATE_MASK); in sdev_show_access_state()
1127 struct scsi_device *sdev = to_scsi_device(dev); in sdev_show_preferred_path() local
1129 if (!sdev->handler) in sdev_show_preferred_path()
1132 if (sdev->access_state & SCSI_ACCESS_STATE_PREFERRED) in sdev_show_preferred_path()
1145 struct scsi_device *sdev; in sdev_show_queue_ramp_up_period() local
1146 sdev = to_scsi_device(dev); in sdev_show_queue_ramp_up_period()
1148 jiffies_to_msecs(sdev->queue_ramp_up_period)); in sdev_show_queue_ramp_up_period()
1156 struct scsi_device *sdev = to_scsi_device(dev); in sdev_store_queue_ramp_up_period() local
1162 sdev->queue_ramp_up_period = msecs_to_jiffies(period); in sdev_store_queue_ramp_up_period()
1174 struct scsi_device *sdev = to_scsi_device(dev); in scsi_sdev_attr_is_visible() local
1178 !sdev->host->hostt->change_queue_depth) in scsi_sdev_attr_is_visible()
1182 !sdev->host->hostt->change_queue_depth) in scsi_sdev_attr_is_visible()
1187 !sdev->handler) in scsi_sdev_attr_is_visible()
1190 !sdev->handler) in scsi_sdev_attr_is_visible()
1200 struct scsi_device *sdev = to_scsi_device(dev); in scsi_sdev_bin_attr_is_visible() local
1203 if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80) in scsi_sdev_bin_attr_is_visible()
1206 if (attr == &dev_attr_vpd_pg83 && !sdev->vpd_pg83) in scsi_sdev_bin_attr_is_visible()
1297 int scsi_sysfs_add_sdev(struct scsi_device *sdev) in scsi_sysfs_add_sdev() argument
1300 struct request_queue *rq = sdev->request_queue; in scsi_sysfs_add_sdev()
1301 struct scsi_target *starget = sdev->sdev_target; in scsi_sysfs_add_sdev()
1309 device_enable_async_suspend(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1311 pm_runtime_set_active(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1312 pm_runtime_forbid(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1313 pm_runtime_enable(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1316 scsi_autopm_get_device(sdev); in scsi_sysfs_add_sdev()
1318 scsi_dh_add_device(sdev); in scsi_sysfs_add_sdev()
1320 error = device_add(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1322 sdev_printk(KERN_INFO, sdev, in scsi_sysfs_add_sdev()
1327 device_enable_async_suspend(&sdev->sdev_dev); in scsi_sysfs_add_sdev()
1328 error = device_add(&sdev->sdev_dev); in scsi_sysfs_add_sdev()
1330 sdev_printk(KERN_INFO, sdev, in scsi_sysfs_add_sdev()
1332 device_del(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1335 transport_add_device(&sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1336 sdev->is_visible = 1; in scsi_sysfs_add_sdev()
1338 error = bsg_scsi_register_queue(rq, &sdev->sdev_gendev); in scsi_sysfs_add_sdev()
1342 sdev_printk(KERN_INFO, sdev, in scsi_sysfs_add_sdev()
1346 if (sdev->host->hostt->sdev_attrs) { in scsi_sysfs_add_sdev()
1347 for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) { in scsi_sysfs_add_sdev()
1348 error = device_create_file(&sdev->sdev_gendev, in scsi_sysfs_add_sdev()
1349 sdev->host->hostt->sdev_attrs[i]); in scsi_sysfs_add_sdev()
1355 if (sdev->host->hostt->sdev_groups) { in scsi_sysfs_add_sdev()
1356 error = sysfs_create_groups(&sdev->sdev_gendev.kobj, in scsi_sysfs_add_sdev()
1357 sdev->host->hostt->sdev_groups); in scsi_sysfs_add_sdev()
1362 scsi_autopm_put_device(sdev); in scsi_sysfs_add_sdev()
1366 void __scsi_remove_device(struct scsi_device *sdev) in __scsi_remove_device() argument
1368 struct device *dev = &sdev->sdev_gendev; in __scsi_remove_device()
1376 if (sdev->sdev_state == SDEV_DEL) in __scsi_remove_device()
1379 if (sdev->is_visible) { in __scsi_remove_device()
1384 mutex_lock(&sdev->state_mutex); in __scsi_remove_device()
1390 res = scsi_device_set_state(sdev, SDEV_CANCEL); in __scsi_remove_device()
1392 res = scsi_device_set_state(sdev, SDEV_DEL); in __scsi_remove_device()
1394 scsi_start_queue(sdev); in __scsi_remove_device()
1396 mutex_unlock(&sdev->state_mutex); in __scsi_remove_device()
1401 if (sdev->host->hostt->sdev_groups) in __scsi_remove_device()
1402 sysfs_remove_groups(&sdev->sdev_gendev.kobj, in __scsi_remove_device()
1403 sdev->host->hostt->sdev_groups); in __scsi_remove_device()
1405 bsg_unregister_queue(sdev->request_queue); in __scsi_remove_device()
1406 device_unregister(&sdev->sdev_dev); in __scsi_remove_device()
1410 put_device(&sdev->sdev_dev); in __scsi_remove_device()
1417 mutex_lock(&sdev->state_mutex); in __scsi_remove_device()
1418 scsi_device_set_state(sdev, SDEV_DEL); in __scsi_remove_device()
1419 mutex_unlock(&sdev->state_mutex); in __scsi_remove_device()
1421 blk_cleanup_queue(sdev->request_queue); in __scsi_remove_device()
1422 cancel_work_sync(&sdev->requeue_work); in __scsi_remove_device()
1424 if (sdev->host->hostt->slave_destroy) in __scsi_remove_device()
1425 sdev->host->hostt->slave_destroy(sdev); in __scsi_remove_device()
1433 scsi_target_reap(scsi_target(sdev)); in __scsi_remove_device()
1442 void scsi_remove_device(struct scsi_device *sdev) in scsi_remove_device() argument
1444 struct Scsi_Host *shost = sdev->host; in scsi_remove_device()
1447 __scsi_remove_device(sdev); in scsi_remove_device()
1456 struct scsi_device *sdev; in __scsi_remove_target() local
1460 list_for_each_entry(sdev, &shost->__devices, siblings) { in __scsi_remove_target()
1467 if (sdev->channel != starget->channel || in __scsi_remove_target()
1468 sdev->id != starget->id) in __scsi_remove_target()
1470 if (sdev->sdev_state == SDEV_DEL || in __scsi_remove_target()
1471 sdev->sdev_state == SDEV_CANCEL || in __scsi_remove_target()
1472 !get_device(&sdev->sdev_gendev)) in __scsi_remove_target()
1475 scsi_remove_device(sdev); in __scsi_remove_target()
1476 put_device(&sdev->sdev_gendev); in __scsi_remove_target()
1565 void scsi_sysfs_device_initialize(struct scsi_device *sdev) in scsi_sysfs_device_initialize() argument
1568 struct Scsi_Host *shost = sdev->host; in scsi_sysfs_device_initialize()
1569 struct scsi_target *starget = sdev->sdev_target; in scsi_sysfs_device_initialize()
1571 device_initialize(&sdev->sdev_gendev); in scsi_sysfs_device_initialize()
1572 sdev->sdev_gendev.bus = &scsi_bus_type; in scsi_sysfs_device_initialize()
1573 sdev->sdev_gendev.type = &scsi_dev_type; in scsi_sysfs_device_initialize()
1574 dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu", in scsi_sysfs_device_initialize()
1575 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); in scsi_sysfs_device_initialize()
1577 device_initialize(&sdev->sdev_dev); in scsi_sysfs_device_initialize()
1578 sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev); in scsi_sysfs_device_initialize()
1579 sdev->sdev_dev.class = &sdev_class; in scsi_sysfs_device_initialize()
1580 dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%llu", in scsi_sysfs_device_initialize()
1581 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); in scsi_sysfs_device_initialize()
1589 sdev->scsi_level = starget->scsi_level; in scsi_sysfs_device_initialize()
1590 if (sdev->scsi_level <= SCSI_2 && in scsi_sysfs_device_initialize()
1591 sdev->scsi_level != SCSI_UNKNOWN && in scsi_sysfs_device_initialize()
1593 sdev->lun_in_cdb = 1; in scsi_sysfs_device_initialize()
1595 transport_setup_device(&sdev->sdev_gendev); in scsi_sysfs_device_initialize()
1597 list_add_tail(&sdev->same_target_siblings, &starget->devices); in scsi_sysfs_device_initialize()
1598 list_add_tail(&sdev->siblings, &shost->__devices); in scsi_sysfs_device_initialize()