使用内核版本-linux-3.2




错误1:


  1. make -C /lib/modules/3.2.0/build M=/home/wrk/works/drivers/ldd3/examples/scullc LDDINC=/home/wrk/works/drivers/ldd3/examples/scullc modules
  2. make[1]: Entering directory `/home/wrk/works/drivers/linux-kernel/linux-3.2'
  3. scripts/Makefile.build:49: *** CFLAGS was changed in "/home/wrk/works/drivers/ldd3/examples/scullc/Makefile". Fix it to use ccflags-y. Stop.
  4. make[1]: *** [_module_/home/wrk/works/drivers/ldd3/examples/scullc] Error 2
  5. make[1]: Leaving directory `/home/wrk/works/drivers/linux-kernel/linux-3.2'
  6. make: *** [modules] Error 2
这个错误还比较好解决,像提示的那样在Makefile中用ccflags-y替换CFLAGS 



错误2:


  1. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:52:1: error: unknown type name ‘kmem_cache_t’

这 是因为kmem_cache_t结构被换成了kmem_cache。而kmem_cache定义在<linux/slab_def.h> 和<linux/slub_def.h>。但是你并不需要包含这两个文件中的一个。因为<linux/slab.h>会根据 CONFIG_SLUB等来判断具体包含<linux/slab_def.h>,还是<linux/slub_def.h>。故 例程中需要将


kmem_cache_t *scullc_cache;
改为:
struct kmem_cache *scullc_cache;




错误3:


  1. /home/wrk/works/drivers/ldd3/examples/scullc/main.c: In function ‘scullc_defer_op’:
  2. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:437:54: error: macro "INIT_WORK" passed 3 arguments, but takes just 2
  3. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:437:2: error: ‘INIT_WORK’ undeclared (first use in this function)
这里需要将
  1. INIT_WORK(&stuff->work, scull_do_deferred_op, stuff);
改为:
  1. INIT_WORK(&stuff->work, scull_do_deferred_op);
并且将scullc_do_deferred_op函数改为
  1. static void scullc_do_deferred_op(struct work_struct *p)
  2. {
  3.         struct async_work *stuff = container_of(p, struct async_work, work);
  4.         aio_complete(stuff->iocb, stuff->result, 0);
  5.         kfree(stuff);
  6. }


错误4:
 
  1. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:467:2: error: unknown field ‘ioctl’ specified in initializer
这里因为内核接口变化需要将.ioctl改为 .unlocked_ioctl

错误5:


  1. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:558:4: error: too many arguments to function ‘kmem_cache_create’
函数kmem_cache_create的原型已经改变:
struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, unsigned long, void (*)(void *));故调用它的时候应该将参数做出相应的改变。需要将最后一个NULL去掉。
下面来解决warning:
  1. /home/wrk/works/drivers/ldd3/examples/scullc/main.c: In function ‘scullc_defer_op’:
  2. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:437:2: warning: assignment from incompatible pointer type [enabled by default]
  3. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:438:2: warning: passing argument 1 of ‘schedule_delayed_work’ from incompatible pointer type [enabled by default]
  4. include/linux/workqueue.h:363:12: note: expected ‘struct delayed_work *’ but argument is of type ‘struct work_struct *’
  5. /home/wrk/works/drivers/ldd3/examples/scullc/main.c: At top level:
  6. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:467:2: warning: initialization from incompatible pointer type [enabled by default]
  7. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:467:2: warning: (near initialization for ‘scullc_fops.unlocked_ioctl’) [enabled by default]
  8. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:470:2: warning: initialization from incompatible pointer type [enabled by default]
  9. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:470:2: warning: (near initialization for ‘scullc_fops.aio_read’) [enabled by default]
  10. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:471:2: warning: initialization from incompatible pointer type [enabled by default]
  11. /home/wrk/works/drivers/ldd3/examples/scullc/main.c:471:2: warning: (near initialization for ‘scullc_fops.aio_write’) [enabled by default]
1.把
  1. struct async_work {
  2. struct kiocb *iocb;
  3. int result;
  4. struct work_struct work;
  5. };
改为:
  1. struct async_work {
  2. struct kiocb *iocb;
  3. int result;
  4. struct delayed_work delayed_work;
  5. }
然后把:
  1. INIT_WORK(&stuff->work, scull_do_deferred_op, stuff);
  2. schedule_delayed_work(&stuff->work, HZ/100);
改为:
  1. INIT_DELAYED_WORK(&(stuff->delayed_work), scullc_do_deferred_op);
  2. schedule_delayed_work(&(stuff->delayed_work), HZ/100);
再编译即可通过。


http://blog.chinaunix.net/uid-25381054-id-3261527.html
創作者介紹
創作者 立你斯 的頭像
立你斯

立你斯學習記錄

立你斯 發表在 痞客邦 留言(0) 人氣()