[OpenWrt-Devel] [PATCH] bcm53xx: Add functions to get/release copies of nvram contents.

Hante Meuleman meuleman at broadcom.com
Wed May 13 03:48:56 EDT 2015


Initially I made the free an inline from header file, but it doesn't compile 
out of the box as it needs the definition for kfree and not all c files which 
include this header file had this, as I don't like the inclusion of header 
files from header files I choose to make an implementation in the c file. 

-----Original Message-----
From: Felix Fietkau [mailto:nbd at openwrt.org] 
Sent: dinsdag 12 mei 2015 22:03
To: Hante Meuleman; OpenWrt Development List
Subject: Re: [OpenWrt-Devel] [PATCH] bcm53xx: Add functions to get/release copies of nvram contents.

On 2015-05-12 15:10, Hante Meuleman wrote:
> Added two functions to the bcm47xx_nvram module to get and release copies 
> of the complete nvram contents. This can be used by for example brcmfmac 
> to get complete nvram contents which will after some parsing be sent to 
> device.
> 
> Signed-off-by: Hante Meuleman <meuleman at broadcom.com>
> ---
> diff --git a/target/linux/bcm53xx/files/drivers/firmware/broadcom/bcm47xx_nvram.c b/target/linux/bcm53xx/files/drivers/firmware/broadcom/bcm47xx_nvram.c
> index d0055a4..96d2308 100644
> --- a/target/linux/bcm53xx/files/drivers/firmware/broadcom/bcm47xx_nvram.c
> +++ b/target/linux/bcm53xx/files/drivers/firmware/broadcom/bcm47xx_nvram.c
> @@ -222,4 +222,32 @@ int bcm47xx_nvram_gpio_pin(const char *name)
>  }
>  EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
>  
> +char *bcm47xx_nvram_get_contents(size_t *nvram_size)
> +{
> +       int err;
> +       char *nvram;
> +
> +       if (!nvram_buf[0]) {
> +               err = nvram_init();
> +               if (err)
> +                       return NULL;
> +       }
> +
> +       *nvram_size = nvram_len - sizeof(struct nvram_header);
> +       nvram = vmalloc(*nvram_size);
> +       if (nvram == NULL)
> +               return NULL;
> +       memcpy(nvram, &nvram_buf[sizeof(struct nvram_header)], *nvram_size);
> +
> +       return nvram;
> +}
> +EXPORT_SYMBOL(bcm47xx_nvram_get_contents);
> +
> +void bcm47xx_nvram_release_contents(char *nvram)
> +{
> +       vfree(nvram);
> +}
> +EXPORT_SYMBOL(bcm47xx_nvram_release_contents);
How about making this one inline instead of adding yet another export?

- Felix
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list