[PATCH v4 5/6] extcon: add possibility to get extcon device by OF node
andy.shevchenko at gmail.com
Wed Feb 21 06:27:11 PST 2018
On Wed, Feb 21, 2018 at 10:55 AM, Andrzej Hajda <a.hajda at samsung.com> wrote:
> Since extcon property is not allowed in DT, extcon subsystem requires
> another way to get extcon device. Lets try the simplest approach - get
> edev by of_node.
> + * extcon_get_edev_by_of_node - Get the extcon device from devicetree.
> + * @node : OF node identyfying edev
> + *
> + * Return the pointer of extcon device if success or ERR_PTR(err) if fail.
> + */
> +struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node)
First of all, the all other similar cases use "_by_node" in the name.
Second, it's not _get_, it's _find_.
> + struct extcon_dev *edev;
> + mutex_lock(&extcon_dev_list_lock);
> + list_for_each_entry(edev, &extcon_dev_list, entry)
> + if (edev->dev.parent && edev->dev.parent->of_node == node)
> + goto out;
> + edev = ERR_PTR(-EPROBE_DEFER);
> + mutex_unlock(&extcon_dev_list_lock);
> + return edev;
Can't it be done using bus_find_device()?
See good example in i2c-core-of.c
With Best Regards,
More information about the linux-arm-kernel