2017-03-31 |
state: storage: direct: do not close file that is not opened
...
When open failed to not try to close the invalid fd afterwards.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend_circular: remove unnecessary warning
...
It's expected that NAND flashes contain bad blocks, do not warn
about them.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend: Add more fields to struct state_backend_storage
...
To save a few function arguments.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend_bucket_direct: max_size is always given
...
max_size is always != 0, so if(direct->max_size) can be skipped.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: bucket: Make output more informative
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend-direct: Fix max_size
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: Drop cache bucket
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: Convert all bufs to void *
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: replace len_hint logic
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: simplify direct backend
...
- 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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: drop lazy_init
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend_circular: Read whole PEB
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: storage: initialize variable once outside loop
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: pass struct state * to storage functions
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: remove unnecessary argument from state_format_init
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: open code state_backend_init in caller
...
Safes a lot of argument passing to a function that is used
only once.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: merge backend.c into state.c
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: Drop backend as extra struct type
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend: remove len_hint argument from state_storage_read
...
The argument is 0 in the only caller, so remove the argument.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend: remove .get_packed_len
...
.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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: Use positive logic
...
bools with "non" in the names are rather confusing. Switch to
positive logic.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: pass error code instead of inventing new one
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: fix finding the correct parent node
...
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>
Michael Olbrich
authored
on 16 Sep 2016
Sascha Hauer
committed
on 31 Mar 2017
|
barebox-state: Sync pieces with barebox
...
dev_add_param_bool are no-ops, save_on_shutdown is irrelevant for the
userspace part. Sync with barebox as of v2017.03.0
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: don't keep pointers to device tree nodes
...
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>
Michael Olbrich
authored
on 16 Sep 2016
Sascha Hauer
committed
on 31 Mar 2017
|
state: make locally used function static
...
state_set_dirty() is only used in one file, make it static.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: consistently pass one type as private data to dev_add_param_*
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: Add state to state_variable
...
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>
Sascha Hauer
committed
on 31 Mar 2017
|
state: copy backend of_path string
...
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>
Michael Olbrich
authored
on 16 Sep 2016
Sascha Hauer
committed
on 31 Mar 2017
|
Revert "barebox-state: Do not defer probe"
...
This reverts commit 898a467 .
Sascha Hauer
committed
on 31 Mar 2017
|