diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/fs.h | 3 | ||||
-rw-r--r-- | include/globalvar.h | 109 | ||||
-rw-r--r-- | include/gpio.h | 25 | ||||
-rw-r--r-- | include/param.h | 16 |
4 files changed, 49 insertions, 104 deletions
diff --git a/include/fs.h b/include/fs.h index 1b40ff55fe..d7fa7714b4 100644 --- a/include/fs.h +++ b/include/fs.h @@ -129,7 +129,8 @@ char *mkmodestr(unsigned long mode, char *str); * of "..", "." and double slashes. The returned string must be freed wit free(). */ char *normalise_path(const char *path); -char *normalise_link(const char *pathname, const char* symlink); + +char *canonicalize_path(const char *pathname); char *get_mounted_path(const char *path); diff --git a/include/globalvar.h b/include/globalvar.h index aea43b193d..df43f1fe66 100644 --- a/include/globalvar.h +++ b/include/globalvar.h @@ -15,9 +15,10 @@ void globalvar_remove(const char *name); char *globalvar_get_match(const char *match, const char *separator); void globalvar_set_match(const char *match, const char *val); -int __globalvar_add_simple_string(const char *name, char **value); -int __globalvar_add_simple_int(const char *name, void *value, - enum param_type type, const char *format); +int globalvar_add_simple_string(const char *name, char **value); +int globalvar_add_simple_int(const char *name, int *value, + const char *format); +int globalvar_add_simple_bool(const char *name, int *value); int globalvar_add_simple_enum(const char *name, int *value, const char * const *names, int max); int globalvar_add_simple_bitmask(const char *name, unsigned long *value, @@ -38,13 +39,19 @@ static inline int globalvar_add_simple(const char *name, const char *value) return 0; } -static inline int __globalvar_add_simple_int(const char *name, void *value, - enum param_type type, const char *format) +static inline int globalvar_add_simple_string(const char *name, char **value) { return 0; } -static inline int __globalvar_add_simple_string(const char *name, char **value) +static inline int globalvar_add_simple_int(const char *name, + int *value, const char *format) +{ + return 0; +} + +static inline int globalvar_add_simple_bool(const char *name, + int *value) { return 0; } @@ -108,96 +115,6 @@ static inline void dev_param_init_from_nv(struct device_d *dev, const char *name #endif -#define DECLARE_GLOBALVAR_INT(intname, inttype, paramtype) \ - static inline int globalvar_add_simple_##intname(const char *name, \ - inttype *value, \ - const char *format) \ - { \ - return __globalvar_add_simple_int(name, value, \ - paramtype, \ - format); \ - } - -DECLARE_GLOBALVAR_INT(uint32, uint32_t, PARAM_TYPE_UINT32) -DECLARE_GLOBALVAR_INT(int32, int32_t, PARAM_TYPE_INT32) -DECLARE_GLOBALVAR_INT(uint64, uint64_t, PARAM_TYPE_UINT64) -DECLARE_GLOBALVAR_INT(int64, int64_t, PARAM_TYPE_INT64) - -static inline int globalvar_add_simple_bool(const char *name, uint32_t *value) -{ - return __globalvar_add_simple_int(name, value, PARAM_TYPE_BOOL, "%u"); -} - -static inline int globalvar_add_simple_string(const char *name, char **value) -{ - return __globalvar_add_simple_string(name, value); -} - -#define DECLARE_GLOBALVAR_INT_RO(intname, inttype, paramtype) \ - static inline int globalvar_add_simple_##intname##_ro(const char *name, \ - inttype *value, \ - const char *format) \ - { \ - return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name,\ - param_set_readonly, \ - NULL, value, \ - paramtype, \ - format, NULL)); \ - } - -DECLARE_GLOBALVAR_INT_RO(uint32, uint32_t, PARAM_TYPE_UINT32) -DECLARE_GLOBALVAR_INT_RO(int32, int32_t, PARAM_TYPE_INT32) -DECLARE_GLOBALVAR_INT_RO(uint64, uint64_t, PARAM_TYPE_UINT64) -DECLARE_GLOBALVAR_INT_RO(int64, int64_t, PARAM_TYPE_INT64) - -static inline int globalvar_add_simple_bool_ro(const char *name, uint32_t *value) -{ - return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, - param_set_readonly, NULL, - value, PARAM_TYPE_BOOL, "%u", - NULL)); -} - -static inline int globalvar_add_simple_string_ro(const char *name, char **value) -{ - return __globalvar_add_simple_string(name, value); -} - -#define DECLARE_GLOBALVAR_INT_FIXED(intname, inttype, paramtype) \ - static inline int globalvar_add_simple_##intname##_fixed(const char *name, \ - inttype value, \ - const char *format) \ - { \ - return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, \ - ERR_PTR(-EROFS), NULL, \ - &value, paramtype, \ - format, NULL)); \ - } - -DECLARE_GLOBALVAR_INT_FIXED(uint32, uint32_t, PARAM_TYPE_UINT32) -DECLARE_GLOBALVAR_INT_FIXED(int32, int32_t, PARAM_TYPE_INT32) -DECLARE_GLOBALVAR_INT_FIXED(uint64, uint64_t, PARAM_TYPE_UINT64) -DECLARE_GLOBALVAR_INT_FIXED(int64, int64_t, PARAM_TYPE_INT64) - -static inline int globalvar_add_simple_bool_fixed(const char *name, uint32_t value) -{ - return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, ERR_PTR(-EROFS), - NULL, &value, PARAM_TYPE_BOOL, "%u", - NULL)); -} - -static inline int globalvar_add_simple_string_fixed(const char *name, char *value) -{ - return PTR_ERR_OR_ZERO(dev_add_param_string_fixed(&global_device, name, value)); -} - -static inline int globalvar_add_simple_enum_ro(const char *name, int *value, - const char * const *names, int max) -{ - return PTR_ERR_OR_ZERO(dev_add_param_enum_ro(&global_device, name, value, names, - max)); -} - void nv_var_set_clean(void); int nvvar_save(void); int nv_global_complete(struct string_list *sl, char *instr); diff --git a/include/gpio.h b/include/gpio.h index 7b3f512b19..56aae22236 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -6,6 +6,11 @@ void gpio_set_value(unsigned gpio, int value); int gpio_get_value(unsigned gpio); int gpio_direction_output(unsigned gpio, int value); int gpio_direction_input(unsigned gpio); + +void gpio_set_active(unsigned gpio, bool state); +int gpio_is_active(unsigned gpio); +int gpio_direction_active(unsigned gpio, bool state); + #else static inline void gpio_set_value(unsigned gpio, int value) { @@ -22,6 +27,18 @@ static inline int gpio_direction_input(unsigned gpio) { return -EINVAL; } + +static inline void gpio_set_active(unsigned gpio, int value) +{ +} +static inline int gpio_is_active(unsigned gpio) +{ + return 0; +} +static inline int gpio_direction_active(unsigned gpio, int value) +{ + return -EINVAL; +} #endif #define ARCH_NR_GPIOS 256 @@ -45,6 +62,14 @@ static inline int gpio_is_valid(int gpio) #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW) #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH) +#define GPIOF_LOGICAL BIT(2) +#define GPIOF_ACTIVE_HIGH GPIOF_LOGICAL +#define GPIOF_ACTIVE_LOW (BIT(3) | GPIOF_LOGICAL) +#define GPIOF_INIT_INACTIVE GPIOF_LOGICAL +#define GPIOF_INIT_ACTIVE (GPIOF_LOGICAL | GPIOF_INIT_HIGH) +#define GPIOF_OUT_INIT_ACTIVE (GPIOF_DIR_OUT | GPIOF_INIT_ACTIVE) +#define GPIOF_OUT_INIT_INACTIVE (GPIOF_DIR_OUT | GPIOF_INIT_INACTIVE) + /** * struct gpio - a structure describing a GPIO with configuration * @gpio: the GPIO number diff --git a/include/param.h b/include/param.h index 9637229838..2592a09c3a 100644 --- a/include/param.h +++ b/include/param.h @@ -6,6 +6,7 @@ #include <linux/list.h> #define PARAM_FLAG_RO (1 << 0) +#define PARAM_GLOBALVAR_UNQUALIFIED (1 << 1) struct device_d; typedef uint32_t IPaddr_t; @@ -24,8 +25,8 @@ enum param_type { }; struct param_d { - const char* (*get)(struct param_d *param); - int (*set)(struct param_d *param, const char *val); + const char* (*get)(struct device_d *, struct param_d *param); + int (*set)(struct device_d *, struct param_d *param, const char *val); void (*info)(struct param_d *param); unsigned int flags; char *name; @@ -43,8 +44,8 @@ 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); struct param_d *dev_add_param(struct device_d *dev, const char *name, - int (*set)(struct param_d *p, const char *val), - const char *(*get)(struct param_d *p), + int (*set)(struct device_d *dev, struct param_d *p, const char *val), + const char *(*get)(struct device_d *, struct param_d *p), unsigned long flags); struct param_d *dev_add_param_string(struct device_d *dev, const char *name, @@ -83,7 +84,8 @@ void dev_remove_param(struct param_d *p); void dev_remove_parameters(struct device_d *dev); -int dev_param_set_generic(struct param_d *p, const char *val); +int dev_param_set_generic(struct device_d *dev, struct param_d *p, + const char *val); #else static inline const char *dev_get_param(struct device_d *dev, const char *name) @@ -102,8 +104,8 @@ static inline struct param_d *get_param_by_name(struct device_d *dev, } static inline struct param_d *dev_add_param(struct device_d *dev, const char *name, - int (*set)(struct device_d *dev, struct param_d *p, const char *val), - const char *(*get)(struct device_d *, struct param_d *p), + int (*set)(struct param_d *p, const char *val), + const char *(*get)(struct param_d *p), unsigned long flags) { return ERR_PTR(-ENOSYS); |