Lines Matching refs:starget

209 static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,  in scsi_alloc_sdev()  argument
214 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_alloc_sdev()
228 sdev->id = starget->id; in scsi_alloc_sdev()
230 sdev->channel = starget->channel; in scsi_alloc_sdev()
241 sdev->sdev_gendev.parent = get_device(&starget->dev); in scsi_alloc_sdev()
242 sdev->sdev_target = starget; in scsi_alloc_sdev()
270 put_device(&starget->dev); in scsi_alloc_sdev()
310 static void scsi_target_destroy(struct scsi_target *starget) in scsi_target_destroy() argument
312 struct device *dev = &starget->dev; in scsi_target_destroy()
316 starget->state = STARGET_DEL; in scsi_target_destroy()
320 shost->hostt->target_destroy(starget); in scsi_target_destroy()
321 list_del_init(&starget->siblings); in scsi_target_destroy()
329 struct scsi_target *starget = to_scsi_target(dev); in scsi_target_dev_release() local
331 kfree(starget); in scsi_target_dev_release()
349 struct scsi_target *starget, *found_starget = NULL; in __scsi_find_target() local
354 list_for_each_entry(starget, &shost->__targets, siblings) { in __scsi_find_target()
355 if (starget->id == id && in __scsi_find_target()
356 starget->channel == channel) { in __scsi_find_target()
357 found_starget = starget; in __scsi_find_target()
378 struct scsi_target *starget in scsi_target_reap_ref_release() local
386 if (starget->state != STARGET_CREATED) { in scsi_target_reap_ref_release()
387 transport_remove_device(&starget->dev); in scsi_target_reap_ref_release()
388 device_del(&starget->dev); in scsi_target_reap_ref_release()
390 scsi_target_destroy(starget); in scsi_target_reap_ref_release()
393 static void scsi_target_reap_ref_put(struct scsi_target *starget) in scsi_target_reap_ref_put() argument
395 kref_put(&starget->reap_ref, scsi_target_reap_ref_release); in scsi_target_reap_ref_put()
418 struct scsi_target *starget; in scsi_alloc_target() local
422 starget = kzalloc(size, GFP_KERNEL); in scsi_alloc_target()
423 if (!starget) { in scsi_alloc_target()
427 dev = &starget->dev; in scsi_alloc_target()
429 kref_init(&starget->reap_ref); in scsi_alloc_target()
434 starget->id = id; in scsi_alloc_target()
435 starget->channel = channel; in scsi_alloc_target()
436 starget->can_queue = 0; in scsi_alloc_target()
437 INIT_LIST_HEAD(&starget->siblings); in scsi_alloc_target()
438 INIT_LIST_HEAD(&starget->devices); in scsi_alloc_target()
439 starget->state = STARGET_CREATED; in scsi_alloc_target()
440 starget->scsi_level = SCSI_2; in scsi_alloc_target()
441 starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED; in scsi_alloc_target()
449 list_add_tail(&starget->siblings, &shost->__targets); in scsi_alloc_target()
454 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()
1045 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()
1146 if (((result[0] >> 5) == 1 || starget->pdt_1f_for_no_lun) && in scsi_probe_and_add_lun()
1196 static void scsi_sequential_lun_scan(struct scsi_target *starget, in scsi_sequential_lun_scan() argument
1201 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_sequential_lun_scan()
1203 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget, in scsi_sequential_lun_scan()
1265 if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, in scsi_sequential_lun_scan()
1353 static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, in scsi_report_lun_scan() argument
1366 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsi_report_lun_scan()
1377 if (starget->scsi_level < SCSI_2 && in scsi_report_lun_scan()
1378 starget->scsi_level != SCSI_UNKNOWN) in scsi_report_lun_scan()
1380 if (starget->scsi_level < SCSI_3 && in scsi_report_lun_scan()
1385 if (starget->no_report_luns) in scsi_report_lun_scan()
1388 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { in scsi_report_lun_scan()
1389 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_report_lun_scan()
1501 res = scsi_probe_and_add_lun(starget, in scsi_report_lun_scan()
1533 struct scsi_target *starget; in __scsi_add_device() local
1538 starget = scsi_alloc_target(parent, channel, id); in __scsi_add_device()
1539 if (!starget) in __scsi_add_device()
1541 scsi_autopm_get_target(starget); in __scsi_add_device()
1548 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); in __scsi_add_device()
1552 scsi_autopm_put_target(starget); in __scsi_add_device()
1557 scsi_target_reap(starget); in __scsi_add_device()
1558 put_device(&starget->dev); in __scsi_add_device()
1597 struct scsi_target *starget; in __scsi_scan_target() local
1605 starget = scsi_alloc_target(parent, channel, id); in __scsi_scan_target()
1606 if (!starget) in __scsi_scan_target()
1608 scsi_autopm_get_target(starget); in __scsi_scan_target()
1614 scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL); in __scsi_scan_target()
1622 res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL); in __scsi_scan_target()
1624 if (scsi_report_lun_scan(starget, bflags, rescan) != 0) in __scsi_scan_target()
1629 scsi_sequential_lun_scan(starget, bflags, in __scsi_scan_target()
1630 starget->scsi_level, rescan); in __scsi_scan_target()
1634 scsi_autopm_put_target(starget); in __scsi_scan_target()
1639 scsi_target_reap(starget); in __scsi_scan_target()
1641 put_device(&starget->dev); in __scsi_scan_target()
1949 struct scsi_target *starget; in scsi_get_host_dev() local
1954 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); in scsi_get_host_dev()
1955 if (!starget) in scsi_get_host_dev()
1958 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_get_host_dev()
1962 scsi_target_reap(starget); in scsi_get_host_dev()
1963 put_device(&starget->dev); in scsi_get_host_dev()