Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp95118imm; Thu, 21 Jun 2018 14:35:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLwE7KdvKe9bL2gYTvpGGvAB8LU6OCo/4FC9GTI47T2Fzo2Ui6mjYgiOr9/s+ifgDxiDy/U X-Received: by 2002:a62:2394:: with SMTP id q20-v6mr28965907pfj.1.1529616932377; Thu, 21 Jun 2018 14:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529616932; cv=none; d=google.com; s=arc-20160816; b=GBm8c4VF7NeO1Hk3cTBQQcsTeTYYdd6j5rkv3zmcPzDi0TQKoXOO5F7YW08BQ7MUPm n3jLaQdNxHQteVU91kXIDxzoUJMm1qy75fHrdcvESKi4jifykeiaihLLvU+EaY26Rj6N ePZEccmMPyLOVZCXrx9XRqTrarZ75kr3NaVKwl224oL6/7lF82GsBNwiM2oJV7vY+PzD AeLOn3yN6dGmjvIxJs6OHyJ0NKrA7L4+pvuj0IBUeO79jyggZ3n/Q4haeARcYZZqACjn CZXZD+yNdSlpVWmVqN3qQHnSCJDYpgSnEd2EPM1cY5DgOVBgGPxMCutLnLySo38v6/yr hKww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=wesYzO7sUKPy+4+U70aatZEC6CUjHr8ewqO8wP2zFc8=; b=qEYXidL6YL67YKHJAiEpnOZRlR3K+PQBnlJR9zXYNmYRv9cE1vtDXtPiWh9puA/Cg7 tkGj2BArXQaJ1nwqIFoRGBOS/r9dokZR+SF+VjVebtX9bW58rKulNv+v06r0K7hhMogK YFOCiBFmqP8dF6b3ng17LPvKJO02U1Y8D5xq+RBMKsBLUq0MxlNU/ez70lVLX0b90JaQ g8U5Yl0Qg1Ryi9hqes168Y2VWkqthF9wtdd/VLnBvTa8BAlB0wYpDXJGR9jITkLB2fa9 e1aYLwGbs66mAxl+Nf5mraR/8UN7vkFUH5QEcanDKzEjV+GuNds5ubwnQG/+tt4ocUwK qxFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="tT/wMuG5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16-v6si4580446pgv.409.2018.06.21.14.35.18; Thu, 21 Jun 2018 14:35:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="tT/wMuG5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933760AbeFUVei (ORCPT + 99 others); Thu, 21 Jun 2018 17:34:38 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41782 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933957AbeFUV3K (ORCPT ); Thu, 21 Jun 2018 17:29:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wesYzO7sUKPy+4+U70aatZEC6CUjHr8ewqO8wP2zFc8=; b=tT/wMuG5svtem8e/qZCdh8FWt Sxyj2L92E1KbH4bmdJ14fzGiphA9Si/v0ev1+nR9Q0PGgyg8xvz25WHQ448Hwu9M8hXf7Ln/DSyRI EyTqrFwJ1F+jU9ThbuBd2r811nP1VeSRWYirJw3k05ht/DKDis9w2Fw1r52RiC2bUh9BA+8gHxUwy NvYkPByLU2KOZOmUwwypzREAZeMrP9ywUoROtMida23AzDGEdoFso9SNBpk0P6d012s98sX0tUJlr qzoPxqTOboWdSArQnUmcGXXpKTp+rZBU7+1dLsI4VsbZvsm/MlJYBVgdqEceRs0Gqi+83a0S1iBoR R9QbBirNg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW78f-0001c6-Or; Thu, 21 Jun 2018 21:29:09 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Dan Williams , Vinod Koul , dmaengine@vger.kernel.org Subject: [PATCH 16/26] dmaengine: Convert to new IDA API Date: Thu, 21 Jun 2018 14:28:25 -0700 Message-Id: <20180621212835.5636-17-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180621212835.5636-1-willy@infradead.org> References: <20180621212835.5636-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simpler and shorter code. Signed-off-by: Matthew Wilcox --- drivers/dma/dmaengine.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 08ba8473a284..1e9bdadfc312 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -161,9 +161,7 @@ static void chan_dev_release(struct device *dev) chan_dev = container_of(dev, typeof(*chan_dev), device); if (atomic_dec_and_test(chan_dev->idr_ref)) { - mutex_lock(&dma_list_mutex); - ida_remove(&dma_ida, chan_dev->dev_id); - mutex_unlock(&dma_list_mutex); + ida_free(&dma_ida, chan_dev->dev_id); kfree(chan_dev->idr_ref); } kfree(chan_dev); @@ -896,16 +894,10 @@ static bool device_has_all_tx_types(struct dma_device *device) static int get_dma_id(struct dma_device *device) { - int rc; - - do { - if (!ida_pre_get(&dma_ida, GFP_KERNEL)) - return -ENOMEM; - mutex_lock(&dma_list_mutex); - rc = ida_get_new(&dma_ida, &device->dev_id); - mutex_unlock(&dma_list_mutex); - } while (rc == -EAGAIN); + int rc = ida_alloc(&dma_ida, GFP_KERNEL); + if (rc >= 0) + device->dev_id = rc; return rc; } @@ -1090,9 +1082,7 @@ int dma_async_device_register(struct dma_device *device) err_out: /* if we never registered a channel just release the idr */ if (atomic_read(idr_ref) == 0) { - mutex_lock(&dma_list_mutex); - ida_remove(&dma_ida, device->dev_id); - mutex_unlock(&dma_list_mutex); + ida_free(&dma_ida, device->dev_id); kfree(idr_ref); return rc; } -- 2.17.1