WiringPi: Check Device Tree first to recognize and change the referenced DT path
As of this quotes from the /sys/firmware/devicetree documents.
Userspace must not use the /sys/firmware/devicetree/base path directly,
but instead should follow /proc/device-tree symlink.
Signed-off-by: Deokgyu Yang <secugyu@gmail.com>
Change-Id: Ib6cd8694cf3b429297e5e7154387c1fb18716600
diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c
index 9fde661..0356619 100644
--- a/wiringPi/wiringPi.c
+++ b/wiringPi/wiringPi.c
@@ -282,7 +282,7 @@
int getModelFromDt(char *line, FILE *dtFd) {
char *model;
- if ((dtFd = fopen("/sys/firmware/devicetree/base/model", "r")) != NULL) {
+ if ((dtFd = fopen("/proc/device-tree/model", "r")) != NULL) {
if (fgets(line, 120, dtFd) == NULL)
return -1;
@@ -308,7 +308,7 @@
int sizeOfAssignedModelNames = 0;
int i;
- if (getModelFromCpuinfo(line, cpuFd) != 0 && getModelFromDt(line, dtFd) != 0)
+ if (getModelFromDt(line, dtFd) != 0 && getModelFromCpuinfo(line, cpuFd) != 0)
wiringPiFailure(WPI_FATAL, "** This board is not an Odroid **");
for (i = 1; i < (int)(sizeof(piModelNames) / sizeof(char*)); i++) {