Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'arm-soc/for-6.2/drivers' of https://github.com/Broadcom/stblinux into soc/drivers

This pull request contains Broadcom SoCs driver changes for 6.2, please
pull the following:

- Yuan uses dev_err_probe() in the Raspberry Pi firmware provider to
simplify the error handling code

- Rafal adds support for initialiazing the BCM47xx NVMEM/NVRAM firmware
provider out of memory-mapped flash devices.

* tag 'arm-soc/for-6.2/drivers' of https://github.com/Broadcom/stblinux:
firmware/nvram: bcm47xx: support init from IO memory
firmware: raspberrypi: Use dev_err_probe() to simplify code

Link: https://lore.kernel.org/r/20221129191755.542584-3-f.fainelli@gmail.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+30 -6
+18
drivers/firmware/broadcom/bcm47xx_nvram.c
··· 110 110 return 0; 111 111 } 112 112 113 + int bcm47xx_nvram_init_from_iomem(void __iomem *nvram_start, size_t res_size) 114 + { 115 + if (nvram_len) { 116 + pr_warn("nvram already initialized\n"); 117 + return -EEXIST; 118 + } 119 + 120 + if (!bcm47xx_nvram_is_valid(nvram_start)) { 121 + pr_err("No valid NVRAM found\n"); 122 + return -ENOENT; 123 + } 124 + 125 + bcm47xx_nvram_copy(nvram_start, res_size); 126 + 127 + return 0; 128 + } 129 + EXPORT_SYMBOL_GPL(bcm47xx_nvram_init_from_iomem); 130 + 113 131 /* 114 132 * On bcm47xx we need access to the NVRAM very early, so we can't use mtd 115 133 * subsystem to access flash. We can't even use platform device / driver to
+3 -6
drivers/firmware/raspberrypi.c
··· 268 268 fw->cl.tx_block = true; 269 269 270 270 fw->chan = mbox_request_channel(&fw->cl, 0); 271 - if (IS_ERR(fw->chan)) { 272 - int ret = PTR_ERR(fw->chan); 273 - if (ret != -EPROBE_DEFER) 274 - dev_err(dev, "Failed to get mbox channel: %d\n", ret); 275 - return ret; 276 - } 271 + if (IS_ERR(fw->chan)) 272 + return dev_err_probe(dev, PTR_ERR(fw->chan), 273 + "Failed to get mbox channel\n"); 277 274 278 275 init_completion(&fw->c); 279 276 kref_init(&fw->consumers);
+3
drivers/nvmem/brcm_nvram.c
··· 3 3 * Copyright (C) 2021 Rafał Miłecki <rafal@milecki.pl> 4 4 */ 5 5 6 + #include <linux/bcm47xx_nvram.h> 6 7 #include <linux/io.h> 7 8 #include <linux/mod_devicetable.h> 8 9 #include <linux/module.h> ··· 136 135 err = brcm_nvram_parse(priv); 137 136 if (err) 138 137 return err; 138 + 139 + bcm47xx_nvram_init_from_iomem(priv->base, resource_size(res)); 139 140 140 141 config.dev = dev; 141 142 config.cells = priv->cells;
+6
include/linux/bcm47xx_nvram.h
··· 11 11 #include <linux/vmalloc.h> 12 12 13 13 #ifdef CONFIG_BCM47XX_NVRAM 14 + int bcm47xx_nvram_init_from_iomem(void __iomem *nvram_start, size_t res_size); 14 15 int bcm47xx_nvram_init_from_mem(u32 base, u32 lim); 15 16 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len); 16 17 int bcm47xx_nvram_gpio_pin(const char *name); ··· 21 20 vfree(nvram); 22 21 }; 23 22 #else 23 + static inline int bcm47xx_nvram_init_from_iomem(void __iomem *nvram_start, 24 + size_t res_size) 25 + { 26 + return -ENOTSUPP; 27 + } 24 28 static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim) 25 29 { 26 30 return -ENOTSUPP;