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
Kirill Smelkov
linux
Commits
787ad903
Commit
787ad903
authored
Sep 03, 2016
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'regmap/fix/rbtree' into regmap-linus
parents
f735aa27
1bc8da4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
+28
-10
drivers/base/regmap/regcache-rbtree.c
drivers/base/regmap/regcache-rbtree.c
+28
-10
No files found.
drivers/base/regmap/regcache-rbtree.c
View file @
787ad903
...
@@ -404,6 +404,7 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
...
@@ -404,6 +404,7 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
unsigned
int
new_base_reg
,
new_top_reg
;
unsigned
int
new_base_reg
,
new_top_reg
;
unsigned
int
min
,
max
;
unsigned
int
min
,
max
;
unsigned
int
max_dist
;
unsigned
int
max_dist
;
unsigned
int
dist
,
best_dist
=
UINT_MAX
;
max_dist
=
map
->
reg_stride
*
sizeof
(
*
rbnode_tmp
)
/
max_dist
=
map
->
reg_stride
*
sizeof
(
*
rbnode_tmp
)
/
map
->
cache_word_size
;
map
->
cache_word_size
;
...
@@ -423,24 +424,41 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
...
@@ -423,24 +424,41 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
&
base_reg
,
&
top_reg
);
&
base_reg
,
&
top_reg
);
if
(
base_reg
<=
max
&&
top_reg
>=
min
)
{
if
(
base_reg
<=
max
&&
top_reg
>=
min
)
{
new_base_reg
=
min
(
reg
,
base_reg
);
if
(
reg
<
base_reg
)
new_top_reg
=
max
(
reg
,
top_reg
);
dist
=
base_reg
-
reg
;
}
else
{
else
if
(
reg
>
top_reg
)
if
(
max
<
base_reg
)
dist
=
reg
-
top_reg
;
node
=
node
->
rb_left
;
else
else
node
=
node
->
rb_right
;
dist
=
0
;
if
(
dist
<
best_dist
)
{
continue
;
rbnode
=
rbnode_tmp
;
best_dist
=
dist
;
new_base_reg
=
min
(
reg
,
base_reg
);
new_top_reg
=
max
(
reg
,
top_reg
);
}
}
}
ret
=
regcache_rbtree_insert_to_block
(
map
,
rbnode_tmp
,
/*
* Keep looking, we want to choose the closest block,
* otherwise we might end up creating overlapping
* blocks, which breaks the rbtree.
*/
if
(
reg
<
base_reg
)
node
=
node
->
rb_left
;
else
if
(
reg
>
top_reg
)
node
=
node
->
rb_right
;
else
break
;
}
if
(
rbnode
)
{
ret
=
regcache_rbtree_insert_to_block
(
map
,
rbnode
,
new_base_reg
,
new_base_reg
,
new_top_reg
,
reg
,
new_top_reg
,
reg
,
value
);
value
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
rbtree_ctx
->
cached_rbnode
=
rbnode
_tmp
;
rbtree_ctx
->
cached_rbnode
=
rbnode
;
return
0
;
return
0
;
}
}
...
...
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