Skip to contentSkip to conversation

core: devres: don't use devres code when CONFIG_DEVRES is not defined

PATCH In review Angus Ainslie 2 participants 4 messages Feb 2, 2022 – Feb 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 core: devres: don't use devres code when CONFIG_DEVRES is not defined

Put guards around the devres code so that it isn't compiled during the SPL.

---
 drivers/core/devres.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/core/devres.c +3 -1
index 313ddc7089..92a237c64c 100644
@@ -91,6 +91,7 @@ void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
 	return dr->data;
 }
 
+#if CONFIG_DEVRES
 void devres_free(void *res)
 {
 	if (res) {
@@ -257,7 +258,7 @@ void devres_get_stats(const struct udevice *dev, struct devres_stats *stats)
 	}
 }
 
-#endif
+#endif /* CONFIG_DEBUG_DEVRES */
 
 /*
  * Managed kmalloc/kfree
@@ -292,3 +293,4 @@ void devm_kfree(struct udevice *dev, void *p)
 	rc = devres_destroy(dev, devm_kmalloc_release, devm_kmalloc_match, p);
 	assert_noisy(!rc);
 }
+#endif /* CONFIG_DEVRES */
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · Angus Ainslie

Put guards around the devres code so that it isn't compiled during the SPL.

---
 drivers/core/devres.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I think the correct fix here is to change the Makefile rule for this file to use

CONFIG_$(SPL_)DEVRES

instead of

CONFIG_DEVRES

Can you try it?

Regards,
Simon
[..]

#2 lore raw

Hi Simon,

Quoted 11 lines · Simon Glass
Quoted 7 lines · Angus Ainslie

Put guards around the devres code so that it isn't compiled during the SPL.

---
 drivers/core/devres.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I think the correct fix here is to change the Makefile rule for this file to use

Quoted 8 lines

CONFIG_$(SPL_)DEVRES

instead of

CONFIG_DEVRES

Can you try it?

I think it will work that way and I did think about doing the patch that way. My concern was that it might break some boards because they are expecting DEVRES in the SPL.

I can rework the patch that way but not sure how I'd test which boards needed the CONFIG_SPL_DEVRES defined.

Thanks
Angus

Quoted 3 lines

Regards,
Simon
[..]

#3 lore raw

Hi Angus,

Quoted 26 lines · Angus Ainslie

Hi Simon,

Quoted 13 lines · Simon Glass
Quoted 8 lines · Angus Ainslie

Put guards around the devres code so that it isn't compiled during the SPL.

---
 drivers/core/devres.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I think the correct fix here is to change the Makefile rule for this file to use

Quoted 8 lines

CONFIG_$(SPL_)DEVRES

instead of

CONFIG_DEVRES

Can you try it?

Quoted 6 lines

I think it will work that way and I did think about doing the patch that way. My concern was that it might break some boards because they are expecting DEVRES in the SPL.

I can rework the patch that way but not sure how I'd test which boards needed the CONFIG_SPL_DEVRES defined.

I very much doubt any are, but the maintainers can test them as needed. After all, freeing memory is not normally supported in SPL, except with full malloc().

Regards,
Simon