平台总线开发(id和设备树匹配)

news2024/11/15 10:51:13

目录

一、ID匹配之框架代码

二、ID匹配之led驱动​​​​​​​

三、设备树匹配

四、设备树匹配之led驱动

五、一个编写驱动用的宏


一、ID匹配之框架代码

id匹配(可想象成八字匹配):一个驱动可以对应多个设备 ------优先级次低

注意事项:

1.  device模块中,id的name成员必须与struct platform_device中的name成员内容一致,因此device模块中,struct platform_device中的name成员必须指定

2.  driver模块中,struct platform_driver成员driver的name成员必须指定,但与device模块中name可以不相同


```c

/*platform device框架*/

#include <linux/module.h>

#include <linux/kernel.h>

#include <linux/init.h>

#include <linux/platform_device.h>



//定义资源数组



static void device_release(struct device *dev)

{

    printk("platform: device release\n");

}



struct platform_device_id test_id = {

    .name = "test_device",

};



struct platform_device test_device = {

    .name = "test_device",//必须初始化

    .dev.release = device_release,

    .id_entry = &test_id,

};



static int __init platform_device_init(void)

{

    platform_device_register(&test_device);

    return 0;

}



static void __exit platform_device_exit(void)

{

    platform_device_unregister(&test_device);

}



module_init(platform_device_init);

module_exit(platform_device_exit);

MODULE_LICENSE("Dual BSD/GPL");

```



```c

/*platform driver框架*/

#include <linux/module.h>

#include <linux/kernel.h>

#include <linux/init.h>

#include <linux/platform_device.h>



static int driver_probe(struct platform_device *dev)

{

    printk("platform: match ok!\n");

    return 0;

}



static int driver_remove(struct platform_device *dev)

{

    printk("platform: driver remove\n");

    return 0;

}



struct platform_device_id testdrv_ids[] =

{

    [0] = {.name = "test_device"},

    [1] = {.name = "abcxyz"},

    [2] = {}, //means ending

};



struct platform_driver test_driver = {

    .probe = driver_probe,

    .remove = driver_remove,

    .driver = {

        .name = "xxxxx", //必须初始化

    },

    .id_table = testdrv_ids,

};



static int __init platform_driver_init(void)

{

    platform_driver_register(&test_driver);

    return 0;

}



static void __exit platform_driver_exit(void)

{

    platform_driver_unregister(&test_driver);

}



module_init(platform_driver_init);

module_exit(platform_driver_exit);

MODULE_LICENSE("Dual BSD/GPL");



```

用到结构体数组,一般不指定大小,初始化时最后加{}表示数组结束

设备中增加资源,驱动中访问资源

 

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>

static void hello_device_release(struct device *dev)
{
	printk("platform:device release\n");
}

struct resource hello_dev_res [] =
{
	[0] = {.start = 0x1000, .end=0x1003, .name="reg1", .flags = IORESOURCE_MEM},
	[1] = {.start = 0x2000, .end=0x2003, .name="reg2", .flags = IORESOURCE_MEM},
	[2] = {.start = 10, .end=10, .name="irq1", .flags = IORESOURCE_IRQ},
	[3] = {.start = 0x3000, .end=0x3003, .name="reg3", .flags = IORESOURCE_MEM},
	[4] = {.start = 100, .end=100, .name="irq2", .flags = IORESOURCE_IRQ},
	[5] = {.start = 62, .end=62, .name="irq3", .flags = IORESOURCE_IRQ},
};

struct platform_device_id hello_id = {
	.name = "hello",
};


struct platform_device hello_device =
{
	.name = "hello",
	.dev.release = hello_device_release,
	.resource = hello_dev_res,
	.num_resources = ARRAY_SIZE(hello_dev_res),
	.id_entry = &hello_id,
};

int __init hello_device_init(void)
{
	platform_device_register(&hello_device);
	return 0;
}
void __exit hello_device_exit(void)
{
	platform_device_unregister(&hello_device);
}
MODULE_LICENSE("GPL");
module_init(hello_device_init);
module_exit(hello_device_exit);

 

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>

int hello_driver_probe(struct platform_device *p_pltdev)
{
	struct resource *pres = NULL;
	printk("hellio_driver_probe is called\n");
	
	pres = platform_get_resource(p_pltdev,IORESOURCE_MEM,2);
	printk("res.start = 0x%x\n",(unsigned int)pres->start);
	
	pres = platform_get_resource(p_pltdev,IORESOURCE_IRQ,1);
	printk("res.start = %d\n",(int)pres->start);
	return 0;
}

int hello_driver_remove(struct platform_device *p_pltdev)
{
	printk("hellio_driver_remove is called\n");
	return 0;
}

struct platform_device_id hellodrv_ids[] = 
{
	[0] = {.name = "hello"},
	[1] = {.name = "xyz"},
	[2] = {}
};

struct platform_driver hello_driver =
{
	.driver.name = "abc",
	.probe = hello_driver_probe,
	.remove = hello_driver_remove,

	.id_table = hellodrv_ids,
};

int __init hello_driver_init(void)
{
	platform_driver_register(&hello_driver);
	return 0;
}
void __exit hello_driver_exit(void)
{
	platform_driver_unregister(&hello_driver);
}
MODULE_LICENSE("GPL");
module_init(hello_driver_init);
module_exit(hello_driver_exit);

二、ID匹配之led驱动


#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>

#define GPX1CON 0x11000C20
#define GPX1DAT 0x11000C24

#define GPX2CON 0x11000C40
#define GPX2DAT 0x11000C44

#define GPF3CON 0x114001E0
#define GPF3DAT 0x114001E4
void fs4412leds_dev_release(struct device *pdev)
{
	printk("fs4412leds_dev_release is called\n");
}

struct resource fs4412leds_dev_res [] =
{
	[0] = {.start = GPX1CON,.end=GPX1CON + 3,.name="GPX1CON",.flags = IORESOURCE_MEM},
	[1] = {.start = GPX1DAT,.end=GPX1DAT + 3,.name="GPX1DAT",.flags = IORESOURCE_MEM},

	[2] = {.start = GPX2CON,.end=GPX2CON + 3,.name="GPX2CON",.flags = IORESOURCE_MEM},
	[3] = {.start = GPX2DAT,.end=GPX2DAT + 3,.name="GPX2DAT",.flags = IORESOURCE_MEM},
	
	[4] = {.start = GPF3CON,.end=GPF3CON + 3,.name="GPF3CON",.flags = IORESOURCE_MEM},
	[5] = {.start = GPF3DAT,.end=GPF3DAT + 3,.name="GPF3DAT",.flags = IORESOURCE_MEM},
};

struct platform_device_id led_id = {
	.name = "fs4412leds",
};

struct platform_device fs4412leds_device = 
{
	.name = "fs4412leds",
	.dev.release = fs4412leds_dev_release,
	.resource = fs4412leds_dev_res,
	.num_resources = ARRAY_SIZE(fs4412leds_dev_res),
	.id_entry = &led_id,
};

int __init fs4412leds_device_init(void)
{
	platform_device_register(&fs4412leds_device);
	return 0;
}

void __exit fs4412leds_device_exit(void)
{
	platform_device_unregister(&fs4412leds_device);
}

MODULE_LICENSE("GPL");
module_init(fs4412leds_device_init);
module_exit(fs4412leds_device_exit);
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/io.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>

#include "leddrv.h"



int major = 11;
int minor = 0;
int myled_num  = 1;

struct myled_dev
{
	struct cdev mydev;

	volatile unsigned long *pled2_con;
	volatile unsigned long *pled2_dat;
	
	volatile unsigned long *pled3_con;
	volatile unsigned long *pled3_dat;

	volatile unsigned long *pled4_con;
	volatile unsigned long *pled4_dat;

	volatile unsigned long *pled5_con;
	volatile unsigned long *pled5_dat;
};

struct myled_dev *pgmydev = NULL;


int myled_open(struct inode *pnode,struct file *pfile)
{
	pfile->private_data =(void *) (container_of(pnode->i_cdev,struct myled_dev,mydev));
	
	return 0;
}

int myled_close(struct inode *pnode,struct file *pfile)
{
	return 0;
}

void led_on(struct myled_dev *pmydev,int ledno)
{
	switch(ledno)
	{
		case 2:
			writel(readl(pmydev->pled2_dat) | (0x1 << 7),pmydev->pled2_dat);
			break;
		case 3:
			writel(readl(pmydev->pled3_dat) | (0x1),pmydev->pled3_dat);
			break;
		case 4:
			writel(readl(pmydev->pled4_dat) | (0x1 << 4),pmydev->pled4_dat);
			break;
		case 5:
			writel(readl(pmydev->pled5_dat) | (0x1 << 5),pmydev->pled5_dat);
			break;
	}
}

void led_off(struct myled_dev *pmydev,int ledno)
{
	switch(ledno)
	{
		case 2:
			writel(readl(pmydev->pled2_dat) & (~(0x1 << 7)),pmydev->pled2_dat);
			break;
		case 3:
			writel(readl(pmydev->pled3_dat) & (~(0x1)),pmydev->pled3_dat);
			break;
		case 4:
			writel(readl(pmydev->pled4_dat) & (~(0x1 << 4)),pmydev->pled4_dat);
			break;
		case 5:
			writel(readl(pmydev->pled5_dat) & (~(0x1 << 5)),pmydev->pled5_dat);
			break;
	}
}


long myled_ioctl(struct file *pfile,unsigned int cmd,unsigned long arg)
{
	struct myled_dev *pmydev = (struct myled_dev *)pfile->private_data;

	if(arg < 2 || arg > 5)
	{
		return -1;
	}
	switch(cmd)
	{
		case MY_LED_ON:
			led_on(pmydev,arg);
			break;
		case MY_LED_OFF:
			led_off(pmydev,arg);
			break;
		default:
			return -1;
	}

	return 0;
}

struct file_operations myops = {
	.owner = THIS_MODULE,
	.open = myled_open,
	.release = myled_close,
	.unlocked_ioctl = myled_ioctl,
};

void ioremap_ledreg(struct myled_dev *pmydev,struct platform_device *p_pltdev)
{
	struct resource *pres = NULL;


	pres = platform_get_resource(p_pltdev,IORESOURCE_MEM,2);
	pmydev->pled2_con = ioremap(pres->start,4);

	pres = platform_get_resource(p_pltdev,IORESOURCE_MEM,3);
	pmydev->pled2_dat = ioremap(pres->start,4);


	pres = platform_get_resource(p_pltdev,IORESOURCE_MEM,0);
	pmydev->pled3_con = ioremap(pres->start,4);

	pres = platform_get_resource(p_pltdev,IORESOURCE_MEM,1);
	pmydev->pled3_dat = ioremap(pres->start,4);
	

	pres = platform_get_resource(p_pltdev,IORESOURCE_MEM,4);
	pmydev->pled4_con = ioremap(pres->start,4);

	pres = platform_get_resource(p_pltdev,IORESOURCE_MEM,5);
	pmydev->pled4_dat = ioremap(pres->start,4);
	
	pmydev->pled5_con = pmydev->pled4_con;
	pmydev->pled5_dat = pmydev->pled4_dat;
}

void set_output_ledconreg(struct myled_dev *pmydev)
{
	writel((readl(pmydev->pled2_con) & (~(0xF << 28))) | (0x1 << 28),pmydev->pled2_con);
	writel((readl(pmydev->pled3_con) & (~(0xF))) | (0x1),pmydev->pled3_con);
	writel((readl(pmydev->pled4_con) & (~(0xF << 16))) | (0x1 << 16),pmydev->pled4_con);
	writel((readl(pmydev->pled5_con) & (~(0xF << 20))) | (0x1 << 20),pmydev->pled5_con);

	writel(readl(pmydev->pled2_dat) & (~(0x1 << 7)),pmydev->pled2_dat);
	writel(readl(pmydev->pled3_dat) & (~(0x1)),pmydev->pled3_dat);
	writel(readl(pmydev->pled4_dat) & (~(0x1 << 4)),pmydev->pled4_dat);
	writel(readl(pmydev->pled5_dat) & (~(0x1 << 5)),pmydev->pled5_dat);
}

void iounmap_ledreg(struct myled_dev *pmydev)
{
	iounmap(pmydev->pled2_con);
	pmydev->pled2_con = NULL;
	iounmap(pmydev->pled2_dat);
	pmydev->pled2_dat = NULL;

	iounmap(pmydev->pled3_con);
	pmydev->pled3_con = NULL;
	iounmap(pmydev->pled3_dat);
	pmydev->pled3_dat = NULL;
	
	iounmap(pmydev->pled4_con);
	pmydev->pled4_con = NULL;
	iounmap(pmydev->pled4_dat);
	pmydev->pled4_dat = NULL;
	
	pmydev->pled5_con = NULL;
	pmydev->pled5_dat = NULL;
}

int fs4412leds_driver_probe(struct platform_device *p_pltdev)
{
	int ret = 0;
	dev_t devno = MKDEV(major,minor);

	/*申请设备号*/
	ret = register_chrdev_region(devno,myled_num,"myled");
	if(ret)
	{
		ret = alloc_chrdev_region(&devno,minor,myled_num,"myled");
		if(ret)
		{
			printk("get devno failed\n");
			return -1;
		}
		major = MAJOR(devno);//容易遗漏,注意
	}

	pgmydev = (struct myled_dev *)kmalloc(sizeof(struct myled_dev),GFP_KERNEL);
	if(NULL == pgmydev)
	{
		unregister_chrdev_region(devno,myled_num);
		printk("kmalloc failed\n");
		return -1;
	}
	memset(pgmydev,0,sizeof(struct myled_dev));

	/*给struct cdev对象指定操作函数集*/	
	cdev_init(&pgmydev->mydev,&myops);

	/*将struct cdev对象添加到内核对应的数据结构里*/
	pgmydev->mydev.owner = THIS_MODULE;
	cdev_add(&pgmydev->mydev,devno,myled_num);

	/*ioremap*/
	ioremap_ledreg(pgmydev,p_pltdev);

	/*con-register set output*/
	set_output_ledconreg(pgmydev);

	return 0;
}

int fs4412leds_driver_remove(struct platform_device *p_pltdev)
{
	dev_t devno = MKDEV(major,minor);

	/*iounmap*/
	iounmap_ledreg(pgmydev);

	cdev_del(&pgmydev->mydev);

	unregister_chrdev_region(devno,myled_num);

	kfree(pgmydev);
	pgmydev = NULL;

	return 0;
}

struct platform_device_id leddrv_ids[] =
{
	[0] = {.name = "fs4412leds"},
	[1] = {.name = "xyz"},
	[2] = {}
};

struct platform_driver fs4412leds_driver = 
{
	.driver.name = "leds",
	.probe = fs4412leds_driver_probe,
	.remove = fs4412leds_driver_remove,
	.id_table = leddrv_ids,
};

int __init fs4412leds_driver_init(void)
{
	platform_driver_register(&fs4412leds_driver);
	return 0;
}

void __exit fs4412leds_driver_exit(void)
{
	platform_driver_unregister(&fs4412leds_driver);
}

MODULE_LICENSE("GPL");

module_init(fs4412leds_driver_init);
module_exit(fs4412leds_driver_exit);
#ifndef LED_DRIVER_H
#define LED_DRIVER_H

#define LED_DEV_MAGIC 'g'

#define MY_LED_OFF _IO(LED_DEV_MAGIC,0)
#define MY_LED_ON _IO(LED_DEV_MAGIC,1)



#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>

#include <stdio.h>

#include "leddrv.h"

int main(int argc,char *argv[])
{
	int fd = -1;
	int onoff = 0;
	int no = 0;

	if(argc < 4)
	{
		printf("The argument is too few\n");
		return 1;
	}

	sscanf(argv[2],"%d",&onoff);
	sscanf(argv[3],"%d",&no);

	if(no < 2 || no > 5)
	{
		printf("len-no is invalid\n");
		return 2;
	}

	fd = open(argv[1],O_RDONLY);
	if(fd < 0)
	{
		printf("open %s failed\n",argv[1]);
		return 3;
	}

	if(onoff)
	{
		ioctl(fd,MY_LED_ON,no);
	}
	else
	{
		ioctl(fd,MY_LED_OFF,no);
	}

	close(fd);
	fd = -1;
	return 0;
}


三、设备树匹配

设备树匹配:内核启动时根据设备树自动产生的设备 ------ 优先级最高

注意事项:

1. 无需编写device模块,只需编写driver模块

2. 使用compatible属性进行匹配,注意设备树中compatible属性值不要包含空白字符

3. id_table可不设置,但struct platform_driver成员driver的name成员必须设置

```c
/*platform driver框架*/
#include <linux/module.h> 
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>

static int driver_probe(struct platform_device *dev)
{
	printk("platform: match ok!\n");
	return 0;
}

static int driver_remove(struct platform_device *dev)
{
	printk("platform: driver remove\n");
	return 0;
}

struct platform_device_id testdrv_ids[] = 
{
	[0] = {.name = "test_device"},
    [1] = {.name = "abcxyz"},
    [2] = {}, //means ending
};

struct of_device_id test_of_ids[] = 
{
	[0] = {.compatible = "xyz,abc"},
    [1] = {.compatible = "qwe,opq"},
    [2] = {},
};

struct platform_driver test_driver = {
	.probe = driver_probe,
	.remove = driver_remove,
	.driver = {
		.name = "xxxxx", //必须初始化
        .of_match_table = test_of_ids,
	},
};

static int __init platform_driver_init(void)
{
	platform_driver_register(&test_driver);
	return 0;
}

static void __exit platform_driver_exit(void)
{
	platform_driver_unregister(&test_driver);
}

module_init(platform_driver_init);
module_exit(platform_driver_exit);
MODULE_LICENSE("Dual BSD/GPL");
```

四、设备树匹配之led驱动

 

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/fs.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/cdev.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/io.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>

#include "leddrv.h"

int major = 11;
int minor = 0;
int myled_num  = 1;

struct myled_dev
{
	struct cdev mydev;

	unsigned int led2gpio;
	unsigned int led3gpio;
	unsigned int led4gpio;
	unsigned int led5gpio;
};

struct myled_dev *pgmydev = NULL;


int myled_open(struct inode *pnode,struct file *pfile)
{
	pfile->private_data =(void *) (container_of(pnode->i_cdev,struct myled_dev,mydev));
	
	return 0;
}

int myled_close(struct inode *pnode,struct file *pfile)
{
	return 0;
}

void led_on(struct myled_dev *pmydev,int ledno)
{
	switch(ledno)
	{
		case 2:
			gpio_set_value(pmydev->led2gpio,1);
			break;
		case 3:
			gpio_set_value(pmydev->led3gpio,1);
			break;
		case 4:
			gpio_set_value(pmydev->led4gpio,1);
			break;
		case 5:
			gpio_set_value(pmydev->led5gpio,1);
			break;
	}
}

void led_off(struct myled_dev *pmydev,int ledno)
{
	switch(ledno)
	{
		case 2:
			gpio_set_value(pmydev->led2gpio,0);
			break;
		case 3:
			gpio_set_value(pmydev->led3gpio,0);
			break;
		case 4:
			gpio_set_value(pmydev->led4gpio,0);
			break;
		case 5:
			gpio_set_value(pmydev->led5gpio,0);
			break;
	}
}


long myled_ioctl(struct file *pfile,unsigned int cmd,unsigned long arg)
{
	struct myled_dev *pmydev = (struct myled_dev *)pfile->private_data;

	if(arg < 2 || arg > 5)
	{
		return -1;
	}
	switch(cmd)
	{
		case MY_LED_ON:
			led_on(pmydev,arg);
			break;
		case MY_LED_OFF:
			led_off(pmydev,arg);
			break;
		default:
			return -1;
	}

	return 0;
}

struct file_operations myops = {
	.owner = THIS_MODULE,
	.open = myled_open,
	.release = myled_close,
	.unlocked_ioctl = myled_ioctl,
};

void request_leds_gpio(struct myled_dev *pmydev,struct device_node *pnode)
{
	pmydev->led2gpio = of_get_named_gpio(pnode,"led2-gpio",0);
	gpio_request(pmydev->led2gpio,"led2");
	
	pmydev->led3gpio = of_get_named_gpio(pnode,"led3-gpio",0);
	gpio_request(pmydev->led3gpio,"led3");
	
	pmydev->led4gpio = of_get_named_gpio(pnode,"led4-gpio",0);
	gpio_request(pmydev->led4gpio,"led4");
	
	pmydev->led5gpio = of_get_named_gpio(pnode,"led5-gpio",0);
	gpio_request(pmydev->led5gpio,"led5");
}

void set_leds_gpio_output(struct myled_dev *pmydev)
{
	gpio_direction_output(pmydev->led2gpio,0);
	gpio_direction_output(pmydev->led3gpio,0);
	gpio_direction_output(pmydev->led4gpio,0);
	gpio_direction_output(pmydev->led5gpio,0);
}

void free_leds_gpio(struct myled_dev *pmydev)
{
	gpio_free(pmydev->led2gpio);
	gpio_free(pmydev->led3gpio);
	gpio_free(pmydev->led4gpio);
	gpio_free(pmydev->led5gpio);
}

int myled_probe(struct platform_device *p_pltdev)
{
	int ret = 0;
	dev_t devno = MKDEV(major,minor);
	struct device_node *pnode = NULL;
	
	/*申请设备号*/
	ret = register_chrdev_region(devno,myled_num,"myled");
	if(ret)
	{
		ret = alloc_chrdev_region(&devno,minor,myled_num,"myled");
		if(ret)
		{
			printk("get devno failed\n");
			return -1;
		}
		major = MAJOR(devno);//容易遗漏,注意
	}

	pgmydev = (struct myled_dev *)kmalloc(sizeof(struct myled_dev),GFP_KERNEL);
	if(NULL == pgmydev)
	{
		unregister_chrdev_region(devno,myled_num);
		printk("kmalloc failed\n");
		return -1;
	}
	memset(pgmydev,0,sizeof(struct myled_dev));

	/*给struct cdev对象指定操作函数集*/	
	cdev_init(&pgmydev->mydev,&myops);

	/*将struct cdev对象添加到内核对应的数据结构里*/
	pgmydev->mydev.owner = THIS_MODULE;
	cdev_add(&pgmydev->mydev,devno,myled_num);

	pnode = p_pltdev->dev.of_node;

	/*ioremap*/
	request_leds_gpio(pgmydev,pnode);

	/*con-register set output*/
	set_leds_gpio_output(pgmydev);

	return 0;
}

int myled_remove(struct platform_device *p_pltdev)
{
	dev_t devno = MKDEV(major,minor);

	/*iounmap*/
	free_leds_gpio(pgmydev);

	cdev_del(&pgmydev->mydev);

	unregister_chrdev_region(devno,myled_num);

	kfree(pgmydev);
	pgmydev = NULL;

	return 0;
}

struct of_device_id myleddrv_of_ids[] = 
{
	[0] = {.compatible = "fs4412,led2-5"},
	[1] = {.compatible = "origen4412,led6-9"},
	[2] = {},
};

struct platform_driver myled_driver = 
{
	.driver = {
		.name = "fs4412leds",
		.of_match_table = myleddrv_of_ids,
	},
	.probe = myled_probe,
	.remove = myled_remove,
};

int __init myled_init(void)
{
	platform_driver_register(&myled_driver);

	return 0;
}

void __exit myled_exit(void)
{
	platform_driver_unregister(&myled_driver);
}


MODULE_LICENSE("GPL");

module_init(myled_init);
module_exit(myled_exit);

五、一个编写驱动用的宏


 

```c

struct platform_driver xxx = {  

    ...

};

module_platform_driver(xxx);

//最终展开后就是如下形式:

static int __init xxx_init(void)

{

        return platform_driver_register(&xxx);

}

module_init(xxx_init);

static void __exit xxx_init(void)

{

        return platform_driver_unregister(&xxx);

}

module_exit(xxx_exit)

```

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/376557.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

河南农信社数字化转型实践方案

农信机构立足地方“三农”&#xff0c;普遍规模较小&#xff0c;高地域集中度在县域和农村地区&#xff0c;容易受到地方农村经济脆弱性的影响。 农信机构由于信贷项目要求多&#xff0c;单笔贷款业务批复的额度相对较小&#xff0c;在信用档案登记环节&#xff0c;造成业务量…

SQL Server主流版本生命周期管理

SQL Server 生命周期 每个版本的 SQL Server 都有至少 10 年的支持期限&#xff0c;其中包括五年的主要支持和五年的扩展支持&#xff1a; “主要支持” 包括功能、性能、可伸缩性和安全更新。“扩展支持” 仅包含安全更新。 “终止支持” &#xff08;有时也称为生命周期结束…

udp套接字编程(超详细带你逐步实现)

我自己在学习UDP服务器的时候&#xff0c;有着太多的不解&#xff0c;我不明白一个udp服务器是如何设计出来的。我在网上找了很多的资料&#xff0c;不过绝大多数都是把代码往哪里一放&#xff0c;具体的设计流程完全不提&#xff0c;这让我看了之后一头雾水。或许对于刚刚开始…

scikit-learn实现近邻算法分类的示例

scikit-learn库 scikit-learn已经封装好很多数据挖掘的算法 现介绍数据挖掘框架的搭建方法 转换器&#xff08;Transformer&#xff09;用于数据预处理&#xff0c;数据转换流水线&#xff08;Pipeline&#xff09;组合数据挖掘流程&#xff0c;方便再次使用&#xff08;封装…

SVN配置使用(钩子配置、updata忽略指定文件)

参考链接&#xff1a; svn(svnsync)实时同步备份及问题解答 SVN常用命令之update SVN钩子就是一个脚本&#xff0c;在SVN更新前、后、或者变化前后等等状态&#xff0c;触发的脚本。据此可以有多种用途&#xff0c;如&#xff1a;1、在版本提交前要求必须对更新进行说明&#…

20分钟6个示例4个动图教你学会Async Hooks

序幕 async_hooks模块提供了一个全新的功能世界,但作为 Node.js 爱好者,我最感兴趣的是,它可以让您轻松了解我们在应用程序中经常执行的一些任务的幕后情况。 在本文中,我将尝试借助async_hooks模块来演示和解释一个典型的异步资源的生命周期。 Async Hooks API 简介 as…

【源码解析】SpringBoot自动装配的实现原理

什么是SpringBoot的自动装配 SpringBoot在启动的时候会扫描外部jar包中的META-INF/spring.factories文件&#xff0c;将文件中配置的类信息按照条件装配到Spring容器中。 实现原理 核心注解SpringBootApplication Target({ElementType.TYPE}) Retention(RetentionPolicy.R…

时间序列分析 | BiLSTM双向长短期记忆神经网络时间序列预测(Matlab完整程序)

时间序列分析 | BiLSTM双向长短期记忆神经网络时间序列预测(Matlab完整程序) 目录 时间序列分析 | BiLSTM双向长短期记忆神经网络时间序列预测(Matlab完整程序)预测结果评价指标基本介绍完整程序参考资料预测结果 评价指标 训练集数据的R2为:0.99302 测试集数据的R2为&…

企业数字化(技术中台、数据中台、工业互联网平台)建设方案

【版权声明】本资料来源网络&#xff0c;知识分享&#xff0c;仅供个人学习&#xff0c;请勿商用。【侵删致歉】如有侵权请联系小编&#xff0c;将在收到信息后第一时间删除&#xff01;完整资料领取见文末&#xff0c;部分资料内容&#xff1a; 1.1 技术架构 1.1.1 技术架构总…

pandas提取excel数据形成三元组,采用neo4j数据库构建小型知识图谱

前言 代码来自github项目 neo4j-python-pandas-py2neo-v3&#xff0c;项目作者为Skyelbin。我记录一下运行该项目的一些过程文字以及遇到的问题和解决办法。 一、提取excel中的数据转换为DataFrame三元组格式 from dataToNeo4jClass.DataToNeo4jClass import DataToNeo4j imp…

Unity WebGL打包后运行

打包后出现以下&#xff1a;工程中没有StreamingAssets文件夹的&#xff0c;则打包后不会有下图StreamingAssets的文件夹 这3个文件夹都是项目资源&#xff0c;只有index.html才是打开Web运行的页面 序列 主流浏览器 WebGL支持 1 Microsoft Edge Edge16或更高版本 2 火狐…

基于超像素的多视觉特征图像分割算法研究

0.引言 背景&#xff1a; 经典聚类算法&#xff1a;Kmeans、FCM 现有问题&#xff1a; 1&#xff09;现有算法大都是基于单一的视觉特征而设计的&#xff0c;eg&#xff1a;基于颜色特征的分割。 2&#xff09;没有考虑像素周围的空间信息&#xff1b;分割结果&#xff1a;多噪…

Spring-boot @ConfigurationProperties(prefix = “/xx“) 实际作用以及实现思路

ConfigurationProperties 可以通过配置该注解到我们自己创建的类上达成取代 Value 的作用 最终目的都是读取到配置文件中的值而已。 ConfigurationProperties(prefix “/xx”) 其中 prefix 指定了配置文件中的配置值得开头值 示例 配置文件中自定义值 application.yml 中…

3-10 图文并茂解释TCP/IP 3次握手4次断开

文章目录前言TCP报文首部TCP数据传输3次握手4次断开前言 TCP/IP传输协议&#xff0c;即传输控制/网络协议&#xff0c;也叫作网络通讯协议。它是在网络的使用中的最基本的通信协议。TCP/IP传输协议对互联网中各部分进行通信的标准和方法进行了规定。并且&#xff0c;TCP/IP传输…

Vue基本指令:v-on,v-if,v-mode

目录 Vue基本指令 1、v-text指令&#xff1a;设置标签的文本值 2、v-html指令&#xff1a;设置标签的innerHTML 3、v-on指令&#xff1a;为元素绑定事件 4、v-on:传参 5、v-show指令&#xff1a;根据真假切换元素的显示状态 6、v-if指令&#xff1a;根据表达式的真假切换…

前端学习---

1.简单且必须掌握的 1.MVVM是什么 将MVC中的V变为了MVVM&#xff0c;实现了双向绑定。其中VM就是vue的作用&#xff0c;这样页面的动态化可以通过vue来操作&#xff0c;而不是页面直接与后端操作&#xff0c;实现了前后端的分离 2.为什么vue采用异步渲染 &#xff1f; 调…

【云原生】k8s集群资源监控平台搭建—20230227

1. 监控指标 集群监控 ①节点资源利用率 ②节点数 ③运行pods pod监控 ①容器指标 ②应用程序 2. 监控平台 1. Prometheus 开源的&#xff1b;集成了很多功能&#xff0c;比如监控、报警、数据库等&#xff1b;以HTTP协议周期性的抓取被监控组件的状态以及相应的数据&…

HarmonyOS Connect “Device Partner”专场FAQ来啦

Device Partner平台是面向AIoT产业链伙伴的一站式服务平台&#xff0c;伙伴可以通过平台获取最新的产品、服务与解决方案&#xff0c;实现智能硬件产品的开发、认证、量产和推广等全生命周期的管理&#xff0c;加入HarmonyOS Connect生态&#xff0c;共同提升消费者的智慧生活体…

就业天花板?33% 程序员月薪达到 5 万元以上

2023年&#xff0c;随着互联网产业的蓬勃发展&#xff0c;程序员作为一个自带“高薪多金”标签的热门群体&#xff0c;被越来越多的人所关注。 在过去充满未知的一年中&#xff0c;他们的职场现状发生了一定的改变。那么&#xff0c;程序员岗位的整体薪资水平、婚恋现状、职业…

主流消息队列RocketMq,RabbitMq比对使用

首先整理这个文章是因为我正好有机会实战了一下rocketmq&#xff0c;阿里巴巴的一个开源消息中间件。所以就与以往中rabbitmq进行小小的比较一下。这里主线的根据常见面试问题进行整理。1.消息队列常用的场景1.1.削峰例如我们做得考试系统中&#xff0c;用户通过人脸识别登录系…