Skip to contentSkip to conversation

MIPS: BCM47XX: Move NVRAM driver to the drivers/misc/

PATCH Superseded Rafał Miłecki 4 participants 7 messages Nov 11, 2014 – Nov 23, 2014

Subsystems (8)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH 1/1 MIPS: BCM47XX: Move NVRAM driver to the drivers/misc/

After Broadcom switched from MIPS to ARM for their home routers we need to have NVRAM driver in some common place (not arch/mips/). We were thinking about putting it in bus directory, however there are two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to the drivers/misc/

---
 arch/mips/Kconfig                                  |   1 +
 arch/mips/bcm47xx/Makefile                         |   2 +-
 arch/mips/bcm47xx/board.c                          |   2 +-
 arch/mips/bcm47xx/nvram.c                          | 228 --------------------
 arch/mips/bcm47xx/setup.c                          |   1 -
 arch/mips/bcm47xx/sprom.c                          |   1 -
 arch/mips/bcm47xx/time.c                           |   1 -
 arch/mips/include/asm/mach-bcm47xx/bcm47xx.h       |   1 +
 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h |  21 --
 drivers/bcma/driver_mips.c                         |   2 +-
 drivers/misc/Kconfig                               |   9 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/bcm47xx_nvram.c                       | 230 +++++++++++++++++++++
 drivers/net/ethernet/broadcom/b44.c                |   2 +-
 drivers/net/ethernet/broadcom/bgmac.c              |   2 +-
 drivers/ssb/driver_chipcommon_pmu.c                |   2 +-
 drivers/ssb/driver_mipscore.c                      |   2 +-
 include/linux/bcm47xx_nvram.h                      |  18 ++
 18 files changed, 267 insertions(+), 259 deletions(-)
 delete mode 100644 arch/mips/bcm47xx/nvram.c
 delete mode 100644 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
 create mode 100644 drivers/misc/bcm47xx_nvram.c
 create mode 100644 include/linux/bcm47xx_nvram.h
arch/mips/Kconfig +1 -0
index 4a7e0c1..3d647e3 100644
@@ -134,6 +134,7 @@ config BCM47XX
 	select USE_GENERIC_EARLY_PRINTK_8250
 	select GPIOLIB
 	select LEDS_GPIO_REGISTER
+	select BCM47XX_NVRAM
 	help
 	 Support for BCM47XX based boards
 
arch/mips/bcm47xx/Makefile +1 -1
index d58c51b..66bea4e 100644
@@ -3,5 +3,5 @@
 # under Linux.
 #
 
-obj-y				+= irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
+obj-y				+= irq.o prom.o serial.o setup.o time.o sprom.o
 obj-y				+= board.o buttons.o leds.o workarounds.o
arch/mips/bcm47xx/board.c +1 -1
index b3ae068..6e85130 100644
@@ -1,8 +1,8 @@
 #include <linux/errno.h>
 #include <linux/export.h>
 #include <linux/string.h>
+#include <bcm47xx.h>
 #include <bcm47xx_board.h>
-#include <bcm47xx_nvram.h>
 
 struct bcm47xx_board_type {
 	const enum bcm47xx_board board;
arch/mips/bcm47xx/nvram.c deleted +0 -228

228 lines not on this page · raw message

arch/mips/bcm47xx/setup.c +0 -1
index e43b504..b26c9c2 100644
@@ -42,7 +42,6 @@
 #include <asm/reboot.h>
 #include <asm/time.h>
 #include <bcm47xx.h>
-#include <bcm47xx_nvram.h>
 #include <bcm47xx_board.h>
 
 union bcm47xx_bus bcm47xx_bus;
arch/mips/bcm47xx/sprom.c +0 -1
index 2eff7fe..a077ed2 100644
@@ -27,7 +27,6 @@
  */
 
 #include <bcm47xx.h>
-#include <bcm47xx_nvram.h>
 #include <linux/if_ether.h>
 #include <linux/etherdevice.h>
 
arch/mips/bcm47xx/time.c +0 -1
index 2c85d92..5b46510 100644
@@ -27,7 +27,6 @@
 #include <linux/ssb/ssb.h>
 #include <asm/time.h>
 #include <bcm47xx.h>
-#include <bcm47xx_nvram.h>
 #include <bcm47xx_board.h>
 
 void __init plat_time_init(void)
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h +1 -0
index 7527c1d..8ed77f6 100644
@@ -22,6 +22,7 @@
 #include <linux/ssb/ssb.h>
 #include <linux/bcma/bcma.h>
 #include <linux/bcma/bcma_soc.h>
+#include <linux/bcm47xx_nvram.h>
 
 enum bcm47xx_bus_type {
 #ifdef CONFIG_BCM47XX_SSB
arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h deleted +0 -21
deleted file mode 100644
index ee59ffe..0000000
@@ -1,21 +0,0 @@
-/*
- *  Copyright (C) 2005, Broadcom Corporation
- *  Copyright (C) 2006, Felix Fietkau <[email protected]>
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
-
-#ifndef __BCM47XX_NVRAM_H
-#define __BCM47XX_NVRAM_H
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-
-int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
-int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
-int bcm47xx_nvram_gpio_pin(const char *name);
-
-#endif /* __BCM47XX_NVRAM_H */
drivers/bcma/driver_mips.c +1 -1
index 8a653dc..15e278f 100644
@@ -21,7 +21,7 @@
 #include <linux/serial_reg.h>
 #include <linux/time.h>
 #ifdef CONFIG_BCM47XX
-#include <bcm47xx_nvram.h>
+#include <linux/bcm47xx_nvram.h>
 #endif
 
 enum bcma_boot_dev {
drivers/misc/Kconfig +9 -0
index bbeb451..e8af594 100644
@@ -84,6 +84,15 @@ config ATMEL_TCB_CLKSRC_BLOCK
 	  TC can be used for other purposes, such as PWM generation and
 	  interval timing.
 
+config BCM47XX_NVRAM
+	bool "Broadcom NVRAM driver"
+	depends on BCM47XX || ARCH_BCM_5301X
+	help
+	  Broadcom home routers contain flash partition called "nvram" with all
+	  important hardware configuration as well as some minor user setup.
+	  It contains a text-like data representing name=value pairs.
+	  This driver provides an easy way to get value of requested parameter.
+
 config DUMMY_IRQ
 	tristate "Dummy IRQ handler"
 	default n
drivers/misc/Makefile +1 -0
index 7d5c4cd..611cb7a 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_AD525X_DPOT_SPI)	+= ad525x_dpot-spi.o
 obj-$(CONFIG_INTEL_MID_PTI)	+= pti.o
 obj-$(CONFIG_ATMEL_SSC)		+= atmel-ssc.o
 obj-$(CONFIG_ATMEL_TCLIB)	+= atmel_tclib.o
+obj-$(CONFIG_BCM47XX_NVRAM)	+= bcm47xx_nvram.o
 obj-$(CONFIG_BMP085)		+= bmp085.o
 obj-$(CONFIG_BMP085_I2C)	+= bmp085-i2c.o
 obj-$(CONFIG_BMP085_SPI)	+= bmp085-spi.o
drivers/misc/bcm47xx_nvram.c new file +230 -0

230 lines not on this page · raw message

drivers/net/ethernet/broadcom/b44.c +1 -1
index 416620f..2095062 100644
@@ -400,7 +400,7 @@ static void b44_set_flow_ctrl(struct b44 *bp, u32 local, u32 remote)
 }
 
 #ifdef CONFIG_BCM47XX
-#include <bcm47xx_nvram.h>
+#include <linux/bcm47xx_nvram.h>
 static void b44_wap54g10_workaround(struct b44 *bp)
 {
 	char buf[20];
drivers/net/ethernet/broadcom/bgmac.c +1 -1
index 05c6af6..bdda57b 100644
@@ -16,7 +16,7 @@
 #include <linux/phy.h>
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
-#include <bcm47xx_nvram.h>
+#include <linux/bcm47xx_nvram.h>
 
 static const struct bcma_device_id bgmac_bcma_tbl[] = {
 	BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_4706_MAC_GBIT, BCMA_ANY_REV, BCMA_ANY_CLASS),
drivers/ssb/driver_chipcommon_pmu.c +1 -1
index 1173a09..0942841 100644
@@ -14,7 +14,7 @@
 #include <linux/delay.h>
 #include <linux/export.h>
 #ifdef CONFIG_BCM47XX
-#include <bcm47xx_nvram.h>
+#include <linux/bcm47xx_nvram.h>
 #endif
 
 #include "ssb_private.h"
drivers/ssb/driver_mipscore.c +1 -1
index 7b986f9..f87efef 100644
@@ -16,7 +16,7 @@
 #include <linux/serial_reg.h>
 #include <linux/time.h>
 #ifdef CONFIG_BCM47XX
-#include <bcm47xx_nvram.h>
+#include <linux/bcm47xx_nvram.h>
 #endif
 
 #include "ssb_private.h"
include/linux/bcm47xx_nvram.h new file +18 -0
new file mode 100644
index 0000000..5ed6917
@@ -0,0 +1,18 @@
+/*
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+
+#ifndef __BCM47XX_NVRAM_H
+#define __BCM47XX_NVRAM_H
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
+int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
+int bcm47xx_nvram_gpio_pin(const char *name);
+
+#endif /* __BCM47XX_NVRAM_H */
Signature · 1 line
1.8.4.5
#1 lore raw

Hi,

Quoted 24 lines · Rafał Miłecki

After Broadcom switched from MIPS to ARM for their home routers we need to have NVRAM driver in some common place (not arch/mips/). We were thinking about putting it in bus directory, however there are two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to the drivers/misc/

---
 arch/mips/Kconfig                                  |   1 +
 arch/mips/bcm47xx/Makefile                         |   2 +-
 arch/mips/bcm47xx/board.c                          |   2 +-
 arch/mips/bcm47xx/nvram.c                          | 228 --------------------
 arch/mips/bcm47xx/setup.c                          |   1 -
 arch/mips/bcm47xx/sprom.c                          |   1 -
 arch/mips/bcm47xx/time.c                           |   1 -
 arch/mips/include/asm/mach-bcm47xx/bcm47xx.h       |   1 +
 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h |  21 --
 drivers/bcma/driver_mips.c                         |   2 +-
 drivers/misc/Kconfig                               |   9 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/bcm47xx_nvram.c                       | 230 +++++++++++++++++++++
 drivers/net/ethernet/broadcom/b44.c                |   2 +-
 drivers/net/ethernet/broadcom/bgmac.c              |   2 +-
Quoted 8 lines
 drivers/ssb/driver_chipcommon_pmu.c                |   2 +-
 drivers/ssb/driver_mipscore.c                      |   2 +-
 include/linux/bcm47xx_nvram.h                      |  18 ++
 18 files changed, 267 insertions(+), 259 deletions(-)
 delete mode 100644 arch/mips/bcm47xx/nvram.c
 delete mode 100644 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
 create mode 100644 drivers/misc/bcm47xx_nvram.c
 create mode 100644 include/linux/bcm47xx_nvram.h

Using git format-patch -M should generate a review-able patch. Especially for nvram.c

Regards
ZubairLK

maintainer
#2 lore raw
In reply to Rafał Miłecki
Quoted 9 lines · On Tuesday 11 November 2014 20:45:46 Rafał Miłecki wrote:

After Broadcom switched from MIPS to ARM for their home routers we need to have NVRAM driver in some common place (not arch/mips/). We were thinking about putting it in bus directory, however there are two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to the drivers/misc/

I think drivers/soc would be more appropriate, as this is a purely in-kernel interface, and it interacts with other drivers, while drivers/misc is generally for oddball devices that don't fit in elsewhere and have their own user interface.

I don't remember if what we had concluded on the previous discussion. I think I suggested converting the nvram variables into DT properties on ARM. The API certainly feels obscure, so it would be nice to keep it out of the modern port if we can come up with a better alternative to pass the same information.

Arnd

maintainer
#3 lore raw
Quoted 16 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 11 November 2014 20:45:46 Rafał Miłecki wrote:

After Broadcom switched from MIPS to ARM for their home routers we need to have NVRAM driver in some common place (not arch/mips/). We were thinking about putting it in bus directory, however there are two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to the drivers/misc/

I think drivers/soc would be more appropriate, as this is a purely in-kernel interface, and it interacts with other drivers, while drivers/misc is generally for oddball devices that don't fit in elsewhere and have their own user interface.

Quoted 5 lines

I don't remember if what we had concluded on the previous discussion. I think I suggested converting the nvram variables into DT properties on ARM. The API certainly feels obscure, so it would be nice to keep it out of the modern port if we can come up with a better alternative to pass the same information.

When there would be devices shipping with device tree in the boot loader with this SoC I would go for using device tree for this purpose, but I do not think there are any and I do not know what Broadcom plans are.

The nvram partition contains all configuration information about the device like the MAC addresses, the calibration data for the Wifi chips (either in the SoC or attached via PCIe/USB), default configuration for the switch and so on. I think expect for the MAC addresses these values do not vary on one series of boards, but I am to completely sure about the calibration data. For the mac address we have to parse this as long as the boot loader does not provide these information in some other way.

My plan would be that we integrate this nvram support into Linux also for the ARM SoCs at first and then make the old drivers also take device tree attributes. For new drivers we can make them use device tree attributes only.

Hauke

maintainer
#4 lore raw
In reply to Rafał Miłecki
Quoted 6 lines · Rafał Miłecki

After Broadcom switched from MIPS to ARM for their home routers we need to have NVRAM driver in some common place (not arch/mips/). We were thinking about putting it in bus directory, however there are two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to the drivers/misc/

I will do a more detailed review when you send a patch with -M

Quoted 25 lines
---
 arch/mips/Kconfig                                  |   1 +
 arch/mips/bcm47xx/Makefile                         |   2 +-
 arch/mips/bcm47xx/board.c                          |   2 +-
 arch/mips/bcm47xx/nvram.c                          | 228 --------------------
 arch/mips/bcm47xx/setup.c                          |   1 -
 arch/mips/bcm47xx/sprom.c                          |   1 -
 arch/mips/bcm47xx/time.c                           |   1 -
 arch/mips/include/asm/mach-bcm47xx/bcm47xx.h       |   1 +
 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h |  21 --
 drivers/bcma/driver_mips.c                         |   2 +-
 drivers/misc/Kconfig                               |   9 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/bcm47xx_nvram.c                       | 230 +++++++++++++++++++++
 drivers/net/ethernet/broadcom/b44.c                |   2 +-
 drivers/net/ethernet/broadcom/bgmac.c              |   2 +-
 drivers/ssb/driver_chipcommon_pmu.c                |   2 +-
 drivers/ssb/driver_mipscore.c                      |   2 +-
 include/linux/bcm47xx_nvram.h                      |  18 ++
 18 files changed, 267 insertions(+), 259 deletions(-)
 delete mode 100644 arch/mips/bcm47xx/nvram.c
 delete mode 100644 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
 create mode 100644 drivers/misc/bcm47xx_nvram.c
 create mode 100644 include/linux/bcm47xx_nvram.h

....

Quoted 12 lines
include/linux/bcm47xx_nvram.h new file +6 -0
new file mode 100644
index 0000000..5ed6917
@@ -0,0 +1,18 @@
+/*
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */

include/linux/bcm47xx_nvram.h line 16

Quoted 10 lines
include/linux/bcm47xx_nvram.h new file +10 -0
+
+#ifndef __BCM47XX_NVRAM_H
+#define __BCM47XX_NVRAM_H
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
+int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
+int bcm47xx_nvram_gpio_pin(const char *name);

Could you change this to something like this:

#ifdef CONFIG_BCM47XX_NVRAM
int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len); int bcm47xx_nvram_gpio_pin(const char *name);
#else
static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim) {return -1;};
static inline int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len) {return -1;};
static inline int bcm47xx_nvram_gpio_pin(const char *name) {return -1;}; #endif

and use something better than -1.

This way we can get rid of these all other the code. #ifdef CONFIG_BCM47XX
..
#endif

If this is planed in the next patch I would be fine with that.

Quoted 3 lines
include/linux/bcm47xx_nvram.h new file +2 -0
+
+#endif /* __BCM47XX_NVRAM_H */
author maintainer
#5 lore raw
Quoted 75 lines · Hauke Mehrtens
Quoted 6 lines · Rafał Miłecki

After Broadcom switched from MIPS to ARM for their home routers we need to have NVRAM driver in some common place (not arch/mips/). We were thinking about putting it in bus directory, however there are two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to the drivers/misc/

I will do a more detailed review when you send a patch with -M

Quoted 25 lines
---
 arch/mips/Kconfig                                  |   1 +
 arch/mips/bcm47xx/Makefile                         |   2 +-
 arch/mips/bcm47xx/board.c                          |   2 +-
 arch/mips/bcm47xx/nvram.c                          | 228 --------------------
 arch/mips/bcm47xx/setup.c                          |   1 -
 arch/mips/bcm47xx/sprom.c                          |   1 -
 arch/mips/bcm47xx/time.c                           |   1 -
 arch/mips/include/asm/mach-bcm47xx/bcm47xx.h       |   1 +
 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h |  21 --
 drivers/bcma/driver_mips.c                         |   2 +-
 drivers/misc/Kconfig                               |   9 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/bcm47xx_nvram.c                       | 230 +++++++++++++++++++++
 drivers/net/ethernet/broadcom/b44.c                |   2 +-
 drivers/net/ethernet/broadcom/bgmac.c              |   2 +-
 drivers/ssb/driver_chipcommon_pmu.c                |   2 +-
 drivers/ssb/driver_mipscore.c                      |   2 +-
 include/linux/bcm47xx_nvram.h                      |  18 ++
 18 files changed, 267 insertions(+), 259 deletions(-)
 delete mode 100644 arch/mips/bcm47xx/nvram.c
 delete mode 100644 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
 create mode 100644 drivers/misc/bcm47xx_nvram.c
 create mode 100644 include/linux/bcm47xx_nvram.h

....

Quoted 12 lines
include/linux/bcm47xx_nvram.h new file +6 -0
new file mode 100644
index 0000000..5ed6917
@@ -0,0 +1,18 @@
+/*
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */

include/linux/bcm47xx_nvram.h line 16

Quoted 10 lines
include/linux/bcm47xx_nvram.h new file +10 -0
+
+#ifndef __BCM47XX_NVRAM_H
+#define __BCM47XX_NVRAM_H
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
+int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
+int bcm47xx_nvram_gpio_pin(const char *name);

Could you change this to something like this:

#ifdef CONFIG_BCM47XX_NVRAM
int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len); int bcm47xx_nvram_gpio_pin(const char *name);
#else
static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim) {return -1;};
static inline int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len) {return -1;};
static inline int bcm47xx_nvram_gpio_pin(const char *name) {return -1;}; #endif

Quoted 6 lines

and use something better than -1.

This way we can get rid of these all other the code. #ifdef CONFIG_BCM47XX
..
#endif

How many drivers using
#ifdef CONFIG_BCM47XX
bcm47xx_nvram_foo(...)
#endif
do we have?

I think right now it is done in
drivers/bcma/driver_mips.c
but should be dropped anyway. We should make BCMA_DRIVER_MIPS depend on BCM47XX.

And second usage is in:
drivers/net/ethernet/broadcom/b44.c

Do you think it's worth doing just for b44.c?

Signature · 1 line
Rafał
maintainer
#6 lore raw
Quoted 89 lines · Rafał Miłecki
Quoted 75 lines · Hauke Mehrtens
Quoted 6 lines · Rafał Miłecki

After Broadcom switched from MIPS to ARM for their home routers we need to have NVRAM driver in some common place (not arch/mips/). We were thinking about putting it in bus directory, however there are two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to the drivers/misc/

I will do a more detailed review when you send a patch with -M

Quoted 25 lines
---
 arch/mips/Kconfig                                  |   1 +
 arch/mips/bcm47xx/Makefile                         |   2 +-
 arch/mips/bcm47xx/board.c                          |   2 +-
 arch/mips/bcm47xx/nvram.c                          | 228 --------------------
 arch/mips/bcm47xx/setup.c                          |   1 -
 arch/mips/bcm47xx/sprom.c                          |   1 -
 arch/mips/bcm47xx/time.c                           |   1 -
 arch/mips/include/asm/mach-bcm47xx/bcm47xx.h       |   1 +
 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h |  21 --
 drivers/bcma/driver_mips.c                         |   2 +-
 drivers/misc/Kconfig                               |   9 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/bcm47xx_nvram.c                       | 230 +++++++++++++++++++++
 drivers/net/ethernet/broadcom/b44.c                |   2 +-
 drivers/net/ethernet/broadcom/bgmac.c              |   2 +-
 drivers/ssb/driver_chipcommon_pmu.c                |   2 +-
 drivers/ssb/driver_mipscore.c                      |   2 +-
 include/linux/bcm47xx_nvram.h                      |  18 ++
 18 files changed, 267 insertions(+), 259 deletions(-)
 delete mode 100644 arch/mips/bcm47xx/nvram.c
 delete mode 100644 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
 create mode 100644 drivers/misc/bcm47xx_nvram.c
 create mode 100644 include/linux/bcm47xx_nvram.h

....

Quoted 12 lines
include/linux/bcm47xx_nvram.h new file +6 -0
new file mode 100644
index 0000000..5ed6917
@@ -0,0 +1,18 @@
+/*
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */

include/linux/bcm47xx_nvram.h line 16

Quoted 10 lines
include/linux/bcm47xx_nvram.h new file +10 -0
+
+#ifndef __BCM47XX_NVRAM_H
+#define __BCM47XX_NVRAM_H
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
+int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
+int bcm47xx_nvram_gpio_pin(const char *name);

Could you change this to something like this:

#ifdef CONFIG_BCM47XX_NVRAM
int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len); int bcm47xx_nvram_gpio_pin(const char *name);
#else
static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim) {return -1;};
static inline int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len) {return -1;};
static inline int bcm47xx_nvram_gpio_pin(const char *name) {return -1;}; #endif

Quoted 6 lines

and use something better than -1.

This way we can get rid of these all other the code. #ifdef CONFIG_BCM47XX
..
#endif

How many drivers using
#ifdef CONFIG_BCM47XX
bcm47xx_nvram_foo(...)
#endif
do we have?

Quoted 9 lines

I think right now it is done in
drivers/bcma/driver_mips.c
but should be dropped anyway. We should make BCMA_DRIVER_MIPS depend on BCM47XX.

And second usage is in:
drivers/net/ethernet/broadcom/b44.c

Do you think it's worth doing just for b44.c?

There is also a call in
drivers/ssb/driver_chipcommon_pmu.c

In addition
drivers/net/ethernet/broadcom/bgmac.c:
calls bcm47xx_nvram_foo(...) without any ifdef and depends on this.

I think it would be best to separate these two things and and try to remove the ifdefs in a separate patch.

Hauke