diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/pci.c')
| -rw-r--r-- | drivers/net/wireless/ath/ath10k/pci.c | 21 | 
1 files changed, 18 insertions, 3 deletions
| diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index bb44f5a0941b..ded7a220a4aa 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1578,7 +1578,7 @@ static int ath10k_pci_set_ram_config(struct ath10k *ar, u32 config)  	return 0;  } -/* if an error happened returns < 0, otherwise the length */ +/* Always returns the length */  static int ath10k_pci_dump_memory_sram(struct ath10k *ar,  				       const struct ath10k_mem_region *region,  				       u8 *buf) @@ -1604,11 +1604,22 @@ static int ath10k_pci_dump_memory_reg(struct ath10k *ar,  {  	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);  	u32 i; +	int ret; + +	mutex_lock(&ar->conf_mutex); +	if (ar->state != ATH10K_STATE_ON) { +		ath10k_warn(ar, "Skipping pci_dump_memory_reg invalid state\n"); +		ret = -EIO; +		goto done; +	}  	for (i = 0; i < region->len; i += 4)  		*(u32 *)(buf + i) = ioread32(ar_pci->mem + region->start + i); -	return region->len; +	ret = region->len; +done: +	mutex_unlock(&ar->conf_mutex); +	return ret;  }  /* if an error happened returns < 0, otherwise the length */ @@ -1704,7 +1715,11 @@ static void ath10k_pci_dump_memory(struct ath10k *ar,  			count = ath10k_pci_dump_memory_sram(ar, current_region, buf);  			break;  		case ATH10K_MEM_REGION_TYPE_IOREG: -			count = ath10k_pci_dump_memory_reg(ar, current_region, buf); +			ret = ath10k_pci_dump_memory_reg(ar, current_region, buf); +			if (ret < 0) +				break; + +			count = ret;  			break;  		default:  			ret = ath10k_pci_dump_memory_generic(ar, current_region, buf); | 
