mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2024-06-17 12:43:56 +02:00
![Rui Salvaterra](/assets/img/avatar_default.png)
Automatically refreshed: ath79/patches-5.10/0032-MIPS-ath79-sanitize-symbols.patch bcm63xx/patches-5.10/322-MIPS-BCM63XX-switch-to-IRQ_DOMAIN.patch bcm63xx/patches-5.10/434-nand-brcmnand-fix-OOB-R-W-with-Hamming-ECC.patch bmips/patches-5.10/001-v5.11-mips-bmips-select-ARCH_HAS_RESET_CONTROLLER.patch bmips/patches-5.10/041-v5.13-mtd-rawnand-brcmnand-fix-OOB-R-W-with-Hamming-ECC.patch bmips/patches-5.10/202-mips-bmips-disable-ARCH_HAS_SYNC_DMA_FOR_CPU_ALL.patch bmips/patches-5.10/600-mips-bmips-add-pci-support.patch generic/backport-5.10/103-v5.13-MIPS-select-CPU_MIPS64-for-remaining-MIPS64-CPUs.patch generic/hack-5.10/301-mips_image_cmdline_hack.patch generic/hack-5.10/402-mtd-blktrans-call-add-disks-after-mtd-device.patch generic/hack-5.10/902-debloat_proc.patch generic/pending-5.10/300-mips_expose_boot_raw.patch generic/pending-5.10/495-mtd-core-add-get_mtd_device_by_node.patch generic/pending-5.10/630-packet_socket_type.patch ipq806x/patches-5.10/0072-add-ipq806x-with-no-clocks.patch ipq806x/patches-5.10/099-1-mtd-nand-raw-qcom_nandc-add-boot_layout_mode-support.patch lantiq/patches-5.10/0001-MIPS-lantiq-add-pcie-driver.patch lantiq/patches-5.10/0023-NET-PHY-add-led-support-for-intel-xway.patch lantiq/patches-5.10/0152-lantiq-VPE.patch Deleted (reverse-appliable): bmips/patches-5.10/052-v5.13-gpio-guard-gpiochip_irqchip_add_domain-with-GPIOLIB_.patch generic/backport-5.10/499-v5.13-mtd-don-t-lock-when-recursively-deleting-partitions.patch Deleted (alternative upstream fix): ramips/patches-5.10/330-fix-pci-init-mt7620.patch Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
76 lines
2.2 KiB
Diff
76 lines
2.2 KiB
Diff
From 1bd1b740f208d1cf4071932cc51860d37266c402 Mon Sep 17 00:00:00 2001
|
|
From: Bernhard Frauendienst <kernel@nospam.obeliks.de>
|
|
Date: Sat, 1 Sep 2018 00:30:11 +0200
|
|
Subject: [PATCH 495/497] mtd: core: add get_mtd_device_by_node
|
|
|
|
Add function to retrieve a mtd device by its OF node. Since drivers can
|
|
assign arbitrary names to mtd devices in the absence of a label
|
|
property, there is no other reliable way to retrieve a mtd device for a
|
|
given OF node.
|
|
|
|
Signed-off-by: Bernhard Frauendienst <kernel@nospam.obeliks.de>
|
|
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
|
---
|
|
drivers/mtd/mtdcore.c | 38 ++++++++++++++++++++++++++++++++++++++
|
|
include/linux/mtd/mtd.h | 2 ++
|
|
2 files changed, 40 insertions(+)
|
|
|
|
--- a/drivers/mtd/mtdcore.c
|
|
+++ b/drivers/mtd/mtdcore.c
|
|
@@ -1046,6 +1046,44 @@ out_unlock:
|
|
}
|
|
EXPORT_SYMBOL_GPL(get_mtd_device_nm);
|
|
|
|
+/**
|
|
+ * get_mtd_device_by_node - obtain a validated handle for an MTD device
|
|
+ * by of_node
|
|
+ * @of_node: OF node of MTD device to open
|
|
+ *
|
|
+ * This function returns MTD device description structure in case of
|
|
+ * success and an error code in case of failure.
|
|
+ */
|
|
+struct mtd_info *get_mtd_device_by_node(const struct device_node *of_node)
|
|
+{
|
|
+ int err = -ENODEV;
|
|
+ struct mtd_info *mtd = NULL, *other;
|
|
+
|
|
+ mutex_lock(&mtd_table_mutex);
|
|
+
|
|
+ mtd_for_each_device(other) {
|
|
+ if (of_node == other->dev.of_node) {
|
|
+ mtd = other;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!mtd)
|
|
+ goto out_unlock;
|
|
+
|
|
+ err = __get_mtd_device(mtd);
|
|
+ if (err)
|
|
+ goto out_unlock;
|
|
+
|
|
+ mutex_unlock(&mtd_table_mutex);
|
|
+ return mtd;
|
|
+
|
|
+out_unlock:
|
|
+ mutex_unlock(&mtd_table_mutex);
|
|
+ return ERR_PTR(err);
|
|
+}
|
|
+EXPORT_SYMBOL_GPL(get_mtd_device_by_node);
|
|
+
|
|
void put_mtd_device(struct mtd_info *mtd)
|
|
{
|
|
mutex_lock(&mtd_table_mutex);
|
|
--- a/include/linux/mtd/mtd.h
|
|
+++ b/include/linux/mtd/mtd.h
|
|
@@ -696,6 +696,8 @@ extern struct mtd_info *get_mtd_device(s
|
|
extern int __get_mtd_device(struct mtd_info *mtd);
|
|
extern void __put_mtd_device(struct mtd_info *mtd);
|
|
extern struct mtd_info *get_mtd_device_nm(const char *name);
|
|
+extern struct mtd_info *get_mtd_device_by_node(
|
|
+ const struct device_node *of_node);
|
|
extern void put_mtd_device(struct mtd_info *mtd);
|
|
|
|
static inline uint64_t mtdpart_get_offset(const struct mtd_info *mtd)
|