summaryrefslogtreecommitdiffstats
path: root/include/param.h
Commit message (Collapse)AuthorAgeFilesLines
* param: drop priv from dev_add_param_string_roAhmad Fatoum2023-08-231-2/+1
| | | | | | | | | dev_add_param_string_ro() is used nowhere, but when we do, having an unused priv parameter serves no purpose, so drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230822074738.3905283-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-101-124/+162
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: introduce file-list parameter typeAhmad Fatoum2021-05-121-0/+15
| | | | | | | | | | | | | | 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>
* Merge branch 'for-next/spdx'Sascha Hauer2020-02-181-0/+1
|\
| * include: add SPDX GPL-2.0-only license tags for files without licensing ↵Roland Hieber2020-02-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | information According to our /README, GPL-2.0-only applies for the whole project except noted otherwise. Signed-off-by: Roland Hieber <rohieb@rohieb.name> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/parameter'Sascha Hauer2020-02-181-10/+10
|\ \
| * | parameter: Return NULL instead of ENOSYS if CONFIG_PARAMETER is disabledChristian Eggers2020-01-271-10/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts 03b59bdb64 ("paramter: The dev_add_param_*() return ERR_PTR(), change no-ops to return ERR_PTR(-ENOSYS) instead of NULL"). Most callers of dev_add_param_*() don't care about whether CONFIG_PARAMETER is enabled or not. The remaining ones have already been prepared for getting a NULL pointer. As a result, these callers will not fail itself, only because CONFIG_PARAMETER (which is always optional) is disabled. Signed-off-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / param: Make enum param_tristate always visibleChristian Eggers2020-01-221-2/+2
|/ | | | | | | | | | | | | When disabling CONFIG_SHELL_HUSH, also CONFIG_PARAMETER may be disabled. In this case, the definition "enum param_tristate" is not reachable from watchdog.h. I also considered moving almost everything in watchdog.h inside the CONFIG_WATCHDOG guard. But this doesn't work for me because drivers/watchdog/imxwd.c can also be built without CONFIG_WATCHDOG. Signed-off-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: add dev_add_param_tristate(_ro) helpersAhmad Fatoum2019-12-051-0/+24
| | | | | | | | | | | | | | | 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>
* param: drop unused parameters in helpersAhmad Fatoum2019-11-051-5/+1
| | | | | | | | These parameters aren't currently used anywhere, but are still useful to have nonetheless. Keep them but drop the unused parameters. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: make dev_add_param_string_fixed value parameter constAhmad Fatoum2019-09-091-1/+1
| | | | | | | | The function is so far unused and the parameter's only use is to be passed as argument to dev_add_param_fixed which is const as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "param: fix stub prototype of dev_add_param"Lucas Stach2017-07-061-2/+2
| | | | | | | This reverts commit 441941f5a664e0333d78ee480ea8b974a9a99d9d, which was on top of the recently reverted nvvar rework, so needs to be reverted, too. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* Revert "globalvar: remove code for unqualified globalvars"Sascha Hauer2017-06-131-0/+1
| | | | This reverts commit e4f81050e098074792730b61563538d9e394e3d6.
* Revert "param: remove unnecessary device_d * argument"Sascha Hauer2017-06-131-5/+6
| | | | This reverts commit 0071bacb4c7cab21c9fab8540f5aa9922a270a85.
* param: fix stub prototype of dev_add_paramLucas Stach2017-05-171-2/+2
| | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/parameter-types'Sascha Hauer2017-05-051-43/+152
|\
| * param: remove unnecessary device_d * argumentSascha Hauer2017-04-111-6/+5
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * param: make parameter functions more consistentSascha Hauer2017-04-111-37/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+15
| | | | | | | | | | | | | | | | 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>
* | param: fix stub prototype const annotationLucas Stach2017-04-261-1/+1
|/ | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* globalvar: remove code for unqualified globalvarsSascha Hauer2017-04-071-1/+0
| | | | | | | | | | | | 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>
* devparam: add static inline dummy for dev_add_param_bitmaskLucas Stach2017-01-091-0/+8
| | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: introduce param_bitmaskSascha Hauer2016-09-221-0/+5
| | | | | | | | | | 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>
* globalvar: sync with nvvarsSascha Hauer2016-09-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the behaviour when a driver creates a globalvar using globalvar_add_simple_[string|int|bool|enum|ip]) *after* nvvars are initialized and this globalvar is overwritten with a nvvar. Currently this fix is not needed because all globalvars are registered before the nvvars are initialized. We have two different typed of globalvars. The first type, here referred to as qualified globalvars, has a backend variable storage (the ones created with globalvar_add_simple_[string|int|bool|enum|ip]), the other created with globalvar_add_simple only has a dynamically allocted string as backend. Normally during startup of barebox the qualified globalvars are registered and during load of nvvars are synced with the values from the nvvars. Everything works fine in this case. However, when during nvvar initialisation a globalvar for a nvvar does not exist, then it is registered as unqualified globalvar. When then later some driver wants to register a qualified globalvar for which a unqualified globalvar already exists, it will get a -EEXIST. This is not the expected behaviour. Instead, the current unqualified globalvar should be removed, recreated as qualified globalvar and then afterwards synced with the corresponding nvvar. This behaviour is fixed with this patch. 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>
* parameter: include header for ERR_PTR and errnoLucas Stach2015-03-111-0/+1
| | | | | | | | | | | Commit 03b59bdb64e83e (paramter: The dev_add_param_*() return ERR_PTR(), change no-ops to return ERR_PTR(-ENOSYS) instead of NULL) started using ERR_PTR and errnos without including the relevant header. This fixes the build for a lot of configurations. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* paramter: The dev_add_param_*() return ERR_PTR(), change no-ops to return ↵Marc Kleine-Budde2015-03-101-9/+9
| | | | | | | ERR_PTR(-ENOSYS) instead of NULL Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: make string arguments to dev_add_param_fixed constSascha Hauer2014-11-281-2/+2
| | | | | | | dev_add_param_fixed does not modify the strings, so make them const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: let dev_add_param return the newly created paramSascha Hauer2014-10-081-2/+2
| | | | | | | | 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>
* Merge branch 'for-next/usb-gadget'Sascha Hauer2014-08-071-0/+13
|\ | | | | | | | | | | | | | | Conflicts: commands/Makefile common/Kconfig common/Makefile drivers/usb/gadget/dfu.c
| * param: Add dev_add_param_stringSascha Hauer2014-07-221-0/+13
| | | | | | | | | | | | | | | | 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>
* | Make IPaddr_t a 32bit typeSascha Hauer2014-07-111-1/+1
|/ | | | | | | unsigned long is 64bit wide on some architectures. Make IPaddr_t a typedef to uint32_t to make sure it's 32bit wide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add support for long long read only dev paramHerve Codina2014-06-131-0/+9
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add dev_add_param_macSascha Hauer2014-04-041-0/+13
| | | | | | | 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>
* param: dev_add_param_fixed: constify argumentSascha Hauer2014-02-281-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add helpers to provide an enum parameterSascha Hauer2013-05-231-0/+14
| | | | | | | | 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: Add info functionSascha Hauer2013-05-231-0/+1
| | | | | | | Some parameters may wish to provide some information about their meaning or possible values. Provide an info callback for parameters. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: pass param to dev_remove_paramSascha Hauer2013-04-111-2/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: remove now unused dev_[gs]et_param_ipSascha Hauer2013-04-111-15/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add ip address convenience functionSascha Hauer2013-04-111-0/+13
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: Add integer and boolean parameter helpersSascha Hauer2013-04-111-0/+37
| | | | | | | | | | 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: 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>
* parameter: fix build warning when !CONFIG_PARAMETERJosh Cartwright2013-04-021-1/+1
| | | | | | | | | | | | | | | | Commit 51f2ded17c35c146488f6f3b697764bb2953a156 ("param: make return value of param getter function const") made the parameter getter const, but neglected to change the dev_add_param() function prototype in the !CONFIG_PARAMETER case. Fixes the following warning with CONFIG_NAND and !CONFIG_PARAMETER: drivers/mtd/nand/nand_base.c: In function 'add_mtd_nand_device': drivers/mtd/nand/nand_base.c:1720:2: warning: passing argument 4 of 'dev_add_param' from incompatible pointer type [enabled by default] include/param.h:59:19: note: expected 'char * (*)(struct device_d *, struct param_d *)' but argument is of type 'const char * (*)(struct device_d *, struct param_d *)' Signed-off-by: Josh Cartwright <joshc@eso.teric.us> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameter: support removing named parametersJan Luebbe2012-10-121-0/+4
| | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameter: remove unused function global_add_parameterJan Luebbe2012-10-121-7/+0
| | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parameter: remove unused struct memberSascha Hauer2012-05-131-1/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: make return value of param getter function constSascha Hauer2012-04-241-3/+3
| | | | | | | The string returned by the getter function should not be changed. Make it const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: add config to disable itJean-Christophe PLAGNIOL-VILLARD2012-01-111-0/+53
| | | | | | this will allow to save 992 Bytes for TI xlaoder or AT91 bootstrap Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* rework device parametersSascha Hauer2010-06-171-1/+14
| | | | | | | | Change device parameters so that the memory management is in generic code. This also removes the need of storing statically initialized parameters as they are stored in a struct list_head for each device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* svn_rev_502Sascha Hauer2007-07-051-1/+4
| | | | complete multiple console support