2014-10-08 7 views
1

플랫폼 드라이버 코드를 PCIe 변형으로 이식하고 있는데 왜 /dev/ 항목이 표시되지 않는지 이해할 수 없습니다. 수정 된 플랫폼 드라이버 코드 : 이 device_create() 호출이/dev/항목을 만들지 않는 이유는 무엇입니까?

static dev_t first; 
static struct class * class; 
ATTRIBUTE_GROUPS(my); 
static int __init my_pci_init(void) 
{ 

    int ret; 
    /* Create a class entry in sysfs */ 
    if ((class = class_create(THIS_MODULE, "test_driver")) == NULL) { 
     pr_err("Couldn't create 'struct class' structure."); 
     ret = -ENODEV; 
     goto exit; 
    } 
    class->dev_groups = my_groups; 
    /* Create the /dev/ file system entry */ 
    /* return value ignored: there's a 'struct class' to 'struct device' mapping */ 
    if (device_create(class, NULL, first, NULL, KBUILD_MODNAME) == NULL) { 
     pr_err("Couldn't create entry in '/dev/' file system."); 
     ret = -ENODEV; 
     goto exit; 
    } else { 
     pr_info("Created a /dev/ entry."); 
    } 

    if ((ret = pci_register_driver(&pci_driver)) < 0) { 
     pr_err("Couldn't register pci driver."); 
    } 
exit: 
    if (ret < 0) { 
     my_pci_exit(); 
     pr_err(" ret = %d", ret); 
    } 
    return ret; 
} 

module_init(my_pci_init); 

모듈 이름은 'cz_tdm가'이면

, 나는 항목 /dev/cz_tdm을 만들 것입니다 위의 코드를 기대했다. 적어도 플랫폼 드라이버로 이것을 컴파일 할 때 했었습니다.

드라이버는 정확하게 열거합니다. lspci의 결과는 드라이버가로드되었고 sysfs을 열람하면 /sys/devices/virtual/...에있는 모든 내 특성이 내가 기대했던 것임을 보여줍니다.

무엇을 제공합니까?

답변

2

와우.

너무 생각 안하기 때문에. 코드를 지나치게 삭제하면이 필요한 요소가 제거됩니다.