Commit graph

22 commits

Author SHA1 Message Date
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Andrzej Puzdrowski 1c777dd52e fs/fcb: improve error handling in fcb_offset_last_n
Fix for not served error code in fcb_offset_last_n()
implementation.
Issue was reported by static code analyze scan.
Looks like the function might have failed silently
if aggressive access to the fcb instance
from another thread have been occurring while the function
have been processing the fcb storage.

fixes #20512

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-11-14 19:33:36 -05:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Andrzej Puzdrowski 94a022c954 fcb: start using errno codes
Switch form using privater FCB error codes to
errno codes. FCB private codes convention were compatible
with <errno.h> codes:
- 0 mean success
- negative values mean errors
- similar error types.
There was no sense to kept private FCB error codes.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-09-08 12:42:53 +02:00
Jan Van Winkel 0b30dc3478 fs: fcb: Increase temporary buffer in fcb_append
Increase temporary buffer size to 8 bytes in fcb_append to prevent
stack overflow in case flash alignment is bigger then 2 bytes.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-08-27 11:49:33 +02:00
Peter A. Bigot b3f99fe0aa subsys/fs: remove FS_FLASH_STORAGE_PARTITION
The last reference to this symbol was removed when flash area management
moved to devicetree.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-22 18:21:50 +02:00
Anas Nashif 4e48e87fd2 cleanup: include/: move crc.h to sys/crc.h
move crc.h to sys/crc.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif d918c98e1d cleanup: include/: move fcb.h to fs/fcb.h
move fcb.h to fs/fcb.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Anas Nashif b8424b4cae crc: deprecate old headers and issue warning when used
Change code to use crc.h instead crc{8,16,32}.h and issue warning when
old headers are used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-04 08:52:46 -06:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Ulf Magnusson 1073882998 subsys: kconfig: Remove 'default n' properties and clean up a bit
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Remove some 'default ""' properties on string symbols too.

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

This shorthand works for int/hex/string symbols too, not just for bool
symbols.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-12 23:13:22 -04:00
Andrzej Puzdrowski f4dcb4593d subsys: fs: fcb: fix - crc write size not aligned
This is bug-fix for issue #7311
FCB: CRC write size in append_finish doesn't honor
flash min write size

This patch changes write size to the minimum supported
write size.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-05-04 17:25:29 -04:00
Andrzej Puzdrowski 4954fe06f2 subsys: fs: fix generic storage partition selection
FS_FLASH_MAP_STORAGE keyword enables the storage partition,
but it was depend on flash_map module which is unused by
NFFS. This patch makes it independent thanks
to it is possible to enable the storage partition
without flash_map module.

FS_FLASH_MAP_STORAGE was renamed to
CONFIG_FS_FLASH_STORAGE_PARTITION
as it is independent for flash_map.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-05-04 10:14:01 -04:00
Johan Hedberg 9968cda453 fs: Convert NFFS partition to a generic one
The NFFS partition at the end of flash is also useful for any other
file system or even the Flash Circular Buffer (FCB). Rename the
partition from 'nffs_partition' to 'storage_partition' and make it
depend on a new hidden Kconfig entry which the relevant users will
select (such as NFFS and FCB).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-04-26 16:06:55 +05:30
Leandro Pereira 02dc6eb960 subsys: fcb: Check for mutex lock failure when walking FCB
Coverity-CID: 182195
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-02-17 09:14:16 -05:00
Andrzej Puzdrowski b3614c0b17 subsys: fs: fcb: remove f_area_id from fcb structure
It is faster to operate directly on flash_area pointer instead
of fetch it all the time using the fcb flash area id.
Also as f_area_id was needed only for get appropriate flash_area
pointer, so it is better to pass it only while initialization
the fcb and not store it in fcb instance data at all.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-02-07 09:51:26 -05:00
Andrzej Puzdrowski 95a9dbc4b3 subsys: fs: fcb: rework fcb_walk and its callback
Previously flash_area structure was the parameter for the callback
function for transferring sector location info.
Now flash_sector is used so relevant flash_area is missing for
the callback.

This patch introduces structure fcb_entry_ctx which incorporates
entries' location and relevant flash area. It is used to pass complete
information to the callback. Additional  pointer to the flash_area fcb
speeds up operations.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-02-07 09:51:26 -05:00
Christopher Collins e3cd915d8f fs: Convert FCB to use sectors (not areas)
Prior to this commit: `struct fcb` contained a pointer to an array of
`struct flash_area`.  Each entry in the array represented a flash sector
that the fcb comprised.

After commit: `struct fcb` contains a pointer to an array of `struct
flash_sector`, not `struct flash_area`.

Rationale: The FCB needs to know which sectors it occupies for its
rotate operation.  However, the `flash_area` type is meant to represent
a collection of sectors, not a single sector.  `struct flash_area`
contains information that the fcb does not need (e.g., area ID and
device ID).  Furthermore, the flash_map API provides a means of
converting a flash area ID to an array of sectors
(`flash_area_get_sectors()`), but no way to convert to an array of
areas.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-07 09:51:26 -05:00
Andrzej Puzdrowski b7f1289847 subsys: fs: Add Flash Circular Buffer
Zephyr already supports NFFS as a storage layer, but it might
be a little bit too heavyweight for certain applications in
memory-restricted ICs.

This module is response for need of Lightweight flash storage
capability. FCB is ported form MyNewt as native zephyr module.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00