From patchwork Mon Nov 30 01:53:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1407932 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=lsqPZ2M9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4CkpHH43CWz9sTc for ; Mon, 30 Nov 2020 12:56:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 877AE827A1; Mon, 30 Nov 2020 02:55:53 +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="lsqPZ2M9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 01320827B4; Mon, 30 Nov 2020 02:54:51 +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-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 82F2482608 for ; Mon, 30 Nov 2020 02:54:40 +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-il1-x141.google.com with SMTP id z10so1367967ilu.3 for ; Sun, 29 Nov 2020 17:54:40 -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=NIacUE+zopQmYZQ9J7VKgVbSbxFyASqCxVfsuM2mTlE=; b=lsqPZ2M9lY8XnqOlR0ERovFBvOR+Pxhm9rbE8BVSiYRJ71Jry/zUnY9rsxXniMT4Id RI1LZVHb4ifpn95MYAqanJzUOhoR/N4izjsMWdgK7Dr0mlMJyYc6Chtl4OpvaBRX75GO QTiy7p78AftE+vM2tipJl04VmbCtLw6Z+F8R4= 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=NIacUE+zopQmYZQ9J7VKgVbSbxFyASqCxVfsuM2mTlE=; b=td3sRn2Q8XuvyXHNkvzKQTbnVJj9JPeFwiMRJ/KvcsAc08v/dGCXIAQmVwJtiLFR49 l0tBu6lSK5l6pJ2jH0VYltcNxvvJP9PqXnA8sOmBdtJavHbIZavM4FOFNxu2i+oSncFO 2H4IqL87lnlDfYthkZW084VkXp3gpwmPY+2rGceNz/6d6UkURT4F9EWfLsBhM12HA0KQ KJpEVm4hwL9e8O0BVePln9mmE3z7HYNHx2xUvPeTKf1IoKZSIciC8zrebiuCHHUIJldq AkRDdSQNwEpqoO1M6RRYnGu7zkELX7Ul5PDjszbe2AcEPbDMMbcs7vJ2dsM1eAsYuPsX UDeg== X-Gm-Message-State: AOAM531OBYgdulxX3TgKdpvk3cgjnf554ONU3WN1ZKqip36+RKXBVNxw k4h/06j/X/NED/6m8+MGdSwdjdwBhakqgw== X-Google-Smtp-Source: ABdhPJzhZ47Lsie5Wy06x2UgGDCS4CExlXI0foRxTyKK5r6jCn1JdOzerLb0j/1+iPblk3ly4K0bPA== X-Received: by 2002:a05:6e02:1214:: with SMTP id a20mr15734862ilq.21.1606701279252; Sun, 29 Nov 2020 17:54:39 -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.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:54:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Heiko Schocher , Marek Vasut , Pavel Herrmann Subject: [PATCH 04/27] dm: core: Update uclass_find_next_free_req_seq() args Date: Sun, 29 Nov 2020 18:53:39 -0700 Message-Id: <20201130015402.2328621-3-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 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 --- 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