Lines Matching defs: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);
456 scsi_dh_release_device(sdev);
458 parent = sdev->sdev_gendev.parent;
460 spin_lock_irqsave(sdev->host->host_lock, flags);
461 list_del(&sdev->siblings);
462 list_del(&sdev->same_target_siblings);
463 list_del(&sdev->starved_entry);
464 spin_unlock_irqrestore(sdev->host->host_lock, flags);
466 cancel_work_sync(&sdev->event_work);
468 list_for_each_safe(this, tmp, &sdev->event_list) {
476 blk_put_queue(sdev->request_queue);
478 sdev->request_queue = NULL;
480 sbitmap_free(&sdev->budget_map);
482 mutex_lock(&sdev->inquiry_mutex);
483 vpd_pg0 = rcu_replace_pointer(sdev->vpd_pg0, vpd_pg0,
484 lockdep_is_held(&sdev->inquiry_mutex));
485 vpd_pg80 = rcu_replace_pointer(sdev->vpd_pg80, vpd_pg80,
486 lockdep_is_held(&sdev->inquiry_mutex));
487 vpd_pg83 = rcu_replace_pointer(sdev->vpd_pg83, vpd_pg83,
488 lockdep_is_held(&sdev->inquiry_mutex));
489 vpd_pg89 = rcu_replace_pointer(sdev->vpd_pg89, vpd_pg89,
490 lockdep_is_held(&sdev->inquiry_mutex));
491 vpd_pgb0 = rcu_replace_pointer(sdev->vpd_pgb0, vpd_pgb0,
492 lockdep_is_held(&sdev->inquiry_mutex));
493 vpd_pgb1 = rcu_replace_pointer(sdev->vpd_pgb1, vpd_pgb1,
494 lockdep_is_held(&sdev->inquiry_mutex));
495 vpd_pgb2 = rcu_replace_pointer(sdev->vpd_pgb2, vpd_pgb2,
496 lockdep_is_held(&sdev->inquiry_mutex));
497 mutex_unlock(&sdev->inquiry_mutex);
513 kfree(sdev->inquiry);
514 kfree(sdev);
541 const struct scsi_device *sdev;
546 sdev = to_scsi_device(dev);
548 add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
590 struct scsi_device *sdev; \
591 sdev = to_scsi_device(dev); \
592 return snprintf (buf, 20, format_string, sdev->field); \
615 struct scsi_device *sdev; \
616 sdev = to_scsi_device(dev); \
617 sscanf (buf, format_string, &sdev->field); \
637 struct scsi_device *sdev; \
640 sdev = to_scsi_device(dev); \
641 sdev->field = ret; \
679 struct scsi_device *sdev = to_scsi_device(dev);
680 return snprintf(buf, 20, "%d\n", scsi_device_busy(sdev));
688 struct scsi_device *sdev = to_scsi_device(dev);
689 return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_blocked));
699 struct scsi_device *sdev;
700 sdev = to_scsi_device(dev);
701 return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ);
708 struct scsi_device *sdev;
710 sdev = to_scsi_device(dev);
712 blk_queue_rq_timeout(sdev->request_queue, timeout * HZ);
720 struct scsi_device *sdev;
721 sdev = to_scsi_device(dev);
722 return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ);
729 struct scsi_device *sdev;
736 sdev = to_scsi_device(dev);
740 sdev->eh_timeout = eh_timeout * HZ;
760 struct scsi_device *sdev = to_scsi_device(dev);
766 if (scsi_device_get(sdev))
782 scsi_remove_device(sdev);
785 scsi_device_put(sdev);
795 struct scsi_device *sdev = to_scsi_device(dev);
815 mutex_lock(&sdev->state_mutex);
816 switch (sdev->sdev_state) {
821 mutex_unlock(&sdev->state_mutex);
824 if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) {
827 ret = scsi_device_set_state(sdev, state);
831 mutex_unlock(&sdev->state_mutex);
842 blk_mq_run_hw_queues(sdev->request_queue, true);
843 scsi_rescan_device(sdev);
852 struct scsi_device *sdev = to_scsi_device(dev);
853 const char *name = scsi_device_state_name(sdev->sdev_state);
867 struct scsi_device *sdev = to_scsi_device(dev);
870 if (sdev->simple_tags)
880 struct scsi_device *sdev = to_scsi_device(dev);
882 if (!sdev->tagged_supported)
885 sdev_printk(KERN_INFO, sdev,
900 struct scsi_device *sdev = to_scsi_device(dev); \
905 vpd_page = rcu_dereference(sdev->vpd_##_page); \
931 struct scsi_device *sdev = to_scsi_device(dev);
933 if (!sdev->inquiry)
936 return memory_read_from_buffer(buf, count, &off, sdev->inquiry,
937 sdev->inquiry_len);
963 struct scsi_device *sdev = to_scsi_device(dev); \
964 unsigned long long count = atomic_read(&sdev->field); \
977 struct scsi_device *sdev;
978 sdev = to_scsi_device(dev);
979 return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type);
988 struct scsi_device *sdev = to_scsi_device(dev); \
989 int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
998 struct scsi_device *sdev = to_scsi_device(dev); \
1001 clear_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
1003 set_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
1028 struct scsi_device *sdev = to_scsi_device(dev);
1029 const struct scsi_host_template *sht = sdev->host->hostt;
1036 if (depth < 1 || depth > sdev->host->can_queue)
1039 retval = sht->change_queue_depth(sdev, depth);
1043 sdev->max_queue_depth = sdev->queue_depth;
1056 struct scsi_device *sdev = to_scsi_device(dev);
1059 count = scsi_vpd_lun_id(sdev, buf, PAGE_SIZE);
1079 struct scsi_device *sdev = to_scsi_device(dev);
1083 for (i = 0; i < sizeof(sdev->sdev_bflags) * BITS_PER_BYTE; i++) {
1086 if (!(sdev->sdev_bflags & (__force blist_flags_t)BIT(i)))
1109 struct scsi_device *sdev = to_scsi_device(dev);
1111 if (!sdev->handler)
1114 return snprintf(buf, 20, "%s\n", sdev->handler->name);
1121 struct scsi_device *sdev = to_scsi_device(dev);
1124 if (sdev->sdev_state == SDEV_CANCEL ||
1125 sdev->sdev_state == SDEV_DEL)
1128 if (!sdev->handler) {
1132 err = scsi_dh_attach(sdev->request_queue, buf);
1137 if (sdev->handler->activate)
1138 err = sdev->handler->activate(sdev, NULL, NULL);
1145 sdev_printk(KERN_WARNING, sdev,
1147 sdev->handler->name);
1162 struct scsi_device *sdev = to_scsi_device(dev);
1166 if (!sdev->handler)
1169 access_state = (sdev->access_state & SCSI_ACCESS_STATE_MASK);
1182 struct scsi_device *sdev = to_scsi_device(dev);
1184 if (!sdev->handler)
1187 if (sdev->access_state & SCSI_ACCESS_STATE_PREFERRED)
1200 struct scsi_device *sdev;
1201 sdev = to_scsi_device(dev);
1203 jiffies_to_msecs(sdev->queue_ramp_up_period));
1211 struct scsi_device *sdev = to_scsi_device(dev);
1217 sdev->queue_ramp_up_period = msecs_to_jiffies(period);
1228 struct scsi_device *sdev = to_scsi_device(dev);
1230 return sysfs_emit(buf, "%d\n", (int)sdev->cdl_enable);
1256 struct scsi_device *sdev = to_scsi_device(dev);
1260 !sdev->host->hostt->change_queue_depth)
1264 !sdev->host->hostt->change_queue_depth)
1274 struct scsi_device *sdev = to_scsi_device(dev);
1277 if (attr == &dev_attr_vpd_pg0 && !sdev->vpd_pg0)
1280 if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80)
1283 if (attr == &dev_attr_vpd_pg83 && !sdev->vpd_pg83)
1286 if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89)
1289 if (attr == &dev_attr_vpd_pgb0 && !sdev->vpd_pgb0)
1292 if (attr == &dev_attr_vpd_pgb1 && !sdev->vpd_pgb1)
1295 if (attr == &dev_attr_vpd_pgb2 && !sdev->vpd_pgb2)
1389 * @sdev: scsi_device to add
1394 int scsi_sysfs_add_sdev(struct scsi_device *sdev)
1397 struct scsi_target *starget = sdev->sdev_target;
1405 device_enable_async_suspend(&sdev->sdev_gendev);
1407 pm_runtime_set_active(&sdev->sdev_gendev);
1408 if (!sdev->rpm_autosuspend)
1409 pm_runtime_forbid(&sdev->sdev_gendev);
1410 pm_runtime_enable(&sdev->sdev_gendev);
1413 scsi_autopm_get_device(sdev);
1415 scsi_dh_add_device(sdev);
1417 error = device_add(&sdev->sdev_gendev);
1419 sdev_printk(KERN_INFO, sdev,
1424 device_enable_async_suspend(&sdev->sdev_dev);
1425 error = device_add(&sdev->sdev_dev);
1427 sdev_printk(KERN_INFO, sdev,
1429 device_del(&sdev->sdev_gendev);
1432 transport_add_device(&sdev->sdev_gendev);
1433 sdev->is_visible = 1;
1436 sdev->bsg_dev = scsi_bsg_register_queue(sdev);
1437 if (IS_ERR(sdev->bsg_dev)) {
1438 error = PTR_ERR(sdev->bsg_dev);
1439 sdev_printk(KERN_INFO, sdev,
1442 sdev->bsg_dev = NULL;
1446 scsi_autopm_put_device(sdev);
1450 void __scsi_remove_device(struct scsi_device *sdev)
1452 struct device *dev = &sdev->sdev_gendev;
1460 if (sdev->sdev_state == SDEV_DEL)
1463 if (sdev->is_visible) {
1468 mutex_lock(&sdev->state_mutex);
1474 res = scsi_device_set_state(sdev, SDEV_CANCEL);
1476 res = scsi_device_set_state(sdev, SDEV_DEL);
1478 scsi_start_queue(sdev);
1480 mutex_unlock(&sdev->state_mutex);
1485 if (IS_ENABLED(CONFIG_BLK_DEV_BSG) && sdev->bsg_dev)
1486 bsg_unregister_queue(sdev->bsg_dev);
1487 device_unregister(&sdev->sdev_dev);
1491 put_device(&sdev->sdev_dev);
1498 mutex_lock(&sdev->state_mutex);
1499 scsi_device_set_state(sdev, SDEV_DEL);
1500 mutex_unlock(&sdev->state_mutex);
1502 blk_mq_destroy_queue(sdev->request_queue);
1503 kref_put(&sdev->host->tagset_refcnt, scsi_mq_free_tags);
1504 cancel_work_sync(&sdev->requeue_work);
1506 if (sdev->host->hostt->slave_destroy)
1507 sdev->host->hostt->slave_destroy(sdev);
1515 scsi_target_reap(scsi_target(sdev));
1522 * @sdev: scsi_device to unregister
1524 void scsi_remove_device(struct scsi_device *sdev)
1526 struct Scsi_Host *shost = sdev->host;
1529 __scsi_remove_device(sdev);
1538 struct scsi_device *sdev;
1542 list_for_each_entry(sdev, &shost->__devices, siblings) {
1549 if (sdev->channel != starget->channel ||
1550 sdev->id != starget->id)
1552 if (sdev->sdev_state == SDEV_DEL ||
1553 sdev->sdev_state == SDEV_CANCEL ||
1554 !get_device(&sdev->sdev_gendev))
1557 scsi_remove_device(sdev);
1558 put_device(&sdev->sdev_gendev);
1635 void scsi_sysfs_device_initialize(struct scsi_device *sdev)
1638 struct Scsi_Host *shost = sdev->host;
1640 struct scsi_target *starget = sdev->sdev_target;
1642 device_initialize(&sdev->sdev_gendev);
1643 sdev->sdev_gendev.bus = &scsi_bus_type;
1644 sdev->sdev_gendev.type = &scsi_dev_type;
1645 scsi_enable_async_suspend(&sdev->sdev_gendev);
1646 dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu",
1647 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
1648 sdev->sdev_gendev.groups = hostt->sdev_groups;
1650 device_initialize(&sdev->sdev_dev);
1651 sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev);
1652 sdev->sdev_dev.class = &sdev_class;
1653 dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%llu",
1654 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
1658 * sdev->lun_in_cdb for the initial INQUIRY command. For LUN 0 the
1662 sdev->scsi_level = starget->scsi_level;
1663 if (sdev->scsi_level <= SCSI_2 &&
1664 sdev->scsi_level != SCSI_UNKNOWN &&
1666 sdev->lun_in_cdb = 1;
1668 transport_setup_device(&sdev->sdev_gendev);
1670 list_add_tail(&sdev->same_target_siblings, &starget->devices);
1671 list_add_tail(&sdev->siblings, &shost->__devices);