diff options
Diffstat (limited to 'drivers/ata/libata-core.c')
| -rw-r--r-- | drivers/ata/libata-core.c | 25 | 
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 40e816419f48..9601fa92950a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2010,16 +2010,16 @@ retry:  	return err_mask;  } -static bool ata_log_supported(struct ata_device *dev, u8 log) +static int ata_log_supported(struct ata_device *dev, u8 log)  {  	struct ata_port *ap = dev->link->ap;  	if (dev->horkage & ATA_HORKAGE_NO_LOG_DIR) -		return false; +		return 0;  	if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, ap->sector_buf, 1)) -		return false; -	return get_unaligned_le16(&ap->sector_buf[log * 2]) ? true : false; +		return 0; +	return get_unaligned_le16(&ap->sector_buf[log * 2]);  }  static bool ata_identify_page_supported(struct ata_device *dev, u8 page) @@ -2455,15 +2455,20 @@ static void ata_dev_config_cpr(struct ata_device *dev)  	struct ata_cpr_log *cpr_log = NULL;  	u8 *desc, *buf = NULL; -	if (ata_id_major_version(dev->id) < 11 || -	    !ata_log_supported(dev, ATA_LOG_CONCURRENT_POSITIONING_RANGES)) +	if (ata_id_major_version(dev->id) < 11) +		goto out; + +	buf_len = ata_log_supported(dev, ATA_LOG_CONCURRENT_POSITIONING_RANGES); +	if (buf_len == 0)  		goto out;  	/*  	 * Read the concurrent positioning ranges log (0x47). We can have at -	 * most 255 32B range descriptors plus a 64B header. +	 * most 255 32B range descriptors plus a 64B header. This log varies in +	 * size, so use the size reported in the GPL directory. Reading beyond +	 * the supported length will result in an error.  	 */ -	buf_len = (64 + 255 * 32 + 511) & ~511; +	buf_len <<= 9;  	buf = kzalloc(buf_len, GFP_KERNEL);  	if (!buf)  		goto out; @@ -5462,7 +5467,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,  				      const struct ata_port_info * const * ppi,  				      int n_ports)  { -	const struct ata_port_info *pi; +	const struct ata_port_info *pi = &ata_dummy_port_info;  	struct ata_host *host;  	int i, j; @@ -5470,7 +5475,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,  	if (!host)  		return NULL; -	for (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) { +	for (i = 0, j = 0; i < host->n_ports; i++) {  		struct ata_port *ap = host->ports[i];  		if (ppi[j])  |