lkml.org 
[lkml]   [2017]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 3/4] regulator: core: Parse coupled regulators properties
On Thu, Dec 07, 2017 at 10:46:14AM +0100, Maciej Purski wrote:

> +static int check_coupled_regulators_array(struct coupling_desc *c_desc,
> + int index)
> +{

> + /* Different number of regulators coupled */
> + if (of_count_phandle_with_args(node, "regulator-coupled-with", 0) !=
> + (n_coupled - 1))
> + return -EINVAL;

This is still DT only code in the core file, we really need the core to
not know anything about DT so that we know that we can support this
feature with other firmwares if we need to. Just move all the parsing
code into the of_regulator.c then have a second step that goes through
and validates extra stuff like the presence of set voltage operations in
the generic code.

> + if (c_desc->coupled_rdevs[i]->constraints->max_spread !=
> + rdev->constraints->max_spread) {
> + rdev_err(rdev, "coupled regulators max_spread mismatch\n");
> + goto err;
> + }

It's better to print out failing values when things go wrong - it really
helps people debug their DTs if the error messages are specific about
what went wrong. This applies to a bunch of the errors here.

> + mutex_lock(&regulator_list_mutex);
> + regulator_resolve_coupling(rdev);
> + mutex_unlock(&regulator_list_mutex);
> +

I'd really expect us to be failing to probe if we run into an error.
Otherwise we could end up doing bad things to the hardware at runtime
later on, or confusing ourselves and crashing with partially set up
datastructures. It's also not 100% clear to me how we handle the case
where only some of the coupled regulators have probed.

> diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h
> index 2f3218b..6290384 100644
> --- a/drivers/regulator/internal.h
> +++ b/drivers/regulator/internal.h
> @@ -16,6 +16,8 @@
> #ifndef __REGULATOR_INTERNAL_H
> #define __REGULATOR_INTERNAL_H
>
> +#include <linux/regulator/driver.h>
> +

Why do we need this?
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-12-12 12:36    [W:0.180 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site