diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2021-12-10 15:49:29 +0900 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2021-12-18 12:05:19 +0100 |
commit | 19b241c61faaa18c777e684ca5c43ad461af0afd (patch) | |
tree | 08d9efeb39f4beae613510fbf8011d82337b922e | |
parent | 5d21dfec4ac92f8b38130660ed9c4d22712ecab5 (diff) | |
download | u-boot-19b241c61faaa18c777e684ca5c43ad461af0afd.zip u-boot-19b241c61faaa18c777e684ca5c43ad461af0afd.tar.gz u-boot-19b241c61faaa18c777e684ca5c43ad461af0afd.tar.bz2 |
blk: add a helper function, blk_probe_or_unbind()
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>
-rw-r--r-- | drivers/block/blk-uclass.c | 13 | ||||
-rw-r--r-- | include/blk.h | 12 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 4ae8af6..a055387 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -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; diff --git a/include/blk.h b/include/blk.h index dde2173..133204a 100644 --- a/include/blk.h +++ b/include/blk.h @@ -371,6 +371,18 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name, 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 * * The devices are removed and then unbound. |