]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
blk: add a helper function, blk_probe_or_unbind()
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Fri, 10 Dec 2021 06:49:29 +0000 (15:49 +0900)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 18 Dec 2021 11:05:19 +0000 (12:05 +0100)
This function will be commonly used in block device drivers
in the succeeding patches.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
drivers/block/blk-uclass.c
include/blk.h

index 4ae8af6d609ac9c3dc8ed8c1185e9ed134591f1f..a055387570a76427636d8c34b5a70fa625515235 100644 (file)
@@ -672,6 +672,19 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name,
        return 0;
 }
 
+int blk_probe_or_unbind(struct udevice *dev)
+{
+       int ret;
+
+       ret = device_probe(dev);
+       if (ret) {
+               log_debug("probing %s failed\n", dev->name);
+               device_unbind(dev);
+       }
+
+       return ret;
+}
+
 int blk_unbind_all(int if_type)
 {
        struct uclass *uc;
index dde2173257242f46bce15de0cbff697fb0a9b575..133204a82e11c1542dfcc55ff40d85f93927a826 100644 (file)
@@ -370,6 +370,18 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name,
                       const char *name, int if_type, int devnum, int blksz,
                       lbaint_t lba, struct udevice **devp);
 
+/**
+ * blk_probe_or_unbind() - Try to probe
+ *
+ * Try to probe the device, primarily for enumerating partitions.
+ * If it fails, the device itself is unbound since it means that it won't
+ * work any more.
+ *
+ * @dev:       The device to probe
+ * Return:     0 if OK, -ve on error
+ */
+int blk_probe_or_unbind(struct udevice *dev);
+
 /**
  * blk_unbind_all() - Unbind all device of the given interface type
  *