Lines Matching +full:rc +full:- +full:map +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-only
5 * (c) Copyright 2007 Hewlett-Packard Development Company, L.P.
26 int fd, rc; in map_mem() local
31 if (fd == -1) { in map_mem()
33 return -1; in map_mem()
37 rc = ioctl(fd, PCIIOC_MMAP_IS_MEM); in map_mem()
38 if (rc == -1) in map_mem()
52 rc = munmap(addr, length); in map_mem()
53 if (rc == -1) { in map_mem()
55 return -1; in map_mem()
65 char *name, *path2; in scan_tree() local
66 int i, n, r, rc = 0, result = 0; in scan_tree() local
72 return -1; in scan_tree()
76 name = namelist[i]->d_name; in scan_tree()
78 if (fnmatch(".", name, 0) == 0) in scan_tree()
80 if (fnmatch("..", name, 0) == 0) in scan_tree()
83 path2 = malloc(strlen(path) + strlen(name) + 3); in scan_tree()
86 strcat(path2, name); in scan_tree()
88 if (fnmatch(file, name, 0) == 0) { in scan_tree()
89 rc = map_mem(path2, offset, length, touch); in scan_tree()
90 if (rc == 0) in scan_tree()
91 …fprintf(stderr, "PASS: %s 0x%lx-0x%lx is %s\n", path2, offset, offset + length, touch ? "readable"… in scan_tree()
92 else if (rc > 0) in scan_tree()
93 fprintf(stderr, "PASS: %s 0x%lx-0x%lx not mappable\n", path2, offset, offset + length); in scan_tree()
95 fprintf(stderr, "FAIL: %s 0x%lx-0x%lx not accessible\n", path2, offset, offset + length); in scan_tree()
96 return rc; in scan_tree()
101 rc = scan_tree(path2, file, offset, length, touch); in scan_tree()
102 if (rc < 0) in scan_tree()
103 return rc; in scan_tree()
107 result |= rc; in scan_tree()
121 int fd, rc; in read_rom() local
125 if (fd == -1) { in read_rom()
127 return -1; in read_rom()
130 rc = write(fd, "1", 2); in read_rom()
131 if (rc <= 0) { in read_rom()
134 return -1; in read_rom()
138 rc = read(fd, buf, sizeof(buf)); in read_rom()
139 if (rc > 0) in read_rom()
140 size += rc; in read_rom()
141 } while (rc > 0); in read_rom()
150 char *name, *path2; in scan_rom() local
151 int i, n, r, rc = 0, result = 0; in scan_rom() local
157 return -1; in scan_rom()
161 name = namelist[i]->d_name; in scan_rom()
163 if (fnmatch(".", name, 0) == 0) in scan_rom()
165 if (fnmatch("..", name, 0) == 0) in scan_rom()
168 path2 = malloc(strlen(path) + strlen(name) + 3); in scan_rom()
171 strcat(path2, name); in scan_rom()
173 if (fnmatch(file, name, 0) == 0) { in scan_rom()
174 rc = read_rom(path2); in scan_rom()
181 if (rc > 0) in scan_rom()
182 fprintf(stderr, "PASS: %s read %d bytes\n", path2, rc); in scan_rom()
185 return rc; in scan_rom()
190 rc = scan_rom(path2, file); in scan_rom()
191 if (rc < 0) in scan_rom()
192 return rc; in scan_rom()
196 result |= rc; in scan_rom()
208 int rc; in main() local
211 fprintf(stderr, "PASS: /dev/mem 0x0-0xa0000 is readable\n"); in main()
213 fprintf(stderr, "FAIL: /dev/mem 0x0-0xa0000 not accessible\n"); in main()
219 * up a non-responding card by just returning -1, but others will in main()
223 fprintf(stderr, "PASS: /dev/mem 0xa0000-0xc0000 is mappable\n"); in main()
225 fprintf(stderr, "FAIL: /dev/mem 0xa0000-0xc0000 not accessible\n"); in main()
228 fprintf(stderr, "PASS: /dev/mem 0xc0000-0x100000 is readable\n"); in main()
230 fprintf(stderr, "FAIL: /dev/mem 0xc0000-0x100000 not accessible\n"); in main()
233 * Often you can map all the individual pieces above (0-0xA0000, in main()
234 * 0xA0000-0xC0000, and 0xC0000-0x100000), but can't map the whole in main()
239 rc = map_mem("/dev/mem", 0, 1024*1024, 0); in main()
240 if (rc == 0) in main()
241 fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 is mappable\n"); in main()
242 else if (rc > 0) in main()
243 fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 not mappable\n"); in main()
245 fprintf(stderr, "FAIL: /dev/mem 0x0-0x100000 not accessible\n"); in main()
259 return rc; in main()