struct uclass_driver

本文介绍了uclass_driver,一种为相关驱动提供一致接口的结构,包含了各种回调函数,如设备绑定、探测和销毁操作,以及私有数据和平台数据的自动分配选项。
摘要由CSDN通过智能技术生成
/**
 * struct uclass_driver - Driver for the uclass
 *
 * A uclass_driver provides a consistent interface to a set of related
 * drivers.
 *
 * @name: Name of uclass driver
 * @id: ID number of this uclass
 * @post_bind: Called after a new device is bound to this uclass
 * @pre_unbind: Called before a device is unbound from this uclass
 * @pre_probe: Called before a new device is probed
 * @post_probe: Called after a new device is probed
 * @pre_remove: Called before a device is removed
 * @child_post_bind: Called after a child is bound to a device in this uclass
 * @child_pre_probe: Called before a child in this uclass is probed
 * @child_post_probe: Called after a child in this uclass is probed
 * @init: Called to set up the uclass
 * @destroy: Called to destroy the uclass
 * @priv_auto_alloc_size: If non-zero this is the size of the private data
 * to be allocated in the uclass's ->priv pointer. If zero, then the uclass
 * driver is responsible for allocating any data required.
 * @per_device_auto_alloc_size: Each device can hold private data owned
 * by the uclass. If required this will be automatically allocated if this
 * value is non-zero.
 * @per_device_platdata_auto_alloc_size: Each device can hold platform data
 * owned by the uclass as 'dev->uclass_platdata'. If the value is non-zero,
 * then this will be automatically allocated.
 * @per_child_auto_alloc_size: Each child device (of a parent in this
 * uclass) can hold parent data for the device/uclass. This value is only
 * used as a fallback if this member is 0 in the driver.
 * @per_child_platdata_auto_alloc_size: A bus likes to store information about
 * its children. If non-zero this is the size of this data, to be allocated
 * in the child device's parent_platdata pointer. This value is only used as
 * a fallback if this member is 0 in the driver.
 * @ops: Uclass operations, providing the consistent interface to devices
 * within the uclass.
 * @flags: Flags for this uclass (DM_UC_...)
 */
struct uclass_driver {
	const char *name;
	enum uclass_id id;
	int (*post_bind)(struct udevice *dev);
	int (*pre_unbind)(struct udevice *dev);
	int (*pre_probe)(struct udevice *dev);
	int (*post_probe)(struct udevice *dev);
	int (*pre_remove)(struct udevice *dev);
	int (*child_post_bind)(struct udevice *dev);
	int (*child_pre_probe)(struct udevice *dev);
	int (*child_post_probe)(struct udevice *dev);
	int (*init)(struct uclass *class);
	int (*destroy)(struct uclass *class);
	int priv_auto_alloc_size;
	int per_device_auto_alloc_size;
	int per_device_platdata_auto_alloc_size;
	int per_child_auto_alloc_size;
	int per_child_platdata_auto_alloc_size;
	const void *ops;
	uint32_t flags;
};
  • uclass_driver为一组相关的驱动提供了一致的接口。
  • name: ucclass驱动的名称
  • id:该类的id号
  • post_bind:在一个新设备绑定到这个类之后调用
  • pre_unbind:在设备从这个类解绑定之前调用
  • pre_probe:在探测新设备之前调用
  • post_probe:在探测新设备后调用
  • pre_remove:在移除设备之前调用
  • child_post_bind:在子类绑定到设备后调用
  • child_pre_probe:在探测类中的子节点之前调用
  • child_post_probe:在探测类中的子节点后调用
  • init:用来设置ucclass
  • destroy:用于销毁类
  • priv_auto_alloc_size:如果非零,这是要在ucclass的->priv指针中分配的私有数据的大小。如果为零,则为ucclass驱动程序负责分配所需的任何数据。
  • per_device_auto_alloc_size:每个设备可以保存ucclass拥有的私有数据。如果需要,如果该值非零,将自动分配此值。
  • per_device_platdata_auto_alloc_size:每个设备可以保存ucclass拥有的平台数据为'dev->uclass_platdata'。如果该值不为零,则会自动分配该值。
  • per_child_auto_alloc_size:每个子设备(在这个ucclass中的父设备)可以保存设备/ ucclass的父数据。此值仅在该成员在驱动程序中为0时用作回退。
  • per_child_platdata_auto_alloc_size:总线喜欢存储其子节点的信息。如果非零,这就是要分配的数据的大小
  • 在子设备的parent_platdata指针中。此值仅在该成员在驱动程序中为0时用作回退。
  • ops: Uclass操作,为ucclass内的设备提供一致的接口。
  • flags:这个ucclass的标志(DM_UC_…)
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

打个工而已

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值