我的编译环境没有问题,可以正常编译出内核镜像zImage,dtb ,但是在编译自己的驱动时提缺了什么东西,网上搜索是缺了头文件但是我对比了下没有缺少#include <linux/module.h>这个头文件

#ifndef FILENAME

#define FILENAME

#include <linux/module.h>

#include <linux/fs.h>

#include <linux/errno.h>

#include <linux/miscdevice.h>

#include <linux/kernel.h>

#include <linux/major.h>

#include <linux/mutex.h>

#include <linux/proc_fs.h>

#include <linux/seq_file.h>

#include <linux/stat.h>

#include <linux/init.h>

#include <linux/device.h>

#include <linux/tty.h>

#include <linux/kmod.h>

#include <linux/gfp.h>

#define MIN(x,y) ( x > y ? x : y )

#endif

char kernel_buf[1024]={’\0’};
static struct class *hello_class=NULL;
static int major=0;

static int hello_drv_open(struct inode *node, struct file *file )
{
printk("%s %s line %d\n",FILE,FUNCTION,LINE);
return 0;
}

static ssize_t hello_drv_read(struct file *file, char __user *buf, size_t size, loff_t * offset)
{

int ret=0;
printk("%s  %s line   %d\n",__FILE__,__FUNCTION__,__LINE__);
ret=copy_to_user(buf,kernel_buf,MIN(1024,size));
return MIN(1024,size);

}

static ssize_t hello_drv_write(struct file *file, const char __user *buf, size_t size, loff_t * offset)

{

int ret=0;
printk("%s  %s line   %d\n",__FILE__,__FUNCTION__,__LINE__);
ret=copy_from_user(kernel_buf,buf,MIN(1024,size));

return MIN(1024,size);
}

static int hello_drv_close (struct inode *node, struct file *file)
{
printk("%s %s line %d\n",FILE,FUNCTION,LINE);
return 0;
}

struct file_operations hello_test=
{
.owner=THIS_MODULE,
.open=hello_drv_open,
.read=hello_drv_read,
.write=hello_drv_write,
.release=hello_drv_close,
};

static int __init hello_init(void)
{
int err=0;
//int register_chrdev(unsigned int major,const charname,structfile_operationsfops);函数原型
major=register_chrdev(major,“hello”,&hello_test);
//struct class *class_create(struct module *owner, const char *name)
hello_class=class_create(THIS_MODULE,“hello_class_name”);
err = PTR_ERR(hello_class);
if (IS_ERR(hello_class))
{
unregister_chrdev(major,“hello”);
return -1;
}
//device_create(struct class *cls, struct device *parent, dev_t devt, void *drvdata, const char *fmt, …);
device_create(hello_class,NULL,MKDEV(major,0),NULL,“hello”);
return 0;
}

static void __exit hello_exit(void)
{
//void device_destroy(struct class *cls, dev_t devt);
device_destroy(hello_class,MKDEV(major,0));
//void class_destroy(struct class *cls)
class_destroy(hello_class);
//unregister_chrdev(unsigned int major, const char *name)
unregister_chrdev(major,“hello”);
return;
}

module_init(hello_init);
module_exit(hello_exit);
MODLUE_LICENSE(“GPL”);

编译提示信息:
wu@ubuntu:~/VsCode/Linux-4.9.88$ make ARCH=arm CROSS_COMPILE=arm-buildroot-linux-gnueabihf- modules
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC [M] drivers/hello_driver.o
drivers/hello_driver.c:99:16: error: expected declaration specifiers or ‘…’ before string constant
MODLUE_LICENSE(“GPL”)
^~~~~
scripts/Makefile.build:299: recipe for target ‘drivers/hello_driver.o’ failed
make[1]: *** [drivers/hello_driver.o] Error 1
Makefile:997: recipe for target ‘drivers’ failed