diff mbox series

[14/18] dm: core: Add function to access uclass priv

Message ID 20201216152506.119900-10-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show
Series dm: Preparation for enhanced of-platdata | expand

Commit Message

Simon Glass Dec. 16, 2020, 3:25 p.m. UTC
Add functions so this information is not accessed directly. This will be
needed for of-platdata which stores it in a different place.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/uclass.c        | 10 ++++++++++
 include/dm/uclass-internal.h | 14 ++++++++++++++
 include/dm/uclass.h          |  8 ++++++++
 3 files changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 6409457fa96..5e24927b341 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -160,6 +160,16 @@  const char *uclass_get_name(enum uclass_id id)
 	return uc->uc_drv->name;
 }
 
+void *uclass_get_priv(const struct uclass *uc)
+{
+	return uc->priv;
+}
+
+void uclass_set_priv(struct uclass *uc, void *priv)
+{
+	uc->priv = priv;
+}
+
 enum uclass_id uclass_get_by_name(const char *name)
 {
 	int i;
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index 3e052f95d32..c5a464be7c4 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -11,6 +11,20 @@ 
 
 #include <dm/ofnode.h>
 
+/**
+ * uclass_set_priv() - Set the private data for a uclass
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * private data when an 'auto' size if provided by the uclass driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @uc		Uclass to update
+ * @priv	New private-data pointer
+ */
+void uclass_set_priv(struct uclass *uc, void *priv);
+
 /**
  * uclass_find_next_free_seq() - Get the next free sequence number
  *
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 897ab7c55b5..1a02acbee5a 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -114,6 +114,14 @@  struct uclass_driver {
 #define UCLASS_DRIVER(__name)						\
 	ll_entry_declare(struct uclass_driver, __name, uclass_driver)
 
+/**
+ * uclass_get_priv() - Get the private data for a uclass
+ *
+ * @uc		Uclass to check
+ * @return private data, or NULL if none
+ */
+void *uclass_get_priv(const struct uclass *uc);
+
 /**
  * uclass_get() - Get a uclass based on an ID, creating it if needed
  *