summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYueHaibing <yuehaibing@huawei.com>2018-11-26 05:24:22 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-27 04:05:36 -0500
commit3b1ad360acad6052c2568f891bb3d0f3f057016f (patch)
treede4291619d8337d97483536676c2938931948c97
parenteb30abeedee76c04bdf41c6d88545472c11a5632 (diff)
pps: using ERR_PTR instead of NULL while pps_register_source fails
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>
-rw-r--r--drivers/pps/clients/pps-gpio.c4
-rw-r--r--drivers/pps/clients/pps-ktimer.c4
-rw-r--r--drivers/pps/clients/pps-ldisc.c4
-rw-r--r--drivers/pps/clients/pps_parport.c2
-rw-r--r--drivers/pps/kapi.c5
5 files changed, 10 insertions, 9 deletions
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 333ad7d5b45b..dd5d1103e02b 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)
158 if (data->capture_clear) 158 if (data->capture_clear)
159 pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR; 159 pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
160 data->pps = pps_register_source(&data->info, pps_default_params); 160 data->pps = pps_register_source(&data->info, pps_default_params);
161 if (data->pps == NULL) { 161 if (IS_ERR(data->pps)) {
162 dev_err(&pdev->dev, "failed to register IRQ %d as PPS source\n", 162 dev_err(&pdev->dev, "failed to register IRQ %d as PPS source\n",
163 data->irq); 163 data->irq);
164 return -EINVAL; 164 return PTR_ERR(data->pps);
165 } 165 }
166 166
167 /* register IRQ interrupt handler */ 167 /* register IRQ interrupt handler */
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index 04735649052a..728818b87af3 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)
80{ 80{
81 pps = pps_register_source(&pps_ktimer_info, 81 pps = pps_register_source(&pps_ktimer_info,
82 PPS_CAPTUREASSERT | PPS_OFFSETASSERT); 82 PPS_CAPTUREASSERT | PPS_OFFSETASSERT);
83 if (pps == NULL) { 83 if (IS_ERR(pps)) {
84 pr_err("cannot register PPS source\n"); 84 pr_err("cannot register PPS source\n");
85 return -ENOMEM; 85 return PTR_ERR(pps);
86 } 86 }
87 87
88 timer_setup(&ktimer, pps_ktimer_event, 0); 88 timer_setup(&ktimer, pps_ktimer_event, 0);
diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
index 73bd3bb4d93b..00f6c460e493 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)
72 72
73 pps = pps_register_source(&info, PPS_CAPTUREBOTH | \ 73 pps = pps_register_source(&info, PPS_CAPTUREBOTH | \
74 PPS_OFFSETASSERT | PPS_OFFSETCLEAR); 74 PPS_OFFSETASSERT | PPS_OFFSETCLEAR);
75 if (pps == NULL) { 75 if (IS_ERR(pps)) {
76 pr_err("cannot register PPS source \"%s\"\n", info.path); 76 pr_err("cannot register PPS source \"%s\"\n", info.path);
77 return -ENOMEM; 77 return PTR_ERR(pps);
78 } 78 }
79 pps->lookup_cookie = tty; 79 pps->lookup_cookie = tty;
80 80
diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c
index 4db824f88d00..7226e39aae83 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)
179 179
180 device->pps = pps_register_source(&info, 180 device->pps = pps_register_source(&info,
181 PPS_CAPTUREBOTH | PPS_OFFSETASSERT | PPS_OFFSETCLEAR); 181 PPS_CAPTUREBOTH | PPS_OFFSETASSERT | PPS_OFFSETCLEAR);
182 if (device->pps == NULL) { 182 if (IS_ERR(device->pps)) {
183 pr_err("couldn't register PPS source\n"); 183 pr_err("couldn't register PPS source\n");
184 goto err_release_dev; 184 goto err_release_dev;
185 } 185 }
diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
index 805c749ac1ad..a1c3cd38754f 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,
72 * source is described by info's fields and it will have, as default PPS 72 * source is described by info's fields and it will have, as default PPS
73 * parameters, the ones specified into default_params. 73 * parameters, the ones specified into default_params.
74 * 74 *
75 * The function returns, in case of success, the PPS device. Otherwise NULL. 75 * The function returns, in case of success, the PPS device. Otherwise
76 * ERR_PTR(errno).
76 */ 77 */
77 78
78struct pps_device *pps_register_source(struct pps_source_info *info, 79struct pps_device *pps_register_source(struct pps_source_info *info,
@@ -135,7 +136,7 @@ kfree_pps:
135pps_register_source_exit: 136pps_register_source_exit:
136 pr_err("%s: unable to register source\n", info->name); 137 pr_err("%s: unable to register source\n", info->name);
137 138
138 return NULL; 139 return ERR_PTR(err);
139} 140}
140EXPORT_SYMBOL(pps_register_source); 141EXPORT_SYMBOL(pps_register_source);
141 142