Re: [PATCH 6/6] powerpc: powernv: no need to check return value of debugfs_create functions

From: Michael Ellerman
Date: Tue Mar 03 2020 - 04:52:25 EST


"Oliver O'Halloran" <oohall@xxxxxxxxx> writes:
> On Mon, Feb 10, 2020 at 12:12 AM Greg Kroah-Hartman
> <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>>
>> 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.
>
> For memtrace debugfs is the only way to actually use the feature. It'd
> be nice if it still printed out *something* if it failed to create the
> files rather than just being mysteriously absent

That's true, but the current code doesn't actually do that anyway.

>> diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
>> index eb2e75dac369..d6d64f8718e6 100644
>> --- a/arch/powerpc/platforms/powernv/memtrace.c
>> +++ b/arch/powerpc/platforms/powernv/memtrace.c
>> @@ -187,11 +187,6 @@ static int memtrace_init_debugfs(void)
>>
>> snprintf(ent->name, 16, "%08x", ent->nid);
>> dir = debugfs_create_dir(ent->name, memtrace_debugfs_dir);
>> - if (!dir) {
>> - pr_err("Failed to create debugfs directory for node %d\n",
>> - ent->nid);
>> - return -1;
>> - }

debugfs_create_dir() doesn't return NULL on error, it returns
ERR_PTR(-ENOMEM), which will not trigger that pr_err().

So I've merged this and if someone wants to they can send a follow-up to
do proper error checking in memtrace.c

cheers