mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] param: Add support for long long read only dev param
@ 2014-06-12  9:37 Herve Codina
  2014-06-12  9:37 ` [PATCH 2/2] mtd: use long long dev param for size Herve Codina
  2014-06-13  4:27 ` [PATCH 1/2] param: Add support for long long read only dev param Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Herve Codina @ 2014-06-12  9:37 UTC (permalink / raw)
  To: barebox; +Cc: Herve Codina

Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
---
 include/param.h |    9 +++++++++
 lib/parameter.c |   26 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/param.h b/include/param.h
index eac3372..24827c5 100644
--- a/include/param.h
+++ b/include/param.h
@@ -49,6 +49,9 @@ struct param_d *dev_add_param_enum(struct device_d *dev, const char *name,
 struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name,
 		int value, const char *format);
 
+struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name,
+		long long value, const char *format);
+
 struct param_d *dev_add_param_ip(struct device_d *dev, const char *name,
 		int (*set)(struct param_d *p, void *priv),
 		int (*get)(struct param_d *p, void *priv),
@@ -123,6 +126,12 @@ static inline struct param_d *dev_add_param_int_ro(struct device_d *dev, const c
 	return NULL;
 }
 
+static inline struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name,
+		long long value, const char *format)
+{
+	return NULL;
+}
+
 static inline struct param_d *dev_add_param_ip(struct device_d *dev, const char *name,
 		int (*set)(struct param_d *p, void *priv),
 		int (*get)(struct param_d *p, void *priv),
diff --git a/lib/parameter.c b/lib/parameter.c
index b1f9aa3..13062bc 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -468,6 +468,32 @@ struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name,
 	return &piro->param;
 }
 
+/**
+ * dev_add_param_llint_ro - add a read only long long parameter to a device
+ * @param dev	The device
+ * @param name	The name of the parameter
+ * @param value	The value of the parameter
+ * @param format the printf format used to print the value
+ */
+struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name,
+		long long value, const char *format)
+{
+	struct param_int *piro;
+	int ret;
+
+	piro = xzalloc(sizeof(*piro));
+
+	ret = __dev_add_param(&piro->param, dev, name, NULL, NULL, 0);
+	if (ret) {
+		free(piro);
+		return ERR_PTR(ret);
+	}
+
+	piro->param.value = asprintf(format, value);
+
+	return &piro->param;
+}
+
 #ifdef CONFIG_NET
 struct param_ip {
 	struct param_d param;
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] mtd: use long long dev param for size
  2014-06-12  9:37 [PATCH 1/2] param: Add support for long long read only dev param Herve Codina
@ 2014-06-12  9:37 ` Herve Codina
  2014-06-13  4:27 ` [PATCH 1/2] param: Add support for long long read only dev param Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Herve Codina @ 2014-06-12  9:37 UTC (permalink / raw)
  To: barebox; +Cc: Herve Codina

Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
---
 drivers/mtd/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index d3e7763..82fb5f7 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -401,7 +401,7 @@ int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id)
 	mtd->cdev.mtd = mtd;
 
 	if (IS_ENABLED(CONFIG_PARAMETER)) {
-		dev_add_param_int_ro(&mtd->class_dev, "size", mtd->size, "%llu");
+		dev_add_param_llint_ro(&mtd->class_dev, "size", mtd->size, "%llu");
 		dev_add_param_int_ro(&mtd->class_dev, "erasesize", mtd->erasesize, "%u");
 		dev_add_param_int_ro(&mtd->class_dev, "writesize", mtd->writesize, "%u");
 		dev_add_param_int_ro(&mtd->class_dev, "oobsize", mtd->oobsize, "%u");
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] param: Add support for long long read only dev param
  2014-06-12  9:37 [PATCH 1/2] param: Add support for long long read only dev param Herve Codina
  2014-06-12  9:37 ` [PATCH 2/2] mtd: use long long dev param for size Herve Codina
@ 2014-06-13  4:27 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-06-13  4:27 UTC (permalink / raw)
  To: Herve Codina; +Cc: barebox

On Thu, Jun 12, 2014 at 11:37:37AM +0200, Herve Codina wrote:
> Signed-off-by: Herve Codina <Herve.CODINA@celad.com>

Applied both, thanks

Sascha

> ---
>  include/param.h |    9 +++++++++
>  lib/parameter.c |   26 ++++++++++++++++++++++++++
>  2 files changed, 35 insertions(+)
> 
> diff --git a/include/param.h b/include/param.h
> index eac3372..24827c5 100644
> --- a/include/param.h
> +++ b/include/param.h
> @@ -49,6 +49,9 @@ struct param_d *dev_add_param_enum(struct device_d *dev, const char *name,
>  struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name,
>  		int value, const char *format);
>  
> +struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name,
> +		long long value, const char *format);
> +
>  struct param_d *dev_add_param_ip(struct device_d *dev, const char *name,
>  		int (*set)(struct param_d *p, void *priv),
>  		int (*get)(struct param_d *p, void *priv),
> @@ -123,6 +126,12 @@ static inline struct param_d *dev_add_param_int_ro(struct device_d *dev, const c
>  	return NULL;
>  }
>  
> +static inline struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name,
> +		long long value, const char *format)
> +{
> +	return NULL;
> +}
> +
>  static inline struct param_d *dev_add_param_ip(struct device_d *dev, const char *name,
>  		int (*set)(struct param_d *p, void *priv),
>  		int (*get)(struct param_d *p, void *priv),
> diff --git a/lib/parameter.c b/lib/parameter.c
> index b1f9aa3..13062bc 100644
> --- a/lib/parameter.c
> +++ b/lib/parameter.c
> @@ -468,6 +468,32 @@ struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name,
>  	return &piro->param;
>  }
>  
> +/**
> + * dev_add_param_llint_ro - add a read only long long parameter to a device
> + * @param dev	The device
> + * @param name	The name of the parameter
> + * @param value	The value of the parameter
> + * @param format the printf format used to print the value
> + */
> +struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name,
> +		long long value, const char *format)
> +{
> +	struct param_int *piro;
> +	int ret;
> +
> +	piro = xzalloc(sizeof(*piro));
> +
> +	ret = __dev_add_param(&piro->param, dev, name, NULL, NULL, 0);
> +	if (ret) {
> +		free(piro);
> +		return ERR_PTR(ret);
> +	}
> +
> +	piro->param.value = asprintf(format, value);
> +
> +	return &piro->param;
> +}
> +
>  #ifdef CONFIG_NET
>  struct param_ip {
>  	struct param_d param;
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-06-13  4:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12  9:37 [PATCH 1/2] param: Add support for long long read only dev param Herve Codina
2014-06-12  9:37 ` [PATCH 2/2] mtd: use long long dev param for size Herve Codina
2014-06-13  4:27 ` [PATCH 1/2] param: Add support for long long read only dev param Sascha Hauer

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