diff options
author | Tom Rini <trini@konsulko.com> | 2021-04-19 17:00:51 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-04-19 17:00:51 -0400 |
commit | ac1f16f916f3e3153f9a8ee76aebe0243c18ff86 (patch) | |
tree | 212186e7a58496abd908981e720343edcf50d9b7 /drivers/sysinfo/sysinfo-uclass.c | |
parent | eed05148c261e3b5f00b11a7a14bf0222b80a0ac (diff) | |
parent | 03ad526edce501b883ea6032a4782967b8b52e81 (diff) | |
download | u-boot-WIP/19Apr2021.zip u-boot-WIP/19Apr2021.tar.gz u-boot-WIP/19Apr2021.tar.bz2 |
Merge branch '2021-04-19-assorted-improvements'WIP/19Apr2021
- ARM64 GIC fix, CONFIG_IRQ now moved to Kconfig
- IDE, lz4 fixes
- octeontx cleanups / enhancements
- highbank DM migration
- sysinfo improvements
- psci updates
- Enable use of -fstack-protector
Diffstat (limited to 'drivers/sysinfo/sysinfo-uclass.c')
-rw-r--r-- | drivers/sysinfo/sysinfo-uclass.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/sysinfo/sysinfo-uclass.c b/drivers/sysinfo/sysinfo-uclass.c index 6df58fe..4a660df 100644 --- a/drivers/sysinfo/sysinfo-uclass.c +++ b/drivers/sysinfo/sysinfo-uclass.c @@ -8,6 +8,10 @@ #include <dm.h> #include <sysinfo.h> +struct sysinfo_priv { + bool detected; +}; + int sysinfo_get(struct udevice **devp) { return uclass_first_device_err(UCLASS_SYSINFO, devp); @@ -15,19 +19,29 @@ int sysinfo_get(struct udevice **devp) int sysinfo_detect(struct udevice *dev) { + int ret; + struct sysinfo_priv *priv = dev_get_uclass_priv(dev); struct sysinfo_ops *ops = sysinfo_get_ops(dev); if (!ops->detect) return -ENOSYS; - return ops->detect(dev); + ret = ops->detect(dev); + if (!ret) + priv->detected = true; + + return ret; } int sysinfo_get_fit_loadable(struct udevice *dev, int index, const char *type, const char **strp) { + struct sysinfo_priv *priv = dev_get_uclass_priv(dev); struct sysinfo_ops *ops = sysinfo_get_ops(dev); + if (!priv->detected) + return -EPERM; + if (!ops->get_fit_loadable) return -ENOSYS; @@ -36,8 +50,12 @@ int sysinfo_get_fit_loadable(struct udevice *dev, int index, const char *type, int sysinfo_get_bool(struct udevice *dev, int id, bool *val) { + struct sysinfo_priv *priv = dev_get_uclass_priv(dev); struct sysinfo_ops *ops = sysinfo_get_ops(dev); + if (!priv->detected) + return -EPERM; + if (!ops->get_bool) return -ENOSYS; @@ -46,8 +64,12 @@ int sysinfo_get_bool(struct udevice *dev, int id, bool *val) int sysinfo_get_int(struct udevice *dev, int id, int *val) { + struct sysinfo_priv *priv = dev_get_uclass_priv(dev); struct sysinfo_ops *ops = sysinfo_get_ops(dev); + if (!priv->detected) + return -EPERM; + if (!ops->get_int) return -ENOSYS; @@ -56,8 +78,12 @@ int sysinfo_get_int(struct udevice *dev, int id, int *val) int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val) { + struct sysinfo_priv *priv = dev_get_uclass_priv(dev); struct sysinfo_ops *ops = sysinfo_get_ops(dev); + if (!priv->detected) + return -EPERM; + if (!ops->get_str) return -ENOSYS; @@ -68,4 +94,5 @@ UCLASS_DRIVER(sysinfo) = { .id = UCLASS_SYSINFO, .name = "sysinfo", .post_bind = dm_scan_fdt_dev, + .per_device_auto = sizeof(bool), }; |