diff --git a/drivers/power/battery/battery_charger.c b/drivers/power/battery/battery_charger.c index f0fff70ecad..d01292b51a9 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 2f784628bf1..45dc694daa2 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 */ };