Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
46294d66
Commit
46294d66
authored
Nov 10, 2017
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'regulator/fix/qcom-spmi' into regulator-linus
parents
39dae59d
ab953b9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
drivers/regulator/qcom_spmi-regulator.c
drivers/regulator/qcom_spmi-regulator.c
+33
-6
No files found.
drivers/regulator/qcom_spmi-regulator.c
View file @
46294d66
...
@@ -593,13 +593,20 @@ static int spmi_sw_selector_to_hw(struct spmi_regulator *vreg,
...
@@ -593,13 +593,20 @@ static int spmi_sw_selector_to_hw(struct spmi_regulator *vreg,
u8
*
voltage_sel
)
u8
*
voltage_sel
)
{
{
const
struct
spmi_voltage_range
*
range
,
*
end
;
const
struct
spmi_voltage_range
*
range
,
*
end
;
unsigned
offset
;
range
=
vreg
->
set_points
->
range
;
range
=
vreg
->
set_points
->
range
;
end
=
range
+
vreg
->
set_points
->
count
;
end
=
range
+
vreg
->
set_points
->
count
;
for
(;
range
<
end
;
range
++
)
{
for
(;
range
<
end
;
range
++
)
{
if
(
selector
<
range
->
n_voltages
)
{
if
(
selector
<
range
->
n_voltages
)
{
*
voltage_sel
=
selector
;
/*
* hardware selectors between set point min and real
* min are invalid so we ignore them
*/
offset
=
range
->
set_point_min_uV
-
range
->
min_uV
;
offset
/=
range
->
step_uV
;
*
voltage_sel
=
selector
+
offset
;
*
range_sel
=
range
->
range_sel
;
*
range_sel
=
range
->
range_sel
;
return
0
;
return
0
;
}
}
...
@@ -613,15 +620,35 @@ static int spmi_sw_selector_to_hw(struct spmi_regulator *vreg,
...
@@ -613,15 +620,35 @@ static int spmi_sw_selector_to_hw(struct spmi_regulator *vreg,
static
int
spmi_hw_selector_to_sw
(
struct
spmi_regulator
*
vreg
,
u8
hw_sel
,
static
int
spmi_hw_selector_to_sw
(
struct
spmi_regulator
*
vreg
,
u8
hw_sel
,
const
struct
spmi_voltage_range
*
range
)
const
struct
spmi_voltage_range
*
range
)
{
{
int
sw_sel
=
hw_sel
;
unsigned
sw_sel
=
0
;
unsigned
offset
,
max_hw_sel
;
const
struct
spmi_voltage_range
*
r
=
vreg
->
set_points
->
range
;
const
struct
spmi_voltage_range
*
r
=
vreg
->
set_points
->
range
;
const
struct
spmi_voltage_range
*
end
=
r
+
vreg
->
set_points
->
count
;
while
(
r
!=
range
)
{
for
(;
r
<
end
;
r
++
)
{
if
(
r
==
range
&&
range
->
n_voltages
)
{
/*
* hardware selectors between set point min and real
* min and between set point max and real max are
* invalid so we return an error if they're
* programmed into the hardware
*/
offset
=
range
->
set_point_min_uV
-
range
->
min_uV
;
offset
/=
range
->
step_uV
;
if
(
hw_sel
<
offset
)
return
-
EINVAL
;
max_hw_sel
=
range
->
set_point_max_uV
-
range
->
min_uV
;
max_hw_sel
/=
range
->
step_uV
;
if
(
hw_sel
>
max_hw_sel
)
return
-
EINVAL
;
return
sw_sel
+
hw_sel
-
offset
;
}
sw_sel
+=
r
->
n_voltages
;
sw_sel
+=
r
->
n_voltages
;
r
++
;
}
}
return
sw_sel
;
return
-
EINVAL
;
}
}
static
const
struct
spmi_voltage_range
*
static
const
struct
spmi_voltage_range
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment