Lines Matching refs:starget

210 static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,  in scsi_alloc_sdev()  argument
215 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_alloc_sdev()
229 sdev->id = starget->id; in scsi_alloc_sdev()
231 sdev->channel = starget->channel; in scsi_alloc_sdev()
242 sdev->sdev_gendev.parent = get_device(&starget->dev); in scsi_alloc_sdev()
243 sdev->sdev_target = starget; in scsi_alloc_sdev()
271 put_device(&starget->dev); in scsi_alloc_sdev()
311 static void scsi_target_destroy(struct scsi_target *starget) in scsi_target_destroy() argument
313 struct device *dev = &starget->dev; in scsi_target_destroy()
317 BUG_ON(starget->state == STARGET_DEL); in scsi_target_destroy()
318 starget->state = STARGET_DEL; in scsi_target_destroy()
322 shost->hostt->target_destroy(starget); in scsi_target_destroy()
323 list_del_init(&starget->siblings); in scsi_target_destroy()
331 struct scsi_target *starget = to_scsi_target(dev); in scsi_target_dev_release() local
333 kfree(starget); in scsi_target_dev_release()
351 struct scsi_target *starget, *found_starget = NULL; in __scsi_find_target() local
356 list_for_each_entry(starget, &shost->__targets, siblings) { in __scsi_find_target()
357 if (starget->id == id && in __scsi_find_target()
358 starget->channel == channel) { in __scsi_find_target()
359 found_starget = starget; in __scsi_find_target()
380 struct scsi_target *starget in scsi_target_reap_ref_release() local
388 if (starget->state != STARGET_CREATED) { in scsi_target_reap_ref_release()
389 transport_remove_device(&starget->dev); in scsi_target_reap_ref_release()
390 device_del(&starget->dev); in scsi_target_reap_ref_release()
392 scsi_target_destroy(starget); in scsi_target_reap_ref_release()
395 static void scsi_target_reap_ref_put(struct scsi_target *starget) in scsi_target_reap_ref_put() argument
397 kref_put(&starget->reap_ref, scsi_target_reap_ref_release); in scsi_target_reap_ref_put()
420 struct scsi_target *starget; in scsi_alloc_target() local
424 starget = kzalloc(size, GFP_KERNEL); in scsi_alloc_target()
425 if (!starget) { in scsi_alloc_target()
429 dev = &starget->dev; in scsi_alloc_target()
431 kref_init(&starget->reap_ref); in scsi_alloc_target()
436 starget->id = id; in scsi_alloc_target()
437 starget->channel = channel; in scsi_alloc_target()
438 starget->can_queue = 0; in scsi_alloc_target()
439 INIT_LIST_HEAD(&starget->siblings); in scsi_alloc_target()
440 INIT_LIST_HEAD(&starget->devices); in scsi_alloc_target()
441 starget->state = STARGET_CREATED; in scsi_alloc_target()
442 starget->scsi_level = SCSI_2; in scsi_alloc_target()
443 starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED; in scsi_alloc_target()
451 list_add_tail(&starget->siblings, &shost->__targets); in scsi_alloc_target()
456 error = shost->hostt->target_alloc(starget); in scsi_alloc_target()
462 scsi_target_destroy(starget); in scsi_alloc_target()
468 return starget; in scsi_alloc_target()
509 void scsi_target_reap(struct scsi_target *starget) in scsi_target_reap() argument
516 BUG_ON(starget->state == STARGET_DEL); in scsi_target_reap()
517 scsi_target_reap_ref_put(starget); in scsi_target_reap()
1050 static int scsi_probe_and_add_lun(struct scsi_target *starget, in scsi_probe_and_add_lun() argument
1058 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_probe_and_add_lun()
1064 sdev = scsi_device_lookup_by_target(starget, lun); in scsi_probe_and_add_lun()
1083 sdev = scsi_alloc_sdev(starget, lun, hostdata); in scsi_probe_and_add_lun()
1151 if (((result[0] >> 5) == 1 || starget->pdt_1f_for_no_lun) && in scsi_probe_and_add_lun()
1201 static void scsi_sequential_lun_scan(struct scsi_target *starget, in scsi_sequential_lun_scan() argument
1206 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_sequential_lun_scan()
1208 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, int bflags, in scsi_report_lun_scan() argument
1309 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsi_report_lun_scan()
1320 if (starget->scsi_level < SCSI_2 && in scsi_report_lun_scan()
1321 starget->scsi_level != SCSI_UNKNOWN) in scsi_report_lun_scan()
1323 if (starget->scsi_level < SCSI_3 && in scsi_report_lun_scan()
1328 if (starget->no_report_luns) in scsi_report_lun_scan()
1331 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { in scsi_report_lun_scan()
1332 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_report_lun_scan()
1444 res = scsi_probe_and_add_lun(starget, in scsi_report_lun_scan()
1476 struct scsi_target *starget; in __scsi_add_device() local
1481 starget = scsi_alloc_target(parent, channel, id); in __scsi_add_device()
1482 if (!starget) in __scsi_add_device()
1484 scsi_autopm_get_target(starget); in __scsi_add_device()
1491 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); in __scsi_add_device()
1495 scsi_autopm_put_target(starget); in __scsi_add_device()
1500 scsi_target_reap(starget); in __scsi_add_device()
1501 put_device(&starget->dev); in __scsi_add_device()
1540 struct scsi_target *starget; in __scsi_scan_target() local
1548 starget = scsi_alloc_target(parent, channel, id); in __scsi_scan_target()
1549 if (!starget) in __scsi_scan_target()
1551 scsi_autopm_get_target(starget); in __scsi_scan_target()
1557 scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL); in __scsi_scan_target()
1565 res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL); in __scsi_scan_target()
1567 if (scsi_report_lun_scan(starget, bflags, rescan) != 0) in __scsi_scan_target()
1572 scsi_sequential_lun_scan(starget, bflags, in __scsi_scan_target()
1573 starget->scsi_level, rescan); in __scsi_scan_target()
1577 scsi_autopm_put_target(starget); in __scsi_scan_target()
1582 scsi_target_reap(starget); in __scsi_scan_target()
1584 put_device(&starget->dev); in __scsi_scan_target()
1891 struct scsi_target *starget; in scsi_get_host_dev() local
1896 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); in scsi_get_host_dev()
1897 if (!starget) in scsi_get_host_dev()
1900 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_get_host_dev()
1904 scsi_target_reap(starget); in scsi_get_host_dev()
1905 put_device(&starget->dev); in scsi_get_host_dev()