* @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). */
| 3084 | * device (e.g. to wire a device to a pre-configured unit number). |
| 3085 | */ |
| 3086 | int |
| 3087 | device_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 | /* |
nothing calls this directly
no test coverage detected