[PATCH 4/6] pps: print error in both cdev and dev error paths in pps_register_cdev()

From: Michal Schmidt
Date: Mon Dec 02 2024 - 11:51:40 EST


For pps, a device_create() failure is just as severe as a cdev_add()
failure. Print the error message in both cases.

Signed-off-by: Michal Schmidt <mschmidt@xxxxxxxxxx>
---
drivers/pps/pps.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index 92be7815a621..f90ee483d343 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -357,11 +357,9 @@ int pps_register_cdev(struct pps_device *pps)
pps->cdev.owner = pps->info.owner;

err = cdev_add(&pps->cdev, devt, 1);
- if (err) {
- pr_err("%s: failed to add char device %d:%d\n",
- pps->info.name, MAJOR(pps_devt), pps->id);
+ if (err)
goto free_idr;
- }
+
pps->dev = device_create(pps_class, pps->info.dev, devt, pps,
"pps%d", pps->id);
if (IS_ERR(pps->dev)) {
@@ -387,6 +385,8 @@ int pps_register_cdev(struct pps_device *pps)
free_idr:
scoped_guard(mutex, &pps_idr_lock)
idr_remove(&pps_idr, pps->id);
+ pr_err("%s: failed to add char device %d:%d\n",
+ pps->info.name, MAJOR(pps_devt), pps->id);
return err;
}

--
2.47.0