From patchwork Wed Aug 18 04:13:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 177092 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Wed, 18 Aug 2010 05:21:07 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1Ola9D-0004aF-6o for chris@printf.net; Wed, 18 Aug 2010 05:21:07 +0100 Received: by mail.laptop.org (Postfix) id 9FE872467E; Wed, 18 Aug 2010 00:20:48 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id 5CB622467B for ; Wed, 18 Aug 2010 00:20:48 -0400 (EDT) X-ASG-Debug-ID: 1282105264-0b74a00f0002-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id cdRZ9NJHqgNCia5O for ; Wed, 18 Aug 2010 00:21:05 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751441Ab0HREU5 (ORCPT ); Wed, 18 Aug 2010 00:20:57 -0400 Received: from mail.lixom.net ([70.86.134.90]:54152 "EHLO mail.lixom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750798Ab0HREUy (ORCPT ); Wed, 18 Aug 2010 00:20:54 -0400 X-Greylist: delayed 441 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Aug 2010 00:20:54 EDT Received: by mail.lixom.net (Postfix, from userid 1000) id 96D4A566119; Tue, 17 Aug 2010 23:13:33 -0500 (CDT) Date: Tue, 17 Aug 2010 23:13:33 -0500 From: Olof Johansson To: linux-mmc@vger.kernel.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org X-ASG-Orig-Subj: [PATCH] mmc: make number of mmcblk minors configurable Subject: [PATCH] mmc: make number of mmcblk minors configurable Message-ID: <20100818041333.GA14149@lixom.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1282105265 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.38285 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig index 3f2a912..e939dcf 100644 --- a/drivers/mmc/card/Kconfig +++ b/drivers/mmc/card/Kconfig @@ -14,6 +14,16 @@ config MMC_BLOCK mount the filesystem. Almost everyone wishing MMC support should say Y or M here. +config MMC_BLOCK_MINORS + int "Number of minors per block device" + range 4 32 + default 8 + help + Number of minors per block device. One is needed for every + partition (plus one for the whole device). + Default is 8 to be backwards compatible with previous + hardcoded device numbering. + config MMC_BLOCK_BOUNCE bool "Use bounce buffer for simple hosts" depends on MMC_BLOCK diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index d545f79..524e232 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -45,13 +45,9 @@ MODULE_ALIAS("mmc:block"); -/* - * max 8 partitions per card - */ -#define MMC_SHIFT 3 -#define MMC_NUM_MINORS (256 >> MMC_SHIFT) +#define MMC_MAX_DEVICES ((255 + CONFIG_MMC_BLOCK_MINORS) / CONFIG_MMC_BLOCK_MINORS) -static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); +static DECLARE_BITMAP(dev_use, MMC_MAX_DEVICES); /* * There is one mmc_blk_data per slot. @@ -88,10 +84,10 @@ static void mmc_blk_put(struct mmc_blk_data *md) md->usage--; if (md->usage == 0) { int devmaj = MAJOR(disk_devt(md->disk)); - int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT; + int devidx = MINOR(disk_devt(md->disk)) / CONFIG_MMC_BLOCK_MINORS; if (!devmaj) - devidx = md->disk->first_minor >> MMC_SHIFT; + devidx = md->disk->first_minor / CONFIG_MMC_BLOCK_MINORS; blk_cleanup_queue(md->queue.queue); @@ -567,8 +563,8 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) struct mmc_blk_data *md; int devidx, ret; - devidx = find_first_zero_bit(dev_use, MMC_NUM_MINORS); - if (devidx >= MMC_NUM_MINORS) + devidx = find_first_zero_bit(dev_use, MMC_MAX_DEVICES); + if (devidx >= MMC_MAX_DEVICES) return ERR_PTR(-ENOSPC); __set_bit(devidx, dev_use); @@ -585,7 +581,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) */ md->read_only = mmc_blk_readonly(card); - md->disk = alloc_disk(1 << MMC_SHIFT); + md->disk = alloc_disk(CONFIG_MMC_BLOCK_MINORS); if (md->disk == NULL) { ret = -ENOMEM; goto err_kfree; @@ -602,7 +598,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) md->queue.data = md; md->disk->major = MMC_BLOCK_MAJOR; - md->disk->first_minor = devidx << MMC_SHIFT; + md->disk->first_minor = devidx * CONFIG_MMC_BLOCK_MINORS; md->disk->fops = &mmc_bdops; md->disk->private_data = md; md->disk->queue = md->queue.queue;