Skip to content

Commit 946540a

Browse files
committed
drm/panel: use fwnode based lookups for panel followers
Use firmware node based lookups for panel followers, to make the code independent of OF and device tree, and make it work also for ACPI with an appropriate _DSD. ASL example: Package (0x02) { "panel", \_SB.PCI0.GFX0.LCD0 } v2: - Update comments (Doug, Arun) - s/IS_ERR_OR_NULL/IS_ERR/ (Doug) Suggested-by: Heikki Krogerus <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Jessica Zhang <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Doug Anderson <[email protected]> Cc: Lee Shawn C <[email protected]> Tested-by: Lee Shawn C <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Tested-by: Douglas Anderson <[email protected]> Reviewed-by: Arun R Murthy <[email protected]> Acked-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jani Nikula <[email protected]>
1 parent edcc9d2 commit 946540a

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

drivers/gpu/drm/drm_panel.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,40 @@ int of_drm_get_panel_orientation(const struct device_node *np,
473473
EXPORT_SYMBOL(of_drm_get_panel_orientation);
474474
#endif
475475

476-
static struct drm_panel *of_find_panel(struct device *follower_dev)
476+
/* Find panel by fwnode. This should be identical to of_drm_find_panel(). */
477+
static struct drm_panel *find_panel_by_fwnode(const struct fwnode_handle *fwnode)
477478
{
478-
struct device_node *panel_np;
479479
struct drm_panel *panel;
480480

481-
panel_np = of_parse_phandle(follower_dev->of_node, "panel", 0);
482-
if (!panel_np)
481+
if (!fwnode_device_is_available(fwnode))
483482
return ERR_PTR(-ENODEV);
484483

485-
panel = of_drm_find_panel(panel_np);
486-
of_node_put(panel_np);
484+
mutex_lock(&panel_lock);
485+
486+
list_for_each_entry(panel, &panel_list, list) {
487+
if (dev_fwnode(panel->dev) == fwnode) {
488+
mutex_unlock(&panel_lock);
489+
return panel;
490+
}
491+
}
492+
493+
mutex_unlock(&panel_lock);
494+
495+
return ERR_PTR(-EPROBE_DEFER);
496+
}
497+
498+
/* Find panel by follower device */
499+
static struct drm_panel *find_panel_by_dev(struct device *follower_dev)
500+
{
501+
struct fwnode_handle *fwnode;
502+
struct drm_panel *panel;
503+
504+
fwnode = fwnode_find_reference(dev_fwnode(follower_dev), "panel", 0);
505+
if (IS_ERR(fwnode))
506+
return ERR_PTR(-ENODEV);
507+
508+
panel = find_panel_by_fwnode(fwnode);
509+
fwnode_handle_put(fwnode);
487510

488511
return panel;
489512
}
@@ -494,7 +517,7 @@ static struct drm_panel *of_find_panel(struct device *follower_dev)
494517
*
495518
* This checks to see if a device needs to be power sequenced together with
496519
* a panel using the panel follower API.
497-
* At the moment panels can only be followed on device tree enabled systems.
520+
*
498521
* The "panel" property of the follower points to the panel to be followed.
499522
*
500523
* Return: true if we should be power sequenced with a panel; false otherwise.
@@ -506,7 +529,7 @@ bool drm_is_panel_follower(struct device *dev)
506529
* don't bother trying to parse it here. We just need to know if the
507530
* property is there.
508531
*/
509-
return of_property_present(dev->of_node, "panel");
532+
return device_property_present(dev, "panel");
510533
}
511534
EXPORT_SYMBOL(drm_is_panel_follower);
512535

@@ -523,7 +546,6 @@ EXPORT_SYMBOL(drm_is_panel_follower);
523546
* If a follower is added to a panel that's already been turned on, the
524547
* follower's prepare callback is called right away.
525548
*
526-
* At the moment panels can only be followed on device tree enabled systems.
527549
* The "panel" property of the follower points to the panel to be followed.
528550
*
529551
* Return: 0 or an error code. Note that -ENODEV means that we detected that
@@ -536,7 +558,7 @@ int drm_panel_add_follower(struct device *follower_dev,
536558
struct drm_panel *panel;
537559
int ret;
538560

539-
panel = of_find_panel(follower_dev);
561+
panel = find_panel_by_dev(follower_dev);
540562
if (IS_ERR(panel))
541563
return PTR_ERR(panel);
542564

0 commit comments

Comments
 (0)