Linux驱动知识:Linux Device Model
发布时间:2020-12-14 00:57:20 所属栏目:Linux 来源:网络整理
导读:Kobjects #include linux/kobject.h // The include file containing definitions for kobjects,related structures,and functions. void kobject_init( struct kobject * kobj); int kobject_set_name( struct kobject *kobj, const char * format,...); //
Kobjects#include <linux/kobject.h> //The include file containing definitions for kobjects,related structures,and functions. void kobject_init(struct kobject *kobj); int kobject_set_name(struct kobject *kobj,const char *format,...); //Functions for kobject initialization. struct kobject *kobject_get(struct kobject *kobj); void kobject_put(struct kobject *kobj); //Functions that manage reference counts for kobjects. struct kobj_type; struct kobj_type *get_ktype(struct kobject *kobj); //Represents the type of structure within which a kobject is embedded. Use get_ktype to get the kobj_type associated with a given kobject. int kobject_add(struct kobject *kobj); extern int kobject_register(struct kobject *kobj); void kobject_del(struct kobject *kobj); void kobject_unregister(struct kobject *kobj); //kobject_add adds a kobject to the system,handling kset membership,sysfs representation,and hotplug event generation. kobject_register is a convenience function that combines kobject_init and kobject_add. Use kobject_del to remove a kobject orkobject_unregister,which combines kobject_del and kobject_put. void kset_init(struct kset *kset); int kset_add(struct kset *kset); int kset_register(struct kset *kset); void kset_unregister(struct kset *kset); //Initialization and registration functions for ksets. decl_subsys(name,type,hotplug_ops); //A macro that makes it easier to declare subsystems. void subsystem_init(struct subsystem *subsys); int subsystem_register(struct subsystem *subsys); void subsystem_unregister(struct subsystem *subsys); struct subsystem *subsys_get(struct subsystem *subsys) void subsys_put(struct subsystem *subsys); //Operations on subsystems. ? Sysfs Operations#include <linux/sysfs.h> //The include file containing declarations for sysfs. int sysfs_create_file(struct kobject *kobj,struct attribute *attr); int sysfs_remove_file(struct kobject *kobj,struct attribute *attr); int sysfs_create_bin_file(struct kobject *kobj,struct bin_attribute *attr); int sysfs_remove_bin_file(struct kobject *kobj,struct bin_attribute *attr); int sysfs_create_link(struct kobject *kobj,struct kobject *target,char *name); void sysfs_remove_link(struct kobject *kobj,char *name); //Functions for creating and removing attribute files associated with a kobject. ? Buses,Devices,and Driversint bus_register(struct bus_type *bus); void bus_unregister(struct bus_type *bus); //Functions that perform registration and unregistration of buses in the device model. 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,int (*fn)(struct device_driver *,void *)); //Functions that iterate over each of the devices and drivers,respectively,that are attached to the given bus. BUS_ATTR(name,mode,show,store); int bus_create_file(struct bus_type *bus,struct bus_attribute *attr); void bus_remove_file(struct bus_type *bus,struct bus_attribute *attr); //The BUS_ATTR macro may be used to declare a bus_attribute structure,which may then be added and removed with the above two functions. int device_register(struct device *dev); void device_unregister(struct device *dev); //Functions that handle device registration. DEVICE_ATTR(name,store); int device_create_file(struct device *device,struct device_attribute *entry); void device_remove_file(struct device *dev,struct device_attribute *attr); //Macros and functions that deal with device attributes. int driver_register(struct device_driver *drv); void driver_unregister(struct device_driver *drv); //Functions that register and unregister a device driver. DRIVER_ATTR(name,store); int driver_create_file(struct device_driver *drv,struct driver_attribute *attr); void driver_remove_file(struct device_driver *drv,struct driver_attribute *attr); //Macros and functions that manage driver attributes. Classesstruct class_simple *class_simple_create(struct module *owner,char *name); void class_simple_destroy(struct class_simple *cs); struct class_device *class_simple_device_add(struct class_simple *cs,dev_t devnum,struct device *device,const char *fmt,...); void class_simple_device_remove(dev_t dev); int class_simple_set_hotplug(struct class_simple *cs,int (*hotplug)(struct class_device *dev,char **envp,int num_envp,char *buffer,int buffer_size)); //Functions that implement the class_simple interface; they manage simple class entries containing a dev attribute and little else. int class_register(struct class *cls); void class_unregister(struct class *cls); Registration and unregistration of classes. CLASS_ATTR(name,store); int class_create_file(struct class *cls,const struct class_attribute *attr); void class_remove_file(struct class *cls,const struct class_attribute *attr); The usual macros and functions for dealing with class attributes. int class_device_register(struct class_device *cd); void class_device_unregister(struct class_device *cd); int class_device_rename(struct class_device *cd,char *new_name); CLASS_DEVICE_ATTR(name,store); int class_device_create_file(struct class_device *cls,const struct class_device_attribute *attr); void class_device_remove_file(struct class_device *cls,const struct class_device_attribute *attr); //Functions and macros that implement the class device interface. int class_interface_register(struct class_interface *intf); void class_interface_unregister(struct class_interface *intf); //Functions that add an interface to a class (or remove it). Firmware#include <linux/firmware.h> int request_firmware(const struct firmware **fw,char *name,struct device *device); int request_firmware_nowait(struct module *module,void *context,void (*cont)(const struct firmware *fw,void *context)); void release_firmware(struct firmware *fw); //Functions that implement the kernel firmware-loading interface. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |