Hi! > My implementation has two primary goals: > > 1.) To help device drivers track and control their device's power state > > 2.) To bubble power state dependency changes from a leaf node to the > last affected parent node in the chain. > > The basic unit of the tree is referred to as a "pm_node". Each > "pm_node" has a list of states it supports, a current state, and a > driver to handle state transitions. Any "pm_node" can have children and > therefore act as a power container. > > struct pm_state { > char *name; > unsigned long index; > unsigned long link_req; > void *link_data; > }; > > "index" is a driver specific value that indicates the state. "link_req" > is a set of flags that indicate requirements from the parent "pm_node". > "link_data" provides additional requirement information. > > struct pm_node { > struct semaphore sem; > struct list_head children; > struct list_head child_list; > struct pm_node *parent; > struct pm_node *tmp_path; > struct device *dev; > > struct pm_node_driver *drv; > unsigned int current_state; > unsigned int target_state; Would not it be cleaner to have struct pm_state *current_state, target state? > "states" is a list of power states sorted from most functional to least > functional. "current_state" and "target_state" are index values for > that list. > > struct pm_node_driver { > int (*set_state) (struct pm_node *node); > int (*raise_event) (struct pm_node *domain, > struct pm_node *child, > unsigned long *new_state); struct pm_state here, too? > void (*lower_event) (struct pm_node *domain); > }; > > "raise_event" notifies the power domain when a child has increased its "Increase" == went more power hungry? > I apologize for the unpolished/untested state of the code as it's > primarily intended to illustrate a concept. I'll need to look over the > problem more carefully if we decide this is the right direction. Power Seems ok to me. -- 64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms