From patchwork Wed Feb 1 18:44:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9550547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 68C1560424 for ; Wed, 1 Feb 2017 18:44:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AE6328450 for ; Wed, 1 Feb 2017 18:44:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F3F228466; Wed, 1 Feb 2017 18:44:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7788A28450 for ; Wed, 1 Feb 2017 18:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752996AbdBASoe (ORCPT ); Wed, 1 Feb 2017 13:44:34 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36271 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752759AbdBASoe (ORCPT ); Wed, 1 Feb 2017 13:44:34 -0500 Received: by mail-wm0-f67.google.com with SMTP id r18so7477597wmd.3 for ; Wed, 01 Feb 2017 10:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=XsHNy6WtetvzVfi6kC77VP55Ykv6FtrsLlqRJ5akUak=; b=hzAir4sYFuhtZaSFRpxa2pFiEhvPwh0tF8HKVBGvSVHdrLorqcmFZXrruPiaYBa0WY r6SI+fwLZn8HHw8EsA/RyQuWU/N8TTOJE+dhcX63/fYTBcTitt6802w1K/9vE3JHdxyo QkY7LyTCHDDPdxErSeN3GdNAK+VUEAK3jRwtVVrTzmFyajYUMa2P9/yEv2TEaZKT1Hja HjlojoOHdNCIcInhmMlPJCVP6dXS3ddvPeMrmBXKo42ZLRW89xXhPAEnj6YIqm/aw8E+ 9VXmx4YDhFYvD5VCip0pz9O350v+TeX2QVAQM3s/FzMEzY8op/92sJwW8sFlii7b4z1L JUrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=XsHNy6WtetvzVfi6kC77VP55Ykv6FtrsLlqRJ5akUak=; b=B/u7yfezrnASyTvKja+57XusSGnn9yfNgW9AvB53HIqsBpqBlgBf2HP1rAFvGmU0HI UpoAfrMBs2oGFn3433YzzbppnCecNWm4XM/a8Ve06oaU+/JFEp0irqdZCOvwTOnZYKu6 ivHXhKpuTrHXtXIHdN8IrYWq0JEgXe0cwXgr/L9fOxg1V1Q81oRfNDCGTd54GUMNf0iY 1mg/pd3Xg5k2yMd64AQRNuYObR9t+sFTALmvQwQ0seKBf6hGeZipV8eO0y4oCjrBL2yw iCKG33ug99Aus1HxHpX02+cfrlQfTNZVGY5cCh7MvYYeGY8AS3IabBVLNCd7TQUZwqrW kQwA== X-Gm-Message-State: AIkVDXKt26Fwhg3VmkrZX9sAdxDcDUZB1OaOe/EncmHGrTIS93KIzAg3K+0AY/YEo5uivQ== X-Received: by 10.28.230.91 with SMTP id d88mr23469557wmh.129.1485974672426; Wed, 01 Feb 2017 10:44:32 -0800 (PST) Received: from ?IPv6:2003:c6:ebc5:6c00:7c0d:c568:586a:c33c? (p200300C6EBC56C007C0DC568586AC33C.dip0.t-ipconnect.de. [2003:c6:ebc5:6c00:7c0d:c568:586a:c33c]) by smtp.googlemail.com with ESMTPSA id y80sm35714904wrb.12.2017.02.01.10.44.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 10:44:31 -0800 (PST) To: Ulf Hansson Cc: linux-mmc@vger.kernel.org From: Heiner Kallweit Subject: [PATCH] mmc: core: switch to ida_simple_ functions in block.c Message-ID: <9c4a989c-0962-0471-5e67-c405f5232efc@gmail.com> Date: Wed, 1 Feb 2017 19:44:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ida code in block.c can be significantly simplified by switching to the ida_simple_ functions. Signed-off-by: Heiner Kallweit --- drivers/mmc/core/block.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index ede759dd..d5d8b0e6 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -90,7 +90,6 @@ static int max_devices; #define MAX_DEVICES 256 static DEFINE_IDA(mmc_blk_ida); -static DEFINE_SPINLOCK(mmc_blk_lock); /* * There is one mmc_blk_data per slot. @@ -163,11 +162,7 @@ static void mmc_blk_put(struct mmc_blk_data *md) if (md->usage == 0) { int devidx = mmc_get_devidx(md->disk); blk_cleanup_queue(md->queue.queue); - - spin_lock(&mmc_blk_lock); - ida_remove(&mmc_blk_ida, devidx); - spin_unlock(&mmc_blk_lock); - + ida_simple_remove(&mmc_blk_ida, devidx); put_disk(md->disk); kfree(md); } @@ -1836,23 +1831,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, struct mmc_blk_data *md; int devidx, ret; -again: - if (!ida_pre_get(&mmc_blk_ida, GFP_KERNEL)) - return ERR_PTR(-ENOMEM); - - spin_lock(&mmc_blk_lock); - ret = ida_get_new(&mmc_blk_ida, &devidx); - spin_unlock(&mmc_blk_lock); - - if (ret == -EAGAIN) - goto again; - else if (ret) - return ERR_PTR(ret); - - if (devidx >= max_devices) { - ret = -ENOSPC; - goto out; - } + devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL); + if (devidx < 0) + return ERR_PTR(devidx); md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL); if (!md) { @@ -1941,9 +1922,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, err_kfree: kfree(md); out: - spin_lock(&mmc_blk_lock); - ida_remove(&mmc_blk_ida, devidx); - spin_unlock(&mmc_blk_lock); + ida_simple_remove(&mmc_blk_ida, devidx); return ERR_PTR(ret); }