diff options
author | Rob Clark <robdclark@gmail.com> | 2017-09-09 13:16:00 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-09-15 09:03:15 -0400 |
commit | 265edc03d5a19550d92cbd6e10631d5a15bdd1d5 (patch) | |
tree | d1275a8421fe74498d39d61059595c5648845eb2 /include/fat.h | |
parent | 21a24c3bf35bac83d66ce4a48eb0c7dd8a7227cb (diff) |
fs/fat: Clean up open-coded sector <-> cluster conversions
Use the clust_to_sect() helper that was introduced earlier, and add an
inverse sect_to_clust(), plus update the various spots that open-coded
this conversion previously.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/fat.h')
-rw-r--r-- | include/fat.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/fat.h b/include/fat.h index 0f58939124..bdeda95e6d 100644 --- a/include/fat.h +++ b/include/fat.h @@ -177,12 +177,16 @@ typedef struct { __u32 root_cluster; /* First cluster of root dir for FAT32 */ } fsdata; -/* TODO clean up places that are open-coding this: */ static inline u32 clust_to_sect(fsdata *fsdata, u32 clust) { return fsdata->data_begin + clust * fsdata->clust_size; } +static inline u32 sect_to_clust(fsdata *fsdata, u32 sect) +{ + return (sect - fsdata->data_begin) / fsdata->clust_size; +} + int file_fat_detectfs(void); int fat_exists(const char *filename); int fat_size(const char *filename, loff_t *size); |