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: 522725 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2168580imb; Thu, 9 Dec 2021 22:50:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeNn4Lqek+ZGk2bNwl0p0b0nVha8++p+WjTrUkaf4W7Dv/r2kFCNTMa48mMO28i8WuDf/k X-Received: by 2002:a17:907:72c7:: with SMTP id du7mr22146130ejc.424.1639119043148; Thu, 09 Dec 2021 22:50:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119043; cv=none; d=google.com; s=arc-20160816; b=wL4Qo5f3Y45KdUndNDo1R4G1YgGswhtDjenjP6rLofGGYFEJVL9GMPTfc2N2oa7FSL B4GHcEG1g2zDXLM7hAYr/NA6ydopwZEnAWdJD6zzc81fb4OfL1JhS8AdpUVxFCtJD4qQ P2aOQRgv4J9zSuhYAhCUjUZ69z9GFXQ9MwOcGyWwjaqrgWUPbZabs3xN4XBAEtZgrBTv 0KKRTm0VBE+00EzDv2sKT+YYF0gfGwZBXAT13OT/2rJqhxmZNJ8hjejZFsP5pHv9PV6H k2TEFZ+DKKDiuEK+k9Zu8lqJwCxI5b4PySAm4KbTlIH4bIfShiUvOHHcHlqfnnzxpSuG NFeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aDXZpBFciB1TCl85HxxTr1gYe7xaD2d3VLbPxF/8dMY=; b=bvBhCkkQNOsY5vNPHUbV4TyZkOJGxf9o809n2YtBwVI5p4DZPGCHGSX2V8cwak0RJL TwsNgXpDqwfvOI23GlFF6gFVub1uMSuSBHksIlOc5E6DjGAy7yIwPl2nUtb7EqjcC4YG TdkMOQDqPnSFPeSFZkxn/Qcl5vmoAts8HBEWKgL0athy7R3reHGB+VJ4cgNwNReOYNts XFvgUuWHi/7G7WF1ZsDm/+8xUbjPOKALqKnfgbJ8ZHlO8rN7c2/02Z28jqpWI/KmcQSu c6q1n5o8c9fSKYmCwCy8cVw6aYPEVltEFQte5cdCHZ2NB4VvnAcks+STD3KfDyklWFZc g+0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uaT2V/ov"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id q20si2941421edi.135.2021.12.09.22.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:43 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uaT2V/ov"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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 *