From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7823FC48BD1 for ; Fri, 11 Jun 2021 03:35:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 527B76139A for ; Fri, 11 Jun 2021 03:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231467AbhFKDhX (ORCPT ); Thu, 10 Jun 2021 23:37:23 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:58080 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbhFKDhV (ORCPT ); Thu, 10 Jun 2021 23:37:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=jrzkXDGoUHtqmy4odHiE/JuI9qwK6iCvH8gOoN3YBxM=; b=rdBay5upgW2U5MUQkDPt/P/0m4 e0+qnNrHQjb2a4L1mdjD/jl5w8Pjjdsod6QAgbV6ZKohmvrOWsQvAUUrw+jbLOKT8Z2mVH+2aloFX uxCsCfHkdYHE93UT+jlbJLAxYIbJ1Q43gCtbmXJOxMHrSb2GA757/is7qgp+vnoGqi60=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1lrXx4-008mbn-7z; Fri, 11 Jun 2021 05:35:22 +0200 Date: Fri, 11 Jun 2021 05:35:22 +0200 From: Andrew Lunn To: Yang Yingliang Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org Subject: Re: [PATCH net-next] net: mdio: mscc-miim: Use devm_platform_get_and_ioremap_resource() Message-ID: References: <20210610091154.4141911-1-yangyingliang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 11, 2021 at 09:35:04AM +0800, Yang Yingliang wrote: > Hi, > > On 2021/6/11 0:01, Andrew Lunn wrote: > > > - dev->regs = devm_ioremap_resource(&pdev->dev, res); > > > + dev->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); > > > if (IS_ERR(dev->regs)) { > > Here, only dev->regs is considered. > > > > > dev_err(&pdev->dev, "Unable to map MIIM registers\n"); > > > return PTR_ERR(dev->regs); > > > } > > > > > > > + dev->phy_regs = devm_platform_get_and_ioremap_resource(pdev, 1, &res); > > > + if (res && IS_ERR(dev->phy_regs)) { > > Here you look at both res and dev->phy_regs. > > > > This seems inconsistent. Can devm_platform_get_and_ioremap_resource() > > return success despite res being NULL? > No, if res is NULL, devm_platform_get_and_ioremap_resource() returns failed. > But, before this patch, if the internal phy res is NULL, it doesn't return > error > code, so I checked the res to make sure it doesn't change the origin code > logic. O.K, so IORESOURCE_MEM, 1 is optional. By making this change, i think you have made this less clear. So i would say it is O.K. to change the first platform_get_resource(pdev, IORESOURCE_MEM, 0) and devm_ioremap_resource(&pdev->dev, res) to one call, but i would leave the second pair alone. Andrew