From patchwork Mon Jul 3 12:18:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiran Gunda X-Patchwork-Id: 9822609 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 42F27602F0 for ; Mon, 3 Jul 2017 12:21:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3289D2855C for ; Mon, 3 Jul 2017 12:21:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26DAF28557; Mon, 3 Jul 2017 12:21:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7827728543 for ; Mon, 3 Jul 2017 12:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754029AbdGCMV0 (ORCPT ); Mon, 3 Jul 2017 08:21:26 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37118 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753765AbdGCMV0 (ORCPT ); Mon, 3 Jul 2017 08:21:26 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 809D46089A; Mon, 3 Jul 2017 12:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499084480; bh=J0AZkBgRXKLn2ggwFSKgNDIHITgCG83Zur8ZBDSeqvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E742Ifcnt3JngeD6xYRThBGGoLgQZuYeooCIXMbLQ9Kr/G7I+dk35Z2QaKktaqHOE kcmzH8v/uROMqXFJRIZIzkHKrnRrygQFmRVmvyODCTAaY0DWKQTR+Ac2QQ+wOaoXDl TY8MxbXPLSfT/FVsl622GyoibLpUXaM/zQpEXA5I= Received: from kgunda-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: kgunda@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id BA6C5607C5; Mon, 3 Jul 2017 12:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499084480; bh=J0AZkBgRXKLn2ggwFSKgNDIHITgCG83Zur8ZBDSeqvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E742Ifcnt3JngeD6xYRThBGGoLgQZuYeooCIXMbLQ9Kr/G7I+dk35Z2QaKktaqHOE kcmzH8v/uROMqXFJRIZIzkHKrnRrygQFmRVmvyODCTAaY0DWKQTR+Ac2QQ+wOaoXDl TY8MxbXPLSfT/FVsl622GyoibLpUXaM/zQpEXA5I= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BA6C5607C5 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kgunda@codeaurora.org From: Kiran Gunda To: Kiran Gunda , Abhijeet Dharmapurikar , Stephen Boyd , Greg Kroah-Hartman , Nicholas Troast , Christophe JAILLET , linux-kernel@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Subject: [PATCH V1 4/5] spmi: pmic-arb: return the value instead of passing by pointer Date: Mon, 3 Jul 2017 17:48:27 +0530 Message-Id: <1499084308-2232-5-git-send-email-kgunda@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499084308-2232-1-git-send-email-kgunda@codeaurora.org> References: <1499084308-2232-1-git-send-email-kgunda@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Returning the output value from a function, when it is possible, is the better and cleaner way than passing it by the pointer. Hence, modify the ppid_to_apid mapping function to return apid instead of passing it by a pointer. While at it, pass the ppid as function parameter to ppid_to_apid mapping function instead of passing the sid and addr. Signed-off-by: Kiran Gunda Reviewed-by: Stephen Boyd --- drivers/spmi/spmi-pmic-arb.c | 47 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index d8c857a..5285245 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -179,8 +179,7 @@ struct spmi_pmic_arb { */ struct pmic_arb_ver_ops { const char *ver_str; - int (*ppid_to_apid)(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr, - u16 *apid); + int (*ppid_to_apid)(struct spmi_pmic_arb *pmic_arb, u16 ppid); /* spmi commands (read_cmd, write_cmd, cmd) functionality */ int (*offset)(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr, u32 *offset); @@ -657,8 +656,8 @@ static int qpnpint_irq_domain_dt_translate(struct irq_domain *d, unsigned int *out_type) { struct spmi_pmic_arb *pmic_arb = d->host_data; + u16 apid, ppid; int rc; - u16 apid; dev_dbg(&pmic_arb->spmic->dev, "intspec[0] 0x%1x intspec[1] 0x%02x intspec[2] 0x%02x\n", intspec[0], intspec[1], intspec[2]); @@ -670,14 +669,15 @@ static int qpnpint_irq_domain_dt_translate(struct irq_domain *d, if (intspec[0] > 0xF || intspec[1] > 0xFF || intspec[2] > 0x7) return -EINVAL; - rc = pmic_arb->ver_ops->ppid_to_apid(pmic_arb, intspec[0], - (intspec[1] << 8), &apid); + ppid = intspec[0] << 8 | intspec[1]; + rc = pmic_arb->ver_ops->ppid_to_apid(pmic_arb, ppid); if (rc < 0) { dev_err(&pmic_arb->spmic->dev, "failed to xlate sid = 0x%x, periph = 0x%x, irq = %x rc = %d\n", intspec[0], intspec[1], intspec[2], rc); return rc; } + apid = rc; /* Keep track of {max,min}_apid for bounding search during interrupt */ if (apid > pmic_arb->max_apid) pmic_arb->max_apid = apid; @@ -706,19 +706,18 @@ static int qpnpint_irq_domain_map(struct irq_domain *d, return 0; } -static int pmic_arb_ppid_to_apid_v1(struct spmi_pmic_arb *pmic_arb, u8 sid, - u16 addr, u16 *apid) +static int pmic_arb_ppid_to_apid_v1(struct spmi_pmic_arb *pmic_arb, u16 ppid) { - u16 ppid = sid << 8 | ((addr >> 8) & 0xFF); u32 *mapping_table = pmic_arb->mapping_table; int index = 0, i; u16 apid_valid; + u16 apid; u32 data; apid_valid = pmic_arb->ppid_to_apid[ppid]; if (apid_valid & PMIC_ARB_APID_VALID) { - *apid = apid_valid & ~PMIC_ARB_APID_VALID; - return 0; + apid = apid_valid & ~PMIC_ARB_APID_VALID; + return apid; } for (i = 0; i < SPMI_MAPPING_TABLE_TREE_DEPTH; ++i) { @@ -732,21 +731,21 @@ static int pmic_arb_ppid_to_apid_v1(struct spmi_pmic_arb *pmic_arb, u8 sid, if (SPMI_MAPPING_BIT_IS_1_FLAG(data)) { index = SPMI_MAPPING_BIT_IS_1_RESULT(data); } else { - *apid = SPMI_MAPPING_BIT_IS_1_RESULT(data); + apid = SPMI_MAPPING_BIT_IS_1_RESULT(data); pmic_arb->ppid_to_apid[ppid] - = *apid | PMIC_ARB_APID_VALID; - pmic_arb->apid_data[*apid].ppid = ppid; - return 0; + = apid | PMIC_ARB_APID_VALID; + pmic_arb->apid_data[apid].ppid = ppid; + return apid; } } else { if (SPMI_MAPPING_BIT_IS_0_FLAG(data)) { index = SPMI_MAPPING_BIT_IS_0_RESULT(data); } else { - *apid = SPMI_MAPPING_BIT_IS_0_RESULT(data); + apid = SPMI_MAPPING_BIT_IS_0_RESULT(data); pmic_arb->ppid_to_apid[ppid] - = *apid | PMIC_ARB_APID_VALID; - pmic_arb->apid_data[*apid].ppid = ppid; - return 0; + = apid | PMIC_ARB_APID_VALID; + pmic_arb->apid_data[apid].ppid = ppid; + return apid; } } } @@ -798,10 +797,8 @@ static u16 pmic_arb_find_apid(struct spmi_pmic_arb *pmic_arb, u16 ppid) return i; } -static int pmic_arb_ppid_to_apid_v2(struct spmi_pmic_arb *pmic_arb, u8 sid, - u16 addr, u16 *apid) +static int pmic_arb_ppid_to_apid_v2(struct spmi_pmic_arb *pmic_arb, u16 ppid) { - u16 ppid = (sid << 8) | (addr >> 8); u16 apid_valid; apid_valid = pmic_arb->ppid_to_apid[ppid]; @@ -810,8 +807,7 @@ static int pmic_arb_ppid_to_apid_v2(struct spmi_pmic_arb *pmic_arb, u8 sid, if (!(apid_valid & PMIC_ARB_APID_VALID)) return -ENODEV; - *apid = apid_valid & ~PMIC_ARB_APID_VALID; - return 0; + return apid_valid & ~PMIC_ARB_APID_VALID; } /* v2 offset per ppid and per ee */ @@ -819,12 +815,15 @@ static int pmic_arb_offset_v2(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr, u32 *offset) { u16 apid; + u16 ppid; int rc; - rc = pmic_arb_ppid_to_apid_v2(pmic_arb, sid, addr, &apid); + ppid = sid << 8 | ((addr >> 8) & 0xFF); + rc = pmic_arb_ppid_to_apid_v2(pmic_arb, ppid); if (rc < 0) return rc; + apid = rc; *offset = 0x1000 * pmic_arb->ee + 0x8000 * apid; return 0; }