diff options
author | Simon Glass <sjg@chromium.org> | 2018-10-01 21:22:46 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-10-09 13:40:27 +0300 |
commit | 751fed426f87204517df14de76762461cd2a4203 (patch) | |
tree | 97843e594f8276674c09d73665fe376bba040ae3 /drivers/sysreset/sysreset-uclass.c | |
parent | eb517315a67320e770cf4a100a922e8ae18fa54e (diff) | |
download | u-boot-751fed426f87204517df14de76762461cd2a4203.tar.xz |
sysreset: Add a way to find the last reset
We have a method to return the last reset as a string for humans, but not
a method that allows it to be used programmatically. Add a new method that
returns the last reset as an enum.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/sysreset/sysreset-uclass.c')
-rw-r--r-- | drivers/sysreset/sysreset-uclass.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index e38814b3ed..ad831c703a 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -36,6 +36,16 @@ int sysreset_get_status(struct udevice *dev, char *buf, int size) return ops->get_status(dev, buf, size); } +int sysreset_get_last(struct udevice *dev) +{ + struct sysreset_ops *ops = sysreset_get_ops(dev); + + if (!ops->get_last) + return -ENOSYS; + + return ops->get_last(dev); +} + int sysreset_walk(enum sysreset_t type) { struct udevice *dev; @@ -55,6 +65,26 @@ int sysreset_walk(enum sysreset_t type) return ret; } +int sysreset_get_last_walk(void) +{ + struct udevice *dev; + int value = -ENOENT; + + for (uclass_first_device(UCLASS_SYSRESET, &dev); + dev; + uclass_next_device(&dev)) { + int ret; + + ret = sysreset_get_last(dev); + if (ret >= 0) { + value = ret; + break; + } + } + + return value; +} + void sysreset_walk_halt(enum sysreset_t type) { int ret; |