From patchwork Fri May 13 06:26:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 572069 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp197691mal; Thu, 12 May 2022 23:29:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxfJ03MBe43wgzLNLZZ9w6rmXRekZ04mW9A/to0/VGGFw9aAQo35/7iNQbGifQ8bLm+TLn X-Received: by 2002:a17:907:6d1c:b0:6f4:4089:8257 with SMTP id sa28-20020a1709076d1c00b006f440898257mr2921772ejc.682.1652423366029; Thu, 12 May 2022 23:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652423366; cv=none; d=google.com; s=arc-20160816; b=NjdxQjuMDoMQXzv2kGMYNqEUwlcaXmamia+zyS0yruH2LR/NmqPF+xK1d+laGB4vK5 TIbMdlBDZgbW+nVxknyv1f8jwPwBkMcePooqGCEJBEmfANnaO90tTsC2k06Dm/cA6eq0 b8xpPlv9YNTEcWrL63DWI2E15OoY6XW2Au4R3RadpS/Rm7P25rXc1+92owNluf3Rod/I 3UEDVgUrTfphs5OVfNWxjYnnF/3+bb3v/BLBmGmiRyguWOfOUV0JdX4g/ghdNgqFBR8w /rlbFO+UVfzm7x8mJ6x9TpwxnVfWVq0VMMZmgdVJIaez3gxWqGqTPKawna2UtqbS8vUL 6zGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=moaGrljTW+1UmBsjRq1ZnDHCE8hqTiGO7oGBWbgGEB0=; b=XRi50RtRMsMXSz8Y1llh67UglJyVgTIxp2R9eMqpFl99QG6dVZQRX0MzVwBgrFPo+X WUm6hs+j7BM6OSExYV1+/dezBHidfsal7B47DULWiT7Zhki21TpQo2WAQSXq+z/KQqAk h3xl+3baYKoMzzbUP7wB7CQgKDLgboDaiY3yb0R/ZXXgP4YfvVgRZrGG32OdoY/B8sAU YpTtSY2jYyL5tgEJ4pqSs0ngSiUOguRx0Qh1vA6PVacadVes43ir2daqqrceNeb3MsFB vVkpasKSpxW6VvCWhqjm6yOrl8MFxyHkvPRHtQ7sJRVVWehFoLyW8YsUvzAW+d4L06Hj iHIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rQmuUL/R"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ji8-20020a170907980800b006f384307fc0si1324531ejc.343.2022.05.12.23.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rQmuUL/R"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E142083E3C; Fri, 13 May 2022 08:28:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rQmuUL/R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B684283ED8; Fri, 13 May 2022 08:28:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (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 75C0683E49 for ; Fri, 13 May 2022 08:28:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-wr1-x42b.google.com with SMTP id v12so10006379wrv.10 for ; Thu, 12 May 2022 23:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=moaGrljTW+1UmBsjRq1ZnDHCE8hqTiGO7oGBWbgGEB0=; b=rQmuUL/RO6M2TE62OQZUiLk7gyO7+2KlXfihi7BUnI4uk49NjTzSkYbMQhID9sTQDf OPWMrU/3DOlrW8LfCOiKkoO9M8qq64nAzyaJJILwdA2uLKsVRa6+wmZ/kCbIN6bp+2lh 2g1G+7h9yL4Mrn8f3AzAIcYP0N8AUOgrXhGFBCoFiL6wyL6iI4tKRHeggdpdYbQdJoBn NOt8R7oAlvLARXaDJoAz/dzCjGh+kTuQmDfLKiXPrMxB37oBB595jwtX9t5c9CymerBk qCePCXy4JBvESRaefWmm8zRisroTQSSPfWLCmqQnZ+aoMKQn0nSiYupfdgN0uYjL90Bl xvgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=moaGrljTW+1UmBsjRq1ZnDHCE8hqTiGO7oGBWbgGEB0=; b=l0jwvBzw1eCGF855iGMmcr2bgK86BD0uA0u+PNuf731p/YPTSBqdt0IFcNwuOnBEDX wTsbf7lPxrL8c62rDZwzeOWx9rs3ecUERZB3DLG5MDR98ttZJGygjTRAWeUuXSlC8U7i pHZwxDjxKLz6EMGLUMG41goLE79i5wFQkj7ok4m2ip9cXH9zVR7YXyBC+E95RyPWdBZc CfPhnfKJQfIJBqipkpuV4IgQcUjUBxqQxBdKJA3b5ri+f6q9e31082OD5jcf+jbMfuwt k7gMBu3/L3+guIrciZ0Z5MNWU1fsx9W6d6azNaF65yC2Chlm/MB+6Gf75obf05kVjpej GlAQ== X-Gm-Message-State: AOAM530n6spGtsK4Aw94gTVxL/r8/YbVpii26iO1HGzyQQcE45Wj1T0q AujNb58hriyMG7cyldlOgC3Ix4x20DuBXw== X-Received: by 2002:adf:d1c7:0:b0:20c:4d5f:e57f with SMTP id b7-20020adfd1c7000000b0020c4d5fe57fmr2479027wrd.453.1652423309688; Thu, 12 May 2022 23:28:29 -0700 (PDT) Received: from lmecxl1178.lme.st.com ([2a04:cec0:1194:a3aa:dc31:6fc0:bd75:771a]) by smtp.gmail.com with ESMTPSA id s18-20020a7bc0d2000000b003942a244eebsm1414235wmh.48.2022.05.12.23.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:28:29 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Etienne Carriere Subject: [PATCH 05/14] firmware: scmi: factorize scmi transport look up Date: Fri, 13 May 2022 08:26:13 +0200 Message-Id: <20220513062622.155433-6-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513062622.155433-1-etienne.carriere@linaro.org> References: <20220513062622.155433-1-etienne.carriere@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean Defines local helper function find_scmi_transport_device() with the instructions to find the SCMI transport device from a SCMI protocol device. Cc: Patrick Delaunay Signed-off-by: Etienne Carriere --- drivers/firmware/scmi/scmi_agent-uclass.c | 26 +++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index c9c9c00384a..f7fa5df214c 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -109,6 +109,20 @@ static int scmi_bind_protocols(struct udevice *dev) return ret; } +static struct udevice *find_scmi_transport_device(struct udevice *dev) +{ + struct udevice *parent = dev; + + do { + parent = dev_get_parent(parent); + } while (parent && device_get_uclass_id(parent) != UCLASS_SCMI_AGENT); + + if (!parent) + dev_err(dev, "Invalid SCMI device, agent not found\n"); + + return parent; +} + static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev) { return (const struct scmi_agent_ops *)dev->driver->ops; @@ -118,17 +132,11 @@ int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, struct scmi_msg *msg) { const struct scmi_agent_ops *ops; - struct udevice *parent = dev; + struct udevice *parent; - /* Find related SCMI agent device */ - do { - parent = dev_get_parent(parent); - } while (parent && device_get_uclass_id(parent) != UCLASS_SCMI_AGENT); - - if (!parent) { - dev_err(dev, "Invalid SCMI device, agent not found\n"); + parent = find_scmi_transport_device(dev); + if (!parent) return -ENODEV; - } ops = transport_dev_ops(parent);