免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3175 | 回复: 1
打印 上一主题 下一主题

ca/proc/devices中没有insmod了驱动的设备号 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-03-31 22:52 |只看该作者 |倒序浏览
/*
shizhihua 2010.03.23.2130
s3c2410的Io口点亮LED指示灯
*/



#define _KERNEL_
#define MODULE
#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/fcntl.h>
#include <linux/miscdevice.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/config.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/device.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/io.h>
#include <linux/cdev.h>
#include <asm/irq.h>
#include <asm/arch/regs-gpio.h>

struct cdev io_dev;

static int s3c2410_F_major=200;

////{
         
//        int i;
//};

//struct s3c2410io_dev *s3c2410_F_dev;
static unsigned long led_table [] = {
        S3C2410_GPF4,
        S3C2410_GPF5,
        S3C2410_GPF6,
        S3C2410_GPF7,
};





int s3c2410_F_open(struct inode *inode, struct file *filp)
{
          return 0;
}

static ssize_t s3c2410_F_read(struct file *filp, char __user *buf, size_t size,loff_t *ppos)
{
        return 0;
}
static ssize_t s3c2410_F_write(struct file *filp, const char __user *buf,size_t size, loff_t *ppos)
{
        return 0;
}
static loff_t s3c2410_F_llseek(struct file *filp, loff_t offset, int orig)
{
        return 0;
}

int s3c2410_F_release(struct inode *inode, struct file *filp)
{
  return 0;
}

static int s3c2410_F_ioctl(struct inode *inodep, struct file *filp, unsigned int cmd, unsigned long arg)
{
        switch (cmd)
        {
        case 0:
        case 1:
                s3c2410_gpio_setpin(led_table[arg], !cmd);
                break;
        default:
                      return -EINVAL;
              }
}
/*文件操作结构体*/
static const struct file_operations s3c2410_F_fops =
{
//  .owner = THIS_MODULE,
  .llseek = s3c2410_F_llseek,
  .read = s3c2410_F_read,
  .write = s3c2410_F_write,
  .ioctl = s3c2410_F_ioctl,
  .open = s3c2410_F_open,
  .release = s3c2410_F_release,
};

static int __init s3c2410_init(void)
{
        int result;
        dev_t devno = MKDEV(s3c2410_F_major, 0);
       
        cdev_init(&io_dev,&s3c2410_F_fops);
//        io_cdev.owner = THIS_MODULE;
        if(s3c2410_F_major)
                result = register_chrdev_region(devno, 1, "s3c2410_io");
        else
        {
                result = alloc_chrdev_region(&devno, 0, 1, "s3c2410_io");
                    s3c2410_F_major = MAJOR(devno);
        }
        if (result < 0)
                    return result;
         
}


static void __exit s3c2410_exit(void)
{
        cdev_del(&io_dev);
        unregister_chrdev_region(MKDEV(s3c2410_F_major, 0), 1);
}
module_init(s3c2410_init);
module_exit(s3c2410_exit);

MODULE_AUTHOR("lili                bit.lili@gmail.com");
MODULE_LICENSE("GPL");

加载 insmod s3c2410_io.ko
lsmod
也显示s3c2410_io
但是在 ca/proc/devices中没有s3c2410_io驱动的设备号
是怎么回事啊

虽然程序中
static int s3c2410_F_major=200;
是知道主设备好
可以 mknod /dev/s3c2410_io c 200 0
但是在为什么就是ca/proc/devices不出现
不懂

论坛徽章:
0
2 [报告]
发表于 2010-04-01 23:24 |只看该作者
是不是register失败了啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP