diff mbox series

[net] nvmem: disallow modular CONFIG_NVMEM

Message ID 20180404103900.4090118-1-arnd@arndb.de
State Accepted
Commit 2a37ce25d9f2071ab6cce7f70fd5bd4bf4a50ee7
Headers show
Series [net] nvmem: disallow modular CONFIG_NVMEM | expand

Commit Message

Arnd Bergmann April 4, 2018, 10:38 a.m. UTC
The new of_get_nvmem_mac_address() helper function causes a link error
with CONFIG_NVMEM=m:

drivers/of/of_net.o: In function `of_get_nvmem_mac_address':
of_net.c:(.text+0x168): undefined reference to `of_nvmem_cell_get'
of_net.c:(.text+0x19c): undefined reference to `nvmem_cell_read'
of_net.c:(.text+0x1a8): undefined reference to `nvmem_cell_put'

I could not come up with a good solution for this, as the code is always
built-in. Using an #if IS_REACHABLE() check around it would solve the
link time issue but then stop it from working in that configuration.
Making of_nvmem_cell_get() an inline function could also solve that, but
seems a bit ugly since it's somewhat larger than most inline functions,
and it would just bring that problem into the callers.  Splitting the
function into a separate file might be an alternative.

This uses the big hammer by making CONFIG_NVMEM itself a 'bool' symbol,
which avoids the problem entirely but makes the vmlinux larger for anyone
that might use NVMEM support but doesn't need it built-in otherwise.

Fixes: 9217e566bdee ("of_net: Implement of_get_nvmem_mac_address helper")
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
The problem arrived through the networking tree, but it's now in
mainline, so the fix could go through either tree
---
 drivers/nvmem/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.9.0

Comments

Mike Looijmans April 4, 2018, 1:32 p.m. UTC | #1
For making things build again:

Acked-by: Mike Looijmans


I'd be interested in use-cases for having nvmem as a module, I cannot think of 
any.


I am working on splitting of_get_nvmem_mac_address(), by moving most of its
burden to the nvmem interface. Intend to create this "just give me my bytes" 
function in nvmem:

int of_nvmem_cell_read(struct device_node *np, const char *name,
                        void *buf, size_t bytes);

With that in place, of_get_nvmem_mac_address becomes a one-liner:

return of_nvmem_cell_read(np, "mac-address", addr, ETH_ALEN);

That would allow of_get_nvmem_mac_address to be inlined, and this would move 
the link issues into modules that actually use that function.

Which may still be very confusing, since it means that CONFIG_MACB=y with 
CONFIG_NVMEM=m will fail, but setting both to "y" or both to "m" will work. So 
that would introduce more build failures again, right?

--
Mike.


On 04-04-18 12:38, Arnd Bergmann wrote:
> The new of_get_nvmem_mac_address() helper function causes a link error

> with CONFIG_NVMEM=m:

> 

> drivers/of/of_net.o: In function `of_get_nvmem_mac_address':

> of_net.c:(.text+0x168): undefined reference to `of_nvmem_cell_get'

> of_net.c:(.text+0x19c): undefined reference to `nvmem_cell_read'

> of_net.c:(.text+0x1a8): undefined reference to `nvmem_cell_put'

> 

> I could not come up with a good solution for this, as the code is always

> built-in. Using an #if IS_REACHABLE() check around it would solve the

> link time issue but then stop it from working in that configuration.

> Making of_nvmem_cell_get() an inline function could also solve that, but

> seems a bit ugly since it's somewhat larger than most inline functions,

> and it would just bring that problem into the callers.  Splitting the

> function into a separate file might be an alternative.

> 

> This uses the big hammer by making CONFIG_NVMEM itself a 'bool' symbol,

> which avoids the problem entirely but makes the vmlinux larger for anyone

> that might use NVMEM support but doesn't need it built-in otherwise.

> 

> Fixes: 9217e566bdee ("of_net: Implement of_get_nvmem_mac_address helper")

> Cc: Mike Looijmans <mike.looijmans@topic.nl>

> Cc: Florian Fainelli <f.fainelli@gmail.com>

> Cc: Andrew Lunn <andrew@lunn.ch>

> Cc: David S. Miller <davem@davemloft.net>

> Cc: netdev@vger.kernel.org

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

> The problem arrived through the networking tree, but it's now in

> mainline, so the fix could go through either tree

> ---

>   drivers/nvmem/Kconfig | 2 +-

>   1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig

> index 5f9bc787d634..1090924efdb1 100644

> --- a/drivers/nvmem/Kconfig

> +++ b/drivers/nvmem/Kconfig

> @@ -1,5 +1,5 @@

>   menuconfig NVMEM

> -	tristate "NVMEM Support"

> +	bool "NVMEM Support"

>   	help

>   	  Support for NVMEM(Non Volatile Memory) devices like EEPROM, EFUSES...

>   

> 




Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijmans@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail
Arnd Bergmann April 4, 2018, 1:38 p.m. UTC | #2
On Wed, Apr 4, 2018 at 3:32 PM, Mike Looijmans <mike.looijmans@topic.nl> wrote:

>

> Which may still be very confusing, since it means that CONFIG_MACB=y with

> CONFIG_NVMEM=m will fail, but setting both to "y" or both to "m" will work.

> So that would introduce more build failures again, right?


Right, it would require having a

      depends on NVMEM || !NVMEM

line in Kconfig for each such driver, or a

      depends on NVMEM != m

for drivers that cannot be modules themselves.

      Arnd
David Miller April 4, 2018, 3:48 p.m. UTC | #3
From: Arnd Bergmann <arnd@arndb.de>

Date: Wed,  4 Apr 2018 12:38:40 +0200

> The new of_get_nvmem_mac_address() helper function causes a link error

> with CONFIG_NVMEM=m:

> 

> drivers/of/of_net.o: In function `of_get_nvmem_mac_address':

> of_net.c:(.text+0x168): undefined reference to `of_nvmem_cell_get'

> of_net.c:(.text+0x19c): undefined reference to `nvmem_cell_read'

> of_net.c:(.text+0x1a8): undefined reference to `nvmem_cell_put'

> 

> I could not come up with a good solution for this, as the code is always

> built-in. Using an #if IS_REACHABLE() check around it would solve the

> link time issue but then stop it from working in that configuration.

> Making of_nvmem_cell_get() an inline function could also solve that, but

> seems a bit ugly since it's somewhat larger than most inline functions,

> and it would just bring that problem into the callers.  Splitting the

> function into a separate file might be an alternative.

> 

> This uses the big hammer by making CONFIG_NVMEM itself a 'bool' symbol,

> which avoids the problem entirely but makes the vmlinux larger for anyone

> that might use NVMEM support but doesn't need it built-in otherwise.

> 

> Fixes: 9217e566bdee ("of_net: Implement of_get_nvmem_mac_address helper")

> Cc: Mike Looijmans <mike.looijmans@topic.nl>

> Cc: Florian Fainelli <f.fainelli@gmail.com>

> Cc: Andrew Lunn <andrew@lunn.ch>

> Cc: David S. Miller <davem@davemloft.net>

> Cc: netdev@vger.kernel.org

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

> The problem arrived through the networking tree, but it's now in

> mainline, so the fix could go through either tree


Ok, applied, thanks Arnd.
diff mbox series

Patch

diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 5f9bc787d634..1090924efdb1 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -1,5 +1,5 @@ 
 menuconfig NVMEM
-	tristate "NVMEM Support"
+	bool "NVMEM Support"
 	help
 	  Support for NVMEM(Non Volatile Memory) devices like EEPROM, EFUSES...