@@ -80,17 +80,25 @@ struct zms_fs {
8080 * @brief Mount a ZMS file system onto the device specified in `fs`.
8181 *
8282 * @param fs Pointer to the file system.
83- * @retval 0 Success
84- * @retval -ERRNO Negative errno code on error
83+ *
84+ * @retval 0 on success.
85+ * @retval -ENOTSUP if the detected file system is not ZMS.
86+ * @retval -EPROTONOSUPPORT if the ZMS version is not supported.
87+ * @retval -EINVAL if any of the flash parameters or the sector layout is invalid.
88+ * @retval -ENXIO if there is a device error.
89+ * @retval -EIO if there is a memory read/write error.
8590 */
8691int zms_mount (struct zms_fs * fs );
8792
8893/**
8994 * @brief Clear the ZMS file system from device.
9095 *
9196 * @param fs Pointer to the file system.
92- * @retval 0 Success
93- * @retval -ERRNO Negative errno code on error
97+ *
98+ * @retval 0 on success.
99+ * @retval -EACCES if `fs` is not mounted.
100+ * @retval -ENXIO if there is a device error.
101+ * @retval -EIO if there is a memory read/write error.
94102 */
95103int zms_clear (struct zms_fs * fs );
96104
@@ -102,65 +110,86 @@ int zms_clear(struct zms_fs *fs);
102110 * entry and an entry with data of length 0.
103111 *
104112 * @param fs Pointer to the file system.
105- * @param id ID of the entry to be written
106- * @param data Pointer to the data to be written
107- * @param len Number of bytes to be written (maximum 64 KiB)
113+ * @param id ID of the entry to be written.
114+ * @param data Pointer to the data to be written.
115+ * @param len Number of bytes to be written (maximum 64 KiB).
108116 *
109117 * @return Number of bytes written. On success, it will be equal to the number of bytes requested
110118 * to be written or 0.
111119 * When a rewrite of the same data already stored is attempted, nothing is written to flash,
112120 * thus 0 is returned. On error, returns negative value of error codes defined in `errno.h`.
121+ * @retval Number of bytes written (`len` or 0) on success.
122+ * @retval -EACCES if ZMS is still not initialized.
123+ * @retval -ENXIO if there is a device error.
124+ * @retval -EIO if there is a memory read/write error.
125+ * @retval -EINVAL if `len` is invalid.
126+ * @retval -ENOSPC if no space is left on the device.
113127 */
114128ssize_t zms_write (struct zms_fs * fs , uint32_t id , const void * data , size_t len );
115129
116130/**
117131 * @brief Delete an entry from the file system
118132 *
119133 * @param fs Pointer to the file system.
120- * @param id ID of the entry to be deleted
121- * @retval 0 Success
122- * @retval -ERRNO Negative errno code on error
134+ * @param id ID of the entry to be deleted.
135+ *
136+ * @retval 0 on success.
137+ * @retval -EACCES if ZMS is still not initialized.
138+ * @retval -ENXIO if there is a device error.
139+ * @retval -EIO if there is a memory read/write error.
123140 */
124141int zms_delete (struct zms_fs * fs , uint32_t id );
125142
126143/**
127144 * @brief Read an entry from the file system.
128145 *
129146 * @param fs Pointer to the file system.
130- * @param id ID of the entry to be read
131- * @param data Pointer to data buffer
132- * @param len Number of bytes to read at most
147+ * @param id ID of the entry to be read.
148+ * @param data Pointer to data buffer.
149+ * @param len Number of bytes to read at most.
133150 *
134151 * @return Number of bytes read. On success, it will be equal to the number of bytes requested
135152 * to be read or less than that if the stored data has a smaller size than the requested one.
136153 * On error, returns negative value of error codes defined in `errno.h`.
154+ * @retval Number of bytes read (> 0) on success.
155+ * @retval -EACCES if ZMS is still not initialized.
156+ * @retval -EIO if there is a memory read/write error.
157+ * @retval -ENOENT if there is no entry with the given `id`.
137158 */
138159ssize_t zms_read (struct zms_fs * fs , uint32_t id , void * data , size_t len );
139160
140161/**
141162 * @brief Read a history entry from the file system.
142163 *
143164 * @param fs Pointer to the file system.
144- * @param id ID of the entry to be read
145- * @param data Pointer to data buffer
146- * @param len Number of bytes to be read
165+ * @param id ID of the entry to be read.
166+ * @param data Pointer to data buffer.
167+ * @param len Number of bytes to be read.
147168 * @param cnt History counter: 0: latest entry, 1: one before latest ...
148169 *
149170 * @return Number of bytes read. On success, it will be equal to the number of bytes requested
150171 * to be read. When the return value is larger than the number of bytes requested to read this
151172 * indicates not all bytes were read, and more data is available. On error, returns negative
152173 * value of error codes defined in `errno.h`.
174+ * @retval Number of bytes read (> 0) on success.
175+ * @retval -EACCES if ZMS is still not initialized.
176+ * @retval -EIO if there is a memory read/write error.
177+ * @retval -ENOENT if there is no entry with the given `id` and history counter.
153178 */
154179ssize_t zms_read_hist (struct zms_fs * fs , uint32_t id , void * data , size_t len , uint32_t cnt );
155180
156181/**
157- * @brief Gets the length of the data that is stored in an entry with a given ID
182+ * @brief Gets the length of the data that is stored in an entry with a given `id`
158183 *
159184 * @param fs Pointer to the file system.
160185 * @param id ID of the entry whose data length to retrieve.
161186 *
162187 * @return Data length contained in the ATE. On success, it will be equal to the number of bytes
163188 * in the ATE. On error, returns negative value of error codes defined in `errno.h`.
189+ * @retval Length of the entry with the given `id` (> 0) on success.
190+ * @retval -EACCES if ZMS is still not initialized.
191+ * @retval -EIO if there is a memory read/write error.
192+ * @retval -ENOENT if there is no entry with the given id and history counter.
164193 */
165194ssize_t zms_get_data_length (struct zms_fs * fs , uint32_t id );
166195
@@ -173,6 +202,9 @@ ssize_t zms_get_data_length(struct zms_fs *fs, uint32_t id);
173202 * still be written to the file system.
174203 * Calculating the free space is a time-consuming operation, especially on SPI flash.
175204 * On error, returns negative value of error codes defined in `errno.h`.
205+ * @retval Number of free bytes (>= 0) on success.
206+ * @retval -EACCES if ZMS is still not initialized.
207+ * @retval -EIO if there is a memory read/write error.
176208 */
177209ssize_t zms_calc_free_space (struct zms_fs * fs );
178210
@@ -181,7 +213,8 @@ ssize_t zms_calc_free_space(struct zms_fs *fs);
181213 *
182214 * @param fs Pointer to the file system.
183215 *
184- * @return Number of free bytes.
216+ * @retval >=0 Number of free bytes in the currently active sector
217+ * @retval -EACCES if ZMS is still not initialized.
185218 */
186219size_t zms_active_sector_free_space (struct zms_fs * fs );
187220
@@ -196,7 +229,9 @@ size_t zms_active_sector_free_space(struct zms_fs *fs);
196229 *
197230 * @param fs Pointer to the file system.
198231 *
199- * @return 0 on success. On error, returns negative value of error codes defined in `errno.h`.
232+ * @retval 0 on success.
233+ * @retval -EACCES if ZMS is still not initialized.
234+ * @retval -EIO if there is a memory read/write error.
200235 */
201236int zms_sector_use_next (struct zms_fs * fs );
202237
0 commit comments