/* gameport_destroy_port() completes deregistration process and removes port from the system  */
static void gameport_destroy_port(struct gameport *gameport)
/* gameport_destroy_port() completes deregistration process and removes port from the system  */
static void gameport_destroy_port(struct gameport *gameport)
{
	struct gameport *child;
	child = gameport_get_pending_child(gameport);
	if (child) {
		gameport_remove_pending_events(child);
		put_device(&child->dev);
	}
	if (gameport->parent) {
		gameport->parent->child = NULL;
		gameport->parent = NULL;
	}
	if (gameport->registered) {
		device_del(&gameport->dev);
		gameport->registered = 0;
	}
	list_del_init(&gameport->node);
	gameport_remove_pending_events(gameport);
	put_device(&gameport->dev);
}