From 8616d9db34dcad467ff779341413f6acb3529487 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Tue, 10 Sep 2024 13:42:59 +0200 Subject: [PATCH] kernel: backport nvmem changes from v6.10 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki --- ...ore-owner-from-modules-with-nvmem_la.patch | 61 +++++++++++++++++++ ...ie-tlv-drop-driver-owner-initializat.patch | 28 +++++++++ ...28vpd-drop-driver-owner-initializati.patch | 28 +++++++++ ...-nvmem-sc27xx-fix-module-autoloading.patch | 26 ++++++++ ...05-nvmem-sprd-fix-module-autoloading.patch | 26 ++++++++ ...core-switch-to-use-device_add_groups.patch | 32 ++++++++++ ...prom-Convert-to-platform-remove-call.patch | 57 +++++++++++++++++ ...fuse-Remove-nvmem_device-from-efuse-.patch | 50 +++++++++++++++ ...m-rmem-Fix-return-value-of-rmem_read.patch | 42 +++++++++++++ ...e-Fix-return-value-of-nvmem-callback.patch | 59 ++++++++++++++++++ ...change-name-to-fram-for-current-attr.patch | 39 ++++++++++++ ...-cell-sysfs-permissions-to-main-attr.patch | 37 +++++++++++ ...ore-owner-from-modules-with-nvmem_la.patch | 61 +++++++++++++++++++ ...ie-tlv-drop-driver-owner-initializat.patch | 28 +++++++++ ...28vpd-drop-driver-owner-initializati.patch | 28 +++++++++ ...-nvmem-sc27xx-fix-module-autoloading.patch | 26 ++++++++ ...05-nvmem-sprd-fix-module-autoloading.patch | 26 ++++++++ ...core-switch-to-use-device_add_groups.patch | 32 ++++++++++ ...prom-Convert-to-platform-remove-call.patch | 57 +++++++++++++++++ ...fuse-Remove-nvmem_device-from-efuse-.patch | 50 +++++++++++++++ ...ore-owner-from-modules-with-nvmem_la.patch | 61 +++++++++++++++++++ ...ie-tlv-drop-driver-owner-initializat.patch | 28 +++++++++ ...28vpd-drop-driver-owner-initializati.patch | 28 +++++++++ ...-nvmem-sc27xx-fix-module-autoloading.patch | 26 ++++++++ ...05-nvmem-sprd-fix-module-autoloading.patch | 26 ++++++++ ...core-switch-to-use-device_add_groups.patch | 32 ++++++++++ ...prom-Convert-to-platform-remove-call.patch | 57 +++++++++++++++++ ...fuse-Remove-nvmem_device-from-efuse-.patch | 50 +++++++++++++++ ...-support-mac-base-fixed-layout-cells.patch | 4 +- 29 files changed, 1103 insertions(+), 2 deletions(-) create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0009-nvmem-rmem-Fix-return-value-of-rmem_read.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0010-nvmem-meson-efuse-Fix-return-value-of-nvmem-callback.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0011-nvmem-core-only-change-name-to-fram-for-current-attr.patch create mode 100644 target/linux/generic/backport-5.15/837-v6.10-0012-nvmem-core-limit-cell-sysfs-permissions-to-main-attr.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch create mode 100644 target/linux/generic/backport-6.1/829-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch create mode 100644 target/linux/generic/backport-6.6/821-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch diff --git a/target/linux/generic/backport-5.15/837-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch b/target/linux/generic/backport-5.15/837-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch new file mode 100644 index 0000000000..418d2c82b2 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch @@ -0,0 +1,61 @@ +From 6d0ca4a2a7e25f9ad07c1f335f20b4d9e048cdd5 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:11 +0100 +Subject: [PATCH] nvmem: layouts: store owner from modules with + nvmem_layout_driver_register() + +Modules registering driver with nvmem_layout_driver_register() might +forget to set .owner field. The field is used by some of other kernel +parts for reference counting (try_module_get()), so it is expected that +drivers will set it. + +Solve the problem by moving this task away from the drivers to the core +code, just like we did for platform_driver in +commit 9447057eaff8 ("platform_device: use a macro instead of +platform_driver_register"). + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Reviewed-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-2-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts.c | 6 ++++-- + include/linux/nvmem-provider.h | 5 ++++- + 2 files changed, 8 insertions(+), 3 deletions(-) + +--- a/drivers/nvmem/layouts.c ++++ b/drivers/nvmem/layouts.c +@@ -52,13 +52,15 @@ static const struct bus_type nvmem_layou + .remove = nvmem_layout_bus_remove, + }; + +-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv) ++int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv, ++ struct module *owner) + { + drv->driver.bus = &nvmem_layout_bus_type; ++ drv->driver.owner = owner; + + return driver_register(&drv->driver); + } +-EXPORT_SYMBOL_GPL(nvmem_layout_driver_register); ++EXPORT_SYMBOL_GPL(__nvmem_layout_driver_register); + + void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv) + { +--- a/include/linux/nvmem-provider.h ++++ b/include/linux/nvmem-provider.h +@@ -199,7 +199,10 @@ int nvmem_add_one_cell(struct nvmem_devi + int nvmem_layout_register(struct nvmem_layout *layout); + void nvmem_layout_unregister(struct nvmem_layout *layout); + +-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv); ++#define nvmem_layout_driver_register(drv) \ ++ __nvmem_layout_driver_register(drv, THIS_MODULE) ++int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv, ++ struct module *owner); + void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv); + #define module_nvmem_layout_driver(__nvmem_layout_driver) \ + module_driver(__nvmem_layout_driver, nvmem_layout_driver_register, \ diff --git a/target/linux/generic/backport-5.15/837-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch b/target/linux/generic/backport-5.15/837-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch new file mode 100644 index 0000000000..b483dd243b --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch @@ -0,0 +1,28 @@ +From 21833338eccb91194fec6ba7548d9c454824eca0 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:12 +0100 +Subject: [PATCH] nvmem: layouts: onie-tlv: drop driver owner initialization + +Core in nvmem_layout_driver_register() already sets the .owner, so +driver does not need to. + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Acked-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts/onie-tlv.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/nvmem/layouts/onie-tlv.c ++++ b/drivers/nvmem/layouts/onie-tlv.c +@@ -247,7 +247,6 @@ MODULE_DEVICE_TABLE(of, onie_tlv_of_matc + + static struct nvmem_layout_driver onie_tlv_layout = { + .driver = { +- .owner = THIS_MODULE, + .name = "onie-tlv-layout", + .of_match_table = onie_tlv_of_match_table, + }, diff --git a/target/linux/generic/backport-5.15/837-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch b/target/linux/generic/backport-5.15/837-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch new file mode 100644 index 0000000000..472a65feca --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch @@ -0,0 +1,28 @@ +From 23fd602f21953c03c0714257d36685cd6b486f04 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:13 +0100 +Subject: [PATCH] nvmem: layouts: sl28vpd: drop driver owner initialization + +Core in nvmem_layout_driver_register() already sets the .owner, so +driver does not need to. + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Reviewed-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-4-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts/sl28vpd.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/nvmem/layouts/sl28vpd.c ++++ b/drivers/nvmem/layouts/sl28vpd.c +@@ -156,7 +156,6 @@ MODULE_DEVICE_TABLE(of, sl28vpd_of_match + + static struct nvmem_layout_driver sl28vpd_layout = { + .driver = { +- .owner = THIS_MODULE, + .name = "kontron-sl28vpd-layout", + .of_match_table = sl28vpd_of_match_table, + }, diff --git a/target/linux/generic/backport-5.15/837-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch b/target/linux/generic/backport-5.15/837-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch new file mode 100644 index 0000000000..2aa13a5c64 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch @@ -0,0 +1,26 @@ +From dc3d88ade857ba3dca34f008e0b0aed3ef79cb15 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:14 +0100 +Subject: [PATCH] nvmem: sc27xx: fix module autoloading + +Add MODULE_DEVICE_TABLE(), so the module could be properly autoloaded +based on the alias from of_device_id table. + +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-5-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/sc27xx-efuse.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/nvmem/sc27xx-efuse.c ++++ b/drivers/nvmem/sc27xx-efuse.c +@@ -263,6 +263,7 @@ static const struct of_device_id sc27xx_ + { .compatible = "sprd,sc2730-efuse", .data = &sc2730_edata}, + { } + }; ++MODULE_DEVICE_TABLE(of, sc27xx_efuse_of_match); + + static struct platform_driver sc27xx_efuse_driver = { + .probe = sc27xx_efuse_probe, diff --git a/target/linux/generic/backport-5.15/837-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch b/target/linux/generic/backport-5.15/837-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch new file mode 100644 index 0000000000..0953c92340 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch @@ -0,0 +1,26 @@ +From 154c1ec943e34f3188c9305b0c91d5e7dc1373b8 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:15 +0100 +Subject: [PATCH] nvmem: sprd: fix module autoloading + +Add MODULE_DEVICE_TABLE(), so the module could be properly autoloaded +based on the alias from of_device_id table. + +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-6-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/sprd-efuse.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/nvmem/sprd-efuse.c ++++ b/drivers/nvmem/sprd-efuse.c +@@ -426,6 +426,7 @@ static const struct of_device_id sprd_ef + { .compatible = "sprd,ums312-efuse", .data = &ums312_data }, + { } + }; ++MODULE_DEVICE_TABLE(of, sprd_efuse_of_match); + + static struct platform_driver sprd_efuse_driver = { + .probe = sprd_efuse_probe, diff --git a/target/linux/generic/backport-5.15/837-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch b/target/linux/generic/backport-5.15/837-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch new file mode 100644 index 0000000000..07eb082296 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch @@ -0,0 +1,32 @@ +From 8d8fc146dd7a0d6a6b37695747a524310dfb9d57 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Tue, 30 Apr 2024 09:49:16 +0100 +Subject: [PATCH] nvmem: core: switch to use device_add_groups() + +devm_device_add_groups() is being removed from the kernel, so move the +nvmem driver to use device_add_groups() instead. The logic is +identical, when the device is removed the driver core will properly +clean up and remove the groups, and the memory used by the attribute +groups will be freed because it was created with dev_* calls, so this is +functionally identical overall. + +Cc: Srinivas Kandagatla +Signed-off-by: Srinivas Kandagatla +Signed-off-by: Greg Kroah-Hartman +Link: https://lore.kernel.org/r/20240430084921.33387-7-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -478,7 +478,7 @@ static int nvmem_populate_sysfs_cells(st + + nvmem_cells_group.bin_attrs = cells_attrs; + +- ret = devm_device_add_groups(&nvmem->dev, nvmem_cells_groups); ++ ret = device_add_groups(&nvmem->dev, nvmem_cells_groups); + if (ret) + goto unlock_mutex; + diff --git a/target/linux/generic/backport-5.15/837-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch b/target/linux/generic/backport-5.15/837-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch new file mode 100644 index 0000000000..27d9270d31 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch @@ -0,0 +1,57 @@ +From 693d2f629962628ddefc88f4b6b453edda5ac32e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= +Date: Tue, 30 Apr 2024 09:49:17 +0100 +Subject: [PATCH] nvmem: lpc18xx_eeprom: Convert to platform remove callback + returning void +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The .remove() callback for a platform driver returns an int which makes +many driver authors wrongly assume it's possible to do error handling by +returning an error code. However the value returned is ignored (apart +from emitting a warning) and this typically results in resource leaks. + +To improve here there is a quest to make the remove callback return +void. In the first step of this quest all drivers are converted to +.remove_new(), which already returns void. Eventually after all drivers +are converted, .remove_new() will be renamed to .remove(). + +Trivially convert this driver from always returning zero in the remove +callback to the void returning variant. + +Signed-off-by: Uwe Kleine-König +Acked-by: Vladimir Zapolskiy +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-8-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/lpc18xx_eeprom.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/drivers/nvmem/lpc18xx_eeprom.c ++++ b/drivers/nvmem/lpc18xx_eeprom.c +@@ -249,13 +249,11 @@ err_clk: + return ret; + } + +-static int lpc18xx_eeprom_remove(struct platform_device *pdev) ++static void lpc18xx_eeprom_remove(struct platform_device *pdev) + { + struct lpc18xx_eeprom_dev *eeprom = platform_get_drvdata(pdev); + + clk_disable_unprepare(eeprom->clk); +- +- return 0; + } + + static const struct of_device_id lpc18xx_eeprom_of_match[] = { +@@ -266,7 +264,7 @@ MODULE_DEVICE_TABLE(of, lpc18xx_eeprom_o + + static struct platform_driver lpc18xx_eeprom_driver = { + .probe = lpc18xx_eeprom_probe, +- .remove = lpc18xx_eeprom_remove, ++ .remove_new = lpc18xx_eeprom_remove, + .driver = { + .name = "lpc18xx-eeprom", + .of_match_table = lpc18xx_eeprom_of_match, diff --git a/target/linux/generic/backport-5.15/837-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch b/target/linux/generic/backport-5.15/837-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch new file mode 100644 index 0000000000..7770052d97 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch @@ -0,0 +1,50 @@ +From 2a1ad6b75292d38aa2f6ded7335979e0632521da Mon Sep 17 00:00:00 2001 +From: Mukesh Ojha +Date: Tue, 30 Apr 2024 09:49:21 +0100 +Subject: [PATCH] nvmem: meson-mx-efuse: Remove nvmem_device from efuse struct + +nvmem_device is used at one place while registering nvmem +device and it is not required to be present in efuse struct +for just this purpose. + +Drop nvmem_device and manage with nvmem device stack variable. + +Signed-off-by: Mukesh Ojha +Reviewed-by: Martin Blumenstingl +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-12-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/meson-mx-efuse.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/nvmem/meson-mx-efuse.c ++++ b/drivers/nvmem/meson-mx-efuse.c +@@ -44,7 +44,6 @@ struct meson_mx_efuse_platform_data { + struct meson_mx_efuse { + void __iomem *base; + struct clk *core_clk; +- struct nvmem_device *nvmem; + struct nvmem_config config; + }; + +@@ -194,6 +193,7 @@ static int meson_mx_efuse_probe(struct p + { + const struct meson_mx_efuse_platform_data *drvdata; + struct meson_mx_efuse *efuse; ++ struct nvmem_device *nvmem; + + drvdata = of_device_get_match_data(&pdev->dev); + if (!drvdata) +@@ -224,9 +224,9 @@ static int meson_mx_efuse_probe(struct p + return PTR_ERR(efuse->core_clk); + } + +- efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); ++ nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); + +- return PTR_ERR_OR_ZERO(efuse->nvmem); ++ return PTR_ERR_OR_ZERO(nvmem); + } + + static struct platform_driver meson_mx_efuse_driver = { diff --git a/target/linux/generic/backport-5.15/837-v6.10-0009-nvmem-rmem-Fix-return-value-of-rmem_read.patch b/target/linux/generic/backport-5.15/837-v6.10-0009-nvmem-rmem-Fix-return-value-of-rmem_read.patch new file mode 100644 index 0000000000..0f0f68b4d7 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0009-nvmem-rmem-Fix-return-value-of-rmem_read.patch @@ -0,0 +1,42 @@ +From 28b008751aa295612318a0fbb2f22dd4f6a83139 Mon Sep 17 00:00:00 2001 +From: Joy Chakraborty +Date: Fri, 28 Jun 2024 12:37:01 +0100 +Subject: [PATCH] nvmem: rmem: Fix return value of rmem_read() + +reg_read() callback registered with nvmem core expects 0 on success and +a negative value on error but rmem_read() returns the number of bytes +read which is treated as an error at the nvmem core. + +This does not break when rmem is accessed using sysfs via +bin_attr_nvmem_read()/write() but causes an error when accessed from +places like nvmem_access_with_keepouts(), etc. + +Change to return 0 on success and error in case +memory_read_from_buffer() returns an error or -EIO if bytes read do not +match what was requested. + +Fixes: 5a3fa75a4d9c ("nvmem: Add driver to expose reserved memory as nvmem") +Cc: stable@vger.kernel.org +Signed-off-by: Joy Chakraborty +Reviewed-by: Dan Carpenter +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240628113704.13742-2-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/rmem.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/nvmem/rmem.c ++++ b/drivers/nvmem/rmem.c +@@ -46,7 +46,10 @@ static int rmem_read(void *context, unsi + + memunmap(addr); + +- return count; ++ if (count < 0) ++ return count; ++ ++ return count == bytes ? 0 : -EIO; + } + + static int rmem_probe(struct platform_device *pdev) diff --git a/target/linux/generic/backport-5.15/837-v6.10-0010-nvmem-meson-efuse-Fix-return-value-of-nvmem-callback.patch b/target/linux/generic/backport-5.15/837-v6.10-0010-nvmem-meson-efuse-Fix-return-value-of-nvmem-callback.patch new file mode 100644 index 0000000000..9e5d6198b7 --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0010-nvmem-meson-efuse-Fix-return-value-of-nvmem-callback.patch @@ -0,0 +1,59 @@ +From 7a0a6d0a7c805f9380381f4deedffdf87b93f408 Mon Sep 17 00:00:00 2001 +From: Joy Chakraborty +Date: Fri, 28 Jun 2024 12:37:02 +0100 +Subject: [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks + +Read/write callbacks registered with nvmem core expect 0 to be returned +on success and a negative value to be returned on failure. + +meson_efuse_read() and meson_efuse_write() call into +meson_sm_call_read() and meson_sm_call_write() respectively which return +the number of bytes read or written on success as per their api +description. + +Fix to return error if meson_sm_call_read()/meson_sm_call_write() +returns an error else return 0. + +Fixes: a29a63bdaf6f ("nvmem: meson-efuse: simplify read callback") +Cc: stable@vger.kernel.org +Signed-off-by: Joy Chakraborty +Reviewed-by: Dan Carpenter +Reviewed-by: Neil Armstrong +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240628113704.13742-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/meson-efuse.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +--- a/drivers/nvmem/meson-efuse.c ++++ b/drivers/nvmem/meson-efuse.c +@@ -18,18 +18,24 @@ static int meson_efuse_read(void *contex + void *val, size_t bytes) + { + struct meson_sm_firmware *fw = context; ++ int ret; + +- return meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset, +- bytes, 0, 0, 0); ++ ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset, ++ bytes, 0, 0, 0); ++ ++ return ret < 0 ? ret : 0; + } + + static int meson_efuse_write(void *context, unsigned int offset, + void *val, size_t bytes) + { + struct meson_sm_firmware *fw = context; ++ int ret; ++ ++ ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset, ++ bytes, 0, 0, 0); + +- return meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset, +- bytes, 0, 0, 0); ++ return ret < 0 ? ret : 0; + } + + static const struct of_device_id meson_efuse_match[] = { diff --git a/target/linux/generic/backport-5.15/837-v6.10-0011-nvmem-core-only-change-name-to-fram-for-current-attr.patch b/target/linux/generic/backport-5.15/837-v6.10-0011-nvmem-core-only-change-name-to-fram-for-current-attr.patch new file mode 100644 index 0000000000..064a44999b --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0011-nvmem-core-only-change-name-to-fram-for-current-attr.patch @@ -0,0 +1,39 @@ +From 0ba424c934fd43dccf0d597e1ae8851f07cb2edf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= +Date: Fri, 28 Jun 2024 12:37:03 +0100 +Subject: [PATCH] nvmem: core: only change name to fram for current attribute +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +bin_attr_nvmem_eeprom_compat is the template from which all future +compat attributes are created. +Changing it means to change all subsquent compat attributes, too. + +Instead only use the "fram" name for the currently registered attribute. + +Fixes: fd307a4ad332 ("nvmem: prepare basics for FRAM support") +Cc: stable@vger.kernel.org +Signed-off-by: Thomas Weißschuh +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240628113704.13742-4-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -397,10 +397,9 @@ static int nvmem_sysfs_setup_compat(stru + if (!config->base_dev) + return -EINVAL; + +- if (config->type == NVMEM_TYPE_FRAM) +- bin_attr_nvmem_eeprom_compat.attr.name = "fram"; +- + nvmem->eeprom = bin_attr_nvmem_eeprom_compat; ++ if (config->type == NVMEM_TYPE_FRAM) ++ nvmem->eeprom.attr.name = "fram"; + nvmem->eeprom.attr.mode = nvmem_bin_attr_get_umode(nvmem); + nvmem->eeprom.size = nvmem->size; + #ifdef CONFIG_DEBUG_LOCK_ALLOC diff --git a/target/linux/generic/backport-5.15/837-v6.10-0012-nvmem-core-limit-cell-sysfs-permissions-to-main-attr.patch b/target/linux/generic/backport-5.15/837-v6.10-0012-nvmem-core-limit-cell-sysfs-permissions-to-main-attr.patch new file mode 100644 index 0000000000..88453e83cc --- /dev/null +++ b/target/linux/generic/backport-5.15/837-v6.10-0012-nvmem-core-limit-cell-sysfs-permissions-to-main-attr.patch @@ -0,0 +1,37 @@ +From 6bef98bafd82903a8d461463f9594f19f1fd6a85 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= +Date: Fri, 28 Jun 2024 12:37:04 +0100 +Subject: [PATCH] nvmem: core: limit cell sysfs permissions to main attribute + ones +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The cell sysfs attribute should not provide more access to the nvmem +data than the main attribute itself. +For example if nvme_config::root_only was set, the cell attribute +would still provide read access to everybody. + +Mask out permissions not available on the main attribute. + +Fixes: 0331c611949f ("nvmem: core: Expose cells through sysfs") +Cc: stable@vger.kernel.org +Signed-off-by: Thomas Weißschuh +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240628113704.13742-5-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -462,7 +462,7 @@ static int nvmem_populate_sysfs_cells(st + attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL, + "%s@%x", entry->name, + entry->offset); +- attrs[i].attr.mode = 0444; ++ attrs[i].attr.mode = 0444 & nvmem_bin_attr_get_umode(nvmem); + attrs[i].size = entry->bytes; + attrs[i].read = &nvmem_cell_attr_read; + attrs[i].private = entry; diff --git a/target/linux/generic/backport-6.1/829-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch b/target/linux/generic/backport-6.1/829-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch new file mode 100644 index 0000000000..418d2c82b2 --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch @@ -0,0 +1,61 @@ +From 6d0ca4a2a7e25f9ad07c1f335f20b4d9e048cdd5 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:11 +0100 +Subject: [PATCH] nvmem: layouts: store owner from modules with + nvmem_layout_driver_register() + +Modules registering driver with nvmem_layout_driver_register() might +forget to set .owner field. The field is used by some of other kernel +parts for reference counting (try_module_get()), so it is expected that +drivers will set it. + +Solve the problem by moving this task away from the drivers to the core +code, just like we did for platform_driver in +commit 9447057eaff8 ("platform_device: use a macro instead of +platform_driver_register"). + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Reviewed-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-2-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts.c | 6 ++++-- + include/linux/nvmem-provider.h | 5 ++++- + 2 files changed, 8 insertions(+), 3 deletions(-) + +--- a/drivers/nvmem/layouts.c ++++ b/drivers/nvmem/layouts.c +@@ -52,13 +52,15 @@ static const struct bus_type nvmem_layou + .remove = nvmem_layout_bus_remove, + }; + +-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv) ++int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv, ++ struct module *owner) + { + drv->driver.bus = &nvmem_layout_bus_type; ++ drv->driver.owner = owner; + + return driver_register(&drv->driver); + } +-EXPORT_SYMBOL_GPL(nvmem_layout_driver_register); ++EXPORT_SYMBOL_GPL(__nvmem_layout_driver_register); + + void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv) + { +--- a/include/linux/nvmem-provider.h ++++ b/include/linux/nvmem-provider.h +@@ -199,7 +199,10 @@ int nvmem_add_one_cell(struct nvmem_devi + int nvmem_layout_register(struct nvmem_layout *layout); + void nvmem_layout_unregister(struct nvmem_layout *layout); + +-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv); ++#define nvmem_layout_driver_register(drv) \ ++ __nvmem_layout_driver_register(drv, THIS_MODULE) ++int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv, ++ struct module *owner); + void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv); + #define module_nvmem_layout_driver(__nvmem_layout_driver) \ + module_driver(__nvmem_layout_driver, nvmem_layout_driver_register, \ diff --git a/target/linux/generic/backport-6.1/829-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch b/target/linux/generic/backport-6.1/829-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch new file mode 100644 index 0000000000..b483dd243b --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch @@ -0,0 +1,28 @@ +From 21833338eccb91194fec6ba7548d9c454824eca0 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:12 +0100 +Subject: [PATCH] nvmem: layouts: onie-tlv: drop driver owner initialization + +Core in nvmem_layout_driver_register() already sets the .owner, so +driver does not need to. + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Acked-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts/onie-tlv.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/nvmem/layouts/onie-tlv.c ++++ b/drivers/nvmem/layouts/onie-tlv.c +@@ -247,7 +247,6 @@ MODULE_DEVICE_TABLE(of, onie_tlv_of_matc + + static struct nvmem_layout_driver onie_tlv_layout = { + .driver = { +- .owner = THIS_MODULE, + .name = "onie-tlv-layout", + .of_match_table = onie_tlv_of_match_table, + }, diff --git a/target/linux/generic/backport-6.1/829-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch b/target/linux/generic/backport-6.1/829-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch new file mode 100644 index 0000000000..472a65feca --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch @@ -0,0 +1,28 @@ +From 23fd602f21953c03c0714257d36685cd6b486f04 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:13 +0100 +Subject: [PATCH] nvmem: layouts: sl28vpd: drop driver owner initialization + +Core in nvmem_layout_driver_register() already sets the .owner, so +driver does not need to. + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Reviewed-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-4-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts/sl28vpd.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/nvmem/layouts/sl28vpd.c ++++ b/drivers/nvmem/layouts/sl28vpd.c +@@ -156,7 +156,6 @@ MODULE_DEVICE_TABLE(of, sl28vpd_of_match + + static struct nvmem_layout_driver sl28vpd_layout = { + .driver = { +- .owner = THIS_MODULE, + .name = "kontron-sl28vpd-layout", + .of_match_table = sl28vpd_of_match_table, + }, diff --git a/target/linux/generic/backport-6.1/829-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch b/target/linux/generic/backport-6.1/829-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch new file mode 100644 index 0000000000..2aa13a5c64 --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch @@ -0,0 +1,26 @@ +From dc3d88ade857ba3dca34f008e0b0aed3ef79cb15 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:14 +0100 +Subject: [PATCH] nvmem: sc27xx: fix module autoloading + +Add MODULE_DEVICE_TABLE(), so the module could be properly autoloaded +based on the alias from of_device_id table. + +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-5-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/sc27xx-efuse.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/nvmem/sc27xx-efuse.c ++++ b/drivers/nvmem/sc27xx-efuse.c +@@ -263,6 +263,7 @@ static const struct of_device_id sc27xx_ + { .compatible = "sprd,sc2730-efuse", .data = &sc2730_edata}, + { } + }; ++MODULE_DEVICE_TABLE(of, sc27xx_efuse_of_match); + + static struct platform_driver sc27xx_efuse_driver = { + .probe = sc27xx_efuse_probe, diff --git a/target/linux/generic/backport-6.1/829-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch b/target/linux/generic/backport-6.1/829-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch new file mode 100644 index 0000000000..0953c92340 --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch @@ -0,0 +1,26 @@ +From 154c1ec943e34f3188c9305b0c91d5e7dc1373b8 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:15 +0100 +Subject: [PATCH] nvmem: sprd: fix module autoloading + +Add MODULE_DEVICE_TABLE(), so the module could be properly autoloaded +based on the alias from of_device_id table. + +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-6-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/sprd-efuse.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/nvmem/sprd-efuse.c ++++ b/drivers/nvmem/sprd-efuse.c +@@ -426,6 +426,7 @@ static const struct of_device_id sprd_ef + { .compatible = "sprd,ums312-efuse", .data = &ums312_data }, + { } + }; ++MODULE_DEVICE_TABLE(of, sprd_efuse_of_match); + + static struct platform_driver sprd_efuse_driver = { + .probe = sprd_efuse_probe, diff --git a/target/linux/generic/backport-6.1/829-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch b/target/linux/generic/backport-6.1/829-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch new file mode 100644 index 0000000000..4de97af6ac --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch @@ -0,0 +1,32 @@ +From 8d8fc146dd7a0d6a6b37695747a524310dfb9d57 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Tue, 30 Apr 2024 09:49:16 +0100 +Subject: [PATCH] nvmem: core: switch to use device_add_groups() + +devm_device_add_groups() is being removed from the kernel, so move the +nvmem driver to use device_add_groups() instead. The logic is +identical, when the device is removed the driver core will properly +clean up and remove the groups, and the memory used by the attribute +groups will be freed because it was created with dev_* calls, so this is +functionally identical overall. + +Cc: Srinivas Kandagatla +Signed-off-by: Srinivas Kandagatla +Signed-off-by: Greg Kroah-Hartman +Link: https://lore.kernel.org/r/20240430084921.33387-7-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -477,7 +477,7 @@ static int nvmem_populate_sysfs_cells(st + + nvmem_cells_group.bin_attrs = cells_attrs; + +- ret = devm_device_add_groups(&nvmem->dev, nvmem_cells_groups); ++ ret = device_add_groups(&nvmem->dev, nvmem_cells_groups); + if (ret) + goto unlock_mutex; + diff --git a/target/linux/generic/backport-6.1/829-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch b/target/linux/generic/backport-6.1/829-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch new file mode 100644 index 0000000000..27d9270d31 --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch @@ -0,0 +1,57 @@ +From 693d2f629962628ddefc88f4b6b453edda5ac32e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= +Date: Tue, 30 Apr 2024 09:49:17 +0100 +Subject: [PATCH] nvmem: lpc18xx_eeprom: Convert to platform remove callback + returning void +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The .remove() callback for a platform driver returns an int which makes +many driver authors wrongly assume it's possible to do error handling by +returning an error code. However the value returned is ignored (apart +from emitting a warning) and this typically results in resource leaks. + +To improve here there is a quest to make the remove callback return +void. In the first step of this quest all drivers are converted to +.remove_new(), which already returns void. Eventually after all drivers +are converted, .remove_new() will be renamed to .remove(). + +Trivially convert this driver from always returning zero in the remove +callback to the void returning variant. + +Signed-off-by: Uwe Kleine-König +Acked-by: Vladimir Zapolskiy +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-8-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/lpc18xx_eeprom.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/drivers/nvmem/lpc18xx_eeprom.c ++++ b/drivers/nvmem/lpc18xx_eeprom.c +@@ -249,13 +249,11 @@ err_clk: + return ret; + } + +-static int lpc18xx_eeprom_remove(struct platform_device *pdev) ++static void lpc18xx_eeprom_remove(struct platform_device *pdev) + { + struct lpc18xx_eeprom_dev *eeprom = platform_get_drvdata(pdev); + + clk_disable_unprepare(eeprom->clk); +- +- return 0; + } + + static const struct of_device_id lpc18xx_eeprom_of_match[] = { +@@ -266,7 +264,7 @@ MODULE_DEVICE_TABLE(of, lpc18xx_eeprom_o + + static struct platform_driver lpc18xx_eeprom_driver = { + .probe = lpc18xx_eeprom_probe, +- .remove = lpc18xx_eeprom_remove, ++ .remove_new = lpc18xx_eeprom_remove, + .driver = { + .name = "lpc18xx-eeprom", + .of_match_table = lpc18xx_eeprom_of_match, diff --git a/target/linux/generic/backport-6.1/829-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch b/target/linux/generic/backport-6.1/829-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch new file mode 100644 index 0000000000..7770052d97 --- /dev/null +++ b/target/linux/generic/backport-6.1/829-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch @@ -0,0 +1,50 @@ +From 2a1ad6b75292d38aa2f6ded7335979e0632521da Mon Sep 17 00:00:00 2001 +From: Mukesh Ojha +Date: Tue, 30 Apr 2024 09:49:21 +0100 +Subject: [PATCH] nvmem: meson-mx-efuse: Remove nvmem_device from efuse struct + +nvmem_device is used at one place while registering nvmem +device and it is not required to be present in efuse struct +for just this purpose. + +Drop nvmem_device and manage with nvmem device stack variable. + +Signed-off-by: Mukesh Ojha +Reviewed-by: Martin Blumenstingl +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-12-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/meson-mx-efuse.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/nvmem/meson-mx-efuse.c ++++ b/drivers/nvmem/meson-mx-efuse.c +@@ -44,7 +44,6 @@ struct meson_mx_efuse_platform_data { + struct meson_mx_efuse { + void __iomem *base; + struct clk *core_clk; +- struct nvmem_device *nvmem; + struct nvmem_config config; + }; + +@@ -194,6 +193,7 @@ static int meson_mx_efuse_probe(struct p + { + const struct meson_mx_efuse_platform_data *drvdata; + struct meson_mx_efuse *efuse; ++ struct nvmem_device *nvmem; + + drvdata = of_device_get_match_data(&pdev->dev); + if (!drvdata) +@@ -224,9 +224,9 @@ static int meson_mx_efuse_probe(struct p + return PTR_ERR(efuse->core_clk); + } + +- efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); ++ nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); + +- return PTR_ERR_OR_ZERO(efuse->nvmem); ++ return PTR_ERR_OR_ZERO(nvmem); + } + + static struct platform_driver meson_mx_efuse_driver = { diff --git a/target/linux/generic/backport-6.6/821-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch b/target/linux/generic/backport-6.6/821-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch new file mode 100644 index 0000000000..418d2c82b2 --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0001-nvmem-layouts-store-owner-from-modules-with-nvmem_la.patch @@ -0,0 +1,61 @@ +From 6d0ca4a2a7e25f9ad07c1f335f20b4d9e048cdd5 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:11 +0100 +Subject: [PATCH] nvmem: layouts: store owner from modules with + nvmem_layout_driver_register() + +Modules registering driver with nvmem_layout_driver_register() might +forget to set .owner field. The field is used by some of other kernel +parts for reference counting (try_module_get()), so it is expected that +drivers will set it. + +Solve the problem by moving this task away from the drivers to the core +code, just like we did for platform_driver in +commit 9447057eaff8 ("platform_device: use a macro instead of +platform_driver_register"). + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Reviewed-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-2-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts.c | 6 ++++-- + include/linux/nvmem-provider.h | 5 ++++- + 2 files changed, 8 insertions(+), 3 deletions(-) + +--- a/drivers/nvmem/layouts.c ++++ b/drivers/nvmem/layouts.c +@@ -52,13 +52,15 @@ static const struct bus_type nvmem_layou + .remove = nvmem_layout_bus_remove, + }; + +-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv) ++int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv, ++ struct module *owner) + { + drv->driver.bus = &nvmem_layout_bus_type; ++ drv->driver.owner = owner; + + return driver_register(&drv->driver); + } +-EXPORT_SYMBOL_GPL(nvmem_layout_driver_register); ++EXPORT_SYMBOL_GPL(__nvmem_layout_driver_register); + + void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv) + { +--- a/include/linux/nvmem-provider.h ++++ b/include/linux/nvmem-provider.h +@@ -199,7 +199,10 @@ int nvmem_add_one_cell(struct nvmem_devi + int nvmem_layout_register(struct nvmem_layout *layout); + void nvmem_layout_unregister(struct nvmem_layout *layout); + +-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv); ++#define nvmem_layout_driver_register(drv) \ ++ __nvmem_layout_driver_register(drv, THIS_MODULE) ++int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv, ++ struct module *owner); + void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv); + #define module_nvmem_layout_driver(__nvmem_layout_driver) \ + module_driver(__nvmem_layout_driver, nvmem_layout_driver_register, \ diff --git a/target/linux/generic/backport-6.6/821-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch b/target/linux/generic/backport-6.6/821-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch new file mode 100644 index 0000000000..b483dd243b --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0002-nvmem-layouts-onie-tlv-drop-driver-owner-initializat.patch @@ -0,0 +1,28 @@ +From 21833338eccb91194fec6ba7548d9c454824eca0 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:12 +0100 +Subject: [PATCH] nvmem: layouts: onie-tlv: drop driver owner initialization + +Core in nvmem_layout_driver_register() already sets the .owner, so +driver does not need to. + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Acked-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-3-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts/onie-tlv.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/nvmem/layouts/onie-tlv.c ++++ b/drivers/nvmem/layouts/onie-tlv.c +@@ -247,7 +247,6 @@ MODULE_DEVICE_TABLE(of, onie_tlv_of_matc + + static struct nvmem_layout_driver onie_tlv_layout = { + .driver = { +- .owner = THIS_MODULE, + .name = "onie-tlv-layout", + .of_match_table = onie_tlv_of_match_table, + }, diff --git a/target/linux/generic/backport-6.6/821-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch b/target/linux/generic/backport-6.6/821-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch new file mode 100644 index 0000000000..472a65feca --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0003-nvmem-layouts-sl28vpd-drop-driver-owner-initializati.patch @@ -0,0 +1,28 @@ +From 23fd602f21953c03c0714257d36685cd6b486f04 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:13 +0100 +Subject: [PATCH] nvmem: layouts: sl28vpd: drop driver owner initialization + +Core in nvmem_layout_driver_register() already sets the .owner, so +driver does not need to. + +Signed-off-by: Krzysztof Kozlowski +Reviewed-by: Michael Walle +Reviewed-by: Miquel Raynal +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-4-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/layouts/sl28vpd.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/nvmem/layouts/sl28vpd.c ++++ b/drivers/nvmem/layouts/sl28vpd.c +@@ -156,7 +156,6 @@ MODULE_DEVICE_TABLE(of, sl28vpd_of_match + + static struct nvmem_layout_driver sl28vpd_layout = { + .driver = { +- .owner = THIS_MODULE, + .name = "kontron-sl28vpd-layout", + .of_match_table = sl28vpd_of_match_table, + }, diff --git a/target/linux/generic/backport-6.6/821-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch b/target/linux/generic/backport-6.6/821-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch new file mode 100644 index 0000000000..8f33f2ab61 --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0004-nvmem-sc27xx-fix-module-autoloading.patch @@ -0,0 +1,26 @@ +From dc3d88ade857ba3dca34f008e0b0aed3ef79cb15 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:14 +0100 +Subject: [PATCH] nvmem: sc27xx: fix module autoloading + +Add MODULE_DEVICE_TABLE(), so the module could be properly autoloaded +based on the alias from of_device_id table. + +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-5-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/sc27xx-efuse.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/nvmem/sc27xx-efuse.c ++++ b/drivers/nvmem/sc27xx-efuse.c +@@ -262,6 +262,7 @@ static const struct of_device_id sc27xx_ + { .compatible = "sprd,sc2730-efuse", .data = &sc2730_edata}, + { } + }; ++MODULE_DEVICE_TABLE(of, sc27xx_efuse_of_match); + + static struct platform_driver sc27xx_efuse_driver = { + .probe = sc27xx_efuse_probe, diff --git a/target/linux/generic/backport-6.6/821-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch b/target/linux/generic/backport-6.6/821-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch new file mode 100644 index 0000000000..0953c92340 --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0005-nvmem-sprd-fix-module-autoloading.patch @@ -0,0 +1,26 @@ +From 154c1ec943e34f3188c9305b0c91d5e7dc1373b8 Mon Sep 17 00:00:00 2001 +From: Krzysztof Kozlowski +Date: Tue, 30 Apr 2024 09:49:15 +0100 +Subject: [PATCH] nvmem: sprd: fix module autoloading + +Add MODULE_DEVICE_TABLE(), so the module could be properly autoloaded +based on the alias from of_device_id table. + +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-6-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/sprd-efuse.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/nvmem/sprd-efuse.c ++++ b/drivers/nvmem/sprd-efuse.c +@@ -426,6 +426,7 @@ static const struct of_device_id sprd_ef + { .compatible = "sprd,ums312-efuse", .data = &ums312_data }, + { } + }; ++MODULE_DEVICE_TABLE(of, sprd_efuse_of_match); + + static struct platform_driver sprd_efuse_driver = { + .probe = sprd_efuse_probe, diff --git a/target/linux/generic/backport-6.6/821-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch b/target/linux/generic/backport-6.6/821-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch new file mode 100644 index 0000000000..14baafc6b8 --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0006-nvmem-core-switch-to-use-device_add_groups.patch @@ -0,0 +1,32 @@ +From 8d8fc146dd7a0d6a6b37695747a524310dfb9d57 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Tue, 30 Apr 2024 09:49:16 +0100 +Subject: [PATCH] nvmem: core: switch to use device_add_groups() + +devm_device_add_groups() is being removed from the kernel, so move the +nvmem driver to use device_add_groups() instead. The logic is +identical, when the device is removed the driver core will properly +clean up and remove the groups, and the memory used by the attribute +groups will be freed because it was created with dev_* calls, so this is +functionally identical overall. + +Cc: Srinivas Kandagatla +Signed-off-by: Srinivas Kandagatla +Signed-off-by: Greg Kroah-Hartman +Link: https://lore.kernel.org/r/20240430084921.33387-7-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -476,7 +476,7 @@ static int nvmem_populate_sysfs_cells(st + + nvmem_cells_group.bin_attrs = cells_attrs; + +- ret = devm_device_add_groups(&nvmem->dev, nvmem_cells_groups); ++ ret = device_add_groups(&nvmem->dev, nvmem_cells_groups); + if (ret) + goto unlock_mutex; + diff --git a/target/linux/generic/backport-6.6/821-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch b/target/linux/generic/backport-6.6/821-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch new file mode 100644 index 0000000000..27d9270d31 --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0007-nvmem-lpc18xx_eeprom-Convert-to-platform-remove-call.patch @@ -0,0 +1,57 @@ +From 693d2f629962628ddefc88f4b6b453edda5ac32e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= +Date: Tue, 30 Apr 2024 09:49:17 +0100 +Subject: [PATCH] nvmem: lpc18xx_eeprom: Convert to platform remove callback + returning void +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The .remove() callback for a platform driver returns an int which makes +many driver authors wrongly assume it's possible to do error handling by +returning an error code. However the value returned is ignored (apart +from emitting a warning) and this typically results in resource leaks. + +To improve here there is a quest to make the remove callback return +void. In the first step of this quest all drivers are converted to +.remove_new(), which already returns void. Eventually after all drivers +are converted, .remove_new() will be renamed to .remove(). + +Trivially convert this driver from always returning zero in the remove +callback to the void returning variant. + +Signed-off-by: Uwe Kleine-König +Acked-by: Vladimir Zapolskiy +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-8-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/lpc18xx_eeprom.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/drivers/nvmem/lpc18xx_eeprom.c ++++ b/drivers/nvmem/lpc18xx_eeprom.c +@@ -249,13 +249,11 @@ err_clk: + return ret; + } + +-static int lpc18xx_eeprom_remove(struct platform_device *pdev) ++static void lpc18xx_eeprom_remove(struct platform_device *pdev) + { + struct lpc18xx_eeprom_dev *eeprom = platform_get_drvdata(pdev); + + clk_disable_unprepare(eeprom->clk); +- +- return 0; + } + + static const struct of_device_id lpc18xx_eeprom_of_match[] = { +@@ -266,7 +264,7 @@ MODULE_DEVICE_TABLE(of, lpc18xx_eeprom_o + + static struct platform_driver lpc18xx_eeprom_driver = { + .probe = lpc18xx_eeprom_probe, +- .remove = lpc18xx_eeprom_remove, ++ .remove_new = lpc18xx_eeprom_remove, + .driver = { + .name = "lpc18xx-eeprom", + .of_match_table = lpc18xx_eeprom_of_match, diff --git a/target/linux/generic/backport-6.6/821-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch b/target/linux/generic/backport-6.6/821-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch new file mode 100644 index 0000000000..0b56ccc785 --- /dev/null +++ b/target/linux/generic/backport-6.6/821-v6.10-0008-nvmem-meson-mx-efuse-Remove-nvmem_device-from-efuse-.patch @@ -0,0 +1,50 @@ +From 2a1ad6b75292d38aa2f6ded7335979e0632521da Mon Sep 17 00:00:00 2001 +From: Mukesh Ojha +Date: Tue, 30 Apr 2024 09:49:21 +0100 +Subject: [PATCH] nvmem: meson-mx-efuse: Remove nvmem_device from efuse struct + +nvmem_device is used at one place while registering nvmem +device and it is not required to be present in efuse struct +for just this purpose. + +Drop nvmem_device and manage with nvmem device stack variable. + +Signed-off-by: Mukesh Ojha +Reviewed-by: Martin Blumenstingl +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20240430084921.33387-12-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/nvmem/meson-mx-efuse.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/nvmem/meson-mx-efuse.c ++++ b/drivers/nvmem/meson-mx-efuse.c +@@ -43,7 +43,6 @@ struct meson_mx_efuse_platform_data { + struct meson_mx_efuse { + void __iomem *base; + struct clk *core_clk; +- struct nvmem_device *nvmem; + struct nvmem_config config; + }; + +@@ -193,6 +192,7 @@ static int meson_mx_efuse_probe(struct p + { + const struct meson_mx_efuse_platform_data *drvdata; + struct meson_mx_efuse *efuse; ++ struct nvmem_device *nvmem; + + drvdata = of_device_get_match_data(&pdev->dev); + if (!drvdata) +@@ -223,9 +223,9 @@ static int meson_mx_efuse_probe(struct p + return PTR_ERR(efuse->core_clk); + } + +- efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); ++ nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); + +- return PTR_ERR_OR_ZERO(efuse->nvmem); ++ return PTR_ERR_OR_ZERO(nvmem); + } + + static struct platform_driver meson_mx_efuse_driver = { diff --git a/target/linux/generic/pending-5.15/804-nvmem-core-support-mac-base-fixed-layout-cells.patch b/target/linux/generic/pending-5.15/804-nvmem-core-support-mac-base-fixed-layout-cells.patch index 8c5d3c266e..d6a471d576 100644 --- a/target/linux/generic/pending-5.15/804-nvmem-core-support-mac-base-fixed-layout-cells.patch +++ b/target/linux/generic/pending-5.15/804-nvmem-core-support-mac-base-fixed-layout-cells.patch @@ -33,7 +33,7 @@ string. #include #include #include -@@ -780,6 +783,62 @@ static int nvmem_validate_keepouts(struc +@@ -779,6 +782,62 @@ static int nvmem_validate_keepouts(struc return 0; } @@ -96,7 +96,7 @@ string. static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) { struct device *dev = &nvmem->dev; -@@ -819,6 +878,25 @@ static int nvmem_add_cells_from_dt(struc +@@ -818,6 +877,25 @@ static int nvmem_add_cells_from_dt(struc if (nvmem->fixup_dt_cell_info) nvmem->fixup_dt_cell_info(nvmem, &info); -- 2.30.2