From patchwork Sun Jan 24 21:32:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1431021 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dobFb532; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 ozlabs.org (Postfix) with ESMTPS id 4DP5q53KSJz9sRR for ; Mon, 25 Jan 2021 08:34:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3226382713; Sun, 24 Jan 2021 22:33:22 +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="dobFb532"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3D3A7826A4; Sun, 24 Jan 2021 22:33:12 +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.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 4213D826C8 for ; Sun, 24 Jan 2021 22:33:08 +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@chromium.org Received: by mail-pl1-x632.google.com with SMTP id e9so6392572plh.3 for ; Sun, 24 Jan 2021 13:33:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j+1b//vgL6YsxjBAPEnHCfqQM8liBi7l9eImZrhJak4=; b=dobFb532IyB0RDk6f5Vb8ISw4iRzjhm5Ye2/OskUr0X/BpxnaMpr2OFD8uqZArkaLz F8KWuA5MgTDCU5sTZ9OTYahEA9zeeHizDTefVQMVZFdpLTauK+Su2WUHj/DAuTxKqDPf BZ05OLMjEBmZHFBZK6sn8TrzjIGzLe4nVnM9o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j+1b//vgL6YsxjBAPEnHCfqQM8liBi7l9eImZrhJak4=; b=UBgI+AuuNhxa1uTjFQABL8Xo3X8DzHk8z6a4OISn7zXGksgXRGd2R1hY3ciB+cZ72Q ZSNxGk9Q8VMiG0982MxoL4Q3bGgNe8CFIVIwEW8SE5ohjjcFMVTpIpMul4BNJWfbn+Xm IMjmO6+igUrNKw7ODB6qWhWKyx4rqQIgpHqpQp8NVpedJLIImD54ca865nK5mNivEgAk lDFmEHZ3ET2CIxkaVOkkVwB0hbaNnTYY2VSPeSEQG+6NnalK+e8fEXdzE53aVaruhyCR oFCk3Fr22cGZranawxthrzSd4weQZyC5gg2bgEv5U08tmzva78Ya6GP0/ESNaCyWrSmS Jx9g== X-Gm-Message-State: AOAM531PsvQgA8Qe5ZBcBht5QG0ES0byVos2C+0WbBHuKhZvoQ8T9C8f 7EQ2sU6Y7T899fHC8nJKkddICZRS4Mo3IQIH X-Google-Smtp-Source: ABdhPJzn2VgVRrwRKwEMXbXlwaIIUDgWJrUZ0qdcO5ERWflw00BxzKwlsGObmfD/C5FhxIgpvjiTmw== X-Received: by 2002:a17:90a:f181:: with SMTP id bv1mr4070212pjb.57.1611523986522; Sun, 24 Jan 2021 13:33:06 -0800 (PST) Received: from sjg1.home ([2600:6c4c:507f:f8e5:0:ec6e:a61e:6ad]) by smtp.gmail.com with ESMTPSA id b203sm14589003pfb.11.2021.01.24.13.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 13:33:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Marek Vasut , Stefan Roese , Tom Rini , Simon Glass , Pavel Herrmann Subject: [PATCH v5 5/9] dm: core: Remove children before advising uclass Date: Sun, 24 Jan 2021 14:32:44 -0700 Message-Id: <20210124213248.3715556-6-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210124213248.3715556-1-sjg@chromium.org> References: <20210124213248.3715556-1-sjg@chromium.org> MIME-Version: 1.0 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present the uclass pre-remove method is called before the children are removed. But the children may refused to be removed, in whch case the uclass is in a tricky situation. At present we handle this by calling the uclass' post_probe() method. But it seems better to avoid doing anything with the uclass in this case. Switch the ordering so that we make sure the children can be removed before advising the uclass. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/device-remove.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c index 7874d53c843..35b625e7b1f 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -172,13 +172,13 @@ int device_remove(struct udevice *dev, uint flags) drv = dev->driver; assert(drv); - ret = uclass_pre_remove_device(dev); + ret = device_chld_remove(dev, NULL, flags); if (ret) return ret; - ret = device_chld_remove(dev, NULL, flags); + ret = uclass_pre_remove_device(dev); if (ret) - goto err; + return ret; /* * Remove the device if called with the "normal" remove flag set, @@ -216,12 +216,6 @@ err_remove: /* We can't put the children back */ dm_warn("%s: Device '%s' failed to remove, but children are gone\n", __func__, dev->name); -err: - ret = uclass_post_probe_device(dev); - if (ret) { - dm_warn("%s: Device '%s' failed to post_probe on error path\n", - __func__, dev->name); - } return ret; }