写一个platform 驱动

#include <linux/init.h>
#include <linux/printk.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>

static const struct of_device_id imatch[] = {
	{ .compatible = "xxxsoc,idriver", },
	{},
};
static int idriver_probe(struct platform_device *pdev)
{
	int ret = 0;

	printk("idriver_probe.\n");
	return ret;
}
static int idriver_remove(struct platform_device *pdev)
{
	printk("idriver_remove.\n");
	return 0;
}
static struct platform_driver iplt_driver = {
	.probe    = idriver_probe,
	.remove   = idriver_remove,
	.driver   =
	{
		.name   = "iplt_driver",
		.owner  = THIS_MODULE,
		.of_match_table = imatch,
	},
};

static int __init hi_init(void)
{
	int ret;
	printk("hello world module.\n");
	ret = platform_driver_register(&iplt_driver);
	return 0;
}

static void __exit hi_exit(void)
{
	platform_driver_unregister(&iplt_driver);
}
module_init(hi_init);
module_exit(hi_exit);

MODULE_LICENSE("GPL");

 

posted @ 2023-09-05 17:23  秦舒云  阅读(18)  评论(0编辑  收藏  举报