From patchwork Tue Aug 11 15:41:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 250714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1024DC433E1 for ; Tue, 11 Aug 2020 15:44:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE9AF2083B for ; Tue, 11 Aug 2020 15:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160651; bh=LzLvznpcNnmXKzaflJxxBBaNzDaD/j3UH7gWllnn0ZU=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=PLTyBsVYlWTkYUaPRh3ZX5cmlO5EUHdC0cQg2xuTymWVj2YaG79lOZRuScaWRpfh6 RYz+dcrk8cN7DxMrha1LXzUma7rFqGHhTqBkbaX/Zotau39v5NM/Z4q6xt3Vb/l+Iu DyQEkj5OVowYDP/LpqBQIwhWGy5IYMBiDwM0mhcM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729296AbgHKPoB (ORCPT ); Tue, 11 Aug 2020 11:44:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:47532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728915AbgHKPmF (ORCPT ); Tue, 11 Aug 2020 11:42:05 -0400 Received: from mail.kernel.org (ip5f5ad5c5.dynamic.kabel-deutschland.de [95.90.213.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FA4E208E4; Tue, 11 Aug 2020 15:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160523; bh=LzLvznpcNnmXKzaflJxxBBaNzDaD/j3UH7gWllnn0ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKui9/+XGuQwiSMt7hhA2UApFZaLi40li6eRcVVck4P858dsHTK9EgBvA4R9Icab4 9ptLZaNgCr26XXmlOgWY4E83G1w1ui8fIVPt/k33VU1hsOBXC/WtpANpCbgOWL1wFJ SwTfxG6Pgyg1yMPzNAuxTqeoDNCYPzlfBw7STims= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k5WPZ-004bmZ-Hq; Tue, 11 Aug 2020 17:42:01 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Stephen Boyd , Mayulong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/33] spmi: hisi-spmi-controller: fix it to probe successfully Date: Tue, 11 Aug 2020 17:41:34 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add a MODULE_DEVICE_TABLE() to the driver. Also, the current logic calls platform_set_drvdata(pdev, NULL) if the driver succeeds loading. While here, remove the .owner, as it is not needed upstream anymore. Signed-off-by: Mauro Carvalho Chehab --- drivers/spmi/hisi-spmi-controller.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c index 3af0bd1b379f..bc6847f9a5e7 100644 --- a/drivers/spmi/hisi-spmi-controller.c +++ b/drivers/spmi/hisi-spmi-controller.c @@ -324,11 +324,14 @@ static int spmi_controller_probe(struct platform_device *pdev) ctrl->write_cmd = spmi_write_cmd; ret = spmi_controller_add(ctrl); - if (ret) { - dev_err(&pdev->dev, "spmi_add_controller failed!\n"); + if (ret) goto err_add_controller; - } + + dev_info(&pdev->dev, "spmi_add_controller initialized\n"); + return 0; + err_add_controller: + dev_err(&pdev->dev, "spmi_add_controller failed!\n"); platform_set_drvdata(pdev, NULL); return ret; } @@ -347,13 +350,13 @@ static const struct of_device_id spmi_controller_match_table[] = { }, {} }; +MODULE_DEVICE_TABLE(of, spmi_controller_match_table); static struct platform_driver spmi_controller_driver = { .probe = spmi_controller_probe, .remove = spmi_del_controller, .driver = { .name = SPMI_CONTROLLER_NAME, - .owner = THIS_MODULE, .of_match_table = spmi_controller_match_table, }, }; From patchwork Tue Aug 11 15:41:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 250718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8849C433DF for ; Tue, 11 Aug 2020 15:42:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A5572076C for ; Tue, 11 Aug 2020 15:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160554; bh=DK21YohqwauX6NuCJLzJ5IGLlCzo0GLJDd68tiuadyc=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=j7RJzgQPo5RIUVJjxlgpNIG3TpYtkQONHOIjKNa5/hoW5FqSQBJ6Nf4WoVr815SPa /g4mCbgcwWCw7l5ZXHBF3eBAiEqFFSzO5GUd3uXKgkFGjfV3d6cMEXPNhbQHEdLLAr OKDA3XA+0WuFsrM1FhV8oAzYBLAawu3GmPDR3txk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729045AbgHKPmK (ORCPT ); Tue, 11 Aug 2020 11:42:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:47556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728954AbgHKPmF (ORCPT ); Tue, 11 Aug 2020 11:42:05 -0400 Received: from mail.kernel.org (ip5f5ad5c5.dynamic.kabel-deutschland.de [95.90.213.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 749AC214F1; Tue, 11 Aug 2020 15:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160523; bh=DK21YohqwauX6NuCJLzJ5IGLlCzo0GLJDd68tiuadyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DGXyoBn/gEQo/c9OYHtdIopuoBK8rWk15XTuBX7j5MCneJQcPxNiXWCMtqw2bKUrB 6IQe8a3vwGfD1iRKGZJ/T2vZokIctpt6SBjfu4KZxTLLk7Y2l9p+N/e+4zc5sifLrx oQTXGMxqYS1TAXfqtr4ZrW3xpT5ym/JeFatO/o7o= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k5WPZ-004bme-Jc; Tue, 11 Aug 2020 17:42:01 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Stephen Boyd , Mayulong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/33] spmi: hisi-spmi-controller: adjust whitespaces at defines Date: Tue, 11 Aug 2020 17:41:36 +0200 Message-Id: <5f65845d47fb8be07aee7aa0197d50724a633018.1597160086.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Some defines are not aligned with tab=8, which is the style defined on Linux. Adjust them. Signed-off-by: Mauro Carvalho Chehab --- drivers/spmi/hisi-spmi-controller.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c index 99cf757d76fe..7fae267a6062 100644 --- a/drivers/spmi/hisi-spmi-controller.c +++ b/drivers/spmi/hisi-spmi-controller.c @@ -18,10 +18,10 @@ /* * SPMI register addr */ -#define SPMI_CHANNEL_OFFSET 0x0300 -#define SPMI_SLAVE_OFFSET 0x20 +#define SPMI_CHANNEL_OFFSET 0x0300 +#define SPMI_SLAVE_OFFSET 0x20 -#define SPMI_APB_SPMI_CMD_BASE_ADDR 0x0100 +#define SPMI_APB_SPMI_CMD_BASE_ADDR 0x0100 #define SPMI_APB_SPMI_WDATA0_BASE_ADDR 0x0104 #define SPMI_APB_SPMI_WDATA1_BASE_ADDR 0x0108 @@ -35,21 +35,21 @@ #define SPMI_APB_SPMI_RDATA2_BASE_ADDR 0x020c #define SPMI_APB_SPMI_RDATA3_BASE_ADDR 0x0210 -#define SPMI_PER_DATAREG_BYTE 4 +#define SPMI_PER_DATAREG_BYTE 4 /* * SPMI cmd register */ -#define SPMI_APB_SPMI_CMD_EN BIT(31) +#define SPMI_APB_SPMI_CMD_EN BIT(31) #define SPMI_APB_SPMI_CMD_TYPE_OFFSET 24 #define SPMI_APB_SPMI_CMD_LENGTH_OFFSET 20 -#define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16 -#define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0 #define bswap_32(X) \ ((((u32)(X) & 0xff000000) >> 24) | \ (((u32)(X) & 0x00ff0000) >> 8) | \ (((u32)(X) & 0x0000ff00) << 8) | \ (((u32)(X) & 0x000000ff) << 24)) +#define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16 +#define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0 /* Command Opcodes */ @@ -70,15 +70,15 @@ enum spmi_controller_cmd_op_code { /* * SPMI status register */ -#define SPMI_APB_TRANS_DONE BIT(0) -#define SPMI_APB_TRANS_FAIL BIT(2) +#define SPMI_APB_TRANS_DONE BIT(0) +#define SPMI_APB_TRANS_FAIL BIT(2) /* Command register fields */ #define SPMI_CONTROLLER_CMD_MAX_BYTE_COUNT 16 /* Maximum number of support PMIC peripherals */ #define SPMI_CONTROLLER_TIMEOUT_US 1000 -#define SPMI_CONTROLLER_MAX_TRANS_BYTES (16) +#define SPMI_CONTROLLER_MAX_TRANS_BYTES 16 /* * @base base address of the PMIC Arbiter core registers. @@ -114,8 +114,10 @@ static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev, { u32 status = 0; u32 timeout = SPMI_CONTROLLER_TIMEOUT_US; - u32 offset = SPMI_APB_SPMI_STATUS_BASE_ADDR + SPMI_CHANNEL_OFFSET * ctrl_dev->channel - + SPMI_SLAVE_OFFSET * sid; + u32 offset; + + offset = SPMI_APB_SPMI_STATUS_BASE_ADDR; + offset += SPMI_CHANNEL_OFFSET * ctrl_dev->channel + SPMI_SLAVE_OFFSET * sid; while (timeout--) { status = readl(base + offset); From patchwork Tue Aug 11 15:41:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 250713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94792C433E3 for ; Tue, 11 Aug 2020 15:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 750DF2076C for ; Tue, 11 Aug 2020 15:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160654; bh=rdCEN/RI25V0Y1iq7dV+krmGtNwdfSkrQ573PfqTzbU=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=k01TEsebhYF7KKERiCyBCC4i47b+7UXZTBk2qqNBevIAROrARPdhloObDbeD7nT/Y 65mmcitieQ2hdU/rLFVpwSTgaSi+o5e5WRjlV04EZGS3DZ0bU7Wf1Zp9TwtnfN1vZe e6sNhIu7dToZWCADrxpA/H8ueFfK9SpiGaowUCss= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729268AbgHKPoB (ORCPT ); Tue, 11 Aug 2020 11:44:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:47554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728946AbgHKPmF (ORCPT ); Tue, 11 Aug 2020 11:42:05 -0400 Received: from mail.kernel.org (ip5f5ad5c5.dynamic.kabel-deutschland.de [95.90.213.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 714B920FC3; Tue, 11 Aug 2020 15:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160523; bh=rdCEN/RI25V0Y1iq7dV+krmGtNwdfSkrQ573PfqTzbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJ52qIUaqF9ELj3CxBxjUZIVra86+XAdL9sO2h1Ri4UAG6+KGxkHyhDMbPDIpGpjh gKIBbjk0OKXmxsRaq+oUZoYbardxLGVB4y1J0FIDjfV28fowaMq2RYrM8N0BZrxciT 6KLZCVr70pR5S8Y7ENNh6x2zO7k9J5KsoSYPXwyM= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k5WPZ-004bmh-KV; Tue, 11 Aug 2020 17:42:01 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Stephen Boyd , Mayulong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/33] spmi: hisi-spmi-controller: use le32 macros where needed Date: Tue, 11 Aug 2020 17:41:37 +0200 Message-Id: <69177c7a8284d827b7024add63fe05b7e3f6ee2f.1597160086.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Instead of manually using bswap_32(), just use the le32 macros. Signed-off-by: Mauro Carvalho Chehab --- drivers/spmi/hisi-spmi-controller.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c index 7fae267a6062..cacd28150b49 100644 --- a/drivers/spmi/hisi-spmi-controller.c +++ b/drivers/spmi/hisi-spmi-controller.c @@ -11,7 +11,6 @@ #include #include #include -#include #define SPMI_CONTROLLER_NAME "spmi_controller" @@ -43,11 +42,6 @@ #define SPMI_APB_SPMI_CMD_TYPE_OFFSET 24 #define SPMI_APB_SPMI_CMD_LENGTH_OFFSET 20 -#define bswap_32(X) \ - ((((u32)(X) & 0xff000000) >> 24) | \ - (((u32)(X) & 0x00ff0000) >> 8) | \ - (((u32)(X) & 0x0000ff00) << 8) | \ - (((u32)(X) & 0x000000ff) << 24)) #define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16 #define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0 @@ -179,14 +173,15 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, writel(cmd, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_CMD_BASE_ADDR); - rc = spmi_controller_wait_for_done(spmi_controller, spmi_controller->base, sid, addr); + rc = spmi_controller_wait_for_done(spmi_controller, + spmi_controller->base, sid, addr); if (rc) goto done; i = 0; do { data = readl(spmi_controller->base + chnl_ofst + SPMI_SLAVE_OFFSET * sid + SPMI_APB_SPMI_RDATA0_BASE_ADDR + i * SPMI_PER_DATAREG_BYTE); - data = bswap_32(data); + data = be32_to_cpu((__be32)data); if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) { memcpy(buf, &data, sizeof(data)); buf += sizeof(data); @@ -210,8 +205,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, { struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev); unsigned long flags; - u32 cmd; - u32 data = 0; + u32 cmd, data; int rc; u32 chnl_ofst = SPMI_CHANNEL_OFFSET * spmi_controller->channel; u8 op_code, i; @@ -246,7 +240,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, i = 0; do { - memset(&data, 0, sizeof(data)); + data = 0; if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) { memcpy(&data, buf, sizeof(data)); buf += sizeof(data); @@ -255,8 +249,8 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, buf += (bc % SPMI_PER_DATAREG_BYTE); } - data = bswap_32(data); - writel(data, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_WDATA0_BASE_ADDR + SPMI_PER_DATAREG_BYTE * i); + writel((u32)cpu_to_be32(data), + spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_WDATA0_BASE_ADDR + SPMI_PER_DATAREG_BYTE * i); i++; } while (bc > i * SPMI_PER_DATAREG_BYTE); From patchwork Tue Aug 11 15:41:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 250715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E965C433E1 for ; Tue, 11 Aug 2020 15:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D7402087C for ; Tue, 11 Aug 2020 15:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160641; bh=fDw2vapQW45GEAIC6jIOi73M8vhpNaPkN5x5Kic47FQ=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=DLZWebckRPV6qfTaeemiL039j+A9XUOf2vm3uqzZ9gtbU2CHlWV8SnIRLhaG7Ue0o 1sRw3yTPoz7XdxUtkQJMZBUnSABQk+DVrFGkr0MKI+NJ2uM9y1cPmlCZYasJzUHfuP R15mmH6GvZs6Pj5ODn8/Rfg5UBpCW9xaTBBq3k0E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729248AbgHKPnp (ORCPT ); Tue, 11 Aug 2020 11:43:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:47558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728952AbgHKPmF (ORCPT ); Tue, 11 Aug 2020 11:42:05 -0400 Received: from mail.kernel.org (ip5f5ad5c5.dynamic.kabel-deutschland.de [95.90.213.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D2CB21744; Tue, 11 Aug 2020 15:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160523; bh=fDw2vapQW45GEAIC6jIOi73M8vhpNaPkN5x5Kic47FQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtHl43FAlReYUvlkW+vyltfmLlwn6J7xS7c43W+dpaU7LJQEiJ/Md2HEGqKdivOwU mUXFq0mrUyxVfh9VvnhPED7d3QJjdDdO9tULV7jiZfI0Nvj6JsAd//ujDgZdBHIHOm bt5LL1gcGjja8eKqI1kKLRHmhJ7X/qD6GR8Nb9D0= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k5WPZ-004bmk-LP; Tue, 11 Aug 2020 17:42:01 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Stephen Boyd , Mayulong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/33] spmi: hisi-spmi-controller: add debug when values are read/write Date: Tue, 11 Aug 2020 17:41:38 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org It is interesting to be able to check if the driver is doing the right thing. So, add some debug macros to allow checking it. Signed-off-by: Mauro Carvalho Chehab --- drivers/spmi/hisi-spmi-controller.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c index cacd28150b49..e996114bc717 100644 --- a/drivers/spmi/hisi-spmi-controller.c +++ b/drivers/spmi/hisi-spmi-controller.c @@ -41,7 +41,6 @@ #define SPMI_APB_SPMI_CMD_EN BIT(31) #define SPMI_APB_SPMI_CMD_TYPE_OFFSET 24 #define SPMI_APB_SPMI_CMD_LENGTH_OFFSET 20 - #define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16 #define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0 @@ -135,10 +134,11 @@ static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev, } static int spmi_read_cmd(struct spmi_controller *ctrl, - u8 opc, u8 sid, u16 addr, u8 *buf, size_t bc) + u8 opc, u8 sid, u16 addr, u8 *__buf, size_t bc) { struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev); unsigned long flags; + u8 *buf = __buf; u32 cmd, data; int rc; u32 chnl_ofst = SPMI_CHANNEL_OFFSET * spmi_controller->channel; @@ -197,13 +197,18 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, if (rc) dev_err(spmi_controller->dev, "spmi read wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", opc, sid, addr, bc + 1); + else + dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, read value: %*ph\n", + __func__, sid, addr, (int)bc, __buf); + return rc; } static int spmi_write_cmd(struct spmi_controller *ctrl, - u8 opc, u8 sid, u16 addr, const u8 *buf, size_t bc) + u8 opc, u8 sid, u16 addr, const u8 *__buf, size_t bc) { struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev); + const u8 *buf = __buf; unsigned long flags; u32 cmd, data; int rc; @@ -263,6 +268,9 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, if (rc) dev_err(spmi_controller->dev, "spmi write wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", opc, sid, addr, bc); + else + dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, wrote value: %*ph\n", + __func__, sid, addr, (int)bc, __buf); return rc; } @@ -275,6 +283,7 @@ static int spmi_controller_probe(struct platform_device *pdev) int ret = 0; dev_info(&pdev->dev, "HISI SPMI probe\n"); + ctrl = spmi_controller_alloc(&pdev->dev, sizeof(*spmi_controller)); if (!ctrl) { dev_err(&pdev->dev, "can not allocate spmi_controller data\n"); From patchwork Tue Aug 11 15:41:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 250716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55498C433DF for ; Tue, 11 Aug 2020 15:43:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 293E72076C for ; Tue, 11 Aug 2020 15:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160627; bh=Mv6bUdWC+SpZr0Ygy9V4QusAzRKfdHVnIi7cmc3ugqw=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=X6ejX82144HxCYKtV4+j61avrej+v6bcjzs/Z2oLnxH5eUauHdssjrxCma3kp2er7 sf7Fraqpt4t0d7bxN4QxKme/Oc6yg3cLtXdspnKRJONh/BwQlvRtSAHrDVyTa+vS0O HMSGW8D7CRR6ZMDgScPKWcaOxDgBKP0Z9rR3NASg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728998AbgHKPnp (ORCPT ); Tue, 11 Aug 2020 11:43:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:47564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728966AbgHKPmF (ORCPT ); Tue, 11 Aug 2020 11:42:05 -0400 Received: from mail.kernel.org (ip5f5ad5c5.dynamic.kabel-deutschland.de [95.90.213.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D88822BED; Tue, 11 Aug 2020 15:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160523; bh=Mv6bUdWC+SpZr0Ygy9V4QusAzRKfdHVnIi7cmc3ugqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXAajxkH4rDw8N0yfJNEtKSJBzOTVILSCqBIDjP6kvBnFBBrCcYhbqTQxevCfDTMr xz/fGSZnDgaXQE1bbUUdRgPorItokDsrVRv0YeC54bUGDlcyeZsRJhMYAQMySwSrQT kAMPaUSHkYpZjkoqMvTMMwMmRq1nBrQ+buNLqT98= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k5WPZ-004bmw-Po; Tue, 11 Aug 2020 17:42:01 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Stephen Boyd , Mayulong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/33] spmi: hisi-spmi-controller: fix the dev_foo() logic Date: Tue, 11 Aug 2020 17:41:42 +0200 Message-Id: <3d20ec2b40ba1c339fd7e0d74ff34863b3d58e35.1597160086.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Right now, driver is printing some messages as: [ 33.833026] (NULL device *): spmi_read_cmd: id:0 addr:0x17, read value: 00 This is because dev_foo() are not using a device with a name set. Change the logic for it to print it right. Signed-off-by: Mauro Carvalho Chehab --- drivers/spmi/hisi-spmi-controller.c | 41 +++++++++++++++-------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c index e996114bc717..153bcdb0cde4 100644 --- a/drivers/spmi/hisi-spmi-controller.c +++ b/drivers/spmi/hisi-spmi-controller.c @@ -102,7 +102,8 @@ struct spmi_controller_dev { u32 channel; }; -static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev, +static int spmi_controller_wait_for_done(struct device *dev, + struct spmi_controller_dev *ctrl_dev, void __iomem *base, u8 sid, u16 addr) { u32 status = 0; @@ -117,19 +118,17 @@ static int spmi_controller_wait_for_done(struct spmi_controller_dev *ctrl_dev, if (status & SPMI_APB_TRANS_DONE) { if (status & SPMI_APB_TRANS_FAIL) { - dev_err(ctrl_dev->dev, - "%s: transaction failed (0x%x)\n", + dev_err(dev, "%s: transaction failed (0x%x)\n", __func__, status); return -EIO; } + dev_dbg(dev, "%s: status 0x%x\n", __func__, status); return 0; } udelay(1); } - dev_err(ctrl_dev->dev, - "%s: timeout, status 0x%x\n", - __func__, status); + dev_err(dev, "%s: timeout, status 0x%x\n", __func__, status); return -ETIMEDOUT; } @@ -145,9 +144,9 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, u8 op_code, i; if (bc > SPMI_CONTROLLER_MAX_TRANS_BYTES) { - dev_err(spmi_controller->dev - , "spmi_controller supports 1..%d bytes per trans, but:%ld requested" - , SPMI_CONTROLLER_MAX_TRANS_BYTES, bc); + dev_err(&ctrl->dev, + "spmi_controller supports 1..%d bytes per trans, but:%ld requested", + SPMI_CONTROLLER_MAX_TRANS_BYTES, bc); return -EINVAL; } @@ -159,7 +158,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, } else if (opc == SPMI_CMD_EXT_READL) { op_code = SPMI_CMD_EXT_REG_READ_L; } else { - dev_err(spmi_controller->dev, "invalid read cmd 0x%x", opc); + dev_err(&ctrl->dev, "invalid read cmd 0x%x", opc); return -EINVAL; } @@ -173,7 +172,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, writel(cmd, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_CMD_BASE_ADDR); - rc = spmi_controller_wait_for_done(spmi_controller, + rc = spmi_controller_wait_for_done(&ctrl->dev, spmi_controller, spmi_controller->base, sid, addr); if (rc) goto done; @@ -195,10 +194,11 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, done: spin_unlock_irqrestore(&spmi_controller->lock, flags); if (rc) - dev_err(spmi_controller->dev, "spmi read wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", + dev_err(&ctrl->dev, + "spmi read wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", opc, sid, addr, bc + 1); else - dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, read value: %*ph\n", + dev_dbg(&ctrl->dev, "%s: id:%d addr:0x%x, read value: %*ph\n", __func__, sid, addr, (int)bc, __buf); return rc; @@ -216,9 +216,9 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, u8 op_code, i; if (bc > SPMI_CONTROLLER_MAX_TRANS_BYTES) { - dev_err(spmi_controller->dev - , "spmi_controller supports 1..%d bytes per trans, but:%ld requested" - , SPMI_CONTROLLER_MAX_TRANS_BYTES, bc); + dev_err(&ctrl->dev, + "spmi_controller supports 1..%d bytes per trans, but:%ld requested", + SPMI_CONTROLLER_MAX_TRANS_BYTES, bc); return -EINVAL; } @@ -230,7 +230,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, } else if (opc == SPMI_CMD_EXT_WRITEL) { op_code = SPMI_CMD_EXT_REG_WRITE_L; } else { - dev_err(spmi_controller->dev, "invalid write cmd 0x%x", opc); + dev_err(&ctrl->dev, "invalid write cmd 0x%x", opc); return -EINVAL; } @@ -262,14 +262,15 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, /* Start the transaction */ writel(cmd, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_CMD_BASE_ADDR); - rc = spmi_controller_wait_for_done(spmi_controller, spmi_controller->base, sid, addr); + rc = spmi_controller_wait_for_done(&ctrl->dev, spmi_controller, + spmi_controller->base, sid, addr); spin_unlock_irqrestore(&spmi_controller->lock, flags); if (rc) - dev_err(spmi_controller->dev, "spmi write wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", + dev_err(&ctrl->dev, "spmi write wait timeout op:0x%x sid:%d addr:0x%x bc:%ld\n", opc, sid, addr, bc); else - dev_dbg(spmi_controller->dev, "%s: id:%d addr:0x%x, wrote value: %*ph\n", + dev_dbg(&ctrl->dev, "%s: id:%d addr:0x%x, wrote value: %*ph\n", __func__, sid, addr, (int)bc, __buf); return rc; From patchwork Tue Aug 11 15:41:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 250717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BD2C433DF for ; Tue, 11 Aug 2020 15:42:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0AB120855 for ; Tue, 11 Aug 2020 15:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160556; bh=2dtYAFvIXzlE8IJbj/8Y9D+YfRwjSvBfDUirFQOrAzA=; h=From:Cc:Subject:Date:In-Reply-To:References:To:List-ID:From; b=U7LlBigbuhBzuzRXeo7VTYhmIhbJ7zuwuiXKbRNb6Wv5M/puZaQ2LtgFGHOKrBX2u x9WLKAC3AzshvcWLouMx2vBdpIzcWkrkXhAbhkUqU4a4Py0m6qYQ5DiqSXfH/0r6ZB tKtzdwcm31Jn+TWkYwAxCcSbUXba+raV8VzAOiU4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728894AbgHKPmf (ORCPT ); Tue, 11 Aug 2020 11:42:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:47664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729041AbgHKPmJ (ORCPT ); Tue, 11 Aug 2020 11:42:09 -0400 Received: from mail.kernel.org (ip5f5ad5c5.dynamic.kabel-deutschland.de [95.90.213.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5931A22E02; Tue, 11 Aug 2020 15:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597160524; bh=2dtYAFvIXzlE8IJbj/8Y9D+YfRwjSvBfDUirFQOrAzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kxbg52TX4tPINiN9Na3z9UOc2DmuBBhdPU67m9e900Nhem8yuzXQcMwfYqPANnxta lu4egku0dn8CEvQb3b1HmSnc2xnvwDmuamn5fmsH025f9/zErkxE++bXf1MXXICULq zjjhTZrzCi+HpxEICz87ZnMvbrhasP0XMBfGpRww= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k5WPa-004bnj-BS; Tue, 11 Aug 2020 17:42:02 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Lee Jones , Liam Girdwood , Mark Brown , Stephen Boyd , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 30/33] mfd, spmi, regulator: fix some coding style issues at HiSilicon SPMI PMIC Date: Tue, 11 Aug 2020 17:41:56 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Checkpatch complains about some minor issues inside the new mft/regulator/spmi drivers for HiSilicon 6421v600. Address them. Signed-off-by: Mauro Carvalho Chehab --- drivers/mfd/hi6421-spmi-pmic.c | 4 ++-- drivers/regulator/hi6421v600-regulator.c | 28 ++++++++++++------------ drivers/spmi/spmi.c | 5 ++++- include/linux/mfd/hi6421-spmi-pmic.h | 3 ++- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/mfd/hi6421-spmi-pmic.c b/drivers/mfd/hi6421-spmi-pmic.c index 09cedfa1e4bb..d8b84d64041e 100644 --- a/drivers/mfd/hi6421-spmi-pmic.c +++ b/drivers/mfd/hi6421-spmi-pmic.c @@ -189,7 +189,7 @@ static struct irq_chip hi6421_spmi_pmu_irqchip = { }; static int hi6421_spmi_irq_map(struct irq_domain *d, unsigned int virq, - irq_hw_number_t hw) + irq_hw_number_t hw) { struct hi6421_spmi_pmic *pmic = d->host_data; @@ -350,7 +350,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) * The logic below will rely that the pmic is already stored at * drvdata. */ - dev_dbg(&pdev->dev, "SPMI-PMIC: adding childs for %pOF\n", + dev_dbg(&pdev->dev, "SPMI-PMIC: adding children for %pOF\n", pdev->dev.of_node); ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs), diff --git a/drivers/regulator/hi6421v600-regulator.c b/drivers/regulator/hi6421v600-regulator.c index 72f51594b5ff..c80dfac1e4c3 100644 --- a/drivers/regulator/hi6421v600-regulator.c +++ b/drivers/regulator/hi6421v600-regulator.c @@ -40,7 +40,7 @@ #include #define rdev_dbg(rdev, fmt, arg...) \ - pr_debug("%s: %s: " fmt, rdev->desc->name, __func__, ##arg) + pr_debug("%s: %s: " fmt, (rdev)->desc->name, __func__, ##arg) struct hi6421v600_regulator { struct regulator_desc rdesc; @@ -105,7 +105,7 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev) rdev->desc->enable_reg, rdev->desc->enable_mask); hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, - rdev->desc->enable_mask, 0); + rdev->desc->enable_mask, 0); return 0; } @@ -122,7 +122,7 @@ static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev) selector = (reg_val & rdev->desc->vsel_mask) >> (ffs(rdev->desc->vsel_mask) - 1); rdev_dbg(rdev, - "vsel_reg=0x%x, value=0x%x, entry=0x%x, voltage=%d mV\n", + "vsel_reg=0x%x, value=0x%x, entry=0x%x, voltage=%d mV\n", rdev->desc->vsel_reg, reg_val, selector, rdev->desc->ops->list_voltage(rdev, selector) / 1000); @@ -144,7 +144,7 @@ static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev, /* set voltage selector */ rdev_dbg(rdev, - "vsel_reg=0x%x, mask=0x%x, value=0x%x, voltage=%d mV\n", + "vsel_reg=0x%x, mask=0x%x, value=0x%x, voltage=%d mV\n", rdev->desc->vsel_reg, rdev->desc->vsel_mask, reg_val, rdev->desc->ops->list_voltage(rdev, selector) / 1000); @@ -169,7 +169,7 @@ static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev) mode = REGULATOR_MODE_NORMAL; rdev_dbg(rdev, - "enable_reg=0x%x, eco_mode_mask=0x%x, reg_val=0x%x, %s mode\n", + "enable_reg=0x%x, eco_mode_mask=0x%x, reg_val=0x%x, %s mode\n", rdev->desc->enable_reg, sreg->eco_mode_mask, reg_val, mode == REGULATOR_MODE_IDLE ? "idle" : "normal"); @@ -177,7 +177,7 @@ static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev) } static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev, - unsigned int mode) + unsigned int mode) { struct hi6421v600_regulator *sreg = rdev_get_drvdata(rdev); struct hi6421_spmi_pmic *pmic = sreg->pmic; @@ -204,9 +204,10 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev, return 0; } -static unsigned int hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev, - int input_uV, int output_uV, - int load_uA) +static unsigned int +hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev, + int input_uV, int output_uV, + int load_uA) { struct hi6421v600_regulator *sreg = rdev_get_drvdata(rdev); @@ -220,7 +221,7 @@ static unsigned int hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev } static int hi6421_spmi_dt_parse(struct platform_device *pdev, - struct hi6421v600_regulator *sreg, + struct hi6421v600_regulator *sreg, struct regulator_desc *rdesc) { struct device *dev = &pdev->dev; @@ -256,7 +257,7 @@ static int hi6421_spmi_dt_parse(struct platform_device *pdev, sreg->eco_uA = 0; } else { ret = of_property_read_u32(np, "eco-microamp", - &sreg->eco_uA); + &sreg->eco_uA); if (ret) { dev_err(dev, "missing eco-microamp property\n"); return ret; @@ -331,8 +332,8 @@ static struct regulator_ops hi6421_spmi_ldo_rops = { */ static int hi6421_spmi_regulator_probe_ldo(struct platform_device *pdev, - struct device_node *np, - struct hi6421_spmi_pmic *pmic) + struct device_node *np, + struct hi6421_spmi_pmic *pmic) { struct device *dev = &pdev->dev; struct regulator_desc *rdesc; @@ -404,7 +405,6 @@ static int hi6421_spmi_regulator_probe_ldo(struct platform_device *pdev, return ret; } - static int hi6421_spmi_regulator_probe(struct platform_device *pdev) { struct device *pmic_dev = pdev->dev.parent; diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c index fd3ff6079b15..253340e10dab 100644 --- a/drivers/spmi/spmi.c +++ b/drivers/spmi/spmi.c @@ -23,6 +23,7 @@ static DEFINE_IDA(ctrl_ida); static void spmi_dev_release(struct device *dev) { struct spmi_device *sdev = to_spmi_device(dev); + kfree(sdev); } @@ -33,6 +34,7 @@ static const struct device_type spmi_dev_type = { static void spmi_ctrl_release(struct device *dev) { struct spmi_controller *ctrl = to_spmi_controller(dev); + ida_simple_remove(&ctrl_ida, ctrl->nr); kfree(ctrl); } @@ -487,7 +489,7 @@ static void of_spmi_register_devices(struct spmi_controller *ctrl) continue; sdev->dev.of_node = node; - sdev->usid = (u8) reg[0]; + sdev->usid = (u8)reg[0]; err = spmi_device_add(sdev); if (err) { @@ -531,6 +533,7 @@ EXPORT_SYMBOL_GPL(spmi_controller_add); static int spmi_ctrl_remove_device(struct device *dev, void *data) { struct spmi_device *spmidev = to_spmi_device(dev); + if (dev->type == &spmi_dev_type) spmi_device_remove(spmidev); return 0; diff --git a/include/linux/mfd/hi6421-spmi-pmic.h b/include/linux/mfd/hi6421-spmi-pmic.h index d12ad7484018..aeff96c4a37e 100644 --- a/include/linux/mfd/hi6421-spmi-pmic.h +++ b/include/linux/mfd/hi6421-spmi-pmic.h @@ -38,7 +38,8 @@ struct hi6421_spmi_pmic { unsigned int *irqs; int irqnum; int irqarray; - struct hi6421_spmi_irq_mask_info irq_mask_addr; + + struct hi6421_spmi_irq_mask_info irq_mask_addr; struct hi6421_spmi_irq_info irq_addr; };