Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1328842ybt; Thu, 18 Jun 2020 06:17:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZkEuqFwGFAUfKRhref6trgnf0Y6PCggYOGJWuDgYHcEPUHwH6TGSYxwhc2tvuWHnBWane X-Received: by 2002:a17:906:d791:: with SMTP id pj17mr3897694ejb.352.1592486231795; Thu, 18 Jun 2020 06:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592486231; cv=none; d=google.com; s=arc-20160816; b=M7+pkA+0LqxNrRwUPiZejOrO7aD+/BH2Wtmg/5eFX5bC4D9yoewdASwPSAlJJ/fKKL xNBih9LwBdQpH6tSYmFpxSEPfDAPnEo6BKz0Tr/qt1hImmKaxTB+njqp7fITNyC4UboC elYqcX1zeUEeds4zHb6fX19KoJx9RiitHI+r4COpPsCoTF5LnlsEJx+JTnAo1tGkbCSE NT5dELxDAUCMTdo65+OJxNDwu5o8q1hEWR0Gf/agserf4hOwprGewtJNukL4RujR1R1y 8D6+k0PGbivjV2vS2gW2WtcCdY9TR8z6Yd2omQS7knagLkReMtlXbcnYpb1btRxlpvZX hVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=P+2IWFsJ5i36ZGvxub4LSfWG3z8Ej4UqapabeTqNW5E=; b=k2tse7Y1W2rf/+4/hJ5xQ6ehLHz72Nz5fPVpZDXYbK1HqXhAX7FIhdxMH5iqa1VbNi qAbHr6rz3MNxKaZayJ7mKg9roeXJfYUiG5F29gdv9od3z6jKn7Nyd68EL3vE8sfFG/z6 WHVW2Afk4EbJCrLZxev74DePVwpuSYmh8vW+IXjn7b2gCDxAxl5oIciwJjz2ikJhdQP3 vbmJMvZMq3Mxa3f3yYxWt1hWau4XUb3DKZWPT63J+lw0S/92YZHqCM4fTsDLA3GgivgB HE+I2im8JDd5YBPojgsZDXnCs/bTjOVvr97hk8rfDyVBE8IyaxeBblfsjm1+d5EfN6Pz 587Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=P432fg3m; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do13si2467866ejc.250.2020.06.18.06.16.48; Thu, 18 Jun 2020 06:17:11 -0700 (PDT) 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; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=P432fg3m; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgFRNOu (ORCPT + 99 others); Thu, 18 Jun 2020 09:14:50 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:25414 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbgFRNOp (ORCPT ); Thu, 18 Jun 2020 09:14:45 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1592486069; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=P+2IWFsJ5i36ZGvxub4LSfWG3z8Ej4UqapabeTqNW5E=; b=P432fg3mMDHItNW8d58GBio0H9HsiEcTGJtrcZYT6KW923mRf+1EKSq2Fi1nayUPf4FzMNRY S0990D5ZBIlAyAnuN/BCKKMRvumcOKHj1Q3JhXzeAOAmfw1D8I7hZ1xdOIE6NbfP9q1zXU/C sCrO28dOHD55saeY/seQ4DDpkns= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-east-1.postgun.com with SMTP id 5eeb68b00206ad41d15acb83 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 18 Jun 2020 13:14:24 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 9D9AAC433C8; Thu, 18 Jun 2020 13:14:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mkshah-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id C3986C433CA; Thu, 18 Jun 2020 13:14:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C3986C433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: bjorn.andersson@linaro.org, agross@kernel.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dianders@chromium.org, swboyd@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH] soc: qcom: rpmh: Use __fill_rpmh_msg API during rpmh_write() Date: Thu, 18 Jun 2020 18:44:11 +0530 Message-Id: <1592486051-22256-1-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use __fill_rpmh_msg API during rpmh_write(). This allows to remove duplication of code in error checking, copying commands and setting message state. Signed-off-by: Maulik Shah --- drivers/soc/qcom/rpmh.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index f2b5b46c..a0a0b97 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -181,8 +181,6 @@ static int __rpmh_write(const struct device *dev, enum rpmh_state state, struct cache_req *req; int i; - rpm_msg->msg.state = state; - /* Cache the request in our store and link the payload */ for (i = 0; i < rpm_msg->msg.num_cmds; i++) { req = cache_rpm_request(ctrlr, state, &rpm_msg->msg.cmds[i]); @@ -190,8 +188,6 @@ static int __rpmh_write(const struct device *dev, enum rpmh_state state, return PTR_ERR(req); } - rpm_msg->msg.state = state; - if (state == RPMH_ACTIVE_ONLY_STATE) { WARN_ON(irqs_disabled()); ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg); @@ -268,11 +264,9 @@ int rpmh_write(const struct device *dev, enum rpmh_state state, DEFINE_RPMH_MSG_ONSTACK(dev, state, &compl, rpm_msg); int ret; - if (!cmd || !n || n > MAX_RPMH_PAYLOAD) - return -EINVAL; - - memcpy(rpm_msg.cmd, cmd, n * sizeof(*cmd)); - rpm_msg.msg.num_cmds = n; + ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n); + if (ret) + return ret; ret = __rpmh_write(dev, state, &rpm_msg); if (ret) -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation