2014-02-28 16:57:13

by Surendra Patil

[permalink] [raw]
Subject: [PATCH] Drivers:staging:ozwpan Fixed sparse context imbalance warning

Sparse warns about -
drivers/staging/ozwpan/ozproto.c:797:6: warning: context imbalance in 'oz_polling_lock_bh' - wrong count at exit
drivers/staging/ozwpan/ozproto.c:802:6: warning: context imbalance in 'oz_polling_unlock_bh' - unexpected unlock
so added __acquires() and __releases().

Signed-off-by: Surendra Patil <[email protected]>
---
drivers/staging/ozwpan/ozproto.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c
index e7138ed..b47cec1 100644
--- a/drivers/staging/ozwpan/ozproto.c
+++ b/drivers/staging/ozwpan/ozproto.c
@@ -795,11 +795,13 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count)
}

void oz_polling_lock_bh(void)
+__acquires(&g_polling_block)
{
spin_lock_bh(&g_polling_lock);
}

void oz_polling_unlock_bh(void)
+__releases(&g_polling_block)
{
spin_unlock_bh(&g_polling_lock);
}
--
1.8.3.2


2014-02-28 17:04:18

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] Drivers:staging:ozwpan Fixed sparse context imbalance warning

On Fri, Feb 28, 2014 at 08:57:02AM -0800, Surendra Patil wrote:
> Sparse warns about -
> drivers/staging/ozwpan/ozproto.c:797:6: warning: context imbalance in 'oz_polling_lock_bh' - wrong count at exit
> drivers/staging/ozwpan/ozproto.c:802:6: warning: context imbalance in 'oz_polling_unlock_bh' - unexpected unlock
> so added __acquires() and __releases().
>
> Signed-off-by: Surendra Patil <[email protected]>
> ---
> drivers/staging/ozwpan/ozproto.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c
> index e7138ed..b47cec1 100644
> --- a/drivers/staging/ozwpan/ozproto.c
> +++ b/drivers/staging/ozwpan/ozproto.c
> @@ -795,11 +795,13 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count)
> }
>
> void oz_polling_lock_bh(void)
> +__acquires(&g_polling_block)
> {
> spin_lock_bh(&g_polling_lock);
> }
>
> void oz_polling_unlock_bh(void)
> +__releases(&g_polling_block)
> {
> spin_unlock_bh(&g_polling_lock);
> }

How about ripping out this "wrapper" function entirely and replacing all
calls to them with the "real" call to the spinlock function?

thanks,

greg k-h