* [PATCH master] lib: genalloc: drop reliance on mmio-sram driver
@ 2023-04-17 12:51 Ahmad Fatoum
2023-05-02 12:06 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2023-04-17 12:51 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The barebox mmio-sram driver just makes SRAMs available as /dev/sramX
devices. The genalloc stub depended on it without selecting CONFIG_SRAM.
Instead of making this dependency explicit, just call of_address_to_resource
and have no dependency on CONFIG_SRAM at all.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
lib/genalloc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 906e2dd5f14b..2e9815c36b78 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -12,6 +12,7 @@
#include <linux/genalloc.h>
#include <linux/export.h>
#include <of.h>
+#include <of_address.h>
#include <driver.h>
#include <linux/string.h>
@@ -98,8 +99,9 @@ EXPORT_SYMBOL(gen_pool_dma_zalloc);
struct gen_pool *of_gen_pool_get(struct device_node *np,
const char *propname, int index)
{
- struct device *dev;
struct device_node *np_pool;
+ struct gen_pool gen_pool;
+ int ret;
np_pool = of_parse_phandle(np, propname, index);
if (!np_pool)
@@ -108,11 +110,11 @@ struct gen_pool *of_gen_pool_get(struct device_node *np,
if (!of_device_is_compatible(np_pool, "mmio-sram"))
return NULL;
- dev = of_find_device_by_node(np_pool);
- if (!dev)
+ ret = of_address_to_resource(np_pool, 0, &gen_pool.res);
+ if (ret)
return NULL;
- return container_of(&dev->resource[0], struct gen_pool, res);
+ return memdup(&gen_pool, sizeof(gen_pool));
}
EXPORT_SYMBOL_GPL(of_gen_pool_get);
#endif /* CONFIG_OF */
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH master] lib: genalloc: drop reliance on mmio-sram driver
2023-04-17 12:51 [PATCH master] lib: genalloc: drop reliance on mmio-sram driver Ahmad Fatoum
@ 2023-05-02 12:06 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-05-02 12:06 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Mon, Apr 17, 2023 at 02:51:58PM +0200, Ahmad Fatoum wrote:
> The barebox mmio-sram driver just makes SRAMs available as /dev/sramX
> devices. The genalloc stub depended on it without selecting CONFIG_SRAM.
>
> Instead of making this dependency explicit, just call of_address_to_resource
> and have no dependency on CONFIG_SRAM at all.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> lib/genalloc.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/lib/genalloc.c b/lib/genalloc.c
> index 906e2dd5f14b..2e9815c36b78 100644
> --- a/lib/genalloc.c
> +++ b/lib/genalloc.c
> @@ -12,6 +12,7 @@
> #include <linux/genalloc.h>
> #include <linux/export.h>
> #include <of.h>
> +#include <of_address.h>
> #include <driver.h>
> #include <linux/string.h>
>
> @@ -98,8 +99,9 @@ EXPORT_SYMBOL(gen_pool_dma_zalloc);
> struct gen_pool *of_gen_pool_get(struct device_node *np,
> const char *propname, int index)
> {
> - struct device *dev;
> struct device_node *np_pool;
> + struct gen_pool gen_pool;
> + int ret;
>
> np_pool = of_parse_phandle(np, propname, index);
> if (!np_pool)
> @@ -108,11 +110,11 @@ struct gen_pool *of_gen_pool_get(struct device_node *np,
> if (!of_device_is_compatible(np_pool, "mmio-sram"))
> return NULL;
>
> - dev = of_find_device_by_node(np_pool);
> - if (!dev)
> + ret = of_address_to_resource(np_pool, 0, &gen_pool.res);
> + if (ret)
> return NULL;
>
> - return container_of(&dev->resource[0], struct gen_pool, res);
> + return memdup(&gen_pool, sizeof(gen_pool));
> }
> EXPORT_SYMBOL_GPL(of_gen_pool_get);
> #endif /* CONFIG_OF */
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-02 12:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17 12:51 [PATCH master] lib: genalloc: drop reliance on mmio-sram driver Ahmad Fatoum
2023-05-02 12:06 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox