linux/drivers/input/gameport/gameport.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Generic gameport layer
 *
 * Copyright (c) 1999-2002 Vojtech Pavlik
 * Copyright (c) 2005 Dmitry Torokhov
 */


#define pr_fmt(fmt)

#include <linux/stddef.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/gameport.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/sched.h>	/* HZ */
#include <linux/mutex.h>
#include <linux/timekeeping.h>

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

static bool use_ktime =;
module_param(use_ktime, bool, 0400);
MODULE_PARM_DESC();

/*
 * gameport_mutex protects entire gameport subsystem and is taken
 * every time gameport port or driver registrered or unregistered.
 */
static DEFINE_MUTEX(gameport_mutex);

static LIST_HEAD(gameport_list);

static const struct bus_type gameport_bus;

static void gameport_add_port(struct gameport *gameport);
static void gameport_attach_driver(struct gameport_driver *drv);
static void gameport_reconnect_port(struct gameport *gameport);
static void gameport_disconnect_port(struct gameport *gameport);

#if defined(__i386__)

#include <linux/i8253.h>

#define DELTA
#define GET_TIME

static unsigned int get_time_pit(void)
{
	unsigned long flags;
	unsigned int count;

	raw_spin_lock_irqsave(&i8253_lock, flags);
	outb_p(0x00, 0x43);
	count = inb_p(0x40);
	count |= inb_p(0x40) << 8;
	raw_spin_unlock_irqrestore(&i8253_lock, flags);

	return count;
}

#endif



/*
 * gameport_measure_speed() measures the gameport i/o speed.
 */

static int gameport_measure_speed(struct gameport *gameport)
{}

static int old_gameport_measure_speed(struct gameport *gameport)
{}

void gameport_start_polling(struct gameport *gameport)
{}
EXPORT_SYMBOL();

void gameport_stop_polling(struct gameport *gameport)
{}
EXPORT_SYMBOL();

static void gameport_run_poll_handler(struct timer_list *t)
{}

/*
 * Basic gameport -> driver core mappings
 */

static int gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv)
{}

static void gameport_find_driver(struct gameport *gameport)
{}


/*
 * Gameport event processing.
 */

enum gameport_event_type {};

struct gameport_event {};

static DEFINE_SPINLOCK(gameport_event_lock);	/* protects gameport_event_list */
static LIST_HEAD(gameport_event_list);

static struct gameport_event *gameport_get_event(void)
{}

static void gameport_free_event(struct gameport_event *event)
{}

static void gameport_remove_duplicate_events(struct gameport_event *event)
{}


static void gameport_handle_events(struct work_struct *work)
{}

static DECLARE_WORK(gameport_event_work, gameport_handle_events);

static int gameport_queue_event(void *object, struct module *owner,
				enum gameport_event_type event_type)
{}

/*
 * Remove all events that have been submitted for a given object,
 * be it a gameport port or a driver.
 */
static void gameport_remove_pending_events(void *object)
{}

/*
 * Destroy child gameport port (if any) that has not been fully registered yet.
 *
 * Note that we rely on the fact that port can have only one child and therefore
 * only one child registration request can be pending. Additionally, children
 * are registered by driver's connect() handler so there can't be a grandchild
 * pending registration together with a child.
 */
static struct gameport *gameport_get_pending_child(struct gameport *parent)
{}

/*
 * Gameport port operations
 */

static ssize_t gameport_description_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(description, S_IRUGO, gameport_description_show, NULL);

static ssize_t drvctl_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{}
static DEVICE_ATTR_WO(drvctl);

static struct attribute *gameport_device_attrs[] =;
ATTRIBUTE_GROUPS();

static void gameport_release_port(struct device *dev)
{}

void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
{}
EXPORT_SYMBOL();

static void gameport_default_trigger(struct gameport *gameport)
{}

static unsigned char gameport_default_read(struct gameport *gameport)
{}

static void gameport_setup_default_handlers(struct gameport *gameport)
{}

/*
 * Prepare gameport port for registration.
 */
static void gameport_init_port(struct gameport *gameport)
{}

/*
 * Complete gameport port registration.
 * Driver core will attempt to find appropriate driver for the port.
 */
static void gameport_add_port(struct gameport *gameport)
{}

/*
 * gameport_destroy_port() completes deregistration process and removes
 * port from the system
 */
static void gameport_destroy_port(struct gameport *gameport)
{}

/*
 * Reconnect gameport port and all its children (re-initialize attached devices)
 */
static void gameport_reconnect_port(struct gameport *gameport)
{}

/*
 * gameport_disconnect_port() unbinds a port from its driver. As a side effect
 * all child ports are unbound and destroyed.
 */
static void gameport_disconnect_port(struct gameport *gameport)
{}

/*
 * Submits register request to kgameportd for subsequent execution.
 * Note that port registration is always asynchronous.
 */
void __gameport_register_port(struct gameport *gameport, struct module *owner)
{}
EXPORT_SYMBOL();

/*
 * Synchronously unregisters gameport port.
 */
void gameport_unregister_port(struct gameport *gameport)
{}
EXPORT_SYMBOL();


/*
 * Gameport driver operations
 */

static ssize_t description_show(struct device_driver *drv, char *buf)
{}
static DRIVER_ATTR_RO(description);

static struct attribute *gameport_driver_attrs[] =;
ATTRIBUTE_GROUPS();

static int gameport_driver_probe(struct device *dev)
{}

static void gameport_driver_remove(struct device *dev)
{}

static void gameport_attach_driver(struct gameport_driver *drv)
{}

int __gameport_register_driver(struct gameport_driver *drv, struct module *owner,
				const char *mod_name)
{}
EXPORT_SYMBOL();

void gameport_unregister_driver(struct gameport_driver *drv)
{}
EXPORT_SYMBOL();

static int gameport_bus_match(struct device *dev, const struct device_driver *drv)
{}

static const struct bus_type gameport_bus =;

static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv)
{}

int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode)
{}
EXPORT_SYMBOL();

void gameport_close(struct gameport *gameport)
{}
EXPORT_SYMBOL();

static int __init gameport_init(void)
{}

static void __exit gameport_exit(void)
{}

subsys_initcall(gameport_init);
module_exit(gameport_exit);