diff options
Diffstat (limited to 'drivers/power/pmic/pmic-uclass.c')
-rw-r--r-- | drivers/power/pmic/pmic-uclass.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c index d82d3da51d..812ac13baa 100644 --- a/drivers/power/pmic/pmic-uclass.c +++ b/drivers/power/pmic/pmic-uclass.c @@ -27,8 +27,8 @@ static ulong str_get_num(const char *ptr, const char *maxptr) return simple_strtoul(ptr, NULL, 0); } -int pmic_bind_childs(struct udevice *pmic, int offset, - const struct pmic_child_info *child_info) +int pmic_bind_children(struct udevice *pmic, int offset, + const struct pmic_child_info *child_info) { const struct pmic_child_info *info; const void *blob = gd->fdt_blob; @@ -53,14 +53,10 @@ int pmic_bind_childs(struct udevice *pmic, int offset, node); child = NULL; - info = child_info; - while (info->prefix) { + for (info = child_info; info->prefix && info->driver; info++) { prefix_len = strlen(info->prefix); - if (strncasecmp(info->prefix, node_name, prefix_len) || - !info->driver) { - info++; + if (strncasecmp(info->prefix, node_name, prefix_len)) continue; - } debug(" - compatible prefix: '%s'\n", info->prefix); @@ -110,16 +106,16 @@ int pmic_get(const char *name, struct udevice **devp) int pmic_reg_count(struct udevice *dev) { const struct dm_pmic_ops *ops = dev_get_driver_ops(dev); - if (!ops) + + if (!ops || !ops->reg_count) return -ENOSYS; - return ops->reg_count; + return ops->reg_count(dev); } int pmic_read(struct udevice *dev, uint reg, uint8_t *buffer, int len) { const struct dm_pmic_ops *ops = dev_get_driver_ops(dev); - int ret; if (!buffer) return -EFAULT; @@ -127,17 +123,12 @@ int pmic_read(struct udevice *dev, uint reg, uint8_t *buffer, int len) if (!ops || !ops->read) return -ENOSYS; - ret = ops->read(dev, reg, buffer, len); - if (ret) - return ret; - - return 0; + return ops->read(dev, reg, buffer, len); } int pmic_write(struct udevice *dev, uint reg, const uint8_t *buffer, int len) { const struct dm_pmic_ops *ops = dev_get_driver_ops(dev); - int ret; if (!buffer) return -EFAULT; @@ -145,11 +136,7 @@ int pmic_write(struct udevice *dev, uint reg, const uint8_t *buffer, int len) if (!ops || !ops->write) return -ENOSYS; - ret = ops->write(dev, reg, buffer, len); - if (ret) - return ret; - - return 0; + return ops->write(dev, reg, buffer, len); } UCLASS_DRIVER(pmic) = { |