Lines Matching refs:starget

231 static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,  in scsi_alloc_sdev()  argument
238 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_alloc_sdev()
250 sdev->id = starget->id; in scsi_alloc_sdev()
252 sdev->channel = starget->channel; in scsi_alloc_sdev()
264 sdev->sdev_gendev.parent = get_device(&starget->dev); in scsi_alloc_sdev()
265 sdev->sdev_target = starget; in scsi_alloc_sdev()
292 put_device(&starget->dev); in scsi_alloc_sdev()
314 put_device(&starget->dev); in scsi_alloc_sdev()
346 static void scsi_target_destroy(struct scsi_target *starget) in scsi_target_destroy() argument
348 struct device *dev = &starget->dev; in scsi_target_destroy()
352 BUG_ON(starget->state == STARGET_DEL); in scsi_target_destroy()
353 starget->state = STARGET_DEL; in scsi_target_destroy()
357 shost->hostt->target_destroy(starget); in scsi_target_destroy()
358 list_del_init(&starget->siblings); in scsi_target_destroy()
366 struct scsi_target *starget = to_scsi_target(dev); in scsi_target_dev_release() local
368 kfree(starget); in scsi_target_dev_release()
386 struct scsi_target *starget, *found_starget = NULL; in __scsi_find_target() local
391 list_for_each_entry(starget, &shost->__targets, siblings) { in __scsi_find_target()
392 if (starget->id == id && in __scsi_find_target()
393 starget->channel == channel) { in __scsi_find_target()
394 found_starget = starget; in __scsi_find_target()
415 struct scsi_target *starget in scsi_target_reap_ref_release() local
423 if ((starget->state != STARGET_CREATED) && in scsi_target_reap_ref_release()
424 (starget->state != STARGET_CREATED_REMOVE)) { in scsi_target_reap_ref_release()
425 transport_remove_device(&starget->dev); in scsi_target_reap_ref_release()
426 device_del(&starget->dev); in scsi_target_reap_ref_release()
428 scsi_target_destroy(starget); in scsi_target_reap_ref_release()
431 static void scsi_target_reap_ref_put(struct scsi_target *starget) in scsi_target_reap_ref_put() argument
433 kref_put(&starget->reap_ref, scsi_target_reap_ref_release); in scsi_target_reap_ref_put()
456 struct scsi_target *starget; in scsi_alloc_target() local
460 starget = kzalloc(size, GFP_KERNEL); in scsi_alloc_target()
461 if (!starget) { in scsi_alloc_target()
465 dev = &starget->dev; in scsi_alloc_target()
467 kref_init(&starget->reap_ref); in scsi_alloc_target()
473 starget->id = id; in scsi_alloc_target()
474 starget->channel = channel; in scsi_alloc_target()
475 starget->can_queue = 0; in scsi_alloc_target()
476 INIT_LIST_HEAD(&starget->siblings); in scsi_alloc_target()
477 INIT_LIST_HEAD(&starget->devices); in scsi_alloc_target()
478 starget->state = STARGET_CREATED; in scsi_alloc_target()
479 starget->scsi_level = SCSI_2; in scsi_alloc_target()
480 starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED; in scsi_alloc_target()
488 list_add_tail(&starget->siblings, &shost->__targets); in scsi_alloc_target()
493 error = shost->hostt->target_alloc(starget); in scsi_alloc_target()
500 scsi_target_destroy(starget); in scsi_alloc_target()
506 return starget; in scsi_alloc_target()
547 void scsi_target_reap(struct scsi_target *starget) in scsi_target_reap() argument
554 BUG_ON(starget->state == STARGET_DEL); in scsi_target_reap()
555 scsi_target_reap_ref_put(starget); in scsi_target_reap()
1087 static int scsi_probe_and_add_lun(struct scsi_target *starget, in scsi_probe_and_add_lun() argument
1097 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_probe_and_add_lun()
1103 sdev = scsi_device_lookup_by_target(starget, lun); in scsi_probe_and_add_lun()
1122 sdev = scsi_alloc_sdev(starget, lun, hostdata); in scsi_probe_and_add_lun()
1191 (starget->pdt_1f_for_no_lun && (result[0] & 0x1f) == 0x1f)) && in scsi_probe_and_add_lun()
1240 static void scsi_sequential_lun_scan(struct scsi_target *starget, in scsi_sequential_lun_scan() argument
1246 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_sequential_lun_scan()
1248 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget, in scsi_sequential_lun_scan()
1306 if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, in scsi_sequential_lun_scan()
1332 static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflags, in scsi_report_lun_scan() argument
1344 struct Scsi_Host *shost = dev_to_shost(&starget->dev); in scsi_report_lun_scan()
1355 if (starget->scsi_level < SCSI_2 && in scsi_report_lun_scan()
1356 starget->scsi_level != SCSI_UNKNOWN) in scsi_report_lun_scan()
1358 if (starget->scsi_level < SCSI_3 && in scsi_report_lun_scan()
1363 if (starget->no_report_luns) in scsi_report_lun_scan()
1366 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { in scsi_report_lun_scan()
1367 sdev = scsi_alloc_sdev(starget, 0, NULL); in scsi_report_lun_scan()
1475 res = scsi_probe_and_add_lun(starget, in scsi_report_lun_scan()
1507 struct scsi_target *starget; in __scsi_add_device() local
1512 starget = scsi_alloc_target(parent, channel, id); in __scsi_add_device()
1513 if (!starget) in __scsi_add_device()
1515 scsi_autopm_get_target(starget); in __scsi_add_device()
1522 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); in __scsi_add_device()
1526 scsi_autopm_put_target(starget); in __scsi_add_device()
1531 scsi_target_reap(starget); in __scsi_add_device()
1532 put_device(&starget->dev); in __scsi_add_device()
1579 struct scsi_target *starget; in __scsi_scan_target() local
1587 starget = scsi_alloc_target(parent, channel, id); in __scsi_scan_target()
1588 if (!starget) in __scsi_scan_target()
1590 scsi_autopm_get_target(starget); in __scsi_scan_target()
1596 scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL); in __scsi_scan_target()
1604 res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL); in __scsi_scan_target()
1606 if (scsi_report_lun_scan(starget, bflags, rescan) != 0) in __scsi_scan_target()
1611 scsi_sequential_lun_scan(starget, bflags, in __scsi_scan_target()
1612 starget->scsi_level, rescan); in __scsi_scan_target()
1616 scsi_autopm_put_target(starget); in __scsi_scan_target()
1621 scsi_target_reap(starget); in __scsi_scan_target()
1623 put_device(&starget->dev); in __scsi_scan_target()