From patchwork Fri Jan 29 14:26:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12055971 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 EE838C433DB for ; Fri, 29 Jan 2021 14:29:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EE5464DF1 for ; Fri, 29 Jan 2021 14:29:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EE5464DF1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YZ5JmUgEBXj2foSneUq1JtJ06GUlz+3QJztaKhQu6So=; b=syMCDFJzgKDQnDJ/5Ilsn3Qrf ysIOcyG3VAdRm4YFxZOGTqfp+zZjbo4PPAXW3L82cgfvPoRLLmvDnLXr1stGW5kAIM4yWjykg2EBo tGFmBCWqkRnTnyEmEODhUlZLbr5WoYuB/F4MuVgbMSfXO2+Nv8ejXdMtbrYAGXCIoQggyLWDCidIW V96KExh5s9UYSoFEGB6CuOHTjr2G9fFW2N6mPNfRB8Q7X/yotCjSGMckCPX3A3R1hFsQCNB+Oylnr xSPsqSpKwC7nMs0XnV/kmLjXQcywR6egzYHXITMvBFzkA3zK/kxfhDyp8UA1omEFDqAgDWoltYtQ+ l7C6JHe1w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkJ-0006sp-9a; Fri, 29 Jan 2021 14:27:35 +0000 Received: from mail-dm6nam10on2050.outbound.protection.outlook.com ([40.107.93.50] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkH-0006sN-II for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2021 14:27:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B0TH1QZ+iJ8xVgDT8GAHETYCtkRuXyjBGg/GLlq8K+P2eylZo21A1pM7hhFscaEYVyFll+ts8Uqp3m63fC9ovFjE4a/6TO71TeXx7AbR4qDv3SucmVtiGi9DB/AjdHKWP2C2SJwj7r/s7DZK3ZjpCJt3kCxlfnSMyNBWSdXELYweBwr1XyF6k3mgmetHnPEI2+UA7bzZkfYTpzy992JSoQnD/pTsre0JfKCxGsCCkokrDHF035769L9lBde+kSAI0aIECpzWp/VvOgJILyRTXEIswQ+3PnFrkuS6oIOArI0rIK60dhEM0auzYqFoYGjoe6gVwU0RcVusRAHt5n3vwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zEFxFxqKNtEcqis/o2KJrQBA4mRW582IJ7dh17vH/O8=; b=hgNVGtM1eGPYmDdgt+GM4T0MwE4hWGBdazY94Vw3MKqcKMi5eN6EmUgwHNgp7aCe8HtZK+hylLfI9AmCrgEvxhEZwUvi27H4WoPjtEBN0YWWtQqRDKh6g5qg1GeHySSdI6NPlfpHlk0J1dURJln+fqTa1Oatr8YfvLY7C+UCYxpfW6+elJNa09cv9cj/2O7Aurz2X6OEjGmQ5z4ugxow9hRMrmLZpx3j42Qy2OqgBqkKMyOwyTz5QaVJSMZ7quIvlNbEYfoDXGezTei7w7sZcsiUl5cFJ0WDovLlQjLtYjK33iK09cqrHveUShD57jqt57/sNkYP7QDZk5w9NNIM7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=linaro.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zEFxFxqKNtEcqis/o2KJrQBA4mRW582IJ7dh17vH/O8=; b=hJmnRCuVZQx+Zi54S53CdualREnOsWEcg17enTnTsKRU4z3fSMhHDkfS9J7GIxrOPQ35FmXZB0bzxDIiAnTdG6A12JRgdcNl47jGBW8xM/gPWKZ7OaiVNs4wLYRwXM3Z70NVNCU5KaBSiWA8Ef9WiFJGTvpvXaR9da3TnskFutM= Received: from SN4PR0801CA0021.namprd08.prod.outlook.com (2603:10b6:803:29::31) by PH0PR02MB7288.namprd02.prod.outlook.com (2603:10b6:510:9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.19; Fri, 29 Jan 2021 14:27:30 +0000 Received: from SN1NAM02FT016.eop-nam02.prod.protection.outlook.com (2603:10b6:803:29:cafe::52) by SN4PR0801CA0021.outlook.office365.com (2603:10b6:803:29::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 14:27:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT016.mail.protection.outlook.com (10.152.72.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3784.12 via Frontend Transport; Fri, 29 Jan 2021 14:27:29 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 29 Jan 2021 06:27:02 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.1913.5 via Frontend Transport; Fri, 29 Jan 2021 06:27:02 -0800 Received: from [10.140.6.6] (port=56658 helo=xhdappanad40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1l5Ujk-00005L-Rg; Fri, 29 Jan 2021 06:27:01 -0800 From: Srinivas Neeli To: , , , , , , Subject: [PATCH V5 1/5] gpio: gpio-xilinx: Simplify with dev_err_probe() Date: Fri, 29 Jan 2021 19:56:46 +0530 Message-ID: <1611930410-25747-2-git-send-email-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> References: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 09310414-0346-4836-49cb-08d8c462023f X-MS-TrafficTypeDiagnostic: PH0PR02MB7288: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dqJOX0eA+wXj7x750SQ2iuCbzSqQNryuk+PulEE+H3zB4+95JvFGD3FpbWyEcCd56tG4sfNArr9ebUBRnRtuPd46JJxazzG9dHMUVWCSJeGEZ/cvC3u+0VmV8kq2m008amDpJyTAQhYZ1pUJxy5Y4+6RgTjc0Uf9RK0Jj4qFrc4b26xD/PbdNIUxypf0dtZBBEijpIXdWXGJ/IaLAvEf+GdO1HeBTh2auuh0O+wuBISCpwf37GEEbtSpsbvxnJGbWJusCnItZru9tRypUhtYIsYTxZMVyvbVhnVF8+zvuBtzp8j2mIpTKaC8mFKjVOrRccZzN80oNeYjwi85uezdlIQ11N71fHJyxqEM6zFr57jG2DeaeMTrL30tTqyNrK4ToP4ub4dsETE3yqsLcXZkEd/52Qnby7yisiIj7kniYYV78zsaV5bXgjJZY2Cf5f+NG0bI26JeC9kGq02vqRUw1BGBu/IqT5wlM4z5JdZ0tCqPQ3KNQ0BnL+la0OF4LeclVgYwAUe6qkMl+xXZ67Om60Xm24/PIdhh3AFNNqHmq2BcQ3RKlhSAYjccs26iHoKKctTAz+MTEVMug/qbk2TOIYhUmO4nqQBnKkvS8LwzFdZY3dv1pxOij+h+oFADQAtc X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(46966006)(83380400001)(36906005)(316002)(9786002)(336012)(26005)(186003)(110136005)(4326008)(70586007)(7636003)(54906003)(70206006)(2906002)(426003)(2616005)(478600001)(7696005)(44832011)(82740400003)(82310400003)(5660300002)(6666004)(356005)(8936002)(107886003)(36756003)(47076005)(8676002)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 14:27:29.5656 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09310414-0346-4836-49cb-08d8c462023f X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT016.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB7288 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210129_092733_630690_2553966E X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Srinivas Neeli , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, git@xilinx.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value. Signed-off-by: Srinivas Neeli Reviewed-by: Linus Walleij --- Changes in V5: -None Changes in V4: -New patch --- drivers/gpio/gpio-xilinx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index be539381fd82..d010a63d5d15 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -357,11 +357,8 @@ static int xgpio_probe(struct platform_device *pdev) } chip->clk = devm_clk_get_optional(&pdev->dev, NULL); - if (IS_ERR(chip->clk)) { - if (PTR_ERR(chip->clk) != -EPROBE_DEFER) - dev_dbg(&pdev->dev, "Input clock not found\n"); - return PTR_ERR(chip->clk); - } + if (IS_ERR(chip->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk), "input clock not found.\n"); status = clk_prepare_enable(chip->clk); if (status < 0) { From patchwork Fri Jan 29 14:26:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12055981 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 4EEE7C433E0 for ; Fri, 29 Jan 2021 14:29:40 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1FFC64DF1 for ; Fri, 29 Jan 2021 14:29:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1FFC64DF1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pqDWoHjHUFWl/GzeCvPtgQJgDu0HzjQ5gW4aee32MJM=; b=ShYu+sTvUUA8slmZlKHRr8hNd lIav6FeLKFolsDZuAb8mkn4iRMWnhjTcK3IfP3Uwk/oSLICvh6lIK/t0T17Mqt2quG1Jm+/Jw+FP3 u5fOjaba0SBJOj6YDdWtG3AC5z2GPuyP6ZfGU3rUOvRwR1j8KseSc/SoCOFyu8ghzkr5i6UOTyvW6 e+PBUlqtsDvWA883uz1p1uP5ErW5M9h9cGIAPhdDtM0mFVfp1dfJry1LZ38LVUrsEhzYfkMLfabHR 6vMYwX8XfyIzf9uUtiYLSPfLvOPYeZ/a9BV4TTfouDRqqKz6r8mZdIqQVGvlonrLvsbnUqVbmv9QU WdpZdoI8Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5Ukz-00074d-L2; Fri, 29 Jan 2021 14:28:17 +0000 Received: from mail-dm6nam12on2073.outbound.protection.outlook.com ([40.107.243.73] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5Ukw-00072u-6k for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2021 14:28:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acRvMQGtk8nrm9VKAtTVQrDwNcWwbXZKYVILPdHJIRSNG5zcMRzKeairIN4ez2Tow+Eb7833ocCkcovIPdKP2wtw+A1tgAp6n7r7pVlARxmDvcKyNvWs8diDkgU5emCVtVE3TOpK4YDieYZHvcG+gWr+fEdWFMW7sTz7wRX5j5Mzk1uI9qFJtglEaLUbWKb7SHMjy+19M4fetNlSvDQhB4k/MiLa8iMpPGtVSnhNIHcwMwjzLrd7rxWI6DxN0snY6aX5K518UpIU3C1vqN/VUpS3sTi3RtjNYox/83+HU/5eZKu4OjKGODrm0qpTuE872/3c8QDUC6jNbvY++gY1JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5kiYTkQ6CNF4A1svU0qtvfJg7LCz3Io0jWVj8M+5SaY=; b=oTTxVMkEnZyBio4fYwRDQNRoxEsKPRTI9j94v3TdYowdk9tXMSZ+cZNzjPCjx2QyktDiFQ8C0LYG4ADU0xXTqw9Man1MZr4cUAM33tjKxRN4t8POdTtxfRAljohuO1ewp+QcA5S0vM1AglvqY++neqSWD5mNEBdrj3aiTh7Wk2W+CXjIf8CZdFxD0pxl+ki9p640EQYXn9o2RKMp6m1FpYM9l937HLoUVZcqybHEbeRpfdnCc6xbkwszZRGH3S5McX5UN74LCSMEAfMidqN8eYkoBRFriGl++x0m5pDfMYPFXSrk2cH6hWVnImC81P1AXV+6rUvZ9ub+spw2bUcF9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=linaro.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5kiYTkQ6CNF4A1svU0qtvfJg7LCz3Io0jWVj8M+5SaY=; b=rTBGcImTMuhHIeKoziZfqxscG+sjmndhyrHW9LtNR5V+8MNH8/AKj+DC+KWjZQQ8UTRLou4NrN3lQLfqfTc0JAuNTV02OZiU+Ta/Vz2koYfy3rBidPJwk0Glt0I4AALCHKfpcWAyN+1RltsQsmSFizm7Io4qSEd2/hcCst7G2NE= Received: from CY4PR22CA0052.namprd22.prod.outlook.com (2603:10b6:903:ae::14) by SN6PR02MB4606.namprd02.prod.outlook.com (2603:10b6:805:b0::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Fri, 29 Jan 2021 14:28:05 +0000 Received: from CY1NAM02FT042.eop-nam02.prod.protection.outlook.com (2603:10b6:903:ae:cafe::da) by CY4PR22CA0052.outlook.office365.com (2603:10b6:903:ae::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16 via Frontend Transport; Fri, 29 Jan 2021 14:28:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by CY1NAM02FT042.mail.protection.outlook.com (10.152.75.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3784.12 via Frontend Transport; Fri, 29 Jan 2021 14:28:05 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 29 Jan 2021 06:27:05 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.1913.5 via Frontend Transport; Fri, 29 Jan 2021 06:27:05 -0800 Received: from [10.140.6.6] (port=56658 helo=xhdappanad40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1l5Ujo-00005L-M5; Fri, 29 Jan 2021 06:27:05 -0800 From: Srinivas Neeli To: , , , , , , Subject: [PATCH V5 2/5] gpio: gpio-xilinx: Reduce spinlock array to array Date: Fri, 29 Jan 2021 19:56:47 +0530 Message-ID: <1611930410-25747-3-git-send-email-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> References: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b52d6e3-5916-4a09-03c5-08d8c4621780 X-MS-TrafficTypeDiagnostic: SN6PR02MB4606: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gKJWEtFYPcGLa8fZDJYCFDtY1K+aonYaPyejoRD4Diisulm6Qim5mSs9aDJY7f+lz5Sw5FMTuSiv5co0aedxcnMllJ1OuLSQoeq1GieHAsEhmpc93My4hojkJ5RevynWamIFAcGEdQZoUDLoV8YSAEB82o0u6UtdXo7NBw8jDfhlqOILjdVNqMyzvK5Fi85YytR7WXFaxT/CY0nfIQCheK5sSkZFESuOZSh53Ksc6AMtcRuDHGLfbzU5fqZGzfnOmjqyUYShW1KyxNjKPs+buIfu2w0forUQhS3cRkvYzevt3a15/zNiGPB4K7M8rB3uJNlwZWWMXg5QY0R+OecFcxBzKKNqj+iC+Pks+EVMP7uZfRm0rKd90koNOrWpwpP9B3KVFTvGXFxWy9O0meALV4Y8DSbcAiFyn6moSa5KP4ehzBNLUUrRQaBmcrt/tA9OK9/jcVZndCHDPAzpjNj1VBLPSIMmGgnAQU2RYLrBhW+d44SVNgi+t8HSwrRFy7r0UxPW2w+mq5Bh0yvNFCKwC51kX4sH/ENNRzrns+xsCgGaXVJLo8mtvTeDSBwFXzKPqCL8o5ormCcOWjJ+2kZ6qNTAARgqDTxgjK5f5pSzgg2KUW2J6ughbA7NGB0/HpAH X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch01.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(396003)(346002)(39860400002)(136003)(376002)(46966006)(9786002)(478600001)(110136005)(8936002)(7636003)(26005)(316002)(82310400003)(70586007)(82740400003)(36756003)(83380400001)(36906005)(186003)(2906002)(2616005)(6666004)(107886003)(7696005)(44832011)(70206006)(47076005)(4326008)(8676002)(356005)(54906003)(5660300002)(336012)(426003)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 14:28:05.2390 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b52d6e3-5916-4a09-03c5-08d8c4621780 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT042.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB4606 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210129_092814_353226_C14116E5 X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Srinivas Neeli , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, git@xilinx.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Changed spinlock array to single. It is preparation for irq support which is shared between two channels that's why spinlock should be only one. Signed-off-by: Srinivas Neeli Reviewed-by: Linus Walleij --- Changes in V5: -None Changes in V4: -None. Changes in V3: -Created new patch for spinlock changes. --- drivers/gpio/gpio-xilinx.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index d010a63d5d15..f88db56543c2 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -47,7 +47,7 @@ struct xgpio_instance { unsigned int gpio_width[2]; u32 gpio_state[2]; u32 gpio_dir[2]; - spinlock_t gpio_lock[2]; + spinlock_t gpio_lock; /* For serializing operations */ struct clk *clk; }; @@ -113,7 +113,7 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); - spin_lock_irqsave(&chip->gpio_lock[index], flags); + spin_lock_irqsave(&chip->gpio_lock, flags); /* Write to GPIO signal and set its direction to output */ if (val) @@ -124,7 +124,7 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + xgpio_regoffset(chip, gpio), chip->gpio_state[index]); - spin_unlock_irqrestore(&chip->gpio_lock[index], flags); + spin_unlock_irqrestore(&chip->gpio_lock, flags); } /** @@ -144,7 +144,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, int index = xgpio_index(chip, 0); int offset, i; - spin_lock_irqsave(&chip->gpio_lock[index], flags); + spin_lock_irqsave(&chip->gpio_lock, flags); /* Write to GPIO signals */ for (i = 0; i < gc->ngpio; i++) { @@ -155,9 +155,9 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + index * XGPIO_CHANNEL_OFFSET, chip->gpio_state[index]); - spin_unlock_irqrestore(&chip->gpio_lock[index], flags); + spin_unlock_irqrestore(&chip->gpio_lock, flags); index = xgpio_index(chip, i); - spin_lock_irqsave(&chip->gpio_lock[index], flags); + spin_lock_irqsave(&chip->gpio_lock, flags); } if (__test_and_clear_bit(i, mask)) { offset = xgpio_offset(chip, i); @@ -171,7 +171,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + index * XGPIO_CHANNEL_OFFSET, chip->gpio_state[index]); - spin_unlock_irqrestore(&chip->gpio_lock[index], flags); + spin_unlock_irqrestore(&chip->gpio_lock, flags); } /** @@ -190,14 +190,14 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); - spin_lock_irqsave(&chip->gpio_lock[index], flags); + spin_lock_irqsave(&chip->gpio_lock, flags); /* Set the GPIO bit in shadow register and set direction as input */ chip->gpio_dir[index] |= BIT(offset); xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); - spin_unlock_irqrestore(&chip->gpio_lock[index], flags); + spin_unlock_irqrestore(&chip->gpio_lock, flags); return 0; } @@ -221,7 +221,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); - spin_lock_irqsave(&chip->gpio_lock[index], flags); + spin_lock_irqsave(&chip->gpio_lock, flags); /* Write state of GPIO signal */ if (val) @@ -236,7 +236,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); - spin_unlock_irqrestore(&chip->gpio_lock[index], flags); + spin_unlock_irqrestore(&chip->gpio_lock, flags); return 0; } @@ -312,7 +312,7 @@ static int xgpio_probe(struct platform_device *pdev) if (of_property_read_u32(np, "xlnx,gpio-width", &chip->gpio_width[0])) chip->gpio_width[0] = 32; - spin_lock_init(&chip->gpio_lock[0]); + spin_lock_init(&chip->gpio_lock); if (of_property_read_u32(np, "xlnx,is-dual", &is_dual)) is_dual = 0; @@ -336,7 +336,6 @@ static int xgpio_probe(struct platform_device *pdev) &chip->gpio_width[1])) chip->gpio_width[1] = 32; - spin_lock_init(&chip->gpio_lock[1]); } chip->gc.base = -1; From patchwork Fri Jan 29 14:26:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12055975 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 50C8BC433E6 for ; Fri, 29 Jan 2021 14:29:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC32364DF1 for ; Fri, 29 Jan 2021 14:29:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC32364DF1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eFWb9c9gHI9sSX8VnBlBdaPKkINFR4V3xa7VymQ4xhw=; b=T7z6C40hgHixRcd6RSjesOHmc l45F95kfDCfz+0LiCsb3jihim0SDfOh7YDTGhoCf96WvC0JP+DBBJsYAmfSMagO+4J2luM8aMt+gG CoO++asHhYrgPzzUh8lBqfYjSqLXFve+M2TL77n/WfszxmB4uafxG0MQCSXmnpiSbYeDfWeagySCS 2iKxMrTSWeEN10YaRBIw3CN1bnDAUkr4yQ1ZdMNjPqYKwgvdLrzSZ6LvPV47xpgDgw0IlMhe54Cfz 1Bmiv6VvU3ZRyxUYthVkYJ3trFqvjky8etMDrrpj4uS2DRnQbKq3hTx8k4eJqQRQWUcFg0CuRfOhe +MSZ+XYoQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkP-0006u8-MJ; Fri, 29 Jan 2021 14:27:41 +0000 Received: from mail-dm6nam11on2050.outbound.protection.outlook.com ([40.107.223.50] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkK-0006sq-46 for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2021 14:27:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V4tAS7o650zB/+z7nllkZY6uy98cTvtSPJAFvSUxt9on3ONtUDiId2Zk1GKsrxo0de+2d1ZXdCsynhmtAgRo85mloio69CvgiwAMaYC9QIHoElguFQAAQtKj4/Z7fVlo9HhVa8tXCfMQOLlOXCWmGxDXVgnfvlo/YFIHwXoUgJUucz73QHJKs94+cTLtApI/DEZt5cofsP0PJRuRB4fG7QwTlpwFxx8DOo0R46FIXuXuw4Gbp48rjPRfH2jiz+if0hUqZTRPuL4RWlU9Y71riTgGJqOFjIWJedo2t+xeTSm0lgkJcJJvkFXKpw51Nb+gPKoscmmXwtztSs6wc1N/XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6jgSlSG7l7MxZVEJM+3hgxMrBH7K8iYDSdoKnmljoog=; b=bjEaF1wALh7MmuUkedsYAM3VTkadRHgUjGItEVXfNs01Oi/NKKqM63Q9886MrZeEVv1bLSs1NkfNeOcQs8K1fvHFHn63vfrSEcZfe/Sgbvf4zWItA4KTLB5iG8tNXWJHs8Z5yWMCgms2iw56TKZ0gaTOtK/Qp1c5bwoBNz0Hog7Gh5Z3gTEy80ZRXU1Lu2YeJfqQ/67pHfi19HgjSyi+vnTrnHj3S8WdOsIUUZZeyA7kn2thxGnnI78CoZc3RIj8ulO7dJB7OmgK+3yo2JKn+QEcj+wp57Sj9Bn/4JP4W9abNmnyu1W0vz+6m0yTph0ex/g4L+iPHFEfBtviVthHaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=linaro.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6jgSlSG7l7MxZVEJM+3hgxMrBH7K8iYDSdoKnmljoog=; b=XmDa3eGpPayCmEvrrMeFu9mrAsJapG7cKdWbS12XeH0lfWrARXiAiHr1m9Yv/BTYPx6a92mIQT/xOxhdNIr8gSyX32sD7zVnRInPcEZcb9RecWXRXRGpnYZ5jSSliNNVoy774xMJhXLT3+kfOuexGyr0CIz148UoT8vd34zhCfo= Received: from SN7PR04CA0063.namprd04.prod.outlook.com (2603:10b6:806:121::8) by BL0PR02MB4276.namprd02.prod.outlook.com (2603:10b6:208:46::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Fri, 29 Jan 2021 14:27:32 +0000 Received: from SN1NAM02FT004.eop-nam02.prod.protection.outlook.com (2603:10b6:806:121:cafe::53) by SN7PR04CA0063.outlook.office365.com (2603:10b6:806:121::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16 via Frontend Transport; Fri, 29 Jan 2021 14:27:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT004.mail.protection.outlook.com (10.152.72.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3784.12 via Frontend Transport; Fri, 29 Jan 2021 14:27:31 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 29 Jan 2021 06:27:09 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server id 15.1.1913.5 via Frontend Transport; Fri, 29 Jan 2021 06:27:09 -0800 Received: from [10.140.6.6] (port=56658 helo=xhdappanad40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1l5Ujs-00005L-O1; Fri, 29 Jan 2021 06:27:09 -0800 From: Srinivas Neeli To: , , , , , , Subject: [PATCH V5 3/5] gpio: gpio-xilinx: Add interrupt support Date: Fri, 29 Jan 2021 19:56:48 +0530 Message-ID: <1611930410-25747-4-git-send-email-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> References: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43cfa507-8053-4f55-893c-08d8c46203a1 X-MS-TrafficTypeDiagnostic: BL0PR02MB4276: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zId9Bm97x3WnZ0kddjG9NvGQCg6ra0nI/rKTCP6UWeg2jR13vTdIlAvKqYjjhptPi5jGM0eGNzRGvNq+EUeNNuv2Ye6UwXKDnX0Cw52l3RDPBmFTOQRdNvAKFni7FzGQBr0R4V2HojHbbMbEv40lhYhCABOHQPGjeaYpfD9TUV4u6oKbkv7uwsrlK7q2gFyYj1ttNV2t3c3aaIDqorwY3jm5Gtjwa5gFNBiERglqk5Zv/jKRo71tBOtK+H7hQ0+dYukVCO21Usw8wrcitYF0Wy7CaJFBDio9chf5nEDq87ElBGDM3iS1a/QwnatRY12LJB5+YqoFdEKeuj5o7BnWBHaCN9ipu/4SRE121xPZsnLasT7RujB1RxDbc4JI89JbUT6iEwqB5yJcVz/jmbqXkq7SRrtI/tgPbnREt9yofJn/biu/LYkHteNurMxA1DRR6u5ITU4NiQ0rWEfYO1B24o9e2/YR4jdJEEejfYwvimyeOqGUj2pNO1WcrI6h/aA4qt/WWPUpuVUXgxPqTeg8zqG8xnBjXLSSuMBOYRsM1kOZFWwNZZEDJvDelNU5gVA3YUvBG0MRInlsiKg+tqjxOnvVlwQfXM10gG3z+6PMxTlEOIy8N7zoRlFwOfT6OaBx X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(396003)(136003)(39860400002)(346002)(376002)(46966006)(356005)(7636003)(8676002)(36906005)(5660300002)(478600001)(7696005)(70206006)(8936002)(36756003)(316002)(30864003)(2906002)(6666004)(26005)(110136005)(9786002)(83380400001)(186003)(336012)(44832011)(82740400003)(426003)(54906003)(82310400003)(2616005)(4326008)(70586007)(47076005)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 14:27:31.8872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43cfa507-8053-4f55-893c-08d8c46203a1 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT004.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB4276 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210129_092736_296799_E073E4EB X-CRM114-Status: GOOD ( 24.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Srinivas Neeli , linux-kernel@vger.kernel.org, Robert Hancock , linux-gpio@vger.kernel.org, git@xilinx.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Adds interrupt support to the Xilinx GPIO driver so that rising and falling edge line events can be supported. Since interrupt support is an optional feature in the Xilinx IP, the driver continues to support devices which have no interrupt provided. Depends on OF_GPIO framework for of_xlate function to translate gpiospec to the GPIO number and flags. Signed-off-by: Robert Hancock Signed-off-by: Shubhrajyoti Datta Signed-off-by: Srinivas Neeli Reviewed-by: Linus Walleij --- Changes in V5: -Removed IRQ_DOMAIN_HIERARCHY from Kconfig and #include from includes. -Fixed "detected irqchip that is shared with multiple gpiochips: please fix the driver"error message. -Added check for #gpio-cells and error message in failure case. Changes in V4: -Added more commit description. Changes in V3: -Created separate patch for Clock changes and runtime resume and suspend. -Updated minor review comments. Changes in V2: -Added check for return value of platform_get_irq() API. -Updated code to support rising edge and falling edge. -Added xgpio_xlate() API to support switch. -Added MAINTAINERS fragment. --- drivers/gpio/Kconfig | 2 + drivers/gpio/gpio-xilinx.c | 246 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 244 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index c70f46e80a3b..2ee57797d908 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -690,6 +690,8 @@ config GPIO_XGENE_SB config GPIO_XILINX tristate "Xilinx GPIO support" + select GPIOLIB_IRQCHIP + depends on OF_GPIO help Say yes here to support the Xilinx FPGA GPIO device diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index f88db56543c2..62deb755f910 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -22,6 +24,11 @@ #define XGPIO_CHANNEL_OFFSET 0x8 +#define XGPIO_GIER_OFFSET 0x11c /* Global Interrupt Enable */ +#define XGPIO_GIER_IE BIT(31) +#define XGPIO_IPISR_OFFSET 0x120 /* IP Interrupt Status */ +#define XGPIO_IPIER_OFFSET 0x128 /* IP Interrupt Enable */ + /* Read/Write access to the GPIO registers */ #if defined(CONFIG_ARCH_ZYNQ) || defined(CONFIG_X86) # define xgpio_readreg(offset) readl(offset) @@ -36,9 +43,15 @@ * @gc: GPIO chip * @regs: register block * @gpio_width: GPIO width for every channel - * @gpio_state: GPIO state shadow register + * @gpio_state: GPIO write state shadow register + * @gpio_last_irq_read: GPIO read state register from last interrupt * @gpio_dir: GPIO direction shadow register * @gpio_lock: Lock used for synchronization + * @irq: IRQ used by GPIO device + * @irqchip: IRQ chip + * @irq_enable: GPIO IRQ enable/disable bitfield + * @irq_rising_edge: GPIO IRQ rising edge enable/disable bitfield + * @irq_falling_edge: GPIO IRQ falling edge enable/disable bitfield * @clk: clock resource for this driver */ struct xgpio_instance { @@ -46,8 +59,14 @@ struct xgpio_instance { void __iomem *regs; unsigned int gpio_width[2]; u32 gpio_state[2]; + u32 gpio_last_irq_read[2]; u32 gpio_dir[2]; spinlock_t gpio_lock; /* For serializing operations */ + int irq; + struct irq_chip irqchip; + u32 irq_enable[2]; + u32 irq_rising_edge[2]; + u32 irq_falling_edge[2]; struct clk *clk; }; @@ -277,6 +296,175 @@ static int xgpio_remove(struct platform_device *pdev) } /** + * xgpio_irq_ack - Acknowledge a child GPIO interrupt. + * @irq_data: per IRQ and chip data passed down to chip functions + * This currently does nothing, but irq_ack is unconditionally called by + * handle_edge_irq and therefore must be defined. + */ +static void xgpio_irq_ack(struct irq_data *irq_data) +{ +} + +/** + * xgpio_irq_mask - Write the specified signal of the GPIO device. + * @irq_data: per IRQ and chip data passed down to chip functions + */ +static void xgpio_irq_mask(struct irq_data *irq_data) +{ + unsigned long flags; + struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data); + int irq_offset = irqd_to_hwirq(irq_data); + int index = xgpio_index(chip, irq_offset); + int offset = xgpio_offset(chip, irq_offset); + + spin_lock_irqsave(&chip->gpio_lock, flags); + + chip->irq_enable[index] &= ~BIT(offset); + + if (!chip->irq_enable[index]) { + /* Disable per channel interrupt */ + u32 temp = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET); + + temp &= ~BIT(index); + xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp); + } + spin_unlock_irqrestore(&chip->gpio_lock, flags); +} + +/** + * xgpio_irq_unmask - Write the specified signal of the GPIO device. + * @irq_data: per IRQ and chip data passed down to chip functions + */ +static void xgpio_irq_unmask(struct irq_data *irq_data) +{ + unsigned long flags; + struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data); + int irq_offset = irqd_to_hwirq(irq_data); + int index = xgpio_index(chip, irq_offset); + int offset = xgpio_offset(chip, irq_offset); + u32 old_enable = chip->irq_enable[index]; + + spin_lock_irqsave(&chip->gpio_lock, flags); + + chip->irq_enable[index] |= BIT(offset); + + if (!old_enable) { + /* Clear any existing per-channel interrupts */ + u32 val = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET) & + BIT(index); + + if (val) + xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, val); + + /* Update GPIO IRQ read data before enabling interrupt*/ + val = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET + + index * XGPIO_CHANNEL_OFFSET); + chip->gpio_last_irq_read[index] = val; + + /* Enable per channel interrupt */ + val = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET); + val |= BIT(index); + xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val); + } + + spin_unlock_irqrestore(&chip->gpio_lock, flags); +} + +/** + * xgpio_set_irq_type - Write the specified signal of the GPIO device. + * @irq_data: Per IRQ and chip data passed down to chip functions + * @type: Interrupt type that is to be set for the gpio pin + * + * Return: + * 0 if interrupt type is supported otherwise -EINVAL + */ +static int xgpio_set_irq_type(struct irq_data *irq_data, unsigned int type) +{ + struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data); + int irq_offset = irqd_to_hwirq(irq_data); + int index = xgpio_index(chip, irq_offset); + int offset = xgpio_offset(chip, irq_offset); + + /* + * The Xilinx GPIO hardware provides a single interrupt status + * indication for any state change in a given GPIO channel (bank). + * Therefore, only rising edge or falling edge triggers are + * supported. + */ + switch (type & IRQ_TYPE_SENSE_MASK) { + case IRQ_TYPE_EDGE_BOTH: + chip->irq_rising_edge[index] |= BIT(offset); + chip->irq_falling_edge[index] |= BIT(offset); + break; + case IRQ_TYPE_EDGE_RISING: + chip->irq_rising_edge[index] |= BIT(offset); + chip->irq_falling_edge[index] &= ~BIT(offset); + break; + case IRQ_TYPE_EDGE_FALLING: + chip->irq_rising_edge[index] &= ~BIT(offset); + chip->irq_falling_edge[index] |= BIT(offset); + break; + default: + return -EINVAL; + } + + irq_set_handler_locked(irq_data, handle_edge_irq); + return 0; +} + +/** + * xgpio_irqhandler - Gpio interrupt service routine + * @desc: Pointer to interrupt description + */ +static void xgpio_irqhandler(struct irq_desc *desc) +{ + struct xgpio_instance *chip = irq_desc_get_handler_data(desc); + struct irq_chip *irqchip = irq_desc_get_chip(desc); + u32 num_channels = chip->gpio_width[1] ? 2 : 1; + u32 offset = 0, index; + u32 status = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET); + + xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, status); + + chained_irq_enter(irqchip, desc); + for (index = 0; index < num_channels; index++) { + if ((status & BIT(index))) { + unsigned long rising_events, falling_events, all_events; + unsigned long flags; + u32 data, bit; + unsigned int irq; + + spin_lock_irqsave(&chip->gpio_lock, flags); + data = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET + + index * XGPIO_CHANNEL_OFFSET); + rising_events = data & + ~chip->gpio_last_irq_read[index] & + chip->irq_enable[index] & + chip->irq_rising_edge[index]; + falling_events = ~data & + chip->gpio_last_irq_read[index] & + chip->irq_enable[index] & + chip->irq_falling_edge[index]; + dev_dbg(chip->gc.parent, + "IRQ chan %u rising 0x%lx falling 0x%lx\n", + index, rising_events, falling_events); + all_events = rising_events | falling_events; + chip->gpio_last_irq_read[index] = data; + spin_unlock_irqrestore(&chip->gpio_lock, flags); + + for_each_set_bit(bit, &all_events, 32) { + irq = irq_find_mapping(chip->gc.irq.domain, + offset + bit); + generic_handle_irq(irq); + } + } + offset += chip->gpio_width[index]; + } + + chained_irq_exit(irqchip, desc); +} + +/** * xgpio_of_probe - Probe method for the GPIO device. * @pdev: pointer to the platform device * @@ -289,7 +477,10 @@ static int xgpio_probe(struct platform_device *pdev) struct xgpio_instance *chip; int status = 0; struct device_node *np = pdev->dev.of_node; - u32 is_dual; + u32 is_dual = 0; + u32 cells = 2; + struct gpio_irq_chip *girq; + u32 temp; chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); if (!chip) @@ -305,6 +496,15 @@ static int xgpio_probe(struct platform_device *pdev) if (of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir[0])) chip->gpio_dir[0] = 0xFFFFFFFF; + /* Update cells with gpio-cells value */ + if (of_property_read_u32(np, "#gpio-cells", &cells)) + dev_dbg(&pdev->dev, "Missing gpio-cells property\n"); + + if (cells != 2) { + dev_err(&pdev->dev, "#gpio-cells mismatch\n"); + return -EINVAL; + } + /* * Check device node and parent device node for device width * and assume default width of 32 @@ -343,6 +543,7 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.parent = &pdev->dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out; + chip->gc.of_gpio_n_cells = cells; chip->gc.get = xgpio_get; chip->gc.set = xgpio_set; chip->gc.set_multiple = xgpio_set_multiple; @@ -367,14 +568,51 @@ static int xgpio_probe(struct platform_device *pdev) xgpio_save_regs(chip); + chip->irq = platform_get_irq_optional(pdev, 0); + if (chip->irq <= 0) + goto skip_irq; + + chip->irqchip.name = "gpio-xilinx"; + chip->irqchip.irq_ack = xgpio_irq_ack; + chip->irqchip.irq_mask = xgpio_irq_mask; + chip->irqchip.irq_unmask = xgpio_irq_unmask; + chip->irqchip.irq_set_type = xgpio_set_irq_type; + + /* Disable per-channel interrupts */ + xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, 0); + /* Clear any existing per-channel interrupts */ + temp = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET); + xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, temp); + /* Enable global interrupts */ + xgpio_writereg(chip->regs + XGPIO_GIER_OFFSET, XGPIO_GIER_IE); + + girq = &chip->gc.irq; + girq->chip = &chip->irqchip; + girq->parent_handler = xgpio_irqhandler; + girq->num_parents = 1; + girq->parents = devm_kcalloc(&pdev->dev, 1, + sizeof(*girq->parents), + GFP_KERNEL); + if (!girq->parents) { + status = -ENOMEM; + goto err_unprepare_clk; + } + girq->parents[0] = chip->irq; + girq->default_type = IRQ_TYPE_NONE; + girq->handler = handle_bad_irq; + +skip_irq: status = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip); if (status) { dev_err(&pdev->dev, "failed to add GPIO chip\n"); - clk_disable_unprepare(chip->clk); - return status; + goto err_unprepare_clk; } return 0; + +err_unprepare_clk: + clk_disable_unprepare(chip->clk); + return status; } static const struct of_device_id xgpio_of_match[] = { From patchwork Fri Jan 29 14:26:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12055973 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 11705C433E0 for ; Fri, 29 Jan 2021 14:29:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE52064DF1 for ; Fri, 29 Jan 2021 14:29:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE52064DF1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2ELpJZzT1tqKzz3SQ9aNrWYMVaf5WYLeNr8ECxd6gjY=; b=vr6Z+Dm6MaAFPGvuIIGVADCDB fEU8PZmblQvftVQagoRsHMRe/+1ruFGa73de6PPetJGs9rR+OIfoRIT4hSXcGXxBKaRK/ieJLAEeo /HfQuSV/z9gzUaJ27uH4mmWcfEbKIWj70HuUfsaOhzu96bboNQtXqyVGpPoLtbI3voWp50rO+XMyB b1uvjraobXyIc/fTFX1tdqcwEULBCNLi+PVO4hLn0KgUlonVk/cub7bMh69bjYMX2t5HoR28OYJbN GE4ZFc6VOvm5JtV+lD6xqmBU0cL/o8YAZD4loRuvQQ07GRLNZK+frjxw4TZr9VpEvewRH8TN/fimA 5ttJOc4CQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkR-0006uO-Bn; Fri, 29 Jan 2021 14:27:43 +0000 Received: from mail-mw2nam12on2066.outbound.protection.outlook.com ([40.107.244.66] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkL-0006t1-Gb for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2021 14:27:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZtBpygQH9Igkf7uniVKlvDWLJJUQO57/1pYPd0yvRako9MSGYHFN8IIou40b4fezu/ffamYMNU67urxz4E28R1WFHoAKbM4QhGQoH30y4mR7K84v8zRDUTJe5G6sz5j1nc5dfvngtdPz4mtKK+SeGqvRER6GG2L95YlFGOaENqQzNFN6SqM0iBi68HOeALpSvJJtzojN7ZJ3Pd3Mq5PZUCCMUH1VFKpWYSzpqyXGqLx/kFQSXpUoeE3j6qVgmO+VUGp8XAOU7THbd/ZoSrKJEDZWz556EqB5MPasAlfnUJSe4PK3r8jkrt2LO103yBE3CiTRXdBigzmPXWC8ifYb1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yHB/ZOYHM4o04THjf6hn8/QAL0vR0QBlIauRkZ/2Ri0=; b=A2EDcOS5rrd1hIsohUd/tsVV6PVn2HUD6wjRZ1GCsUi9N4II7TRpH9QbtUWPIOpepkUINDkb95y3a0ShnH6Jt5KbbsWLEpyWc4cXCUZmcMYEYI3vRZz1EqRBlSvb9ItguJ80d0bd2Raf3R5gaHSxpdp6YH3SCzbBtp5T3FiXHJ4dpGJsEL8fgRauUL5e7BaK1Q65leI05bmjozmrT3U2plsrk+GsDWuHKjBiKep4rKO/Tz3wAqTow9LuTIcHfjJUoFXaj8M/yE2g+9nLoJohxEm4l9WKFd/bX6b629zpMjtl/TTJiERGHqgrlkQiG9L9uw6meCyE/1SJYUC9ZOBPDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=linaro.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yHB/ZOYHM4o04THjf6hn8/QAL0vR0QBlIauRkZ/2Ri0=; b=SKAXE7jxM/Ho5MDX5baaBF5oeXacED117V8X3v2mic4YF9yKaqcCVJKsNHFUm1CJ9WRM9dJt5xCgsYQSIPYW6ImQf0CvVSQLohQo/aowoMfBhwzdfFwtxxMfMUYYeiGcInUSiijG1ag/MlNjyXi+oXj/lSVU0CCvWTv1qUhNNyU= Received: from SN7PR04CA0067.namprd04.prod.outlook.com (2603:10b6:806:121::12) by DM6PR02MB5849.namprd02.prod.outlook.com (2603:10b6:5:156::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Fri, 29 Jan 2021 14:27:34 +0000 Received: from SN1NAM02FT004.eop-nam02.prod.protection.outlook.com (2603:10b6:806:121:cafe::ce) by SN7PR04CA0067.outlook.office365.com (2603:10b6:806:121::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 14:27:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT004.mail.protection.outlook.com (10.152.72.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3784.12 via Frontend Transport; Fri, 29 Jan 2021 14:27:33 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 29 Jan 2021 06:27:13 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.1913.5 via Frontend Transport; Fri, 29 Jan 2021 06:27:13 -0800 Received: from [10.140.6.6] (port=56658 helo=xhdappanad40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1l5Ujw-00005L-PX; Fri, 29 Jan 2021 06:27:13 -0800 From: Srinivas Neeli To: , , , , , , Subject: [PATCH V5 4/5] gpio: gpio-xilinx: Add support for suspend and resume Date: Fri, 29 Jan 2021 19:56:49 +0530 Message-ID: <1611930410-25747-5-git-send-email-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> References: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06f13bcc-d00e-4504-bd36-08d8c46204c7 X-MS-TrafficTypeDiagnostic: DM6PR02MB5849: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vD8568F0Bj/pxgkWea5P/81ARsUTk7OQ4Rg+9fOOCs9Pco4XIAWZ/FTdXw2AcC5+4ZeuKPnnu1wA/qllBDwb/qXJbMAAehxr9BkFRuGm1vuDr3ben0H9IBabxz2Ldfay2SSweH/g2p6zD/4+fHZu2hs7vRrV0LU8ZugJxVF2XEwiMz7vkSD6LOiR0dIhQMpG/5jw92oT798wohUgnI5tmpXu4wEdPzi1jjFo1hDpGlyc95n5XNUA/EBoTU9t0tkDQeV0i0fFHE47YJsSt5uvInd7rVTrmqzFsDfeb92PCrEXW8wZJvkdwLGTuvchYnEXFPrsXQoLE29Bh1Xvt3QF2u/Dok1R+rFBVp0ZRfUAYi5XAT9rQkj/KiYv8+mOK+ByPquQpUwujDG223O03h0BEoJGhxw6pOg0LD/hcb7CEQVhKRu4MudEH0+ORaXTsbnfrnjdzaqtkuV8/is3Bt/2dXmC2lurJLSAFk38jDi63Aw1UKO4ekmUXwdPy6EiNSIuEHuXWXl67aEouRaJ2FniNorYHmdos4bPMnF54UXuLCnxx+OMcsIXECMsHx4fMbTB6LlN1Fhg02s48erKxCtLAR41cuPA4skqdI4HKDgFkPeSzTQtVfiDwVm6DHL86I6z X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(136003)(396003)(376002)(39860400002)(346002)(46966006)(478600001)(82310400003)(107886003)(2906002)(9786002)(54906003)(8936002)(4326008)(6666004)(8676002)(7636003)(336012)(2616005)(82740400003)(70586007)(15650500001)(70206006)(36906005)(47076005)(356005)(26005)(186003)(36756003)(110136005)(83380400001)(7696005)(426003)(316002)(44832011)(5660300002)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 14:27:33.8093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06f13bcc-d00e-4504-bd36-08d8c46204c7 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT004.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB5849 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210129_092737_600655_FC22FEF1 X-CRM114-Status: GOOD ( 21.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Srinivas Neeli , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, git@xilinx.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for suspend and resume, pm runtime suspend and resume. Added free and request calls. Signed-off-by: Srinivas Neeli Reviewed-by: Linus Walleij --- Changes in V5: -Updated xgpio_remove function with review comments. -The normal sequence for remove function is: pm_runtime_get_sync(dev); pm_runtime_put_noidle(dev); pm_runtime_disable(dev); Changes in V4: -Adjust code to remove conflicts. Changes in V3: -Created new patch for suspend and resume. --- drivers/gpio/gpio-xilinx.c | 92 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 62deb755f910..acd574779ca6 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -16,6 +16,7 @@ #include #include #include +#include #include /* Register Offset Definitions */ @@ -278,6 +279,39 @@ static void xgpio_save_regs(struct xgpio_instance *chip) chip->gpio_dir[1]); } +static int xgpio_request(struct gpio_chip *chip, unsigned int offset) +{ + int ret; + + ret = pm_runtime_get_sync(chip->parent); + /* + * If the device is already active pm_runtime_get() will return 1 on + * success, but gpio_request still needs to return 0. + */ + return ret < 0 ? ret : 0; +} + +static void xgpio_free(struct gpio_chip *chip, unsigned int offset) +{ + pm_runtime_put(chip->parent); +} + +static int __maybe_unused xgpio_suspend(struct device *dev) +{ + struct xgpio_instance *gpio = dev_get_drvdata(dev); + struct irq_data *data = irq_get_irq_data(gpio->irq); + + if (!data) { + dev_err(dev, "irq_get_irq_data() failed\n"); + return -EINVAL; + } + + if (!irqd_is_wakeup_set(data)) + return pm_runtime_force_suspend(dev); + + return 0; +} + /** * xgpio_remove - Remove method for the GPIO device. * @pdev: pointer to the platform device @@ -290,6 +324,9 @@ static int xgpio_remove(struct platform_device *pdev) { struct xgpio_instance *gpio = platform_get_drvdata(pdev); + pm_runtime_get_sync(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); clk_disable_unprepare(gpio->clk); return 0; @@ -305,6 +342,46 @@ static void xgpio_irq_ack(struct irq_data *irq_data) { } +static int __maybe_unused xgpio_resume(struct device *dev) +{ + struct xgpio_instance *gpio = dev_get_drvdata(dev); + struct irq_data *data = irq_get_irq_data(gpio->irq); + + if (!data) { + dev_err(dev, "irq_get_irq_data() failed\n"); + return -EINVAL; + } + + if (!irqd_is_wakeup_set(data)) + return pm_runtime_force_resume(dev); + + return 0; +} + +static int __maybe_unused xgpio_runtime_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct xgpio_instance *gpio = platform_get_drvdata(pdev); + + clk_disable(gpio->clk); + + return 0; +} + +static int __maybe_unused xgpio_runtime_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct xgpio_instance *gpio = platform_get_drvdata(pdev); + + return clk_enable(gpio->clk); +} + +static const struct dev_pm_ops xgpio_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(xgpio_suspend, xgpio_resume) + SET_RUNTIME_PM_OPS(xgpio_runtime_suspend, + xgpio_runtime_resume, NULL) +}; + /** * xgpio_irq_mask - Write the specified signal of the GPIO device. * @irq_data: per IRQ and chip data passed down to chip functions @@ -546,6 +623,8 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.of_gpio_n_cells = cells; chip->gc.get = xgpio_get; chip->gc.set = xgpio_set; + chip->gc.request = xgpio_request; + chip->gc.free = xgpio_free; chip->gc.set_multiple = xgpio_set_multiple; chip->gc.label = dev_name(&pdev->dev); @@ -565,6 +644,9 @@ static int xgpio_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to prepare clk\n"); return status; } + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); xgpio_save_regs(chip); @@ -595,7 +677,7 @@ static int xgpio_probe(struct platform_device *pdev) GFP_KERNEL); if (!girq->parents) { status = -ENOMEM; - goto err_unprepare_clk; + goto err_pm_put; } girq->parents[0] = chip->irq; girq->default_type = IRQ_TYPE_NONE; @@ -605,12 +687,15 @@ static int xgpio_probe(struct platform_device *pdev) status = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip); if (status) { dev_err(&pdev->dev, "failed to add GPIO chip\n"); - goto err_unprepare_clk; + goto err_pm_put; } + pm_runtime_put(&pdev->dev); return 0; -err_unprepare_clk: +err_pm_put: + pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); clk_disable_unprepare(chip->clk); return status; } @@ -628,6 +713,7 @@ static struct platform_driver xgpio_plat_driver = { .driver = { .name = "gpio-xilinx", .of_match_table = xgpio_of_match, + .pm = &xgpio_dev_pm_ops, }, }; From patchwork Fri Jan 29 14:26:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Neeli X-Patchwork-Id: 12055977 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 3EEF2C433DB for ; Fri, 29 Jan 2021 14:29:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDC2F64DFA for ; Fri, 29 Jan 2021 14:29:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDC2F64DFA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2otrtw3LwadNZ5MJpHfvUcNQPcZCyaWU96S6Zngw2N4=; b=DLKdimfQ32Jp21n7XzfOEsaZU Joe4pcEcOZZlxr7CerBcFLjEiad09ZpC9lKSDkXaQjkQgCkVrgF1r1t0JYDmnbvqWf0spVsmxF90A Zcw7PXAJ09xi2UoAELuOHrPEiUDSjlCl3CdP7C9c2MwkuXMA+K/DP0GIpwA6MNGQiCBdZYRvaTyAe NNrBplmHLhb4tJ4OiFRp7V+mXFJ+DCtISN29em1VbpVw+9+0mNN4cSAkuXrEJTw9ipTHzg2VYaI1h hjtmdOxSpOPOXWZEzq+3Dj1ICzkXmUzUNfSOjtpY2X0gmrF5+D/XZ2YS0h4R+uXiNjyV9NQMRYSdI eAzKFbHUg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkW-0006uv-3T; Fri, 29 Jan 2021 14:27:48 +0000 Received: from mail-mw2nam10on2051.outbound.protection.outlook.com ([40.107.94.51] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l5UkM-0006tJ-9M for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2021 14:27:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jEGYuX6jyFqfG4Kavv84ofJoNsDkdq2DWlkW751ISJ8EuX0CJfKLMKnc4MdCvYul0fucDRlOq5mGCvgmlFybpnKy4foE32dOo/Fdq55lIEXAAP+Ft3CIZbuU4DLeuoFpovK7jyynqaHwi12awOku7tc9ykp97UwsPZY2VwaV67R/JQzwVq+eKZ5uUlWti1mV1unpDBHeIi8KwyMRQRKrx8fH2Vq2Qjie8UXsNmpXm/6T4wKO22UA+72ThJ7St/O4stYKTlm2SEnMgk2LZtNOc+iW+XTinee1rnL/h9JKyKu4S4+5l+as5Rbq3ug7d4ebY9H64Y6VZQvTIbyQjn52fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VnNHPWxNdoqHBOE4l/Fa6ZwnbHk6rl/5z0u/PVMtWoI=; b=cvE1xdz6rkYaf6hs+nlOjgZAK23w4gpljr9+YeXsMaGhqFtc6ez8zzr0Ez18ohLBBvKEAjIJdI6m95cC5d9OONweg8Fp6H+MJEYGI79ivJ+hJ176r/38wR32S0nZ698KJhI1NSnbqaYt4WgwCk1jxKZAmaMLzsgqhyiEg/DGlZGZt3fblyAuE6Hym0itWlKUYMe01pjG0Rfg2yDjizPL2/8shNqdFzH9jmqV/UJfX7mnCSljoTZZsI+CeHlW6F3zOM7Hi2KQKsiHpHBR9WLSYvsWlw7jYz/En9K53NGlrzLMxxQP5lHESGVCz1477FiRiXfhfPLiymRgBat3P24Fuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=linaro.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VnNHPWxNdoqHBOE4l/Fa6ZwnbHk6rl/5z0u/PVMtWoI=; b=QBDt25BkHThzK8JR227hfnFECHDKXjR5OVQ22HcK/jPwtqLx9ZJjOdLhoD642LOkUskNyz7IWIspYD92+wzyYdqlY6CQne+COrLA4csIMIkA1Aa59TsMCyVodkJ4vcckDylz7ea7UVQlreC0CsKVBF0vHWLqdB3/0e7VAuj0nI0= Received: from SN4PR0801CA0006.namprd08.prod.outlook.com (2603:10b6:803:29::16) by MWHPR02MB2687.namprd02.prod.outlook.com (2603:10b6:300:106::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Fri, 29 Jan 2021 14:27:35 +0000 Received: from SN1NAM02FT016.eop-nam02.prod.protection.outlook.com (2603:10b6:803:29:cafe::67) by SN4PR0801CA0006.outlook.office365.com (2603:10b6:803:29::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 14:27:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT016.mail.protection.outlook.com (10.152.72.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3784.12 via Frontend Transport; Fri, 29 Jan 2021 14:27:34 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 29 Jan 2021 06:27:17 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server id 15.1.1913.5 via Frontend Transport; Fri, 29 Jan 2021 06:27:17 -0800 Received: from [10.140.6.6] (port=56658 helo=xhdappanad40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1l5Uk0-00005L-Ji; Fri, 29 Jan 2021 06:27:17 -0800 From: Srinivas Neeli To: , , , , , , Subject: [PATCH V5 5/5] gpio: gpio-xilinx: Add check if width exceeds 32 Date: Fri, 29 Jan 2021 19:56:50 +0530 Message-ID: <1611930410-25747-6-git-send-email-srinivas.neeli@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> References: <1611930410-25747-1-git-send-email-srinivas.neeli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8322ffcc-a292-4ede-b6c5-08d8c462055b X-MS-TrafficTypeDiagnostic: MWHPR02MB2687: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sYEpj5Qey1e0l76LSsxYTdK8CAE3ULa+NbAZViq8fVZ0Zl8jq0UiYEJB2sZwiTfTDkfT51K6skLhkcZio1sDPC9X8uj8SBCOr9Fu/64x55+wWFrQeMKh7G+Mw1qBEKuIQuytwWmv/msTuHMTZX9BgZpZD9576WAKjcnysy46fSDW7mAuqhXnX10UfqDdyqBUz+HougEwkZZg0hu9NHsHyUyBuJtW+dK10e56qD1XPpSMmOtQEbJsqO+JvhKXkYdC7JdugpSaM60PUo5p5ws+irDiKeiVBk1tguqdlCmr3iZpNIrrFgykvJZk7WD1CUhP0sfZnNQUuu00lP3vRqVSimb8twc8EoGZvK79rXIAT5nSPIyhllMFUSA6xtteG2J4ceYr5BtFgGrIqGxBUHW5G+MtUxXAhp5uOnWbCSpLb0Q7SbxLItl9g25buI5MwoCv6ytkV5dV52eC1cUT64p2CMgMUCPT3BdJdUVwTyTI3YcZr4nhEoJNb+u4o1A04hav8ChtYXS1bv2c8ErEvDkqioyulTpN4STGL1k4dpn36uFrF+7FW0mg0MgaSxBvhF6hF5/xOxe0IJ3ybxz8GeQHT0YuF1NGm9iWE1t01k8u4XvzMP9J3UtpoHLDbXn/RKHm X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(346002)(136003)(376002)(396003)(39860400002)(46966006)(110136005)(36756003)(186003)(44832011)(8936002)(82310400003)(47076005)(336012)(478600001)(7696005)(9786002)(426003)(2906002)(356005)(70586007)(316002)(26005)(107886003)(6666004)(4326008)(5660300002)(70206006)(36906005)(54906003)(8676002)(82740400003)(7636003)(83380400001)(2616005)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 14:27:34.7851 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8322ffcc-a292-4ede-b6c5-08d8c462055b X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT016.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2687 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210129_092738_420640_408FFE87 X-CRM114-Status: GOOD ( 10.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Srinivas Neeli , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, git@xilinx.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add check to see if gpio-width property does not exceed 32. If it exceeds then return -EINVAL. Signed-off-by: Srinivas Neeli Reviewed-by: Linus Walleij Acked-by: William Breathitt Gray --- Changes in V5: -None Changes in V4: -New patch. --- drivers/gpio/gpio-xilinx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index acd574779ca6..b411d3156e0b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -589,6 +589,9 @@ static int xgpio_probe(struct platform_device *pdev) if (of_property_read_u32(np, "xlnx,gpio-width", &chip->gpio_width[0])) chip->gpio_width[0] = 32; + if (chip->gpio_width[0] > 32) + return -EINVAL; + spin_lock_init(&chip->gpio_lock); if (of_property_read_u32(np, "xlnx,is-dual", &is_dual)) @@ -613,6 +616,8 @@ static int xgpio_probe(struct platform_device *pdev) &chip->gpio_width[1])) chip->gpio_width[1] = 32; + if (chip->gpio_width[1] > 32) + return -EINVAL; } chip->gc.base = -1;