Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp94295imm; Thu, 21 Jun 2018 14:34:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdfanGYRsx81oAedgrUkXQJb7P0QfZBZvKDPC4hiUvcsYPQ32DYYqIFXPY3X5uh4w84ooV X-Received: by 2002:a17:902:5a1:: with SMTP id f30-v6mr30457164plf.167.1529616870577; Thu, 21 Jun 2018 14:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529616870; cv=none; d=google.com; s=arc-20160816; b=aR+jcVA2wPtSjyX3B8MCsAPasps/NDfFfOgdwielNBMSTVkEM4cbzKbvLt6f8+bhUb 0cvT2DHxC9MfORL2I/ls8W7gJlU1i6Lc396AUBgWOW6FIX+qUjlF5Q5c7hkQBTYo5CCI edxS3QnLDpQO+/u61u9b58crgbjRD6q8exWH40T8jUMmrQ/K9yLGOu84hUPGYjqSwpG5 A1AcNZQVrzDBkmfE02W4aDAcRpsttw1RjRb8y/93RX2x4hazaga2hU7b721ftRtnBKr9 PQh6o/c/PcCkKwQyzbYTXyPxeBJEEuKRCsmSDalTebO0HsUkqgDBCV5rePZ1U2S+5Jpk nsGA== 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=DgiDTYObtEDk2O8cnHX6t2kCdY4GY3B7mxCy/I7vJRQ=; b=VNBo3De7PpgDhgqG4qvXTHbQb29QqKNj9ddSi7QLPa2FPUQ9Zh74ma+PBYM23RKhy/ 6OAs7/0p45U+iNcUw0qcW+3itM7VQKR2LCWeS+DUZGEITTUwQNMvVtJueUXJtQwV+wZ1 RUcdTS84r92xQcCeLI9Y9K9OFdthFLq7FNNgNKle9+d8TBLWHraBwY7i2PcFx8NTxlPJ cYF1w2nziC7MuRoieVP5CdxrI7T10c0yJKNpx4M7XHG/2GwdhL98B9A4aOopJTL+cqmX CJOV0073cElP6v4QuX2rUP+eFF63W2ya0GbJ4fNRZno2+KwYDNvK2EO20/QyaEv+aqKj 49CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XFfZl2sa; 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 p29-v6si4712110pgc.199.2018.06.21.14.34.15; Thu, 21 Jun 2018 14:34:30 -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=XFfZl2sa; 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 S934117AbeFUVc7 (ORCPT + 99 others); Thu, 21 Jun 2018 17:32:59 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41788 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933955AbeFUV3K (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=DgiDTYObtEDk2O8cnHX6t2kCdY4GY3B7mxCy/I7vJRQ=; b=XFfZl2saElqcS2NGS8hcA8/yN tkZSfN1Q9cQSKg4+Tbe5fX4PyLmWGlQonXy4DIM804o/uS9EGjm7fBs2psUF+PShM8/a8a+ePFS6Q fHBrR15RPRxhxOt3bYIHYiFcTOuaZeK5oTkzryaGHXtwcvzHp8QoRkObQUnS+Z8nru8Ewqt8rz18i v+LCv9YwHxQDo6SF0wjnfqJsFlg5KerhOh/0+unZXuvIPPsC8SPlWzNKRoDYEbYQDfzUSdY/LyoGu Bk7Q3jyjYnenakP7++hQr97GT+cWuFglrpWOGNYZTP7H5uNdi/DQ+lHuvsLvL8JOp9Z2QVZOMkI/1 2AZ8KnOkA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW78e-0001bE-I1; Thu, 21 Jun 2018 21:29:08 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Boaz Harrosh , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 09/26] osd: Convert to new IDA API Date: Thu, 21 Jun 2018 14:28:18 -0700 Message-Id: <20180621212835.5636-10-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 Slightly simpler code. Signed-off-by: Matthew Wilcox --- drivers/scsi/osd/osd_uld.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index 0e56f1eb05dc..eaf36ccf58db 100644 --- a/drivers/scsi/osd/osd_uld.c +++ b/drivers/scsi/osd/osd_uld.c @@ -423,19 +423,11 @@ static int osd_probe(struct device *dev) if (scsi_device->type != TYPE_OSD) return -ENODEV; - do { - if (!ida_pre_get(&osd_minor_ida, GFP_KERNEL)) - return -ENODEV; - - error = ida_get_new(&osd_minor_ida, &minor); - } while (error == -EAGAIN); - - if (error) - return error; - if (minor >= SCSI_OSD_MAX_MINOR) { - error = -EBUSY; - goto err_retract_minor; - } + minor = ida_alloc_max(&osd_minor_ida, SCSI_OSD_MAX_MINOR, GFP_KERNEL); + if (minor == -ENOSPC) + return -EBUSY; + if (minor < 0) + return -ENODEV; error = -ENOMEM; oud = kzalloc(sizeof(*oud), GFP_KERNEL); @@ -499,7 +491,7 @@ static int osd_probe(struct device *dev) err_free_osd: put_device(&oud->class_dev); err_retract_minor: - ida_remove(&osd_minor_ida, minor); + ida_free(&osd_minor_ida, minor); return error; } @@ -514,7 +506,7 @@ static int osd_remove(struct device *dev) } cdev_device_del(&oud->cdev, &oud->class_dev); - ida_remove(&osd_minor_ida, oud->minor); + ida_free(&osd_minor_ida, oud->minor); put_device(&oud->class_dev); return 0; -- 2.17.1