Skip to content

Commit 8cd08e3

Browse files
Jinjie RuanHans Verkuil
authored andcommitted
media: siano: Drop unnecessary error check for debugfs_create_dir/file()
Both debugfs_create_dir() and debugfs_create_file() return ERR_PTR and never return NULL. As Hans suggested, this patch removes the error checking for both debugfs_create_dir() and debugfs_create_file() in smsdvb_debugfs_create(). This is because the DebugFS kernel API is developed in a way that the caller can safely ignore the errors that occur during the creation of DebugFS nodes. The debugfs APIs have a IS_ERR() judge in start_creating() which can handle it gracefully. So these checks are unnecessary. And as Hans pointed out, it's much better to first allocate debug_data before calling debugfs_create_dir, which need not to clean anything up in that case. Fixes: 503efe5 ("[media] siano: split debugfs code into a separate file") Signed-off-by: Jinjie Ruan <[email protected]> Suggested-by: Hans Verkuil <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 19e2e01 commit 8cd08e3

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

drivers/media/common/siano/smsdvb-debugfs.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -353,31 +353,21 @@ static const struct file_operations debugfs_stats_ops = {
353353
int smsdvb_debugfs_create(struct smsdvb_client_t *client)
354354
{
355355
struct smscore_device_t *coredev = client->coredev;
356-
struct dentry *d;
357356
struct smsdvb_debugfs *debug_data;
358357

359358
if (!smsdvb_debugfs_usb_root || !coredev->is_usb_device)
360359
return -ENODEV;
361360

362-
client->debugfs = debugfs_create_dir(coredev->devpath,
363-
smsdvb_debugfs_usb_root);
364-
if (IS_ERR_OR_NULL(client->debugfs)) {
365-
pr_info("Unable to create debugfs %s directory.\n",
366-
coredev->devpath);
367-
return -ENODEV;
368-
}
369-
370-
d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
371-
client, &debugfs_stats_ops);
372-
if (!d) {
373-
debugfs_remove(client->debugfs);
374-
return -ENOMEM;
375-
}
376-
377361
debug_data = kzalloc(sizeof(*client->debug_data), GFP_KERNEL);
378362
if (!debug_data)
379363
return -ENOMEM;
380364

365+
client->debugfs = debugfs_create_dir(coredev->devpath,
366+
smsdvb_debugfs_usb_root);
367+
368+
debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
369+
client, &debugfs_stats_ops);
370+
381371
client->debug_data = debug_data;
382372
client->prt_dvb_stats = smsdvb_print_dvb_stats;
383373
client->prt_isdb_stats = smsdvb_print_isdb_stats;

0 commit comments

Comments
 (0)