linux驱动学习笔记(2.3) scull模块 init_MUTEX被废除

一、今天在编译ldd3上的scullc的时候,出现如下错误:

clip_image006

刚开始我以为没有包含头文件,然后我就去查2.6.39.1的源代码,结果在所有的符号中都没有发现init_MUTEX,后面在网站上发现了init_MUTEX的定义,如下所示:

clip_image007

源码衔接:

http://lxr.oss.org.cn/source/include/asm-i386/semaphore.h#L89

上面的源码是2.6.16以前的,在2.6.25以后就再也找不到这个宏了,原因我目前不清楚,根据定义就已经可以把问题解决了,将代码改成下面的就行了:

clip_image008

二.排出此问题,出现例外一个问题

image

原因:在2.6.32 linux/fs/ntfs/ChangeLog 看到如下片段

  672.1.26 - Minor bug fixes and updates.
  68
  69        - Fix a potential overflow in file.c where a cast to s64 was missing in
  70          a left shift of a page index.
  71        - The struct inode has had its i_sem semaphore changed to a mutex named
  72          i_mutex.
 
  75        - Implement support for sector sizes above 512 bytes (up to the maximum
  76          supported by NTFS which is 4096 bytes).
  77        - Do more detailed reporting of why we cannot mount read-write by
  78          special casing the VOLUME_MODIFIED_BY_CHKDSK flag.

解决 修改main.c中的 52 53 54行

/* declare one cache pointer: use it for all devices */
//kmem_cache_t *scullc_cache;
struct kmem_cache *scullc_cache;

三,问题又来了

home/allen/share/ldd3/src/scull/pipe.c:131:7: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/allen/share/ldd3/src/scull/pipe.c:131:7: note: each undeclared identifier is reported only once for each function it appears in
/home/allen/share/ldd3/src/scull/pipe.c:131:3: error: implicit declaration of function ‘signal_pending’
/home/allen/share/ldd3/src/scull/pipe.c:131:3: error: implicit declaration of function ‘schedule’
/home/allen/share/ldd3/src/scull/pipe.c: In function ‘scull_getwritespace’:
/home/allen/share/ldd3/src/scull/pipe.c:168:38: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/allen/share/ldd3/src/scull/pipe.c: In function ‘scull_p_write’:
/home/allen/share/ldd3/src/scull/pipe.c:219:2: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/allen/share/ldd3/src/scull/pipe.c:223:34: error: ‘SIGIO’ undeclared (first use in this function)
/home/allen/share/ldd3/src/scull/pipe.c:223:41: error: ‘POLL_IN’ undeclared (first use in this function)
/home/allen/share/ldd3/src/scull/pipe.c: At top level:
/home/allen/share/ldd3/src/scull/pipe.c:319:2: error: unknown field ‘ioctl’ specified in initializer
/home/allen/share/ldd3/src/scull/pipe.c:319:2: warning: initialization from incompatible pointer type
/home/allen/share/ldd3/src/scull/pipe.c: In function ‘scull_p_init’:
/home/allen/share/ldd3/src/scull/pipe.c:365:3: error: implicit declaration of function ‘init_MUTEX’
make[2]: *** [/home/allen/share/ldd3/src/scull/pipe.o] Error 1
make[1]: *** [_module_/home/allen/share/ldd3/src/scull] Error 2

TASK_INTERRUPTIBLE找不到,既然前面删除掉了了一个头文件,必然有很多变量找不到,
那就到/usr/src/linux-headers-2.6.32-22-generic下grep一下呗:
最终找到头文件,添加上:
#include <linux/sched.h>
access.c也需要添加上面的头文件。

 

unknown field ‘ioctl’ specified in initializer

是因为ioctl接口更换的问题。

使用.unlocked_ioctl =    scull_ioctl,

 

error: implicit declaration of function ‘init_MUTEX’

此问题前面也曾提到

 

四.做如下替换

//int scull_ioctl(struct inode *inode, struct file *filp,
//                unsigned int cmd, unsigned long arg)

long scull_ioctl( struct file *filp,
                 unsigned int cmd, unsigned long arg)

五。到此编译成功

root@ubuntu:/home/allen/share/ldd3/src/scull# make
make -C /usr/src/linux-headers-2.6.38-8-generic/ M=/home/allen/share/ldd3/src/scull LDDINC=/home/allen/share/ldd3/src/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.38-8-generic'
  CC [M]  /home/allen/share/ldd3/src/scull/main.o
  CC [M]  /home/allen/share/ldd3/src/scull/pipe.o
  CC [M]  /home/allen/share/ldd3/src/scull/access.o
  LD [M]  /home/allen/share/ldd3/src/scull/scull.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/allen/share/ldd3/src/scull/scull.mod.o
  LD [M]  /home/allen/share/ldd3/src/scull/scull.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.38-8-generic'

 

参考文章:http://www.cnblogs.com/justinzhang/archive/2011/07/18/2109617.html

http://hi.baidu.com/%B3%C1%BC%C5%B5%C4%B9%C2%B3%C7/blog/item/570c3c52760aa62843a75b2a.html/cmtid/2fcadaf301a692cc7831aa4d

转载于:https://www.cnblogs.com/fly-fish/archive/2011/08/24/2152434.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目标检测(Object Detection)是计算机视觉领域的一个核心问题,其主要任务是找出图像中所有感兴趣的目标(物体),并确定它们的类别和位置。以下是对目标检测的详细阐述: 一、基本概念 目标检测的任务是解决“在哪里?是什么?”的问题,即定位出图像中目标的位置并识别出目标的类别。由于各类物体具有不同的外观、形状和姿态,加上成像时光照、遮挡等因素的干扰,目标检测一直是计算机视觉领域最具挑战性的任务之一。 二、核心问题 目标检测涉及以下几个核心问题: 分类问题:判断图像中的目标属于哪个类别。 定位问题:确定目标在图像中的具体位置。 大小问题:目标可能具有不同的大小。 形状问题:目标可能具有不同的形状。 三、算法分类 基于深度学习的目标检测算法主要分为两大类: Two-stage算法:先进行区域生成(Region Proposal),生成有可能包含待检物体的预选框(Region Proposal),再通过卷积神经网络进行样本分类。常见的Two-stage算法包括R-CNN、Fast R-CNN、Faster R-CNN等。 One-stage算法:不用生成区域提议,直接在网络中提取特征来预测物体分类和位置。常见的One-stage算法包括YOLO系列(YOLOv1、YOLOv2、YOLOv3、YOLOv4、YOLOv5等)、SSD和RetinaNet等。 四、算法原理 以YOLO系列为例,YOLO将目标检测视为回归问题,将输入图像一次性划分为多个区域,直接在输出层预测边界框和类别概率。YOLO采用卷积网络来提取特征,使用全连接层来得到预测值。其网络结构通常包含多个卷积层和全连接层,通过卷积层提取图像特征,通过全连接层输出预测结果。 五、应用领域 目标检测技术已经广泛应用于各个领域,为人们的生活带来了极大的便利。以下是一些主要的应用领域: 安全监控:在商场、银行
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值