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

fbdev: mbx: fix up debugfs file creation

There is no need to keep the dentries around for the individual debugfs
files, just delete the whole directory all at once at shutdown instead.

This also fixes a tiny memory leak where the memory for the pointers to
the file dentries was never freed when the device shut down, as well as
making the logic of the code a lot simpler.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

authored by

Greg Kroah-Hartman and committed by
Bartlomiej Zolnierkiewicz
72aed9e3 60d2fa0d

+11 -25
+10 -24
drivers/video/fbdev/mbx/mbxdebugfs.c
··· 211 211 static void mbxfb_debugfs_init(struct fb_info *fbi) 212 212 { 213 213 struct mbxfb_info *mfbi = fbi->par; 214 - struct mbxfb_debugfs_data *dbg; 214 + struct dentry *dir; 215 215 216 - dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL); 217 - mfbi->debugfs_data = dbg; 216 + dir = debugfs_create_dir("mbxfb", NULL); 217 + mbfi->debugfs_dir = dir; 218 218 219 - dbg->dir = debugfs_create_dir("mbxfb", NULL); 220 - dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir, 221 - fbi, &sysconf_fops); 222 - dbg->clock = debugfs_create_file("clock", 0444, dbg->dir, 223 - fbi, &clock_fops); 224 - dbg->display = debugfs_create_file("display", 0444, dbg->dir, 225 - fbi, &display_fops); 226 - dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir, 227 - fbi, &gsctl_fops); 228 - dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir, 229 - fbi, &sdram_fops); 230 - dbg->misc = debugfs_create_file("misc", 0444, dbg->dir, 231 - fbi, &misc_fops); 219 + debugfs_create_file("sysconf", 0444, dir, fbi, &sysconf_fops); 220 + debugfs_create_file("clock", 0444, dir, fbi, &clock_fops); 221 + debugfs_create_file("display", 0444, dir, fbi, &display_fops); 222 + debugfs_create_file("gsctl", 0444, dir, fbi, &gsctl_fops); 223 + debugfs_create_file("sdram", 0444, dir, fbi, &sdram_fops); 224 + debugfs_create_file("misc", 0444, dir, fbi, &misc_fops); 232 225 } 233 226 234 227 static void mbxfb_debugfs_remove(struct fb_info *fbi) 235 228 { 236 229 struct mbxfb_info *mfbi = fbi->par; 237 - struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data; 238 230 239 - debugfs_remove(dbg->misc); 240 - debugfs_remove(dbg->sdram); 241 - debugfs_remove(dbg->gsctl); 242 - debugfs_remove(dbg->display); 243 - debugfs_remove(dbg->clock); 244 - debugfs_remove(dbg->sysconf); 245 - debugfs_remove(dbg->dir); 231 + debugfs_remove_recursive(mfbi->debugfs_dir); 246 232 }
+1 -1
drivers/video/fbdev/mbx/mbxfb.c
··· 74 74 75 75 u32 pseudo_palette[MAX_PALETTES]; 76 76 #ifdef CONFIG_FB_MBX_DEBUG 77 - void *debugfs_data; 77 + struct dentry *debugfs_dir; 78 78 #endif 79 79 80 80 };