From patchwork Tue May 31 16:09:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 577450 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:330b:0:0:0:0 with SMTP id f11csp1300748mag; Tue, 31 May 2022 09:10:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIcZCYETiMKeB1jPDJjOhCbmshP/PrbNMy5oEQxc/nAV4AWjdhe7X68tHTYODvma/K1b2E X-Received: by 2002:a05:6e02:174f:b0:2d1:3971:9348 with SMTP id y15-20020a056e02174f00b002d139719348mr32324372ill.4.1654013436207; Tue, 31 May 2022 09:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654013436; cv=none; d=google.com; s=arc-20160816; b=Wbhp/P6LjX7u8UGr2uql4b12Ti7CGA4s4TfM7FunrWSp5MLyK1HxsGMDT1Ed/FmXEu K3o8rRIyhV/XoVi98dobQtJnx5YprNJ0TsbKkGLX/vgnJRIvn1X/zobURsc2ekjiQ+gf DvmRi8dbdJj+Q7x9X+wM7jIl43KQUK2Sc6/EziDRCOKOQECoRuBaRGPX+Q93HPg7IDhp MCPGhtlAsGuMnmB6I5HVkSRt3qB0+Gsluu8+IPLpHnjEHMdl5A9Y4J4iaZ0s0jBXYcQv ZMOermRNc3b1jIchqBvX2JWe/Mrt+bWVFL5ouHJh72kge6f+9f5uoWd/cTEWTmQjhq4w L86g== 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=AcIJuiH5tQ6CZ0cG4yoE3grwba7ePWNaHcRR8vepnhs=; b=es50RGP9NBkMSzlSLU/U7y+XpriEomu56OKbhGXW3YHwuC4YxF9cFF+2UAdjkSqC42 aeRM0LSAJHVS0EFWUHvQbZ+u0I76syXdH4qW98bMeXkrOruK6x3dtAH/YTJT2cZQNdRq GRWHPX4IpcjbTTVV3Xm5jupOx7/9gADCpoCWikzjGlvlUFfLlf7Biaf/Ub4GYLZSk6hU /aELL9qigYziHj2DzSCjQifyMd8w0bFwuETnx54A3AWOlpugSe68H6sHZylaE2cyvRY0 SILHmxgH/H0F7ptEu4u+42GdbLxPY7xoBLOp1Oy5xWQazfPWL4bpzw2E4S/yQmPNTGK0 w4tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="g7M/BuoE"; 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 a10-20020a056602148a00b00657b5f29ab7si23610424iow.66.2022.05.31.09.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:10:36 -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="g7M/BuoE"; 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 5594683F40; Tue, 31 May 2022 18:10:13 +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="g7M/BuoE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 495E283E1B; Tue, 31 May 2022 18:09:49 +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-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 7689B83DE0 for ; Tue, 31 May 2022 18:09:42 +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-wm1-x333.google.com with SMTP id f23-20020a7bcc17000000b003972dda143eso1519758wmh.3 for ; Tue, 31 May 2022 09:09:42 -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=AcIJuiH5tQ6CZ0cG4yoE3grwba7ePWNaHcRR8vepnhs=; b=g7M/BuoEFJ0pYxxkCEVybGDxwbxgvjG2g+aMgJGhpMBexA3Z7cG9Mzv1C1w11xETax r6pqINtDWBX9knD/OevMsTLV4/5QfDZqTYkTA6/5eilarobEvmRMXtQMCm5+6qBkoUMk Nel2ryZVM24eX8OBs0f8fW1VJLX2HqT5Ust6EwO72RR2+l/lxbSpqCFo2dWY8YUIL4N/ FGBB+xmDVPxKzLXBA1ITK7pQ1kFypYiNenfKIKf/cz2kGwAQkGVsC73U/i8hIP5t5VCN bRprV4Li6NehHOc903MEM7WhVxCKr87ALrQCsj6I1L0KS6F/iMxfMUY4cVw17CL5pE7E roqg== 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=AcIJuiH5tQ6CZ0cG4yoE3grwba7ePWNaHcRR8vepnhs=; b=X3RYM04sXHjH8s7UtG18hmmGCg2zyQBCLLQLyrjL4uy1aM4TJKZefxLYjaHxRVwyMo ee4L0Cb5Qqbts2vIJmtV+KKwgwr3LXwnXuXm7X3z4oFstyV+WvYzOgaZHm672uPobkgF wVJyKzlBQOYYPw2qzKAC+fcYGcSgM5439btDR4Fj0wILVHcP/lMmlyHK65N9l1Fktaa+ Nufe3jHg7QTqindNQXwcE0ZCCtLKeCfK3/ibGsolYSUFxtzgmxY5gnY/NMFKSpWcXowD QbNTQ0lALq0dhP/D9jIR/Q6ZwIMWMJ3kXlW4ZbTRlFvmpGLu2xEJuuQI8BPcaZF/VCAu a+1Q== X-Gm-Message-State: AOAM531iZy3dZv73lRVu/ZlxoBs9KVtbtUAMjlEiD/bwBZ0s52Q3bsXf LUDkqEnp3a0SrYoq9KnUGH+c8GnePuRMVQ== X-Received: by 2002:a05:600c:4f0c:b0:397:6a3a:d3f9 with SMTP id l12-20020a05600c4f0c00b003976a3ad3f9mr24482105wmq.103.1654013381491; Tue, 31 May 2022 09:09:41 -0700 (PDT) Received: from lmecxl1178.lme.st.com ([2a04:cec0:117a:a94e:9569:2e63:8a35:2cc5]) by smtp.gmail.com with ESMTPSA id r23-20020a05600c321700b0039aa4d054f8sm2884035wmp.5.2022.05.31.09.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:09:41 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , etienne.carriere@linaro.org Subject: [PATCH v2 05/14] firmware: scmi: factorize scmi transport look up Date: Tue, 31 May 2022 18:09:20 +0200 Message-Id: <20220531160929.931150-6-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531160929.931150-1-etienne.carriere@linaro.org> References: <20220531160929.931150-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 --- No change since v1. --- 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);