linux-stable/drivers/nvmem
Christian Lamparter ee424f7d39 nvmem: u-boot-env: fix crc32_data_offset on redundant u-boot-env
The Western Digital MyBook Live (PowerPC 464/APM82181)
has a set of redundant u-boot-env. Loading up the driver
the following error:

| u_boot_env: Invalid calculated CRC32: 0x4f8f2c86 (expected: 0x98b14514)
| u_boot_env: probe of partition@1e000 failed with error -22

Looking up the userspace libubootenv utilities source [0],
it looks like the "mark" or "flag" is not part of the
crc32 sum... which is unfortunate :(

|static int libuboot_load(struct uboot_ctx *ctx)
|{
|[...]
|       if (ctx->redundant) {
|		[...]
|               offsetdata = offsetof(struct uboot_env_redund, data);
|		[...]					//-----^^
|       }
|       usable_envsize = ctx->size - offsetdata;
|       buf[0] = malloc(bufsize);
|[...]
|	for (i = 0; i < copies; i++) {
|		data = (uint8_t *)(buf[i] + offsetdata);
|               uint32_t crc;
|
|		ret = devread(ctx, i, buf[i]);
|		[...]
|		crc = *(uint32_t *)(buf[i] + offsetcrc);
|               dev->crc = crc32(0, (uint8_t *)data, usable_envsize);
|

[0] https://github.com/sbabic/libubootenv/blob/master/src/uboot_env.c#L951

Fixes: d5542923f2 ("nvmem: add driver handling U-Boot environment variables")
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Link: https://lore.kernel.org/r/70a16eae113e08db2390b76e174f4837caa135c3.1667580636.git.chunkeey@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-10 18:45:59 +01:00
..
apple-efuses.c nvmem: Add Apple eFuse driver 2022-05-09 15:44:21 +02:00
bcm-ocotp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_30.RULE (part 2) 2022-06-10 14:51:35 +02:00
brcm_nvram.c nvmem: brcm_nvram: Use kzalloc for allocating only one element 2022-09-24 14:54:38 +02:00
core.c nvmem: core: add error handling for dev_set_name 2022-09-24 14:54:38 +02:00
imx-iim.c nvmem: imx-iim: Use of_device_get_match_data() 2021-02-04 17:04:18 +01:00
imx-ocotp-scu.c
imx-ocotp.c nvmem: imx-ocotp: add support for post processing 2021-10-13 15:33:17 +02:00
jz4780-efuse.c nvmem: jz4780-efuse: Use PTR_ERR_OR_ZERO() to simplify code 2020-05-15 16:20:02 +02:00
Kconfig nvmem: lan9662-otp: add support 2022-09-24 14:54:38 +02:00
lan9662-otpc.c nvmem: lan9662-otp: Fix compatible string 2022-11-10 18:45:01 +01:00
layerscape-sfp.c nvmem: sfp: Add support for TA 2.1 devices 2022-05-09 15:46:29 +02:00
lpc18xx_eeprom.c
lpc18xx_otp.c
Makefile nvmem: lan9662-otp: add support 2022-09-24 14:54:38 +02:00
meson-efuse.c
meson-mx-efuse.c nvmem: meson-mx-efuse: replace unnecessary devm_kstrdup() 2022-02-21 18:00:30 +01:00
microchip-otpc.c nvmem: microchip-otpc: add support 2022-07-08 15:45:05 +02:00
mtk-efuse.c nvmem: mtk-efuse: Simplify with devm_platform_get_and_ioremap_resource() 2022-07-08 15:45:05 +02:00
mxs-ocotp.c nvmem: mxs-ocotp: Use devm_add_action_or_reset() for cleanup 2020-03-23 20:05:23 +01:00
nintendo-otp.c nvmem: nintendo-otp: Add new driver for the Wii and Wii U OTP 2021-08-13 10:27:20 +02:00
qcom-spmi-sdam.c nvmem: convert comma to semicolon 2021-04-02 16:26:33 +02:00
qfprom.c nvmem: qfprom: using pm_runtime_resume_and_get instead of pm_runtime_get_sync 2022-05-09 15:45:39 +02:00
rave-sp-eeprom.c
rmem.c nvmem: Add driver to expose reserved memory as nvmem 2021-02-04 17:04:18 +01:00
rockchip-efuse.c
rockchip-otp.c
sc27xx-efuse.c nvmem: sc27xx: add sc2730 efuse support 2020-07-29 17:12:08 +02:00
snvs_lpgpr.c nvmem: convert comma to semicolon 2021-04-02 16:26:33 +02:00
sprd-efuse.c nvmem: sprd: Fix an error message 2021-05-14 13:39:50 +02:00
stm32-romem.c
sunplus-ocotp.c nvmem: sunplus-ocotp: drop useless probe confirmation 2022-04-24 17:15:15 +02:00
sunxi_sid.c nvmem: sunxi_sid: Add support for D1 variant 2022-02-21 18:00:30 +01:00
u-boot-env.c nvmem: u-boot-env: fix crc32_data_offset on redundant u-boot-env 2022-11-10 18:45:59 +01:00
uniphier-efuse.c
vf610-ocotp.c
zynqmp_nvmem.c firmware: xilinx: Remove eemi ops for get_chipid 2020-04-28 15:45:06 +02:00