当前位置: 技术问答>linux和unix
静态编译出现的问题
来源: 互联网 发布时间:2016-03-16
本文导语: 前两天编了一个LED的驱动,动态加载到内核里面了,并且测试顺利,呵呵,但是我想静态加到内核里面,编译成的内核加到板子里面,但在/proc/devices 和 /dev目录下都没有出现leds,试了好多次不知道怎么回事,望大...
前两天编了一个LED的驱动,动态加载到内核里面了,并且测试顺利,呵呵,但是我想静态加到内核里面,编译成的内核加到板子里面,但在/proc/devices 和 /dev目录下都没有出现leds,试了好多次不知道怎么回事,望大侠们帮我看看!
驱动原程序:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define DEVICE_NAME "leds"
#define LED_MAJOR 231
static unsigned long led_table [] = {
GPIO_B0,
GPIO_B1,
GPIO_B6,
GPIO_B5,
GPIO_B7,
GPIO_B8,
GPIO_B9,
GPIO_B10,
};
static int leds_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
switch(cmd) {
case 0:
case 1:
if (arg > 8) {
return -EINVAL;
}
write_gpio_bit(led_table[arg], !cmd);
default:
return -EINVAL;
}
}
static struct file_operations leds_fops = {
owner: THIS_MODULE,
ioctl: leds_ioctl,
};
static devfs_handle_t devfs_handle;
static int __init leds_init(void)
{
int ret;
int i;
ret = register_chrdev(LED_MAJOR, DEVICE_NAME, &leds_fops);
if (ret
驱动原程序:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define DEVICE_NAME "leds"
#define LED_MAJOR 231
static unsigned long led_table [] = {
GPIO_B0,
GPIO_B1,
GPIO_B6,
GPIO_B5,
GPIO_B7,
GPIO_B8,
GPIO_B9,
GPIO_B10,
};
static int leds_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
switch(cmd) {
case 0:
case 1:
if (arg > 8) {
return -EINVAL;
}
write_gpio_bit(led_table[arg], !cmd);
default:
return -EINVAL;
}
}
static struct file_operations leds_fops = {
owner: THIS_MODULE,
ioctl: leds_ioctl,
};
static devfs_handle_t devfs_handle;
static int __init leds_init(void)
{
int ret;
int i;
ret = register_chrdev(LED_MAJOR, DEVICE_NAME, &leds_fops);
if (ret