You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/28 03:25:24 UTC
(nuttx) 01/04: power:add default protocol for the driver which not impl get_protocol
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 797df22802e053951b521e76f09b2b785afed137
Author: dulibo1 <du...@xiaomi.com>
AuthorDate: Sat Jan 27 20:03:51 2024 +0800
power:add default protocol for the driver which not impl get_protocol
add default protocol for the driver which not impl get_protocol
Signed-off-by: dulibo1 <du...@xiaomi.com>
---
drivers/power/battery/battery_charger.c | 10 +++++++++-
include/nuttx/power/battery_ioctl.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/power/battery/battery_charger.c b/drivers/power/battery/battery_charger.c
index f0fff70eca..d01292b51a 100644
--- a/drivers/power/battery/battery_charger.c
+++ b/drivers/power/battery/battery_charger.c
@@ -391,7 +391,15 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd,
FAR int *ptr = (FAR int *)((uintptr_t)arg);
if (ptr)
{
- ret = dev->ops->get_protocol(dev, ptr);
+ if (dev->ops->get_protocol)
+ {
+ ret = dev->ops->get_protocol(dev, ptr);
+ }
+ else
+ {
+ *ptr = BATTERY_PROTOCOL_DEFAULT;
+ ret = OK;
+ }
}
}
break;
diff --git a/include/nuttx/power/battery_ioctl.h b/include/nuttx/power/battery_ioctl.h
index 2f784628bf..45dc694daa 100644
--- a/include/nuttx/power/battery_ioctl.h
+++ b/include/nuttx/power/battery_ioctl.h
@@ -116,6 +116,7 @@ enum battery_health_e
enum battery_protocol_e
{
+ BATTERY_PROTOCOL_DEFAULT = 0, /* Battery charge protocol of adapter is DEFAULT */
BATTERY_PROTOCOL_QC3P0 = 1 << 0, /* Battery charge protocol of adapter is QC 3.0 */
BATTERY_PROTOCOL_TX_XIAOMI = 1 << 1, /* Battery charge protocol of TX is xiaomi standard */
};