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
addfd8a0
Commit
addfd8a0
authored
Mar 14, 2012
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'regmap/topic/bulk' into regmap-next
parents
eae4b51b
df00c79f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
5 deletions
+78
-5
drivers/base/regmap/regcache.c
drivers/base/regmap/regcache.c
+5
-0
drivers/base/regmap/regmap.c
drivers/base/regmap/regmap.c
+71
-5
include/linux/regmap.h
include/linux/regmap.h
+2
-0
No files found.
drivers/base/regmap/regcache.c
View file @
addfd8a0
...
...
@@ -35,12 +35,17 @@ static int regcache_hw_init(struct regmap *map)
return
-
EINVAL
;
if
(
!
map
->
reg_defaults_raw
)
{
u32
cache_bypass
=
map
->
cache_bypass
;
dev_warn
(
map
->
dev
,
"No cache defaults, reading back from HW
\n
"
);
/* Bypass the cache access till data read from HW*/
map
->
cache_bypass
=
1
;
tmp_buf
=
kmalloc
(
map
->
cache_size_raw
,
GFP_KERNEL
);
if
(
!
tmp_buf
)
return
-
EINVAL
;
ret
=
regmap_bulk_read
(
map
,
0
,
tmp_buf
,
map
->
num_reg_defaults_raw
);
map
->
cache_bypass
=
cache_bypass
;
if
(
ret
<
0
)
{
kfree
(
tmp_buf
);
return
ret
;
...
...
drivers/base/regmap/regmap.c
View file @
addfd8a0
...
...
@@ -411,6 +411,26 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
if
(
!
map
->
writeable_reg
(
map
->
dev
,
reg
+
i
))
return
-
EINVAL
;
if
(
!
map
->
cache_bypass
&&
map
->
format
.
parse_val
)
{
unsigned
int
ival
;
int
val_bytes
=
map
->
format
.
val_bytes
;
for
(
i
=
0
;
i
<
val_len
/
val_bytes
;
i
++
)
{
memcpy
(
map
->
work_buf
,
val
+
(
i
*
val_bytes
),
val_bytes
);
ival
=
map
->
format
.
parse_val
(
map
->
work_buf
);
ret
=
regcache_write
(
map
,
reg
+
i
,
ival
);
if
(
ret
)
{
dev_err
(
map
->
dev
,
"Error in caching of register: %u ret: %d
\n
"
,
reg
+
i
,
ret
);
return
ret
;
}
}
if
(
map
->
cache_only
)
{
map
->
cache_dirty
=
true
;
return
0
;
}
}
map
->
format
.
format_reg
(
map
->
work_buf
,
reg
);
u8
[
0
]
|=
map
->
write_flag_mask
;
...
...
@@ -461,7 +481,7 @@ int _regmap_write(struct regmap *map, unsigned int reg,
int
ret
;
BUG_ON
(
!
map
->
format
.
format_write
&&
!
map
->
format
.
format_val
);
if
(
!
map
->
cache_bypass
)
{
if
(
!
map
->
cache_bypass
&&
map
->
format
.
format_write
)
{
ret
=
regcache_write
(
map
,
reg
,
val
);
if
(
ret
!=
0
)
return
ret
;
...
...
@@ -538,12 +558,8 @@ EXPORT_SYMBOL_GPL(regmap_write);
int
regmap_raw_write
(
struct
regmap
*
map
,
unsigned
int
reg
,
const
void
*
val
,
size_t
val_len
)
{
size_t
val_count
=
val_len
/
map
->
format
.
val_bytes
;
int
ret
;
WARN_ON
(
!
regmap_volatile_range
(
map
,
reg
,
val_count
)
&&
map
->
cache_type
!=
REGCACHE_NONE
);
mutex_lock
(
&
map
->
lock
);
ret
=
_regmap_raw_write
(
map
,
reg
,
val
,
val_len
);
...
...
@@ -554,6 +570,56 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
}
EXPORT_SYMBOL_GPL
(
regmap_raw_write
);
/*
* regmap_bulk_write(): Write multiple registers to the device
*
* @map: Register map to write to
* @reg: First register to be write from
* @val: Block of data to be written, in native register size for device
* @val_count: Number of registers to write
*
* This function is intended to be used for writing a large block of
* data to be device either in single transfer or multiple transfer.
*
* A value of zero will be returned on success, a negative errno will
* be returned in error cases.
*/
int
regmap_bulk_write
(
struct
regmap
*
map
,
unsigned
int
reg
,
const
void
*
val
,
size_t
val_count
)
{
int
ret
=
0
,
i
;
size_t
val_bytes
=
map
->
format
.
val_bytes
;
void
*
wval
;
if
(
!
map
->
format
.
parse_val
)
return
-
EINVAL
;
mutex_lock
(
&
map
->
lock
);
/* No formatting is require if val_byte is 1 */
if
(
val_bytes
==
1
)
{
wval
=
(
void
*
)
val
;
}
else
{
wval
=
kmemdup
(
val
,
val_count
*
val_bytes
,
GFP_KERNEL
);
if
(
!
wval
)
{
ret
=
-
ENOMEM
;
dev_err
(
map
->
dev
,
"Error in memory allocation
\n
"
);
goto
out
;
}
for
(
i
=
0
;
i
<
val_count
*
val_bytes
;
i
+=
val_bytes
)
map
->
format
.
parse_val
(
wval
+
i
);
}
ret
=
_regmap_raw_write
(
map
,
reg
,
wval
,
val_bytes
*
val_count
);
if
(
val_bytes
!=
1
)
kfree
(
wval
);
out:
mutex_unlock
(
&
map
->
lock
);
return
ret
;
}
EXPORT_SYMBOL_GPL
(
regmap_bulk_write
);
static
int
_regmap_raw_read
(
struct
regmap
*
map
,
unsigned
int
reg
,
void
*
val
,
unsigned
int
val_len
)
{
...
...
include/linux/regmap.h
View file @
addfd8a0
...
...
@@ -146,6 +146,8 @@ int regmap_reinit_cache(struct regmap *map,
int
regmap_write
(
struct
regmap
*
map
,
unsigned
int
reg
,
unsigned
int
val
);
int
regmap_raw_write
(
struct
regmap
*
map
,
unsigned
int
reg
,
const
void
*
val
,
size_t
val_len
);
int
regmap_bulk_write
(
struct
regmap
*
map
,
unsigned
int
reg
,
const
void
*
val
,
size_t
val_count
);
int
regmap_read
(
struct
regmap
*
map
,
unsigned
int
reg
,
unsigned
int
*
val
);
int
regmap_raw_read
(
struct
regmap
*
map
,
unsigned
int
reg
,
void
*
val
,
size_t
val_len
);
...
...
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