<commit_before>/* drivers/char/dcc_tty.c
 *
 * Copyright (C) 2007 Google, Inc.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/console.h>
#include <linux/hrtimer.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>

MODULE_DESCRIPTION("DCC TTY Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");

static spinlock_t g_dcc_tty_lock = SPIN_LOCK_UNLOCKED;
static struct hrtimer g_dcc_timer;
static char g_dcc_buffer[16];
static int g_dcc_buffer_head;
static int g_dcc_buffer_count;
static unsigned g_dcc_write_delay_usecs = 1;
static struct tty_driver *g_dcc_tty_driver;
static struct tty_struct *g_dcc_tty;
static int g_dcc_tty_open_count;

static void dcc_poll_locked(void)
{
	char ch;
	int rch;
	int written;

	while (g_dcc_buffer_count) {
		ch = g_dcc_buffer[g_dcc_buffer_head];
		asm(
			"mrc 14, 0, r15, c0, c1, 0\n"
			"mcrcc 14, 0, %1, c0, c5, 0\n"
			"movcc %0, #1\n"
			"movcs %0, #0\n"
			: "=r" (written)
			: "r" (ch)
		);
		if (written) {
			if (ch == '\n')
				g_dcc_buffer[g_dcc_buffer_head] = '\r';
			else {
				g_dcc_buffer_head = (g_dcc_buffer_head + 1) % ARRAY_SIZE(g_dcc_buffer);
				g_dcc_buffer_count--;<commit_msg>char: dcc_tty: Update for spinlock changes<commit_after>/* drivers/char/dcc_tty.c
 *
 * Copyright (C) 2007 Google, Inc.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/console.h>
#include <linux/hrtimer.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/spinlock.h>

MODULE_DESCRIPTION("DCC TTY Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");

static spinlock_t g_dcc_tty_lock = __SPIN_LOCK_UNLOCKED(g_dcc_tty_lock);
static struct hrtimer g_dcc_timer;
static char g_dcc_buffer[16];
static int g_dcc_buffer_head;
static int g_dcc_buffer_count;
static unsigned g_dcc_write_delay_usecs = 1;
static struct tty_driver *g_dcc_tty_driver;
static struct tty_struct *g_dcc_tty;
static int g_dcc_tty_open_count;

static void dcc_poll_locked(void)
{
	char ch;
	int rch;
	int written;

	while (g_dcc_buffer_count) {
		ch = g_dcc_buffer[g_dcc_buffer_head];
		asm(
			"mrc 14, 0, r15, c0, c1, 0\n"
			"mcrcc 14, 0, %1, c0, c5, 0\n"
			"movcc %0, #1\n"
			"movcs %0, #0\n"
			: "=r" (written)
			: "r" (ch)
		);
		if (written) {
			if (ch == '\n')
				g_dcc_buffer[g_dcc_buffer_head] = '\r';
			else {
				g_dcc_buffer_head = (g_dcc_buffer_head + 1) % ARRAY_SIZE(g_dcc_buffer);
				g_dcc_buffer_count--;
{'fraction_non_alphanumeric': 0.11316931982633864, 'fraction_numerical': 0.017366136034732273, 'mean_word_length': 4.503184713375796, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '2721210', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1314, 'n_words': 368}