[PATCH v3] ARM: tegra: expose chip ID and revision
Russell King - ARM Linux
linux at arm.linux.org.uk
Wed Mar 13 06:09:49 EDT 2013
On Wed, Mar 13, 2013 at 05:48:00PM +0800, Danny Huang wrote:
> + soc_dev = soc_device_register(soc_dev_attr);
> + if (IS_ERR(soc_dev)) {
> + kfree(soc_dev_attr->soc_id);
> + kfree(soc_dev_attr->revision);
> + kfree(soc_dev_attr->family);
> + kfree(soc_dev_attr);
> + goto out;
> + }
> +
> + parent = soc_device_to_device(soc_dev);
> + if (IS_ERR(parent))
> + parent = NULL;
I know other places have done this kind of thing but what use is it?
struct device *soc_device_to_device(struct soc_device *soc_dev)
{
return &soc_dev->dev;
}
Now, consider that soc_device_register() returns one of two things:
1. A valid pointer - it must be valid, because soc_device_register()
already dereferences it.
2. An error pointer, trappable with IS_ERR().
You are trapping it with IS_ERR() - that's good news. So, by the time
we get to soc_device_to_device(), we know that it _is_ a valid pointer.
So why would soc_device_to_device() return an error pointer?
More information about the linux-arm-kernel
mailing list