Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm: rcar-du: Use __free() to simplify device_node handling

Replace manual of_node_put() calls with __free(). This simplifies error
handling code and makes it less bug-prone.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://patch.msgid.link/20260323164526.2292491-4-laurent.pinchart+renesas@ideasonboard.com
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

authored by

Laurent Pinchart and committed by
Tomi Valkeinen
a93b8739 0f6f28c8

+7 -18
+7 -18
drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
··· 19 19 #include <drm/drm_probe_helper.h> 20 20 #include <drm/drm_vblank.h> 21 21 22 + #include <linux/cleanup.h> 22 23 #include <linux/device.h> 23 24 #include <linux/dma-buf.h> 24 25 #include <linux/of.h> ··· 574 573 enum rcar_du_output output, 575 574 struct of_endpoint *ep) 576 575 { 577 - struct device_node *entity; 576 + struct device_node *entity __free(device_node) = NULL; 578 577 int ret; 579 578 580 579 /* Locate the connected entity and initialize the encoder. */ ··· 589 588 dev_dbg(rcdu->dev, 590 589 "connected entity %pOF is disabled, skipping\n", 591 590 entity); 592 - of_node_put(entity); 593 591 return -ENODEV; 594 592 } 595 593 ··· 598 598 "failed to initialize encoder %pOF on output %s (%d), skipping\n", 599 599 entity, rcar_du_output_name(output), ret); 600 600 601 - of_node_put(entity); 602 - 603 601 return ret; 604 602 } 605 603 606 604 static int rcar_du_encoders_init(struct rcar_du_device *rcdu) 607 605 { 606 + struct device_node *ep_node __free(device_node) = NULL; 608 607 struct device_node *np = rcdu->dev->of_node; 609 - struct device_node *ep_node; 610 608 unsigned int num_encoders = 0; 611 609 612 610 /* ··· 618 620 int ret; 619 621 620 622 ret = of_graph_parse_endpoint(ep_node, &ep); 621 - if (ret < 0) { 622 - of_node_put(ep_node); 623 + if (ret < 0) 623 624 return ret; 624 - } 625 625 626 626 /* Find the output route corresponding to the port number. */ 627 627 for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) { ··· 640 644 /* Process the output pipeline. */ 641 645 ret = rcar_du_encoders_init_one(rcdu, output, &ep); 642 646 if (ret < 0) { 643 - if (ret == -EPROBE_DEFER) { 644 - of_node_put(ep_node); 647 + if (ret == -EPROBE_DEFER) 645 648 return ret; 646 - } 647 649 648 650 continue; 649 651 } ··· 769 775 } 770 776 771 777 for (i = 0; i < cells; ++i) { 778 + struct device_node *cmm __free(device_node) = NULL; 772 779 struct platform_device *pdev; 773 780 struct device_link *link; 774 - struct device_node *cmm; 775 781 int ret; 776 782 777 783 cmm = of_parse_phandle(np, "renesas,cmms", i); ··· 781 787 return -EINVAL; 782 788 } 783 789 784 - if (!of_device_is_available(cmm)) { 790 + if (!of_device_is_available(cmm)) 785 791 /* It's fine to have a phandle to a non-enabled CMM. */ 786 - of_node_put(cmm); 787 792 continue; 788 - } 789 793 790 794 pdev = of_find_device_by_node(cmm); 791 795 if (!pdev) { 792 796 dev_err(rcdu->dev, "No device found for CMM%u\n", i); 793 - of_node_put(cmm); 794 797 return -EINVAL; 795 798 } 796 - 797 - of_node_put(cmm); 798 799 799 800 /* 800 801 * -ENODEV is used to report that the CMM config option is