summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJuergen Beisert <jbe@pengutronix.de>2010-10-08 18:30:52 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-10-11 13:08:27 +0200
commit63690cc4061719813c3d271b993f04ffe98ba0e5 (patch)
tree509c4d5305b295a36adb15aa56d8103886a4acdd /drivers
parent5340589afcec8fad6df708b60888c45a8a6d08f9 (diff)
downloadbarebox-63690cc4061719813c3d271b993f04ffe98ba0e5.tar.gz
barebox-63690cc4061719813c3d271b993f04ffe98ba0e5.tar.xz
Don't try to guess the size of a disk if its size value is already given
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/disk_drive.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
index 15ef5f41b9..a54429a5f1 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*)&sector[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*)&sector[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*)&sector[446]);