Exemple #1
0
static int __init myhook_init(void)
{
	unsigned char value;
	value =0xff;
	
	rt_i2c_read(0x50, 0x00, &value, 1);
	prink("%d", value);
    return 0;//nf_register_hook(&nfho);
}
Exemple #2
0
static void globalmem_setup_cdev(struct globalmem_dev *dev, int index)
{
	int err, devno = MKDEV(globalmem_major, index);
	cdev_init(&dev->cdev, &globalmem_fops);
	dev->cdev.owner = THIS_MODULE;
	
	err = cdev_add(&dev->cdev, devno, 1);
	if (err)
		prink(KERN_NOTICE"ERROR %d adding globalmem %d", err, index);
}
Exemple #3
0
static int globalmem_ioctl(struct inode *inodep, struct file *filp, unsigned int cmd, unsigned long arg)
{
	struct globalmem_dev *dev = filp->private_data;
	switch (cmd) {
	case MEM_CLEAR:
		memset(dev->mem, 0, GLOBALMEM_SIZE);
		prink(KERN_INFO"globalmem is set to zero\n");
		break;
	default:
		return -EINVAL;
		break;

	}
	return 0;
}
Exemple #4
0
static ssize_t globalmem_write(struct file *filp, char __user *buf, size_t size, loff_t *ppos)
{
	unsigned long p = *ppos;
	unsigned int count = size;

	int ret = 0;
	struct globalmem_dev *dev = filp->private_data;

	if (p >= GLOBALMEM_SIZE)
		return 0;
	if (count > GLOBALMEM_SIZE)
		count = GLOBAL_SIZE - p;

	if (copy_from_user(buf, (void *)(dev->mem + p), count))
		ret = -EFAULT;
	else {
		*ppos += count;
		ret = count;
		prink(KERN_INFO"write %u bytes(s) to %lu\n", count, p);
	}
	return ret;
}