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: 13181597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F5AEC761AF for ; Mon, 20 Mar 2023 16:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WoxcnoVS5kR52yV6vDJwK1IDDpfmB0TuTbSqffgoj3g=; b=pLNfV5Xq/i94Tn cc41rLDpOUXfObT2s8eVvNtp0pYCG9/Hy/EHUERITWJU6p/+TmL5h3YI2vlCOySn7adRGxMJQMQsy yGoMgk5hEHYsYnxqAermpEEf9mJGYGuI27YFnV/2LG9/WxM7dXj2bbHK1Bpl/J+Vk9rm7OyUOmgBu bfQvk1T3XC41k1MLONmE6fVyEr7qYpwIWtqza7zrkM9aunAi7awuSHU9LWTVtI1eQDfHmqBDjqLWa 7oOaplIqF7kcTEH8JBluAj+skUXmHkZ9zJyn2zTsVrtzfW+s2CFsr2GzEa6yGgZu34nqbOftpIn5N bxjYaSkB6UUpjJmxOfFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peIXS-009pPU-3C; Mon, 20 Mar 2023 16:39:15 +0000 Received: from mail-vi1eur05on20603.outbound.protection.outlook.com ([2a01:111:f400:7d00::603] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peIXQ-009pO8-1T for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 16:39:13 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230320_093912_499233_B01D8ED5 X-CRM114-Status: GOOD ( 10.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13181649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBDD4C7618A for ; Mon, 20 Mar 2023 17:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=06JX59n+vx3Rto4EEu38uUW+R4Vl5sMvMqY1CHSiGWs=; b=Snv0wyd4m25aah jPEKpgzONJCpiPvd8tacHoxjPmLhDQgcz1vQDL6AuUwzOjrbYEar7spaKh9uAk2VsfhjRHA2vLlEY PMwXd9pmJIywsNl3cOE6HLMezBYIb6SlwX7tQuSjomVjxeeQ2R+61RvznhJIwmTDkfCHEyJWVU2Z/ +lHxQkF1JldxFWAyQ+riXRaAgOdzWgGcanhQtkfVt2Wir3tx1CPqtV4prmO0Q4ZCsto53/t4tKWVU rOEpdYtOM5PKjH0tR006lKv0Cbi9dy/DFok0ztBEyWeUEgbmHjXPrcICMsiVEQiYnv420mqr5fHRs KjLPViKNvCcP/oNqffng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peJZQ-00A1Zl-0d; Mon, 20 Mar 2023 17:45:20 +0000 Received: from mail-vi1eur05on20616.outbound.protection.outlook.com ([2a01:111:f400:7d00::616] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peIXp-009pZj-0T for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 16:39:42 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230320_093937_372384_68980B06 X-CRM114-Status: GOOD ( 23.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13181598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE633C7618A for ; Mon, 20 Mar 2023 16:40:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TVeGZeeY0vvc1EGcNNHE04oGhscmGRh6DWE242WCWjY=; b=JZGYs6vPbK7Fhz Lix65TQqPQh7sDapCkCB/mu1cDJcZzJqotDB8ssG5U3BGy8HQrhahod2eB0EJ7aes7wSJxj+Yah+8 Y32UfYRice25adOYrwI7+iFz3tPGwMJliXK3Vz18CVzM6xKiMKfnRV2LejVg3/0tmRKdsZbRAiXli C1dBLWflKFXorQzdMwOr5FS1/NobYuyTopXsn+MNMQ2F+5YjJuVAL/ctbhe8nd23YZZaPpjQNI/FH JASQBnfWJP+q42kSk63PtuwTg53K9m9nV/tz6+iiYZhnAGhy2/lCI46BKhlQPHM6lHFHhcxYfRjwb 1/yBdctq1WxCD7vAgwoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peIYC-009pp3-1x; Mon, 20 Mar 2023 16:40:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peIYB-009po5-01 for linux-arm-kernel@bombadil.infradead.org; Mon, 20 Mar 2023 16:39:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=mQu3jYKokEz7tGJfJMQP/VuspHARz/h6PMLM5pn2zdY=; b=VLn3AMQkjKxk+iyBA3/1EuVdYy HH3nnRjNsQyDcxHblodiDLnOIPQ8uiRTuAW3IacSYwAaOx3JW2OuwjmcTKfsEamI/Ng414z2bEoNf NCkwZ20bVq0s9JIru8xIXqe8c9rRhyC0LYV/HasSEMv7to8RfmFxR5P+P2mfPnA6/zoYC9NmueTEn 8RCC8K9Bpe15WVD1O9jmtuWOrE5Q32j6wdSiHstB6MzjaipCBeCWtGfFZa12mT8bGM6211PbMJCrS keLWv0KOosVEV3Fv05vMEZBWyfCDpcNFUAFR1T94XytnFHDEPqexDho+Re8KG3zLhJq0jT1ZZv23a OFT7liKg==; Received: from mail-vi1eur05on20621.outbound.protection.outlook.com ([2a01:111:f400:7d00::621] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peIY3-003zfF-0b for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 16:39:57 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230320_163951_578538_8BE2EFE7 X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; } From patchwork Mon Mar 20 16:38:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 13181599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2E81C6FD1D for ; Mon, 20 Mar 2023 16:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=16wYMHEXMEbFTAfWoqVIG/QN/0H23Mya5U3qStJXC2A=; b=hCeXrmqjioH22W IG5ZAI61WbS4N/NrqyXj2by1BE5UYt+unwzmVEyH828Cx9OFoRNvLw5t4tR/isfns5j4udu7g88j+ HtLxFRp672c+ys6m6vpipdLRSAIDPXDNTT78u/i7Q8irLAUrmMvuSC8vvhoPLzJ+VUzOlsy7R73th k5d5NFeUF2bLfbRCREeXcsdC198f3rzJlHvnrZpxV+qBvQARpMu9TF9TTMebvdigbZj5Y/IvF1/5E l79U6XDFxyz74XCnoRHEo5s92a7Js63g86LnrdHd32MedcoOQbQUWnR0mxVsIgpD60U2oczRyFH2T yUexOD5M9C3wzbjrz4mQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peIYL-009pt4-0B; Mon, 20 Mar 2023 16:40:09 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peIYD-009pp0-0h for linux-arm-kernel@bombadil.infradead.org; Mon, 20 Mar 2023 16:40:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=atEW99XphxxL5vQX+WSYX8HvoXtoyRlQitZt2ZVpS8o=; b=C+q+xFL5IbTJ8BwECEOtQfLeGG gGW2t3gmBjfv6tEI0qbTx2Qgx+Ox541txDypvN1GfBJi5bBWwZv6TQeOcgsVMI/DSAInfOtxN8yWz dq1sDhiNotGkMhSG1fh0g3q3OARGTr5OeghjYGFp0cOH2vNjeTw91cc6nAQnF2af+Nr950Ipsz4ss llGbR3TfkBK96pduES7EKuw1llQnnLXdLjl0HslO639kjkguq1z/T2psEk0ffvigz/BPUxYAUyUup wWkrY+KmaaNoQzHxWLj2eYx80HfeDsJSrSy73QHSkaI42vcd2BTYm5JynAS+06ZndDUg9cQ7oMVBg mAcr7Q3w==; Received: from mail-vi1eur05on20621.outbound.protection.outlook.com ([2a01:111:f400:7d00::621] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peIY9-003zfF-1R for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 16:39:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0GX2W9OBshiJ9S3fwrAXKPE27hYuBNth5MIuLdEIzbQH0iywAduTmiC9sPyozk0D0Xmr7JGwHmywHd3CI+l27NgmqZBi4pm+43PW7fGfscQ7CtE6FAZaL5N6PsIAbMdsaPjV4LWDzP1hLwbUTYzwWqycO2huBVUD56P1NUrtBna5tIa477vVUq2j8NOolyvR3BwQzWvcc4rOFh7FDcK1VSuZ2Xfmwu5KIzTJzLhXXzgq+z2ma5mg1m4x7hOapmS8EuM3QDrv7cmMR1qEXefyHkTGVO1k7NC8cFGQzn5uQLuFF2VOh2fyNHBDrFdTwLwfL0IqxKUFIdFQSijbF6cgw== 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=atEW99XphxxL5vQX+WSYX8HvoXtoyRlQitZt2ZVpS8o=; b=QWjo8tWI94a+1+5TTMFOAwm2Y4RNxT48bCy4Ui3xRNsn+k1W9yRjX77E0zY/t3BeBa10V0L+QwaVp47EhdmjzFS8o69AEOts6PnVEY5QAyqSvGGZk5nE8KoUyzGDF3RgAsfhXkBkbm63jYTaHU91lWT/SgZ76qZl9E9FiR/ITN3gFH96YZx8zKYLZ8OIRWTcEXA6WCjTENXh82+E337UOaDkg+JRMs5CPUrikKlctzvNwcN9UnhuqoLD0CCOKVC/PKFcZKqZ0Ko3knaIUsNGPexNoCwOB3dNsk8FBBbXeIpzfwD06GczRqcxslu0eZFYG0S1eN/VgjUOasgndCiW4Q== 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=atEW99XphxxL5vQX+WSYX8HvoXtoyRlQitZt2ZVpS8o=; b=e9WBtq/Tv33XYgJZbfOEAvv4HuHfvslrPcZAqQ0uZNicxx9+M2toW+7ZFFXpEKVGewGVqzyKtAzPZlKr5OwiwaMvEgNSfRIoXT7VZ7JqGzS/DwG0jZkwpld/ttZefZ+LKvJZ1vD0aTguRkHpKlXtugJlxpVCjT0Mu7ypopNql9YIuDcypsJj8dtpIhZrCUBugVWdF2zzIf1BDdj3lbczky0u/2AY7PUbU1YPBtlhHB9AI0PKMCXUKy66r2Mkhhg38jHR4A062BKk+P5XcrAxgJXEAR/5eVWcT0mw18vUDUPsDWxSZCE+QfQpnw1GmmYtxeCaIDwpYpRP0r2TNjcYiA== 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:52 +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:52 +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 4/4] pinctrl: s32cc: embed generic struct pingroup and pinfunction Date: Tue, 21 Mar 2023 00:38:23 +0800 Message-Id: <20230320163823.886-5-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: TYCP286CA0170.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c6::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_|DU0PR04MB9274:EE_ X-MS-Office365-Filtering-Correlation-Id: f7f96ce3-b218-43ee-abc1-08db2961ba63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 77FOf8IM0yiSvut8zmdQxGHN2j9Mx/Qox+rLB2GfOEovplZwBP9Hfnr/XAXrVKzSc8Ga0cqlyvG3Qr7hVohX8ybzS3Yvk2LQtSbbimX8JBMETj+hxzR0ipLSqODh254r8Zqb4Kh5YTnFRh+vkN7mGyeqZocWDT/ijpWXZawKjZWIM5AXBu5CJDqy2mlerCkgH42Cwh7mgM9xJ+cMxdlcoBjdeOLOA62s/kGOl4ib1p+N4j4vPF1uKw0DCbUImZG4GFm6RCwwzdm4hIVSKoeRdmKDAcKESMgQwvh/XK3OmUUTYzu2rE2ZOi1HUQ8zeGKwdLRBw6Gysx7tH5vZ7n188Tkdx46igLrTys0IyI7oUa3sIdIXJqht4Iuo3r78wRXuSDkFmLN/4XHkCL+NcV2gCesUheWlh7pHkjNwNM6RsBJYLkAWNAULtPUq5zNgBYtfpvjdRSjkw2/GMHUgdWSwAC+5WhUXl2ypqgJgDYgyfbLp8NW0dpj0EdBQjGgNc4e3tDaRtcBC3t6e/eJlDqfaExJ3QJyJLRHP901RkpvwBY1ASYCgGTYP+8BV6nepJ/IKPioMBsu6OblFmjadpO9+nKVegB3mQPjny6tB8Wt+fZlFwkfn4FeDNn/v2RGVOPAV1sMFpGMDL5ZbiPsY1CcQI0ZMqncqPB1Pseo4+IIVof1t5lkqSqNa+uxviPV+0nCp 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)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wjkYSf/hoCrvvwt9/spwqkRP7U4PAZgnoQZwrT8+Brb4DBc05mlKReWmxe7RS7SDg4T/2UjgjnyvKShGlVxxdwrPpNFwAujSxUXWgTw/jKgB3rqj4b8uxzMOAJQpV8xxBNtUE4S6xp2cQ/ACgffxp5+N5vMX1hLK+zISORJFAu8cQwoADbm+Elqs+nv0RvQanIGTmn0JkR/ubM90lV8izN4yTc7w/veLumihkJk0MbHyh1ea69NzP7GyRt955ZgALZMy5ptIeu+CthefuC0PqSLRteJU6DxkG38wZKIVd3ScShhnpVJQH2y2D/ZARVRHaSqrQMJR5cNMsb+x8QTNJ2o1w0vjkXX44yqgM/U5xjsuyC4WmD2A7KuDaqyJT4RE0q4vnJSnDnneA8WACnd07/eTPVLK4R9yka4GoF8OZu3Sdv32tryGBqcKcAuVykkdBzYD0eeT5muDyE/bo/fJY7bLunDFXewlUjxy232i7gZdGQEV1kqoEpM5SbfgG/nzc27TZ+XenZDfUkv+u2QoRXnm/I2kIH6EJMEhhtjlWtG5thyXoIg/6dnUEr2UX5wO6bzuDyqt6KEaQut6NaAaqjZ7BvhQJBUt3uSSyuMJKnyuEKERTKYnfBlkSgEK56BB+NDNTMfk0C9CNdiP7o39Rs/KDGKo/TzSdO/zdhQNm5gAOx5C1URsulyebpsOolFrASFn3oSt6ubuOXtzMzYJ96BYks/VZwlLThTNEjzt/fgFXXfnw75wIMeJm1LPnHsbt9wGQN0kRwBnTHhFCIsKwbx1/jo89RgS1EnhWBxGdEi/Uokld3pq3IUAEGHLlJDGqfoSATmObjgj2NOmOUNCzZkvMnKnp/Q0riToVn1d04sLOJlKCpqhuirv0J7TjflchDXCXZE/9CyqNWL7UindwpuT3rJNTVjlVy1vB/gwyv2dQmE8niMPJJvEJGxOfXcHkNFCoUcx8e7FE63/WkV7gAnLOc+HAtRb5WObAh4HtZpf7StB/coMZxvCQh3oogdhmQAVyWdDrF+hRwEKvjwGECwbjWNTp5yfVZIWeKV322Sg22d6G24pqTNMlAPZEr6wXt6fzeb84oQ65KhuEFlcZb+KXAyMFRozYGiZ46nLddhQMbQbs+WZ8ZKg7gCXyRPE701UU9d4vGZamXwIj0ejU2Awzn7+aVfjGLN5qXD/LeV1+soTcNu0/HmCMaBFbeXsDZljLzHC4bbAXey1x2vsumbskgnoiH14ycL43iqK39lSgEOy7031UdAh5xnnhA8B9N3AHkFBFXyAh/sxC3LkOJwHZb7om8fiQZP7Nvd95sKxsjDY26WflTZsFASHUvpiTtjW+wkmQ7AeeLbSNFU73z4Tv6T7Apa8/4I3x1OAdVyFdRZtFToh7bcGhvyfs8p4Eiindfq1v3NOigeL8pUHc5mcm1oywjW29/+kssytyI+8lFe8w9WowMcRXlTEQu54SHm5RDDSXLRymKEhGhaYWdl7pbSypMJ0ZRBJzmzx13alMCtVJfqcqj0yJ2Zbaw9hbOJNwOKNCjriwHpGjIFIwPsD8aMCAUP/ijAsOO1mHS8= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7f96ce3-b218-43ee-abc1-08db2961ba63 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:52.0436 (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: u1iXnwv0VGmODT/6D3YvSBfZo4hLUDGOZQXoaD9/pyFnttlljifflIXFcw8PKZ4e X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9274 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230320_163957_671433_A29B5FA5 X-CRM114-Status: GOOD ( 19.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use generic data structure to describe pin control functions and groups in S32 SoC family and drop duplicated struct members. Signed-off-by: Chester Lin Reviewed-by: Andy Shevchenko --- Changes in v2: - Simply use generic 'struct pinfunction' rather than having extra 'struct s32_pmx_func'. drivers/pinctrl/nxp/pinctrl-s32.h | 26 ++-------- drivers/pinctrl/nxp/pinctrl-s32cc.c | 76 +++++++++++++++-------------- 2 files changed, 45 insertions(+), 57 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32.h b/drivers/pinctrl/nxp/pinctrl-s32.h index 545bf16b988d..2f7aecd462e4 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32.h +++ b/drivers/pinctrl/nxp/pinctrl-s32.h @@ -15,31 +15,15 @@ struct platform_device; /** * struct s32_pin_group - describes an S32 pin group - * @name: the name of this specific pin group - * @npins: the number of pins in this group array, i.e. the number of - * elements in pin_ids and pin_sss so we can iterate over that array - * @pin_ids: an array of pin IDs in this group - * @pin_sss: an array of source signal select configs paired with pin_ids + * @data: generic data describes group name, number of pins, and a pin array in + this group. + * @pin_sss: an array of source signal select configs paired with pin array. */ struct s32_pin_group { - const char *name; - unsigned int npins; - unsigned int *pin_ids; + struct pingroup data; 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 @@ -56,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 cb8a0844c0fa..4ed0cc905232 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32cc.c +++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c @@ -188,7 +188,7 @@ static const char *s32_get_group_name(struct pinctrl_dev *pctldev, struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); const struct s32_pinctrl_soc_info *info = ipctl->info; - return info->groups[selector].name; + return info->groups[selector].data.name; } static int s32_get_group_pins(struct pinctrl_dev *pctldev, @@ -198,8 +198,8 @@ static int s32_get_group_pins(struct pinctrl_dev *pctldev, struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); const struct s32_pinctrl_soc_info *info = ipctl->info; - *pins = info->groups[selector].pin_ids; - *npins = info->groups[selector].npins; + *pins = info->groups[selector].data.pins; + *npins = info->groups[selector].data.npins; return 0; } @@ -314,23 +314,23 @@ static int s32_pmx_set(struct pinctrl_dev *pctldev, unsigned int selector, grp = &info->groups[group]; dev_dbg(ipctl->dev, "set mux for function %s group %s\n", - info->functions[selector].name, grp->name); + info->functions[selector].name, grp->data.name); /* Check beforehand so we don't have a partial config. */ - for (i = 0; i < grp->npins; i++) { - if (s32_check_pin(pctldev, grp->pin_ids[i]) != 0) { + for (i = 0; i < grp->data.npins; i++) { + if (s32_check_pin(pctldev, grp->data.pins[i]) != 0) { dev_err(info->dev, "invalid pin: %u in group: %u\n", - grp->pin_ids[i], group); + grp->data.pins[i], group); return -EINVAL; } } - for (i = 0, ret = 0; i < grp->npins && !ret; i++) { - ret = s32_regmap_update(pctldev, grp->pin_ids[i], + for (i = 0, ret = 0; i < grp->data.npins && !ret; i++) { + ret = s32_regmap_update(pctldev, grp->data.pins[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]); + grp->data.pins[i]); return ret; } } @@ -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; } @@ -602,8 +602,8 @@ static int s32_pconf_group_set(struct pinctrl_dev *pctldev, unsigned int selecto int i, ret; grp = &info->groups[selector]; - for (i = 0; i < grp->npins; i++) { - ret = s32_pinconf_mscr_update(pctldev, grp->pin_ids[i], + for (i = 0; i < grp->data.npins; i++) { + ret = s32_pinconf_mscr_update(pctldev, grp->data.pins[i], configs, num_configs); if (ret) return ret; @@ -637,9 +637,9 @@ static void s32_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, seq_puts(s, "\n"); grp = &info->groups[selector]; - for (i = 0; i < grp->npins; i++) { - name = pin_get_name(pctldev, grp->pin_ids[i]); - ret = s32_regmap_read(pctldev, grp->pin_ids[i], &config); + for (i = 0; i < grp->data.npins; i++) { + name = pin_get_name(pctldev, grp->data.pins[i]); + ret = s32_regmap_read(pctldev, grp->data.pins[i], &config); if (ret) return; seq_printf(s, "%s: 0x%x\n", name, config); @@ -732,6 +732,7 @@ static int s32_pinctrl_parse_groups(struct device_node *np, const __be32 *p; struct device *dev; struct property *prop; + unsigned int *pins, *sss; int i, npins; u32 pinmux; @@ -740,38 +741,38 @@ static int s32_pinctrl_parse_groups(struct device_node *np, dev_dbg(dev, "group: %pOFn\n", np); /* Initialise group */ - grp->name = np->name; + grp->data.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", - grp->name); + grp->data.name); return -EINVAL; } if (!npins) { - dev_err(dev, "The group %s has no pins.\n", grp->name); + dev_err(dev, "The group %s has no pins.\n", grp->data.name); return -EINVAL; } - grp->npins = npins; + grp->data.npins = npins; - grp->pin_ids = devm_kcalloc(info->dev, grp->npins, - 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) + pins = devm_kcalloc(info->dev, npins, sizeof(*pins), GFP_KERNEL); + sss = devm_kcalloc(info->dev, npins, sizeof(*sss), GFP_KERNEL); + if (!pins || !sss) return -ENOMEM; i = 0; of_property_for_each_u32(np, "pinmux", prop, p, pinmux) { - grp->pin_ids[i] = get_pin_no(pinmux); - grp->pin_sss[i] = get_pin_func(pinmux); + pins[i] = get_pin_no(pinmux); + sss[i] = get_pin_func(pinmux); - dev_dbg(info->dev, "pin-id: 0x%x, sss: 0x%x", - grp->pin_ids[i], grp->pin_sss[i]); + dev_dbg(info->dev, "pin: 0x%x, sss: 0x%x", pins[i], sss[i]); i++; } + grp->data.pins = pins; + grp->pin_sss = sss; + return 0; } @@ -780,8 +781,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; + char **groups; u32 i = 0; int ret = 0; @@ -791,18 +793,18 @@ 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, - sizeof(*func->groups), GFP_KERNEL); - if (!func->groups) + groups = devm_kcalloc(info->dev, func->ngroups, + sizeof(*func->groups), GFP_KERNEL); + if (!groups) return -ENOMEM; for_each_child_of_node(np, child) { - func->groups[i] = child->name; + groups[i] = (char *)child->name; grp = &info->groups[info->grp_index++]; ret = s32_pinctrl_parse_groups(child, grp, info); if (ret) @@ -810,6 +812,8 @@ static int s32_pinctrl_parse_functions(struct device_node *np, i++; } + func->groups = (const char **)groups; + return 0; }