[PATCH 3/3] dev_add_param: check if param exists already

Sascha Hauer s.hauer at pengutronix.de
Tue Apr 24 05:21:19 EDT 2012


Before adding a new parameter to a device we should check if
it already exists.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 lib/parameter.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/parameter.c b/lib/parameter.c
index e746467..baf7720 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -183,6 +183,10 @@ int dev_add_param(struct device_d *dev, const char *name,
 {
 	struct param_d *param;
 
+	param = get_param_by_name(dev, name);
+	if (param)
+		return -EEXIST;
+
 	param = __dev_add_param(dev, name, set, get, flags);
 
 	return param ? 0 : -EINVAL;
-- 
1.7.10




More information about the barebox mailing list