[4/6] drivers/thermal/rcar_gen3_thermal: Convert to devm_platform_ioremap_resource()
Message ID | 20230626124334.15100-4-frank.li@vivo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7467253vqr; Mon, 26 Jun 2023 06:05:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ECFiR36+r87duLPlMRUx6WHj8yV3pmsx8PN5vPOg6MompBSDFs5k6vZYj58WS8DAZsuKt X-Received: by 2002:a17:907:970f:b0:990:27e2:7f81 with SMTP id jg15-20020a170907970f00b0099027e27f81mr3256878ejc.31.1687784745687; Mon, 26 Jun 2023 06:05:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687784745; cv=pass; d=google.com; s=arc-20160816; b=mD5wLlHHf2ISaSARCTT65is6d4Pu7sstG5IXXynxbL0zHO5dE42AQwi2+RGCQuhzRV 68sz47lgy0qeDGKDO6I5f+1S0YtKRYat2jUW8vsxzOHi15AYRzz83oG9mLxD5Vxc4TlA Hpbv2pzVV1qOyLPiUNoMAyz1iTjuQ7kjvjBHKl2+uB8HxoGRfOOqjSVRqFfRS1/0fN8U nytAEqiaE39lCOLTlGnWpH/+7kBKmAXq0CeZ8NytMb89paWqgqWbtRfKCZwS+UwRmCVU ov3JyJBvFpQnNON69C8YUaj3Tjyy46ApiivkzJvsmXq2Q2gcC7rVrS2HKEIOt3JVe0CU y5iQ== 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=/Q8iWy4Ib3U9fQybucQ9dbTjbgZldNv/RPDvTadx198=; fh=fuE7B8ip+UuRYp/yeCOPrX8hhnGv4MRUxcm2DDHYPRA=; b=XokjKUB1dzlH00PwHz4Gu0cB1RN8Aj+tIfFrP0yXxX/KqvwApYAQiIBzvrycR0i396 a6rZ5yK1OmXE4jCqqdRn2npxeh8jWP5KzmdnZPLORi+R29pQiQoq0JSP4u1Xya5sT8d3 mypidfIUusOb0wf3dT36/0DrjAWE8W0sp/gLTY366DtwcEk7eGgP+5/3rkH4FTksbAvq 1EVy8txoOT+j9zsKfu8H7HDmuNhd3KQJQGiBXQLrxodwO4YASL089Cn3MpBF0KOtKb62 +BA6MhUPfJ8AacJDIenX0n2OqV4eaLd2WF4I7Aq0rW7I9JvBUIveKyw60cOSwJ4NxZe3 fw5w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=HqaN2b28; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dv5-20020a170906b80500b0098d73b25019si2585983ejb.724.2023.06.26.06.05.21; Mon, 26 Jun 2023 06:05:45 -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=@vivo.com header.s=selector2 header.b=HqaN2b28; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbjFZMoY (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Mon, 26 Jun 2023 08:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjFZMoK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 26 Jun 2023 08:44:10 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2136.outbound.protection.outlook.com [40.107.117.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C5C010C4; Mon, 26 Jun 2023 05:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PtC+yvw7SD5A9waJYhYc8ayxC0CwKLv/Xnat427dBrvfB81vMMRuszHyXL3oZvQQ4Q05HGbLvzWZo6VGCLbt67HpF3xqozLfZBH3pdJe2Y6nDqkrKQqcEAm3OVW7H502EXF44cgKEoTk2OE8rbi4oULxeLe6XwdBbIj4ZFSFfbDCkGDYXozurXPbcNMgvJei6u2zrtNHm0La3WS4uIYH21uBBabZIC+rwaa3kVD/KHz/0bgDkKlt2ZPMpcLRrh2SneYQRBwD+D72vsbfcT7N0kVh0WQTtySW/iTfOh1h+Ocmila/c8Z2FTtZzqhh98pQguKjRhVM1hdEur10QhUsWA== 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=/Q8iWy4Ib3U9fQybucQ9dbTjbgZldNv/RPDvTadx198=; b=VOu+Pin+0pdicaMsomTF7DeXajNc9gbQ25CCFRdEQAPpFpfQ2MtaKo9EcCg1Z+UlegvcRpR/r2gyWVU7MtmVj7R70+kN2XVX6K8Ht0as6i2iEEBrujXkub7uupn9/8qXVAZzjkHeDJRcFQ/LcBaj8I7EGafun/J8NXGf5hUclJec7OlcnI2LwkOYSxUHE+iqgIA/vW0P6YI6PDWE3u8uW3um8pwoi1aos7XvWu5vPATOI1AFEke5r/VLsI1+HYYlGiY5f8wo4ksnXzvN81/SgFjzY9dDdvwHwkRDeLggyglKf5OQY34Z9r4J5PIokPa3DpUiX0vh386pEouZyxZY3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Q8iWy4Ib3U9fQybucQ9dbTjbgZldNv/RPDvTadx198=; b=HqaN2b28vO9Fm7EoVIAhEWCOe437bGQE253SVjRgGYf4zMbAK+0LOPyyajSd61ame+kOQWv3Mb01QC5uzIFy1e/C4lWO9e/2dHESpSJME8gjOzlmuCqxLZ4BJXvoPwE08DFmY7DA8El9XwwaRie7PSuFIBsLynnRYq+JUwnmAUUW0+I7mLwPNIFJqm7Z4x+edqZMiPwS7d488GpgCpf4NOOLa7qUSeaTeAtuwSKuTKvFEwbvapTIAB8TxitcTagtBhcvR61VSbzPODQgNmGzwYzhXkZ+1gcKUWTqtwtz1Jgr01KPv2LhmXopEnoJXyHgZ7VrQpym2iZC0vQyeBN9ZQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SEZPR06MB5320.apcprd06.prod.outlook.com (2603:1096:101:7f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Mon, 26 Jun 2023 12:44:00 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6521.023; Mon, 26 Jun 2023 12:44:00 +0000 From: Yangtao Li <frank.li@vivo.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>, "Rafael J. Wysocki" <rafael@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com> Cc: Yangtao Li <frank.li@vivo.com>, linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] drivers/thermal/rcar_gen3_thermal: Convert to devm_platform_ioremap_resource() Date: Mon, 26 Jun 2023 20:43:31 +0800 Message-Id: <20230626124334.15100-4-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230626124334.15100-1-frank.li@vivo.com> References: <20230626124334.15100-1-frank.li@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0003.apcprd02.prod.outlook.com (2603:1096:4:194::13) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEZPR06MB5320:EE_ X-MS-Office365-Filtering-Correlation-Id: 27489156-4d24-4c9e-7328-08db764303d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /bbTi5fW2TdZinTdde+aWlqL+WIafBttX+ShsucPbP+UqRZ7AezNo80sv4ud9jb82z2BhbelVLGSZyFJtCeTdkQqL8z85lhenyYRitWG2CphZJLlzIF9lQplf/0EeXXR+zr7xdcpxJuzkGganFMZd4lPpLbhhrvWsnzgltgOIxFxrS2GIDx/JtyqB87ueNGx2tnAy5w564mN+ZxzWvRdQLViqLY9pq+i37Ny7qZseVzGVSKEAT2bWhPtWS8uxaIysyXHRJGCszq/+OiNPYBR0ObGRhEXRejEqzlTVYl/IetKccLel6b57EXmCnK2axatOse9VaDNQH6IFr97dQUEO1Gr3axqW2JLXsfAXl1gqpeAadB/CaZeKUJ7q3GozDqx+5Y7PWXvD7Co3UrLPcuNbaLxtzqcBdZ2DIFLtm2L89Av8nXIDGeoBdY49DC0ZudRSgk1RPC/MRu4uwLc1PklyH2th21CB75MrsnN5DsJhQAAyZ0d2Wdgd7iWtzLpBx7OuAeTxykJ+9ut8nSpw3O3pVP32YdsVvVTL2iIxX4m1Q7KmxfetTzJNkBHNXYbosmsJbJMYpqW0jy6Q9YJ/PP7zB4dQdsg2dUWJtUx3Xcw+n8oVqz5YYDGbAHpbgCzl4dA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(136003)(346002)(396003)(376002)(451199021)(2906002)(6486002)(52116002)(6666004)(38350700002)(38100700002)(83380400001)(2616005)(6512007)(26005)(186003)(41300700001)(110136005)(86362001)(478600001)(36756003)(66476007)(66556008)(4326008)(66946007)(316002)(6506007)(1076003)(5660300002)(8676002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5tJw2FOGln0Tu2E/BYd1wBy0HCBSBFfWIxoP6aE1fgweFtjJL1/SeRZkfDWNOLRX0pqVk5lqbnAZXsfD9PC0zxHeNXdU0OfyOIGYixyX6X3WOhB67kxoOklOWP/NsMlJ2uc4hCwuRGTtLmAowH8xLKvhZ6ngWe4W0gdcNRytTEdnWwnU8dM5CvBnvEK8mpKErc8H7kfDCeYQSwJTUumIY4Cn53IhsRx8nRifRZzP00bQe/T6hMg9QI4rl3wUsHObYCwtCyYt00Sbmg0APw7W6yd+njqi3iYzbTIy8gciBnELqyr3/LUVJLuHqoWHPx08PV7HAG6oqyDK7OI3jmImA6b1fDrM1WQDAZ4pCPXwxJUIjj7CT/rI+XfZxumvevkUowfLh6znEii/cXvp84XhgnkPdS9UR7WFDsP3O/A6EYHAkPBp8xsruAB4t1tCtuvZz9UDH+uKAWyLDbD9kWepyCgBII3ut9Ai01oc8Efj6aSKSU+29yvl3fpvm4R0eJ00cly+7QfII3LFwl3VRK3HVcfo1tMClePsPIYtxY78VUTjzO0HkUCDsX4Jf5HHKXEopu7OrUFhdLDKUVv5SpmvKX9dRSTw7cXtu4DP/PsWNMYwlZunD9tyzIxuVWvQz1TLf2oPqmpozZM+S9dxB7MYV/G5LstKKP+y9qDkHqhstLaGyGfVTtQGoUVq0Hqr8DPxwy87NL0t/HBtLwFcDeSw8k2/EAfoVlo5AeL1uonqtC8HOtEoK0uzzjzNHSU4IykjApqiWq9xgNTBhR7Z1VSaVsj4v1VJcfvA4CiLZT5zTypkvHMxXSGKWNcyKbrZ9jv7OJASHzl5NOt1uwEJAcJLmmvxRty5y3zLNR4/ETPyUmYhDRGOPTabAkE5a7OEihFYoZ/V6ccu1/lK1paatAVK8MXOeX0Fs/CbIPztPGy7JhS2z/RkDDln954ZIpX/dGIobGD8da4h8kFH3notZ+lI24DOScJd4pPjyTuWneTesT4l63coPdVdc35/bZRiSP+ETos/c0/FQcc4H1hM8jQGcOnKRzWKVpB5nJlsCNbpqF0zoB5MVr3aY9GaSd3//6M3Rq14/xDoTWfnstUJj/0VbC1mTMzFTQQOwiktj/IzEp4XCtaA6vXxHnO2prgtUyZDrG3HoZJgVIl9JLii1Xl59CLaKhnqXGSNw13ZR4bz1LM+PJapexcfrxcMaqJ+ry/ZEbA4zXwnE0W91Na0dUPS4NVUtMu7vXr+2lvWXS+DtBZzJKKjNAIoHcoBzuFQqqcJZhQw2f0m+plkAvsWErcqLtvqnvukzvbaNehGXXtefHaacGyEei8JBD0LjhI1QQ60dZRUvjDu0PPCxcc2q6gOwbtSgZMRiVh64s848ivX29ppOLdvOd1kLEzRiMioyLUdB3Th04hvSlaaXmN2FL1zWSMGLnshdvkiIj3ewreBTisDAUXvUR8M5/8VZobiawhUb5Bw8ohvscqqguxPDn1tTj5pC0xczR2XBiYzKA9ysfwpEkQSoMumj7ZOnUYUd+OEC2uQ0pkwMy13Ejy5iFBYKQYHRQb06aOgEkTMQoaeDUgdqniyF+3Kx85kCzvGQNZ8 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27489156-4d24-4c9e-7328-08db764303d8 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2023 12:44:00.4568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OxfdeJE1sSYix3VZSz9vDMfZvlJk31sWopWFfIK49eDxbIr2YVuij69t/7s27Kn0e4Jn219l+CJ/dfTonCPr0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB5320 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769770577278469944?= X-GMAIL-MSGID: =?utf-8?q?1769770577278469944?= |
Series |
[1/6] drivers/thermal/k3: Convert to devm_platform_ioremap_resource()
|
|
Commit Message
李扬韬
June 26, 2023, 12:43 p.m. UTC
Use devm_platform_ioremap_resource() to simplify code.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/thermal/rcar_gen3_thermal.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
Comments
Hi Yangtao, Thanks for your work. On 2023-06-26 20:43:31 +0800, Yangtao Li wrote: > Use devm_platform_ioremap_resource() to simplify code. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> This do indeed simplify the code, but it also breaks the driver :-) Before the change, failing to find a resource at position "i", breaks the probe loop, and probing continues and the number of resource described are the number of TSC find are used. After the change failing to find all possible TCS will fail the whole probe process, even if some TCS where described. And not describing max number of TCS on each system is perfectly fine. Nacked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > drivers/thermal/rcar_gen3_thermal.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c > index 9029d01e029b..5c623f13d9ec 100644 > --- a/drivers/thermal/rcar_gen3_thermal.c > +++ b/drivers/thermal/rcar_gen3_thermal.c > @@ -481,7 +481,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) > { > struct rcar_gen3_thermal_priv *priv; > struct device *dev = &pdev->dev; > - struct resource *res; > struct thermal_zone_device *zone; > unsigned int i; > int ret; > @@ -504,17 +503,13 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) > for (i = 0; i < TSC_MAX_NUM; i++) { > struct rcar_gen3_thermal_tsc *tsc; > > - res = platform_get_resource(pdev, IORESOURCE_MEM, i); > - if (!res) > - break; > - > tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); > if (!tsc) { > ret = -ENOMEM; > goto error_unregister; > } > > - tsc->base = devm_ioremap_resource(dev, res); > + tsc->base = devm_platform_ioremap_resource(pdev, i); > if (IS_ERR(tsc->base)) { > ret = PTR_ERR(tsc->base); > goto error_unregister; > -- > 2.39.0 >
Hi Niklas, On 2023/6/27 0:28, Niklas Söderlund wrote: > Hi Yangtao, > > Thanks for your work. > > On 2023-06-26 20:43:31 +0800, Yangtao Li wrote: >> Use devm_platform_ioremap_resource() to simplify code. >> >> Signed-off-by: Yangtao Li <frank.li@vivo.com> > This do indeed simplify the code, but it also breaks the driver :-) How about the patch below? Can the following rcar driver also take a similar approach? diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 9029d01e029b..0cd9a030eb9e 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -481,7 +481,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) { struct rcar_gen3_thermal_priv *priv; struct device *dev = &pdev->dev; - struct resource *res; struct thermal_zone_device *zone; unsigned int i; int ret; @@ -503,22 +502,23 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) for (i = 0; i < TSC_MAX_NUM; i++) { struct rcar_gen3_thermal_tsc *tsc; + void __iomem *base; - res = platform_get_resource(pdev, IORESOURCE_MEM, i); - if (!res) - break; + base = devm_platform_ioremap_resource(pdev, i); + if (IS_ERR(base)) { + if (PTR_ERR(base) == -EINVAL) + break; - tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); - if (!tsc) { - ret = -ENOMEM; + ret = PTR_ERR(base); goto error_unregister; } - tsc->base = devm_ioremap_resource(dev, res); - if (IS_ERR(tsc->base)) { - ret = PTR_ERR(tsc->base); + tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); + if (!tsc) { + ret = -ENOMEM; goto error_unregister; } + tsc->base = base; priv->tscs[i] = tsc; } > Before the change, failing to find a resource at position "i", breaks > the probe loop, and probing continues and the number of resource > described are the number of TSC find are used. > > After the change failing to find all possible TCS will fail the whole > probe process, even if some TCS where described. And not describing max > number of TCS on each system is perfectly fine. > > Nacked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > >> --- >> drivers/thermal/rcar_gen3_thermal.c | 7 +------ >> 1 file changed, 1 insertion(+), 6 deletions(-) >> >> diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c >> index 9029d01e029b..5c623f13d9ec 100644 >> --- a/drivers/thermal/rcar_gen3_thermal.c >> +++ b/drivers/thermal/rcar_gen3_thermal.c >> @@ -481,7 +481,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) >> { >> struct rcar_gen3_thermal_priv *priv; >> struct device *dev = &pdev->dev; >> - struct resource *res; >> struct thermal_zone_device *zone; >> unsigned int i; >> int ret; >> @@ -504,17 +503,13 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) >> for (i = 0; i < TSC_MAX_NUM; i++) { >> struct rcar_gen3_thermal_tsc *tsc; >> >> - res = platform_get_resource(pdev, IORESOURCE_MEM, i); >> - if (!res) >> - break; >> - >> tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); >> if (!tsc) { >> ret = -ENOMEM; >> goto error_unregister; >> } >> >> - tsc->base = devm_ioremap_resource(dev, res); >> + tsc->base = devm_platform_ioremap_resource(pdev, i); >> if (IS_ERR(tsc->base)) { >> ret = PTR_ERR(tsc->base); >> goto error_unregister; >> -- >> 2.39.0 >>
Hi Yangtao, On 2023-06-27 10:58:16 +0800, Yangtao Li wrote: > Hi Niklas, > > On 2023/6/27 0:28, Niklas Söderlund wrote: > > > Hi Yangtao, > > > > Thanks for your work. > > > > On 2023-06-26 20:43:31 +0800, Yangtao Li wrote: > > > Use devm_platform_ioremap_resource() to simplify code. > > > > > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > > This do indeed simplify the code, but it also breaks the driver :-) > > How about the patch below? Can the following rcar driver also take a similar > approach? Maybe it could, I would need to test it and I'm traveling this week with no access to hardware. But I don't like the change you propose, as it makes the code more complex without any other goal then to s/platform_get_resource/devm_platform_ioremap_resource/. If you have a reason, like trying to remove platform_get_resource() from the kernel or such I will consider the change. But if you only want to change things *because* I think the current code do the right thing in a clear way, look for resource, if found map it else use what resources have been found already. Adding special case based on return code is IMHO more complex, again if you need to go that route please add a comment describing the special case. > > > diff --git a/drivers/thermal/rcar_gen3_thermal.c > b/drivers/thermal/rcar_gen3_thermal.c > index 9029d01e029b..0cd9a030eb9e 100644 > --- a/drivers/thermal/rcar_gen3_thermal.c > +++ b/drivers/thermal/rcar_gen3_thermal.c > @@ -481,7 +481,6 @@ static int rcar_gen3_thermal_probe(struct > platform_device *pdev) > { > struct rcar_gen3_thermal_priv *priv; > struct device *dev = &pdev->dev; > - struct resource *res; > struct thermal_zone_device *zone; > unsigned int i; > int ret; > @@ -503,22 +502,23 @@ static int rcar_gen3_thermal_probe(struct > platform_device *pdev) > > for (i = 0; i < TSC_MAX_NUM; i++) { > struct rcar_gen3_thermal_tsc *tsc; > + void __iomem *base; > > - res = platform_get_resource(pdev, IORESOURCE_MEM, i); > - if (!res) > - break; > + base = devm_platform_ioremap_resource(pdev, i); > + if (IS_ERR(base)) { > + if (PTR_ERR(base) == -EINVAL) > + break; > > - tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); > - if (!tsc) { > - ret = -ENOMEM; > + ret = PTR_ERR(base); > goto error_unregister; > } > > - tsc->base = devm_ioremap_resource(dev, res); > - if (IS_ERR(tsc->base)) { > - ret = PTR_ERR(tsc->base); > + tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); > + if (!tsc) { > + ret = -ENOMEM; > goto error_unregister; > } > + tsc->base = base; > > priv->tscs[i] = tsc; > } > > > > Before the change, failing to find a resource at position "i", breaks > > the probe loop, and probing continues and the number of resource > > described are the number of TSC find are used. > > > > After the change failing to find all possible TCS will fail the whole > > probe process, even if some TCS where described. And not describing max > > number of TCS on each system is perfectly fine. > > > > Nacked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > > > > > --- > > > drivers/thermal/rcar_gen3_thermal.c | 7 +------ > > > 1 file changed, 1 insertion(+), 6 deletions(-) > > > > > > diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c > > > index 9029d01e029b..5c623f13d9ec 100644 > > > --- a/drivers/thermal/rcar_gen3_thermal.c > > > +++ b/drivers/thermal/rcar_gen3_thermal.c > > > @@ -481,7 +481,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) > > > { > > > struct rcar_gen3_thermal_priv *priv; > > > struct device *dev = &pdev->dev; > > > - struct resource *res; > > > struct thermal_zone_device *zone; > > > unsigned int i; > > > int ret; > > > @@ -504,17 +503,13 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) > > > for (i = 0; i < TSC_MAX_NUM; i++) { > > > struct rcar_gen3_thermal_tsc *tsc; > > > - res = platform_get_resource(pdev, IORESOURCE_MEM, i); > > > - if (!res) > > > - break; > > > - > > > tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); > > > if (!tsc) { > > > ret = -ENOMEM; > > > goto error_unregister; > > > } > > > - tsc->base = devm_ioremap_resource(dev, res); > > > + tsc->base = devm_platform_ioremap_resource(pdev, i); > > > if (IS_ERR(tsc->base)) { > > > ret = PTR_ERR(tsc->base); > > > goto error_unregister; > > > -- > > > 2.39.0 > > >
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 9029d01e029b..5c623f13d9ec 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -481,7 +481,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) { struct rcar_gen3_thermal_priv *priv; struct device *dev = &pdev->dev; - struct resource *res; struct thermal_zone_device *zone; unsigned int i; int ret; @@ -504,17 +503,13 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) for (i = 0; i < TSC_MAX_NUM; i++) { struct rcar_gen3_thermal_tsc *tsc; - res = platform_get_resource(pdev, IORESOURCE_MEM, i); - if (!res) - break; - tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); if (!tsc) { ret = -ENOMEM; goto error_unregister; } - tsc->base = devm_ioremap_resource(dev, res); + tsc->base = devm_platform_ioremap_resource(pdev, i); if (IS_ERR(tsc->base)) { ret = PTR_ERR(tsc->base); goto error_unregister;