ata: Don't try to use non-existent ports
The controller indicates the number of ports but also has a port map which specifies which ports are actually valid. Make use of this to avoid trying to send commands to an invalid port. This avoids a crash on some controllers. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
							parent
							
								
									a60f7a3e35
								
							
						
					
					
						commit
						2b3ebf2013
					
				|  | @ -675,6 +675,12 @@ static int ata_scsiop_inquiry(struct ahci_uc_priv *uc_priv, | ||||||
| 	/* Read id from sata */ | 	/* Read id from sata */ | ||||||
| 	port = pccb->target; | 	port = pccb->target; | ||||||
| 
 | 
 | ||||||
|  | 	/* If this port number is not valid, give up */ | ||||||
|  | 	if (!(uc_priv->port_map & (1 << port))) { | ||||||
|  | 		debug("Port %x not valid in map %x\n", port, uc_priv->port_map); | ||||||
|  | 		return -ENODEV; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if (ahci_device_data_io(uc_priv, port, (u8 *)&fis, sizeof(fis), | 	if (ahci_device_data_io(uc_priv, port, (u8 *)&fis, sizeof(fis), | ||||||
| 				(u8 *)tmpid, ATA_ID_WORDS * 2, 0)) { | 				(u8 *)tmpid, ATA_ID_WORDS * 2, 0)) { | ||||||
| 		debug("scsi_ahci: SCSI inquiry command failure.\n"); | 		debug("scsi_ahci: SCSI inquiry command failure.\n"); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue