diff options
author | Vinod Koul <vinod.koul@intel.com> | 2018-01-31 03:20:40 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2018-01-31 03:20:40 -0500 |
commit | 2cb1800ccf257a541f7e25975f14abd292fe5d65 (patch) | |
tree | cf2fe9ef4bda174f8532adc592d3d37e6b3c269e | |
parent | c203f677c0f6926351b26bc3fdef24236c7b8644 (diff) | |
parent | 37fa4905d22a903f9fe120016fe7d6a2ece8d736 (diff) |
Merge branch 'topic/qcom_hidma' into for-linus
-rw-r--r-- | drivers/dma/qcom/hidma_mgmt.c | 61 |
1 files changed, 15 insertions, 46 deletions
diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c index 7335e2eb9b72..000c7019ca7d 100644 --- a/drivers/dma/qcom/hidma_mgmt.c +++ b/drivers/dma/qcom/hidma_mgmt.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/acpi.h> | 17 | #include <linux/acpi.h> |
18 | #include <linux/of.h> | 18 | #include <linux/of.h> |
19 | #include <linux/property.h> | 19 | #include <linux/property.h> |
20 | #include <linux/of_address.h> | ||
20 | #include <linux/of_irq.h> | 21 | #include <linux/of_irq.h> |
21 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
22 | #include <linux/module.h> | 23 | #include <linux/module.h> |
@@ -356,67 +357,37 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np) | |||
356 | { | 357 | { |
357 | struct platform_device *pdev_parent = of_find_device_by_node(np); | 358 | struct platform_device *pdev_parent = of_find_device_by_node(np); |
358 | struct platform_device_info pdevinfo; | 359 | struct platform_device_info pdevinfo; |
359 | struct of_phandle_args out_irq; | ||
360 | struct device_node *child; | 360 | struct device_node *child; |
361 | struct resource *res = NULL; | 361 | struct resource *res; |
362 | const __be32 *cell; | 362 | int ret = 0; |
363 | int ret = 0, size, i, num; | 363 | |
364 | u64 addr, addr_size; | 364 | /* allocate a resource array */ |
365 | res = kcalloc(3, sizeof(*res), GFP_KERNEL); | ||
366 | if (!res) | ||
367 | return -ENOMEM; | ||
365 | 368 | ||
366 | for_each_available_child_of_node(np, child) { | 369 | for_each_available_child_of_node(np, child) { |
367 | struct resource *res_iter; | ||
368 | struct platform_device *new_pdev; | 370 | struct platform_device *new_pdev; |
369 | 371 | ||
370 | cell = of_get_property(child, "reg", &size); | 372 | ret = of_address_to_resource(child, 0, &res[0]); |
371 | if (!cell) { | 373 | if (!ret) |
372 | ret = -EINVAL; | ||
373 | goto out; | 374 | goto out; |
374 | } | ||
375 | |||
376 | size /= sizeof(*cell); | ||
377 | num = size / | ||
378 | (of_n_addr_cells(child) + of_n_size_cells(child)) + 1; | ||
379 | 375 | ||
380 | /* allocate a resource array */ | 376 | ret = of_address_to_resource(child, 1, &res[1]); |
381 | res = kcalloc(num, sizeof(*res), GFP_KERNEL); | 377 | if (!ret) |
382 | if (!res) { | ||
383 | ret = -ENOMEM; | ||
384 | goto out; | 378 | goto out; |
385 | } | ||
386 | |||
387 | /* read each reg value */ | ||
388 | i = 0; | ||
389 | res_iter = res; | ||
390 | while (i < size) { | ||
391 | addr = of_read_number(&cell[i], | ||
392 | of_n_addr_cells(child)); | ||
393 | i += of_n_addr_cells(child); | ||
394 | |||
395 | addr_size = of_read_number(&cell[i], | ||
396 | of_n_size_cells(child)); | ||
397 | i += of_n_size_cells(child); | ||
398 | |||
399 | res_iter->start = addr; | ||
400 | res_iter->end = res_iter->start + addr_size - 1; | ||
401 | res_iter->flags = IORESOURCE_MEM; | ||
402 | res_iter++; | ||
403 | } | ||
404 | 379 | ||
405 | ret = of_irq_parse_one(child, 0, &out_irq); | 380 | ret = of_irq_to_resource(child, 0, &res[2]); |
406 | if (ret) | 381 | if (ret <= 0) |
407 | goto out; | 382 | goto out; |
408 | 383 | ||
409 | res_iter->start = irq_create_of_mapping(&out_irq); | ||
410 | res_iter->name = "hidma event irq"; | ||
411 | res_iter->flags = IORESOURCE_IRQ; | ||
412 | |||
413 | memset(&pdevinfo, 0, sizeof(pdevinfo)); | 384 | memset(&pdevinfo, 0, sizeof(pdevinfo)); |
414 | pdevinfo.fwnode = &child->fwnode; | 385 | pdevinfo.fwnode = &child->fwnode; |
415 | pdevinfo.parent = pdev_parent ? &pdev_parent->dev : NULL; | 386 | pdevinfo.parent = pdev_parent ? &pdev_parent->dev : NULL; |
416 | pdevinfo.name = child->name; | 387 | pdevinfo.name = child->name; |
417 | pdevinfo.id = object_counter++; | 388 | pdevinfo.id = object_counter++; |
418 | pdevinfo.res = res; | 389 | pdevinfo.res = res; |
419 | pdevinfo.num_res = num; | 390 | pdevinfo.num_res = 3; |
420 | pdevinfo.data = NULL; | 391 | pdevinfo.data = NULL; |
421 | pdevinfo.size_data = 0; | 392 | pdevinfo.size_data = 0; |
422 | pdevinfo.dma_mask = DMA_BIT_MASK(64); | 393 | pdevinfo.dma_mask = DMA_BIT_MASK(64); |
@@ -434,8 +405,6 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np) | |||
434 | */ | 405 | */ |
435 | of_msi_configure(&new_pdev->dev, child); | 406 | of_msi_configure(&new_pdev->dev, child); |
436 | of_node_put(child); | 407 | of_node_put(child); |
437 | kfree(res); | ||
438 | res = NULL; | ||
439 | } | 408 | } |
440 | out: | 409 | out: |
441 | kfree(res); | 410 | kfree(res); |