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
(cherry picked from commit fc1a736758)
This commit is contained in:
Hector Palacios 2020-07-17 12:40:04 +02:00
parent 5403b831df
commit ff5d0628d9
1 changed files with 6 additions and 12 deletions

View File

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