国产毛片a精品毛-国产毛片黄片-国产毛片久久国产-国产毛片久久精品-青娱乐极品在线-青娱乐精品

jrj317的個人空間 http://www.qingdxww.cn/space-uid-9104.html [收藏] [復制] [RSS]

博客

Bus Types

已有 1913 次閱讀2011-4-10 08:03


Bus Types
Definition
~~~~~~~~~~
struct bus_type {
 char   * name;
 struct subsystem subsys;
 struct kset  drivers;
 struct kset  devices;
 struct bus_attribute * bus_attrs;
 struct device_attribute * dev_attrs;
 struct driver_attribute * drv_attrs;
 int  (*match)(struct device * dev, struct device_driver * drv);
 int  (*hotplug) (struct device *dev, char **envp,
        int num_envp, char *buffer, int buffer_size);
 int  (*suspend)(struct device * dev, pm_message_t state);
 int  (*resume)(struct device * dev);
};
int bus_register(struct bus_type * bus);

Declaration
~~~~~~~~~~~
Each bus type in the kernel (PCI, USB, etc) should declare one static
object of this type. They must initialize the name field, and may
optionally initialize the match callback.
struct bus_type pci_bus_type = {
       .name = "pci",
       .match = pci_bus_match,
};
The structure should be exported to drivers in a header file:
extern struct bus_type pci_bus_type;

Registration
~~~~~~~~~~~~
When a bus driver is initialized, it calls bus_register. This
initializes the rest of the fields in the bus object and inserts it
into a global list of bus types. Once the bus object is registered,
the fields in it are usable by the bus driver.

Callbacks
~~~~~~~~~
match(): Attaching Drivers to Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The format of device ID structures and the semantics for comparing
them are inherently bus-specific. Drivers typically declare an array
of device IDs of devices they support that reside in a bus-specific
driver structure.
The purpose of the match callback is provide the bus an opportunity to
determine if a particular driver supports a particular device by
comparing the device IDs the driver supports with the device ID of a
particular device, without sacrificing bus-specific functionality or
type-safety.
When a driver is registered with the bus, the bus's list of devices is
iterated over, and the match callback is called for each device that
does not have a driver associated with it.
 
Device and Driver Lists
~~~~~~~~~~~~~~~~~~~~~~~
The lists of devices and drivers are intended to replace the local
lists that many buses keep. They are lists of struct devices and
struct device_drivers, respectively. Bus drivers are free to use the
lists as they please, but conversion to the bus-specific type may be
necessary.
The LDM core provides helper functions for iterating over each list.
int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data,
       int (*fn)(struct device *, void *));
int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
       void * data, int (*fn)(struct device_driver *, void *));
These helpers iterate over the respective list, and call the callback
for each device or driver in the list. All list accesses are
synchronized by taking the bus's lock (read currently). The reference
count on each object in the list is incremented before the callback is
called; it is decremented after the next object has been obtained. The
lock is not held when calling the callback.

sysfs
~~~~~~~~
There is a top-level directory named 'bus'.
Each bus gets a directory in the bus directory, along with two default
directories:
 /sys/bus/pci/
 |-- devices
 `-- drivers
Drivers registered with the bus get a directory in the bus's drivers
directory:
 /sys/bus/pci/
 |-- devices
 `-- drivers
     |-- Intel ICH
     |-- Intel ICH Joystick
     |-- agpgart
     `-- e100
Each device that is discovered on a bus of that type gets a symlink in
the bus's devices directory to the device's directory in the physical
hierarchy:
 /sys/bus/pci/
 |-- devices
 |   |-- 00:00.0 -> ../../../root/pci0/00:00.0
 |   |-- 00:01.0 -> ../../../root/pci0/00:01.0
 |   `-- 00:02.0 -> ../../../root/pci0/00:02.0
 `-- drivers

Exporting Attributes
~~~~~~~~~~~~~~~~~~~~
struct bus_attribute {
 struct attribute attr;
 ssize_t (*show)(struct bus_type *, char * buf);
 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
};
Bus drivers can export attributes using the BUS_ATTR macro that works
similarly to the DEVICE_ATTR macro for devices. For example, a definition
like this:
static BUS_ATTR(debug,0644,show_debug,store_debug);
is equivalent to declaring:
static bus_attribute bus_attr_debug;
This can then be used to add and remove the attribute from the bus's
sysfs directory using:
int bus_create_file(struct bus_type *, struct bus_attribute *);
void bus_remove_file(struct bus_type *, struct bus_attribute *);

 

路過

雞蛋

鮮花

握手

雷人

評論 (0 個評論)

facelist

您需要登錄后才可以評論 登錄 | 立即注冊

關于我們  -  服務條款  -  使用指南  -  站點地圖  -  友情鏈接  -  聯系我們
電子工程網 © 版權所有   京ICP備16069177號 | 京公網安備11010502021702
返回頂部
主站蜘蛛池模板: 好男人官网在线观看 | 精品伊人网 | 三级福利视频 | 国产大片黄在线观看 | 国产精品国产三级国产专区5o | 日韩新片在线观看网 | 精品亚洲欧美高清不卡高清 | 国产99热 | 久久国产热这里只有精品 | 亚洲日韩欧美一区二区在线 | 99国产精品视频免费观看 | 亚洲高清一区二区三区四区 | 韩国精品欧美一区二区三区 | 欧美va在线播放免费观看 | 91麻豆极品在线观看 | 最新内地三级在线观看 | 在线看的毛片 | 99精彩免费观看 | 日日视频 | 好男人好手机视频在线影视 | 欧美亚洲国产片在线观看 | 欧美精品91| 国产一国产一级毛片视频在线 | 天天干天天操天天透 | 久久精品国产精品亚洲婷婷 | 中文字幕手机在线视频 | 成人午夜视频在线观 | 91香蕉国产亚洲一二三区 | 欧美成人免费在线 | 久久综合影院 | 91在线视频免费观看 | 中文字幕在线观看日本 | 欧美日韩免费一区二区三区 | 高清一区二区三区四区五区 | 国产三级全黄在线观看 | 日韩色视频一区二区三区亚洲 | 亚洲国产精久久久久久久春色 | 免费一级做a爰片久久毛片潮 | 欧美中文一区 | 日韩手机在线免费视频 | 狠狠综合久久久久尤物丿 |