Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5841869rwb; Wed, 7 Sep 2022 08:43:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR7nqTEobh2dqm492T3F47Sa+i4CYTqvNTBYLZqiFucnZO1iVSWJowwFF0NFC5xWXPh88JDV X-Received: by 2002:aa7:9193:0:b0:536:62e6:1a84 with SMTP id x19-20020aa79193000000b0053662e61a84mr4462397pfa.20.1662565381776; Wed, 07 Sep 2022 08:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662565381; cv=none; d=google.com; s=arc-20160816; b=o5ITQ+jarA3uLc1dQSh0K/h/G++fqir304lPo7HX6PiL6OU+X6IXqsTtG3t32HynrL BSPtCmwI1xK62G3FO+FdFYNiSG+89yACDB8ZLnjbSH2LvOgto2X5zLoq1sK5YnHGvvah vDoqCR/gIzLFCL5XBjYyMp+j/0XhC0X0lODMpks5NmRYyhTNJ2Y0pLoodaIAcuGZEpt2 xyADIDRndcIT8OcC7ZViwf1PUSDGM6GlWf4feyTvbYH3SQuvd2GxQo3PNJK+jjmSJOq7 yGTHn3tkiM1n+Ml0xAeYsWYgxOORIpa6o+i8nCgthlv6fuYxWjAAbcl5LZdUIohJ1Ryr 7KFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nSDxx4LkX8apvYeyL3S36rUjyBQTAYeS6aBPYwwibjQ=; b=ntG0VRqaLL9poCP/lmsH41mgspNhLm6fmMjyO3V1rwEAHyu9MoqCSFnC5ZP7lu6KFj fNfQwkqcCXbgA2BG+dObBKAZjPAh8/eVljoAOacamr+katVyjlNlatBYWMJXM/ccz16c gaYeDwNKJ6iZ3Ac8lHpvqhnXeelfjofB1KZTla+Oao1ffRAEmRJhw3oEG3voHcxe90OU 6uVYJ7D2qzAQ/PwwGp8rvXU9e/Z12pfbc+lBTqkhbuFNTnIrwNrqYaVk5lZ32O6Yczlb D5BxYVjpGUVZ+JA9vwkYnvljqs7b4dB3p6Q4pEE+qnP+AM22dldXwQj/FJ5v3K1L3M53 ag6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a170903110800b0016eec1292e4si18764270plh.500.2022.09.07.08.42.48; Wed, 07 Sep 2022 08:43:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbiIGOwt (ORCPT + 99 others); Wed, 7 Sep 2022 10:52:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiIGOwr (ORCPT ); Wed, 7 Sep 2022 10:52:47 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E5EBAA8975 for ; Wed, 7 Sep 2022 07:52:45 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E6FD913D5; Wed, 7 Sep 2022 07:52:51 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 53B873F71A; Wed, 7 Sep 2022 07:52:44 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org Cc: Sudeep Holla , Marc Bonnici , Achin Gupta , Jens Wiklander , Valentin Laurent , Lukas Hanel , Coboy Chen Subject: [PATCH v3 01/10] firmware: arm_ffa: Add pointer to the ffa_dev_ops in struct ffa_dev Date: Wed, 7 Sep 2022 15:52:31 +0100 Message-Id: <20220907145240.1683088-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907145240.1683088-1-sudeep.holla@arm.com> References: <20220907145240.1683088-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently ffa_dev_ops_get() is the way to fetch the ffa_dev_ops pointer. It checks if the ffa_dev structure pointer is valid before returning the ffa_dev_ops pointer. Instead, the pointer can be made part of the ffa_dev structure and since the core driver is incharge of creating ffa_device for each identified partition, there is no need to check for the validity explicitly if the pointer is embedded in the structure. Add the pointer to the ffa_dev_ops in the ffa_dev structure itself and initialise the same as part of creation of the device. Reviewed-by: Jens Wiklander Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/bus.c | 4 +++- drivers/firmware/arm_ffa/driver.c | 2 +- include/linux/arm_ffa.h | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index 641a91819088..69328041fbc3 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -167,7 +167,8 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev) return valid; } -struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id) +struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, + const struct ffa_dev_ops *ops) { int ret; struct device *dev; @@ -183,6 +184,7 @@ struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id) dev_set_name(&ffa_dev->dev, "arm-ffa-%04x", vm_id); ffa_dev->vm_id = vm_id; + ffa_dev->ops = ops; uuid_copy(&ffa_dev->uuid, uuid); ret = device_register(&ffa_dev->dev); diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index ec731e9e942b..213665e5ad0e 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -688,7 +688,7 @@ static void ffa_setup_partitions(void) * as part of the discovery API, we need to pass the * discovered UUID here instead. */ - ffa_dev = ffa_device_register(&uuid_null, tpbuf->id); + ffa_dev = ffa_device_register(&uuid_null, tpbuf->id, &ffa_ops); if (!ffa_dev) { pr_err("%s: failed to register partition ID 0x%x\n", __func__, tpbuf->id); diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index e5c76c1ef9ed..91b47e42b73d 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -17,6 +17,7 @@ struct ffa_device { bool mode_32bit; uuid_t uuid; struct device dev; + const struct ffa_dev_ops *ops; }; #define to_ffa_dev(d) container_of(d, struct ffa_device, dev) @@ -47,7 +48,8 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev) } #if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT) -struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id); +struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, + const struct ffa_dev_ops *ops); void ffa_device_unregister(struct ffa_device *ffa_dev); int ffa_driver_register(struct ffa_driver *driver, struct module *owner, const char *mod_name); @@ -57,7 +59,8 @@ const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev); #else static inline -struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id) +struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, + const struct ffa_dev_ops *ops) { return NULL; } -- 2.37.3