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()
246 sdev->sdev_gendev.parent = get_device(&starget->dev); in scsi_alloc_sdev()
247 sdev->sdev_target = starget; in scsi_alloc_sdev()
272 put_device(&starget->dev); in scsi_alloc_sdev()
307 static void scsi_target_destroy(struct scsi_target *starget) in scsi_target_destroy() argument
309 struct device *dev = &starget->dev; in scsi_target_destroy()
313 BUG_ON(starget->state == STARGET_DEL); in scsi_target_destroy()
314 starget->state = STARGET_DEL; in scsi_target_destroy()
318 shost->hostt->target_destroy(starget); in scsi_target_destroy()
319 list_del_init(&starget->siblings); in scsi_target_destroy()
327 struct scsi_target *starget = to_scsi_target(dev); in scsi_target_dev_release() local
329 kfree(starget); in scsi_target_dev_release()
347 struct scsi_target *starget, *found_starget = NULL; in __scsi_find_target() local
352 list_for_each_entry(starget, &shost->__targets, siblings) { in __scsi_find_target()
353 if (starget->id == id && in __scsi_find_target()
354 starget->channel == channel) { in __scsi_find_target()
355 found_starget = starget; in __scsi_find_target()
376 struct scsi_target *starget in scsi_target_reap_ref_release() local
384 if ((starget->state != STARGET_CREATED) && in scsi_target_reap_ref_release()
385 (starget->state != STARGET_CREATED_REMOVE)) { in scsi_target_reap_ref_release()
386 transport_remove_device(&starget->dev); in scsi_target_reap_ref_release()
387 device_del(&starget->dev); in scsi_target_reap_ref_release()
389 scsi_target_destroy(starget); in scsi_target_reap_ref_release()
392 static void scsi_target_reap_ref_put(struct scsi_target *starget) in scsi_target_reap_ref_put() argument
394 kref_put(&starget->reap_ref, scsi_target_reap_ref_release); in scsi_target_reap_ref_put()
417 struct scsi_target *starget; in scsi_alloc_target() local
421 starget = kzalloc(size, GFP_KERNEL); in scsi_alloc_target()
422 if (!starget) { in scsi_alloc_target()
426 dev = &starget->dev; in scsi_alloc_target()
428 kref_init(&starget->reap_ref); in scsi_alloc_target()
433 starget->id = id; in scsi_alloc_target()
434 starget->channel = channel; in scsi_alloc_target()
435 starget->can_queue = 0; in scsi_alloc_target()
436 INIT_LIST_HEAD(&starget->siblings); in scsi_alloc_target()
437 INIT_LIST_HEAD(&starget->devices); in scsi_alloc_target()
438 starget->state = STARGET_CREATED; in scsi_alloc_target()
439 starget->scsi_level = SCSI_2; in scsi_alloc_target()
440 starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED; in scsi_alloc_target()
448 list_add_tail(&starget->siblings, &shost->__targets); in scsi_alloc_target()
453 error = shost->hostt->target_alloc(starget); in scsi_alloc_target()
460 scsi_target_destroy(starget); in scsi_alloc_target()
466 return starget; in scsi_alloc_target()
507 void scsi_target_reap(struct scsi_target *starget) in scsi_target_reap() argument
514 BUG_ON(starget->state == STARGET_DEL); in scsi_target_reap()
515 scsi_target_reap_ref_put(starget); in scsi_target_reap()
1043 static int scsi_probe_and_add_lun(struct scsi_target *starget, in scsi_probe_and_add_lun() argument
1053 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_probe_and_add_lun()
1059 sdev = scsi_device_lookup_by_target(starget, lun); in scsi_probe_and_add_lun()
1078 sdev = scsi_alloc_sdev(starget, lun, hostdata); in scsi_probe_and_add_lun()
1148 (starget->pdt_1f_for_no_lun && (result[0] & 0x1f) == 0x1f)) && in scsi_probe_and_add_lun()
1197 static void scsi_sequential_lun_scan(struct scsi_target *starget, in scsi_sequential_lun_scan() argument
1203 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_sequential_lun_scan()
1205 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget, in scsi_sequential_lun_scan()
1263 if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, in scsi_sequential_lun_scan()
1289 static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflags, in scsi_report_lun_scan() argument
1301 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsi_report_lun_scan()
1312 if (starget->scsi_level < SCSI_2 && in scsi_report_lun_scan()
1313 starget->scsi_level != SCSI_UNKNOWN) in scsi_report_lun_scan()
1315 if (starget->scsi_level < SCSI_3 && in scsi_report_lun_scan()
1320 if (starget->no_report_luns) in scsi_report_lun_scan()
1323 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { in scsi_report_lun_scan()
1324 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_report_lun_scan()
1433 res = scsi_probe_and_add_lun(starget, in scsi_report_lun_scan()
1465 struct scsi_target *starget; in __scsi_add_device() local
1470 starget = scsi_alloc_target(parent, channel, id); in __scsi_add_device()
1471 if (!starget) in __scsi_add_device()
1473 scsi_autopm_get_target(starget); in __scsi_add_device()
1480 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); in __scsi_add_device()
1484 scsi_autopm_put_target(starget); in __scsi_add_device()
1489 scsi_target_reap(starget); in __scsi_add_device()
1490 put_device(&starget->dev); in __scsi_add_device()
1537 struct scsi_target *starget; in __scsi_scan_target() local
1545 starget = scsi_alloc_target(parent, channel, id); in __scsi_scan_target()
1546 if (!starget) in __scsi_scan_target()
1548 scsi_autopm_get_target(starget); in __scsi_scan_target()
1554 scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL); in __scsi_scan_target()
1562 res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL); in __scsi_scan_target()
1564 if (scsi_report_lun_scan(starget, bflags, rescan) != 0) in __scsi_scan_target()
1569 scsi_sequential_lun_scan(starget, bflags, in __scsi_scan_target()
1570 starget->scsi_level, rescan); in __scsi_scan_target()
1574 scsi_autopm_put_target(starget); in __scsi_scan_target()
1579 scsi_target_reap(starget); in __scsi_scan_target()
1581 put_device(&starget->dev); in __scsi_scan_target()
1899 struct scsi_target *starget; in scsi_get_host_dev() local
1904 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); in scsi_get_host_dev()
1905 if (!starget) in scsi_get_host_dev()
1908 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_get_host_dev()
1912 scsi_target_reap(starget); in scsi_get_host_dev()
1913 put_device(&starget->dev); in scsi_get_host_dev()