/* device_free() - Free memory buffers allocated by a device @dev: Device that is to be started  */
void device_free(struct udevice *dev)
/* device_free() - Free memory buffers allocated by a device @dev: Device that is to be started  */
void device_free(struct udevice *dev)
{
	int size;
	if (dev->driver->priv_auto_alloc_size) {
		free(dev->priv);
		dev->priv = NULL;
	}
	size = dev->uclass->uc_drv->per_device_auto_alloc_size;
	if (size) {
		free(dev->uclass_priv);
		dev->uclass_priv = NULL;
	}
	if (dev->parent) {
		size = dev->parent->driver->per_child_auto_alloc_size;
		if (!size) {
			size = dev->parent->uclass->uc_drv->
					per_child_auto_alloc_size;
		}
		if (size) {
			free(dev->parent_priv);
			dev->parent_priv = NULL;
		}
	}
	devres_release_probe(dev);
}