Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/4] Use PTR_ERR_OR_ZERO directly
@ 2019-09-05  6:43 zhong jiang
  2019-09-05  6:43 ` [PATCH 1/4] bus: ti-sysc: Use PTR_ERR_OR_ZERO rather than its implementation zhong jiang
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-05  6:43 UTC (permalink / raw)
  To: tony, udeep.dutt, ashutosh.dixit, gregkh, kishon, jonathanh,
	a.zummo, alexandre.belloni
  Cc: zhongjiang, linux-kernel, linux-rtc, arnd, lorenzo.pieralisi

With the help of ptr_ret.cocci, I find some place to use
PTR_ERR_OR_ZERO directly.

zhong jiang (4):
  bus: ti-sysc: Use PTR_ERR_OR_ZERO rather than its implementation
  misc: mic: Use PTR_ERR_OR_ZERO rather than its implementation
  phy: tegra: Use PTR_ERR_OR_ZERO rather than its implementation
  rtc: ds1347: Use PTR_ERR_OR_ZERO rather than its implementation

 drivers/bus/ti-sysc.c                | 4 +---
 drivers/misc/mic/scif/scif_epd.h     | 5 ++---
 drivers/phy/tegra/phy-tegra194-p2u.c | 4 +---
 drivers/rtc/rtc-ds1347.c             | 5 +----
 4 files changed, 5 insertions(+), 13 deletions(-)

-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] bus: ti-sysc: Use PTR_ERR_OR_ZERO rather than its implementation
  2019-09-05  6:43 [PATCH 0/4] Use PTR_ERR_OR_ZERO directly zhong jiang
@ 2019-09-05  6:43 ` zhong jiang
  2019-09-05  6:43 ` [PATCH 2/4] misc: mic: " zhong jiang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-05  6:43 UTC (permalink / raw)
  To: tony, udeep.dutt, ashutosh.dixit, gregkh, kishon, jonathanh,
	a.zummo, alexandre.belloni
  Cc: zhongjiang, linux-kernel, linux-rtc, arnd, lorenzo.pieralisi

PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR. It is better to
use it directly. hence just replace it.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/bus/ti-sysc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 9207ac2..6f4c102 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -504,10 +504,8 @@ static int sysc_init_resets(struct sysc *ddata)
 {
 	ddata->rsts =
 		devm_reset_control_get_optional_shared(ddata->dev, "rstctrl");
-	if (IS_ERR(ddata->rsts))
-		return PTR_ERR(ddata->rsts);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(ddata->rsts);
 }
 
 /**
-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] misc: mic: Use PTR_ERR_OR_ZERO rather than its implementation
  2019-09-05  6:43 [PATCH 0/4] Use PTR_ERR_OR_ZERO directly zhong jiang
  2019-09-05  6:43 ` [PATCH 1/4] bus: ti-sysc: Use PTR_ERR_OR_ZERO rather than its implementation zhong jiang
@ 2019-09-05  6:43 ` " zhong jiang
  2019-09-05  6:43 ` [PATCH 3/4] phy: tegra: " zhong jiang
  2019-09-05  6:43 ` [PATCH 4/4] rtc: ds1347: " zhong jiang
  3 siblings, 0 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-05  6:43 UTC (permalink / raw)
  To: tony, udeep.dutt, ashutosh.dixit, gregkh, kishon, jonathanh,
	a.zummo, alexandre.belloni
  Cc: zhongjiang, linux-kernel, linux-rtc, arnd, lorenzo.pieralisi

PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR. It is better to
use it directly. hence just replace it.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/misc/mic/scif/scif_epd.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/mic/scif/scif_epd.h b/drivers/misc/mic/scif/scif_epd.h
index d3837f8..0b9dfe1 100644
--- a/drivers/misc/mic/scif/scif_epd.h
+++ b/drivers/misc/mic/scif/scif_epd.h
@@ -156,9 +156,8 @@ static inline int scif_verify_epd(struct scif_endpt *ep)
 static inline int scif_anon_inode_getfile(scif_epd_t epd)
 {
 	epd->anon = anon_inode_getfile("scif", &scif_anon_fops, NULL, 0);
-	if (IS_ERR(epd->anon))
-		return PTR_ERR(epd->anon);
-	return 0;
+
+	return PTR_ERR_OR_ZERO(epd->anon);
 }
 
 static inline void scif_anon_inode_fput(scif_epd_t epd)
-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] phy: tegra: Use PTR_ERR_OR_ZERO rather than its implementation
  2019-09-05  6:43 [PATCH 0/4] Use PTR_ERR_OR_ZERO directly zhong jiang
  2019-09-05  6:43 ` [PATCH 1/4] bus: ti-sysc: Use PTR_ERR_OR_ZERO rather than its implementation zhong jiang
  2019-09-05  6:43 ` [PATCH 2/4] misc: mic: " zhong jiang
@ 2019-09-05  6:43 ` " zhong jiang
  2019-09-05  6:43 ` [PATCH 4/4] rtc: ds1347: " zhong jiang
  3 siblings, 0 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-05  6:43 UTC (permalink / raw)
  To: tony, udeep.dutt, ashutosh.dixit, gregkh, kishon, jonathanh,
	a.zummo, alexandre.belloni
  Cc: zhongjiang, linux-kernel, linux-rtc, arnd, lorenzo.pieralisi

PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR. It is better to
use it directly. hence just replace it.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/phy/tegra/phy-tegra194-p2u.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/phy/tegra/phy-tegra194-p2u.c b/drivers/phy/tegra/phy-tegra194-p2u.c
index 7042bed..40bc550 100644
--- a/drivers/phy/tegra/phy-tegra194-p2u.c
+++ b/drivers/phy/tegra/phy-tegra194-p2u.c
@@ -92,10 +92,8 @@ static int tegra_p2u_probe(struct platform_device *pdev)
 	phy_set_drvdata(generic_phy, phy);
 
 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	if (IS_ERR(phy_provider))
-		return PTR_ERR(phy_provider);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(phy_provider);
 }
 
 static const struct of_device_id tegra_p2u_id_table[] = {
-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] rtc: ds1347: Use PTR_ERR_OR_ZERO rather than its implementation
  2019-09-05  6:43 [PATCH 0/4] Use PTR_ERR_OR_ZERO directly zhong jiang
                   ` (2 preceding siblings ...)
  2019-09-05  6:43 ` [PATCH 3/4] phy: tegra: " zhong jiang
@ 2019-09-05  6:43 ` " zhong jiang
  2019-09-05  7:39   ` Alexandre Belloni
  3 siblings, 1 reply; 7+ messages in thread
From: zhong jiang @ 2019-09-05  6:43 UTC (permalink / raw)
  To: tony, udeep.dutt, ashutosh.dixit, gregkh, kishon, jonathanh,
	a.zummo, alexandre.belloni
  Cc: zhongjiang, linux-kernel, linux-rtc, arnd, lorenzo.pieralisi

PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR. It is better to
use it directly. hence just replace it.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/rtc/rtc-ds1347.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-ds1347.c b/drivers/rtc/rtc-ds1347.c
index d392a7b..5a64eea 100644
--- a/drivers/rtc/rtc-ds1347.c
+++ b/drivers/rtc/rtc-ds1347.c
@@ -151,10 +151,7 @@ static int ds1347_probe(struct spi_device *spi)
 	rtc = devm_rtc_device_register(&spi->dev, "ds1347",
 				&ds1347_rtc_ops, THIS_MODULE);
 
-	if (IS_ERR(rtc))
-		return PTR_ERR(rtc);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(rtc);
 }
 
 static struct spi_driver ds1347_driver = {
-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] rtc: ds1347: Use PTR_ERR_OR_ZERO rather than its implementation
  2019-09-05  6:43 ` [PATCH 4/4] rtc: ds1347: " zhong jiang
@ 2019-09-05  7:39   ` Alexandre Belloni
  2019-09-05  8:18     ` zhong jiang
  0 siblings, 1 reply; 7+ messages in thread
From: Alexandre Belloni @ 2019-09-05  7:39 UTC (permalink / raw)
  To: zhong jiang
  Cc: tony, udeep.dutt, ashutosh.dixit, gregkh, kishon, jonathanh,
	a.zummo, linux-kernel, linux-rtc, arnd, lorenzo.pieralisi

On 05/09/2019 14:43:15+0800, zhong jiang wrote:
> PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR. It is better to
> use it directly. hence just replace it.
> 

Unless you have a more significant contribution to this driver, I'm not
going to apply this patch, especially since it will have to be reverted
as soon as the probe function changes.

> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/rtc/rtc-ds1347.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ds1347.c b/drivers/rtc/rtc-ds1347.c
> index d392a7b..5a64eea 100644
> --- a/drivers/rtc/rtc-ds1347.c
> +++ b/drivers/rtc/rtc-ds1347.c
> @@ -151,10 +151,7 @@ static int ds1347_probe(struct spi_device *spi)
>  	rtc = devm_rtc_device_register(&spi->dev, "ds1347",
>  				&ds1347_rtc_ops, THIS_MODULE);
>  
> -	if (IS_ERR(rtc))
> -		return PTR_ERR(rtc);
> -
> -	return 0;
> +	return PTR_ERR_OR_ZERO(rtc);
>  }
>  
>  static struct spi_driver ds1347_driver = {
> -- 
> 1.7.12.4
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] rtc: ds1347: Use PTR_ERR_OR_ZERO rather than its implementation
  2019-09-05  7:39   ` Alexandre Belloni
@ 2019-09-05  8:18     ` zhong jiang
  0 siblings, 0 replies; 7+ messages in thread
From: zhong jiang @ 2019-09-05  8:18 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: tony, udeep.dutt, ashutosh.dixit, gregkh, kishon, jonathanh,
	a.zummo, linux-kernel, linux-rtc, arnd, lorenzo.pieralisi

On 2019/9/5 15:39, Alexandre Belloni wrote:
> On 05/09/2019 14:43:15+0800, zhong jiang wrote:
>> PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR. It is better to
>> use it directly. hence just replace it.
>>
> Unless you have a more significant contribution to this driver, I'm not
> going to apply this patch, especially since it will have to be reverted
> as soon as the probe function changes.
Anyway,  Thanks,

Sincerely,
zhong jiang
>> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
>> ---
>>  drivers/rtc/rtc-ds1347.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/drivers/rtc/rtc-ds1347.c b/drivers/rtc/rtc-ds1347.c
>> index d392a7b..5a64eea 100644
>> --- a/drivers/rtc/rtc-ds1347.c
>> +++ b/drivers/rtc/rtc-ds1347.c
>> @@ -151,10 +151,7 @@ static int ds1347_probe(struct spi_device *spi)
>>  	rtc = devm_rtc_device_register(&spi->dev, "ds1347",
>>  				&ds1347_rtc_ops, THIS_MODULE);
>>  
>> -	if (IS_ERR(rtc))
>> -		return PTR_ERR(rtc);
>> -
>> -	return 0;
>> +	return PTR_ERR_OR_ZERO(rtc);
>>  }
>>  
>>  static struct spi_driver ds1347_driver = {
>> -- 
>> 1.7.12.4
>>



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05  6:43 [PATCH 0/4] Use PTR_ERR_OR_ZERO directly zhong jiang
2019-09-05  6:43 ` [PATCH 1/4] bus: ti-sysc: Use PTR_ERR_OR_ZERO rather than its implementation zhong jiang
2019-09-05  6:43 ` [PATCH 2/4] misc: mic: " zhong jiang
2019-09-05  6:43 ` [PATCH 3/4] phy: tegra: " zhong jiang
2019-09-05  6:43 ` [PATCH 4/4] rtc: ds1347: " zhong jiang
2019-09-05  7:39   ` Alexandre Belloni
2019-09-05  8:18     ` zhong jiang

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org linux-rtc@archiver.kernel.org
	public-inbox-index linux-rtc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox