type stringclasses 5
values | content stringlengths 9 163k |
|---|---|
main | int
main(int argc, char **argv) {
int fd, n;
int len;
char buf[BUFFSIZE];
if ((fd = open(SOURCE, O_RDWR | O_APPEND)) == -1) {
fprintf(stderr, "Unable to open '%s': %s\n",
SOURCE, strerror(errno));
exit(EXIT_FAILURE);
} |
includes |
#include <linux/module.h> |
includes | #include <linux/kernel.h> |
includes | #include <linux/sched.h> |
includes | #include <linux/types.h> |
includes | #include <linux/fcntl.h> |
includes | #include <linux/interrupt.h> |
includes | #include <linux/ptrace.h> |
includes | #include <linux/ioport.h> |
includes | #include <linux/in.h> |
includes | #include <linux/slab.h> |
includes | #include <linux/smp_lock.h> |
includes | #include <linux/tty.h> |
includes | #include <linux/errno.h> |
includes | #include <linux/string.h> |
includes | #include <linux/signal.h> |
includes | #include <linux/ioctl.h> |
includes | #include <linux/n_r3964.h> |
includes | #include <linux/poll.h> |
includes | #include <linux/init.h> |
includes | #include <asm/uaccess.h> |
defines | #define TRACE(format, args...) printk("r3964: " format "\n" , ## args) |
defines | #define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args) |
defines | #define TRACE_M(fmt, arg...) do {} while (0) |
defines | #define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args) |
defines | #define TRACE_PS(fmt, arg...) do {} while (0) |
defines | #define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args) |
defines | #define TRACE_PE(fmt, arg...) do {} while (0) |
defines | #define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args) |
defines | #define TRACE_L(fmt, arg...) do {} while (0) |
defines | #define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args) |
defines | #define TRACE_Q(fmt, arg...) do {} while (0) |
functions | void dump_block(const unsigned char *block, unsigned int length)
{
unsigned int i, j;
char linebuf[16 * 3 + 1];
for (i = 0; i < length; i += 16) {
for (j = 0; (j < 16) && (j + i < length); j++) {
sprintf(linebuf + 3 * j, "%02x ", block[i + j]);
} |
functions | __exit r3964_exit(void)
{
int status;
TRACE_M("cleanup_module()");
status = tty_unregister_ldisc(N_R3964);
if (status != 0) {
printk(KERN_ERR "r3964: error unregistering linediscipline: "
"%d\n", status);
} |
functions | __init r3964_init(void)
{
int status;
printk("r3964: Philips r3964 Driver $Revision: 1.1.1.1 $\n");
/*
* Register the tty line discipline
*/
status = tty_register_ldisc(N_R3964, &tty_ldisc_N_R3964);
if (status == 0) {
TRACE_L("line discipline %d registered", N_R3964);
TRACE_L("flags=%x num=%x", tty_ldis... |
functions | void add_tx_queue(struct r3964_info *pInfo,
struct r3964_block_header *pHeader)
{
unsigned long flags;
spin_lock_irqsave(&pInfo->lock, flags);
pHeader->next = NULL;
if (pInfo->tx_last == NULL) {
pInfo->tx_first = pInfo->tx_last = pHeader;
} |
functions | void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
{
struct r3964_block_header *pHeader;
unsigned long flags;
#ifdef DEBUG_QUEUE
struct r3964_block_header *pDump;
#endif
pHeader = pInfo->tx_first;
if (pHeader == NULL)
return;
#ifdef DEBUG_QUEUE
printk("r3964: remove_from_tx_queue: %p, length... |
functions | void add_rx_queue(struct r3964_info *pInfo,
struct r3964_block_header *pHeader)
{
unsigned long flags;
spin_lock_irqsave(&pInfo->lock, flags);
pHeader->next = NULL;
if (pInfo->rx_last == NULL) {
pInfo->rx_first = pInfo->rx_last = pHeader;
} |
functions | void remove_from_rx_queue(struct r3964_info *pInfo,
struct r3964_block_header *pHeader)
{
unsigned long flags;
struct r3964_block_header *pFind;
if (pHeader == NULL)
return;
TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue... |
functions | void put_char(struct r3964_info *pInfo, unsigned char ch)
{
struct tty_struct *tty = pInfo->tty;
/* FIXME: put_char should not be called from an IRQ */
tty_put_char(tty, ch);
pInfo->bcc ^= ch;
} |
functions | void flush(struct r3964_info *pInfo)
{
struct tty_struct *tty = pInfo->tty;
if (tty == NULL || tty->ops->flush_chars == NULL)
return;
tty->ops->flush_chars(tty);
} |
functions | void trigger_transmit(struct r3964_info *pInfo)
{
unsigned long flags;
spin_lock_irqsave(&pInfo->lock, flags);
if ((pInfo->state == R3964_IDLE) && (pInfo->tx_first != NULL)) {
pInfo->state = R3964_TX_REQUEST;
pInfo->nRetry = 0;
pInfo->flags &= ~R3964_ERROR;
mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
... |
functions | void retry_transmit(struct r3964_info *pInfo)
{
if (pInfo->nRetry < R3964_MAX_RETRIES) {
TRACE_PE("transmission failed. Retry #%d", pInfo->nRetry);
pInfo->bcc = 0;
put_char(pInfo, STX);
flush(pInfo);
pInfo->state = R3964_TX_REQUEST;
pInfo->nRetry++;
mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
} |
functions | void transmit_block(struct r3964_info *pInfo)
{
struct tty_struct *tty = pInfo->tty;
struct r3964_block_header *pBlock = pInfo->tx_first;
int room = 0;
if (tty == NULL || pBlock == NULL) {
return;
} |
functions | void on_receive_block(struct r3964_info *pInfo)
{
unsigned int length;
struct r3964_client_info *pClient;
struct r3964_block_header *pBlock;
length = pInfo->rx_position;
/* compare byte checksum characters: */
if (pInfo->flags & R3964_BCC) {
if (pInfo->bcc != pInfo->last_rx) {
TRACE_PE("checksum error - go... |
functions | void receive_char(struct r3964_info *pInfo, const unsigned char c)
{
switch (pInfo->state) {
case R3964_TX_REQUEST:
if (c == DLE) {
TRACE_PS("TX_REQUEST - got DLE");
pInfo->state = R3964_TRANSMITTING;
pInfo->tx_position = 0;
transmit_block(pInfo);
} |
functions | else if (c == STX) {
if (pInfo->nRetry == 0) {
TRACE_PE("TX_REQUEST - init conflict");
if (pInfo->priority == R3964_SLAVE) {
goto start_receiving;
} |
functions | void receive_error(struct r3964_info *pInfo, const char flag)
{
switch (flag) {
case TTY_NORMAL:
break;
case TTY_BREAK:
TRACE_PE("received break");
pInfo->flags |= R3964_BREAK;
break;
case TTY_PARITY:
TRACE_PE("parity error");
pInfo->flags |= R3964_PARITY;
break;
case TTY_FRAME:
TRACE_PE("frame err... |
functions | void on_timeout(unsigned long priv)
{
struct r3964_info *pInfo = (void *)priv;
switch (pInfo->state) {
case R3964_TX_REQUEST:
TRACE_PE("TX_REQUEST - timeout");
retry_transmit(pInfo);
break;
case R3964_WAIT_ZVZ_BEFORE_TX_RETRY:
put_char(pInfo, NAK);
flush(pInfo);
retry_transmit(pInfo);
break;
case R3... |
functions | int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg)
{
struct r3964_client_info *pClient;
struct r3964_client_info **ppClient;
struct r3964_message *pMsg;
if ((arg & R3964_SIG_ALL) == 0) {
/* Remove client from client list */
for (ppClient = &pInfo->firstClient; *ppClient;
ppClient = &... |
functions | int read_telegram(struct r3964_info *pInfo, struct pid *pid,
unsigned char __user * buf)
{
struct r3964_client_info *pClient;
struct r3964_block_header *block;
if (!buf) {
return -EINVAL;
} |
functions | void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
int error_code, struct r3964_block_header *pBlock)
{
struct r3964_message *pMsg;
unsigned long flags;
if (pClient->msg_count < R3964_MAX_MSG_COUNT - 1) {
queue_the_message:
pMsg = kmalloc(sizeof(struct r3964_message),
error_code ? GFP_ATO... |
functions | void remove_client_block(struct r3964_info *pInfo,
struct r3964_client_info *pClient)
{
struct r3964_block_header *block;
TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
block = pClient->next_block_to_read;
if (block) {
block->locks--;
if (block->locks == 0) {
remove_from_rx_queue(pInfo, ... |
functions | int r3964_open(struct tty_struct *tty)
{
struct r3964_info *pInfo;
TRACE_L("open");
TRACE_L("tty=%p, PID=%d, disc_data=%p",
tty, current->pid, tty->disc_data);
pInfo = kmalloc(sizeof(struct r3964_info), GFP_KERNEL);
TRACE_M("r3964_open - info kmalloc %p", pInfo);
if (!pInfo) {
printk(KERN_ERR "r3964: faile... |
functions | void r3964_close(struct tty_struct *tty)
{
struct r3964_info *pInfo = tty->disc_data;
struct r3964_client_info *pClient, *pNext;
struct r3964_message *pMsg;
struct r3964_block_header *pHeader, *pNextHeader;
unsigned long flags;
TRACE_L("close");
/*
* Make sure that our task queue isn't activated. If it
* ... |
functions | ssize_t r3964_read(struct tty_struct *tty, struct file *file,
unsigned char __user * buf, size_t nr)
{
struct r3964_info *pInfo = tty->disc_data;
struct r3964_client_info *pClient;
struct r3964_message *pMsg;
struct r3964_client_message theMsg;
int ret;
TRACE_L("read()");
lock_kernel();
pClient = findCl... |
functions | ssize_t r3964_write(struct tty_struct *tty, struct file *file,
const unsigned char *data, size_t count)
{
struct r3964_info *pInfo = tty->disc_data;
struct r3964_block_header *pHeader;
struct r3964_client_info *pClient;
unsigned char *new_data;
TRACE_L("write request, %d characters", count);
/*
* Verify t... |
functions | int r3964_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct r3964_info *pInfo = tty->disc_data;
if (pInfo == NULL)
return -EINVAL;
switch (cmd) {
case R3964_ENABLE_SIGNALS:
return enable_signals(pInfo, task_pid(current), arg);
case R3964_SETPRIORITY:
if (arg < R... |
functions | void r3964_set_termios(struct tty_struct *tty, struct ktermios *old)
{
TRACE_L("set_termios");
} |
functions | int r3964_poll(struct tty_struct *tty, struct file *file,
struct poll_table_struct *wait)
{
struct r3964_info *pInfo = tty->disc_data;
struct r3964_client_info *pClient;
struct r3964_message *pMsg = NULL;
unsigned long flags;
int result = POLLOUT;
TRACE_L("POLL");
pClient = findClient(pInfo, task_pid(curren... |
functions | void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{
struct r3964_info *pInfo = tty->disc_data;
const unsigned char *p;
char *f, flags = 0;
int i;
for (i = count, p = cp, f = fp; i; i--, p++) {
if (f)
flags = *f++;
if (flags == TTY_NORMAL) {
receive_char(pInf... |
includes |
#include <linux/init.h> |
includes | #include <linux/module.h> |
includes | #include <linux/ioctl.h> |
includes | #include <linux/fs.h> |
includes | #include <linux/device.h> |
includes | #include <linux/err.h> |
includes | #include <linux/list.h> |
includes | #include <linux/errno.h> |
includes | #include <linux/mutex.h> |
includes | #include <linux/slab.h> |
includes | #include <linux/compat.h> |
includes | #include <linux/of.h> |
includes | #include <linux/of_device.h> |
includes |
#include <linux/spi/spi.h> |
includes | #include <linux/spi/spidev.h> |
includes |
#include <asm/uaccess.h> |
defines | #define SPIDEV_MAJOR 153 /* assigned */ |
defines | #define N_SPI_MINORS 32 /* ... up to 256 */ |
defines | #define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \ |
defines | #define spidev_compat_ioctl NULL |
structs | struct spidev_data {
dev_t devt;
spinlock_t spi_lock;
struct spi_device *spi;
struct list_head device_entry;
/* buffer is NULL unless this device is open (users > 0) */
struct mutex buf_lock;
unsigned users;
u8 *buffer;
}; |
functions | void spidev_complete(void *arg)
{
complete(arg);
} |
functions | ssize_t
spidev_sync(struct spidev_data *spidev, struct spi_message *message)
{
DECLARE_COMPLETION_ONSTACK(done);
int status;
message->complete = spidev_complete;
message->context = &done;
spin_lock_irq(&spidev->spi_lock);
if (spidev->spi == NULL)
status = -ESHUTDOWN;
else
status = spi_async(spidev->spi, me... |
functions | ssize_t
spidev_sync_write(struct spidev_data *spidev, size_t len)
{
struct spi_transfer t = {
.tx_buf = spidev->buffer,
.len = len,
} |
functions | ssize_t
spidev_sync_read(struct spidev_data *spidev, size_t len)
{
struct spi_transfer t = {
.rx_buf = spidev->buffer,
.len = len,
} |
functions | ssize_t
spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
struct spidev_data *spidev;
ssize_t status = 0;
/* chipselect only toggles at start or end of operation */
if (count > bufsiz)
return -EMSGSIZE;
spidev = filp->private_data;
mutex_lock(&spidev->buf_lock);
status = spid... |
functions | ssize_t
spidev_write(struct file *filp, const char __user *buf,
size_t count, loff_t *f_pos)
{
struct spidev_data *spidev;
ssize_t status = 0;
unsigned long missing;
/* chipselect only toggles at start or end of operation */
if (count > bufsiz)
return -EMSGSIZE;
spidev = filp->private_data;
mutex_lock(... |
functions | int spidev_message(struct spidev_data *spidev,
struct spi_ioc_transfer *u_xfers, unsigned n_xfers)
{
struct spi_message msg;
struct spi_transfer *k_xfers;
struct spi_transfer *k_tmp;
struct spi_ioc_transfer *u_tmp;
unsigned n, total;
u8 *buf;
int status = -EFAULT;
spi_message_init(&msg);
k_xfers = kcal... |
functions | long
spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
int err = 0;
int retval = 0;
struct spidev_data *spidev;
struct spi_device *spi;
u32 tmp;
unsigned n_ioc;
struct spi_ioc_transfer *ioc;
/* Check type and command number */
if (_IOC_TYPE(cmd) != SPI_IOC_MAGIC)
return -ENOTTY;
... |
functions | long
spidev_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
return spidev_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
} |
functions | int spidev_open(struct inode *inode, struct file *filp)
{
struct spidev_data *spidev;
int status = -ENXIO;
mutex_lock(&device_list_lock);
list_for_each_entry(spidev, &device_list, device_entry) {
if (spidev->devt == inode->i_rdev) {
status = 0;
break;
} |
functions | int spidev_release(struct inode *inode, struct file *filp)
{
struct spidev_data *spidev;
int status = 0;
mutex_lock(&device_list_lock);
spidev = filp->private_data;
filp->private_data = NULL;
/* last close? */
spidev->users--;
if (!spidev->users) {
int dofree;
kfree(spidev->buffer);
spidev->buffer =... |
functions | __devinit spidev_probe(struct spi_device *spi)
{
struct spidev_data *spidev;
int status;
unsigned long minor;
/* Allocate driver data */
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
if (!spidev)
return -ENOMEM;
/* Initialize the driver data */
spidev->spi = spi;
spin_lock_init(&spidev->spi_lock);
mut... |
functions | __devexit spidev_remove(struct spi_device *spi)
{
struct spidev_data *spidev = spi_get_drvdata(spi);
/* make sure ops on existing fds can abort cleanly */
spin_lock_irq(&spidev->spi_lock);
spidev->spi = NULL;
spi_set_drvdata(spi, NULL);
spin_unlock_irq(&spidev->spi_lock);
/* prevent new opens */
mutex_lock(&d... |
functions | __init spidev_init(void)
{
int status;
/* Claim our 256 reserved device numbers. Then register a class
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers.
*/
BUILD_BUG_ON(N_SPI_MINORS > 256);
status = register_chrdev(SPIDEV_MAJOR, "spi", &spid... |
functions | __exit spidev_exit(void)
{
spi_unregister_driver(&spidev_spi_driver);
class_destroy(spidev_class);
unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
} |
includes |
#include <linux/kernel.h> |
includes | #include <linux/module.h> |
includes | #include <linux/init.h> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.