diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-11-05 04:44:48 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-12-02 01:54:34 -0500 |
commit | 5617ad097959cb39b96d08af0a9b3d51215deaba (patch) | |
tree | 547cf7ece86dc063ca6b0f143405e258099a3681 /drivers/video | |
parent | 58452341265844d830ef5d0e705ee7577461bc45 (diff) |
OMAPDSS: store managers in an array
Overlay managers 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 overlay managers.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/omap2/dss/manager.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/video/omap2/dss/manager.c b/drivers/video/omap2/dss/manager.c index 780a307c815e..a08cc6e7f5ca 100644 --- a/drivers/video/omap2/dss/manager.c +++ b/drivers/video/omap2/dss/manager.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "dss_features.h" | 34 | #include "dss_features.h" |
35 | 35 | ||
36 | static int num_managers; | 36 | static int num_managers; |
37 | static struct list_head manager_list; | 37 | static struct omap_overlay_manager *managers; |
38 | 38 | ||
39 | static ssize_t manager_name_show(struct omap_overlay_manager *mgr, char *buf) | 39 | static ssize_t manager_name_show(struct omap_overlay_manager *mgr, char *buf) |
40 | { | 40 | { |
@@ -585,25 +585,19 @@ static void omap_dss_mgr_get_info(struct omap_overlay_manager *mgr, | |||
585 | *info = mgr->info; | 585 | *info = mgr->info; |
586 | } | 586 | } |
587 | 587 | ||
588 | static void omap_dss_add_overlay_manager(struct omap_overlay_manager *manager) | ||
589 | { | ||
590 | ++num_managers; | ||
591 | list_add_tail(&manager->list, &manager_list); | ||
592 | } | ||
593 | |||
594 | int dss_init_overlay_managers(struct platform_device *pdev) | 588 | int dss_init_overlay_managers(struct platform_device *pdev) |
595 | { | 589 | { |
596 | int i, r; | 590 | int i, r; |
597 | 591 | ||
598 | INIT_LIST_HEAD(&manager_list); | 592 | num_managers = dss_feat_get_num_mgrs(); |
599 | 593 | ||
600 | num_managers = 0; | 594 | managers = kzalloc(sizeof(struct omap_overlay_manager) * num_managers, |
595 | GFP_KERNEL); | ||
601 | 596 | ||
602 | for (i = 0; i < dss_feat_get_num_mgrs(); ++i) { | 597 | BUG_ON(managers == NULL); |
603 | struct omap_overlay_manager *mgr; | ||
604 | mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); | ||
605 | 598 | ||
606 | BUG_ON(mgr == NULL); | 599 | for (i = 0; i < num_managers; ++i) { |
600 | struct omap_overlay_manager *mgr = &managers[i]; | ||
607 | 601 | ||
608 | switch (i) { | 602 | switch (i) { |
609 | case 0: | 603 | case 0: |
@@ -634,15 +628,11 @@ int dss_init_overlay_managers(struct platform_device *pdev) | |||
634 | 628 | ||
635 | dss_overlay_setup_dispc_manager(mgr); | 629 | dss_overlay_setup_dispc_manager(mgr); |
636 | 630 | ||
637 | omap_dss_add_overlay_manager(mgr); | ||
638 | |||
639 | r = kobject_init_and_add(&mgr->kobj, &manager_ktype, | 631 | r = kobject_init_and_add(&mgr->kobj, &manager_ktype, |
640 | &pdev->dev.kobj, "manager%d", i); | 632 | &pdev->dev.kobj, "manager%d", i); |
641 | 633 | ||
642 | if (r) { | 634 | if (r) |
643 | DSSERR("failed to create sysfs file\n"); | 635 | DSSERR("failed to create sysfs file\n"); |
644 | continue; | ||
645 | } | ||
646 | } | 636 | } |
647 | 637 | ||
648 | return 0; | 638 | return 0; |
@@ -650,17 +640,17 @@ int dss_init_overlay_managers(struct platform_device *pdev) | |||
650 | 640 | ||
651 | void dss_uninit_overlay_managers(struct platform_device *pdev) | 641 | void dss_uninit_overlay_managers(struct platform_device *pdev) |
652 | { | 642 | { |
653 | struct omap_overlay_manager *mgr; | 643 | int i; |
644 | |||
645 | for (i = 0; i < num_managers; ++i) { | ||
646 | struct omap_overlay_manager *mgr = &managers[i]; | ||
654 | 647 | ||
655 | while (!list_empty(&manager_list)) { | ||
656 | mgr = list_first_entry(&manager_list, | ||
657 | struct omap_overlay_manager, list); | ||
658 | list_del(&mgr->list); | ||
659 | kobject_del(&mgr->kobj); | 648 | kobject_del(&mgr->kobj); |
660 | kobject_put(&mgr->kobj); | 649 | kobject_put(&mgr->kobj); |
661 | kfree(mgr); | ||
662 | } | 650 | } |
663 | 651 | ||
652 | kfree(managers); | ||
653 | managers = NULL; | ||
664 | num_managers = 0; | 654 | num_managers = 0; |
665 | } | 655 | } |
666 | 656 | ||
@@ -672,15 +662,10 @@ EXPORT_SYMBOL(omap_dss_get_num_overlay_managers); | |||
672 | 662 | ||
673 | struct omap_overlay_manager *omap_dss_get_overlay_manager(int num) | 663 | struct omap_overlay_manager *omap_dss_get_overlay_manager(int num) |
674 | { | 664 | { |
675 | int i = 0; | 665 | if (num >= num_managers) |
676 | struct omap_overlay_manager *mgr; | 666 | return NULL; |
677 | |||
678 | list_for_each_entry(mgr, &manager_list, list) { | ||
679 | if (i++ == num) | ||
680 | return mgr; | ||
681 | } | ||
682 | 667 | ||
683 | return NULL; | 668 | return &managers[num]; |
684 | } | 669 | } |
685 | EXPORT_SYMBOL(omap_dss_get_overlay_manager); | 670 | EXPORT_SYMBOL(omap_dss_get_overlay_manager); |
686 | 671 | ||