From patchwork Mon Nov 30 01:54:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1407948 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; dmarc=pass (p=none dis=none) header.from=chromium.org 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=FvsYsDEW; 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 4CkpLx0gy1z9sTc for ; Mon, 30 Nov 2020 12:59:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0F5E3827DD; Mon, 30 Nov 2020 02:57:38 +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="FvsYsDEW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0EAA282633; Mon, 30 Nov 2020 02:55:38 +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=-3.5 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-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 3E17B827C6 for ; Mon, 30 Nov 2020 02:55:03 +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-io1-xd43.google.com with SMTP id d8so9025161ioc.13 for ; Sun, 29 Nov 2020 17:55:03 -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=YKLdQ+bd1wImOmLBrzzTeas7QR8+nywd0rLSMzrDEY8=; b=FvsYsDEWdDbA1IA0flNuj2Rb9WZ9szUZhwc1+imVQbzGhDgrIFQ5IDYV2NLWBga+cZ dNZyHv5P9Ujj/s12ekYRcJkhFo7j6abTaic832FE/kYpNy3YKKO22cqu9fo81Gz0JE6n tgdUHmwHehjXSZjwSmoIwm5+xdoSnwAbI+oGo= 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=YKLdQ+bd1wImOmLBrzzTeas7QR8+nywd0rLSMzrDEY8=; b=McjQ1w/aWFg0URazP94UhbF/+x3SnkWcu2CLSwyv32K8N4+NrwMvQYo9zExMIAeIT+ d/cwT7vayKpzE7ZzeUZLjMz55aQ7zelkwylEhxjfGPORIQlsF6pOGzGKQuC2SFfjvfpf PKviCCL6R1rJUqaLGhuhM+rQv/CkDOIQSo9m4U/PFMX33K1TRmEw/WwlqwXjKJEBBTH9 +2BxEzWEeV7x8EPdEQmkwx9XJX6WAiyuPxt5/jdj2za76oREajW42qHqH6GIO+SPc0Gp 0CnJWLpck1t0BS1T8VCKZ54z6RfXAwvmOEjj/tpcCNcppXH+5/9FYPe020AQFgxgoUER xY8A== X-Gm-Message-State: AOAM532AGWCmQnZpNJEPQmfi2AFHtp6CncmMYKT8+X7s27REFhqnJbUS 0mA5Eg3JrFE0Wrd454EdSxrJIByTcmPkeA== X-Google-Smtp-Source: ABdhPJxcm87huTVkk2WZMvEM+SFfgtt+mr2SNvFWTqi7pp+HNcUQF5U3QSnNSb2t/L7UMHTAwy/ZFw== X-Received: by 2002:a6b:6b0f:: with SMTP id g15mr7518068ioc.68.1606701301737; Sun, 29 Nov 2020 17:55:01 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q5sm6543341ilg.62.2020.11.29.17.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:55:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 26/27] dm: core: Drop seq and req_seq Date: Sun, 29 Nov 2020 18:54:01 -0700 Message-Id: <20201130015402.2328621-25-sjg@chromium.org> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog In-Reply-To: <20201130015402.2328621-1-sjg@chromium.org> References: <20201130015402.2328621-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 Now that migration to the new sequence numbers is complete, drop the old fields. Add a test that covers the new behaviour. Also drop the check for OF_PRIOR_STAGE since we always assign sequence numbers now. Signed-off-by: Simon Glass --- drivers/core/device-remove.c | 1 - drivers/core/device.c | 18 +++--------------- include/dm/device.h | 9 +-------- test/dm/test-fdt.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c index efdb0f29058..114bb1bcea8 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -207,7 +207,6 @@ int device_remove(struct udevice *dev, uint flags) if (flags_remove(flags, drv->flags)) { device_free(dev); - dev->seq = -1; dev->flags &= ~DM_FLAG_ACTIVATED; } diff --git a/drivers/core/device.c b/drivers/core/device.c index d9648f9394e..bcf437ac231 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -72,34 +72,23 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, dev->driver = drv; dev->uclass = uc; - dev->seq = -1; - dev->req_seq = -1; dev->sqq = -1; if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) && (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) { /* * Some devices, such as a SPI bus, I2C bus and serial ports * are numbered using aliases. - * - * This is just a 'requested' sequence, and will be - * resolved (and ->seq updated) when the device is probed. */ if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { if (uc->uc_drv->name && ofnode_valid(node)) { - dev_read_alias_seq(dev, &dev->sqq); - dev_read_alias_seq(dev, &dev->req_seq); - } - if (CONFIG_IS_ENABLED(OF_PRIOR_STAGE)) { - if (dev->req_seq == -1) { + if (dev_read_alias_seq(dev, &dev->sqq)) auto_seq = true; - dev->req_seq = - uclass_find_next_free_seq(uc); - } + } else { + auto_seq = true; } } else { auto_seq = true; - dev->req_seq = uclass_find_next_free_seq(uc); } if (auto_seq && !(gd->flags & GD_FLG_DM_NO_SEQ)) dev->sqq = uclass_find_next_free_seq(uc); @@ -518,7 +507,6 @@ fail_uclass: fail: dev->flags &= ~DM_FLAG_ACTIVATED; - dev->seq = -1; device_free(dev); return ret; diff --git a/include/dm/device.h b/include/dm/device.h index 073c5438fc2..b95aa346820 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -131,16 +131,11 @@ enum { * @child_head: List of children of this device * @sibling_node: Next device in list of all devices * @flags: Flags for this device DM_FLAG_... - * @sqq: Allocated sequence number for this device (-1 = none). This is set up + * @seq: Allocated sequence number for this device (-1 = none). This is set up * when the device is bound and is unique within the device's uclass. If the * device has an alias in the devicetree then that is used to set the sequence * number. Otherwise, the next available number is used. Sequence numbers are * used by certain commands that need device to be numbered (e.g. 'mmc dev') - * - * The following two fields are deprecated: - * @req_seq: Requested sequence number for this device (-1 = any) - * @seq: Allocated sequence number for this device (-1 = none). This is set up - * when the device is probed and will be unique within the device's uclass. * @devres_head: List of memory allocations associated with this device. * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed @@ -164,8 +159,6 @@ struct udevice { struct list_head sibling_node; uint32_t flags; int sqq; - int req_seq; - int seq; #ifdef CONFIG_DEVRES struct list_head devres_head; #endif diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 50267f2fc26..c4de91da102 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -386,6 +386,34 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) } DM_TEST(dm_test_fdt_uclass_seq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* More tests for sequence numbers */ +static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts) +{ + struct udevice *dev; + ofnode node; + + /* Check creating a device with an alias */ + node = ofnode_path("/some-bus/c-test@1"); + ut_assertok(device_bind(dm_root(), DM_GET_DRIVER(testfdt_drv), + "c-test@1", NULL, node, &dev)); + ut_asserteq(0, uclass_get_device_by_seq(UCLASS_TEST_FDT, 12, &dev)); + + /* + * Now bind a device without an alias. It should not get the next + * sequence number after all aliases, skipping 10 and 11 + */ + ut_assertok(device_bind(dm_root(), DM_GET_DRIVER(testfdt_drv), + "fred", NULL, ofnode_null(), &dev)); + ut_asserteq(13, dev_seq(dev)); + + ut_assertok(device_bind(dm_root(), DM_GET_DRIVER(testfdt_drv), + "fred2", NULL, ofnode_null(), &dev)); + ut_asserteq(14, dev_seq(dev)); + + return 0; +} +DM_TEST(dm_test_fdt_uclass_seq_more, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + /* Test that we can find a device by device tree offset */ static int dm_test_fdt_offset(struct unit_test_state *uts) {