MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bus_helper_reset_prepare

Function bus_helper_reset_prepare

freebsd/kern/subr_bus.c:3931–3962  ·  view source on GitHub ↗

* @brief Helper function for implementing BUS_RESET_PREPARE * * Bus can use this function to implement common operations of * detaching or suspending the children before the bus itself is * reset, and then save bus-unique state of children that must * persists around reset. * * @param dev The bus * #param flags DEVF_RESET_* */

Source from the content-addressed store, hash-verified

3929 * #param flags DEVF_RESET_*
3930 */
3931int
3932bus_helper_reset_prepare(device_t dev, int flags)
3933{
3934 device_t child;
3935 int error;
3936
3937 if (dev->state != DS_ATTACHED)
3938 return (EBUSY);
3939
3940 TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
3941 if ((flags & DEVF_RESET_DETACH) != 0) {
3942 error = device_get_state(child) == DS_ATTACHED ?
3943 device_detach(child) : 0;
3944 } else {
3945 error = BUS_SUSPEND_CHILD(dev, child);
3946 }
3947 if (error == 0) {
3948 error = BUS_RESET_PREPARE(dev, child);
3949 if (error != 0) {
3950 if ((flags & DEVF_RESET_DETACH) != 0)
3951 device_probe_and_attach(child);
3952 else
3953 BUS_RESUME_CHILD(dev, child);
3954 }
3955 }
3956 if (error != 0) {
3957 bus_helper_reset_prepare_rollback(dev, child, flags);
3958 return (error);
3959 }
3960 }
3961 return (0);
3962}
3963
3964/**
3965 * @brief Helper function for implementing BUS_PRINT_CHILD().

Callers

nothing calls this directly

Calls 4

device_get_stateFunction · 0.85
device_detachFunction · 0.85
device_probe_and_attachFunction · 0.85

Tested by

no test coverage detected