xref: /OK3568_Linux_fs/u-boot/drivers/power/charge-display-uclass.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #include <command.h>
8 #include <common.h>
9 #include <dm.h>
10 #include <power/charge_display.h>
11 
charge_display_show(struct udevice * dev)12 int charge_display_show(struct udevice *dev)
13 {
14 	const struct dm_charge_display_ops *ops = dev_get_driver_ops(dev);
15 
16 	if (!ops || !ops->show)
17 		return -ENOSYS;
18 
19 	return ops->show(dev);
20 }
21 
charge_display(void)22 int charge_display(void)
23 {
24 	struct udevice *dev;
25 	int ret;
26 
27 	ret = uclass_get_device(UCLASS_CHARGE_DISPLAY, 0, &dev);
28 	if (ret) {
29 		debug("Get charge display failed, ret=%d\n", ret);
30 		return ret;
31 	}
32 
33 	return charge_display_show(dev);
34 }
35 
36 UCLASS_DRIVER(charge_display) = {
37 	.id	= UCLASS_CHARGE_DISPLAY,
38 	.name	= "charge_display",
39 };
40