[PATCH] staging: greybus: uart: return tty_alloc_driver() errors

Alfie Varghese posted 1 patch 1 week, 5 days ago
There is a newer version of this series
drivers/staging/greybus/uart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] staging: greybus: uart: return tty_alloc_driver() errors
Posted by Alfie Varghese 1 week, 5 days ago
gb_tty_init() maps any tty_alloc_driver() failure to -ENOMEM. This
loses the real errno returned by the driver core and makes failures
harder to diagnose correctly.

Return PTR_ERR(gb_tty_driver) instead so callers receive the actual
failure reason while preserving the existing cleanup path.

Signed-off-by: Alfie Varghese <alfievarghese22@gmail.com>
---
 drivers/staging/greybus/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..24b4dab069c3 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -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;
 	}
 
-- 
2.54.0.windows.1
Re: [PATCH] staging: greybus: uart: return tty_alloc_driver() errors
Posted by Dan Carpenter 1 week, 4 days ago
On Mon, Jul 13, 2026 at 10:38:45PM +0530, Alfie Varghese wrote:
> gb_tty_init() maps any tty_alloc_driver() failure to -ENOMEM. This
> loses the real errno returned by the driver core and makes failures
> harder to diagnose correctly.
> 
> Return PTR_ERR(gb_tty_driver) instead so callers receive the actual
> failure reason while preserving the existing cleanup path.
> 
> Signed-off-by: Alfie Varghese <alfievarghese22@gmail.com>
> ---

I don't have a problem with this change but the commit message
should say that tty_alloc_driver() in this case always returns
-ENOMEM so this is just a style fix and not anything which matters.

regards,
dan carpenter