Lines Matching +full:reverse +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2009-2016 CompuLab, Ltd.
14 char *delimiter, bool reverse) in __eeprom_field_print_bin() argument
17 int from = reverse ? field->size - 1 : 0; in __eeprom_field_print_bin()
18 int to = reverse ? 0 : field->size - 1; in __eeprom_field_print_bin()
20 printf(PRINT_FIELD_SEGMENT, field->name); in __eeprom_field_print_bin()
21 for (i = from; i != to; reverse ? i-- : i++) in __eeprom_field_print_bin()
22 printf("%02x%s", field->buf[i], delimiter); in __eeprom_field_print_bin()
24 printf("%02x\n", field->buf[i]); in __eeprom_field_print_bin()
28 const char *value, bool reverse) in __eeprom_field_update_bin() argument
31 int k, j, i = reverse ? len - 1 : 0; in __eeprom_field_update_bin()
36 if (len > field->size * 2) in __eeprom_field_update_bin()
37 return -1; in __eeprom_field_update_bin()
39 memset(field->buf, 0, field->size); in __eeprom_field_update_bin()
41 /* i - string iterator, j - buf iterator */ in __eeprom_field_update_bin()
42 for (j = 0; j < field->size; j++) { in __eeprom_field_update_bin()
46 if ((reverse && i < 0) || (!reverse && i >= len)) in __eeprom_field_update_bin()
50 if (reverse && i == 0) { in __eeprom_field_update_bin()
55 tmp[k] = value[reverse ? i - 1 + k : i + k]; in __eeprom_field_update_bin()
60 return -1; in __eeprom_field_update_bin()
62 field->buf[j] = byte; in __eeprom_field_update_bin()
63 i = reverse ? i - 2 : i + 2; in __eeprom_field_update_bin()
85 if (count > field->size) in __eeprom_field_update_bin_delim()
86 return -1; in __eeprom_field_update_bin_delim()
89 for (i = 0; tok && i < field->size; i++) { in __eeprom_field_update_bin_delim()
92 return -1; in __eeprom_field_update_bin_delim()
95 field->buf[i] = (unsigned char)val; in __eeprom_field_update_bin_delim()
103 * eeprom_field_print_bin() - print a field which contains binary data
105 * Treat the field data as simple binary data, and print it as two digit
118 * eeprom_field_update_bin() - Update field with new data in binary form
129 * eeprom_field_update_reserved() - Update reserved field with new data in
141 * eeprom_field_print_bin_rev() - print a field which contains binary data in
142 * reverse order
144 * Treat the field data as simple binary data, and print it in reverse order
147 * Data in field:
160 * eeprom_field_update_bin_rev() - Update field with new data in binary form,
161 * storing it in reverse
164 * in the field in the reverse order. i.e. if the input string was "1234",
176 * eeprom_field_print_mac_addr() - print a field which contains a mac address
178 * Treat the field data as simple binary data, and print it formatted as a MAC
191 * eeprom_field_update_mac() - Update a mac address field which contains binary
192 * data
203 * eeprom_field_print_ascii() - print a field which contains ASCII data
210 sprintf(format, "%%.%ds\n", field->size); in eeprom_field_print_ascii()
211 printf(PRINT_FIELD_SEGMENT, field->name); in eeprom_field_print_ascii()
212 printf(format, field->buf); in eeprom_field_print_ascii()
216 * eeprom_field_update_ascii() - Update field with new data in ASCII form
218 * @value: the new string data
220 * Returns 0 on success, -1 of failure (new string too long).
224 if (strlen(value) >= field->size) { in eeprom_field_update_ascii()
225 printf("%s: new data too long\n", field->name); in eeprom_field_update_ascii()
226 return -1; in eeprom_field_update_ascii()
229 strncpy((char *)field->buf, value, field->size - 1); in eeprom_field_update_ascii()
230 field->buf[field->size - 1] = '\0'; in eeprom_field_update_ascii()
236 * eeprom_field_print_reserved() - print the "Reserved fields" field
248 printf("(%d bytes)\n", field->size); in eeprom_field_print_reserved()