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 <dulibo1@xiaomi.com>
This commit is contained in:
dulibo1 2024-01-27 20:03:51 +08:00 committed by Xiang Xiao
parent b29d103ad3
commit 797df22802
2 changed files with 10 additions and 1 deletions

View file

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

View file

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