Lines Matching refs:starget

215 static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,  in scsi_alloc_sdev()  argument
220 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_alloc_sdev()
232 sdev->id = starget->id; in scsi_alloc_sdev()
234 sdev->channel = starget->channel; in scsi_alloc_sdev()
247 sdev->sdev_gendev.parent = get_device(&starget->dev); in scsi_alloc_sdev()
248 sdev->sdev_target = starget; in scsi_alloc_sdev()
276 put_device(&starget->dev); in scsi_alloc_sdev()
316 static void scsi_target_destroy(struct scsi_target *starget) in scsi_target_destroy() argument
318 struct device *dev = &starget->dev; in scsi_target_destroy()
322 BUG_ON(starget->state == STARGET_DEL); in scsi_target_destroy()
323 starget->state = STARGET_DEL; in scsi_target_destroy()
327 shost->hostt->target_destroy(starget); in scsi_target_destroy()
328 list_del_init(&starget->siblings); in scsi_target_destroy()
336 struct scsi_target *starget = to_scsi_target(dev); in scsi_target_dev_release() local
338 kfree(starget); in scsi_target_dev_release()
356 struct scsi_target *starget, *found_starget = NULL; in __scsi_find_target() local
361 list_for_each_entry(starget, &shost->__targets, siblings) { in __scsi_find_target()
362 if (starget->id == id && in __scsi_find_target()
363 starget->channel == channel) { in __scsi_find_target()
364 found_starget = starget; in __scsi_find_target()
385 struct scsi_target *starget in scsi_target_reap_ref_release() local
393 if ((starget->state != STARGET_CREATED) && in scsi_target_reap_ref_release()
394 (starget->state != STARGET_CREATED_REMOVE)) { in scsi_target_reap_ref_release()
395 transport_remove_device(&starget->dev); in scsi_target_reap_ref_release()
396 device_del(&starget->dev); in scsi_target_reap_ref_release()
398 scsi_target_destroy(starget); in scsi_target_reap_ref_release()
401 static void scsi_target_reap_ref_put(struct scsi_target *starget) in scsi_target_reap_ref_put() argument
403 kref_put(&starget->reap_ref, scsi_target_reap_ref_release); in scsi_target_reap_ref_put()
426 struct scsi_target *starget; in scsi_alloc_target() local
430 starget = kzalloc(size, GFP_KERNEL); in scsi_alloc_target()
431 if (!starget) { in scsi_alloc_target()
435 dev = &starget->dev; in scsi_alloc_target()
437 kref_init(&starget->reap_ref); in scsi_alloc_target()
442 starget->id = id; in scsi_alloc_target()
443 starget->channel = channel; in scsi_alloc_target()
444 starget->can_queue = 0; in scsi_alloc_target()
445 INIT_LIST_HEAD(&starget->siblings); in scsi_alloc_target()
446 INIT_LIST_HEAD(&starget->devices); in scsi_alloc_target()
447 starget->state = STARGET_CREATED; in scsi_alloc_target()
448 starget->scsi_level = SCSI_2; in scsi_alloc_target()
449 starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED; in scsi_alloc_target()
457 list_add_tail(&starget->siblings, &shost->__targets); in scsi_alloc_target()
462 error = shost->hostt->target_alloc(starget); in scsi_alloc_target()
468 scsi_target_destroy(starget); in scsi_alloc_target()
474 return starget; in scsi_alloc_target()
515 void scsi_target_reap(struct scsi_target *starget) in scsi_target_reap() argument
522 BUG_ON(starget->state == STARGET_DEL); in scsi_target_reap()
523 scsi_target_reap_ref_put(starget); in scsi_target_reap()
1051 static int scsi_probe_and_add_lun(struct scsi_target *starget, in scsi_probe_and_add_lun() argument
1061 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_probe_and_add_lun()
1067 sdev = scsi_device_lookup_by_target(starget, lun); in scsi_probe_and_add_lun()
1086 sdev = scsi_alloc_sdev(starget, lun, hostdata); in scsi_probe_and_add_lun()
1154 if (((result[0] >> 5) == 1 || starget->pdt_1f_for_no_lun) && in scsi_probe_and_add_lun()
1204 static void scsi_sequential_lun_scan(struct scsi_target *starget, in scsi_sequential_lun_scan() argument
1210 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_sequential_lun_scan()
1212 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget, in scsi_sequential_lun_scan()
1270 if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, in scsi_sequential_lun_scan()
1296 static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflags, in scsi_report_lun_scan() argument
1308 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsi_report_lun_scan()
1319 if (starget->scsi_level < SCSI_2 && in scsi_report_lun_scan()
1320 starget->scsi_level != SCSI_UNKNOWN) in scsi_report_lun_scan()
1322 if (starget->scsi_level < SCSI_3 && in scsi_report_lun_scan()
1327 if (starget->no_report_luns) in scsi_report_lun_scan()
1330 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { in scsi_report_lun_scan()
1331 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_report_lun_scan()
1440 res = scsi_probe_and_add_lun(starget, in scsi_report_lun_scan()
1472 struct scsi_target *starget; in __scsi_add_device() local
1477 starget = scsi_alloc_target(parent, channel, id); in __scsi_add_device()
1478 if (!starget) in __scsi_add_device()
1480 scsi_autopm_get_target(starget); in __scsi_add_device()
1487 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); in __scsi_add_device()
1491 scsi_autopm_put_target(starget); in __scsi_add_device()
1496 scsi_target_reap(starget); in __scsi_add_device()
1497 put_device(&starget->dev); in __scsi_add_device()
1544 struct scsi_target *starget; in __scsi_scan_target() local
1552 starget = scsi_alloc_target(parent, channel, id); in __scsi_scan_target()
1553 if (!starget) in __scsi_scan_target()
1555 scsi_autopm_get_target(starget); in __scsi_scan_target()
1561 scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL); in __scsi_scan_target()
1569 res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL); in __scsi_scan_target()
1571 if (scsi_report_lun_scan(starget, bflags, rescan) != 0) in __scsi_scan_target()
1576 scsi_sequential_lun_scan(starget, bflags, in __scsi_scan_target()
1577 starget->scsi_level, rescan); in __scsi_scan_target()
1581 scsi_autopm_put_target(starget); in __scsi_scan_target()
1586 scsi_target_reap(starget); in __scsi_scan_target()
1588 put_device(&starget->dev); in __scsi_scan_target()
1905 struct scsi_target *starget; in scsi_get_host_dev() local
1910 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); in scsi_get_host_dev()
1911 if (!starget) in scsi_get_host_dev()
1914 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_get_host_dev()
1918 scsi_target_reap(starget); in scsi_get_host_dev()
1919 put_device(&starget->dev); in scsi_get_host_dev()