删除属性文件
  driver_remove_file(struct device_driver *driver, const struct driver_attribute *attr);
  在写总线驱动时,总线 设备、驱动三者缺一不可,设备才能工作,对于这三个模块的程序设计流程极其相似
  步骤:
  1、首先是注册设备(总线、设备、驱动)
  2、创建设备属性文件(是对 总线、设备、驱动的读写函数)
  3、实现这些读写函数
  其实程序的书写很简单,关键是弄清楚三者之间的关系
  1、设备室如何挂载到总线上的???
  2、驱动什么时候去查找匹配的设备“????//注册的时候会去查找
  3、驱动找到匹配的设备的标准是什么????//match是判断是否匹配的
  要理解这三个关系--其实这些关系都在 总线、设备、驱动的描述结构体重已经体现 下面我们将这三个结构体再次贴出贴出来,备注一下 便于理解
  总线描述结构体:struct bus_type
struct bus_type {
const char
*name;/*这个是总线的名称*/
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 (*uevent)(struct device *dev, struct kobj_uevent_env *env);/*处理驱动热插拔事件的函数*/
int (*probe)(struct device *dev);//probe是驱动实现的真正的函数
int (*remove)(struct device *dev);/*设备删除处理函数*/
void (*shutdown)(struct device *dev);/*设备关闭函数*/
int (*suspend)(struct device *dev, pm_message_t state);
int (*resume)(struct device *dev);
const struct dev_pm_ops *pm;
struct subsys_private *p;
};
  设备描述结构体:
struct device {
struct device *parent;//父类设备,
struct device_private *p;
struct kobject kobj;
const char *init_name; /* 设备的名字 */
struct device_type *type;
struct mutex mutex; /* mutex to synchronize calls to
* its driver.
*/
struct bus_type *bus; /* 挂载到哪个总线上 */
struct device_driver *driver; /* which driver has allocated thisdevice */
void *platform_data; /* Platform specific data, device
core doesn't touch it */
struct dev_pm_info power;
#ifdef CONFIG_NUMA
int numa_node; /* NUMA node this device is close to */
#endif
u64 *dma_mask; /* dma mask (if dma'able device) */
u64 coherent_dma_mask;/* Like dma_mask, but for
alloc_coherent mappings as
not all hardware supports
64 bit addresses for consistent
allocations such descriptors. */
struct device_dma_parameters *dma_parms;
struct list_head dma_pools; /* dma pools (if dma'ble) */
struct dma_coherent_mem *dma_mem; /* internal for coherent mem
override */
/* arch specific additions */
struct dev_archdata archdata;
#ifdef CONFIG_OF
struct device_node *of_node;
#endif
dev_t devt; /* dev_t, creates the sysfs "dev" */
spinlock_t devres_lock;
struct list_head devres_head;
struct klist_node knode_class;
struct class *class;
const struct attribute_group **groups; /* optional groups */
void (*release)(struct device *dev);
};