出现这些错误..多半是代码问题
rmmod时候出现Segmentation fault错误
rmmod: remove 'led': Device or resource busy
rmmod: chdir(/lib/modules): No such file or directory
/lib/modules #
/lib/modules #
/lib/modules # ls
3.5.0-FriendlyARM
/lib/modules #
/lib/modules #
rmmod: remove 'led': Device or resource busy
rmmod: remove 'led': Device or resource busy
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <linux/device.h>
static struct class *firstdrv_class;
static struct class_device *firstdrv_class_dev;
static int first_drv_open(struct inode *inode, struct file *file)
{
printk("first_drv_open\n");
return 0;
}
static ssize_t first_drv_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos)
{
printk("first_drv_write\n");
return 0;
}
static struct file_operations first_drv_fops = {
.owner = THIS_MODULE, /* 杩欐槸涓€涓畯锛屾帹鍚戠紪璇戞ā鍧楁椂鑷姩鍒涘缓鐨刜_this_module鍙橀噺 */
.open = first_drv_open,
.write = first_drv_write,
};
int major;
static int first_drv_init(void)
{
major = register_chrdev(0, "hello", &first_drv_fops); // 娉ㄥ唽, 鍛婅瘔鍐呮牳
firstdrv_class = class_create(THIS_MODULE, "hello");
firstdrv_class_dev = device_create(firstdrv_class, NULL, MKDEV(major, 0), NULL, "hello"); /* /dev/xyz */
printk("first_drv_init\n");
return 0;
}
static void first_drv_exit(void)
{
printk("first_drv_exit\n");
unregister_chrdev(major, "hello"); // 鍗歌浇
printk("unregister_chrdev\n");
/* class_unregister(firstdrv_class_dev);
// class_destroy(firstdrv_class);
printk("class_unregister\n");
device_destroy(firstdrv_class, major);
printk("device_destroy\n");
class_destroy(firstdrv_class); */
printk("class_destroy\n");
}
module_init(first_drv_init);
module_exit(first_drv_exit);
MODULE_LICENSE("GPL");
模块卸载的地方注释就可以 ,不知道为啥
rmmod时候出现Segmentation fault错误
rmmod: remove 'led': Device or resource busy
rmmod: chdir(/lib/modules): No such file or directory
/lib/modules #
/lib/modules #
/lib/modules # ls
3.5.0-FriendlyARM
/lib/modules #
/lib/modules #
rmmod: remove 'led': Device or resource busy
rmmod: remove 'led': Device or resource busy
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <linux/device.h>
static struct class *firstdrv_class;
static struct class_device *firstdrv_class_dev;
static int first_drv_open(struct inode *inode, struct file *file)
{
printk("first_drv_open\n");
return 0;
}
static ssize_t first_drv_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos)
{
printk("first_drv_write\n");
return 0;
}
static struct file_operations first_drv_fops = {
.owner = THIS_MODULE, /* 杩欐槸涓€涓畯锛屾帹鍚戠紪璇戞ā鍧楁椂鑷姩鍒涘缓鐨刜_this_module鍙橀噺 */
.open = first_drv_open,
.write = first_drv_write,
};
int major;
static int first_drv_init(void)
{
major = register_chrdev(0, "hello", &first_drv_fops); // 娉ㄥ唽, 鍛婅瘔鍐呮牳
firstdrv_class = class_create(THIS_MODULE, "hello");
firstdrv_class_dev = device_create(firstdrv_class, NULL, MKDEV(major, 0), NULL, "hello"); /* /dev/xyz */
printk("first_drv_init\n");
return 0;
}
static void first_drv_exit(void)
{
printk("first_drv_exit\n");
unregister_chrdev(major, "hello"); // 鍗歌浇
printk("unregister_chrdev\n");
/* class_unregister(firstdrv_class_dev);
// class_destroy(firstdrv_class);
printk("class_unregister\n");
device_destroy(firstdrv_class, major);
printk("device_destroy\n");
class_destroy(firstdrv_class); */
printk("class_destroy\n");
}
module_init(first_drv_init);
module_exit(first_drv_exit);
MODULE_LICENSE("GPL");
模块卸载的地方注释就可以 ,不知道为啥