diff options
author | Suman Anna <s-anna@ti.com> | 2018-07-11 19:42:12 -0400 |
---|---|---|
committer | Jassi Brar <jaswinder.singh@linaro.org> | 2018-08-03 09:27:15 -0400 |
commit | ea2ec1e80f78e5f1d6bd04315a2a0bf0646d8548 (patch) | |
tree | 5913dfa3afd83d7e3f8fab56d263ece1c0f9322e | |
parent | 2ad5157650b446f14a719280ba3670303bc4f439 (diff) |
mailbox/omap: use of_device_get_match_data() to get match data
The OMAP Mailbox driver is directly using an integer value as
match data for distinguishing the interrupt register layout
between OMAP2 and OMAP4+ SoCs. Introduce a dedicated structure
for storing this match data, and simplify the probe function by
using the of_device_get_match_data() function. This allows the
driver to scale for 64-bit platforms by eliminating the unnecessary
type-casting between a u32 and a void pointer types.
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
-rw-r--r-- | drivers/mailbox/omap-mailbox.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index 97c7d9b7f46f..db66e952a871 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c | |||
@@ -69,6 +69,10 @@ struct omap_mbox_queue { | |||
69 | bool full; | 69 | bool full; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | struct omap_mbox_match_data { | ||
73 | u32 intr_type; | ||
74 | }; | ||
75 | |||
72 | struct omap_mbox_device { | 76 | struct omap_mbox_device { |
73 | struct device *dev; | 77 | struct device *dev; |
74 | struct mutex cfg_lock; | 78 | struct mutex cfg_lock; |
@@ -638,18 +642,21 @@ static const struct dev_pm_ops omap_mbox_pm_ops = { | |||
638 | SET_SYSTEM_SLEEP_PM_OPS(omap_mbox_suspend, omap_mbox_resume) | 642 | SET_SYSTEM_SLEEP_PM_OPS(omap_mbox_suspend, omap_mbox_resume) |
639 | }; | 643 | }; |
640 | 644 | ||
645 | static const struct omap_mbox_match_data omap2_data = { MBOX_INTR_CFG_TYPE1 }; | ||
646 | static const struct omap_mbox_match_data omap4_data = { MBOX_INTR_CFG_TYPE2 }; | ||
647 | |||
641 | static const struct of_device_id omap_mailbox_of_match[] = { | 648 | static const struct of_device_id omap_mailbox_of_match[] = { |
642 | { | 649 | { |
643 | .compatible = "ti,omap2-mailbox", | 650 | .compatible = "ti,omap2-mailbox", |
644 | .data = (void *)MBOX_INTR_CFG_TYPE1, | 651 | .data = &omap2_data, |
645 | }, | 652 | }, |
646 | { | 653 | { |
647 | .compatible = "ti,omap3-mailbox", | 654 | .compatible = "ti,omap3-mailbox", |
648 | .data = (void *)MBOX_INTR_CFG_TYPE1, | 655 | .data = &omap2_data, |
649 | }, | 656 | }, |
650 | { | 657 | { |
651 | .compatible = "ti,omap4-mailbox", | 658 | .compatible = "ti,omap4-mailbox", |
652 | .data = (void *)MBOX_INTR_CFG_TYPE2, | 659 | .data = &omap4_data, |
653 | }, | 660 | }, |
654 | { | 661 | { |
655 | /* end */ | 662 | /* end */ |
@@ -692,7 +699,7 @@ static int omap_mbox_probe(struct platform_device *pdev) | |||
692 | struct omap_mbox_fifo *fifo; | 699 | struct omap_mbox_fifo *fifo; |
693 | struct device_node *node = pdev->dev.of_node; | 700 | struct device_node *node = pdev->dev.of_node; |
694 | struct device_node *child; | 701 | struct device_node *child; |
695 | const struct of_device_id *match; | 702 | const struct omap_mbox_match_data *match_data; |
696 | u32 intr_type, info_count; | 703 | u32 intr_type, info_count; |
697 | u32 num_users, num_fifos; | 704 | u32 num_users, num_fifos; |
698 | u32 tmp[3]; | 705 | u32 tmp[3]; |
@@ -704,10 +711,10 @@ static int omap_mbox_probe(struct platform_device *pdev) | |||
704 | return -ENODEV; | 711 | return -ENODEV; |
705 | } | 712 | } |
706 | 713 | ||
707 | match = of_match_device(omap_mailbox_of_match, &pdev->dev); | 714 | match_data = of_device_get_match_data(&pdev->dev); |
708 | if (!match) | 715 | if (!match_data) |
709 | return -ENODEV; | 716 | return -ENODEV; |
710 | intr_type = (u32)match->data; | 717 | intr_type = match_data->intr_type; |
711 | 718 | ||
712 | if (of_property_read_u32(node, "ti,mbox-num-users", &num_users)) | 719 | if (of_property_read_u32(node, "ti,mbox-num-users", &num_users)) |
713 | return -ENODEV; | 720 | return -ENODEV; |