<commit_before>#include <linux/version.h>
#if LINUX_VERSION_CODE < 0x020200
#error "--- Sorry, this driver needs kernel version 2.2.0 or higher. ---"
#endif

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/malloc.h>
#include <linux/tqueue.h>
#include <linux/poll.h>
#include <linux/kmod.h>

/*#include <linux/i2c-old.h>*/ /*-- use this after applying the lm_sensors
                                patches to kernel!*/
#include <linux/i2c.h>

#include "drivers/lirc.h"

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "lirc_haup.h"

#define dprintk if (debug) printk
#define DEVICE_NAME "hauppauge ir rc"

/* lock for SMP support */
spinlock_t remote_lock;

/* we use a timer_list instead of a tq_struct. */
static struct timer_list lirc_haup_timer;

static struct file_operations lirc_haup_fops = {
	NULL,            /* seek    */
	lirc_haup_read,  /* read    */
	lirc_haup_write, /* write   */
	NULL,            /* readdir */
	lirc_haup_poll,  /* poll    */
	lirc_haup_ioctl, /* ioctl   */
	NULL,            /* mmap    */
	lirc_haup_open,  /* open    */
	NULL,            /* flush   */
	lirc_haup_close  /* release */
};

/* ----------------------------------------------------------------------- */

struct i2c_driver lirc_haup_i2c_driver = 
{
	"remote",                     /* name       */
	I2C_DRIVERID_REMOTE,          /* ID         */
	IR_READ_LOW, IR_READ_HIGH,    /* addr range */

	lirc_haup_attach,
	lirc_haup_detach,
	lirc_haup_command
};


static struct lirc_haup_status remote;

/* some other tunable parameters */
static int polling     = POLLING;

/* Default address, will be overwritten by autodetection */
static int ir_read     = IR_READ_LOW;

/* debug module parameter */
static int debug = 0;

static void lirc_haup_do_timer(unsigned long data)
{
	struct lirc_haup_status *remote = (struct lirc_haup_status *)data;
	unsigned short code;

	spin_lock(&remote_lock);
	
	if (remote->wait_cleanup != NULL) {
		wake_up(&remote->wait_cleanup);
	        spin_unlock(&remote_lock);
		/* Now cleanup_module can return */
		return;
	}

	if (remote->attached) {
		/* keep the remote_lock during the execution
		   of read_raw_keypress */
		code = read_raw_keypress(remote); /* get key from the remote */
		if( (code!=0xffff) ) {
			/* if buffer is full, drop input */
			if (((remote->tail+1)%BUFLEN)==remote->head) {
				dprintk("lirc_haup: input buffer overflow\n");
			} else {
				/* put new code to the buffer */
				remote->buffer[remote->tail++]=code;
				remote->tail%=BUFLEN;
				wake_up_interruptible(&remote->wait_poll);
			}<commit_msg>uploaded patch from Mike <<EMAIL>> for 2.3.x kernels<commit_after>#include <linux/version.h>
#if LINUX_VERSION_CODE < 0x020200
#error "--- Sorry, this driver needs kernel version 2.2.0 or higher. ---"
#endif

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/malloc.h>
#include <linux/tqueue.h>
#include <linux/poll.h>
#include <linux/kmod.h>

/*#include <linux/i2c-old.h>*/ /*-- use this after applying the lm_sensors
                                patches to kernel!*/
#include <linux/i2c.h>

#include "drivers/lirc.h"

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "lirc_haup.h"

#define dprintk if (debug) printk
#define DEVICE_NAME "hauppauge ir rc"

/* lock for SMP support */
spinlock_t remote_lock;

/* we use a timer_list instead of a tq_struct. */
static struct timer_list lirc_haup_timer;

static struct file_operations lirc_haup_fops = {
	NULL,            /* seek    */
	lirc_haup_read,  /* read    */
	lirc_haup_write, /* write   */
	NULL,            /* readdir */
	lirc_haup_poll,  /* poll    */
	lirc_haup_ioctl, /* ioctl   */
	NULL,            /* mmap    */
	lirc_haup_open,  /* open    */
	NULL,            /* flush   */
	lirc_haup_close  /* release */
};

/* ----------------------------------------------------------------------- */

struct i2c_driver lirc_haup_i2c_driver = 
{
	"remote",                     /* name       */
	I2C_DRIVERID_REMOTE,          /* ID         */
	IR_READ_LOW, IR_READ_HIGH,    /* addr range */

	lirc_haup_attach,
	lirc_haup_detach,
	lirc_haup_command
};


static struct lirc_haup_status remote;

/* some other tunable parameters */
static int polling     = POLLING;

/* Default address, will be overwritten by autodetection */
static int ir_read     = IR_READ_LOW;

/* debug module parameter */
static int debug = 0;

static void lirc_haup_do_timer(unsigned long data)
{
	struct lirc_haup_status *remote = (struct lirc_haup_status *)data;
	unsigned short code;

	spin_lock(&remote_lock);
	
#if LINUX_VERSION_CODE < 0x020300
        if (remote->wait_cleanup != NULL) {
#else
	if (remote->wait_cleanup.task_list.next != 
	    &(remote->wait_cleanup.task_list)) {
#endif
		wake_up(&remote->wait_cleanup);
	        spin_unlock(&remote_lock);
		/* Now cleanup_module can return */
		return;
	}

	if (remote->attached) {
		/* keep the remote_lock during the execution
		   of read_raw_keypress */
		code = read_raw_keypress(remote); /* get key from the remote */
		if( (code!=0xffff) ) {
			/* if buffer is full, drop input */
			if (((remote->tail+1)%BUFLEN)==remote->head) {
				dprintk("lirc_haup: input buffer overflow\n");
			} else {
				/* put new code to the buffer */
				remote->buffer[remote->tail++]=code;
				remote->tail%=BUFLEN;
				wake_up_interruptible(&remote->wait_poll);
			}
{'fraction_non_alphanumeric': 0.15460057061340943, 'fraction_numerical': 0.008024251069900143, 'mean_word_length': 2.7293882978723403, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2948701', 'n_tokens_mistral': 2155, 'n_tokens_neox': 1968, 'n_words': 459}