From patchwork Fri Dec 10 06:49:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1566195 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=uaT2V/ov; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J9M453z2kz9sR4 for ; Fri, 10 Dec 2021 17:50:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66BE383112; Fri, 10 Dec 2021 07:50:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uaT2V/ov"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4300882F96; Fri, 10 Dec 2021 07:50:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 20F0E82D5B for ; Fri, 10 Dec 2021 07:50:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x534.google.com with SMTP id g16so7283641pgi.1 for ; Thu, 09 Dec 2021 22:50:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aDXZpBFciB1TCl85HxxTr1gYe7xaD2d3VLbPxF/8dMY=; b=uaT2V/ove3v2aRGjLxU4GC3LvcSwcdo5uksCyf/a7Yz7FZKz+Sh0xluXPYT59b8nY1 rP4ntEUcB5hRHSCOUCWAMquTikaUEnZ332wB2q9EY15dIih8YxPdFh9/DmX6Y329NTEp VusaIQykmxe+m/nVHODsI/K3UnWOFvHkQZMDwmEy3ZPzFULtaaJlOEPJthU4M/gk0Lpd DZVcVsUynbnXzikH6QNEvwqOSkxOKS+L+mALw3wmMII72MOAWy0jsYcGqPT/LB8ZFLiz LnzbP6R1fWr436f1SDdSPQGo48IjRba09yxPj8Ii9sbpEQ1jblf7OqkbSeXmJ4r/Xw0p ezwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aDXZpBFciB1TCl85HxxTr1gYe7xaD2d3VLbPxF/8dMY=; b=LTWZynDwFZESURa8vnD9AdpeGN5q2AzACkGUhv6sA/G/mJIAFP5U1NklF9smpbF6Eh vbVAKP5xyKCm2e4W3QriaeUgwd8FHBiN9hyvJ7/WKINMu1Vn+Ei2ikkmGv3dPrED4a4D NDi8iU4Y/9607g1nwEsaC5pUjECBjGXdntjXfSCW2BdPviAYIt4e5+AEutwEl77fHZdL +O1FH9ciTFlxYh9sSCZRjQ7hlzq/gzySm9c14bNPT0rcrQDAUVHoiYNqEZW5tQZ6Cs4B d9UmnFc92juC7iazHSTaJxZeX7GzKDHHe+NRDZMlzP7E87dlX2L5/uFDdQ3Q7GEU3Jsp TEBw== X-Gm-Message-State: AOAM5302tC2YpEIMDhMG2qW1+MT/TjsIwjdchPINMzin8kUzNt/zlvE7 ydB1KiHumx+0itXb1NA2SLdxXw== X-Google-Smtp-Source: ABdhPJzhPVHZ6Dz/Mq3z8wX6mxORO750p8DeX/vVVWp0g3e0fWbsdOckI9qRrR2NMgX2o966uc/wuA== X-Received: by 2002:a05:6a00:2af:b0:49f:c4b0:879b with SMTP id q15-20020a056a0002af00b0049fc4b0879bmr16252481pfs.55.1639119024547; Thu, 09 Dec 2021 22:50:24 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:24 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 02/20] blk: add a helper function, blk_probe_or_unbind() Date: Fri, 10 Dec 2021 15:49:29 +0900 Message-Id: <20211210064947.73361-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This function will be commonly used in block device drivers in the succeeding patches. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- drivers/block/blk-uclass.c | 13 +++++++++++++ include/blk.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 83682dcc181a..f7ad90e8890f 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -670,6 +670,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) { + 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 f0cc7ca1a28c..ef79e7b27b0a 100644 --- a/include/blk.h +++ b/include/blk.h @@ -369,6 +369,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 enumelating 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 *