Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuttx: switch to flash_area_get_sector #1764

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions boot/nuttx/include/flash_map_backend/flash_map_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ static inline uint8_t flash_area_get_device_id(const struct flash_area *fa)
}

/****************************************************************************
* Name: flash_area_sector_from_off
* Name: flash_area_get_sector
*
* Description:
* Retrieve the flash sector a given offset belongs to.
*
* Input Parameters:
* fap - flash area structure
* off - address offset.
* sector - flash sector
*
Expand All @@ -121,7 +122,8 @@ static inline uint8_t flash_area_get_device_id(const struct flash_area *fa)
*
****************************************************************************/

int flash_area_sector_from_off(off_t off, struct flash_sector *fs);
int flash_area_get_sector(const struct flash_area *fap, off_t off,
struct flash_sector *fs);

/****************************************************************************
* Name: flash_area_get_off
Expand Down
17 changes: 10 additions & 7 deletions boot/nuttx/src/flash_map_backend/flash_map_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,13 @@ int flash_area_id_from_image_offset(uint32_t offset)
}

/****************************************************************************
* Name: flash_area_sector_from_off
* Name: flash_area_get_sector
*
* Description:
* Retrieve the flash sector a given offset belongs to.
*
* Input Parameters:
* fap - flash area structure
* off - address offset.
* sector - flash sector
*
Expand All @@ -826,15 +827,17 @@ int flash_area_id_from_image_offset(uint32_t offset)
*
****************************************************************************/

int flash_area_sector_from_off(off_t off, struct flash_sector *fs)
int flash_area_get_sector(const struct flash_area *fap, off_t off,
struct flash_sector *fs)
{
struct flash_device_s *dev = lookup_flash_device_by_offset(off);
off_t offset = fap->fa_off + off;
struct flash_device_s *dev = lookup_flash_device_by_offset(offset);
if (dev == NULL)
{
return -errno;
}
{
return -errno;
}

fs->fs_off = (off / dev->mtdgeo.erasesize) * dev->mtdgeo.erasesize;
fs->fs_off = (offset / dev->mtdgeo.erasesize) * dev->mtdgeo.erasesize;
fs->fs_size = dev->mtdgeo.erasesize;

return 0;
Expand Down
Loading