Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1377543imw; Tue, 5 Jul 2022 08:24:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vWfWAsXSQUM6Mh57PmCt+v0FZyWUcVgmoDwMwqNTLlhdL5iev6IxNj5V/WUuapt8U+/KcC X-Received: by 2002:a17:90b:1d06:b0:1ec:cd94:539b with SMTP id on6-20020a17090b1d0600b001eccd94539bmr41507725pjb.215.1657034656562; Tue, 05 Jul 2022 08:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657034656; cv=none; d=google.com; s=arc-20160816; b=0e6OvQ4GnDhIsIlWtVINRXxKo5SbJLo0+eH/Fux+1Dvvt99K4B41tjPFuEETXUB8KE lJcYgLA5kWBgCcWg4tjyZKzn3pEX6Wjp2/ueJyD7hc1+GCjavQ+Ib/5j/dyZ3IbuccCY XKh6qaCy5u5CRhudTyCuzyOmwBiQ0+HM49e6W1X0qDNCR0S9NVNv+GRIhL6YOp1OO27w AKeyi8Gnl0zFPHsnSveHrSU61m7YRN7/ouPXAsM4WcdSe/mXuxSLeiAXd0O/7mFwnWMA RwLghtZj3dUGbIwsE32+AAiMrHvsIjj7PvchonCo0g03zMh1OdVEnUQJcCL5yg1PLm3F 1F4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:subject:user-agent:mime-version:date:message-id; bh=3QQz4uT3a79/OBpu7CEX6n1j5PHrepbF5Mn1K0k8xVY=; b=nNn5Apxg4LNRDO9vFT+NIdnpEivqxzgLCId0/li6aMd2xLIeeVZp8iO1vF22DwNyhg xjQ8KHq9EsmxtLGDa2dNbkbZjypjSeGESD+Q6m1uBtJQMtCT1ljwS5kICAm2ZCeJv0LW hqpHU1zetBEzSRJGuOtKukXtKPF5TEQoF1oe4DFD7pDv2KHUlvin3cGkYU6BSzc2vhWx guEUmz+tAMyrtW/bSnnL9nbEQCBlMB3WJarYjeUXNZMubDLY/h+pei+FaJhSGGXtrBxE MF9u5el+W71fqN4vkhLnzk8Hz2DP3aoV7f4HPQV9itL9ZcyUCv/BmpOqEIj7FNpSiQym kNiQ== ARC-Authentication-Results: i=1; mx.google.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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r192-20020a632bc9000000b004125addbbc9si6107890pgr.470.2022.07.05.08.24.04; Tue, 05 Jul 2022 08:24:16 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232633AbiGEPFg (ORCPT + 99 others); Tue, 5 Jul 2022 11:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232651AbiGEPEg (ORCPT ); Tue, 5 Jul 2022 11:04:36 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1270E15A3E for ; Tue, 5 Jul 2022 08:02:25 -0700 (PDT) Received: from fraeml736-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Lcm8b5hBbz6GD7R; Tue, 5 Jul 2022 23:01:19 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml736-chm.china.huawei.com (10.206.15.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 5 Jul 2022 17:02:22 +0200 Received: from [10.126.171.232] (10.126.171.232) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.24; Tue, 5 Jul 2022 16:02:22 +0100 Message-ID: Date: Tue, 5 Jul 2022 16:02:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v1 1/4] bus: hisi_lpc: Don't dereference fwnode handle To: Andy Shevchenko , "Rafael J. Wysocki" , References: <20220705114312.86164-1-andriy.shevchenko@linux.intel.com> From: John Garry In-Reply-To: <20220705114312.86164-1-andriy.shevchenko@linux.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.126.171.232] X-ClientProxiedBy: lhreml703-chm.china.huawei.com (10.201.108.52) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org On 05/07/2022 12:43, Andy Shevchenko wrote: > Use dev_fwnode() and acpi_fwnode_handle() instead of dereferencing > an fwnode handle directly. ...which is a better coding practice, right? If so, it would be nice to mention it - well at least I think so. > > While at it, reuse fwnode instead of ACPI_COMPANION(). Apart from above and nit, below: Acked-by: John Garry > > Signed-off-by: Andy Shevchenko > --- > drivers/bus/hisi_lpc.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c > index 2e564803e786..6d432a07cbba 100644 > --- a/drivers/bus/hisi_lpc.c > +++ b/drivers/bus/hisi_lpc.c > @@ -347,7 +347,7 @@ static int hisi_lpc_acpi_xlat_io_res(struct acpi_device *adev, > unsigned long sys_port; > resource_size_t len = resource_size(res); > > - sys_port = logic_pio_trans_hwaddr(&host->fwnode, res->start, len); > + sys_port = logic_pio_trans_hwaddr(acpi_fwnode_handle(host), res->start, len); nit: currently the driver keeps to the old 80 character line limit. While the rules may have been relaxed, I'd rather we still maintain it. > if (sys_port == ~0UL) > return -EFAULT; > > @@ -615,7 +615,6 @@ static void hisi_lpc_acpi_remove(struct device *hostdev) > static int hisi_lpc_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > - struct acpi_device *acpi_device = ACPI_COMPANION(dev); > struct logic_pio_hwaddr *range; > struct hisi_lpc_dev *lpcdev; > resource_size_t io_end; > @@ -637,7 +636,7 @@ static int hisi_lpc_probe(struct platform_device *pdev) > if (!range) > return -ENOMEM; > > - range->fwnode = dev->fwnode; > + range->fwnode = dev_fwnode(dev); > range->flags = LOGIC_PIO_INDIRECT; > range->size = PIO_INDIRECT_SIZE; > range->hostdata = lpcdev; > @@ -651,7 +650,7 @@ static int hisi_lpc_probe(struct platform_device *pdev) > } > > /* register the LPC host PIO resources */ > - if (acpi_device) > + if (is_acpi_device_node(range->fwnode)) > ret = hisi_lpc_acpi_probe(dev); > else > ret = of_platform_populate(dev->of_node, NULL, NULL, dev); > @@ -672,11 +671,10 @@ static int hisi_lpc_probe(struct platform_device *pdev) > static int hisi_lpc_remove(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > - struct acpi_device *acpi_device = ACPI_COMPANION(dev); > struct hisi_lpc_dev *lpcdev = dev_get_drvdata(dev); > struct logic_pio_hwaddr *range = lpcdev->io_host; > > - if (acpi_device) > + if (is_acpi_device_node(range->fwnode)) > hisi_lpc_acpi_remove(dev); > else > of_platform_depopulate(dev);