summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/sdmmc-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-10-22 15:55:28 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-10-22 15:55:28 +0200
commit4aa32fb8f4b2921cca6e17716d7ad8a7a30f192a (patch)
treebfe0747973862191374cd44d7ffd8e9217264388 /firmware/target/arm/imx233/sdmmc-imx233.c
parent51ed6da0b1a79b86e3e41eed3b6671eadb0081a6 (diff)
downloadrockbox-4aa32fb8f4b2921cca6e17716d7ad8a7a30f192a.tar.gz
rockbox-4aa32fb8f4b2921cca6e17716d7ad8a7a30f192a.tar.bz2
rockbox-4aa32fb8f4b2921cca6e17716d7ad8a7a30f192a.zip
imx233: fix partition window computation
The code was broken in two ways: - it called storage_read_sectors with a wrong drive number - calling storage_read_sectors too early at boot time will fail because we are in the init function, so the drive is not yet registered. To fix this, use a user provided read callback instead of storage read functions. Change-Id: I5ab79d48391fae619d5f8ae09c3d499fc43854c8
Diffstat (limited to 'firmware/target/arm/imx233/sdmmc-imx233.c')
-rw-r--r--firmware/target/arm/imx233/sdmmc-imx233.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c
index cff801f6b9..24bf69e332 100644
--- a/firmware/target/arm/imx233/sdmmc-imx233.c
+++ b/firmware/target/arm/imx233/sdmmc-imx233.c
@@ -672,6 +672,12 @@ static int transfer_sectors(int drive, unsigned long start, int count, void *buf
return ret;
}
+// user specificies the sdmmc drive
+static int part_read_fn(intptr_t user, unsigned long start, int count, void* buf)
+{
+ return transfer_sectors(user, start, count, buf, true);
+}
+
static int init_drive(int drive)
{
int ret;
@@ -693,8 +699,8 @@ static int init_drive(int drive)
{
/* NOTE: at this point the window shows the whole disk so raw disk
* accesses can be made to lookup partitions */
- ret = imx233_partitions_compute_window(IF_MD(drive,) IMX233_PART_USER,
- &window_start[drive], &window_end[drive]);
+ ret = imx233_partitions_compute_window(IF_MD_DRV(drive), part_read_fn,
+ IMX233_PART_USER, &window_start[drive], &window_end[drive]);
if(ret)
panicf("cannot compute partitions window: %d", ret);
SDMMC_INFO(drive).numblocks = window_end[drive] - window_start[drive];