aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r--drivers/ata/libata-scsi.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index ec0e2638200..3d6d5f73799 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2425,7 +2425,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2425 2425
2426static struct ata_device * ata_find_dev(struct ata_port *ap, int id) 2426static struct ata_device * ata_find_dev(struct ata_port *ap, int id)
2427{ 2427{
2428 if (likely(id < ATA_MAX_DEVICES)) 2428 if (likely(id < ata_link_max_devices(&ap->link)))
2429 return &ap->link.device[id]; 2429 return &ap->link.device[id];
2430 return NULL; 2430 return NULL;
2431} 2431}
@@ -2952,21 +2952,18 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
2952 int tries = 5; 2952 int tries = 5;
2953 struct ata_device *last_failed_dev = NULL; 2953 struct ata_device *last_failed_dev = NULL;
2954 struct ata_device *dev; 2954 struct ata_device *dev;
2955 unsigned int i;
2956 2955
2957 if (ap->flags & ATA_FLAG_DISABLED) 2956 if (ap->flags & ATA_FLAG_DISABLED)
2958 return; 2957 return;
2959 2958
2960 repeat: 2959 repeat:
2961 for (i = 0; i < ATA_MAX_DEVICES; i++) { 2960 ata_link_for_each_dev(dev, &ap->link) {
2962 struct scsi_device *sdev; 2961 struct scsi_device *sdev;
2963 2962
2964 dev = &ap->link.device[i];
2965
2966 if (!ata_dev_enabled(dev) || dev->sdev) 2963 if (!ata_dev_enabled(dev) || dev->sdev)
2967 continue; 2964 continue;
2968 2965
2969 sdev = __scsi_add_device(ap->scsi_host, 0, i, 0, NULL); 2966 sdev = __scsi_add_device(ap->scsi_host, 0, dev->devno, 0, NULL);
2970 if (!IS_ERR(sdev)) { 2967 if (!IS_ERR(sdev)) {
2971 dev->sdev = sdev; 2968 dev->sdev = sdev;
2972 scsi_device_put(sdev); 2969 scsi_device_put(sdev);
@@ -2977,12 +2974,11 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
2977 * failure occurred, scan would have failed silently. Check 2974 * failure occurred, scan would have failed silently. Check
2978 * whether all devices are attached. 2975 * whether all devices are attached.
2979 */ 2976 */
2980 for (i = 0; i < ATA_MAX_DEVICES; i++) { 2977 ata_link_for_each_dev(dev, &ap->link) {
2981 dev = &ap->link.device[i];
2982 if (ata_dev_enabled(dev) && !dev->sdev) 2978 if (ata_dev_enabled(dev) && !dev->sdev)
2983 break; 2979 break;
2984 } 2980 }
2985 if (i == ATA_MAX_DEVICES) 2981 if (!dev)
2986 return; 2982 return;
2987 2983
2988 /* we're missing some SCSI devices */ 2984 /* we're missing some SCSI devices */
@@ -3112,7 +3108,7 @@ void ata_scsi_hotplug(struct work_struct *work)
3112{ 3108{
3113 struct ata_port *ap = 3109 struct ata_port *ap =
3114 container_of(work, struct ata_port, hotplug_task.work); 3110 container_of(work, struct ata_port, hotplug_task.work);
3115 int i; 3111 struct ata_device *dev;
3116 3112
3117 if (ap->pflags & ATA_PFLAG_UNLOADING) { 3113 if (ap->pflags & ATA_PFLAG_UNLOADING) {
3118 DPRINTK("ENTER/EXIT - unloading\n"); 3114 DPRINTK("ENTER/EXIT - unloading\n");
@@ -3122,8 +3118,7 @@ void ata_scsi_hotplug(struct work_struct *work)
3122 DPRINTK("ENTER\n"); 3118 DPRINTK("ENTER\n");
3123 3119
3124 /* unplug detached devices */ 3120 /* unplug detached devices */
3125 for (i = 0; i < ATA_MAX_DEVICES; i++) { 3121 ata_link_for_each_dev(dev, &ap->link) {
3126 struct ata_device *dev = &ap->link.device[i];
3127 unsigned long flags; 3122 unsigned long flags;
3128 3123
3129 if (!(dev->flags & ATA_DFLAG_DETACHED)) 3124 if (!(dev->flags & ATA_DFLAG_DETACHED))
@@ -3176,7 +3171,7 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3176 spin_lock_irqsave(ap->lock, flags); 3171 spin_lock_irqsave(ap->lock, flags);
3177 3172
3178 if (id == SCAN_WILD_CARD) { 3173 if (id == SCAN_WILD_CARD) {
3179 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; 3174 ehi->probe_mask |= (1 << ata_link_max_devices(&ap->link)) - 1;
3180 ehi->action |= ATA_EH_SOFTRESET; 3175 ehi->action |= ATA_EH_SOFTRESET;
3181 } else { 3176 } else {
3182 struct ata_device *dev = ata_find_dev(ap, id); 3177 struct ata_device *dev = ata_find_dev(ap, id);
@@ -3215,13 +3210,12 @@ void ata_scsi_dev_rescan(struct work_struct *work)
3215{ 3210{
3216 struct ata_port *ap = 3211 struct ata_port *ap =
3217 container_of(work, struct ata_port, scsi_rescan_task); 3212 container_of(work, struct ata_port, scsi_rescan_task);
3213 struct ata_device *dev;
3218 unsigned long flags; 3214 unsigned long flags;
3219 unsigned int i;
3220 3215
3221 spin_lock_irqsave(ap->lock, flags); 3216 spin_lock_irqsave(ap->lock, flags);
3222 3217
3223 for (i = 0; i < ATA_MAX_DEVICES; i++) { 3218 ata_link_for_each_dev(dev, &ap->link) {
3224 struct ata_device *dev = &ap->link.device[i];
3225 struct scsi_device *sdev = dev->sdev; 3219 struct scsi_device *sdev = dev->sdev;
3226 3220
3227 if (!ata_dev_enabled(dev) || !sdev) 3221 if (!ata_dev_enabled(dev) || !sdev)