From patchwork Mon Mar 20 16:38:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 72290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1324283wrt; Mon, 20 Mar 2023 09:59:25 -0700 (PDT) X-Google-Smtp-Source: AK7set+zFNo+B9nWpFQ9UMyTDQCU5tynTKJWxz6kOpmFd0BPmZzyJtkm8jDW16LCpkPtaPSkGbkR X-Received: by 2002:a17:90a:190f:b0:237:50b6:9838 with SMTP id 15-20020a17090a190f00b0023750b69838mr19660606pjg.45.1679331565294; Mon, 20 Mar 2023 09:59:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679331565; cv=pass; d=google.com; s=arc-20160816; b=NtGO+Zdx0BsYsVriVWEhWT0+p5F8ierHS6CI7u4iLTDy2WHDvkmGBpEhfjBBxKBsQd cnUQcHaVDrX/WyQYiKjArNVV/4OIQ1aSiZYPVb3/FePItA34Fa5PuL7oSt47EBNpWLYX bMsXSnSNSieC5UZoqU5KpAzCiByyeAQ8aflHZVguzYILx49uEx7aVcU1iSk0CRoTsy50 UYbsF30fMwrHk1qkHmpGeTDWm0kyRmhqWc2bGunGOSWcBOT9PyHuXIIjqgSyaWn+Sak9 USA0cNfEt6Ubt2wbe6iDPjJVFbdlnOWEQ5qVk2X2pkoGz1C4Wg1SDlm3V/rzpopIjVHc NdKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xNDPnp+blOHO2CqkrXX1ETmJ7PEE6MQf90eOmcm6Ma4=; b=FXyV+RnQaVd8vDDqfh5qs9qm+2gdsoKs8p5aGcIkmWHKx+HVHHnlypQ9qWtCyunbQK I6E6fW7/lMo5EktcBVCLqKK7XX4wcaT9pfSwmAvd2A0EhO0pXNR7TAyO/sWrx7aYLhwC KMV/BELxUWboaPOuVAVhoM8u93IV0R8VRCGAiKjZF0rPgqZ2OldGcl3c8uEabo8oCQZM 8pD8ajvst4dv79nfLtfGNYYJHQH07fEE+qgPQtkMXtiy0X8Xg3EkHYCToYmW99lPkTCl JOklcQ0X2H3GxhuQYhO78/3ByyMwgXyO3B2HZft4AC4Zjo/j1VTNQiduxmIdH/PxZBbM dHNg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=qSFJNTuY; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs69-20020a632848000000b0050f7c95bafesi3632505pgb.73.2023.03.20.09.59.10; Mon, 20 Mar 2023 09:59:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=qSFJNTuY; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232032AbjCTQqW (ORCPT + 99 others); Mon, 20 Mar 2023 12:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233433AbjCTQpX (ORCPT ); Mon, 20 Mar 2023 12:45:23 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2082.outbound.protection.outlook.com [40.107.7.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE1CEC55; Mon, 20 Mar 2023 09:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AN3bWLtCVGMiXcwRS7J8a7/wnGcWFUpmh/Y7IfQDu2EBL6MQWO57gF8pXC5N03FwoxVKwIcMGaaqbQx0Y4WqoMrHPf19hAxaE0uC/86GB0AQtOF8+iHQxNuuF5nf4AT2pbscNbz8oVWlgQHGs7NoGpIpOmEFHSw6Dri9usfQMD0wbCytn9HAnCjcqp47817IOyTM6POZj6j4TY4bPoPD/VS225g8J13e9QnaIe1713QgrS0bJSkSK1Of29I5ePtG+IEaXfZRzxeDXHSwOYDY4I6BzRlQi2Vm8oufFZ9mHezui0PweAmAV0wH9VodUC4oURcEyG1B3D/hacUK8+gfGQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xNDPnp+blOHO2CqkrXX1ETmJ7PEE6MQf90eOmcm6Ma4=; b=GJZORVRv28ZkmcPz5DcNhVFqzI7+zv1zLTUs55g5Qfp16ZE2C8/urvc5DE1XQdLgWnQZEJzpVi9vGRSXXDt7JofcvWw+9KCHCXkZPioICgmCURTPwan91Xos44/jYHU2H6KEhhuPoG7coHjMUEIStpaOONysmHw9GOnooY0SRa728yl8txo/7eIh0JLtt9NaMYwp9ZLpvE7I405WuvbFVcCG00ET5JH8WDXCxLxEQQ5NaMAiiWd5PpLOVM8ZVCoJcWHSBtLFZN17lflks36p9PumE1Az69FYcHI8iog3ZVNR+swVWrRwKStFdnKY6RlwszOSNjwuXcMoGkIm0C2xAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xNDPnp+blOHO2CqkrXX1ETmJ7PEE6MQf90eOmcm6Ma4=; b=qSFJNTuY8IVQKJnkEigR6W4I8wcNcGat6dmNI6ln1PQ21fCcAS8riLiKq7c8w+kRQY8E9fNEzH++EGgJHNetQeOTOJl+ZixJqt5YgmwDCUqW1Nny5QwMGe/0eK5u9hUEbs78hKEN+ljvdh5+XCQmsOXURzKPpVL8UcgFd/W3xlwdQHVdqjvf7pFwnA8Nft5j///KCOcF9Ls/hdmOnE2WZbtomQf+VFyiJJLs+dUgULkHnPLp8k9HTWPrzmlXV/t8PEkNI2Ib9M2IQLmbFFY+cRRzqkKXdsR3pCXFDsuWpkQURHbtjuDw0hFdVK0WjZqYql8aUeUNH5wolht06m/+fQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) by DU0PR04MB9274.eurprd04.prod.outlook.com (2603:10a6:10:355::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Mon, 20 Mar 2023 16:39:07 +0000 Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::6802:b2c3:5f12:8f9f]) by VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::6802:b2c3:5f12:8f9f%2]) with mapi id 15.20.6178.037; Mon, 20 Mar 2023 16:39:07 +0000 From: Chester Lin To: Linus Walleij , Andy Shevchenko Cc: Chester Lin , NXP S32 Linux Team , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ghennadi Procopciuc , Andrei Stefanescu , Radu Pirea , =?utf-8?q?Andreas_F=C3=A4rber?= , Matthias Brugger Subject: [PATCH v2 1/4] pinctrl: s32: use of_device_get_match_data() to get device data Date: Tue, 21 Mar 2023 00:38:20 +0800 Message-Id: <20230320163823.886-2-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230320163823.886-1-clin@suse.com> References: <20230320163823.886-1-clin@suse.com> X-ClientProxiedBy: TYCPR01CA0050.jpnprd01.prod.outlook.com (2603:1096:405:2::14) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|DU0PR04MB9274:EE_ X-MS-Office365-Filtering-Correlation-Id: a8ab178a-63f5-4bd9-2068-08db29619fd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: loWJfdi0DxhATunVst+npiXBcWlAOvxnMIdxf1D5Gt8JmeF6/hPLI3mbGdYQF/4Z3V4QyzIW0UUdpwCC9G+2/t0+kUCV1+PHcS1xmLPylpKq6pjI6kTj46QV4uDMlBXoGq4hLVqVuvMUDxhwJWXUtbqz0LnIgpYHvhjbinr5DdUch8uSLzSFoiqNe7zXeyVuWjE5SfO4qW6qG4uHqRYK3NEAbzJDsh/UlPAQEoiXbwuyKXLJwOQqWTr80VGYvlcMX0ZKRyrVdK2jkZXZsxoM3X6kL8ic/5xaeJJTTD/gvF8atNpaDvrv7sa2cjj8FZhhA7XYKdJnVUS4LtBrhENaFfDwKhrz2FNe7FDeNyKr32Hp9WAufLALVbeyqK8iSqqi5uhUNWPi7nJk6JvNUAXl5NiZE8j5DXUpzYOziUKyZIJ+tJbI4M+0JPW5vtSiGoNlyx/t408OcY+Z+ZYR0d+pXh4D0ikC1s1ORxSoFQdgjef9wMjn2Ci4ak80pHMwHZjWNHaw6AFdYK7xXaiM2prBH4hpVGZgu/rZ1gANR0Tg2PRT4+QrFP+xdgxvjFnHYL3U1NAqt6HISNLWYq4HOtDSmv6UZgdMBk//9ueb2UbdlIFwbIeo6vXSTiW9Bw6wGcXDxcEaeidulzknCXdF2qyZmg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR0402MB3439.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(396003)(136003)(346002)(39860400002)(376002)(451199018)(8936002)(5660300002)(7416002)(86362001)(38100700002)(2906002)(36756003)(4326008)(6486002)(83380400001)(478600001)(6666004)(107886003)(41300700001)(2616005)(186003)(1076003)(6512007)(26005)(6506007)(54906003)(110136005)(316002)(8676002)(66556008)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 19uaPTxzlFkp2VJICwi0UwBVxzqN3PL5aV699mibvARgrA50q0y9lCVa0oNe7ZFMo2PzH97f/OmrwOGlOncvtUa5d4gGErYqaSqF4X7YXO492Lci524abfQ7aZ01gQwE7Tld3EY/g6jUWEOd+JPgNMB7FJIVNxelTPPGe4y7EZpQX0I48aen8jE9WRi9QHhOH7+x8j36/k3iQke+xBxjjFYwcAJqMlniKKdXadg0tmvi9vbMra/+CIbhG1y/4FZtbjm6QghoGESuIK3gCRNOrzjHGmGQQ8NJx6vQYoMe+Yir5VmCNcvE3gFhRCuPbUNjKvjkvEL4ErV3nRspCIWuJLY+MJcyP8LPGC52ea1ns4q3K3nnNxuary+/cKof1qFMcHcHbU+JYQ2+vwUj9twDgdK2BFJyUXaD7Zn0kKly5qKNlEroFDQss/4kDKKZzdxZIWs1naBWQqyoZbMMcCmtx0KxWaCvqXchbn0hUDcPtCW8EXUmfZB+ClbremGdrvRfg5qHyHgm+9CDrvLWFQHZ46Sp6vl2dfWGU0ErnQG/n03PNfx71VgenLjNnGKxA169RW7cKMo3/wZiLBNb7hZ+Y+6V28TKMFZ61z0eWYZT+gfKpzxqrIXFP4L7WYWPKf91E/HNzMjohOdhyVrtkDUmXRtZmfxAGHSimz2OVxGHgEt00q90dIEsBuic//2pzFMsLuY8pu/KQD8THflJ+WFaGbQ8BTqo9SWjpDjFr2h1+20LgyBtYSfCHw2zfh+uROXBoJJ6feLrpcTHxRddGAkfp2G50Wm103mvOjki6WCtR8BZT0foAtRHcGIsGXPub2vzB7dM0zUDatbDmo9KP6EfQTefk96P5tzEFySay/r7gIgZHvewiSZIKwn8+xryYm2YeKbiBm36IX09WuPtMQKPNC6U2Q9Mg3E6VdutlSx8KA0XY6jmLB5zrgAQ2+wkSuK80XVojCu/E6bkIb/XyptW9oRYCFj/me5gQj60KUfw9aKe8EILSyO3Ba368V2bgYxaa5DI8rax10WpbzJxTsXLPZ1XE3SRnd7Cl6ec9v6lXzQj9Fgazf5EA61vH4H52cvvux36il4cPkLVmMGlIZrwQLAcAT49bTv2i8rVgWSErFQIiUjBidbyYpP/PhEUxoMr1iPtiNCz7lnAI0g60gfDxFSwGZl/n2MSmLLK8SCCjlm34qG01pPQEfcCy4B/cr233onDCll6bGSoqwzuGry+S2rZIkutXB35zRDzBN4qOUptckOgKb6Co+e4vy9SnPwXPlWIY2kq3ThaM2m9J5NAVjup0rdXGhcqJkvp7xrNxvdPTqcY3hArd99hFZemc6PHMyHWv4pIGcdPNwEam7dePMCrxRpjwbTv2MbA/hYjmYWdVJiOVpxmx7+ZRCz6zUPg4HU4Dj2OzvkrzJuSz2xPNzrysxjGTSimV4zJDASyVTCJxS9BeqO7EBaWeNkNAkJBWXYasmq6K0VF+z4qTESRo+9tA6Z9mx14bzUPZ5f8unKnMKek7j82cK98SQf58j21VYtj2JAvkupkYQmHX/lxiUxLQE2wINbj0mqOrlIj9UM= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8ab178a-63f5-4bd9-2068-08db29619fd2 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2023 16:39:07.7034 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XaD9q6/jRJY7FGwKlThgp4MmxyN6xFEREXDcZlGYo055mcd1wvIMxIFjX7MHXlga X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9274 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760906775404852463?= X-GMAIL-MSGID: =?utf-8?q?1760906775404852463?= Instead of relying on of_match_device(), using of_device_get_match_data() can simplify implementation and avoid code duplication. Signed-off-by: Chester Lin --- (An initial version since v2) drivers/pinctrl/nxp/pinctrl-s32g2.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32g2.c b/drivers/pinctrl/nxp/pinctrl-s32g2.c index 5028f4adc389..f99f88615ef6 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32g2.c +++ b/drivers/pinctrl/nxp/pinctrl-s32g2.c @@ -740,14 +740,12 @@ MODULE_DEVICE_TABLE(of, s32_pinctrl_of_match); static int s32g_pinctrl_probe(struct platform_device *pdev) { - const struct of_device_id *of_id = - of_match_device(s32_pinctrl_of_match, &pdev->dev); + struct s32_pinctrl_soc_info *soc_info; - if (!of_id) - return -ENODEV; + soc_info = (struct s32_pinctrl_soc_info *) + of_device_get_match_data(&pdev->dev); - return s32_pinctrl_probe - (pdev, (struct s32_pinctrl_soc_info *) of_id->data); + return s32_pinctrl_probe(pdev, soc_info); } static const struct dev_pm_ops s32g_pinctrl_pm_ops = { From patchwork Mon Mar 20 16:38:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 72306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1330716wrt; Mon, 20 Mar 2023 10:10:41 -0700 (PDT) X-Google-Smtp-Source: AK7set+Pj7x6IJk+Ar8Zrj/VoM18koKG3AgbX+c+aMbVN/4ZB82cIPJL8/96WM921B1PKJdaLvT3 X-Received: by 2002:a05:6a20:4da6:b0:d9:e45d:95da with SMTP id gj38-20020a056a204da600b000d9e45d95damr2960290pzb.20.1679332241163; Mon, 20 Mar 2023 10:10:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679332241; cv=pass; d=google.com; s=arc-20160816; b=C0mqcI0nIRKW2mrGZlAYJmwdtsipTQbcBiPNYeUo1o+vfZiyaQJ++pvzC5BLblB/hC EbLUa0FlMrdTJc623t7z6MZDRmO6mNCQf8co9EtqRYcF3lZXZ8I1T68/CQSPXlapJzlb pttkaenYhLyLmwXQd1y6Yuc5mYcJ6W2wI1T0ol6Ax0aFj++d/5vYjOEqfNFsLMiFHzHE m2W4ZyMyZ83wo+anH2JU/9urczaccGzySetI9J/MQjpWC0/9X2Nm9lz6wzBAx88ykiwb FLAI9j0ztJvGjyLdG2/odgPi7Et5duKPDn8l5mBOzdq21YRCVwueFibdFlIWjucx33H+ TaKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m6XFF4HqWe/7xjL1xMujk9Z0saez063aTDC2xCGJWcw=; b=lsaSZnhbwY4Bmtymsn9P6oWyDKMdTfOIgY9bDNLKQGVuvRthRtDsxfZUHSEYyTsvn0 YTKQuAoAojyvkHlL2RgSx6ZYPsyka2WxB/EXeHmnxHNfqaEpc9C2Lf5S1dk0U+34q/R1 KK9VCJdhTAJplvQPlD0WwTa5ECL8xniyH/10OpCAEE8U1RjFEfynNkSCNPUCvmO9hzZz XZupuI+rQUv0XPGwZ1Bv7mStQdFCjqkGn7JTulyYkLKeXw77z0rwQGqv3wJmMFYABmwr njMFOCVz74L3GZTVyLb/ad8PTPfarwrp1j+DLRi2lYn+3Tjh0uiDIE6Tf+/qLxDcn5ga c5Rg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=oj7jjfnl; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e189-20020a6369c6000000b00509f75feffasi10911315pgc.56.2023.03.20.10.10.25; Mon, 20 Mar 2023 10:10:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=oj7jjfnl; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232391AbjCTQp7 (ORCPT + 99 others); Mon, 20 Mar 2023 12:45:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233255AbjCTQpK (ORCPT ); Mon, 20 Mar 2023 12:45:10 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2086.outbound.protection.outlook.com [40.107.21.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1467C14237; Mon, 20 Mar 2023 09:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fBFUU2JPiGaFa+SlrwNffh0Idv0EoYWB0Wd1epWWgdP6k1fb99Hx8VNeWAZFxpVlLRU1HeaqypNLwnHnLUmAqLqlHorn9fziuitSEBwbzRCyucq5j+JWjM8HG8JyeGnu9gSkNh13GmyAowrxpEpGDYjNJCmPft+1IOO/CTnuSRbKaLJj4x9uGJFU6+8LOhZRJfsI7hS5VLsoebLM9eB31fBreLQQ13wH9m4SyYZj9xZ4chvynHOu67i04rYu/EHPfdhLugGEVpaVUY1oDvNV8LwHObCXQ5yz39VHWnLx2dDqXVWYVlRKRnPXOewY+hXDS6MGDkkiP9aO0owpdLHqXw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m6XFF4HqWe/7xjL1xMujk9Z0saez063aTDC2xCGJWcw=; b=QY0+Uap6BijAr5OFs2NTYVeYmIPHWgRDeBg/TaVpPilKTak5OARmnJtxHF988jE4/uhB1zYVC9eMGDah3PlQ6cSvOFrNJv+QVGS6jRcV/S4kJ+rOofg68MXFDA4Oytux39MzolvBg1c3WP+/81z5J9QtuVl49SRDXmSwoUW2bIp6PKtznkJcSbvdynTX14zF741zwLmUWtb22nsgyJFpefHOCWJ+G7kQTcYdzc7igDiqhQFYh0tROybRLuAGWhtmpSbQaVEqOk0aDNBfwO9ghZr97/Mpc0avVJ2IlGg3C7w1eZaOkwp4DCFaSVXMGQUDOEnNSi6aGspWXL6KkezRSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m6XFF4HqWe/7xjL1xMujk9Z0saez063aTDC2xCGJWcw=; b=oj7jjfnlZnSFF+FeoqfIjhggSkFgniAx7kUv/lwE5fJ4SrNvU7lIlBJsHvnxOJBasFU1/FdIMIfqXANsxDcKYaJ+/EgjexZ2LTqXje4aTrAEyiivElMEy41TS+pci9kGqzFx1V25hPwFmibP9OLgGBhF1P2C0ZILkk9vLv1lT9drr4Et1yCgbg8VD13pLtcGipmt2z54N9IAyTy4vGasN74tuQsTa/VrrWvuPQ1qD37xGNoquu/CUjpsWHiX2RY3EcTY2Pk107qRCuGoMSNtSLpizgSxoNW5APqK5qpwPYLCUCaBeAKWkeLyyeX9y9p7mAlMaoPIRpiwb/d+Tq/qXA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) by DU0PR04MB9274.eurprd04.prod.outlook.com (2603:10a6:10:355::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Mon, 20 Mar 2023 16:39:32 +0000 Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::6802:b2c3:5f12:8f9f]) by VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::6802:b2c3:5f12:8f9f%2]) with mapi id 15.20.6178.037; Mon, 20 Mar 2023 16:39:32 +0000 From: Chester Lin To: Linus Walleij , Andy Shevchenko Cc: Chester Lin , NXP S32 Linux Team , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ghennadi Procopciuc , Andrei Stefanescu , Radu Pirea , =?utf-8?q?Andreas_F=C3=A4rber?= , Matthias Brugger Subject: [PATCH v2 2/4] pinctrl: s32: refine error/return/config checks and simplify driver codes Date: Tue, 21 Mar 2023 00:38:21 +0800 Message-Id: <20230320163823.886-3-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230320163823.886-1-clin@suse.com> References: <20230320163823.886-1-clin@suse.com> X-ClientProxiedBy: TYCP286CA0150.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:31b::17) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|DU0PR04MB9274:EE_ X-MS-Office365-Filtering-Correlation-Id: d292625f-c580-4748-6f14-08db2961aee3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ra2BkvKV+NiSU1mNDy8ao5MG/Bzy5dS9KstUSMfm53BU6QuEjJaT1ZnUwFxg1OPBMjKlW0anp7gsL6hjTY+DenBkJFW8f/FcawmY+8RQFwSRaEjhEhql/jW6kMi9VIKIoY4/yAYa5IX8H26NXVr8SI5Db+pvdMyQX1cCF9fAaPaWpXX6vTU/Ujv6lSWI1MLY19ChMR5ZQJEznntuB3t8A4mirzZVl0DUkoSDqSsdgjj5skZP1Uahi83ES3ROUwznL5no/J9lCIqo+8hSPP1JeuBS2ccBZNSUQM0fMdAMErzDrcH87ktZXfs5ey9yWFMePHLuuhI6BEGKaRnDYvf20P7pCECes4rx5NlemSNYyuGJo/4UetO8S4ci7XlgBaZ7+Von9doF0YaNJUVGfClBG3PfEF13AfZrceJr2gbGvykHL9M/TQu/q2Fcxano8Hzq7iwIiO4GUV4mRvRe/Khlc524RDZGKWd0KVGs63QfdAeeElyo66x/L27UwQJsNiUkg6IaRsREQoPMH9hJzpkiKZWtSbGQtTJKL0VQmy+pX3/zmOvdy05rFG9vuvUw8Z8i3r4L+Kv4jdFshUjp49bVIYRkCh9wufXrY9ycza2V/0Vy04dvqRVM8QS5Jue91qoS8YWwkxNVn/tGzCwPuGuu9A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR0402MB3439.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(396003)(136003)(346002)(39860400002)(376002)(451199018)(8936002)(5660300002)(30864003)(7416002)(86362001)(38100700002)(2906002)(36756003)(4326008)(6486002)(83380400001)(478600001)(6666004)(107886003)(41300700001)(2616005)(186003)(1076003)(6512007)(26005)(6506007)(54906003)(110136005)(316002)(8676002)(66556008)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zpCmj0r3ZVzDbbYbiw9eyofIwm+2EKKwxCR1yVI6I36OwNUATGjM8q8pM7MqIev8hpsByw6XbRYSg4rILyGVM03YVYk+oGkkue0if4vaK67JNrYuXZoMZzPzx+3Ye7gCkumsJteWADtF8qkx7ayuC0Rm+AH07mHn1/W9FZS0NpUEaKcUmrDmFp9Ah8zUdPvLm+tdEHA0JbrxCBlQsX7y0xbDUm7/u+2ZnZBDfaRNB1ozVq9kp9TdGCfUWhi14Go9eTmuipm0FYpL6OBZIx2dbR+bV469zL/ECpr7sDgqdGDkWzNxHMcxF5itblFfRgQlRHB6sVfzy5wvLLN4ZIEHjqv4YJDCXrDYljF/F+LPolDrhJEvziEiJhhmwh45ncxZmbX/bVI8838FxEP0MdZ1zM6lwOynDaMDQNUx2Oasoe025ckk7dFXW+v2umVyvJ09/qJ/eyiJKq6nRlLDoBVs9eG2yoCYAWAc1eqaSA1wpbvvF3HexQXPuokjY4YAk6IAOZK56mAsJgJT+R1+NIehQTxONzIay3hMTA9qYPBSyOh+m1WG0yV1bDW3qSkIH3Ufmot8YbFuhXC2lBdbWSKVrt0c4iCBnpseKqZl6r2Juh8FeLDb4N+OwVH2ITDW6LfF3mIFUreJfxthpP8v5UxI/3hucO72P+iWUylZDjXLwKAyE80RFBlVjhOP4YNLxIgiTXxZ78yNM1/JonPewqKtypd/vOqRvvlB85p6Sw8riQO5kF98hbq5nc5QKUXqLkZvb3i7YYkI33veoGC5mZcF9k50jFj7xVSCUBG3KrI2Q1LDqgSmP/h89sxMJs8lUeR8N3dbTnjgpRPIrca16TMW82hAhTBYOGM8bp6icd4UF/vHzOm2JN5IE+bD7ZwB5VdoFNZ7ITX+nvKDoP81CKSx2ISruyc7Jy3ebghogdZvRBpATG7jfAwse6dXbb0exZXDG579RstU8KpQaTFSM0A31Vj2+YSF67lK+ZKihIE8HzdEgViAxD2ktg7zIBWCYuRwbiDgNpaiD/uCF1CxMq3Lxzv21hdvnFaBvV9D25wvBZ1549PmkRlja2JNdySqc9iNmKHNlS3g0fWfgmfrH0G4vnIQdoDlw5PYcD49D1Bob0g4vJMbHDukRrntpHDXo2VWzYNenIFR9ZwLceW7vNcEqxe7W16FJfDqQ8vXISdsflOukYETjStkv/Nh6+1SQu306XNT2Iom7eYVwx5s1Bz75Aay97OqPaSnjiJKDPSd5SsxLuCmfFYl/p/jECi4T58Yl1p1V3oV/PbZUHrUsY0HDkvtoRLyhhcdVGwnQqvLid/Iol9dsjmtz76a3zshggNUk6fqo15b2LYyDYuKDFtYvUbjs86TsyO+q50yLOB+ScCQ8+KWxOydmdv+Q6knzrrXImxI+9ZiuO/kd9Kuf5KMy7cvdPDFrswZCnZmTXjyQv9Ev5fTd1RDTMlXdGlS5kS6GQ0+yoloKWSs+N6DFZaHeG3M4czvGSN1p3Y4l1Qnjlbo4qngQyGR7nS2TRrsP4yrg69fLVrZ6Jwz3MSptbCpL8tun1fxLXVbvUstcTJJ6I8= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d292625f-c580-4748-6f14-08db2961aee3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2023 16:39:32.7170 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: klKHDpaVJKYnc/Vf83pakGtfdrk7rMEXRQ34HTBun9yHq/ykwAZsJGPND7CXFCra X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9274 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760907483850325153?= X-GMAIL-MSGID: =?utf-8?q?1760907483850325153?= Improve error/return code handlings and config checks in order to have better reliability and simplify driver codes such as removing/changing improper macros, blanks, print formats and helper calls. Signed-off-by: Chester Lin Reviewed-by: Andy Shevchenko --- Changes in v2: - Enhance sizeof() arguments. - Fix blanks and remove unnecessary parentheses. - Move s32g_pinctrl_probe() changes to the patch [1/4]. drivers/pinctrl/nxp/pinctrl-s32cc.c | 141 +++++++++++++++------------- drivers/pinctrl/nxp/pinctrl-s32g2.c | 4 +- 2 files changed, 76 insertions(+), 69 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index e1da332433a3..f698e1a240ef 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32cc.c +++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c @@ -28,7 +28,8 @@ #include "../pinctrl-utils.h" #include "pinctrl-s32.h" -#define S32_PIN_ID_MASK GENMASK(31, 4) +#define S32_PIN_ID_SHIFT 4 +#define S32_PIN_ID_MASK GENMASK(31, S32_PIN_ID_SHIFT) #define S32_MSCR_SSS_MASK GENMASK(2, 0) #define S32_MSCR_PUS BIT(12) @@ -46,7 +47,7 @@ static struct regmap_config s32_regmap_config = { static u32 get_pin_no(u32 pinmux) { - return (pinmux & S32_PIN_ID_MASK) >> __ffs(S32_PIN_ID_MASK); + return (pinmux & S32_PIN_ID_MASK) >> S32_PIN_ID_SHIFT; } static u32 get_pin_func(u32 pinmux) @@ -108,7 +109,7 @@ s32_get_region(struct pinctrl_dev *pctldev, unsigned int pin) unsigned int mem_regions = ipctl->info->mem_regions; unsigned int i; - for (i = 0; i < mem_regions; ++i) { + for (i = 0; i < mem_regions; i++) { pin_range = ipctl->regions[i].pin_range; if (pin >= pin_range->start && pin <= pin_range->end) return &ipctl->regions[i]; @@ -224,8 +225,7 @@ static int s32_dt_group_node_to_map(struct pinctrl_dev *pctldev, n_pins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32)); if (n_pins < 0) { - dev_warn(dev, "Unable to find 'pinmux' property in node %s.\n", - np->name); + dev_warn(dev, "Can't find 'pinmux' property in node %pOFn\n", np); } else if (!n_pins) { return -EINVAL; } @@ -317,20 +317,25 @@ static int s32_pmx_set(struct pinctrl_dev *pctldev, unsigned int selector, info->functions[selector].name, grp->name); /* Check beforehand so we don't have a partial config. */ - for (i = 0; i < grp->npins; ++i) { + for (i = 0; i < grp->npins; i++) { if (s32_check_pin(pctldev, grp->pin_ids[i]) != 0) { - dev_err(info->dev, "invalid pin: %d in group: %d\n", + dev_err(info->dev, "invalid pin: %u in group: %u\n", grp->pin_ids[i], group); return -EINVAL; } } - for (i = 0, ret = 0; i < grp->npins && !ret; ++i) { + for (i = 0, ret = 0; i < grp->npins && !ret; i++) { ret = s32_regmap_update(pctldev, grp->pin_ids[i], S32_MSCR_SSS_MASK, grp->pin_sss[i]); + if (ret) { + dev_err(info->dev, "Failed to set pin %u\n", + grp->pin_ids[i]); + return ret; + } } - return ret; + return 0; } static int s32_pmx_get_funcs_count(struct pinctrl_dev *pctldev) @@ -375,8 +380,8 @@ static int s32_pmx_gpio_request_enable(struct pinctrl_dev *pctldev, int ret; ret = s32_regmap_read(pctldev, offset, &config); - if (ret != 0) - return -EINVAL; + if (ret) + return ret; /* Save current configuration */ gpio_pin = kmalloc(sizeof(*gpio_pin), GFP_KERNEL); @@ -387,7 +392,7 @@ static int s32_pmx_gpio_request_enable(struct pinctrl_dev *pctldev, gpio_pin->config = config; spin_lock_irqsave(&ipctl->gpio_configs_lock, flags); - list_add(&(gpio_pin->list), &(ipctl->gpio_configs)); + list_add(&gpio_pin->list, &ipctl->gpio_configs); spin_unlock_irqrestore(&ipctl->gpio_configs_lock, flags); /* GPIO pin means SSS = 0 */ @@ -401,23 +406,20 @@ static void s32_pmx_gpio_disable_free(struct pinctrl_dev *pctldev, unsigned int offset) { struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); - struct list_head *pos, *tmp; - struct gpio_pin_config *gpio_pin; + struct gpio_pin_config *gpio_pin, *tmp; unsigned long flags; int ret; spin_lock_irqsave(&ipctl->gpio_configs_lock, flags); - list_for_each_safe(pos, tmp, &ipctl->gpio_configs) { - gpio_pin = list_entry(pos, struct gpio_pin_config, list); - + list_for_each_entry_safe(gpio_pin, tmp, &ipctl->gpio_configs, list) { if (gpio_pin->pin_id == offset) { ret = s32_regmap_write(pctldev, gpio_pin->pin_id, gpio_pin->config); if (ret != 0) goto unlock; - list_del(pos); + list_del(&gpio_pin->list); kfree(gpio_pin); break; } @@ -461,7 +463,8 @@ static const int support_slew[] = {208, -1, -1, -1, 166, 150, 133, 83}; static int s32_get_slew_regval(int arg) { - int i; + unsigned int i; + /* Translate a real slew rate (MHz) to a register value */ for (i = 0; i < ARRAY_SIZE(support_slew); i++) { if (arg == support_slew[i]) @@ -542,10 +545,11 @@ static int s32_pinconf_mscr_update(struct pinctrl_dev *pctldev, unsigned int config = 0, mask = 0; int i, ret; - if (s32_check_pin(pctldev, pin_id) != 0) - return -EINVAL; + ret = s32_check_pin(pctldev, pin_id); + if (ret) + return ret; - dev_dbg(ipctl->dev, "pinconf set pin %s with %d configs\n", + dev_dbg(ipctl->dev, "pinconf set pin %s with %u configs\n", pin_get_name(pctldev, pin_id), num_configs); for (i = 0; i < num_configs; i++) { @@ -559,11 +563,9 @@ static int s32_pinconf_mscr_update(struct pinctrl_dev *pctldev, if (!config && !mask) return 0; - ret = s32_regmap_update(pctldev, pin_id, mask, config); + dev_dbg(ipctl->dev, "update: pin %u cfg 0x%x\n", pin_id, config); - dev_dbg(ipctl->dev, "update: pin %d cfg 0x%x\n", pin_id, config); - - return ret; + return s32_regmap_update(pctldev, pin_id, mask, config); } static int s32_pinconf_get(struct pinctrl_dev *pctldev, @@ -604,10 +606,13 @@ static void s32_pinconf_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned int pin_id) { unsigned int config; - int ret = s32_regmap_read(pctldev, pin_id, &config); + int ret; - if (!ret) - seq_printf(s, "0x%x", config); + ret = s32_regmap_read(pctldev, pin_id, &config); + if (ret) + return; + + seq_printf(s, "0x%x", config); } static void s32_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, @@ -710,7 +715,7 @@ int s32_pinctrl_resume(struct device *dev) } #endif -static void s32_pinctrl_parse_groups(struct device_node *np, +static int s32_pinctrl_parse_groups(struct device_node *np, struct s32_pin_group *grp, struct s32_pinctrl_soc_info *info) { @@ -722,21 +727,20 @@ static void s32_pinctrl_parse_groups(struct device_node *np, dev = info->dev; - dev_dbg(dev, "group: %s\n", np->name); + dev_dbg(dev, "group: %pOFn\n", np); /* Initialise group */ grp->name = np->name; npins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32)); - if (npins < 0) { dev_err(dev, "Failed to read 'pinmux' property in node %s.\n", - np->name); - return; + grp->name); + return -EINVAL; } if (!npins) { - dev_err(dev, "The group %s has no pins.\n", np->name); - return; + dev_err(dev, "The group %s has no pins.\n", grp->name); + return -EINVAL; } grp->npins = npins; @@ -745,12 +749,8 @@ static void s32_pinctrl_parse_groups(struct device_node *np, sizeof(unsigned int), GFP_KERNEL); grp->pin_sss = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int), GFP_KERNEL); - - if (!grp->pin_ids || !grp->pin_sss) { - dev_err(dev, "Failed to allocate memory for the group %s.\n", - np->name); - return; - } + if (!grp->pin_ids || !grp->pin_sss) + return -ENOMEM; i = 0; of_property_for_each_u32(np, "pinmux", prop, p, pinmux) { @@ -761,9 +761,11 @@ static void s32_pinctrl_parse_groups(struct device_node *np, grp->pin_ids[i], grp->pin_sss[i]); i++; } + + return 0; } -static void s32_pinctrl_parse_functions(struct device_node *np, +static int s32_pinctrl_parse_functions(struct device_node *np, struct s32_pinctrl_soc_info *info, u32 index) { @@ -771,8 +773,9 @@ static void s32_pinctrl_parse_functions(struct device_node *np, struct s32_pmx_func *func; struct s32_pin_group *grp; u32 i = 0; + int ret = 0; - dev_dbg(info->dev, "parse function(%d): %s\n", index, np->name); + dev_dbg(info->dev, "parse function(%u): %pOFn\n", index, np); func = &info->functions[index]; @@ -780,18 +783,24 @@ static void s32_pinctrl_parse_functions(struct device_node *np, func->name = np->name; func->num_groups = of_get_child_count(np); if (func->num_groups == 0) { - dev_err(info->dev, "no groups defined in %s\n", np->full_name); - return; + dev_err(info->dev, "no groups defined in %pOF\n", np); + return -EINVAL; } - func->groups = devm_kzalloc(info->dev, - func->num_groups * sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(info->dev, func->num_groups, + sizeof(*func->groups), GFP_KERNEL); + if (!func->groups) + return -ENOMEM; for_each_child_of_node(np, child) { func->groups[i] = child->name; grp = &info->groups[info->grp_index++]; - s32_pinctrl_parse_groups(child, grp, info); + ret = s32_pinctrl_parse_groups(child, grp, info); + if (ret) + return ret; i++; } + + return 0; } static int s32_pinctrl_probe_dt(struct platform_device *pdev, @@ -804,6 +813,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, struct regmap *map; void __iomem *base; int mem_regions = info->mem_regions; + int ret; u32 nfuncs = 0; u32 i = 0; @@ -815,13 +825,12 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, return -EINVAL; } - ipctl->regions = devm_kzalloc(&pdev->dev, - mem_regions * sizeof(*(ipctl->regions)), - GFP_KERNEL); + ipctl->regions = devm_kcalloc(&pdev->dev, mem_regions, + sizeof(*ipctl->regions), GFP_KERNEL); if (!ipctl->regions) return -ENOMEM; - for (i = 0; i < mem_regions; ++i) { + for (i = 0; i < mem_regions; i++) { base = devm_platform_get_and_ioremap_resource(pdev, i, &res); if (IS_ERR(base)) return PTR_ERR(base); @@ -851,24 +860,26 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, } info->nfunctions = nfuncs; - info->functions = devm_kzalloc(&pdev->dev, - nfuncs * sizeof(struct s32_pmx_func), - GFP_KERNEL); + info->functions = devm_kcalloc(&pdev->dev, nfuncs, + sizeof(*info->functions), GFP_KERNEL); if (!info->functions) return -ENOMEM; info->ngroups = 0; for_each_child_of_node(np, child) info->ngroups += of_get_child_count(child); - info->groups = devm_kzalloc(&pdev->dev, - info->ngroups * sizeof(struct s32_pin_group), - GFP_KERNEL); + + info->groups = devm_kcalloc(&pdev->dev, info->ngroups, + sizeof(*info->groups), GFP_KERNEL); if (!info->groups) return -ENOMEM; i = 0; - for_each_child_of_node(np, child) - s32_pinctrl_parse_functions(child, info, i++); + for_each_child_of_node(np, child) { + ret = s32_pinctrl_parse_functions(child, info, i++); + if (ret) + return ret; + } return 0; } @@ -923,11 +934,9 @@ int s32_pinctrl_probe(struct platform_device *pdev, ipctl->pctl = devm_pinctrl_register(&pdev->dev, s32_pinctrl_desc, ipctl); - - if (IS_ERR(ipctl->pctl)) { - dev_err(&pdev->dev, "could not register s32 pinctrl driver\n"); - return PTR_ERR(ipctl->pctl); - } + if (IS_ERR(ipctl->pctl)) + return dev_err_probe(&pdev->dev, PTR_ERR(ipctl->pctl), + "could not register s32 pinctrl driver\n"); #ifdef CONFIG_PM_SLEEP saved_context = &ipctl->saved_context; diff --git a/drivers/pinctrl/nxp/pinctrl-s32g2.c b/drivers/pinctrl/nxp/pinctrl-s32g2.c index f99f88615ef6..9f521312f768 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32g2.c +++ b/drivers/pinctrl/nxp/pinctrl-s32g2.c @@ -755,14 +755,12 @@ static const struct dev_pm_ops s32g_pinctrl_pm_ops = { static struct platform_driver s32g_pinctrl_driver = { .driver = { .name = "s32g-siul2-pinctrl", - .owner = THIS_MODULE, .of_match_table = s32_pinctrl_of_match, - .pm = &s32g_pinctrl_pm_ops, + .pm = pm_sleep_ptr(&s32g_pinctrl_pm_ops), .suppress_bind_attrs = true, }, .probe = s32g_pinctrl_probe, }; - builtin_platform_driver(s32g_pinctrl_driver); MODULE_AUTHOR("Matthew Nunez "); From patchwork Mon Mar 20 16:38:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 72314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1334392wrt; Mon, 20 Mar 2023 10:18:03 -0700 (PDT) X-Google-Smtp-Source: AK7set9z0yYj1n9ro86BkyrGVvxEDp2jwb5Fd0/SlqqAyyY5x8oakio67sKBLzLcSvHvG7E1NdrN X-Received: by 2002:a17:902:db07:b0:19c:be57:9c82 with SMTP id m7-20020a170902db0700b0019cbe579c82mr21629476plx.65.1679332683628; Mon, 20 Mar 2023 10:18:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679332683; cv=pass; d=google.com; s=arc-20160816; b=GWJVfBvLoWBGbPFVL0/u894tl/Kz0uKDCJ8lH7AaJ++MygNsvAF5U1XYlRqz/0ca+m w2Dm55FskN2uQjn/hqFPDUQV053+PFOLgnNRERl1ZoqYCmlQwce3pHMQEjdJ0Eaasrxo JsUzZNxCCKmEdFCogYOvwAQMzahnnVPoK2qkRpEL/TQUMavobQIIbpQPwAfVGs8YQ1i+ LDc/cGTnZhMOdz6tpumhjo4q1NzilNvwjawzw6sLugE+bj2ZaULMbLOeMXVAkebtE5PA 0ziglIzWBcpuZxt+SZloIeoPbp4ATnX4fhmGPjoYtCtlqAhkdHAoWVl2E6r9TuAFUWNb Yajw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mQu3jYKokEz7tGJfJMQP/VuspHARz/h6PMLM5pn2zdY=; b=rA3HBDbLA1k6ICITOn12s8tkFMM9ShqZoF/sgH9Ukps7bxJU64vahaGhFz1DMdbWIm YL3Ov019YqaQKotnD3cQ+C9Wcq7RVQ+JcKU6IbyF5nBuUY8VvmfHQLIsf7RH2En8MbkT jT/xz0ekldfGRjqu6pQMc3y6OM9s6vbiRCr7SSf917yXDYbv+9o97eGoHcvyFSHHd0MQ fWbC16D0qK4KlYpPZIQ0g7gjwobVXOVpv4wVb/5mdMJvPB0LiUXsj5+hNMkKbGTFxkgq iVKXfCFdSCCsZG/Q+sRIYgpP8ug7GRpfMUB5hY86g3x2EYGyj/Yv9PWfX5nBcQP3zCeC ZugA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=3PTRK1W6; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a170902b18400b001967f72c227si10433197plr.390.2023.03.20.10.17.48; Mon, 20 Mar 2023 10:18:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=3PTRK1W6; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231901AbjCTQqz (ORCPT + 99 others); Mon, 20 Mar 2023 12:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbjCTQpe (ORCPT ); Mon, 20 Mar 2023 12:45:34 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2086.outbound.protection.outlook.com [40.107.21.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B34833461; Mon, 20 Mar 2023 09:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMVkbd01A7yrnkSV0srQ7zXFx1OkOzHCS1+1l1irwB53BoYdXAZSvML96O0pssiiIZu4iNYv7n+i0YyDDMhVtG5LbcEtap8jQeKT8f8tCaLXsfp/XE1eVntT15YG7/zNa1iHYiBZDWOFGEna8kIq/MnT3hhn1wmOqiaGObpjd24Mhzw1G/5f/JmZ2mv/k5sgy7LIlI97MtCUZ3VL6UeYl7dxWvYoCiyM1bnPizd8H18MEX2ExxI8EwPZpfn+y8fwSrZG12JT8tfJNqGbJ9Y61OyBGfPutCMLzDM7/HtHW6doEdiu2agVZ97ycKaYtUgL9Ii7dzb2p9I5YmYwzoEcyA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mQu3jYKokEz7tGJfJMQP/VuspHARz/h6PMLM5pn2zdY=; b=AL5XuwcVUMS3zq7hFNG/1adWJFJmRUL1mcxFPYSfTcKTIIF8b08NhgsAgY/1z/cXJ0T5i6EoNT4MIyBSTYqkTrNU7Y+V7YFHCRkBDW73aq9sVFHwvDRY8XJKeCqIIJISxoU9IvYVN8Zx8m9wP3hOiK0Y81YnZmb56hzA7BveULYdIwctJEwetFXU/wVGikroTLS975hZSEFFZta9QZwK1iU+kbMkDhuk+/hpvreirg6OYWEdawK/mqBnMxDBDL2MCc/5eeLn0/o5eT0JaMdP1HQWfpMgIwSs46LvDweT10UvSjfqwM0P12nUf0tj1abyBmGBrCRQ0WZPC4EZxHeuyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mQu3jYKokEz7tGJfJMQP/VuspHARz/h6PMLM5pn2zdY=; b=3PTRK1W6czKXuYSBjLYqakcpyjvL9Bh5hKLrJhoAr4tTaASxB7p+YoH0IzQZLlIgd4XBiLJhoJWCd6OuHF0MYVB8+2BiLtG5QOAkiLvP3j2Pwkw0g5/1jMKzFImkH6M4HPlSpbxR55dVHkjZH9PDeO0VEbzj02BnKJoaLXbaSoARtvBDHPdqNB38YhCYVsHrzKlOw/OxuSpqtPYGschKyvmt5nTQFdAF14e/WFOGMUn6aL+e+u8kMUOalYuWQDygUh6I2jRkSOMyptWkUoV3GpAzyIOXRNkV/x/7zJwOpbX/81tRVt8iEiIlyKM54uKYH95KBr0o+MJIoLYxg14PKw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) by DU0PR04MB9274.eurprd04.prod.outlook.com (2603:10a6:10:355::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Mon, 20 Mar 2023 16:39:42 +0000 Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::6802:b2c3:5f12:8f9f]) by VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::6802:b2c3:5f12:8f9f%2]) with mapi id 15.20.6178.037; Mon, 20 Mar 2023 16:39:42 +0000 From: Chester Lin To: Linus Walleij , Andy Shevchenko Cc: Chester Lin , NXP S32 Linux Team , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ghennadi Procopciuc , Andrei Stefanescu , Radu Pirea , =?utf-8?q?Andreas_F=C3=A4rber?= , Matthias Brugger Subject: [PATCH v2 3/4] pinctrl: s32cc: refactor pin config parsing Date: Tue, 21 Mar 2023 00:38:22 +0800 Message-Id: <20230320163823.886-4-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230320163823.886-1-clin@suse.com> References: <20230320163823.886-1-clin@suse.com> X-ClientProxiedBy: TYCP286CA0177.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c6::20) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|DU0PR04MB9274:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cd42464-8a6f-4b44-9591-08db2961b4bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3lyTXE+FH2n9QUP82u9GcI1f5p9MvOE3wswwtfq786He9MoH7612KGR0MfVjDJ8feWGNDkGlQf38SZ/u8qJoNWfrWO+ac/XU64dOYKTDz0HoFfvRWMo2FKWjJOfI2SPniUyGgyvL3hP5/yI0AHPH3hF2bL07huIVhDtdFF8DdlBDTjztckJJDad/AKV+glA7cDcvVXrqMNbDHFU1q2nEaCC9vW7rtKcK3Xm/lhrvbFkKtVyEP9/3Bve1nPdiLfA2zNcuRAv/X1ylOY+YGmy3L1ZzshTgS6MHvgljAbeQrRMxNGQOOAqG2brX2ZrRTnX+8+hHUWR2itJbRmRrUpiR1Jv/cjJcwEijeRFOaCAltpRrFSkM8Yvj+AWzQ/xQ2lDtbmKYyBDOCjcd9VMsSjFMdMpGNG/MB5qc5NYMXeHSkoWVi58GwTobeA9lW4aXzRNyuPGbKjQKx02glIqfcbbZ/4U4Z01lWK25S+j+OXeI5KEGHWTvtr8YW71BLCYkWeXkDoUwH6WC/rXA1aRbT+4B418Q6oJSdvlbeFQaTwqzRmhq3dqVi9BJWLrayfwvAuvm+sl6hkOcuXbfll2VVr488BxbHV5HIfCcBSiVYDOkHtxuZz/zPYVr3bpm1zAum/XdWNiv6ziBwOVQHBaeT8bNBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR0402MB3439.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(396003)(136003)(346002)(39860400002)(376002)(451199018)(8936002)(5660300002)(7416002)(86362001)(38100700002)(2906002)(36756003)(4326008)(6486002)(83380400001)(478600001)(6666004)(107886003)(41300700001)(2616005)(186003)(1076003)(6512007)(26005)(6506007)(54906003)(110136005)(316002)(8676002)(66556008)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r1Mf4mcY8YpmZPtVsYhFrEr1nTO0weweuB0NhtDCNFlwlTZqKx8noDAfDXYxHIW76gC3uL5+ViIwwUe3fiUxk/iJ5scjYprjpFVJTwtw/Mo6Lw8wl+b9tYcTrf4LNSkhzTNKmgBMLAjkaCFzFBR0bJPC4uNo6gKdJl3P3gvPghmsHueNAQAwAzVj4BLcPmB9haYg2TeyR+ZPtxpusy73WhV61EMJsi9r8vShK0ZZRN10kFrzErvzxZuY7UDvZFaPPpfPy7iJV3mNp1MeucOsOSNgRq92c2r9WGsT4UB+JWx0m1oyuKyUjxIhDzrbdPoYMMS4ucMjHj5/AbUMmcbmggnyf4WskdO9ZlP9NA8CjdzLfEovcq83JoM1v4hJk8UrY19+O1186FE46Rg367n5X+rwT+4+NYuMNlL4c/FMhV/TpockRRB06hslX/FQOops+uZ14dKdgPmnhxztMG08+JKnJPB8IP0MyUBiTzp8ITQQ8fcGeX+vGnGVxSavd89xAfiaSTixgkAZVcQPQORpV44B+7ate8DCyRW8Y8fZHYHdvj05orD75OmnO2QNk+WRP1Irj2UjZ/5oINUKsK6Y6QRZl5hx+HP0nMEQ+djWVMJU0fhjHZ5ms3y/BP6P6CtFxEWFsaDxhmLIFJmtU8x2d9LPR3DDtZjlrEKGpL5EZlwzGsC3WRUr8kUFB17BtsnQL+9UwVA8KhI2NhTxPlxhtjZqL6tMnXIyawNjWPds7YZgz5j3qc1ReTIeeJd5yF8YNLXwivMEW8DMNxp2cGLH9pJwk1EaeBSdbDClxVORm5P0ks5gXUUgbikm47I17P5z0vvjKQ6REb0TM+zAjHzP677RoABYD5BL8FrQjZPmZFAydmXvpr5K0vnA05fRN5UnxNjTzycuudFLM/02rIZSzsrP6DG9qE3jk9OtW30PoAg85V+Yn2QhjGf291JuS7p+uW/XqUJ3cW/+bqPwnjfK+iAik11/9/PkYeSXLCviq0eC+Ml5cqDsfYXJNZjJo6/rQGbBRo5PHOO405JRyAo0AtUXtu1mOXiiu0qxAaPUyA/vWYUPIINtuDMKGYpMCmf6yg52tq9a0RL36kowS08WKaKvhN/U6nWULEojWXko/R34lj6BAoZ9RHB3KZgIMp9JhBa9m3r8t6MksMMP5D8i+SyTJg1St2mVEx2Fd096Rbod6ulT4g7LLENn9OA8EZBktaN8+UcXiM6z28s4s1rvrxLL7DKau1RICi4n3Z7CgwAFmc4TUZzWLw3QbTLHWG9+7ei/LXAR4ZPCWFnxoxQMiFs5g0inahFoH1ueBfsDJYW8sLEX3lITm5/cLWUSTws0sQsBTpK87ImfsN2ObF473Z/eycrFdW2Z9JFFN/P9TAHxXlB9lGv2Pgr+oNhRXazpWlZMe+dvN/NM0RND1lmnsfEZfCYtU6pgM3i3UeLZ0CVvo9GsPoPJ+xOWrdN8RZvCtw61xi2xBQYKNuaG+5fEOckpOIY3y9f0k5fCROfWncPMUSWX1E+cI+Bg1Wv5xelZNtuK+hwYmkEfJO3Hre1k+H078YyaYTVTE6xO34pI8aQ= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cd42464-8a6f-4b44-9591-08db2961b4bc X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2023 16:39:42.6068 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ucLPWKFTubXFKqgGksMpp8H7Di+4QgFrKfTDOpigk+d1mzpPlkzc+nQBVv3T/Aw1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9274 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760907948056584539?= X-GMAIL-MSGID: =?utf-8?q?1760907948056584539?= Move common codes into smaller inline functions and remove some argument handlings that are not actually used by either S32 MSCR register or generic config params. Signed-off-by: Chester Lin --- Changes in v2: - Drop unnecessary marcos and s32_pin_config() implemented in v1 and set/clear mask/config values transparently. - Put pull-function related cases together in s32_pin_set_pull(). drivers/pinctrl/nxp/pinctrl-s32cc.c | 62 +++++++++++++++++------------ 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index f698e1a240ef..cb8a0844c0fa 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32cc.c +++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c @@ -474,11 +474,38 @@ static int s32_get_slew_regval(int arg) return -EINVAL; } -static int s32_get_pin_conf(enum pin_config_param param, u32 arg, - unsigned int *mask, unsigned int *config) +static inline void s32_pin_set_pull(enum pin_config_param param, + unsigned int *mask, unsigned int *config) { + switch (param) { + case PIN_CONFIG_BIAS_DISABLE: + case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: + *config &= ~(S32_MSCR_PUS | S32_MSCR_PUE); + break; + case PIN_CONFIG_BIAS_PULL_UP: + *config |= S32_MSCR_PUS | S32_MSCR_PUE; + break; + case PIN_CONFIG_BIAS_PULL_DOWN: + *config &= ~S32_MSCR_PUS; + *config |= S32_MSCR_PUE; + break; + default: + return; + } + + *mask |= S32_MSCR_PUS | S32_MSCR_PUE; +} + +static int s32_parse_pincfg(unsigned long pincfg, unsigned int *mask, + unsigned int *config) +{ + enum pin_config_param param; + u32 arg; int ret; + param = pinconf_to_config_param(pincfg); + arg = pinconf_to_config_argument(pincfg); + switch (param) { /* All pins are persistent over suspend */ case PIN_CONFIG_PERSIST_STATE: @@ -488,17 +515,11 @@ static int s32_get_pin_conf(enum pin_config_param param, u32 arg, *mask |= S32_MSCR_ODE; break; case PIN_CONFIG_OUTPUT_ENABLE: - if (arg) - *config |= S32_MSCR_OBE; - else - *config &= ~S32_MSCR_OBE; + *config |= S32_MSCR_OBE; *mask |= S32_MSCR_OBE; break; case PIN_CONFIG_INPUT_ENABLE: - if (arg) - *config |= S32_MSCR_IBE; - else - *config &= ~S32_MSCR_IBE; + *config |= S32_MSCR_IBE; *mask |= S32_MSCR_IBE; break; case PIN_CONFIG_SLEW_RATE: @@ -509,25 +530,16 @@ static int s32_get_pin_conf(enum pin_config_param param, u32 arg, *mask |= S32_MSCR_SRE(~0); break; case PIN_CONFIG_BIAS_PULL_UP: - if (arg) - *config |= S32_MSCR_PUS; - else - *config &= ~S32_MSCR_PUS; - fallthrough; case PIN_CONFIG_BIAS_PULL_DOWN: - if (arg) - *config |= S32_MSCR_PUE; - else - *config &= ~S32_MSCR_PUE; - *mask |= S32_MSCR_PUE | S32_MSCR_PUS; + s32_pin_set_pull(param, mask, config); break; case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: *config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE); *mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE; - fallthrough; + s32_pin_set_pull(param, mask, config); + break; case PIN_CONFIG_BIAS_DISABLE: - *config &= ~(S32_MSCR_PUS | S32_MSCR_PUE); - *mask |= S32_MSCR_PUS | S32_MSCR_PUE; + s32_pin_set_pull(param, mask, config); break; default: return -EOPNOTSUPP; @@ -553,9 +565,7 @@ static int s32_pinconf_mscr_update(struct pinctrl_dev *pctldev, pin_get_name(pctldev, pin_id), num_configs); for (i = 0; i < num_configs; i++) { - ret = s32_get_pin_conf(pinconf_to_config_param(configs[i]), - pinconf_to_config_argument(configs[i]), - &mask, &config); + ret = s32_parse_pincfg(configs[i], &mask, &config); if (ret) return ret; }