Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_bus.c
Show First 20 Lines • Show All 3,858 Lines • ▼ Show 20 Lines | bus_generic_resume(device_t dev) | ||||
TAILQ_FOREACH(child, &dev->children, link) { | TAILQ_FOREACH(child, &dev->children, link) { | ||||
BUS_RESUME_CHILD(dev, child); | BUS_RESUME_CHILD(dev, child); | ||||
/* if resume fails, there's nothing we can usefully do... */ | /* if resume fails, there's nothing we can usefully do... */ | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
int | |||||
jhb: Doxygen comments for the new non-static functions would be consistent with the rest of this… | |||||
bus_helper_reset_post(device_t dev, int flags) | |||||
{ | |||||
device_t child; | |||||
int error, error1; | |||||
error = 0; | |||||
TAILQ_FOREACH(child, &dev->children,link) { | |||||
BUS_RESET_POST(dev, child); | |||||
error1 = (flags & DEVF_RESET_DETACH) != 0 ? | |||||
device_probe_and_attach(child) : | |||||
Not Done Inline ActionsThere's code in device_probe which is called from device_probe_and_attach that handles the device being attached properly. It returns -1 which is translated to return 0 which is what you want here. It seems like this check shouldn't be needed, so I'll ask: What is Is the reason you've added the check here and elsewhere? imp: There's code in device_probe which is called from device_probe_and_attach that handles the… | |||||
Done Inline ActionsI removed the checks for DS_ATTACHED before device_probe_and_attach() calls. kib: I removed the checks for DS_ATTACHED before device_probe_and_attach() calls. | |||||
BUS_RESUME_CHILD(dev, child); | |||||
if (error == 0 && error1 != 0) | |||||
error = error1; | |||||
} | |||||
return (error); | |||||
} | |||||
static void | |||||
bus_helper_reset_prepare_rollback(device_t dev, device_t child, int flags) | |||||
{ | |||||
child = TAILQ_NEXT(child, link); | |||||
if (child == NULL) | |||||
return; | |||||
TAILQ_FOREACH_FROM(child, &dev->children,link) { | |||||
BUS_RESET_POST(dev, child); | |||||
if ((flags & DEVF_RESET_DETACH) != 0) | |||||
device_probe_and_attach(child); | |||||
else | |||||
BUS_RESUME_CHILD(dev, child); | |||||
} | |||||
} | |||||
int | |||||
bus_helper_reset_prepare(device_t dev, int flags) | |||||
{ | |||||
device_t child; | |||||
int error; | |||||
if (dev->state != DS_ATTACHED) | |||||
return (EBUSY); | |||||
TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) { | |||||
if ((flags & DEVF_RESET_DETACH) != 0) { | |||||
error = device_get_state(child) == DS_ATTACHED ? | |||||
device_detach(child) : 0; | |||||
} else { | |||||
error = BUS_SUSPEND_CHILD(dev, child); | |||||
} | |||||
if (error == 0) { | |||||
error = BUS_RESET_PREPARE(dev, child); | |||||
if (error != 0) { | |||||
if ((flags & DEVF_RESET_DETACH) != 0) | |||||
device_probe_and_attach(child); | |||||
else | |||||
BUS_RESUME_CHILD(dev, child); | |||||
} | |||||
} | |||||
if (error != 0) { | |||||
bus_helper_reset_prepare_rollback(dev, child, flags); | |||||
return (error); | |||||
} | |||||
} | |||||
return (0); | |||||
} | |||||
/** | /** | ||||
* @brief Helper function for implementing BUS_PRINT_CHILD(). | * @brief Helper function for implementing BUS_PRINT_CHILD(). | ||||
* | * | ||||
* This function prints the first part of the ascii representation of | * This function prints the first part of the ascii representation of | ||||
* @p child, including its name, unit and description (if any - see | * @p child, including its name, unit and description (if any - see | ||||
* device_set_desc()). | * device_set_desc()). | ||||
* | * | ||||
* @returns the number of characters printed | * @returns the number of characters printed | ||||
▲ Show 20 Lines • Show All 1,676 Lines • ▼ Show 20 Lines | devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, | ||||
case DEV_ENABLE: | case DEV_ENABLE: | ||||
case DEV_DISABLE: | case DEV_DISABLE: | ||||
case DEV_SUSPEND: | case DEV_SUSPEND: | ||||
case DEV_RESUME: | case DEV_RESUME: | ||||
case DEV_SET_DRIVER: | case DEV_SET_DRIVER: | ||||
case DEV_CLEAR_DRIVER: | case DEV_CLEAR_DRIVER: | ||||
case DEV_RESCAN: | case DEV_RESCAN: | ||||
case DEV_DELETE: | case DEV_DELETE: | ||||
case DEV_RESET: | |||||
error = priv_check(td, PRIV_DRIVER); | error = priv_check(td, PRIV_DRIVER); | ||||
if (error == 0) | if (error == 0) | ||||
error = find_device(req, &dev); | error = find_device(req, &dev); | ||||
break; | break; | ||||
case DEV_FREEZE: | case DEV_FREEZE: | ||||
case DEV_THAW: | case DEV_THAW: | ||||
error = priv_check(td, PRIV_DRIVER); | error = priv_check(td, PRIV_DRIVER); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | case DEV_FREEZE: | ||||
break; | break; | ||||
case DEV_THAW: | case DEV_THAW: | ||||
if (!device_frozen) | if (!device_frozen) | ||||
error = EBUSY; | error = EBUSY; | ||||
else { | else { | ||||
device_do_deferred_actions(); | device_do_deferred_actions(); | ||||
device_frozen = false; | device_frozen = false; | ||||
} | } | ||||
break; | |||||
case DEV_RESET: | |||||
if ((req->dr_flags & ~(DEVF_RESET_DETACH)) != 0) { | |||||
error = EINVAL; | |||||
break; | |||||
} | |||||
error = BUS_RESET_CHILD(device_get_parent(dev), dev, | |||||
req->dr_flags); | |||||
break; | break; | ||||
} | } | ||||
mtx_unlock(&Giant); | mtx_unlock(&Giant); | ||||
return (error); | return (error); | ||||
} | } | ||||
static struct cdevsw devctl2_cdevsw = { | static struct cdevsw devctl2_cdevsw = { | ||||
.d_version = D_VERSION, | .d_version = D_VERSION, | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |
Doxygen comments for the new non-static functions would be consistent with the rest of this file. Sorry I didn't notice that earlier. If you add them, no need for me to review them.