Linuxプラットフォームのドライバについて学びたいと思っています。これは、基本的なプラットフォームドライバであるデバイスドライバを使ってデバイスを接続する
http://linuxseekernel.blogspot.com/2014/05/platform-device-driver-practical.html
:私は、次のチュートリアルからドライバをとっています。私はそれをコンパイルし、モジュールをロードしました。しかし、それは正常にロードされますが、そのプローブ関数は決して実行されません。デバイスIDとドライバIDが一致している限り、プローブ機能が呼び出されるまで多くのドキュメントがあります。まあ、私は次のドライバがあります。
#include <linux/module.h>
#include <linux/kernel.h>
//for platform drivers....
#include <linux/platform_device.h>
#define DRIVER_NAME "twl12xx"
MODULE_LICENSE("GPL");
/**************/
static int sample_drv_probe(struct platform_device *pdev){
printk(KERN_ALERT "twl12xx: Probed\n");
return 0;
}
static int sample_drv_remove(struct platform_device *pdev){
printk(KERN_ALERT "twl12xx: Removing twl12xx\n");
return 0;
}
static const struct platform_device_id twl12xx_id_table[] = {
{ "twl12xx", 0},
{}
};
MODULE_DEVICE_TABLE(platform, twl12xx_id_table);
static struct platform_driver sample_pldriver = {
.probe = sample_drv_probe,
.remove = sample_drv_remove,
.driver = {
.name = DRIVER_NAME,
},
};
/**************/
int ourinitmodule(void)
{
printk(KERN_ALERT "\n Welcome to twl12xx driver.... \n");
/* Registering with Kernel */
platform_driver_register(&sample_pldriver);
return 0;
}
void ourcleanupmodule(void)
{
printk(KERN_ALERT "\n Thanks....Exiting twl12xx driver... \n");
/* Unregistering from Kernel */
platform_driver_unregister(&sample_pldriver);
return;
}
module_init(ourinitmodule);
module_exit(ourcleanupmodule);
を私も自分のデバイスツリーに次のエントリを持っている:
twl12xx: [email protected] {
compatible = "twl12xx";
};
私は何かが足りないか、正しく私のデバイスツリーを定義しなければならないのですように私は感じます。
あなたはデバイスツリーまたはOpen Firmwareのために意図されていないガイドを使用しています。作者はおそらくx86中心です。書かれたドライバはDT対応ではありません。 ** linux/of.h **は含まれておらず、互換性のある文字列を持つ 'struct of_device_id'を持っていません。カーネルには、例として使用する多数のプラットフォームドライバがあります。 http://stackoverflow.com/questions/26840267/driver-code-in-kernel-module-doesnt-execute/26855205#26855205 – sawdust
[カーネルモジュールのドライバコードは実行できませんか?](http: //stackoverflow.com/questions/26840267/driver-code-in-kernel-module-doesnt-execute) – sawdust
@sawdust、それ以上のx86中心のコードはありません、私は少し少ないDT中心であるべきです、言及ガイドが古くなっている可能性があります。今日では、他の機能の中で統一されたデバイスのプロパティは、ドライバを書くことが誰がリソースプロバイダであるか無視することを可能にします。だから、XYZ中心のコードを作る開発者を非難して、アーキテクチャを責めないでください。 – 0andriy