]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
drivers/mtd/nvmxip: Trigger post bind as probe on driver level
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Wed, 23 Aug 2023 00:18:17 +0000 (02:18 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 30 Aug 2023 21:56:21 +0000 (17:56 -0400)
Perform all the block device creation only once, after the driver itself
successfully bound. Do not do this in uclass post bind, as this might be
triggered multiple times. For example the ut_dm_host test triggers this
and triggers a memory leak that way, since there are now multiple block
devices created using the blk_create_devicef() .

To retain the old probe-on-boot behavior, set DM_FLAG_PROBE_AFTER_BIND
flag in uclass post_bind callback, so the driver model would probe the
driver at the right time.

Rename the function as well, to match similar functions in
other block-related subsystems, like the mmc one.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
drivers/mtd/nvmxip/nvmxip-uclass.c
drivers/mtd/nvmxip/nvmxip_qspi.c
include/nvmxip.h

index 6d8eb177b500c63a47e12f2b7302443caea5271b..36eb056c213e1c3bf3672a926bf0a445efc7ef18 100644 (file)
 
 #define DEFAULT_LBA_SZ BIT(DEFAULT_LBA_SHIFT)
 
-/**
- * nvmxip_post_bind() - post binding treatments
- * @dev:       the NVMXIP device
- *
- * Create and probe a child block device.
- *
- * Return:
- *
- * 0 on success. Otherwise, failure
- */
-static int nvmxip_post_bind(struct udevice *udev)
+int nvmxip_probe(struct udevice *udev)
 {
        int ret;
        struct udevice *bdev = NULL;
@@ -67,6 +57,12 @@ static int nvmxip_post_bind(struct udevice *udev)
        return 0;
 }
 
+static int nvmxip_post_bind(struct udevice *udev)
+{
+       dev_or_flags(udev, DM_FLAG_PROBE_AFTER_BIND);
+       return 0;
+}
+
 UCLASS_DRIVER(nvmxip) = {
        .name      = "nvmxip",
        .id        = UCLASS_NVMXIP,
index 7221fd1cb46dcc819c0cfd0e3e9b33a9fb07a848..1bf0d311fe36c76242032d1670d8f25594cbcb95 100644 (file)
@@ -66,5 +66,6 @@ U_BOOT_DRIVER(nvmxip_qspi) = {
        .id = UCLASS_NVMXIP,
        .of_match = nvmxip_qspi_ids,
        .of_to_plat = nvmxip_qspi_of_to_plat,
+       .probe = nvmxip_probe,
        .plat_auto = sizeof(struct nvmxip_plat),
 };
index f4ef37725d2ad60c6a0aeac4961ffdde667396d3..726fffeb3e8e118769cd05d5dc687191077916bc 100644 (file)
@@ -29,4 +29,16 @@ struct nvmxip_plat {
        lbaint_t lba;
 };
 
+/**
+ * nvmxip_bind() - post binding treatments
+ * @dev:       the NVMXIP device
+ *
+ * Create and probe a child block device.
+ *
+ * Return:
+ *
+ * 0 on success. Otherwise, failure
+ */
+int nvmxip_probe(struct udevice *udev);
+
 #endif /* __DRIVER_NVMXIP_H__ */