From patchwork Wed Sep 16 17:50:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Duncan X-Patchwork-Id: 7198081 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 D37A99F380 for ; Wed, 16 Sep 2015 17:53:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1894B207B5 for ; Wed, 16 Sep 2015 17:53:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2303D203DC for ; Wed, 16 Sep 2015 17:53:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754620AbbIPRx4 (ORCPT ); Wed, 16 Sep 2015 13:53:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:51413 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754270AbbIPRvT (ORCPT ); Wed, 16 Sep 2015 13:51:19 -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 58A42ADD4; Wed, 16 Sep 2015 17:51:17 +0000 (UTC) Received: by worklaptop.gonzoleeman.net (Postfix, from userid 1000) id 3044F40C7D; Wed, 16 Sep 2015 10:51:12 -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 10/17] Update the DCA DMA driver to use idr helper functions. Date: Wed, 16 Sep 2015 10:50:28 -0700 Message-Id: <77238f931cd168e25f836e0d0fdf0eeab4eb9056.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/dca/dca-sysfs.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c index 126cf295b198..8930707df295 100644 --- a/drivers/dca/dca-sysfs.c +++ b/drivers/dca/dca-sysfs.c @@ -55,23 +55,14 @@ int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev) struct device *cd; int ret; - idr_preload(GFP_KERNEL); - spin_lock(&dca_idr_lock); - - ret = idr_alloc(&dca_idr, dca, 0, 0, GFP_NOWAIT); - if (ret >= 0) - dca->id = ret; - - spin_unlock(&dca_idr_lock); - idr_preload_end(); + ret = idr_get_index(&dca_idr, &dca_idr_lock, dca); if (ret < 0) return ret; + dca->id = ret; cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id); if (IS_ERR(cd)) { - spin_lock(&dca_idr_lock); - idr_remove(&dca_idr, dca->id); - spin_unlock(&dca_idr_lock); + idr_put_index(&dca_idr, &dca_idr_lock, dca->id); return PTR_ERR(cd); } dca->cd = cd; @@ -82,9 +73,7 @@ void dca_sysfs_remove_provider(struct dca_provider *dca) { device_unregister(dca->cd); dca->cd = NULL; - spin_lock(&dca_idr_lock); - idr_remove(&dca_idr, dca->id); - spin_unlock(&dca_idr_lock); + idr_put_index(&dca_idr, &dca_idr_lock, dca->id); } int __init dca_sysfs_init(void)