| 219 | } |
| 220 | |
| 221 | static int |
| 222 | read_sysfs_string(const char *path, char *buf, size_t size) |
| 223 | { |
| 224 | FILE *f; |
| 225 | char *p; |
| 226 | |
| 227 | f = fopen(path, "r"); |
| 228 | if (f == NULL) |
| 229 | return -errno; |
| 230 | |
| 231 | if (fgets(buf, size, f) == NULL) { |
| 232 | fclose(f); |
| 233 | return -ENODATA; |
| 234 | } |
| 235 | |
| 236 | fclose(f); |
| 237 | |
| 238 | p = strrchr(buf, '\n'); |
| 239 | if (p != NULL) |
| 240 | *p = '\0'; |
| 241 | |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | static char * |
| 246 | of_resource_name(const char *dev_name, int index) |
no test coverage detected