Skip to content

Commit

Permalink
of: Provide static inline function for of_translate_address if needed
Browse files Browse the repository at this point in the history
If OF_ADDRESS is not configured, builds can fail with errors such as

drivers/net/ethernet/hisilicon/hns_mdio.c:
	In function 'hns_mdio_bus_name':
drivers/net/ethernet/hisilicon/hns_mdio.c:411:3:
	error: implicit declaration of function 'of_translate_address'

as currently seen when building sparc:allmodconfig.

Introduce a static inline function if OF_ADDRESS is not configured to fix
the build failure. Return OF_BAD_ADDR in this case. For this to work, the
definition of OF_BAD_ADDR has to be moved outside CONFIG_OF conditional
code.

Fixes: 876133d ("net: hisilicon: add OF dependency")
Cc: Arnd Bergmann <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
Reviewed-by: Arnd Bergmann <[email protected]>
Reviewed-by: Frank Rowand <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
  • Loading branch information
groeck authored and robherring committed Nov 10, 2015
1 parent 1cc8e34 commit b1d06b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ extern raw_spinlock_t devtree_lock;
#define OF_POPULATED 3 /* device already created for the node */
#define OF_POPULATED_BUS 4 /* of_platform_populate recursed to children of this node */

#define OF_BAD_ADDR ((u64)-1)

#ifdef CONFIG_OF
void of_core_init(void);

Expand Down Expand Up @@ -229,8 +231,6 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)

#define OF_BAD_ADDR ((u64)-1)

static inline const char *of_node_full_name(const struct device_node *np)
{
return np ? np->full_name : "<no-node>";
Expand Down
7 changes: 7 additions & 0 deletions include/linux/of_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ extern int of_dma_get_range(struct device_node *np, u64 *dma_addr,
u64 *paddr, u64 *size);
extern bool of_dma_is_coherent(struct device_node *np);
#else /* CONFIG_OF_ADDRESS */

static inline u64 of_translate_address(struct device_node *np,
const __be32 *addr)
{
return OF_BAD_ADDR;
}

static inline struct device_node *of_find_matching_node_by_address(
struct device_node *from,
const struct of_device_id *matches,
Expand Down

0 comments on commit b1d06b6

Please sign in to comment.