]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
pps: using ERR_PTR instead of NULL while pps_register_source fails
authorYueHaibing <yuehaibing@huawei.com>
Mon, 26 Nov 2018 10:24:22 +0000 (18:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Nov 2018 09:05:36 +0000 (10:05 +0100)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pps/clients/pps-gpio.c
drivers/pps/clients/pps-ktimer.c
drivers/pps/clients/pps-ldisc.c
drivers/pps/clients/pps_parport.c
drivers/pps/kapi.c

index 333ad7d5b45bf34c76ce4c7a0a8e4e703e83d3f0..dd5d1103e02b25e47580f10b1190af819edb9c1e 100644 (file)
@@ -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 */
index 04735649052ab3652d38c8ce775d033fb8cde7ac..728818b87af3a249a1b7b92652d47ee9a60c0c5e 100644 (file)
@@ -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);
index 73bd3bb4d93b5945c89b49a7ed60ea49750da796..00f6c460e493cede10c736acb99014bf4d269986 100644 (file)
@@ -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;
 
index 4db824f88d0095363d387cdfae7905784e4ffd28..7226e39aae83a55d4f1173b0a1b3e5a48b6d339a 100644 (file)
@@ -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;
        }
index 805c749ac1ad035975a36c00231a83395e55e102..a1c3cd38754f2afeadf0802dcfda62e5b8687ccb 100644 (file)
@@ -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);