[PATCH 2/3] memory: emif: Simplify code handling CONFIG_OF

Uwe Kleine-König posted 3 patches 2 years ago
[PATCH 2/3] memory: emif: Simplify code handling CONFIG_OF
Posted by Uwe Kleine-König 2 years ago
The first thing that of_get_memory_device_details() does is calling
of_parse_phandle(). With CONFIG_OF=n this returns NULL in a static
inline function. So the compiler can determine that
of_get_memory_device_details() also returns NULL. bloat-o-meter confirms
that this patch has no effects on the size of the generated code for
CONFIG_OF=n builds.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/memory/emif.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
index dd1d87f8fdc8..5a3194b9b3bc 100644
--- a/drivers/memory/emif.c
+++ b/drivers/memory/emif.c
@@ -826,7 +826,6 @@ static int is_custom_config_valid(struct emif_custom_configs *cust_cfgs,
 	return valid;
 }
 
-#if defined(CONFIG_OF)
 static void __init_or_module of_get_custom_configs(struct device_node *np_emif,
 		struct emif_data *emif)
 {
@@ -983,15 +982,6 @@ static struct emif_data * __init_or_module of_get_memory_device_details(
 	return emif;
 }
 
-#else
-
-static struct emif_data * __init_or_module of_get_memory_device_details(
-		struct device_node *np_emif, struct device *dev)
-{
-	return NULL;
-}
-#endif
-
 static struct emif_data *__init_or_module get_device_details(
 		struct platform_device *pdev)
 {
-- 
2.42.0

Re: [PATCH 2/3] memory: emif: Simplify code handling CONFIG_OF
Posted by Krzysztof Kozlowski 1 year, 11 months ago
On 17/12/2023 20:31, Uwe Kleine-König wrote:
> The first thing that of_get_memory_device_details() does is calling
> of_parse_phandle(). With CONFIG_OF=n this returns NULL in a static
> inline function. So the compiler can determine that
> of_get_memory_device_details() also returns NULL. bloat-o-meter confirms
> that this patch has no effects on the size of the generated code for
> CONFIG_OF=n builds.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/memory/emif.c | 10 ----------
>  1 file changed, 10 deletions(-)

Applied.

Best regards,
Krzysztof