mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-05 21:17:44 -05:00
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: 503efe5cfc ("[media] siano: split debugfs code into a separate file")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
committed by
Hans Verkuil
parent
19e2e01f30
commit
8cd08e3651
@@ -353,31 +353,21 @@ static const struct file_operations debugfs_stats_ops = {
|
||||
int smsdvb_debugfs_create(struct smsdvb_client_t *client)
|
||||
{
|
||||
struct smscore_device_t *coredev = client->coredev;
|
||||
struct dentry *d;
|
||||
struct smsdvb_debugfs *debug_data;
|
||||
|
||||
if (!smsdvb_debugfs_usb_root || !coredev->is_usb_device)
|
||||
return -ENODEV;
|
||||
|
||||
client->debugfs = debugfs_create_dir(coredev->devpath,
|
||||
smsdvb_debugfs_usb_root);
|
||||
if (IS_ERR_OR_NULL(client->debugfs)) {
|
||||
pr_info("Unable to create debugfs %s directory.\n",
|
||||
coredev->devpath);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
|
||||
client, &debugfs_stats_ops);
|
||||
if (!d) {
|
||||
debugfs_remove(client->debugfs);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
debug_data = kzalloc(sizeof(*client->debug_data), GFP_KERNEL);
|
||||
if (!debug_data)
|
||||
return -ENOMEM;
|
||||
|
||||
client->debugfs = debugfs_create_dir(coredev->devpath,
|
||||
smsdvb_debugfs_usb_root);
|
||||
|
||||
debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
|
||||
client, &debugfs_stats_ops);
|
||||
|
||||
client->debug_data = debug_data;
|
||||
client->prt_dvb_stats = smsdvb_print_dvb_stats;
|
||||
client->prt_isdb_stats = smsdvb_print_isdb_stats;
|
||||
|
||||
Reference in New Issue
Block a user