fuel_gauge: Join get/set prop structs
The fuel gauge API uses separate get/set property structs to indicate what properties are readable or writable. This lead to duplication in property names and potential confusion for new users of the API. See issue #61818. In addition to above, drivers already determine at runtime if a property is supported for read or write actions. Join the get/set fuel gauge property structs as a single struct. Signed-off-by: Aaron Massey <aaronmassey@google.com>
This commit is contained in:
parent
eae44a55d8
commit
a7b25d599b
10 changed files with 60 additions and 87 deletions
|
@ -109,7 +109,7 @@ static int bq27z746_read_mac(const struct device *dev, uint16_t cmd, uint8_t *da
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int bq27z746_get_prop(const struct device *dev, struct fuel_gauge_get_property *prop)
|
||||
static int bq27z746_get_prop(const struct device *dev, struct fuel_gauge_property *prop)
|
||||
{
|
||||
int rc = 0;
|
||||
uint16_t val = 0;
|
||||
|
@ -198,7 +198,7 @@ static int bq27z746_get_prop(const struct device *dev, struct fuel_gauge_get_pro
|
|||
}
|
||||
|
||||
static int bq27z746_get_buffer_prop(const struct device *dev,
|
||||
struct fuel_gauge_get_buffer_property *prop, void *dst,
|
||||
struct fuel_gauge_buffer_property *prop, void *dst,
|
||||
size_t dst_len)
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -236,7 +236,7 @@ static int bq27z746_get_buffer_prop(const struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int bq27z746_set_prop(const struct device *dev, struct fuel_gauge_set_property *prop)
|
||||
static int bq27z746_set_prop(const struct device *dev, struct fuel_gauge_property *prop)
|
||||
{
|
||||
int rc = 0;
|
||||
uint16_t val = 0;
|
||||
|
@ -260,7 +260,7 @@ static int bq27z746_set_prop(const struct device *dev, struct fuel_gauge_set_pro
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int bq27z746_get_props(const struct device *dev, struct fuel_gauge_get_property *props,
|
||||
static int bq27z746_get_props(const struct device *dev, struct fuel_gauge_property *props,
|
||||
size_t len)
|
||||
{
|
||||
int err_count = 0;
|
||||
|
@ -276,7 +276,7 @@ static int bq27z746_get_props(const struct device *dev, struct fuel_gauge_get_pr
|
|||
return err_count;
|
||||
}
|
||||
|
||||
static int bq27z746_set_props(const struct device *dev, struct fuel_gauge_set_property *props,
|
||||
static int bq27z746_set_props(const struct device *dev, struct fuel_gauge_property *props,
|
||||
size_t len)
|
||||
{
|
||||
int err_count = 0;
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
#include <zephyr/drivers/fuel_gauge.h>
|
||||
|
||||
static inline int z_vrfy_fuel_gauge_get_prop(const struct device *dev,
|
||||
struct fuel_gauge_get_property *props,
|
||||
struct fuel_gauge_property *props,
|
||||
size_t props_len)
|
||||
{
|
||||
struct fuel_gauge_get_property k_props[props_len];
|
||||
struct fuel_gauge_property k_props[props_len];
|
||||
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_property));
|
||||
|
||||
Z_OOPS(z_user_from_copy(k_props, props,
|
||||
props_len * sizeof(struct fuel_gauge_get_property)));
|
||||
props_len * sizeof(struct fuel_gauge_property)));
|
||||
|
||||
int ret = z_impl_fuel_gauge_get_prop(dev, k_props, props_len);
|
||||
|
||||
Z_OOPS(z_user_to_copy(props, k_props, props_len * sizeof(struct fuel_gauge_get_property)));
|
||||
Z_OOPS(z_user_to_copy(props, k_props, props_len * sizeof(struct fuel_gauge_property)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -29,19 +29,19 @@ static inline int z_vrfy_fuel_gauge_get_prop(const struct device *dev,
|
|||
#include <syscalls/fuel_gauge_get_prop_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_fuel_gauge_set_prop(const struct device *dev,
|
||||
struct fuel_gauge_set_property *props,
|
||||
struct fuel_gauge_property *props,
|
||||
size_t props_len)
|
||||
{
|
||||
struct fuel_gauge_set_property k_props[props_len];
|
||||
struct fuel_gauge_property k_props[props_len];
|
||||
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_FUEL_GAUGE(dev, set_property));
|
||||
|
||||
Z_OOPS(z_user_from_copy(k_props, props,
|
||||
props_len * sizeof(struct fuel_gauge_set_property)));
|
||||
props_len * sizeof(struct fuel_gauge_property)));
|
||||
|
||||
int ret = z_impl_fuel_gauge_set_prop(dev, k_props, props_len);
|
||||
|
||||
Z_OOPS(z_user_to_copy(props, k_props, props_len * sizeof(struct fuel_gauge_set_property)));
|
||||
Z_OOPS(z_user_to_copy(props, k_props, props_len * sizeof(struct fuel_gauge_property)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -49,22 +49,22 @@ static inline int z_vrfy_fuel_gauge_set_prop(const struct device *dev,
|
|||
#include <syscalls/fuel_gauge_set_prop_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_fuel_gauge_get_buffer_prop(const struct device *dev,
|
||||
struct fuel_gauge_get_buffer_property *prop,
|
||||
struct fuel_gauge_buffer_property *prop,
|
||||
void *dst, size_t dst_len)
|
||||
{
|
||||
struct fuel_gauge_get_buffer_property k_prop;
|
||||
struct fuel_gauge_buffer_property k_prop;
|
||||
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_buffer_property));
|
||||
|
||||
Z_OOPS(z_user_from_copy(&k_prop, prop,
|
||||
sizeof(struct fuel_gauge_get_buffer_property)));
|
||||
sizeof(struct fuel_gauge_buffer_property)));
|
||||
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(dst, dst_len));
|
||||
|
||||
int ret = z_impl_fuel_gauge_get_buffer_prop(dev, &k_prop, dst, dst_len);
|
||||
|
||||
Z_OOPS(z_user_to_copy(prop, &k_prop,
|
||||
sizeof(struct fuel_gauge_get_buffer_property)));
|
||||
sizeof(struct fuel_gauge_buffer_property)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ static int max17048_init(const struct device *dev)
|
|||
/**
|
||||
* Get a single property from the fuel gauge
|
||||
*/
|
||||
static int max17048_get_prop(const struct device *dev, struct fuel_gauge_get_property *prop)
|
||||
static int max17048_get_prop(const struct device *dev, struct fuel_gauge_property *prop)
|
||||
{
|
||||
struct max17048_data *data = dev->data;
|
||||
int rc = 0;
|
||||
|
@ -205,7 +205,7 @@ static int max17048_get_prop(const struct device *dev, struct fuel_gauge_get_pro
|
|||
/**
|
||||
* Get all possible properties from the fuel gague
|
||||
*/
|
||||
static int max17048_get_props(const struct device *dev, struct fuel_gauge_get_property *props,
|
||||
static int max17048_get_props(const struct device *dev, struct fuel_gauge_property *props,
|
||||
size_t len)
|
||||
{
|
||||
int err_count = 0;
|
||||
|
|
|
@ -66,7 +66,7 @@ static int sbs_cmd_buffer_read(const struct device *dev, uint8_t reg_addr, char
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sbs_gauge_get_prop(const struct device *dev, struct fuel_gauge_get_property *prop)
|
||||
static int sbs_gauge_get_prop(const struct device *dev, struct fuel_gauge_property *prop)
|
||||
{
|
||||
int rc = 0;
|
||||
uint16_t val = 0;
|
||||
|
@ -196,7 +196,7 @@ static int sbs_gauge_do_battery_cutoff(const struct device *dev)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sbs_gauge_set_prop(const struct device *dev, struct fuel_gauge_set_property *prop)
|
||||
static int sbs_gauge_set_prop(const struct device *dev, struct fuel_gauge_property *prop)
|
||||
{
|
||||
int rc = 0;
|
||||
uint16_t val = 0;
|
||||
|
@ -236,7 +236,7 @@ static int sbs_gauge_set_prop(const struct device *dev, struct fuel_gauge_set_pr
|
|||
}
|
||||
|
||||
static int sbs_gauge_get_buffer_prop(const struct device *dev,
|
||||
struct fuel_gauge_get_buffer_property *prop, void *dst,
|
||||
struct fuel_gauge_buffer_property *prop, void *dst,
|
||||
size_t dst_len)
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -274,7 +274,7 @@ static int sbs_gauge_get_buffer_prop(const struct device *dev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int sbs_gauge_get_props(const struct device *dev, struct fuel_gauge_get_property *props,
|
||||
static int sbs_gauge_get_props(const struct device *dev, struct fuel_gauge_property *props,
|
||||
size_t len)
|
||||
{
|
||||
int err_count = 0;
|
||||
|
@ -290,7 +290,7 @@ static int sbs_gauge_get_props(const struct device *dev, struct fuel_gauge_get_p
|
|||
return err_count;
|
||||
}
|
||||
|
||||
static int sbs_gauge_set_props(const struct device *dev, struct fuel_gauge_set_property *props,
|
||||
static int sbs_gauge_set_props(const struct device *dev, struct fuel_gauge_property *props,
|
||||
size_t len)
|
||||
{
|
||||
int err_count = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue