summaryrefslogtreecommitdiffstats
path: root/lib/parameter.c
Commit message (Collapse)AuthorAgeFilesLines
* param: introduce file-list parameter typeAhmad Fatoum2021-05-121-0/+88
| | | | | | | | | | | | | | 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>
* 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>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: add dev_add_param_tristate(_ro) helpersAhmad Fatoum2019-12-051-0/+22
| | | | | | | | | | | | | | | This is can be considered an extension to the dev_add_param_bool interfaces with a third value that's "unknown". This can be used for cases, where barebox can flip a bit somewhere, but it has no way of knowing what the initial state of the bit was, e.g. turn on/off the watchdog, but no watchdog status. Turn on/off a co-processor, but no co-processor online status. And so on. Not providing a way to customize the "unknown" string is a deliberate choice, so future device parameters follow the same naming scheme. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameter: strip leading and trailing whitespacesMarco Felsch2019-11-041-1/+4
| | | | | | | | | | | | | | | | | My initial bug was the following: I set the global.boot.default="boot1 boot2 " and executed the 'boot' command. If both targets are not bootable barebox starts to execute the boot scripts found under /env/boot. This is because of the command/boot.c implementation and the leading whitespace. Without the whitespace only the two desired boot targets are tried. IMHO leading and trailing whitespaces are error-prone in many cases. If someone wants to concatenate strings he/she should add spaces on purpose. So I fixed the bug above globally by always stripping leading and trailing whitespaces. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib/parameter: Fix typecases to match corresponding PARAM_TYPE_*Andrey Smirnov2018-12-101-2/+2
| | | | | | | | | This change should be a no-op in terms of behavior, but it makes code less confusing when PARAM_TYPE_* matches the type used in the type cast. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "param: remove unnecessary device_d * argument"Sascha Hauer2017-06-131-22/+22
| | | | This reverts commit 0071bacb4c7cab21c9fab8540f5aa9922a270a85.
* param: remove unnecessary device_d * argumentSascha Hauer2017-04-111-22/+22
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: make parameter functions more consistentSascha Hauer2017-04-111-112/+78
| | | | | | | | | | | | | | | | | | | | | | This patch creates a consitent set of device parameter functions. With this we have: dev_add_param_<type><access> "type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask The improvement here is that we now can exactly specify the width of the int type parameters and also correctly distinguish between signed and unsigned variables which means that a variable no longer ends up with INT_MAX when it's assigned -1. "access" can be empty for regular read/write parameter, "_ro" for readonly parameters which get their value from a variable pointer in the background or "_fixed" for parameters which are set to a fixed value (without a pointer in the background). Some more exotic types are not (yet) implemented, like dev_add_param_ip_ro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameter: Give device parameters typesSascha Hauer2017-04-101-1/+29
| | | | | | | | This adds a variable type enum and adds this to the device parameters. This information gives the user a hint which values a parameter expects and also helps to organize the parameters better internally. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameter: fix read only int supportJean-Christophe PLAGNIOL-VILLARD2017-03-101-2/+2
| | | | | | | | pass PARAM_FLAG_RO flag for read only it so we can not change them Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-10-101-1/+1
|\
| * 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>
* | 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>
* 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>
* Merge branch 'for-next/include-cleanup'Sascha Hauer2016-05-091-4/+4
|\
| * string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-4/+4
| | | | | | | | | | | | | | | | | | | | 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>
* | 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>
* param_enum: protect against invalid valuesSascha Hauer2015-08-261-2/+6
| | | | | | | | Since dev_add_param_enum is passed a pointer containing the actual value it can contain an invalid value. Protect against it so that we do not access invalid array elements. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param_enum: Make name strings constSascha Hauer2015-08-261-2/+2
| | | | | | | | Not only the array containing the pointers should be const but also the strings themselves, so instead of using const char ** use const char * const *. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/state'Sascha Hauer2015-07-031-1/+1
|\
| * parameter: allow setting of string parameters of zero lengthMarc Kleine-Budde2015-06-181-1/+1
| | | | | | | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | parameter: always build MAC dev param functionsLucas Stach2015-07-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The MAC dev parameter functions would only be built when CONFIG_NET is set. This was okay as long as only network devices were using MAC dev params. This has changed with the merge of the state framework, so always compile them in if CONFIG_PARAMETER is set. Fixes: common/built-in.o: In function `state_mac_create': common/state.c:387: undefined reference to `dev_add_param_mac' Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | device parameters: sort alphabeticallySascha Hauer2015-06-181-1/+9
|/ | | | | | | | With many parameters on the global device it becomes increasingly annoying to find a parameter in the list. Sort it alphabetically to make this easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: add error check to __dev_add_param()Masahiro Yamada2015-02-021-1/+4
| | | | | | | | | | | | If strdup() fails with out-of-memory, __dev_add_param() should fail with -ENOMEM. (Note strdup() is always given with a non-NULL pointer. If the argument name is given with NULL, the system would already have crashed in the get_param_by_name() function.) Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: add error check to dev_param_set_generic()Masahiro Yamada2015-02-021-1/+1
| | | | | | | | The function dev_param_set_generic() may fail because of out of memory. If so, return -ENOMEM. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: make string arguments to dev_add_param_fixed constSascha Hauer2014-11-281-1/+1
| | | | | | | dev_add_param_fixed does not modify the strings, so make them const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2014-11-051-3/+5
|\
| * param: let dev_add_param return the newly created paramSascha Hauer2014-10-081-3/+5
| | | | | | | | | | | | | | | | dev_add_param creates a new parameter so it makes more sense to return it than to return an error code. Since the return value is hardly ever checked this is only a small patch. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: parameter: fixed doku renamed ip -> ipaddrRolf Evers-Fischer2014-10-231-2/+2
|/ | | | | | | Long time ago all ".ip" parameters have been replaced with ".ipaddr". Signed-off-by: Rolf Evers-Fischer <embedded24@evers-fischer.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add dev_add_param_stringSascha Hauer2014-07-221-0/+76
| | | | | | | | This function allows drivers to create a string parameter and provides access to it via a pointer. Using regular dev_add_param only allows access via dev_get_param(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add support for long long read only dev paramHerve Codina2014-06-131-0/+26
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameters: only show possible enumerations if there are anyHolger Schurig2014-06-021-0/+3
| | | | | | | | | Enumeration values will only be shown if there are at least two of them. With only one enumeration, it was just repeating what was previously printed anyway. Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add dev_add_param_macSascha Hauer2014-04-041-0/+87
| | | | | | | This adds a convenience function to register a MAC address device parameter. The only current user is converted to use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubi'Sascha Hauer2014-03-071-1/+1
|\ | | | | | | | | Conflicts: drivers/mtd/ubi/cdev.c
| * param: dev_add_param_fixed: constify argumentSascha Hauer2014-02-281-1/+1
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | remove redundant NULL check on freeLucas Stach2014-02-101-2/+1
|/ | | | | | | | free() already checks the pointer to be non NULL. No need to do it again. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add helpers to provide an enum parameterSascha Hauer2013-05-231-0/+104
| | | | | | | | We recently gained helper functions for different types of device parameters. One thing missing was a helper for an enum type parameter. This patch adds this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: pass param to dev_remove_paramSascha Hauer2013-04-111-11/+6
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: remove now unused dev_[gs]et_param_ipSascha Hauer2013-04-111-17/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add ip address convenience functionSascha Hauer2013-04-111-8/+87
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add integer and boolean parameter helpersSascha Hauer2013-04-111-0/+161
| | | | | | | | | | This adds convenience functions for directly registering integers and bools as device parameter. This way driver no longer have to fiddle with string handling. The format used to print the parameter is passed to the functions to be able to print parameters in a flexible way. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: refactor __dev_add_paramSascha Hauer2013-04-071-13/+18
| | | | | | | | Let __dev_add_param take a previously allocated struct param_d. This helps when later other users wish to embed a struct param_d in a bigger struct. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add dev member to struct param_dSascha Hauer2013-04-061-0/+1
| | | | | | This will make it unnecessary to pass the dev pointer around later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2012-11-161-0/+18
|\ | | | | | | | | | | | | Conflicts: commands/Makefile Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * parameter: support removing named parametersJan Luebbe2012-10-121-0/+18
| | | | | | | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | parameter: fix memory leakJan Luebbe2012-10-121-0/+1
|/ | | | | | | | In __dev_add_param, the name string is allocated using strdup. Free it when removing the parameter. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-3/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Make errno a positive valueSascha Hauer2012-05-141-6/+10
| | | | | | | | | Normally errno contains a positive error value. A certain unnamed developer mixed this up while implementing U-Boot-v2. Also, normally errno is never set to zero by any library function. This patch fixes this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameter: return empty string for unset parametersSascha Hauer2012-05-131-1/+1
| | | | | | | | Currently we return NULL for unset parameters. As we can't set them back to NULL once set this is not very consistent. Return an empty string instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>