From patchwork Thu Mar 23 14:48:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 74095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2956724wrt; Thu, 23 Mar 2023 07:54:15 -0700 (PDT) X-Google-Smtp-Source: AK7set9qKb23QGuXlnPi8BF3dG8cP4ei/hHLZfzjiQMa7P7jqFrH23rorD2PamUp/OsGSkmGpOmG X-Received: by 2002:a17:902:e54c:b0:1a1:9020:f9c7 with SMTP id n12-20020a170902e54c00b001a19020f9c7mr8495175plf.44.1679583255468; Thu, 23 Mar 2023 07:54:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679583255; cv=pass; d=google.com; s=arc-20160816; b=dStMtHy5x8U0VPngIbJs+UshWwfU7aPs13xl2JEBL892tXdXx+FAJcaVqdWy7FCeKk UT+KArRhHsBOaOk0oIsYi6vODI706PL6RNQOVPgUV66I6TGt77kUi0FhM2fMkxGHdWVJ vqhCzlcwejkXPmNwzr43klTCRuHJWqTkT8arwT4wZqN509J4fk0gykmVKVEswHQ5BFtY oyMD1Y1DpTYBlIcciopQ534xSjhNXMrv/PcpXEDuMlAQEm5cR2vgxtP0WbHpTquuhAl4 /yhkH5Q+4/aK3BZAt5vfYF9igLKcyhthp1fi54WgwG1FJjttCL2vzMrrYTUjRNKEPMph tPxg== 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=cruGKK4IQW6635Ztcdl12flObos7TvxEmOlvETIWy48=; b=TiSaKgDbaNhNjEOJ80ZTkq+VE/QFRWFXlrd3kIdnAzWCyd1k7dJnTTWVaOaWyXUJgu jgEqZVfOcSkgFvL1CM9t7jqIStw4s7CDuUmcGkXvYKVRRAJlHwxAacKvM6vwjajE1+wV y3AOIC6hUidPT1IOI0pEGf8gpouBueSszlZbmJT3bj8k0+GGzJetAj7huwpIMN15d+vS W+FJOcuNpdJ9EQ1D46mE4p1LV0N9+VD74uuw3WoNQd+fFlBXsbjR5nG4ZBoaXPsMlheW SwzKDcGhuLmIZ5rwWUjSg3q7UrKf+Vi600wuH+U9/ilYdXEjLU1QZv29dtx5DODDLkeE xOdQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=anFwEHmb; 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 bd8-20020a170902830800b0019b4ee071f3si17861591plb.584.2023.03.23.07.54.02; Thu, 23 Mar 2023 07:54:15 -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=anFwEHmb; 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 S231886AbjCWOtR (ORCPT + 99 others); Thu, 23 Mar 2023 10:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbjCWOtM (ORCPT ); Thu, 23 Mar 2023 10:49:12 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2077.outbound.protection.outlook.com [40.107.8.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 672B7F773; Thu, 23 Mar 2023 07:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sg5SN4ej+qiM+RQvkapyGCEiEmXRUyew69MReLWD2KITAXhtj7+8iRog71qJMzVsR3fROxq/FMZqe9j1/1L4kcb6kGs2dxmvEVatN8imrsWDaXqiQRuDyvr8x+jzvqVe3SU68bX1H9AYWwmgY/xHlp+0IVM3vrzOxXU+cN9ik8dXG5aJb8SGkrIYsoTr75MN0MmNhLA8ZSyh2w7ePGG/+M7hDOyMXinO75Mx5gh2keN1wIItJidLfPXZg/VSlvvp6Z39ozGk6Nx1ScYIOPwxlVh76svReL9J7D3Oj37L702L8+qJ1CVMNbdHMs3EbGv2xdLyYZ29nk8TYxJYZ8SIVQ== 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=cruGKK4IQW6635Ztcdl12flObos7TvxEmOlvETIWy48=; b=P3UMuKYoK+6tXtAjeul+mIg+dIqq+69X38opGkSU0Q9Mv5BLfzf9fxRj9lradjCZH4t7R7t+V9MEV3MD+kWS1RTNINHyF8P2AH5mBEF5T4YC539nBoXht6aZQQ7X7KFfSmgyqKZwVYgGm0tbiVL7f/SGGky5mScITfQQJecNhO5YovwIWccU5v93Cfx4ZQBADBPD0jM9UL9KteVwza9pyy4qIuCokwXxwy5fqzX0IyXBC/1M8MJupPPf0cDmJ4d6rR9M+QiMsTIlt/qp4orICM78iQuNfNl3pmN661ARfQgUHmh7wBej5Ay2CYmoFATT0daMcMmtKdc91Axsd1sjTQ== 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=cruGKK4IQW6635Ztcdl12flObos7TvxEmOlvETIWy48=; b=anFwEHmb8MOr81TAL6FA5rNLUeUhIYWk2DI234PvqcpfUNUXqr4AHb48pgntREkleB8g5PoLEOIcWYIA9BONgu8+d8fvC3th2jR4pnE7MVrAFMjLhcIXcxEr92872Qw7461aZAeISAtb12fVm2jqfnlT1VL+tUfNeY7OmPW7VRCE790KRiNeLMkO5Ykk+FYBCnCyRiqdB1sogmqG8GqjJNeilaKNhBZ9GOaG/0EAmcyO5wIbrosuSssK0Lp8Y/Hh6RKlYo9bdfL87T83BvFuOB7eVZquPvZkenCGmAczePlFPaZy4FEGbZgtccKz9wJ2PA8aNzlwzuGC8x/4eqX1CQ== 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 DB9PR04MB9625.eurprd04.prod.outlook.com (2603:10a6:10:308::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Thu, 23 Mar 2023 14:49:03 +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; Thu, 23 Mar 2023 14:49:03 +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 v3 1/6] pinctrl: s32g2: use of_device_get_match_data() to get device data Date: Thu, 23 Mar 2023 22:48:28 +0800 Message-Id: <20230323144833.28562-2-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230323144833.28562-1-clin@suse.com> References: <20230323144833.28562-1-clin@suse.com> X-ClientProxiedBy: TYCP286CA0294.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c8::6) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|DB9PR04MB9625:EE_ X-MS-Office365-Filtering-Correlation-Id: b46f1637-a2d0-4c7b-e7f1-08db2badbec5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ANM9oHAPDQdZljT6kfgXnrc5o0kjEo3caUWGA6SLbEe4ikA2qC1ra6Md0HV+n7iXB1b7TvTVVBI3vWF1zTeK1gp6RcgGtLRnFO8t6g7V8Yft5Qrjz+IoZc2w4+3D7Vc6wE3OsAbwns4rAaMdQMhecD5pwl+SVt+Fd3ggJeiBiUDgNrZDBs0bF5oigmTWibNLB+jDwzGczz0zW123vrLhyAJyBGimSlpmIYK426R/whf7DOU5dEmO2zmhVxMMF2+dJa+uWX8Vmfbuh0uUXodfFoP0gR8IQ7WsRlYreI7PLy8ixFR5XNp8rQQcvgDoZID0igVZY+x27F7tl6ZTsGxvy/SiuGUq+YQZSnQ90AY2xZp4bD5pPuI1HFtbCL4ipm+2BXOFTc9XVUiYUDEVE5BF1DtTdZroN8d4mmevo5EnNlUyFODSorpc9VkzWpLAEHRgIM4x89qjqT5p4jvvLLTx7+REnFBXkrFvOkcvzP0TwZ8XV3H8D6TkRV4YwSkekH924RHzn5GSOFp1+C5HUbYGwmJZkkPlURp7xezUK8IUlxVOuNxFWG1b8rbu3E71CeDA/OxI6KSGNzKf3A1GxnCXy9GloCu1JMssQVOGSlUTH0pA0TlLOploMLEmNWnsxyi5IFbEsDkcEmrwwKykVRRtAg== 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)(396003)(39860400002)(136003)(366004)(376002)(346002)(451199018)(4326008)(66556008)(66946007)(66476007)(8676002)(110136005)(316002)(54906003)(5660300002)(7416002)(41300700001)(8936002)(1076003)(26005)(6512007)(6506007)(107886003)(6666004)(2616005)(186003)(83380400001)(478600001)(6486002)(86362001)(36756003)(38100700002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4RjQ7KDid2LWk5YhdKCgFAaQ2+cGDHE8Kr/BvqV4FTg7GiCIB+mrKix/svDTJ942iB91JL9S9f+5cuxemFNFkDjad1Nnm9rbIWYGMOs8YHNuzRmW8PdwJK5DayjQr0prNHmO4SULBL6hQ0LWPtqBNBl22f7ID795FLGdJEJR8zNDfqQxumAX31Exu1vdd3tGjI5E4UtgR/rS93CqPivjwOQv8xpW+s/YXNjT/eQPtNipeGXJ772C8kbTEhN3kwX3A8wLysaUkJ5xk+fi4m8Z4WdGDYN+EfEns24e59zWqQ9Yq5joAa8ZZ625+R+GV3fR//Wdco+jT2H5pm7BN8REruxjYb4aYGnhciT1JsnT8qHAJQ8VJyQokM6cfpHIMLeAG936O2AKQ7G3krRE0LO0JGFGmpcwMA0cAEBilPNA9eo7ZofirDdrEEyIy+l7Iv/ynjZhXlCBuztoxPp740KC+ZkGWtrhVlfO8/Nc8Ivw1TgkhJhB4+lSLTdk+DIXayb/9Ja5QD7K6Rx1BYaEXFftbb6B4qqdl9hYhQhv9YVf5YVLCpLu7AwLfvjfVnZFuB+QIhdQN0muPnZf0up26J61LDeHICtDJeIscNkKvWrsa0JUFtTgr/NaXyitOZz1vkjIqRVuhxZEF/kLcnA71oyffEQX5oBCd9nCJaqdaZWmE5G+KF3K5YqqTM6aDnsuLo0JOL0fxs9BJxqAzZnY0IPPRx/lM06y6INLXtsfIKrrL3FKMba1SUV1o8RGpUrzGtoujmDHqMOxvADowk8Am/GVl5EBQxPB49nsp9WssbjmCXD6Ej1Ye9x3OlhvNsgwUOVrMa7JxnGftRpyIy1sPtPhdOjkbyzEi8XBHNg5K4BN7H288pJ7LMWYpJ6N9Ex3+tvJXFwTSRHlOn9RG6khK2jAsZ709iFQ4HE4osMNYN/isbmrLHGeUWZrDok58ttA56ZavIpMPC8dkr2UeAgU1vTMFpv0ss3zxdxCcKpSyxj0LHF9714T/zEzy4SE6u5a4MgshfWP5jibn7bOoNAqfOC4dbWE7OXecMHXjoQUtRmEtbuJ1xYnKIqCJ9zoIAcBaj7Q5U5eEfXUHlvk6llWAnNv7fAxSh8O/hhSdP0uq96U/42FIVs2RZ09Pg9eJTHUmfztz5ZXDflVrKwrC9mRJzRN+fKew0Yrz2iHv8xrxj4XliJGvSljnfY26GwyD8ammQx37BR2I044tR9me4SeDMWjR9bhV21P3SH4NvgFuOtbxozAEmDqI/0WAhgGrkEYv4ik0xIHi/KFUicnnExdaA5k3UO34y/Mo8Q57yVhZd283XCOtCA1koqYcwCxb9Z0K1nr9VNVVjiAb469mCIl59W/mPcPaSWSheSuKjVHJwnbjaZ6+YH8wCUaezHq8+6GwZAUpix5xgVI+v/IIeIH+cc/DhVo5Yl78vhhDwI9+ZDwAG+l/V+QgMqP2GwEtimj12URQMMHoLMCcbxVL//cnXpa7LOJmSRrAaYHEUDdhWuDMEyfXIl7bUuwNZ2z1nKN2bR2y7KGG/gTWiIwU9lwSxdR6MdmkU4x7lC0W7G8bT+SOlg= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: b46f1637-a2d0-4c7b-e7f1-08db2badbec5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 14:49:03.4597 (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: NxeRMOcuXpz0qOKp467D9f/dJOf36to2VRqP8luVHyRJyh94qS2jOxeeIYm2mE0E X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9625 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1761170691499385846?= X-GMAIL-MSGID: =?utf-8?q?1761170691499385846?= Choose of_device_get_match_data() instead of indirect reference via of_match_device() so that the implementation can be more concise. Suggested-by: Andy Shevchenko Signed-off-by: Chester Lin --- Changes in v3: - Declare the struct var 'info' as const and remove unnecessary type casting. drivers/pinctrl/nxp/pinctrl-s32g2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32g2.c b/drivers/pinctrl/nxp/pinctrl-s32g2.c index 5028f4adc389..0e2d93681769 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32g2.c +++ b/drivers/pinctrl/nxp/pinctrl-s32g2.c @@ -740,14 +740,11 @@ 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); + const struct s32_pinctrl_soc_info *info; - if (!of_id) - return -ENODEV; + 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, info); } static const struct dev_pm_ops s32g_pinctrl_pm_ops = { From patchwork Thu Mar 23 14:48:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 74100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2961741wrt; Thu, 23 Mar 2023 08:03:01 -0700 (PDT) X-Google-Smtp-Source: AK7set9qdPa0NYzAluE+Tfn8u9+QuxF3kSS+Y8oWrpLt7K46TsryQEX8rYJnVVL2tSj9s1s1H7PJ X-Received: by 2002:a05:6a20:3b83:b0:bd:23a2:8840 with SMTP id b3-20020a056a203b8300b000bd23a28840mr3390264pzh.35.1679583781357; Thu, 23 Mar 2023 08:03:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679583781; cv=pass; d=google.com; s=arc-20160816; b=rfRKsrJ4kgKT1F/4XxANDFaHX96pU0lY1QK69NhBLBxE9dYi364hug2jSiOg8wZrZu YUuOWZFmJk7unGYCGKjJxV0W1H+bSNF0tJ1rlVFDz8tNG0Rimdu0N0FXX0piolGuRzOr NlpGYWXL+GMZrRaTI8a7CXLSMIY6PqcADp3/2m8XFd/nFmdDX5O6iIQvpzRp1+K4jsMq klXzuswcpwFXLsBNfywXptTZBKrfYHdKqulFJd2Y4gMBbAhiPj3nZzZPmy+SUezcEtJl BoOOIqxusIxX/vOi3WU+Csb3ZtJE4/FG0GTyZp5hMOUUIlHgLa17nSfS0cHihDJLgier 6b7A== 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=NUVQY39rnq/iC+i1aiK8K33wTWf8DjeE2CewvWWfpFI=; b=FtyFGsCBw5UHgCAVD/dPqafJh9nod8wjiRg+F9NWZg9SOcu9v/x/IMlFT08xFv8ITP 6VfYchrggjCLj6RK470+f/xfwE1b0nDrSSwvzc0lnz/Iz0YqGIKRSycGha5B9rcKzijZ LSeNTE399dit9t7N/i3inMQhY17ZjOsIDIft1NOMmQOJ3HYScw0nbviRFptDn2osqrfK 91GZk7sEVkaT8RJJqzWrQNyUJ+qIhmcgO4cmjYSdUVUkgfwE3lxFkhsFKzSRAxsR5V+b wzE0hQZM8V9emm7Zw/Y4bORAIzG1CSZUOfVmh6ddmJwu4hudJrEX8IF+F0wXTz1Ly5Ra Ti6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=0zDN25mm; 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 z36-20020a630a64000000b0050bf56c35c3si18613616pgk.81.2023.03.23.08.02.43; Thu, 23 Mar 2023 08:03:01 -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=0zDN25mm; 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 S231851AbjCWOte (ORCPT + 99 others); Thu, 23 Mar 2023 10:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231888AbjCWOtZ (ORCPT ); Thu, 23 Mar 2023 10:49:25 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D01010244; Thu, 23 Mar 2023 07:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ikdG1BkUPc3JWWfm6njoiMrkbbnnLoEYd6HN6Y0FvnT2deu4XnCzX9btaBCTMp/TmN/ZzsZ9izgLZE5S/W9hqFWHVcEU+tO3vWB7dNyciNjsovfrLk2VcSYHMeobQA/NUcQxOhkgwzgm5iOiEPgU1qelWg0XOWD94v1XvH/CC96dm4bZ13wy25fxBvrpER4RjBiQir6n7OPqIB+lj73kRdRZepRyYibp0H3klxp7XbIAc7IjWP8e20U3GKKBwQqZgchUwA9p4++0Ns65K5iJ+xE3IcJODXYQM0DNO3S6RHWiCQm0igz6hn12XKpo5uCdExEZ/2YRlHDULdVRLXF+iA== 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=NUVQY39rnq/iC+i1aiK8K33wTWf8DjeE2CewvWWfpFI=; b=asybYF0Dy39lYNoyiIEKHsuE1/iQisL5VWbsfrxtuET1469Dh2uZeJqPtnCnzVgc5sYR6hkboyr1X8mAg3DHZwqdYcLAApYl3+txXqT87xYWl3sW6Pw4rspYGxogmNHbCoQc4YewcUorr+eCQi+ySI9fIsdrhtxB9syJFsX6AJaUSaN/meDHX2TB5ee0E2YnozrJ+2ES6V0Fl2zmWND16z3FsgNStK9gJ5iPMotDe1TFxh5zt0UPQ2arAMw1Ac8XMJ+MUJj76uaX9LNpQTBLyyS5sJee6Ww1Lt3NmxsN4H/gBRQ1HB0/02fOHcLmQemHuAFaChCX6ijzMvFx7BufeA== 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=NUVQY39rnq/iC+i1aiK8K33wTWf8DjeE2CewvWWfpFI=; b=0zDN25mmZO4k2iCrgIf/97464Mz4pxPNrtbToaNAI43qwRwRsw5TQBPQNori00537nyK2h65WogczbB0LERqwnMmdlXDhmpIkGjGPVuk9bpXljPHZoDvISSjLoDOUk8rBzYm0M4FMonooNXXvjwvd78hGsuib4ldKsRJnlkXTqAyaMyGo9BNyJHLpdPtFo8HdkfAu4iOVn/2kKT9LlLq7IgF3xft15XVydEOtPHREwv5RHxEYiztuLxgM23vIRTYBKqg3rDRu65fgC+2OTxCjY8msd5FHsfsbK9aLmeHGOanTQGTYWSZxHqBTqU/mToE0jCST47kyQG7o21dv2Cb+A== 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 DB9PR04MB9625.eurprd04.prod.outlook.com (2603:10a6:10:308::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Thu, 23 Mar 2023 14:49:18 +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; Thu, 23 Mar 2023 14:49:18 +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 v3 2/6] pinctrl: s32: refine error/return/config checks and simplify driver codes Date: Thu, 23 Mar 2023 22:48:29 +0800 Message-Id: <20230323144833.28562-3-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230323144833.28562-1-clin@suse.com> References: <20230323144833.28562-1-clin@suse.com> X-ClientProxiedBy: TYCPR01CA0124.jpnprd01.prod.outlook.com (2603:1096:400:26d::10) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|DB9PR04MB9625:EE_ X-MS-Office365-Filtering-Correlation-Id: 1370cb59-9cb8-4314-f045-08db2badc799 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: usos8reJfuf5k4D9djnyfuNf2sHPc9rnhx+7u8GgVv3NTun3I390uFxnpbLgzPODnMddm0yehZjmIJlt1mHamfX6HZZgXdqy8zpUM6kQ2LA2urQ6UZTij//OuSAXnlOrcrxtYRNiIi4kLjJWXmPFuon2GoPdbWg15HfvF7i4LGPN6eZEL6RvWwVVWONhTnCSrWc08tbxRJNqP+QADe4CLX4NrDd+9K0ip7yS183qwm1Smtx/NgXaCSyR8c6EH5PHR9UcICrvlC/a1eF1Fugp8JLBAOwbH5BryqKH/a4DLwyHVHXoKxBZj07s7BE2zkHeK00GKUYe6CRcPEcl4kziMtUN5iunlpDt/R8ILQzS/K/xI+pBHoK/NLSso52KubDHyaYRXLgQdUxhDWd9Y/MKTN+edaxoqOSwMmnS2PLN0juGAVpgN9oeI11gbU1R1RZWKpqn3UOlhsjvkVqxzHzsr2+032xtLeP4e8Y4mNwSemgrB6XZHfnYI6n7Hh9G1CygW8LKVtc9QZpKqw6xUHzkyCd/iTTKqBKF2LdmhcMXAdIqU+Kt/pJI88/yG6DXDRY9oGJngVFAH8r+KCrWj6KS0QmJKS9/5dOi39TJffDTZSxCkppGFg+kuX7q2Uo5B2Ekol0GgHIlSu+EN7S37dv40w== 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)(396003)(39860400002)(136003)(366004)(376002)(346002)(451199018)(30864003)(4326008)(66556008)(66946007)(66476007)(8676002)(110136005)(316002)(54906003)(5660300002)(7416002)(41300700001)(8936002)(1076003)(26005)(6512007)(6506007)(107886003)(6666004)(2616005)(186003)(83380400001)(478600001)(6486002)(86362001)(36756003)(38100700002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eqad8rA3iz99CzF1dNTE9e96mr6/zW8zH6BebPPlZ/PUrQO3f52fWOE4J7OL+7TFpXTXNhxkF0XCoIMNovd77ULpwQdHoUVsRYOoipr+l1xDZwdzmB6PHtWxzXIcqCvj/m8+DGbBnJVp9t+B0IkxThc7dBUpj9In4GTrJn3DAgPBVFmLHX0b76yggri/H8iYASjJayxGl10AZB6tx+M20geVVH7bFw4qwSh7bUjEU1kE09ufKt3RONYsF2pstzwi98+X6NmW6UpWiQoQ4Mj+n+ZWCep2tedLuxOnHnPGh3dekwq4gT8SMPdKz9n8w1T4UVDeqeBbvsMr4MzMz1UPixXCi/T8B6SqYaHF+eHuaHaXouTdOrDPyHprBt0NZVsZ5S2xtw7wsYuXTnywqu7C9TG4ezMjRfpsjQb3lDujGJt0OvgP3o2p7jjkeNp5xVYQoInUogEs396jsE5rTuqYWwRCGYoIN9OMwGkBUaN9b07F57oUwGYhYlyZIRfNndI7sgaU8crxtC8XJg9z7y4tuV0hzY+HUrgOAGfLktpZiANejtd4oPQVvzRZaToPpeLAWwLCMNuTeobarBOI1oB98VrcQR2+YJYrWSNdaV9W7vZCW1V4zSNtLZPmSGQhdzWw1XNHL4ekR7BCpsut9VCoFVZDyM8ZyLXltZo2qR58wnvKmkDViMccdAJ7S9eOQOJlsjt2D+yOnDO52+Kz+jRibmUk7SXgSWMEUWTrZnOuBpMXVtqSSDeh1XERdBm3rhCJxlp/eRLJLGp1PpMYt4LG10qYz9C7uin80hJo6GfS66ChM0KHCaB9fayhGxK4164Jm0GJ0vcbGJFcQG0clvL3SU+DpVXfUz0dFle6O+HUrxl3ZdvBFpzEpx1BpRxXw4QfNeGVg9lKFaVhcM5mFrMP5IY0lJ4A8ngdUJd2kFkJQN8uQ1Lzk6zGr4RgEFLfOnwO9wx2p3D9jLOEAl3BT5Z6DIUefwOZq4nyStREs7ruaQbPb1fCduXnpCIHKK12lsi6Q2macznYYzobK8TIjYPI/CqQ+XhXrOZIqVtTLQMo7i3lsZVGr4YChmHWDH6V2QhHXPwm8V5FJskI26cPPBW/po3tVvfwzW3pIT42byOM1G2pRFg0Y2qRXJOGHQV2F92/gloChVc5yJI/K4gLuefHFwDr43kfQH4jZuC1KfM2nfIdyDl26sjTYk5IRbla4sEkkib0YaGNFk8uv+X9OSzMlfF7C3zHv+nMKlpKGVqW4p5RhdZAnwuftqlFIVKjn8/580C4nOomL/DpAwzHOp1CuWIy5ez3RytMGf+lm/24PgW7ovFQTW8oYEjOTQTFtZA3Jz4rHE2cRS89OFL9NerQ04+WR0M78RjYM1/pVaAbPis1YgYNH2QeKIaYCbrfSaAyEK1Fra/to4KQtAsNLaFylhWWjMzuQtiGGRfeVBsONkOuthRP8lALsNQLXFpdk+shB/WLO6egrE6li4HUIsb4O6iuNBQ4GbxZCW+pobSrzMxk9uAVPVNrDMMG1hTZqMk0HX9D5W2p/qa7Ag4t0hGaEK44eKAO0g0rr+Cb5KqGsR4= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1370cb59-9cb8-4314-f045-08db2badc799 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 14:49:18.2398 (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: WfqslLyLCMRD0MoQVO0PdcxUJDe3I5UXskZj3HC5oEGxvIx83o6Yrn9ArnfXutz5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9625 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1761171242608849001?= X-GMAIL-MSGID: =?utf-8?q?1761171242608849001?= 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 --- (No change since v2) 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 0e2d93681769..9124c6c5e5d4 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32g2.c +++ b/drivers/pinctrl/nxp/pinctrl-s32g2.c @@ -754,14 +754,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 Thu Mar 23 14:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 74098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2960802wrt; Thu, 23 Mar 2023 08:01:54 -0700 (PDT) X-Google-Smtp-Source: AK7set9Z3rUOdUKhAznx65u3E3SDX3kjyXr/OJ4/853leQK8nAHDNZZY37T0cdk9gdl48fDYiT6x X-Received: by 2002:a17:903:4101:b0:1a1:dd05:39fe with SMTP id r1-20020a170903410100b001a1dd0539femr6082546pld.4.1679583714341; Thu, 23 Mar 2023 08:01:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679583714; cv=pass; d=google.com; s=arc-20160816; b=DWoGLWU8vqntWGH/N2WBR+K3/mrdSmq5IiOSq0CJsWFndRWb3b3cdzcynzdN/YI8VV DPG7rQB4yZi1VV0TOoopmTTcbdFHf5JwDVuEt6BmAmbKNQTaxYF1OHuw2iZD9OVZP0Sx 77I68o7wc5Rq6fbDpjvErVnbsiPhGYsv8WwI3Tfgk0tWJHwvMtILiIAwsYNeRQ2mpuQv la/2g47qi+LWdgZjuP9YBF8GIfzD35CHBkeA699DP7ZaoCWn9nFSlt9AHeTwFoIqH+rS 3xRxe6Xv6OOzQKooaYU7K9UZlJadKJd15pFf7vdUkrtiT92LYr+Mr+DfY/VR7GUdD+y4 l7Aw== 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=hm+Vx6MTV2jd4c9xtkF2pGG0an24ec9FXbgz+8g44Fg=; b=OyKozDNwbVhhLkv+5ofXoEysin3byZmgmtLRt7/JpNEgbEcqrfJk4FPcVdfaueNPk5 1OA7c79cw28bUNEVKVvhH4MCR2Tl9WZqoIRn4y2uzodHjuFEjUrSMm46LKi2HwS7rZyY kSQp1PYKlnG7LAEnwt0kQhcJXJN7I0I2hSjxgzHMWT/i1n4amIWxSgMBSHDFwxcE/9yd gJ3C9M5cy+uUQGKl9Ro7SsMkQCCVbkeaQfPd1U1eaT0HOd4immJfAbdQKZdxl/3j3Fke 8lWMzvacgnZ4OxTVHFC3rJR4/7zN/sT3aaJfOUeoi9E11SaFD9T+IPGFrnDqM2uucunq dHrg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=Sd8+v6gw; 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 n10-20020a654cca000000b00503e9b0490fsi19794614pgt.512.2023.03.23.08.01.40; Thu, 23 Mar 2023 08:01:54 -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=Sd8+v6gw; 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 S231888AbjCWOto (ORCPT + 99 others); Thu, 23 Mar 2023 10:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231876AbjCWOtg (ORCPT ); Thu, 23 Mar 2023 10:49:36 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2059.outbound.protection.outlook.com [40.107.8.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC07811660; Thu, 23 Mar 2023 07:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fuj3W4Md950fd5qD5aXrCXIu8j3PJUSU6X3h2I1hYtjUi/whMkCDjGSjalc4hDOcj8Cih/e2DRc3Rwe1Y6SL5dR6VBL+jsHrK58gD8ib1xIE7Y2YiL2nFcfF5ujliqBGLSkAnbwEQbA4yszmr0Ufd5gStIn74bQx8SvvMpA0v/kTkELy2Ir1sJaoFy57plmSk/b91QfVfA7kafXixhJ/tRnC4E2aJT6BCSwmpXo4ozC6SNpLAoFDLlqtSfAJmnBZM+5dcOo0R6i6zxJxn3Oz2D017mEcyrcamnMTPzibvg1Mr5rp8IN30gWwZcBMk1ZcxhZssdNkTBLzhBjUjpaPBg== 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=hm+Vx6MTV2jd4c9xtkF2pGG0an24ec9FXbgz+8g44Fg=; b=T6fCzU4vhoi8RS/8gHG4a2QWGO2S5E+NxGrsKqVebWVX4FyfUkMUiS/0uetMI6PZMm/QxfnnhIO9gHKH2z+sHFqAAAbuOTbmv27lY9QDgxYGkSzDF9GsGvlJSmDxgfburgZ55XtF24gMSEYUqNe2sZBn9Tni/E5lcEANPgDttDoLGotW377xuKfXEE9WFZIb/K+gG2JY2B7olYZvLZQi5OqOO69l3KffwMxLDBzmMIX8rnQAmJW359u7026jgt/D0r+7lAX/ijkl2CK4lmL2oAh9pgsseOkt1TUI86ytcr9zhbcC3VSEFwlxv5/K/S6cS7NUO4ak+aGRAPMJ7ykYxA== 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=hm+Vx6MTV2jd4c9xtkF2pGG0an24ec9FXbgz+8g44Fg=; b=Sd8+v6gwPhBL/MbKoWXhRA1eOeNjW8RKGxtkK4cJPwf/SQXZqwHpGD7YlQvhqbgWMTTq/wkha+2e1KfWnTm/ahy6++h1p0uZLScELxaNyln0FR1wImnAsIuXurnUczUBj5rlImLCo6yGkqeIMAHeo9WiDoFnvyEu/dTDXAKg/6eAbyCkvZs7stLVcjAYNc065ptpKjIFNr1xqP/AQs4Y9X4eWnisM8mXhfPbIM6huxrgDHX9r97YUBtM7wyZHkZiA+h4BjRvAQ+HUNhw5+6WlXb/gFpLuKH9nPzWU9NR0RL38CHJWxUAKkBokOwRtEnwdfFYyPwAKCbrQmbRpAGtcQ== 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 AS8PR04MB7544.eurprd04.prod.outlook.com (2603:10a6:20b:23f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Thu, 23 Mar 2023 14:49:27 +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; Thu, 23 Mar 2023 14:49:27 +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 v3 3/6] pinctrl: s32cc: refactor pin config parsing Date: Thu, 23 Mar 2023 22:48:30 +0800 Message-Id: <20230323144833.28562-4-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230323144833.28562-1-clin@suse.com> References: <20230323144833.28562-1-clin@suse.com> X-ClientProxiedBy: TYCP286CA0332.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:38e::18) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|AS8PR04MB7544:EE_ X-MS-Office365-Filtering-Correlation-Id: f59b9066-3cd0-4ac1-1d62-08db2badcd16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EsZ5Ycp0sWkWwXdCDL+94Fu5bcMSUrtQ74uSyQYWiMrmYgrXElxVYAVQ4LRj1Hj7VLvwKXWgXtGw11kctBfzx/sMHPEdktNSLIeUU7XWoTzYzcRgkcXaZ+KhLgij71vEjQTMpWIrgFRn+ZVIt9el7Wdi3JBwqtNa2alroKBjw57y7JTnldgvsWWQBjGzp0UeXV/Ch77HKxVtsqIVR9v5uBdW3TNp88/PBkUSUtOneZI5FVarmtwH3whCllSIV0YSxLC3Sg3bbp3U18vMrnHHFVDPXBoVOWraT4Chcm6qpNZn9fqR/cL7RotmMOkeEuaZhPXMburHdmA9OMHQuomDf9wD/3+d4GP1yG0q1GlG5l+sV9q9BV5ret+02Vhd0BJvFHdo1s2zwAPAbfOLl3MND8O8kJwiVVpqFv8/ccjETM8/r9UpeyfGH1lpDpBCCMdy5+6ok+tW7WCAABT8ykVmt82zcbmVxRaayPvL+gkAPokSVaWLabbgakGvP4Ep6CLMLIMB6BFOb0KB9kZuvzZlBe1ae1X+b8aQ5jH1Uiep/TNEckHoiXaLOg5bwlNju1SJr5NrMICtUoa0s0QMOOjk0nXw39vN1oShtMcB1QQn6vjgybzWAQujv1Q8pV+8FeDa8FGd9Oihss6JWlEIRD2J/g== 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)(396003)(136003)(366004)(39860400002)(376002)(346002)(451199018)(4326008)(66556008)(66946007)(66476007)(8676002)(110136005)(316002)(54906003)(5660300002)(7416002)(41300700001)(8936002)(1076003)(26005)(6512007)(6506007)(107886003)(6666004)(2616005)(186003)(478600001)(83380400001)(6486002)(86362001)(36756003)(38100700002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bOBLIp5xZ2Imd6GelnGUa671DPPQCnjBJFisr1xS59uwFangYhTTMhsuImehzlfUOIGRswrlUywDYBhTKuZoFk0X3S7f+w1RY2LeMlgk/RSlAAV9sj2ix7iPmZGn/4hsGARUPx7M5ze0jgb5edNQRnES3Uq8rHlHnzyhyiSjm+W4N8DtCEFOjqbQnEACa4Dv4NXYnvgvqb7YLmOK1ZTUCtlJsPF+/zs9Xdo02CmcuHxRqMfYh17QTA6VNW+MqhYrfp9k1Fvg8EIpDeoOMIpXQ2L1YkWBgzacAfLF01KrzXZynPmuQR5uPDl1jdrDOXKqgVodVk2rLjuvXCf1P1ai0Uf+GVmFIzm7suoPwHiW/khiqY+kvxX8lYNAK0AZzjZpqKcPkXlbb2HkttC2I39hflBiIrIBcoikeHwzBh0CJ+LLTTUiBjf1HPXVc9AG0cHFKKU+gsXLbVZW6VVS60qI50/Nlc+KM4k14x8ATfSHI0ERblv3ImeQLBClz7KzVBK1Wm5PBeSrxlrtg0acx6flshukCFzzixw8lTpeOSwFXjFeUNfx8gNU/UHASt175fYY2y30+jodJutbAo8PQqF4UlZNVGj3HqVY0uKtU7P5cOCHK6fJumxrknfsPGBouhTxi0M0ETea9jl8rSoU2+YSLm+JTAMmx+/IPmBrznTjuQYj+CRuSQ/uLEXswJuun8SYoJon4ssQgrwOQsV0zGYtzT5EQMfXaIqNcCBBNeUL564VT1URvS0lBwskdFj8xH5rPwFdUiu6KIktP2w3U9gErX1lxY88uYLklgB9gTIeOSEMSi878G1sFl+ZArEoQ9j+/IOgC8/1cNvEIDZTlRSJbJTIyrRQnv3jC0PJ0YkkiLU9Kl/uybqTWqyFI7Oq+VkJ304RFl2B7Vro+uDiKloqlCU3yOKWQeUAezX1s5jK3dWlh/v4sjF9S6UScgB0V0kb/6GrJu4zrRl4U0d2oqyxxZ1hCKoTk/xK6pjMAGXfzNlOzQ01ETJNmhtdJ/k3FUXYDmgFg/LBfYNOXzrypMn0FlFCcu2GSTEXW+pxPeuxz294hExthYNVgqRNvaU7LbP4QyPnzDoE6rXucuphRDFYy9WVD/TMlSgXDQ1y15gmapvLEwg1Nj34GQQNIouokFwebgjXJx2QhkdfV3UEVFeGtv+svh8rZY6PE1wcIp2O71fU7lHABzq+llvE59UUERTtMmDBfT8wpKP8ZkelQAYIuSNqVZSJuGy5nyQ9iSjE949JLri4J//vp40/SWLpoWn/wIdZ405oPVWEkzTzi5QB7zOjnhlnEFixJRzTeJsa4PYPW3xMdwkuHeBbkgPCAp21uGh9HqRsKC7tYibYVCTNQPpF27clHpUrhc2CG15OWPokk6pa8jH1nahRfwJXmYUftr53EYnNx6D2gPLs4ogYPGUiz2WypKP2mASFZHYQ6aOH7ZgSdwd60dWPF1n2F40LnU1erNBOibAFrwWgtA9PNsvsXYdIDFxg/knt1Ct7FeX74iNSOhxjYT8KOjuMQqV8YTBFkQCIxe1+gapQmf3Bx+YcKNG64PNRusDnadIcS/s= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: f59b9066-3cd0-4ac1-1d62-08db2badcd16 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 14:49:27.4422 (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: PMQ8ocR7io/rOc7wIHJg5tJeCZEfm/UZY1FzUvuGt1yZ+x6nHUMg3Za8q96f3GES X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7544 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1761171173040698204?= X-GMAIL-MSGID: =?utf-8?q?1761171173040698204?= Move common codes into smaller inline functions and remove argument checks that are not actually used by pull up/down bits in S32 MSCR register. Signed-off-by: Chester Lin Reviewed-by: Andy Shevchenko --- Changes v3: - Move the PIN_CONFIG_BIAS_DISABLE case to be with PU and PD cases since they have the same function call. - Roll back the argument checks of OUTPUT_ENABLE and INPUT_ENABLE cases since they were wrongly removed with the PU & PD parts in v2. drivers/pinctrl/nxp/pinctrl-s32cc.c | 52 ++++++++++++++++++----------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index f698e1a240ef..36f323f87785 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: @@ -508,26 +535,15 @@ static int s32_get_pin_conf(enum pin_config_param param, u32 arg, *config |= S32_MSCR_SRE((u32)ret); *mask |= S32_MSCR_SRE(~0); break; + case PIN_CONFIG_BIAS_DISABLE: 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; - 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 +569,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; } From patchwork Thu Mar 23 14:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 74096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2959813wrt; Thu, 23 Mar 2023 08:00:40 -0700 (PDT) X-Google-Smtp-Source: AK7set/e0xQy5f/wj7i9FV+7iQr9/1fprBu0/yL8sR9DCucq+zi5NbSaALrmMPh5DVcmNvHW8GgM X-Received: by 2002:a17:903:27cb:b0:1a0:7508:dae6 with SMTP id km11-20020a17090327cb00b001a07508dae6mr5871894plb.63.1679583640323; Thu, 23 Mar 2023 08:00:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679583640; cv=pass; d=google.com; s=arc-20160816; b=0R1BnPljLur/U3SRceykVw8xBEZr95ilhzws75YBcoIWdleXbD6xLs5fii7wmS/HIM 7AiNd3t4FfK55ulErVTxZZZZh+WrF24C/44m+0TQEc6FvJA6Iy87/WyJ4wN/b6qppmO6 EIFA0WDctT6CdGNR4h9tDYI+pzwxX203wzM4LE+kHhq7mQPWKDKij4zFSUCcpTpVy0K4 2O10DuZQVJ4y1lQpr6/10RyLQ7pKY0z8QYOW4btLlMEu5+DeRv612X7IzFUq3Pkedr/A bDoi8h4CYIl0AYF6YGpVzWhfjb2J7KjzBWvogVvccVHdp1cij2krOt/BE/RHufKf5Jst zFRQ== 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=YPHjBpbyjqpZdYucP8HA6SoZjt7wrYl9ZeRBprvTChA=; b=fgDVFTvFngkFAYnf2kD0RVeNiXwdb51j5VWGnpOcWg7LK7hFuabIDOGHLm6uzaYLSq kQ9eC29Wk2szAOrWWFS3ehn/dH/Oy8bXC1b54pwiGShP3AIO9YJ1he9Klbb7PmxKVkxt HpKJIJOBttu4cTi/+iTwyabluM9YlfRK+SHu7qhHbXNzpfTxZKfcOPGMlscJvmveMhbj GBX37GEpxzF55WU9UxhOeGA2ewrW7S1v4gvzbU/D017MaaJJ2BR+d782g1Lrr+RWGMva EJEQKdWeiS9u/C3Zn48zf3hne9L7/Qe8FjCVOy9vMgJiRFdyrVQqlWyrqmYQXcSqI8XD 7k+w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=UwkqAC7U; 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 f13-20020a65400d000000b0050c0e269719si17906321pgp.513.2023.03.23.08.00.20; Thu, 23 Mar 2023 08:00:40 -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=UwkqAC7U; 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 S231897AbjCWOuM (ORCPT + 99 others); Thu, 23 Mar 2023 10:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbjCWOuH (ORCPT ); Thu, 23 Mar 2023 10:50:07 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2073.outbound.protection.outlook.com [40.107.13.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA5E7EC54; Thu, 23 Mar 2023 07:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K68DjeHnAteFebQ99cU3PVQTs3BcieWZ6dZ7gP8sk3VCkyRPcJvvTGGuMkMqL9GuAjayBKYO8JAlz648ZDVatCxC4R5354xjWS1pxSGPqMHqU9CYKYWhsrsXqnnciZco7DDIQXFcR77b+EX5gXoZmp1MmepyeQbRwMiBODRwmt7BI39Rcb5DckjOTj7VVEestcayoM4OsDkoLTE+GidMlpcuvJ4RJKiXGHzsznT/pCZ4HnfCCWjsujf5uglACCT3gWSVV707JgtRhJeyEToyNVb6dlEZje9aA0mfE53WSCAolj29/vKXoo5+1QtlM1mPrgUrRxIXWeOM8cdsE/QjxA== 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=YPHjBpbyjqpZdYucP8HA6SoZjt7wrYl9ZeRBprvTChA=; b=ionni5yFjUH6rtqC+dSqFRyIXOl6DpiTFH+Rm4bkWNuyJXwy7Kg77XxsAJbuV46HtraBqBZsBoxAh8c75SIR2/NrY4nbz2Q1bFAfcXfsFYR7cLqA9n7KzgK0TAosUBLSvQCnaVPj/3BGDVga6WA3RJ7JgtptN65I9efHzSMWTrRV6cyvtrKFyhHYeD/im6R1+cDi02ttei/6pZrx+5vRiQe4Da+hFIsNXz9jaXLLl4z9V4Uc7X1+9ViEL2Kmc1Sx+5iXx1mPfu5PbQSIxOHJWNovJWQpxWhrBN+4rKM58giYJc5tfd9oL6OBLSYLHWsXGzlcCjdAzHMhnc66IJroZg== 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=YPHjBpbyjqpZdYucP8HA6SoZjt7wrYl9ZeRBprvTChA=; b=UwkqAC7UlSiRLlPM421F30zhzD/OePLC5nLxjtk53HpFgB9qVfuFdVS//eM7RXpOTw/VByTSw1eeQnCT4uYP9CC1IXONM86uNKbcgIUW0XERVW9SAJkqLfdvdr95VLf45IfP3lZNkKWmWCuOySi02o9bnbOIaxlHLeJzTeyX7bCkLvyo92Vve+cdPEtS6xc6miBq8IwVFPGQjJu6scpJQe0PjjO1Cr4sJPWMdysNdgxP/oBoSwDGO31eBu+64aTOcNQhX6PKqG8qkUNZyZxTSgAvI0U8oV/bw4M/LdqvQ1xAhm8X3ufkak0Z28IlhOiWoH3tkfmBxc2JuAJzoII2+Q== 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 PAXPR04MB9254.eurprd04.prod.outlook.com (2603:10a6:102:2bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Thu, 23 Mar 2023 14:49:44 +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; Thu, 23 Mar 2023 14:49:44 +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 v3 5/6] pinctrl: s32cc: Use generic struct data to describe pin function Date: Thu, 23 Mar 2023 22:48:32 +0800 Message-Id: <20230323144833.28562-6-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230323144833.28562-1-clin@suse.com> References: <20230323144833.28562-1-clin@suse.com> X-ClientProxiedBy: TYCP286CA0343.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:38e::11) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|PAXPR04MB9254:EE_ X-MS-Office365-Filtering-Correlation-Id: 82adb6c0-8611-4115-9c9f-08db2badd70a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w8aWPrRQggVFxedVCl6hzOye8r3WnkDQmr41C6fBxFBKDOk5EJHDu82fYC1gPwq8XFyPAA6EPOsPPPIU5OwQoa7eAaufyGDakkcusLRYWcBiPmnA1TOQB2GqzjfGRR/qOnW6u++2/IjvLFP3Q4F9Ze+2YISU3oUBn+JEtggZ0sb5BVZdMIAzen8+qjcZMm2EKyWOvHyipHnwgDNMrELM8ypeN3BO5V810Z7KAhMrCXsleBTOuW6NpRbUDiUY4iEjuRktAJBBdNb640EqCLuO7om3es/tYVPWREQyrYbGsXBVeUWV06/1jaGURYiviOnPe1EnJIImZRoGwgSyQC6yTayaYXZTfNqsmeHe0TDUsMXqvW2Oi7AuI5RE9GUhZI0xKElDD66kBs/NpBtjKspCxlGK9wHO5OOeMNmAtDv/DWgwwi6XmL9WT9lmrtbsV24c4yK3qX1kUzE8e9xdXtFEsjgb/mG0Z1LSNrrA83OEyK3yORbFRGs3kR48kkQwx9JMLZLVZKgX913l0spk+z/jRJa6VYIsTF4Y3rOU3JzpqRwJbjTivMMWe1PvlbDTcNjeuAy0xsJO1kUo905/cN0SWUmhsvTpTuYGP9R1fZx+ZcyV1haqMhm/1yBfj16QbT2SCG8qBsccSsem0gkNL/h4ALBGADgJz//S4OLD3z6/WuzQgJlBJKWylq8KiWtGTtue 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)(396003)(136003)(39860400002)(346002)(376002)(366004)(451199018)(4326008)(66476007)(8676002)(66556008)(66946007)(316002)(110136005)(54906003)(5660300002)(7416002)(41300700001)(8936002)(6512007)(6506007)(1076003)(26005)(107886003)(6666004)(2616005)(186003)(83380400001)(478600001)(6486002)(86362001)(36756003)(38100700002)(2906002)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8n6QPhWcFA+BtNYB0yJ6iSme1XTr9lrOioRp821tNksTVOhSaYh2uwM+p8wK8YCpjbYB/9+lKAkrYCZb+1xqm2H2Ddx463CFlKNmgAQtnIstynPCx6pmRg1P5FaZK8BX8dasg/aK9eh5EPt/fi7//OR7Nu2ruBZU90uE8Lwc2PhHnuSxl7QSwX94dQ3rtia8MZmjSN+t8iiWU6IuNRGB2HSfBRdWAP+rWFGpkYqgjBlrnS3AlOQ7xys3YBmlBL/sSIOb265jSK6cc1aECAExXZauogdRj7krmM961lBFvkX9sb+/oeab3sZ1DKCBuwoNrSN65nPz6qzkviqOWJdJhfo9d/Kn9OXNH8yIWgS584Fjzw49R6QkazXYbMHHyaJASG39t08GDApUx8E10y16GUzIX80t4Efj8onZcVZse0mjI+4daLHFGaXbgagmwFDClEhx6hnql92TzAFGGZKCCceGxMpY9kJEDynDLpsr27w6s8y/qrrdAtGy/AgXR1mjmTqZeWTxmCVg9PYzRM3+sKIdKCRFg3fdtMYJepXXEO84902U9dPdOAbb35iHfgJhJ2gT1fNe0+kwjncNATLzxmq27ABUtSnUWqoxcIpeEZTiEnYMM/WmWfanYeh8KhgRHbxUUrPjPxJ/DyJjO/e+ropwxXvBy8hHWK3sJuTo/XbcKvzLEYHVLqOup2ljkj5RWXbAkSYNqAdLNTXDrTFtI9xuivJwWIRqKzIrs91d2NWqSVoyOoXSZcPL8C/NiYb5bAZVS7CqTr4wqBwZsRDEQImQ1mVusA5M+sfQZ1OJyCfZQM0LR01SSD1x8khs2i2m21fcB5bsFMpg9E4k1hsDf2me/eR0ngSaZgafO4+N9d+YnwPYGwmiad7x+yvfhzLa7oksLZAouREpPLDr6S98TLzBAntHF1yJclgwyYM2w+HirzavIMQKSz5/rFiCtjzTlnWAj7L0urLrO7apdgShyu0NB7Ak0snYq5KVTWfCKzEjOmg2Rzhrvqf+PRuR76pI0N7TNvLKGFbXVbsoFzjCiNruHJCyr3iTVtQiVCBKZ20/0Vjdw9T4CULe9uMIcVcPo4sGn0M6Ej5nzlFpmaH0VhoWALQ8G8UrNsYvqiS2Us+lIgmQkMoprq+2QwrUhLGgzX2cjViWE4hsYSnbHcnIMFpY8rtgwzZwhqOGfHX0VKmsv7KA+Y0osRhvrtbXClWy5y4k7Qk6Qkwf/4CRcLxgAVmiVqqU9I7d+5ov1YLdulMiNqD6/nYlauyCaIf2WMWbLL5eWaJtj9S1nWYzEIRNGetxnvrsq+egdsB6UHlgN3LkV+03Pc7t1zXnyft3fl6mQAZvMcWcoBY8uw5DdNevriT6vEe2FBNGBgSqWw2fxQR5kpdXdz+3CYiKAPTVk0y6S5G+PYenpDRT9fw++Mv59pOLsD88Wj42l0OGcoUPkXzdCWlkC4TTOBSSJga7/AnN8qrvGHQSu3AjiFbJJKLz9hOvEjPMCJaV08omfoULUk4g/VSA5D/6tzh9/jAVgltpjPC+N/KP7bIUgQ4FLp8ZrAJCqOQR0xsLx3vOr0FKU/o= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82adb6c0-8611-4115-9c9f-08db2badd70a X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 14:49:44.4721 (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: mO2GH/Gi+nMJwlPU3+PEWPmH6BjdeBkv1uPx29i+8jXiGar7kJmQFQ0T4tIqmykY X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9254 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1761171095021394263?= X-GMAIL-MSGID: =?utf-8?q?1761171095021394263?= Replace struct s32_pmx_func with generic struct pinfunction since they have the same data fields. Suggested-by: Andy Shevchenko Signed-off-by: Chester Lin Reviewed-by: Andy Shevchenko --- Changes in v3: - Separate the generic pinfunction patch from [PATCH v2 4/4] - Fix the data type declaration and remove unncessary type casting developed in v2. drivers/pinctrl/nxp/pinctrl-s32.h | 14 +------------- drivers/pinctrl/nxp/pinctrl-s32cc.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32.h b/drivers/pinctrl/nxp/pinctrl-s32.h index 850cd668f406..2f7aecd462e4 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32.h +++ b/drivers/pinctrl/nxp/pinctrl-s32.h @@ -24,18 +24,6 @@ struct s32_pin_group { unsigned int *pin_sss; }; -/** - * struct s32_pmx_func - describes S32 pinmux functions - * @name: the name of this specific function - * @groups: corresponding pin groups - * @num_groups: the number of groups - */ -struct s32_pmx_func { - const char *name; - const char **groups; - unsigned int num_groups; -}; - /** * struct s32_pin_range - pin ID range for each memory region. * @start: start pin ID @@ -52,7 +40,7 @@ struct s32_pinctrl_soc_info { unsigned int npins; struct s32_pin_group *groups; unsigned int ngroups; - struct s32_pmx_func *functions; + struct pinfunction *functions; unsigned int nfunctions; unsigned int grp_index; const struct s32_pin_range *mem_pin_ranges; diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index e65c88162d7f..8373468719b6 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32cc.c +++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c @@ -364,7 +364,7 @@ static int s32_pmx_get_groups(struct pinctrl_dev *pctldev, const struct s32_pinctrl_soc_info *info = ipctl->info; *groups = info->functions[selector].groups; - *num_groups = info->functions[selector].num_groups; + *num_groups = info->functions[selector].ngroups; return 0; } @@ -785,8 +785,9 @@ static int s32_pinctrl_parse_functions(struct device_node *np, u32 index) { struct device_node *child; - struct s32_pmx_func *func; + struct pinfunction *func; struct s32_pin_group *grp; + const char **groups; u32 i = 0; int ret = 0; @@ -796,18 +797,19 @@ static int s32_pinctrl_parse_functions(struct device_node *np, /* Initialise function */ func->name = np->name; - func->num_groups = of_get_child_count(np); - if (func->num_groups == 0) { + func->ngroups = of_get_child_count(np); + if (func->ngroups == 0) { dev_err(info->dev, "no groups defined in %pOF\n", np); return -EINVAL; } - func->groups = devm_kcalloc(info->dev, func->num_groups, + + groups = devm_kcalloc(info->dev, func->ngroups, sizeof(*func->groups), GFP_KERNEL); - if (!func->groups) + if (!groups) return -ENOMEM; for_each_child_of_node(np, child) { - func->groups[i] = child->name; + groups[i] = child->name; grp = &info->groups[info->grp_index++]; ret = s32_pinctrl_parse_groups(child, grp, info); if (ret) @@ -815,6 +817,8 @@ static int s32_pinctrl_parse_functions(struct device_node *np, i++; } + func->groups = groups; + return 0; } From patchwork Thu Mar 23 14:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 74099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2961705wrt; Thu, 23 Mar 2023 08:02:58 -0700 (PDT) X-Google-Smtp-Source: AK7set/rOM8SIN1DdPoQd1UG+QYZtA9MzyHXTxWtAOqSOowBDgwaM+iwdXl+q1jxPuBVic+eBnNz X-Received: by 2002:a05:6a20:c746:b0:d9:2cef:949f with SMTP id hj6-20020a056a20c74600b000d92cef949fmr3051514pzb.40.1679583778211; Thu, 23 Mar 2023 08:02:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679583778; cv=pass; d=google.com; s=arc-20160816; b=qWjIY2Odg+UZD00CkzPIHnrhurBTIVPPMASfDgAKta87FWS06S80Z6gHJ91ha1qAAq kjDVqA2t/+dK/pBSM2BmIf/ArbAMHanya0lmjGQfemGwD6NlkIo9j4+in1RXExiks7Gl Zm+PD4Kx+b/ZpTbyxNc9AC2UjRlKXeVVEyAKMZTizeyZqNwA3biBZy6Rql3ErrXBCYqS 2Qwu8ofLtjUfSUHfGODNIgJSufL/mF+/LvIasTfnz/p9VaUm5nH09XL4RuKLlPh/oYX4 DA4lE4j0s1FKmuS+/azNwgMGNoXwDlCD0yyLiNT39yRGBEm8oePD1eeUMXJBb6ahQHcZ mxRA== 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=j0PWgupYOZLX8O33zYdT2WcS8EVIDjigMriWTCCCE1U=; b=YLeOWxgC/ntaTKcaWSGCj6xmr29JH/uBvOJLVA5GIxdSNYAUkz/roxD0NmwQKiA+AW QAR2ebzzxpOfUn+Lp9aJ6wuGKQhpl9vk/tag/L6qwxAZl5rAfiqImSTcXa+UL4SNpZM1 7L7tey19JHRu/SKD0y7LYHyVBZlxxzA+qEqZZz6PRwBUlfyJ71GwaWk4t0aRB5Kz30Qt tor+gHOCISTqojbHd2bpSA6RlCiPUUxqxlqGvUrkycPDNyTVU54JlsxGcpJDKavWK24D sq6/I14rAYVbTGTZyqrzRaEEQpflG51jyTdJzh672krLcqfuU86ESo3H3ce5BUMMKhm7 ub2A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=LaFD1V6S; 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 b24-20020a63d818000000b0050bebbffdc3si18514294pgh.98.2023.03.23.08.02.37; Thu, 23 Mar 2023 08:02:58 -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=LaFD1V6S; 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 S231902AbjCWOuc (ORCPT + 99 others); Thu, 23 Mar 2023 10:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231923AbjCWOu2 (ORCPT ); Thu, 23 Mar 2023 10:50:28 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2073.outbound.protection.outlook.com [40.107.13.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80604EF8C; Thu, 23 Mar 2023 07:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jqUayn79HBUItgfIOB94WSvz3dszJ+x+u5Ljx+Cha/p0wPH5yUHS2/QlPC3F0RrZoPRpYmY8rjG4LF6Vgqqvgx91uZAwzDFpPOMJELZCBALWr4CIVikTs86QOAaUx+R65NNIoeWSmd8TWSgcY3ZyrBbeBIko+eFqHeO5xxkQNs2jTPHoSsGy1gVW7gaXf6fb+gZZgVF7Y+G4S0lsfMKucIS2Y1DXOwd47QyvMeyvt2psOYxXbHaXEyfnAEpcXKaHzxpQbr4OGPDeKFnMs/3UNzhxmYZZwHfCkJBGhso+2H4r56u/1cZta2gkx2a+LHy49ny4Pd40QWVJArxRwXNSAw== 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=j0PWgupYOZLX8O33zYdT2WcS8EVIDjigMriWTCCCE1U=; b=A4MJq1q3z4Zzi/KcPL3/NDtMOgDThOkCZtMGrQfKaNg2NSmu+kID6+WcKPUrFTt8SkwRrIiy0VfCkyhONgJ6HTkz0nIyz50Ri2W5U6HJfeUqgbzLGIVgca4S7QNxDo7QoxG4EUF0FXeYUCGmqJnCluuxqgHyZZiW/M4SG+byUBaa1Z1/slX3SR/OknDeR0Y7qiKFBl021vuM9V8wF+YuZeISA3bWLwm1UU4qGxWWLxZyPXxT3LmbFgfzkvA4SHoyiIQ7ARyerR/ReeAeq5HipYg1kcOhWHWQ9ECFyn21civT9XFDZB8UTDW5JSxciuVCZQEYkxsLCnceY6+o+GXr8w== 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=j0PWgupYOZLX8O33zYdT2WcS8EVIDjigMriWTCCCE1U=; b=LaFD1V6SkAUmry+HhPR+31/YsXx43BlwSkKPm0/vgtrRFN9f9fMg4BWW2s/FJOiyhwFHuEKu886zx3VLbY64EQtw4hw3zWrLroHgM8uWFQA8lmL9Q1ar+jLL2o6yg7G9EbPD9xueUHgkk5+mac1EB4N7cXMazv7tvurB/m7PWQtCU3AsFtOGs/1KcdhGMK9yJNnpanQq5jiVzPL2/xGLBwky9ckO65HRcx7RukO+alau4Egw3Us9r4yvqYHISeTxjh3xEre1J2QLNRby8tfGreTfLCLa/t8Zvh9qVDVEdVF4rHBYLcwS5V0TgMUbk4jBYmLn1olrJLbLKnvX1KLP9g== 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 PAXPR04MB9254.eurprd04.prod.outlook.com (2603:10a6:102:2bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Thu, 23 Mar 2023 14:49:54 +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; Thu, 23 Mar 2023 14:49:54 +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 v3 6/6] pinctrl: s32: separate const device data from struct s32_pinctrl_soc_info Date: Thu, 23 Mar 2023 22:48:33 +0800 Message-Id: <20230323144833.28562-7-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230323144833.28562-1-clin@suse.com> References: <20230323144833.28562-1-clin@suse.com> X-ClientProxiedBy: TYCP286CA0345.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:38e::6) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|PAXPR04MB9254:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b2b06d9-a5c8-40b4-d984-08db2baddcd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LPw1Rts/f5cq5HKoq4wggemKxVK2dwHh7rWgGyrmjqSJtwMJJzNzloM0PlsP8sP0RNBDkAxX7Lc+mO9ovLMtrkS4TATk67LR53Ho32aznhG2sQWFrPh6xE/hMYIhFJNJP17Lt9aQg76TIABJ+36M09QipCr/TcGvWiRCGaABlc5txKfBGQzgCt0u8ZzPRO8d2KJ5xLH1kNYyplr+xrpNkPgOrrjll1Oc1MEJhBj/TPmlJLAGwIxze29/u8xB3jInD2fycxTW0orjGINNViok/nEiA1mB2rMZUG1WPWGakoubuq9x/8/hHPiU5QHvG0UxLLITZcpY3Jbop2VuCMrozbURYdgg/4ABFqZWNoK8OCb4VBQa46CzTxN5OrxusU59mX1TkAFaPZ3xKNrvVO1lLSU58H4ujNCJm+HFQM41RCdQaYGsiBu4IE5qGiBFYb/GBPwcIN+hbK+iAt5hXTvi2FD89PZ39s7RKIP6uuc9GGuZu2/DRIN77ItFEi7T7vko8o5uiOLqURjUm6+3KFDDqbMUZCI9tgdqRq3/b+nROf7ERqxoNuia0lk5Nqpn0Pvyoil1uqgXT4XVz48+0DDHlXilxzie3sSGXz2ukHYxxZ+btKRZ3+fN2Tlb7zos6ipORd9EiJWPx8/Z2rnfBvsXvw== 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)(396003)(136003)(39860400002)(346002)(376002)(366004)(451199018)(4326008)(66476007)(8676002)(66556008)(66946007)(316002)(110136005)(54906003)(5660300002)(7416002)(41300700001)(8936002)(6512007)(6506007)(1076003)(26005)(107886003)(6666004)(2616005)(186003)(83380400001)(478600001)(6486002)(86362001)(36756003)(38100700002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q5pmYUrDlHpbqHkRBVihiJhMwczBFbdiHKRCw0VBUcNAwwIqE4toeERqlNfVNzqI30EN2gKu3MwtSdF+Ckfj4WQJSXJTNJH+bxat46HlPPbDGM9Xu2VWxqjUoH2MGhxXTPF1vMJTiaZc232DYLOE3M3amJxTIECrxe3duetI9/E7FCN9ULML/3HtoTuKttp3KbYKt3DVqHQ+fgV+I83MP46ZoLyYG9DeQ4loYCCG8M1LEXh/zochP5cc6EpQQbazPBCpx7yVhKP4Z7ZzSFjKEo/sPotnmqzFonvOwFSmBd4OEMXwHk2uj04aEv7UN0DA+MaJqBaBAZth2ez8WVJlq5gQM3W2OnbRMGZwpAEmx+m1su0PJTM45OolCS5rzqXOxbnzblIyehExECSchwhRlKwMtgDX74+Vtin6hQghdU0fhTBSgc/Px7AqdIlg4QH3fJTV8OnUg5oQz4dAPCKKoMF9UyBIxIH4jQpFFtJJJ0z/hr6ERWj8Hfrn4qncVir1tcAAYHyZ+PRElGo/GS2GgMKFt4knFCb8F+sLUC+EgZMMQkidWVxhGj9el0EWWyLroDeNgGepgqbGexnNQKCCdjkIVSsU8Qe6+POYzZJ6UMipQlMJ4h7dPyOXL4F1weSPiGMNm+Is5F6kSc6ntuh7FcBcHcPMkd3ce+HpAIv7Cd/4avzh38fGXvYfyxaEfhbxdZMyhxxhVkMDp40VQpsCHqP1XxHdNbJwwov7BaJL8eLmOVJnXVw9x+10/boxeZigH8a/Vcw8/armXwZvIhNiFwD2h6FUs29pT8ugHLMdyul22XWNXqq8oje3WZzBpJ4J30DqEJAAmfoQoDOooNXLb94Ez6hXQ6tBgGmMsdc+ELY78s43USzOlENwGimSu6jPCnu49YK3q0S1gORobFUJf+xdqODcO54SiPbxpg1RHzI0J3Sg11TT7IcAuQU/DeD04TKNLX6E2gBa5hw36YWx8APJQm0Ve7Mo7hh35fOwNrCAO97/QOpADN864Qu//T+mXNEj2UTCnGhxPjFjYQdTtlhQAxn72sHDoFHPV2CdFeNxuJnh8CyM2dqU8OMCrB1UVUvwmbTvEADz8helu+WSMxV5QxO+Yb3bcM7tWtrdTVZJuouFQZufkY5ZAvgqk9BV/czXmMChG2eTn5QvNhuGbD0AdJrgoU4eToT6DQajO6WPQd6EL+/fdi2LT74/gDapTKey0PwP4wTNJt9Xr6tofLN8e/aJK+kZBpaSdUE65i2a3tKduNuxq5gAtwrwC/ccSF0WTZBzatH/5pHskBGAbcFmCXpcIR3KGpocSawnUJC31UA8RJQEs70cMoAySOttOsYLAdXxYW819cOqY4KrfEZh7W2XaX8VGGyFlH+oBikJ7PKk1wT4gZdjliQ0iSI5O08XKLrN6Qyhs6cpO/ML+WhhUrwgJUCLrykp3JnkqtxDqtBTH0d7+xdfEuqLgLRNK6AIFLCropzpItJGP7i167eLtpx7cXJGjagFKJ3jCGnCXod0+/Jm8G/4ONqmNwUSWR/2ggIaj1UpXiFrpjOm3mnYZG9B3MDMIv0X2sGCSSE= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b2b06d9-a5c8-40b4-d984-08db2baddcd7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 14:49:53.9402 (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: i9csOiru6pkro16Rel9yJOGICKxR8RN3OatvVyL6VZLcuZvZP8a6w3mPcZ2ZmFmG X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9254 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1761171239513420838?= X-GMAIL-MSGID: =?utf-8?q?1761171239513420838?= The .data field in struct of_device_id is used as a const member so it's inappropriate to attach struct s32_pinctrl_soc_info with of_device_id because some members in s32_pinctrl_soc_info need to be filled by pinctrl-s32cc at runtime. For this reason, struct s32_pinctrl_soc_info must be allocated in pinctrl-s32cc and then create a new struct s32_pinctrl_soc_data in order to represent const .data in of_device_id. To combine these two structures, a s32_pinctrl_soc_data pointer is introduced in s32_pinctrl_soc_info. Signed-off-by: Chester Lin --- (Initial version in v3) drivers/pinctrl/nxp/pinctrl-s32.h | 14 +++++++++----- drivers/pinctrl/nxp/pinctrl-s32cc.c | 30 +++++++++++++++++------------ drivers/pinctrl/nxp/pinctrl-s32g2.c | 10 +++++----- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32.h b/drivers/pinctrl/nxp/pinctrl-s32.h index 2f7aecd462e4..add3c77ddfed 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32.h +++ b/drivers/pinctrl/nxp/pinctrl-s32.h @@ -34,24 +34,28 @@ struct s32_pin_range { unsigned int end; }; -struct s32_pinctrl_soc_info { - struct device *dev; +struct s32_pinctrl_soc_data { const struct pinctrl_pin_desc *pins; unsigned int npins; + const struct s32_pin_range *mem_pin_ranges; + unsigned int mem_regions; +}; + +struct s32_pinctrl_soc_info { + struct device *dev; + const struct s32_pinctrl_soc_data *soc_data; struct s32_pin_group *groups; unsigned int ngroups; struct pinfunction *functions; unsigned int nfunctions; unsigned int grp_index; - const struct s32_pin_range *mem_pin_ranges; - unsigned int mem_regions; }; #define S32_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin) #define S32_PIN_RANGE(_start, _end) { .start = _start, .end = _end } int s32_pinctrl_probe(struct platform_device *pdev, - struct s32_pinctrl_soc_info *info); + const struct s32_pinctrl_soc_data *soc_data); int s32_pinctrl_resume(struct device *dev); int s32_pinctrl_suspend(struct device *dev); #endif /* __DRIVERS_PINCTRL_S32_H */ diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index 8373468719b6..41e024160f36 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32cc.c +++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c @@ -106,7 +106,7 @@ s32_get_region(struct pinctrl_dev *pctldev, unsigned int pin) { struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); const struct s32_pin_range *pin_range; - unsigned int mem_regions = ipctl->info->mem_regions; + unsigned int mem_regions = ipctl->info->soc_data->mem_regions; unsigned int i; for (i = 0; i < mem_regions; i++) { @@ -688,8 +688,8 @@ int s32_pinctrl_suspend(struct device *dev) int ret; unsigned int config; - for (i = 0; i < info->npins; i++) { - pin = &info->pins[i]; + for (i = 0; i < info->soc_data->npins; i++) { + pin = &info->soc_data->pins[i]; if (!s32_pinctrl_should_save(ipctl, pin->number)) continue; @@ -713,8 +713,8 @@ int s32_pinctrl_resume(struct device *dev) struct s32_pinctrl_context *saved_context = &ipctl->saved_context; int ret, i; - for (i = 0; i < info->npins; i++) { - pin = &info->pins[i]; + for (i = 0; i < info->soc_data->npins; i++) { + pin = &info->soc_data->pins[i]; if (!s32_pinctrl_should_save(ipctl, pin->number)) continue; @@ -831,7 +831,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, struct resource *res; struct regmap *map; void __iomem *base; - int mem_regions = info->mem_regions; + unsigned int mem_regions = info->soc_data->mem_regions; int ret; u32 nfuncs = 0; u32 i = 0; @@ -869,7 +869,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, } ipctl->regions[i].map = map; - ipctl->regions[i].pin_range = &info->mem_pin_ranges[i]; + ipctl->regions[i].pin_range = &info->soc_data->mem_pin_ranges[i]; } nfuncs = of_get_child_count(np); @@ -904,20 +904,26 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, } int s32_pinctrl_probe(struct platform_device *pdev, - struct s32_pinctrl_soc_info *info) + const struct s32_pinctrl_soc_data *soc_data) { struct s32_pinctrl *ipctl; int ret; struct pinctrl_desc *s32_pinctrl_desc; + struct s32_pinctrl_soc_info *info; #ifdef CONFIG_PM_SLEEP struct s32_pinctrl_context *saved_context; #endif - if (!info || !info->pins || !info->npins) { + if (!soc_data || !soc_data->pins || !soc_data->npins) { dev_err(&pdev->dev, "wrong pinctrl info\n"); return -EINVAL; } + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->soc_data = soc_data; info->dev = &pdev->dev; /* Create state holders etc for this driver */ @@ -938,8 +944,8 @@ int s32_pinctrl_probe(struct platform_device *pdev, return -ENOMEM; s32_pinctrl_desc->name = dev_name(&pdev->dev); - s32_pinctrl_desc->pins = info->pins; - s32_pinctrl_desc->npins = info->npins; + s32_pinctrl_desc->pins = info->soc_data->pins; + s32_pinctrl_desc->npins = info->soc_data->npins; s32_pinctrl_desc->pctlops = &s32_pctrl_ops; s32_pinctrl_desc->pmxops = &s32_pmx_ops; s32_pinctrl_desc->confops = &s32_pinconf_ops; @@ -960,7 +966,7 @@ int s32_pinctrl_probe(struct platform_device *pdev, #ifdef CONFIG_PM_SLEEP saved_context = &ipctl->saved_context; saved_context->pads = - devm_kcalloc(&pdev->dev, info->npins, + devm_kcalloc(&pdev->dev, info->soc_data->npins, sizeof(*saved_context->pads), GFP_KERNEL); if (!saved_context->pads) diff --git a/drivers/pinctrl/nxp/pinctrl-s32g2.c b/drivers/pinctrl/nxp/pinctrl-s32g2.c index 9124c6c5e5d4..e0944c071c8c 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32g2.c +++ b/drivers/pinctrl/nxp/pinctrl-s32g2.c @@ -721,7 +721,7 @@ static const struct s32_pin_range s32_pin_ranges_siul2[] = { S32_PIN_RANGE(942, 1007), }; -static struct s32_pinctrl_soc_info s32_pinctrl_info = { +static struct s32_pinctrl_soc_data s32_pinctrl_data = { .pins = s32_pinctrl_pads_siul2, .npins = ARRAY_SIZE(s32_pinctrl_pads_siul2), .mem_pin_ranges = s32_pin_ranges_siul2, @@ -732,7 +732,7 @@ static const struct of_device_id s32_pinctrl_of_match[] = { { .compatible = "nxp,s32g2-siul2-pinctrl", - .data = (void *) &s32_pinctrl_info, + .data = (void *) &s32_pinctrl_data, }, { /* sentinel */ } }; @@ -740,11 +740,11 @@ MODULE_DEVICE_TABLE(of, s32_pinctrl_of_match); static int s32g_pinctrl_probe(struct platform_device *pdev) { - const struct s32_pinctrl_soc_info *info; + const struct s32_pinctrl_soc_data *soc_data; - info = of_device_get_match_data(&pdev->dev); + soc_data = of_device_get_match_data(&pdev->dev); - return s32_pinctrl_probe(pdev, info); + return s32_pinctrl_probe(pdev, soc_data); } static const struct dev_pm_ops s32g_pinctrl_pm_ops = {