summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2022-04-211-0/+25
|\
| * libfile: implement new pread_fullAhmad Fatoum2022-03-281-0/+25
| | | | | | | | | | | | | | | | We already have pwrite_full, add pread_full for symmetry. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220318144942.498124-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | hexdump: provide support for dev_print_hex_dump()Oleksij Rempel2022-04-191-8/+16
|/ | | | | | | | | In some cases we need to know the interface name of dumped hex. So, provide optional device_d pointer and use it to get device name. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20220413082205.429509-14-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/qoi'Sascha Hauer2022-02-187-15/+853
|\
| * logo: Add choice for the QOI image format optionJules Maselbas2022-01-203-1/+22
| | | | | | | | | | | | Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20220117230235.13549-6-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * logo: Enable image format selection for the logoJules Maselbas2022-01-203-15/+56
| | | | | | | | | | | | | | | | | | | | Enables the selection of an image format to be used for the built-in barebox logo. The default image format is set to png, has it was the only choice before. This also adds bmp as the other option. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20220117230235.13549-5-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * gui: Add qoi image formatJules Maselbas2022-01-204-0/+776
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "Quite OK Image Format", aka QOI, aims to be a fast, lossless image compression format, with comparable compression factor against png, and beeing faster to encode and decode. In barebox only care about decoding, the qoi image format might be an intresting alternative to both bmp and png, some kind of midle ground. The project home page can be found at https://qoiformat.org, there is a reference implementation, for both encoder and decoder, in a single header file (qoi.h) hosted at https://github.com/phoboslab/qoi. There is no plan for future version, this is a frozen format. In case the reference implementation should be updated, the qoi.h file must be copied to the lib/gui/qoi.h without requiring modifications. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20220117230235.13549-3-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/efi'Sascha Hauer2022-02-181-2/+2
|\ \
| * | rename cdev_open() -> cdev_open_by_name()Sascha Hauer2022-02-081-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | The cdev_* functions normally take a struct cdev * argument, with the exception of cdev_open(). Rename cdev_open() to cdev_open_by_name() to be able to implement cdev_open() with the expected semantics in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / commands: add missing command groupsAhmad Fatoum2022-01-261-0/+1
|/ | | | | | | | | CMD_GRP_MISC is assumed in absence of an explicit group. Let's be explicit instead to silence the warnings during documentation build. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220124151827.3313412-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2022-01-1956-0/+106
|\
| * treewide: add SPDX-License-Identifier for files without explicit licenseAhmad Fatoum2022-01-0535-0/+66
| | | | | | | | | | | | | | | | | | Record GPL-2.0-only as license for all files lacking an explicit license statement. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: add SPDX-License-Identifier for .gitignoreAhmad Fatoum2022-01-051-0/+2
| | | | | | | | | | | | | | | | | | Makes the files not appear when searching for files that lack SPDX-License-Identifier. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: add SPDX-License-Identifier for Kbuild/KconfigAhmad Fatoum2022-01-0520-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To verify only Kconfig/Makefile is touched: git show --numstat --format=oneline HEAD | grep -v 'Kconfig\|Makefile' will print only arch/powerpc/Kbuild. To verify nothing unexpected is added: git show -U0 | grep '^-[^-]\|^+[^+]' | sort -u Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | getopt: Add support for '+' in optstringSascha Hauer2022-01-051-3/+14
| | | | | | | | | | | | | | Stop option parsing at nonoptions when the first character of optstring is '+'. This is analog to getopt(3). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | parseopt: drop unused, duplicate, parseopt_u16Ahmad Fatoum2022-01-051-31/+0
|/ | | | | | | | | | | We always have sizeof(unsigned short) == sizeof(uint16_t), so parseopt_u16() is exactly equivalent to parseopt_hu(). The former is unused anyway, so just drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120205.1728778-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: add new PRINTF_FULL optionAhmad Fatoum2021-12-141-0/+3
| | | | | | | | | | We now got three compile-time selectable printf format specifiers. For debugging, it can be useful to enable all of them, thus add a new PRINTF_FULL option. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211209105708.3517684-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* vsprintf: add support for printing raw buffers as hex (%*ph)Ahmad Fatoum2021-12-142-0/+53
| | | | | | | | | | | | | | | Import from Linux support for printing buffers as a hex string with a certain separator. For larger buffers consider using print_hex_dump(). Examples: %*ph 00 01 02 ... 3f %*phC 00:01:02: ... :3f %*phD 00-01-02- ... -3f %*phN 000102 ... 3f Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211209105708.3517684-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* libfile: null-terminate read_file of wchar_t bufferAhmad Fatoum2021-12-131-1/+2
| | | | | | | | | | read_file always nul-terminates the buffer, which is useful when slurping ASCII text into a variable. This doesn't work as well for UCS-2, because we need two aligned nuls there. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-21-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* vsprintf: add optional support for %ls format modifierAhmad Fatoum2021-12-132-12/+58
| | | | | | | | | Incoming EFI loader support will deal a lot with wide strings, so it makes sense to have printf directly support printing it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-20-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: implement wcsnlenAhmad Fatoum2021-11-251-0/+9
| | | | | | | | This will come in handy for implementing %ls in the follow up commit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-19-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: wchar: add wctomb and mbtowcAhmad Fatoum2021-11-251-2/+20
| | | | | | | | | | We currently convert wchar_t to char by truncating to 8-bit. In future, we may want to do UTF-16 to UTF-8 conversion. Prepare for this by wrapping each conversion direction in a function. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-18-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: add dedicated header for printf/printkAhmad Fatoum2021-11-012-2/+2
| | | | | | | | | | | | Including <stdio.h> for printf is a bit problematic, because it pulls in other headers for <console.h>, which includes quite a few more headers as well. To make it easier to share code between barebox and host tools make <printk.h> the new minimal header for printf and move the extra logging stuff into <linux/printk.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141739.2207431-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* logo: Makefile: Replace inkscape with convertJules Maselbas2021-10-112-14/+11
| | | | | | | | | | | The uses of inkscape to convert svg to png hasn't been very stable from one version to another, and required quirks from one version to another. I hope that convert from imagemagick will be a more stable solution. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20211007115254.32270-1-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2021-07-182-5/+1
|\
| * test: self: add tests for progress notifierAhmad Fatoum2021-06-281-1/+1
| | | | | | | | | | | | | | | | | | We don't yet have any boards upstream that make use of the progress notifier, but at least have some tests, so we know it's working. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210619054048.498826-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * image-sparse: remove unused defineRouven Czerwinski2021-06-231-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE is present since the very first addition of sparse image support. However its not used anywhere in the code, so remove it. Fixes: 13f649a4f960 ("Add support for fastboot sparse images") Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210621102706.586345-1-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/firmware'Sascha Hauer2021-07-182-20/+61
|\ \
| * | libbb: Add find_path functionSascha Hauer2021-06-251-20/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libbb contains a find_execable() function to find an executable in a colon separated path. The code can be reused by making the environment variable name and the is-executable test parameters. Do this and add a find_path() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-6-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | libfile: Add copy_fd()Sascha Hauer2021-06-231-0/+23
| |/ | | | | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210623043359.18391-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / string: implement strchrnulAhmad Fatoum2021-06-281-0/+18
|/ | | | | | | | | | We have at least two places opencoding strchrnul, one of them needlessly iterating twice instead of once over the string. Replace both by calling a common single pass implementation. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628051934.9604-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2021-06-161-1/+2
|\
| * uncompress: use read_full to fill decompression bufferLucas Stach2021-05-271-1/+2
| | | | | | | | | | | | | | | | | | | | The decompression algorithms want all of the requested buffer size to be filled and don't cope with less bytes being returned. Use read_full to satisfy this requirement. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Link: https://lore.barebox.org/20210526090216.4003977-1-l.stach@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib/math/rational.c: Fix divide by zeroTrent Piepho2021-06-091-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the input is out of the range of the allowed values, either larger than the largest value or closer to zero than the smallest non-zero allowed value, then a division by zero would occur. In the case of input too large, the division by zero will occur on the first iteration. The best result (largest allowed value) will be found by always choosing the semi-convergent and excluding the denominator based limit when finding it. In the case of the input too small, the division by zero will occur on the second iteration. The numerator based semi-convergent should not be calculated to avoid the division by zero. But the semi-convergent vs previous convergent test is still needed, which effectively chooses between 0 (the previous convergent) vs the smallest allowed fraction (best semi-convergent) as the result. Fixes: 323dd2c3ed0 ("lib/math/rational.c: fix possible incorrect result from rational fractions helper") Reported-by: Yiyuan Guo <yguoaz@gmail.com> Signed-off-by: Trent Piepho <tpiepho@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Add rational_best_approximation()Sascha Hauer2021-06-072-0/+101
|/ | | | | | | | | | Import rational_best_approximation() from Linux. This is used by an upcoming update of the clk_fractional_divider code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210602095507.24609-12-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-gadget'Sascha Hauer2021-05-176-0/+174
|\
| * param: introduce file-list parameter typeAhmad Fatoum2021-05-122-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | DFU, fastboot and incoming mass storage support all use file lists as input, but individually check syntax correctness only on use. A dedicated file list parameter would improve the user experience and makes the code using it easier to handle: the struct file_list can be passed around directly instead of having to parse it first on use. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * vsprintf: introduce %m shorthand for "%s", strerror(errno)Ahmad Fatoum2021-05-031-0/+13
| | | | | | | | | | | | | | | | | | | | | | We have many places across the code base that use either do printf("%s..", errno_str()) or printf("%s..", strerror(errno). We already have %pe support for printing arbitrary errors and it's not much work to add %m to print errno as well. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * string: implement strstarts along with strendsAhmad Fatoum2021-05-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | Both can be useful when parsing file paths. They are added to different files, because only one of them is available in upstream <linux/string.h>. The other we add to <string.h>, which contains more barebox-specific string functions. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * show_progress: add system wide progress stage notifierAhmad Fatoum2021-05-032-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use case is e.g. board code that wants to register a client to light status LEDs to indicate system state when no serial output is available. This functionality doesn't increase code size due to linker GC when CONFIG_PROGRESS_NOTIFIER is disabled. There is a generic progress notifier provided that just logs the status. This could be shared with the booted kernel via pstore or the log as a whole written to a system setup USB drive. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | readline_simple: Fix compiler warningSascha Hauer2021-05-121-1/+1
|/ | | | | | | char can be an unsigned type. To test the getchar() return value against negative values we have to use a signed type. Use int instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2021-03-232-2/+23
|\
| * param: drop unused left-over struct membersAhmad Fatoum2021-03-161-2/+0
| | | | | | | | | | | | | | | | Both seem to be a copy-paste left-over from the int param. They are unused anywhere, so it's safe to just drop them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * stringlist: Add adding sort uniqSascha Hauer2021-03-161-0/+23
| | | | | | | | | | | | | | Function to add an entry sorted to a string list only when it doesn't exist. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/bthreads'Sascha Hauer2021-03-231-2/+2
|\ \
| * | common: poller: replace explicit calls to poller_call() with resched()Ahmad Fatoum2021-03-171-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | We won't replace pollers with bthreads completely over night. To make migration easier, replace explicit calls to poller_call with a new resched() function. This can be made to call bthread_reschedule() in future and eventually replaced with bthread_reschedule() once pollers are removed. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / glob: use empty globfree when compiling without CONFIG_GLOBAhmad Fatoum2021-03-221-12/+12
|/ | | | | | | | | | | | | | | | We already return an error code unconditionally when building with !CONFIG_GLOB. We need to do the same for globfree. Otherwise, we run risk of corrupting memory. This issue exists since the code was first added, but it became more acute with 90cde3b9ff46 ("startup: Execute init scripts in alphabetical order"), which added a globfree into the shell init. Configuration without CONFIG_GLOB would from then on experience memory corruption during startup. Reported-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ext4'Sascha Hauer2021-02-222-10/+9
|\
| * copy_file: fix progress bar for files larger than 2GAhmad Fatoum2021-02-192-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Files larger than 2G cause the benign bug, that the progress bar is no longer accurate. Use loff_t to fix this. Note that printed % HASHES_PER_LINE in show_progress implies a 64-bit division. A previous commit changed the constant divisor to a power of two, so a division shouldn't be generated. The original multiplication and modulo operations are left as is for clarity. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * show_progress: change HASHES_PER_LINE from 65 to 64 to avoid divisionAhmad Fatoum2021-02-181-1/+1
| | | | | | | | | | | | | | | | | | Decreasing the progress bar length by one won't change visuals much, but will allow the compiler to optimize a multiplication and a modulo into bitwise operations. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>