Commit 528f3119 authored by Jiri Slaby (SUSE)'s avatar Jiri Slaby (SUSE) Committed by Greg Kroah-Hartman
Browse files

tty: srmcons: fix retval from srmcons_init()



The value returned from srmcons_init() was -ENODEV for over 2 decades.
But it does not matter, given device_initcall() ignores retvals.

But to be honest, return 0 in case the tty driver was registered
properly.

To do that, the condition is inverted and a short path taken in case of
error.

err_free_drv is introduced as it will be used from more places later.

Signed-off-by: default avatarJiri Slaby (SUSE) <jirislaby@kernel.org>
Tested-by: default avatarMagnus Lindholm <linmag7@gmail.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Link: https://lore.kernel.org/r/20250317070046.24386-22-jirislaby@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 794d7b27
Loading
Loading
Loading
Loading
+33 −29
Original line number Diff line number Diff line
@@ -196,11 +196,14 @@ static const struct tty_operations srmcons_ops = {
static int __init
srmcons_init(void)
{
	timer_setup(&srmcons_singleton.timer, srmcons_receive_chars, 0);
	if (srm_is_registered_console) {
	struct tty_driver *driver;
	int err;

	timer_setup(&srmcons_singleton.timer, srmcons_receive_chars, 0);

	if (!srm_is_registered_console)
		return -ENODEV;

	driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0);
	if (IS_ERR(driver))
		return PTR_ERR(driver);
@@ -217,19 +220,20 @@ srmcons_init(void)
	tty_set_operations(driver, &srmcons_ops);
	tty_port_link_device(&srmcons_singleton.port, driver, 0);
	err = tty_register_driver(driver);
		if (err) {
	if (err)
		goto err_free_drv;

	srmcons_driver = driver;

	return 0;
err_free_drv:
	tty_driver_kref_put(driver);
	tty_port_destroy(&srmcons_singleton.port);
			return err;
		}
		srmcons_driver = driver;
	}

	return -ENODEV;
	return err;
}
device_initcall(srmcons_init);


/*
 * The console driver
 */