* [PATCH] of_regulator: use of_property_read_{bool|u32}()
@ 2014-05-26 20:27 Sergei Shtylyov
2014-06-01 10:56 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Sergei Shtylyov @ 2014-05-26 20:27 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: grant.likely, robh+dt, devicetree, linux-kernel
Use more compact of_property_read_{bool|u32}() calls instead of the
of_{find|get}_property() calls in of_get_regulation_constraints() where
possible (note that of_property_read_{bool|u32}() were already used to read
some properties).
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
The patch is against Mark Brown's 'regulator.git' repo's 'for-next' branch.
drivers/regulator/of_regulator.c | 37 ++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
Index: regulator/drivers/regulator/of_regulator.c
===================================================================
--- regulator.orig/drivers/regulator/of_regulator.c
+++ regulator/drivers/regulator/of_regulator.c
@@ -19,9 +19,7 @@
static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data)
{
- const __be32 *min_uV, *max_uV, *uV_offset;
- const __be32 *min_uA, *max_uA, *ramp_delay;
- struct property *prop;
+ const __be32 *min_uV, *max_uV;
struct regulation_constraints *constraints = &(*init_data)->constraints;
int ret;
u32 pval;
@@ -42,36 +40,29 @@ static void of_get_regulation_constraint
if (min_uV && max_uV && constraints->min_uV == constraints->max_uV)
constraints->apply_uV = true;
- uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL);
- if (uV_offset)
- constraints->uV_offset = be32_to_cpu(*uV_offset);
- min_uA = of_get_property(np, "regulator-min-microamp", NULL);
- if (min_uA)
- constraints->min_uA = be32_to_cpu(*min_uA);
- max_uA = of_get_property(np, "regulator-max-microamp", NULL);
- if (max_uA)
- constraints->max_uA = be32_to_cpu(*max_uA);
+ if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval))
+ constraints->uV_offset = pval;
+ if (!of_property_read_u32(np, "regulator-min-microamp", &pval))
+ constraints->min_uA = pval;
+ if (!of_property_read_u32(np, "regulator-max-microamp", &pval))
+ constraints->max_uA = pval;
/* Current change possible? */
if (constraints->min_uA != constraints->max_uA)
constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT;
- if (of_find_property(np, "regulator-boot-on", NULL))
- constraints->boot_on = true;
-
- if (of_find_property(np, "regulator-always-on", NULL))
- constraints->always_on = true;
- else /* status change should be possible if not always on. */
+ constraints->boot_on = of_property_read_bool(np, "regulator-boot-on");
+ constraints->always_on = of_property_read_bool(np, "regulator-always-on");
+ if (!constraints->always_on) /* status change should be possible. */
constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS;
if (of_property_read_bool(np, "regulator-allow-bypass"))
constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;
- prop = of_find_property(np, "regulator-ramp-delay", NULL);
- if (prop && prop->value) {
- ramp_delay = prop->value;
- if (*ramp_delay)
- constraints->ramp_delay = be32_to_cpu(*ramp_delay);
+ ret = of_property_read_u32(np, "regulator-ramp-delay", &pval);
+ if (!ret) {
+ if (pval)
+ constraints->ramp_delay = pval;
else
constraints->ramp_disable = true;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] of_regulator: use of_property_read_{bool|u32}()
2014-05-26 20:27 [PATCH] of_regulator: use of_property_read_{bool|u32}() Sergei Shtylyov
@ 2014-06-01 10:56 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-06-01 10:56 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: lgirdwood, grant.likely, robh+dt, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 389 bytes --]
On Tue, May 27, 2014 at 12:27:19AM +0400, Sergei Shtylyov wrote:
> Use more compact of_property_read_{bool|u32}() calls instead of the
> of_{find|get}_property() calls in of_get_regulation_constraints() where
> possible (note that of_property_read_{bool|u32}() were already used to read
> some properties).
Applied, thanks. Please use subject lines matching the style for the
subsystem.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-01 10:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 20:27 [PATCH] of_regulator: use of_property_read_{bool|u32}() Sergei Shtylyov
2014-06-01 10:56 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).