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/atmel-hlcdc: use managed device resources for the display controller

Take benefit of managed device resources to reduce the risk of memory
leak and to simplify error paths.

Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
Link: https://patch.msgid.link/20251218-lcd_cleanup_mainline-v2-1-df837aba878f@microchip.com
Signed-off-by: Manikandan Muralidharan <manikandan.m@microchip.com>

authored by

Ludovic Desroches and committed by
Manikandan Muralidharan
950cba98 ce76a267

+13 -13
+12 -13
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
··· 751 751 return 0; 752 752 } 753 753 754 + static struct atmel_hlcdc_dc *atmel_hlcdc_dc_of_dev(struct drm_device *dev) 755 + { 756 + return container_of(dev, struct atmel_hlcdc_dc, dev); 757 + } 758 + 754 759 static int atmel_hlcdc_dc_load(struct drm_device *dev) 755 760 { 756 761 struct platform_device *pdev = to_platform_device(dev->dev); 757 762 const struct of_device_id *match; 758 - struct atmel_hlcdc_dc *dc; 763 + struct atmel_hlcdc_dc *dc = atmel_hlcdc_dc_of_dev(dev); 759 764 int ret; 760 765 761 766 match = of_match_node(atmel_hlcdc_of_match, dev->dev->parent->of_node); ··· 773 768 dev_err(&pdev->dev, "invalid hlcdc description\n"); 774 769 return -EINVAL; 775 770 } 776 - 777 - dc = devm_kzalloc(dev->dev, sizeof(*dc), GFP_KERNEL); 778 - if (!dc) 779 - return -ENOMEM; 780 771 781 772 dc->desc = match->data; 782 773 dc->hlcdc = dev_get_drvdata(dev->dev->parent); ··· 854 853 855 854 static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev) 856 855 { 856 + struct atmel_hlcdc_dc *dc; 857 857 struct drm_device *ddev; 858 858 int ret; 859 859 860 - ddev = drm_dev_alloc(&atmel_hlcdc_dc_driver, &pdev->dev); 861 - if (IS_ERR(ddev)) 862 - return PTR_ERR(ddev); 860 + dc = devm_drm_dev_alloc(&pdev->dev, &atmel_hlcdc_dc_driver, struct atmel_hlcdc_dc, dev); 861 + if (IS_ERR(dc)) 862 + return PTR_ERR(dc); 863 + ddev = &dc->dev; 863 864 864 865 ret = atmel_hlcdc_dc_load(ddev); 865 866 if (ret) 866 - goto err_put; 867 + return ret; 867 868 868 869 ret = drm_dev_register(ddev, 0); 869 870 if (ret) ··· 878 875 err_unload: 879 876 atmel_hlcdc_dc_unload(ddev); 880 877 881 - err_put: 882 - drm_dev_put(ddev); 883 - 884 878 return ret; 885 879 } 886 880 ··· 887 887 888 888 drm_dev_unregister(ddev); 889 889 atmel_hlcdc_dc_unload(ddev); 890 - drm_dev_put(ddev); 891 890 } 892 891 893 892 static void atmel_hlcdc_dc_drm_shutdown(struct platform_device *pdev)
+1
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
··· 350 350 struct dma_pool *dscrpool; 351 351 struct atmel_hlcdc *hlcdc; 352 352 struct drm_crtc *crtc; 353 + struct drm_device dev; 353 354 struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS]; 354 355 struct { 355 356 u32 imr;