/* This is called once the reference count for the object reaches 0. We forward the call to the device's release method, which should handle actually freeing the structure.  */
static void device_release(struct kobject *kobj)
/* This is called once the reference count for the object reaches 0. We forward the call to the device's release method, which should handle actually freeing the structure.  */
static void device_release(struct kobject *kobj)
{
	struct device *dev = to_dev(kobj);
	struct device_private *p = dev->p;
	if (dev->release)
		dev->release(dev);
	else if (dev->type && dev->type->release)
		dev->type->release(dev);
	else if (dev->class && dev->class->dev_release)
		dev->class->dev_release(dev);
	else
		WARN(1, KERN_ERR "Device '%s' does not have a release() "
			"function, it is broken and must be fixed.\n",
			dev_name(dev));
	kfree(p);
}