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

media: mgb4: Fix debugfs error handling

Fix broken handling of debugfs_create_dir() errors including errors
creating the parent mgb4(PCIe) device's debugfs directory.

Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Martin Tůma and committed by
Hans Verkuil
9d31522a 45103196

+22 -40
+2 -6
drivers/media/pci/mgb4/mgb4_core.c
··· 582 582 NULL); 583 583 #endif 584 584 585 - #ifdef CONFIG_DEBUG_FS 586 585 mgbdev->debugfs = debugfs_create_dir(dev_name(&pdev->dev), NULL); 587 - #endif 588 586 589 587 /* Get card serial number. On systems without MTD flash support we may 590 588 * get an error thus ignore the return value. An invalid serial number ··· 644 646 hwmon_device_unregister(mgbdev->hwmon_dev); 645 647 #endif 646 648 649 + debugfs_remove_recursive(mgbdev->debugfs); 650 + 647 651 if (mgbdev->indio_dev) 648 652 mgb4_trigger_free(mgbdev->indio_dev); 649 653 ··· 655 655 for (i = 0; i < MGB4_VIN_DEVICES; i++) 656 656 if (mgbdev->vin[i]) 657 657 mgb4_vin_free(mgbdev->vin[i]); 658 - 659 - #ifdef CONFIG_DEBUG_FS 660 - debugfs_remove_recursive(mgbdev->debugfs); 661 - #endif 662 658 663 659 device_remove_groups(&mgbdev->pdev->dev, mgb4_pci_groups); 664 660 free_spi(mgbdev);
-2
drivers/media/pci/mgb4/mgb4_core.h
··· 68 68 u8 module_version; 69 69 u32 serial_number; 70 70 71 - #ifdef CONFIG_DEBUG_FS 72 71 struct dentry *debugfs; 73 - #endif 74 72 }; 75 73 76 74 #endif
+10 -15
drivers/media/pci/mgb4/mgb4_vin.c
··· 853 853 mgb4_write_reg(video, regs->config, 1U << 9); 854 854 } 855 855 856 - #ifdef CONFIG_DEBUG_FS 857 - static void debugfs_init(struct mgb4_vin_dev *vindev) 856 + static void create_debugfs(struct mgb4_vin_dev *vindev) 858 857 { 858 + #ifdef CONFIG_DEBUG_FS 859 859 struct mgb4_regs *video = &vindev->mgbdev->video; 860 + struct dentry *entry; 860 861 861 - vindev->debugfs = debugfs_create_dir(vindev->vdev.name, 862 - vindev->mgbdev->debugfs); 863 - if (!vindev->debugfs) 862 + if (IS_ERR_OR_NULL(vindev->mgbdev->debugfs)) 863 + return; 864 + entry = debugfs_create_dir(vindev->vdev.name, vindev->mgbdev->debugfs); 865 + if (IS_ERR(entry)) 864 866 return; 865 867 866 868 vindev->regs[0].name = "CONFIG"; ··· 894 892 vindev->regset.base = video->membase; 895 893 vindev->regset.regs = vindev->regs; 896 894 897 - debugfs_create_regset32("registers", 0444, vindev->debugfs, 898 - &vindev->regset); 899 - } 895 + debugfs_create_regset32("registers", 0444, entry, &vindev->regset); 900 896 #endif 897 + } 901 898 902 899 struct mgb4_vin_dev *mgb4_vin_create(struct mgb4_dev *mgbdev, int id) 903 900 { ··· 1002 1001 goto err_video_dev; 1003 1002 } 1004 1003 1005 - #ifdef CONFIG_DEBUG_FS 1006 - debugfs_init(vindev); 1007 - #endif 1004 + create_debugfs(vindev); 1008 1005 1009 1006 return vindev; 1010 1007 ··· 1032 1033 1033 1034 free_irq(vin_irq, vindev); 1034 1035 free_irq(err_irq, vindev); 1035 - 1036 - #ifdef CONFIG_DEBUG_FS 1037 - debugfs_remove_recursive(vindev->debugfs); 1038 - #endif 1039 1036 1040 1037 groups = MGB4_IS_GMSL(vindev->mgbdev) 1041 1038 ? mgb4_gmsl_in_groups : mgb4_fpdl3_in_groups;
-1
drivers/media/pci/mgb4/mgb4_vin.h
··· 58 58 const struct mgb4_vin_config *config; 59 59 60 60 #ifdef CONFIG_DEBUG_FS 61 - struct dentry *debugfs; 62 61 struct debugfs_regset32 regset; 63 62 struct debugfs_reg32 regs[sizeof(struct mgb4_vin_regs) / 4]; 64 63 #endif
+10 -15
drivers/media/pci/mgb4/mgb4_vout.c
··· 676 676 (voutdev->config->id + MGB4_VIN_DEVICES) << 2 | 1 << 4); 677 677 } 678 678 679 - #ifdef CONFIG_DEBUG_FS 680 - static void debugfs_init(struct mgb4_vout_dev *voutdev) 679 + static void create_debugfs(struct mgb4_vout_dev *voutdev) 681 680 { 681 + #ifdef CONFIG_DEBUG_FS 682 682 struct mgb4_regs *video = &voutdev->mgbdev->video; 683 + struct dentry *entry; 683 684 684 - voutdev->debugfs = debugfs_create_dir(voutdev->vdev.name, 685 - voutdev->mgbdev->debugfs); 686 - if (!voutdev->debugfs) 685 + if (IS_ERR_OR_NULL(voutdev->mgbdev->debugfs)) 686 + return; 687 + entry = debugfs_create_dir(voutdev->vdev.name, voutdev->mgbdev->debugfs); 688 + if (IS_ERR(entry)) 687 689 return; 688 690 689 691 voutdev->regs[0].name = "CONFIG"; ··· 713 711 voutdev->regset.base = video->membase; 714 712 voutdev->regset.regs = voutdev->regs; 715 713 716 - debugfs_create_regset32("registers", 0444, voutdev->debugfs, 717 - &voutdev->regset); 718 - } 714 + debugfs_create_regset32("registers", 0444, entry, &voutdev->regset); 719 715 #endif 716 + } 720 717 721 718 struct mgb4_vout_dev *mgb4_vout_create(struct mgb4_dev *mgbdev, int id) 722 719 { ··· 809 808 goto err_video_dev; 810 809 } 811 810 812 - #ifdef CONFIG_DEBUG_FS 813 - debugfs_init(voutdev); 814 - #endif 811 + create_debugfs(voutdev); 815 812 816 813 return voutdev; 817 814 ··· 831 832 int irq = xdma_get_user_irq(voutdev->mgbdev->xdev, voutdev->config->irq); 832 833 833 834 free_irq(irq, voutdev); 834 - 835 - #ifdef CONFIG_DEBUG_FS 836 - debugfs_remove_recursive(voutdev->debugfs); 837 - #endif 838 835 839 836 groups = MGB4_IS_GMSL(voutdev->mgbdev) 840 837 ? mgb4_gmsl_out_groups : mgb4_fpdl3_out_groups;
-1
drivers/media/pci/mgb4/mgb4_vout.h
··· 54 54 const struct mgb4_vout_config *config; 55 55 56 56 #ifdef CONFIG_DEBUG_FS 57 - struct dentry *debugfs; 58 57 struct debugfs_regset32 regset; 59 58 struct debugfs_reg32 regs[sizeof(struct mgb4_vout_regs) / 4]; 60 59 #endif