Lines Matching defs:starget
203 * @starget: which target to allocate a &scsi_device for
215 static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
220 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
232 sdev->id = starget->id;
234 sdev->channel = starget->channel;
246 sdev->sdev_gendev.parent = get_device(&starget->dev);
247 sdev->sdev_target = starget;
272 put_device(&starget->dev);
307 static void scsi_target_destroy(struct scsi_target *starget)
309 struct device *dev = &starget->dev;
313 BUG_ON(starget->state == STARGET_DEL);
314 starget->state = STARGET_DEL;
318 shost->hostt->target_destroy(starget);
319 list_del_init(&starget->siblings);
327 struct scsi_target *starget = to_scsi_target(dev);
329 kfree(starget);
347 struct scsi_target *starget, *found_starget = NULL;
352 list_for_each_entry(starget, &shost->__targets, siblings) {
353 if (starget->id == id &&
354 starget->channel == channel) {
355 found_starget = starget;
376 struct scsi_target *starget
384 if ((starget->state != STARGET_CREATED) &&
385 (starget->state != STARGET_CREATED_REMOVE)) {
386 transport_remove_device(&starget->dev);
387 device_del(&starget->dev);
389 scsi_target_destroy(starget);
392 static void scsi_target_reap_ref_put(struct scsi_target *starget)
394 kref_put(&starget->reap_ref, scsi_target_reap_ref_release);
417 struct scsi_target *starget;
421 starget = kzalloc(size, GFP_KERNEL);
422 if (!starget) {
426 dev = &starget->dev;
428 kref_init(&starget->reap_ref);
433 starget->id = id;
434 starget->channel = channel;
435 starget->can_queue = 0;
436 INIT_LIST_HEAD(&starget->siblings);
437 INIT_LIST_HEAD(&starget->devices);
438 starget->state = STARGET_CREATED;
439 starget->scsi_level = SCSI_2;
440 starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED;
448 list_add_tail(&starget->siblings, &shost->__targets);
453 error = shost->hostt->target_alloc(starget);
460 scsi_target_destroy(starget);
466 return starget;
501 * @starget: target to be checked
507 void scsi_target_reap(struct scsi_target *starget)
514 BUG_ON(starget->state == STARGET_DEL);
515 scsi_target_reap_ref_put(starget);
1024 * @starget: pointer to target device structure
1043 static int scsi_probe_and_add_lun(struct scsi_target *starget,
1053 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1059 sdev = scsi_device_lookup_by_target(starget, lun);
1078 sdev = scsi_alloc_sdev(starget, lun, hostdata);
1146 if (((result[0] >> 5) == 1 || starget->pdt_1f_for_no_lun) &&
1184 * @starget: pointer to target structure to scan
1196 static void scsi_sequential_lun_scan(struct scsi_target *starget,
1202 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1204 SCSI_LOG_SCAN_BUS(3, starget_printk(KERN_INFO, starget,
1262 if ((scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan,
1270 * @starget: which target
1282 * If starget->no_report_luns is set, return 1 always.
1288 static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflags,
1300 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
1311 if (starget->scsi_level < SCSI_2 &&
1312 starget->scsi_level != SCSI_UNKNOWN)
1314 if (starget->scsi_level < SCSI_3 &&
1319 if (starget->no_report_luns)
1322 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) {
1323 sdev = scsi_alloc_sdev(starget, 0, NULL);
1432 res = scsi_probe_and_add_lun(starget,
1464 struct scsi_target *starget;
1469 starget = scsi_alloc_target(parent, channel, id);
1470 if (!starget)
1472 scsi_autopm_get_target(starget);
1479 scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
1483 scsi_autopm_put_target(starget);
1488 scsi_target_reap(starget);
1489 put_device(&starget->dev);
1536 struct scsi_target *starget;
1544 starget = scsi_alloc_target(parent, channel, id);
1545 if (!starget)
1547 scsi_autopm_get_target(starget);
1553 scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL);
1561 res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL);
1563 if (scsi_report_lun_scan(starget, bflags, rescan) != 0)
1568 scsi_sequential_lun_scan(starget, bflags,
1569 starget->scsi_level, rescan);
1573 scsi_autopm_put_target(starget);
1578 scsi_target_reap(starget);
1580 put_device(&starget->dev);
1898 struct scsi_target *starget;
1903 starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id);
1904 if (!starget)
1907 sdev = scsi_alloc_sdev(starget, 0, NULL);
1911 scsi_target_reap(starget);
1912 put_device(&starget->dev);