Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit ee291f75 authored by Vaishnav Achath's avatar Vaishnav Achath Committed by Robert Nelson
Browse files

serdev: add of_ helper to get serdev controller


add of_find_serdev_controller_by_node to obtain a
serdev_controller from the device_node, which
can help if the serdev_device is not described
over device tree and instantiation of the device
happens from a different driver, for the same purpose
an option to not delete an empty serdev controller
is added.

Signed-off-by: default avatarVaishnav M A <vaishnav@beagleboard.org>
parent a779141f
No related merge requests found
...@@ -582,6 +582,17 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl) ...@@ -582,6 +582,17 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
return 0; return 0;
} }
struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node)
{
struct device *dev = bus_find_device_by_of_node(&serdev_bus_type, node);
if (!dev)
return NULL;
return (dev->type == &serdev_ctrl_type) ? to_serdev_controller(dev) : NULL;
}
EXPORT_SYMBOL_GPL(of_find_serdev_controller_by_node);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
#define SERDEV_ACPI_MAX_SCAN_DEPTH 32 #define SERDEV_ACPI_MAX_SCAN_DEPTH 32
...@@ -779,6 +790,12 @@ int serdev_controller_add(struct serdev_controller *ctrl) ...@@ -779,6 +790,12 @@ int serdev_controller_add(struct serdev_controller *ctrl)
pm_runtime_enable(&ctrl->dev); pm_runtime_enable(&ctrl->dev);
/* provide option to not delete a serdev controller without devices
* if property is present
*/
if (device_property_present(&ctrl->dev, "force-empty-serdev-controller"))
return 0;
ret_of = of_serdev_register_devices(ctrl); ret_of = of_serdev_register_devices(ctrl);
ret_acpi = acpi_serdev_register_devices(ctrl); ret_acpi = acpi_serdev_register_devices(ctrl);
if (ret_of && ret_acpi) { if (ret_of && ret_acpi) {
......
...@@ -115,6 +115,8 @@ static inline struct serdev_controller *to_serdev_controller(struct device *d) ...@@ -115,6 +115,8 @@ static inline struct serdev_controller *to_serdev_controller(struct device *d)
return container_of(d, struct serdev_controller, dev); return container_of(d, struct serdev_controller, dev);
} }
struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node);
static inline void *serdev_device_get_drvdata(const struct serdev_device *serdev) static inline void *serdev_device_get_drvdata(const struct serdev_device *serdev)
{ {
return dev_get_drvdata(&serdev->dev); return dev_get_drvdata(&serdev->dev);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment