aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-12-16 21:20:08 -0700
committerSimon Glass <sjg@chromium.org>2020-12-18 20:32:21 -0700
commitd03adb4a78d18b5506350b3ac72ab2f18f1ed160 (patch)
treee5d27de4a64912a3152d490d33638d60b07d7a36
parent8b85dfc675f12de8d04126c07f3c796965b990c2 (diff)
downloadu-boot-d03adb4a78d18b5506350b3ac72ab2f18f1ed160.zip
u-boot-d03adb4a78d18b5506350b3ac72ab2f18f1ed160.tar.gz
u-boot-d03adb4a78d18b5506350b3ac72ab2f18f1ed160.tar.bz2
dm: core: Update uclass_find_next_free_req_seq() args
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>
-rw-r--r--drivers/core/device.c4
-rw-r--r--drivers/core/uclass.c8
-rw-r--r--drivers/i2c/designware_i2c_pci.c8
-rw-r--r--include/dm/uclass-internal.h4
4 files changed, 12 insertions, 12 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index fce9909..22d8069 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 e2372c6..96b7d16 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 8d7b1fe..3c15320 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 6e3f15c..2c21871 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