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

fs: fcb: rename variables differently than struct tag #75654

Merged
merged 1 commit into from
Jul 11, 2024
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
58 changes: 28 additions & 30 deletions include/zephyr/fs/fcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ struct fcb {
* Initialize FCB instance.
*
* @param[in] f_area_id ID of flash area where fcb storage resides.
* @param[in,out] fcb FCB instance structure.
* @param[in,out] fcbp FCB instance structure.
*
* @return 0 on success, non-zero on failure.
*/
int fcb_init(int f_area_id, struct fcb *fcb);
int fcb_init(int f_area_id, struct fcb *fcbp);

/**
* Appends an entry to circular buffer.
Expand All @@ -172,24 +172,24 @@ int fcb_init(int f_area_id, struct fcb *fcb);
* flash_area_write() to fcb flash_area.
* When you're finished, call fcb_append_finish() with loc as argument.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
* @param[in] len Length of data which are expected to be written as the entry
* payload.
* @param[out] loc entry location information
*
* @return 0 on success, non-zero on failure.
*/
int fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *loc);
int fcb_append(struct fcb *fcbp, uint16_t len, struct fcb_entry *loc);

/**
* Finishes entry append operation.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
* @param[in] append_loc entry location information
*
* @return 0 on success, non-zero on failure.
*/
int fcb_append_finish(struct fcb *fcb, struct fcb_entry *append_loc);
int fcb_append_finish(struct fcb *fcbp, struct fcb_entry *append_loc);

/**
* FCB Walk callback function type.
Expand All @@ -213,7 +213,7 @@ typedef int (*fcb_walk_cb)(struct fcb_entry_ctx *loc_ctx, void *arg);
*
* @param[in] sector fcb sector to be walked. If null, traverse entire
* storage.
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
* @param[in] cb pointer to the function which gets called for every
* entry. If cb wants to stop the walk, it should return
* non-zero value.
Expand All @@ -223,8 +223,7 @@ typedef int (*fcb_walk_cb)(struct fcb_entry_ctx *loc_ctx, void *arg);
* @return 0 on success, negative on failure (or transferred form callback
* return-value), positive transferred form callback return-value
*/
int fcb_walk(struct fcb *fcb, struct flash_sector *sector, fcb_walk_cb cb,
void *cb_arg);
int fcb_walk(struct fcb *fcbp, struct flash_sector *sector, fcb_walk_cb cb, void *cb_arg);

/**
* Get next fcb entry location.
Expand All @@ -237,73 +236,72 @@ int fcb_walk(struct fcb *fcb, struct flash_sector *sector, fcb_walk_cb cb,
* FCB storage. loc->fe_sector is set and loc->fe_elem_off is 0 function fetches
* the first entry location in the fcb sector.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
* @param[in,out] loc entry location information
*
* @return 0 on success, non-zero on failure.
*/
int fcb_getnext(struct fcb *fcb, struct fcb_entry *loc);
int fcb_getnext(struct fcb *fcbp, struct fcb_entry *loc);

/**
* Rotate fcb sectors
*
* Function erases the data from oldest sector. Upon that the next sector
* becomes the oldest. Active sector is also switched if needed.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
*/
int fcb_rotate(struct fcb *fcb);
int fcb_rotate(struct fcb *fcbp);

/**
* Start using the scratch block.
*
* Take one of the scratch blocks into use. So a scratch sector becomes
* active sector to which entries can be appended.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
*
* @return 0 on success, non-zero on failure.
*/
int fcb_append_to_scratch(struct fcb *fcb);
int fcb_append_to_scratch(struct fcb *fcbp);

/**
* Get free sector count.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
*
* @return Number of free sectors.
*/
int fcb_free_sector_cnt(struct fcb *fcb);
int fcb_free_sector_cnt(struct fcb *fcbp);

/**
* Check whether FCB has any data.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
*
* @return Positive value if fcb is empty, otherwise 0.
*/
int fcb_is_empty(struct fcb *fcb);
int fcb_is_empty(struct fcb *fcbp);

/**
* Finds the fcb entry that gives back up to n entries at the end.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
* @param[in] entries number of fcb entries the user wants to get
* @param[out] last_n_entry last_n_entry the fcb_entry to be returned
*
* @return 0 on there are any fcbs available; -ENOENT otherwise
*/
int fcb_offset_last_n(struct fcb *fcb, uint8_t entries,
struct fcb_entry *last_n_entry);
int fcb_offset_last_n(struct fcb *fcbp, uint8_t entries, struct fcb_entry *last_n_entry);

/**
* Clear fcb instance storage.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
*
* @return 0 on success; non-zero on failure
*/
int fcb_clear(struct fcb *fcb);
int fcb_clear(struct fcb *fcbp);

/**
* @}
Expand All @@ -319,30 +317,30 @@ int fcb_clear(struct fcb *fcb);
/**
* Read raw data from the fcb flash sector.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
* @param[in] sector FCB sector.
* @param[in] off Read offset form sector begin.
* @param[out] dst Destination buffer.
* @param[in] len Read-out size.
*
* @return 0 on success, negative errno code on fail.
*/
int fcb_flash_read(const struct fcb *fcb, const struct flash_sector *sector,
off_t off, void *dst, size_t len);
int fcb_flash_read(const struct fcb *fcbp, const struct flash_sector *sector, off_t off,
void *dst, size_t len);

/**
* Write raw data to the fcb flash sector.
*
* @param[in] fcb FCB instance structure.
* @param[in] fcbp FCB instance structure.
* @param[in] sector FCB sector.
* @param[in] off Write offset form sector begin.
* @param[in] src Source buffer.
* @param[in] len Write size.
*
* @return 0 on success, negative errno code on fail.
*/
int fcb_flash_write(const struct fcb *fcb, const struct flash_sector *sector,
off_t off, const void *src, size_t len);
int fcb_flash_write(const struct fcb *fcbp, const struct flash_sector *sector, off_t off,
const void *src, size_t len);

/**
* @}
Expand Down
Loading
Loading