All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: mach-tegra: check wether we have debugfs enabled or not
@ 2012-10-17 19:13 Devendra Naga
       [not found] ` <1350501196-5632-1-git-send-email-devendra.aaru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Devendra Naga @ 2012-10-17 19:13 UTC (permalink / raw)
  To: Stephen Warren, Russell King, linux-tegra-u79uwXL29TY76Z2rM5mHXA
  Cc: Devendra Naga

if debugfs is not enabled in kernel it returns -ENODEV, check it
with IS_ERR_OR_NULL along with the null return if it fails to
create a file in debugfs.

Signed-off-by: Devendra Naga <devendra.aaru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-tegra/powergate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
index de0662d..1809b91d 100644
--- a/arch/arm/mach-tegra/powergate.c
+++ b/arch/arm/mach-tegra/powergate.c
@@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
 	if (powergate_name) {
 		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
 			&powergate_fops);
-		if (!d)
+		if (IS_ERR_OR_NULL(d))
 			return -ENOMEM;
 	}
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] arm: mach-tegra: check wether we have debugfs enabled or not
       [not found] ` <1350501196-5632-1-git-send-email-devendra.aaru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-10-17 20:12   ` Russell King - ARM Linux
       [not found]     ` <20121017201244.GN21164-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Russell King - ARM Linux @ 2012-10-17 20:12 UTC (permalink / raw)
  To: Devendra Naga; +Cc: Stephen Warren, linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Wed, Oct 17, 2012 at 03:13:16PM -0400, Devendra Naga wrote:
> if debugfs is not enabled in kernel it returns -ENODEV, check it
> with IS_ERR_OR_NULL along with the null return if it fails to
> create a file in debugfs.
> 
> Signed-off-by: Devendra Naga <devendra.aaru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  arch/arm/mach-tegra/powergate.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
> index de0662d..1809b91d 100644
> --- a/arch/arm/mach-tegra/powergate.c
> +++ b/arch/arm/mach-tegra/powergate.c
> @@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
>  	if (powergate_name) {
>  		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
>  			&powergate_fops);
> -		if (!d)
> +		if (IS_ERR_OR_NULL(d))
>  			return -ENOMEM;

So, you want to make this function hard-fail if a debugfs error occurs
_or_ debugfs is not configured?  That doesn't seem to be a clever thing
to do.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] arm: mach-tegra: check wether we have debugfs enabled or not
       [not found]     ` <20121017201244.GN21164-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
@ 2012-10-17 20:18       ` devendra.aaru
  2012-10-17 21:22       ` Stephen Warren
  1 sibling, 0 replies; 5+ messages in thread
From: devendra.aaru @ 2012-10-17 20:18 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Stephen Warren, linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Wed, Oct 17, 2012 at 4:12 PM, Russell King - ARM Linux
<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> wrote:
>
> So, you want to make this function hard-fail if a debugfs error occurs
> _or_ debugfs is not configured?  That doesn't seem to be a clever thing
> to do.


I was seeing some places where the check is only for the pointer null
or valid one that is returned by
the debugfs_create_file, and fixed it up using this macro by failing
out even if we dont have debugfs
enabled in kernel.

I am sure that i really dont' know any part of the ARM stuff, tried to
fix this too, because this function
also checks for the null pointer if debugfs_create_file failed to
create a file in debugfs and fails out if
it can't be able to create that, but it wont check for whether we have
debugfs enabled in kernel.

thanks,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] arm: mach-tegra: check wether we have debugfs enabled or not
       [not found]     ` <20121017201244.GN21164-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
  2012-10-17 20:18       ` devendra.aaru
@ 2012-10-17 21:22       ` Stephen Warren
       [not found]         ` <507F2185.3070408-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2012-10-17 21:22 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Devendra Naga, linux-tegra-u79uwXL29TY76Z2rM5mHXA

On 10/17/2012 02:12 PM, Russell King - ARM Linux wrote:
> On Wed, Oct 17, 2012 at 03:13:16PM -0400, Devendra Naga wrote:
>> if debugfs is not enabled in kernel it returns -ENODEV, check it
>> with IS_ERR_OR_NULL along with the null return if it fails to
>> create a file in debugfs.
>>
>> Signed-off-by: Devendra Naga <devendra.aaru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  arch/arm/mach-tegra/powergate.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
>> index de0662d..1809b91d 100644
>> --- a/arch/arm/mach-tegra/powergate.c
>> +++ b/arch/arm/mach-tegra/powergate.c
>> @@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
>>  	if (powergate_name) {
>>  		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
>>  			&powergate_fops);
>> -		if (!d)
>> +		if (IS_ERR_OR_NULL(d))
>>  			return -ENOMEM;
> 
> So, you want to make this function hard-fail if a debugfs error occurs
> _or_ debugfs is not configured?  That doesn't seem to be a clever thing
> to do.

In practice, that quoted chunk of code is inside an #ifdef
CONFIG_DEBUG_FS, so according to the documentation for
debugfs_create_file(), the IS_ERR case of IS_ERR_OR_NULL cannot happen
here. So, the above change is a no-op, so there's not much point
applying it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] arm: mach-tegra: check wether we have debugfs enabled or not
       [not found]         ` <507F2185.3070408-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2012-10-17 22:14           ` Russell King - ARM Linux
  0 siblings, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux @ 2012-10-17 22:14 UTC (permalink / raw)
  To: Stephen Warren; +Cc: Devendra Naga, linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Wed, Oct 17, 2012 at 03:22:13PM -0600, Stephen Warren wrote:
> On 10/17/2012 02:12 PM, Russell King - ARM Linux wrote:
> > On Wed, Oct 17, 2012 at 03:13:16PM -0400, Devendra Naga wrote:
> >> if debugfs is not enabled in kernel it returns -ENODEV, check it
> >> with IS_ERR_OR_NULL along with the null return if it fails to
> >> create a file in debugfs.
> >>
> >> Signed-off-by: Devendra Naga <devendra.aaru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> >> ---
> >>  arch/arm/mach-tegra/powergate.c |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
> >> index de0662d..1809b91d 100644
> >> --- a/arch/arm/mach-tegra/powergate.c
> >> +++ b/arch/arm/mach-tegra/powergate.c
> >> @@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
> >>  	if (powergate_name) {
> >>  		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
> >>  			&powergate_fops);
> >> -		if (!d)
> >> +		if (IS_ERR_OR_NULL(d))
> >>  			return -ENOMEM;
> > 
> > So, you want to make this function hard-fail if a debugfs error occurs
> > _or_ debugfs is not configured?  That doesn't seem to be a clever thing
> > to do.
> 
> In practice, that quoted chunk of code is inside an #ifdef
> CONFIG_DEBUG_FS, so according to the documentation for
> debugfs_create_file(), the IS_ERR case of IS_ERR_OR_NULL cannot happen
> here. So, the above change is a no-op, so there's not much point
> applying it.

Ok.  Another reason not to apply it is that should the ifdefs get
removed, it'll start failing when debugfs is disabled with -ENOMEM,
which isn't bright.  A further reason is it's another place that'd
need reviewing for bad usage of the IS_ERR_OR_NULL() problem I've
pointed out this evening.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-17 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 19:13 [PATCH] arm: mach-tegra: check wether we have debugfs enabled or not Devendra Naga
     [not found] ` <1350501196-5632-1-git-send-email-devendra.aaru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-17 20:12   ` Russell King - ARM Linux
     [not found]     ` <20121017201244.GN21164-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2012-10-17 20:18       ` devendra.aaru
2012-10-17 21:22       ` Stephen Warren
     [not found]         ` <507F2185.3070408-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-17 22:14           ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.