mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] parameter: fix parameter name to reflect usage
Date: Mon,  5 Aug 2024 14:23:17 +0200	[thread overview]
Message-ID: <20240805122317.3649096-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2024-08-05 12:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05 12:23 Ahmad Fatoum [this message]
2024-08-05 12:54 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240805122317.3649096-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox