I have a device tree like below :
&bus {
child_1 : childNode@50 {
cell-index = <0>;
..........
status "ok";
};
child_2 : childNode@70 {
cell-index = <1>;
..........
status "ok";
};
};
In my child driver i’ll be needing Parent’s handle before child driver is binded to its Parent that is “bus”.
Why i need Parent handle ?
I have a requirement that when “child_1” or “child_2” driver is starting to probe i need to keep the parent or master driver “bus” in High power State by calling power management API’s and for that reason, i need Parent’s Device handle. So, that i can call below Kernel API’s
pm_runtime_getsync(struct device *bus_handle); /Here “bus_handle” is handle to “bus”(parent) device/
……….Once the child device probe is completed…..will call below to make parent to suspend….
pm_runtime_putsync(struct device *bus_handle);
For this am checking if there is any device tree calls exisit to fetch the Parent’s struct device* handle
I do see this : struct device_node *parent_node = of_get_parent(child_node);
And again i need to convert this parent_node type to struct device. Before that i need to check if there is any cleaner way to do that ?