mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] parameter: fix parameter name to reflect usage
@ 2024-08-05 12:23 Ahmad Fatoum
  2024-08-05 12:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-08-05 12:23 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Everywhere the max parameter is used, it's assumed it has the value of
the highest index into the names array + 1. As counting begins from
zero, rename it to num_names in the prototypes for clarity.

This is already the name used internally in struct param_d.

No functional change.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/param.h | 16 ++++++++--------
 lib/parameter.c |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/param.h b/include/param.h
index 5d4f7f3db52f..1ccb6a26eb78 100644
--- a/include/param.h
+++ b/include/param.h
@@ -68,7 +68,7 @@ struct param_d *dev_add_param_enum(struct device *dev, const char *name,
 				   int (*set)(struct param_d *p, void *priv),
 				   int (*get)(struct param_d *p, void *priv),
 				   int *value, const char * const *names,
-				   int max, void *priv);
+				   int num_names, void *priv);
 
 struct param_d *dev_add_param_tristate(struct device *dev, const char *name,
 				       int (*set)(struct param_d *p, void *priv),
@@ -83,7 +83,7 @@ struct param_d *dev_add_param_bitmask(struct device *dev, const char *name,
 				      int (*set)(struct param_d *p, void *priv),
 				      int (*get)(struct param_d *p, void *priv),
 				      unsigned long *value,
-				      const char * const *names, int max,
+				      const char * const *names, int num_names,
 				      void *priv);
 
 struct param_d *dev_add_param_ip(struct device *dev, const char *name,
@@ -164,7 +164,7 @@ static inline struct param_d *dev_add_param_enum(struct device *dev,
 						 int (*get)(struct param_d *p, void *priv),
 						 int *value,
 						 const char * const *names,
-						 int max, void *priv)
+						 int num_names, void *priv)
 
 {
 	return NULL;
@@ -176,7 +176,7 @@ static inline struct param_d *dev_add_param_bitmask(struct device *dev,
 						    int (*get)(struct param_d *p, void *priv),
 						    unsigned long *value,
 						    const char * const *names,
-						    int max, void *priv)
+						    int num_names, void *priv)
 {
 	return NULL;
 }
@@ -350,20 +350,20 @@ static inline struct param_d *dev_add_param_enum_ro(struct device *dev,
 						    const char *name,
 						    int *value,
 						    const char * const *names,
-						    int max)
+						    int num_names)
 {
 	return dev_add_param_enum(dev, name, param_set_readonly, NULL,
-				  value, names, max, NULL);
+				  value, names, num_names, NULL);
 }
 
 static inline struct param_d *dev_add_param_bitmask_ro(struct device *dev,
 						       const char *name,
 						       unsigned long *value,
 						       const char * const *names,
-						       int max)
+						       int num_names)
 {
 	return dev_add_param_bitmask(dev, name, param_set_readonly, NULL,
-				     value, names, max, NULL);
+				     value, names, num_names, NULL);
 }
 
 /*
diff --git a/lib/parameter.c b/lib/parameter.c
index c587d10eabcc..bf9e83152b77 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -718,7 +718,7 @@ struct param_d *dev_add_param_bitmask(struct device *dev, const char *name,
 				      int (*set)(struct param_d *p, void *priv),
 				      int (*get)(struct param_d *p, void *priv),
 				      unsigned long *value,
-				      const char * const *names, int max,
+				      const char * const *names, int num_names,
 				      void *priv)
 {
 	struct param_bitmask *pb;
@@ -731,7 +731,7 @@ struct param_d *dev_add_param_bitmask(struct device *dev, const char *name,
 	pb->set = set;
 	pb->get = get;
 	pb->names = names;
-	pb->num_names = max;
+	pb->num_names = num_names;
 	p = &pb->param;
 	p->driver_priv = priv;
 	p->type = PARAM_TYPE_BITMASK;
-- 
2.39.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] parameter: fix parameter name to reflect usage
  2024-08-05 12:23 [PATCH] parameter: fix parameter name to reflect usage Ahmad Fatoum
@ 2024-08-05 12:54 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-08-05 12:54 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 05 Aug 2024 14:23:17 +0200, Ahmad Fatoum wrote:
> Everywhere the max parameter is used, it's assumed it has the value of
> the highest index into the names array + 1. As counting begins from
> zero, rename it to num_names in the prototypes for clarity.
> 
> This is already the name used internally in struct param_d.
> 
> No functional change.
> 
> [...]

Applied, thanks!

[1/1] parameter: fix parameter name to reflect usage
      https://git.pengutronix.de/cgit/barebox/commit/?id=90b6a7468bf5 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-05 12:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-05 12:23 [PATCH] parameter: fix parameter name to reflect usage Ahmad Fatoum
2024-08-05 12:54 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox