Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4596904pxb; Tue, 31 Aug 2021 08:47:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI4IPzOkHi284N1dUqbTC6m4q62nMJcU3Y6yhi8SSN9aD6BoMJ1bpTk9GZHQhI0hWASlD9 X-Received: by 2002:a1c:4682:: with SMTP id t124mr5065275wma.168.1630424862283; Tue, 31 Aug 2021 08:47:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630424862; cv=none; d=google.com; s=arc-20160816; b=dshEpoUbvs3Rg5U9GDcrS/I+yNVodq7X5/W7+NKtxee6RIEoRsRZM58o40u2eLJzBA pqIZfOimr1auBwZBBHlKIsOp2wDdi7fRmJcETucnrwMg93WvFf/lspnURXuECCXwAcXR iIzKke1ZgLl5WBzt93jjC7ipEVSKw4DHUFH5flyEUIXT3FOEDXkuv8mL8MB0ZW2bn6+m 50kWHz8M1aSKR7Gi3OV3GMFiMJHJk2Uwzw0AZD9p5p6r7/OjPrVObMmQCmVqDlgZ1kKt 90NFdYPMJxm8YT0lsLDRm8cCvJ8BwsoPwItppU4FAhixxh50HeaIm1rieMdDjBgK1lfE xxrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=uF2zWPXFu0dWr/k2DJBZO8X3hZq7bJ2sCH/dW84m21w=; b=iW6zkDeta01DxrqA2LhEXy3UzdoieWDGiPIzQPRnaNyds5kYp9hMc7Kl6XRUDn90gg k6UtneXSfzIuDnec28u8faP2F0rlae7jIcWOFp56lR7iIdEtTV5o06PTsk6HP15VmBen /iHAYQWRi6fbvdLKCjs7quXXhiU47seT8QY/RuDwt0rHnR4kSFAfDpm4BtQA3K2nej7M f9LJuSbHPHe8mZEWOZ7JDv7QNKjFyeThxIj0hQEjXlBmZc1jVsDjbmKiSlArF2FZJzXo HS3P5AiJ+T/Y1CXNoY5U8YttRBOa8ST+kSp4OmF5oby/eQiQVDODftdqGPTfGo6snmXN JE0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G0yMMTqH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si18427431edy.395.2021.08.31.08.47.17; Tue, 31 Aug 2021 08:47:42 -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=@kernel.org header.s=k20201202 header.b=G0yMMTqH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238852AbhHaPTC (ORCPT + 99 others); Tue, 31 Aug 2021 11:19:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:60494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232559AbhHaPTC (ORCPT ); Tue, 31 Aug 2021 11:19:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EBCB46103A; Tue, 31 Aug 2021 15:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630423087; bh=RJTxHIyrBUknplHV6hGq8g2EyXUUbu+8+pAvfCZtkMk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=G0yMMTqHzwe0qELu/DoAveRwHUB13dr3KPJRkqxmmeotdjBerRgfbWfJzvi9M4w7j R3d+skaMiYzBdMNJOfXm9IWujZ7afBwVsnt3mzrac3T8HNMuZFQm6btu2kyq11MD9l NU0wxpysBolR1UlYFWOd3DdrfplB3FDtilgRYq9UbC1JXckD5jD+uXirhjfZ876WcO cqkLBhbYdUEdxIO0Y3pu3KB4qCvNUYdQDdwG5VOgIGLiZCWlloej9IUto9KfnXma+I CftbNTGohba7GqvjL/2RLJlsW3BEuUXuEVwcoNO1UjdzSkJ21YGcAF73la1USBO6cM 6J9E/lUdaDRTA== Received: by mail-ej1-f52.google.com with SMTP id e21so39507055ejz.12; Tue, 31 Aug 2021 08:18:06 -0700 (PDT) X-Gm-Message-State: AOAM533EBAIN1HUAZg0/mQATQ8qqgXXGodmv2IfUN97ibNJZ9hbfx17i HWNAvjWe1xztl4hw9M8chUknL8zsQLruroCGlQ== X-Received: by 2002:a17:906:8cd:: with SMTP id o13mr32127271eje.341.1630423085544; Tue, 31 Aug 2021 08:18:05 -0700 (PDT) MIME-Version: 1.0 References: <20210830214317.GA27606@bjorn-Precision-5520> In-Reply-To: From: Rob Herring Date: Tue, 31 Aug 2021 10:17:53 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v12 2/6] PCI: mediatek: Add new method to get shared pcie-cfg base address To: Chuanjia Liu Cc: Bjorn Helgaas , Bjorn Helgaas , Matthias Brugger , Lorenzo Pieralisi , Ryder Lee , Jianjun Wang , Yong Wu , PCI , "moderated list:ARM/Mediatek SoC support" , devicetree@vger.kernel.org, linux-arm-kernel , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 30, 2021 at 10:31 PM Chuanjia Liu wrote: > > On Mon, 2021-08-30 at 16:43 -0500, Bjorn Helgaas wrote: > > On Mon, Aug 30, 2021 at 03:09:44PM +0800, Chuanjia Liu wrote: > > > On Fri, 2021-08-27 at 11:46 -0500, Bjorn Helgaas wrote: > > > > On Mon, Aug 23, 2021 at 11:27:56AM +0800, Chuanjia Liu wrote: > > > > > @@ -995,6 +1004,14 @@ static int mtk_pcie_subsys_powerup(struct > > > > > mtk_pcie *pcie) > > > > > return PTR_ERR(pcie->base); > > > > > } > > > > > > > > > > + cfg_node = of_find_compatible_node(NULL, NULL, > > > > > + "mediatek,generic- > > > > > pciecfg"); > > > > > + if (cfg_node) { > > > > > + pcie->cfg = syscon_node_to_regmap(cfg_node); > > > > > > > > Other drivers in drivers/pci/controller/ use > > > > syscon_regmap_lookup_by_phandle() (j721e, dra7xx, keystone, > > > > layerscape, artpec6) or syscon_regmap_lookup_by_compatible() > > > > (imx6, > > > > kirin, v3-semi). > > > > > > > > You should do it the same way unless there's a need to be > > > > different. > > > > > > I have used phandle, but Rob suggested to search for the node by > > > compatible. > > > The reason why syscon_regmap_lookup_by_compatible() is not > > > used here is that the pciecfg node is optional, and there is no > > > need to > > > return error when the node is not searched. > > > > How about this? > > > > regmap = syscon_regmap_lookup_by_compatible("mediatek,generic- > > pciecfg"); > > if (!IS_ERR(regmap)) > > pcie->cfg = regmap; +1 > > Hi Bjorn, > > We need to deal with three situations > 1) No error > 2) The error of the node not found, don't do anything > 3) Other errors, return errors > > I guess you mean > > regmap = syscon_regmap_lookup_by_compatible("mediatek,generic- > pciecfg"); > if (!IS_ERR(regmap)) > pcie->cfg = regmap; > else if (IS_ERR(regmap) && PTR_ERR(regmap) != -ENODEV) You already know IS_ERR is true here. > return PTR_ERR(regmap); syscon_regmap_lookup_by_compatible_optional is the function you are looking for. The _optional flavor doesn't exist, so create it. There is one for the phandle lookup. > > I'm not sure if we need this, it seems a little weird and there are > many drivers in other subsystems that use syscon_node_to_regmap(). You are implementing the exact same sequence that syscon_regmap_lookup_by_compatible() does, so clearly you should be using it. The one difference is you forgot the of_node_put(). Rob