9
0
Fork 0
Commit Graph

41 Commits

Author SHA1 Message Date
Masahiro Yamada 03dabc0fe4 param: add error check to __dev_add_param()
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>
2015-02-02 11:46:31 +01:00
Masahiro Yamada 31cbf0880d param: add error check to dev_param_set_generic()
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>
2015-02-02 11:46:31 +01:00
Sascha Hauer 0d5c1b9e97 param: make string arguments to dev_add_param_fixed const
dev_add_param_fixed does not modify the strings, so make them
const.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-11-28 15:21:26 +01:00
Sascha Hauer e3c49aac69 Merge branch 'for-next/misc' 2014-11-05 15:47:39 +01:00
Rolf Evers-Fischer 9ab02e4ec6 lib: parameter: fixed doku renamed ip -> ipaddr
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>
2014-10-23 07:51:37 +02:00
Sascha Hauer ade0583602 param: let dev_add_param return the newly created param
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>
2014-10-08 16:33:34 +02:00
Sascha Hauer 32f4bd130c param: Add dev_add_param_string
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>
2014-07-22 08:09:23 +02:00
Herve Codina f2e86a2964 param: Add support for long long read only dev param
Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-13 06:27:34 +02:00
Holger Schurig 9b57fd27f5 parameters: only show possible enumerations if there are any
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>
2014-06-02 09:07:12 +02:00
Sascha Hauer 1273cc2d47 param: Add dev_add_param_mac
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>
2014-04-04 09:04:31 +02:00
Sascha Hauer cf1b29a850 Merge branch 'for-next/ubi'
Conflicts:
	drivers/mtd/ubi/cdev.c
2014-03-07 09:26:35 +01:00
Sascha Hauer 81ba01fee6 param: dev_add_param_fixed: constify argument
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-28 11:22:57 +01:00
Lucas Stach aa6694b542 remove redundant NULL check on free
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>
2014-02-10 08:49:55 +01:00
Sascha Hauer a6afae76f1 param: Add helpers to provide an enum parameter
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>
2013-05-23 15:40:26 +02:00
Sascha Hauer c57fa97ee7 param: pass param to dev_remove_param
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-11 11:48:35 +02:00
Sascha Hauer a280858594 param: remove now unused dev_[gs]et_param_ip
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-11 11:48:35 +02:00
Sascha Hauer f80e7c4920 param: Add ip address convenience function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-11 11:48:31 +02:00
Sascha Hauer 2df33a69bd param: Add integer and boolean parameter helpers
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>
2013-04-11 10:20:56 +02:00
Sascha Hauer c4b7f8ad38 param: refactor __dev_add_param
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>
2013-04-07 11:33:04 +02:00
Sascha Hauer f1253fdf8e param: Add dev member to struct param_d
This will make it unnecessary to pass the dev pointer around later.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-06 08:23:45 +02:00
Sascha Hauer 856f60dbd1 Merge branch 'for-next/misc'
Conflicts:
	commands/Makefile

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-11-16 14:01:34 +01:00
Jan Luebbe 247022ec92 parameter: support removing named parameters
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-12 10:02:57 +02:00
Jan Luebbe 0b78902b01 parameter: fix memory leak
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>
2012-10-12 10:01:27 +02:00
Sascha Hauer 77322aa896 Treewide: remove address of the Free Software Foundation
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>
2012-09-17 10:57:41 +02:00
Sascha Hauer 6188685091 Make errno a positive value
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>
2012-05-14 08:35:54 +02:00
Sascha Hauer 8cab6a8733 parameter: return empty string for unset parameters
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>
2012-05-13 14:02:03 +02:00
Sascha Hauer af06205ad5 dev_add_param: check if param exists already
Before adding a new parameter to a device we should check if
it already exists.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-24 11:19:59 +02:00
Sascha Hauer 51f2ded17c param: make return value of param getter function const
The string returned by the getter function should not be
changed. Make it const.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-24 11:17:02 +02:00
Sascha Hauer 9d699b790c net: use static string in string_to_ip
Simplify usage of ip_to_string by using a static string.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-15 15:05:38 +02:00
Robert Schwebel ee1419ec92 doc: fix wrongly named parameter
Silence this warning:

lib/parameter.c:85: Warning: argument `value' of command @param is not found in the argument list of dev_set_param(struct device_d *dev, const char *name, const char *val)
lib/parameter.c:85: Warning: The following parameters of dev_set_param(struct device_d *dev, const char *name, const char *val) are not documented:
  parameter val

Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-10-22 20:47:03 +02:00
Sascha Hauer c3789cd49b rework device parameters
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>
2010-06-17 08:28:25 +02:00
Sascha Hauer a3ffa97f40 rename U-Boot-v2 project to barebox
This has been done with the following script:

find -path ./.git -prune -o -type f -print0 | xargs -0 -r sed -i \
	-e 's/u2boot/barebox/g' \
	-e 's/U2Boot/barebox/g' \
	-e 's/U-boot V2/barebox/g' \
	-e 's/u-boot v2/barebox/g' \
	-e 's/U-Boot V2/barebox/g' \
	-e 's/U-Boot-v2/barebox/g' \
	-e 's/U_BOOT/BAREBOX/g' \
	-e 's/UBOOT/BAREBOX/g' \
	-e 's/uboot/barebox/g' \
	-e 's/u-boot/barebox/g' \
	-e 's/u_boot/barebox/g' \
	-e 's/U-Boot/barebox/g' \
	-e 's/U-boot/barebox/g' \
	-e 's/U-BOOT/barebox/g'

find -path ./.git -prune -o \( -name "*u-boot*" -o -name "*uboot*" -o -name "*u_boot*" \) -print0 | \
	xargs -0 -r rename 's/u[-_]?boot/barebox/'

It needs some manual fixup following in the next patch

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-12-15 10:18:30 +01:00
Juergen Beisert afd482e833 Move the parameter's documentation where it belongs to
Signed-off-by: Juergen Beisert <j.beisert@pengutronix.de>
2009-07-31 13:24:35 +02:00
Sascha Hauer c0d02ffc3d Fix string_to_ip
Use a pointer to an ip address instead of the return value in string_to_ip
and use the return value for error indication only. 0.0.0.0 can be a valid
ip address

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2008-08-20 17:46:47 +02:00
Sascha Hauer ad3b376c3d parameter: set errno in dev_set_param
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2008-08-20 13:12:42 +02:00
Sascha Hauer 1d35082db5 parameter: make stringlen more readable
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2008-08-20 13:10:48 +02:00
Marc Kleine-Budde f0e65e3cf6 [sparse] use NULL for nullpointer
fixes:
lib/parameter.c:108:19: warning: Using plain integer as NULL pointer

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2007-11-29 10:22:47 +01:00
Sascha Hauer 22c0e805ea replace 8 spaces with tabs 2007-10-11 20:56:18 +02:00
Sascha Hauer 75a10b942c svn_rev_706
add file headers
2007-07-05 18:02:19 +02:00
Sascha Hauer b2c5310d4d svn_rev_653
restructure tree, add reginfo command
2007-07-05 18:02:14 +02:00
Sascha Hauer 4a660c0877 svn_rev_639 2007-07-05 18:02:12 +02:00