[PATCH 5/6] param: add config to disable it
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Wed Jan 11 08:31:55 EST 2012
this will allow to save 992 Bytes for TI xlaoder or AT91 bootstrap
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
common/Kconfig | 2 +
drivers/mtd/core.c | 18 +++++++++-------
include/param.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/Kconfig | 3 ++
lib/Makefile | 2 +-
5 files changed, 69 insertions(+), 9 deletions(-)
diff --git a/common/Kconfig b/common/Kconfig
index 20e4050..382e591 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -258,6 +258,7 @@ choice
bool "hush parser"
select ENVIRONMENT_VARIABLES
select COMMAND_SUPPORT
+ select PARAMETER
help
Enable hush support. This is the most advanced shell available
for barebox.
@@ -266,6 +267,7 @@ choice
bool "Simple parser"
select ENVIRONMENT_VARIABLES
select COMMAND_SUPPORT
+ select PARAMETER
help
simple shell. No if/then, no return values from commands, no loops
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index f25863d..491cc1f 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -204,14 +204,16 @@ int add_mtd_device(struct mtd_info *mtd, char *devname)
mtd->cdev.dev = &mtd->class_dev;
mtd->cdev.mtd = mtd;
- sprintf(str, "%u", mtd->size);
- dev_add_param_fixed(&mtd->class_dev, "size", str);
- sprintf(str, "%u", mtd->erasesize);
- dev_add_param_fixed(&mtd->class_dev, "erasesize", str);
- sprintf(str, "%u", mtd->writesize);
- dev_add_param_fixed(&mtd->class_dev, "writesize", str);
- sprintf(str, "%u", mtd->oobsize);
- dev_add_param_fixed(&mtd->class_dev, "oobsize", str);
+ if (IS_ENABLED(CONFIG_PARAMETER)) {
+ sprintf(str, "%u", mtd->size);
+ dev_add_param_fixed(&mtd->class_dev, "size", str);
+ sprintf(str, "%u", mtd->erasesize);
+ dev_add_param_fixed(&mtd->class_dev, "erasesize", str);
+ sprintf(str, "%u", mtd->writesize);
+ dev_add_param_fixed(&mtd->class_dev, "writesize", str);
+ sprintf(str, "%u", mtd->oobsize);
+ dev_add_param_fixed(&mtd->class_dev, "oobsize", str);
+ }
devfs_create(&mtd->cdev);
diff --git a/include/param.h b/include/param.h
index 207ad50..4a39dc7 100644
--- a/include/param.h
+++ b/include/param.h
@@ -19,6 +19,7 @@ struct param_d {
struct list_head list;
};
+#ifdef CONFIG_PARAMETER
const char *dev_get_param(struct device_d *dev, const char *name);
int dev_set_param(struct device_d *dev, const char *name, const char *val);
struct param_d *get_param_by_name(struct device_d *dev, const char *name);
@@ -40,6 +41,58 @@ int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip);
IPaddr_t dev_get_param_ip(struct device_d *dev, char *name);
int global_add_parameter(struct param_d *param);
+#else
+static inline const char *dev_get_param(struct device_d *dev, const char *name)
+{
+ return NULL;
+}
+static inline int dev_set_param(struct device_d *dev, const char *name,
+ const char *val)
+{
+ return 0;
+}
+static inline struct param_d *get_param_by_name(struct device_d *dev,
+ const char *name)
+{
+ return NULL;
+}
+
+static inline int dev_add_param(struct device_d *dev, char *name,
+ int (*set)(struct device_d *dev, struct param_d *p, const char *val),
+ char *(*get)(struct device_d *, struct param_d *p),
+ unsigned long flags)
+{
+ return 0;
+}
+
+static inline int dev_add_param_fixed(struct device_d *dev, char *name, char *value)
+{
+ return 0;
+}
+
+static inline void dev_remove_parameters(struct device_d *dev) {}
+
+static inline int dev_param_set_generic(struct device_d *dev, struct param_d *p,
+ const char *val)
+{
+ return 0;
+}
+
+/* Convenience functions to handle a parameter as an ip address */
+static inline int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip)
+{
+ return 0;
+}
+static inline IPaddr_t dev_get_param_ip(struct device_d *dev, char *name)
+{
+ return 0;
+}
+
+static inline int global_add_parameter(struct param_d *param)
+{
+ return 0;
+}
+#endif
#endif /* PARAM_H */
diff --git a/lib/Kconfig b/lib/Kconfig
index 6b4063d..f886e6e 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1,4 +1,7 @@
menu "Library routines"
+config PARAMETER
+ bool
+
config UNCOMPRESS
bool
select FILETYPE
diff --git a/lib/Makefile b/lib/Makefile
index c273c58..01a01b5 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -5,7 +5,7 @@ obj-y += string.o
obj-y += vsprintf.o
obj-y += div64.o
obj-y += misc.o
-obj-y += parameter.o
+obj-$(CONFIG_PARAMETER) += parameter.o
obj-y += xfuncs.o
obj-y += getopt.o
obj-y += readkey.o
--
1.7.7
More information about the barebox
mailing list