drivers/net/wireless/ath/ath9k/eeprom.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath9k/eeprom.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/ath/ath9k/eeprom.c
Extension
.c
Size
17478 bytes
Lines
676
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (pList[i] == target) {
			*indexL = *indexR = i;
			return true;
		}
		if (target < pList[i + 1]) {
			*indexL = i;
			*indexR = (u16) (i + 1);
			return false;
		}
	}
	return false;
}

void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
				  int eep_start_loc, int size)
{
	int i = 0, j, addr;
	u32 addrdata[8];
	u32 data[8];

	for (addr = 0; addr < size; addr++) {
		addrdata[i] = AR5416_EEPROM_OFFSET +
			((addr + eep_start_loc) << AR5416_EEPROM_S);
		i++;
		if (i == 8) {
			REG_READ_MULTI(ah, addrdata, data, i);

			for (j = 0; j < i; j++) {
				*eep_data = data[j];
				eep_data++;
			}
			i = 0;
		}
	}

	if (i != 0) {
		REG_READ_MULTI(ah, addrdata, data, i);

		for (j = 0; j < i; j++) {
			*eep_data = data[j];
			eep_data++;
		}
	}
}

static bool ath9k_hw_nvram_read_array(u16 *blob, size_t blob_size,
				      off_t offset, u16 *data)
{
	if (offset >= blob_size)
		return false;

	*data =  blob[offset];
	return true;
}

static bool ath9k_hw_nvram_read_firmware(const struct firmware *eeprom_blob,
					 off_t offset, u16 *data)
{
	return ath9k_hw_nvram_read_array((u16 *) eeprom_blob->data,
					 eeprom_blob->size / sizeof(u16),
					 offset, data);
}

static bool ath9k_hw_nvram_read_nvmem(struct ath_hw *ah, off_t offset,
				      u16 *data)
{
	return ath9k_hw_nvram_read_array(ah->nvmem_blob,
					 ah->nvmem_blob_len / sizeof(u16),
					 offset, data);
}

bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data)
{
	struct ath_common *common = ath9k_hw_common(ah);
	bool ret;

	if (ah->nvmem_blob)
		ret = ath9k_hw_nvram_read_nvmem(ah, off, data);
	else if (ah->eeprom_blob)
		ret = ath9k_hw_nvram_read_firmware(ah->eeprom_blob, off, data);
	else
		ret = common->bus_ops->eeprom_read(common, off, data);

	if (!ret)
		ath_dbg(common, EEPROM,
			"unable to read eeprom region at offset %u\n", off);

	return ret;
}

Annotation

Implementation Notes