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
db760fbe
Commit
db760fbe
authored
Dec 11, 2012
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'regmap/topic/lock' into regmap-next
parents
4d348e6e
0d4529c5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
31 deletions
+54
-31
drivers/base/regmap/internal.h
drivers/base/regmap/internal.h
+1
-3
drivers/base/regmap/regmap.c
drivers/base/regmap/regmap.c
+38
-27
include/linux/regmap.h
include/linux/regmap.h
+15
-1
No files found.
drivers/base/regmap/internal.h
View file @
db760fbe
...
@@ -39,14 +39,12 @@ struct regmap_format {
...
@@ -39,14 +39,12 @@ struct regmap_format {
unsigned
int
(
*
parse_val
)(
void
*
buf
);
unsigned
int
(
*
parse_val
)(
void
*
buf
);
};
};
typedef
void
(
*
regmap_lock
)(
struct
regmap
*
map
);
typedef
void
(
*
regmap_unlock
)(
struct
regmap
*
map
);
struct
regmap
{
struct
regmap
{
struct
mutex
mutex
;
struct
mutex
mutex
;
spinlock_t
spinlock
;
spinlock_t
spinlock
;
regmap_lock
lock
;
regmap_lock
lock
;
regmap_unlock
unlock
;
regmap_unlock
unlock
;
void
*
lock_arg
;
/* This is passed to lock/unlock functions */
struct
device
*
dev
;
/* Device we do I/O on */
struct
device
*
dev
;
/* Device we do I/O on */
void
*
work_buf
;
/* Scratch buffer used to format I/O */
void
*
work_buf
;
/* Scratch buffer used to format I/O */
...
...
drivers/base/regmap/regmap.c
View file @
db760fbe
...
@@ -214,23 +214,27 @@ static unsigned int regmap_parse_32_native(void *buf)
...
@@ -214,23 +214,27 @@ static unsigned int regmap_parse_32_native(void *buf)
return
*
(
u32
*
)
buf
;
return
*
(
u32
*
)
buf
;
}
}
static
void
regmap_lock_mutex
(
struct
regmap
*
map
)
static
void
regmap_lock_mutex
(
void
*
__
map
)
{
{
struct
regmap
*
map
=
__map
;
mutex_lock
(
&
map
->
mutex
);
mutex_lock
(
&
map
->
mutex
);
}
}
static
void
regmap_unlock_mutex
(
struct
regmap
*
map
)
static
void
regmap_unlock_mutex
(
void
*
__
map
)
{
{
struct
regmap
*
map
=
__map
;
mutex_unlock
(
&
map
->
mutex
);
mutex_unlock
(
&
map
->
mutex
);
}
}
static
void
regmap_lock_spinlock
(
struct
regmap
*
map
)
static
void
regmap_lock_spinlock
(
void
*
__
map
)
{
{
struct
regmap
*
map
=
__map
;
spin_lock
(
&
map
->
spinlock
);
spin_lock
(
&
map
->
spinlock
);
}
}
static
void
regmap_unlock_spinlock
(
struct
regmap
*
map
)
static
void
regmap_unlock_spinlock
(
void
*
__
map
)
{
{
struct
regmap
*
map
=
__map
;
spin_unlock
(
&
map
->
spinlock
);
spin_unlock
(
&
map
->
spinlock
);
}
}
...
@@ -335,6 +339,11 @@ struct regmap *regmap_init(struct device *dev,
...
@@ -335,6 +339,11 @@ struct regmap *regmap_init(struct device *dev,
goto
err
;
goto
err
;
}
}
if
(
config
->
lock
&&
config
->
unlock
)
{
map
->
lock
=
config
->
lock
;
map
->
unlock
=
config
->
unlock
;
map
->
lock_arg
=
config
->
lock_arg
;
}
else
{
if
(
bus
->
fast_io
)
{
if
(
bus
->
fast_io
)
{
spin_lock_init
(
&
map
->
spinlock
);
spin_lock_init
(
&
map
->
spinlock
);
map
->
lock
=
regmap_lock_spinlock
;
map
->
lock
=
regmap_lock_spinlock
;
...
@@ -344,6 +353,8 @@ struct regmap *regmap_init(struct device *dev,
...
@@ -344,6 +353,8 @@ struct regmap *regmap_init(struct device *dev,
map
->
lock
=
regmap_lock_mutex
;
map
->
lock
=
regmap_lock_mutex
;
map
->
unlock
=
regmap_unlock_mutex
;
map
->
unlock
=
regmap_unlock_mutex
;
}
}
map
->
lock_arg
=
map
;
}
map
->
format
.
reg_bytes
=
DIV_ROUND_UP
(
config
->
reg_bits
,
8
);
map
->
format
.
reg_bytes
=
DIV_ROUND_UP
(
config
->
reg_bits
,
8
);
map
->
format
.
pad_bytes
=
config
->
pad_bits
/
8
;
map
->
format
.
pad_bytes
=
config
->
pad_bits
/
8
;
map
->
format
.
val_bytes
=
DIV_ROUND_UP
(
config
->
val_bits
,
8
);
map
->
format
.
val_bytes
=
DIV_ROUND_UP
(
config
->
val_bits
,
8
);
...
@@ -994,11 +1005,11 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
...
@@ -994,11 +1005,11 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
if
(
reg
%
map
->
reg_stride
)
if
(
reg
%
map
->
reg_stride
)
return
-
EINVAL
;
return
-
EINVAL
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
ret
=
_regmap_write
(
map
,
reg
,
val
);
ret
=
_regmap_write
(
map
,
reg
,
val
);
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
...
@@ -1030,11 +1041,11 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
...
@@ -1030,11 +1041,11 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
if
(
reg
%
map
->
reg_stride
)
if
(
reg
%
map
->
reg_stride
)
return
-
EINVAL
;
return
-
EINVAL
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
ret
=
_regmap_raw_write
(
map
,
reg
,
val
,
val_len
);
ret
=
_regmap_raw_write
(
map
,
reg
,
val
,
val_len
);
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
...
@@ -1066,7 +1077,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
...
@@ -1066,7 +1077,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
if
(
reg
%
map
->
reg_stride
)
if
(
reg
%
map
->
reg_stride
)
return
-
EINVAL
;
return
-
EINVAL
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
/* No formatting is require if val_byte is 1 */
/* No formatting is require if val_byte is 1 */
if
(
val_bytes
==
1
)
{
if
(
val_bytes
==
1
)
{
...
@@ -1102,7 +1113,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
...
@@ -1102,7 +1113,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
kfree
(
wval
);
kfree
(
wval
);
out:
out:
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
EXPORT_SYMBOL_GPL
(
regmap_bulk_write
);
EXPORT_SYMBOL_GPL
(
regmap_bulk_write
);
...
@@ -1197,11 +1208,11 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)
...
@@ -1197,11 +1208,11 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)
if
(
reg
%
map
->
reg_stride
)
if
(
reg
%
map
->
reg_stride
)
return
-
EINVAL
;
return
-
EINVAL
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
ret
=
_regmap_read
(
map
,
reg
,
val
);
ret
=
_regmap_read
(
map
,
reg
,
val
);
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
...
@@ -1231,7 +1242,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
...
@@ -1231,7 +1242,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
if
(
reg
%
map
->
reg_stride
)
if
(
reg
%
map
->
reg_stride
)
return
-
EINVAL
;
return
-
EINVAL
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
if
(
regmap_volatile_range
(
map
,
reg
,
val_count
)
||
map
->
cache_bypass
||
if
(
regmap_volatile_range
(
map
,
reg
,
val_count
)
||
map
->
cache_bypass
||
map
->
cache_type
==
REGCACHE_NONE
)
{
map
->
cache_type
==
REGCACHE_NONE
)
{
...
@@ -1253,7 +1264,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
...
@@ -1253,7 +1264,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
}
}
out:
out:
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
...
@@ -1360,9 +1371,9 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
...
@@ -1360,9 +1371,9 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
bool
change
;
bool
change
;
int
ret
;
int
ret
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
ret
=
_regmap_update_bits
(
map
,
reg
,
mask
,
val
,
&
change
);
ret
=
_regmap_update_bits
(
map
,
reg
,
mask
,
val
,
&
change
);
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
...
@@ -1386,9 +1397,9 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
...
@@ -1386,9 +1397,9 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
{
{
int
ret
;
int
ret
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
ret
=
_regmap_update_bits
(
map
,
reg
,
mask
,
val
,
change
);
ret
=
_regmap_update_bits
(
map
,
reg
,
mask
,
val
,
change
);
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
EXPORT_SYMBOL_GPL
(
regmap_update_bits_check
);
EXPORT_SYMBOL_GPL
(
regmap_update_bits_check
);
...
@@ -1417,7 +1428,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
...
@@ -1417,7 +1428,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
if
(
map
->
patch
)
if
(
map
->
patch
)
return
-
EBUSY
;
return
-
EBUSY
;
map
->
lock
(
map
);
map
->
lock
(
map
->
lock_arg
);
bypass
=
map
->
cache_bypass
;
bypass
=
map
->
cache_bypass
;
...
@@ -1445,7 +1456,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
...
@@ -1445,7 +1456,7 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
out:
out:
map
->
cache_bypass
=
bypass
;
map
->
cache_bypass
=
bypass
;
map
->
unlock
(
map
);
map
->
unlock
(
map
->
lock_arg
);
return
ret
;
return
ret
;
}
}
...
...
include/linux/regmap.h
View file @
db760fbe
...
@@ -54,6 +54,9 @@ enum regmap_endian {
...
@@ -54,6 +54,9 @@ enum regmap_endian {
REGMAP_ENDIAN_NATIVE
,
REGMAP_ENDIAN_NATIVE
,
};
};
typedef
void
(
*
regmap_lock
)(
void
*
);
typedef
void
(
*
regmap_unlock
)(
void
*
);
/**
/**
* Configuration for the register map of a device.
* Configuration for the register map of a device.
*
*
...
@@ -76,6 +79,12 @@ enum regmap_endian {
...
@@ -76,6 +79,12 @@ enum regmap_endian {
* @precious_reg: Optional callback returning true if the rgister
* @precious_reg: Optional callback returning true if the rgister
* should not be read outside of a call from the driver
* should not be read outside of a call from the driver
* (eg, a clear on read interrupt status register).
* (eg, a clear on read interrupt status register).
* @lock: Optional lock callback (overrides regmap's default lock
* function, based on spinlock or mutex).
* @unlock: As above for unlocking.
* @lock_arg: this field is passed as the only argument of lock/unlock
* functions (ignored in case regular lock/unlock functions
* are not overridden).
*
*
* @max_register: Optional, specifies the maximum valid register index.
* @max_register: Optional, specifies the maximum valid register index.
* @reg_defaults: Power on reset values for registers (for use with
* @reg_defaults: Power on reset values for registers (for use with
...
@@ -117,6 +126,9 @@ struct regmap_config {
...
@@ -117,6 +126,9 @@ struct regmap_config {
bool
(
*
readable_reg
)(
struct
device
*
dev
,
unsigned
int
reg
);
bool
(
*
readable_reg
)(
struct
device
*
dev
,
unsigned
int
reg
);
bool
(
*
volatile_reg
)(
struct
device
*
dev
,
unsigned
int
reg
);
bool
(
*
volatile_reg
)(
struct
device
*
dev
,
unsigned
int
reg
);
bool
(
*
precious_reg
)(
struct
device
*
dev
,
unsigned
int
reg
);
bool
(
*
precious_reg
)(
struct
device
*
dev
,
unsigned
int
reg
);
regmap_lock
lock
;
regmap_unlock
unlock
;
void
*
lock_arg
;
unsigned
int
max_register
;
unsigned
int
max_register
;
const
struct
reg_default
*
reg_defaults
;
const
struct
reg_default
*
reg_defaults
;
...
@@ -186,7 +198,9 @@ typedef void (*regmap_hw_free_context)(void *context);
...
@@ -186,7 +198,9 @@ typedef void (*regmap_hw_free_context)(void *context);
* Description of a hardware bus for the register map infrastructure.
* Description of a hardware bus for the register map infrastructure.
*
*
* @fast_io: Register IO is fast. Use a spinlock instead of a mutex
* @fast_io: Register IO is fast. Use a spinlock instead of a mutex
* to perform locking.
* to perform locking. This field is ignored if custom lock/unlock
* functions are used (see fields lock/unlock of
* struct regmap_config).
* @write: Write operation.
* @write: Write operation.
* @gather_write: Write operation with split register/value, return -ENOTSUPP
* @gather_write: Write operation with split register/value, return -ENOTSUPP
* if not implemented on a given device.
* if not implemented on a given device.
...
...
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