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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6367C433F5 for ; Mon, 11 Oct 2021 14:55:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 08B9560BD3 for ; Mon, 11 Oct 2021 14:55:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 08B9560BD3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7359283710; Mon, 11 Oct 2021 16:55:38 +0200 (CEST) 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="Y7UGz3CW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 29A7A836F4; Mon, 11 Oct 2021 16:54:42 +0200 (CEST) Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) (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 477EB836F3 for ; Mon, 11 Oct 2021 16:54:28 +0200 (CEST) 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-oi1-x234.google.com with SMTP id a3so24990563oid.6 for ; Mon, 11 Oct 2021 07:54:28 -0700 (PDT) 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; bh=a0MX1Bu1mu5x5dAv1qNIjgEYOTp8v9yV4rQgQTmYeT0=; b=Y7UGz3CW2zU/QNzsBZvIytFaqqp0OCG9Wcxsqp+bYg/mprDpIXElS5IidDcfqebY2C NvVR7sF1Jyg80jom55mss3oq88xX6QeCgfgFBl8SqRXibw7DMbj57Zwk9xAK15HtyY3U bd1rB8WdXn08kK3W641EVBNtuTE7GLiAETeEM= 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; bh=a0MX1Bu1mu5x5dAv1qNIjgEYOTp8v9yV4rQgQTmYeT0=; b=Odz5LuXaU49BRYAg/pHQlFUEp4KZp/nZBsblhsceUXa4BDDQIw9zwgS2Xasu0kabVr JUXL+wCQeQoH0sHPgWs/ZnYDUdlzIorFMa/dKk/bDDiVMGf+klRcCBRb7sf3SUFvZljp 9vEW6kU//RiTMnv6SS+wIL8DXpL1avF0dJRrd71ZQan3YuMRFtGJmI/RoD1g1gHieQxE g4Ls90/Bj7VXSxmV0n4Kfhvh3OPtuGFzNVva2uYUZsvd6NUNn8ILJjPFSC06DmgEERTP gLcaUXbcYNobEJdGHav9UNKeoSl5vWnOlgQatBWyx1T4VBITNGdfLQjzFpRoLz+L9QgK z0/w== X-Gm-Message-State: AOAM5314YCXkXgDsJL03J15C9HO6ScYa69prGgezuFan+LQHt721ac1a 6eUngxhmb/exinNIE2suGGoMpQvUfm4TfZvGUBRbeA== X-Google-Smtp-Source: ABdhPJyEch3khR/st+GN8jNS0h5g3DCwazCvsoKfSLu1PqiO9PN6A3yz8yFQb7NkF7KUWru4oeDwoXConahwFGR70C8= X-Received: by 2002:aca:ab15:: with SMTP id u21mr2530734oie.53.1633964066546; Mon, 11 Oct 2021 07:54:26 -0700 (PDT) MIME-Version: 1.0 References: <20211001050228.55183-1-takahiro.akashi@linaro.org> <20211001050228.55183-14-takahiro.akashi@linaro.org> <20211011014327.GD44356@laputa> In-Reply-To: <20211011014327.GD44356@laputa> From: Simon Glass Date: Mon, 11 Oct 2021 08:54:13 -0600 Message-ID: Subject: Re: [RFC 07/22] block: ide: call device_probe() after scanning To: AKASHI Takahiro , Simon Glass , Heinrich Schuchardt , Alex Graf , Ilias Apalodimas , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 Sun, 10 Oct 2021 at 19:43, AKASHI Takahiro wrote: > > On Sun, Oct 10, 2021 at 08:14:13AM -0600, Simon Glass wrote: > > On Thu, 30 Sept 2021 at 23:03, AKASHI Takahiro > > wrote: > > > > > > Every time an ide bus/port is scanned and a new device is detected, > > > we want to call device_probe() as it will give us a chance to run additional > > > post-processings for some purposes. > > > > > > In particular, support for creating partitions on a device will be added. > > > > > > Signed-off-by: AKASHI Takahiro > > > --- > > > drivers/block/ide.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > > Reviewed-by: Simon Glass > > > > I'm starting to wonder if you can create a function that does the > > probe and unbind? Something in the blk interface, perhaps? It would > > reduce the duplicated code and provide a standard way of bringing up a > > new device. > > That is exactly what Ilias suggested but I'm a bit declined to do :) > > Common 'scanning' code looks like: > blk_create_devicef(... , &dev); > desc = dev_get_uclass_data(dev); > initialize some members in desc as well as device-specific info --- (A) > (now dev can be accessible.) > ret = device_probe(dev); > if (ret) { > de-initialize *dev* --- (B) > device_unbind() > } > > Basically (B) is supposed to undo (A) which may or may not exist, > depending on types of block devices. > > So I'm not 100% sure that a combination of device_probe() and device_unbind() > will fit to all the device types. > (The only cases that I have noticed are fsl_sata.c and sata_sil.c. Both > have their own xxx_unbind_device(), but they simply call device_remove() and > device_unbind(), though. So no worry?) Yes I agree it would be a very strange function. But at least it would have the benefit of grouping the code together under a particular name, something like blk_back_out_bind(), but that's not a good name....it just feels like this might get refactored in the future and having the code in one place might be handy. Regards, Simon