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";
};
합니다.
; 저자는 아마도 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