summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-09 08:30:10 -0400
committerMark Brown <broonie@linaro.org>2013-10-09 09:05:26 -0400
commit915f441b6f31b1a8ee01e9263a4e2d44c434d832 (patch)
treeb1e989bb442bfc62eb75766be97c87077903593c /drivers/base
parent0a8198094da895c8d5db95812fe9de7027d808e4 (diff)
regmap: Provide asynchronous write and update bits operations
Make it easier for drivers to include single register writes in asynchronous sequences by providing async versions of the write and update bits operations. The update bits operations are only likely to be effective when used with devices that have caches but this is common enough to be useful. Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 268fb71891ee..0503d868ff8c 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1338,6 +1338,37 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
1338EXPORT_SYMBOL_GPL(regmap_write); 1338EXPORT_SYMBOL_GPL(regmap_write);
1339 1339
1340/** 1340/**
1341 * regmap_write_async(): Write a value to a single register asynchronously
1342 *
1343 * @map: Register map to write to
1344 * @reg: Register to write to
1345 * @val: Value to be written
1346 *
1347 * A value of zero will be returned on success, a negative errno will
1348 * be returned in error cases.
1349 */
1350int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val)
1351{
1352 int ret;
1353
1354 if (reg % map->reg_stride)
1355 return -EINVAL;
1356
1357 map->lock(map->lock_arg);
1358
1359 map->async = true;
1360
1361 ret = _regmap_write(map, reg, val);
1362
1363 map->async = false;
1364
1365 map->unlock(map->lock_arg);
1366
1367 return ret;
1368}
1369EXPORT_SYMBOL_GPL(regmap_write_async);
1370
1371/**
1341 * regmap_raw_write(): Write raw values to one or more registers 1372 * regmap_raw_write(): Write raw values to one or more registers
1342 * 1373 *
1343 * @map: Register map to write to 1374 * @map: Register map to write to
@@ -1811,6 +1842,41 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
1811EXPORT_SYMBOL_GPL(regmap_update_bits); 1842EXPORT_SYMBOL_GPL(regmap_update_bits);
1812 1843
1813/** 1844/**
1845 * regmap_update_bits_async: Perform a read/modify/write cycle on the register
1846 * map asynchronously
1847 *
1848 * @map: Register map to update
1849 * @reg: Register to update
1850 * @mask: Bitmask to change
1851 * @val: New value for bitmask
1852 *
1853 * With most buses the read must be done synchronously so this is most
1854 * useful for devices with a cache which do not need to interact with
1855 * the hardware to determine the current register value.
1856 *
1857 * Returns zero for success, a negative number on error.
1858 */
1859int regmap_update_bits_async(struct regmap *map, unsigned int reg,
1860 unsigned int mask, unsigned int val)
1861{
1862 bool change;
1863 int ret;
1864
1865 map->lock(map->lock_arg);
1866
1867 map->async = true;
1868
1869 ret = _regmap_update_bits(map, reg, mask, val, &change);
1870
1871 map->async = false;
1872
1873 map->unlock(map->lock_arg);
1874
1875 return ret;
1876}
1877EXPORT_SYMBOL_GPL(regmap_update_bits_async);
1878
1879/**
1814 * regmap_update_bits_check: Perform a read/modify/write cycle on the 1880 * regmap_update_bits_check: Perform a read/modify/write cycle on the
1815 * register map and report if updated 1881 * register map and report if updated
1816 * 1882 *
@@ -1835,6 +1901,43 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
1835} 1901}
1836EXPORT_SYMBOL_GPL(regmap_update_bits_check); 1902EXPORT_SYMBOL_GPL(regmap_update_bits_check);
1837 1903
1904/**
1905 * regmap_update_bits_check_async: Perform a read/modify/write cycle on the
1906 * register map asynchronously and report if
1907 * updated
1908 *
1909 * @map: Register map to update
1910 * @reg: Register to update
1911 * @mask: Bitmask to change
1912 * @val: New value for bitmask
1913 * @change: Boolean indicating if a write was done
1914 *
1915 * With most buses the read must be done synchronously so this is most
1916 * useful for devices with a cache which do not need to interact with
1917 * the hardware to determine the current register value.
1918 *
1919 * Returns zero for success, a negative number on error.
1920 */
1921int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
1922 unsigned int mask, unsigned int val,
1923 bool *change)
1924{
1925 int ret;
1926
1927 map->lock(map->lock_arg);
1928
1929 map->async = true;
1930
1931 ret = _regmap_update_bits(map, reg, mask, val, change);
1932
1933 map->async = false;
1934
1935 map->unlock(map->lock_arg);
1936
1937 return ret;
1938}
1939EXPORT_SYMBOL_GPL(regmap_update_bits_check_async);
1940
1838void regmap_async_complete_cb(struct regmap_async *async, int ret) 1941void regmap_async_complete_cb(struct regmap_async *async, int ret)
1839{ 1942{
1840 struct regmap *map = async->map; 1943 struct regmap *map = async->map;