/* The driver must unbind first prior to unregistration.  */
int unregister_con_driver(const struct consw *csw)
/* The driver must unbind first prior to unregistration.  */
int unregister_con_driver(const struct consw *csw)
{
	int i, retval = -ENODEV;
	acquire_console_sem();
	if (con_is_bound(csw))
		goto err;
	for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
		struct con_driver *con_driver = &registered_con_driver[i];
		if (con_driver->con == csw &&
		    con_driver->flag & CON_DRIVER_FLAG_MODULE) {
			vtconsole_deinit_device(con_driver);
			device_destroy(vtconsole_class,
				       MKDEV(0, con_driver->node));
			con_driver->con = NULL;
			con_driver->desc = NULL;
			con_driver->dev = NULL;
			con_driver->node = 0;
			con_driver->flag = 0;
			con_driver->first = 0;
			con_driver->last = 0;
			retval = 0;
			break;
		}
	}
err:
	release_console_sem();
	return retval;
}