Commit c4fd527f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Michael Ellerman

powerpc/kvm: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Because of this cleanup, we get to remove a few fields in struct
kvm_arch that are now unused.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[mpe: Fix build error in kvm/timing.c, adapt kvmppc_remove_cpu_debugfs()]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200209105901.1620958-2-gregkh@linuxfoundation.org
parent 860286cf
...@@ -308,8 +308,6 @@ struct kvm_arch { ...@@ -308,8 +308,6 @@ struct kvm_arch {
pgd_t *pgtable; pgd_t *pgtable;
u64 process_table; u64 process_table;
struct dentry *debugfs_dir; struct dentry *debugfs_dir;
struct dentry *htab_dentry;
struct dentry *radix_dentry;
struct kvm_resize_hpt *resize_hpt; /* protected by kvm->lock */ struct kvm_resize_hpt *resize_hpt; /* protected by kvm->lock */
#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
...@@ -830,7 +828,6 @@ struct kvm_vcpu_arch { ...@@ -830,7 +828,6 @@ struct kvm_vcpu_arch {
struct kvmhv_tb_accumulator cede_time; /* time napping inside guest */ struct kvmhv_tb_accumulator cede_time; /* time napping inside guest */
struct dentry *debugfs_dir; struct dentry *debugfs_dir;
struct dentry *debugfs_timings;
#endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ #endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */
}; };
......
...@@ -2138,9 +2138,8 @@ static const struct file_operations debugfs_htab_fops = { ...@@ -2138,9 +2138,8 @@ static const struct file_operations debugfs_htab_fops = {
void kvmppc_mmu_debugfs_init(struct kvm *kvm) void kvmppc_mmu_debugfs_init(struct kvm *kvm)
{ {
kvm->arch.htab_dentry = debugfs_create_file("htab", 0400, debugfs_create_file("htab", 0400, kvm->arch.debugfs_dir, kvm,
kvm->arch.debugfs_dir, kvm, &debugfs_htab_fops);
&debugfs_htab_fops);
} }
void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu) void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu)
......
...@@ -1376,9 +1376,8 @@ static const struct file_operations debugfs_radix_fops = { ...@@ -1376,9 +1376,8 @@ static const struct file_operations debugfs_radix_fops = {
void kvmhv_radix_debugfs_init(struct kvm *kvm) void kvmhv_radix_debugfs_init(struct kvm *kvm)
{ {
kvm->arch.radix_dentry = debugfs_create_file("radix", 0400, debugfs_create_file("radix", 0400, kvm->arch.debugfs_dir, kvm,
kvm->arch.debugfs_dir, kvm, &debugfs_radix_fops);
&debugfs_radix_fops);
} }
int kvmppc_radix_init(void) int kvmppc_radix_init(void)
......
...@@ -2258,14 +2258,9 @@ static void debugfs_vcpu_init(struct kvm_vcpu *vcpu, unsigned int id) ...@@ -2258,14 +2258,9 @@ static void debugfs_vcpu_init(struct kvm_vcpu *vcpu, unsigned int id)
struct kvm *kvm = vcpu->kvm; struct kvm *kvm = vcpu->kvm;
snprintf(buf, sizeof(buf), "vcpu%u", id); snprintf(buf, sizeof(buf), "vcpu%u", id);
if (IS_ERR_OR_NULL(kvm->arch.debugfs_dir))
return;
vcpu->arch.debugfs_dir = debugfs_create_dir(buf, kvm->arch.debugfs_dir); vcpu->arch.debugfs_dir = debugfs_create_dir(buf, kvm->arch.debugfs_dir);
if (IS_ERR_OR_NULL(vcpu->arch.debugfs_dir)) debugfs_create_file("timings", 0444, vcpu->arch.debugfs_dir, vcpu,
return; &debugfs_timings_ops);
vcpu->arch.debugfs_timings =
debugfs_create_file("timings", 0444, vcpu->arch.debugfs_dir,
vcpu, &debugfs_timings_ops);
} }
#else /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ #else /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */
......
...@@ -211,23 +211,14 @@ void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id) ...@@ -211,23 +211,14 @@ void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id)
snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing", snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing",
current->pid, id); current->pid, id);
debugfs_file = debugfs_create_file(dbg_fname, 0666, debugfs_file = debugfs_create_file(dbg_fname, 0666, kvm_debugfs_dir,
kvm_debugfs_dir, vcpu, vcpu, &kvmppc_exit_timing_fops);
&kvmppc_exit_timing_fops);
if (!debugfs_file) {
printk(KERN_ERR"%s: error creating debugfs file %s\n",
__func__, dbg_fname);
return;
}
vcpu->arch.debugfs_exit_timing = debugfs_file; vcpu->arch.debugfs_exit_timing = debugfs_file;
} }
void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu) void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu)
{ {
if (vcpu->arch.debugfs_exit_timing) { debugfs_remove(vcpu->arch.debugfs_exit_timing);
debugfs_remove(vcpu->arch.debugfs_exit_timing); vcpu->arch.debugfs_exit_timing = NULL;
vcpu->arch.debugfs_exit_timing = NULL;
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment