summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
...
| * state: remove unused variable typeSascha Hauer2017-04-043-17/+0
| | | | | | | | | | | | enum state_variable_type is never used. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * state: find device node from device path, not from device node pathSascha Hauer2017-03-312-6/+6
| | | | | | | | | | | | | | | | | | The device node path may change from the internal device tree to the one Linux is started with, so using this path to fixup the tree is not very robust. Instead, use of_find_node_by_devpath() which has been created for exactly this purpose. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * state: Remove -EUCLEAN check from userspace toolSascha Hauer2017-03-311-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The state code is used for the userspace tool aswell, kept in sync manually. This patch only introduces a change for the userspace tool, not for barebox. In Linux userspace there is no direct possibility to check for -EUCLEAN. To indirectly check for -EUCLEAN the state tool reads the number of corrected bits before and after reading a block. Unfortunately it does not take the number of acceptable bitflips into account, but instead returns -EUCLEAN even when only a single bitflip occurred on a whole page. To be correct the algorithm must be more complicated: We would have to read the bitflip_threshold from sysfs. This value is per ECC step (often 512 byte), not per page. We would have to read the page in ECC step size chunks, testing for bitflips lower than the threshold for each chunk. Even if we would do that, there's still another issue. The eccstats ioctl delivers the eccstats for the whole device, so a concurrent reader would falsify the result. Let's decide that this is not worth the hassle and assume that no device has enough uptime that a cleanup in barebox is not sufficient. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * state: Do not load state during state_new_from_nodeSascha Hauer2017-03-311-5/+0
| | | | | | | | | | | | | | | | The caller of state_new_from_node() may have it's own ideas what to do when loading the state fails, so do not load it in the initialization function, but instead let the caller do it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * 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>
* | Merge branch 'for-next/ofpart'Sascha Hauer2017-04-074-5/+6
|\|
| * of: partitions: flag partitions from a partition tableSascha Hauer2017-03-311-0/+2
| | | | | | | | | | | | | | | | | | We are going to call the of_partition_fixup for regular block devices like MMC/SD aswell. Add a flag to partitions indicating they are instanciated from a on-disk partition table so that they won't be added as device tree partitions during fixup. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: Use of_property_write_string() where appropriateSascha Hauer2017-03-303-5/+4
| | | | | | | | | | | | | | 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>
* | Merge branch 'for-next/misc'Sascha Hauer2017-04-077-103/+246
|\ \
| * | globalvar: remove code for unqualified globalvarsSascha Hauer2017-04-071-42/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The globalvar_add_simple_* functions will fail when a globalvar of the name already exists. This happened when the globalvar was created previously because a corresponding nvvar existed. For this reason we removed the globalvars that have been previously created by nvvar creation (we called these unqualified globalvars). Since we no longer create the corresponding globalvars on nvvar creation this code is no longer needed. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | nv: Do not create globalvars from nvvarsSascha Hauer2017-04-071-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we create a new nvvar there's no need to create the corresponding globalvar, because whoever wants to use the corresponding globalvar will create it before usage anyway. Doing this means that we have to test for existence of a corresponding nvvar when we create a globalvar, and if it does, set the value of the globalvar from the nvvar. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | globalvar: remove unused globalvar_add()Sascha Hauer2017-04-071-16/+0
| | | | | | | | | | | | | | | | | | globalvar_add() is unused in the tree. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | bootchooser: export bootchooser_bootSascha Hauer2017-04-061-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some boards that boot directly from C code do already know that they want to boot from bootchooser and nothing else. For these it's easiest to call bootchooser_boot directly, so export this function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | bootchooser: register as bootentry providerSascha Hauer2017-04-062-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using a global function called by bootentry_create_from_name(), register the bootchooser as bootentry provider. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | blspec: register as bootentry providerSascha Hauer2017-04-062-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using a global function called by bootentry_create_from_name(), register blspec as bootentry provider. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | boot: Allow to register boot entry providersSascha Hauer2017-04-061-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bootentry_create_from_name() takes a name and creates bootentries for it. It tries different providers that interpret the name: blspec, bootchooser or script pathes. Instead of hardcoding the different providers in the function, allow the providers to register themselves. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | global command: print info about variablesSascha Hauer2017-04-041-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | The info contains useful information at least for enums, for these the possible values are printed. This makes the output of the "global" command more useful and similar to "devinfo global" Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>