Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1103346pxu; Wed, 6 Jan 2021 12:20:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyx+QOuc4VR7sWv+4MsOPYQBeJgcg7KJ5sMTwgNDVkVKrK0QV1jCpS/Zihx1gdnAkdXD7vm X-Received: by 2002:a17:906:e28c:: with SMTP id gg12mr4292956ejb.74.1609964444070; Wed, 06 Jan 2021 12:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609964444; cv=none; d=google.com; s=arc-20160816; b=yeC/86t8YeZBK+LKR3OVZi81klIOn1mGa+A+YMS14AiNDyg3ClwAeOR2y678cDAZbG Hl5NpO8j9oEbiJ6e4HJKh9Gk9+OoUv8BN+NeI9sOTgr1yn+6/yDBFlrbkuH+enIoPxKP 94HvBJvg03InUyeHADPu+ZCcD4bKFaaQRQuozyoQTQBUn8Cafxz0jP+3jK3y0P4Ln5+a A8LNGs4/fzUi04Z4Acj6MbhA/47i856EiJschG/3j89+uNLl+xerJbcxwU0SOa/oskvd m5mKlTgtGfTpR7doTN2SIK3xWF1TVFhixCTRaxNJc8ANZNC/sSSHVekpSym0qYPcZcHh 6vbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Q6cERLmk6uTya8wRd4Q7JkuJZVzEo8vgI8PAFsWV0QQ=; b=RbtKcm3PT4SIAc0+i8EutqgM8pf+jFEawgs9aRBiVRFnFC3mqptlXyP5zlOwuoF7SB oO3pZs2dpLPh4PnMEiZuEaHyOD3q5AuYcmRMWEYs8GLMGEG9DdaEbvdhN4Z3w1ycCmRo cdEcrAG/2cy6Y+GoHP0p0Vv5w5pfEt0T4yaQvDxTSEImpMUndiQXpr8RXVGaMKW16Mwv C1lC60wZ1nD8dmUS2yanF0P3AiGgi0KrMzVpQdj3welmt10eEWHEb4wGs1rpumVmAHht wxVRpsj+TG7A/YxoPCNawLDcVhQINBNnEKTnDHMn6A1/E69/MPC9Who1v8LpAz1MPlLk JWjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn6si1204407ejc.234.2021.01.06.12.20.20; Wed, 06 Jan 2021 12:20:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727260AbhAFURq (ORCPT + 99 others); Wed, 6 Jan 2021 15:17:46 -0500 Received: from foss.arm.com ([217.140.110.172]:46782 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726773AbhAFURq (ORCPT ); Wed, 6 Jan 2021 15:17:46 -0500 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 884CE12FC; Wed, 6 Jan 2021 12:17:00 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 25CD63F719; Wed, 6 Jan 2021 12:16:58 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, lukasz.luba@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, etienne.carriere@linaro.org, thara.gopinath@linaro.org, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, cristian.marussi@arm.com Subject: [PATCH v4 04/37] [RFC] firmware: arm_scmi: introduce bare get/put protocols ops Date: Wed, 6 Jan 2021 20:15:37 +0000 Message-Id: <20210106201610.26538-5-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210106201610.26538-1-cristian.marussi@arm.com> References: <20210106201610.26538-1-cristian.marussi@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose to the SCMI drivers a non managed version of a common protocols API based on generic get/put methods and protocol handles. All drivers still keep using the old API, no functional change. Signed-off-by: Cristian Marussi --- These non devres methods are probably not needed, given the devm_ ones are already provided and any SCMI driver (user of the API) has surely available an scmi_device reference to use in the devm_ flavour...so the RFC --- drivers/firmware/arm_scmi/driver.c | 34 ++++++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 8 +++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index fbc3ba1b69f6..e6e760501587 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -710,6 +710,38 @@ void scmi_release_protocol(struct scmi_handle *handle, u8 protocol_id) mutex_unlock(&info->protocols_mtx); } +/** + * scmi_get_protocol_operations - Get protocol operations + * @handle: A reference to the SCMI platform instance. + * @protocol_id: The protocol being requested. + * @ph: A pointer reference used to pass back the associated protocol handle. + * + * Get hold of a protocol accounting for its usage, eventually triggering its + * initialization, and returning the protocol specific operations and related + * protocol handle which will be used as first argument in most of the protocols + * operations methods. + * + * Return: A reference to the requested protocol operations or error. + * Must be checked for errors by caller. + */ +static const void __must_check * +scmi_get_protocol_operations(struct scmi_handle *handle, u8 protocol_id, + struct scmi_protocol_handle **ph) +{ + struct scmi_protocol_instance *pi; + + if (!ph) + return ERR_PTR(-EINVAL); + + pi = scmi_get_protocol_instance(handle, protocol_id); + if (IS_ERR(pi)) + return pi; + + *ph = &pi->ph; + + return pi->proto->ops; +} + void scmi_setup_protocol_implemented(const struct scmi_handle *handle, u8 *prot_imp) { @@ -1078,6 +1110,8 @@ static int scmi_probe(struct platform_device *pdev) handle->version = &info->version; handle->devm_get_ops = scmi_devm_get_protocol_ops; handle->devm_put_ops = scmi_devm_put_protocol_ops; + handle->get_ops = scmi_get_protocol_operations; + handle->put_ops = scmi_release_protocol; ret = scmi_txrx_setup(info, dev, SCMI_PROTOCOL_BASE); if (ret) diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 2fd2fffb4024..8a2bb723602f 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -598,6 +598,9 @@ struct scmi_notify_ops { * @devm_get_ops: devres managed method to acquire a protocol and get specific * operations and a dedicated protocol handler * @devm_put_ops: devres managed method to release a protocol + * @get_ops: method to acquire a protocol and get specific operations and a + * dedicated protocol handler + * @put_ops: method to release a protocol * @notify_ops: pointer to set of notifications related operations * @perf_priv: pointer to private data structure specific to performance * protocol(for internal use only) @@ -629,6 +632,11 @@ struct scmi_handle { struct scmi_protocol_handle **ph); void (*devm_put_ops)(struct scmi_device *sdev, u8 proto); + const void __must_check * + (*get_ops)(struct scmi_handle *handle, u8 proto, + struct scmi_protocol_handle **ph); + void (*put_ops)(struct scmi_handle *handle, u8 proto); + const struct scmi_notify_ops *notify_ops; /* for protocol internal use */ void *perf_priv; -- 2.17.1