From patchwork Tue Sep 15 16:46:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Duncan X-Patchwork-Id: 7188521 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 57B96BEEC1 for ; Tue, 15 Sep 2015 16:56:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EC092070F for ; Tue, 15 Sep 2015 16:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AF2220695 for ; Tue, 15 Sep 2015 16:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752969AbbIOQrr (ORCPT ); Tue, 15 Sep 2015 12:47:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:52829 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752951AbbIOQrp (ORCPT ); Tue, 15 Sep 2015 12:47:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E7435AD61; Tue, 15 Sep 2015 16:47:43 +0000 (UTC) Received: by worklaptop.gonzoleeman.net (Postfix, from userid 1000) id 8D87B40C7A; Tue, 15 Sep 2015 09:47:36 -0700 (PDT) From: Lee Duncan To: , Cc: Hannes Reinecke , Johannes Thumshirn , Christoph Hellwig , Lee Duncan , Kai.Makisara@kolumbus.fi Subject: [PATCH 03/17] Update the st driver to use idr helper functions. Date: Tue, 15 Sep 2015 09:46:03 -0700 Message-Id: <0999c39931090daa5a78996039b5d58812a71e34.1442263512.git.lduncan@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Lee Duncan --- drivers/scsi/st.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index b37b9b00c4b4..51e1ce721d9f 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -4265,11 +4265,8 @@ static int st_probe(struct device *dev) tpnt->blksize_changed = 0; mutex_init(&tpnt->lock); - idr_preload(GFP_KERNEL); - spin_lock(&st_index_lock); - error = idr_alloc(&st_index_idr, tpnt, 0, ST_MAX_TAPES + 1, GFP_NOWAIT); - spin_unlock(&st_index_lock); - idr_preload_end(); + error = idr_get_index_in_range(&st_index_idr, &st_index_lock, tpnt, + 0, ST_MAX_TAPES + 1); if (error < 0) { pr_warn("st: idr allocation failed: %d\n", error); goto out_put_queue; @@ -4303,9 +4300,7 @@ out_remove_devs: remove_cdevs(tpnt); kfree(tpnt->stats); out_idr_remove: - spin_lock(&st_index_lock); - idr_remove(&st_index_idr, tpnt->index); - spin_unlock(&st_index_lock); + idr_put_index(&st_index_idr, &st_index_lock, tpnt->index); out_put_queue: blk_put_queue(disk->queue); out_put_disk: @@ -4330,9 +4325,7 @@ static int st_remove(struct device *dev) mutex_lock(&st_ref_mutex); kref_put(&tpnt->kref, scsi_tape_release); mutex_unlock(&st_ref_mutex); - spin_lock(&st_index_lock); - idr_remove(&st_index_idr, index); - spin_unlock(&st_index_lock); + idr_put_index(&st_index_idr, &st_index_lock, index); return 0; }