All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] pps: using ERR_PTR instead of NULL while pps_register_source fails
@ 2018-11-26 10:24 YueHaibing
  2018-11-26 10:43 ` Rodolfo Giometti
  0 siblings, 1 reply; 5+ messages in thread
From: YueHaibing @ 2018-11-26 10:24 UTC (permalink / raw)
  To: davem, giometti, richardcochran, sudipm.mukherjee, gregkh
  Cc: linux-kernel, netdev, YueHaibing

pps_register_source() has keeps error codes in a local variable,
but it does not make use of the code. This patch let it return
the errcode in case of failure.

Suggested-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/pps/clients/pps-gpio.c    | 4 ++--
 drivers/pps/clients/pps-ktimer.c  | 4 ++--
 drivers/pps/clients/pps-ldisc.c   | 4 ++--
 drivers/pps/clients/pps_parport.c | 2 +-
 drivers/pps/kapi.c                | 5 +++--
 drivers/ptp/ptp_clock.c           | 4 ++--
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 333ad7d..dd5d110 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -158,10 +158,10 @@ static int pps_gpio_probe(struct platform_device *pdev)
 	if (data->capture_clear)
 		pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
 	data->pps = pps_register_source(&data->info, pps_default_params);
-	if (data->pps == NULL) {
+	if (IS_ERR(data->pps)) {
 		dev_err(&pdev->dev, "failed to register IRQ %d as PPS source\n",
 			data->irq);
-		return -EINVAL;
+		return PTR_ERR(data->pps);
 	}
 
 	/* register IRQ interrupt handler */
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index 0473564..728818b 100644
--- a/drivers/pps/clients/pps-ktimer.c
+++ b/drivers/pps/clients/pps-ktimer.c
@@ -80,9 +80,9 @@ static int __init pps_ktimer_init(void)
 {
 	pps = pps_register_source(&pps_ktimer_info,
 				PPS_CAPTUREASSERT | PPS_OFFSETASSERT);
-	if (pps == NULL) {
+	if (IS_ERR(pps)) {
 		pr_err("cannot register PPS source\n");
-		return -ENOMEM;
+		return PTR_ERR(pps);
 	}
 
 	timer_setup(&ktimer, pps_ktimer_event, 0);
diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
index 73bd3bb..00f6c46 100644
--- a/drivers/pps/clients/pps-ldisc.c
+++ b/drivers/pps/clients/pps-ldisc.c
@@ -72,9 +72,9 @@ static int pps_tty_open(struct tty_struct *tty)
 
 	pps = pps_register_source(&info, PPS_CAPTUREBOTH | \
 				PPS_OFFSETASSERT | PPS_OFFSETCLEAR);
-	if (pps == NULL) {
+	if (IS_ERR(pps)) {
 		pr_err("cannot register PPS source \"%s\"\n", info.path);
-		return -ENOMEM;
+		return PTR_ERR(pps);
 	}
 	pps->lookup_cookie = tty;
 
diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c
index 4db824f..7226e39 100644
--- a/drivers/pps/clients/pps_parport.c
+++ b/drivers/pps/clients/pps_parport.c
@@ -179,7 +179,7 @@ static void parport_attach(struct parport *port)
 
 	device->pps = pps_register_source(&info,
 			PPS_CAPTUREBOTH | PPS_OFFSETASSERT | PPS_OFFSETCLEAR);
-	if (device->pps == NULL) {
+	if (IS_ERR(device->pps)) {
 		pr_err("couldn't register PPS source\n");
 		goto err_release_dev;
 	}
diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
index 805c749..a1c3cd3 100644
--- a/drivers/pps/kapi.c
+++ b/drivers/pps/kapi.c
@@ -72,7 +72,8 @@ static void pps_echo_client_default(struct pps_device *pps, int event,
  * source is described by info's fields and it will have, as default PPS
  * parameters, the ones specified into default_params.
  *
- * The function returns, in case of success, the PPS device. Otherwise NULL.
+ * The function returns, in case of success, the PPS device. Otherwise
+ * ERR_PTR(errno).
  */
 
 struct pps_device *pps_register_source(struct pps_source_info *info,
@@ -135,7 +136,7 @@ struct pps_device *pps_register_source(struct pps_source_info *info,
 pps_register_source_exit:
 	pr_err("%s: unable to register source\n", info->name);
 
-	return NULL;
+	return ERR_PTR(err);
 }
 EXPORT_SYMBOL(pps_register_source);
 
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 8a81eec..48f3594 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -265,8 +265,8 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
 		pps.mode = PTP_PPS_MODE;
 		pps.owner = info->owner;
 		ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS);
-		if (!ptp->pps_source) {
-			err = -EINVAL;
+		if (IS_ERR(ptp->pps_source)) {
+			err = PTR_ERR(ptp->pps_source);
 			pr_err("failed to register pps source\n");
 			goto no_pps;
 		}
-- 
2.7.0



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

* Re: [PATCH -next] pps: using ERR_PTR instead of NULL while pps_register_source fails
  2018-11-26 10:24 [PATCH -next] pps: using ERR_PTR instead of NULL while pps_register_source fails YueHaibing
@ 2018-11-26 10:43 ` Rodolfo Giometti
  2018-11-27  7:34   ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Rodolfo Giometti @ 2018-11-26 10:43 UTC (permalink / raw)
  To: YueHaibing, davem, richardcochran, sudipm.mukherjee, gregkh
  Cc: linux-kernel, netdev

On 26/11/2018 11:24, YueHaibing wrote:
> pps_register_source() has keeps error codes in a local variable,
> but it does not make use of the code. This patch let it return
> the errcode in case of failure.
> 
> Suggested-by: Richard Cochran <richardcochran@gmail.com>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Acked-by: Rodolfo Giometti <giometti@enneenne.com>

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

* Re: [PATCH -next] pps: using ERR_PTR instead of NULL while pps_register_source fails
  2018-11-26 10:43 ` Rodolfo Giometti
@ 2018-11-27  7:34   ` Greg KH
  2018-11-27  8:36     ` Rodolfo Giometti
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2018-11-27  7:34 UTC (permalink / raw)
  To: Rodolfo Giometti
  Cc: YueHaibing, davem, richardcochran, sudipm.mukherjee,
	linux-kernel, netdev

On Mon, Nov 26, 2018 at 11:43:06AM +0100, Rodolfo Giometti wrote:
> On 26/11/2018 11:24, YueHaibing wrote:
> > pps_register_source() has keeps error codes in a local variable,
> > but it does not make use of the code. This patch let it return
> > the errcode in case of failure.
> > 
> > Suggested-by: Richard Cochran <richardcochran@gmail.com>
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Acked-by: Rodolfo Giometti <giometti@enneenne.com>

You are the maintainer of this file, shouldn't you be the one sending it
off to Linus or putting it in your tree somewhere?

thanks,

greg k-h

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

* Re: [PATCH -next] pps: using ERR_PTR instead of NULL while pps_register_source fails
  2018-11-27  7:34   ` Greg KH
@ 2018-11-27  8:36     ` Rodolfo Giometti
  2018-11-27  8:54       ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Rodolfo Giometti @ 2018-11-27  8:36 UTC (permalink / raw)
  To: Greg KH
  Cc: YueHaibing, davem, richardcochran, sudipm.mukherjee,
	linux-kernel, netdev

On 27/11/2018 08:34, Greg KH wrote:
> On Mon, Nov 26, 2018 at 11:43:06AM +0100, Rodolfo Giometti wrote:
>> On 26/11/2018 11:24, YueHaibing wrote:
>>> pps_register_source() has keeps error codes in a local variable,
>>> but it does not make use of the code. This patch let it return
>>> the errcode in case of failure.
>>>
>>> Suggested-by: Richard Cochran <richardcochran@gmail.com>
>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>
>> Acked-by: Rodolfo Giometti <giometti@enneenne.com>
> 
> You are the maintainer of this file, shouldn't you be the one sending it
> off to Linus or putting it in your tree somewhere?

This subsystem never had an official tree and in the past I simply acked the 
code and patches was taken by you (or other maintainers) for inclusion... I know 
it's not usual by it worked as is since right now!

However if you prefer having an official tree even for LinuxPPS I can do it and 
then sending my pull requests to Linus! Just let me know what is better for you! :-)

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti

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

* Re: [PATCH -next] pps: using ERR_PTR instead of NULL while pps_register_source fails
  2018-11-27  8:36     ` Rodolfo Giometti
@ 2018-11-27  8:54       ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2018-11-27  8:54 UTC (permalink / raw)
  To: Rodolfo Giometti
  Cc: YueHaibing, davem, richardcochran, sudipm.mukherjee,
	linux-kernel, netdev

On Tue, Nov 27, 2018 at 09:36:38AM +0100, Rodolfo Giometti wrote:
> On 27/11/2018 08:34, Greg KH wrote:
> > On Mon, Nov 26, 2018 at 11:43:06AM +0100, Rodolfo Giometti wrote:
> > > On 26/11/2018 11:24, YueHaibing wrote:
> > > > pps_register_source() has keeps error codes in a local variable,
> > > > but it does not make use of the code. This patch let it return
> > > > the errcode in case of failure.
> > > > 
> > > > Suggested-by: Richard Cochran <richardcochran@gmail.com>
> > > > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > > 
> > > Acked-by: Rodolfo Giometti <giometti@enneenne.com>
> > 
> > You are the maintainer of this file, shouldn't you be the one sending it
> > off to Linus or putting it in your tree somewhere?
> 
> This subsystem never had an official tree and in the past I simply acked the
> code and patches was taken by you (or other maintainers) for inclusion... I
> know it's not usual by it worked as is since right now!
> 
> However if you prefer having an official tree even for LinuxPPS I can do it
> and then sending my pull requests to Linus! Just let me know what is better
> for you! :-)

Ok, I'll take it now, thanks.

greg k-h

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

end of thread, other threads:[~2018-11-27  8:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26 10:24 [PATCH -next] pps: using ERR_PTR instead of NULL while pps_register_source fails YueHaibing
2018-11-26 10:43 ` Rodolfo Giometti
2018-11-27  7:34   ` Greg KH
2018-11-27  8:36     ` Rodolfo Giometti
2018-11-27  8:54       ` Greg KH

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.