Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5212397rdb; Wed, 13 Dec 2023 02:08:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IElRV2gdiZh69GNtBWKs2yoZvCDTv2x/gRjxc339B+Kkzo4ckQC+9SBf8RI/iJFaJjFYrIp X-Received: by 2002:a05:6808:2e96:b0:3b9:da57:6d90 with SMTP id gt22-20020a0568082e9600b003b9da576d90mr11471973oib.111.1702462087778; Wed, 13 Dec 2023 02:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702462087; cv=none; d=google.com; s=arc-20160816; b=e0eW3TwpQEI175sYRrwCPDkvEMNFzN99+AQ+668cP5U7/f9PUUsVXtH9VWBRfHDMG5 OEahEqzi4fE1loBYCq7dbBZj9PKf1tCrwjfpM/H+LcjAF3nMSBHGVHMxLwaLU8ldlN0S 0rEMQ8i30QMHGXCsATsLB7vkt+yOpameGFtAuZ3kWVOefnqul26Am5sg1PJsKgcPDUTv gPTbPLZ7U+iq87DWupCOzqG5aO6YehMDXG3tTg9DowqiSJt6pZQB9nzKJk3XpLyRuBn2 r/CPmtDKGBIvT84bh1oyOMUwr3wn6rmk7E1vqAELR2PbjslG0INsskGza9Mo2Y7OouaQ vDzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=NNBNl0TQMsl9kyDYCCoCiEJ6n4wPwD+uoJm0c+3lwuY=; fh=Va2tenj77oYq6DtoHqGEW5H1gz/WBUGdJJNyT9vm9oQ=; b=zma3RpF0kTA6H1SK1jvuVSBWKdeoWzPYD7vFUNGanawPYqCK8Q29JfvY4Cxzd0GvDK YefH0HbpkE7ckazt5pZfOPQCnXrNNYGp6P8Hpn5OVepCVUbB+fDalR54tKZUuEGxTM0j Ncyd+CxWOel1/h4Q7P2zN8Ve7qIDF6DePNHzUIi9GLU9ekEqYquROYpaa/T5m/11h6Wj yvEobgX6w+83+Q2JTEdpZ+swoc16ScRHVGhTH1q7zVuq/qas8HNUqTJYB/H5LUiZJTe3 6/8EKKIqVMP9VmUd5BjdA4gZGHXJh5/lhv8eVrs0M1hdsGD+i1P5H2nK5hIEf6Hb0siv H80w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MewhdTNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id o2-20020a655202000000b005c666162406si9473783pgp.565.2023.12.13.02.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 02:08:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MewhdTNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D73C28048784; Wed, 13 Dec 2023 02:08:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235275AbjLMKHg (ORCPT + 99 others); Wed, 13 Dec 2023 05:07:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235271AbjLMKHg (ORCPT ); Wed, 13 Dec 2023 05:07:36 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4910A83; Wed, 13 Dec 2023 02:07:41 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 797076000F; Wed, 13 Dec 2023 10:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702462059; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NNBNl0TQMsl9kyDYCCoCiEJ6n4wPwD+uoJm0c+3lwuY=; b=MewhdTNm3jOs2pi3D64QUvQZPkNQ0HPcH3aRaqhy2teQxKwbJVqwXwKAfHep/fpnpTKevP 9uT3jHCQgEyMVpt8L0D+GqYL9944vOucN+dvsTsYWmMb1tqfDOvegJhwApScWBC9V3KuHw O1ZugHSWtvFWXwqF9Et/DSA/ocT3arVyjAf8y4vz8ktb2EF4KVkYhBdiCSgeGQwq0yfIZy 6km1AVa+Wy/1U6yUGF8MHKNaI9b/tY4KBIVVB3ps4PZtdEvIYtEBZL+9VhXk3sBgApWjWJ Vj/drso5e7UJVmQY3Kqq4DsMi0iNud7qKwTU4fiKP1oko/RNmzLxYFDEtRLwBw== Date: Wed, 13 Dec 2023 11:07:37 +0100 From: Maxime Chevallier To: "Russell King (Oracle)" Cc: Luo Jie , agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, robert.marko@sartura.hr, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, quic_srichara@quicinc.com Subject: Re: [PATCH v2 1/5] net: mdio: ipq4019: move eth_ldo_rdy before MDIO bus register Message-ID: <20231213110737.6e96dba1@device.home> In-Reply-To: References: <20231212115151.20016-1-quic_luoj@quicinc.com> <20231212115151.20016-2-quic_luoj@quicinc.com> <20231212135001.6bf40e4d@device.home> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 02:08:05 -0800 (PST) Hello Russell, On Tue, 12 Dec 2023 19:11:15 +0000 "Russell King (Oracle)" wrote: > On Tue, Dec 12, 2023 at 01:50:01PM +0100, Maxime Chevallier wrote: > > Hello, > > > > On Tue, 12 Dec 2023 19:51:46 +0800 > > Luo Jie wrote: > > > @@ -252,11 +244,32 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) > > > if (IS_ERR(priv->mdio_clk)) > > > return PTR_ERR(priv->mdio_clk); > > > > > > - /* The platform resource is provided on the chipset IPQ5018 */ > > > - /* This resource is optional */ > > > - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > > > - if (res) > > > - priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res); > > > + /* These platform resources are provided on the chipset IPQ5018 or > > > + * IPQ5332. > > > + */ > > > + /* This resource are optional */ > > > + for (index = 0; index < ETH_LDO_RDY_CNT; index++) { > > > + res = platform_get_resource(pdev, IORESOURCE_MEM, index + 1); > > > + if (res) { > > > + priv->eth_ldo_rdy[index] = devm_ioremap(&pdev->dev, > > > + res->start, > > > + resource_size(res)); > > > > You can simplify that sequence by using > > devm_platform_get_and_ioremap_resource(), which will do both the > > platform_get_resource and the devm_ioremap at once for you. > > Sadly it can't if resources are optional. __devm_ioremap_resource() > which will be capped by devm_platform_get_and_ioremap_resource() will > be passed a NULL 'res', which will lead to: > > if (!res || resource_type(res) != IORESOURCE_MEM) { > dev_err(dev, "invalid resource %pR\n", res); > return IOMEM_ERR_PTR(-EINVAL); > } > > There isn't an "optional" version of > devm_platform_get_and_ioremap_resource(). > Ah right, I missed that part indeed. Sorry for the noise then, and thanks for double-checking :) Best regards, Maxime