summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* readkey: keys are unsigned charMichael Olbrich2017-01-241-2/+2
| | | | | | | Otherwise values > 127 will become negative and are dropped. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: libfile: Fix copying files to a non existing destinationTeresa Remmet2017-01-171-4/+5
| | | | | | | | | | | | If the destination file does not exist the stat call to check the file type fails. Extend the check of the stat return value. To allow to copy files to a new destination. Fixes commit 0ec6bd3e1be8 ("libfile: copy_file: Only open regular files with O_TRUNC") Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/truncate'Sascha Hauer2017-01-111-6/+16
|\
| * libfile: copy_file: Only open regular files with O_TRUNCTeresa Remmet2017-01-111-6/+16
| | | | | | | | | | | | | | | | Device files can not truncate in the most cases. Check if the destination is a regular file and open only those with O_TRUNC. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib/int_sqrt.c: Fix compiler warningSascha Hauer2017-01-101-0/+1
|/ | | | | | | | | | include int_sqrt.h to have the prototype for the function defined in this file. Fixes: lib/int_sqrt.c:25:15: warning: no previous prototype for 'int_sqrt' [-Wmissing-prototypes] Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-10-102-1/+30
|\
| * convert users to %pI4Sascha Hauer2016-09-221-1/+1
| | | | | | | | | | | | | | Convert users of ip_to_string() and print_IPaddr() to %pI4 and remove the now unused functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * vsprintf: Add support for printing ipv4 addresses with %pI4Sascha Hauer2016-09-221-0/+29
| | | | | | | | | | | | Can be used conveniently in places that currently use ip_to_string(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | param: introduce param_bitmaskSascha Hauer2016-09-221-0/+135
|/ | | | | | | | | | param_bitmask behaves similar to an enum, except that with a bitmask multiple values can be specified. On the command line the bits are represented as a space separated list of strings. In memory a unsigned long * is used as backend storage, this can be modified using the regular bitmap functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-09-131-1/+1
|\
| * clarify strim function descriptionAleksey Kuleshov2016-08-221-1/+1
| | | | | | | | | | Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | xstrdup: don't panic on xstrdup(NULL)Uwe Kleine-König2016-09-121-1/+6
|/ | | | | | | | | | | | Instead return just NULL. This matches the behaviour of kstrdup in the kernel and xstrdup in busybox. This fixes a panic with CONFIG_CMD_MAGICVAR=y and CONFIG_CMD_MAGICVAR_HELP unset in magicvar_add() where description is always NULL. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nv'Sascha Hauer2016-08-032-1/+4
|\
| * lib: Add Kconfig symbol for FNMATCHSascha Hauer2016-07-252-1/+4
| | | | | | | | | | | | | | fnmatch is useful on its own, so make a separate Kconfig symbol and select it from GLOB. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | getopt: Add support for '--' to stop option parsingSascha Hauer2016-07-251-0/+5
|/ | | | | | | | In some cases when commands have optional arguments it is necessary to explicitly stop option parsing after the last nonpositonal option. Add support for '--' to accomplish this as done in getopt(3) aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/video'Sascha Hauer2016-07-116-0/+279
|\
| * video/edid: Move int_sqrt() outAndrey Smirnov2016-06-302-0/+47
| | | | | | | | | | | | | | | | Move int_sqrt() out of drivers/video/edid.c so that it is availible to other parts of Barebox. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * GUI: Add code to draw simple graphicsAndrey Smirnov2016-06-303-0/+203
| | | | | | | | | | | | | | | | Add code to draw simple graphics, namely lines(solid or dashed) and circles. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * GUI: Add a function to draw vertical/horizontal barsAndrey Smirnov2016-06-301-0/+29
| | | | | | | | | | | | | | Add a function to draw solid vertical or horizontal bars. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/state'Sascha Hauer2016-07-111-1/+1
|\ \
| * | libfile: Change write_full to be have const bufMarkus Pargmann2016-07-081-1/+1
| | | | | | | | | | | | | | | | | | | | | write() uses a const pointer so write_full should do the same. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/nvdevvars'Sascha Hauer2016-07-111-0/+3
|\ \ \ | |/ / |/| |
| * | Introduce non volatile device variablesSascha Hauer2016-07-061-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Non volatile device variables are used to make device parameters persistent. They are like normal non volatile variables, but set the values of the device parameters with the corresponding name. Every nv variable beginning with nv.dev is a non volatile device variable. They have the form nv.dev.<devname>.<paramname> and act on the parameter <paramname> of the device named <devname>. The non volatile device variables are designated for example for video modes, ethernet device ip addresses or mtd partitioning. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / vsprintf: fix handling of strp arg in asprintfEnrico Jorns2016-07-071-2/+1
|/ | | | | | | | strp argument was ignored but should be forwarded to vasprintf() call in order to make this funktion work as expected. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: Fix formatting devices with unreadable areasSascha Hauer2016-05-201-2/+7
| | | | | | | | | When parts of a Nand device are not readable due to excessive bit flips we should not bail out with an error as this means we can never repair the device by flashing a fresh image using ubiformat. Instead, treat a failed read as a corrupt block and ignore the read failure. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: Ignore bitflip errorsSascha Hauer2016-05-201-1/+1
| | | | | | | | | Fixes: 1d88c66 ubiformat: Use mtd-peb API bit flips are no error, when encountering them during scanning of a device just ignore them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-05-093-13/+4
|\
| * whole tree: remove trailing whitespacesDu Huanpeng2016-04-212-3/+3
| | | | | | | | | | Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * NULL: keep NULL definition in stddef.h onlyDu Huanpeng2016-04-141-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove other local definition of NULL, use #include <linux/stddef.h> instead. I use this command to search NULL definition, grep -R "define\s*\<NULL\>" hope there are no more definition of NULL. from ISO/IEC 9899:TC3: The macros are NULL which expands to an implementation-defined null pointer constant; Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/include-cleanup'Sascha Hauer2016-05-0912-26/+92
|\ \
| * | stdio: rename getc to getcharSascha Hauer2016-04-152-5/+5
| | | | | | | | | | | | | | | | | | | | | The function we have implemented as getc has the semantics of the standard function getchar, so rename it accorgingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | move unlink_recursive declaration to libfile.hSascha Hauer2016-04-151-0/+1
| | | | | | | | | | | | | | | | | | | | | unlink_recursive is a file utility function, so move the prototype to libfile.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | move make_directory declaration to libfile.hSascha Hauer2016-04-151-0/+1
| | | | | | | | | | | | | | | | | | | | | As a utility function for file handling make_directory() is well suited for libfile. Move it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | string: Fix (v)asprintf prototypesSascha Hauer2016-04-157-19/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | show_progress: print spaces with %*sSascha Hauer2016-04-151-2/+1
| | | | | | | | | | | | | | | | | | | | | Removes the need for include/linux/stringify.h in the progress bar code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | libfile: move open_and_lseek() to libfileSascha Hauer2016-04-151-0/+32
| |/ | | | | | | | | | | | | libfile is a collection of helpers for handling files. open_and_lseek() is a perfect match for this, so move it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | parameter: Use strtoboolSascha Hauer2016-05-041-4/+8
| | | | | | | | | | | | Use strtobool to convert the input string to a boolean type. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | string: Introduce strtoboolSascha Hauer2016-04-291-0/+43
|/ | | | | | | | | | | | | | | | We have at least two places which convert a string to a boolean type, so create a common function for this. strtobool treats - any positive (nonzero) number as true - "0" as false - "true" (case insensitive) as true - "false" (case insensitive) as false Every other value results in an error and the input *val is not modified. The caller is expected to initialize *val with the correct default before calling strtobool. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: declared buffer is too small to hold stringRenaud Barbier2016-04-121-1/+1
| | | | | | | | | | Displaying an unsigned 64-bit integer can be represented by up to 20 characters. The 20 bytes buffer reserved to store the formatted string "%llu Bytes" is to small: (20 + 6) = 26. Hence, a bigger buffer is reserved to hold this string. Signed-off-by: Renaud Barbier <renaud.barbier@ge.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add list_sort from u-boot v2016.03Alexander Stein2016-04-082-0/+297
| | | | | | | This is required by UBIFS update. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rbtree: Update to u-boot v2016.03Alexander Stein2016-04-081-265/+430
| | | | | | | | | | This adds (among others) rbtree_postorder_for_each_entry_safe which is required by the upcoming UBIFS update. Changes to u-boot source: * Adding include <module.h> for EXPORT_SYMBOL* Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* decompressors: Use malloc/free wrappersSascha Hauer2016-04-089-37/+48
| | | | | | | | | | The decompressors are used both in a regular image and also for image decompression. Both need different malloc implementations. Using malloc/free directly in the decompressor code easily leads to include file conflicts, so use MALLOC/FREE which can be defined correctly for the two different usecases. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove now unused libmtdSascha Hauer2016-04-063-372/+0
| | | | | | | The only user of libmtd was ubiformat which now uses the mtd-peb API, so remove the now unused libmtd. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: Use mtd-peb APISascha Hauer2016-04-062-30/+21
| | | | | | | | This changes ubiformat from the libmtd API to the mtd-peb API. This makes the libmtd API unnecessary and it can be removed in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: rename mtd_all_ff -> mtd_buf_all_ffSascha Hauer2016-03-151-1/+1
| | | | | | | To make clear this function checks a given buffer and not data on a mtd device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* process_escape_sequence: add support for \uPhilipp Zabel2016-02-171-0/+6
| | | | | | | | Expand the \u escape sequence to the user currently set in the $global.user variable. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ratp'Sascha Hauer2016-02-084-0/+1851
|\
| * barebox remote controlSascha Hauer2016-01-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the ability to control barebox over serial lines. The regular console is designed for human input and is unsuitable for controlling barebox from scripts since characters can be lost on both ends, the data stream contains escape sequences and the prompt cannot be easily matched upon. This approach is based on the RATP protocol. RATP packages start with a binary 0x01 which does not occur in normal console data. Whenever a 0x01 character is detected in the console barebox goes into RATP mode. The RATP packets contain a simple structure with a command/respone type and data for that type. Currently defined types are: BB_RATP_TYPE_COMMAND (host->barebox): Execute a command in the shell BB_RATP_TYPE_COMMAND_RETURN (barebox->host) Sends return value of the command back to the host, also means barebox is ready for the next command BB_RATP_TYPE_CONSOLEMSG (barebox->host) Console message from barebox Planned but not yet implemented are: BB_RATP_TYPE_PING (host->barebox) BB_RATP_TYPE_PONG (barebox->host) For testing purposes BB_RATP_TYPE_GETENV (host->barebox) BB_RATP_TYPE_GETENV_RETURN (barebox->host) Get values of environment variables Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
| * Add Reliable Asynchronous Transfer ProtocolSascha Hauer2016-01-183-0/+1843
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for Reliable Asynchronous Transfer Protocol (RATP) as described in RFC916. Communication over RS232 is often unreliable as characters are lost or misinterpreted. This protocol allows for a reliable packet based communication over serial lines. The implementation simply follows the state machine described in the RFC text with one exception. RFC916 uses a plain checksum for the transferred data. We decided to use CRC16 for greater robustness. Since this is the only RFC916 implementation we currently know of interoperability with other implementations should not matter. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
* | vsprintf: Add support for %paSascha Hauer2016-01-151-0/+27
| | | | | | | | | | | | | | Add support for the %pa format specifier to print phys_addr_t, dma_addr_t and resource_size_t. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>