summaryrefslogtreecommitdiffstats
path: root/common/state
Commit message (Collapse)AuthorAgeFilesLines
...
* state: Allow to load without authentificationSascha Hauer2017-03-315-11/+28
| | | | | | | Sometimes it's useful to be able to load a state even when it can't be authentificated. Add an option for this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend bucket circular: Explain metadataSascha Hauer2017-03-311-0/+5
| | | | | | Explain why we have metadata and where it is used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: Set minumum writesize to 8Sascha Hauer2017-03-311-0/+3
| | | | | | | | NOR flashes have a write size of 1. With this the metadata may end up on non-4-byte-aligned offsets. Force the minimum writesize to 8 so that the metadata is always at aligned offsets. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_raw: alloc digest only when neededSascha Hauer2017-03-311-53/+59
| | | | | | | | Instead of deferring probe just allocate the digest when it's needed. This way the credentials can be added later, possibly on the commandline. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: rename more variablesSascha Hauer2017-03-311-6/+6
| | | | | | Use "buckets" rather than "copies" in variable names. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: make locally used variable staticSascha Hauer2017-03-311-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: rewrite function docSascha Hauer2017-03-311-2/+2
| | | | | | | The function documentation for state_storage_file_buckets_init() is not very accurate. Rewrite it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: Rename variable desired_copies to desired_bucketsSascha Hauer2017-03-311-9/+9
| | | | | | | | | We defined what a bucket is, so rename the variable that holds the number of desired buckets from desired_copies to desired_buckets. While at it, make locally used variable static. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: Rename variable nr_copies to n_bucketsSascha Hauer2017-03-311-12/+12
| | | | | | | We defined what a bucket is, so use n_buckets when counting buckets, and not nr_copies. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: rewrite function docSascha Hauer2017-03-311-5/+3
| | | | | | | The commment talks about copies where buckets are meant and also claims we start at offset 0, which may not be true. Rewrite comment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: default to circular storageSascha Hauer2017-03-311-6/+8
| | | | | | | | Default to the new circular storage format which saves erase cycles. The old format can still be selected with backend-storage-type = "noncircular". Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: Add some documentationSascha Hauer2017-03-312-1/+37
| | | | | | Write some sentences to make the concepts clearer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: storage: direct: do not close file that is not openedSascha Hauer2017-03-311-1/+0
| | | | | | When open failed to not try to close the invalid fd afterwards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: remove unnecessary warningSascha Hauer2017-03-311-4/+1
| | | | | | | It's expected that NAND flashes contain bad blocks, do not warn about them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: Add more fields to struct state_backend_storageSascha Hauer2017-03-312-28/+26
| | | | | | To save a few function arguments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_bucket_direct: max_size is always givenSascha Hauer2017-03-311-1/+1
| | | | | | max_size is always != 0, so if(direct->max_size) can be skipped. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: bucket: Make output more informativeSascha Hauer2017-03-312-10/+18
| | | | | | | | | | | Print offset and number of the bucket along with the bucket specific messages to give a hint which bucket a message is for. Also it's pretty much expected that buckets sometimes have no data or need cleanup, so instead of complaining loudly, only write which bucket is used and which buckets are cleaned up. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend-direct: Fix max_sizeSascha Hauer2017-03-311-1/+1
| | | | | | | The max_size in the direct backend includes the meta data, so substract its size when determing the max data size we can store. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Drop cache bucketSascha Hauer2017-03-314-190/+71
| | | | | | | | | | | | | | The cache bucket sits between the storage functions and the backend storage. We only read from the storage once, so there is no need to cache anything. The real purpose of the cache bucket is to keep the -EUCLEAN information when a NAND block needs to be rewritten and to keep the read buffers as long as the backend iterates over all buckets trying to find the one we want to use. This can be coded easier and more obvious in the backend code, so drop the cache bucket. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Convert all bufs to void *Sascha Hauer2017-03-318-35/+35
| | | | | | | | A void * is a much better type for a buffer than a u8 * as it can be casted to any other type implicitly. Convert all buffers used by the state framework to void *. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: replace len_hint logicSascha Hauer2017-03-316-17/+21
| | | | | | | | The len_hint mechanism is rather hard to understand as it's not clear from where to where the hint is passed and also it's not clear what happens if the hint is empty or wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: simplify direct backendSascha Hauer2017-03-311-131/+14
| | | | | | | | | - drop support for regular files. This, if at all, is only useful for debugging. For the debugging case still a file of sufficient size can be created manually. - make stridesize mandatory. Makes the code simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: drop lazy_initSascha Hauer2017-03-314-60/+6
| | | | | | | | | lazy_init is an optimization that makes it possible to read only up to the first valid bucket when starting. However, when restoring consistency, immediately afterwards we have we have to initialize all buckets anyway, so being lazy doesn't give us any gain. Remove it to simplify the code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: Read whole PEBSascha Hauer2017-03-311-10/+8
| | | | | | | | | | | When the circular backend searches for the last page written in the eraseblock, it iterates backwards pagewise from the end of the block. This is ok for NAND flash, but on NOR flash, which does not have pages, the code ends up iterating bytewise backwards, calling into mtd each time. This is very time consuming, so optimize this by reading the whole eraseblock once and just iterate over the buffer in memory. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: storage: initialize variable once outside loopSascha Hauer2017-03-311-4/+6
| | | | | | | writesize is initialized with the same value in each loop iteration, Instead, initialize it once outside the loop. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: pass struct state * to storage functionsSascha Hauer2017-03-313-7/+5
| | | | | | | We can get a state_backend_storage * and the device * from struct state, so pass this to the storage functions rather than the two pointers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: remove unnecessary argument from state_format_initSascha Hauer2017-03-311-7/+6
| | | | | | | The device pointer is already in struct state, no need to pass it around when a struct state * is already passed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: open code state_backend_init in callerSascha Hauer2017-03-311-57/+13
| | | | | | | Safes a lot of argument passing to a function that is used only once. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: merge backend.c into state.cSascha Hauer2017-03-314-190/+161
| | | | | | | The code in backend.c is too small to justify an extra file. Merge it into state.c. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Drop backend as extra struct typeSascha Hauer2017-03-313-59/+46
| | | | | | | struct state_backend is embedded into struct state. This additional indirection does not have any real gain. Drop it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: remove len_hint argument from state_storage_readSascha Hauer2017-03-313-7/+4
| | | | | | The argument is 0 in the only caller, so remove the argument. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: remove .get_packed_lenSascha Hauer2017-03-312-5/+0
| | | | | | | .get_packed_len isn't implemented by any backend, so remove the hook and its potential caller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Use positive logicSascha Hauer2017-03-311-7/+7
| | | | | | | bools with "non" in the names are rather confusing. Switch to positive logic. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Make pointing to the backend using a phandle the only supported methodSascha Hauer2017-03-311-12/+9
| | | | | | | | | | All other methods are broken for some time already: When starting the kernel the state code rewrites the state node in the device tree and replaced the "backend" property with a phandle - even when the target can't be described as a phandle. Since using phandles is the nicest way to point to the storage device anyway remove the other methods. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Use of_property_write_string() where appropriateSascha Hauer2017-03-301-3/+2
| | | | | | | Replace users which use of_set_property() to set a property to a string with of_property_write_string(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend circular: Fix wrong commentSascha Hauer2017-03-271-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: bucket_circular: -EUCLEAN means data could be readSascha Hauer2017-03-231-1/+1
| | | | | | | | -EUCLEAN returned from state_mtd_peb_read() means that the data shall still be used. This fixes initialization of buckets which need cleanup Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: bucket_cached: Fix reading pages which need cleanupSascha Hauer2017-03-231-4/+4
| | | | | | | | When the raw device returns -EUCLEAN we have to return successfully to the upper layer, otherwise it will discard the data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/state'Sascha Hauer2016-11-145-12/+13
|\
| * state: fix indentationStefan Lengfeld2016-11-031-3/+3
| | | | | | | | | | Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * state: use packed attribute for on storage structsStefan Lengfeld2016-11-033-3/+3
| | | | | | | | | | | | | | | | | | | | | | These structs are used for on-storage data layouts. They should be not affected by different integer precisions and alignment optimizations of 32bit or 64bit machines. Using the architecture independent integer data types, like uint32_t, achieves the former, using the packed attribute the later. Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * state: Use dev_* for information rather than pr_*Sascha Hauer2016-10-201-4/+4
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * state: pass error code instead of inventing new oneSascha Hauer2016-10-201-3/+4
| | | | | | | | | | | | | | | | Both of_find_path() and of_find_path_by_node() return a meaningful error code, so forward it instead of inventing a new one. Do this especially for the -EPROBE_DEFER case which currently does not work. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | state: fix state is not saved when string variable is changedStefan Lengfeld2016-11-031-1/+1
|/ | | | | | | The dirty flag was not set properly. Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: consistently pass one type as private data to dev_add_param_*Sascha Hauer2016-09-201-14/+15
| | | | | | | The different dev_add_param_* calls all use different types as private data. This is unnecessary, use struct state_variable * for all of them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: make locally used function staticSascha Hauer2016-09-202-2/+1
| | | | | | state_set_dirty() is only used in one file, make it static. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Add state to state_variableSascha Hauer2016-09-202-6/+8
| | | | | | | A state variable should know which state it belongs to. Add field for it to struct state_variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: fix finding the correct parent nodeMichael Olbrich2016-09-201-2/+2
| | | | | | | | | | Looking for the parent node during fixup is broken. The path of the parent node is not correctly terminated ('0' vs '\0'). Also, the new state node should be added to the supplied device tree not the barebox device tree used by of_find_node_by_path(). Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: don't keep pointers to device tree nodesMichael Olbrich2016-09-202-8/+13
| | | | | | | | | | Caching pointers to device tree nodes or is not save. The barebox internal device tree may be changed by loading a new device tree or through fixup handlers. As a result, the node may be deleted and replaced with a new one. Keep a copy of the full path instead and resolve the node as needed. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: copy backend of_path stringMichael Olbrich2016-09-202-2/+3
| | | | | | | | | | Caching pointers to device tree nodes or names is not safe. The barebox internal device tree may be changed by loading a new device tree or through fixup handlers. As a result, the string may be deleted. Use local copies of the full path instead. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>