diff options
author | Arun Kumar K <arun.kk@samsung.com> | 2013-01-18 13:42:34 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-05 14:32:52 -0500 |
commit | 6e83e6e25eb49dc57a69b3f8ecc1e764c9775101 (patch) | |
tree | 3e70dad972ae097059af269eba7b17671c5679ef | |
parent | e82564475eab196b2e8a11572fff8e268329530e (diff) |
[media] s5p-mfc: Fix kernel warning on memory init
Cleaned up the memory devices allocation code and added
missing device_initialize() call to remove the kernel warning
during memory allocations.
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/platform/s5p-mfc/s5p_mfc.c | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 5050168ad211..3669e3b933ca 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c | |||
@@ -1014,6 +1014,46 @@ static int match_child(struct device *dev, void *data) | |||
1014 | 1014 | ||
1015 | static void *mfc_get_drv_data(struct platform_device *pdev); | 1015 | static void *mfc_get_drv_data(struct platform_device *pdev); |
1016 | 1016 | ||
1017 | static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) | ||
1018 | { | ||
1019 | unsigned int mem_info[2]; | ||
1020 | |||
1021 | dev->mem_dev_l = devm_kzalloc(&dev->plat_dev->dev, | ||
1022 | sizeof(struct device), GFP_KERNEL); | ||
1023 | if (!dev->mem_dev_l) { | ||
1024 | mfc_err("Not enough memory\n"); | ||
1025 | return -ENOMEM; | ||
1026 | } | ||
1027 | device_initialize(dev->mem_dev_l); | ||
1028 | of_property_read_u32_array(dev->plat_dev->dev.of_node, | ||
1029 | "samsung,mfc-l", mem_info, 2); | ||
1030 | if (dma_declare_coherent_memory(dev->mem_dev_l, mem_info[0], | ||
1031 | mem_info[0], mem_info[1], | ||
1032 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) { | ||
1033 | mfc_err("Failed to declare coherent memory for\n" | ||
1034 | "MFC device\n"); | ||
1035 | return -ENOMEM; | ||
1036 | } | ||
1037 | |||
1038 | dev->mem_dev_r = devm_kzalloc(&dev->plat_dev->dev, | ||
1039 | sizeof(struct device), GFP_KERNEL); | ||
1040 | if (!dev->mem_dev_r) { | ||
1041 | mfc_err("Not enough memory\n"); | ||
1042 | return -ENOMEM; | ||
1043 | } | ||
1044 | device_initialize(dev->mem_dev_r); | ||
1045 | of_property_read_u32_array(dev->plat_dev->dev.of_node, | ||
1046 | "samsung,mfc-r", mem_info, 2); | ||
1047 | if (dma_declare_coherent_memory(dev->mem_dev_r, mem_info[0], | ||
1048 | mem_info[0], mem_info[1], | ||
1049 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) { | ||
1050 | pr_err("Failed to declare coherent memory for\n" | ||
1051 | "MFC device\n"); | ||
1052 | return -ENOMEM; | ||
1053 | } | ||
1054 | return 0; | ||
1055 | } | ||
1056 | |||
1017 | /* MFC probe function */ | 1057 | /* MFC probe function */ |
1018 | static int s5p_mfc_probe(struct platform_device *pdev) | 1058 | static int s5p_mfc_probe(struct platform_device *pdev) |
1019 | { | 1059 | { |
@@ -1021,7 +1061,6 @@ static int s5p_mfc_probe(struct platform_device *pdev) | |||
1021 | struct video_device *vfd; | 1061 | struct video_device *vfd; |
1022 | struct resource *res; | 1062 | struct resource *res; |
1023 | int ret; | 1063 | int ret; |
1024 | unsigned int mem_info[2]; | ||
1025 | 1064 | ||
1026 | pr_debug("%s++\n", __func__); | 1065 | pr_debug("%s++\n", __func__); |
1027 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); | 1066 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); |
@@ -1069,39 +1108,8 @@ static int s5p_mfc_probe(struct platform_device *pdev) | |||
1069 | } | 1108 | } |
1070 | 1109 | ||
1071 | if (pdev->dev.of_node) { | 1110 | if (pdev->dev.of_node) { |
1072 | dev->mem_dev_l = kzalloc(sizeof(struct device), GFP_KERNEL); | 1111 | if (s5p_mfc_alloc_memdevs(dev) < 0) |
1073 | if (!dev->mem_dev_l) { | ||
1074 | mfc_err("Not enough memory\n"); | ||
1075 | ret = -ENOMEM; | ||
1076 | goto err_res; | ||
1077 | } | ||
1078 | of_property_read_u32_array(pdev->dev.of_node, "samsung,mfc-l", | ||
1079 | mem_info, 2); | ||
1080 | if (dma_declare_coherent_memory(dev->mem_dev_l, mem_info[0], | ||
1081 | mem_info[0], mem_info[1], | ||
1082 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) { | ||
1083 | mfc_err("Failed to declare coherent memory for\n" | ||
1084 | "MFC device\n"); | ||
1085 | ret = -ENOMEM; | ||
1086 | goto err_res; | 1112 | goto err_res; |
1087 | } | ||
1088 | |||
1089 | dev->mem_dev_r = kzalloc(sizeof(struct device), GFP_KERNEL); | ||
1090 | if (!dev->mem_dev_r) { | ||
1091 | mfc_err("Not enough memory\n"); | ||
1092 | ret = -ENOMEM; | ||
1093 | goto err_res; | ||
1094 | } | ||
1095 | of_property_read_u32_array(pdev->dev.of_node, "samsung,mfc-r", | ||
1096 | mem_info, 2); | ||
1097 | if (dma_declare_coherent_memory(dev->mem_dev_r, mem_info[0], | ||
1098 | mem_info[0], mem_info[1], | ||
1099 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) { | ||
1100 | pr_err("Failed to declare coherent memory for\n" | ||
1101 | "MFC device\n"); | ||
1102 | ret = -ENOMEM; | ||
1103 | goto err_res; | ||
1104 | } | ||
1105 | } else { | 1113 | } else { |
1106 | dev->mem_dev_l = device_find_child(&dev->plat_dev->dev, | 1114 | dev->mem_dev_l = device_find_child(&dev->plat_dev->dev, |
1107 | "s5p-mfc-l", match_child); | 1115 | "s5p-mfc-l", match_child); |
@@ -1247,6 +1255,10 @@ static int s5p_mfc_remove(struct platform_device *pdev) | |||
1247 | s5p_mfc_release_firmware(dev); | 1255 | s5p_mfc_release_firmware(dev); |
1248 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]); | 1256 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]); |
1249 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[1]); | 1257 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[1]); |
1258 | if (pdev->dev.of_node) { | ||
1259 | put_device(dev->mem_dev_l); | ||
1260 | put_device(dev->mem_dev_r); | ||
1261 | } | ||
1250 | 1262 | ||
1251 | s5p_mfc_final_pm(dev); | 1263 | s5p_mfc_final_pm(dev); |
1252 | return 0; | 1264 | return 0; |