Skip to contentSkip to conversation

staging: greybus: uart: return tty_alloc_driver() errors

PATCH In review Alfie Varghese 2 participants 2 messages Jul 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 staging: greybus: uart: return tty_alloc_driver() errors

gb_tty_init() maps any tty_alloc_driver() failure to -ENOMEM. tty_alloc_driver() currently always returns -ENOMEM on failure, so this does not change behavior in practice. However, returning PTR_ERR(gb_tty_driver) is more correct and consistent with kernel conventions, preserving any future error codes the function might return.

---
v3: resend, v2 was corrupted in transit. No code changes.
v2: updated commit message per Dan Carpenter's review to clarify
that tty_alloc_driver() currently only returns -ENOMEM, making this a style fix rather than a behavioral change.

---
 drivers/staging/greybus/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/uart.c +1 -1
index 7d060b4cd33d..24b4dab069c3 100644
@@ -951,7 +951,7 @@ static int gb_tty_init(void)
 					 TTY_DRIVER_DYNAMIC_DEV);
 	if (IS_ERR(gb_tty_driver)) {
 		pr_err("Can not allocate tty driver\n");
-		retval = -ENOMEM;
+		retval = PTR_ERR(gb_tty_driver);
 		goto fail_unregister_dev;
 	}
 
Signature · 1 line
2.54.0.windows.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 9 lines · Alfie Varghese

gb_tty_init() maps any tty_alloc_driver() failure to -ENOMEM. tty_alloc_driver() currently always returns -ENOMEM on failure, so this does not change behavior in practice. However, returning PTR_ERR(gb_tty_driver) is more correct and consistent with kernel conventions, preserving any future error codes the function might return.

---

Thanks!

regards,
dan carpenter