/**
 * e100_diag_eeprom - validate eeprom checksum correctness
 * @dev: atapter's net device data struct
 *
 */
static u8
e100_diag_eeprom (struct net_device *dev)
{
	struct e100_private *bdp = dev->priv;
	u16 i, eeprom_sum, eeprom_actual_csm;

	for (i = 0, eeprom_sum = 0; i < (bdp->eeprom_size - 1); i++) {
		eeprom_sum += e100_eeprom_read(bdp, i);
	}

	eeprom_actual_csm = e100_eeprom_read(bdp, bdp->eeprom_size - 1);

	if (eeprom_actual_csm == (u16)(EEPROM_SUM - eeprom_sum)) {
		return true;
	}

	return false;
}
Example #2
0
//**********************************************************************************
// Procedure:   e100_eeprom_update_chksum
//
// Description: Calculates the checksum and writes it to the EEProm. 
//              It calculates the checksum accroding to the formula: 
//                              Checksum = 0xBABA - (sum of first 63 words).
//
//-----------------------------------------------------------------------------------
u16
e100_eeprom_calculate_chksum(struct e100_private *adapter)
{
	u16 idx, xsum_index, checksum = 0;

	// eeprom size is initialized to zero
	if (!adapter->eeprom_size)
		adapter->eeprom_size = e100_eeprom_size(adapter);

	xsum_index = adapter->eeprom_size - 1;
	for (idx = 0; idx < xsum_index; idx++)
		checksum += e100_eeprom_read(adapter, idx);

	checksum = EEPROM_CHECKSUM - checksum;
	return checksum;
}