From patchwork Fri Mar 24 14:36: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: 74576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp676707vqo; Fri, 24 Mar 2023 07:40:39 -0700 (PDT) X-Google-Smtp-Source: AKy350Z/SgVTh8hdZ3fri4PEu0rteDAYqKbiybNa5Z8QaH9oKt2pRK1luQg6D6t3iot1BmVst0Nr X-Received: by 2002:a17:90b:3e89:b0:236:a4bc:222 with SMTP id rj9-20020a17090b3e8900b00236a4bc0222mr2787007pjb.38.1679668839072; Fri, 24 Mar 2023 07:40:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679668839; cv=pass; d=google.com; s=arc-20160816; b=abIin+3OzOGYTzyvuQ26OXVQhLxhhFY8hUw0qd0z7qb12WHE47/LxhfIEoz78TGAZh 49R4F1HFrQg8U7d+ay0vxmmJeT+Frm5YValVEl8Z5KwCarY/DID51jmoDrGWlVMEnVyy mvYRZ8GHhdPXokv0BHfvLYrh10wfQOcMUeuFb8v7Q4U7DSmNgg3zAwcQrZbJrzPh4REy e84MXKiIM+j8qzDW9/Gn22Ym9f9w/LhabcI/1Hdd8QyjXVTVnhWgbKzBzum7dPe1E+ji DdEMCBwuJnCuKikqhKHYaG6ZIAlkpfKZwHeYrW6rpwKR1myVeYri+5axJy8pZqnDlIzF Lm0A== 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=UvLq29R3cJdMNhrDZYSjsggrvLxGzA+VlJIrGEgigSA=; b=bvATFQoZJ45Id3ROL5TY880fCWHsr3aRzn2pOtu5P3jnFdnYZqOUfuHVCIjSsW+L4o 83EyZ51NfsQSlFQQX0jxa20UUF7VL/OnuPrZ9VSOsfWdbj+qff8aVcePZyPyP2wrRvX3 LQb72K30qzG0RnCYH2soktUGjE6p5PnBnmuuweuRXMMZJ1vI0I7I68WT3sJkjm56ufhV YQlCSd6IGYmEWp1B6uR1NF7KCMkS0JNpa/pm2YDCU3OHZQyy4M8sI8isyI8qduxO1tKn oCpa0gaVj2IdOF7HKRXsrsr0kzuWl45UBzqCMTAom4jkbSZfrUC7KAHbTCt0Y/dMv2cD f4HQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=SmHZy2iN; 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 i18-20020a170902c95200b001a1c93b36aasi15967636pla.480.2023.03.24.07.40.25; Fri, 24 Mar 2023 07:40:39 -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=SmHZy2iN; 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 S231872AbjCXOhX (ORCPT + 99 others); Fri, 24 Mar 2023 10:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231819AbjCXOhV (ORCPT ); Fri, 24 Mar 2023 10:37:21 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2053.outbound.protection.outlook.com [40.107.22.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B0919103; Fri, 24 Mar 2023 07:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O2zkUofELxNDpbpQsOU27Wpnc4xpDjYGnZNWLfK/MFmcBocqu1HneO1LMKIYQxcx+kK5n3RfV9P1Ogg3584J+XrWXN9qrlSykns3oqdNqgBl/9uPS/s5wQOf5ERUB2+7cmuHM9J218iC66HaOWZfLKOanNU/SXX8ms58hL4NI8BGM0i7BNZ8wxA/rIH0zpzqnKUZWjeqn7ls4Zhh1Jev5zm17YdjjFOkLJ9QNBpppwgIxSZJPlF+L+Ou+LrqnFBwmIblKoM2LRzjE5mssLpxcOJYUo7JlMwClxDVsu5NofvM6WAp4ytvw12Ja3C1Gb5NpIY4rH/t4oSZI1Z+N86yvQ== 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=UvLq29R3cJdMNhrDZYSjsggrvLxGzA+VlJIrGEgigSA=; b=MqzLjP0mQR8OnYwAswm2k+a3XSo7QZxwA1AcaVMKLfVslbuBuqZTCj68ZI71OQd6JHKfLnODaZt9uGXoyqdeLRYV9PxfJ07VMuS9Q35F0N9cGu2/rKHMExCjUjrMrzVeLduBYefxa0uUTlyi2l8x0jbN+22sREi8sdVJ/FqxI2J0y4C+agJ9bhN3shjHe6fyZ5HxTs1EZXXfc2vu54jKsU55L9uZ1CJdY4es7Us1oA9ciKyDbHhzGJMHHeRA7x0SSvvn731VQOPLexg73bMeNOkjJb9gHZvGAqZx/GDxZhUPL6CL9scBKkLBOvkJx5h4io2Osez4p45+SSBIPT8gxw== 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=UvLq29R3cJdMNhrDZYSjsggrvLxGzA+VlJIrGEgigSA=; b=SmHZy2iN+Idw71PZ6QuEmdlIlAdtmRdkP5xsZ6kItKwTBRfNte6No83j0AaXU8oUrgPo80zeDRsLf6UGsNRu0sDdWgXlK1H4jge/TooIpAvTpwxr/cmQSPQoXbyViL945fBnQWZlh1FwfhXps0UBIsw74ZA7NX8A8nVmnYGUW00HQNm1JG95DNz1d+08vl9t2e3JCYcwr4xf35AClgRo2Wy05zTgfZjA5Mryu98ZVAl+FAO3nO1emuwdm0iHOGrtE4mqZVlqCIbaF7dBMwlIVmuu9ht4srdSZHvPU6Xk5Semd4ZZcgan/SNZUTEjKU9W8RSJaiJp83hlhDfTS2qpXQ== 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 VE1PR04MB7454.eurprd04.prod.outlook.com (2603:10a6:800:1a8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Fri, 24 Mar 2023 14:37:16 +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.038; Fri, 24 Mar 2023 14:37:16 +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 v4 1/5] pinctrl: s32: refine error/return/config checks and simplify driver codes Date: Fri, 24 Mar 2023 22:36:22 +0800 Message-Id: <20230324143626.16336-2-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230324143626.16336-1-clin@suse.com> References: <20230324143626.16336-1-clin@suse.com> X-ClientProxiedBy: TY2PR02CA0034.apcprd02.prod.outlook.com (2603:1096:404:a6::22) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|VE1PR04MB7454:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bda6f5c-f97f-49f0-8fc4-08db2c754367 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vKX1Y8r3eXUNLF7WJO1JMgJ4v+1gnhYy8s27uoRH7uOv6xzs08FNMZFJFb6UNp+MOpePLhz4H9SaD5E4q90vVShjWZ/RH4GtadNnCLI/gTrsSZMwactepXo2GbH4f9L4flKUb7duVpJ0sYSdm3f95NN7e24Gke1p2lo8fWHf0mFZeJsSalkM4Ou9YOYMlj9BKxxj6LQEfcXx/iWiiiw9yQepHGLoLubVrLrqhtE8HCTbtCGIPtFe/KI5vLz8jsMgb7bnZCYdws1VSUCVPO+BtiBzuTPuHUY3CHzToxlrbEFpbQDiqovuSll9wx/uKohyJR+19Q87u/gOC7EZKh/MovsytrAhlngj2NeQGcebkUkBS3eR1FWsgfeu3S/miCcq9nrTu5r7AbfZgf+f6jscyP/OzmP687rST/mzamMxIqS3X/GCe4iuv9M4EfdKE9HrdV/P7KWcp6IVcAAMTbURwc5NSp385zgWF5+8T2O4SsWXVZ1Xv8OjMiMC433Yg6gMTkoz2BgswRxp323r/BFroIzPrIKjfjC6MLap4Ua4fCYvx3e5041M8qUmqhaefz6wpVxZpNAjpvA7uY0HGMkPf4zcac3b6+pAlwke6s0DZlg4zcDkFIkJZz3keKXlcehvnjZ6SdmQf0RyTSqtX8wvOw== 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)(346002)(396003)(366004)(136003)(376002)(39850400004)(451199018)(8936002)(66946007)(66476007)(66556008)(41300700001)(4326008)(86362001)(8676002)(36756003)(38100700002)(6506007)(1076003)(6512007)(6666004)(26005)(83380400001)(186003)(2616005)(107886003)(316002)(6486002)(54906003)(110136005)(478600001)(5660300002)(7416002)(2906002)(30864003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TfAyX5UQEGkScTcoA4fTEolfucP1J34BTRGRADwzgqR07MBLdaolaI8UYE+mcyaZgip0A1qoebJfJUZqaObVSQ/Yvqed7Y6W7GD4rGCXjuv1bxYfxIWLO2gF4ASt9hXduHEsHUJDOXqexIEwfX5q0AQq8Oa23SYlBHftaa9/H9mVL616DqJ/RjM1R64asiQb4j4Dq/T4lpbvWv1P9VnondgqOS2Gzl0PpgRWANlyqCZMiABeDzwNqOI90W1hV/8dsc20vjcbVTsDeGgizN+6UM5CNb98J7vaF8+u6OnJ/Wfqfs5xN/O1HQQkJK7HMGdOkF26sXVTqVvl0aLBU7G6+150hQvpNvvZ6K3RaxMovFK0gtO5LLz757Tlgngsknig1EdPoFxdJ/ONVzdB61YfpWseoPl8ZkBhlbno1/X6C8soH6DfUDbtk0iSccnh66XhxCH2Q4z2766bX1GXjf/n5KqG9mstwWiIMfMeB7VleD7Qa/xJnZ46ZqMtquappIjJ1tS6Y0a4nOn9ddH/PuCaQfpv+99fsfOaP62AX9bjxbV2ruEkk9OPV2uWbpCAiSbiROAyGUBrIZExMQ5h43Th7gkb/NATw38O/B7u/t/EmwITXv8ZfYAmKTDuIkwXa3xVg4B2JheboEa8EQ/09mJ/W5JBcEfPFt/reE4utTJr9V7883DMtwtYswLOmS5AHIheky8XiY2o9UV9oqxuWh0SgOZQdMD05naIRzNX21nNXTGtt5GJZg6HAg+aYFKDdBzvlzcHJAvsi0xhjBgIm9GQqoKITmZCFG29nw/nW7hUgyEjCZCNQke7YAWMu6o2Vv+VeNwWCT96DYjG9tQRDqvpEF3D2/qFupkOG5/xy+vzSCt8vX22Q6CdKDIhiQHzXLlDsZNNwoU5k0jd0QMtsioPHDG8qTXc+0oBJeUevos6bRQIRIdQS6KrovnOeg2/yh2qztJwP/4ORdUSAfb3Z6osmmnUalqeUfSm2fIEXtuEhfQjOtvOfU7rju/IgRZ1/EXd6SndtpM/O7Qo8VGEUj3HlmdJNXA4KP5813llF6TodsyKMX7Pkz4i0fbKVrU+sagL8Wj5nfYy85fCfISfhaNEMQa+Xv4EsltOJ6fc50DJzuMV0nWx9Nrfu5e6Hok5OoiH7OmIyG2aibeB/tPuWX2e6JNSiIW0t7d/h5IApr2CC0F5ndFr0Gsf7pBA7+T8nAbactfe0ITFoPZJsZXq4XG2lqPHNOpT+Vo4OpWVmnKn0ww/ggOPW8Y+yaDXjh2jElLUzZ6zvhW1QcR1IH0fEwI8zdxOXFLjRJC0i2HEikCG1WSug35Nzq2BKFp6eDNDrmfJb2cITVBUS5U7W7sj3J/STFKLwmP2aWRFqyLeq2R68wCuRCqml4/hn+wikRfKWEppYcp21JV9sNHiXO8O5NSp8svaWRxxxzabOpOCdNz6aPy6/Q5cWK9xqkm2ABPWm3y8JSQUZgwEJcywMyEL4DvBgZ0F8mU5FYOE7Hwz7Qo5TOQZ6FxqU/BQopoRUBaLQbL+dXRR+JHhQeHDg1ahzvEInfFwDvz8aTU+PBsPrHRA6e4= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bda6f5c-f97f-49f0-8fc4-08db2c754367 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2023 14:37:16.0306 (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: 7WUMfrRO8lijD6S1sYJbkFU6nSesajsJMZi2bwEQTlhTTqvJu0t8AMFlMsOfdFyz X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7454 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?1761260432523316955?= X-GMAIL-MSGID: =?utf-8?q?1761260432523316955?= 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 5028f4adc389..d9f3ff6794ea 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32g2.c +++ b/drivers/pinctrl/nxp/pinctrl-s32g2.c @@ -757,14 +757,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 Fri Mar 24 14:36: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: 74578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp677141vqo; Fri, 24 Mar 2023 07:41:20 -0700 (PDT) X-Google-Smtp-Source: AKy350a5fTO+CV+qSXOFguf/Q6onlYubtJNkk5tOnb3FFxtS6ATjK3ssxS63cuUZM0A78MYLmdUK X-Received: by 2002:a17:90b:4d0d:b0:233:cd29:f168 with SMTP id mw13-20020a17090b4d0d00b00233cd29f168mr3424870pjb.24.1679668880047; Fri, 24 Mar 2023 07:41:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679668880; cv=pass; d=google.com; s=arc-20160816; b=uFjNdmax0YxCLS3tTBNrCr47yjb5gsjdCA+TPv4nNhGGOpLS0c+s+M9cvyLmx0BQNm 4Ss0bp1WGN0xmlGXONnu2b4Ei7Wn86qCuJ0hZ64lP7tVpRVaoXkFRy4iKwj6k1geU8Y3 uGnzOMxOZdJHOwzq3AoUOayeJlHolKler2z69S8lrL9VloQlObu4gGVlOZTnRS+AyLzN 6pxEtNOTyz8H3UGx1XMZ5Opg0hU+lmIE/EGKHr23+mTdcdHZoaduN532klaib0HBxsa3 Qg7Ygf+3CKM1nKxS0IcbU7LcRKoIJ2/aCNyZ1RsgjmC6uJGbVe7QCiOlEToZmOSpsfcO v3oQ== 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=gA36rjGQaztJzKACtcCbtTz7Hrsky4bgENUo5JjXWaQ=; b=bd4Vj6VlCDu9iCL9B3NbYzXdmrjQlgQnCRfmHlIi9DZlgiL13IjF9+mei+Xo07HTcK qy34gNVPOTqbHw9k7O4SxwnQmJuhRFe4K8JEDNgGmodLRvCL5g3Jrsh+X9gqItJQEg0G v7SOOlwx/wi5Fdxfx71QE3h65R7AQGnj/qw75MtxQ9hxyc5CgY3Yi+nfq2fXFEeFbDkO zAsdMa17nQP1NiMRP3NgB9KkkBBUaAxyTIkeSjZa8PWwI8Dx8q3IP0xm4AT3VHWSQYEs kU4Q7HwDvlkQqJC+J3zKLLPJ1awjAG/68pOtfiSyiO5dpmYOne/bD9jO0DGuIJg3jFuh t92w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=2Fu3lyJa; 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 a8-20020a17090a740800b00233ea6a32c7si4473890pjg.112.2023.03.24.07.41.07; Fri, 24 Mar 2023 07:41:20 -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=2Fu3lyJa; 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 S231889AbjCXOhj (ORCPT + 99 others); Fri, 24 Mar 2023 10:37:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231955AbjCXOhg (ORCPT ); Fri, 24 Mar 2023 10:37:36 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2084.outbound.protection.outlook.com [40.107.22.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4712279C; Fri, 24 Mar 2023 07:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MxqusOopXuo6MS1IsrLhD8CN6EqZIKBlcMprOhvdMJpkjsZWfa6x9I093gkH84JLE5yddRyDpt1Y3ItJwRHcqfWkiXodpraYQh7YaCLyK26SXqovCi2QciFYBq9oXm0nkXFK9+3LLJqsqFJomWCv8Qh3SkW0zYrXV6i+nWCEeRkyhpWX2wSEQ1MZ2k8cS3s2JDWRP3M4XbfvbG3MFuIqZJQ699VslEF7s1YI19IK9bMbVKrBAWGUIcGN8eS7PzvoFe/IrJ8JmbpjXG+TWiZS4QwbiRwhzAmG8qjdcCLidFNcuRP6uUx3UZFWbEqxYhRK8Pe/rvfGayTlrfBSmL6sKg== 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=gA36rjGQaztJzKACtcCbtTz7Hrsky4bgENUo5JjXWaQ=; b=X2rKnAKdk0+E3TjnwBKJL0IDmWvVyYx+vL+0TcC6YmlJFEKWwgPA+cvSrYm+/Mi4wJ+5UvpS0vm9oyUdKievjsW1XBnEjgh+qGVKhTZmcp6rKgDpxOXruulvdqhSs0yKYmssQdQG5IOYvtLZZG42g7IYaCj0hGj9nL5MWhIL6gvGN7Htv3n8PY66EcznreyEBynjp8Kqzah9bEFyB9G16v1+GZ5s5BOW1lKi+O6IbxummJsk4r3v/BTumEB/UdZ6g0kxcmWQQZQZEHXpd379Y/F37Tk04M9ZR5qstw3kO6rpLpWeMyO63usdS4HBa54eGxWbIiUGElpcipOLrtE0Kw== 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=gA36rjGQaztJzKACtcCbtTz7Hrsky4bgENUo5JjXWaQ=; b=2Fu3lyJaLu1IzPNf9895q/8CnMPl75yc3owaEm8Zzv8NMxLFtY8btZGtDGIpZB4phEmX/+K+yc1DLokqgHIuv5N969KwhTOWDtZc/dF3cCHeN409xrQ8ywSz/3RWqp7ZGO2ke7dxusPQBA6E/AXmiI+ExdIFNMAwX0zCAJaT211XsviqIL/2gZAD/NcL4N4suUEwufSgpNUJcojwXd63AuIU2dF5h1bQoX67bvb3n3/qXh7F4zncBc3s/p9DsFfOkWm810IdEojzaJuNY3VEEUkvCaTzmxLmPl8sS7GbdMVxmQ+AUYojc50BMyxWIa6Y3Uo/CuKpY/FBeg2mx7bt6g== 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 VE1PR04MB7454.eurprd04.prod.outlook.com (2603:10a6:800:1a8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Fri, 24 Mar 2023 14:37:30 +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.038; Fri, 24 Mar 2023 14:37:30 +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 v4 2/5] pinctrl: s32cc: refactor pin config parsing Date: Fri, 24 Mar 2023 22:36:23 +0800 Message-Id: <20230324143626.16336-3-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230324143626.16336-1-clin@suse.com> References: <20230324143626.16336-1-clin@suse.com> X-ClientProxiedBy: TYCP301CA0053.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:384::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_|VE1PR04MB7454:EE_ X-MS-Office365-Filtering-Correlation-Id: 36c981a7-8f04-46e3-f94b-08db2c754c1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: knLGLmZi2zQQCS+w3YAVDp/9PVIaMkThwhTpaC+7EEjXKUbxrbRXqxsuF7MnTz1x22IGIS/dUrcm2HlnNsWq2a2SMw35C20yZQwoHUIjnvU1fayQfsuREt/TO1lTNGMjUUwJcptvcG9PePGv4gNWwvxnovJUSY0/ji7atCBCj1aDfEA3O1eqHFHB5xSOOqRmzSx8GsWS9cmyf1et+BUYbzDAegk+1Jq021qZhVIcN4LcQh3bVUJfQRcMTyCFV22SN9CHVngW87vhrBc9NKZYMY4ImEPlRTVWiRgr44O2RCyW9hl0lM6BJtn42AH/GqgFdeYLcMJ5/KlCU85qMd0m6FX8qlIG4tQUkKb8cYb3m73CHhrzxbo5qMvh8yxtjf3hMOtsJXG2vXHnl7UI+F5a38ebCzEQnCiV/mx056kK2Gjp5Z+mE3PaI6z+kzqGYZBkp1pHDObhfrT9onIoIQGqeM6oiviUF25/9NZX0GK/Rb4/C6pMyR+eMSE2/CELjFQGTzwqxsjJWlXPJlOV9mYaTPNezxVsm+udjq1CzuP3zE/kdZ+L4GBtHtN/kDl3AFqjNxiogixR9BOUtM3aJ6e5zpJkqe5Pf77/EsMyFj6Qv3J/cv/x0mIt00ElgEiK1WMagqfvnW2e16Pml8+dCMuahQ== 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)(346002)(396003)(366004)(136003)(376002)(39850400004)(451199018)(8936002)(66946007)(66476007)(66556008)(41300700001)(4326008)(86362001)(8676002)(36756003)(38100700002)(6506007)(1076003)(6512007)(6666004)(26005)(83380400001)(186003)(2616005)(107886003)(316002)(6486002)(54906003)(110136005)(478600001)(5660300002)(7416002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZCf9oSMpr+4NN50ONOZgam782YTns7Y/YeGRrle6p19uZFH1S84W4K9y4xhU+vdCe/zI2Y4MjR7Z1TK4ICK5ahcwNuTOwepfgZsHqus0qN8dWWfKvb4A/keWLIr4rlploKQNOdnNRzNHGZ6mAUv6FilsrlZreymWcUl+dOkJOeB40/zns7JHgcnrkssvzaslkk4u4UazROyK1l9g25VpIk9BzyNe0EsWN65HjW/tqpwB78PonrFgmmXoRYPagyN1V2YS09LS93pH1LSCqXNBpXCiJEoAmW+lfddK6ab9gOXidkRDL+31khUfiL8t+jQypuzYTaMqF/zZjCUboYhNYEHNki0BtcQWJtT9O5xBN/BG7bzffEP9Qd6zVJYWT4wZ8D86oI0lqDzeKqAhgszZ2VLL+vSFk6v9kxLeLam7lmJNXHr9QcVQTRDIkQytFyweHMxw5cr4tSV++jCO2E4kZ6zHQvOaL4aOnsc9gJFcxthoAtfN8k8hTeUxJrqNb/7rTxlwxv5eVL7h2q99CHAcaU8VeZw2mLT3PLcMdYwidoojB7gXPpkWPTdzgYTqIWdnjl993HewmJUEPbdgYyMDqHZLZ2uvU3B494jgVgnMKyZb3YuQhBHlciXKWAKytczTTXAgXc3vKF7dn1DFKe5ELluQ55dnUQUkoKncXBJSnZU59vsluxadvUkLUUc/5KXu2Wxi4aIVnrDU2rdRPTJtiJ1a4LIV0UxaQAwNsPwYLit/UkI49ellh/1CPCP1GsrjLA4QhJ2YaRDNL8zb93BhzaybRd0+lkjShBi5upd4daonomJWHnpjUwN2DqfevdB0Y7h0M4dU9WmLVSUW7XW2uTn0vrNYbts70fXRTexiO7KweriMLfJGaRJZaa+5mgCenKAIh6QfgG5EcpD279AUNEeSu6PjmKXh2wvLrxWwW9pqFMf40N8nBvMbvgQzINZq0KBhNZJ/bow7+gBA87T5IcEuNH27NXyiYXUcOjr2tXjKp8+JQ8oZk5t1qh3ZpbTquqvRXTEHFLVV+n/qVI76BCXpLuZWpjCUYyD6pYsL0VakJG3m+Lvx9sT62phUeb8wBdwT7vzdQQVYOVRFZ/S0Zmy6hPMATSYnCf1K7qqQUItz5N1I7flV+8Jmy9whmfJmbTTooSx2l9V36IhvcVSpRUuaakjapxiTZGrZASaWHHRkhYkBwt1AB8hHT75W97djyHtpfHofoPuxSpMJdNW356yC9cvwWqRDtRCYSmVn1FIrhAU0r6/e3DDLbO1g7dUehVjpfwEI1/BV0sNwCu/ny9EulPVmQs61889vjpdALMuMuZDhs/08LC9tasc+kCrUUDbEV7BoWEPs9vjpdT4AaXLK+fQ1frN3885XrwtTFSj9C5sT8vxusSTCE1XY5QqgqUdoOKrIi/OQ2OwS+0vc0+uQXbD1WjFJsADOjx7ITVPDjAkPS5Q5IttUhmt0bZ1CEJRDNzW2Qbuktic/FBgvlMbuzY+dwnt0hOTltKLlA9+6GlBe+aB4nQKtxpakmmrGuZ3gTI3ctoG3G4CYwez1ZM1ji5SurN2qQdXlmVcrVAE= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36c981a7-8f04-46e3-f94b-08db2c754c1e X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2023 14:37:30.6388 (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: /2kBnO8EySvmRCcbw+xJHp8Xc/1MzHeOqEw/wqzIq6xjLTRRZRu2Zk+ItiR0kuq9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7454 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?1761260475691651209?= X-GMAIL-MSGID: =?utf-8?q?1761260475691651209?= Move common codes into smaller inline functions and remove argument checks that are not actually used by pull up/down bits in the S32 MSCR register. Signed-off-by: Chester Lin Reviewed-by: Andy Shevchenko --- (No change since v3) 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 Fri Mar 24 14:36:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 74577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp677130vqo; Fri, 24 Mar 2023 07:41:18 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0sklQcCTCKONHzvKQ0Wp3Vhqi5Jj4Ui3SWfDcE3hrrViHuvfLSq8M3dTDytDBeuQ1kXQx X-Received: by 2002:a17:90a:18e:b0:23e:f8e2:9ed3 with SMTP id 14-20020a17090a018e00b0023ef8e29ed3mr3130241pjc.43.1679668878666; Fri, 24 Mar 2023 07:41:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679668878; cv=pass; d=google.com; s=arc-20160816; b=Nf5i5m4yrZbZHmJ2TlaLre2aJfXhy2FvoZ7CT3CSUGrV16+vH/R2S9P8HUWgqNHkwT zSi0hRiVbeVIObUWJgm3YM1bR+b1L6kpEyIQiz2PHHrtJQw36wCMkHFTkQeERj/kSTXI KB+a9X784h8AJGzBZL0X4j2Qp+gMByULnh//tEAPc3wAp9+SbqCjXXlf1SLBdIgXWXV8 d/artbLwpL4rOsWtsSdj0V+Z8qjl92CflmUtND8QOj0Xj0W/eNpopBiNDC9+0folbxuh 1mcG7AM/5DkvIBVP9UjRaOrEYMcz+w/G+M4J9dDLaqpva5KzImhAbvBinPeECCXhU3w1 RaRg== 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=fN4oSk/fg6PFOW23zvTHHTxM97j8i0UUQgD086d68p0=; b=qrDsg3F6HflPpuPiISiP+0CjdMgcoVLMvwHqksDAm3VP6HX7r4uKaoEayHnwtCom5F /Sq2TIxr+EHKJ5txBYUUI3wsoUWMyim8XNeYK1xzVB0p7oGA4it7sXQmCpj75NKL2SUU AlRC3bR/vA7X7hT+B5QCaxSH/UadAKaF/cFf5hrTVTybn30dMVQeNW8Z8ZVokqBa38sX Gmzbr3U+f9cj7NfDJst/AUswi91s1b5A8q9iXAzOim4bSNyrEtMdIQfdDcldT+Ps/YFT FwfkZAsER0xK3tpAYfsN0Rjc/Y8VWq8k7b4VtFHAfrX3NsHROM2/G2vcDfUBh37oaQFz O6HQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=uhY8pVSf; 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 n19-20020a17090ade9300b00229242a29afsi4337893pjv.124.2023.03.24.07.41.05; Fri, 24 Mar 2023 07:41:18 -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=uhY8pVSf; 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 S231901AbjCXOiP (ORCPT + 99 others); Fri, 24 Mar 2023 10:38:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231960AbjCXOiN (ORCPT ); Fri, 24 Mar 2023 10:38:13 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2046.outbound.protection.outlook.com [40.107.21.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0028623116; Fri, 24 Mar 2023 07:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CPIm3kP34qvliYnAPjgi2IKSFq1EoI0xO+tt7afHeMut40WEmUPWTJXFwgmpXjUR+SxTd6wd0NSF7lhBJgqMVZofi6LiQaHcqCcUgwA14InduolipVFiyltCPHGMZei07d1bsaVP3BODw43fFxUNmdTxM/HWer1SSff+LitLf+LH5dWHwj7aRQB5zkhVScUwEARsyqY36tqKxnsnQVpLI9/ZqRlx+l4PsHu1x2fcgmgNAAr6SL9N2dvJpMA9WN/KnSzj+c5bf8pLzd7C6j6Ep4ME7OZSp9gIyMbuWU2MuCZLFkC/IoOXqWImbWQyQ2MumMCctUCFllTnLTPbdI8m/w== 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=fN4oSk/fg6PFOW23zvTHHTxM97j8i0UUQgD086d68p0=; b=eKOqjj/NxCf/lVC0cQL35ptJjLDia5pwy5eR1KjjfbAGfixemZYNtWlDxZrM/ROgJmJnjHXkQLDkRg+tQRsEkYzu+Sq6FrZSetorpkSzUe/VgLlI98QPyxHAmtHEnz7NaI+uIuuDcN0Kd394ABeXzPNroqZl8tQ5M0H0aaJD1NHlOG8s0s/J8zADXbxaArsRW4YgTSks1dtn8Cu861yRBYkoSEFGZzsEwMAfIz7acXZlo/CJ+XH57vefHEXfPeH1m3GjSxN68dYZII1+F9Cg+xjJlALICmMmkyYfRPIaRpGQdMu4yiGORYxfqUx507gy2jJsRSCeXu1SDN9UjxPxAw== 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=fN4oSk/fg6PFOW23zvTHHTxM97j8i0UUQgD086d68p0=; b=uhY8pVSfxrM8IXC5JnXtJ2/Mjvr9Z/H8F9l8dv3qMH6HqjF4Jek2rDOkdldQEWVJRuzQ24c9zg7q40AvmcQAfvAuI+FHnRDEZTC6Ci5GZILThbQqzpsx1dp42uH7rWKupdMJrhR4p0aPKjjgr9h6d+HHW8If6yOis1SZrDLISKW3CyKNUP1y6f07R8gB88d6hxRuDV6dRm2sPG9SIzps0LpICJ/5rhS14AK0p/KLe6ao77LcJ1mlu32LqFGCa4k0r+yXl5rYS9jY37LdOPgZ4QKrgBk2WEn5iKWAvI8IClkN2EMjmz32qdSDYPzUF11e5zSsopZC6kEQGlJKtNWLMg== 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 PAXPR04MB8623.eurprd04.prod.outlook.com (2603:10a6:102:21a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Fri, 24 Mar 2023 14:37:51 +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.038; Fri, 24 Mar 2023 14:37:50 +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 v4 4/5] pinctrl: s32cc: Use generic struct data to describe pin function Date: Fri, 24 Mar 2023 22:36:25 +0800 Message-Id: <20230324143626.16336-5-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230324143626.16336-1-clin@suse.com> References: <20230324143626.16336-1-clin@suse.com> X-ClientProxiedBy: TY2PR0101CA0016.apcprd01.prod.exchangelabs.com (2603:1096:404:92::28) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|PAXPR04MB8623:EE_ X-MS-Office365-Filtering-Correlation-Id: bd21aa54-b754-4fad-3f6b-08db2c75580f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oVDi9jb+COb7rjVctMcfAsvZkyUuUdMHCsAmZQMuqIhQS6bQ1gRuUB9r0X3OJVfmgbn4XkKcRqZPDY/7XDjuTXWmdEhethlqPhe+aCZ718rq6mcj06SrMtC/gnTt4XlTEat4W5Z27hIMjdt6nsbKRH9MG8nfwfj5pGtwC2RW2oM7fjxEWM5tjOS1FtWKKyGRyDAk/fS+AovP5ScyZ3rOOd5ukOvcxUVwR2lk+ntGG0DwYGX8raGU7J1yWaq98nNIiJ0cBoUFIkKfVCCjMToUjFM2BUKBt0bbcX7QXgy94nGHhw76oaVeRWPPTc7VHmSjUViOLfyFRuiA23QDgGnacxeW5C8HyOdqe5bfxKMpw8cFe/7tN+QK9hy7H4P67jsoJzZT6htx49zutFVSXQOaSW8QKoT33QPqLe2xyzZJ7y1b32LGQKI5EJ3iuEoyCDVPKySWr6OAYzaxoCF8mEhCJzlM2CHr3sxdS2Vmce2Pn/H2g1LA6vkxoT7XczuVDUzC1SsfQgMcI94gZgYMGksmFdmEH0g/5w3IAHeP93UFTZBURLPEyL6y4WqBAeFPtH3Wg73bwXA6s53PC5M9OEkfu4azU2iYHDniy/H5ZHmrMnRUIR/vuzIMZZwaY0icswn0OcVwPukzC0ftfMkOoKWc92ph9Hc/FrwUzFeaov9OjHwRzCqIhKlkjSavazmydZ+o 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)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199018)(38100700002)(2906002)(83380400001)(6486002)(478600001)(186003)(2616005)(86362001)(36756003)(110136005)(54906003)(66556008)(8676002)(4326008)(5660300002)(1076003)(66946007)(66476007)(8936002)(107886003)(6506007)(26005)(6512007)(6666004)(316002)(41300700001)(7416002)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9SNJ56bAmeNoheMN/U3dPjzXSPwbU3JKpQ28Euq0FTt9HHV8FB4f/HIuT1ZVxCkEUn+kStym/VumMdav8PiFJUhhEEtFNfjkdtFbjsCK7WZ3Jel1DM4veuklOFz/46HBSSqAjimt8wlyPhF93r4IyOIrkCoIef4b3fLrvbqpq1MVxXj3N8kD2uhTyldjk8ZaAigrZWEAwQJRmtXBs7zB+G6shhR/E6MSlDzq2Ac86oEBavOsug39Qqz5OrGJvg4mpS7xC3GK1Lp2/uGxjsYeaqC7mcUZEvcaxjZTIJ4VSOJawV9rWaEi/k3e/p9/8WG4lRdAnmwZacfMJTByUEaayCXxwBsQiaOYgJI4L7s3QHpQBYLZXvWGXb6aVQ68Vb/+OZ71/JaulOe/v5cZV0m9KlajPd3+fIqM1b86/HMurfcXeid6gLsT97UyvXlzeIuf5gwIVLXpIWmhtBFRw0p4FrnXb1TFaHTmuixFKFYMLEYg+uu/jBAGnW6wRXwqf8l/OcovH8j3j7xmW/FYokcs0itAyPwHtvZnFXioc4ntT57bBIKqnvp30H5jMVhucF+LTB9mS281lh9IsEKYQJZvNM07Wy1A1Y4IVRHS1LA0Tb7JSm3n4E6m0U6pL4JcGD2KyiunTT190QCfF8rhMFAkhNW3hfddb55/f4XjWxfx5u92V1ENSsQEoL7y3Bl49EnlcEBqb3qAAEKGIX2BepvC+5e14tTiLtOz0InIF+ShYtEVNPGtyRr08Nvj4tS41Jgs+PIvJafTdIR2FQsTPT5tVH71+T+jY9XLBxlB3cdRn8gyrRxoEC6xsHU52PgciThu5HGyY8Pg9HLmiai1+bw8/P5eO5i1P2OOKh5pCn5XlpvIxp4d1uzN2YGTa/3xWAB/mbLbPyJcW3QvFFbK5s0ytftuOMBIzbGtS6eNyar17gc6P174P420sqwM0HKlnUSfr2iY9iq1sFxC39VslvK+ecwDJNHpqZXKla24i3gzddzGVTUkECmWrNllr8hXU10KHs9vAOjJfnhW+SgN8I8Ds4RmbNuP/cC3n9T+Kg7CX6YuQvLYX/qk4+n2zGGKJ9EZffMq92yAM/i+0gcg+2M+GSnaefuK36ujZLDh4RP3xixhwX+YtRkHIamv+3qhUHQq0FL6wNxHMYvDEsyNGGp769TTByMLuileqrwjg/7C03f6LpEfjqvqPoPxarkfkNHGQPdwppPHocV730ghTAjPbqjndVoWhveApzV4XQHuPgFbLhW74ImGvrx+mrrIpV1sJLTJZL/+rKi6qHwQB4iW3FuK4Xv1/GkprJCloomnFTSB8f/Wc3TwQN21lAOnPpPqP7AE3lG5/kUwIYLMa4YXLBKiDNW7qc353IAOKOe+vqu5c2d64id7JXzpfzSrh5bJLJ0DFjliQgU1a68Ipc/Lax5Prg2pdWzp1olpVEVyBUkeh5/npyxi1IVBFC5M3x+XPCeexa2OA7fN0N4mmFYVMDgkX20gQde/roW8yS8crugEOKOT7+QgopZ6l+zblIjz6Ac734xC3I2htB7a+GuZrAWXckS8oJHq5y/eTw0zOEM= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd21aa54-b754-4fad-3f6b-08db2c75580f X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2023 14:37:50.4653 (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: 26+vXZZ0nTDy17eiOUXcItIuS0aGlFyHCZPA9lW3ukcvdWDhhutcQzPaCZaew30U X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8623 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?1761260474179862199?= X-GMAIL-MSGID: =?utf-8?q?1761260474179862199?= 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 --- (No change since v3) 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 Fri Mar 24 14:36:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 74580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp681529vqo; Fri, 24 Mar 2023 07:48:05 -0700 (PDT) X-Google-Smtp-Source: AK7set/O+Dww4lsq+8AGtE0SPQkubOq5jZ4iEooWtLapwQfkHbyQ5CAGaxb0WZP+JwhcnusuRl7r X-Received: by 2002:a05:6a20:4e1a:b0:d6:b44e:f644 with SMTP id gk26-20020a056a204e1a00b000d6b44ef644mr2961009pzb.59.1679669284882; Fri, 24 Mar 2023 07:48:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679669284; cv=pass; d=google.com; s=arc-20160816; b=YEvEKhVdMkwVMxz0Tk+wJNhPteJ+ORRypGPAbSL8JiycBnluin/fCCd3YWCOgvthpf DuVXp5xgSSv53kqmMp5bW9vL+RsnXUzq6MmgAt8JgTu7Qnk4ykjaSpH8TjfVksjPd+wi JZlDqn31UB9ytdCyjI/o43C/o+ogi5r9QzUlcY/iTB8aaxlJ92NlpmVbE8MSL5Exn6ZO NIaIs5z90EMBWbxl1vzgCBNLz7/23Peu4CPOPukJ7M+bqr74XAo1QhywJgRCgi4efrHU aHRbE4DVx/gS3MmiUCAgEL8T9FBX3geI+YMi1x/y8OwM4u7lVS2RF2451K0yQrvkBNQL wzBQ== 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=0ZbbeGlXq8UVl23v7QdPvF2RjzZHx2LPO53+RbV34S0=; b=I8JUCge54TSXh8SH1a5pAgFOGQTL+F2ol4VixI4vStZoroK+2GCJjsW7D/1c4MFO6E vTfye8PGMYvdfotu3tOTIgSEWl9Td6zkWlplUPh4iSIdAa4wvaYR0kB4PncDG4DcAEZz t2kFLkOrCye+CIbYmlkLZuinlgsQfyP/4si9InG6ZObokdG4NqN149ZR0VprMO+AmYzi dTr6Z44NdWNIPK4Aq18QhNk5FOfaVG0etM7LQqCxfrydhPnVT2RLR+oSoYyfrWhnaFnK +GwjTo3GUxtgPh7BvsCUImAyF7lmqLAbwCiiPUHvzqK3T+20mBN3RSTqExyEUzQ7G94U Sh2Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=eqmuPUrZ; 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 a18-20020a056a000c9200b005dde05007b8si22867627pfv.18.2023.03.24.07.47.51; Fri, 24 Mar 2023 07:48:04 -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=eqmuPUrZ; 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 S231986AbjCXOik (ORCPT + 99 others); Fri, 24 Mar 2023 10:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbjCXOii (ORCPT ); Fri, 24 Mar 2023 10:38:38 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2046.outbound.protection.outlook.com [40.107.21.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 193F810261; Fri, 24 Mar 2023 07:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cnnH3n6wse9a88iyFFi/dpcxJubKs0EjNiExw9mUHbArmqjaHllkiYmC9go0CL3ovkit/dbdl/seIcj0reannRMFmFQxVe6Tu6Vy+rMyTKCKHxkE5+6PvjLfr+lpaBDGRhMxY4fpecf5SGosXioqA5GEUVSI/GR5HxRfhNjlk5wJFhlOBSgnzqiVBeWjE2OsaABExF0BxDJ8y8mCyZAjUDxqJ0s80kE1EWZ7qiC9X82LIu3txiHl05/Pf1mF3GCTptp8Nj6HT5cdX7F1qiVAkX1oCW4D4gFuDO5lGvTzKStkh7qqJ2MxqTW9a4u+sF08SKWgmtd3l6JuhZjm/hTPYQ== 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=0ZbbeGlXq8UVl23v7QdPvF2RjzZHx2LPO53+RbV34S0=; b=F0spOvpJt5vH92KgMCXdDMyW4jTyDzZdVgtiqexVZJdy9abGL4lZaAJ8VQN75URSyYL5uBEK0PdVzQDjI/H+icvW6ETu+amH2eT9SYe0xyfHt2MeXaU+I+WQvHjx8GrRiq9I+7gybszxmryonAdTyfCdV05TFqaNoi12M5yTJ7ekJyO86DTv+trJbWmSwR5ymo8mmfJ33ypkGcIEPcwlG7OkZ+KWWOoTO3z5TEVi7JBOitJk4BBI38iQwdYk/+UtsigWhR/rmCl4Kxk5W3Cs3GiP99RJDRlnDueRT1tj7qnWqvM8csiKQRbaubTjGqqUvMHPEdCvvDXEFCKv5m65/g== 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=0ZbbeGlXq8UVl23v7QdPvF2RjzZHx2LPO53+RbV34S0=; b=eqmuPUrZU5Dh0ypQTNzcpzHt0TXFfZV+TUzlbM9jHLJp6OFWCWBbZsG8zopYtq44oS5AuYS6/quBJO0mG+HOPFKhplN/Fa2vt+pkTUCRElTmoVDohcXobuyuXEDKwHbQzIjI8vhFbWL/nxtDk5K2s7vJVPYB7m0rRgDBm2D8YltUHSO8U91RotazdoIznh5Sf5y+UVQmOTwDRwwwlVihRuZnossz1GvIfdmPrZ0W/dool7nlNCn0CGCKgT7CgzrACB90Hji+SDNzMohl+dL0OFcVEpMnbgQ5GhTp4K8QX7Twbfe/OyxcaVh5J4P0lijosMkyZL3nbTyk3WYKa7NIFw== 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 PAXPR04MB8623.eurprd04.prod.outlook.com (2603:10a6:102:21a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Fri, 24 Mar 2023 14:38:00 +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.038; Fri, 24 Mar 2023 14:38:00 +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 v4 5/5] pinctrl: s32: separate const device data from struct s32_pinctrl_soc_info Date: Fri, 24 Mar 2023 22:36:26 +0800 Message-Id: <20230324143626.16336-6-clin@suse.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230324143626.16336-1-clin@suse.com> References: <20230324143626.16336-1-clin@suse.com> X-ClientProxiedBy: TY2PR0101CA0022.apcprd01.prod.exchangelabs.com (2603:1096:404:92::34) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|PAXPR04MB8623:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ec323a2-8062-426d-8bad-08db2c755def X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CDHPgVVOPnkvpeX+P6wGgX060o3YLJgbDyrh4WPaFIgNWEHby5Eg/Rz8Y5+t8D1qmGVC1ZAVDA5GihXN+TlfM5IXQfe7QSFd9FdJRF7LLPaN94yYqxK2IDHMLA2nMeUkeh1iKyU8+h/QzoIaPKrApENOawgy+Zl/hzj3wbHofadVaSwpQLmBh+1WFy+YJ3ubc6+JH5ZBNI6ofZ9DYjNjy9qxTgkJaTymy6xaf/QXyw3QRkY4w8m5jqDcsWmM+5EurMD5tYQUimdU/5GTZc3xA16fp2PYSI1xb3FcbEFfXY+Kp9MD8XnG2bwm0PebFqeWakiStejNJ38ZteykqOsMjSpI2sgaR2TO7zVN8nDNSC1xsZIcHtpW8yaOQ4ieRDuqWYnV6LavGW9dHXGRivK5hqpsf/ogNFXQj0PuisAqeinp+37fE5QOf8eHnc7ELauFKxKpYUTFOHlQrAxEx6vPqkxIVKQf3y6ZW/xcKsIHhEJ+TRRkB4LUO0RHfMjKG5ZBsNdIXW/9W+rMii0IYzBGEOGzbFf/pU4CPjW4Jcn09enAT7nb4wWWbrWZ1p6qEbDSKsQa10z4K6VXPC8NR0iVENi5vXi9YLGqtHElWrUvTZtH5mt8pjtSXeqy2pcpfh7/zF+ciYFCcuFDeWwMQuS8xg== 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)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199018)(38100700002)(2906002)(83380400001)(6486002)(478600001)(186003)(2616005)(86362001)(36756003)(110136005)(54906003)(66556008)(8676002)(4326008)(5660300002)(1076003)(66946007)(66476007)(8936002)(107886003)(6506007)(26005)(6512007)(6666004)(316002)(41300700001)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h2JjuliZJNHRFqCh5uEnsfIuLpDSFBzHiuXsIWWTgG7Yhj2bgsPziAyoNlyUD3ccNLztyGvog+nXjyTrXIAYzKfH8kPMF2huCFJGvq4FyYM11qLWNrnmq4wTLNNMv5lhWyyHpwPJbqPbwePjMB7ORtsxGIPfFPq5g0mRyXxAEhiVNGsAqhRASy4fYSHlNafoTm8rs8h73iI3yqq2hWpYiSjpWouSmMe+Ww4oFOWiC9nq56CDRIypmImfNnkXTEySEBj2+4Ier9DUnZVf1BXNpkpRtZWZ2HW4QEcKnU66YleTJn+RDn5egXQurllqBBJkJ4l1XHIeuA2jfzcLcUuX2SYgMxnQOqSmos1gNQQAgS3VPcv1GTxm+I+3TXytD3BtARJ5elQph7UtBp4cOgXAnPjYjScwxfqBfNon46YPJSMzkMLnam03rtH/HZ0xO++VI28/AE+TDrUPVQYW2yFSbNaLx68a+ia603ep2OsH8PIIinxT5G3QprbK+iTo2+rClDGxNqipQOuf9F46xKzC0e9CNETJdlmDBDrYFt8kr49tAChmAegExgBXQ7eiBBwbBfcsmlc8K3bNEu1UZOO+Tm6I5DNZDh2iJGIFtw9lLm/60QjbehZqvtMZwa/AUXFV2Bt0LQt8ht74CgtQ1yvhCRTpzpp7dLM12KS/UcZx769I2fV2FK1l/FLW1j4evG5kkiCliWCUvL/FqINrPvqKi4qxaTHGxiHHYiOc29SeqEWTCyPuc0jrcB7CryRu58ozGf8vwwJuVoYNbnD+cFhSv0qn8zYuUvqme6rBnwILUl1iKLuDGNRVJmlNB6JXXZ+dNx6kcp4vRzIhk6wBnSst/S41QwSqyUwURAEofnNTZOY8Wu1zOPk2dwKQrHiXmGVF/cKwBIkutpZHve6urrKWRs8uweXPoUm4Jn5zU5LhfIjBaDGy0qJGLgoyUzW8ZwIWpho2Lcx0jyVuC5INg2GFKpthId6t8JjsxoSxHH5IGg48CPCBjyVv9x+yPJ3UBU6C9+OwDAWdV1b3X8G7sady0Ys3cvXbNSP8aGE2ywNDL9/tyynjDg+aYxHk38LuzhLBb5waPX4zY/K0J1g2GpzOm824QBdVXPw6ZwfdyEX94+NNfXTWQITyoOULBA8FW81IpELzzXR/qgv3+8HglndQvhZkJOxKE8exc+K9Vg0Wz44vdsAA8orOfPQ+xQoL3WEcwQCaU7R2LXwW0uUG9Wq0VpSAKScIaFB5073Hhy3hg/mIDF9cs0ro+AreoPvtqnl75B2YFROJvO1wNGHyu2ZrvyWaGUV3DJ5IVkTv7C/fsuWIbqIGLXnmJ7tvmvK+ffxJrA/Mqt2ypN8caNDI4CXmigfZzx5PS5AbiwTQr6QqBciZluzuF4Njh9UelNGnaVQkhUHhcJxLS6tbQZALD2Eaj6za+ru3Cc40lr2o1Ye+b6LQyx7pKRhQaPc8HVds7Iug3C0/U4+wuwd7Z6D7G9/uU5zMyd0at+atSgznZ+IzS0W9sWStovAn5rfx6Sv6cNgjpYW+L8qDEgJaqBJJM0Iu1iDqYJxCmlY6weN1Iw4DC84= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ec323a2-8062-426d-8bad-08db2c755def X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2023 14:38:00.4020 (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: gwatRvlSDAO9ZTZ+MBvqy1raOv53Z/Z0faSu+f0eRrCA2HzhblMOoNZ0NtXe6ZRb X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8623 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?1761260900136325950?= X-GMAIL-MSGID: =?utf-8?q?1761260900136325950?= 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. Besides, use of_device_get_match_data() instead of of_match_device() since the driver only needs to retrieve the .data from of_device_id. Suggested-by: Andy Shevchenko Signed-off-by: Chester Lin Reviewed-by: Andy Shevchenko --- Changes in v4: - Retrieve the matched device data by calling of_device_get_match_data() and remove unnecessary type casting. (Merged from the previous v3 series [PATCH v3 1/6]) drivers/pinctrl/nxp/pinctrl-s32.h | 14 +++++++++----- drivers/pinctrl/nxp/pinctrl-s32cc.c | 30 +++++++++++++++++------------ drivers/pinctrl/nxp/pinctrl-s32g2.c | 13 +++++-------- 3 files changed, 32 insertions(+), 25 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 d9f3ff6794ea..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,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_data *soc_data; - if (!of_id) - return -ENODEV; + soc_data = 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_data); } static const struct dev_pm_ops s32g_pinctrl_pm_ops = {