lkml.org 
[lkml]   [2016]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 6/8] IB/hns: Replace counting semaphore event_sem with wait_event
On 25 October 2016 at 18:51, Arnd Bergmann <arnd@arndb.de> wrote:
> On Tuesday, October 25, 2016 6:29:45 PM CEST Binoy Jayan wrote:
>
> Something like
>
> static struct hns_roce_cmd_context *hns_roce_try_get_context(struct hns_roce_cmdq *cmd)
> {
> struct hns_roce_cmd_context *context = NULL;
>
> spin_lock(&cmd->context_lock);
>
> if (cmd->free_head < 0)
> goto out;
>
> context = &cmd->context[cmd->free_head];
>
> ... /* update free_head */
>
> out:
> spin_unlock(&cmd->context_lock);
>
> return context;
> }
> ...
>
> static struct hns_roce_cmd_context *hns_roce_get_context(struct hns_roce_cmdq *cmd)
> {
> struct hns_roce_cmd_context *context;
>
> wait_event(cmd->wq, (context = hns_roce_try_get_context(cmd)));
>
> return context;
> }

That looks more elegant. Didn't think of that, Thank you Arnd.:)

\
 
 \ /
  Last update: 2016-10-25 15:37    [W:0.044 / U:0.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site