From patchwork Wed Sep 16 17:50:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Duncan X-Patchwork-Id: 7198141 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 7AE4ABEEC1 for ; Wed, 16 Sep 2015 17:55:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7C102053B for ; Wed, 16 Sep 2015 17:55:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C709E2052D for ; Wed, 16 Sep 2015 17:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753828AbbIPRz3 (ORCPT ); Wed, 16 Sep 2015 13:55:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:51407 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754223AbbIPRvR (ORCPT ); Wed, 16 Sep 2015 13:51:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1F3DEADCD; Wed, 16 Sep 2015 17:51:16 +0000 (UTC) Received: by worklaptop.gonzoleeman.net (Postfix, from userid 1000) id DBCDB40C7B; Wed, 16 Sep 2015 10:51:09 -0700 (PDT) From: Lee Duncan To: linux-scsi@vger.kernel.org, James.Bottomley@HansenPartnership.com Cc: linux-kernel@vger.kernel.org, hare@suse.com, jthumshirn@suse.de, hch@infradead.org, Lee Duncan Subject: [PATCH 07/17] Update the memstick driver to use idr helper functions. Date: Wed, 16 Sep 2015 10:50:25 -0700 Message-Id: <09696655141544933a380e88afe3c3ecf31e4f8d.1442263513.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/memstick/core/memstick.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index a0547dbf9806..8f40a3d5108b 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c @@ -512,25 +512,16 @@ int memstick_add_host(struct memstick_host *host) { int rc; - idr_preload(GFP_KERNEL); - spin_lock(&memstick_host_lock); - - rc = idr_alloc(&memstick_host_idr, host, 0, 0, GFP_NOWAIT); - if (rc >= 0) - host->id = rc; - - spin_unlock(&memstick_host_lock); - idr_preload_end(); + rc = idr_get_index(&memstick_host_idr, &memstick_host_lock, host); if (rc < 0) return rc; + host->id = rc; dev_set_name(&host->dev, "memstick%u", host->id); rc = device_add(&host->dev); if (rc) { - spin_lock(&memstick_host_lock); - idr_remove(&memstick_host_idr, host->id); - spin_unlock(&memstick_host_lock); + idr_put_index(&memstick_host_idr, &memstick_host_lock, host->id); return rc; } @@ -554,9 +545,7 @@ void memstick_remove_host(struct memstick_host *host) host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); mutex_unlock(&host->lock); - spin_lock(&memstick_host_lock); - idr_remove(&memstick_host_idr, host->id); - spin_unlock(&memstick_host_lock); + idr_put_index(&memstick_host_idr, &memstick_host_lock, host->id); device_del(&host->dev); } EXPORT_SYMBOL(memstick_remove_host);