* [PATCH] powerpc/powernv: use appropiate error code
@ 2023-09-01 17:19 mirimmad
2023-09-01 17:40 ` Christophe Leroy
0 siblings, 1 reply; 5+ messages in thread
From: mirimmad @ 2023-09-01 17:19 UTC (permalink / raw)
Cc: gregkh, open list, Nicholas Piggin,
open list:LINUX FOR POWERPC 32-BIT AND 64-BIT, Immad Mir
From: Immad Mir <mirimmad17@gmail.com>
-1 is not a valid error code. This patch replaces it with -EPERM.
Signed-off-by: Immad Mir <mirimmad17@gmail.com>
---
arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
index 262cd6fac..ce4b089dd 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -171,7 +171,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
if (IS_ERR(dir)) {
kfree(ent->path.data);
kfree(ent);
- return -1;
+ return -EPERM;
}
debugfs_create_blob("devspec", 0400, dir, &ent->path);
@@ -191,7 +191,7 @@ static int scom_debug_init(void)
root = debugfs_create_dir("scom", arch_debugfs_dir);
if (IS_ERR(root))
- return -1;
+ return -EPERM;
rc = 0;
for_each_node_with_property(dn, "scom-controller") {
--
2.40.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/powernv: use appropiate error code
2023-09-01 17:19 [PATCH] powerpc/powernv: use appropiate error code mirimmad
@ 2023-09-01 17:40 ` Christophe Leroy
2023-09-01 17:57 ` Immad Mir
2023-09-01 18:03 ` Immad Mir
0 siblings, 2 replies; 5+ messages in thread
From: Christophe Leroy @ 2023-09-01 17:40 UTC (permalink / raw)
To: mirimmad@outlook.com
Cc: gregkh@linuxfoundation.org, open list, Nicholas Piggin,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), Immad Mir
Le 01/09/2023 à 19:19, mirimmad@outlook.com a écrit :
> [Vous ne recevez pas souvent de courriers de mirimmad@outlook.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Immad Mir <mirimmad17@gmail.com>
>
> -1 is not a valid error code. This patch replaces it with -EPERM.
Can you explain how it will work ?
In scom_debug_init() rc is built by oring the value returned by
scom_debug_init_one().
What will be the result when oring some valid values with -EPERM ?
It was working well with -1 because when you or -1 with anything you get
-1 as result. But with your change I don't think it will work.
Christophe
>
> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
> ---
> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
> index 262cd6fac..ce4b089dd 100644
> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
> @@ -171,7 +171,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
> if (IS_ERR(dir)) {
> kfree(ent->path.data);
> kfree(ent);
> - return -1;
> + return -EPERM;
> }
>
> debugfs_create_blob("devspec", 0400, dir, &ent->path);
> @@ -191,7 +191,7 @@ static int scom_debug_init(void)
>
> root = debugfs_create_dir("scom", arch_debugfs_dir);
> if (IS_ERR(root))
> - return -1;
> + return -EPERM;
>
> rc = 0;
> for_each_node_with_property(dn, "scom-controller") {
> --
> 2.40.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/powernv: use appropiate error code
2023-09-01 17:40 ` Christophe Leroy
@ 2023-09-01 17:57 ` Immad Mir
2023-09-01 18:03 ` Immad Mir
1 sibling, 0 replies; 5+ messages in thread
From: Immad Mir @ 2023-09-01 17:57 UTC (permalink / raw)
To: Christophe Leroy
Cc: gregkh@linuxfoundation.org, open list, Nicholas Piggin,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), Immad Mir
On 01/09/23 11:10 pm, Christophe Leroy wrote:
>
> Le 01/09/2023 à 19:19, mirimmad@outlook.com a écrit :
>> [Vous ne recevez pas souvent de courriers de mirimmad@outlook.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
>>
>> From: Immad Mir <mirimmad17@gmail.com>
>>
>> -1 is not a valid error code. This patch replaces it with -EPERM.
> Can you explain how it will work ?
> In scom_debug_init() rc is built by oring the value returned by
> scom_debug_init_one().
> What will be the result when oring some valid values with -EPERM ?
> It was working well with -1 because when you or -1 with anything you get
> -1 as result. But with your change I don't think it will work.
But Isn't EPERM defined to be 1.
Immad.
>
> Christophe
>
>> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
>> ---
>> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
>> index 262cd6fac..ce4b089dd 100644
>> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
>> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
>> @@ -171,7 +171,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
>> if (IS_ERR(dir)) {
>> kfree(ent->path.data);
>> kfree(ent);
>> - return -1;
>> + return -EPERM;
>> }
>>
>> debugfs_create_blob("devspec", 0400, dir, &ent->path);
>> @@ -191,7 +191,7 @@ static int scom_debug_init(void)
>>
>> root = debugfs_create_dir("scom", arch_debugfs_dir);
>> if (IS_ERR(root))
>> - return -1;
>> + return -EPERM;
>>
>> rc = 0;
>> for_each_node_with_property(dn, "scom-controller") {
>> --
>> 2.40.0
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/powernv: use appropiate error code
2023-09-01 17:40 ` Christophe Leroy
2023-09-01 17:57 ` Immad Mir
@ 2023-09-01 18:03 ` Immad Mir
2023-10-13 13:03 ` Christophe Leroy
1 sibling, 1 reply; 5+ messages in thread
From: Immad Mir @ 2023-09-01 18:03 UTC (permalink / raw)
To: Christophe Leroy
Cc: gregkh@linuxfoundation.org, open list, Nicholas Piggin,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), Immad Mir
On 01/09/23 11:10 pm, Christophe Leroy wrote:
>
> Le 01/09/2023 à 19:19, mirimmad@outlook.com a écrit :
>> [Vous ne recevez pas souvent de courriers de mirimmad@outlook.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
>>
>> From: Immad Mir <mirimmad17@gmail.com>
>>
>> -1 is not a valid error code. This patch replaces it with -EPERM.
> Can you explain how it will work ?
> In scom_debug_init() rc is built by oring the value returned by
> scom_debug_init_one().
> What will be the result when oring some valid values with -EPERM ?
> It was working well with -1 because when you or -1 with anything you get
> -1 as result. But with your change I don't think it will work.
if EPERM is not always necessarily equal to 1, we can put a check in
scom_debug_init before returning rc. If it is less than 1 (because AFAIK
or-ring with negative number results back into the same negative number)
we set rc equal to -1.
Immad.
>
> Christophe
>
>> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
>> ---
>> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
>> index 262cd6fac..ce4b089dd 100644
>> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
>> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
>> @@ -171,7 +171,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
>> if (IS_ERR(dir)) {
>> kfree(ent->path.data);
>> kfree(ent);
>> - return -1;
>> + return -EPERM;
>> }
>>
>> debugfs_create_blob("devspec", 0400, dir, &ent->path);
>> @@ -191,7 +191,7 @@ static int scom_debug_init(void)
>>
>> root = debugfs_create_dir("scom", arch_debugfs_dir);
>> if (IS_ERR(root))
>> - return -1;
>> + return -EPERM;
>>
>> rc = 0;
>> for_each_node_with_property(dn, "scom-controller") {
>> --
>> 2.40.0
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/powernv: use appropiate error code
2023-09-01 18:03 ` Immad Mir
@ 2023-10-13 13:03 ` Christophe Leroy
0 siblings, 0 replies; 5+ messages in thread
From: Christophe Leroy @ 2023-10-13 13:03 UTC (permalink / raw)
To: Immad Mir
Cc: gregkh@linuxfoundation.org, open list, Nicholas Piggin,
open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), Immad Mir
Le 01/09/2023 à 20:03, Immad Mir a écrit :
>
> On 01/09/23 11:10 pm, Christophe Leroy wrote:
>>
>> Le 01/09/2023 à 19:19, mirimmad@outlook.com a écrit :
>>> [Vous ne recevez pas souvent de courriers de mirimmad@outlook.com.
>>> Découvrez pourquoi ceci est important à
>>> https://aka.ms/LearnAboutSenderIdentification ]
>>>
>>> From: Immad Mir <mirimmad17@gmail.com>
>>>
>>> -1 is not a valid error code. This patch replaces it with -EPERM.
>> Can you explain how it will work ?
>> In scom_debug_init() rc is built by oring the value returned by
>> scom_debug_init_one().
>> What will be the result when oring some valid values with -EPERM ?
>> It was working well with -1 because when you or -1 with anything you get
>> -1 as result. But with your change I don't think it will work.
>
>
> if EPERM is not always necessarily equal to 1, we can put a check in
> scom_debug_init before returning rc. If it is less than 1 (because AFAIK
> or-ring with negative number results back into the same negative number)
> we set rc equal to -1.
>
The point is that EPERM is 1 by coincidence, the intention here is not
to return -EPERM but really -1, so by changing this you just make the
code harded to understand and maintain.
Christophe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-13 13:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-01 17:19 [PATCH] powerpc/powernv: use appropiate error code mirimmad
2023-09-01 17:40 ` Christophe Leroy
2023-09-01 17:57 ` Immad Mir
2023-09-01 18:03 ` Immad Mir
2023-10-13 13:03 ` Christophe Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox