From patchwork Sat Jan 28 08:32:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9543111 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 021A46016C for ; Sat, 28 Jan 2017 08:42:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E89D628249 for ; Sat, 28 Jan 2017 08:42:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD13F28304; Sat, 28 Jan 2017 08:42:48 +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 874E828249 for ; Sat, 28 Jan 2017 08:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751233AbdA1Imq (ORCPT ); Sat, 28 Jan 2017 03:42:46 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34413 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750904AbdA1Imf (ORCPT ); Sat, 28 Jan 2017 03:42:35 -0500 Received: by mail-wm0-f65.google.com with SMTP id c85so63318169wmi.1 for ; Sat, 28 Jan 2017 00:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=GT7I05H0Ba4uk+S8oQiOAMWhunZkJThX/zTBegBKXtQ=; b=eOxCU2nungA0AuXKP3w6r5I57baSLXE8Pwfx6Wdkw3uDfvlPxFJ5WgDp+ne4i0V+d1 Tl+cOvWusvoJnc06BMH1R+eJcFUggGywKaRBpK9LVZNBoef3JUiLqvkOMY7inGrF2Rt9 WdW57rLE9wiG+oFt/BXECXnlsOwQv0WJXTAnUCyc30IDjq3YCcMBDD0MNEJvssk2UcDD 0+5SiBmplTq5Ub+UlW8U6Pm64g1Zx4iStnledq3iVI6rejgjSrxKJGYtDgxzrpPjMWF9 +yK/1t9/nANVJWaXgCInVQRBAYIF0NWYhfHRvLUlqbMNigj08e0D4oZJ0YcOatYsF1It m9Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=GT7I05H0Ba4uk+S8oQiOAMWhunZkJThX/zTBegBKXtQ=; b=p/RctI/NP+l33pwhrO70d6upP7IzXr85pL9AAEpxFzKylioXo0VitY8ygl1eb3agyQ VEDm4T6zDknreWVUlFu70ExmftUO5zuRqu6fnBraMQBXPs6T3bk8SdcYCNuzwHLXVQLP hoJyO6BU0l3QoZA7bfG0z9/QG/UljlPP0Qi5Peox4cS12hphawNvLteBvZTnssM4yzRu qUmgsTccZZg5U9xkhRCS4ZhDFmle6+r0CFymbmK2yy++/lH22C/CiVtEifOdK4Kdzg/s 0xAq6oPZapDZ8cJ6sYbCiQ3zfALp4JIALVxiXRgL7ejKOe1D8oIlDxkjz8VtWmGuhJ34 a43Q== X-Gm-Message-State: AIkVDXLVKUpOBpGVoUu2yaocSdinGDiYeJiE5qD0lBDmd/YzGOFz6YBJ4Vyb98BbmQvE0Q== X-Received: by 10.28.185.193 with SMTP id j184mr6758541wmf.86.1485592397198; Sat, 28 Jan 2017 00:33:17 -0800 (PST) Received: from ?IPv6:2003:c6:ebc5:6c00:45f2:4915:150a:1788? (p200300C6EBC56C0045F24915150A1788.dip0.t-ipconnect.de. [2003:c6:ebc5:6c00:45f2:4915:150a:1788]) by smtp.googlemail.com with ESMTPSA id s26sm11698782wra.26.2017.01.28.00.33.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jan 2017 00:33:16 -0800 (PST) From: Heiner Kallweit Subject: [PATCH 1/2] mmc: core: simplify ida handling To: Ulf Hansson Cc: linux-mmc@vger.kernel.org Message-ID: <4dae93b9-78f6-25c5-4836-4a70a5a00ab6@gmail.com> Date: Sat, 28 Jan 2017 09:32:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.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 handling can be simplified by switching to the ida_simple_ functions. Signed-off-by: Heiner Kallweit --- drivers/mmc/core/host.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 98f25ffb..0a26c8b6 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -34,14 +34,11 @@ #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) static DEFINE_IDA(mmc_host_ida); -static DEFINE_SPINLOCK(mmc_host_lock); static void mmc_host_classdev_release(struct device *dev) { struct mmc_host *host = cls_dev_to_mmc_host(dev); - spin_lock(&mmc_host_lock); - ida_remove(&mmc_host_ida, host->index); - spin_unlock(&mmc_host_lock); + ida_simple_remove(&mmc_host_ida, host->index); kfree(host); } @@ -354,22 +351,13 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) /* scanning will be enabled when we're ready */ host->rescan_disable = 1; -again: - if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) { + err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL); + if (err < 0) { kfree(host); return NULL; } - spin_lock(&mmc_host_lock); - err = ida_get_new(&mmc_host_ida, &host->index); - spin_unlock(&mmc_host_lock); - - if (err == -EAGAIN) { - goto again; - } else if (err) { - kfree(host); - return NULL; - } + host->index = err; dev_set_name(&host->class_dev, "mmc%d", host->index);