All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.
@ 2012-11-05  4:50 Harvey Yang
  2012-11-05  4:57 ` Greg Kroah-Hartman
  2012-11-05  5:34 ` Prashant Shah
  0 siblings, 2 replies; 4+ messages in thread
From: Harvey Yang @ 2012-11-05  4:50 UTC (permalink / raw)
  To: Matt Mooney, Greg Kroah-Hartman, linux-usb; +Cc: linux-kernel, harvey.yang

From: harvey.yang <harvey.huawei.yang@gmail.com>


Signed-off-by: harvey.yang <harvey.huawei.yang@gmail.com>
---
 drivers/staging/usbip/usbip_event.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c
index d332a34..668f8e0 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -116,10 +116,8 @@ int usbip_event_happened(struct usbip_device *ud)
 {
 	int happened = 0;
 
-	spin_lock(&ud->lock);
 	if (ud->event != 0)
 		happened = 1;
-	spin_unlock(&ud->lock);
 
 	return happened;
 }
-- 
1.7.1


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

* Re: [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.
  2012-11-05  4:50 [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here Harvey Yang
@ 2012-11-05  4:57 ` Greg Kroah-Hartman
  2012-11-05  5:34 ` Prashant Shah
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2012-11-05  4:57 UTC (permalink / raw)
  To: Harvey Yang; +Cc: Matt Mooney, linux-usb, linux-kernel

On Mon, Nov 05, 2012 at 12:50:26PM +0800, Harvey Yang wrote:
> From: harvey.yang <harvey.huawei.yang@gmail.com>
> 
> 
> Signed-off-by: harvey.yang <harvey.huawei.yang@gmail.com>
> ---
>  drivers/staging/usbip/usbip_event.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c
> index d332a34..668f8e0 100644
> --- a/drivers/staging/usbip/usbip_event.c
> +++ b/drivers/staging/usbip/usbip_event.c
> @@ -116,10 +116,8 @@ int usbip_event_happened(struct usbip_device *ud)
>  {
>  	int happened = 0;
>  
> -	spin_lock(&ud->lock);
>  	if (ud->event != 0)
>  		happened = 1;
> -	spin_unlock(&ud->lock);
>  
>  	return happened;

Are you sure that the real fix for this isn't just making 'happened' a
static variable?  That would make more sense here.  Well maybe, the code
seems pretty dumb, it's hard to tell what this is supposed to be doing,
any ideas?

thanks,

greg k-h

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

* Re: [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.
  2012-11-05  4:50 [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here Harvey Yang
  2012-11-05  4:57 ` Greg Kroah-Hartman
@ 2012-11-05  5:34 ` Prashant Shah
  2012-11-05  6:34   ` harvey yang
  1 sibling, 1 reply; 4+ messages in thread
From: Prashant Shah @ 2012-11-05  5:34 UTC (permalink / raw)
  To: Harvey Yang; +Cc: Matt Mooney, Greg Kroah-Hartman, linux-usb, linux-kernel

Hi,

>         int happened = 0;
>
> -       spin_lock(&ud->lock);
>         if (ud->event != 0)
>                 happened = 1;
> -       spin_unlock(&ud->lock);
>
>         return happened;

I am guessing locking was intended to protect ud->event along with
happened so that (checking the value of ud->event and setting value of
happened) was atomic.

return ud->event != 0 ? 1 : 0;

Regards.

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

* Re: [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.
  2012-11-05  5:34 ` Prashant Shah
@ 2012-11-05  6:34   ` harvey yang
  0 siblings, 0 replies; 4+ messages in thread
From: harvey yang @ 2012-11-05  6:34 UTC (permalink / raw)
  To: Prashant Shah; +Cc: Matt Mooney, Greg Kroah-Hartman, linux-usb, linux-kernel

I think no need to make 'happened' static as we just check 'ud->event'
feild. Maybe making this function inline would make more sense.

inline int usbip_event_happened(struct usbip_device *ud)
{
        return ud->event ? 1 : 0;
}

Thanks
Harvey


On Mon, Nov 5, 2012 at 1:34 PM, Prashant Shah <kerneldev100@gmail.com> wrote:
> Hi,
>
>>         int happened = 0;
>>
>> -       spin_lock(&ud->lock);
>>         if (ud->event != 0)
>>                 happened = 1;
>> -       spin_unlock(&ud->lock);
>>
>>         return happened;
>
> I am guessing locking was intended to protect ud->event along with
> happened so that (checking the value of ud->event and setting value of
> happened) was atomic.
>
> return ud->event != 0 ? 1 : 0;
>
> Regards.

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

end of thread, other threads:[~2012-11-05  6:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-05  4:50 [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here Harvey Yang
2012-11-05  4:57 ` Greg Kroah-Hartman
2012-11-05  5:34 ` Prashant Shah
2012-11-05  6:34   ` harvey yang

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.