recovery: change the way to determine if the device is closed

The old fsl_otp driver is deprecated and we need to determine
if the device is closed using a new property of the device tree
called 'digi,tf-closed'.

Assume the device is open if the property is not found.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://jira.digi.com/browse/DEL-7185
This commit is contained in:
Hector Palacios 2020-07-17 12:40:04 +02:00
parent 8ced362766
commit fc1a736758
1 changed files with 6 additions and 12 deletions

View File

@ -94,21 +94,15 @@ err:
*/ */
static int is_device_closed(void) static int is_device_closed(void)
{ {
const char *path = "/sys/fsl_otp/HW_OCOTP_CFG5"; const char *path_closed = "/proc/device-tree/digi,tf-closed";
FILE *fd = NULL;
unsigned int value = 0;
long open = 0;
if ((fd = fopen(path, "r")) == NULL) { if (access(path_closed, F_OK) != -1)
fprintf(stderr, "Cannot check device status. Assuming closed...\n");
return 1; return 1;
} else
fprintf(stderr,
"Cannot check device status. Assuming open...\n");
open = (fscanf(fd, "%x", &value) == 1) && (value & OTP_CLOSED_BIT); return 0;
fclose(fd);
return open;
} }
/* /*