Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936356AbcJYNgC (ORCPT ); Tue, 25 Oct 2016 09:36:02 -0400 Received: from mail-vk0-f50.google.com ([209.85.213.50]:37768 "EHLO mail-vk0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933363AbcJYNgA (ORCPT ); Tue, 25 Oct 2016 09:36:00 -0400 MIME-Version: 1.0 In-Reply-To: <3400101.E3rphEBHnx@wuerfel> References: <1477396919-27669-1-git-send-email-binoy.jayan@linaro.org> <5375848.bxLv0aDzDv@wuerfel> <3400101.E3rphEBHnx@wuerfel> From: Binoy Jayan Date: Tue, 25 Oct 2016 19:05:59 +0530 Message-ID: Subject: Re: [PATCH v2 6/8] IB/hns: Replace counting semaphore event_sem with wait_event To: Arnd Bergmann Cc: Doug Ledford , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, Linux kernel mailing list Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 905 Lines: 35 On 25 October 2016 at 18:51, Arnd Bergmann 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.:)