Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2713344pxt; Mon, 9 Aug 2021 07:14:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwP6mefoQ3YCXCM+tsUpvRHCSylJrFzoqgQJOzcpK9y3covB3JvgIpNrIprS1Ju1xuGva3L X-Received: by 2002:a05:6402:31ed:: with SMTP id dy13mr11686412edb.179.1628518475218; Mon, 09 Aug 2021 07:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628518475; cv=none; d=google.com; s=arc-20160816; b=mJuo2s7uj+BOitIoI+kSZ5XFaz3prkFCIlbr6UYPlmTewhFxBrdXnPN7jvU07O2KvW 5OgZzHkAjarX+p6QBgetJbIy0UGczeN3ieUToXUsVYOIfH697OEUWrjpS7VO52qE+/2e +O2LizZr/TuMnUZynu8/5wvM2P0Mv5i6qbiz2uPwqDqEcxinnARfIH+5e+gvf6ErsFEk lFb9m/preAgVH6kssmNay7qrDRAkkJsqELkOTE+2ShA2NYbz6X/1Bgqog33q9yhdiVN9 rFjmDRGll6M8SZfUZu8wcWMQTGyRTWO/+jVeqsVz2bGMhCRCgFHDQC4eN5LA0UDPFVeL exGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=KtUqhdxeXHYQtJGeZBIygKhoiIrAgKcUwoMNQMcw69A=; b=cYkc7aEhwV5gNRXxq/3JTyRZEbrpnVIXWLm3X5xglimOxTEJLUo+OLutlO/DAjAUN3 Df6HowHijiGjJUQa8aVEhmqYl8tMIz6y32PkgxnMvxS0G4+Xb7yYcNfdhVki9kCBDAjy xDKKwTG4SeFpXJHo66XYO1P66/OWmUw96kZdMROWsTWIztQbqidDBmZiC6oxcwgqNrcZ QNK990TGHYLAmufdQZ0ak3uaUK6AJToCEtU764pbAx6k8X2nac+yDdKNEPsnctMMvChG 3xfPEsO5cBuGlRh8ovmfVf9RXc8ATjpFKI9LzIWfQIYx4MH1jxg3cIrsUJkCHG4PVv9G 6sew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=sHO0lnuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si17646213edv.197.2021.08.09.07.14.11; Mon, 09 Aug 2021 07:14:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=sHO0lnuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234478AbhHINCz (ORCPT + 99 others); Mon, 9 Aug 2021 09:02:55 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:18672 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233845AbhHINCy (ORCPT ); Mon, 9 Aug 2021 09:02:54 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1628514154; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=KtUqhdxeXHYQtJGeZBIygKhoiIrAgKcUwoMNQMcw69A=; b=sHO0lnukSCa3WYutr3UecqW0x0sssCpJ4FjWl0II7FiArJ7+k1oP9b5by3eqLwsUugw1TN4h JXOCgR1ZnIo+FuNTbJJSmzsca0N3keKXBm66S/TaG8mRq/WJPWE4jnRPE8dL171cCmCNsmkl 5XnD7ZkQ/CWD7KFAmT2jMPWabZA= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 61112735b3873958f56de78d (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 09 Aug 2021 13:01:41 GMT Sender: luoj=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 150F5C43144; Mon, 9 Aug 2021 13:01:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from [10.92.0.248] (unknown [180.166.53.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luoj) by smtp.codeaurora.org (Postfix) with ESMTPSA id 76709C433F1; Mon, 9 Aug 2021 13:01:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 76709C433F1 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=luoj@codeaurora.org Subject: Re: [PATCH v1 1/2] net: mdio: Add the reset function for IPQ MDIO driver To: Andrew Lunn Cc: hkallweit1@gmail.com, davem@davemloft.net, kuba@kernel.org, linux@armlinux.org.uk, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sricharan@codeaurora.org References: <20210808072111.8365-1-luoj@codeaurora.org> <20210808072111.8365-2-luoj@codeaurora.org> From: Jie Luo Message-ID: Date: Mon, 9 Aug 2021 21:01:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/8/2021 11:27 PM, Andrew Lunn wrote: >> +static int ipq_mdio_reset(struct mii_bus *bus) >> +{ >> + struct ipq4019_mdio_data *priv = bus->priv; >> + u32 val; >> + int ret; >> + >> + /* To indicate CMN_PLL that ethernet_ldo has been ready if platform resource 1 >> + * is specified in the device tree. >> + * */ >> + if (!IS_ERR(priv->eth_ldo_rdy)) { >> + val = readl(priv->eth_ldo_rdy); >> + val |= BIT(0); >> + writel(val, priv->eth_ldo_rdy); >> + fsleep(IPQ_PHY_SET_DELAY_US); >> + } >> + >> + /* Configure MDIO clock source frequency if clock is specified in the device tree */ >> + if (!IS_ERR_OR_NULL(priv->mdio_clk)) { >> + ret = clk_set_rate(priv->mdio_clk, IPQ_MDIO_CLK_RATE); >> + if (ret) >> + return ret; >> + >> + ret = clk_prepare_enable(priv->mdio_clk); >> + if (ret) >> + return ret; >> + } > These !IS_ERR() are pretty ugly. So > >> @@ -182,14 +221,22 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) >> return -ENOMEM; >> >> priv = bus->priv; >> + priv->eth_ldo_rdy = IOMEM_ERR_PTR(-EINVAL); >> >> priv->membase = devm_platform_ioremap_resource(pdev, 0); >> if (IS_ERR(priv->membase)) >> return PTR_ERR(priv->membase); >> >> + priv->mdio_clk = devm_clk_get_optional(&pdev->dev, "gcc_mdio_ahb_clk"); > If this returns an error, it is a real error. You should not ignore > it. Fail the probe returning the error. That then means when the reset > function is called priv->mdio_clk contains either a clock, or NULL, > which the clk API is happy to take. No need for an if. > > >> + >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); >> + if (res) >> + priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res); > platform_get_resource() returns a pointer or NULL. There is no error > code. So > >> + if (!IS_ERR(priv->eth_ldo_rdy)) { > is actually wrong, should simply become > >> + if (priv->eth_ldo_rdy) { > Andrew Hi Andrew, Thanks for the kindly review and the comments, will follow it in the next patch set.