mmcsd_sdio:Fix breakage from 997d4 SD not functional

When CONFIG_MMCSD_MULTIBLOCK_DISABLE is lit, all SD
   read/write failed. The function return the number of
   blocks in `ret`, set on entry to nsectors. That was
   then wiped out by using the ret for the mmcsd_takesem.

   Since the code had many path setting return, the choices for
   the fix could have been add a new varaible or simple init it
   were used. I choose the latter.
This commit is contained in:
David Sidrane
2020-08-18 12:21:35 -07:00
committed by Xiang Xiao
parent 1d97b2ecee
commit e21dd68755
+5
View File
@@ -2245,6 +2245,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer,
#elif defined(CONFIG_MMCSD_MULTIBLOCK_DISABLE) #elif defined(CONFIG_MMCSD_MULTIBLOCK_DISABLE)
/* Read each block using only the single block transfer method */ /* Read each block using only the single block transfer method */
ret = nsectors;
endsector = startsector + nsectors - 1; endsector = startsector + nsectors - 1;
for (sector = startsector; sector <= endsector; sector++) for (sector = startsector; sector <= endsector; sector++)
{ {
@@ -2309,6 +2310,8 @@ static ssize_t mmcsd_write(FAR struct inode *inode,
finfo("sector: %lu nsectors: %u sectorsize: %u\n", finfo("sector: %lu nsectors: %u sectorsize: %u\n",
(unsigned long)startsector, nsectors, priv->blocksize); (unsigned long)startsector, nsectors, priv->blocksize);
if (nsectors > 0)
{
ret = mmcsd_takesem(priv); ret = mmcsd_takesem(priv);
if (ret < 0) if (ret < 0)
{ {
@@ -2323,6 +2326,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode,
#elif defined(CONFIG_MMCSD_MULTIBLOCK_DISABLE) #elif defined(CONFIG_MMCSD_MULTIBLOCK_DISABLE)
/* Write each block using only the single block transfer method */ /* Write each block using only the single block transfer method */
ret = nsectors;
endsector = startsector + nsectors - 1; endsector = startsector + nsectors - 1;
for (sector = startsector; sector <= endsector; sector++) for (sector = startsector; sector <= endsector; sector++)
{ {
@@ -2354,6 +2358,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode,
#endif #endif
mmcsd_givesem(priv); mmcsd_givesem(priv);
}
/* On success, return the number of blocks written */ /* On success, return the number of blocks written */