From 265edc03d5a19550d92cbd6e10631d5a15bdd1d5 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 9 Sep 2017 13:16:00 -0400 Subject: 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 Reviewed-by: Simon Glass --- include/fat.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/fat.h') 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); -- cgit v1.2.3