summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c')
-rw-r--r--tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
index f20d1c166d1e..4f1fef6198fc 100644
--- a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
+++ b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
@@ -12,27 +12,16 @@
static int check_cpu_dscr_default(char *file, unsigned long val)
{
- char buf[10];
- int fd, rc;
+ unsigned long cpu_dscr;
+ int err;
- fd = open(file, O_RDWR);
- if (fd == -1) {
- perror("open() failed");
- return 1;
- }
-
- rc = read(fd, buf, sizeof(buf));
- if (rc == -1) {
- perror("read() failed");
- close(fd);
- return 1;
- }
- close(fd);
+ err = read_ulong(file, &cpu_dscr, 16);
+ if (err)
+ return err;
- buf[rc] = '\0';
- if (strtol(buf, NULL, 16) != val) {
+ if (cpu_dscr != val) {
printf("DSCR match failed: %ld (system) %ld (cpu)\n",
- val, strtol(buf, NULL, 16));
+ val, cpu_dscr);
return 1;
}
return 0;