forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * POWER Data Stream Control Register (DSCR) sysfs interface test
34 *
....@@ -6,10 +7,6 @@
67 * well verified from their sysfs interfaces.
78 *
89 * Copyright 2015, Anshuman Khandual, IBM Corporation.
9
- *
10
- * This program is free software; you can redistribute it and/or modify it
11
- * under the terms of the GNU General Public License version 2 as published
12
- * by the Free Software Foundation.
1310 */
1411 #include "dscr.h"
1512
....@@ -27,6 +24,7 @@
2724 rc = read(fd, buf, sizeof(buf));
2825 if (rc == -1) {
2926 perror("read() failed");
27
+ close(fd);
3028 return 1;
3129 }
3230 close(fd);
....@@ -68,8 +66,10 @@
6866 if (access(file, F_OK))
6967 continue;
7068
71
- if (check_cpu_dscr_default(file, val))
69
+ if (check_cpu_dscr_default(file, val)) {
70
+ closedir(sysfs);
7271 return 1;
72
+ }
7373 }
7474 closedir(sysfs);
7575 return 0;
....@@ -80,6 +80,8 @@
8080 unsigned long orig_dscr_default;
8181 int i, j;
8282
83
+ SKIP_IF(!have_hwcap2(PPC_FEATURE2_DSCR));
84
+
8385 orig_dscr_default = get_default_dscr();
8486 for (i = 0; i < COUNT; i++) {
8587 for (j = 0; j < DSCR_MAX; j++) {