From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BB1CC433F5 for ; Mon, 13 Dec 2021 12:52:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0081583767; Mon, 13 Dec 2021 13:51:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="nfx5XCxr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C89F483767; Mon, 13 Dec 2021 13:51:57 +0100 (CET) Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) (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 0C73982F5E for ; Mon, 13 Dec 2021 13:51:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-vk1-xa2c.google.com with SMTP id m16so10154785vkl.13 for ; Mon, 13 Dec 2021 04:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ew4VzWzUc0Tty/UCuZPb5iebvRAh4PmQenqNtqWzT90=; b=nfx5XCxrO+mxAO+Z7NKN9Uaij/49iIBgU3ewOnVZOLr05d3dOrHYosCkgIH56vk39+ tZ7glm0Ckucf3FQ9L/uNYVtr4/xTkHxVDQOtDKAUirOCR6fwoBUxflCjQ3PPBYZisWHw jUqO+1qGXusyR1snvMhdQFO7U/Z0G6bJMvt1Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ew4VzWzUc0Tty/UCuZPb5iebvRAh4PmQenqNtqWzT90=; b=VBC4i83mnyvpB/w78/F8+glVX4KLSgNs4XqDrQuEwgX9DW7PnNy6vNBr2Pdq9JJP7o ny05LLfzedmAdXIbSid/Dx6N5Kqi1t8vfHDwXyZ6BM5t0/86NpPt02mznillP5G+cgGP re0sMLK5OHntrPLgFc06uVbZnH9kUs7oTi5scG3t4WAPrBpRHVDZCSJm0Im5mFJdfz+X HrYJPYYFlr/GNe+cTiA5UQbUrnq7OjhXlkGWvXJfZnmGEJRmvcQEDFWmqceSZD4pZGPD LoTlJEhQasq66Jcx3dWOMO6vU30Gdh2qLvmTSOq1GxkSgXgdVm8l62AL6CgMuSsrvcl3 yaqA== X-Gm-Message-State: AOAM533rWRcdyNPwdnJZsLzyRCP/kWzfH5KmQqcPOP5zOkN2qBbStrP+ fONrtswhgSBVLkEmxDo+lnD/+uGdGfmKRrYhWoxc0w== X-Google-Smtp-Source: ABdhPJz6uivzHnae7PCNasL1Xuus6nFsPq4wIUHP4muIIZdTx1QLygu/oNxYyiNXhrMBJnZ0pfmHwm9YWbrGmC3Ij1w= X-Received: by 2002:a05:6122:64b:: with SMTP id h11mr30714914vkp.16.1639399912256; Mon, 13 Dec 2021 04:51:52 -0800 (PST) MIME-Version: 1.0 References: <20211210064947.73361-1-takahiro.akashi@linaro.org> <20211210064947.73361-3-takahiro.akashi@linaro.org> In-Reply-To: <20211210064947.73361-3-takahiro.akashi@linaro.org> From: Simon Glass Date: Mon, 13 Dec 2021 05:51:40 -0700 Message-ID: Subject: Re: [RFC v2 02/20] blk: add a helper function, blk_probe_or_unbind() To: AKASHI Takahiro Cc: xypron.glpk@gmx.de, agraf@csgraf.de, ilias.apalodimas@linaro.org, masami.hiramatsu@linaro.org, u-boot@lists.denx.de Content-Type: text/plain; charset="UTF-8" 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 Hi Takahiro, On Thu, 9 Dec 2021 at 23:59, AKASHI Takahiro wrote: > > This function will be commonly used in block device drivers > in the succeeding patches. > > Signed-off-by: AKASHI Takahiro > --- > drivers/block/blk-uclass.c | 13 +++++++++++++ > include/blk.h | 12 ++++++++++++ > 2 files changed, 25 insertions(+) Reviewed-by: Simon Glass But please add a test for this. > > 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. enumerating > + * 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 > * > -- > 2.33.0 >