9
0
Fork 0

param: add config to disable it

this will allow to save 992 Bytes for TI xlaoder or AT91 bootstrap

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
This commit is contained in:
Jean-Christophe PLAGNIOL-VILLARD 2012-01-09 01:25:18 +08:00
parent 18e18dd13b
commit 971d164f62
5 changed files with 69 additions and 9 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 */

View File

@ -1,4 +1,7 @@
menu "Library routines"
config PARAMETER
bool
config UNCOMPRESS
bool
select FILETYPE

View File

@ -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