diff options
-rw-r--r-- | drivers/scsi/libata-core.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 3aa477a3302f..38fc75d6b39c 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -5403,7 +5403,7 @@ void ata_host_set_init(struct ata_host_set *host_set, | |||
5403 | */ | 5403 | */ |
5404 | int ata_device_add(const struct ata_probe_ent *ent) | 5404 | int ata_device_add(const struct ata_probe_ent *ent) |
5405 | { | 5405 | { |
5406 | unsigned int count = 0, i; | 5406 | unsigned int i; |
5407 | struct device *dev = ent->dev; | 5407 | struct device *dev = ent->dev; |
5408 | struct ata_host_set *host_set; | 5408 | struct ata_host_set *host_set; |
5409 | int rc; | 5409 | int rc; |
@@ -5422,7 +5422,7 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5422 | host_set->private_data = ent->private_data; | 5422 | host_set->private_data = ent->private_data; |
5423 | 5423 | ||
5424 | /* register each port bound to this device */ | 5424 | /* register each port bound to this device */ |
5425 | for (i = 0; i < ent->n_ports; i++) { | 5425 | for (i = 0; i < host_set->n_ports; i++) { |
5426 | struct ata_port *ap; | 5426 | struct ata_port *ap; |
5427 | unsigned long xfer_mode_mask; | 5427 | unsigned long xfer_mode_mask; |
5428 | 5428 | ||
@@ -5448,12 +5448,8 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5448 | ata_chk_status(ap); | 5448 | ata_chk_status(ap); |
5449 | host_set->ops->irq_clear(ap); | 5449 | host_set->ops->irq_clear(ap); |
5450 | ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */ | 5450 | ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */ |
5451 | count++; | ||
5452 | } | 5451 | } |
5453 | 5452 | ||
5454 | if (!count) | ||
5455 | goto err_free_ret; | ||
5456 | |||
5457 | /* obtain irq, that is shared between channels */ | 5453 | /* obtain irq, that is shared between channels */ |
5458 | rc = request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags, | 5454 | rc = request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags, |
5459 | DRV_NAME, host_set); | 5455 | DRV_NAME, host_set); |
@@ -5465,13 +5461,11 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5465 | 5461 | ||
5466 | /* perform each probe synchronously */ | 5462 | /* perform each probe synchronously */ |
5467 | DPRINTK("probe begin\n"); | 5463 | DPRINTK("probe begin\n"); |
5468 | for (i = 0; i < count; i++) { | 5464 | for (i = 0; i < host_set->n_ports; i++) { |
5469 | struct ata_port *ap; | 5465 | struct ata_port *ap = host_set->ports[i]; |
5470 | u32 scontrol; | 5466 | u32 scontrol; |
5471 | int rc; | 5467 | int rc; |
5472 | 5468 | ||
5473 | ap = host_set->ports[i]; | ||
5474 | |||
5475 | /* init sata_spd_limit to the current value */ | 5469 | /* init sata_spd_limit to the current value */ |
5476 | if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { | 5470 | if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { |
5477 | int spd = (scontrol >> 4) & 0xf; | 5471 | int spd = (scontrol >> 4) & 0xf; |
@@ -5527,7 +5521,7 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5527 | 5521 | ||
5528 | /* probes are done, now scan each port's disk(s) */ | 5522 | /* probes are done, now scan each port's disk(s) */ |
5529 | DPRINTK("host probe begin\n"); | 5523 | DPRINTK("host probe begin\n"); |
5530 | for (i = 0; i < count; i++) { | 5524 | for (i = 0; i < host_set->n_ports; i++) { |
5531 | struct ata_port *ap = host_set->ports[i]; | 5525 | struct ata_port *ap = host_set->ports[i]; |
5532 | 5526 | ||
5533 | ata_scsi_scan_host(ap); | 5527 | ata_scsi_scan_host(ap); |
@@ -5539,14 +5533,14 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5539 | return ent->n_ports; /* success */ | 5533 | return ent->n_ports; /* success */ |
5540 | 5534 | ||
5541 | err_out: | 5535 | err_out: |
5542 | for (i = 0; i < count; i++) { | 5536 | for (i = 0; i < host_set->n_ports; i++) { |
5543 | struct ata_port *ap = host_set->ports[i]; | 5537 | struct ata_port *ap = host_set->ports[i]; |
5544 | if (ap) { | 5538 | if (ap) { |
5545 | ap->ops->port_stop(ap); | 5539 | ap->ops->port_stop(ap); |
5546 | scsi_host_put(ap->host); | 5540 | scsi_host_put(ap->host); |
5547 | } | 5541 | } |
5548 | } | 5542 | } |
5549 | err_free_ret: | 5543 | |
5550 | kfree(host_set); | 5544 | kfree(host_set); |
5551 | VPRINTK("EXIT, returning 0\n"); | 5545 | VPRINTK("EXIT, returning 0\n"); |
5552 | return 0; | 5546 | return 0; |