From patchwork Tue Sep 15 16:46:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Duncan X-Patchwork-Id: 7188401 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C62E9F32B for ; Tue, 15 Sep 2015 16:54:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3982F2051A for ; Tue, 15 Sep 2015 16:54:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07C1520751 for ; Tue, 15 Sep 2015 16:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753116AbbIOQrv (ORCPT ); Tue, 15 Sep 2015 12:47:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:52866 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753049AbbIOQru (ORCPT ); Tue, 15 Sep 2015 12:47:50 -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 B93F6AD6A; Tue, 15 Sep 2015 16:47:48 +0000 (UTC) Received: by worklaptop.gonzoleeman.net (Postfix, from userid 1000) id CAA6140C7B; Tue, 15 Sep 2015 09:47:36 -0700 (PDT) From: Lee Duncan To: , Cc: Hannes Reinecke , Johannes Thumshirn , Christoph Hellwig , Lee Duncan Subject: [PATCH 07/17] Update the memstick driver to use idr helper functions. Date: Tue, 15 Sep 2015 09:46:07 -0700 Message-Id: <09696655141544933a380e88afe3c3ecf31e4f8d.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/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);