rename module into modules

This commit is contained in:
Siegfried Kienzle
2017-06-07 08:24:13 +00:00
parent b1cad51075
commit 596bcfad22
10 changed files with 504 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/gpio.h>
#include <linux/kobject.h>
#include <linux/device.h>
#include <linux/uaccess.h>
#define DEVICE_NAME "infrared_sensor";
#define NUMBER_OF_MINOR_DEVICE (1);
#include "infrared_sensor.def.h"
static unsigned int infrared_sensor_in_1 = 2;
static unsigned int infrared_sensor_in_2 = 3;
static unsigned int infrared_sensor_in_3 = 4;
static unsigned int infrared_sensor_in_4 = 17;
static int infrared_sensor_open(struct inode devfile, struct file *instance)
{
int err;
err = gpio_request(infrared_sensor_in_1, "rpi-gpio-1");
if (err) {
printk("gpio_request failed %d\n", err);
return -1;
}
err = gpio_direction_output(infrared_sensor_in_1);
if (err) {
printk("gpio_direction_input failed %d\n", err);
gpio_free(infrared_sensor_in_1);
return -1;
}
printk("gpio 2 successfull configured\n");
}
static ssize_t infrared_sensor_read( struct file *instance, char __user *buffer,
size_t max_bytes_to_read, loff_t *offset)
{
}
static int infrared_sensor_close( struct inode devfile, struct file *instance)
{
}
static struct file_operations fops = {
.owner = THIS_MODULE,
.open = infrared_sensor_open,
.release = infrared_sensor_close,
.read = infrared_sensor_read,
};
#include "infrared_sensor.h";