Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1093829pxk; Fri, 18 Sep 2020 03:41:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJeApdse4iPdda5+vb2qymq12kQ3UgqtQFAgxvBS6C8fCoS1JGP2XrwwXJhyozvittm4bF X-Received: by 2002:a17:906:2786:: with SMTP id j6mr34814514ejc.73.1600425671930; Fri, 18 Sep 2020 03:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600425671; cv=none; d=google.com; s=arc-20160816; b=e3VL4fvNqUygfRijiCGC2Rb0AtLodOmX4+JKnA9T0lmwX13QkesUtrxfTuSLV1EGiM Q/s5it/5dU07OEadXeZ9ssw5IUT1qOc7UsmzTZM7bGgF+Q2zN4x1ZzqWIUZev1rc1tL4 zNrE5oZ2S6BTv3Y8K2WzApWbtsuHHW3gzyzsGP+iTPfuhGt0RBjOqPlRqpRSq6aUOayt 7NNYKdXhzka5aoijZOXEVRXV3WRUD1BPVaWkZlk/8i5ONUCwJvxTqFpyZyNL2xEwIxvV tM442AXn4NgXnaJ4cr+DzbI3TErk/ztPzv5crPFAYIGzuq5sFDfPEQGxtJ6PmRdDSt+s Cdhg== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=FF77/udNT5ZdYmapv0JzXbWwYGpVS9HZiHxnusgK160=; b=znMXpOikRBdJRGUMIY7UhpyixGuOjdMcboSXC6J669Y6E/tGskn2hxJlN4AITbW06q efPDDQmzuLDSbXDmY9VsboBUAEImpnjtGlzqy93M3sC/MgXkjC304wtJMl6hM1bGHVDv 3n2uEQ2gQ9x9pl/vPIHR5zxeVPP4L3Szjha4WQ8i75BdmIe8RzvIr96go+CXfPb3RUwb owf4H2UYCoJs2TJxTxcBgYXeHvaG/MbxcYzf8ig5l4npIb13fX4Hzolz7U5gbSXHi006 tCKQzauITdn+U8BTCS2Kle0h5u+tev977zpQzAfmKdiPGzj1wszrZUaYxBuM6rIBUyL+ QSUg== ARC-Authentication-Results: i=1; mx.google.com; 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 j22si2150224eds.357.2020.09.18.03.40.47; Fri, 18 Sep 2020 03:41:11 -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; 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 S1726126AbgIRKhd (ORCPT + 99 others); Fri, 18 Sep 2020 06:37:33 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:48420 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725941AbgIRKhd (ORCPT ); Fri, 18 Sep 2020 06:37:33 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DCCD93B05D18F5165875; Fri, 18 Sep 2020 18:37:30 +0800 (CST) Received: from [10.174.179.63] (10.174.179.63) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Fri, 18 Sep 2020 18:37:24 +0800 Subject: Re: [PATCH -next] i2c: efm32: Use devm_platform_get_and_ioremap_resource() To: Yicong Yang CC: , , , , , , References: <20200918082508.32427-1-bobo.shaobowang@huawei.com> <961c1feb-f818-f98c-f618-57c643bac04c@hisilicon.com> From: "Wangshaobo (bobo)" Message-ID: <01032e87-f334-c586-2baa-78919310d736@huawei.com> Date: Fri, 18 Sep 2020 18:37:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <961c1feb-f818-f98c-f618-57c643bac04c@hisilicon.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.63] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/9/18 18:01, Yicong Yang 写道: > On 2020/9/18 16:25, Wang ShaoBo wrote: >> Make use of devm_platform_get_and_ioremap_resource() provided by >> driver core platform instead of duplicated analogue. dev_err() is >> removed because it has been done in devm_ioremap_resource(). >> >> Signed-off-by: Wang ShaoBo >> --- >> drivers/i2c/busses/i2c-efm32.c | 12 +++--------- >> 1 file changed, 3 insertions(+), 9 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c >> index 838ce0947191..f6e13ceeb2b3 100644 >> --- a/drivers/i2c/busses/i2c-efm32.c >> +++ b/drivers/i2c/busses/i2c-efm32.c >> @@ -332,21 +332,15 @@ static int efm32_i2c_probe(struct platform_device *pdev) >> return ret; >> } >> >> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> - if (!res) { >> - dev_err(&pdev->dev, "failed to determine base address\n"); >> - return -ENODEV; >> - } >> + ddata->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); >> + if (IS_ERR(ddata->base)) >> + return PTR_ERR(ddata->base); >> >> if (resource_size(res) < 0x42) { > res is not assigned. should it be removed? I am not sure what you want to ask, but devm_platform_get_and_ioremap_resource() will assign variable res a value, if it is NULL, internal devm_ioremap_resource() will return error at the begining, so at this time if(IS_ERR(ddata->base)) true and terminate the process, which is as same as the original sentences work. >> dev_err(&pdev->dev, "memory resource too small\n"); >> return -EINVAL; >> } >> >> - ddata->base = devm_ioremap_resource(&pdev->dev, res); >> - if (IS_ERR(ddata->base)) >> - return PTR_ERR(ddata->base); >> - >> ret = platform_get_irq(pdev, 0); >> if (ret <= 0) { >> if (!ret) > .