1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (c) 2013 Google, Inc 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * (C) Copyright 2012 5*4882a593Smuzhiyun * Pavel Herrmann <morpheus.ibis@gmail.com> 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+ 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun #ifndef _DM_UCLASS_H 11*4882a593Smuzhiyun #define _DM_UCLASS_H 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #include <dm/ofnode.h> 14*4882a593Smuzhiyun #include <dm/uclass-id.h> 15*4882a593Smuzhiyun #include <linker_lists.h> 16*4882a593Smuzhiyun #include <linux/list.h> 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /** 19*4882a593Smuzhiyun * struct uclass - a U-Boot drive class, collecting together similar drivers 20*4882a593Smuzhiyun * 21*4882a593Smuzhiyun * A uclass provides an interface to a particular function, which is 22*4882a593Smuzhiyun * implemented by one or more drivers. Every driver belongs to a uclass even 23*4882a593Smuzhiyun * if it is the only driver in that uclass. An example uclass is GPIO, which 24*4882a593Smuzhiyun * provides the ability to change read inputs, set and clear outputs, etc. 25*4882a593Smuzhiyun * There may be drivers for on-chip SoC GPIO banks, I2C GPIO expanders and 26*4882a593Smuzhiyun * PMIC IO lines, all made available in a unified way through the uclass. 27*4882a593Smuzhiyun * 28*4882a593Smuzhiyun * @priv: Private data for this uclass 29*4882a593Smuzhiyun * @uc_drv: The driver for the uclass itself, not to be confused with a 30*4882a593Smuzhiyun * 'struct driver' 31*4882a593Smuzhiyun * @dev_head: List of devices in this uclass (devices are attached to their 32*4882a593Smuzhiyun * uclass when their bind method is called) 33*4882a593Smuzhiyun * @sibling_node: Next uclass in the linked list of uclasses 34*4882a593Smuzhiyun */ 35*4882a593Smuzhiyun struct uclass { 36*4882a593Smuzhiyun void *priv; 37*4882a593Smuzhiyun struct uclass_driver *uc_drv; 38*4882a593Smuzhiyun struct list_head dev_head; 39*4882a593Smuzhiyun struct list_head sibling_node; 40*4882a593Smuzhiyun #ifdef CONFIG_USING_KERNEL_DTB_V2 41*4882a593Smuzhiyun struct list_head *u_boot_dev_head; 42*4882a593Smuzhiyun #endif 43*4882a593Smuzhiyun }; 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun struct driver; 46*4882a593Smuzhiyun struct udevice; 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /* Members of this uclass sequence themselves with aliases */ 49*4882a593Smuzhiyun #define DM_UC_FLAG_SEQ_ALIAS (1 << 0) 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun /** 52*4882a593Smuzhiyun * struct uclass_driver - Driver for the uclass 53*4882a593Smuzhiyun * 54*4882a593Smuzhiyun * A uclass_driver provides a consistent interface to a set of related 55*4882a593Smuzhiyun * drivers. 56*4882a593Smuzhiyun * 57*4882a593Smuzhiyun * @name: Name of uclass driver 58*4882a593Smuzhiyun * @id: ID number of this uclass 59*4882a593Smuzhiyun * @post_bind: Called after a new device is bound to this uclass 60*4882a593Smuzhiyun * @pre_unbind: Called before a device is unbound from this uclass 61*4882a593Smuzhiyun * @pre_probe: Called before a new device is probed 62*4882a593Smuzhiyun * @post_probe: Called after a new device is probed 63*4882a593Smuzhiyun * @pre_remove: Called before a device is removed 64*4882a593Smuzhiyun * @child_post_bind: Called after a child is bound to a device in this uclass 65*4882a593Smuzhiyun * @init: Called to set up the uclass 66*4882a593Smuzhiyun * @destroy: Called to destroy the uclass 67*4882a593Smuzhiyun * @priv_auto_alloc_size: If non-zero this is the size of the private data 68*4882a593Smuzhiyun * to be allocated in the uclass's ->priv pointer. If zero, then the uclass 69*4882a593Smuzhiyun * driver is responsible for allocating any data required. 70*4882a593Smuzhiyun * @per_device_auto_alloc_size: Each device can hold private data owned 71*4882a593Smuzhiyun * by the uclass. If required this will be automatically allocated if this 72*4882a593Smuzhiyun * value is non-zero. 73*4882a593Smuzhiyun * @per_device_platdata_auto_alloc_size: Each device can hold platform data 74*4882a593Smuzhiyun * owned by the uclass as 'dev->uclass_platdata'. If the value is non-zero, 75*4882a593Smuzhiyun * then this will be automatically allocated. 76*4882a593Smuzhiyun * @per_child_auto_alloc_size: Each child device (of a parent in this 77*4882a593Smuzhiyun * uclass) can hold parent data for the device/uclass. This value is only 78*4882a593Smuzhiyun * used as a falback if this member is 0 in the driver. 79*4882a593Smuzhiyun * @per_child_platdata_auto_alloc_size: A bus likes to store information about 80*4882a593Smuzhiyun * its children. If non-zero this is the size of this data, to be allocated 81*4882a593Smuzhiyun * in the child device's parent_platdata pointer. This value is only used as 82*4882a593Smuzhiyun * a falback if this member is 0 in the driver. 83*4882a593Smuzhiyun * @ops: Uclass operations, providing the consistent interface to devices 84*4882a593Smuzhiyun * within the uclass. 85*4882a593Smuzhiyun * @flags: Flags for this uclass (DM_UC_...) 86*4882a593Smuzhiyun */ 87*4882a593Smuzhiyun struct uclass_driver { 88*4882a593Smuzhiyun const char *name; 89*4882a593Smuzhiyun enum uclass_id id; 90*4882a593Smuzhiyun int (*post_bind)(struct udevice *dev); 91*4882a593Smuzhiyun int (*pre_unbind)(struct udevice *dev); 92*4882a593Smuzhiyun int (*pre_probe)(struct udevice *dev); 93*4882a593Smuzhiyun int (*post_probe)(struct udevice *dev); 94*4882a593Smuzhiyun int (*pre_remove)(struct udevice *dev); 95*4882a593Smuzhiyun int (*child_post_bind)(struct udevice *dev); 96*4882a593Smuzhiyun int (*child_pre_probe)(struct udevice *dev); 97*4882a593Smuzhiyun int (*init)(struct uclass *class); 98*4882a593Smuzhiyun int (*destroy)(struct uclass *class); 99*4882a593Smuzhiyun int priv_auto_alloc_size; 100*4882a593Smuzhiyun int per_device_auto_alloc_size; 101*4882a593Smuzhiyun int per_device_platdata_auto_alloc_size; 102*4882a593Smuzhiyun int per_child_auto_alloc_size; 103*4882a593Smuzhiyun int per_child_platdata_auto_alloc_size; 104*4882a593Smuzhiyun const void *ops; 105*4882a593Smuzhiyun uint32_t flags; 106*4882a593Smuzhiyun }; 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun /* Declare a new uclass_driver */ 109*4882a593Smuzhiyun #define UCLASS_DRIVER(__name) \ 110*4882a593Smuzhiyun ll_entry_declare(struct uclass_driver, __name, uclass) 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun /** 113*4882a593Smuzhiyun * uclass_get() - Get a uclass based on an ID, creating it if needed 114*4882a593Smuzhiyun * 115*4882a593Smuzhiyun * Every uclass is identified by an ID, a number from 0 to n-1 where n is 116*4882a593Smuzhiyun * the number of uclasses. This function allows looking up a uclass by its 117*4882a593Smuzhiyun * ID. 118*4882a593Smuzhiyun * 119*4882a593Smuzhiyun * @key: ID to look up 120*4882a593Smuzhiyun * @ucp: Returns pointer to uclass (there is only one per ID) 121*4882a593Smuzhiyun * @return 0 if OK, -ve on error 122*4882a593Smuzhiyun */ 123*4882a593Smuzhiyun int uclass_get(enum uclass_id key, struct uclass **ucp); 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun /** 126*4882a593Smuzhiyun * uclass_get_name() - Get the name of a uclass driver 127*4882a593Smuzhiyun * 128*4882a593Smuzhiyun * @id: ID to look up 129*4882a593Smuzhiyun * @returns the name of the uclass driver for that ID, or NULL if none 130*4882a593Smuzhiyun */ 131*4882a593Smuzhiyun const char *uclass_get_name(enum uclass_id id); 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun /** 134*4882a593Smuzhiyun * uclass_get_by_name() - Look up a uclass by its driver name 135*4882a593Smuzhiyun * 136*4882a593Smuzhiyun * @name: Name to look up 137*4882a593Smuzhiyun * @returns the associated uclass ID, or UCLASS_INVALID if not found 138*4882a593Smuzhiyun */ 139*4882a593Smuzhiyun enum uclass_id uclass_get_by_name(const char *name); 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun /** 142*4882a593Smuzhiyun * uclass_get_device() - Get a uclass device based on an ID and index 143*4882a593Smuzhiyun * 144*4882a593Smuzhiyun * The device is probed to activate it ready for use. 145*4882a593Smuzhiyun * 146*4882a593Smuzhiyun * @id: ID to look up 147*4882a593Smuzhiyun * @index: Device number within that uclass (0=first) 148*4882a593Smuzhiyun * @devp: Returns pointer to device (there is only one per for each ID) 149*4882a593Smuzhiyun * @return 0 if OK, -ve on error 150*4882a593Smuzhiyun */ 151*4882a593Smuzhiyun int uclass_get_device(enum uclass_id id, int index, struct udevice **devp); 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun /** 154*4882a593Smuzhiyun * uclass_get_device_by_name() - Get a uclass device by its name 155*4882a593Smuzhiyun * 156*4882a593Smuzhiyun * This searches the devices in the uclass for one with the exactly given name. 157*4882a593Smuzhiyun * 158*4882a593Smuzhiyun * The device is probed to activate it ready for use. 159*4882a593Smuzhiyun * 160*4882a593Smuzhiyun * @id: ID to look up 161*4882a593Smuzhiyun * @name: name of a device to get 162*4882a593Smuzhiyun * @devp: Returns pointer to device (the first one with the name) 163*4882a593Smuzhiyun * @return 0 if OK, -ve on error 164*4882a593Smuzhiyun */ 165*4882a593Smuzhiyun int uclass_get_device_by_name(enum uclass_id id, const char *name, 166*4882a593Smuzhiyun struct udevice **devp); 167*4882a593Smuzhiyun 168*4882a593Smuzhiyun /** 169*4882a593Smuzhiyun * uclass_get_device_by_seq() - Get a uclass device based on an ID and sequence 170*4882a593Smuzhiyun * 171*4882a593Smuzhiyun * If an active device has this sequence it will be returned. If there is no 172*4882a593Smuzhiyun * such device then this will check for a device that is requesting this 173*4882a593Smuzhiyun * sequence. 174*4882a593Smuzhiyun * 175*4882a593Smuzhiyun * The device is probed to activate it ready for use. 176*4882a593Smuzhiyun * 177*4882a593Smuzhiyun * @id: ID to look up 178*4882a593Smuzhiyun * @seq: Sequence number to find (0=first) 179*4882a593Smuzhiyun * @devp: Returns pointer to device (there is only one for each seq) 180*4882a593Smuzhiyun * @return 0 if OK, -ve on error 181*4882a593Smuzhiyun */ 182*4882a593Smuzhiyun int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp); 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun /** 185*4882a593Smuzhiyun * uclass_get_device_by_of_offset() - Get a uclass device by device tree node 186*4882a593Smuzhiyun * 187*4882a593Smuzhiyun * This searches the devices in the uclass for one attached to the given 188*4882a593Smuzhiyun * device tree node. 189*4882a593Smuzhiyun * 190*4882a593Smuzhiyun * The device is probed to activate it ready for use. 191*4882a593Smuzhiyun * 192*4882a593Smuzhiyun * @id: ID to look up 193*4882a593Smuzhiyun * @node: Device tree offset to search for (if -ve then -ENODEV is returned) 194*4882a593Smuzhiyun * @devp: Returns pointer to device (there is only one for each node) 195*4882a593Smuzhiyun * @return 0 if OK, -ve on error 196*4882a593Smuzhiyun */ 197*4882a593Smuzhiyun int uclass_get_device_by_of_offset(enum uclass_id id, int node, 198*4882a593Smuzhiyun struct udevice **devp); 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun /** 201*4882a593Smuzhiyun * uclass_get_device_by_ofnode() - Get a uclass device by device tree node 202*4882a593Smuzhiyun * 203*4882a593Smuzhiyun * This searches the devices in the uclass for one attached to the given 204*4882a593Smuzhiyun * device tree node. 205*4882a593Smuzhiyun * 206*4882a593Smuzhiyun * The device is probed to activate it ready for use. 207*4882a593Smuzhiyun * 208*4882a593Smuzhiyun * @id: ID to look up 209*4882a593Smuzhiyun * @np: Device tree node to search for (if NULL then -ENODEV is returned) 210*4882a593Smuzhiyun * @devp: Returns pointer to device (there is only one for each node) 211*4882a593Smuzhiyun * @return 0 if OK, -ve on error 212*4882a593Smuzhiyun */ 213*4882a593Smuzhiyun int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node, 214*4882a593Smuzhiyun struct udevice **devp); 215*4882a593Smuzhiyun 216*4882a593Smuzhiyun /** 217*4882a593Smuzhiyun * uclass_get_device_by_phandle_id() - Get a uclass device by phandle id 218*4882a593Smuzhiyun * 219*4882a593Smuzhiyun * This searches the devices in the uclass for one with the given phandle id. 220*4882a593Smuzhiyun * 221*4882a593Smuzhiyun * The device is probed to activate it ready for use. 222*4882a593Smuzhiyun * 223*4882a593Smuzhiyun * @id: uclass ID to look up 224*4882a593Smuzhiyun * @phandle_id: the phandle id to look up 225*4882a593Smuzhiyun * @devp: Returns pointer to device (there is only one for each node) 226*4882a593Smuzhiyun * @return 0 if OK, -ENODEV if there is no device match the phandle, other 227*4882a593Smuzhiyun * -ve on error 228*4882a593Smuzhiyun */ 229*4882a593Smuzhiyun int uclass_get_device_by_phandle_id(enum uclass_id id, uint phandle_id, 230*4882a593Smuzhiyun struct udevice **devp); 231*4882a593Smuzhiyun 232*4882a593Smuzhiyun /** 233*4882a593Smuzhiyun * uclass_get_device_by_phandle() - Get a uclass device by phandle 234*4882a593Smuzhiyun * 235*4882a593Smuzhiyun * This searches the devices in the uclass for one with the given phandle. 236*4882a593Smuzhiyun * 237*4882a593Smuzhiyun * The device is probed to activate it ready for use. 238*4882a593Smuzhiyun * 239*4882a593Smuzhiyun * @id: uclass ID to look up 240*4882a593Smuzhiyun * @parent: Parent device containing the phandle pointer 241*4882a593Smuzhiyun * @name: Name of property in the parent device node 242*4882a593Smuzhiyun * @devp: Returns pointer to device (there is only one for each node) 243*4882a593Smuzhiyun * @return 0 if OK, -ENOENT if there is no @name present in the node, other 244*4882a593Smuzhiyun * -ve on error 245*4882a593Smuzhiyun */ 246*4882a593Smuzhiyun int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent, 247*4882a593Smuzhiyun const char *name, struct udevice **devp); 248*4882a593Smuzhiyun 249*4882a593Smuzhiyun /** 250*4882a593Smuzhiyun * uclass_get_device_by_driver() - Get a uclass device for a driver 251*4882a593Smuzhiyun * 252*4882a593Smuzhiyun * This searches the devices in the uclass for one that uses the given 253*4882a593Smuzhiyun * driver. Use DM_GET_DRIVER(name) for the @drv argument, where 'name' is 254*4882a593Smuzhiyun * the driver name - as used in U_BOOT_DRIVER(name). 255*4882a593Smuzhiyun * 256*4882a593Smuzhiyun * The device is probed to activate it ready for use. 257*4882a593Smuzhiyun * 258*4882a593Smuzhiyun * @id: ID to look up 259*4882a593Smuzhiyun * @drv: Driver to look for 260*4882a593Smuzhiyun * @devp: Returns pointer to the first device with that driver 261*4882a593Smuzhiyun * @return 0 if OK, -ve on error 262*4882a593Smuzhiyun */ 263*4882a593Smuzhiyun int uclass_get_device_by_driver(enum uclass_id id, const struct driver *drv, 264*4882a593Smuzhiyun struct udevice **devp); 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun /** 267*4882a593Smuzhiyun * uclass_first_device() - Get the first device in a uclass 268*4882a593Smuzhiyun * 269*4882a593Smuzhiyun * The device returned is probed if necessary, and ready for use 270*4882a593Smuzhiyun * 271*4882a593Smuzhiyun * This function is useful to start iterating through a list of devices which 272*4882a593Smuzhiyun * are functioning correctly and can be probed. 273*4882a593Smuzhiyun * 274*4882a593Smuzhiyun * @id: Uclass ID to look up 275*4882a593Smuzhiyun * @devp: Returns pointer to the first device in that uclass if no error 276*4882a593Smuzhiyun * occurred, or NULL if there is no first device, or an error occurred with 277*4882a593Smuzhiyun * that device. 278*4882a593Smuzhiyun * @return 0 if OK (found or not found), other -ve on error 279*4882a593Smuzhiyun */ 280*4882a593Smuzhiyun int uclass_first_device(enum uclass_id id, struct udevice **devp); 281*4882a593Smuzhiyun 282*4882a593Smuzhiyun /** 283*4882a593Smuzhiyun * uclass_first_device_err() - Get the first device in a uclass 284*4882a593Smuzhiyun * 285*4882a593Smuzhiyun * The device returned is probed if necessary, and ready for use 286*4882a593Smuzhiyun * 287*4882a593Smuzhiyun * @id: Uclass ID to look up 288*4882a593Smuzhiyun * @devp: Returns pointer to the first device in that uclass, or NULL if none 289*4882a593Smuzhiyun * @return 0 if found, -ENODEV if not found, other -ve on error 290*4882a593Smuzhiyun */ 291*4882a593Smuzhiyun int uclass_first_device_err(enum uclass_id id, struct udevice **devp); 292*4882a593Smuzhiyun 293*4882a593Smuzhiyun /** 294*4882a593Smuzhiyun * uclass_next_device() - Get the next device in a uclass 295*4882a593Smuzhiyun * 296*4882a593Smuzhiyun * The device returned is probed if necessary, and ready for use 297*4882a593Smuzhiyun * 298*4882a593Smuzhiyun * This function is useful to start iterating through a list of devices which 299*4882a593Smuzhiyun * are functioning correctly and can be probed. 300*4882a593Smuzhiyun * 301*4882a593Smuzhiyun * @devp: On entry, pointer to device to lookup. On exit, returns pointer 302*4882a593Smuzhiyun * to the next device in the uclass if no error occurred, or NULL if there is 303*4882a593Smuzhiyun * no next device, or an error occurred with that next device. 304*4882a593Smuzhiyun * @return 0 if OK (found or not found), other -ve on error 305*4882a593Smuzhiyun */ 306*4882a593Smuzhiyun int uclass_next_device(struct udevice **devp); 307*4882a593Smuzhiyun 308*4882a593Smuzhiyun /** 309*4882a593Smuzhiyun * uclass_first_device() - Get the first device in a uclass 310*4882a593Smuzhiyun * 311*4882a593Smuzhiyun * The device returned is probed if necessary, and ready for use 312*4882a593Smuzhiyun * 313*4882a593Smuzhiyun * This function is useful to start iterating through a list of devices which 314*4882a593Smuzhiyun * are functioning correctly and can be probed. 315*4882a593Smuzhiyun * 316*4882a593Smuzhiyun * @id: Uclass ID to look up 317*4882a593Smuzhiyun * @devp: Returns pointer to the first device in that uclass, or NULL if there 318*4882a593Smuzhiyun * is no first device 319*4882a593Smuzhiyun * @return 0 if OK (found or not found), other -ve on error. If an error occurs 320*4882a593Smuzhiyun * it is still possible to move to the next device. 321*4882a593Smuzhiyun */ 322*4882a593Smuzhiyun int uclass_first_device_check(enum uclass_id id, struct udevice **devp); 323*4882a593Smuzhiyun 324*4882a593Smuzhiyun /** 325*4882a593Smuzhiyun * uclass_next_device() - Get the next device in a uclass 326*4882a593Smuzhiyun * 327*4882a593Smuzhiyun * The device returned is probed if necessary, and ready for use 328*4882a593Smuzhiyun * 329*4882a593Smuzhiyun * This function is useful to start iterating through a list of devices which 330*4882a593Smuzhiyun * are functioning correctly and can be probed. 331*4882a593Smuzhiyun * 332*4882a593Smuzhiyun * @devp: On entry, pointer to device to lookup. On exit, returns pointer 333*4882a593Smuzhiyun * to the next device in the uclass if any 334*4882a593Smuzhiyun * @return 0 if OK (found or not found), other -ve on error. If an error occurs 335*4882a593Smuzhiyun * it is still possible to move to the next device. 336*4882a593Smuzhiyun */ 337*4882a593Smuzhiyun int uclass_next_device_check(struct udevice **devp); 338*4882a593Smuzhiyun 339*4882a593Smuzhiyun /** 340*4882a593Smuzhiyun * uclass_resolve_seq() - Resolve a device's sequence number 341*4882a593Smuzhiyun * 342*4882a593Smuzhiyun * On entry dev->seq is -1, and dev->req_seq may be -1 (to allocate a 343*4882a593Smuzhiyun * sequence number automatically, or >= 0 to select a particular number. 344*4882a593Smuzhiyun * If the requested sequence number is in use, then this device will 345*4882a593Smuzhiyun * be allocated another one. 346*4882a593Smuzhiyun * 347*4882a593Smuzhiyun * Note that the device's seq value is not changed by this function. 348*4882a593Smuzhiyun * 349*4882a593Smuzhiyun * @dev: Device for which to allocate sequence number 350*4882a593Smuzhiyun * @return sequence number allocated, or -ve on error 351*4882a593Smuzhiyun */ 352*4882a593Smuzhiyun int uclass_resolve_seq(struct udevice *dev); 353*4882a593Smuzhiyun 354*4882a593Smuzhiyun /** 355*4882a593Smuzhiyun * uclass_foreach_dev() - Helper function to iteration through devices 356*4882a593Smuzhiyun * 357*4882a593Smuzhiyun * This creates a for() loop which works through the available devices in 358*4882a593Smuzhiyun * a uclass in order from start to end. 359*4882a593Smuzhiyun * 360*4882a593Smuzhiyun * @pos: struct udevice * to hold the current device. Set to NULL when there 361*4882a593Smuzhiyun * are no more devices. 362*4882a593Smuzhiyun * @uc: uclass to scan 363*4882a593Smuzhiyun */ 364*4882a593Smuzhiyun #define uclass_foreach_dev(pos, uc) \ 365*4882a593Smuzhiyun list_for_each_entry(pos, &uc->dev_head, uclass_node) 366*4882a593Smuzhiyun 367*4882a593Smuzhiyun /** 368*4882a593Smuzhiyun * uclass_foreach_dev_safe() - Helper function to safely iteration through devs 369*4882a593Smuzhiyun * 370*4882a593Smuzhiyun * This creates a for() loop which works through the available devices in 371*4882a593Smuzhiyun * a uclass in order from start to end. Inside the loop, it is safe to remove 372*4882a593Smuzhiyun * @pos if required. 373*4882a593Smuzhiyun * 374*4882a593Smuzhiyun * @pos: struct udevice * to hold the current device. Set to NULL when there 375*4882a593Smuzhiyun * are no more devices. 376*4882a593Smuzhiyun * @next: struct udevice * to hold the next next 377*4882a593Smuzhiyun * @uc: uclass to scan 378*4882a593Smuzhiyun */ 379*4882a593Smuzhiyun #define uclass_foreach_dev_safe(pos, next, uc) \ 380*4882a593Smuzhiyun list_for_each_entry_safe(pos, next, &uc->dev_head, uclass_node) 381*4882a593Smuzhiyun 382*4882a593Smuzhiyun #endif 383