diff options
Diffstat (limited to 'drivers/scsi/scsi_scan.c')
-rw-r--r-- | drivers/scsi/scsi_scan.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 05ebb9cef961..752fb5da3de4 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -334,19 +334,6 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, | |||
334 | struct scsi_target *starget; | 334 | struct scsi_target *starget; |
335 | struct scsi_target *found_target; | 335 | struct scsi_target *found_target; |
336 | 336 | ||
337 | /* | ||
338 | * Obtain the real parent from the transport. The transport | ||
339 | * is allowed to fail (no error) if there is nothing at that | ||
340 | * target id. | ||
341 | */ | ||
342 | if (shost->transportt->target_parent) { | ||
343 | spin_lock_irqsave(shost->host_lock, flags); | ||
344 | parent = shost->transportt->target_parent(shost, channel, id); | ||
345 | spin_unlock_irqrestore(shost->host_lock, flags); | ||
346 | if (!parent) | ||
347 | return NULL; | ||
348 | } | ||
349 | |||
350 | starget = kmalloc(size, GFP_KERNEL); | 337 | starget = kmalloc(size, GFP_KERNEL); |
351 | if (!starget) { | 338 | if (!starget) { |
352 | printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); | 339 | printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); |
@@ -1283,20 +1270,21 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, | |||
1283 | struct scsi_device *sdev; | 1270 | struct scsi_device *sdev; |
1284 | struct device *parent = &shost->shost_gendev; | 1271 | struct device *parent = &shost->shost_gendev; |
1285 | int res; | 1272 | int res; |
1286 | struct scsi_target *starget = scsi_alloc_target(parent, channel, id); | 1273 | struct scsi_target *starget; |
1287 | 1274 | ||
1275 | starget = scsi_alloc_target(parent, channel, id); | ||
1288 | if (!starget) | 1276 | if (!starget) |
1289 | return ERR_PTR(-ENOMEM); | 1277 | return ERR_PTR(-ENOMEM); |
1290 | 1278 | ||
1291 | get_device(&starget->dev); | 1279 | get_device(&starget->dev); |
1292 | down(&shost->scan_mutex); | 1280 | mutex_lock(&shost->scan_mutex); |
1293 | if (scsi_host_scan_allowed(shost)) { | 1281 | if (scsi_host_scan_allowed(shost)) { |
1294 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, | 1282 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, |
1295 | hostdata); | 1283 | hostdata); |
1296 | if (res != SCSI_SCAN_LUN_PRESENT) | 1284 | if (res != SCSI_SCAN_LUN_PRESENT) |
1297 | sdev = ERR_PTR(-ENODEV); | 1285 | sdev = ERR_PTR(-ENODEV); |
1298 | } | 1286 | } |
1299 | up(&shost->scan_mutex); | 1287 | mutex_unlock(&shost->scan_mutex); |
1300 | scsi_target_reap(starget); | 1288 | scsi_target_reap(starget); |
1301 | put_device(&starget->dev); | 1289 | put_device(&starget->dev); |
1302 | 1290 | ||
@@ -1404,10 +1392,10 @@ void scsi_scan_target(struct device *parent, unsigned int channel, | |||
1404 | { | 1392 | { |
1405 | struct Scsi_Host *shost = dev_to_shost(parent); | 1393 | struct Scsi_Host *shost = dev_to_shost(parent); |
1406 | 1394 | ||
1407 | down(&shost->scan_mutex); | 1395 | mutex_lock(&shost->scan_mutex); |
1408 | if (scsi_host_scan_allowed(shost)) | 1396 | if (scsi_host_scan_allowed(shost)) |
1409 | __scsi_scan_target(parent, channel, id, lun, rescan); | 1397 | __scsi_scan_target(parent, channel, id, lun, rescan); |
1410 | up(&shost->scan_mutex); | 1398 | mutex_unlock(&shost->scan_mutex); |
1411 | } | 1399 | } |
1412 | EXPORT_SYMBOL(scsi_scan_target); | 1400 | EXPORT_SYMBOL(scsi_scan_target); |
1413 | 1401 | ||
@@ -1454,7 +1442,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, | |||
1454 | ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) | 1442 | ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) |
1455 | return -EINVAL; | 1443 | return -EINVAL; |
1456 | 1444 | ||
1457 | down(&shost->scan_mutex); | 1445 | mutex_lock(&shost->scan_mutex); |
1458 | if (scsi_host_scan_allowed(shost)) { | 1446 | if (scsi_host_scan_allowed(shost)) { |
1459 | if (channel == SCAN_WILD_CARD) | 1447 | if (channel == SCAN_WILD_CARD) |
1460 | for (channel = 0; channel <= shost->max_channel; | 1448 | for (channel = 0; channel <= shost->max_channel; |
@@ -1464,7 +1452,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, | |||
1464 | else | 1452 | else |
1465 | scsi_scan_channel(shost, channel, id, lun, rescan); | 1453 | scsi_scan_channel(shost, channel, id, lun, rescan); |
1466 | } | 1454 | } |
1467 | up(&shost->scan_mutex); | 1455 | mutex_unlock(&shost->scan_mutex); |
1468 | 1456 | ||
1469 | return 0; | 1457 | return 0; |
1470 | } | 1458 | } |
@@ -1522,7 +1510,7 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) | |||
1522 | struct scsi_device *sdev = NULL; | 1510 | struct scsi_device *sdev = NULL; |
1523 | struct scsi_target *starget; | 1511 | struct scsi_target *starget; |
1524 | 1512 | ||
1525 | down(&shost->scan_mutex); | 1513 | mutex_lock(&shost->scan_mutex); |
1526 | if (!scsi_host_scan_allowed(shost)) | 1514 | if (!scsi_host_scan_allowed(shost)) |
1527 | goto out; | 1515 | goto out; |
1528 | starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); | 1516 | starget = scsi_alloc_target(&shost->shost_gendev, 0, shost->this_id); |
@@ -1536,7 +1524,7 @@ struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) | |||
1536 | } | 1524 | } |
1537 | put_device(&starget->dev); | 1525 | put_device(&starget->dev); |
1538 | out: | 1526 | out: |
1539 | up(&shost->scan_mutex); | 1527 | mutex_unlock(&shost->scan_mutex); |
1540 | return sdev; | 1528 | return sdev; |
1541 | } | 1529 | } |
1542 | EXPORT_SYMBOL(scsi_get_host_dev); | 1530 | EXPORT_SYMBOL(scsi_get_host_dev); |