aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/fpga/fpga-region.c
diff options
context:
space:
mode:
authorAlan Tull <atull@kernel.org>2017-11-15 15:20:22 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-28 10:30:38 -0500
commit3b49537f8084af15ccaac542eaf317e01c6869e6 (patch)
tree9c2ca34e564878bad6eccacd57d092c8ab83f5e0 /drivers/fpga/fpga-region.c
parent59460a9305458ac3e7f2415b602dbaa6cfcb8a3b (diff)
fpga: region: rename some functions prior to moving
Rename some functions that will be moved to of-fpga-region.c. Also change some parameters and export a function to help with refactoring. This is a step towards the larger goal of separating device tree support from FPGA region common code. * fpga_region_get_manager -> of_fpga_region_get_mgr * add 'of_' prefix to the following: * fpga_region_find * fpga_region_get_bridges * fpga_region_notify_pre_apply * fpga_region_notify_post_remove), * fpga_region_probe/remove Parameter changes: * of_fpga_region_find change parameter to be the device node of the region. * of_fpga_region_get_bridges change second parameter to FPGA image info. Export of_fpga_region_find as well. Signed-off-by: Alan Tull <atull@kernel.org> Acked-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/fpga/fpga-region.c')
-rw-r--r--drivers/fpga/fpga-region.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
index 402d0b68b97a..92ab21651aeb 100644
--- a/drivers/fpga/fpga-region.c
+++ b/drivers/fpga/fpga-region.c
@@ -42,12 +42,14 @@ static int fpga_region_of_node_match(struct device *dev, const void *data)
42} 42}
43 43
44/** 44/**
45 * fpga_region_find - find FPGA region 45 * of_fpga_region_find - find FPGA region
46 * @np: device node of FPGA Region 46 * @np: device node of FPGA Region
47 *
47 * Caller will need to put_device(&region->dev) when done. 48 * Caller will need to put_device(&region->dev) when done.
49 *
48 * Returns FPGA Region struct or NULL 50 * Returns FPGA Region struct or NULL
49 */ 51 */
50static struct fpga_region *fpga_region_find(struct device_node *np) 52static struct fpga_region *of_fpga_region_find(struct device_node *np)
51{ 53{
52 struct device *dev; 54 struct device *dev;
53 55
@@ -107,7 +109,7 @@ static void fpga_region_put(struct fpga_region *region)
107} 109}
108 110
109/** 111/**
110 * fpga_region_get_manager - get reference for FPGA manager 112 * of_fpga_region_get_mgr - get reference for FPGA manager
111 * @np: device node of FPGA region 113 * @np: device node of FPGA region
112 * 114 *
113 * Get FPGA Manager from "fpga-mgr" property or from ancestor region. 115 * Get FPGA Manager from "fpga-mgr" property or from ancestor region.
@@ -116,7 +118,7 @@ static void fpga_region_put(struct fpga_region *region)
116 * 118 *
117 * Return: fpga manager struct or IS_ERR() condition containing error code. 119 * Return: fpga manager struct or IS_ERR() condition containing error code.
118 */ 120 */
119static struct fpga_manager *fpga_region_get_manager(struct device_node *np) 121static struct fpga_manager *of_fpga_region_get_mgr(struct device_node *np)
120{ 122{
121 struct device_node *mgr_node; 123 struct device_node *mgr_node;
122 struct fpga_manager *mgr; 124 struct fpga_manager *mgr;
@@ -139,9 +141,9 @@ static struct fpga_manager *fpga_region_get_manager(struct device_node *np)
139} 141}
140 142
141/** 143/**
142 * fpga_region_get_bridges - create a list of bridges 144 * of_fpga_region_get_bridges - create a list of bridges
143 * @region: FPGA region 145 * @region: FPGA region
144 * @overlay: device node of the overlay 146 * @info: FPGA image info
145 * 147 *
146 * Create a list of bridges including the parent bridge and the bridges 148 * Create a list of bridges including the parent bridge and the bridges
147 * specified by "fpga-bridges" property. Note that the 149 * specified by "fpga-bridges" property. Note that the
@@ -154,8 +156,8 @@ static struct fpga_manager *fpga_region_get_manager(struct device_node *np)
154 * Return 0 for success (even if there are no bridges specified) 156 * Return 0 for success (even if there are no bridges specified)
155 * or -EBUSY if any of the bridges are in use. 157 * or -EBUSY if any of the bridges are in use.
156 */ 158 */
157static int fpga_region_get_bridges(struct fpga_region *region, 159static int of_fpga_region_get_bridges(struct fpga_region *region,
158 struct device_node *overlay) 160 struct fpga_image_info *info)
159{ 161{
160 struct device *dev = &region->dev; 162 struct device *dev = &region->dev;
161 struct device_node *region_np = dev->of_node; 163 struct device_node *region_np = dev->of_node;
@@ -163,7 +165,7 @@ static int fpga_region_get_bridges(struct fpga_region *region,
163 int i, ret; 165 int i, ret;
164 166
165 /* If parent is a bridge, add to list */ 167 /* If parent is a bridge, add to list */
166 ret = of_fpga_bridge_get_to_list(region_np->parent, region->info, 168 ret = of_fpga_bridge_get_to_list(region_np->parent, info,
167 &region->bridge_list); 169 &region->bridge_list);
168 170
169 /* -EBUSY means parent is a bridge that is under use. Give up. */ 171 /* -EBUSY means parent is a bridge that is under use. Give up. */
@@ -175,8 +177,8 @@ static int fpga_region_get_bridges(struct fpga_region *region,
175 parent_br = region_np->parent; 177 parent_br = region_np->parent;
176 178
177 /* If overlay has a list of bridges, use it. */ 179 /* If overlay has a list of bridges, use it. */
178 if (of_parse_phandle(overlay, "fpga-bridges", 0)) 180 if (of_parse_phandle(info->overlay, "fpga-bridges", 0))
179 np = overlay; 181 np = info->overlay;
180 else 182 else
181 np = region_np; 183 np = region_np;
182 184
@@ -227,7 +229,7 @@ int fpga_region_program_fpga(struct fpga_region *region)
227 goto err_put_region; 229 goto err_put_region;
228 } 230 }
229 231
230 ret = fpga_region_get_bridges(region, info->overlay); 232 ret = of_fpga_region_get_bridges(region, info);
231 if (ret) { 233 if (ret) {
232 dev_err(dev, "failed to get FPGA bridges\n"); 234 dev_err(dev, "failed to get FPGA bridges\n");
233 goto err_unlock_mgr; 235 goto err_unlock_mgr;
@@ -397,7 +399,7 @@ ret_no_info:
397} 399}
398 400
399/** 401/**
400 * fpga_region_notify_pre_apply - pre-apply overlay notification 402 * of_fpga_region_notify_pre_apply - pre-apply overlay notification
401 * 403 *
402 * @region: FPGA region that the overlay was applied to 404 * @region: FPGA region that the overlay was applied to
403 * @nd: overlay notification data 405 * @nd: overlay notification data
@@ -410,8 +412,8 @@ ret_no_info:
410 * 412 *
411 * Returns 0 for success or negative error code for failure. 413 * Returns 0 for success or negative error code for failure.
412 */ 414 */
413static int fpga_region_notify_pre_apply(struct fpga_region *region, 415static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
414 struct of_overlay_notify_data *nd) 416 struct of_overlay_notify_data *nd)
415{ 417{
416 struct device *dev = &region->dev; 418 struct device *dev = &region->dev;
417 struct fpga_image_info *info; 419 struct fpga_image_info *info;
@@ -441,7 +443,7 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
441} 443}
442 444
443/** 445/**
444 * fpga_region_notify_post_remove - post-remove overlay notification 446 * of_fpga_region_notify_post_remove - post-remove overlay notification
445 * 447 *
446 * @region: FPGA region that was targeted by the overlay that was removed 448 * @region: FPGA region that was targeted by the overlay that was removed
447 * @nd: overlay notification data 449 * @nd: overlay notification data
@@ -449,8 +451,8 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
449 * Called after an overlay has been removed if the overlay's target was a 451 * Called after an overlay has been removed if the overlay's target was a
450 * FPGA region. 452 * FPGA region.
451 */ 453 */
452static void fpga_region_notify_post_remove(struct fpga_region *region, 454static void of_fpga_region_notify_post_remove(struct fpga_region *region,
453 struct of_overlay_notify_data *nd) 455 struct of_overlay_notify_data *nd)
454{ 456{
455 fpga_bridges_disable(&region->bridge_list); 457 fpga_bridges_disable(&region->bridge_list);
456 fpga_bridges_put(&region->bridge_list); 458 fpga_bridges_put(&region->bridge_list);
@@ -493,18 +495,18 @@ static int of_fpga_region_notify(struct notifier_block *nb,
493 return NOTIFY_OK; 495 return NOTIFY_OK;
494 } 496 }
495 497
496 region = fpga_region_find(nd->target); 498 region = of_fpga_region_find(nd->target);
497 if (!region) 499 if (!region)
498 return NOTIFY_OK; 500 return NOTIFY_OK;
499 501
500 ret = 0; 502 ret = 0;
501 switch (action) { 503 switch (action) {
502 case OF_OVERLAY_PRE_APPLY: 504 case OF_OVERLAY_PRE_APPLY:
503 ret = fpga_region_notify_pre_apply(region, nd); 505 ret = of_fpga_region_notify_pre_apply(region, nd);
504 break; 506 break;
505 507
506 case OF_OVERLAY_POST_REMOVE: 508 case OF_OVERLAY_POST_REMOVE:
507 fpga_region_notify_post_remove(region, nd); 509 of_fpga_region_notify_post_remove(region, nd);
508 break; 510 break;
509 } 511 }
510 512
@@ -520,7 +522,7 @@ static struct notifier_block fpga_region_of_nb = {
520 .notifier_call = of_fpga_region_notify, 522 .notifier_call = of_fpga_region_notify,
521}; 523};
522 524
523static int fpga_region_probe(struct platform_device *pdev) 525static int of_fpga_region_probe(struct platform_device *pdev)
524{ 526{
525 struct device *dev = &pdev->dev; 527 struct device *dev = &pdev->dev;
526 struct device_node *np = dev->of_node; 528 struct device_node *np = dev->of_node;
@@ -528,7 +530,7 @@ static int fpga_region_probe(struct platform_device *pdev)
528 struct fpga_manager *mgr; 530 struct fpga_manager *mgr;
529 int id, ret = 0; 531 int id, ret = 0;
530 532
531 mgr = fpga_region_get_manager(np); 533 mgr = of_fpga_region_get_mgr(np);
532 if (IS_ERR(mgr)) 534 if (IS_ERR(mgr))
533 return -EPROBE_DEFER; 535 return -EPROBE_DEFER;
534 536
@@ -580,7 +582,7 @@ err_put_mgr:
580 return ret; 582 return ret;
581} 583}
582 584
583static int fpga_region_remove(struct platform_device *pdev) 585static int of_fpga_region_remove(struct platform_device *pdev)
584{ 586{
585 struct fpga_region *region = platform_get_drvdata(pdev); 587 struct fpga_region *region = platform_get_drvdata(pdev);
586 588
@@ -590,9 +592,9 @@ static int fpga_region_remove(struct platform_device *pdev)
590 return 0; 592 return 0;
591} 593}
592 594
593static struct platform_driver fpga_region_driver = { 595static struct platform_driver of_fpga_region_driver = {
594 .probe = fpga_region_probe, 596 .probe = of_fpga_region_probe,
595 .remove = fpga_region_remove, 597 .remove = of_fpga_region_remove,
596 .driver = { 598 .driver = {
597 .name = "fpga-region", 599 .name = "fpga-region",
598 .of_match_table = of_match_ptr(fpga_region_of_match), 600 .of_match_table = of_match_ptr(fpga_region_of_match),
@@ -625,7 +627,7 @@ static int __init fpga_region_init(void)
625 if (ret) 627 if (ret)
626 goto err_class; 628 goto err_class;
627 629
628 ret = platform_driver_register(&fpga_region_driver); 630 ret = platform_driver_register(&of_fpga_region_driver);
629 if (ret) 631 if (ret)
630 goto err_plat; 632 goto err_plat;
631 633
@@ -641,7 +643,7 @@ err_class:
641 643
642static void __exit fpga_region_exit(void) 644static void __exit fpga_region_exit(void)
643{ 645{
644 platform_driver_unregister(&fpga_region_driver); 646 platform_driver_unregister(&of_fpga_region_driver);
645 of_overlay_notifier_unregister(&fpga_region_of_nb); 647 of_overlay_notifier_unregister(&fpga_region_of_nb);
646 class_destroy(fpga_region_class); 648 class_destroy(fpga_region_class);
647 ida_destroy(&fpga_region_ida); 649 ida_destroy(&fpga_region_ida);