From 943bd3c9f6244c928cd168302d638a6a218fd4e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 2 Nov 2023 09:08:54 +0100 Subject: [PATCH] bcm53xx: add the latest fix version of brcm_nvram MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It was just sent for upstream. Signed-off-by: Rafał Miłecki --- ...nvram-store-a-copy-of-NVRAM-content.patch} | 23 +++++++++++-------- ...nvram-store-a-copy-of-NVRAM-content.patch} | 23 +++++++++++-------- 2 files changed, 28 insertions(+), 18 deletions(-) rename target/linux/bcm53xx/patches-5.15/{800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch => 181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch} (91%) rename target/linux/bcm53xx/patches-6.1/{800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch => 181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch} (91%) diff --git a/target/linux/bcm53xx/patches-5.15/800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch b/target/linux/bcm53xx/patches-5.15/181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch similarity index 91% rename from target/linux/bcm53xx/patches-5.15/800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch rename to target/linux/bcm53xx/patches-5.15/181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch index 2aae713b64..cceb3635ac 100644 --- a/target/linux/bcm53xx/patches-5.15/800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch +++ b/target/linux/bcm53xx/patches-5.15/181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch @@ -25,23 +25,27 @@ Cc: Arınç ÜNAL Cc: Florian Fainelli Cc: Scott Branden Signed-off-by: Rafał Miłecki +Acked-by: Arınç ÜNAL --- - drivers/nvmem/brcm_nvram.c | 130 +++++++++++++++++++++++++------------ - 1 file changed, 90 insertions(+), 40 deletions(-) + drivers/nvmem/brcm_nvram.c | 134 ++++++++++++++++++++++++++----------- + 1 file changed, 94 insertions(+), 40 deletions(-) --- a/drivers/nvmem/brcm_nvram.c +++ b/drivers/nvmem/brcm_nvram.c -@@ -17,9 +17,20 @@ +@@ -17,9 +17,23 @@ #define NVRAM_MAGIC "FLSH" +/** + * struct brcm_nvram - driver state internal struct + * ++ * @dev: NVMEM device pointer + * @nvmem_size: Size of the whole space available for NVRAM + * @data: NVRAM data copy stored to avoid poking underlaying flash controller + * @data_len: NVRAM data size + * @padding_byte: Padding value used to fill remaining space ++ * @cells: Array of discovered NVMEM cells ++ * @ncells: Number of elements in cells + */ struct brcm_nvram { struct device *dev; @@ -53,7 +57,7 @@ Signed-off-by: Rafał Miłecki struct nvmem_cell_info *cells; int ncells; }; -@@ -36,10 +47,47 @@ static int brcm_nvram_read(void *context +@@ -36,10 +50,47 @@ static int brcm_nvram_read(void *context size_t bytes) { struct brcm_nvram *priv = context; @@ -104,7 +108,7 @@ Signed-off-by: Rafał Miłecki return 0; } -@@ -67,8 +115,13 @@ static int brcm_nvram_add_cells(struct b +@@ -67,8 +118,13 @@ static int brcm_nvram_add_cells(struct b size_t len) { struct device *dev = priv->dev; @@ -119,7 +123,7 @@ Signed-off-by: Rafał Miłecki priv->ncells = 0; for (var = data + sizeof(struct brcm_nvram_header); -@@ -78,67 +131,67 @@ static int brcm_nvram_add_cells(struct b +@@ -78,67 +134,68 @@ static int brcm_nvram_add_cells(struct b } priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL); @@ -204,7 +208,8 @@ Signed-off-by: Rafał Miłecki - return err; + len = le32_to_cpu(header->len); + if (len > priv->nvmem_size) { -+ dev_err(dev, "NVRAM length (%zd) exceeds mapped size (%zd)\n", len, priv->nvmem_size); ++ dev_err(dev, "NVRAM length (%zd) exceeds mapped size (%zd)\n", len, ++ priv->nvmem_size); + return -EINVAL; } @@ -215,7 +220,7 @@ Signed-off-by: Rafał Miłecki return 0; } -@@ -150,7 +203,6 @@ static int brcm_nvram_probe(struct platf +@@ -150,7 +207,6 @@ static int brcm_nvram_probe(struct platf .reg_read = brcm_nvram_read, }; struct device *dev = &pdev->dev; @@ -223,7 +228,7 @@ Signed-off-by: Rafał Miłecki struct brcm_nvram *priv; int err; -@@ -159,21 +211,19 @@ static int brcm_nvram_probe(struct platf +@@ -159,21 +215,19 @@ static int brcm_nvram_probe(struct platf return -ENOMEM; priv->dev = dev; diff --git a/target/linux/bcm53xx/patches-6.1/800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch b/target/linux/bcm53xx/patches-6.1/181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch similarity index 91% rename from target/linux/bcm53xx/patches-6.1/800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch rename to target/linux/bcm53xx/patches-6.1/181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch index 2aae713b64..cceb3635ac 100644 --- a/target/linux/bcm53xx/patches-6.1/800-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch +++ b/target/linux/bcm53xx/patches-6.1/181-nvmem-brcm_nvram-store-a-copy-of-NVRAM-content.patch @@ -25,23 +25,27 @@ Cc: Arınç ÜNAL Cc: Florian Fainelli Cc: Scott Branden Signed-off-by: Rafał Miłecki +Acked-by: Arınç ÜNAL --- - drivers/nvmem/brcm_nvram.c | 130 +++++++++++++++++++++++++------------ - 1 file changed, 90 insertions(+), 40 deletions(-) + drivers/nvmem/brcm_nvram.c | 134 ++++++++++++++++++++++++++----------- + 1 file changed, 94 insertions(+), 40 deletions(-) --- a/drivers/nvmem/brcm_nvram.c +++ b/drivers/nvmem/brcm_nvram.c -@@ -17,9 +17,20 @@ +@@ -17,9 +17,23 @@ #define NVRAM_MAGIC "FLSH" +/** + * struct brcm_nvram - driver state internal struct + * ++ * @dev: NVMEM device pointer + * @nvmem_size: Size of the whole space available for NVRAM + * @data: NVRAM data copy stored to avoid poking underlaying flash controller + * @data_len: NVRAM data size + * @padding_byte: Padding value used to fill remaining space ++ * @cells: Array of discovered NVMEM cells ++ * @ncells: Number of elements in cells + */ struct brcm_nvram { struct device *dev; @@ -53,7 +57,7 @@ Signed-off-by: Rafał Miłecki struct nvmem_cell_info *cells; int ncells; }; -@@ -36,10 +47,47 @@ static int brcm_nvram_read(void *context +@@ -36,10 +50,47 @@ static int brcm_nvram_read(void *context size_t bytes) { struct brcm_nvram *priv = context; @@ -104,7 +108,7 @@ Signed-off-by: Rafał Miłecki return 0; } -@@ -67,8 +115,13 @@ static int brcm_nvram_add_cells(struct b +@@ -67,8 +118,13 @@ static int brcm_nvram_add_cells(struct b size_t len) { struct device *dev = priv->dev; @@ -119,7 +123,7 @@ Signed-off-by: Rafał Miłecki priv->ncells = 0; for (var = data + sizeof(struct brcm_nvram_header); -@@ -78,67 +131,67 @@ static int brcm_nvram_add_cells(struct b +@@ -78,67 +134,68 @@ static int brcm_nvram_add_cells(struct b } priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL); @@ -204,7 +208,8 @@ Signed-off-by: Rafał Miłecki - return err; + len = le32_to_cpu(header->len); + if (len > priv->nvmem_size) { -+ dev_err(dev, "NVRAM length (%zd) exceeds mapped size (%zd)\n", len, priv->nvmem_size); ++ dev_err(dev, "NVRAM length (%zd) exceeds mapped size (%zd)\n", len, ++ priv->nvmem_size); + return -EINVAL; } @@ -215,7 +220,7 @@ Signed-off-by: Rafał Miłecki return 0; } -@@ -150,7 +203,6 @@ static int brcm_nvram_probe(struct platf +@@ -150,7 +207,6 @@ static int brcm_nvram_probe(struct platf .reg_read = brcm_nvram_read, }; struct device *dev = &pdev->dev; @@ -223,7 +228,7 @@ Signed-off-by: Rafał Miłecki struct brcm_nvram *priv; int err; -@@ -159,21 +211,19 @@ static int brcm_nvram_probe(struct platf +@@ -159,21 +215,19 @@ static int brcm_nvram_probe(struct platf return -ENOMEM; priv->dev = dev; -- 2.30.2