Skip to content

Commit 1734514

Browse files
Zijun Hurobherring
authored andcommitted
of: Remove a duplicated code block
address.c has a same code block with fdt_address.c. Remove a copy by moving the duplicated code block into of_private.h. Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Link: https://lore.kernel.org/r/20250109-of_core_fix-v4-8-db8a72415b8c@quicinc.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
1 parent f73780e commit 1734514

3 files changed

Lines changed: 25 additions & 35 deletions

File tree

drivers/of/address.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,10 @@
1616
#include <linux/string.h>
1717
#include <linux/dma-direct.h> /* for bus_dma_region */
1818

19-
#include "of_private.h"
20-
21-
/* Max address size we deal with */
22-
#define OF_MAX_ADDR_CELLS 4
23-
#define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS)
24-
#define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && (ns) > 0)
19+
/* Uncomment me to enable of_dump_addr() debugging output */
20+
// #define DEBUG
2521

26-
/* Debug utility */
27-
#ifdef DEBUG
28-
static void of_dump_addr(const char *s, const __be32 *addr, int na)
29-
{
30-
pr_debug("%s", s);
31-
while (na--)
32-
pr_cont(" %08x", be32_to_cpu(*(addr++)));
33-
pr_cont("\n");
34-
}
35-
#else
36-
static void of_dump_addr(const char *s, const __be32 *addr, int na) { }
37-
#endif
22+
#include "of_private.h"
3823

3924
/* Callbacks for bus specific translators */
4025
struct of_bus {

drivers/of/fdt_address.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,10 @@
1717
#include <linux/of_fdt.h>
1818
#include <linux/sizes.h>
1919

20-
/* Max address size we deal with */
21-
#define OF_MAX_ADDR_CELLS 4
22-
#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
23-
(ns) > 0)
24-
25-
/* Debug utility */
26-
#ifdef DEBUG
27-
static void __init of_dump_addr(const char *s, const __be32 *addr, int na)
28-
{
29-
pr_debug("%s", s);
30-
while(na--)
31-
pr_cont(" %08x", be32_to_cpu(*(addr++)));
32-
pr_cont("\n");
33-
}
34-
#else
35-
static void __init of_dump_addr(const char *s, const __be32 *addr, int na) { }
36-
#endif
20+
/* Uncomment me to enable of_dump_addr() debugging output */
21+
// #define DEBUG
22+
23+
#include "of_private.h"
3724

3825
/* Callbacks for bus specific translators */
3926
struct of_bus {

drivers/of/of_private.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,22 @@ void __init fdt_scan_reserved_mem_reg_nodes(void);
188188

189189
bool of_fdt_device_is_available(const void *blob, unsigned long node);
190190

191+
/* Max address size we deal with */
192+
#define OF_MAX_ADDR_CELLS 4
193+
#define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS)
194+
#define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && (ns) > 0)
195+
196+
/* Debug utility */
197+
#ifdef DEBUG
198+
static void __maybe_unused of_dump_addr(const char *s, const __be32 *addr, int na)
199+
{
200+
pr_debug("%s", s);
201+
while (na--)
202+
pr_cont(" %08x", be32_to_cpu(*(addr++)));
203+
pr_cont("\n");
204+
}
205+
#else
206+
static void __maybe_unused of_dump_addr(const char *s, const __be32 *addr, int na) { }
207+
#endif
208+
191209
#endif /* _LINUX_OF_PRIVATE_H */

0 commit comments

Comments
 (0)