diff options
author | Simon Glass <sjg@chromium.org> | 2020-12-23 05:30:29 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-01-05 22:24:40 +0300 |
commit | 89ba6d553572fe9177ae472170b8373e49f97953 (patch) | |
tree | e71f9263d0c27163d49e78157963de130393e148 /drivers/core/uclass.c | |
parent | 0fd3d91152df5bb6c5f7b9ee68f01a9a1c9a875d (diff) | |
download | u-boot-89ba6d553572fe9177ae472170b8373e49f97953.tar.xz |
dm: core: Use access methods for dev/uclass private data
Use these functions in the core code as much as possible. With this, there
are only two places where each priv/plat pointer is accessed, one for read
and one for write.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/uclass.c')
-rw-r--r-- | drivers/core/uclass.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 5e24927b34..e845f60472 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -72,11 +72,14 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp) if (!uc) return -ENOMEM; if (uc_drv->priv_auto) { - uc->priv = calloc(1, uc_drv->priv_auto); - if (!uc->priv) { + void *ptr; + + ptr = calloc(1, uc_drv->priv_auto); + if (!ptr) { ret = -ENOMEM; goto fail_mem; } + uclass_set_priv(uc, ptr); } uc->uc_drv = uc_drv; INIT_LIST_HEAD(&uc->sibling_node); @@ -94,8 +97,8 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp) return 0; fail: if (uc_drv->priv_auto) { - free(uc->priv); - uc->priv = NULL; + free(uclass_get_priv(uc)); + uclass_set_priv(uc, NULL); } list_del(&uc->sibling_node); fail_mem: @@ -132,7 +135,7 @@ int uclass_destroy(struct uclass *uc) uc_drv->destroy(uc); list_del(&uc->sibling_node); if (uc_drv->priv_auto) - free(uc->priv); + free(uclass_get_priv(uc)); free(uc); return 0; |