All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 03/26] dm: core: Update uclass_find_next_free_req_seq() args
Date: Thu, 10 Dec 2020 18:31:28 -0700	[thread overview]
Message-ID: <20201211013151.1927814-2-sjg@chromium.org> (raw)
In-Reply-To: <20201211013151.1927814-1-sjg@chromium.org>

At present this is passed a uclass ID and it has to do a lookup. The
callers all have the uclass pointer, except for the I2C uclass where the
code will soon be deleted.

Update the argument to a uclass * instead of an ID since it is more
efficient.

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

(no changes since v1)

 drivers/core/device.c            | 4 ++--
 drivers/core/uclass.c            | 8 +-------
 drivers/i2c/designware_i2c_pci.c | 8 +++++++-
 include/dm/uclass-internal.h     | 4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 5660310c754..5febdb67503 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -89,10 +89,10 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 #if CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
 			if (dev->req_seq == -1)
 				dev->req_seq =
-					uclass_find_next_free_req_seq(drv->id);
+					uclass_find_next_free_req_seq(uc);
 #endif
 		} else {
-			dev->req_seq = uclass_find_next_free_req_seq(drv->id);
+			dev->req_seq = uclass_find_next_free_req_seq(uc);
 		}
 	}
 
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 699f24843cf..cdf0674cd82 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -272,17 +272,11 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
 	return -ENODEV;
 }
 
-int uclass_find_next_free_req_seq(enum uclass_id id)
+int uclass_find_next_free_req_seq(struct uclass *uc)
 {
-	struct uclass *uc;
 	struct udevice *dev;
-	int ret;
 	int max = -1;
 
-	ret = uclass_get(id, &uc);
-	if (ret)
-		return ret;
-
 	list_for_each_entry(dev, &uc->dev_head, uclass_node) {
 		if ((dev->req_seq != -1) && (dev->req_seq > max))
 			max = dev->req_seq;
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index d0d869c81a1..04921a304ac 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -90,7 +90,9 @@ static int designware_i2c_pci_probe(struct udevice *dev)
 
 static int designware_i2c_pci_bind(struct udevice *dev)
 {
+	struct uclass *uc;
 	char name[20];
+	int ret;
 
 	if (dev_of_valid(dev))
 		return 0;
@@ -108,7 +110,11 @@ static int designware_i2c_pci_bind(struct udevice *dev)
 	 * be possible. We cannot use static data in drivers since they may be
 	 * used in SPL or before relocation.
 	 */
-	dev->req_seq = uclass_find_next_free_req_seq(UCLASS_I2C);
+	ret = uclass_get(UCLASS_I2C, &uc);
+	if (ret)
+		return ret;
+
+	dev->req_seq = uclass_find_next_free_req_seq(uc);
 	sprintf(name, "i2c_designware#%u", dev->req_seq);
 	device_set_name(dev, name);
 
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index 6e3f15c2b08..2c21871e0fd 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -19,10 +19,10 @@
  * maximum req_seq of the uclass + 1.
  * This allows assiging req_seq number in the binding order.
  *
- * @id:		Id number of the uclass
+ * @uc:		uclass to check
  * @return	The next free req_seq number
  */
-int uclass_find_next_free_req_seq(enum uclass_id id);
+int uclass_find_next_free_req_seq(struct uclass *uc);
 
 /**
  * uclass_get_device_tail() - handle the end of a get_device call
-- 
2.29.2.576.ga3fc446d84-goog

  parent reply	other threads:[~2020-12-11  1:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11  1:31 [PATCH v2 00/26] dm: Change the way sequence numbers are implemented Simon Glass
2020-12-11  1:31 ` [PATCH v2 01/26] linker_lists: Fix alignment issue Simon Glass
2020-12-11  1:31 ` [PATCH v2 02/26] dm: Avoid accessing seq directly Simon Glass
2020-12-11  1:31 ` Simon Glass [this message]
2020-12-11  1:31 ` [PATCH v2 04/26] dm: core: Add a new sequence number for devices Simon Glass
2020-12-11  1:31 ` [PATCH v2 05/26] dm: test: Check all devices have a sequence numbers Simon Glass
2020-12-11  1:31 ` [PATCH v2 06/26] dm: core: Switch binding to use new " Simon Glass
2020-12-11  1:31 ` [PATCH v2 07/26] dm: Fix return value in dev_read_alias_seq() Simon Glass
2020-12-11  1:31 ` [PATCH v2 08/26] dm: test: Drop assumptions of no sequence numbers Simon Glass
2020-12-11  1:31 ` [PATCH v2 09/26] octeon: Don't attempt to set the sequence number Simon Glass
2020-12-11  1:31 ` [PATCH v2 10/26] i2c: Update for new sequence numbers Simon Glass
2020-12-11  1:31 ` [PATCH v2 11/26] net: Update to use " Simon Glass
2020-12-11  1:31 ` [PATCH v2 12/26] pci: " Simon Glass
2020-12-11  1:31 ` [PATCH v2 13/26] spi: Update for " Simon Glass
2020-12-11  1:31 ` [PATCH v2 14/26] usb: ehci-mx6: Drop assignment of sequence number Simon Glass
2020-12-11  1:31 ` [PATCH v2 15/26] usb: Update for new sequence numbers Simon Glass
2020-12-11  1:31 ` [PATCH v2 16/26] x86: Drop unnecessary mp_init logic Simon Glass
2020-12-11  1:31 ` [PATCH v2 17/26] x86: Simplify acpi_device_infer_name() Simon Glass
2020-12-11  1:31 ` [PATCH v2 18/26] gpio: Update for new sequence numbers Simon Glass
2020-12-11  1:31 ` [PATCH v2 19/26] pinctrl: " Simon Glass
2020-12-11  1:31 ` [PATCH v2 20/26] dm: Switch over to use new sequence number for dev_seq() Simon Glass
2020-12-11  1:31 ` [PATCH v2 21/26] dm: Drop uclass_resolve_seq() Simon Glass
2020-12-11  1:31 ` [PATCH v2 22/26] dm: Drop the unused arg in uclass_find_device_by_seq() Simon Glass
2020-12-11  1:31 ` [PATCH v2 23/26] dm: core: Update uclass_find_next_free_req_seq() for new scheme Simon Glass
2020-12-11  1:31 ` [PATCH v2 24/26] cmd: Drop use of old sequence numbers in commands Simon Glass
2020-12-11  1:31 ` [PATCH v2 25/26] dm: core: Drop seq and req_seq Simon Glass
2020-12-11  1:31 ` [PATCH v2 26/26] dm: Update documentation for new sequence numbers Simon Glass
2020-12-11  8:55 ` [PATCH v2 00/26] dm: Change the way sequence numbers are implemented Michael Walle
2020-12-12 15:39   ` Simon Glass
2020-12-12 17:53     ` Michael Walle
2020-12-12 18:38       ` Simon Glass
2020-12-15  4:28         ` Simon Glass
2020-12-15  8:58           ` Michael Walle
2020-12-15 16:50             ` 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=20201211013151.1927814-2-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.