Lines Matching refs:buf
15 static int ivm_calc_crc(unsigned char *buf, int len) in ivm_calc_crc() argument
30 byte = buf[i]; in ivm_calc_crc()
57 static int ivm_get_value(unsigned char *buf, int len, char *name, int off, in ivm_get_value() argument
63 if (buf[off + 0] != buf[off + 2] && in ivm_get_value()
64 buf[off + 2] != buf[off + 4]) { in ivm_get_value()
68 val = buf[off + 0] + (buf[off + 1] << 8); in ivm_get_value()
102 unsigned char *buf) in ivm_findinventorystring() argument
124 if (buf[addr] == '\r') in ivm_findinventorystring()
135 for (; (buf[addr] != '\r') && in ivm_findinventorystring()
136 ((buf[addr] != ';') || (!stop)) && in ivm_findinventorystring()
140 convert_char (buf[addr])); in ivm_findinventorystring()
152 (buf[addr] != '\r')) { in ivm_findinventorystring()
168 if (ivm_findinventorystring(which, valbuf, len, buf) == 0) { \
172 static int ivm_check_crc(unsigned char *buf, int block) in ivm_check_crc() argument
177 crc = ivm_calc_crc(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2); in ivm_check_crc()
178 crceeprom = (buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 1] + in ivm_check_crc()
179 buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2] * 256); in ivm_check_crc()
190 static int process_mac(unsigned char *valbuf, unsigned char *buf, in process_mac() argument
194 unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; in process_mac()
199 memcpy(mac, buf + 1, 6); in process_mac()
219 static int ivm_analyze_block2(unsigned char *buf, int len) in ivm_analyze_block2() argument
225 sprintf((char *)valbuf, "%pM", buf + 1); in ivm_analyze_block2()
228 count = (buf[10] << 24) + in ivm_analyze_block2()
229 (buf[11] << 16) + in ivm_analyze_block2()
230 (buf[12] << 8) + in ivm_analyze_block2()
231 buf[13]; in ivm_analyze_block2()
239 int ivm_analyze_eeprom(unsigned char *buf, int len) in ivm_analyze_eeprom() argument
245 if (ivm_check_crc(buf, 0) != 0) in ivm_analyze_eeprom()
248 ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, in ivm_analyze_eeprom()
250 val = ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, in ivm_analyze_eeprom()
258 ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, in ivm_analyze_eeprom()
291 if (ivm_check_crc(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], 2) != 0) in ivm_analyze_eeprom()
293 ivm_analyze_block2(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], in ivm_analyze_eeprom()
299 static int ivm_populate_env(unsigned char *buf, int len, int mac_address_offset) in ivm_populate_env() argument
305 if (ivm_check_crc(buf, 2)) in ivm_populate_env()
307 page2 = &buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2]; in ivm_populate_env()
333 int ivm_read_eeprom(unsigned char *buf, int len, int mac_address_offset) in ivm_read_eeprom() argument
347 ret = dm_i2c_read(eedev, 0, buf, len); in ivm_read_eeprom()
358 ret = i2c_read(CONFIG_SYS_IVM_EEPROM_ADR, 0, 1, buf, len); in ivm_read_eeprom()
364 return ivm_populate_env(buf, len, mac_address_offset); in ivm_read_eeprom()