Skip to content

Commit 606f3c7

Browse files
util/cbmem: search for CBMEM in sysfs by default
Kernel driver may expose CBMEM in sysfs. By doing so, it is possible to use cbmem utility even with CONFIG_STRICT_DEVMEM. If there is no file exposed, cbmem falls back to probing memory directly. Signed-off-by: Krystian Hebel <[email protected]>
1 parent 06adc98 commit 606f3c7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

util/cbmem/cbmem.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,11 @@ int main(int argc, char** argv)
18641864
print_usage(argv[0], 1);
18651865
}
18661866

1867+
/* Check if Linux driver exposes CBMEM in sysfs. */
1868+
if (file_fd < 0) {
1869+
file_fd = open("/sys/firmware/cbmem", O_RDONLY, 0);
1870+
}
1871+
18671872
if (file_fd < 0) {
18681873
mem_fd = open("/dev/mem", timestamp_id ? O_RDWR : O_RDONLY, 0);
18691874
if (mem_fd < 0) {

0 commit comments

Comments
 (0)