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
c6efe576
Commit
c6efe576
authored
Nov 21, 2014
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'regmap/topic/cache' into regmap-next
parents
28176ab6
3d7e9cec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
25 deletions
+30
-25
drivers/base/regmap/regcache.c
drivers/base/regmap/regcache.c
+30
-25
No files found.
drivers/base/regmap/regcache.c
View file @
c6efe576
...
@@ -36,6 +36,23 @@ static int regcache_hw_init(struct regmap *map)
...
@@ -36,6 +36,23 @@ static int regcache_hw_init(struct regmap *map)
if
(
!
map
->
num_reg_defaults_raw
)
if
(
!
map
->
num_reg_defaults_raw
)
return
-
EINVAL
;
return
-
EINVAL
;
/* calculate the size of reg_defaults */
for
(
count
=
0
,
i
=
0
;
i
<
map
->
num_reg_defaults_raw
;
i
++
)
if
(
!
regmap_volatile
(
map
,
i
*
map
->
reg_stride
))
count
++
;
/* all registers are volatile, so just bypass */
if
(
!
count
)
{
map
->
cache_bypass
=
true
;
return
0
;
}
map
->
num_reg_defaults
=
count
;
map
->
reg_defaults
=
kmalloc_array
(
count
,
sizeof
(
struct
reg_default
),
GFP_KERNEL
);
if
(
!
map
->
reg_defaults
)
return
-
ENOMEM
;
if
(
!
map
->
reg_defaults_raw
)
{
if
(
!
map
->
reg_defaults_raw
)
{
u32
cache_bypass
=
map
->
cache_bypass
;
u32
cache_bypass
=
map
->
cache_bypass
;
dev_warn
(
map
->
dev
,
"No cache defaults, reading back from HW
\n
"
);
dev_warn
(
map
->
dev
,
"No cache defaults, reading back from HW
\n
"
);
...
@@ -43,40 +60,25 @@ static int regcache_hw_init(struct regmap *map)
...
@@ -43,40 +60,25 @@ static int regcache_hw_init(struct regmap *map)
/* Bypass the cache access till data read from HW*/
/* Bypass the cache access till data read from HW*/
map
->
cache_bypass
=
1
;
map
->
cache_bypass
=
1
;
tmp_buf
=
kmalloc
(
map
->
cache_size_raw
,
GFP_KERNEL
);
tmp_buf
=
kmalloc
(
map
->
cache_size_raw
,
GFP_KERNEL
);
if
(
!
tmp_buf
)
if
(
!
tmp_buf
)
{
return
-
ENOMEM
;
ret
=
-
ENOMEM
;
goto
err_free
;
}
ret
=
regmap_raw_read
(
map
,
0
,
tmp_buf
,
ret
=
regmap_raw_read
(
map
,
0
,
tmp_buf
,
map
->
num_reg_defaults_raw
);
map
->
num_reg_defaults_raw
);
map
->
cache_bypass
=
cache_bypass
;
map
->
cache_bypass
=
cache_bypass
;
if
(
ret
<
0
)
{
if
(
ret
<
0
)
kfree
(
tmp_buf
);
goto
err_cache_free
;
return
ret
;
}
map
->
reg_defaults_raw
=
tmp_buf
;
map
->
reg_defaults_raw
=
tmp_buf
;
map
->
cache_free
=
1
;
map
->
cache_free
=
1
;
}
}
/* calculate the size of reg_defaults */
for
(
count
=
0
,
i
=
0
;
i
<
map
->
num_reg_defaults_raw
;
i
++
)
{
val
=
regcache_get_val
(
map
,
map
->
reg_defaults_raw
,
i
);
if
(
regmap_volatile
(
map
,
i
*
map
->
reg_stride
))
continue
;
count
++
;
}
map
->
reg_defaults
=
kmalloc
(
count
*
sizeof
(
struct
reg_default
),
GFP_KERNEL
);
if
(
!
map
->
reg_defaults
)
{
ret
=
-
ENOMEM
;
goto
err_free
;
}
/* fill the reg_defaults */
/* fill the reg_defaults */
map
->
num_reg_defaults
=
count
;
for
(
i
=
0
,
j
=
0
;
i
<
map
->
num_reg_defaults_raw
;
i
++
)
{
for
(
i
=
0
,
j
=
0
;
i
<
map
->
num_reg_defaults_raw
;
i
++
)
{
val
=
regcache_get_val
(
map
,
map
->
reg_defaults_raw
,
i
);
if
(
regmap_volatile
(
map
,
i
*
map
->
reg_stride
))
if
(
regmap_volatile
(
map
,
i
*
map
->
reg_stride
))
continue
;
continue
;
val
=
regcache_get_val
(
map
,
map
->
reg_defaults_raw
,
i
);
map
->
reg_defaults
[
j
].
reg
=
i
*
map
->
reg_stride
;
map
->
reg_defaults
[
j
].
reg
=
i
*
map
->
reg_stride
;
map
->
reg_defaults
[
j
].
def
=
val
;
map
->
reg_defaults
[
j
].
def
=
val
;
j
++
;
j
++
;
...
@@ -84,9 +86,10 @@ static int regcache_hw_init(struct regmap *map)
...
@@ -84,9 +86,10 @@ static int regcache_hw_init(struct regmap *map)
return
0
;
return
0
;
err_cache_free:
kfree
(
tmp_buf
);
err_free:
err_free:
if
(
map
->
cache_free
)
kfree
(
map
->
reg_defaults
);
kfree
(
map
->
reg_defaults_raw
);
return
ret
;
return
ret
;
}
}
...
@@ -150,6 +153,8 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
...
@@ -150,6 +153,8 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
ret
=
regcache_hw_init
(
map
);
ret
=
regcache_hw_init
(
map
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
if
(
map
->
cache_bypass
)
return
0
;
}
}
if
(
!
map
->
max_register
)
if
(
!
map
->
max_register
)
...
...
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