diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-11-05 04:39:59 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-12-02 01:54:34 -0500 |
commit | 58452341265844d830ef5d0e705ee7577461bc45 (patch) | |
tree | ea9dfc486230a2d455f64e298130522a072e46ab /drivers/video/omap2/dss/overlay.c | |
parent | 6e53ca9dda65dd300ce150822832ba6e169643c7 (diff) |
OMAPDSS: store overlays in an array
Overlays are stored in a linked list. There's no need for this list, as
an array would do just as fine.
This patch changes the code to use an array for overlays.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video/omap2/dss/overlay.c')
-rw-r--r-- | drivers/video/omap2/dss/overlay.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/video/omap2/dss/overlay.c b/drivers/video/omap2/dss/overlay.c index 0ab14fa9d907..ccd6127d2eef 100644 --- a/drivers/video/omap2/dss/overlay.c +++ b/drivers/video/omap2/dss/overlay.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "dss_features.h" | 38 | #include "dss_features.h" |
39 | 39 | ||
40 | static int num_overlays; | 40 | static int num_overlays; |
41 | static struct list_head overlay_list; | 41 | static struct omap_overlay *overlays; |
42 | 42 | ||
43 | static ssize_t overlay_name_show(struct omap_overlay *ovl, char *buf) | 43 | static ssize_t overlay_name_show(struct omap_overlay *ovl, char *buf) |
44 | { | 44 | { |
@@ -610,24 +610,13 @@ EXPORT_SYMBOL(omap_dss_get_num_overlays); | |||
610 | 610 | ||
611 | struct omap_overlay *omap_dss_get_overlay(int num) | 611 | struct omap_overlay *omap_dss_get_overlay(int num) |
612 | { | 612 | { |
613 | int i = 0; | 613 | if (num >= num_overlays) |
614 | struct omap_overlay *ovl; | 614 | return NULL; |
615 | 615 | ||
616 | list_for_each_entry(ovl, &overlay_list, list) { | 616 | return &overlays[num]; |
617 | if (i++ == num) | ||
618 | return ovl; | ||
619 | } | ||
620 | |||
621 | return NULL; | ||
622 | } | 617 | } |
623 | EXPORT_SYMBOL(omap_dss_get_overlay); | 618 | EXPORT_SYMBOL(omap_dss_get_overlay); |
624 | 619 | ||
625 | static void omap_dss_add_overlay(struct omap_overlay *overlay) | ||
626 | { | ||
627 | ++num_overlays; | ||
628 | list_add_tail(&overlay->list, &overlay_list); | ||
629 | } | ||
630 | |||
631 | static struct omap_overlay *dispc_overlays[MAX_DSS_OVERLAYS]; | 620 | static struct omap_overlay *dispc_overlays[MAX_DSS_OVERLAYS]; |
632 | 621 | ||
633 | void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr) | 622 | void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr) |
@@ -640,15 +629,15 @@ void dss_init_overlays(struct platform_device *pdev) | |||
640 | { | 629 | { |
641 | int i, r; | 630 | int i, r; |
642 | 631 | ||
643 | INIT_LIST_HEAD(&overlay_list); | 632 | num_overlays = dss_feat_get_num_ovls(); |
644 | 633 | ||
645 | num_overlays = 0; | 634 | overlays = kzalloc(sizeof(struct omap_overlay) * num_overlays, |
635 | GFP_KERNEL); | ||
646 | 636 | ||
647 | for (i = 0; i < dss_feat_get_num_ovls(); ++i) { | 637 | BUG_ON(overlays == NULL); |
648 | struct omap_overlay *ovl; | ||
649 | ovl = kzalloc(sizeof(*ovl), GFP_KERNEL); | ||
650 | 638 | ||
651 | BUG_ON(ovl == NULL); | 639 | for (i = 0; i < num_overlays; ++i) { |
640 | struct omap_overlay *ovl = &overlays[i]; | ||
652 | 641 | ||
653 | switch (i) { | 642 | switch (i) { |
654 | case 0: | 643 | case 0: |
@@ -690,15 +679,11 @@ void dss_init_overlays(struct platform_device *pdev) | |||
690 | ovl->supported_modes = | 679 | ovl->supported_modes = |
691 | dss_feat_get_supported_color_modes(ovl->id); | 680 | dss_feat_get_supported_color_modes(ovl->id); |
692 | 681 | ||
693 | omap_dss_add_overlay(ovl); | ||
694 | |||
695 | r = kobject_init_and_add(&ovl->kobj, &overlay_ktype, | 682 | r = kobject_init_and_add(&ovl->kobj, &overlay_ktype, |
696 | &pdev->dev.kobj, "overlay%d", i); | 683 | &pdev->dev.kobj, "overlay%d", i); |
697 | 684 | ||
698 | if (r) { | 685 | if (r) |
699 | DSSERR("failed to create sysfs file\n"); | 686 | DSSERR("failed to create sysfs file\n"); |
700 | continue; | ||
701 | } | ||
702 | 687 | ||
703 | dispc_overlays[i] = ovl; | 688 | dispc_overlays[i] = ovl; |
704 | } | 689 | } |
@@ -765,17 +750,17 @@ void dss_recheck_connections(struct omap_dss_device *dssdev, bool force) | |||
765 | 750 | ||
766 | void dss_uninit_overlays(struct platform_device *pdev) | 751 | void dss_uninit_overlays(struct platform_device *pdev) |
767 | { | 752 | { |
768 | struct omap_overlay *ovl; | 753 | int i; |
754 | |||
755 | for (i = 0; i < num_overlays; ++i) { | ||
756 | struct omap_overlay *ovl = &overlays[i]; | ||
769 | 757 | ||
770 | while (!list_empty(&overlay_list)) { | ||
771 | ovl = list_first_entry(&overlay_list, | ||
772 | struct omap_overlay, list); | ||
773 | list_del(&ovl->list); | ||
774 | kobject_del(&ovl->kobj); | 758 | kobject_del(&ovl->kobj); |
775 | kobject_put(&ovl->kobj); | 759 | kobject_put(&ovl->kobj); |
776 | kfree(ovl); | ||
777 | } | 760 | } |
778 | 761 | ||
762 | kfree(overlays); | ||
763 | overlays = NULL; | ||
779 | num_overlays = 0; | 764 | num_overlays = 0; |
780 | } | 765 | } |
781 | 766 | ||