All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Wangshaobo (bobo)" <bobo.shaobowang@huawei.com>
To: Yicong Yang <yangyicong@hisilicon.com>
Cc: <cj.chengjian@huawei.com>, <huawei.libin@huawei.com>,
	<wsa@kernel.org>, <u.kleine-koenig@pengutronix.de>,
	<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH -next] i2c: efm32: Use devm_platform_get_and_ioremap_resource()
Date: Fri, 18 Sep 2020 18:37:24 +0800	[thread overview]
Message-ID: <01032e87-f334-c586-2baa-78919310d736@huawei.com> (raw)
In-Reply-To: <961c1feb-f818-f98c-f618-57c643bac04c@hisilicon.com>


在 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 <bobo.shaobowang@huawei.com>
>> ---
>>   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)
> .

WARNING: multiple messages have this Message-ID (diff)
From: "Wangshaobo (bobo)" <bobo.shaobowang@huawei.com>
To: Yicong Yang <yangyicong@hisilicon.com>
Cc: cj.chengjian@huawei.com, linux-kernel@vger.kernel.org,
	wsa@kernel.org, linux-i2c@vger.kernel.org,
	huawei.libin@huawei.com, u.kleine-koenig@pengutronix.de,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH -next] i2c: efm32: Use devm_platform_get_and_ioremap_resource()
Date: Fri, 18 Sep 2020 18:37:24 +0800	[thread overview]
Message-ID: <01032e87-f334-c586-2baa-78919310d736@huawei.com> (raw)
In-Reply-To: <961c1feb-f818-f98c-f618-57c643bac04c@hisilicon.com>


在 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 <bobo.shaobowang@huawei.com>
>> ---
>>   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)
> .

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-09-18 10:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18  8:25 [PATCH -next] i2c: efm32: Use devm_platform_get_and_ioremap_resource() Wang ShaoBo
2020-09-18  8:25 ` Wang ShaoBo
2020-09-18  9:20 ` Uwe Kleine-König
2020-09-18  9:20   ` Uwe Kleine-König
2020-09-18 10:01 ` Yicong Yang
2020-09-18 10:01   ` Yicong Yang
2020-09-18 10:37   ` Wangshaobo (bobo) [this message]
2020-09-18 10:37     ` Wangshaobo (bobo)
2020-09-29 19:38 ` Wolfram Sang
2020-09-29 19:38   ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01032e87-f334-c586-2baa-78919310d736@huawei.com \
    --to=bobo.shaobowang@huawei.com \
    --cc=cj.chengjian@huawei.com \
    --cc=huawei.libin@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wsa@kernel.org \
    --cc=yangyicong@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.