From patchwork Tue Sep 26 03:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 726827 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EDEFE81815 for ; Tue, 26 Sep 2023 03:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233011AbjIZD3W (ORCPT ); Mon, 25 Sep 2023 23:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233498AbjIZD3T (ORCPT ); Mon, 25 Sep 2023 23:29:19 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2051.outbound.protection.outlook.com [40.107.6.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE991E9; Mon, 25 Sep 2023 20:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OcCQj1UB5cm2W1CPs5DYSUE4rd/csDoGqQXiFIgNrNS+0u9Wk+kBIwPb4yQCm94bxg/Wcn4DgxtQIzhi4x3ov39XIrOoVcTSML03Os9AuyI4Aaejnms8vMC+xi99U/m+NZmzaEgHnXXlupPo+e985qS97Niaj+N6vyAppkHAlINRjKalwB6HUXEQIjD7MxY8q+i2Yhl2m/jtGenKDHZqyeRG+rLYxIt6eM9Xy/vznY8nBB7wUcBeYZpANkFORIUNZ9tGHUbiHq3Tmvu8n8jrlI0WHz0+Nc01GJRsOTULDytQqskmnU4FVK3FKUxgEWakGiVgNT6CEsA5RZKypa1pJQ== 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=3x9H1Ce1qmUmynZ0C+sr8L+tCdY5jnEewoTuImSmj+c=; b=SYA7ltTuq6gQ2tff3oVU2184UzKHIo2F9gah/wXsdJfcF7jNyNhmUha296UKhQ3tP96vzE843Y7W2lnk2S4UUS7VNzgbybuT+rUx/U+UmyTRcFdt4+Qb7ybAXxTZkpG+tRlu7cwRJ5TrKnr/fdyNVYRoE70THB5HbetxPB0oYc9kM8cbvBxwoXoZfQhTXxFNwHI8UYmRM0mJiMMsB6xQDAjrHC0IJqxKfeCwD0z/CL4yiMBIWj1djVBzE+dwXxYdtcVa7Dk6GkUns2y9zFM9hYI+IXcSC9Fu3GM4gsCg5ba+60EFmAbd1GVRXzz969c6lJLGHBnYo8G1+egQTvr9Dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3x9H1Ce1qmUmynZ0C+sr8L+tCdY5jnEewoTuImSmj+c=; b=eg5ENCGJ406G9XxUNCVvhmKcOd5Ocye+vpF2LiE4uIRnluSKy9faIIpT5OFdaSNva3DJk4hSnJiXRnGDf7w/GBJi4DT4I/xn80nsqNXlhMNxi45/YFaNEMEIoZaZ6UjEr3x4FPR+6r4qog3ntGd1rgZUQ1FMzZy3UgUm8ui/w0Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AS8PR04MB8436.eurprd04.prod.outlook.com (2603:10a6:20b:347::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Tue, 26 Sep 2023 03:29:10 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b%3]) with mapi id 15.20.6813.027; Tue, 26 Sep 2023 03:29:10 +0000 From: "Peng Fan (OSS)" Date: Tue, 26 Sep 2023 11:33:21 +0800 Subject: [PATCH v4 5/7] gpio: vf610: simplify code by adding of_device_id data for vf610 Message-Id: <20230926-vf610-gpio-v4-5-b57b7f6e8368@nxp.com> References: <20230926-vf610-gpio-v4-0-b57b7f6e8368@nxp.com> In-Reply-To: <20230926-vf610-gpio-v4-0-b57b7f6e8368@nxp.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stefan Agner , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Marco Felsch Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1695699209; l=2667; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=6f39vc2cftNdy+/GaahiBhBp1bGlVPLOucytL1yIoAw=; b=GHK0VJqZSSbmQY15QcyO9yutCxZdbcD+4lti8idqyJIhChzz+qc79NZfDXFcp4QSQl7pTAD+C cGGCTjf8J2XCOTmqhDJvXZ8A2qdfL4JW1ER68DNSRWhFIKBFXp8iEq8 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0054.apcprd02.prod.outlook.com (2603:1096:4:54::18) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AS8PR04MB8436:EE_ X-MS-Office365-Filtering-Correlation-Id: bd04cf7d-522c-4dd4-2655-08dbbe40bf7e X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RP8SFdOF0YBqZ/26+z+ot4RCUy36X1+LhSi+9K5AFvam9kYhNNP44e2xHvesJW9xHDJJWyPABSYbftd1LisTxNhr2lJ0dzkg7OAN3PK0Ic49ehyZ1gJQ7oGOZVM3jmGfiewUFS+0GKEEichEK08jmhLNtx/FORXzwRnM6ZXXRC6kWUtrP3VRmJMG1Q20doqlIKgTSRLDSjfdJjdZDmAj4LiTdTBIzdg7x+DglJBjx8gDyYBqnXquwseHf7X5rtX3YlfAS3BzOf79HNDQAr13IE+1mOtKtqU04jaubCDZDVlCgHoHwp7TgVpCwj48fqVUo+8un1faQdfuMvN5yH/gGKQr3MasvVVH+BNc6uLCQDGbHo34uLSugQN6pd+5zJq8pf9s+wxtPT1bANsccsLTCHLp1KB+N+vkQaNFd046AWMu1HvYTGr0Rz6fWFNPZMK34MC9MBjNNLJld8uehAyYNyNHQxwMmqiRUCxXM0up7pUCozJt9PXJEx/JrRO8se0tmzTXPtTrs6chali4jZD195+VDvYY6W2Zf9A/EY1WETsSmrnDjhuUvSXiiZB6KTGSYEz8BjV0afbkTC2VtPtAvPMvoTz6wp0JMHfAyjWYf/cXgN8YQSxM98ZUTYKqGxCQ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(136003)(39860400002)(376002)(366004)(346002)(230922051799003)(1800799009)(451199024)(186009)(41300700001)(8936002)(4326008)(8676002)(7416002)(66476007)(66946007)(66556008)(316002)(26005)(110136005)(86362001)(2906002)(921005)(6486002)(478600001)(38350700002)(83380400001)(36756003)(52116002)(38100700002)(6666004)(6512007)(9686003)(5660300002)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CAcZTDreHTPGtKZ8DHoeccpWrf5h?= =?utf-8?q?WUgq3GGYK/NZToy8WKwAbmTTXfI8w1e6n8u5ms1uHy2QJ/0oCtcHDmLAAnKotOneW?= =?utf-8?q?bBezq2ZT180k23Q0RKuPWi7IUQm9UbV/KaJrKCw1JVPcvLZNITg4h/uGeP2BBfPXY?= =?utf-8?q?yQp81zU74itHopPd9oaaj+dFWrz2Wqnuy7gM3b6sO0qdazPgWBROKr0pgboW/1VK8?= =?utf-8?q?o7GkKptKhpbv2eqcxgn/myn9xx9sJZnJnVVdUpjQQMkkn+3k/hphbcmXakTFyBRHE?= =?utf-8?q?xmQ2Fqni4JAlR4Wt5jLgBRY2PmlQJRLKEjCgbCTEehQC+/aa0J9LUM8rqJYDQKaHp?= =?utf-8?q?/q6j1oJphyn5unWbZXrp8PQYI8Waf5acmCkKSfX7GunndX+zRuOYxGerGr7Ejid99?= =?utf-8?q?hdaOqySt/TJen4PTGF27SPr4Vy4IiGgTnddbje00RcoK0DDQdfqQqGX0LbsTlvgYN?= =?utf-8?q?e/pqeE17bdD5L19isOvP/RaiAcxH1dfD5WH4fZoYNgOE4ec5MIOYe4qwZiHwnosMl?= =?utf-8?q?GJRU9O7xXprwkT2zbp5XFRdD37jgfBQsmoxdal24YEWrgo23bpU23vJmC/31r4u/8?= =?utf-8?q?UqrZWS5ITaOBgMVgovUXLC0qdSs6cnbhWFoYDls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PyUxiM2FKFY88SgeyAppQZLg?= =?utf-8?q?wgE+aYV/Raz4?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd04cf7d-522c-4dd4-2655-08dbbe40bf7e X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2023 03:29:10.4137 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jfN0lspNCtaju7KSpxg+Jh3+FTWFLKhNBVoYhLoVx97ShjN/BnUwqnkCjZ1eSQVIhrdoGNYDvwiDHDe38PDuJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8436 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Peng Fan Add of_device_id data for devices compatible with fsl,vf610-gpio, then no need to check port->sdata is NULL or not. So code simplified a bit. Signed-off-by: Peng Fan --- drivers/gpio/gpio-vf610.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index 49867d5db642..c48a3bdfb942 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c @@ -64,6 +64,10 @@ struct vf610_gpio_port { #define IMX8ULP_GPIO_BASE_OFF 0x40 #define IMX8ULP_BASE_OFF 0x80 +static const struct fsl_gpio_soc_data vf610_data = { + .have_dual_base = true, +}; + static const struct fsl_gpio_soc_data imx_data = { .have_paddr = true, .have_dual_base = true, @@ -74,7 +78,7 @@ static const struct fsl_gpio_soc_data imx8ulp_data = { }; static const struct of_device_id vf610_gpio_dt_ids[] = { - { .compatible = "fsl,vf610-gpio", .data = NULL, }, + { .compatible = "fsl,vf610-gpio", .data = &vf610_data }, { .compatible = "fsl,imx7ulp-gpio", .data = &imx_data, }, { .compatible = "fsl,imx8ulp-gpio", .data = &imx8ulp_data, }, { /* sentinel */ } @@ -96,7 +100,7 @@ static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio) unsigned long mask = BIT(gpio); unsigned long offset = GPIO_PDIR; - if (port->sdata && port->sdata->have_paddr) { + if (port->sdata->have_paddr) { mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR); if (mask) offset = GPIO_PDOR; @@ -120,7 +124,7 @@ static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) unsigned long mask = BIT(gpio); u32 val; - if (port->sdata && port->sdata->have_paddr) { + if (port->sdata->have_paddr) { val = vf610_gpio_readl(port->gpio_base + GPIO_PDDR); val &= ~mask; vf610_gpio_writel(val, port->gpio_base + GPIO_PDDR); @@ -136,7 +140,7 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, unsigned long mask = BIT(gpio); u32 val; - if (port->sdata && port->sdata->have_paddr) { + if (port->sdata->have_paddr) { val = vf610_gpio_readl(port->gpio_base + GPIO_PDDR); val |= mask; vf610_gpio_writel(val, port->gpio_base + GPIO_PDDR); @@ -287,7 +291,7 @@ static int vf610_gpio_probe(struct platform_device *pdev) (device_is_compatible(dev, "fsl,imx8ulp-gpio")))) dual_base = true; - if ((port->sdata && port->sdata->have_dual_base) || dual_base) { + if (port->sdata->have_dual_base || dual_base) { port->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(port->base)) return PTR_ERR(port->base);