Commit Graph

313 Commits

Author SHA1 Message Date
Mark Brown 0bdf7953e7 regmap: debugfs: Don't bother actually printing when calculating max length
commit 176fc2d5770a0990eebff903ba680d2edd32e718 upstream.

The in kernel snprintf() will conveniently return the actual length of
the printed string even if not given an output beffer at all so just do
that rather than relying on the user to pass in a suitable buffer,
ensuring that we don't need to worry if the buffer was truncated due to
the size of the buffer passed in.

Reported-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-22 14:37:51 -07:00
Mark Brown 789ef3db34 regmap: debugfs: Ensure we don't underflow when printing access masks
commit b763ec17ac762470eec5be8ebcc43e4f8b2c2b82 upstream.

If a read is attempted which is smaller than the line length then we may
underflow the subtraction we're doing with the unsigned size_t type so
move some of the calculation to be additions on the right hand side
instead in order to avoid this.

Reported-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-22 14:37:51 -07:00
Arun Chandran c9f4682139 regmap: Fix regmap_bulk_read in BE mode
commit 15b8d2c41fe5839582029f65c5f7004db451cc2b upstream.

In big endian mode regmap_bulk_read gives incorrect data
for byte reads.

This is because memcpy of a single byte from an address
after full word read gives different results when
endianness differs. ie. we get little-end in LE and big-end in BE.

Signed-off-by: Arun Chandran <achandran@mvista.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-03 09:29:41 -07:00
Pankaj Dubey a110e6d6eb regmap: fix NULL pointer dereference in _regmap_write/read
commit 5336be8416a71b5568d2cf54a2f2066abe9f2a53 upstream.

If LOG_DEVICE is defined and map->dev is NULL it will lead to NULL
pointer dereference. This patch fixes this issue by adding check for
dev->NULL in all such places in regmap.c

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 09:35:10 -07:00
Xiubo Li d9aa4aecb2 regmap: debugfs: fix possbile NULL pointer dereference
commit 2c98e0c1cc6b8e86f1978286c3d4e0769ee9d733 upstream.

If 'map->dev' is NULL and there will lead dev_name() to be NULL pointer
dereference. So before dev_name(), we need to have check of the map->dev
pionter.

We also should make sure that the 'name' pointer shouldn't be NULL for
debugfs_create_dir(). So here using one default "dummy" debugfs name when
the 'name' pointer and 'map->dev' are both NULL.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 09:35:10 -07:00
Mark Brown 070fdd7aac regmap: Fix handling of volatile registers for format_write() chips
commit 5844a8b9d98ec11ce1d77610daacf3f0a0e14715 upstream.

A previous over-zealous factorisation of code means that we only treat
registers as volatile if they are readable. For most devices this is fine
since normally most registers can be read and volatility implies
readability but for format_write() devices where there is no readback from
the hardware and we use volatility to mean simply uncacheability this means
that we end up treating all registers as cacheble.

A bigger refactoring of the code to clarify this is in order but as a fix
make a minimal change and only check readability when checking volatility
if there is no format_write() operation defined for the device.

Signed-off-by: Mark Brown <broonie@linaro.org>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-05 14:54:11 -07:00
David Jander 0c6471cc8e regmap: rbtree: Fix overlapping rbnodes.
commit 4e67fb5f5e336250db944921e3c68057d6203034 upstream.

Avoid overlapping register regions by making the initial blklen of a new
node 1. If a register write occurs to a yet uncached register, that is
lower than but near an existing node's base_reg, a new node is created
and it's blklen is set to an arbitrary value (sizeof(*rbnode)). That may
cause this node to overlap with another node. Those nodes should be merged,
but this merge doesn't happen yet, so this patch at least makes the initial
blklen small enough to avoid hitting the wrong node, which may otherwise
lead to severe breakage.

Signed-off-by: David Jander <david@protonic.nl>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Zhouping Liu <zliu@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-07 22:10:00 -07:00
Lars-Peter Clausen 83b83227df regmap: cache: Make sure to sync the last register in a block
commit 2d49b5987561e480bdbd8692b27fc5f49a1e2f0b upstream.

regcache_sync_block_raw_flush() expects the address of the register after last
register that needs to be synced as its parameter. But the last call to
regcache_sync_block_raw_flush() in regcache_sync_block_raw() passes the address
of the last register in the block. This effectively always skips over the last
register in a block, even if it needs to be synced. In order to fix it increase
the address by one register.

The issue was introduced in commit 75a5f89 ("regmap: cache: Write consecutive
registers in a single block write").

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-14 22:59:06 -07:00
Daniel Mack 8acd5b1eaa regmap: cache: bail in regmap_async_complete() for bus-less maps
commit f2e055e7c9c6084bfbaa68701e52562acf96419e upstream.

Commit f8bd822cb ("regmap: cache: Factor out block sync") made
regcache_rbtree_sync() call regmap_async_complete(), which in turn does
not check for map->bus before dereferencing it.

This causes a NULL pointer dereference on bus-less maps.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-04 16:50:58 +08:00
Mark Brown 998a4f2f1c Merge remote-tracking branch 'regmap/fix/debugfs' into regmap-linus 2013-06-03 18:07:38 +01:00
Maarten ter Huurne f3284f9153 regmap: rbtree: Fixed node range check on sync
A node starting before the minimum register is no reason to reject it,
since its end could be in range. The check for the end already exists
two lines lower, so we can just remove the incorrect check.

Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-06-01 20:10:05 +01:00
Lars-Peter Clausen f20c783c3a regmap: regcache: Fixup locking for custom lock callbacks
The parameter passed to the regmap lock/unlock callbacks needs to be
map->lock_arg, regcache passes just map. This works fine in the case that no
custom locking callbacks are used since in this case map->lock_arg equals map,
but will break when custom locking callbacks are used. The issue was introduced
in commit 0d4529c5("regmap: make lock/unlock functions customizable") and is
fixed by this patch.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-23 11:02:14 -05:00
Dimitris Papastamos 68e850d80d regmap: debugfs: Check return value of regmap_write()
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-12 18:57:48 +04:00
Mark Brown 38a817965d Merge remote-tracking branch 'regmap/topic/range' into regmap-next 2013-04-16 16:05:50 +01:00
Mark Brown 7f47db4006 Merge remote-tracking branch 'regmap/topic/irq' into regmap-next 2013-04-16 16:05:48 +01:00
Mark Brown 5b3b448475 Merge remote-tracking branch 'regmap/topic/cache' into regmap-next 2013-04-16 16:05:46 +01:00
Mark Brown b508c80c55 Merge remote-tracking branch 'regmap/topic/async' into regmap-next 2013-04-16 16:05:44 +01:00
Stephen Warren 5a08d15602 regmap: don't corrupt work buffer in _regmap_raw_write()
_regmap_raw_write() contains code to call regcache_write() to write
values to the cache. That code calls memcpy() to copy the value data to
the start of the work_buf. However, at least when _regmap_raw_write() is
called from _regmap_bus_raw_write(), the value data is in the work_buf,
and this memcpy() operation may over-write part of that value data,
depending on the value of reg_bytes + pad_bytes. At least when using
reg_bytes==1 and pad_bytes==0, corruption of the value data does occur.

To solve this, remove the memcpy() operation, and modify the subsequent
.parse_val() call to parse the original value buffer directly.

At least in the case of 8-bit register address and 16-bit values, and
writes of single registers at a time, this memcpy-then-parse combination
used to cancel each-other out; for a work-buffer containing xx 89 03,
the memcpy changed it to 89 03 03, and the parse_val changed it back to
89 89 03, thus leaving the value uncorrupted. This appears completely
accidental though. Since commit 8a819ff "regmap: core: Split out in
place value parsing", .parse_val only returns the parsed value, and does
not modify the buffer, and hence does not (accidentally) undo the
corruption caused by memcpy(). This caused bogus values to get written
to HW, thus preventing e.g. audio playback on systems with a WM8903
CODEC. This patch fixes that.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-16 16:05:03 +01:00
Mark Brown 60f7110e36 Linux 3.9-rc7
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iQEcBAABAgAGBQJRa02/AAoJEHm+PkMAQRiGDRoH/08Cu2LpmX4VN+YMC3BkGWxn
 4oOHGqdN0hrIQ4TysC43QNL6g7QJUnIR6fChn7pRJ6a8ljdzKjDHr/tZSIPJE3Ns
 UAGIDaaQWnZvGmHPzpbo4gmdMOTxg9xmpgac6Qpk6QowPIPc6fhl6AichP9OdH2G
 Fp6Irfznn5ZCBldJYg2+umoHyFTZARCxtdOKmmUnB7zH0GaX5ZRf/R6nmZEPlxE+
 5qJC1yxRxJE+I7gjNRFovxaLPuAmjPy5j6NJuGP8rR6epkhcJ2EVHSliI3KDKAO6
 D3Fy9T5qHv2A2gvSxtC0m5/1WrutXZqxZ/DOB/uv9U7vqomiIs/EsHIuvc9qFBY=
 =NrST
 -----END PGP SIGNATURE-----

Merge tag 'v3.9-rc7' into regmap-cache

Linux 3.9-rc7
2013-04-16 16:02:41 +01:00
Mark Brown 51a246aa5c regmap: Back out work buffer fix
This reverts commit bc8ce4 (regmap: don't corrupt work buffer in
_regmap_raw_write()) since it turns out that it can cause issues when
taken in isolation from the other changes in -next that lead to its
discovery.  On the basis that nobody noticed the problems for quite some
time without that subsequent work let's drop it from v3.9.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-09 18:03:25 +01:00
Stratos Karafotis 9659293c17 regmap: cache: Fix format specifier in dev_dbg
Fix format specifier in dev_dbg and suppress the following warning

drivers/base/regmap/regcache.c: In function
‘regcache_sync_block_raw_flush’:
drivers/base/regmap/regcache.c:593:2: warning: format ‘%d’ expects
argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat]

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-05 11:28:12 +01:00
Sachin Kamat f52687afb8 regmap: cache: Make regcache_sync_block_raw static
regcache_sync_block_raw is used only in this file. Hence make it static.
Silences the following warning:
drivers/base/regmap/regcache.c:608:5: warning:
symbol 'regcache_sync_block_raw' was not declared. Should it be static?

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-05 11:28:12 +01:00
Mark Brown af8ee69df3 Merge remote-tracking branch 'regmap/fix/async' into tmp 2013-03-31 23:27:38 +01:00
Mark Brown 6d66df4109 Merge remote-tracking branch 'regmap/fix/core' into tmp 2013-03-31 23:09:22 +01:00
Mark Brown 75a5f89f63 regmap: cache: Write consecutive registers in a single block write
When syncing blocks of data using raw writes combine the writes into a
single block write, saving us bus overhead for setup, addressing and
teardown.

Currently the block write is done unconditionally as it is expected that
hardware which has a register format which can support raw writes will
support auto incrementing writes, this decision may need to be revised in
future.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2013-03-30 13:52:36 +00:00
Mark Brown cfdeb8c37e regmap: cache: Split raw and non-raw syncs
For code clarity after implementing block writes split out the raw and
non-raw I/O sync implementations.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2013-03-30 13:52:31 +00:00
Mark Brown f8bd822cbf regmap: cache: Factor out block sync
The idea of holding blocks of registers in device format is shared between
at least rbtree and lzo cache formats so split out the loop that does the
sync from the rbtree code so optimisations on it can be reused.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2013-03-30 13:52:25 +00:00
Mark Brown 78493f2d7b regmap: cache: Factor out reg_present support from rbtree cache
The idea of maintaining a bitmap of present registers is something that
can usefully be used by other cache types that maintain blocks of cached
registers so move the code out of the rbtree cache and into the generic
regcache code.

Refactor the interface slightly as we go to wrap the set bit and enlarge
bitmap operations (since we never do one without the other) and make it
more robust for reads of uncached registers by bounds checking before we
look at the bitmap.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2013-03-30 13:49:17 +00:00
Mark Brown f951b6587b regmap: async: Add missing return
Let's only write once...

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-27 13:08:44 +00:00
Mark Brown 137b833457 regmap: cache: Use raw I/O to sync rbtrees if we can
This will bring no meaningful benefit by itself, it is done as a separate
commit to aid bisection if there are problems with the following commits
adding support for coalescing adjacent writes.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-27 13:03:41 +00:00
Mark Brown 221ad7f2df regmap: core: Provide regmap_can_raw_write() operation
Mainly useful internally but exported since this is a public API that's
being checked for.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-27 13:03:39 +00:00
Mark Brown 8817796b75 regmap: cache: Provide a get address of value operation
Provide a helper to do the size based index into a block of registers and
use it when reading a value.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-26 21:38:16 +00:00
Dimitris Papastamos 0c7ed8563a regmap: Cut down on the average # of nodes in the rbtree cache
This patch aims to bring down the average number of nodes
in the rbtree cache and increase the average number of registers
per node.  This should improve general lookup and traversal times.
This is achieved by setting the minimum size of a block within the
rbnode to the size of the rbnode itself.  This will essentially
cache possibly non-existent registers so to combat this scenario,
we keep a separate bitmap in memory which keeps track of which register
exists.  The memory overhead of this change is likely in the order of
~5-10%, possibly less depending on the register file layout.  On my test
system with a bitmap of ~4300 bits and a relatively sparse register
layout, the memory requirements for the entire cache did not increase
(the cutting down of nodes which was about 50% of the original number
compensated the situation).

A second patch that can be built on top of this can look at the
ratio `sizeof(*rbnode) / map->cache_word_size' in order to suitably
adjust the block length of each block.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-26 21:38:15 +00:00
Mark Brown 584de329ca regmap: core: Make raw write available to regcache
This allows the cache to sync values directly to the device when stored
in native format and also allows asynchronous I/O.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-26 19:17:32 +00:00
Mark Brown f1b5c5c342 regmap: core: Warn on invalid operation combinations
Don't grind to a screaming halt, just generate a warning.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-26 19:17:11 +00:00
Stephen Warren bc8ce4afd7 regmap: don't corrupt work buffer in _regmap_raw_write()
_regmap_raw_write() contains code to call regcache_write() to write
values to the cache. That code calls memcpy() to copy the value data to
the start of the work_buf. However, at least when _regmap_raw_write() is
called from _regmap_bus_raw_write(), the value data is in the work_buf,
and this memcpy() operation may over-write part of that value data,
depending on the value of reg_bytes + pad_bytes. At least when using
reg_bytes==1 and pad_bytes==0, corruption of the value data does occur.

To solve this, remove the memcpy() operation, and modify the subsequent
.parse_val() call to parse the original value buffer directly.

At least in the case of 8-bit register address and 16-bit values, and
writes of single registers at a time, this memcpy-then-parse combination
used to cancel each-other out; for a work-buffer containing xx 89 03,
the memcpy changed it to 89 03 03, and the parse_val changed it back to
89 89 03, thus leaving the value uncorrupted. This appears completely
accidental though. Since commit 8a819ff "regmap: core: Split out in
place value parsing", .parse_val only returns the parsed value, and does
not modify the buffer, and hence does not (accidentally) undo the
corruption caused by memcpy(). This caused bogus values to get written
to HW, thus preventing e.g. audio playback on systems with a WM8903
CODEC. This patch fixes that.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-21 20:08:15 +01:00
Mark Brown eed456f93d regmap: irq: Clarify error message when we fail to request primary IRQ
Display the name for the chip rather than just the primary IRQ so it is
clearer what exactly has failed.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-19 10:50:56 +00:00
Lars-Peter Clausen 8abac3ba51 regmap: cache Fix regcache-rbtree sync
The last register block, which falls into the specified range, is not handled
correctly. The formula which calculates the number of register which should be
synced is inverse (and off by one). E.g. if all registers in that block should
be synced only one is synced, and if only one should be synced all (but one) are
synced. To calculate the number of registers that need to be synced we need to
subtract the number of the first register in the block from the max register
number and add one. This patch updates the code accordingly.

The issue was introduced in commit ac8d91c ("regmap: Supply ranges to the sync
operations").

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org
2013-03-13 19:07:19 +00:00
Dimitris Papastamos a42277c739 regmap: rbtree Expose total memory consumption in the rbtree debugfs entry
Provide a feel of how much overhead the rbtree cache adds to
the game.

[Slightly reworded output in debugfs -- broonie]

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-13 11:13:48 +00:00
Dimitris Papastamos c6432ea9cc regmap: Initialize `map->debugfs' before regcache
In the rbtree code we are exposing statistics relating to the
number of nodes/registers of the rbtree cache for each of the
devices.  Ensure that `map->debugfs' has been initialized before
we attempt to initialize the debugfs entry for the rbtree cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org
2013-03-12 18:25:10 +00:00
Linus Torvalds 0c8150d2c4 regmap: PM fix for v3.9
A simple fix to stop us leaking a runtime PM reference in the case where
 we fail to enable a device.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIcBAABAgAGBQJRNVQ5AAoJELSic+t+oim93WQQAJIToyJgnuoZfebD3vgT1Tey
 YVGM5YY0pL+Ec5Fg91vu/ypFaY888J3UlRtQGxEM13grPunR4y/OflRYAXXTnspW
 TcPbcWpkEv464iTQra2GY9Z4gqL9c6fKKBSFwrj74wRb+Jq0BQhrdmbw6U6pMnDS
 iAxngfYEdlIULy8gyGnAszJFrQWjYh4U4e7wnUlsOJoZbc7JpW/6ITslwG9PWwK7
 h+o7ekjn2anyjAqBStlnSOzQ12kcaam+cDh8Fa8TUmg3HTmFmuCytGA8+XwCVBSQ
 ndWIhL1bqeyk7MdS84HjatNRAfPtpSZ9ouxKvLHm/tgALTNt/7CIsXeCm+2OoCQU
 7uFJ01WnAstQ58ggEndgjvhr4wGRIp9VZXyVjm8tqH2CLT/UE7H+nnOAcABcd/cn
 jZ+t8DQHU2ST1Rvs4Mohax8K6XcOTEQLp/kuhPEUXyqsv73VqIsjloPtqcLbUQdA
 RYjMMsSFVFqlPQEOBTDNhGVjrfI4/tlkEh7Kw4VXSZXqf8cvTrAvbWYmMV/MJu2M
 pvncD872/jSatRbj5qocnUbOuEyQe3UmdBNtQrdWgseI1z0fyz41X/VvZlzgt+Ll
 se8iU4YojEviAUjPzKbKpFwr98r6pmMXtHqxDCYSv47YukiCC5QMenFukMGE5G9R
 2qSw38quY1edJiXnq42Y
 =D1mN
 -----END PGP SIGNATURE-----

Merge tag 'regmap-v3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull regmap PM fix from Mark Brown:
 "A simple fix to stop us leaking a runtime PM reference in the case
  where we fail to enable a device."

* tag 'regmap-v3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
  regmap: irq: call pm_runtime_put in pm_runtime_get_sync failed case
2013-03-07 13:06:21 -08:00
Dimitris Papastamos 065b4c5875 regmap: debugfs: Add a registers `range' file
This file lists the register ranges in the register map.  The condition
to split the range is based on whether the block is readable or not.

Ensure that we lock the `debugfs_off_cache' list whenever we access
and modify the list.  There is a possible race otherwise between the
read() operations of the `registers' file and the `range' file.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:33:03 +08:00
Dimitris Papastamos 480738de0e regmap: debugfs: Simplify calculation of `c->max_reg'
We don't need to use any of the file position information
to calculate the base and max register of each block.  Just
use the counter directly.

Set `i = base' at the top to avoid GCC flow analysis bugs.  The
value of `i' can never be undefined or 0 in the if (c) { ... }.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:33:02 +08:00
Mark Brown eb4cb76ff0 regmap: cache: Store caches in native register format where possible
This allows the cached data to be sent directly to the device when
we sync it.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:30:28 +08:00
Mark Brown 8a819ff8ab regmap: core: Split out in place value parsing
Currently the value parsing operations both return the parsed value and
modify the passed buffer. This precludes their use in places like the cache
code so split out the in place modification into a new parse_inplace()
operation.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:30:27 +08:00
Mark Brown 325acab447 regmap: cache: Use regcache_get_value() to check if we updated
Factor things out a little.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:30:27 +08:00
Mark Brown 879082c9fe regmap: cache: Pass the map rather than the word size when updating values
It's more idiomatic to pass the map structure around and this means we
can use other bits of information from the map.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:30:27 +08:00
Mark Brown 66baf40757 regmap: rbtree: Don't bother checking for noop updates
If we're updating a value in place it's more work to read the value and
compare the value with what we're about to set than it is to just write
the value into the cache; there are no further operations after writing
in the code even though there's an early return here.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:30:27 +08:00
Mark Brown fe7d4ccd1d regmap: async: Add tracepoints for async I/O
Trace when we start and complete async writes, and when we start and
finish blocking for their completion. This is useful for performance
analysis of the resulting I/O patterns.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:28:29 +08:00
Li Fei 283189d3be regmap: irq: call pm_runtime_put in pm_runtime_get_sync failed case
Even in failed case of pm_runtime_get_sync, the usage_count
is incremented. In order to keep the usage_count with correct
value and runtime power management to behave correctly, call
pm_runtime_put(_sync) in such case.

Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
Signed-off-by: Li Fei <fei.li@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-01 14:54:16 +08:00