[PATCH 1/2] reset: introduce reset_get_bulk_optional()
Nikita Yushchenko
nikita.yoush at cogentembedded.com
Tue Feb 15 20:54:16 CET 2022
This is a version of reset_get_bulk() that does not treat no resets
definition as an error.
Signed-off-by: Nikita Yushchenko <nikita.yoush at cogentembedded.com>
---
drivers/reset/reset-uclass.c | 10 ++++++++++
include/reset.h | 21 +++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index ca9f00a8f2..5a66fe5aef 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -144,6 +144,16 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk)
return __reset_get_bulk(dev, dev_ofnode(dev), bulk);
}
+int reset_get_bulk_optional(struct udevice *dev, struct reset_ctl_bulk *bulk)
+{
+ int ret = reset_get_bulk(dev, bulk);
+
+ if (ret == -ENODEV)
+ ret = 0;
+
+ return ret;
+}
+
int reset_get_by_name(struct udevice *dev, const char *name,
struct reset_ctl *reset_ctl)
{
diff --git a/include/reset.h b/include/reset.h
index 965f02e0ce..b61a2a765f 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -226,6 +226,21 @@ int reset_get_by_index_nodev(ofnode node, int index,
*/
int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk);
+/**
+ * reset_get_bulk_optional - Get/request all reset signals of a device, do not
+ * fail if resets are not defined.
+ *
+ * This is similar to reset_get_bulk(), but does not return error code when
+ * no resets are defined. Instead, bulk->count is set to zero; this turns
+ * reset_assert_bulk() / reset_deassert_bulk() / reset_release_bulk() into
+ * no-ops.
+ *
+ * @dev: The client device.
+ * @bulk A pointer to a reset control bulk struct to initialize.
+ * Return: 0 if OK, or a negative error code.
+ */
+int reset_get_bulk_optional(struct udevice *dev, struct reset_ctl_bulk *bulk);
+
/**
* reset_get_by_name - Get/request a reset signal by name.
*
@@ -411,6 +426,12 @@ static inline int reset_get_bulk(struct udevice *dev,
return -ENOTSUPP;
}
+static inline int reset_get_bulk_optional(struct udevice *dev,
+ struct reset_ctl_bulk *bulk)
+{
+ return -ENOTSUPP;
+}
+
static inline int reset_get_by_name(struct udevice *dev, const char *name,
struct reset_ctl *reset_ctl)
{
--
2.30.2
More information about the U-Boot
mailing list