Linux内核平台总线设备驱动模型浅析
发布日期:2021-05-10 21:40:45 浏览次数:12 分类:精选文章

本文共 4657 字,大约阅读时间需要 15 分钟。

������������������������������

���Linux������������������������������������������������������������������������������������������������������������������������������������������������������������

������������������������������������������������

���������������������������������������������������������C������������������������

  • struct bus_type������������������������������������

    • ���������������������������������
      • name���������������������������������������������������
      • bus_attrs���������������������������������/sys/bus/xxx������������������������������������������������
      • dev_attrs���������������������������������������������������
      • drv_attrs������������������������������������������������������
      • match������������������������������������������������������
      • p������������������������������������������������klist_devices���klist_drivers���������������������������������������
  • struct device������������������������������

    • ���������������������������
      • kobj���������������������������������������������������������������
      • name������������������������/sys/devices������
      • bus���������������������������������
      • driver���������������������������������������
      • platform_data������������������������������������������������������������������������������������������������������
      • devt������������������������������������������������������������
  • struct device_driver������������������������������

    • ���������������������������
      • name���������������
      • bus���������������������������������
      • probe���������������������������������
      • remove���������������������������������
      • p���������������������������������
  • ���������������������������������������������������

    ���������������������������������������������������������������PCI���������USB���������I2C���������SPI���������������������������������������������������������������struct device������������������������������������������������������������������������

  • ���������������������device_register(struct device *dev)���������������������������

    int device_register(struct device *dev) {    device_initialize(dev);    return device_add(dev);
    • device_initialize���������������������������������������������������������������������������������������������
    • device_add���������������������������������������������������������������������������������������������������������������������klist_devices���������������
  • ���������������������driver_register(structdevice_driver *drv)���������������������������

    int driver_register(structdevice_driver *drv) {    return bus_add_driver(drv);}
    • bus_add_driver���������������������������������������klist_drivers���������������
  • ������������������������������������������������match������������������������������������������������������������������������������������������������������������probe���������������������������������������

  • ���������������������

    ������struct bus_type���struct device���struct device_driver������������������������������������������������������������������������������������������������������������

    ���������

    • ������I2C���������������������struct device���������I2C���������������������
    • ������SPI������������������struct device������������SPI���������������
    • ������������������������PCI������������USB������������������������������������������������������������������������

    ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

    ���������������������������������probe������

    ������������������������������������������������������������probe���������������������������������������������������������������

    ���������������I2C������������������������������probe���������������������������������������������������������������������������

    int (*probe)(struct device *dev) {    // 1. ������������������������������������������������������������������������������������������    // 2. ���������������������������������������������    // 3. ������������������������������    // 4. ������`device_set_drvdata(dev, pdata)`������������������������������������������������    return 0;}

    ������������������������������struct device_driver���������probe���������������������������������������������������������������������������������������������struct device_driver���probe������������������������

    ���������������������������������������������������������������������������������������������������������������������������Linux���������������������������������������������������������������������������������������������������������������������������������������������������������������

    上一篇:韦东山:机会总是留给有准备的人
    下一篇:浅谈text段、data段和bss段

    发表评论

    最新留言

    路过,博主的博客真漂亮。。
    [***.116.15.85]2025年04月24日 14时11分47秒