From patchwork Wed May 9 17:07:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135315 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5223lji; Wed, 9 May 2018 10:12:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrttQ2YMwPmePG7S07tYJOP6W2ykwSu2jZzCAozAte4cdf3ktVNgr+wx09CrF1G6X1mm6qm X-Received: by 2002:a65:6182:: with SMTP id c2-v6mr2273674pgv.219.1525885966756; Wed, 09 May 2018 10:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885966; cv=none; d=google.com; s=arc-20160816; b=MCit/2H0RU2jtNlgSm9wcngkd96kpOxZmCHP2SP4rEhN1uk5KH4xF8P9JQNJqtW38c qRYm4nApqCbxlIcSKbjzvlMhchoZYXtF5Tv1Qjegs9vzIbGWx7c1Qaddv2r+OW2hW2ZJ QpqkXKMFwdoYvyNf0btkIc+D5Kbw1PVk0RzaKTWY/SIUT7rRO/46rJhCbIpvQyutN3/K X2zm4HUQ/4YoEgzhwPobDB70lgZAxe4e5Xwue995ETULkRnPz9iprIjiFecSNcRT8Q2h 21ncrrMXMtQ1Wum1zcF4Myya6Onojvym5htDEVSaZ4CsD9IsMAt9rYziTiFPPD14cN1j /rGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=oFcLmpB358l0WHExLhDAI32xSRPa0eEgmaVppMxr+5M=; b=UL0wP61Us2I7GEv5o9K5SplCbta6ZqmO+30NHwvUcXwI8MEVJUgLjgNrmW+iJRTWEK F74fxvMmOHBgiwpSJadiwrRIUtNSXRINQI/KWlWQAfb99CC2TgaxYQZpIbUG005WJ6s/ ZXW+9zA/1LEpcZUIQLLsmnD6V0y2Subd4XtrYXz7AGztaS+qokTeBoydqTIB6dbDMTy1 2zSNGVUz/Nl9XIE3FCRdYqLryK5MmgLi9kuzjH2WV/cJQm9sfkHS/4aP1y7Do4Rv1dBO 5ZUDALOZDmB1pjwEuzmvi3jPxnljpfBj7RXAED6Vv4RT2TKE2/a5CqoGHwb2QweDNp+6 KOBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.46; Wed, 09 May 2018 10:12:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965690AbeEIRMp (ORCPT + 10 others); Wed, 9 May 2018 13:12:45 -0400 Received: from foss.arm.com ([217.140.101.70]:47264 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMp (ORCPT ); Wed, 9 May 2018 13:12:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 04E9515B2; Wed, 9 May 2018 10:12:45 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1A99D3F592; Wed, 9 May 2018 10:12:43 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 1/8] firmware: arm_scmi: improve code readability using bitfield accessor macros Date: Wed, 9 May 2018 18:07:07 +0100 Message-Id: <1525885634-22348-2-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org By using FIELD_{FIT,GET,PREP} and GENMASK macro accessors we can avoid some clumpsy custom shifting and masking macros and also improve the code better readability. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/common.h | 9 +++++---- drivers/firmware/arm_scmi/driver.c | 31 ++++++++++++++----------------- 2 files changed, 19 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 0c30234f9098..e8f332c9c469 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -7,6 +7,7 @@ * Copyright (C) 2018 ARM Ltd. */ +#include #include #include #include @@ -14,10 +15,10 @@ #include #include -#define PROTOCOL_REV_MINOR_BITS 16 -#define PROTOCOL_REV_MINOR_MASK ((1U << PROTOCOL_REV_MINOR_BITS) - 1) -#define PROTOCOL_REV_MAJOR(x) ((x) >> PROTOCOL_REV_MINOR_BITS) -#define PROTOCOL_REV_MINOR(x) ((x) & PROTOCOL_REV_MINOR_MASK) +#define PROTOCOL_REV_MINOR_MASK GENMASK(15, 0) +#define PROTOCOL_REV_MAJOR_MASK GENMASK(31, 16) +#define PROTOCOL_REV_MAJOR(x) (u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x))) +#define PROTOCOL_REV_MINOR(x) (u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x))) #define MAX_PROTOCOLS_IMP 16 #define MAX_OPPS 16 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 14b147135a0c..917786d91f55 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -29,16 +29,12 @@ #include "common.h" -#define MSG_ID_SHIFT 0 -#define MSG_ID_MASK 0xff -#define MSG_TYPE_SHIFT 8 -#define MSG_TYPE_MASK 0x3 -#define MSG_PROTOCOL_ID_SHIFT 10 -#define MSG_PROTOCOL_ID_MASK 0xff -#define MSG_TOKEN_ID_SHIFT 18 -#define MSG_TOKEN_ID_MASK 0x3ff -#define MSG_XTRACT_TOKEN(header) \ - (((header) >> MSG_TOKEN_ID_SHIFT) & MSG_TOKEN_ID_MASK) +#define MSG_ID_MASK GENMASK(7, 0) +#define MSG_TYPE_MASK GENMASK(9, 8) +#define MSG_PROTOCOL_ID_MASK GENMASK(17, 10) +#define MSG_TOKEN_ID_MASK GENMASK(27, 18) +#define MSG_XTRACT_TOKEN(hdr) FIELD_GET(MSG_TOKEN_ID_MASK, (hdr)) +#define MSG_TOKEN_MAX (MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1) enum scmi_error_codes { SCMI_SUCCESS = 0, /* Success */ @@ -255,9 +251,9 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m) */ static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr) { - return ((hdr->id & MSG_ID_MASK) << MSG_ID_SHIFT) | - ((hdr->seq & MSG_TOKEN_ID_MASK) << MSG_TOKEN_ID_SHIFT) | - ((hdr->protocol_id & MSG_PROTOCOL_ID_MASK) << MSG_PROTOCOL_ID_SHIFT); + return FIELD_PREP(MSG_ID_MASK, hdr->id) | + FIELD_PREP(MSG_TOKEN_ID_MASK, hdr->seq) | + FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id); } /** @@ -621,9 +617,9 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo) struct scmi_xfers_info *info = &sinfo->minfo; /* Pre-allocated messages, no more than what hdr.seq can support */ - if (WARN_ON(desc->max_msg >= (MSG_TOKEN_ID_MASK + 1))) { - dev_err(dev, "Maximum message of %d exceeds supported %d\n", - desc->max_msg, MSG_TOKEN_ID_MASK + 1); + if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) { + dev_err(dev, "Maximum message of %d exceeds supported %ld\n", + desc->max_msg, MSG_TOKEN_MAX); return -EINVAL; } @@ -840,7 +836,8 @@ static int scmi_probe(struct platform_device *pdev) if (of_property_read_u32(child, "reg", &prot_id)) continue; - prot_id &= MSG_PROTOCOL_ID_MASK; + if (!FIELD_FIT(MSG_PROTOCOL_ID_MASK, prot_id)) + dev_err(dev, "Out of range protocol %d\n", prot_id); if (!scmi_is_protocol_implemented(handle, prot_id)) { dev_err(dev, "SCMI protocol %d not implemented\n", From patchwork Wed May 9 17:07:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135316 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5247lji; Wed, 9 May 2018 10:12:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpBfMX4nZ220MhS2fMePvign/aT2K9TJA3uRCRpniONfnPFgUMPydEahnkK3H/LGgCbWFZ8 X-Received: by 2002:a63:8e42:: with SMTP id k63-v6mr36343106pge.278.1525885968188; Wed, 09 May 2018 10:12:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885968; cv=none; d=google.com; s=arc-20160816; b=tn9sCUtUwq2WmSgpvHmiXRA0nKj0e6ApD6Y00ra4BpywyZUL55+TLOBZ9avzbww0xz B8twqcLr4+Y065x1lTKlE779HTfWkrGllxo/1OKUnAmTM+31xSuElDW0JhFJuAqmcnPl 9x2uagVGNEKzvGba9N52oRRzJTK29f+RN9A5OYpUtIQbGapKQeCURiuWRcJnoDcF6Xmv /qaGIL2J9Ak+ZpmJoGR9lhftUwIQo9GWluZp8twQ3KOeoB0/uJmvgutMPW0SYn2SdeLt 2vxeZzGyOh/qlz+mwtegHAVcG1cniR0A0pmqjFG6YTlIEtzazGYtzh2qBSEQqn5DNWoH xVLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8jFt+UTfxiKsTH+GwcTpxhw6rdgzjfdm3ZfkGrJmjxY=; b=T34ysQYEa6PmWQHSeSLe7orrWRODYzryB9PcY0ec7QLVolFKJVchh53EUoP8yeY6iL iO4JlP/7I/vef39j9SXDLGRbVnvDfeFKOIu78VzRkA5U9pk9MUqg8iYKLnaOFrO7G1QI uM8fGfkjy5lFUNRdBfNSkqFPtT6YUU5RvwCfK01Dr7cwd6ulg2Rvp5w5FnlTZ29C9fNh vLu+qerlcJkWMBGhVd6rSc4qiPa4Bve5QvDQyX5kRlcfvXPSqhJZxt2zbMU7Q9rOgp8T 2s2/K22/4LnO0FtADItEXgUYDUBDkWYgVtiU1ehBowTWisTfiamjQhllclqhUopRYKxM dXTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.47; Wed, 09 May 2018 10:12:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965691AbeEIRMr (ORCPT + 10 others); Wed, 9 May 2018 13:12:47 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47274 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMq (ORCPT ); Wed, 9 May 2018 13:12:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D57115BE; Wed, 9 May 2018 10:12:46 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 42FFE3F592; Wed, 9 May 2018 10:12:45 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 2/8] firmware: arm_scmi: fix kernel-docs documentation Date: Wed, 9 May 2018 18:07:08 +0100 Message-Id: <1525885634-22348-3-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There are few missing descriptions for function parameters and structure members along with certain instances where excessive function parameters or structure members are described. This patch fixes all of those warnings. Reported-by: Jonathan Cameron Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/base.c | 20 +++++++++-------- drivers/firmware/arm_scmi/common.h | 7 ++++-- drivers/firmware/arm_scmi/driver.c | 45 ++++++++++++++++++++------------------ include/linux/scmi_protocol.h | 8 +++++++ 4 files changed, 48 insertions(+), 32 deletions(-) -- 2.7.4 Reviewed-by: Jonathan Cameron diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c index 0d3806c0d432..c36ded9dbb83 100644 --- a/drivers/firmware/arm_scmi/base.c +++ b/drivers/firmware/arm_scmi/base.c @@ -26,7 +26,7 @@ struct scmi_msg_resp_base_attributes { * scmi_base_attributes_get() - gets the implementation details * that are associated with the base protocol. * - * @handle - SCMI entity handle + * @handle: SCMI entity handle * * Return: 0 on success, else appropriate SCMI error. */ @@ -50,14 +50,15 @@ static int scmi_base_attributes_get(const struct scmi_handle *handle) } scmi_one_xfer_put(handle, t); + return ret; } /** * scmi_base_vendor_id_get() - gets vendor/subvendor identifier ASCII string. * - * @handle - SCMI entity handle - * @sub_vendor - specify true if sub-vendor ID is needed + * @handle: SCMI entity handle + * @sub_vendor: specify true if sub-vendor ID is needed * * Return: 0 on success, else appropriate SCMI error. */ @@ -97,7 +98,7 @@ scmi_base_vendor_id_get(const struct scmi_handle *handle, bool sub_vendor) * implementation 32-bit version. The format of the version number is * vendor-specific * - * @handle - SCMI entity handle + * @handle: SCMI entity handle * * Return: 0 on success, else appropriate SCMI error. */ @@ -128,8 +129,8 @@ scmi_base_implementation_version_get(const struct scmi_handle *handle) * scmi_base_implementation_list_get() - gets the list of protocols it is * OSPM is allowed to access * - * @handle - SCMI entity handle - * @protocols_imp - pointer to hold the list of protocol identifiers + * @handle: SCMI entity handle + * @protocols_imp: pointer to hold the list of protocol identifiers * * Return: 0 on success, else appropriate SCMI error. */ @@ -173,15 +174,16 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle, } while (loop_num_ret); scmi_one_xfer_put(handle, t); + return ret; } /** * scmi_base_discover_agent_get() - discover the name of an agent * - * @handle - SCMI entity handle - * @id - Agent identifier - * @name - Agent identifier ASCII string + * @handle: SCMI entity handle + * @id: Agent identifier + * @name: Agent identifier ASCII string * * An agent id of 0 is reserved to identify the platform itself. * Generally operating system is represented as "OSPM" diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index e8f332c9c469..0821662a4633 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -51,8 +51,11 @@ struct scmi_msg_resp_prot_version { * @id: The identifier of the command being sent * @protocol_id: The identifier of the protocol used to send @id command * @seq: The token to identify the message. when a message/command returns, - * the platform returns the whole message header unmodified including - * the token. + * the platform returns the whole message header unmodified including + * the token + * @status: Status of the transfer once it's complete + * @poll_completion: Indicate if the transfer needs to be polled for + * completion or interrupt mode is used */ struct scmi_msg_hdr { u8 id; diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 917786d91f55..6fee11f06a66 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -51,7 +51,7 @@ enum scmi_error_codes { SCMI_ERR_MAX }; -/* List of all SCMI devices active in system */ +/* List of all SCMI devices active in system */ static LIST_HEAD(scmi_list); /* Protection for the entire list */ static DEFINE_MUTEX(scmi_list_mutex); @@ -68,7 +68,6 @@ static DEFINE_MUTEX(scmi_list_mutex); struct scmi_xfers_info { struct scmi_xfer *xfer_block; unsigned long *xfer_alloc_table; - /* protect transfer allocation */ spinlock_t xfer_lock; }; @@ -94,6 +93,7 @@ struct scmi_desc { * @payload: Transmit/Receive mailbox channel payload area * @dev: Reference to device in the SCMI hierarchy corresponding to this * channel + * @handle: Pointer to SCMI entity handle */ struct scmi_chan_info { struct mbox_client cl; @@ -104,7 +104,7 @@ struct scmi_chan_info { }; /** - * struct scmi_info - Structure representing a SCMI instance + * struct scmi_info - Structure representing a SCMI instance * * @dev: Device pointer * @desc: SoC description for this instance @@ -113,9 +113,9 @@ struct scmi_chan_info { * implementation version and (sub-)vendor identification. * @minfo: Message info * @tx_idr: IDR object to map protocol id to channel info pointer - * @protocols_imp: list of protocols implemented, currently maximum of + * @protocols_imp: List of protocols implemented, currently maximum of * MAX_PROTOCOLS_IMP elements allocated by the base protocol - * @node: list head + * @node: List head * @users: Number of users of this instance */ struct scmi_info { @@ -221,9 +221,7 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m) xfer_id = MSG_XTRACT_TOKEN(ioread32(&mem->msg_header)); - /* - * Are we even expecting this? - */ + /* Are we even expecting this? */ if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { dev_err(dev, "message for %d is not expected!\n", xfer_id); return; @@ -248,6 +246,8 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m) * * @hdr: pointer to header containing all the information on message id, * protocol id and sequence id. + * + * Return: 32-bit packed command header to be sent to the platform. */ static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr) { @@ -282,9 +282,9 @@ static void scmi_tx_prepare(struct mbox_client *cl, void *m) } /** - * scmi_one_xfer_get() - Allocate one message + * scmi_xfer_get() - Allocate one message * - * @handle: SCMI entity handle + * @handle: Pointer to SCMI entity handle * * Helper function which is used by various command functions that are * exposed to clients of this driver for allocating a message traffic event. @@ -326,8 +326,8 @@ static struct scmi_xfer *scmi_one_xfer_get(const struct scmi_handle *handle) /** * scmi_one_xfer_put() - Release a message * - * @minfo: transfer info pointer - * @xfer: message that was reserved by scmi_one_xfer_get + * @handle: Pointer to SCMI entity handle + * @xfer: message that was reserved by scmi_xfer_get * * This holds a spinlock to maintain integrity of internal data structures. */ @@ -374,12 +374,12 @@ static bool scmi_xfer_done_no_timeout(const struct scmi_chan_info *cinfo, /** * scmi_do_xfer() - Do one transfer * - * @info: Pointer to SCMI entity information + * @handle: Pointer to SCMI entity handle * @xfer: Transfer to initiate and wait for response * * Return: -ETIMEDOUT in case of no response, if transmit error, - * return corresponding error, else if all goes well, - * return 0. + * return corresponding error, else if all goes well, + * return 0. */ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) { @@ -438,9 +438,9 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) /** * scmi_one_xfer_init() - Allocate and initialise one message * - * @handle: SCMI entity handle + * @handle: Pointer to SCMI entity handle * @msg_id: Message identifier - * @msg_prot_id: Protocol identifier for the message + * @prot_id: Protocol identifier for the message * @tx_size: transmit message size * @rx_size: receive message size * @p: pointer to the allocated and initialised message @@ -478,13 +478,16 @@ int scmi_one_xfer_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id, xfer->hdr.poll_completion = false; *p = xfer; + return 0; } /** * scmi_version_get() - command to get the revision of the SCMI entity * - * @handle: Handle to SCMI entity information + * @handle: Pointer to SCMI entity handle + * @protocol: Protocol identifier for the message + * @version: Holds returned version of protocol. * * Updates the SCMI information in the internal data structure. * @@ -541,7 +544,7 @@ scmi_is_protocol_implemented(const struct scmi_handle *handle, u8 prot_id) * @dev: pointer to device for which we want SCMI handle * * NOTE: The function does not track individual clients of the framework - * and is expected to be maintained by caller of SCMI protocol library. + * and is expected to be maintained by caller of SCMI protocol library. * scmi_handle_put must be balanced with successful scmi_handle_get * * Return: pointer to handle if successful, NULL on error @@ -572,7 +575,7 @@ struct scmi_handle *scmi_handle_get(struct device *dev) * @handle: handle acquired by scmi_handle_get * * NOTE: The function does not track individual clients of the framework - * and is expected to be maintained by caller of SCMI protocol library. + * and is expected to be maintained by caller of SCMI protocol library. * scmi_handle_put must be balanced with successful scmi_handle_get * * Return: 0 is successfully released @@ -595,7 +598,7 @@ int scmi_handle_put(const struct scmi_handle *handle) } static const struct scmi_desc scmi_generic_desc = { - .max_rx_timeout_ms = 30, /* we may increase this if required */ + .max_rx_timeout_ms = 30, /* We may increase this if required */ .max_msg = 20, /* Limited by MBOX_TX_QUEUE_LEN */ .max_msg_size = 128, }; diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index b458c87b866c..a171c1e293e8 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -189,6 +189,14 @@ struct scmi_sensor_ops { * @perf_ops: pointer to set of performance protocol operations * @clk_ops: pointer to set of clock protocol operations * @sensor_ops: pointer to set of sensor protocol operations + * @perf_priv: pointer to private data structure specific to performance + * protocol(for internal use only) + * @clk_priv: pointer to private data structure specific to clock + * protocol(for internal use only) + * @power_priv: pointer to private data structure specific to power + * protocol(for internal use only) + * @sensor_priv: pointer to private data structure specific to sensors + * protocol(for internal use only) */ struct scmi_handle { struct device *dev; From patchwork Wed May 9 17:07:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135317 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5261lji; Wed, 9 May 2018 10:12:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwqS0Ez3LPBwieeTSz0d8+dCLk284DKKXbDSvPVhLd1ZcQdcEpp17SQSCbfrNKVyi9iBbf X-Received: by 10.98.68.156 with SMTP id m28mr38952742pfi.145.1525885969074; Wed, 09 May 2018 10:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885969; cv=none; d=google.com; s=arc-20160816; b=0gurLPIboIebcuz6IP21+hTPWXUy3L4VEeBAxcUiJJS/6CBDaiywWPi/dm6nHOUnLj RBsuzRpEULXsch4/TFNwoSpjJni8PaFeRGKuUOuNdJKobtuOY+7IiTujhflLWHgwcC6b 4Bc4DR5Wg0jp7yf9TJLU7jJN8P0TBV6J9lrJBSXInQB5WAskwqblUrfDFZAbI+UyNMXb KWzC6Dx14Tzi1Foe+7msOHKhS4P/m/W/z/zeA5CIGPKIbIwouf0nD4zi/NDdhiDXm70i aOL4voPoO0t8voeJZFjlAtu6uA/FGLxJKHXB0QTOF3Ff6HfLqEOfKGhCdtalBPzlREmb zfBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=0Owq8yOW6oWk0tkC9jKumjeYtnJtrkJuPF+5PVrDWtA=; b=xDvg0qvkq+VOckVEGxah6wwnhilRCyjOaxwJGwqM1BZiz0oaFS0Dw+Gs4W0kVEaF7o 2RrWB/rEeepQRd76ymv2HLxTE+E00ARp/bF/mTJGFgPcLKrQCsOwFVR2pm6CTUh26vUi C0NrZT2tqah/B8rKfg6U73UEGHRnh7D3znvJrk02aldBmij0noLaho2FKuJnl7BLEJhA 2W62Cype9k9uwuUDGWVvUeCjpUx2scYRqd/bZ2utHrOQZZ6Y3g+uzd1QGhC4GUSnrTga t+AXIP7V0KMYDI8N00M1esyFhuBychO6xvGbXUCwZj5nVisUiYk9ti77D73a/JpmxM+r YXyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.48; Wed, 09 May 2018 10:12:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965693AbeEIRMs (ORCPT + 10 others); Wed, 9 May 2018 13:12:48 -0400 Received: from foss.arm.com ([217.140.101.70]:47282 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMr (ORCPT ); Wed, 9 May 2018 13:12:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 55D581650; Wed, 9 May 2018 10:12:47 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6B65A3F592; Wed, 9 May 2018 10:12:46 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 3/8] firmware: arm_scmi: rename get_transition_latency and add_opps_to_device Date: Wed, 9 May 2018 18:07:09 +0100 Message-Id: <1525885634-22348-4-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Most of the scmi code follows the suggestion from Greg KH on a totally different thread[0] to have the subsystem name first, followed by the noun and finally the verb with couple of these exceptions. This patch fixes them so that all the functions names are aligned to on practice. [0] https://www.spinics.net/lists/arm-kernel/msg583673.html Signed-off-by: Sudeep Holla --- drivers/cpufreq/scmi-cpufreq.c | 4 ++-- drivers/firmware/arm_scmi/perf.c | 10 +++++----- include/linux/scmi_protocol.h | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) -- 2.7.4 Reviewed-by: Jonathan Cameron diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index b4dbc77459b6..50b1551ba894 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -117,7 +117,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) return -ENODEV; } - ret = handle->perf_ops->add_opps_to_device(handle, cpu_dev); + ret = handle->perf_ops->device_opps_add(handle, cpu_dev); if (ret) { dev_warn(cpu_dev, "failed to add opps to the device\n"); return ret; @@ -164,7 +164,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) /* SCMI allows DVFS request for any domain from any CPU */ policy->dvfs_possible_from_any_cpu = true; - latency = handle->perf_ops->get_transition_latency(handle, cpu_dev); + latency = handle->perf_ops->transition_latency_get(handle, cpu_dev); if (!latency) latency = CPUFREQ_ETERNAL; diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 987c64d19801..611ab08e6174 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -349,8 +349,8 @@ static int scmi_dev_domain_id(struct device *dev) return clkspec.args[0]; } -static int scmi_dvfs_add_opps_to_device(const struct scmi_handle *handle, - struct device *dev) +static int scmi_dvfs_device_opps_add(const struct scmi_handle *handle, + struct device *dev) { int idx, ret, domain; unsigned long freq; @@ -383,7 +383,7 @@ static int scmi_dvfs_add_opps_to_device(const struct scmi_handle *handle, return 0; } -static int scmi_dvfs_get_transition_latency(const struct scmi_handle *handle, +static int scmi_dvfs_transition_latency_get(const struct scmi_handle *handle, struct device *dev) { struct perf_dom_info *dom; @@ -432,8 +432,8 @@ static struct scmi_perf_ops perf_ops = { .level_set = scmi_perf_level_set, .level_get = scmi_perf_level_get, .device_domain_id = scmi_dev_domain_id, - .get_transition_latency = scmi_dvfs_get_transition_latency, - .add_opps_to_device = scmi_dvfs_add_opps_to_device, + .transition_latency_get = scmi_dvfs_transition_latency_get, + .device_opps_add = scmi_dvfs_device_opps_add, .freq_set = scmi_dvfs_freq_set, .freq_get = scmi_dvfs_freq_get, }; diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index a171c1e293e8..f4c9fc0fc755 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -85,8 +85,8 @@ struct scmi_clk_ops { * @level_set: sets the performance level of a domain * @level_get: gets the performance level of a domain * @device_domain_id: gets the scmi domain id for a given device - * @get_transition_latency: gets the DVFS transition latency for a given device - * @add_opps_to_device: adds all the OPPs for a given device + * @transition_latency_get: gets the DVFS transition latency for a given device + * @device_opps_add: adds all the OPPs for a given device * @freq_set: sets the frequency for a given device using sustained frequency * to sustained performance level mapping * @freq_get: gets the frequency for a given device using sustained frequency @@ -102,10 +102,10 @@ struct scmi_perf_ops { int (*level_get)(const struct scmi_handle *handle, u32 domain, u32 *level, bool poll); int (*device_domain_id)(struct device *dev); - int (*get_transition_latency)(const struct scmi_handle *handle, + int (*transition_latency_get)(const struct scmi_handle *handle, struct device *dev); - int (*add_opps_to_device)(const struct scmi_handle *handle, - struct device *dev); + int (*device_opps_add)(const struct scmi_handle *handle, + struct device *dev); int (*freq_set)(const struct scmi_handle *handle, u32 domain, unsigned long rate, bool poll); int (*freq_get)(const struct scmi_handle *handle, u32 domain, From patchwork Wed May 9 17:07:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135318 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5287lji; Wed, 9 May 2018 10:12:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqLUV9oiffeVyirs3P2XiMm6D3Rcs2Z3LQphPEBd17+kkBhBG5Ir66JG+KsUKs9dzz1q95M X-Received: by 2002:a63:7150:: with SMTP id b16-v6mr36482223pgn.326.1525885970601; Wed, 09 May 2018 10:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885970; cv=none; d=google.com; s=arc-20160816; b=QKg28CwqenpQgWxi3lUC1Xr0FMj2aoUp1TIAh0oShybRavXu0dR+vNKTq8ypchwe8l h1ShvP1O6Gc/I3HHMIoVuwTwSsTV8I4HT22FjLfz5wtoADqzVdJhFd5NG2tubJHBxVGI FbSoAFB1manphGz1MQO0slZp/sb/JjpTLgBfvsFzbhllYPYdFvShVMx2/dIBreKenMfr kuDGt6zGgbnmHM6tlmKpFcVkuNcOJvyY8VOhODr7ewynZ5m5JKGi+MnTClhBMHspR03M S1bAxsl7SNN+Ah2ULG7GrXUsChgMnpOR+KtQqtIRjmkM8NIYMv2+VBcwsxPY8+saIF8G oEOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=65LwbFPXY+ltIAxGYMXL85odMvgV4N0113nFTFFNFj4=; b=McqTNc5AU07s2UAIDxJKPFIf3/myAMMU7A7HOkZKAy9xrd3SHtYdnkKjacGCq92wAu EZAmgRFC45J5GnRforGwQYXicIsLPNyAv8mqqWf0dN6LJWECW3xZFMgBEELVO/ECSIYT E2AyujBFyxo3KuO6y8kv7KZbKGGThcE75ebViT54pUKmQhUedG2UN2TDeDaOvVmYATsB lDxnr8k+ic7jl+FktpT5jpJG0OYFEG+G0cLfFvwx0+EyWNhwGyQFIdFbUYjdmug3H0q6 omF7BiUNuMpaA7M6Jg9f59cs0ke/LSjcd5tDqRrGJ+3H65C0krKZ1oNt/tp1nNx/GGXS 8Lrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.50; Wed, 09 May 2018 10:12:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965698AbeEIRMt (ORCPT + 10 others); Wed, 9 May 2018 13:12:49 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47296 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMs (ORCPT ); Wed, 9 May 2018 13:12:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A1016165C; Wed, 9 May 2018 10:12:48 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 939853F592; Wed, 9 May 2018 10:12:47 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 4/8] firmware: arm_scmi: rename scmi_xfer_{init,get,put} Date: Wed, 9 May 2018 18:07:10 +0100 Message-Id: <1525885634-22348-5-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Just after the initial patches were queued, Jonathan Cameron mentioned that scmi_one_xfer_{get_put} were not very clear and suggested to use scmi_xfer_{alloc,free}. While I agree to some extent, the reason not to have alloc/free as these are preallocated buffers and these functions just returns a reference to free slot in that preallocated array. However it was agreed to drop "_one" as it's implicit that we are always dealing with one slot anyways. This patch updates the name accordingly dropping "_one" in both {get,put} functions. Also scmi_one_xfer_init is renamed as scmi_xfer_get_init to reflect the fact that it gets the free slots and then initialise it. Reported-by: Jonathan Cameron Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/base.c | 23 +++++++++++++---------- drivers/firmware/arm_scmi/clock.c | 24 ++++++++++++------------ drivers/firmware/arm_scmi/common.h | 4 ++-- drivers/firmware/arm_scmi/driver.c | 20 ++++++++++---------- drivers/firmware/arm_scmi/perf.c | 28 ++++++++++++++-------------- drivers/firmware/arm_scmi/power.c | 16 ++++++++-------- drivers/firmware/arm_scmi/sensors.c | 20 ++++++++++---------- 7 files changed, 69 insertions(+), 66 deletions(-) -- 2.7.4 Reviewed-by: Jonathan Cameron diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c index c36ded9dbb83..9dff33ea6416 100644 --- a/drivers/firmware/arm_scmi/base.c +++ b/drivers/firmware/arm_scmi/base.c @@ -37,7 +37,7 @@ static int scmi_base_attributes_get(const struct scmi_handle *handle) struct scmi_msg_resp_base_attributes *attr_info; struct scmi_revision_info *rev = handle->version; - ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES, + ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES, SCMI_PROTOCOL_BASE, 0, sizeof(*attr_info), &t); if (ret) return ret; @@ -49,7 +49,7 @@ static int scmi_base_attributes_get(const struct scmi_handle *handle) rev->num_agents = attr_info->num_agents; } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -81,7 +81,7 @@ scmi_base_vendor_id_get(const struct scmi_handle *handle, bool sub_vendor) size = ARRAY_SIZE(rev->vendor_id); } - ret = scmi_one_xfer_init(handle, cmd, SCMI_PROTOCOL_BASE, 0, size, &t); + ret = scmi_xfer_get_init(handle, cmd, SCMI_PROTOCOL_BASE, 0, size, &t); if (ret) return ret; @@ -89,7 +89,8 @@ scmi_base_vendor_id_get(const struct scmi_handle *handle, bool sub_vendor) if (!ret) memcpy(vendor_id, t->rx.buf, size); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); + return ret; } @@ -110,7 +111,7 @@ scmi_base_implementation_version_get(const struct scmi_handle *handle) struct scmi_xfer *t; struct scmi_revision_info *rev = handle->version; - ret = scmi_one_xfer_init(handle, BASE_DISCOVER_IMPLEMENT_VERSION, + ret = scmi_xfer_get_init(handle, BASE_DISCOVER_IMPLEMENT_VERSION, SCMI_PROTOCOL_BASE, 0, sizeof(*impl_ver), &t); if (ret) return ret; @@ -121,7 +122,8 @@ scmi_base_implementation_version_get(const struct scmi_handle *handle) rev->impl_ver = le32_to_cpu(*impl_ver); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); + return ret; } @@ -144,7 +146,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle, u32 tot_num_ret = 0, loop_num_ret; struct device *dev = handle->dev; - ret = scmi_one_xfer_init(handle, BASE_DISCOVER_LIST_PROTOCOLS, + ret = scmi_xfer_get_init(handle, BASE_DISCOVER_LIST_PROTOCOLS, SCMI_PROTOCOL_BASE, sizeof(*num_skip), 0, &t); if (ret) return ret; @@ -173,7 +175,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle, tot_num_ret += loop_num_ret; } while (loop_num_ret); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -196,7 +198,7 @@ static int scmi_base_discover_agent_get(const struct scmi_handle *handle, int ret; struct scmi_xfer *t; - ret = scmi_one_xfer_init(handle, BASE_DISCOVER_AGENT, + ret = scmi_xfer_get_init(handle, BASE_DISCOVER_AGENT, SCMI_PROTOCOL_BASE, sizeof(__le32), SCMI_MAX_STR_SIZE, &t); if (ret) @@ -208,7 +210,8 @@ static int scmi_base_discover_agent_get(const struct scmi_handle *handle, if (!ret) memcpy(name, t->rx.buf, SCMI_MAX_STR_SIZE); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); + return ret; } diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index e6f17825db79..3874666a8a14 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -77,7 +77,7 @@ static int scmi_clock_protocol_attributes_get(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_resp_clock_protocol_attributes *attr; - ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES, + ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES, SCMI_PROTOCOL_CLOCK, 0, sizeof(*attr), &t); if (ret) return ret; @@ -90,7 +90,7 @@ static int scmi_clock_protocol_attributes_get(const struct scmi_handle *handle, ci->max_async_req = attr->max_async_req; } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -101,7 +101,7 @@ static int scmi_clock_attributes_get(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_resp_clock_attributes *attr; - ret = scmi_one_xfer_init(handle, CLOCK_ATTRIBUTES, SCMI_PROTOCOL_CLOCK, + ret = scmi_xfer_get_init(handle, CLOCK_ATTRIBUTES, SCMI_PROTOCOL_CLOCK, sizeof(clk_id), sizeof(*attr), &t); if (ret) return ret; @@ -115,7 +115,7 @@ static int scmi_clock_attributes_get(const struct scmi_handle *handle, else clk->name[0] = '\0'; - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -132,7 +132,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id, struct scmi_msg_clock_describe_rates *clk_desc; struct scmi_msg_resp_clock_describe_rates *rlist; - ret = scmi_one_xfer_init(handle, CLOCK_DESCRIBE_RATES, + ret = scmi_xfer_get_init(handle, CLOCK_DESCRIBE_RATES, SCMI_PROTOCOL_CLOCK, sizeof(*clk_desc), 0, &t); if (ret) return ret; @@ -186,7 +186,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id, clk->list.num_rates = tot_rate_cnt; err: - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -196,7 +196,7 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value) int ret; struct scmi_xfer *t; - ret = scmi_one_xfer_init(handle, CLOCK_RATE_GET, SCMI_PROTOCOL_CLOCK, + ret = scmi_xfer_get_init(handle, CLOCK_RATE_GET, SCMI_PROTOCOL_CLOCK, sizeof(__le32), sizeof(u64), &t); if (ret) return ret; @@ -211,7 +211,7 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value) *value |= (u64)le32_to_cpu(*(pval + 1)) << 32; } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -222,7 +222,7 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id, struct scmi_xfer *t; struct scmi_clock_set_rate *cfg; - ret = scmi_one_xfer_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK, + ret = scmi_xfer_get_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK, sizeof(*cfg), 0, &t); if (ret) return ret; @@ -235,7 +235,7 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id, ret = scmi_do_xfer(handle, t); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -246,7 +246,7 @@ scmi_clock_config_set(const struct scmi_handle *handle, u32 clk_id, u32 config) struct scmi_xfer *t; struct scmi_clock_set_config *cfg; - ret = scmi_one_xfer_init(handle, CLOCK_CONFIG_SET, SCMI_PROTOCOL_CLOCK, + ret = scmi_xfer_get_init(handle, CLOCK_CONFIG_SET, SCMI_PROTOCOL_CLOCK, sizeof(*cfg), 0, &t); if (ret) return ret; @@ -257,7 +257,7 @@ scmi_clock_config_set(const struct scmi_handle *handle, u32 clk_id, u32 config) ret = scmi_do_xfer(handle, t); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 0821662a4633..41b03e46cca8 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -95,9 +95,9 @@ struct scmi_xfer { struct completion done; }; -void scmi_one_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer); +void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer); int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer); -int scmi_one_xfer_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id, +int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id, size_t tx_size, size_t rx_size, struct scmi_xfer **p); int scmi_handle_put(const struct scmi_handle *handle); struct scmi_handle *scmi_handle_get(struct device *dev); diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 6fee11f06a66..33d2b78af3ff 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -295,7 +295,7 @@ static void scmi_tx_prepare(struct mbox_client *cl, void *m) * * Return: 0 if all went fine, else corresponding error. */ -static struct scmi_xfer *scmi_one_xfer_get(const struct scmi_handle *handle) +static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle) { u16 xfer_id; struct scmi_xfer *xfer; @@ -324,14 +324,14 @@ static struct scmi_xfer *scmi_one_xfer_get(const struct scmi_handle *handle) } /** - * scmi_one_xfer_put() - Release a message + * scmi_xfer_put() - Release a message * * @handle: Pointer to SCMI entity handle * @xfer: message that was reserved by scmi_xfer_get * * This holds a spinlock to maintain integrity of internal data structures. */ -void scmi_one_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer) +void scmi_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer) { unsigned long flags; struct scmi_info *info = handle_to_scmi_info(handle); @@ -436,7 +436,7 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) } /** - * scmi_one_xfer_init() - Allocate and initialise one message + * scmi_xfer_get_init() - Allocate and initialise one message * * @handle: Pointer to SCMI entity handle * @msg_id: Message identifier @@ -445,13 +445,13 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) * @rx_size: receive message size * @p: pointer to the allocated and initialised message * - * This function allocates the message using @scmi_one_xfer_get and + * This function allocates the message using @scmi_xfer_get and * initialise the header. * * Return: 0 if all went fine with @p pointing to message, else * corresponding error. */ -int scmi_one_xfer_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id, +int scmi_xfer_get_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id, size_t tx_size, size_t rx_size, struct scmi_xfer **p) { int ret; @@ -464,7 +464,7 @@ int scmi_one_xfer_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id, tx_size > info->desc->max_msg_size) return -ERANGE; - xfer = scmi_one_xfer_get(handle); + xfer = scmi_xfer_get(handle); if (IS_ERR(xfer)) { ret = PTR_ERR(xfer); dev_err(dev, "failed to get free message slot(%d)\n", ret); @@ -500,7 +500,7 @@ int scmi_version_get(const struct scmi_handle *handle, u8 protocol, __le32 *rev_info; struct scmi_xfer *t; - ret = scmi_one_xfer_init(handle, PROTOCOL_VERSION, protocol, 0, + ret = scmi_xfer_get_init(handle, PROTOCOL_VERSION, protocol, 0, sizeof(*version), &t); if (ret) return ret; @@ -511,7 +511,7 @@ int scmi_version_get(const struct scmi_handle *handle, u8 protocol, *version = le32_to_cpu(*rev_info); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -539,7 +539,7 @@ scmi_is_protocol_implemented(const struct scmi_handle *handle, u8 prot_id) } /** - * scmi_handle_get() - Get the SCMI handle for a device + * scmi_handle_get() - Get the SCMI handle for a device * * @dev: pointer to device for which we want SCMI handle * diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 611ab08e6174..2a219b1261b1 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -115,7 +115,7 @@ static int scmi_perf_attributes_get(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_resp_perf_attributes *attr; - ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES, + ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES, SCMI_PROTOCOL_PERF, 0, sizeof(*attr), &t); if (ret) return ret; @@ -133,7 +133,7 @@ static int scmi_perf_attributes_get(const struct scmi_handle *handle, pi->stats_size = le32_to_cpu(attr->stats_size); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -145,7 +145,7 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain, struct scmi_xfer *t; struct scmi_msg_resp_perf_domain_attributes *attr; - ret = scmi_one_xfer_init(handle, PERF_DOMAIN_ATTRIBUTES, + ret = scmi_xfer_get_init(handle, PERF_DOMAIN_ATTRIBUTES, SCMI_PROTOCOL_PERF, sizeof(domain), sizeof(*attr), &t); if (ret) @@ -171,7 +171,7 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain, memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -194,7 +194,7 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain, struct scmi_msg_perf_describe_levels *dom_info; struct scmi_msg_resp_perf_describe_levels *level_info; - ret = scmi_one_xfer_init(handle, PERF_DESCRIBE_LEVELS, + ret = scmi_xfer_get_init(handle, PERF_DESCRIBE_LEVELS, SCMI_PROTOCOL_PERF, sizeof(*dom_info), 0, &t); if (ret) return ret; @@ -237,7 +237,7 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain, } while (num_returned && num_remaining); perf_dom->opp_count = tot_opp_cnt; - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); sort(perf_dom->opp, tot_opp_cnt, sizeof(*opp), opp_cmp_func, NULL); return ret; @@ -250,7 +250,7 @@ static int scmi_perf_limits_set(const struct scmi_handle *handle, u32 domain, struct scmi_xfer *t; struct scmi_perf_set_limits *limits; - ret = scmi_one_xfer_init(handle, PERF_LIMITS_SET, SCMI_PROTOCOL_PERF, + ret = scmi_xfer_get_init(handle, PERF_LIMITS_SET, SCMI_PROTOCOL_PERF, sizeof(*limits), 0, &t); if (ret) return ret; @@ -262,7 +262,7 @@ static int scmi_perf_limits_set(const struct scmi_handle *handle, u32 domain, ret = scmi_do_xfer(handle, t); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -273,7 +273,7 @@ static int scmi_perf_limits_get(const struct scmi_handle *handle, u32 domain, struct scmi_xfer *t; struct scmi_perf_get_limits *limits; - ret = scmi_one_xfer_init(handle, PERF_LIMITS_GET, SCMI_PROTOCOL_PERF, + ret = scmi_xfer_get_init(handle, PERF_LIMITS_GET, SCMI_PROTOCOL_PERF, sizeof(__le32), 0, &t); if (ret) return ret; @@ -288,7 +288,7 @@ static int scmi_perf_limits_get(const struct scmi_handle *handle, u32 domain, *min_perf = le32_to_cpu(limits->min_level); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -299,7 +299,7 @@ static int scmi_perf_level_set(const struct scmi_handle *handle, u32 domain, struct scmi_xfer *t; struct scmi_perf_set_level *lvl; - ret = scmi_one_xfer_init(handle, PERF_LEVEL_SET, SCMI_PROTOCOL_PERF, + ret = scmi_xfer_get_init(handle, PERF_LEVEL_SET, SCMI_PROTOCOL_PERF, sizeof(*lvl), 0, &t); if (ret) return ret; @@ -311,7 +311,7 @@ static int scmi_perf_level_set(const struct scmi_handle *handle, u32 domain, ret = scmi_do_xfer(handle, t); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -321,7 +321,7 @@ static int scmi_perf_level_get(const struct scmi_handle *handle, u32 domain, int ret; struct scmi_xfer *t; - ret = scmi_one_xfer_init(handle, PERF_LEVEL_GET, SCMI_PROTOCOL_PERF, + ret = scmi_xfer_get_init(handle, PERF_LEVEL_GET, SCMI_PROTOCOL_PERF, sizeof(u32), sizeof(u32), &t); if (ret) return ret; @@ -333,7 +333,7 @@ static int scmi_perf_level_get(const struct scmi_handle *handle, u32 domain, if (!ret) *level = le32_to_cpu(*(__le32 *)t->rx.buf); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } diff --git a/drivers/firmware/arm_scmi/power.c b/drivers/firmware/arm_scmi/power.c index 087c2876cdf2..cfa033b05aed 100644 --- a/drivers/firmware/arm_scmi/power.c +++ b/drivers/firmware/arm_scmi/power.c @@ -63,7 +63,7 @@ static int scmi_power_attributes_get(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_resp_power_attributes *attr; - ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES, + ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES, SCMI_PROTOCOL_POWER, 0, sizeof(*attr), &t); if (ret) return ret; @@ -78,7 +78,7 @@ static int scmi_power_attributes_get(const struct scmi_handle *handle, pi->stats_size = le32_to_cpu(attr->stats_size); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -90,7 +90,7 @@ scmi_power_domain_attributes_get(const struct scmi_handle *handle, u32 domain, struct scmi_xfer *t; struct scmi_msg_resp_power_domain_attributes *attr; - ret = scmi_one_xfer_init(handle, POWER_DOMAIN_ATTRIBUTES, + ret = scmi_xfer_get_init(handle, POWER_DOMAIN_ATTRIBUTES, SCMI_PROTOCOL_POWER, sizeof(domain), sizeof(*attr), &t); if (ret) @@ -109,7 +109,7 @@ scmi_power_domain_attributes_get(const struct scmi_handle *handle, u32 domain, memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -120,7 +120,7 @@ scmi_power_state_set(const struct scmi_handle *handle, u32 domain, u32 state) struct scmi_xfer *t; struct scmi_power_set_state *st; - ret = scmi_one_xfer_init(handle, POWER_STATE_SET, SCMI_PROTOCOL_POWER, + ret = scmi_xfer_get_init(handle, POWER_STATE_SET, SCMI_PROTOCOL_POWER, sizeof(*st), 0, &t); if (ret) return ret; @@ -132,7 +132,7 @@ scmi_power_state_set(const struct scmi_handle *handle, u32 domain, u32 state) ret = scmi_do_xfer(handle, t); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -142,7 +142,7 @@ scmi_power_state_get(const struct scmi_handle *handle, u32 domain, u32 *state) int ret; struct scmi_xfer *t; - ret = scmi_one_xfer_init(handle, POWER_STATE_GET, SCMI_PROTOCOL_POWER, + ret = scmi_xfer_get_init(handle, POWER_STATE_GET, SCMI_PROTOCOL_POWER, sizeof(u32), sizeof(u32), &t); if (ret) return ret; @@ -153,7 +153,7 @@ scmi_power_state_get(const struct scmi_handle *handle, u32 domain, u32 *state) if (!ret) *state = le32_to_cpu(*(__le32 *)t->rx.buf); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index bbb469fea0ed..27f2092b9882 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -79,7 +79,7 @@ static int scmi_sensor_attributes_get(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_resp_sensor_attributes *attr; - ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES, + ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES, SCMI_PROTOCOL_SENSOR, 0, sizeof(*attr), &t); if (ret) return ret; @@ -95,7 +95,7 @@ static int scmi_sensor_attributes_get(const struct scmi_handle *handle, si->reg_size = le32_to_cpu(attr->reg_size); } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -108,7 +108,7 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_resp_sensor_description *buf; - ret = scmi_one_xfer_init(handle, SENSOR_DESCRIPTION_GET, + ret = scmi_xfer_get_init(handle, SENSOR_DESCRIPTION_GET, SCMI_PROTOCOL_SENSOR, sizeof(__le32), 0, &t); if (ret) return ret; @@ -150,7 +150,7 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle, */ } while (num_returned && num_remaining); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -162,7 +162,7 @@ scmi_sensor_configuration_set(const struct scmi_handle *handle, u32 sensor_id) struct scmi_xfer *t; struct scmi_msg_set_sensor_config *cfg; - ret = scmi_one_xfer_init(handle, SENSOR_CONFIG_SET, + ret = scmi_xfer_get_init(handle, SENSOR_CONFIG_SET, SCMI_PROTOCOL_SENSOR, sizeof(*cfg), 0, &t); if (ret) return ret; @@ -173,7 +173,7 @@ scmi_sensor_configuration_set(const struct scmi_handle *handle, u32 sensor_id) ret = scmi_do_xfer(handle, t); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -185,7 +185,7 @@ static int scmi_sensor_trip_point_set(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_set_sensor_trip_point *trip; - ret = scmi_one_xfer_init(handle, SENSOR_TRIP_POINT_SET, + ret = scmi_xfer_get_init(handle, SENSOR_TRIP_POINT_SET, SCMI_PROTOCOL_SENSOR, sizeof(*trip), 0, &t); if (ret) return ret; @@ -198,7 +198,7 @@ static int scmi_sensor_trip_point_set(const struct scmi_handle *handle, ret = scmi_do_xfer(handle, t); - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } @@ -209,7 +209,7 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle, struct scmi_xfer *t; struct scmi_msg_sensor_reading_get *sensor; - ret = scmi_one_xfer_init(handle, SENSOR_READING_GET, + ret = scmi_xfer_get_init(handle, SENSOR_READING_GET, SCMI_PROTOCOL_SENSOR, sizeof(*sensor), sizeof(u64), &t); if (ret) @@ -227,7 +227,7 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle, *value |= (u64)le32_to_cpu(*(pval + 1)) << 32; } - scmi_one_xfer_put(handle, t); + scmi_xfer_put(handle, t); return ret; } From patchwork Wed May 9 17:07:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135319 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5306lji; Wed, 9 May 2018 10:12:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrfRnleKDvmZcHSWVngh9HSultuqpBoFGWZKuuc9WOOkNG+04qg+WYTpnQkPfVumlQQ63TC X-Received: by 2002:a63:344c:: with SMTP id b73-v6mr36874608pga.258.1525885971645; Wed, 09 May 2018 10:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885971; cv=none; d=google.com; s=arc-20160816; b=gU6l78SLtS4SYxKQIi6RIe4vbS2nnwFx8qR7IwB4JSJ+LjxCT/56LoPeNfA6Ms6Kqz YOCiQZvKqeIlslkCJZ0OkXAYuurpX/eke4oYRA94vZ2Refap04OJqB5EaV5T3RHruufc FOMav00WsTtr79Dmt9REqFmQyEaB7t3DSwnEz8DURiYQPjpmleS2a4XAHfH0tjg1xWwB fv1nlCQ4MKIOoAw/AqIL0EIjo1j4hxNRXrm8Eo8kwlXqHNda4WOX5a5Sdp4WZnz1sRkd ZA/dyR5KkvghcVENJxYYJrhlQobtv0uQwsoXRSFe9KKnOVQxRHCuFrzdnT1OfxUlrwa9 qK0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Ra2hd88TeTDAMI5wsOlsTnN3+HYxGH7HD8Z5cHWpvjo=; b=0MTv7X+dl5CdgRabZvQZ5qzV2avciT1/I4S6zDxk2GjCduoVqsnE03tZ3VTrfYWOoK 1IGTBg1BCpwICGEY+QOUOxwrLhIEwvdedceZYW/2vhbFOHfglFURT3COfiIKdAM1Hc6/ mqvKlV9/Rpbf+WJJ47VlS2WulZFMFUjUE0SvV3VTZYd0rmwuAvPnUSah4rVFRtHenyWl nigIwOzWOcYltd++V86uKwrejXpo+VNYhB66Bhn5UXqgKgSN7Y6+WFs36TFHDlPnCR04 vbwE32S8Y1Gi7odIktyPvWfWlqbbf+2Us+N1Hc4AY4csflH8/r2J90//ehNSqX+/pQXR StcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.51; Wed, 09 May 2018 10:12:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965699AbeEIRMu (ORCPT + 10 others); Wed, 9 May 2018 13:12:50 -0400 Received: from foss.arm.com ([217.140.101.70]:47308 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMu (ORCPT ); Wed, 9 May 2018 13:12:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2674165D; Wed, 9 May 2018 10:12:49 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF42B3F592; Wed, 9 May 2018 10:12:48 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 5/8] firmware: arm_scmi: drop unused `con_priv` structure member Date: Wed, 9 May 2018 18:07:11 +0100 Message-Id: <1525885634-22348-6-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Initially con_priv was supposedly used for transport specific data when the SCMI driver had an abstraction to communicate with different mailbox controllers. But after some discussions, the idea was dropped but this variable slipped through the cracks. This patch gets rid of this unused variable. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/common.h | 2 -- 1 file changed, 2 deletions(-) -- 2.7.4 Acked-by: Jonathan Cameron diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 41b03e46cca8..937a930ce87d 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -86,9 +86,7 @@ struct scmi_msg { * buffer for the rx path as we use for the tx path. * @done: completion event */ - struct scmi_xfer { - void *con_priv; struct scmi_msg_hdr hdr; struct scmi_msg tx; struct scmi_msg rx; From patchwork Wed May 9 17:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135320 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5313lji; Wed, 9 May 2018 10:12:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpszwMPln1Mqf9tRKALHY+LFl1Jk50hmUPEGGL++QfI5Uf9Ad5jfC7PAH8SIrF56qES/sGu X-Received: by 2002:a17:902:bc4a:: with SMTP id t10-v6mr46341152plz.343.1525885972493; Wed, 09 May 2018 10:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885972; cv=none; d=google.com; s=arc-20160816; b=YGnhkbwcjjf2Mzo2nwMrQ76JxJrrMog0Jn9Jcvxl6hWmjnnS4Zk7c8QuwgixRNbzZC pP79r24Nn2sAafTg9160Ubd3f1bZKm81vuvrluqJtAONjYhtTv6/ACuJnJ6eZrOKc7dA EpEw0lPziqgEnAWCR9DwOzkG+ig6jTY8H0YDdFQ7LBtVXvunaW9cVZ7IB4LIVeAkgj4x vyoayDvz8BSSuB2hOhqW02vFKNvJl9hljl/ViaYT22BF7fDcmQ+ZyaRdsaZ36jenDG+w +DWVFnlnIEKVmfpk3wp9AXV9548sg5hdlUdhLav5CLreT1/RlNIj4OussPSrvR1fGTjT VW2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=vtbHm+gTyWZ/MaBqLpSIPqxY+ZL+z3fd9U2PXx8ehzM=; b=sjQN4gU9ZJfumzP+djQvvsIf/JxVNEXRfKI5RZuOGuOBbt72KtpAK/zlpPaAoiw5cZ I7CoaB5O/r6LYG/YNkg+929RB4nm0G0BoTtGhGpp++TtszQPp3CspPRIwmz53iQa3qYs bcybRTdceh9AzvDbrwolroT50o3EmPb59UbKwoqWq1plCDxa4NBONyRiJN9BBtooHzPt srFO6VaXo9kigB8yL9d5Xpl0s4/Uzdz1+OtKHp1dpVn0jZRs+RQIU3yNvG38WtNpTHEO NDm1Nl/7l4zz7/DHeBMYieIi3k0mnrpIu/OGC1+Ex9PJkdYaB9qwQcQH1trWCnPrZpxO ojSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.52; Wed, 09 May 2018 10:12:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965701AbeEIRMv (ORCPT + 10 others); Wed, 9 May 2018 13:12:51 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47312 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMv (ORCPT ); Wed, 9 May 2018 13:12:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0F0221684; Wed, 9 May 2018 10:12:51 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1C57B3F592; Wed, 9 May 2018 10:12:49 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 6/8] firmware: arm_scmi: remove unnecessary bitmap_zero Date: Wed, 9 May 2018 18:07:12 +0100 Message-Id: <1525885634-22348-7-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org kcalloc zeros the memory and it's totally unnecessary to zero the bitmap again using bitmap_zero. This patch just drops the unnecessary use of the bitmap_zero in the context. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 2 -- 1 file changed, 2 deletions(-) -- 2.7.4 Acked-by: Jonathan Cameron diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 33d2b78af3ff..4087d6c50ecd 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -636,8 +636,6 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo) if (!info->xfer_alloc_table) return -ENOMEM; - bitmap_zero(info->xfer_alloc_table, desc->max_msg); - /* Pre-initialize the buffer pointer to pre-allocated buffers */ for (i = 0, xfer = info->xfer_block; i < desc->max_msg; i++, xfer++) { xfer->rx.buf = devm_kcalloc(dev, sizeof(u8), desc->max_msg_size, From patchwork Wed May 9 17:07:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135321 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5333lji; Wed, 9 May 2018 10:12:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqEowJOx1o2QQIGFCHvW+771gy4ipz36xz+YVYA8CbjQMbrkLqqPaAVDrUHyzpqX14J40Dp X-Received: by 10.98.68.156 with SMTP id m28mr38952969pfi.145.1525885973781; Wed, 09 May 2018 10:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885973; cv=none; d=google.com; s=arc-20160816; b=I57lHvEJlihQAKszMh5xIHxZLETi3SAWt1sn4/ANQQkgxqLySZWwwUkqwmwLZclNg1 Yn/IgJrH33Z4rW7UAri51HP/AEWD0WRzEOONRNh9zVa5UnJpTpzZsjz9FRCSBJ4qjD61 Nj3CjGmg0ugS3MS3nMyadq41TYUVdE4/Vc+JuebFUsOqG3VueY0cUYNc0vfRiUbfYV0a HSPBwIWDV9hwd/nSb3bd/QpIrrw5LHyNbSeRPlHplGmz9BABTIdnoYo4wzaxF9EzUtQ9 CaM+/cKCwQjxubfsfXizuGpFg1700xplhrtik/pomjXuBKWMoMAotrIqvknmaZWy0zOx OYuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KesC0CFhmLFMd8FtDA4gLMiF0yDXzpyiuDGouz1OxhY=; b=V3mlfWhWo4SGHqdnZ+jaR/YeJB3HPunyCq4s307vnMXss+Ni7Su9oAjuEtmPfDvozD 7ISYGvCMP8C5bwia1wIIjM8EH4e7JRaLxsuvHq54fVu0GGob3x9svIWGSxoxqHkuYRyt uTb2/7qao0B96qbkL0uH9uTLJkA7bJ21EW7+hL1WJHu0BzOU/jZKdbnMn50wqnIjVzlP XUvbRSGGChZc/d5jf79Fp7Vr+R5AnvphnVtIUuYvtBuWwB2vDBpHjK/n3zNwkHMuCZd+ mNpsEdMmtqDC3qxysgrt0ffiKu5Sc9w9N2mosgv9WXG4dhRniocIxZNoPPCnBnqtCpHa ErCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.53; Wed, 09 May 2018 10:12:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965704AbeEIRMw (ORCPT + 10 others); Wed, 9 May 2018 13:12:52 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47326 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMw (ORCPT ); Wed, 9 May 2018 13:12:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3729F1688; Wed, 9 May 2018 10:12:52 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D2693F592; Wed, 9 May 2018 10:12:51 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 7/8] firmware: arm_scmi: improve exit paths and code readability Date: Wed, 9 May 2018 18:07:13 +0100 Message-Id: <1525885634-22348-8-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The existing code intends the good path to reduce the code which is so uncommon. It's obvious to have more readable code with a goto used for the error path. This patch adds more appropriate error paths and makes code more readable. It also moves a error logging outside the scope of locking. Suggested-by: Jonathan Cameron Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.7.4 Reviewed-by: Jonathan Cameron diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index f2760a596c28..472c88ae1c0f 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -125,13 +125,13 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol) int id, retval; struct scmi_device *scmi_dev; - id = ida_simple_get(&scmi_bus_id, 1, 0, GFP_KERNEL); - if (id < 0) - return NULL; - scmi_dev = kzalloc(sizeof(*scmi_dev), GFP_KERNEL); if (!scmi_dev) - goto no_mem; + return NULL; + + id = ida_simple_get(&scmi_bus_id, 1, 0, GFP_KERNEL); + if (id < 0) + goto free_mem; scmi_dev->id = id; scmi_dev->protocol_id = protocol; @@ -141,13 +141,15 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol) dev_set_name(&scmi_dev->dev, "scmi_dev.%d", id); retval = device_register(&scmi_dev->dev); - if (!retval) - return scmi_dev; + if (retval) + goto put_dev; + return scmi_dev; +put_dev: put_device(&scmi_dev->dev); - kfree(scmi_dev); -no_mem: ida_simple_remove(&scmi_bus_id, id); +free_mem: + kfree(scmi_dev); return NULL; } @@ -171,9 +173,9 @@ int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn) spin_lock(&protocol_lock); ret = idr_alloc(&scmi_protocols, fn, protocol_id, protocol_id + 1, GFP_ATOMIC); + spin_unlock(&protocol_lock); if (ret != protocol_id) pr_err("unable to allocate SCMI idr slot, err %d\n", ret); - spin_unlock(&protocol_lock); return ret; } From patchwork Wed May 9 17:07:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 135322 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5359lji; Wed, 9 May 2018 10:12:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoKk66w2Qlz19ABk+rj10Pp1FLv3hRjcPS7D/LkEFurRqsIqniX/hQnlN42Mhmah2jO9C1f X-Received: by 10.98.100.2 with SMTP id y2mr31160868pfb.71.1525885974918; Wed, 09 May 2018 10:12:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525885974; cv=none; d=google.com; s=arc-20160816; b=vm7N+5+NeseHENTn36dMGKvo07PmpbBBqKgZ9mYnEYnx/DnA6ubPPLIm/m6IJwGY3Y ulodj35ZdwYNEiJi6eYaROkIIz0YAZOiwzie7wUb/CSbb3B3hnULCJh9RO3+ElCrnwEr xOGs5pXttu/Bn8OEzaE8/KcLwODYn6bMhfGCGMG6gjVKPf13oK9BjItP6Tyd6GBQRyrj 2tHoObwSn/n0MW6Qphh3OXy+Ja4voXOH6qZ6znc7QbbBXgzVnaNpIaLuqIcIhjzS3bwd S3C9FRlOnB20kmVtNKKwGmeq8hVuQyQ9cSaYuXmdyYY0CTYZYTnMUwjj9RmaMet1i0dW 1mcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=RNd+8DxKVBWAiBqb9CX3ggAH3luC+yR7GJDmxGfQGsM=; b=Sd5acT/zI/x+hf/W8ohCt2GDZpk1kbR6c0x8ZPe1BVFeszPbVgswkY3uUn/n5reI7h VnE3nSYZA4ixSQAkMJGzJwyZ16RfL6PTTkq4KJIgZExN97Xw/PchMqFh4029lsuheRBj yIcvZeqJdE/lGRi9nTyHi6kBChZ9QmJ/f0Yhz6DmqDNHAxba2VMDulSsbHfT+Sle2afA DAtecpp8SRIBFcgTYPoM9ByxK6+gwCJjiguiPWVirMCFxVOl2whHL75KaElESTWdUeTY FCWhYh8NVQ2KMsbpP5Ru7JzWhedJeFeIJ7vCJEatjk4NY7iIprrajG6roNJyvhmVvKw7 guXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si16858745pld.151.2018.05.09.10.12.54; Wed, 09 May 2018 10:12:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965706AbeEIRMy (ORCPT + 10 others); Wed, 9 May 2018 13:12:54 -0400 Received: from foss.arm.com ([217.140.101.70]:47336 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRMx (ORCPT ); Wed, 9 May 2018 13:12:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 691F6168F; Wed, 9 May 2018 10:12:53 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 755213F592; Wed, 9 May 2018 10:12:52 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, Jonathan Cameron Cc: Sudeep Holla , linux-pm@vger.kernel.org Subject: [PATCH 8/8] firmware: arm_scmi: simplify exit path by returning on error Date: Wed, 9 May 2018 18:07:14 +0100 Message-Id: <1525885634-22348-9-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> References: <1525885634-22348-1-git-send-email-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Yet another nasty indentation left out during code restructuring. It's must simpler to return on error instead of having unnecessary indentation. Suggested-by: Jonathan Cameron Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.7.4 Reviewed-by: Jonathan Cameron diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 4087d6c50ecd..e996395af5f2 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -687,11 +687,12 @@ static int scmi_remove(struct platform_device *pdev) list_del(&info->node); mutex_unlock(&scmi_list_mutex); - if (!ret) { - /* Safe to free channels since no more users */ - ret = idr_for_each(idr, scmi_mbox_free_channel, idr); - idr_destroy(&info->tx_idr); - } + if (ret) + return ret; + + /* Safe to free channels since no more users */ + ret = idr_for_each(idr, scmi_mbox_free_channel, idr); + idr_destroy(&info->tx_idr); return ret; }