All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 25/28] dm: core: Update uclass_find_next_free_req_seq() for new scheme
Date: Wed, 16 Dec 2020 21:20:30 -0700	[thread overview]
Message-ID: <20201217042034.411902-22-sjg@chromium.org> (raw)
In-Reply-To: <20201217042034.411902-1-sjg@chromium.org>

This function current deals with req_seq which is deprecated. Update it to
use the new sequence numbers, putting them above existing aliases. Rename
the function to make this clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v2)

Changes in v2:
- Update for new logic
- Adjust commit message
- Drop pointless check for max == -1

 drivers/core/device.c        |  8 ++------
 drivers/core/uclass.c        | 19 +++++++++++++------
 drivers/pci/pci-uclass.c     |  2 +-
 include/dm/uclass-internal.h | 17 ++++++++++-------
 4 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index b878a4d4b69..4abb5be56a4 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -93,18 +93,14 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 			}
 			if (CONFIG_IS_ENABLED(OF_PRIOR_STAGE)) {
 				if (dev->req_seq == -1) {
-					auto_seq = true;
 					dev->req_seq =
-						uclass_find_next_free_req_seq(
-							uc);
+						uclass_find_next_free_seq(uc);
 				}
 			}
-		} else {
-			dev->req_seq = uclass_find_next_free_req_seq(uc);
 		}
 	}
 	if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
-		dev->sqq = uclass_find_next_free_req_seq(uc);
+		dev->sqq = uclass_find_next_free_seq(uc);
 
 	if (drv->plat_auto) {
 		bool alloc = !plat;
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 42c9ba58281..6409457fa96 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -272,18 +272,25 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
 	return -ENODEV;
 }
 
-int uclass_find_next_free_req_seq(struct uclass *uc)
+int uclass_find_next_free_seq(struct uclass *uc)
 {
 	struct udevice *dev;
 	int max = -1;
 
+	/* If using aliases, start with the highest alias value */
+	if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
+	    (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS))
+		max = dev_read_alias_highest_id(uc->uc_drv->name);
+
+	/* Avoid conflict with existing devices */
 	list_for_each_entry(dev, &uc->dev_head, uclass_node) {
-		if ((dev->req_seq != -1) && (dev->req_seq > max))
-			max = dev->req_seq;
+		if (dev->sqq > max)
+			max = dev->sqq;
 	}
-
-	if (max == -1)
-		return 0;
+	/*
+	 * At this point, max will be -1 if there are no existing aliases or
+	 * devices
+	 */
 
 	return max + 1;
 }
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index bff183eea23..914217d0c9a 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1019,7 +1019,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
 		ret = uclass_get(UCLASS_PCI, &uc);
 		if (ret)
 			return ret;
-		bus->sqq = uclass_find_next_free_req_seq(uc);
+		bus->sqq = uclass_find_next_free_seq(uc);
 	}
 
 	/* For bridges, use the top-level PCI controller */
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index 9c23d3f223e..3e052f95d32 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -12,17 +12,20 @@
 #include <dm/ofnode.h>
 
 /**
- * uclass_find_next_free_req_seq() - Get the next free req_seq number
+ * uclass_find_next_free_seq() - Get the next free sequence number
  *
- * This returns the next free req_seq number. This is useful only if
- * OF_CONTROL is not used. The next free req_seq number is simply the
- * maximum req_seq of the uclass + 1.
- * This allows assiging req_seq number in the binding order.
+ * This returns the next free sequence number. This is useful only if
+ * OF_CONTROL is not used. The next free sequence number is simply the
+ * maximum sequence number used by all devices in the uclass + 1. The value
+ * returned is always greater than the largest alias, if DM_SEQ_ALIAS is enabled
+ * and the uclass has the DM_UC_FLAG_SEQ_ALIAS flag.
+ *
+ * This allows assigning the sequence number in the binding order.
  *
  * @uc:		uclass to check
- * @return	The next free req_seq number
+ * @return	The next free sequence number
  */
-int uclass_find_next_free_req_seq(struct uclass *uc);
+int uclass_find_next_free_seq(struct uclass *uc);
 
 /**
  * uclass_get_device_tail() - handle the end of a get_device call
-- 
2.29.2.684.gfbc64c5ab5-goog

  parent reply	other threads:[~2020-12-17  4:20 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  4:20 [PATCH v3 00/28] dm: Change the way sequence numbers are implemented Simon Glass
2020-12-17  4:20 ` [PATCH v3 01/28] linker_lists: Fix alignment issue Simon Glass
2021-04-15  7:39   ` Heinrich Schuchardt
2021-04-21  7:14     ` Simon Glass
2020-12-17  4:20 ` [PATCH v3 02/28] dm: Avoid accessing seq directly Simon Glass
2020-12-17  4:20 ` [PATCH v3 03/28] dm: core: Update uclass_find_next_free_req_seq() args Simon Glass
2020-12-17  4:20 ` [PATCH v3 04/28] dm: core: Add a new sequence number for devices Simon Glass
2020-12-17  4:20 ` [PATCH v3 05/28] dm: test: Check all devices have a sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 06/28] dm: core: Switch binding to use new " Simon Glass
2020-12-17  4:20 ` [PATCH v3 07/28] dm: Fix return value in dev_read_alias_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 08/28] dm: test: Drop assumptions of no sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 09/28] octeon: Don't attempt to set the sequence number Simon Glass
2020-12-17  4:20 ` [PATCH v3 10/28] i2c: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 11/28] net: Update to use " Simon Glass
2020-12-17  4:20 ` [PATCH v3 12/28] dm: core: Allow manual sequence numbering Simon Glass
2020-12-17  4:20 ` [PATCH v3 13/28] pci: Update to use new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 14/28] spi: Update for " Simon Glass
2020-12-17  4:20 ` [PATCH v3 15/28] usb: ehci-mx6: Drop assignment of sequence number Simon Glass
2020-12-17  4:20 ` [PATCH v3 16/28] usb: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 17/28] x86: Drop unnecessary mp_init logic Simon Glass
2020-12-17  4:20 ` [PATCH v3 18/28] x86: Simplify acpi_device_infer_name() Simon Glass
2020-12-17  4:20 ` [PATCH v3 19/28] gpio: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 20/28] pinctrl: " Simon Glass
2020-12-17  4:20 ` [PATCH v3 21/28] dm: Switch over to use new sequence number for dev_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 22/28] dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ Simon Glass
2020-12-17  4:20 ` [PATCH v3 23/28] dm: Drop uclass_resolve_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 24/28] dm: Drop the unused arg in uclass_find_device_by_seq() Simon Glass
2020-12-17  4:20 ` Simon Glass [this message]
2020-12-17  4:20 ` [PATCH v3 26/28] cmd: Drop use of old sequence numbers in commands Simon Glass
2020-12-17  4:20 ` [PATCH v3 27/28] dm: core: Drop seq and req_seq Simon Glass
2020-12-17  4:20 ` [PATCH v3 28/28] dm: Update documentation for new sequence numbers Simon Glass
2020-12-18 11:09 ` [PATCH v3 00/28] dm: Change the way sequence numbers are implemented Michael Walle
2020-12-19 16:40 ` [PATCH v3 28/28] dm: Update documentation for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 27/28] dm: core: Drop seq and req_seq Simon Glass
2020-12-19 16:40 ` [PATCH v3 25/28] dm: core: Update uclass_find_next_free_req_seq() for new scheme Simon Glass
2020-12-19 16:40 ` [PATCH v3 26/28] cmd: Drop use of old sequence numbers in commands Simon Glass
2020-12-19 16:40 ` [PATCH v3 24/28] dm: Drop the unused arg in uclass_find_device_by_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 23/28] dm: Drop uclass_resolve_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 22/28] dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ Simon Glass
2020-12-19 16:40 ` [PATCH v3 21/28] dm: Switch over to use new sequence number for dev_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 20/28] pinctrl: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 19/28] gpio: " Simon Glass
2020-12-19 16:40 ` [PATCH v3 18/28] x86: Simplify acpi_device_infer_name() Simon Glass
2020-12-19 16:40 ` [PATCH v3 17/28] x86: Drop unnecessary mp_init logic Simon Glass
2020-12-19 16:40 ` [PATCH v3 16/28] usb: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 15/28] usb: ehci-mx6: Drop assignment of sequence number Simon Glass
2021-03-31 19:14   ` Marek Vasut
2021-03-31 19:27     ` Tom Rini
2021-03-31 22:20       ` Simon Glass
2020-12-19 16:40 ` [PATCH v3 14/28] spi: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 13/28] pci: Update to use " Simon Glass
2021-04-13 18:32   ` Tim Harvey
2021-04-14 19:37     ` Simon Glass
2021-04-15  0:28       ` Tim Harvey
2021-04-15  0:44         ` Simon Glass
2020-12-19 16:40 ` [PATCH v3 12/28] dm: core: Allow manual sequence numbering Simon Glass
2020-12-19 16:40 ` [PATCH v3 11/28] net: Update to use new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 10/28] i2c: Update for " Simon Glass
2020-12-19 16:40 ` [PATCH v3 09/28] octeon: Don't attempt to set the sequence number Simon Glass
2020-12-19 16:40 ` [PATCH v3 08/28] dm: test: Drop assumptions of no sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 07/28] dm: Fix return value in dev_read_alias_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 06/28] dm: core: Switch binding to use new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 05/28] dm: test: Check all devices have a " Simon Glass
2020-12-19 16:40 ` [PATCH v3 04/28] dm: core: Add a new sequence number for devices Simon Glass
2020-12-19 16:40 ` [PATCH v3 03/28] dm: core: Update uclass_find_next_free_req_seq() args Simon Glass
2020-12-19 16:40 ` [PATCH v3 02/28] dm: Avoid accessing seq directly Simon Glass
2020-12-19 16:40 ` [PATCH v3 01/28] linker_lists: Fix alignment issue Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201217042034.411902-22-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.