From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 04/10] Don't try to guess the size of a disk if its size value is already given
Date: Fri, 8 Oct 2010 18:30:52 +0200 [thread overview]
Message-ID: <1286555458-20125-5-git-send-email-jbe@pengutronix.de> (raw)
In-Reply-To: <1286555458-20125-1-git-send-email-jbe@pengutronix.de>
Guessing the size of an attached harddisk (access via x86 BIOS) was needed
due to the fact, barebox can't query this information from the BIOS easily.
But with the SD/MMC cards, there will be a second user of the generic disk
handling routines. And with this media it is very easy to know its size.
This patch provides a workaround to keep the guessing feature if the size of
the registered disk is 0. If it is not 0, the given value will be used instead.
Note: This is in preparation to add MCI card support, which can be handled
like a disk drive.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
arch/x86/boards/x86_generic/generic_pc.c | 2 +-
drivers/ata/disk_drive.c | 27 ++++++++++++++++++---------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c
index a6cd7e0..b9c31aa 100644
--- a/arch/x86/boards/x86_generic/generic_pc.c
+++ b/arch/x86/boards/x86_generic/generic_pc.c
@@ -46,7 +46,7 @@ static struct device_d sdram_dev = {
static struct device_d bios_disk_dev = {
.id = -1,
.name = "biosdrive",
- .size = 1,
+ .size = 0, /* auto guess */
};
/*
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
index 15ef5f4..a54429a 100644
--- a/drivers/ata/disk_drive.c
+++ b/drivers/ata/disk_drive.c
@@ -23,6 +23,7 @@
* @brief Generic disk drive support
*
* @todo Support for disks larger than 4 GiB
+ * @todo Reliable size detection for BIOS based disks (on x86 only)
*/
#include <stdio.h>
@@ -299,11 +300,16 @@ static int disk_probe(struct device_d *dev)
else
#endif
disk_cdev->name = asprintf("disk%d", dev->id);
- /**
- * @todo we need the size of the drive, else its nearly impossible
- * to do anything with it (at least with the generic routines)
- */
- disk_cdev->size = 32; /* FIXME */
+
+ /* On x86, BIOS based disks are coming without a valid .size field */
+ if (dev->size == 0) {
+ /*
+ * We need always the size of the drive, else its nearly impossible
+ * to do anything with it (at least with the generic routines)
+ */
+ disk_cdev->size = 32;
+ } else
+ disk_cdev->size = dev->size;
disk_cdev->ops = &disk_ops;
disk_cdev->dev = dev;
devfs_create(disk_cdev);
@@ -314,10 +320,13 @@ static int disk_probe(struct device_d *dev)
goto on_error;
}
- /* guess the size of this drive */
- dev->size = disk_guess_size(dev, (struct partition_entry*)§or[446]) * SECTOR_SIZE;
- dev_info(dev, "Drive size guessed to %u kiB\n", dev->size / 1024);
- disk_cdev->size = dev->size;
+ if (dev->size == 0) {
+ /* guess the size of this drive if not otherwise given */
+ dev->size = disk_guess_size(dev,
+ (struct partition_entry*)§or[446]) * SECTOR_SIZE;
+ dev_info(dev, "Drive size guessed to %u kiB\n", dev->size / 1024);
+ disk_cdev->size = dev->size;
+ }
rc = disk_register_partitions(dev, (struct partition_entry*)§or[446]);
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2010-10-08 16:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-08 16:30 [PATCH v2] Add MCI card support to barebox Juergen Beisert
2010-10-08 16:30 ` [PATCH 01/10] x-functions do not return in case of failure Juergen Beisert
2010-10-08 16:30 ` [PATCH 02/10] Make the disk driver less noisy Juergen Beisert
2010-10-08 16:30 ` [PATCH 03/10] Don't use a sector buffer on stack Juergen Beisert
2010-10-08 16:30 ` Juergen Beisert [this message]
2010-10-08 16:30 ` [PATCH 05/10] Add MCI card support to barebox Juergen Beisert
2010-10-08 16:30 ` [PATCH 06/10] Add i.MX23 MCI card support Juergen Beisert
2010-10-08 16:30 ` [PATCH 07/10] Add S3C2440 " Juergen Beisert
2010-10-08 16:30 ` [PATCH 08/10] i.MX27: Add mmc clock support in order to add an i.MX MCI driver Juergen Beisert
2010-10-08 16:30 ` [PATCH 09/10] mci: Add i.MX27/31 driver Juergen Beisert
2010-10-08 16:30 ` [PATCH 10/10] ARM pca100: Add mci support Juergen Beisert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1286555458-20125-5-git-send-email-jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox