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

Function device_set_unit

freebsd/kern/subr_bus.c:3086–3105  ·  view source on GitHub ↗

* @brief Set the unit number of a device * * This function can be used to override the unit number used for a * device (e.g. to wire a device to a pre-configured unit number). */

Source from the content-addressed store, hash-verified

3084 * device (e.g. to wire a device to a pre-configured unit number).
3085 */
3086int
3087device_set_unit(device_t dev, int unit)
3088{
3089 devclass_t dc;
3090 int err;
3091
3092 dc = device_get_devclass(dev);
3093 if (unit < dc->maxunit && dc->devices[unit])
3094 return (EBUSY);
3095 err = devclass_delete_device(dc, dev);
3096 if (err)
3097 return (err);
3098 dev->unit = unit;
3099 err = devclass_add_device(dc, dev);
3100 if (err)
3101 return (err);
3102
3103 bus_data_generation_update();
3104 return (0);
3105}
3106
3107/*======================================*/
3108/*

Callers

nothing calls this directly

Calls 4

device_get_devclassFunction · 0.85
devclass_delete_deviceFunction · 0.85
devclass_add_deviceFunction · 0.85

Tested by

no test coverage detected